umx_merge_randomized_columns {umx} | R Documentation |
umx_merge_randomized_columns
Description
umx_merge_randomized_columns
is designed to merge data where subjects have been randomized
to conditions, so they have a value in one column, and NA in the other condition columns.
It returns a new column of merged scores, and a new column of associated conditions.
Usage
umx_merge_randomized_columns(
colNames,
df,
levels = colNames,
newVarName = "score",
newCondName = "condition",
as.factor = FALSE
)
Arguments
colNames |
Names of the columns containing the condition data. |
df |
The data frame |
levels |
optional names for the levels of condition (default = |
newVarName |
Name for the new column holding the newVarName (default "score"). |
newCondName |
Name for the new column holding the condition (default "condition"). |
as.factor |
Turn condition into a factor? (FALSE) |
Value
df with new cols
See Also
Other Data Functions:
noNAs()
,
prolific_anonymize()
,
prolific_check_ID()
,
prolific_read_demog()
,
umxFactor()
,
umxHetCor()
,
umx_as_numeric()
,
umx_cont_2_quantiles()
,
umx_lower2full()
,
umx_make_MR_data()
,
umx_make_TwinData()
,
umx_make_fake_data()
,
umx_make_raw_from_cov()
,
umx_polychoric()
,
umx_polypairwise()
,
umx_polytriowise()
,
umx_read_lower()
,
umx_rename()
,
umx_reorder()
,
umx_score_scale()
,
umx_select_valid()
,
umx_stack()
,
umx_strings2numeric()
,
umx
Examples
## Not run:
fp = "~/Desktop/Political Ideology_September 13, 2022_10.47.xlsx"
df = readxl::read_excel(fp)
df = df[c(-1,-2), ] # delete temp data and question text
df = data.frame(df)
namez(df, "ris", coll = "vec") # c('RiskAversionNoLotter', 'RiskAversionLottery')
colNames= c('RiskAversionNoLotter', 'RiskAversionLottery')
df = umx_as_numeric(df, colNames, force=TRUE)
tmp = umx_merge_randomized_columns(colNames, df); table(tmp$condition)
tmp = umx_merge_randomized_columns(colNames, df,
levels = c("treatment", "control")); table(tmp$condition)
## End(Not run)