# [R] A comment about R:

TEMPL Matthias Matthias.Templ at statistik.gv.at
Wed Jan 4 09:47:59 CET 2006

```Hello,

One additional example how easy are simple calculations in R.

Calculate the mean of data htinches, multiply it with 2.54 and round the result:

In R:
round( 2.54 * mean( htinches ) )

In SAS could this be done in 2 data steps and 2 proc steps:
DATA new; SET old;
htcm = htinches * 2.54;
PROC means; VAR htcm;
output out=new2 mean=htcm;
DATA new2; set new2;
htcm=round(htcm);
PROC fsview; run;

(you can do this also in one data step, but the code would be longer and more(!) cryptic (or say horrible).
And, of course, you can do this with the help of SAS´s SQL approach, but note that the syntax
is different (!) (comma´s,...) as the "normal" syntax in a data step.)

--> useR!

Matthias

> Patrick Burns <pburns at pburns.seanet.com> writes:
>
> > I have had an email conversation with the author of the technical
> > report from which the quote was taken.  I am formulating a
> comment to
> > the report that will be posted with the technical report.
> >
> > I would be pleased if this thread continued, so I will know better
> > what I want to say.  Plus I should be able to reference
> > the comment.
>
> One thing that is often overlooked, and hasn't yet been
> mentioned in the thread, is how much *simpler* R can be for
> certain completely basic tasks of practical or pedagogical
> relevance: Calculate a simple derived statistic, confidence
> intervals from estimate and SE, percentage points of the
> binomial distribution - using dbinom or from the formula,
> take the sum of each of 10 random samples from a set of
> numbers, etc. This is where other packages get stuck in the
> procedure+dataset mindset.
>
> For much the same reason, those packages make you tend to
> treat practical data analysis as something distinct from
> theoretical understanding of the methods: You just don't use
> SAS or SPSS or Stata to illustrate the concept of a random
> sample by setting up a small simulation study as the first
> thing you do in a statistics class, whereas you could quite
> conceivably do it in R. (What *is* the equivalent of
> rnorm(25) in those languages, actually?)
>
> Even when using SAS in teaching, I sometimes fire up R just
> to calculate simple things like
>
>   pbar <- (p1+p2)/2
>   sqrt(pbar*(1-pbar))
>
> which you need to cheat SAS Analyst's sample size calculator
> to work with proportions rather than means. SAS leaves you no
> way to do this short of setting up a new data set. The
> Windows calculator will do it, of course, but the students
> can't see what you are doing then.
>
>
> --
>    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark          Ph:
> (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX:
> (+45) 35327907
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help