RStudio Quick Start (Nick Horton)

require(nycflights13)
## Loading required package: nycflights13
data(flights)
glimpse(flights)
## Observations: 336776
## Variables:
## $ year      (int) 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013...
## $ month     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
## $ day       (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
## $ dep_time  (int) 517, 533, 542, 544, 554, 554, 555, 557, 557, 558, 55...
## $ dep_delay (dbl) 2, 4, 2, -1, -6, -4, -5, -3, -3, -2, -2, -2, -2, -2,...
## $ arr_time  (int) 830, 850, 923, 1004, 812, 740, 913, 709, 838, 753, 8...
## $ arr_delay (dbl) 11, 20, 33, -18, -25, 12, 19, -14, -8, 8, -2, -3, 7,...
## $ carrier   (chr) "UA", "UA", "AA", "B6", "DL", "UA", "B6", "EV", "B6"...
## $ tailnum   (chr) "N14228", "N24211", "N619AA", "N804JB", "N668DN", "N...
## $ flight    (int) 1545, 1714, 1141, 725, 461, 1696, 507, 5708, 79, 301...
## $ origin    (chr) "EWR", "LGA", "JFK", "JFK", "LGA", "EWR", "EWR", "LG...
## $ dest      (chr) "IAH", "IAH", "MIA", "BQN", "ATL", "ORD", "FLL", "IA...
## $ air_time  (dbl) 227, 227, 160, 183, 116, 150, 158, 53, 140, 138, 149...
## $ distance  (dbl) 1400, 1416, 1089, 1576, 762, 719, 1065, 229, 944, 73...
## $ hour      (dbl) 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6...
## $ minute    (dbl) 17, 33, 42, 44, 54, 54, 55, 57, 57, 58, 58, 58, 58, ...
?glimpse
?View
View(flights)
DTW <- filter(flights, dest=="DTW")
glimpse(DTW)
## Observations: 9384
## Variables:
## $ year      (int) 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013...
## $ month     (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
## $ day       (int) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
## $ dep_time  (int) 602, 659, 840, 851, 857, 858, 1048, 1113, 1230, 1231...
## $ dep_delay (dbl) -3, -6, -5, -8, -8, -2, -2, -2, -5, -7, 11, -10, 0, ...
## $ arr_time  (int) 821, 907, 1053, 1102, 1107, 1102, 1302, 1318, 1440, ...
## $ arr_delay (dbl) 16, -6, -9, -3, -13, -8, 12, 3, 2, 3, 23, 3, 15, 2, ...
## $ carrier   (chr) "MQ", "DL", "DL", "DL", "DL", "MQ", "MQ", "DL", "EV"...
## $ tailnum   (chr) "N730MQ", "N998DL", "N926DL", "N361NB", "N321NB", "N...
## $ flight    (int) 4401, 831, 2304, 869, 181, 4478, 4589, 1031, 5311, 1...
## $ origin    (chr) "LGA", "LGA", "JFK", "EWR", "LGA", "LGA", "LGA", "LG...
## $ dest      (chr) "DTW", "DTW", "DTW", "DTW", "DTW", "DTW", "DTW", "DT...
## $ air_time  (dbl) 105, 105, 108, 106, 110, 103, 112, 104, 108, 108, 11...
## $ distance  (dbl) 502, 502, 509, 488, 502, 502, 502, 502, 488, 502, 48...
## $ hour      (dbl) 6, 6, 8, 8, 8, 8, 10, 11, 12, 12, 12, 13, 14, 16, 16...
## $ minute    (dbl) 2, 59, 40, 51, 57, 58, 48, 13, 30, 31, 40, 5, 40, 26...
?filter

Data Visualization (Danny Kaplan)

library(DCF)
## Loading required package: NHANES
## Loading required package: tidyr
## 
## Attaching package: 'DCF'
## 
## The following object is masked from 'package:mosaic':
## 
##     CIAdata
help(CountryData)
library(DCFinteractive)
## Loading required package: shiny
## Loading required package: manipulate
## 
## Attaching package: 'DCFinteractive'
## 
## The following objects are masked from 'package:mosaic':
## 
##     mScatter, mUSMap, mWorldMap
mScatter(CountryData)
data(package="mosaicData")
help(HELPrct)
glimpse(HELPrct)
## Observations: 453
## Variables:
## $ age          (int) 37, 37, 26, 39, 32, 47, 49, 28, 50, 39, 34, 58, 5...
## $ anysubstatus (int) 1, 1, 1, 1, 1, 1, NA, 1, 1, 1, NA, 0, 1, 1, 1, 1,...
## $ anysub       (fctr) yes, yes, yes, yes, yes, yes, NA, yes, yes, yes,...
## $ cesd         (int) 49, 30, 39, 15, 39, 6, 52, 32, 50, 46, 46, 49, 22...
## $ d1           (int) 3, 22, 0, 2, 12, 1, 14, 1, 14, 4, 0, 3, 5, 10, 2,...
## $ daysanysub   (int) 177, 2, 3, 189, 2, 31, NA, 47, 31, 115, NA, 192, ...
## $ dayslink     (int) 225, NA, 365, 343, 57, 365, 334, 365, 365, 382, 3...
## $ drugrisk     (int) 0, 0, 20, 0, 0, 0, 0, 7, 18, 20, 8, 0, 0, 0, 0, 0...
## $ e2b          (int) NA, NA, NA, 1, 1, NA, 1, 8, 7, 3, NA, NA, NA, 1, ...
## $ female       (int) 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0...
## $ sex          (fctr) male, male, male, female, male, female, female, ...
## $ g1b          (fctr) yes, yes, no, no, no, no, yes, yes, no, no, no, ...
## $ homeless     (fctr) housed, homeless, housed, housed, homeless, hous...
## $ i1           (int) 13, 56, 0, 5, 10, 4, 13, 12, 71, 20, 0, 13, 20, 1...
## $ i2           (int) 26, 62, 0, 5, 13, 4, 20, 24, 129, 27, 0, 13, 31, ...
## $ id           (int) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16...
## $ indtot       (int) 39, 43, 41, 28, 38, 29, 38, 44, 44, 44, 34, 11, 4...
## $ linkstatus   (int) 1, NA, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, ...
## $ link         (fctr) yes, NA, no, no, yes, no, no, no, no, no, no, no...
## $ mcs          (dbl) 25.1120, 26.6703, 6.7629, 43.9679, 21.6758, 55.50...
## $ pcs          (dbl) 58.414, 36.037, 74.806, 61.932, 37.346, 46.475, 2...
## $ pss_fr       (int) 0, 1, 13, 11, 10, 5, 1, 4, 5, 0, 0, 13, 13, 1, 1,...
## $ racegrp      (fctr) black, white, black, white, black, black, black,...
## $ satreat      (fctr) no, no, no, yes, no, no, yes, yes, no, yes, no, ...
## $ sexrisk      (int) 4, 7, 2, 4, 6, 5, 8, 6, 8, 0, 2, 0, 1, 4, 8, 3, 4...
## $ substance    (fctr) cocaine, alcohol, heroin, heroin, cocaine, cocai...
## $ treat        (fctr) yes, yes, no, no, no, yes, no, yes, no, yes, yes...
mScatter(HELPrct)

Result from Show Expression in mScatter(HELPrct)

ggplot(data=HELPrct,aes(x=mcs,y=dayslink))+geom_point()+aes(colour=female)+aes(size=drugrisk)