Dear Gerit,
Here is a start using a data set which first column is numeric and the rest
are factors 'f1', 'f2',....,'f1381' (I'm using only 3):

# Data set
x <- c(1,4,2,6,8,3,4,2,4,5,1,3)
y <- as.factor(c(2,2,1,1,1,2,2,1,1,2,1,2))
z <- as.factor(c(1,2,2,1,1,2,2,3,3,3,3,3))
mydata=data.frame(x,y,z)
mydata

# Function
foo=function(FACTOR) do.call(rbind,tapply(x,FACTOR,function(w)
c(summary(w),SD=sd(w))))

# Calculations
res=apply(mydata[,-1],2,foo)
res2=do.call(rbind,res)
rnames=rownames(res2)
rownames(res2)<-NULL

# Output
final=data.frame(Factor=rep(names(res),lapply(res,function(x)
nrow(x))),Levels=rnames,res2)
colnames(final)=c('Factor','Level',c('Min.','1st.Qu.','Median','Mean','3rd.Qu.','Max.','SD'))
final

See ?tapply and ?do.call for details.

HTH,

Jorge



On Thu, Nov 20, 2008 at 9:16 AM, Gerit Offermann <gerit.offermann@gmx.de>wrote:

> Dear list,
>
> I reduced my data to the following:
>
> x <- c(1,4,2,6,8,3,4,2,4,5,1,3)
> y <- as.factor(c(2,2,1,1,1,2,2,1,1,2,1,2))
> z <- as.factor(c(1,2,2,1,1,2,2,3,3,3,3,3))
>
> I can produce the statistical summary just fine.
> s1 <- tapply(x, y, summary)
> d1 <- tapply(x, y, sd)
> s2 <- tapply(x, z, summary)
> d2 <- tapply(x, z, sd)
>
> First thing:
> I have 100 plus factors to analyse. Theirs names are f1001 to f1381
> (about).
> Is there a way to avoid having to write these lines 100 plus times?
>
> Second thing:
> How can I put the standard deviation and the summary statistics into one
> output?
>
> Third thing:
> In the end I want to write the summary statistics into a data base
> (Access). It would be fantastic if I could achieve a table such as:
>
> factor  level  Min. 1st Qu.  Median    Mean 3rd Qu.    Max.   SDev.
> y         1   1.000   2.000   3.000   3.833   5.500   8.000  2.714160
> y         2   1.000   3.000   3.500   3.333   4.000   5.000  1.366260
> z         1   1.0       3.5       6.0      5.0       7.0      8.0
> 3.6055513
> .
> .
> .
>
> I tried to unlist the matrices, but it did not help much.
> it <- NULL # "it" - Iterationen
>
> for (i in 1:nlevels(z)){
>     it[[i]] <- unlist(s1[[i]])}
>
>
> Help to any of the three points is greatly appreciated.
>
> Cheers,
> Gerit
> --
>
> ______________________________________________
> R-help@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.
>

	[[alternative HTML version deleted]]

