I have a Character List in the format of deck/number/side, and I'd like to create separate variables for deck and side.
the spaceTrainTib$Cabin Variable looks like:
[1] "B/0/P" "F/0/S" "A/0/S" "A/0/S" "F/1/S" "F/0/P" "F/2/S" "G/0/S"
[9] "F/3/S" "B/1/P" "B/1/P" "B/1/P" "F/1/P" "G/1/S" "F/2/P" NA
[17] "F/3/P" "F/4/P" "F/5/P" "G/0/P" "F/6/P" "E/0/S" "E/0/S" "E/0/S"
[25] "E/0/S" "E/0/S" "E/0/S" "D/0/P" "C/2/S" "F/6/S" "C/0/P" "F/8/P"
[33] "G/4/S" "F/9/P" "F/9/P" "F/9/P" "D/1/S" "D/1/P" "F/8/S" "F/10/S" [41] "G/1/P" "G/2/P" "B/3/P" "G/3/P" "G/3/P" "G/3/P" "F/10/P" "F/10/P"
deck <- map_chr(str_split(spaceTrainTib$Cabin, "/"), 1)
deck
returning
[1] "B" "F" "A" "A" "F" "F" "F" "G" "F" "B" "B" "B" "F" "G" "F" NA "F" "F" "F" "G" "F"
[22] "E" "E" "E" "E" "E" "E" "D" "C" "F" "C" "F" "G" "F" "F" "F" "D" "D" "F" "F" "G" "G"
[43] "B" "G" "G" "G" "F" "F" "E" "E" "G" "F" "A" "A" "A" "G" "F" "F" "F" "E" "G" "G" "G"
is doing it's job. But it will not work if I use
side <- map_chr(str_split(spaceTrainTib$Cabin, "/"), 3)
side
The error ist: "Error in `stop_bad_type()' ! Result 16 must be a single string, not NULL of length 0
to extract the third letter. Can anyone help?