[R] Table of basic descriptive statistics like SPSS

Philippe Grosjean phgrosjean at sciviews.org
Tue Mar 18 09:53:10 CET 2008


Jim Lemon wrote:
> ukoenig at med.uni-marburg.de wrote:
>> Dear list readers,
>> I want to:
>>
>> 1. Get a table of basic descriptive statistics for my variables
>> with the variable names one below the other
>> like SPSS descriptive statistics:
>>
>> Varname N Min Max Mean SD
>> xxxx    x  x  x    x   x
>> xxx     x  x  x    x   x
>> ....
>>
> This looks very much like the output of the "describe" function in the 
> prettyR package. You can specify which summary stats you want (even roll 
> your own).

And if that's not enough:

library(pastecs)
data(trees)
t(stat.desc(trees))
?stat.desc

>> 2. Delete some variables from a data frame or exclude variables
>> from beeing analyzed.

df2 <- df[ , -c(1, 3), drop = FALSE]

for instance to eliminate variables in columns 1 and 3, but there are 
many other ways to select variables to use in an analysis, beginning 
with the formula interface, see,  e.g., ?lm.

>> 3. Create a text file / redirect the terminal output to a
>> file (it is supposed to be easy, but I could not find a solution)?
>>
> sink("myoutputfile.txt")
> do.your.stuff(...)
> sink()
> OR
> maybe you would enjoy "htmlize" or "R2html" in the prettyR package.

... or the R2html package!

>> 4. Create a latex/dvi file
>>
> You do this with Sweave, I think.

See also functions in the Hmisc package.

>> 5. Create a PDF file (can that be done within R?)
>>
> For plots, the pdf device.

See ?pdf

Please, note first search commands:

apropos("pdf")
RSiteSearch("latex")

Using these, you would have found by yourself the various corresponding 
functions.

Philippe

> Jim
> 
> ______________________________________________
> 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.
>



More information about the R-help mailing list