Computing new variable with Rj editor and seeing it in the spreadsheet

General help and assistance with jamovi. Bug reports can be made at our issues page: https://github.com/jamovi/jamovi/issues . (If you're unsure feel free to discuss it here)
Post Reply
User avatar
Cristóbal Lozano
Posts: 2
Joined: Fri Jul 26, 2024 10:44 pm
Contact:

Computing new variable with Rj editor and seeing it in the spreadsheet

Post by Cristóbal Lozano »

Hi there!

I am trying to compute a new variable 'combo', which is a combination of two existing variables (Participant, ID).

I can do this easily with the Compute menu with a formula (= Participant + "-" + ID) and it works perfectly. I can see the new variable 'combo' in the Jamovi spreadsheet.

Imagine now I want to do the same but this time using the Rj editor. I can calculate a new variable 'combo2' with the 'paste' function:

Code: Select all

data$combo2 <- paste(data$Participant, data$ID, sep = "-")
I can see that the newly computed variable 'combo2' has been created when I ask for a summary of the variable:

Code: Select all

summary(data$combo2)
Length Class Mode
7319 character character


The problem is that the new computed variable 'combo2' does not show up in the Jamovi spreadsheet!! I have tried several things to see 'combo2' in the spreadsheet but Jamovi always reports an errror. I have tried these lines of code (one at a time) but I get an error message of the type 'update is not an exported object from namespace:jmv' or 'fromDataFrame is not an exported object from namespace:jmv' and similar.

Code: Select all

jmv::update(data)

Code: Select all

jmv::fromDataFrame(data)   

Code: Select all

jmvcore::toDataFrame(data)  

Code: Select all

jmvcore::setData(data)
The problem (not visualising in the spreadsheet a newly computed variable via Rj editor) seems silly but I cannot figure out how to solve it. Please help!! Thanks. Cristóbal
User avatar
reason180
Posts: 309
Joined: Mon Jul 24, 2017 4:56 pm

Re: Computing new variable with Rj editor and seeing it in the spreadsheet

Post by reason180 »

You need to opt to use Rj+ (within Rj). Then you need to select the Participant and ID variables (using the gui). Then run your R code.
User avatar
Cristóbal Lozano
Posts: 2
Joined: Fri Jul 26, 2024 10:44 pm
Contact:

Re: Computing new variable with Rj editor and seeing it in the spreadsheet

Post by Cristóbal Lozano »

It works now!!
Thank you so much, reason180.
I can see now that one of the differences between the Rj Editor and the Rj Editor+ is that in the latter you need to move the variables to the right in the GUI for them to be considered by the function at hand, right?
User avatar
reason180
Posts: 309
Joined: Mon Jul 24, 2017 4:56 pm

Re: Computing new variable with Rj editor and seeing it in the spreadsheet

Post by reason180 »

Yes, that's correct.
Post Reply