Answers for "how to use different scripts in one in R"

0

how to use different scripts in one in R

# This code is in scriptA.R
	setwd(dirname(rstudioapi::getActiveDocumentContext()$path)) # set the work directory
	# to the same file location that the r script is in.
	WD <- getwd() # get the current working directory

	print('this is script A')

	source(paste0(WD,"/scriptB.R")) # loads the functions from that file in this one

	LOG()

# This code is in scriptB.R
	LOG <- function(){
		print('this is script B')
	}

# Both .R files at the same directory
# The result is:
# this is script A
# this is script B
Posted by: Guest on January-03-2021

Code answers related to "how to use different scripts in one in R"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language