f <- function(x,p) { f <- x^p } # use source("/your/current/directory/powerfun.R") to get the code # then f() to use the code in the R session