I have a large dataframe
with a structure like this:
id v1 v2 v3 v4 v5
1 1 1 98 1 1
2 1 1 1 1 1
3 4 1 0 22 1
4 5 1 1 1 1
5 1 1 90 1 1
I would like to move from v2
all the way to v5
and if the variable value is greater than 1 character in length then it gets recoded to 9, so the resulting df
would be:
id v1 v2 v3 v4 v5
1 1 1 9 1 1
2 1 1 1 1 1
3 4 1 0 9 1
4 5 1 1 1 1
5 1 1 9 1 1
- Note: All variables are stored as strings that's why I'm looking to incorporate length as part of the answer.