This is similar to read.csv row.names and https://stackoverflow.com/questions/12425599/duplicated-row-names , but I do not see the answers that help.
Problem: Trying to read in a file that contains duplicate numbers in the first column, but shifts the column headers when row.names = NULL.
I am trying to read the following file in R
TripId VID TspVID VWT VCLS Week 201110041426 2226 33889 1 0 41 201110041501 2226 33889 1 0 41 201110041510 2226 33889 1 0 41 201110041557 2226 33889 1 0 41
(This is a small excerpt from a CSV Excel file with many thousands of rows and ~ 200 columns. The first row has as many records as the rest. The first row has duplicates. The columns do not match the labels in this view, but they are executed in CSV space.)
Team
> lm.table <- read.table(file= file.in, sep=",", header=TRUE) Error in read.table(file = file.in, sep = ",", header = TRUE) : duplicate 'row.names' are not allowed
does not work. Using the first column for row.names means that the first row has fewer values ββthan the others, which is not the case. I do not want the first column to be like row.names.
I am trying to set row.names = NULL
> lm.table <- read.table(file= file.in, sep=",", header=TRUE, row.names=NULL)
but the columns are offset
> head(lm.table) row.names TripId VID TspVID VWT VCLS Week Date TimeStart TimeEnd Lat1 1 201110010006 2226 33889 1 0 40 2011/09/30 17:06:37 17:25:16 47.5168 -122.209 2 201110010028 2226 33889 1 0 40 2011/09/30 17:28:45 17:43:14 47.5517 -122.058 3 201110010000 2231 45781 1 0 40 2011/09/30 17:00:00 18:02:30 32.9010 -117.193 4 201110011407 2231 45781 1 0 40 2011/10/01 07:07:57 07:48:17 32.7044 -117.004
Notice that the new column name is "row.names", and the entire row is shifted to the right.
Here is the tail of the result> head (lm.table). He shifted the column labels to an undefined column (I think this also shows the number of column labels = number of columns, which is also true when checking).
FVavR FVstdR FIdlR 1 3.959140 2 NA 2 5.285770 20 NA 3 4.274140 26 NA
Any idea why I get shift in columns and how not to shift, and that row.names are just ascending numbers?