[R] Create function from string

2013-04-16 Thread Jon Olav Skoien
Dear list, I am trying to create a function from a string, and have so far solved it with eval(parse()). This works well also when using the newly created function as an argument to another function. The trouble starts when I want to use it with parLapply. Below is a much simplified example:

Re: [R] Create function from string

2013-04-16 Thread peter dalgaard
Is this what you are looking for? FUN = eval(bquote(function(x) .(parse(text = fstring)[[1]]))) FUN function (x) x + 2 FUN(3) [1] 5 On Apr 16, 2013, at 09:50 , Jon Olav Skoien wrote: Dear list, I am trying to create a function from a string, and have so far solved it with

Re: [R] Create function from string

2013-04-16 Thread Jon Olav Skoien
Thanks a lot, that seems to do exactly what I need! Best wishes, Jon On 16-Apr-13 10:21, peter dalgaard wrote: Is this what you are looking for? FUN = eval(bquote(function(x) .(parse(text = fstring)[[1]]))) FUN function (x) x + 2 FUN(3) [1] 5 On Apr 16, 2013, at 09:50 , Jon Olav Skoien