1/31
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
arithmetic symbols
+, -, *, /, ^
pi and e
pi, exp(
scientific notation
e+, e-
variable
v <-
display the value of a variable as an output on the screen
print(
load data from a file
data_frame <- read.csv(file = ‘‘, header = TRUE/FALSE)
see the names of the variables and the first few rows of values
head(data_frame)
set the number of digits that R outputs
options(digits=
calculate the mean and ignore missing values
mean(data_frame, na.rm=TRUE)
calculate the median
median(
calculate the variance
var(
calculate the standard deviation
sd(
calculate the range as a value
diff(range(data_frame, na.rm=TRUE))
calculate the mean of the first 30 individuals
mean(data_frame[1:30])
make a histogram
hist(data_frame, main = “”, xlab = ““)
make a boxplot
boxplot(data_frame, main = ““, ylab = ““)
make two boxplots together
boxplot(data_frame1, data_frame2, main = ‘‘, ylab = ‘‘, names = c(‘‘,’’), at = 1:2)
make a box plot showing categorical variables
boxplot(y ~ x, data = data_frame, main = ””, ylab = ““)
assign a vector to a variable
v←c(
display the index for the first number of a vector
print(vec[1])
generate a vector with integers 1 to 20
vec <-1:20
generate a vector with values 1 to 20 with a step of 0.5
vec <- seq(1, 20, 0.5)
generate a vector with ten zeroes
v <- rep(0,10)
print the vector indices 2 and 5
print(vec[c(2,5)])
print the vector indices 2 to 5
print(vec[2:5])
print all vector indices except 2 to 5
print(vec[-(2:5)])
print a vector from 1 to 20 with only its odd indices
print(vec[seq(1,20,2)])
plot a scatter plot
plot(x-vector, y-vector, main = ““)
plot a function (continuous line)
plot(x-vector, y-vector, main = ‘‘, type = ‘l’, xlab= ‘‘, ylab = ‘‘, xlim = c(x1, x2), ylim = c(y1, y2))
add a line to a plot and make it red
line(x, y, col = “red”)
f(a) is black with circles. f(b) is red and a line. Add a legend to the bottom right
legend(“bottomright”, legend = c(“f(a)”, “f(b)”), col = c(“black“,”red”), pch = c(1, NA), lty = c(0, 1))
plot x² and 5x from x=0 to x=3 on the same graph. make 5x red. Label the x-axis x and the y-axis f(x). Extend the graph limits from 0 to 5 on x and 0 to 5 on y
curve(x², 0, 3, xlab = ”x”, ylab = “f(x)”, xlim = c(0,5), ylim = c(0,5))
curve(5x, 0, 3, add = TRUE, col = ”red”)