首页 > 解决方案 > 如何修复 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

标签: r-markdown

解决方案


我相信你需要library(janitor)在“这个”代码块中添加。


推荐阅读