Dear kind people of the internet, I need help. I am trying to split a string column into several columns and keep the null/NA entries.
df <- cSplit(df, "question", "_")
This code currently splits them but removes the null entries and shows the following warming message:
Warning messages:
1: In type.convert.default(X[[i]], ...) :
'as.is' should be specified by the caller; using TRUE
df
client_id question
15962 eng_child_pregnancy_standard_focused
15963 null
15964 xho_child_developed_sleep
15965 eng_mother_spacing_other
15966 null
15967 null
Current split df using the above code:
client_id question question_2 question_3 question_4 question_5
15962 eng child pregnancy standard focused
15964 xho child developed sleep NA
15965 eng mother spacing other NA
How do I keep the null entries and what does the warning mean?
From
?cSplit
, we can see that there's atype.convert
argument in the function that would change the type of the result in each column (i.e. figure out whether the column should be numeric, logical or character). The warning message aboutas.is
is from theutils::type.convert()
function, which is used iftype.convert
is set toTRUE
.Therefore to avoid the message, use
type.convert = FALSE
.