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

______________________________________________
R-help@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.

Reply via email to