[R] data.frame - how to calculate the number of rows
Agrarimmobilien
ralf.pfeiffer at agrarimmobilien.info
Thu Dec 27 11:53:29 CET 2007
now it works again,
length gave the same resultat as 'numrows'=as.numeric(table(df$A)))
thanks for your help
Macki
----- Original Message -----
From: "Henrique Dallazuanna" <wwwhsd at gmail.com>
To: "Agrarimmobilien" <ralf.pfeiffer at agrarimmobilien.info>
Cc: <r-help at r-project.org>
Sent: Thursday, December 27, 2007 11:16 AM
Subject: Re: [R] data.frame - how to calculate the number of rows
Try this:
summaryBy(B+C~ A+D, data=daten,FUN=c(mean, var, length))
On 26/12/2007, Agrarimmobilien <ralf.pfeiffer at agrarimmobilien.info> wrote:
> this works now,
>
> cbind(summaryBy(B+C~ A, data=df, FUN=c(mean, var)),
> 'numrows'=as.numeric(table(df$A)))
>
>
> but now, I cannot add another column D beside A, as I do before, like
>
> cbind(summaryBy(B+C~ A+D, data=df,FUN=c(mean, var)),
> 'numrows'=as.numeric(table(df$A)))
>
> because of this D, I got the following error message in german:
> <<Fehler in data.frame(..., check.names = FALSE) : Argumente implizieren
> unterschiedliche Anzahl Zeilen: 21, 18>>
>
> <<error in data.frame(...., check.names = FALSE): arguments has differents
> counts of rows: 21, 18>>
>
> has anybody an idea, what I can do ?
>
>
>
>
> On 26/12/2007, Agrarimmobilien <ralf.pfeiffer at agrarimmobilien.info> wrote:
> > Hello,
> >
> > I had to give some more information to my posting:
> >
> > as ouput there are more than one row, depending on the values of column
> > A
> > (transformierung to distinct values, here 3 and 4, but there are much
> > more)
> >
> > > A B C
> > > 1 3 6 5
> > > 2 3 4 20
> > > 3 3 8 2
> > > 4 4 8 3
> > > 5 4 2 6
> >
> > Output:
> >
> > > A B C num rows
> > > 1 3 6 6.16 3
> > > 2 4 5 4.00 3
> >
> >
> > B is mean and C variance.
> >
> >
> > thank you
> > Macki
> >
> >
> >
> > > Hello,
> > >
> > > it seems to be a simple problem, but I couldn't find an answer in the
> > > archiv. (I think, it must has something to do with the group-select,
> > > like
> > > in
> > > php)
> > >
> > > I've the following data.frame:
> > >
> > > A B C
> > > 1 3 6 5
> > > 2 4 4 20
> > > 3 5 8 2
> > >
> > > I want to get the number of the rows in the 4th column, like:
> > >
> > > A B C num rows
> > > 1 3 6 6.16 3
> > >
> > >
> > > (B is mean, C is variance by using summaryBy(B+C~ A, data=daten,
> > > FUN=c(mean,var)) from the doBy-package)
> > >
> > > But, how can I add the column 'numrow' and count the number of the
> > > rows?
> > >
> > > Thanks!
> > >
> > > Macki
> > >
> > > ______________________________________________
> > > 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.
> > >
> >
> > ______________________________________________
> > 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.
> >
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>
> ______________________________________________
> 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.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
More information about the R-help
mailing list