(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?
You have to read the data into an object: e.g., mydata <- read.delim("Filename.txt", header=TRUE) and then you can access the data with 'mydata'. If you had "test" as a column header,then mydata$test will access that data. On 7/3/07, Susie Iredale <skewsie@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@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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]]
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. >