-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
158 lines (114 loc) · 4.49 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
---
output: rmarkdown::github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
# SpaceX - An R API wrapper for the SpaceX project
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
```{r setup, include=FALSE, echo = FALSE}
knitr::opts_chunk$set(collapse = TRUE,
comment = "##",
fig.retina = 2,
fig.align = "center",
fig.path = "README_figs/README-")
```
## Installation
Until now the package is not on CRAN but you can download it via GitHub with the following command:
```{r, eval = FALSE}
if (!require("devtools"))
install.packages("devtools")
devtools::install_github("JohannesFriedrich/SpaceX")
```
## Introduction
The **R**-package *SpaceX* is an API wrapper for data collected by https://api.spacexdata.com/v3/ (version v3). You can request available data with different functions:
Function name | Description | Example
--------------------|----------------------------------------------------| -------
get_SpaceX_capsules() | request information on capsules | get_SpaceX_capsules("upcoming")
get_SpaceX_cores() | request information on cores | get_SpaceX_cores(core_serial = "B1037")
get_SpaceX_dragons() | request information on dragon capsules | get_SpaceX_dragons("dragon1")
get_SpaceX_history() | request information on SpaceX history | get_SpaceX_history()
get_SpaceX_info() | request common information on SpaceX | get_SpaceX_info()
get_SpaceX_landpads() | request information on landpads | get_SpaceX_landpads(id = "LZ-4")
get_SpaceX_launches() | request information on launches | get_SpaceX_launches(launch_year = 2020)
get_SpaceX_launchpads() | request information on launchpads | get_SpaceX_launchpads(site_id = "ksc_lc_39a")
get_SpaceX_missions() | request information on missions | get_SpaceX_missions()
get_SpaceX_payloads() | request information on payloads | get_SpaceX_payloads()
get_SpaceX_rockets() | request information on rockets | get_SpaceX_rockets("falcon1")
get_SpaceX_ships() | request information on ships | get_SpaceX_ships()
get_SpaceX_roadster() | request information on SpaceX roadster | get_SpaceX_roadster()
## Request basic information from SpaceX API <a id="basic_information"></a>
First we load some needed packages. The function `get_SpaceX_info()` will deliver some information about the company.
```{r, warning=FALSE, message=FALSE}
library(SpaceX)
library(ggplot2)
library(dplyr)
info <- get_SpaceX_info()
```
```{r, eval = FALSE, echo = FALSE}
info
```
```{r echo=FALSE}
knitr::kable(
info[,1:7],
format = "html"
)
```
## Request upcoming starts
```{r upcoming launches}
upcoming <- get_SpaceX_launches("upcoming")
```
```{r, echo = FALSE}
knitr::kable(upcoming[1:3,1:9],
format = "html")
```
## Play around with data
```{r past_launches}
get_SpaceX_launches() %>%
ggplot() +
geom_bar(aes(launch_year, fill = launch_site$site_name)) +
facet_grid(rocket$rocket_name~launch_success, scales = "free_x") +
theme(legend.position = "bottom") +
scale_fill_discrete(name = "Launch Site") +
labs(x = "Year", y = "Counts") +
theme(legend.position = "bottom",
axis.text.x = element_text(angle = 45, hjust = 1))
```
Now we request some data about the used rockets. This can be done with the function `get_SpaceX_rockets()`.
```{r}
rockets <- get_SpaceX_rockets()
```
```{r, echo = FALSE}
knitr::kable(rockets[,1:9],
format = "html")
```
## Stats 2020
```{r}
stats_2020 <- get_SpaceX_launches(launch_year = 2020)
```
```{r}
launchpads <- get_SpaceX_launchpads()
library(leaflet)
library(htmltools)
leaflet(launchpads) %>%
addProviderTiles(providers$OpenStreetMap) %>%
addTiles() %>%
addMarkers(~location$long, ~location$lat, popup = ~htmltools::htmlEscape(location$name))
```
## Missions
```{r missions}
missions <- get_SpaceX_missions()
```
```{r, echo = FALSE}
knitr::kable(missions[,1:3],
format = "html")
```
## SpaceX support ships
```{r ship}
ship <- get_SpaceX_ships(active = "true")
```
```{r, echo = FALSE}
knitr::kable(ship[1:4,1:7],
format = "html")
```
## Related projects
* [SpaceX](http://www.spacex.com/)
* [SpaceX-API](https://github.com/r-spacex/SpaceX-API)