I have a ".txt" file that does not contain row names, but when I use read.table
with row.names = NULL
it still takes in the first 2 rows as row names.
test <- read.table('C:\\somefolder\\myfile.txt', header = FALSE, row.names = NULL)
head(test)
# V1 V2 V3
#1 1002345017,1598773715,56 ,23 ,29
#2 2000310429,1134645573,68 ,12 ,36
#3 3003044126,1403951625,147 ,53 ,28
#4 4045601426,1003975400,38 ,18 ,0
#5 4500450126,1016051119,30 ,15 ,0
#6 6049000126,1013902600,29 ,19 ,2
I get the same results without using row.names
specification as well.
You are missing sep
parameter:
res <- read.table(text = "1002345017,1598773715,56 ,23 ,29
2000310429,1134645573,68 ,12 ,36
3003044126,1403951625,147 ,53 ,28
4045601426,1003975400,38 ,18 ,0
4500450126,1016051119,30 ,15 ,0
6049000126,1013902600,29 ,19 ,2", header = FALSE, row.names = NULL, sep= ",")
As you source has a mix of spaces and commas you get it right half of the time.