#Addition of three numbers
1+1+1
## [1] 3
#Subtraction of one number from another
2-1
## [1] 1
#Two numbers multiplied together
2*2
## [1] 4
#Division of one number from another
2/1
## [1] 2
#Taking one number to the fourth power
2^4
## [1] 16
#Finding the third root of a number
(64)^(1/3)
## [1] 4
#Log to the base ten of two
log(2,10)
## [1] 0.30103
#Created a vector of six numbers
c <- c(4,5,6,7,8,9)
#Printing the third element
c[3]
## [1] 6
#Finding the length of vector "c"
length(c)
## [1] 6
#Creating a matrix
d <- matrix(c(1,3,5,7,2,4,6,8), nrow=2, byrow = TRUE)
#Assigning "f" to the addition of five and "d"
f <- d-5
#Printing "f"
f
## [,1] [,2] [,3] [,4]
## [1,] -4 -2 0 2
## [2,] -3 -1 1 3
#Printing the dimensions of "f"
dim(f)
## [1] 2 4
#Assigning an opertor to a value
k <- 5.25
#Assigning an opertor to a character
m <- 'frank'
#Determining data type
class(k)
## [1] "numeric"
#Determining data type
class(m)
## [1] "character"
#Converting to an integer
p <- as.integer(k)
#Printing "k"
p
## [1] 5
#Converting to a character
g <- as.character(k)
# 5.1 could not be added to "g" because I convert the orginal "k"(which was 5.25) to be read as a character not a number. 5.1 plus "g" results in an error.
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE
parameter was added to the code chunk to prevent printing of the R code that generated the plot.