0

Why the output is not correct?

I am trying to finish the last code project in R language, but I do not why I can not get the expected output. I can not get the correct mean https://code.sololearn.com/cOY0N3X7V9kK/?ref=app

15th Sep 2022, 1:15 PM
Mohammad Reza Moravejolahkami
Mohammad Reza Moravejolahkami - avatar
6 Answers
+ 2
You can approach the task like this: 1. Make a subset of the data, only keep those rows for which age is >= 18 2. Use the subset to calculate the means (with tapply) x$Age >= 18 will not work as it only returns a vector of booleans
15th Sep 2022, 1:38 PM
Lisa
Lisa - avatar
+ 1
x <- read.csv('/usercode/files/titanic.csv') x <- x[x$Age >= 18, ] tapply(x$Pclass, x$Survived, mean)
15th Sep 2022, 1:26 PM
SoloProg
SoloProg - avatar
+ 1
Thank you guys, But what is Pclass SoloProg ?
16th Sep 2022, 3:43 AM
Mohammad Reza Moravejolahkami
Mohammad Reza Moravejolahkami - avatar
+ 1
Read the task description again: You are supposed to calculate the mean class grouped by survivial
16th Sep 2022, 6:24 AM
Lisa
Lisa - avatar
+ 1
Lisa DM is not working: Was willst du mit 🐈
16th Sep 2022, 11:00 AM
Oma Falk
Oma Falk - avatar
0
Kkk
16th Sep 2022, 10:10 PM
Bendaoud Mohamed Sabri
Bendaoud Mohamed Sabri - avatar