0% found this document useful (0 votes)
135 views24 pages

Getwd

The document shows an R session where the user is attempting to import and manipulate data files. They run commands to change the working directory, import data from a CSV file into a dataframe, and view and summarize the data. They also bind and merge multiple dataframes.

Uploaded by

Elysa Musarofah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views24 pages

Getwd

The document shows an R session where the user is attempting to import and manipulate data files. They run commands to change the working directory, import data from a CSV file into a dataframe, and view and summarize the data. They also bind and merge multiple dataframes.

Uploaded by

Elysa Musarofah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

R version 3.5.

3 (2019-03-11) -- "Great Truth"


Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.


Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or


'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> getwd()
[1] "C:/Users/ASUS/Documents"
> setwd(coba/R-for-beginners)
Error: unexpected '-' in "setwd(coba/R-for-"
> setwd("coba/R-for-beginners")
Error in setwd("coba/R-for-beginners") : cannot change working directory
> setwd("coba/R-for-beginners-master")
Error in setwd("coba/R-for-beginners-master") :
cannot change working directory
> setwd("coba/R-for-beginners")
Error in setwd("coba/R-for-beginners") : cannot change working directory
> data <- read.csv("Data1-WaterTemp.csv")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'Data1-WaterTemp.csv': No such file or directory
> getwd()
[1] "C:/Users/ASUS/Documents"
> setwd("D:/coba/R-for-beginners")
> data <- read.csv("Data1-WaterTemp.csv")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'Data1-WaterTemp.csv': No such file or directory
> data <- read.csv("Data1-WaterTemp.csv")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'Data1-WaterTemp.csv': No such file or directory
> data <- read.csv("Data1-WaterTemp.csv")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'Data1-WaterTemp.csv': No such file or directory
> data <- read.csv("Data1-WaterTemp.csv")
> title: "Bab 4 Manipulasi data dengan R"
Error in title:"Bab 4 Manipulasi data dengan R" : NA/NaN argument
In addition: Warning message:
NAs introduced by coercion
> data <- read.csv("Data1-WaterTemp.csv")
> data
Sample_ID Temp
1 1 20
2 2 23
3 3 26
4 4 37
5 5 42
6 6 45
7 7 53
8 8 21
9 9 23
10 10 24
11 11 23
12 12 25
13 13 25
14 14 27
15 15 26
16 16 25
17 17 25
18 18 25
19 19 57
20 20 25
> data <- read.csv("Data1-WaterTemp.csv")
> View(data)
> str(data)
'data.frame': 20 obs. of 2 variables:
$ Sample_ID: int 1 2 3 4 5 6 7 8 9 10 ...
$ Temp : int 20 23 26 37 42 45 53 21 23 24 ...
> dim(data)
[1] 20 2
> summary(data)
Sample_ID Temp
Min. : 1.00 Min. :20.00
1st Qu.: 5.75 1st Qu.:23.75
Median :10.50 Median :25.00
Mean :10.50 Mean :29.85
3rd Qu.:15.25 3rd Qu.:29.50
Max. :20.00 Max. :57.00
> datamurid <- data.frame(nama = c("Abi", "Aci", "Adi", "Afi", "Agi", "Ali"),
+ tahun.lahir = c(76, 78, 79, 80, 83, 87),
+ usia = c(38, 36, 35, 34, 31, 27)
+ )
> datamurid2 <- data.frame(nama = c("Ani", "Ami", "Aki"),
+ tahun.lahir = c(76, 78, 79),
+ usia = c(38, 36, 35)
+ )
> View(data)
> View(data)
> View(datamurid)
> View(datamurid)
> View(datamurid2)
> View(datamurid2)
> datamuridtotal <- merge(datamurid, datamurid2, by="nama")
> datamuridrevisi <- rbind(datamurid, datamurid2)
> View(datamuridrevisi)
> View(datamuridrevisi)
> View(datamuridtotal)
> View(datamuridtotal)
> ?data.frame
> df1 <- data.frame(ref = c('Ref1', 'Ref2'),
+ label = c('Label01', 'Label02')
+ )
> df2 <- data.frame(id = c('A1', 'C2', 'B3', 'D4'),
+ ref = c('Ref1', 'Ref2' , 'Ref3','Ref1'),
+ val = c( 1.11, 2.22, 3.33, 4.44 )
+ )
> df1
ref label
1 Ref1 Label01
2 Ref2 Label02
> df2
id ref val
1 A1 Ref1 1.11
2 C2 Ref2 2.22
3 B3 Ref3 3.33
4 D4 Ref1 4.44
> dftotal <- merge(df1, df2, by='ref', all.y = T, sort= T)
> dftotal
ref label id val
1 Ref1 Label01 A1 1.11
2 Ref1 Label01 D4 4.44
3 Ref2 Label02 C2 2.22
4 Ref3 <NA> B3 3.33

(kalau missal all.y=T nya di hilangkan maka ref 3 akan kosong.. NA=not available)

> install.packages("dplyr")
WARNING: Rtools is required to build R packages but is not currently
installed. Please download and install the appropriate version of Rtools
before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/ASUS/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependencies ‘backports’, ‘ellipsis’, ‘digest’,
‘zeallot’, ‘utf8’, ‘vctrs’, ‘cli’, ‘crayon’, ‘fansi’, ‘pillar’, ‘purrr’,
‘assertthat’, ‘glue’, ‘magrittr’, ‘pkgconfig’, ‘R6’, ‘Rcpp’, ‘rlang’,
‘tibble’, ‘tidyselect’, ‘BH’, ‘plogr’

trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/backports_1.1.4.zip'
Content type 'application/zip' length 66186 bytes (64 KB)
downloaded 64 KB

trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/ellipsis_0.2.0.1.zip'
Content type 'application/zip' length 43270 bytes (42 KB)
downloaded 42 KB

trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/digest_0.6.20.zip'
Content type 'application/zip' length 222453 bytes (217 KB)
downloaded 217 KB

trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/zeallot_0.1.0.zip'
Content type 'application/zip' length 61464 bytes (60 KB)
downloaded 60 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/utf8_1.1.4.zip'


Content type 'application/zip' length 214542 bytes (209 KB)
downloaded 209 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/vctrs_0.2.0.zip'


Content type 'application/zip' length 821190 bytes (801 KB)
downloaded 801 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/cli_1.1.0.zip'


Content type 'application/zip' length 172678 bytes (168 KB)
downloaded 168 KB

trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/crayon_1.3.4.zip'
Content type 'application/zip' length 749109 bytes (731 KB)
downloaded 731 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/fansi_0.4.0.zip'


Content type 'application/zip' length 220348 bytes (215 KB)
downloaded 215 KB

trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/pillar_1.4.2.zip'
Content type 'application/zip' length 179982 bytes (175 KB)
downloaded 175 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/purrr_0.3.2.zip'


Content type 'application/zip' length 417664 bytes (407 KB)
downloaded 407 KB

trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/assertthat_0.2.1.zip'
Content type 'application/zip' length 54021 bytes (52 KB)
downloaded 52 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/glue_1.3.1.zip'


Content type 'application/zip' length 172491 bytes (168 KB)
downloaded 168 KB

trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/magrittr_1.5.zip'
Content type 'application/zip' length 155732 bytes (152 KB)
downloaded 152 KB

trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/pkgconfig_2.0.2.zip'
Content type 'application/zip' length 22205 bytes (21 KB)
downloaded 21 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/R6_2.4.0.zip'


Content type 'application/zip' length 58369 bytes (57 KB)
downloaded 57 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/Rcpp_1.0.2.zip'


Content type 'application/zip' length 4551012 bytes (4.3 MB)
downloaded 4.3 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/rlang_0.4.0.zip'


Content type 'application/zip' length 1079426 bytes (1.0 MB)
downloaded 1.0 MB
trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/tibble_2.1.3.zip'
Content type 'application/zip' length 333922 bytes (326 KB)
downloaded 326 KB

trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/tidyselect_0.2.5.zip'
Content type 'application/zip' length 625672 bytes (611 KB)
downloaded 611 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/BH_1.69.0-1.zip'


Content type 'application/zip' length 19008161 bytes (18.1 MB)
downloaded 18.1 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/plogr_0.2.0.zip'


Content type 'application/zip' length 18728 bytes (18 KB)
downloaded 18 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/dplyr_0.8.3.zip'
Content type 'application/zip' length 3255178 bytes (3.1 MB)
downloaded 3.1 MB
package ‘backports’ successfully unpacked and MD5 sums checked
package ‘ellipsis’ successfully unpacked and MD5 sums checked
package ‘digest’ successfully unpacked and MD5 sums checked
package ‘zeallot’ successfully unpacked and MD5 sums checked
package ‘utf8’ successfully unpacked and MD5 sums checked
package ‘vctrs’ successfully unpacked and MD5 sums checked
package ‘cli’ successfully unpacked and MD5 sums checked
package ‘crayon’ successfully unpacked and MD5 sums checked
package ‘fansi’ successfully unpacked and MD5 sums checked
package ‘pillar’ successfully unpacked and MD5 sums checked
package ‘purrr’ successfully unpacked and MD5 sums checked
package ‘assertthat’ successfully unpacked and MD5 sums checked
package ‘glue’ successfully unpacked and MD5 sums checked
package ‘magrittr’ successfully unpacked and MD5 sums checked
package ‘pkgconfig’ successfully unpacked and MD5 sums checked
package ‘R6’ successfully unpacked and MD5 sums checked
package ‘Rcpp’ successfully unpacked and MD5 sums checked
package ‘rlang’ successfully unpacked and MD5 sums checked
package ‘tibble’ successfully unpacked and MD5 sums checked
package ‘tidyselect’ successfully unpacked and MD5 sums checked
package ‘BH’ successfully unpacked and MD5 sums checked
package ‘plogr’ successfully unpacked and MD5 sums checked
package ‘dplyr’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in


C:\Users\ASUS\AppData\Local\Temp\RtmpC83Lbz\downloaded_packages
> library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

filter, lag

The following objects are masked from ‘package:base’:


intersect, setdiff, setequal, union

> library(hflights)
Error in library(hflights) : there is no package called ‘hflights’
> install.packages("hflights")
WARNING: Rtools is required to build R packages but is not currently
installed. Please download and install the appropriate version of Rtools
before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/ASUS/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.5/hflights_0.1.zip'
Content type 'application/zip' length 3473044 bytes (3.3 MB)
downloaded 3.3 MB

package ‘hflights’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in


C:\Users\ASUS\AppData\Local\Temp\RtmpC83Lbz\downloaded_packages
> library(hflights)
> data(hflights)
> head(hflights)
Year Month DayofMonth DayOfWeek DepTime ArrTime UniqueCarrier FlightNum
5424 2011 1 1 6 1400 1500 AA 428
5425 2011 1 2 7 1401 1501 AA 428
5426 2011 1 3 1 1352 1502 AA 428
5427 2011 1 4 2 1403 1513 AA 428
5428 2011 1 5 3 1405 1507 AA 428
5429 2011 1 6 4 1359 1503 AA 428
TailNum ActualElapsedTime AirTime ArrDelay DepDelay Origin Dest Distance
5424 N576AA 60 40 -10 0 IAH DFW 224
5425 N557AA 60 45 -9 1 IAH DFW 224
5426 N541AA 70 48 -8 -8 IAH DFW 224
5427 N403AA 70 39 3 3 IAH DFW 224
5428 N492AA 62 44 -3 5 IAH DFW 224
5429 N262AA 64 45 -7 -1 IAH DFW 224
TaxiIn TaxiOut Cancelled CancellationCode Diverted
5424 7 13 0 0
5425 6 9 0 0
5426 5 17 0 0
5427 9 22 0 0
5428 9 9 0 0
5429 6 13 0 0
> hflights
Year Month DayofMonth DayOfWeek DepTime ArrTime UniqueCarrier FlightNum
5424 2011 1 1 6 1400 1500 AA 428
5425 2011 1 2 7 1401 1501 AA 428
5426 2011 1 3 1 1352 1502 AA 428
5427 2011 1 4 2 1403 1513 AA 428
5428 2011 1 5 3 1405 1507 AA 428
5429 2011 1 6 4 1359 1503 AA 428
5430 2011 1 7 5 1359 1509 AA 428
5431 2011 1 8 6 1355 1454 AA 428
5432 2011 1 9 7 1443 1554 AA 428
5433 2011 1 10 1 1443 1553 AA 428
5434 2011 1 11 2 1429 1539 AA 428
5435 2011 1 12 3 1419 1515 AA 428
5436 2011 1 13 4 1358 1501 AA 428
5437 2011 1 14 5 1357 1504 AA 428
5438 2011 1 15 6 1359 1459 AA 428
5439 2011 1 16 7 1359 1509 AA 428
5440 2011 1 17 1 1530 1634 AA 428
5441 2011 1 18 2 1408 1508 AA 428
5442 2011 1 19 3 1356 1503 AA 428
5443 2011 1 20 4 1507 1622 AA 428
5444 2011 1 21 5 1357 1459 AA 428
5445 2011 1 22 6 1355 1456 AA 428
5446 2011 1 23 7 1356 1501 AA 428
5447 2011 1 24 1 1356 1513 AA 428
5448 2011 1 25 2 1352 1452 AA 428
5449 2011 1 26 3 1353 1455 AA 428
5450 2011 1 27 4 1356 1458 AA 428
5451 2011 1 28 5 1359 1505 AA 428
5452 2011 1 29 6 1355 1455 AA 428
5453 2011 1 30 7 1359 1456 AA 428
5454 2011 1 31 1 1441 1553 AA 428
6343 2011 1 1 6 728 840 AA 460
6344 2011 1 2 7 719 821 AA 460
6345 2011 1 3 1 717 834 AA 460
6346 2011 1 4 2 714 821 AA 460
6347 2011 1 5 3 718 822 AA 460
6348 2011 1 6 4 719 821 AA 460
6349 2011 1 7 5 711 827 AA 460
6350 2011 1 8 6 713 805 AA 460
6351 2011 1 9 7 714 829 AA 460
6352 2011 1 10 1 715 818 AA 460
6353 2011 1 11 2 717 820 AA 460
6354 2011 1 12 3 714 814 AA 460
6355 2011 1 13 4 722 841 AA 460
6356 2011 1 14 5 715 828 AA 460
6357 2011 1 15 6 719 833 AA 460
6358 2011 1 16 7 743 843 AA 460
TailNum ActualElapsedTime AirTime ArrDelay DepDelay Origin Dest Distance
5424 N576AA 60 40 -10 0 IAH DFW 224
5425 N557AA 60 45 -9 1 IAH DFW 224
5426 N541AA 70 48 -8 -8 IAH DFW 224
5427 N403AA 70 39 3 3 IAH DFW 224
5428 N492AA 62 44 -3 5 IAH DFW 224
5429 N262AA 64 45 -7 -1 IAH DFW 224
5430 N493AA 70 43 -1 -1 IAH DFW 224
5431 N477AA 59 40 -16 -5 IAH DFW 224
5432 N476AA 71 41 44 43 IAH DFW 224
5433 N504AA 70 45 43 43 IAH DFW 224
5434 N565AA 70 42 29 29 IAH DFW 224
5435 N577AA 56 41 5 19 IAH DFW 224
5436 N476AA 63 44 -9 -2 IAH DFW 224
5437 N552AA 67 47 -6 -3 IAH DFW 224
5438 N462AA 60 44 -11 -1 IAH DFW 224
5439 N555AA 70 41 -1 -1 IAH DFW 224
5440 N518AA 64 48 84 90 IAH DFW 224
5441 N507AA 60 42 -2 8 IAH DFW 224
5442 N523AA 67 46 -7 -4 IAH DFW 224
5443 N425AA 75 42 72 67 IAH DFW 224
5444 N251AA 62 47 -11 -3 IAH DFW 224
5445 N551AA 61 44 -14 -5 IAH DFW 224
5446 N479AA 65 40 -9 -4 IAH DFW 224
5447 N531AA 77 43 3 -4 IAH DFW 224
5448 N561AA 60 40 -18 -8 IAH DFW 224
5449 N541AA 62 40 -15 -7 IAH DFW 224
5450 N512AA 62 40 -12 -4 IAH DFW 224
5451 N4UBAA 66 46 -5 -1 IAH DFW 224
5452 N491AA 60 46 -15 -5 IAH DFW 224
5453 N561AA 57 39 -14 -1 IAH DFW 224
5454 N505AA 72 39 43 41 IAH DFW 224
6343 N520AA 72 41 5 8 IAH DFW 224
6344 N537AA 62 43 -14 -1 IAH DFW 224
6345 N512AA 77 46 -1 -3 IAH DFW 224
6346 N478AA 67 46 -14 -6 IAH DFW 224
6347 N551AA 64 44 -13 -2 IAH DFW 224
6348 N251AA 62 44 -14 -1 IAH DFW 224
6349 N478AA 76 42 -8 -9 IAH DFW 224
6350 N550AA 52 40 -30 -7 IAH DFW 224
6351 N586AA 75 51 -6 -6 IAH DFW 224
6352 N587AA 63 44 -17 -5 IAH DFW 224
6353 N574AA 63 44 -15 -3 IAH DFW 224
6354 N580AA 60 42 -21 -6 IAH DFW 224
6355 N586AA 79 49 6 2 IAH DFW 224
6356 N468AA 73 47 -7 -5 IAH DFW 224
6357 N251AA 74 49 -2 -1 IAH DFW 224
6358 N546AA 60 45 8 23 IAH DFW 224
TaxiIn TaxiOut Cancelled CancellationCode Diverted
5424 7 13 0 0
5425 6 9 0 0
5426 5 17 0 0
5427 9 22 0 0
5428 9 9 0 0
5429 6 13 0 0
5430 12 15 0 0
5431 7 12 0 0
5432 8 22 0 0
5433 6 19 0 0
5434 8 20 0 0
5435 4 11 0 0
5436 6 13 0 0
5437 5 15 0 0
5438 6 10 0 0
5439 12 17 0 0
5440 8 8 0 0
5441 7 11 0 0
5442 10 11 0 0
5443 9 24 0 0
5444 6 9 0 0
5445 9 8 0 0
5446 7 18 0 0
5447 6 28 0 0
5448 7 13 0 0
5449 8 14 0 0
5450 12 10 0 0
5451 8 12 0 0
5452 7 7 0 0
5453 7 11 0 0
5454 8 25 0 0
6343 6 25 0 0
6344 9 10 0 0
6345 21 10 0 0
6346 6 15 0 0
6347 7 13 0 0
6348 8 10 0 0
6349 24 10 0 0
6350 3 9 0 0
6351 11 13 0 0
6352 8 11 0 0
6353 7 12 0 0
6354 10 8 0 0
6355 16 14 0 0
6356 15 11 0 0
6357 12 13 0 0
6358 5 10 0 0
[ reached 'max' / getOption("max.print") -- omitted 227449 rows ]
> flights <- tbl_df(hflights)
> flights
# A tibble: 227,496 x 21
Year Month DayofMonth DayOfWeek DepTime ArrTime UniqueCarrier FlightNum
TailNum
<int> <int> <int> <int> <int> <int> <chr> <int>
<chr>
1 2011 1 1 6 1400 1500 AA 428
N576AA
2 2011 1 2 7 1401 1501 AA 428
N557AA
3 2011 1 3 1 1352 1502 AA 428
N541AA
4 2011 1 4 2 1403 1513 AA 428
N403AA
5 2011 1 5 3 1405 1507 AA 428
N492AA
6 2011 1 6 4 1359 1503 AA 428
N262AA
7 2011 1 7 5 1359 1509 AA 428
N493AA
8 2011 1 8 6 1355 1454 AA 428
N477AA
9 2011 1 9 7 1443 1554 AA 428
N476AA
10 2011 1 10 1 1443 1553 AA 428
N504AA
# ... with 227,486 more rows, and 12 more variables: ActualElapsedTime <int>,
# AirTime <int>, ArrDelay <int>, DepDelay <int>, Origin <chr>, Dest <chr>,
# Distance <int>, TaxiIn <int>, TaxiOut <int>, Cancelled <int>,
# CancellationCode <chr>, Diverted <int>
> print(flights, n=20)
# A tibble: 227,496 x 21
Year Month DayofMonth DayOfWeek DepTime ArrTime UniqueCarrier FlightNum TailNum
<int> <int> <int> <int> <int> <int> <chr> <int> <chr>
1 2011 1 1 6 1400 1500 AA 428 N576AA
2 2011 1 2 7 1401 1501 AA 428 N557AA
3 2011 1 3 1 1352 1502 AA 428 N541AA
4 2011 1 4 2 1403 1513 AA 428 N403AA
5 2011 1 5 3 1405 1507 AA 428 N492AA
6 2011 1 6 4 1359 1503 AA 428 N262AA
7 2011 1 7 5 1359 1509 AA 428 N493AA
8 2011 1 8 6 1355 1454 AA 428 N477AA
9 2011 1 9 7 1443 1554 AA 428 N476AA
10 2011 1 10 1 1443 1553 AA 428 N504AA
11 2011 1 11 2 1429 1539 AA 428 N565AA
12 2011 1 12 3 1419 1515 AA 428 N577AA
13 2011 1 13 4 1358 1501 AA 428 N476AA
14 2011 1 14 5 1357 1504 AA 428 N552AA
15 2011 1 15 6 1359 1459 AA 428 N462AA
16 2011 1 16 7 1359 1509 AA 428 N555AA
17 2011 1 17 1 1530 1634 AA 428 N518AA
18 2011 1 18 2 1408 1508 AA 428 N507AA
19 2011 1 19 3 1356 1503 AA 428 N523AA
20 2011 1 20 4 1507 1622 AA 428 N425AA
# ... with 2.275e+05 more rows, and 12 more variables: ActualElapsedTime <int>,
# AirTime <int>, ArrDelay <int>, DepDelay <int>, Origin <chr>, Dest <chr>,
# Distance <int>, TaxiIn <int>, TaxiOut <int>, Cancelled <int>,
# CancellationCode <chr>, Diverted <int>
> data.frame(head(flights))
Year Month DayofMonth DayOfWeek DepTime ArrTime UniqueCarrier FlightNum TailNum
1 2011 1 1 6 1400 1500 AA 428 N576AA
2 2011 1 2 7 1401 1501 AA 428 N557AA
3 2011 1 3 1 1352 1502 AA 428 N541AA
4 2011 1 4 2 1403 1513 AA 428 N403AA
5 2011 1 5 3 1405 1507 AA 428 N492AA
6 2011 1 6 4 1359 1503 AA 428 N262AA
ActualElapsedTime AirTime ArrDelay DepDelay Origin Dest Distance TaxiIn TaxiOut
1 60 40 -10 0 IAH DFW 224 7 13
2 60 45 -9 1 IAH DFW 224 6 9
3 70 48 -8 -8 IAH DFW 224 5 17
4 70 39 3 3 IAH DFW 224 9 22
5 62 44 -3 5 IAH DFW 224 9 9
6 64 45 -7 -1 IAH DFW 224 6 13
Cancelled CancellationCode Diverted
1 0 0
2 0 0
3 0 0
4 0 0
5 0 0
6 0 0

> flights[flights$Month==1 & flights$DayofMonth==1, ]


# A tibble: 552 x 21
Year Month DayofMonth DayOfWeek DepTime ArrTime UniqueCarrier FlightNum TailNum
<int> <int> <int> <int> <int> <int> <chr> <int> <chr>
1 2011 1 1 6 1400 1500 AA 428 N576AA
2 2011 1 1 6 728 840 AA 460 N520AA
3 2011 1 1 6 1631 1736 AA 1121 N4WVAA
4 2011 1 1 6 1756 2112 AA 1294 N3DGAA
5 2011 1 1 6 1012 1347 AA 1700 N3DAAA
6 2011 1 1 6 1211 1325 AA 1820 N593AA
7 2011 1 1 6 557 906 AA 1994 N3BBAA
8 2011 1 1 6 1824 2106 AS 731 N614AS
9 2011 1 1 6 654 1124 B6 620 N324JB
10 2011 1 1 6 1639 2110 B6 622 N324JB
# ... with 542 more rows, and 12 more variables: ActualElapsedTime <int>,
# AirTime <int>, ArrDelay <int>, DepDelay <int>, Origin <chr>, Dest <chr>,
# Distance <int>, TaxiIn <int>, TaxiOut <int>, Cancelled <int>,
# CancellationCode <chr>, Diverted <int>

filter(flights, Month==1, DayofMonth==1)


# A tibble: 552 x 21
Year Month DayofMonth DayOfWeek DepTime ArrTime UniqueCarrier FlightNum TailNum
<int> <int> <int> <int> <int> <int> <chr> <int> <chr>
1 2011 1 1 6 1400 1500 AA 428 N576AA
2 2011 1 1 6 728 840 AA 460 N520AA
3 2011 1 1 6 1631 1736 AA 1121 N4WVAA
4 2011 1 1 6 1756 2112 AA 1294 N3DGAA
5 2011 1 1 6 1012 1347 AA 1700 N3DAAA
6 2011 1 1 6 1211 1325 AA 1820 N593AA
7 2011 1 1 6 557 906 AA 1994 N3BBAA
8 2011 1 1 6 1824 2106 AS 731 N614AS
9 2011 1 1 6 654 1124 B6 620 N324JB
10 2011 1 1 6 1639 2110 B6 622 N324JB
# ... with 542 more rows, and 12 more variables: ActualElapsedTime <int>,
# AirTime <int>, ArrDelay <int>, DepDelay <int>, Origin <chr>, Dest <chr>,
# Distance <int>, TaxiIn <int>, TaxiOut <int>, Cancelled <int>,
# CancellationCode <chr>, Diverted <int>
> filter(flights, Month==1 & DayofMonth==1)
# A tibble: 552 x 21
Year Month DayofMonth DayOfWeek DepTime ArrTime UniqueCarrier FlightNum TailNum
<int> <int> <int> <int> <int> <int> <chr> <int> <chr>
1 2011 1 1 6 1400 1500 AA 428 N576AA
2 2011 1 1 6 728 840 AA 460 N520AA
3 2011 1 1 6 1631 1736 AA 1121 N4WVAA
4 2011 1 1 6 1756 2112 AA 1294 N3DGAA
5 2011 1 1 6 1012 1347 AA 1700 N3DAAA
6 2011 1 1 6 1211 1325 AA 1820 N593AA
7 2011 1 1 6 557 906 AA 1994 N3BBAA
8 2011 1 1 6 1824 2106 AS 731 N614AS
9 2011 1 1 6 654 1124 B6 620 N324JB
10 2011 1 1 6 1639 2110 B6 622 N324JB
# ... with 542 more rows, and 12 more variables: ActualElapsedTime <int>,
# AirTime <int>, ArrDelay <int>, DepDelay <int>, Origin <chr>, Dest <chr>,
# Distance <int>, TaxiIn <int>, TaxiOut <int>, Cancelled <int>,
# CancellationCode <chr>, Diverted <int>

