问题
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.
回答1:
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":
- R and S Plus companion
- Modern Applied Biostatistical Methods
回答2:
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
.
回答3:
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.
来源:https://stackoverflow.com/questions/29785037/what-does-the-t-in-tapply-stand-for