How to rename a vector/data frame with a single column?
I know with various columns, I can use
colnames(x) <- c("col1","col2")
#Consider this example
Samp <- data.frame(sample(trainer$index, 10000))
head(Samp )
# sample.trainer.index..10000.
# 1 5907862
# 2 2181266
# 3 7368504
# 4 1949790
# 5 3475174
# 6 6062879
ncol(Samp)
# [1] 1
class(Samp)
# [1] "data.frame"
class(Samp[1])
# [1] "data.frame"
class(Samp[,1])
# [1] "numeric"
colnames(Samp)[2] <- "newname2"
# Error in names(x) <- value :
# 'names' attribute [2] must be the same length as the vector [1]