avg_Sepal_Length <- mean(iris$Sepal.Length)
df1 <- iris[iris$Sepal.Length > avg_Sepal_Length, ]
df2 <- iris[!(iris$Sepal.Length > avg_Sepal_Length), ]
library(ggplot2)
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color = Species)) +
  geom_point() +
  labs(title = "Relationship between Sepal.Length and Petal.Length",
       x = "Sepal.Length",
       y = "Petal.Length")
From the plot, we can observe that there is a positive relationship between Sepal.Length and Petal.Length. Additionally, different species have distinct patterns in terms of their Sepal.Length and Petal.Length.

From the plot, we can observe that there is a positive relationship between Sepal.Length and Petal.Length. Additionally, different species have distinct patterns in terms of their Sepal.Length and Petal.Length.

library(ggplot2)
ggplot(iris, aes(x = Sepal.Width, y = Petal.Width, color = Species)) +
  geom_point() +
  labs(title = "Relationship between Sepal.Width and Petal.Width",
       x = "Sepal.Width",
       y = "Petal.Width")
From the plot, we can observe that there is some variation in the relationship between Sepal.Width and Petal.Width across different species. Setosa species generally has lower Sepal.Width and smaller Petal.Width compared to Versicolor and Virginica species.

From the plot, we can observe that there is some variation in the relationship between Sepal.Width and Petal.Width across different species. Setosa species generally has lower Sepal.Width and smaller Petal.Width compared to Versicolor and Virginica species.

4.cbind(): It is used to combine objects (vectors, matrices, or data frames) column-wise. For example, cbind(df1, df2) will combine the columns of df1 and df2 into a single data frame.

rbind(): It is used to combine objects (vectors, matrices, or data frames) row-wise. For example, rbind(df1, df2) will combine the rows of df1 and df2 into a single data frame.

merge(): It is used to merge two or more data frames based on common columns. It performs a database-style join operation. For example, merge(df1, df2, by = “ID”) will merge df1 and df2 based on the common column “ID”.

5.apply(): It applies a function to either rows or columns of a matrix or data frame. For example, apply(iris[, c(“Sepal.Length”, “Sepal.Width”)], 2, mean) will calculate the mean for columns “Sepal.Length” and “Sepal.Width”.

lapply(): It applies a function to each element of a list or data frame. Forexample, lapply(iris[, c(“Sepal.Length”, “Sepal.Width”)], mean) will calculate the mean for columns “Sepal.Length” and “Sepal.Width” in the iris dataset.

tapply(): It applies a function to subsets of a vector or data frame based on one or more factors. For example, tapply(iris\(Petal.Length, iris\)Species, mean) will calculate the mean Petal.Length for each Species in the iris dataset.

aggregate(): It applies a function to subsets of a data frame based on one or more grouping variables. For example, aggregate(. ~ Species, data = iris, mean) will calculate the mean of all columns for each Species in the iris dataset.

?apply
## 打开httpd帮助服务器… 好了
?lapply
?tapply
?aggregate