In your text you say that you read the information but your code does not do that.
So the first time you use data (in head) the variable data will not be found.
Just insert in your code readLines or read.csv or whatever you need to get the information. E.g. data=read.csv("mydata.csv")