Help guys am confused | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help guys am confused

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.

17th Jul 2022, 9:31 AM
Thandolwenkosi
6 Answers
+ 3
Please LINK your code attempt. "Help" does not mean that we write the code for you. Please mention the task number.
17th Jul 2022, 9:58 AM
Lisa
Lisa - avatar
+ 2
You didn't spell the column names correctly. And look at the task description carefully: You need to get the mean passenger class, not the mean age
24th Jul 2022, 8:56 AM
Lisa
Lisa - avatar
+ 1
The issue is that you are trying to apply by() to 2 different data frames: the original data x and the subset data y. You need to perform by() on the dataset y only
20th Jul 2022, 4:29 PM
Lisa
Lisa - avatar
0
x <- read.csv('/usercode/files/titanic.csv') y<-x[x$age>=18,] m<-by(y$age,x$survived,mean) print(m) This is my code
20th Jul 2022, 4:02 PM
Thandolwenkosi
0
Okay meaning that where ever l have x on the by() it should be changed to y l did that l didn't get the answer
24th Jul 2022, 8:31 AM
Thandolwenkosi
0
x <- read.csv('/usercode/files/titanic.csv') y<-x[x$age>=18,] res<-by(y$age,y$survived,mean) print(res)
24th Jul 2022, 8:32 AM
Thandolwenkosi