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)
    7200    23955
16.39977 10.03896

See ?tapply and/or ?ave for more information.

HTH,

Jorge


On Wed, Nov 19, 2008 at 11:59 PM, pufftissue pufftissue <
[EMAIL PROTECTED]> 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 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 attempting
> to compute SD in SQL, or is this easily accomplished in R?
>
>
> *      SUBJECT_ID  HR
> 1        7200 158
> 2        7200 165
> 3        7200 138
> 4        7200 152
> 5        7200 139
> 6        7200 157
> 7        7200 186
> 8       23955 167
> 9       23955 162
> 10      23955 171
> 11      23955 139
> 12      23955 170
> 13      23955 177
> 14      23955 180
> 15      23955 176
> 16      23955 172
> 17      23955 179
> 18      23955 181
> 19      23955 169
> 20      23955 168
> 21      23955 185
> 22      23955 181
> 23      23955 191
> 24      23955 179
> 25      23955 178
> 26      23955 184
> 27      23955 179
> 28      23955 172
> 29      23955 173
> 30      23955 182
> 31      23955 174
>
> *
> So, what I would want is a table of 800 patients with a SD for their heart
> rates:
>
> subject id       Heart Rate SD
>
> 7200              20 (for example)
> 23955           18 (for example)*
>
> Thank you!
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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]]

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

Reply via email to