Dear R users and Helpers I am beginner with using R and interested in carrying out certain task for my statistical research. I am reading data for a text file, which could contain data in following pattern x y 8 10 11 14 16 16 18 15 6 20 4 4 20 18 As per the example I have two columns and 7 rows of data in each. However is real life data situation I may not know how many columns are present and how rows are present and also with the certain data is missing. Yes I am assuming the data is delimited my Tab. My question or rather problem is I want read data from each colum say col x (8,11,16,18.....20) and store it into a variable so that I could perform some operations on them. I have also looked into certain R-help for Read.table and data.frame but still struggling on my requirement. They are http://tolstoy.newcastle.edu.au/R/help/04/07/2040.html http://tolstoy.newcastle.edu.au/R/help/04/07/3152.html Regards Kunal
James Thank you for response. I am working on treatment for missing data for both bivariate and multivariate normal data. Coming back to example. My problem was that once we do execute this command x.1 <- read.table('/tempxx.txt', fill=T) How can access the particular column say X8 and all its values so that I could assign some other operations on them. Because if I say print.default(x.1) the result.. V1 V2 1 X y 2 8 10 3 11 1 4 4 16 16 5 18 15 6 6 20 7 4 4 8 20 18 9 25 22 and I want to access V1 values...... thank you regards Kunal james.holtman@convergys.com wrote:> > > > > If you have an unequal number of columns, then use 'fill=T' on read.table > > It puts NAs. > > Is this what you want? > > Here is what happens on the input file which is your data and some extra > columns: > > 8 10 > 11 14 > 16 16 > 18 15 12 > 6 20 > 4 4 12 > 20 18 > > > > x.1 <- read.table('/tempxx.txt', fill=T) > > x.1 > X8 X10 > 11 14 NA > 16 16 NA > 18 15 12 > 6 20 NA > 4 4 12 > 20 18 NA > __________________________________________________________ > James Holtman "What is the problem you are trying to solve?" > Executive Technical Consultant -- Office of Technology, Convergys > james.holtman@convergys.com > +1 (513) 723-2929 > > > > Kunal Shetty > <kshe4@student.monash To: r-help@stat.math.ethz.ch > .edu> cc: > Sent by: Subject: [R] Read.Table Reading a Text file > r-help-bounces@stat.m > ath.ethz.ch > > > 10/07/2004 16:18 > > > > > > > Dear R users and Helpers > > I am beginner with using R and interested in carrying out certain task > for > my statistical research. > I am reading data for a text file, which could contain data in following > pattern > > x y > 8 10 > 11 14 > 16 16 > 18 15 > 6 20 > 4 4 > 20 18 > > As per the example I have two columns and 7 rows of data in each. > However is real life data situation I may not know how many columns are > present and how rows are present and also with the certain data is > missing. Yes I am assuming the data is delimited my Tab. > > > My question or rather problem is I want read data from each colum say col > x > (8,11,16,18â¦.20) and store it into a variable so that I could perform > some > operations on them. > > I have also looked into certain R-help for Read.table and data.frame but > still struggling on my requirement. They are > > http://tolstoy.newcastle.edu.au/R/help/04/07/2040.html > http://tolstoy.newcastle.edu.au/R/help/04/07/3152.html > > > Regards > Kunal > > ______________________________________________ > 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 >
thanks austin, it worked..it was exactly what I was looking for regards Kunal "Austin, Matt" <maustin@amgen.com> wrote:> x.1$V1 > or > x.1[,1] > or > x.1['V1'] > > and you shouldn't need to call print.default() directly, just call > print(). > > --Matt > -----Original Message----- > From: r-help-bounces@stat.math.ethz.ch > [mailto:r-help-bounces@stat.math.ethz.ch]On Behalf Of Kunal Shetty > Sent: Thursday, October 07, 2004 18:44 PM > To: james.holtman@convergys.com > Cc: R-help > Subject: Re: [R] Read.Table Reading a Text file > > > > James > Thank you for response. I am working on treatment for missing > data for both bivariate and multivariate normal data. Coming back to > example. My problem was that once we do execute this command > x.1 <- read.table('/tempxx.txt', fill=T) > > > How can access the particular column say X8 and all it's values so that I > could assign some other operations on them. > Because if I say > print.default(x.1) > > the result.. > > V1 V2 > 1 X y > 2 8 10 > 3 11 1 4 > 4 16 16 > 5 18 15 > 6 6 20 > 7 4 4 > 8 20 18 > 9 25 22 > > > and I want to access V1 values..... > > > thank you > regards > Kunal > > > james.holtman@convergys.com wrote: > > > > > > > > > > If you have an unequal number of columns, then use 'fill=T' onread.table > > > > It putsNAs. > > > > Is this what youwant? > > > > Here is what happens on the input file which is your data and someextra > >columns: > > > > 8 10 > > 11 14 > > 16 16 > > 18 15 12 > > 6 20 > > 4 4 12 > > 20 18 > > > > > > > x.1 <- read.table('/tempxx.txt',fill=T) > > >x.1 > > X8X10 > > 11 14 NA > > 16 16 NA > > 18 15 12 > > 6 20 NA > > 4 4 12 > > 20 18 NA > >__________________________________________________________ > > James Holtman "What is the problem you are trying tosolve?" > > Executive Technical Consultant -- Office of Technology,Convergys > >james.holtman@convergys.com > > +1 (513)723-2929 > > > > > > > > KunalShetty > > <kshe4@student.monash To:r-help@stat.math.ethz.ch > > .edu>cc: > > Sent by: Subject: [R] Read.Table Reading a Textfile > >r-help-bounces@stat.m > >ath.ethz.ch > > > > > > 10/07/200416:18 > > > > > > > > > > > > > > Dear R users andHelpers > > > > I am beginner with using R and interested in carrying out certaintask > >for > > my statisticalresearch. > > I am reading data for a text file, which could contain data infollowing > >pattern > > > > x y > > 8 10 > > 11 14 > > 16 16 > > 18 15 > > 6 20 > > 4 4 > > 20 18 > > > > As per the example I have two columns and 7 rows of data ineach. > > However is real life data situation I may not know how many columnsare > > present and how rows are present and also with the certain datais > > missing. Yes I am assuming the data is delimited myTab. > > > > > > My question or rather problem is I want read data from each colum saycol > >x > > (8,11,16,18âEUR¦.20) and store it into a variable so that I couldperform > >some > > operations onthem. > > > > I have also looked into certain R-help for Read.table and data.framebut > > still struggling on my requirement. Theyare > > > >http://tolstoy.newcastle.edu.au/R/help/04/07/2040.html > >http://tolstoy.newcastle.edu.au/R/help/04/07/3152.html > > > > > >Regards > >Kunal > > > >______________________________________________ > > R-help@stat.math.ethz.ch mailinglist > >https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the postingguide! > >http://www.R-project.org/posting-guide.html > > > > ______________________________________________ > 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
On 7 Oct 2004 at 20:18, Kunal Shetty wrote:> Dear R users and Helpers > > I am beginner with using R and interested in carrying out certain task > for my statistical research. I am reading data for a text file, which > could contain data in following pattern > > x y > 8 10 > 11 14 > 16 16 > 18 15 > 6 20 > 4 4 > 20 18 > > As per the example I have two columns and 7 rows of data in each. > However is real life data situation I may not know how many columns > are present and how rows are present and also with the certain data > is missing. Yes I am assuming the data is delimited my Tab. > > > My question or rather problem is I want read data from each colum say > col x (8,11,16,18.....20) and store it into a variable so that I could > perform some operations on them.Hi Better to read by appropriate read.whatever() function to data frame, see eg. ?read.table I hope you have already read some intro documents in which there is stated how you could read your data and organize them. I also recommend to go through Paul Johnsons Rtips. You can find it by e.g. Google. Cheers Petr> > I have also looked into certain R-help for Read.table and data.frame > but still struggling on my requirement. They are > > http://tolstoy.newcastle.edu.au/R/help/04/07/2040.html > http://tolstoy.newcastle.edu.au/R/help/04/07/3152.html > > > Regards > Kunal > > ______________________________________________ > 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.htmlPetr Pikal petr.pikal at precheza.cz