If you haven’t already, download and install R from the official website: https://cran.r-project.org/
Next, download and install RStudio Desktop from: https://www.rstudio.com/products/rstudio/download/
2 + 2 and press Enter to see how R
performs basic arithmetic.<-, for example: x <- 5.x by typing x in the
Console and pressing Enter.install.packages("tidyverse") in the Console and pressing
Enter.library(tidyverse)
and pressing Enter.library(tidyverse)
iris dataset by typing
data(iris) in the Console and pressing Enter.data(iris)
Species is “setosa”:filtered_data <- iris %>% filter(Species == "setosa")
Sepal.Length and
Sepal.Width columns:selected_data <- iris %>% select(Sepal.Length, Sepal.Width)
Petal.Area by mutating
the dataset:mutated_data <- iris %>% mutate(Petal.Area = Petal.Length * Petal.Width)
Sepal.Length and Sepal.Width:summary_data <- iris %>%
group_by(Species) %>%
summarise(mean_Sepal.Length = mean(Sepal.Length),
mean_Sepal.Width = mean(Sepal.Width))
ggplot() function to create basic plots.Sepal.Length for each
species:ggplot(iris, aes(x = Species, y = Sepal.Length)) +
geom_boxplot()
Sepal.Length of
setosa and versicolor species:t_test_result <- t.test(Sepal.Length ~ Species, data = subset(iris, Species %in% c("setosa", "versicolor")))
print(t_test_result)
##
## Welch Two Sample t-test
##
## data: Sepal.Length by Species
## t = -10.521, df = 86.538, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group setosa and group versicolor is not equal to 0
## 95 percent confidence interval:
## -1.1057074 -0.7542926
## sample estimates:
## mean in group setosa mean in group versicolor
## 5.006 5.936