我用this answer的代碼把我的列車數據分成兩組。如何拆分一列data.frame並獲取data.frame作爲輸出?
trainLabels <- read.csv(trainLabels.file, stringsAsFactors=F, header=FALSE)
> str(trainLabels)
'data.frame': 1000 obs. of 1 variable:
$ V1: int 1 0 0 1 0 1 0 1 1 0 ...
trainLabelsTrain <- trainLabels[train_ind, ]
trainLabelsTest <- trainLabels[-train_ind, ]
> str(trainLabelsTrain)
int [1:750] 0 1 0 0 0 0 1 1 1 0 ...
然後我想有一個data.frame就像原始數據(trainLabels
)。
如何獲取data.frame?
在您的子集行中放置drop = FALSE。 – Thomas