What is the best way to convert data from typeof "character" to typeof "integer" and parsed into either a matrix or a data.frame, preserving the order?
I'm using the r serial package (from CRAN) to get data from a serial port into R, using the example provided in the package. The output is typeof "character" (Please see this question "How to Read Data from Serial Port in R"), but I would like it to be typeof integer, and in either a matrix or a data.frame.
My data looks like this:
> foo
[2] " 36037960 0 0\n100 0 0\n35 0 0\n33 0 0\n33 0 0\n0 36077681 0"
>
I would like to change the above to: [6, 3]
36037960 0 0
100 0 0
35 0 0
33 0 0
33 0 0
0 36077681 0
Background: The data is from three vibration switches (fast, medium, slow), and the value is the number of microseconds since the switch last operated. The vibration switches are attached to an ESP8266, this then sends the data via the USB port, and later by Wifi. This unit is (or will be) attached to my washing machine, to let me know at what stage of the cycle it is at, or if it is out of balance and stopped.
Please note: If possible, I wish to keep the function that reads the serial port as simple as possible. I am new to R and I'm keen to write good code.