hi I'm making some program and it need to be hidden. it's not commercial purpose but it is educational, so i do want to hide the code of function. for example, if i made following function: a<-function(x){ y<-x^2 print(y) } i do not want someone to type "a" and take the code of the function. is there anyone who can help me? -- View this message in context: http://r.789695.n4.nabble.com/how-to-hide-code-of-any-function-tp4474822p4474822.html Sent from the R help mailing list archive at Nabble.com.
On 15/03/2012 8:53 AM, mrzung wrote:> hi > > I'm making some program and it need to be hidden. > > it's not commercial purpose but it is educational, > > so i do want to hide the code of function. > > for example, > > if i made following function: > > a<-function(x){ > y<-x^2 > print(y) > } > > i do not want someone to type "a" and take the code of the function. > > is there anyone who can help me?R has no explicit support for that. If your function is written in R code, it won't be hard to find the source. So you could write your function in C and not distribute the source (assuming all of your users are on one platform), or you could write obscurely so that it's not obvious what you are doing, e.g. a <- function(x) { eval(parse(text=somestring)) } environment(a) <- new.env() environment(a)$somestring <- "y <- x^2; print(y)" However, this won't slow down anyone who knows about the debug() function. Duncan Murdoch
See the 'petals' function in the TeachingDemos package for one example of hiding source from casual inspection (intermediate level R users will still easily be able to figure out what the key code is, but will not be able to claim that they stumbled across it on accident). This post gives another possibility: https://stat.ethz.ch/pipermail/r-devel/2011-October/062236.html On Thu, Mar 15, 2012 at 6:53 AM, mrzung <mrzung46 at gmail.com> wrote:> hi > > I'm making some program and it need to be hidden. > > it's not commercial purpose but it is educational, > > so i do want to hide the code of function. > > for example, > > if i made following function: > > a<-function(x){ > y<-x^2 > print(y) > } > > i do not want someone to type "a" and take the code of the function. > > is there anyone who can help me? > > > -- > View this message in context: http://r.789695.n4.nabble.com/how-to-hide-code-of-any-function-tp4474822p4474822.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.-- Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com