You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Survey responses are often encoded both as a number (0,1,2,3) and as a response string (None, mild, moderate, severe).
Data mishaps often occur when people analyzing the data mix up which number is associated with each response
This can be really embarrassing when you mix up things like male/female or
responded/did not respond, and you make the wrong conclusion in your data analysis.
In a perfect world, we would all refer to the codebook every time we needed to,
but humans are a bit lazy, and
we often wing it (or assume we know the encoding)
It can be really helpful to store the survey responses as self-encoding data, where the numbers are linked to the responses,
with a single intervening underscore,
like "0_None", "1_Mild", "2_Moderate", "3_Severe", or
"0_Alive", "1_Dead",
or "1_Male", "2_Female"
So that you don't need to look at the codebook, and you won't make silly mistakes
These work well as character variables, or (even better) stored as ordered factors.
But sometimes it is helpful to be able to
extract the number - parse_number() already does this, and is fabulous
extract the string (response) - parse_character() does not extract the response - it returns all characters, which is reasonable.
but it would be really nice to have something like parse_string() to extract
"None", "Mild", "Moderate", "Severe"
without the numbers or underscores (like parse_number() does for numbers)
These are nice for labels in tables or in categorical plots
I propose using the function:
parse_string<-function(value) {
str_extract(string=value,
pattern="(?<=\\d\\_).+")
# to extract the response string portion from NN_ResponseString
}
The text was updated successfully, but these errors were encountered:
higgi13425
changed the title
feature request: read_string or for self-documenting survey responses
feature request: read_string for self-documenting survey responses
Dec 12, 2024
Survey responses are often encoded both as a number (0,1,2,3) and as a response string (None, mild, moderate, severe).
Data mishaps often occur when people analyzing the data mix up which number is associated with each response
This can be really embarrassing when you mix up things like male/female or
responded/did not respond, and you make the wrong conclusion in your data analysis.
In a perfect world, we would all refer to the codebook every time we needed to,
but humans are a bit lazy, and
we often wing it (or assume we know the encoding)
It can be really helpful to store the survey responses as self-encoding data, where the numbers are linked to the responses,
with a single intervening underscore,
like "0_None", "1_Mild", "2_Moderate", "3_Severe", or
"0_Alive", "1_Dead",
or "1_Male", "2_Female"
So that you don't need to look at the codebook, and you won't make silly mistakes
These work well as character variables, or (even better) stored as ordered factors.
But sometimes it is helpful to be able to
without the numbers or underscores (like parse_number() does for numbers)
These are nice for labels in tables or in categorical plots
I propose using the function:
The text was updated successfully, but these errors were encountered: