Click here to Skip to main content
14,421,575 members
Rate this:
Please Sign up or sign in to vote.
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 19-Jul-17 0:50am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 2

This can be done as below,

RawData[[colName]]

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

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100