data_shuffle | R Documentation |
Shorthand to shuffle a data frame and save
data_shuffle(., which = c("rows", "cols"), seed = NULL)
. |
data to shuffle as data frame |
which |
what to shuffle, rows or columns |
seed |
apply seed if indicated for reproducibility |
shuffled data frame of items store to the data frame name
#basic example
data.frame(ID=46:55,PK=c(rep("Treatment",5),rep("Placebo",5))) #before
data_shuffle(
data.frame(ID=46:55,PK=c(rep("Treatment",5),rep("Placebo",5)))
) #after shuffle row
data_shuffle(
data.frame(ID=46:55,PK=c(rep("Treatment",5),rep("Placebo",5))),
which = "cols"
) #after shuffle column
# examples using object
df1<-data.frame(ID=46:55,PK=c(rep("Treatment",5),rep("Placebo",5)))
#illustrate basic functionality
data_shuffle(df1)
df1 #shuffle and resaved to variable
data.f2<-df1
data_shuffle(data.f2)
data.f2 #first output
data.f2<-df1
data_shuffle(data.f2)
data.f2 # different output from first output top
data.f2<-df1
data_shuffle(data.f2,seed = 344L)
data.f2 #second output
data.f2<-df1
data_shuffle(data.f2,seed = 344L)
data.f2 #the same output as second output top
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.