Based on this question: Split text string in a data.table columns, I was wondering whether there is an efficient method to split the text string conditionally based on the contents of the row.
Suppose I have the following table:
Comments Eaten
001 Testing my computer No
0026 Testing my fridge No
Testing my car Yes
and I would to have this:
ID Comments Eaten
001 Testing my computer No
0026 Testing my fridge No
NA Testing my car Yes
Where NA is empty.
Is this possible in data.table?
The comment should have an ID, but since this is optional, I only want to extract the ID's if and only if the comment starts with a number.