Here are two alternatives.  See ?"<<-"

testfct1 <- function() test[1] <<- 100

# following one can be written more compactly as
#   testfct2 <- function(test) replace(test, 1, 100)
testfct2 <- function(test) { test[1] <- 100; test }

# test
test <- 1:3; testfct1(); test
test <- 1:3; test <- testfct2(test); test

On 6/14/06, Sebastian Leuzinger <[EMAIL PROTECTED]> wrote:
> Dear list,
> My apologies if a solution / explanation to this already exists on the list,
> but it is difficult to assign it to a certain keyword.
>
> test<-c(1:3)
> testfct <- function(x) {test[1]<-100}
>  test
> [1] 1 2 3
>  testfct(1)
> [1] 1 2 3
>
> Basically, I would like to write data into an external table that the function
> does not know. Why is this not working / what alternatives exist?
>
> Thanks, Sebastian
>
> ------------------------------------------------
> Sebastian Leuzinger
> University of Basel, Department of Environmental Science
> Institute of Botany
> Schönbeinstr. 6 CH-4056 Basel
> ph    0041 (0) 61 2673511
> fax   0041 (0) 61 2673504
> email [EMAIL PROTECTED]
> web   http://pages.unibas.ch/botschoen/leuzinger
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to