吴裕雄--天生自然 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 ...
随机推荐
- Android巩固之事件分发机制
https://www.cnblogs.com/liaojie970/p/5869152.html onTouchEvent是真正用来进行业务逻辑处理的地方,返回true表示已经将该事件消费,返回fa ...
- python的稀疏矩阵计算
尽量避免稀疏矩阵, 加快计算. 比如计算稀疏矩阵S的F范数 a = norm(S, 'fro'), 方法1效率比方法2高很多. 方法 1 import numpy as np a = np.linal ...
- 吴裕雄--天生自然 PYTHON3开发学习:输入和输出
str = input("请输入:"); print ("你输入的内容是: ", str) # 打开一个文件 f = open("/tmp/foo.t ...
- 让debian8.8不休眠,debian设置不休眠模式,因为我的本本休眠了时间不准确了,得重新同步
第一步:sudo vi /etc/systemd/logind.conf /*最好备份下再修改*/ 把下面的参数改为ignoreHandleLidSwitch=ignore 第二步: sudo ser ...
- TPO1-2 The Origin of Theater
Stories (myths) may then grow up around a ritual. Frequently the myths include representatives of th ...
- Java注解基础
0.背景 Java注解--Annotation产生于JDK5.作为code的特殊“标记”,注解可以在编译.类加载.运行时被读取,并执行处理. 开发利用注解在源码中嵌入补充信息,工具(代码分析.开发.部 ...
- 4412开发板QtE系统下MT6620-wifi的测试
基于iTOP4412系统烧写并启动之后,使用如下命令.wpa_passphrase XXX "YYY " >> /etc/wpa_supplicant.conf其中 X ...
- space sniffer
space sniffer 一款检测本地磁盘文件占用情况的工具,高效,快速.
- git命令简单使用
git config --global user.name 'sss' git config --global user.email 'huahua@163.com' cd d:/mywork git ...
- VS2010 保护视力 背景色设置
vs2010——工具——选项---环境——字体和颜色——纯文本——项背景色——自定义 色调:88 饱和度:92 亮度:209