I have a requirement where in 70 odd data needs to be separated into 7 random data frame without any duplicate rows being selected, i.e. Replace = FALSE has been used still it picks duplicate rows even with sample_n() function results are the same.
Is it a bug known?
How will this be remedied as for future requirements this makes and arduous job to manually select.
df = name = c("arjun","Andrea", "Biswas","Ann","Biju", "Sheela","Deepti","Betty", "Hema", "Gowri"," Kunal", "Anamika","Ashik", "Hina","Kiran" )
gender = c("M","F", "M","M","F", "M","F","F","F", "F","M","F", "F","F","M")
etc like wise 5 with additional columns each group needs two females and rest males. but the basic splitting itself is having duplicates generated in group say arjun is in group 1 and 3 Andrea is in group 2 and 3 etc which should not happen.
code i tried
library(dplyr)
L4 = list()
dfc = list()
f = list()
numzone <- c(1:5)
for (i in numzone){
L4 <- df[sample(nrow(df) ,size = 3 ,replace = FALSE),]
f<-paste("df", i, sep="")
dfc <- L4
if (i %in% c(1:5)) {
f <- dfc[]
}
print(f)
Also, additionally I need this separated rows be assigned to dynamic data frame, may be from a list defined.