> filter(flights, UniqueCarrier=="AA" | UniqueCarrier=="UA")


# A tibble: 5,316 x 21
Year Month DayofMonth DayOfWeek DepTime ArrTime UniqueCarrier FlightNum TailNum
<int> <int> <int> <int> <int> <int> <chr> <int> <chr>
1 2011 1 1 6 1400 1500 AA 428 N576AA
2 2011 1 2 7 1401 1501 AA 428 N557AA
3 2011 1 3 1 1352 1502 AA 428 N541AA
4 2011 1 4 2 1403 1513 AA 428 N403AA
5 2011 1 5 3 1405 1507 AA 428 N492AA
6 2011 1 6 4 1359 1503 AA 428 N262AA
7 2011 1 7 5 1359 1509 AA 428 N493AA
8 2011 1 8 6 1355 1454 AA 428 N477AA
9 2011 1 9 7 1443 1554 AA 428 N476AA
10 2011 1 10 1 1443 1553 AA 428 N504AA
# ... with 5,306 more rows, and 12 more variables: ActualElapsedTime <int>,
# AirTime <int>, ArrDelay <int>, DepDelay <int>, Origin <chr>, Dest <chr>,
# Distance <int>, TaxiIn <int>, TaxiOut <int>, Cancelled <int>,
# CancellationCode <chr>, Diverted <int>
> filter(flights, UniqueCarrier %in% c("AA", "UA"))
# A tibble: 5,316 x 21
Year Month DayofMonth DayOfWeek DepTime ArrTime UniqueCarrier FlightNum TailNum
<int> <int> <int> <int> <int> <int> <chr> <int> <chr>
1 2011 1 1 6 1400 1500 AA 428 N576AA
2 2011 1 2 7 1401 1501 AA 428 N557AA
3 2011 1 3 1 1352 1502 AA 428 N541AA
4 2011 1 4 2 1403 1513 AA 428 N403AA
5 2011 1 5 3 1405 1507 AA 428 N492AA
6 2011 1 6 4 1359 1503 AA 428 N262AA
7 2011 1 7 5 1359 1509 AA 428 N493AA
8 2011 1 8 6 1355 1454 AA 428 N477AA
9 2011 1 9 7 1443 1554 AA 428 N476AA
10 2011 1 10 1 1443 1553 AA 428 N504AA
# ... with 5,306 more rows, and 12 more variables: ActualElapsedTime <int>,
# AirTime <int>, ArrDelay <int>, DepDelay <int>, Origin <chr>, Dest <chr>,
# Distance <int>, TaxiIn <int>, TaxiOut <int>, Cancelled <int>,
# CancellationCode <chr>, Diverted <int>

> flights[, c("DepTime", "ArrTime", "FlightNum")]


# A tibble: 227,496 x 3
DepTime ArrTime FlightNum
<int> <int> <int>
1 1400 1500 428
2 1401 1501 428
3 1352 1502 428
4 1403 1513 428
5 1405 1507 428
6 1359 1503 428
7 1359 1509 428
8 1355 1454 428
9 1443 1554 428
10 1443 1553 428
# ... with 227,486 more rows
> select(flights, DepTime, ArrTime, FlightNum)
# A tibble: 227,496 x 3
DepTime ArrTime FlightNum
<int> <int> <int>
1 1400 1500 428
2 1401 1501 428
3 1352 1502 428
4 1403 1513 428
5 1405 1507 428
6 1359 1503 428
7 1359 1509 428
8 1355 1454 428
9 1443 1554 428
10 1443 1553 428
# ... with 227,486 more rows
kita ingin melihat kolom “Year” hingga “DayofMonth” dan kolom-kolom lain yang
mengandung kata-kata “Taxi” dan “Delay”.
> select(flights, Year:DayofMonth, contains("Taxi"), contains("Delay"))
# A tibble: 227,496 x 7
Year Month DayofMonth TaxiIn TaxiOut ArrDelay DepDelay
<int> <int> <int> <int> <int> <int> <int>
1 2011 1 1 7 13 -10 0
2 2011 1 2 6 9 -9 1
3 2011 1 3 5 17 -8 -8
4 2011 1 4 9 22 3 3
5 2011 1 5 9 9 -3 5
6 2011 1 6 6 13 -7 -1
7 2011 1 7 12 15 -1 -1
8 2011 1 8 7 12 -16 -5
9 2011 1 9 8 22 44 43
10 2011 1 10 6 19 43 43
# ... with 227,486 more rows

> flights[order(flights$DepDelay), c("UniqueCarrier", "DepDelay")]


# A tibble: 227,496 x 2
UniqueCarrier DepDelay
<chr> <int>
1 OO -33
2 MQ -23
3 XE -19
4 XE -19
5 CO -18
6 EV -18
7 XE -17
8 CO -17
9 XE -17
10 MQ -17
# ... with 227,486 more rows
> flights %>%
+ select(UniqueCarrier, DepDelay) %>%
+ arrange(DepDelay) ->dari kecil ke besar
# A tibble: 227,496 x 2
UniqueCarrier DepDelay
<chr> <int>
1 OO -33
2 MQ -23
3 XE -19
4 XE -19
5 CO -18
6 EV -18
7 XE -17
8 CO -17
9 XE -17
10 MQ -17
# ... with 227,486 more rows
> flights %>%
+ select(UniqueCarrier, DepDelay) %>%
+ arrange(desc(DepDelay)) ->dari besar ke kecil
# A tibble: 227,496 x 2
UniqueCarrier DepDelay
<chr> <int>
1 CO 981
2 AA 970
3 MQ 931
4 UA 869
5 MQ 814
6 MQ 803
7 CO 780
8 CO 758
9 DL 730
10 MQ 691
# ... with 227,486 more rows

> flights$Speed <- flights$Distance / flights$AirTime*60 ->(distance/airtime) x 60


> flights[, c("Distance", "AirTime", "Speed")]
# A tibble: 227,496 x 3
Distance AirTime Speed
<int> <int> <dbl>
1 224 40 336
2 224 45 299.
3 224 48 280
4 224 39 345.
5 224 44 305.
6 224 45 299.
7 224 43 313.
8 224 40 336
9 224 41 328.
10 224 45 299.
# ... with 227,486 more rows

