- Means that the
as.vector(x)
operation resulted in one or more elements ofx
being converted toNA
as the conversion for those components is not defined. - When
mean.default
is called,x
is neither numeric or logical and hence the function can't do anything with the data - Means that
x
ormx
or both are factors and-
(and other mathematical operators) is not defined for factor objects. - See 1. above.
All point to an issue with the input data, usually a factor has been created.
The warnings come from this line:
> coun <- skew(x$Country)
Warning messages:
1: In var(as.vector(x), na.rm = na.rm) : NAs introduced by coercion
2: In mean.default(x) : argument is not numeric or logical: returning NA
3: In Ops.factor(x, mx) : - not meaningful for factors
4: In var(as.vector(x), na.rm = na.rm) : NAs introduced by coercion
This is because x$Country
is a factor:
> str(x)
'data.frame': 1362 obs. of 12 variables:
$ Country : Factor w/ 227 levels "","Afghanistan",..: 19 19 19 19 19 19 166 166 166 166 ...
....
Even if you made this a character you could compute the skewness of this variable. Just comment this line out.