4 ms·
At my previous job we used to play "Guess what R does" over lunch. Someone would write a few R statements and we'd have to guess the output. Extremely difficult
by numlocked 11y ago
At my previous job we used to play "Guess what R does" over lunch. Someone would write a few R statements and we'd have to guess the output. Extremely difficult!
>> a=c(1,2,3,4)
>> b=c(1,2)
>> a+b
Any guesses?
- jmcphers 11y ago2, 4, 4, 6. The second vector is recycled along the first one: 1 + 1, 2 + 2, 3 + 1, 4 + 2.
- epistasis 11y ago+ is a vector operation, and does it elementwise. R recycles vectors. You get warnings if there are elements left over. This is something you should know within the first 5 minutes of learning the language, hopefully?