Reputation: 17
New in R. I haven´t find an answer for this.
When I read a table in R, it introduces a V1, V2, V3, names in the columns. HOw can I get rid of them?. The file doesn´t have column names. This is my code. I have tried with txt and csv files.
write.table(test,file="tab.txt",append=F,quote=F)
write.csv(test,file="tab.csv",append=F,quote=F)
tab <- read.table("tab.txt",header=T)
tab2 <- read.csv("tab.csv",header=T)
X V1 V2 V3 V4 V5
1 1 -1 -1 -0.5418994 -1.0000000 -0.1967213
2 10 -1 -1 -0.5418994 -0.3514739 -0.1967213
3 100 -1 -1 -0.5418994 -1.0000000 -1.0000000
4 1000 -1 -1 -0.5418994 -0.3514739 -0.1967213
5 1001 -1 -1 -0.5418994 -0.3514739 -0.1967213
Upvotes: 0
Views: 2207
Reputation: 109864
Make it into a matrix as I've done here with the cars data set:
cars2 <- as.matrix(cars)
colnames(cars2) <- NULL
head(cars2)
## > head(cars2)
## [,1] [,2]
## [1,] 4 2
## [2,] 4 10
## [3,] 7 4
## [4,] 7 22
## [5,] 8 16
## [6,] 9 10
A data.frame object needs column names (or it's particularly difficult to force no names).
Upvotes: 2