What does the t in tapply stand for?
Asked Answered
C

3

14

There seems to be general agreement that the l in "lapply" stands for list, the s in "sapply" stands for simplify and the r in "rapply" stands for recursively. But I could not find anything on the t in "tapply". I am now very curious.

Clangor answered 21/4, 2015 at 23:33 Comment(1)
No idea - t for tabulating the data into groups?Udella
P
14

Stands for table since tapply is the generic form of the table function. You can see this by comparing the following calls:

x <- sample(letters, 100, rep=T)
table(x)
tapply(x, x, length)

although obviously tapply can do more than counting.

Also, some references that refer to "table-apply":

Parapodium answered 22/4, 2015 at 1:20 Comment(0)
R
5

I think of it as 'table'-apply since the result comes as a matrix/table/array and its dimensions are established by the INDEX arguments. An R table-classed object is really very similar in contrcution and behavior to an R matrix or array. The application is being performed in a manner similar to that of ave. Groups are first assembled on the basis of the "factorized" INDEX argument list (possibly with multiple dimensions) and a matrix or array is returned with the results of the FUN applied to each cross-classified grouping.

The other somewhat similar function is 'xtabs'. I keep thinking it should have a "FUN" argument, but what I'm probably forgetting at that point is really tapply.

Remotion answered 22/4, 2015 at 0:58 Comment(0)
M
2

tapply is sort of the odd man out. As far as I know, and as far as the R documentation for the apply functions goes, the 't' does not stand for anything, unlike the other apply functions which indicate the input or output options.

Melanesian answered 21/4, 2015 at 23:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.