More on “A Little Trick in Reading Data”

· Data manipulation, GNU-R

Here is an example of the beauty of R.

To split up a character string, all you need is to use a function called substr (for sub string)!! So you don’t really need to write the variable into a new file and read it back with read.fwf as I did (see my earlier post titled A Little Trick in Reading Data).

All you need, is to use substr to create a (set of) new variables out of the character strings. And if you want to turn them into numeric variables, you just have to us “as.numeric(substr(…))”.

It is such a joy when you discover that there is something meant to do exactly what you wanted.


%d bloggers like this: