[R] things that are difficult/impossible to do in SAS or SPSS but simple in R

Charles C. Berry cberry at tajo.ucsd.edu
Wed Jan 16 01:35:37 CET 2008

On Tue, 15 Jan 2008, Roland Rau wrote:

> Hi,
> maybe I missed something while using SAS or SPSS. So please make sure
> that I am not talking nonsense here.
> - How would you re-use results in SPSS or SAS? If it is possible for SAS
> and SPSS, I am fairly sure it is not as easy as in R:
> lmmodel1 <- lm(Y~X)
> myslope <- coef(lmmodel1)[2]

taking off on the 're-use' idea here is a simple, instructive graphic:

  iris.cluster <- hclust( dist( iris[,-5]) )
  plot( iris[,-5], col=cutree( iris.cluster, k=4))

and here we can see if the clustering and choice of 4 clusters was 

   table( iris[,5], cutree( iris.cluster, k=4 ))

Can SAS/SPSS do this easily?

One of the things that makes R/S nice is the existence of sensible methods 
for plot, summary, and so on.


> - You have population and death data on the individual level classified
> by year, age, sex, and country. Now you want to calculate the
> probability of dying by year, age, sex, and country.
> In R, i would do:
> pop.array <- tapply(X=popdata$Count,
> 			INDEX=list(Age=popdata$Age,
> 				Year=popdata$Year,
> 				Sex=popdata$Sex,
> 				Country=popdata$Country),
> 			FUN=sum)
> dth.array <- tapply(X=dthdata$Count,
> 			INDEX=list(Age=dthdata$Age,
> 				Year=dthdata$Year,
> 				Sex=dthdata$Sex,
> 				Country=dthdata$Country),
> 			FUN=sum)
> prop.dying.array <- dth.array / pop.array
> Now you can easily extract a vector of the probability of dying of 85
> year-old men dying in the first year of observation in all countries by
> writing:
> prop.dying.array[86,1,1,]
> - I hope I am wrong on this one. But when I was using SPSS, I could not
> find any possibility to include left truncated data in survival
> analysis. Maybe I did not find this possibility or maybe it has been
> included since.
> - The function outer()
> - Data are not always rectangular data frames.
> Those are just a few thoughts which came to my mind.
> I hope this helps,
> Roland
> 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
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

More information about the R-help mailing list