This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
plot(cars)
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
library(ggplot2)
library(dplyr)
library(skimr)
glimpse(mpg)
Observations: 234
Variables: 11
$ manufacturer <chr> "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi"...
$ model <chr> "a4", "a4", "a4", "a4", "a4", "a4", "a4", "a4 quattro", "a4 quattro", ...
$ displ <dbl> 1.8, 1.8, 2.0, 2.0, 2.8, 2.8, 3.1, 1.8, 1.8, 2.0, 2.0, 2.8, 2.8, 3.1, ...
$ year <int> 1999, 1999, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 2008, 2008, 1999...
$ cyl <int> 4, 4, 4, 4, 6, 6, 6, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8...
$ trans <chr> "auto(l5)", "manual(m5)", "manual(m6)", "auto(av)", "auto(l5)", "manua...
$ drv <chr> "f", "f", "f", "f", "f", "f", "f", "4", "4", "4", "4", "4", "4", "4", ...
$ cty <int> 18, 21, 20, 21, 16, 18, 18, 18, 16, 20, 19, 15, 17, 17, 15, 15, 17, 16...
$ hwy <int> 29, 29, 31, 30, 26, 26, 27, 26, 25, 28, 27, 25, 25, 25, 25, 24, 25, 23...
$ fl <chr> "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", ...
$ class <chr> "compact", "compact", "compact", "compact", "compact", "compact", "com...
skim(mpg)
Skim summary statistics
n obs: 234
n variables: 11
-- Variable type:character -----------------------------------------------------
variable missing complete n min max empty n_unique
class 0 234 234 3 10 0 7
drv 0 234 234 1 1 0 3
fl 0 234 234 1 1 0 5
manufacturer 0 234 234 4 10 0 15
model 0 234 234 2 22 0 38
trans 0 234 234 8 10 0 10
-- Variable type:integer -------------------------------------------------------
variable missing complete n mean sd p0 p25 p50 p75 p100 hist
cty 0 234 234 16.86 4.26 9 14 17 19 35 <U+2585><U+2587><U+2587><U+2587><U+2581><U+2581><U+2581><U+2581>
cyl 0 234 234 5.89 1.61 4 4 6 8 8 <U+2587><U+2581><U+2581><U+2587><U+2581><U+2581><U+2581><U+2587>
hwy 0 234 234 23.44 5.95 12 18 24 27 44 <U+2583><U+2587><U+2583><U+2587><U+2585><U+2581><U+2581><U+2581>
year 0 234 234 2003.5 4.51 1999 1999 2003.5 2008 2008 <U+2587><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2587>
-- Variable type:numeric -------------------------------------------------------
variable missing complete n mean sd p0 p25 p50 p75 p100 hist
displ 0 234 234 3.47 1.29 1.6 2.4 3.3 4.6 7 <U+2587><U+2587><U+2585><U+2585><U+2585><U+2583><U+2582><U+2581>
ggplot() +
geom_point(data = mpg, mapping = aes(x = displ, y = hwy, color = class, shape = drv))
ggplot(mpg) +
geom_point(aes(x = displ, y = hwy, color = class)) +
facet_wrap(~ drv)
NA
ggplot(data = mpg) +
geom_bar(aes(x = drv))
data_autos_resumida <- tribble (
~ tipo_traccion, ~ num_obs,
"4" , 104,
"f" , 102,
"r" , 25
)
data_autos_resumida
ggplot(data = data_autos_resumida) +
geom_bar(mapping = aes(x = tipo_traccion, y = num_obs),
stat = "identity")
ggplot(mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = class)) +
geom_smooth(mapping = aes(x = displ, y = hwy))
ggplot(mpg) +
geom_point(mapping = aes(x = displ, y = hwy), color = "#123456") +
geom_point(mapping = aes(x = displ, y = hwy),
data = data.frame(displ = 4, hwy = 40),
color = "red",
size = 4)
library(gapminder)
mis_datos <- filter(gapminder, continent == "Europe")
mis_datos
ggplot()+
geom_point(data = mis_datos, mapping = aes(x = gdpPercap, y = lifeExp, size = pop))