exploring the data
# This R script will run on our backend. You can write arbitrary code here! # reading data train <- read.csv(“../input/train.csv”, na.strings = c(“NA”,””)) test <- read.csv(“../input/test.csv”, na.strings = c(“NA”,””)) train$Survived <- factor(train$Survived, levels = c(0,1)) train$SibSp <- factor(train$SibSp) train$Parch <- factor(train$Parch) train$Pclass <- factor(train$Pclass) # exploring the data library(ggplot2) g <- ggplot(train, aes(Survived)) g + geom_bar() dev.copy(png, file =”plot0.png”) dev.off() g2 <-ggplot(train, aes(Pclass, fill = Survived)) g2 + geom_bar() + facet_wrap(~Sex) dev.copy(png, file =”plot1.png”) dev.off() g2 <-ggplot(train, aes(Age, fill = Survived)) g2 + geom_histogram(binwidth =5, color=”black”) + facet_wrap(~Sex) dev.copy(png, file =”plot2.png”) dev.off() g2 <-ggplot(train, aes(Embarked, fill = Survived)) g2 + geom_bar() + facet_wrap(~Sex) dev.copy(png, file =”plot3.png”) dev.off() g2 <-ggplot(train, aes(SibSp, fill = Survived)) g2 + geom_bar() + facet_wrap(~Sex) dev.copy(png, file =”plot4.png”) dev.off() g2 <-ggplot(train, aes(Parch, fill = Survived)) g2…
Link to Full Article: exploring the data