[R] newbie: data frame to vector

Deepayan Sarkar deepayan at stat.wisc.edu
Tue Jan 21 22:59:04 CET 2003


On Tuesday 21 January 2003 03:47 pm, Eric Peterson wrote:
> Sorry, but I'm very new to R.  I'm trying to figure out how to convert a
> column from a data frame to a vector.  More specifically, I have read in a
> comma separated value table which contains a number of variables in
> columns, plots in rows...
>
> t <- read.table("G:/R/table1.txt", sep=",", header=TRUE)
>
> the data comes in just fine.  Now I want to do an XY plot of 2 variables
> and will be doing some statistical analyses on them.  But
>
> plot(t["Var1"], t["Var2"])

You want t$Var1 instead of t["Var1"], etc. 

t, incidentally, is the name of an R function, so you might want to avoid 
using it as a variable name.

Deepayan




More information about the R-help mailing list