我正在尝试将运行完美的代码放在 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” 调用: ... handle -> withCallingHandlers -> withVisible -> eval -> eval
答案 0 :(得分:1)
我相信您需要在“这个”代码块中添加 library(janitor)
。