Creating a New Script

hello.R script

# Print text
print("Hello World") 

# Generate sequence
seq(0, 100, by = 10) # Create a sequence of numbers


Running entire script from console using source()

# Run script using source() function
source("code/hello.R")

OutputCars.R

# Assign mtcars data to variable
cars <- mtcars

# Write data to file
write.csv(cars, "outputs/cars.csv")