如何使用變數在收集函式中設定“鍵”引數?as.character() 和 get() 也不起作用
library(tidyr)
library(dplyr)
path = "C:/Users/lukas/Documents/Projekt/Data/"
files <- list.files(path = path, pattern = "*.csv")
dane <- list()
for (file in files){
temp_name <- file
file <- tibble(read.csv(paste(path,file,sep = ""))) %>%
gather("year", key = temp_name , -country)
dane <- append(dane,list(file))
}
Error in `ensym2()`:
! Must supply a symbol or a string as argument
uj5u.com熱心網友回復:
我們可能會逃脫!!
dane <- list()
for (file in files){
temp_name <- file
file <- tibble(read.csv(paste(path,file,sep = ""))) %>%
gather("year", key = !!temp_name , -country)
dane <- append(dane,list(file))
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/532629.html
標籤:r
上一篇:socket.io中的房間是否會在一段時間后自動洗掉?
下一篇:在R中的資料框中填充缺失值