1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
hist(x = df$weight, xlab = "Weight (grams)", main = "Histogram of Weight") boxplot(x = df$weight, xlab = "Weight (grams)", main = "Boxplot of Weight")
hist(x = df$Time, xlab = "Time (days)", main = "Histogram of Time") boxplot(x = df$Time, xlab = "Time (days)", main = "Boxplot of Time")
table(df$Diet) barplot(table(df$Diet), main = "Frequency Barplot of Diet") barplot(table(df$Diet)/sum(table(df$Diet)), main = "Relative Frequency Barplot of Diet")
pie(x = table(df$Diet), main = "Pie Chart of Diet")
plot(x = df$Time, y = df$weight, xlab = "Time (days)", ylab = "Weight (grams)", main = "Scatter Plot of Weight vs. Time")
boxplot(df$weight ~ df$Diet, ylab = "Weight (grams)", main = "Weight by Diet Type")
par(mfrow = c(1,3)) hist(x = df$weight, xlab = "Weight (grams)", main = "Histogram of Weight") plot(x = df$Time, y = df$weight, xlab = "Time (days)", ylab = "Weight (grams)", main = "Scatter Plot of Weight vs. Time") boxplot(df$weight ~ df$Diet, ylab = "Weight (grams)", main = "Weight by Diet Type")
table(df$Diet, df$Chick) par(mfrow = c(1,1)) mosaicplot(x = table(df$Diet, df$Chick), xlab = "Diet", ylab = "Chick ID", main = "Chick ID by Diet")
? HairEyeColor HairEyeColor mosaicplot(x = HairEyeColor[,,1], main = "Male Hair and Eye Colour") mosaicplot(x = HairEyeColor[,,2], main = "Female Hair and Eye Colour")
plot(x = rnorm(n = 1000, mean = 0, sd = 1), y = rnorm(n = 1000, mean = 0, sd = 1), xlab = "", ylab = "", main = "", pch = 16, xlim = c(-3.5, 3.5), ylim = c(-3.5, 3.5))
abline(a = 0, b = 1, col = "red")
abline(a = -1, b = 0.5, col = "green", lwd = 2)
abline(h = 0, col = "blue", lwd = 2, lty = 2) abline(v = -2, col = "purple", lwd = 2, lty = 3)
segments(x0 = -2, y0 = -3, x1 = -1, y1 = -3, col = "magenta", lwd = 3, lty = 1)
lines(x = seq(-3, 3, 0.1), y = cos(3*seq(-3, 3, 0.1)), col = "orange", lwd = 4)
legend("bottomright", legend = c("Diagonal", "General Line", "Horizontal", "Vertical", "Segment", "Curve"), col = c("red", "green", "blue", "purple", "magenta", "orange"), lwd = c(1, 2, 2, 2, 3, 4), lty = c(1, 1, 2, 3, 1, 1))
points(x = rnorm(n = 100, mean = -3, sd = 0.2), y = rnorm(n = 100, mean = 3, sd = 0.2), col = "cyan", pch = 17)
|