[R] write data from function into external table

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Wed Jun 14 13:01:27 CEST 2006


What is your desired output ? This will clarify the problem greatly.

Perhaps, this might be of some use :

 f <- function(v, pos, val=100){  v[pos] <- val; return(v)  }

 test <- 1:3
 test <- f(test, 1)
 test
 [1] 100  2  3

Regards, ADai



On Wed, 2006-06-14 at 12:41 +0200, Sebastian Leuzinger 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 Sebastian.Leuzinger at unibas.ch 
> web   http://pages.unibas.ch/botschoen/leuzinger
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



More information about the R-help mailing list