How would I go about getting a random sample from a lot of data.frames, so that I can perform some quality control just on my random sample?
Thanks in advance for your help and suggestions.
Here an example that hopefully clarifies what I am looking for:
set.seed(1234)
i = 1
for (i in 1:10){
df <- data.frame(x = sample(1:100, 5, replace = T), y = sample(1:100, 5, replace = T))
df <- df %>% mutate(z = x/y)
nam <- paste0("dataframe_", i)
assign(nam, df)
}
dataframe_1
# x y qc
# 1 28 38 0.73684211
# 2 80 16 5.00000000
# 3 22 4 5.50000000
# 4 9 98 0.09183673
# 5 5 86 0.05813953
# random sample from my dfs
randomtest<-sample(1:10,5)
randomtest
# [1] 5 10 8 9 1
# QC
df %>% mutate(qc = x/y)
Aucun commentaire:
Enregistrer un commentaire