[R] things that are difficult/impossible to do in SAS or SPSS but simple in R
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Jan 16 00:15:45 CET 2008
On Jan 15, 2008 6:04 PM, Frank E Harrell Jr <f.harrell at vanderbilt.edu> wrote:
> Matthew Keller wrote:
> > Hi all,
> >
> > I'm giving a talk in a few days to a group of psychology faculty and
> > grad students re the R statistical language. Most people in my dept.
> > use SAS or SPSS. It occurred to me that it would be nice to have a few
> > concrete examples of things that are fairly straightforward to do in R
> > but that are difficult or impossible to do in SAS or SPSS. However, it
> > has been so long since I have used either of those commercial products
> > that I am drawing a blank. I've searched the forums and web for a list
> > and came up with just Bob Muenchen's comparison of general procedures
> > and Patrick Burns' overview of the three. Neither of these give
> > concrete examples of statistical problems that are easily solved in R
> > but not the commercial packages.
> >
> > Can anyone more familiar with SAS or SPSS think of some examples of
> > problems that they couldn't do in one of those packages but that could
> > be done easily in R? Similarly, if there are any examples of the
> > converse I would also be interested to know.
> >
> > Best,
> >
> > Matt
> >
>
> Here is a simple thing that is easy to do in R or S-Plus but difficult
> in SAS or SPSS:
>
> Compute the number of subjects having age below the mean age
>
> sum(age < mean(age))
>
>
> Here is something not quite so simple that is very difficult to do in
> SPSS or SAS. Show descriptive statistics for every variable in a data
> frame that is numeric and has at least 10 unique values.
>
> v <- sapply(mydata, function(x) is.numeric(x) && length(unique(x)) >= 10)
> summary(mydata[v])
>
This can be simplified very slightly (creating mydata[v] directly
rather than creating a vector v and then subscripting with it)
using Filter:
is.ok <- function(x) is.numeric(x) & length(unique(x)) > 10
summary(Filter(is.ok, mydata))
More information about the R-help
mailing list