Hi everyone,
i'm having a problem extracting objects out of functions i've created, so i
can use them for further analysis. Here's a small example:
# ---
test <- function(i, j){
x <- i:j
y <- i*j
z <- i/j
return(x,y,z)
}
# -
test$x doesn't evaluate the function, you want something like test(1,2)$x, e.g.:
test <- function(i, j){
x <- i:j
y <- i*j
z <- i/j
return(list(x=x,y=y,z=z))
}
test(1,2)$x
[1] 1 2
test(1,2)$y
[1] 2
test(1,2)$z
[1] 0.5
Or if you want to avoid evaluating y
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Stropharia
> Sent: Monday, October 12, 2009 4:07 PM
> To: r-help@r-project.org
> Subject: [R] Re use objects from within a custom made function
>
>
Thanks a lot Tony and Daniel for making that clear.
best,
Steve
Stropharia wrote:
>
> Hi everyone,
>
> i'm having a problem extracting objects out of functions i've created, so
> i can use them for further analysis. Here's a small example:
>
> # ---
> test <- functi
On Oct 12, 2009, at 7:06 PM, Stropharia wrote:
Hi everyone,
i'm having a problem extracting objects out of functions i've
created, so i
can use them for further analysis. Here's a small example:
# ---
test <- function(i, j){
x <- i:j
y <- i*j
5 matches
Mail list logo