[R] newbie: data frame to vector

Eric Peterson peterson at heritage.nv.gov
Tue Jan 21 22:48:03 CET 2003


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"])

Gives me the error, "Error in pmatch(x, table, duplicates.ok) :
        argument is not of mode character"

and

v1 <- t["Var1"]
v2 <- t["Var2"]
plot(v1, v2)

gives me the same error (of course) and v1 does not display the same as a
vector; it looks like it is an array(?)

Thanks,
-Eric

---
Eric B. Peterson
Vegetation Ecologist & Lichenologist
Nevada Natural Heritage Program
Department of Conservation and Natural Resources
1550 E. College Pkwy #137
Carson City, NV 89706
775-687-4245 x236
http://heritage.nv.gov/




More information about the R-help mailing list