This is supposed to be as simple question but I couldn't figure it out. I'm trying to use a given variables list to choose data variables, however, apply string split I got 8 instead of 5. Clearly, the extra spaces were splited into empty variables for 1,3,5. Any hints on how to solve this?
list <- " ethnicity_source_value race_source_value gender_source_value dx_age site"
unlist(strsplit(list, " "))
[1] "" "ethnicity_source_value" ""
[4] "race_source_value" "" "gender_source_value"
[7] "dx_age" "site"