> flights %>%


+ select(Distance, AirTime) %>%
+ mutate(Speed = Distance/AirTime*60)
# A tibble: 227,496 x 3
Distance AirTime Speed
<int> <int> <dbl>
1 224 40 336
2 224 45 299.
3 224 48 280
4 224 39 345.
5 224 44 305.
6 224 45 299.
7 224 43 313.
8 224 40 336
9 224 41 328.
10 224 45 299.
# ... with 227,486 more rows

> flights <- flights %>% mutate(Speed = Distance/AirTime*60)


> flights
# A tibble: 227,496 x 22
Year Month DayofMonth DayOfWeek DepTime ArrTime UniqueCarrier FlightNum TailNum
<int> <int> <int> <int> <int> <int> <chr> <int> <chr>
1 2011 1 1 6 1400 1500 AA 428 N576AA
2 2011 1 2 7 1401 1501 AA 428 N557AA
3 2011 1 3 1 1352 1502 AA 428 N541AA
4 2011 1 4 2 1403 1513 AA 428 N403AA
5 2011 1 5 3 1405 1507 AA 428 N492AA
6 2011 1 6 4 1359 1503 AA 428 N262AA
7 2011 1 7 5 1359 1509 AA 428 N493AA
8 2011 1 8 6 1355 1454 AA 428 N477AA
9 2011 1 9 7 1443 1554 AA 428 N476AA
10 2011 1 10 1 1443 1553 AA 428 N504AA
# ... with 227,486 more rows, and 13 more variables: ActualElapsedTime <int>,
# AirTime <int>, ArrDelay <int>, DepDelay <int>, Origin <chr>, Dest <chr>,
# Distance <int>, TaxiIn <int>, TaxiOut <int>, Cancelled <int>,
# CancellationCode <chr>, Diverted <int>, Speed <dbl>

> head(with(flights, tapply(ArrDelay, Dest, mean, na.rm=TRUE)))


ABQ AEX AGS AMA ANC ASE
7.226259 5.839437 4.000000 6.840095 26.080645 6.794643
> head(aggregate(ArrDelay ~ Dest, flights, mean))
Dest ArrDelay
1 ABQ 7.226259
2 AEX 5.839437
3 AGS 4.000000
4 AMA 6.840095
5 ANC 26.080645
6 ASE 6.794643
> flights %>%
+ group_by(Dest) %>% ->mengkelompokkan kolom sebelumnya berdasarkan destination
+ summarise(avg_delay = mean(ArrDelay, na.rm=TRUE)) –> kalau missal nggak ada delay
tetep dihitung..walaupun kosong tetap ikut (na.rm=True)
# A tibble: 116 x 2
Dest avg_delay
<chr> <dbl>
1 ABQ 7.23
2 AEX 5.84
3 AGS 4
4 AMA 6.84
5 ANC 26.1
6 ASE 6.79
7 ATL 8.23
8 AUS 7.45
9 AVL 9.97
10 BFL -13.2
# ... with 106 more rows
- pilih data.frame = “flights”
- group_by = “UniqueCarrier”
- lakukan summarise_each untuk menghitung “mean” terhadap persentase penerbangan yang
“Cancelled” dan “Diverted”
> flights %>%
+ group_by(UniqueCarrier) %>%
+ summarise_each(funs(mean), Cancelled, Diverted)
# A tibble: 15 x 3
UniqueCarrier Cancelled Diverted
<chr> <dbl> <dbl>
1 AA 0.0185 0.00185
2 AS 0 0.00274
3 B6 0.0259 0.00576
4 CO 0.00678 0.00263
5 DL 0.0159 0.00303
6 EV 0.0345 0.00318
7 F9 0.00716 0
8 FL 0.00982 0.00327
9 MQ 0.0290 0.00194
10 OO 0.0139 0.00349
11 UA 0.0164 0.00241
12 US 0.0113 0.00147
13 WN 0.0155 0.00229
14 XE 0.0155 0.00345
15 YV 0.0127 0
Warning message:
funs() is soft deprecated as of dplyr 0.8.0
Please use a list of either functions or lambdas:

# Simple named list:


list(mean = mean, median = median)

# Auto named with `tibble::lst()`:


tibble::lst(mean, median)

# Using lambdas
list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
This warning is displayed once per session.

 Biar tidak merah, funs diganti list (pembaruan dari funs=list)


> flights %>%
+ group_by(UniqueCarrier) %>%
+ summarise_each(list(mean), Cancelled, Diverted)
# A tibble: 15 x 3
UniqueCarrier Cancelled Diverted
<chr> <dbl> <dbl>
1 AA 0.0185 0.00185
2 AS 0 0.00274
3 B6 0.0259 0.00576
4 CO 0.00678 0.00263
5 DL 0.0159 0.00303
6 EV 0.0345 0.00318
7 F9 0.00716 0
8 FL 0.00982 0.00327
9 MQ 0.0290 0.00194
10 OO 0.0139 0.00349
11 UA 0.0164 0.00241
12 US 0.0113 0.00147
13 WN 0.0155 0.00229
14 XE 0.0155 0.00345
15 YV 0.0127 0

# untuk tiap penerbangan, hitung minimum dan maksimum delay untuk kedatangan dan
keberangkatan
> flights %>%
+ group_by(UniqueCarrier) %>%
+ summarise_each(funs(min(., na.rm=TRUE), max(., na.rm=TRUE)), matches("Delay"))
# A tibble: 15 x 5
UniqueCarrier ArrDelay_min DepDelay_min ArrDelay_max DepDelay_max
<chr> <int> <int> <int> <int>
1 AA -39 -15 978 970
2 AS -43 -15 183 172
3 B6 -44 -14 335 310
4 CO -55 -18 957 981
5 DL -32 -17 701 730
6 EV -40 -18 469 479
7 F9 -24 -15 277 275
8 FL -30 -14 500 507
9 MQ -38 -23 918 931
10 OO -57 -33 380 360
11 UA -47 -11 861 869
12 US -42 -17 433 425
13 WN -44 -10 499 548
14 XE -70 -19 634 628
15 YV -32 -11 72 54

> install.packages("reshape2")
WARNING: Rtools is required to build R packages but is not currently installed. Please
download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/ASUS/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependencies ‘stringi’, ‘plyr’, ‘stringr’

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/stringi_1.4.3.zip'


Content type 'application/zip' length 15289558 bytes (14.6 MB)
downloaded 14.6 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/plyr_1.8.4.zip'


Content type 'application/zip' length 1298043 bytes (1.2 MB)
downloaded 1.2 MB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/stringr_1.4.0.zip'
Content type 'application/zip' length 215497 bytes (210 KB)
downloaded 210 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/reshape2_1.4.3.zip'


