I basically want to create a vector which length is 82. This should contain either "W" or "L", but their occurrences should be randomly determined. I tried with this season<-rep(c("W","L"), times = 1, length.out = 82, each = 1)
but I only get this: [1] "W" "L" "W" "L" "W" "L"
... Trivial question but I am a newbie to R. Thanks!
You can do:
set.seed(1)
sample(c("W", "L"), 82, replace = TRUE)
# [1] "W" "W" "L" "L" "W" "L" ...
With set.seed
you set the seed of the random generator and hence get the same results, whenever you run this 2 lines. If you run a second time sample
you will get a different result.