Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply-on-nonnumeric-columns #21

Open
noamross opened this issue Mar 24, 2015 · 0 comments
Open

apply-on-nonnumeric-columns #21

noamross opened this issue Mar 24, 2015 · 0 comments

Comments

@noamross
Copy link
Owner

https://github.com/noamross/zero-dependency-problems/blob/master/R/apply-on-nonnumeric-columns.md

I'm having some trouble applying things to a subset of the dataframe I'm using.

Diet121 <- subset(ChickWeight, Diet == 1 & Time == 21)

This works fine, and gives the subset I want, but when I try to apply the mean to the columns, I get an error message

apply(Diet121, 2, mean)
weight Time Chick Diet
NA NA NA NA
Warning messages:
1: In mean.default(newX[, i], ...) :
argument is not numeric or logical: returning NA
2: In mean.default(newX[, i], ...) :
argument is not numeric or logical: returning NA
3: In mean.default(newX[, i], ...) :
argument is not numeric or logical: returning NA
4: In mean.default(newX[, i], ...) :
argument is not numeric or logical: returning NA

I'm assuming I'm doing something stupid such as not attaching something correctly. Is something wrong with 'mean'?

noamross added a commit that referenced this issue Mar 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant