[R] should I use rbind in my example?
David Freedman
3.14david at gmail.com
Wed Jan 21 20:16:53 CET 2009
Are you sure that you want to loop over variables for each subset, and do
this within each subset? A simple way to generate summary statistics
(across variables and within categories) is the summaryBy function in the
doBy package:
d=data.frame(wt=rnorm(100,100,10),ht=rnorm(100,2,1),sex=gl(2,1,100))
library(doBy)
summaryBy(wt+ht~sex,da=d,FUN=c(mean,sd))
David Freedman
SNN wrote:
>
>
> Hi,
>
> This is just for print out so it looks nice. what I have is a loop that
> loops over my variables and calculates the mean and the sd for these
> variables. Then I need to rbind them so I can stack them up in one file.
> the problem is that only the fist header appears and the rest do not. this
> is because I used rbind.
>
> I am new into R , can you tell me how you put them in a 'list'?.
>
> Thanks
>
>
>
>
> jholtman wrote:
>>
>> What do you want to do with it? Is this just for printing out? What
>> other types of transformations are you intending to do? Why not just
>> put them in a 'list' and then write your own specialized print
>> routine.
>>
>> On Wed, Jan 21, 2009 at 10:30 AM, SNN <s.nancy1 at yahoo.com> wrote:
>>>
>>> Hi,
>>>
>>> I need to rbind two data frames. Each one has a header . after the rbind
>>> I
>>> would like to keep the header for each and have the two data frames
>>> separated by a line. Is this possible to do in R?
>>>
>>> For example
>>>
>>> weight_mean weight_sd.dev
>>>> F 14.33333 4.932883
>>>> M 34.66667 10.692677
>>>>
>>>> hight_mean hight_sd.dev
>>>> F 35.00000 7.071068
>>>> M 34.66667 10.692677
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/should-I-use-rbind-in-my-example--tp21585464p21585464.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> ______________________________________________
>>> 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.
>>>
>>
>>
>>
>> --
>> Jim Holtman
>> Cincinnati, OH
>> +1 513 646 9390
>>
>> What is the problem that you are trying to solve?
>>
>> ______________________________________________
>> 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.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/should-I-use-rbind-in-my-example--tp21585464p21590200.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list