On Thu, Nov 20, 2008 at 10:04 AM, Dieter Menne
<[EMAIL PROTECTED]> wrote:
> hadley wickham gmail.com> writes:
>
>> > library(plyr)
>> > dat = data.frame(SUBJECT_ID=sample(letters[1:5],100,TRUE),HR=rnorm(100))
>> > daply(dat,.(SUBJECT_ID),sd)
>> > ddply(dat,.(SUBJECT_ID),sd)
>>
>> Well that calcula
hadley wickham gmail.com> writes:
> > library(plyr)
> > dat = data.frame(SUBJECT_ID=sample(letters[1:5],100,TRUE),HR=rnorm(100))
> > daply(dat,.(SUBJECT_ID),sd)
> > ddply(dat,.(SUBJECT_ID),sd)
>
> Well that calculates sd on the whole data frame. (Like sd(dat)).
Not really, it looks like the b
On Thu, Nov 20, 2008 at 2:20 AM, Dieter Menne
<[EMAIL PROTECTED]> wrote:
> pufftissue pufftissue gmail.com> writes:
>
>>
>> What I am getting is indeed:
>>
>> 7200 23955345638934
>> 16.39977 10.0389611.234 14.02
>>
>> I'd like the final output to be:
>>
>> subject
What about aggregate.
with(dat, aggregate(HR, list(sub_id=SUBJECT_ID), sd))
shall result in required final output form.
Regards
Petr
[EMAIL PROTECTED] napsal dne 20.11.2008 09:20:36:
> pufftissue pufftissue gmail.com> writes:
>
> >
> > What I am getting is indeed:
> >
> > 7200 23
pufftissue pufftissue gmail.com> writes:
>
> What I am getting is indeed:
>
> 7200 23955345638934
> 16.39977 10.0389611.234 14.02
>
> I'd like the final output to be:
>
> subject_id hr_Stand_Deviation
> 7200 16.39977
> 23955
Thank you for your help!
It works beautifully, but how would I transpose the results?
What I am getting is indeed:
7200 23955345638934
16.39977 10.0389611.234 14.02
I'd like the final output to be:
subject_id hr_Stand_Deviation
7200 16.
How about:
with(dat, tapply(HR, SUBJECT_ID, sd))
Assuming your data frame is named dat.
On Wed, 2008-11-19 at 23:59 -0500, pufftissue pufftissue wrote:
> *Hi all,
>
> I know this is probably basic, but I have proven to be a slow learner in any
> programming language. Anyhow,
> how can I calcu
Dear pufftissue,
If your data set is a data.frame called 'x', one approach could be:
# Data set
x=read.table('clipboard',header=TRUE)
# Calculations
tapply(x$HR,x$SUBJECT_ID,sd,na.rm=TRUE)
720023955
16.39977 10.03896
See ?tapply and/or ?ave for more information.
HTH,
Jorge
On Wed, N
*Hi all,
I know this is probably basic, but I have proven to be a slow learner in any
programming language. Anyhow,
how can I calculate the SD for each person in my table? I have two patients
in this R data.frame, 7200 and 23955.
I extracted this from a relational database, but am I better off
9 matches
Mail list logo