[R] Problems using imported data
Stephen Tucker
brown_emu at yahoo.com
Wed Jul 4 05:39:43 CEST 2007
Actually, I believe attach() and detached() is discouraged nowadays...
x <- read.delim("Filename.txt", header=TRUE)
You can access your data by column:
x[,1]
x[,c(1,3)]
or if your first column is named "Col1" and the third "Col3",
x[,"Col1"]
x[,c("Col1","Col3")]
and you can do the same to access by row - by indices or rownames [which you
can set with "rownames<-", see help("rownames<-")]
Alternatively, with this type of data [created by the read.delim() function]
you can also access with the following syntax:
x$Col1
x$Col3
with(x,Col1)
with(x,cbind(Col1,Col3))
...hope this helps
ST
--- Susie Iredale <skewsie at yahoo.com> wrote:
>
>
>
> (Repeat of previous HTML version)
>
> Hello all,
>
> I am a new R user and I have finally imported my data using
> >read.delim("Filename.txt", header=TRUE) after some difficulty, by changing
> file directories (a hint to anyone who might be stuck there).
>
> However, I am now stuck trying to use my data. When I try to use
> data.frame("filename.txt") it tells me object not found, which makes it
> difficult to use attach() or with(). How do I get R to recognize my data?
>
>
> Thanks,
> Susie
> PhD Student UCI
>
>
>
>
>
>
____________________________________________________________________________________
> Luggage? GPS? Comic books?
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
More information about the R-help
mailing list