Last active
December 18, 2017 21:15
-
-
Save juananpe/f4b4c758cd7f1126829c465f2d655020 to your computer and use it in GitHub Desktop.
intro.R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
?cars | |
str(cars) | |
summary(cars) | |
gg <- ggplot(cars, aes(x=speed, y=dist)) + | |
geom_point() | |
plot(gg) | |
gg <- ggplot(cars, aes(x=speed, y=dist)) + | |
geom_point() + | |
geom_smooth(method="loess", se=F) | |
plot(gg) | |
gg <- ggplot(cars, aes(x=speed, y=dist)) + | |
geom_point() + | |
geom_smooth(method="loess", se=T) + | |
labs(title="Scatterplot", | |
subtitle="Feets de frenada vs velocidad (mph)", | |
x="Velocidad", | |
y="fts frenada", | |
caption = "Source: cars") | |
plot(gg) | |
# Publicar | |
library(ggplot2) | |
data("midwest", package = "ggplot2") | |
?midwest | |
# midwest <- read.csv("http://goo.gl/G1K41K") # bkup data source | |
colnames(midwest) | |
str(midwest) | |
summary(midwest) | |
head(midwest) | |
dim(midwest) | |
View(midwest) | |
class(midwest$state) | |
midwest$state | |
summary(midwest$state) | |
midwest$state <- as.factor(midwest$state) | |
summary(midwest$state) | |
gg <- ggplot(midwest, aes(x=area, y=poptotal)) + | |
geom_point(aes(col=state, size=popdensity)) + | |
geom_smooth(method="loess", se=F) + | |
xlim(c(0, 0.1)) + | |
ylim(c(0, 500000)) + | |
labs(subtitle="Area Vs Population", | |
y="Population", | |
x="Area", | |
title="Scatterplot", | |
caption = "Source: midwest") | |
plot(gg) | |
options(scipen=999) # turn-off scientific notation like 1e+48 | |
# EJERCICIOS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment