Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mollietaylor
Created January 7, 2013 03:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mollietaylor/4472146 to your computer and use it in GitHub Desktop.
Save mollietaylor/4472146 to your computer and use it in GitHub Desktop.
Storing a Function in a Separate File in R
# calling the functions
# this is the file where we will call the functions in fun.R and times.R
times <- dget("times.R")
times(-4:4, 2)
source("fun.R")
mult(-4:4, 2)
# defining the function
mult <- function(x, y) {
x*y
}
# defining the function
function(x, y) {
x*y
}
@robvanmechelen
Copy link

thanks you very much cristal clear!

@rjkhan
Copy link

rjkhan commented Oct 1, 2017

i have a seperate file in package which stores a function when i used a source in inlcude in another file file of same package it is not working and give me an error on travis ???
anyone please help me out?
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment