#install.packages(tidyverse)
#install.packages('Tmisc')
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.4
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(Tmisc)
Create & view a data frame
data(quartet)
#View(quartet)
Use group by & summarize to create the statiistical data frame. Use mean to calculate average, sd()= “desviacion estandar” y cor= “correlation”
quartet %>%
group_by(set) %>%
summarize(mean(x), sd(x), mean(y), sd(y),cor(x,y))
## # A tibble: 4 × 6
## set `mean(x)` `sd(x)` `mean(y)` `sd(y)` `cor(x, y)`
## <fct> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 I 9 3.32 7.50 2.03 0.816
## 2 II 9 3.32 7.50 2.03 0.816
## 3 III 9 3.32 7.5 2.03 0.816
## 4 IV 9 3.32 7.50 2.03 0.817
Use ggplot to paint graphs
ggplot(quartet, aes(x,y)) +
geom_point() +
geom_smooth(method=lm,se=FALSE) +
facet_wrap(~set)
## `geom_smooth()` using formula = 'y ~ x'
Other data frame interesting, that is including in DatasauRus package
#install.packages('datasauRus')
library('datasauRus')
View the data frame
#View(datasaurus_dozen)
ggplot(datasaurus_dozen, aes(x=x,y=y, colour=dataset))+
geom_point()+
theme_void()+
theme(legend.position = "none")+
facet_wrap(~dataset,ncol=3)