Hi I have a list called g as follows and I want to  make elements of g into
functions so that I can evaluate them at randomly generated data point say
c(0,0,0). For example,

change  g[[1]]  (!x[2] & !x[3]) | (!x[2] & x[3]) | (x[2] & x[3]) to
function(x) (!x[2] & !x[3]) | (!x[2] & x[3]) | (x[2] & x[3])

change g[[2]]  (!x[2] & !x[1]) | (!x[2] & x[1]) | (x[2] & !x[1]) to
function(x) (!x[2] & !x[1]) | (!x[2] & x[1]) | (x[2] & !x[1])

and so on......

So that I  can evaluate g[[1]] as follows g1<-function(x) (!x[2] & !x[3]) |
(!x[2] & x[3]) | (x[2] & x[3])

> g1(c(0,0,0))
[1] TRUE

g<-list(structure("(!x[2] & !x[3]) | (!x[2] & x[3]) | (x[2] & x[3])", class
= "noquote"),
        structure("(!x[2] & !x[1]) | (!x[2] & x[1]) | (x[2] & !x[1])",
class = "noquote"),
        structure("(!x[2] & x[3]) | (x[2] & !x[3])", class = "noquote"))

g
[[1]]
[1] (!x[2] & !x[3]) | (!x[2] & x[3]) | (x[2] & x[3])

[[2]]
[1] (!x[2] & !x[1]) | (!x[2] & x[1]) | (x[2] & !x[1])

[[3]]
[1] (!x[2] & x[3]) | (x[2] & !x[3])

Do not know how proceed. Any help is appreciated. I have created a small
example for demo. My actual list g has 50 elements so need a function which
can pick each element of g and convert it into function (x)......

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to