[R] Newb question re. read.table...

Ista Zahn istazahn at gmail.com
Wed Mar 3 23:18:34 CET 2010


Hi Steve,
I think the problem is just that those variables are in the con
data.frame. If so you have several options:

1) with(con, plot(rel, len))
2) plot(con$rel, con$len)
3) attach(con); plot(rel, len)

Best,
Ista


On Wed, Mar 3, 2010 at 4:50 PM, Steven DeRose
<steve.derose at openamplify.com> wrote:
> I'm trying to get started with R, on Ubuntu. I worked through the
> tutorial, and have made a small tab-delimited subset of my data to try
> out (10 cases with about a dozens variables). But I can't seem to figure
> out how to actually refer to variables. I presume I'm missing something
> very simple, but quite a while searching the doc and the FAQ haven't
> helped me.
>
> I'm loading the data with
>    con <- read.table("tiny.txt", header=TRUE)
>
> The first record is a set of variable names, tab-separated like the rest
> of the rows. There are no row labels, thus the same number of
> tab-delimited fields in the header record and the following records. The
> read.table returns silently, and I can get a reasonable summary(con).
> But if I try something like plot(rel,len), where rel and len are two of
> the labels from the header row, I get
>
>     Error in plot(rel, len) : object 'rel' not found
>
> I've tried many variations (different variables, adding "con." on the
> front, quoting, using field numbers instead of names, etc. I've also
> read what I can find on read.table, but I'm clearly missing some basic
> thing....
>
> Can somebody put me back on the right track? Is there some additional
> thing I have to do to make this into a "real" frame, or to bind
> variables names to header names, or something like that?
>
> Thanks, and sorry for being dense....
>
> Steve
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org



More information about the R-help mailing list