+ 2
Please anyone solve this.
You are working on the Titanic Survivors data set, which includes information on the passengers of the ship. The data is stored in a CSV file, which is already imported in the given code. You want to understand how the class of the ticket impacted the survival rate. For that, you need to find and output the mean class value for the passengers who are adults (Age >= 18), grouped by the Survived column.
10 Respostas
+ 8
Reassign to x when subsetting:
x <- x[x$Age >= 18,]
(You have a typo for Age)
This way, only the rows with Age >= 18 will be kept in x and used for calculating the mean :)
+ 3
Please show your code.
Similar question here:
https://www.sololearn.com/Discuss/2878820/?ref=app
+ 2
Ammara Tayyab ,
the community is willing to help you. but before we can do this, we like to see your code first.
please post it here.
thanks!
+ 1
Lothar
Now where is the error in the program?
x <- read.csv('/usercode/files/titanic.csv')
x[x$age >= 18, ]
tapply(x$Pclass, x$Survived, mean)
+ 1
x <- read.csv('/usercode/files/titanic.csv')
y <- x[x$Age >= 18,]
tapply(y$Pclass, y$Survived, mean)
+ 1
This is working......
x <- read.csv('/usercode/files/titanic.csv')
adult <- x[x$Age>=18,]
tapply(adult$Pclass,adult$Survived,mean)
0
Visit kaggle website you can find dataset as well as source code take a reference
0
Thank you Lisa. It worked.
0
#library("tidyverse")
x <- read.csv('/usercode/files/titanic.csv')
x<-subset(x,Age>=18)
tapply(x$Pclass,x$Survived,mean)
0
x <- read.csv('/usercode/files/titanic.csv')
x <- x[x$Age >= 18,]
tapply(x$Pclass, x$Survived, mean)