umx_merge_randomized_columns | R Documentation |
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.
umx_merge_randomized_columns(
colNames,
df,
levels = colNames,
newVarName = "score",
newCondName = "condition",
as.factor = FALSE
)
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) |
df with new cols
umx_long2wide()
, prolific_check_ID()
, prolific_read_demog()
, prolific_anonymize()
Other Data Functions:
noNAs()
,
prolific_anonymize()
,
prolific_check_ID()
,
prolific_read_demog()
,
umx
,
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()
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.