Hi all, I'm new to R and I'm struggling with loading a data file without attribute names, like: 1,72,0,5.6431,28.199 1,72,0,12.666,28.447 1,72,0,19.681,28.695 1,72,0,25.647,28.905 It has no names for the columns nor the rows. I tried data <- read.table(path,header = FALSE, sep = ",") and it seems to work. But later, when I try qqnorm to plot the graph, it gives me the error msg: xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ I think the reason might be that I load the file wrongly. What should I do in this case? -- View this message in context: http://r.789695.n4.nabble.com/How-to-load-data-file-without-attribute-names-tp3061489p3061489.html Sent from the R help mailing list archive at Nabble.com.
You need to follow the posting guide and show exactly what you did. I read in your data and can print it. You did not show what 'x', and 'y' were in your data:> myData <- read.table('clipboard', sep=',')> myDataV1 V2 V3 V4 V5 1 1 72 0 5.6431 28.199 2 1 72 0 12.6660 28.447 3 1 72 0 19.6810 28.695 4 1 72 0 25.6470 28.905> plot(myData$V4, myData$V5) >You need to at least do str(x) str(y) to show what you are working with. On Sat, Nov 27, 2010 at 7:45 AM, 44whyfrog <44whyfrog at 163.com> wrote:> > Hi all, > > I'm new to R and I'm struggling with loading a data file without attribute > names, like: > > 1,72,0,5.6431,28.199 > 1,72,0,12.666,28.447 > 1,72,0,19.681,28.695 > 1,72,0,25.647,28.905 > > It has no names for the columns nor the rows. I tried > > data <- read.table(path,header = FALSE, sep = ",") > > and it seems to work. But later, when I try qqnorm to plot the graph, it > gives me the error msg: > > xy.coords(x, y, xlabel, ylabel, log) : > ?'x' and 'y' lengths differ > > I think the reason might be that I load the file wrongly. What should I do > in this case? > -- > View this message in context: http://r.789695.n4.nabble.com/How-to-load-data-file-without-attribute-names-tp3061489p3061489.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
On 11/27/2010 11:45 PM, 44whyfrog wrote:> > Hi all, > > I'm new to R and I'm struggling with loading a data file without attribute > names, like: > > 1,72,0,5.6431,28.199 > 1,72,0,12.666,28.447 > 1,72,0,19.681,28.695 > 1,72,0,25.647,28.905 > > It has no names for the columns nor the rows. I tried > > data<- read.table(path,header = FALSE, sep = ",") > > and it seems to work. But later, when I try qqnorm to plot the graph, it > gives me the error msg: > > xy.coords(x, y, xlabel, ylabel, log) : > 'x' and 'y' lengths differ > > I think the reason might be that I load the file wrongly. What should I do > in this case?Hi 44whyfrog, I guess (and it's a wild one) that you have simply typed in the "usage" arguments, and these have little or no relation to what is in "data". If I were in your pond, I would first try: names(data) to see what the names of your columns are. If you do find columns named "x" and "y", try: length(data$x) length(data$y) The error message may relate to the fact that you already have an "x" or a "y" object hanging around in your workspace, and they have different lengths. Jim
Thank you very much. What I actually do was data1 <- read.delim(path,head=FALSE,sep=",") motor_UPDRS <-data1[5] qqnorm(motor_UPDRS) I eventually noticed that I missed a "," in the second command. And I cannot retrieve a vector correctly. -- View this message in context: http://r.789695.n4.nabble.com/How-to-load-data-file-without-attribute-names-tp3061489p3062333.html Sent from the R help mailing list archive at Nabble.com.