Content type 'application/zip' length 626841 bytes (612 KB)
downloaded 612 KB

package ‘stringi’ successfully unpacked and MD5 sums checked


package ‘plyr’ successfully unpacked and MD5 sums checked
package ‘stringr’ successfully unpacked and MD5 sums checked
package ‘reshape2’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\ASUS\AppData\Local\Temp\RtmpC83Lbz\downloaded_packages
> library(reshape2)
> names(airquality) <- tolower(names(airquality)) -> mengubah nama kolom biar jadi
kecil semua namanya
> head(airquality)
ozone solar.r wind temp month day
1 41 190 7.4 67 5 1
2 36 118 8.0 72 5 2
3 12 149 12.6 74 5 3
4 18 313 11.5 62 5 4
5 NA NA 14.3 56 5 5
6 28 NA 14.9 66 5 6

> aql <- melt(airquality)


No id variables; using all as measure variables
> aql
variable value
1 ozone 41.0
2 ozone 36.0
3 ozone 12.0
4 ozone 18.0
5 ozone NA
6 ozone 28.0
7 ozone 23.0
8 ozone 19.0
9 ozone 8.0
10 ozone NA
11 ozone 7.0
12 ozone 16.0
13 ozone 11.0
14 ozone 14.0
15 ozone 18.0
16 ozone 14.0
17 ozone 34.0
18 ozone 6.0
19 ozone 30.0
20 ozone 11.0
21 ozone 1.0
22 ozone 11.0
23 ozone 4.0
24 ozone 32.0
25 ozone NA
26 ozone NA
27 ozone NA
28 ozone 23.0
29 ozone 45.0
30 ozone 115.0
31 ozone 37.0
32 ozone NA
33 ozone NA
34 ozone NA
35 ozone NA
36 ozone NA
37 ozone NA
38 ozone 29.0
39 ozone NA
40 ozone 71.0
41 ozone 39.0
42 ozone NA
43 ozone NA
44 ozone 23.0
45 ozone NA
46 ozone NA
47 ozone 21.0
48 ozone 37.0
49 ozone 20.0
50 ozone 12.0
51 ozone 13.0
52 ozone NA
53 ozone NA
54 ozone NA
55 ozone NA
56 ozone NA
57 ozone NA
58 ozone NA
59 ozone NA
60 ozone NA
61 ozone NA
62 ozone 135.0
63 ozone 49.0
64 ozone 32.0
65 ozone NA
66 ozone 64.0
67 ozone 40.0
68 ozone 77.0
69 ozone 97.0
70 ozone 97.0
71 ozone 85.0
72 ozone NA
73 ozone 10.0
74 ozone 27.0
75 ozone NA
76 ozone 7.0
77 ozone 48.0
78 ozone 35.0
79 ozone 61.0
80 ozone 79.0
81 ozone 63.0
82 ozone 16.0
83 ozone NA
84 ozone NA
85 ozone 80.0
86 ozone 108.0
87 ozone 20.0
88 ozone 52.0
89 ozone 82.0
90 ozone 50.0
91 ozone 64.0
92 ozone 59.0
93 ozone 39.0
94 ozone 9.0
95 ozone 16.0
96 ozone 78.0
97 ozone 35.0
98 ozone 66.0
99 ozone 122.0
100 ozone 89.0
101 ozone 110.0
102 ozone NA
103 ozone NA
104 ozone 44.0
105 ozone 28.0
106 ozone 65.0
107 ozone NA
108 ozone 22.0
109 ozone 59.0
110 ozone 23.0
111 ozone 31.0
112 ozone 44.0
113 ozone 21.0
114 ozone 9.0
115 ozone NA
116 ozone 45.0
117 ozone 168.0
118 ozone 73.0
119 ozone NA
120 ozone 76.0
121 ozone 118.0
122 ozone 84.0
123 ozone 85.0
124 ozone 96.0
125 ozone 78.0
126 ozone 73.0
127 ozone 91.0
128 ozone 47.0
129 ozone 32.0
130 ozone 20.0
131 ozone 23.0
132 ozone 21.0
133 ozone 24.0
134 ozone 44.0
135 ozone 21.0
136 ozone 28.0
137 ozone 9.0
138 ozone 13.0
139 ozone 46.0
140 ozone 18.0
141 ozone 13.0
142 ozone 24.0
143 ozone 16.0
144 ozone 13.0
145 ozone 23.0
146 ozone 36.0
147 ozone 7.0
148 ozone 14.0
149 ozone 30.0
150 ozone NA
151 ozone 14.0
152 ozone 18.0
153 ozone 20.0
154 solar.r 190.0
155 solar.r 118.0
156 solar.r 149.0
157 solar.r 313.0
158 solar.r NA
159 solar.r NA
160 solar.r 299.0
161 solar.r 99.0
162 solar.r 19.0
163 solar.r 194.0
164 solar.r NA
165 solar.r 256.0
166 solar.r 290.0
167 solar.r 274.0
168 solar.r 65.0
169 solar.r 334.0
170 solar.r 307.0
171 solar.r 78.0
172 solar.r 322.0
173 solar.r 44.0
174 solar.r 8.0
175 solar.r 320.0
176 solar.r 25.0
177 solar.r 92.0
178 solar.r 66.0
179 solar.r 266.0
180 solar.r NA
181 solar.r 13.0
182 solar.r 252.0
183 solar.r 223.0
184 solar.r 279.0
185 solar.r 286.0
186 solar.r 287.0
187 solar.r 242.0
188 solar.r 186.0
189 solar.r 220.0
190 solar.r 264.0
191 solar.r 127.0
192 solar.r 273.0
193 solar.r 291.0
194 solar.r 323.0
195 solar.r 259.0
196 solar.r 250.0
197 solar.r 148.0
198 solar.r 332.0
199 solar.r 322.0
200 solar.r 191.0
201 solar.r 284.0
202 solar.r 37.0
203 solar.r 120.0
204 solar.r 137.0
205 solar.r 150.0
206 solar.r 59.0
207 solar.r 91.0
208 solar.r 250.0
209 solar.r 135.0
210 solar.r 127.0
211 solar.r 47.0
212 solar.r 98.0
213 solar.r 31.0
214 solar.r 138.0
215 solar.r 269.0
216 solar.r 248.0
217 solar.r 236.0
218 solar.r 101.0
219 solar.r 175.0
220 solar.r 314.0
221 solar.r 276.0
222 solar.r 267.0
223 solar.r 272.0
224 solar.r 175.0
225 solar.r 139.0
226 solar.r 264.0
227 solar.r 175.0
228 solar.r 291.0
229 solar.r 48.0
230 solar.r 260.0
231 solar.r 274.0
232 solar.r 285.0
233 solar.r 187.0
234 solar.r 220.0
235 solar.r 7.0
236 solar.r 258.0
237 solar.r 295.0
238 solar.r 294.0
239 solar.r 223.0
240 solar.r 81.0
241 solar.r 82.0
242 solar.r 213.0
243 solar.r 275.0
244 solar.r 253.0
245 solar.r 254.0
246 solar.r 83.0
247 solar.r 24.0
248 solar.r 77.0
249 solar.r NA
250 solar.r NA
251 solar.r NA
252 solar.r 255.0
253 solar.r 229.0
254 solar.r 207.0
255 solar.r 222.0
256 solar.r 137.0
257 solar.r 192.0
258 solar.r 273.0
259 solar.r 157.0
260 solar.r 64.0
261 solar.r 71.0
262 solar.r 51.0
263 solar.r 115.0
264 solar.r 244.0
265 solar.r 190.0
266 solar.r 259.0
267 solar.r 36.0
268 solar.r 255.0
269 solar.r 212.0
270 solar.r 238.0
271 solar.r 215.0
272 solar.r 153.0
273 solar.r 203.0
274 solar.r 225.0
275 solar.r 237.0
276 solar.r 188.0
277 solar.r 167.0
278 solar.r 197.0
279 solar.r 183.0
280 solar.r 189.0
281 solar.r 95.0
282 solar.r 92.0
283 solar.r 252.0
284 solar.r 220.0
285 solar.r 230.0
286 solar.r 259.0
287 solar.r 236.0
288 solar.r 259.0
289 solar.r 238.0
290 solar.r 24.0
291 solar.r 112.0
292 solar.r 237.0
293 solar.r 224.0
294 solar.r 27.0
295 solar.r 238.0
296 solar.r 201.0
297 solar.r 238.0
298 solar.r 14.0
299 solar.r 139.0
300 solar.r 49.0
301 solar.r 20.0
302 solar.r 193.0
303 solar.r 145.0
304 solar.r 191.0
305 solar.r 131.0
306 solar.r 223.0
307 wind 7.4
308 wind 8.0
309 wind 12.6
310 wind 11.5
311 wind 14.3
312 wind 14.9
313 wind 8.6
314 wind 13.8
315 wind 20.1
316 wind 8.6
317 wind 6.9
318 wind 9.7
319 wind 9.2
320 wind 10.9
321 wind 13.2
322 wind 11.5
323 wind 12.0
324 wind 18.4
325 wind 11.5
326 wind 9.7
327 wind 9.7
328 wind 16.6
329 wind 9.7
330 wind 12.0
331 wind 16.6
332 wind 14.9
333 wind 8.0
334 wind 12.0
335 wind 14.9
336 wind 5.7
337 wind 7.4
338 wind 8.6
339 wind 9.7
340 wind 16.1
341 wind 9.2
342 wind 8.6
343 wind 14.3
344 wind 9.7
345 wind 6.9
346 wind 13.8
347 wind 11.5
348 wind 10.9
349 wind 9.2
350 wind 8.0
351 wind 13.8
352 wind 11.5
353 wind 14.9
354 wind 20.7
355 wind 9.2
356 wind 11.5
357 wind 10.3
358 wind 6.3
359 wind 1.7
360 wind 4.6
361 wind 6.3
362 wind 8.0
363 wind 8.0
364 wind 10.3
365 wind 11.5
366 wind 14.9
367 wind 8.0
368 wind 4.1
369 wind 9.2
370 wind 9.2
371 wind 10.9
372 wind 4.6
373 wind 10.9
374 wind 5.1
375 wind 6.3
376 wind 5.7
377 wind 7.4
378 wind 8.6
379 wind 14.3
380 wind 14.9
381 wind 14.9
382 wind 14.3
383 wind 6.9
384 wind 10.3
385 wind 6.3
386 wind 5.1
387 wind 11.5
388 wind 6.9
389 wind 9.7
390 wind 11.5
391 wind 8.6
392 wind 8.0
393 wind 8.6
394 wind 12.0
395 wind 7.4
396 wind 7.4
397 wind 7.4
398 wind 9.2
399 wind 6.9
400 wind 13.8
401 wind 7.4
402 wind 6.9
403 wind 7.4
404 wind 4.6
405 wind 4.0
406 wind 10.3
407 wind 8.0
408 wind 8.6
409 wind 11.5
410 wind 11.5
411 wind 11.5
412 wind 9.7
413 wind 11.5
414 wind 10.3
415 wind 6.3
416 wind 7.4
417 wind 10.9
418 wind 10.3
419 wind 15.5
420 wind 14.3
421 wind 12.6
422 wind 9.7
423 wind 3.4
424 wind 8.0
425 wind 5.7
426 wind 9.7
427 wind 2.3
428 wind 6.3
429 wind 6.3
430 wind 6.9
431 wind 5.1
432 wind 2.8
433 wind 4.6
434 wind 7.4
435 wind 15.5
436 wind 10.9
437 wind 10.3
438 wind 10.9
439 wind 9.7
440 wind 14.9
441 wind 15.5
442 wind 6.3
443 wind 10.9
444 wind 11.5
445 wind 6.9
446 wind 13.8
447 wind 10.3
448 wind 10.3
449 wind 8.0
450 wind 12.6
451 wind 9.2
452 wind 10.3
453 wind 10.3
454 wind 16.6
455 wind 6.9
456 wind 13.2
457 wind 14.3
458 wind 8.0
459 wind 11.5
460 temp 67.0
461 temp 72.0
462 temp 74.0
463 temp 62.0
464 temp 56.0
465 temp 66.0
466 temp 65.0
467 temp 59.0
468 temp 61.0
469 temp 69.0
470 temp 74.0
471 temp 69.0
472 temp 66.0
473 temp 68.0
474 temp 58.0
475 temp 64.0
476 temp 66.0
477 temp 57.0
478 temp 68.0
479 temp 62.0
480 temp 59.0
481 temp 73.0
482 temp 61.0
483 temp 61.0
484 temp 57.0
485 temp 58.0
486 temp 57.0
487 temp 67.0
488 temp 81.0
489 temp 79.0
490 temp 76.0
491 temp 78.0
492 temp 74.0
493 temp 67.0
494 temp 84.0
495 temp 85.0
496 temp 79.0
497 temp 82.0
498 temp 87.0
499 temp 90.0
500 temp 87.0
[ reached 'max' / getOption("max.print") -- omitted 418 rows ]
> head(aql)
variable value
1 ozone 41
2 ozone 36
3 ozone 12
4 ozone 18
5 ozone NA
6 ozone 28
> tail(aql)
variable value
913 day 25
914 day 26
915 day 27
916 day 28
917 day 29
918 day 30

You might also like