Try this:
transform(testDF, value = as.numeric(paste(round(abs(x)),
round(abs(y)), sep = ".")))
On Wed, Sep 16, 2009 at 3:22 PM, Jon Loehrke wrote:
> Greetings,
>
> I am attempting to run a function, which produces a vector and
> requires two input variables, across two nested factor levels. I
Hi Jon,
Here is a suggestion:
foo <- function(x) as.numeric( paste( abs( round( x ) ), collapse = "." ) )
testDF$value <- apply( testDF[,1:2], 1, foo )
testDF
HTH,
Jorge
On Wed, Sep 16, 2009 at 3:22 PM, Jon Loehrke wrote:
> Greetings,
>
> I am attempting to run a function, which produces a ve
One correction below,
---snip---
> >
> > # example data frame
> > testDF<-data.frame(
> > x=rnorm(12),
> > y=rnorm(12),
> > f1=gl(3,4),
> > f2=gl(2,2,12))
> >
>
> Try this using lapply, split, mapply? Maybe it is in a nicer output
> object for you?
>
> testFun2 <- function(x,
Hello,
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Jon Loehrke
> Sent: Wednesday, September 16, 2009 2:23 PM
> To: r-help@r-project.org
> Subject: [R] apply function across two variables by mult fact
Greetings,
I am attempting to run a function, which produces a vector and
requires two input variables, across two nested factor levels. I can
do this using by(X, list(factor1, factor2), function), however I
haven't found a simple way to extract the list output into an
organized vector fo
5 matches
Mail list logo