Computing new variables — recycling code

Discuss the jamovi platform, possible improvements, etc.
User avatar
leehw
Posts: 20
Joined: Fri Nov 22, 2019 8:48 am

Re: Computing new variables — recycling code

Post 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.
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: Computing new variables — recycling code

Post 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
Post Reply