Page 3 of 3

Re: Computing new variables — recycling code

Posted: Thu Sep 15, 2022 7:58 am
by leehw
Thank you. I forgot I was on the stable version, rather than the latest. Am I reading this right, that this solution breaks normal vectorisation in R? I've tried a standard bit of code:

Code: Select all

data$FooBar <- data$Subject * 100
I get an error:

Code: Select all

replacement has 0 rows, data has 93
And I can see from your code you have a

Code: Select all

for
loop.

I could be coming to the wrong conclusion here, but it almost seems like the operation isn't being completed in a vectorised manner, which seems odd for a vectorised programming language.

Re: Computing new variables — recycling code

Posted: Thu Sep 15, 2022 1:38 pm
by MAgojam
Hey @leehw,
it is likely that the error is due to having used the Subject variable of nominal integer type, pass it to a continuous integer.

Cheers,
Maurizio