Thursday, April 11, 2013

use scan to read in a piece of data for ad-hoc analysis

Sometimes it is necessary to read in a piece of data for ad-hoc analysis. We can save the data to txt and then read in by read.table. In this way we need to find physical path of the data. It is not convenient for ad-hoc analysis especially when data is in server and R is in local machine.
 
A convenient way is to use scan function in R to directly read in the data by pasting them. Like:
 
x=scan(what=(list(a1=0,a2=0)))
 

y=data.frame(x)


Then do any analysis like plot and so on based on df y.

1 comment: