I have a doubt about how to sample a dataframe. The dataset is like this:
with 114 rows with 9 columns. I need to extract 3 subsets, each one of 38 rows (114 / 3).
I have this script, but it doesn't works for the last subset:
install.packages("Rcmdr")
library(Rcmdr)
ana <- read.delim("~/Desktop/ana", header=TRUE, dec=",")
set1 <- ana[sample(nrow(ana), 38), ]
set1.index <- as.numeric(rownames(set1))
ana2 <- ana[(-set1.index),]
set2 <- ana2[sample(nrow(ana2), 38), ]
set2.index <- as.numeric(rownames(set2))
ana3 <- ana2[(-set2.index),]
ana3
For set1 and set2 I get the subsets correctly, but for set3 I get 50 rows (or less).
(Thank you in advance! =) )