Giter Club home page Giter Club logo

data-science-collection's Introduction

Data Exploration

Jiaqi Yin 07 May, 2019

knitr::opts_chunk$set(echo = TRUE,nclude=FALSE, cache=TRUE, include=TRUE, message=FALSE, warning=FALSE)
rm(list = ls()) # clean all the data
library(ggplot2)
library(dplyr)
library(tidyr)

library(rms)
library(rmarkdown)

dplyr, tidyr, and ggplots are excellent tools dealing with data. There are so many usefull functions in those packages and sometimes we (I) may forget how to implement those functions. Therefore, I try to make a notebook where I collect some representative work from my previous/current projects. There are no certain orders here. However, once it (this notebook) grows large enough, I will organize it and maybe have blogs for it.

titanic data

getHdata(titanic3)

dat = titanic3 %>% select(survived, pclass, sex, age) # only select those variables

dat$dead = 1 - dat$survived

# dead vs. passeneger class
dat %>%
      group_by(pclass, dead) %>%
      summarise(n = n()) %>% # count number
      mutate(N = sum(n), prop = n / sum(n)) %>% # add prop column
      filter(dead == 1) %>% ggplot(aes(x = pclass, y = prop)) + 
      geom_point(aes(size = N), alpha = 0.7, color = "red") +
      scale_y_continuous(breaks = seq(0, 1, 0.2), limits = c(0, 1)) +
      scale_size_continuous(breaks = c(300, 500, 700), range = c(10,25), name = "Size") + 
      xlab("Passenger Class") +
      ylab("Probability of Death") +
      theme_bw() + # white backgroud
      theme(axis.text.x = element_text(color = "grey20", size = 10, face = "plain"),
            axis.text.y = element_text(color = "grey20", size = 10, face = "plain"),
            axis.title.x = element_text(color = "grey20", size = 15, face = "bold"),
            axis.title.y = element_text(color = "grey20", size = 15, face = "bold"),
            legend.text = element_text(size = 10),
            legend.title = element_text(size = 10, face = "bold"),
            legend.position="bottom")

data-science-collection's People

Contributors

placeboo avatar

Watchers

 avatar

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.