r-markdown - 如何修复 R markdown 中的 row_to_name 错误?
问题描述
我正在尝试将运行完美的代码放在 R 降价中,但我在编织时不断收到 row_to_name 错误,但在运行块时却没有。老实说,我不知道如何解决它。
编码:
homicidios<-read.csv("/Users/julia/Documents/rdoctorado/tasa estatal homicidios.csv",header = TRUE)
#Transform the vector to data frame
thomicidios<-data.frame(homicidios)
# transpose the matrix To compute stats
th<-t(homicidios)
#delete first row and set it as header
thomicidios<-row_to_names(th,1,remove_row = TRUE)
#Transform the vector to data frame
thomicidios2<-data.frame(thomicidios)
#Convert string to integer
thomicidios2[c(1:33)] <- lapply(thomicidios2[c(1:33)], as.integer)
#Summary of the data
summary(thomicidios2)
错误是:
row_to_names(th, 1, remove_row = TRUE) 中的错误:找不到函数“row_to_names”调用:...句柄 -> withCallingHandlers -> withVisible -> eval -> eval
解决方案
我相信你需要library(janitor)
在“这个”代码块中添加。
推荐阅读
- android - 未捕获 Firebase Analytics user_engagement 事件
- r - In R, the function seq(1,10) and seq(1:10) have same outputs and why there are different outputs for the function mean(1,10) and mean(1:10)?
- ruby - Ruby 代码添加单个 \ 来转义 #,而不是添加 \\
- elasticsearch - 如何在 Kafka 连接的 Elastic Search 中创建多个索引
- tsql - 如何确保记录始终在返回列表中并正确排序
- mongodb - 带有 upsert=true 的 Mongodb UpdateMany。有什么方法可以识别修改的记录吗?
- java - 如何使用 exoplayer 检测视频是否包含声音
- postman - 在 Postman 中定义多个变量和初始值
- git - 没有什么可以比较的
- java - 从 gradle 中以管理员身份运行 groovy 脚本,即没有管理员命令提示符