I searched this extensively and all the examples I was able to find randomize row order but not the data in the row itself. I am trying to create a dataset where data needs to be randomized.
I'm trying to turn df into df2;
df:
df <- data.frame(a = c(1:5),
b = c(LETTERS[1:5]),
c = c(letters[1:5]))
a b c
1 1 A a
2 2 B b
3 3 C c
4 4 D d
5 5 E e
df2
a b c
1 2 D b
2 1 B d
3 4 E c
4 3 A a
5 5 C e
I think the reason there are not a lot of solutions for this on people need to keep their data intact but in this case I'm trying to sort of brake the dataset itself, so entries are not correct anymore.
Currently all I can achieve is
df2 <- df[sample(1:nrow(df)), ]
a b c
3 3 C c
4 4 D d
2 2 B b
1 1 A a
5 5 E e
which randomizes the order of the rows but keeps the data intact.