Environment expansion in R -


i have problem don't know how solve. prehistory: use r.net calculation (need wpf application). so, want parallelize app, , created dynamic proxy rengine class. needs serialize data pass , receive data from-to rengine instance via tcp. bad news - r.net classes cannot serialized. so, have idea serialize r objects in r , pass r serialized data between processes.

so have same script this:

a <- 5; b <- 10; x <- a+b; 

i need wrap this:

wrapfunction <- function() {     <- 5;     b <- 10;     x <- a+b; }  serializedresult <- serialize(wrapfunction()); 

i'll serializedresult , pass byte array. need pass environments. won't a, b, x in .globalenv after these manipulations. how possible variables, defined in function body, in .globalenv? don't know names , count, can't rewrite basic script, replacing "<-" "<<-". other ways?

thank you.

i'm not sure understand requirements. seem go against functional language paradigm, r tries follow. following might helpful or not:

e <- new.env() wrapfunction <- function(){   with(e, {          <- 5;          b <- 10;          x <- a+b;           }) }  wrapfunction() e$a #[1] 5 

you can of course use .globalenv instead of e, @ least in r considered worse practice.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -