[R] array problem and for looping
Dear R- users and Helpers Is there some way to re initialise or clear the array elements? Pardon me for being vague but the problem itself quite vague. I have attached the code along with email. When I run the saved r- code using source(random1.txt) , command. The program runs fine..but at times there is an error see below # ; but again after the error if re-excuted it would work fine I probably missed some array detail in my program any suggestions #Error in var(parrX[1, ]) : missing observations in cov/cor parrX[] is an array . 2) Also pardon me for the lengthy procedural code but as you could see in it..i have used the for loop for finding the positions (indexes) of the missing values and later carry out updating the new array element values at those particular positions/ So how can I escape the for loop in this case ? i.e get the missing position indexes and save another object ay vector or array ? And also later wanted to use matrix or vector multiplication (%*%) for the updating statement newy[i]- u2 + covXY/varX * (sample$x[i] - u1) is any of the apply function good out here ? I really feel that I am doing something very routine and donkey work and I am most certain that powerful R functions could just execute the same 10 liner for loop condition to mere 4 lines ? but how I am getting lost in the sea of functions here Thank u for reading Regards Kunal # creation for random data set x - rnorm(100,17,24) y - rnorm(100,7,11) A - matrix(c(10,25,8,40),nrow=2,ncol=2) z - rbind(x, y) # now 2 x 100 w - A %*% z # 2 x 100 x - w[1,] y - w[2,] print(meanX meanY varX varY covar) # mean of the variates u1 - mean(x) u2 - mean(y) # Variances of the variates varX - var(x) varY - var(y) # coVariances of the variates covXY - cov(x,y) # printing mean , var , covar print(c(u1,u2,varX,varY,covXY)) # now replace randomly with NA x[sample(1:length(x), 10)] - NA y[sample(1:length(y), 10)] - NA # just a variable sample - data.frame(x=x,y=y) # Vector for missing values missing - is.na(sample$x) | is.na(sample$y) xNA - array(sample$x[missing], dim=c(1,length(sample$x[missing]))) yNA - array(sample$y[missing], dim=c(1,length(sample$y[missing]))) # find the mean of the non missing values in the array mX - mean(sample$x,na.rm=TRUE) mY - mean(sample$y,na.rm=TRUE) # Imputing the missing values with current estimated means x-array(ifelse(is.na(sample$x), mX, sample$x),dim=c(1,length(sample$x))) y-array(ifelse(is.na(sample$y), mY, sample$y),dim=c(1,length(sample$y))) print( meanX meanY varX varY covar) # algorithm function to find out new estimate values algoResult - function(parrX,parrY,parrXNA,parrYNA,ictr) { # Variables for New X and Y newx - array(parrX, dim=c(1,length(parrX))) newy - array(parrY, dim=c(1,length(parrY))) # mean of the variates u1 - mean(parrX) u2 - mean(parrY) # Variances of the variates varX - var(parrX[1,]) varY - var(parrY[1,]) # coVariances of the variates covXY - cov(parrX[1,],parrY[1,]) # printing mean , var , covar print(c(u1,u2,varX,varY,covXY)) # Expected or updated values for the missing values # loop for finding positon of missing vectors for (i in 1:length(missing)) { if (missing[i]==TRUE) { if (is.na(sample$x[i]== TRUE)) { newx[i] - u1 + covXY/varY * (sample$y[i] -u2) } if (is.na(sample$y[i]== TRUE)) { newy[i]- u2 + covXY/varX * (sample$x[i] - u1) } } } l - list(c(newx),c(newy)) names(l)-c(X1,Y1); as.data.frame(l) return(l) } # the iteration loop to do the algorithm for (ctr in 1:50) { Output - algoResult(x,y,xNA,yNA,ctr); Output x - array(Output$X1, dim=c(1,length(Output$X1))) y - array(Output$Y1, dim=c(1,length(Output$Y1))) } __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Loop conditioning situation
Dear R-users and helpers I am facing a problem basically structuring my condition loop Say I have three values say x, y , z X Y Z Then I need to loop (till each of the values of X and Y and Z are same as the previous one) { over here the function does some calculations and updates the X and Y and Z with new values. I then save these values for X and Y and Z And the function or loop get called once again with these values. What I need is to stop or exit these loop moment the new values are equal to old saved values ( each of them X Y and Z) } any suggestion for structuring the loop I could always use three IF conditions and or three Boolean checks but is there some way for condition the loop for all three values at one go. regards Kunal __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Random number
thank you Sundar,Andy, Partha for your prompt reply. as for the %*% is matrix multiplication problem sunder here is a sample of what i want... x - rnorm(100,17,24) # X values y - rnorm(100,7,11) # Y values # since X and Y values are independent to get their # covariance need to multiply each of them with a Matrix say A A - matrix(c(10,25,8,40),nrow=2,ncol=2) further i would like to assign both x and y vectors to one variale say z - c(x,y) but if i do this my matrix multiplication fail i.e w - A%*%z Error in A %*% z : non-conformable arguments ?? so it tired multiply the X and Y vector individually x- (A%*%x) y- (A%*%y) Error in A %*% z : non-conformable arguments ?? the error persist...sunder... or anybody who could direct me..? regards Kunal Sundar Dorai-Raj [EMAIL PROTECTED] wrote: Kunal Shetty wrote: Dear R- User I created two random number sets using rnorm function and calcuted their respective means. However now I would like to randomly replace some values with NA. Thus create my own test data. Any help or suggestions on this ? Use ?sample: n - 100 x - rnorm(n) x[sample(n, 4)] - NA sum(is.na(x)) # [1] 4 Also wanted to confirm when multiplying two random number vectors x am y by matrix..is this how i do it. A is the matrix z - c(x,y)# x and y the two set of vectors w - A%*%Z # each element in each vector multipled by the matrix . (Be careful: R is case sensitive (z != Z).) I'm not really clear what you want here. %*% is matrix multiplication and * is elementwise multiplication. Also using c makes a vector or length n = length(x) + length(y). This implies that A above p x n (i.e. p rows, n columns) and the result w would be p x 1. Please provide an example of what you expect to see by the multiplication. --sundar regards Kunal __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Ref: Variable scope or function behaviour or array reassign
Thank you regards Kunal Uwe Ligges [EMAIL PROTECTED] wrote: Kunal Shetty wrote: Uwe Ligges thank you for u prompt reply my problem was in step3 where my function returns two different arrays. Yes i did try returning an object from the array. but the problem became...i tired returning the two arrays in a dataframe such as newXY - data.frame(newXmean=newx, newYmean =newy) Please don't use double spacing. You want to return a list: foo1 - function(.){ . return(list(newXmean = newx, newYmean = newy)) } and call the resulting objects as follows: foo2 - function(.){ new - foo1(.) print(new$newXmean) print(new$newYmean) } Uwe Ligges __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Ref: Variable scope or function behaviour or array reassign
Dear R- helpers Following a draft structure of the R script for which I am facing problem Step 1 x - of type array with original values y - of type array with original values Step 2 for (ctr in 1:10) { # my problem here the both x and y still show the original values from step 1 # in spite of making changes to the old values of the arrays x and y in the function function (x,y) ??? } step3 output - function(parX,parY){ Variables for New X and Y newx - array(parX, dim=c(1,length(parX))) newy - array(parY, dim=c(1,length(parY))) # make some calculation and updated some arrays element in the newX and # #newY # finally assign the global original values x and y with newX and newY x- newx y- newy # if print here I can see the new values # but when the function gets called the second time the original values of # x and y get called hence failing my motive of passing update values of #the arrays to the function each time ??? } I believe there something to deal with env or new.env but never could get the concept of the variable scope .where the fact with the function the x and y get updated but while calling from the main loop the x and y are pointing to old values also I am keen to know as to is there a way to clear the array of old values and reasign new values..or the - operator take care of it by overwriting regards Kunal __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Ref: Variable scope or function behaviour or array reassign
Uwe Ligges thank you for u prompt reply my problem was in step3 where my function returns two different arrays. Yes i did try returning an object from the array. but the problem became...i tired returning the two arrays in a dataframe such as newXY - data.frame(newXmean=newx, newYmean =newy) but in the calling function or loop; i wasn't able to access each individual array as an array; from the assigned object. Output - algoResult(x,y,xNA,yNA,ctr); Output print(Output) ?? print(Output[1]) print(Output$newy) hence was trying to assign the global arrays within the function itself without bothering to return any object... any help on this.. regards Kunal Uwe Ligges [EMAIL PROTECTED] wrote: Kunal Shetty wrote: Dear R- helpers Following a draft structure of the R script for which I am facing problem Step 1 x - of type array with original values y - of type array with original values Step 2 for (ctr in 1:10) { # my problem here the both x and y still show the original values from step 1 # in spite of making changes to the old values of the arrays x and y in the function function (x,y) ??? } step3 output - function(parX,parY){ Variables for New X and Y newx - array(parX, dim=c(1,length(parX))) newy - array(parY, dim=c(1,length(parY))) # make some calculation and updated some arrays element in the newX and # #newY # finally assign the global original values x and y with newX and newY x- newx y- newy # if print here I can see the new values # but when the function gets called the second time the original values of # x and y get called hence failing my motive of passing update values of #the arrays to the function each time ??? } I believe there something to deal with env or new.env but never could get the concept of the variable scope .where the fact with the function the x and y get updated but while calling from the main loop the x and y are pointing to old values also I am keen to know as to is there a way to clear the array of old values and reasign new values..or the - operator take care of it by overwriting regards Kunal __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html I don't understand your question completely. Anyway, I guess you have missed the point that you can pass arguments to a function and that you can return an object (e.g. a list of other objects) from the function (please read An Introduction to R for more details). Assign the value returned by a function it to an object in the calling function. In most circumstances, don't think too much about accessing environments, because you don't want to do it! The mechanisms mentioned above are sufficient in most circumstances. Uwe Ligges Uwe Ligges [EMAIL PROTECTED] wrote: Kunal Shetty wrote: Dear R- helpers Following a draft structure of the R script for which I am facing problem Step 1 x - of type array with original values y - of type array with original values Step 2 for (ctr in 1:10) { # my problem here the both x and y still show the original values from step 1 # in spite of making changes to the old values of the arrays x and y in the function function (x,y) ??? } step3 output - function(parX,parY){ Variables for New X and Y newx - array(parX, dim=c(1,length(parX))) newy - array(parY, dim=c(1,length(parY))) # make some calculation and updated some arrays element in the newX and # #newY # finally assign the global original values x and y with newX and newY x- newx y- newy # if print here I can see the new values # but when the function gets called the second time the original values of # x and y get called hence failing my motive of passing update values of #the arrays to the function each time ??? } I believe there something to deal with env or new.env but never could get the concept of the variable scope .where the fact with the function the x and y get updated but while calling from the main loop the x and y are pointing to old values also I am keen to know as to is there a way to clear the array of old values and reasign new values..or the - operator
[R] Maximum Likelihood :- Log likehoood function
Dear R - users/Helpers I am dealing with bivariate Normal data with missing values. Further I am trying to implement Expectation-Maximization (EM) algorithm to resolve the missing data problem. Now one of the requirements is use the Log likehood function i.e -2Log so as to find a reliable convergence My question is there any R built function for the same or do i have to use the packages contributed by other R Developers. Regards Kunal __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Re:How to create a R -application
Dear Ted and R- users and Helpers thanks ted once again for letting me know about Shafer's EM methods I am developing or rather working on windows platform. how do I use or rather install the contributed packages in my application or script. I could find documentation for unix paltform eg $ R CMD INSTALL /path/to/pkg_version.tar.gz and for windows...the zip file conatins a package.dll file...in the lib folder of the package...my hunt for R help documentation regarding insatlling and using packing on windows platform is onif anybody could guide me on this...please. regards Kunal [EMAIL PROTECTED] (Ted Harding) wrote: On 07-Oct-04 Kunal Shetty wrote: Dear R- users and Helpers I am a beginner for R. I am using R to implement EM algorithm for treating Missing values. I would like to know how can save or compile my logical R commands to an application; so that the next time I could just execute the R- file. Example for calculating the mean of a data set x - c(8,11,16,18,6,4,20,25,9,13) u - mean(x) u Now I would like to save these commands as batch or an application Anybody could please help or direct me in this problem There are several approaches possible, depending on what you find convenient at the time. 1. Have a look at the history-related commands: ?history savehistory(file=mycommands) will save the entire history of your session in mycommands which you can later edit. 2. In developing an application, I often experiment with different forms of a command or different combinations of commands. When I'm satisfied with a group of commands, I can copy-and-paste that part of the R window into a file which I have open in a separate editing window on the side (using X windows in Linux here, which makes this very easy). It can be convenient to use the 'history' command setting the max.show parameter (default=25), e.g. history(max.show=15) will give you only the last 15 commands you used. You can then copy over a selected few of these. 3. A converse version of (2) is to initially enter the commands into your editing window, and then copy-and-paste these into the R window to test them. Edit the commands file until you're happy. While I'm at it, are you aware of the R library packages 'cat', 'norm', 'mix' and 'pan' which implement Shafer's EM methods for imputing missing data? See CRAN. Good luck, and welcome to R! Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 [NB: New number!] Date: 07-Oct-04 Time: 19:32:22 -- XFMail -- __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Re:How to create a R -application
Dear Ted and R- users and Helpers very sorry folks i take by my question.i have found the solution...it is Installing Packages To get a package, the easiest way is to use Rgui. In Rgui, at the top you will see the standard pull-down menus, click on Packages - Install package from CRAN... . You will then see a list of packages which you can select from. and a very useful site for R developers on windows paltform http://wwwmaths.anu.edu.au/~wangk/personal/pub/R/WinBook/node7.html regards Kunal Kunal Shetty [EMAIL PROTECTED] wrote: Dear Ted and R- users and Helpers thanks ted once again for letting me know about Shafer's EM methods I am developing or rather working on windows platform. how do I use or rather install the contributed packages in my application or script. I could find documentation for unix paltform eg $ R CMD INSTALL /path/to/pkg_version.tar.gz and for windows...the zip file conatins a package.dll file...in the lib folder of the package...my hunt for R help documentation regarding insatlling and using packing on windows platform is onif anybody could guide me on this...please. regards Kunal [EMAIL PROTECTED] (Ted Harding) wrote: On 07-Oct-04 Kunal Shetty wrote: Dear R- users and Helpers I am a beginner for R. I am using R to implement EM algorithm for treating Missing values. I would like to know how can save or compile my logical R commands to an application; so that the next time I could just execute the R- file. Example for calculating the mean of a data set x - c(8,11,16,18,6,4,20,25,9,13) u - mean(x) u Now I would like to save these commands as batch or an application Anybody could please help or direct me in this problem There are several approaches possible, depending on what you find convenient at the time. 1. Have a look at the history-related commands: ?history savehistory(file=mycommands) will save the entire history of your session in mycommands which you can later edit. 2. In developing an application, I often experiment with different forms of a command or different combinations of commands. When I'm satisfied with a group of commands, I can copy-and-paste that part of the R window into a file which I have open in a separate editing window on the side (using X windows in Linux here, which makes this very easy). It can be convenient to use the 'history' command setting the max.show parameter (default=25), e.g. history(max.show=15) will give you only the last 15 commands you used. You can then copy over a selected few of these. 3. A converse version of (2) is to initially enter the commands into your editing window, and then copy-and-paste these into the R window to test them. Edit the commands file until you're happy. While I'm at it, are you aware of the R library packages 'cat', 'norm', 'mix' and 'pan' which implement Shafer's EM methods for imputing missing data? See CRAN. Good luck, and welcome to R! Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 [NB: New number!] Date: 07-Oct-04 Time: 19:32:22 -- XFMail-- __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re:How to create a R -application
Dear R- users and Helpers I am a beginner for R. I am using R to implement EM algorithm for treating Missing values. I would like to know how can save or compile my logical R commands to an application; so that the next time I could just execute the R- file. Example for calculating the mean of a data set x - c(8,11,16,18,6,4,20,25,9,13) u - mean(x) u Now I would like to save these commands as batch or an application Anybody could please help or direct me in this problem Thank you Regards Kunal __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Re:How to create a R -application
Ted Thank you for making me aware about the R library packages ; related to shafer's EM methods for imputing missing data...infact I juat had a look at on of the mailing list queries regarding imputing missing data http://tolstoy.newcastle.edu.au/R/help/04/07/3152.html regards Kunal Thank you for providing me details about While I'm at it, are you aware of the R library packages 'cat', 'norm', 'mix' and 'pan' which implement Shafer's EM methods for imputing missing data? See CRAN. regards Kunal [EMAIL PROTECTED] (Ted Harding) wrote: On 07-Oct-04 Kunal Shetty wrote: Dear R- users and Helpers I am a beginner for R. I am using R to implement EM algorithm for treating Missing values. I would like to know how can save or compile my logical R commands to an application; so that the next time I could just execute the R- file. Example for calculating the mean of a data set x - c(8,11,16,18,6,4,20,25,9,13) u - mean(x) u Now I would like to save these commands as batch or an application Anybody could please help or direct me in this problem There are several approaches possible, depending on what you find convenient at the time. 1. Have a look at the history-related commands: ?history savehistory(file=mycommands) will save the entire history of your session in mycommands which you can later edit. 2. In developing an application, I often experiment with different forms of a command or different combinations of commands. When I'm satisfied with a group of commands, I can copy-and-paste that part of the R window into a file which I have open in a separate editing window on the side (using X windows in Linux here, which makes this very easy). It can be convenient to use the 'history' command setting the max.show parameter (default=25), e.g. history(max.show=15) will give you only the last 15 commands you used. You can then copy over a selected few of these. 3. A converse version of (2) is to initially enter the commands into your editing window, and then copy-and-paste these into the R window to test them. Edit the commands file until you're happy. While I'm at it, are you aware of the R library packages 'cat', 'norm', 'mix' and 'pan' which implement Shafer's EM methods for imputing missing data? See CRAN. Good luck, and welcome to R! Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 [NB: New number!] Date: 07-Oct-04 Time: 19:32:22 -- XFMail -- __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Read.Table Reading a Text file
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 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
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 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 Xy 2 810 3 11 1 4 4 16 16 5 18 15 6 620 7 4 4 8 20 18 9 2522 and I want to access V1 values .. thank you regards Kunal [EMAIL PROTECTED] 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: 810 11 14 16 16 18 15 12 620 44 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 HoltmanWhat is the problem you are trying to solve? Executive Technical Consultant -- Office of Technology, Convergys [EMAIL PROTECTED] +1 (513) 723-2929 Kunal Shetty [EMAIL PROTECTED] To: [EMAIL PROTECTED] .edu cc: Sent by: Subject: [R] Read.Table Reading a Text file [EMAIL PROTECTED] 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 xy 810 11 14 16 16 18 15 620 44 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 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Read.Table Reading a Text file
thanks austin, it worked..it was exactly what I was looking for regards Kunal Austin, Matt [EMAIL PROTECTED] 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Kunal Shetty Sent: Thursday, October 07, 2004 18:44 PM To: [EMAIL PROTECTED] 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 Xy 2 810 3 11 1 4 4 16 16 5 18 15 6 620 7 4 4 8 20 18 9 2522 and I want to access V1 values. thank you regards Kunal [EMAIL PROTECTED] 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 44 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 HoltmanWhat is the problem you are trying tosolve? Executive Technical Consultant -- Office of Technology,Convergys [EMAIL PROTECTED] +1 (513)723-2929 KunalShetty [EMAIL PROTECTED] To:[EMAIL PROTECTED] .educc: Sent by: Subject: [R] Read.Table Reading a Textfile [EMAIL PROTECTED] 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 __ [EMAIL PROTECTED] mailinglist https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the postingguide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html