+ 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.

15th Sep 2021, 4:28 PM
Ammara Tayyab
10 Respuestas
+ 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 :)
15th Sep 2021, 7:59 PM
Lisa
Lisa - avatar
+ 3
Please show your code. Similar question here: https://www.sololearn.com/Discuss/2878820/?ref=app
15th Sep 2021, 4:48 PM
Lisa
Lisa - avatar
+ 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!
15th Sep 2021, 6:57 PM
Lothar
Lothar - avatar
+ 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)
15th Sep 2021, 7:55 PM
Ammara Tayyab
+ 1
x <- read.csv('/usercode/files/titanic.csv') y <- x[x$Age >= 18,] tapply(y$Pclass, y$Survived, mean)
28th Feb 2022, 3:34 AM
Aran Willetts
+ 1
This is working...... x <- read.csv('/usercode/files/titanic.csv') adult <- x[x$Age>=18,] tapply(adult$Pclass,adult$Survived,mean)
11th Aug 2022, 7:20 PM
Pubudu Ishan Wickrama Arachchi
Pubudu Ishan Wickrama Arachchi - avatar
0
Visit kaggle website you can find dataset as well as source code take a reference
15th Sep 2021, 6:41 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
Thank you Lisa. It worked.
15th Sep 2021, 8:01 PM
Ammara Tayyab
0
#library("tidyverse") x <- read.csv('/usercode/files/titanic.csv') x<-subset(x,Age>=18) tapply(x$Pclass,x$Survived,mean)
28th Feb 2022, 11:30 PM
karthik v
karthik v - avatar
0
x <- read.csv('/usercode/files/titanic.csv') x <- x[x$Age >= 18,] tapply(x$Pclass, x$Survived, mean)
4th Apr 2023, 7:04 AM
Grace Johnruz Imperial