# Generate a sequence of numbers from 1 to 20 with a step of 2
print(seq(1, 20, 2))
[1] 1 3 5 7 9 11 13 15 17 19
Peter Nutter
Sunday, April 14, 2024
[1] 1 3 5 7 9 11 13 15 17 19
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
[1] 0.78997690 0.52227519 0.67701569 0.28452173 0.07227832
[1] 1.644854
[1] "/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/stats/help/TDist"
# Calculate the cumulative probability for the t-distribution with 10 degrees of freedom at 1.96
pt(1.96, df = 10)
[1] 0.9607819
[1] 0.3678794
FALSE TRUE
25 25
[1] TRUE
[1] TRUE
# Calculate the density of the normal distribution at 0 with mean = 2 and sd = 5
means = 2
sdev = 5
dnorm(0, mean = means, sd = sdev)
[1] 0.07365403
# Create a 3x2 matrix filled by column with numbers 1 to 6
mat = matrix(1:6, nrow = 3, ncol = 2)
mat
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
[,1] [,2]
[1,] 1 2
[2,] 3 4
[3,] 5 6
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
[,1] [,2]
[1,] 0 0
[2,] 0 0
[,1] [,2]
[1,] -2 1.5
[2,] 1 -0.5
# Create a line plot with customizations
plot(1:10, seq(1, 20, 2), type = "l", col = "blue", lwd = 2, main = "Line Plot", xlab = "X-axis", ylab = "Y-axis")
abline(h = 10, col = "red", lwd = 6)
# Create a histogram of 1000 random normal numbers
hist(rnorm(1000), col = "blue", main = "Histogram of 1000 random normal numbers", xlab = "Value", ylab = "Frequency")
# Create a barplot of numbers from 1 to 10
barplot(1:10, col = "red", main = "Barplot of 1:10", xlab = "Index", ylab = "Value")
# Create an empirical cumulative distribution function plot
plot.ecdf(rnorm(1000), col = "blue", main = "ECDF of 1000 random normal numbers", xlab = "Value", ylab = "Cumulative Probability")