Giter Site home page Giter Site logo

spacex's Introduction

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.

Installation

Until now the package is not on CRAN but you can download it via GitHub with the following command:

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

First we load some needed packages. The function get_SpaceX_info() will deliver some information about the company.

library(SpaceX)
library(ggplot2)
library(dplyr)

info <- get_SpaceX_info()
name founder founded employees vehicles launch\_sites test\_sites
SpaceX Elon Musk 2002 7000 3 3 1

Request upcoming starts

upcoming <- get_SpaceX_launches("upcoming")
flight\_number mission\_name mission\_id launch\_year launch\_date\_unix launch\_date\_utc launch\_date\_local is\_tentative tentative\_max\_precision
1 110 CRS-21 EE86F74 2020 1607271420 2020-12-06T16:17:00.000Z 2020-12-06T11:17:00-05:00 FALSE hour
2 110 SXM-7 2020 1607880600 2020-12-13T17:30:00.000Z 2020-12-13T12:30:00-05:00 FALSE hour
NA NA NA NULL NA NA NA NA NA NA

Play around with data

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().

rockets <- get_SpaceX_rockets()
id active stages boosters cost\_per\_launch success\_rate\_pct first\_flight country company
1 FALSE 2 0 6.7e+06 40 2006-03-24 Republic of the Marshall Islands SpaceX
2 TRUE 2 0 5.0e+07 97 2010-06-04 United States SpaceX
3 TRUE 2 2 9.0e+07 100 2018-02-06 United States SpaceX
4 FALSE 2 0 7.0e+06 0 2021-12-01 United States SpaceX

Stats 2020

stats_2020 <- get_SpaceX_launches(launch_year = 2020)
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

missions <- get_SpaceX_missions()
mission\_name mission\_id manufacturers
Thaicom 9D1B7E0 Orbital ATK
Telstar F4F83DE SSL
Iridium NEXT F3364BF Orbital ATK
Commercial Resupply Services EE86F74 SpaceX
SES 6C42550 Orbital ATK , Boeing , Airbus Defence and Space
JCSAT FE3533D SSL
AsiaSat 593B499 SSL
Orbcomm OG2 CE91D46 Sierra Nevada Corporation
ABS 2CF444A Boeing
Eutelsat F7709F2 Boeing

SpaceX support ships

ship <- get_SpaceX_ships(active = "true")
ship\_id ship\_name ship\_model ship\_type roles active imo
GOMSCHIEF GO Ms Chief NA High Speed Craft Fairing Recovery TRUE 9744453
GOMSTREE GO Ms Tree NA High Speed Craft Fairing Recovery TRUE 9744465
GONAVIGATOR GO Navigator NA Cargo Support Ship , Fairing Recovery TRUE 9566887
GOQUEST GO Quest NA Cargo Support Ship TRUE 1155515

Related projects

spacex's People

Contributors

johannesfriedrich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

da505819

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.