Click here to Skip to main content
15,888,320 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have column name in a variable. I want to acess that column from a csv how will I do it?.

What I have tried:

RawData <- read.csv("DataCombined.csv")
colName <- grp2$Col1[1]

I want to access RawData$colName. But I am getting error saying $colName is not valid.

Can anyone help me in getting the value.
Posted
Updated 18-Jul-17 23:50pm

1 solution

This can be done as below,

RawData[[colName]]

Two [[]] will help to access the column with variable name.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900