Re: [R] Accessing a field in a data fram

From: jim holtman <jholtman_at_gmail.com>
Date: Wed, 02 Jul 2008 17:13:01 -0400

?"[["

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?

______________________________________________
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.
Received on Wed 02 Jul 2008 - 21:42:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jul 2008 - 22:31:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive