[R] Why do I have a column called row.names?
David L Carlson
dcarlson at tamu.edu
Mon Jun 4 21:10:18 CEST 2012
You will probably need to show us the first few lines of the .csv file.
Assuming that the lines look like this
start,stop,Symbol,Insert sequence,Clone End Pair,FISH
203048,67173930,ABC8-43024000D23,TI:993812543,TI:993834585
255176,87869359,ABC8-43034700N15,TI:995224581,TI:995237913
1022033,1060472,ABC27-1253C21,TI:2094436044,TI:2094696079
1022033,1061172,ABC23-1388A1,TI:2120730727,TI:2121592459
If I copy those lines to the clipboard and then use the command
read.csv("clipboard")
start stop Symbol Insert.sequence Clone.End.Pair FISH
1 203048 67173930 ABC8-43024000D23 TI:993812543 TI:993834585 NA
2 255176 87869359 ABC8-43034700N15 TI:995224581 TI:995237913 NA
3 1022033 1060472 ABC27-1253C21 TI:2094436044 TI:2094696079 NA
4 1022033 1061172 ABC23-1388A1 TI:2120730727 TI:2121592459 NA
I get numbered rows but no row.names (and I get the same when row.names=NULL
and FILL=TRUE is included).
----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352
> -----Original Message-----
> From: Ed Siefker [mailto:ebs15242 at gmail.com]
> Sent: Monday, June 04, 2012 1:16 PM
> To: dcarlson at tamu.edu
> Subject: Re: [R] Why do I have a column called row.names?
>
> I did read that, and I still don't understand why I have a column
> called row.names.
> I used "row.names = NULL" in order to get numbered row names, which was
> successful:
>
> > row.names(BACS)
> [1] "1" "2" "3" "4"
>
> I don't see what this has to do with an extraneous column name. Can
> you be
> more explicit as to what exactly I'm supposed to take away from this
> segment
> of the help file? Thanks.
>
>
> On Mon, Jun 4, 2012 at 1:05 PM, David L Carlson <dcarlson at tamu.edu>
> wrote:
> > Try help("read.delim") - always a good strategy before using a
> function for
> > the first time:
> >
> > In it, you will find: "Using row.names = NULL forces row numbering.
> Missing
> > or NULL row.names generate row names that are considered to be
> 'automatic'
> > (and not preserved by as.matrix)."
> >
> > ----------------------------------------------
> > David L Carlson
> > Associate Professor of Anthropology
> > Texas A&M University
> > College Station, TX 77843-4352
> >
> >
> >> -----Original Message-----
> >> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> >> project.org] On Behalf Of Ed Siefker
> >> Sent: Monday, June 04, 2012 12:47 PM
> >> To: r-help at r-project.org
> >> Subject: [R] Why do I have a column called row.names?
> >>
> >> I'm trying to read in a tab separated table with read.delim().
> >> I don't particularly care what the row names are.
> >> My data file looks like this:
> >>
> >>
> >> start stop Symbol Insert sequence Clone End Pair FISH
> >> 203048 67173930 ABC8-43024000D23 TI:993812543
> >> TI:993834585
> >> 255176 87869359 ABC8-43034700N15 TI:995224581
> >> TI:995237913
> >> 1022033 1060472 ABC27-1253C21 TI:2094436044
> TI:2094696079
> >> 1022033 1061172 ABC23-1388A1 TI:2120730727
> TI:2121592459
> >>
> >>
> >>
> >> I have to do something with row.names because my first column has
> >> duplicate entries. So I read in the file like this:
> >>
> >> > BACS<-read.delim("testdata.txt", row.names=NULL, fill=TRUE)
> >> > head(BACS)
> >> row.names start stop Symbol Insert.sequence
> >> Clone.End.Pair
> >> 1 203048 67173930 ABC8-43024000D23 NA TI:993812543
> >> TI:993834585
> >> 2 255176 87869359 ABC8-43034700N15 NA TI:995224581
> >> TI:995237913
> >> 3 1022033 1060472 ABC27-1253C21 NA TI:2094436044
> >> TI:2094696079
> >> 4 1022033 1061172 ABC23-1388A1 NA TI:2120730727
> >> TI:2121592459
> >> FISH
> >> 1 NA
> >> 2 NA
> >> 3 NA
> >> 4 NA
> >>
> >>
> >> Why is there a column named "row.names"? I've tried a few different
> >> ways of invoking this, but I always get the first column named
> >> row.names,
> >> and the rest of the columns shifted by one.
> >>
> >> Obviously I could fix this by using row.names<-, but I'd like to
> >> understand
> >> why this happens. Any insight?
> >>
> >> ______________________________________________
> >> 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.
> >
More information about the R-help
mailing list