Re: [R] read.csv help
On 2011-07-19 01:27, psombe wrote: Well yeah it works fine for small data but when i tried the exact same command with a large data set (abt 167 rows and 4000 columns) it gave me a different data frame. either i get the first column as row names and so when i put data[1,1] i get the the first row second column data (from the original data) as the first row became row names. or if i explicitly put row.names = NULL i get my columns shifted. this is how the data should look tdata[1,1:3] timestamp system.system.nfs_ops system.system.cifs_ops 1 1299376803 1104233 0 and this is how i'm able to load the data row.names timestamp system.system.nfs_ops system.system.cifs_ops 1 1299376803 1104233 0 0 notice the shift in the first column i hope this makes my problem clearer This has nothing to do with the size of your data set. Try count.fields() on your data file and do take note of the description of the row.names argument to read.csv function: "If there is a header and the first row contains one fewer field than the number of columns, the first column in the input is used for the row names." Peter Ehlers -- View this message in context: http://r.789695.n4.nabble.com/read-csv-help-tp3677454p3677586.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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. __ R-help@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.
Re: [R] read.csv help
Well yeah it works fine for small data but when i tried the exact same command with a large data set (abt 167 rows and 4000 columns) it gave me a different data frame. either i get the first column as row names and so when i put data[1,1] i get the the first row second column data (from the original data) as the first row became row names. or if i explicitly put row.names = NULL i get my columns shifted. this is how the data should look > tdata[1,1:3] timestamp system.system.nfs_ops system.system.cifs_ops 1 1299376803 1104233 0 and this is how i'm able to load the data row.names timestamp system.system.nfs_ops system.system.cifs_ops 1 1299376803 1104233 0 0 notice the shift in the first column i hope this makes my problem clearer -- View this message in context: http://r.789695.n4.nabble.com/read-csv-help-tp3677454p3677586.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] read.csv help
Can you explain a little more? I have created a small CSV file following your pattern which looks like this in a text editor: A,B,C,D,E 65,68,71,74,77 67,71,75,79,83 69,73,77,81,85 71,77,83,89,95 When I load it into R with > x <- read.csv( "a.csv" ) I get this which I think is what you would expect: > x A B C D E 1 65 68 71 74 77 2 67 71 75 79 83 3 69 73 77 81 85 4 71 77 83 89 95 with > rownames( x ) [1] "1" "2" "3" "4" Here is the dput version: > dput( x ) structure(list(A = c(65L, 67L, 69L, 71L), B = c(68L, 71L, 73L, 77L), C = c(71L, 75L, 77L, 83L), D = c(74L, 79L, 81L, 89L), E = c(77L, 83L, 85L, 95L)), .Names = c("A", "B", "C", "D", "E"), class = "data.frame", row.names = c(NA, -4L)) What is different with your data? Rgds, Rainer Original-Nachricht ---- > Datum: Tue, 19 Jul 2011 00:05:30 -0700 (PDT) > Von: psombe > An: r-help@r-project.org > Betreff: [R] read.csv help > Hi, > I'm a new R user and I'm having trouble with the read.csv command. It > somehow treats the first column as a row name field even though it's not a > row name. there are no missing columns/entries and i'm not sure how to > resolve this. > > the format of my data is > > A, B, C, D,..(3984 columns) > 12, 13, 41,..(all numeric) > > it either treats column A as rownames or if I explicitly disable row names > with row.names = NULL field it right shifts all the columns like > > rowno. A B C Last column > 1 12 13 41 NA > > Srinivas > > -- > View this message in context: > http://r.789695.n4.nabble.com/read-csv-help-tp3677454p3677454.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@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. -- --- Windows: Just say No. __ R-help@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.
[R] read.csv help
Hi, I'm a new R user and I'm having trouble with the read.csv command. It somehow treats the first column as a row name field even though it's not a row name. there are no missing columns/entries and i'm not sure how to resolve this. the format of my data is A, B, C, D,..(3984 columns) 12, 13, 41,..(all numeric) it either treats column A as rownames or if I explicitly disable row names with row.names = NULL field it right shifts all the columns like rowno. A B C Last column 1 12 13 41 NA Srinivas -- View this message in context: http://r.789695.n4.nabble.com/read-csv-help-tp3677454p3677454.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.