[R] Data Manipulation Question
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Fri Dec 4 09:18:58 CET 2009
On Thu, Dec 3, 2009 at 9:52 PM, John Filben <johnfilben at yahoo.com> wrote:
> Can R support data manipulation programming that is available in the SAS datastep? Specifically, can R support the following:
> - Read multiple dataset one record at a time and compare values from each; then base on if-then logic write to multiple output files
> - Load a lookup table and then process a different file; based on if-then logic, access and lookup values in the table
> - Support modular “gosub”programming
> - Sort files
> - Date math and conversions
> - Would it be able to support the following type of logic:
> o Start
> § Read Record from File 1
> § Read Record from File 2
> § Match
> · If Key 1 <> Key 2 and Key 1 < Key 2, Write to output file A
> · If Key 1 = Key 2, Write to output file B
> · If Key 1 <> Key 2 and Key 1 > Key 2, Write to output file C§ Goto Start until File 1 Done
> John Filben
I'll expand on Hadley Wickham's "Yes", to say "Yes, and it wouldn't be
much of a 'system for statistical computation and graphics' if it
couldn't do that".
Remember R uses the 'S' and C programming languages and is Open
Source. If it _cant_ do something you want it to do, you can write
code that does it. Like the date math and conversions. Originally,
maybe waaaay back in R version 0.something, it didn't have that. But
someone wrote it, and wisely contributed it, and the community saw
that it was good. And now we have date math and conversions. And
nobody has to write any date math or conversion codes ever again.
Now tell me how to get something into the SAS core code.
Barry
P.S. I see a very obvious optimisation you can do on this line:
If Key 1 <> Key 2 and Key 1 < Key 2, Write to output file A
but maybe that's some kind of weird SASism....
More information about the R-help
mailing list