r - 使用 knitr 和 read.csv 处理 data.frame(..., check.names = FALSE) 中的错误
问题描述
我有这个玩具 Rnw 示例,我想在其中加载一些数据并使用汇总函数。我编译失败并不断抛出Error in data.frame(..., check.names = FALSE)
,我不知道为什么?
我很感激任何建议。谢谢。
\documentclass[]{article}
\begin{document}
<<>>=
x <- read.csv("stockres.txt")
summary(x)
@
\end{document}
从哪里来stockres
_
https://raw.githubusercontent.com/b2q/SPM-Ready/master/QID-670-SPMhistogram/stockres.txt
日志信息:
> knitr::knit2pdf("problem-knitr.Rnw")
processing file: problem-knitr.Rnw
|................................. | 33%
ordinary text without R code
|................................................................. | 67%
label: unnamed-chunk-1
Quitting from lines 4-6 (problem-knitr.Rnw)
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 10, 0
这是我的会话信息。
> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-suse-linux-gnu (64-bit)
Running under: openSUSE Leap 15.1
Matrix products: default
BLAS: /usr/lib64/R/lib/libRblas.so
LAPACK: /usr/lib64/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=es_CR.UTF-8 LC_NUMERIC=C LC_TIME=es_CR.UTF-8
[4] LC_COLLATE=es_CR.UTF-8 LC_MONETARY=es_CR.UTF-8 LC_MESSAGES=es_CR.UTF-8
[7] LC_PAPER=es_CR.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=es_CR.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_3.3.0 knitr_1.27
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4 magrittr_1.5 tidyselect_0.2.5 munsell_0.5.0 colorspace_1.4-1 R6_2.4.1
[7] rlang_0.4.5 fansi_0.4.1 stringr_1.4.0 highr_0.3 dplyr_0.8.5 tools_4.0.0
[13] grid_4.0.0 gtable_0.3.0 xfun_0.8 cli_2.0.1 withr_2.1.2 ellipsis_0.3.0
[19] digest_0.6.25 assertthat_0.2.1 tibble_3.0.0 lifecycle_0.2.0 crayon_1.3.4 formatR_1.0
[25] farver_2.0.3 purrr_0.3.3 codetools_0.2-16 vctrs_0.2.4 glue_1.3.1 evaluate_0.14
[31] labeling_0.3 stringi_1.4.6 compiler_4.0.0 pillar_1.4.3 scales_1.1.0 Cairo_1.5-12
[37] pkgconfig_2.0.2
解决方案
推荐阅读
- java - partitioningby如何区分真假?
- javascript - Angular 6:HTML 表格创建动态列和行
- angular - 在 Angular 中隐藏部分菜单(权限)
- javascript - 使用 fabricjs 执行语义缩放
- filesystems - 安装不同版本的应用程序时出现签名错误
- angular - Angular 7 - 有没有办法存储 JSESSIONID 并在每个请求中发送它?
- docker - 在构建期间将参数传递给通过 Dockerfile 运行的脚本
- flutter - CachedNetworkImage 图像不会以相同的名称更改
- regex - 根据附件中的特定内容转发 Outlook 电子邮件
- excel - 如何使用 VBA 将计算列添加到 PowerPivot 数据模型中的表?