Could someone help me fix some errors in my assignment , I try several times but cannot fix

Hi, I'm try to plot a data static but I cannot find where exactly errors happen

var <- c("PassengerId","Survived","Pclass","Sex","Age","SibSp","Parch","Fare")
static_titanic <- titanic[,var]

aggregate(static_titanic[,2:8],list(static_titanic$Sex),mean)
aggregate(static_titanic[,2:8],list(static_titanic$Sex),median)
aggregate(static_titanic[,2:8],list(static_titanic$Sex),sd)

It displays errors such as:
=> aggregate(static_titanic[,2:8],list(static_titanic$Sex),mean)
Warning messages:
1: In mean.default(X[[i]], ...) :
argument is not numeric or logical: returning NA
2: In mean.default(X[[i]], ...) :
argument is not numeric or logical: returning NA

=> aggregate(static_titanic[,2:8],list(static_titanic$Sex),median)
Warning message:
In mean.default(sort(x, partial = half + 0L:1L)[half + 0L:1L]) :
argument is not numeric or logical: returning NA

=> aggregate(static_titanic[,2:8],list(static_titanic$Sex),sd)
Warning messages:
1: In var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm) :
NAs introduced by coercion
2: In var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm) :
NAs introduced by coercion

Your variable is not numeric. You can't calculate the mean of sex.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.