Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone)
You are trying to take the mean of data frames. There is no
"data.frame" method for mean().
Try:
by(hold,Arm,function(x){sapply(x,mean)})
BTW what's the point of "na.rm=TRUE" in your call? There are no missing
values in the data that you present.
In future, please use dput() to
When I run by, I get an error message and no results. Any help in understanding
what is wrong would be appreciated.
Error message:
Warning messages:
1: In mean.default(data[x, , drop = FALSE], ...) :
argument is not numeric or logical: returning NA
2: In mean.default(data[x, , drop = FALSE],
Rolf,
Thank you!
John
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore,
by(dataFrame, groupId, FUN) applies FUN a bunch of data.frames (row subsets
of the dataFrame input). mean() returns NA for data.frames. You could use
FUN=colMeans if you wanted column means or FUN=function(x)mean(colMeans(x))
or FUN=function(x)mean(unlist(x)) if you wanted some version of a
5 matches
Mail list logo