我有一个功能:
aggreg <- function(fileName, param){
contents <- read.csv(fileName, header=T)
#print(contents) #This displays all contents
print(contents$param) #gives NULL
}
> aggreg("test.csv","Close.Price")
> NULL
请进一步指导。感谢:)
答案 0 :(得分:23)
您需要使用另一种方式来访问数据框中的列,而不是通过$
。还有另外两种方式:
1
print(content[[param]])
2
print(content[,param])