13

I have got a function :

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

Please guide further. Thanks:)

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
Dhara
  • 133
  • 1
  • 1
  • 4

1 Answers1

24

you need to use another way of accessing the columns in the dataframe than via $. There are two other ways:

1.

print(content[[param]])

2.

print(content[,param])
Henrik
  • 14,202
  • 10
  • 68
  • 91