[R] Problem using the source-function within R-functions

Giovanni Petris GPetris at uark.edu
Tue Oct 20 18:59:00 CEST 2009


The problem probably lies in the source-ing part: look at

getwd()
setwd()

HTH,
Giovanni

> Date: Tue, 20 Oct 2009 13:00:02 +0200
> From: Johan Lassen <jlenvi at gmail.com>
> Sender: r-help-bounces at r-project.org
> Precedence: list
> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
> DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
> 
> --===============0554064772==
> Content-Type: text/plain
> Content-Disposition: inline
> Content-Transfer-Encoding: quoted-printable
> Content-length: 1477
> 
> Dear R community,
> 
> You may have the solution to how to construct a function using the function
> "source()" to build the function; i.e.
> 
> myfunction <- function(...){
> source('file1.r')
> source('file2.r')
> }
> 
> After compiling and installing the "myfunction" in R, then calling the
> "myfunction" gives an error because the content of 'file1.r' and 'file2.r'
> seems to be missing.
> 
> Anyone has the trick to overcome this problem?
> 
> Thanks in advance!
> 
> best wishes, Johan
> 
> 
> PS: My function is:
> 
> 
> run_accumm_value <- function(ind_noder_0,
> ind_loc_val,ind_retention,downstream){
> ## Preprocessing of looping calculations:
> koersel_uden_ret <- length(unique(ind_noder_0$oplid))
> opsaml_b_0_2 <- numeric(koersel_uden_ret)
> opsaml_b_0_2_1 <- numeric(koersel_uden_ret)
> opsaml_b_0_2_2 <- seq(1:koersel_uden_ret)
> ## Preprocessing of topology and local values to be summed:
> source('preproces_topology.r', local =3D T)
> source('preproces_loc_val.r', local =3D T)
> # Loop for each grouping factor (column in ind_noder_0: "oplid"):
> for(j in 1:koersel_uden_ret){
> source('matrix_0.r', local =3D T)
> source('matrix.r', local =3D T)
> source('local_value.r', local =3D T)
> source('fordeling.r', local =3D T)
> source('fordeling_manuel.r', local =3D T)
> source('local_ret.r', local =3D T)
> source('Ax=3Db.r', local =3D T)
> source('opsamling_x_0_acc.r', local =3D T)
> }
> source('opsamling_b_1.r', local =3D T)
> opsaml_b_2
> }
> 
> 
> 
> 
> 
> --=20
> Johan Lassen
> Environment Center Nyk=F8bing F
> Denmark
> 
> 	[[alternative HTML version deleted]]
> 
> 
> --===============0554064772==
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> --===============0554064772==--
> 
> 

-- 

Giovanni Petris  <GPetris at uark.edu>
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/




More information about the R-help mailing list