Suppose I have a data frame that looks like this:
df1 <- as.data.frame(matrix( rnorm(100*50,mean=0,sd=1), 100, 50))
I want to create a new variable y
that is the sum alpha_i*V_i with i from 1 to 50 and where alpha is a random number drawn from a uniform distribution (0,1).
What is the best way of doing this? Can I do it with mutate
and dplyr
?