When I run the code symbols always equal to [0,0,0] while get_symbols() gives different results.
Why the function output doesn't get assigned to symbols?
Thanks! Actually I was reading the book you recommend and tried to write the code in my own way
As you said, there are two errors with my script:
the first error is the typo with "(",
the 2nd error is the last line of the code must generate an output, a code like " symbols<-sample(wheel, size = 3, replace=TRUE, prob =c(0.03, 0.03, 0.06, 0.1, 0.25, 0.01, 0.52))" will not generate an output, it simply assigns a value to symbol object, however, this object is only saved in run-time environment.
The get_symbols() function will not save this result to Global Environment as it's not an calculation output, hence symbol object remains 0 in Global Environment.
You are right, though, that everything that is created inside of a function will remain there. However, unless you define the symbols object in your Global environment, it's value will be not defined and not 0. The reason you were getting [1] 0 0 0 output is because of randomness in your function and since "0" has 0.52 weight.