# Store the value 42 in the object my_number
my_number <- 42
# Print the value of my_number
my_number
[1] 42
Session 2–Coding in R
<-
<-
, and the data or value you wish to assign to the object is on the right+
addition-
subtraction*
multiplication/
division^
exponentiation (also **
)mean()
function to calculate the average of a set of numbersc()
to create a vector of numbersCreate a vector of numbers and take the mean…
mean()
calculates the mean of a set of numbersmedian()
calculates the median of a set of numberssd()
calculates the standard deviation of a set of numberssum()
calculates the sum of a set of numberslength()
calculates the length of a vectormax()
and min()
calculate the maximum and minimum values of a vectorround()
rounds a number to a specified number of decimal placessqrt()
calculates the square root of a numberlog()
calculates the natural logarithm of a numberexp()
calculates the exponential of a numberabs()
calculates the absolute value of a number03:00
read_csv()
is a functionggplot()
is a functionreadr
is a package that contains the read_csv()
functionggplot2
is a package that contains the ggplot()
functioninstall.packages()
to install packageslibrary()
to load packagesinstall.packages("tidyverse")
devtools
install.packages("devtools")
vdemdata
devtools::install_github("vdeminstitute/vdemdata")
leaflet
install.packages("leaflet")
quarto install tinytex
03:00
ggplot2
for data visualizationreadr
for reading datadplyr
for data manipulationtidyr
for data tidyinglibrary(ggplot2)
library(tidyverse)
false
02:00
02:00