First of all, not sure if this is the right forum to post about this, feel free to remove/move to another subforum.
I am trying to move jmv syntax to R.
Sorry this question may be basic, are there R code for the below "ifmiss" function? I am trying to compute such variables in R but couldn't find related function. See attached
Regarding R version of "ifmiss"
Regarding R version of "ifmiss"
- Attachments
-
- Jamovi to R.JPG (123.94 KiB) Viewed 2091 times
Re: Regarding R version of "ifmiss"
in R, if you wanted an equivalent to
IFMISS(columnName, ..., ...)
i'd suggest something like:
ifelse(is.na(data$columnName), ..., ...)
cheers
IFMISS(columnName, ..., ...)
i'd suggest something like:
ifelse(is.na(data$columnName), ..., ...)
cheers
Re: Regarding R version of "ifmiss"
Great, thank you.jonathon wrote:in R, if you wanted an equivalent to
IFMISS(columnName, ..., ...)
i'd suggest something like:
ifelse(is.na(data$columnName), ..., ...)
cheers
Sorry I am unfamiliar ifelse function
So the Jamovi computed variable is IFMISS(P_gain_book, IFMISS(N_nongain_book, IFMISS(N_loss_book, IFMISS(P_nonloss_book, NA,"Book-Negative"),"Book-Negative"),"Book-Positive"),"Book-Positive")"
How to convert that to R using ifelse?
Re: Regarding R version of "ifmiss"
so we could rewrite:
IFMISS(P_nonloss_book, NA,"Book-Negative")
as:
ifelse(is.na(data$P_nonloss_book), NA, "Book-Negative")
cheers
IFMISS(P_nonloss_book, NA,"Book-Negative")
as:
ifelse(is.na(data$P_nonloss_book), NA, "Book-Negative")
cheers
Re: Regarding R version of "ifmiss"
Thank you very much!jonathon wrote:so we could rewrite:
IFMISS(P_nonloss_book, NA,"Book-Negative")
as:
ifelse(is.na(data$P_nonloss_book), NA, "Book-Negative")
cheers
I have been making some progress, but encountered an error below.
So what I am trying to do is
If P_gain_book_1 OR P_nongain_book_4 has a value, then the computed variable BookConditionPositiveNegative is "Book-Positive"
If N_nonloss_book_1 OR N_loss_book_1 has a value, then the computed variable BookConditionPositiveNegative is "Book-Negative"
It is a between-subject design.
I tried:
Idsonrepextdatafile$BookConditionPositiveNegative <- ifelse(is.na(Idsonrepextdatafile$P_gain_book_1) | is.na(Idsonrepextdatafile$P_nongain_book_4),NA,"Book-Positive",ifelse(is.na(Idsonrepextdatafile$N_nonloss_book_1) | is.na(Idsonrepextdatafile$N_loss_book_1),NA,"Book-Negative"))
Error:
Error in ifelse(is.na(Idsonrepextdatafile$P_gain_book_1) | is.na(Idsonrepextdatafile$P_nongain_book_4), :
unused argument (ifelse(is.na(Idsonrepextdatafile$N_nonloss_book_1) | is.na(Idsonrepextdatafile$N_loss_book_1), NA, "Book-Negative"))
Re: Regarding R version of "ifmiss"
Hey @u3517520,
check arguments and parentheses ...
Look at the Rj script of the attached file, maybe it helps you. Cheers,
Maurizio
check arguments and parentheses ...
Look at the Rj script of the attached file, maybe it helps you. Cheers,
Maurizio
Re: Regarding R version of "ifmiss"
Great, thanks a lot, very much appreciated. It is working now.MAgojam wrote:Hey @u3517520,
check arguments and parentheses ...
Look at the Rj script of the attached file, maybe it helps you. Cheers,
Maurizio