[R] getting numeric arrays from data frame

Mark Farnell mark.farnell at gmail.com
Mon Apr 7 05:15:14 CEST 2008


Currently I invoke:

foo <- read.table("foo.data", header=TRUE)

to read a table into foo

Then when I try to plot a histogram out of the 5th column of foo:

hist(foo[5])

It fails and it says:

Error in hist.default(foo[5]) : 'x' must be numeric

Then I tried:

>typeof(foo[5])
[1] "List"

So how can I get an numeric array out of one of the columns?

Also suppose if the dataframe foo (above) has eight columns and I want
to make an x-y scatter plot on two of the columns, how can I extract
these two specific columns?

Thanks

Mark



More information about the R-help mailing list