[R] Accessing a field in a data fram

jim holtman jholtman at gmail.com
Wed Jul 2 23:13:01 CEST 2008


?"[["

decision <- "one"
raw[[decision]]

On Wed, Jul 2, 2008 at 3:10 PM, R_Learner <sschiang8 at gmail.com> wrote:
>
> raw <- read.csv(file=filename, head=TRUE,sep=",")
>
> I've read in a csv file, and I'm looking to access a column whose name is
> held in a string.
>
> For example, I want to access raw$one or raw$two, but this will depending on
> the string. Let's say that the string is decision<-"one". How would I access
> raw$one?
>
> The following doesn't work:
> numbers<-raw$decision
>
> Please help me!
> Thanks!
> --
> View this message in context: http://www.nabble.com/Accessing-a-field-in-a-data-fram-tp18244661p18244661.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list