[R] Reading in and writing out one line at a time

sedm1000 gdoran at mit.edu
Thu May 20 00:47:05 CEST 2010


I hope that somebody can help me with this - I think very simple - issue...?

I am running a package that only accepts one line at a time, but I would
like to run this package on a dataframe of >500 lines. 

Dataframe "d" is a single column:

APPLES
PEARS
AUBERGINES
KUMQUATS

I would like to read one line of my dataframe "d", individually into a new
frame "f", then execute the program on "f" and it provides an output:

>mash(f)

[[1]]
[1]  FREDBLOGGS

[2]  250

I would like to record this output to a two column dataframe, "r", such as:

FREDBLOGGS     250

and then repeat the process on the next line of dataframe "d", and so on to
the end of dataframe "d",writing each line into "r" so that the dataframe
"r" eventually reads:

FREDBLOGGS     250
JAMESJONES      175
TERRYTAITE       892
HARRYSMITH     320


I'm afraid that I'm new to this, but think that this first step in will be
very useful in general. Thank you kindly for any help.
-- 
View this message in context: http://r.789695.n4.nabble.com/Reading-in-and-writing-out-one-line-at-a-time-tp2223726p2223726.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list