-
Notifications
You must be signed in to change notification settings - Fork 47
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
Example is not equivalent #15
Comments
Also it doesn't render the quoted output. with(mtcars,tapply(mpg,list(cyl,gear),function(x) c(mean(x),sd(x))))
#> 3 4 5
#> 4 Numeric,2 Numeric,2 Numeric,2
#> 6 Numeric,2 Numeric,2 Numeric,2
#> 8 Numeric,2 NULL Numeric,2 Your output seems to the be result of applying only with(mtcars,tapply(mpg,list(cyl,gear),function(x) c(mean(x))))
#> 3 4 5
#> 4 21.50 26.925 28.2
#> 6 19.75 19.750 19.7
#> 8 15.05 NA 15.4 |
If one assigns the result to z, then which.max(z) does work. However, it gives 7, saying the 7th element is the largest, which may not be so convenient. I assume there is a table helper function to deal with this, but I'm not deep enough into tables to say. As to displaying only the means, that's of course why I wrote "E.g." One could do 3 with() calls, or use tapply() with a custom function. |
As to displaying only the means, my point is that with(mtcars,tapply(mpg,list(cyl,gear),function(x) c(mean(x),sd(x))) does not output 3 4 5
4 21.50 26.925 28.2
6 19.75 19.750 19.7
8 15.05 NA 15.4 |
Thanks! Wrote this on my phone, traveling on a train.
Norm
…On Mon, Jul 15, 2019 at 03:23:25PM -0700, Duncan Garmonsway wrote:
As to displaying only the means, my point is that
``` r
with(mtcars,tapply(mpg,list(cyl,gear),function(x) c(mean(x),sd(x)))
```
does not output
``` r
3 4 5
4 21.50 26.925 28.2
6 19.75 19.750 19.7
8 15.05 NA 15.4
```
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#15 (comment)
|
This is not equivalent in an important way: the table form is difficult to use in subsequent commands. For example, try filtering the table for the combination of
cyl
andmpg
that has the highest meanmpg
.The text was updated successfully, but these errors were encountered: