I am a new learner of R. Creating a function to roll two virtual dice. The function should work like this: each time you call roll(), R should return the sum of rolling two dice. The code is as follows along with the error message:
roll<-function() {die<-1:6 dice<-sample(x=die,size=2,replace=TRUE) sum(dice)}
Error: unexpected symbol in "roll<-function() {die<-1:6 dice"
Dont write dice on the same line as the die assignment bevause the parser doesnt understand what you are assigning to die. It seems like you want to assign more than only 1:6.
You can add ; to seperate the staments, but starting a new line would be the typical way to go.