![]() ![]() Value labels for new values can be assigned inside the recode pattern by writing the value label in square brackets after defining the new value in a recode pair, e.g. "rev" is a special token that reverses the value order (see 'Examples') direct value labelling "NA=1 3:5=NA" (recodes all NA into 1, and all values from 3 to 5 into NA in the new variable) "rev" NA values are allowed both as old and new value, e.g. will not be recoded, but copied, see 'Examples') NA's "3=1 1=2 else=copy" (recodes 3 into 1, 1 into 2 and all other values like 2, 4 or 5 etc. The "else"-token can be combined with copy, indicating that all remaining, not yet recoded values should stay the same (are copied from the original value), e.g. "3=1 1=2 else=3" (recodes 3 into 1, 1 into 2 and all other values into 3) "copy" "min:4=1 5:max=2" (recodes all values from minimum values of x to 4 into 1, and from 5 to maximum values of x into 2) "else"Īll other values, which have not been specified yet, are indicated by else, e.g. Minimum and maximum values are indicates by min (or lo) and max (or hi), e.g. 1:2.5=1 2.6:3=2 recodes 1 to 2.5 into 1 and 2.6 to 3 into 2, but 2.55 would not be recoded (since it's not included in any of the specified ranges) "min" and "max" "1:4=1 5:8=2" (recodes all values from 1 to 4 into 1, and from 5 to 8 into 2) value range for doublesįor double vectors (with fractional part), all values within the specified range are recoded e.g. "1,2=1 3,4=2" value rangeĪ value range is indicated by a colon, e.g. Multiple old values that should be recoded into a new single value may be separated with comma, e.g. The rec string has following syntax: recode pairsĮach recode pair has to be separated by a, e.g. Variables for which predicate returns TRUE are selected. If TRUE, return valueĪ predicate function to be applied to the columns. Have been recoded/transformed will be overwritten. If suffix = "" and append = TRUE, existing variables that Standardized variables ( std()) will be suffixed with "_z"Ĭentered variables ( center()) will be suffixed with "_c" Grouped variables ( group_var()) will be suffixed with "_gr" Grouped variables ( split_var()) will be suffixed with "_g" Recoded variables ( recode_to()) will be suffixed with "_r0"ĭichotomized variables ( dicho()) will be suffixed with "_d" Recoded variables ( rec()) will be suffixed with "_r" The default value to suffixĬolumn names in a data frame depends on the function call: If x is not a dataįrame, this argument will be ignored. String value, will be appended to variable (column) names of If FALSE, only the new variables are returned. X including the new variables as additional columns is returned Logical, if TRUE (the default) and x is a data frame, Value labelsĬan also be directly defined in the rec-syntax, see If NULL (default), no value labels will be set. Of recoded variable (see vignette Labelled Data and the sjlabelled-Package). Optional character vector, to set value label attributes If empty, variable label attributes will be removed. If NULL (default), variable label attribute of x willīe used (if present). Returned variable (see vignette Labelled Data and the sjlabelled-Package). Optional string, to set variable label attribute for the Logical, if TRUE, return value will be numeric, not a factor. rec_pattern is a convenient function toĬreate recode strings for grouping variables. String with recode pairs of old and new values. You may also use functions like : or tidyselect's Vector) and only selected variables from x should be processed. ![]() Optional, unquoted names of variables that should be selected forįurther processing. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |