Running code in R is easy (if copy/paste). Our motive here is not to teach you R. However, you’ll catch with basic R code in no-time.
- First, make sure you’ve installed R .
- Then, search and open R.
- Copy the code below and run it in your R console
Run the code below:
# printing
print("Hello World")
#assignment
a <- 10
b <- 15
#add
a + b
#add + assign
c <- a + b
# print 1 to 100
1:10
# sum from 1 to 100
sum(1:100)
# mean / average
mean(c(10, 15, 20, 25))
# median / central value
median(c(5, 10, 15, 25, 30))
# function
addition <- function(x, y){ x + y }
# calling function
addition(10, 15)