[R] Can R replicate this data manipulation in SAS?
izahn at psych.rochester.edu
Fri Apr 22 16:34:52 CEST 2011
On Fri, Apr 22, 2011 at 10:21 AM, Paul Miller <pjmiller_57 at yahoo.com> wrote:
> Hello Everyone,
> It seems to me that Bert’s assertion about my question is not entirely accurate.
> In my question, I wrote:
> I'm hearing in some places that R may not be able to accomplish all of the data manipulation tasks that SAS can. In others, I'm hearing that R can do pretty much any data manipulation that SAS can but the way in which it does so is likely to be quite different.
> It's not clear to me how this represents a "wrong question," in the sense that it implies that R should solve the problem in the same way that SAS does.
> I really liked Ista’s solution, but now I’m wondering if it’s an attempt to mimic SAS and not a solution that’s natural to R.
> Is there another solution that is more natural in R? And if so, what would it look like?
R is flexible, which is one of the things I like most about it. That
flexibility means you can do almost any given task in more than one
way. This can sometimes lead to the question "which is the best way",
which may be interesting but in my experience is almost always a waste
of time (this statement is ment to apply to data
manipulation/analysis, not nesessarily to package development). Of
course you don't want to make things more complicated than they have
to be, and you of course want to get the right result in the end. But
my view is that when manipulating/analyzing data one should strive for
a "good enough" solution and not worry too much about finding the
"best" one. So while I'm sure someone can improve on my solution, it
works, is relatively easy to follow, and is not overly verbose. Good
enough I say.
I should also note that I don't understand SAS speak at all. I did NOT
translate your SAS code (except for the HARRT part, where a direct
translation seemed like the easies thing to do) -- in fact the first
thing I did was copy your email to a text editor and delete all the
SAS stuff. The way I arrived at the solution was just by looking at
the output you wanted and producing it in R in the way that seemed
most natural to me. Would someone else do it differently? Yes. Could
someone else do it better? Yes. But is it worth the time to try and
find a better way? I doubt it.
University of Rochester
Department of Clinical and Social Psychology
More information about the R-help