[R] read.csv help

Rainer Schuermann Rainer.Schuermann at gmx.net
Tue Jul 19 09:52:25 CEST 2011


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 <srinivas.eswar at gmail.com>
> An: r-help at 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 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.

-- 

-------

Windows: Just say No.



More information about the R-help mailing list