[R] implementing Grubbs outlier test on a large dataframe
dwinsemius at comcast.net
Sun Feb 15 00:17:46 CET 2009
Sending each row of a datatframe, dfm, as a vector to a function,
fcn, is as simple as;
apply(dfm, 1, fcn)
> dfm <- data.frame(x=rnorm(10), y=rnorm(10), z=rnorm(10))
> apply(dfm, 1, sum)
 0.7385838 -3.1819193 0.3415670 -0.6552601 -1.3470174
 0.1778169 -0.3330527 0.6246071
And with the second argument set to 2, you would get a columnwise
application of the function.
You need to show us what your function looks like to go any further. I
am unclear how one could get a function that only operates on a single
row to yield an outlier classification.
On Feb 14, 2009, at 6:01 PM, John Malone wrote:
> I'm trying to implement an outlier test once/row in a large dataframe.
> Ideally, I'd do this then add the Pvalue results and the number
> flagged as
> an outlier as two new separate columns to the dataframe. Grubbs
> test requires a vector and I'm confused how to make each row of my
> a vector, followed by doing a Grubbs test for each row containing
> the vector
> of numbers I want to perform the outlier test on.
> I'm new to R and no doubt this is a simple problem. Any help you might
> provide would be greatly appreciated.
> Many thanks in advance!!
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help