Posts

Showing posts with the label tidyr

R unnest ragged column into fixed length chunks

R unnest ragged column into fixed length chunks I have a dataset where one column is a string made of 1 number indicating day of week, followed any number of 10 digit chunks: # A tibble: 7 x 3 respid record_type record_data <chr> <chr> <chr> 1 20163911123050111 6 1000456561200035759120000989800 2 20163911123050111 6 2000405161200031719120000999900 3 20163911123050111 6 30004071212000320212200032832220003545620 4 20163911123050111 6 40004051612000326272200033032220003545620 5 20163911123050111 6 5036803031200040404120004051812000434361200045556120003575910 6 20163911123050111 6 6000411161200031720120003283121000344462100035759120004707410 7 20163911123050111 6 70004111312...