library(dplyr)
library(magrittr)
library(ggplot2)
library(ggthemes)

1 import data & Convert the titanic540.csv dataset into data frame as a “tibble.”

midtermidata<-read.csv("http://www.personal.psu.edu/dlp/w540/titanic540.csv ")
midtermidata
data<- tbl_df(midtermdata)
data 

Calculate the proportion of surviving passengers by sex

selected.data1 <- select(data, survived)
selected.data1

Calculate the proportion of surviving passengers.

selected.data <- select(data, sex)
selected.data

Calculate the mean (average) age of surviving female passengers

data %>%
  group_by(survived) %>% 
 summarise(av=mean(survived),na.rm=TRUE)

Calculate the number of surviving passengers 10 years old or younger

selected.data3 <- select(data, survived,age)
selected.data3

Calculate the maximum, minimum, and median age of surviving passengers 10 years old or older

data %>%

 selected.data3 <- select(data, survived,age)%>%
  summarise(av=mean(survived),na.rm=TRUE,min=minimum(survived),na.rm=TRUE,max=maximum(survived),na.rm=TRUE )

Calculate the proportion of surviving passengers by port of embarkation

selected.data4 <- select(data, survived,embarked)
selected.data4

Calculate number of surviving passengers who had any siblings/spouses aboard the Titanic.

selected.data5 <- select(data, survived,sibsp)
selected.data5

Calculate number of surviving passengers who had any parents/children aboard the Titanic.

selected.data6 <- select(data, survived,parch)
selected.data6

Calculate the mean (average) fare that passengers paid by passenger class.

(r) data%>% filted_by(fare())%>% filter(fare)%>% summarise(mean.fare = mean(fare))

#Calculate a regular frequency distribution of the number of parents/children aboard the Titanic of female passenger

(r) titanic.freq <- table(data$parch) titanic.freq cbind(titanic.freq) #Calculate a regular frequency distribution of the number of siblings/spouses of male passengers who had at least one or more (r) titan.freq <- table(data$sibsp) titan.freq cbind(titan.freq)