吴裕雄--天生自然 R语言数据分析:火箭发射的地点、日期/时间和结果分析
dfS = read.csv("F:\\kaggleDataSet\\spacex-missions\\database.csv") library(dplyr)
library(tidyr)
library(data.table)
library(sqldf)
library(highcharter)
library(ggrepel)
library(leaflet)
library(viridisLite)
library(countrycode)
library(ggplot2)
names(dfS) <- gsub("\\.", "", names(dfS))
dfS$CustomerCountry = sub(x = dfS$CustomerCountry, pattern = "France (Mexico)", replacement = "France", fixed=T) dfS = data.table(sqldf(c("UPDATE dfS SET PayloadType = PayloadName WHERE PayloadType == ''",
"SELECT * FROM main.dfS"), method = "raw"))
dfS = data.table(sqldf(c("UPDATE dfS SET PayloadOrbit = 'Unknown' WHERE PayloadOrbit == ''",
"SELECT * FROM main.dfS"), method = "raw"))
dfS = data.table(sqldf(c("UPDATE dfS SET CustomerName = 'N/A' WHERE CustomerName == ''", "SELECT * FROM main.dfS"),
method = "raw"))
dfS = data.table(sqldf(c("UPDATE dfS SET CustomerType = 'N/A' WHERE CustomerType == ''", "SELECT * FROM main.dfS"),
method = "raw"))
dfS = data.table(sqldf(c("UPDATE dfS SET CustomerCountry = 'N/A'WHERE CustomerCountry == ''",
"SELECT * FROM main.dfS"), method = "raw"))
dfS$PayloadMasskg[is.na(dfS$PayloadMasskg)] <- 'Unknown' dfS = as.data.frame(dfS)
date.chr <- as.character(dfS$LaunchDate)
date <- strptime(date.chr,format="%d %b %Y")
dfS$LaunchDate = date
dfS$LaunchDate = as.Date(dfS$LaunchDate)
hchart(dfS$CustomerCountry, colorByPoint = TRUE, name = "Customer's country") %>%
hc_title(text = "SpaceX Missions by the country of customer") %>% hc_add_theme(hc_theme_flat()) %>%
hc_credits(enabled = TRUE, text = "Sources: SpaceX, NASA", style = list(fontSize = "10px"))
hchart(dfS$CustomerName, colorByPoint = TRUE, name = "Name of the customer") %>%
hc_title(text = "SpaceX Missions by name of the customer") %>% hc_add_theme(hc_theme_ffx()) %>%
hc_credits(enabled = TRUE, text = "Sources: SpaceX, NASA", style = list(fontSize = "10px"))
hchart(dfS$LaunchSite, colorByPoint = TRUE, name = "Launch site") %>%
hc_title(text = "SpaceX Missions by launch site") %>% hc_add_theme(hc_theme_ffx()) %>%
hc_credits(enabled = TRUE, text = "Sources: SpaceX, NASA", style = list(fontSize = "10px"))
hchart(dfS$PayloadType, colorByPoint = TRUE, name = "Type of Paylod") %>%
hc_title(text = "SpaceX Missions by type of Payload") %>% hc_add_theme(hc_theme_ffx()) %>%
hc_credits(enabled = TRUE, text = "Sources: SpaceX, NASA", style = list(fontSize = "10px"))
hchart(dfS$MissionOutcome, colorByPoint = TRUE, name = "Mission outcome") %>%
hc_title(text = "SpaceX Missions by mission outcome") %>% hc_add_theme(hc_theme_ffx()) %>%
hc_credits(enabled = TRUE, text = "Sources: SpaceX, NASA", style = list(fontSize = "10px"))
ggplot(dfS)+ geom_point(aes(VehicleType, LaunchDate), size = 5, color = 'grey60') +
geom_label_repel(aes(VehicleType, LaunchDate, fill = ifelse(dfS$MissionOutcome == 'Failure', 'Failure', 'Success'),
label = PayloadMasskg),fontface = 'bold', color = 'white', size = 6, box.padding = unit(0.35, "lines"),
point.padding = unit(0.5, "lines"),segment.color = 'grey50') +
ggtitle("SpaceX missions outcome by Year, Vehicle and Payload mass in KG")+ labs(x="Vehicle type",y="Year") +
theme(legend.title = element_text(face = "bold", size = 16)) + theme(legend.text = element_text(size = 16)) +
theme(legend.position = "bottom")+ labs(fill = "Mission Outcome") +
theme(plot.title = element_text(size = 22, face = "bold")) +
theme(axis.text=element_text(size=13), axis.title=element_text(size=16,face="bold"))
ggplot(dfS)+ geom_point(aes(LaunchSite, LaunchDate), size = 4, color = 'grey60') +
geom_label_repel(aes(LaunchSite, LaunchDate, fill = ifelse(dfS$MissionOutcome == 'Failure', 'Failure', 'Success'),
label = VehicleType), fontface = 'bold', color = 'white', size = 4, box.padding = unit(0.35, "lines"),
point.padding = unit(0.5, "lines"),segment.color = 'grey50') +
ggtitle("SpaceX missions outcome by Year, Launch site and Vehicle type")+ labs(x="Launch site",y="Year") +
theme(legend.title = element_text(face = "bold", size = 16)) + theme(legend.text = element_text(size = 16)) +
theme(legend.position = "bottom")+ labs(fill = "Mission Outcome") +
theme(plot.title = element_text(size = 22, face = "bold")) +
theme(axis.text=element_text(size=13), axis.title=element_text(size=16,face="bold"))
ggplot(dfS)+ geom_point(aes(LaunchSite, LaunchDate), size = 5, color = 'grey60') +
geom_label_repel(aes(LaunchSite, LaunchDate, fill = ifelse(dfS$MissionOutcome == 'Failure', 'Failure', 'Success'),
label = PayloadType), fontface = 'bold', color = 'white', size = 5, box.padding = unit(0.35, "lines"),
point.padding = unit(0.5, "lines"),segment.color = 'grey50') +
ggtitle("SpaceX missions outcome by Year, Launch Site and Payload Type")+ labs(x="Launch site",y="Year") +
theme(legend.title = element_text(face = "bold", size = 16)) + theme(legend.text = element_text(size = 16)) +
theme(legend.position = "bottom")+ labs(fill = "Mission Outcome") +
theme(plot.title = element_text(size = 22, face = "bold")) +
theme(axis.text=element_text(size=13), axis.title=element_text(size=16,face="bold"))
ggplot(dfS)+ geom_point(aes(VehicleType, LaunchDate), size = 5, color = 'grey60') +
geom_label_repel(aes(VehicleType, LaunchDate, fill = ifelse(dfS$MissionOutcome == 'Failure', 'Failure', 'Success'),
label = PayloadOrbit), fontface = 'bold', color = 'white', size = 5, box.padding = unit(0.35, "lines"),
point.padding = unit(0.5, "lines"),segment.color = 'grey50') +
ggtitle("SpaceX missions outcome by Year, Vehicle type and Payload Orbit")+ labs(x="Vehicle type",y="Year") +
theme(legend.title = element_text(face = "bold", size = 16)) + theme(legend.text = element_text(size = 16)) +
theme(legend.position = "bottom")+ labs(fill = "Mission Outcome") +
theme(plot.title = element_text(size = 22, face = "bold")) +
theme(axis.text=element_text(size=13), axis.title=element_text(size=16,face="bold"))
ggplot(dfS)+ geom_point(aes(CustomerType, LaunchDate), size = 5, color = 'grey60') +
geom_label_repel(aes(CustomerType, LaunchDate, fill = ifelse(dfS$MissionOutcome == 'Failure', 'Failure', 'Success'),
label = CustomerCountry), fontface = 'bold', color = 'white', size = 6, box.padding = unit(0.35, "lines"),
point.padding = unit(0.5, "lines"),segment.color = 'grey50') +
ggtitle("SpaceX missions outcome by Year, Customer type and Customer's country")+ labs(x="Customer type",y="Year") +
theme(legend.title = element_text(face = "bold", size = 16)) + theme(legend.text = element_text(size = 16)) +
theme(legend.position = "bottom")+ labs(fill = "Mission Outcome") +
theme(plot.title = element_text(size = 22, face = "bold")) +
theme(axis.text=element_text(size=13), axis.title=element_text(size=16,face="bold"))
ggplot(dfS)+ geom_point(aes(VehicleType, LaunchTime), size = 5, color = 'grey60') +
geom_label_repel(aes(VehicleType, LaunchTime, fill = ifelse(dfS$MissionOutcome == 'Failure', 'Failure', 'Success'),
label = CustomerName), fontface = 'bold', color = 'white', size = 6, box.padding = unit(0.35, "lines"),
point.padding = unit(0.5, "lines"),segment.color = 'grey50') +
ggtitle("SpaceX missions outcome by Launch time, Vehicle type and Customer's name")+ labs(x="Vehicle type",y="Launch time") +
theme(legend.title = element_text(face = "bold", size = 16)) + theme(legend.text = element_text(size = 16)) +
theme(legend.position = "bottom")+ labs(fill = "Mission Outcome") +
theme(plot.title = element_text(size = 22, face = "bold")) +
theme(axis.text=element_text(size=13), axis.title=element_text(size=16,face="bold"))
ggplot(dfS)+ geom_point(aes(CustomerCountry, LaunchTime), size = 5, color = 'grey60') +
geom_label_repel(aes(CustomerCountry, LaunchTime, fill = ifelse(dfS$MissionOutcome == 'Failure', 'Failure', 'Success'),
label = CustomerName), fontface = 'bold', color = 'white', size = 6, box.padding = unit(0.35, "lines"),
point.padding = unit(0.5, "lines"),segment.color = 'grey50') +
ggtitle("SpaceX missions outcome by Launch time, Customer's country and Customer's name")+
labs(x="Customer's country",y="Launch time") +
theme(legend.title = element_text(face = "bold", size = 16)) + theme(legend.text = element_text(size = 16)) +
theme(legend.position = "bottom")+ labs(fill = "Mission Outcome") +
theme(plot.title = element_text(size = 22, face = "bold")) +
theme(axis.text=element_text(size=13), axis.title=element_text(size=16,face="bold"))
dfS$PayloadMasskg = as.integer(dfS$PayloadMasskg) ggplot(dfS)+ geom_point(aes(LaunchDate, PayloadMasskg), size = 5, color = 'grey60') +
geom_label_repel(aes(LaunchDate, PayloadMasskg, fill = ifelse(dfS$MissionOutcome == 'Failure', 'Failure', 'Success'),
label = CustomerCountry), fontface = 'bold', color = 'white', size = 6, box.padding = unit(0.35, "lines"),
point.padding = unit(0.5, "lines"),segment.color = 'grey50') +
ggtitle("SpaceX missions outcome by Year, Payload mass in KG and Customer's country")+ labs(x="Year",y="Payload mass in KG") +
theme(legend.title = element_text(face = "bold", size = 16)) + theme(legend.text = element_text(size = 18)) +
theme(legend.position = "bottom")+ labs(fill = "Mission Outcome") +
theme(plot.title = element_text(size = 22, face = "bold")) +
theme(axis.text=element_text(size=13), axis.title=element_text(size=16,face="bold"))
吴裕雄--天生自然 R语言数据分析:火箭发射的地点、日期/时间和结果分析的更多相关文章
- 吴裕雄--天生自然 python语言数据分析:开普勒系外行星搜索结果分析
import pandas as pd pd.DataFrame({'Yes': [50, 21], 'No': [131, 2]}) pd.DataFrame({'Bob': ['I liked i ...
- 吴裕雄--天生自然 R语言开发学习:R语言的安装与配置
下载R语言和开发工具RStudio安装包 先安装R
- 吴裕雄--天生自然 R语言开发学习:数据集和数据结构
数据集的概念 数据集通常是由数据构成的一个矩形数组,行表示观测,列表示变量.表2-1提供了一个假想的病例数据集. 不同的行业对于数据集的行和列叫法不同.统计学家称它们为观测(observation)和 ...
- 吴裕雄--天生自然 R语言数据可视化绘图(3)
par(ask=TRUE) opar <- par(no.readonly=TRUE) # record current settings # Listing 11.1 - A scatter ...
- 吴裕雄--天生自然 R语言开发学习:使用键盘、带分隔符的文本文件输入数据
R可从键盘.文本文件.Microsoft Excel和Access.流行的统计软件.特殊格 式的文件.多种关系型数据库管理系统.专业数据库.网站和在线服务中导入数据. 使用键盘了.有两种常见的方式:用 ...
- 吴裕雄--天生自然 R语言开发学习:R语言的简单介绍和使用
假设我们正在研究生理发育问 题,并收集了10名婴儿在出生后一年内的月龄和体重数据(见表1-).我们感兴趣的是体重的分 布及体重和月龄的关系. 可以使用函数c()以向量的形式输入月龄和体重数据,此函 数 ...
- 吴裕雄--天生自然 R语言开发学习:基础知识
1.基础数据结构 1.1 向量 # 创建向量a a <- c(1,2,3) print(a) 1.2 矩阵 #创建矩阵 mymat <- matrix(c(1:10), nrow=2, n ...
- 吴裕雄--天生自然 R语言开发学习:图形初阶(续二)
# ----------------------------------------------------# # R in Action (2nd ed): Chapter 3 # # Gettin ...
- 吴裕雄--天生自然 R语言开发学习:图形初阶(续一)
# ----------------------------------------------------# # R in Action (2nd ed): Chapter 3 # # Gettin ...
随机推荐
- LUA函数闭包
词法定界:当一个函数内嵌套另一个函数的时候,内函数可以访问外部函数的局部变量,这种特征叫做词法定界 table.sort(names,functin (n1,n2) return grades[n1] ...
- MySQL--数据插入
1.创建表的同时插入其他表的数据 CREATE TABLE table_name SELECT ... FROM ... [...] 例: CREATE TABLE tabl_memory EN ...
- python字符串——"奇葩“的内置函数
一.前言 python编程语言里的字符串与我们初期所学的c语言内的字符串还是有一定不同的,比如python字符串里的内置函数就比语言的要多得多:字符串内的书写格式也会有一点差异,例:字符串内含有引 ...
- linux服务器开放防火墙和端口,以及查询状态
自己搞一个自己网站时候,购买的阿里云服务器,发现部署项目访问不到,首先需要确认入站规则是否配置. 一.安全组列表添加 1.打开安全组列表 2.添加入站规则 3.添加安全组规则 二.通过防火墙,开启端口 ...
- CF 1095C Powers Of Two
题目连接:http://codeforces.com/problemset/problem/1095/C 题目: C. Powers Of Two time limit per test 4 seco ...
- Canvas 橡皮擦效果
引子 解决了第一个问题图像灰度处理之后,接着就是做擦除的效果. Origin My GitHub 思路 一开始想到 Canvas 的画布可以相互覆盖的特性,彩色原图作为背景,灰度图渲染到 Canvas ...
- windows下快速安装tensorflow
下载安装文件 https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/ 配置pip参数文件 [global] index-url = https://mi ...
- 虹软最新版 python 接口 完整版
虹软最新版 python 接口 完整版 当前开源的人脸检测模型,识别很多,很多小伙伴也踩过不少坑.相信不少使用过dlib和facenet人脸识别的小伙伴都有这样的疑惑,为什么论文里高达99.8以上的准 ...
- C3D使用指南
C3D GitHub项目地址:https://github.com/facebook/C3D C3D 官方用户指南:https://goo.gl/k2SnLY 1. C3D特征提取 1.1 命令参数介 ...
- iso镜像文件的挂载和yum库的搭建
挂载镜像文件 1.上传镜像文件到服务器(或电脑)的某一目录下 如:(/media/rpm_pack/rhel...iso) 2.root 用户下创建镜像文件挂载目录 mkdir /mnt/vcd ...