[R] Partial table.

g.romero@utoronto.ca g.romero at utoronto.ca
Wed Dec 20 20:15:07 CET 2000


Try something like this: 
CONTAR_function(X,Y)  {cbind(Y,sapply(1:length(Y),function(Z) sum(X==Y[Z])))}

Giovanni E. Romero
Department of Economics
University of Toronto 

Quoting Kenneth Cabrera <krcabrer at epm.net.co>:

> Hi R users:
> 
> Thank you very much for you help, you are very kind.
> 
> I am again asking for your help to make a function that returns the
> numbers of elements of each category given in another vector.
> 
> I mean, I have a vector "x" with several elements (most of them
> more that once) and other vector "y" with the elements that I want
> to count in the first vector (is not a exhaustive "table or tabulate"
> function).
> And I want to obtain a data frame with one variable with the elements
> in "y" and other with its corresponding frequencies.
> 
> One more question: How can I deal with an unit and an empty vector in a
> function that eliminates an element from a it, given the original vector
> and the index of the
> element to be eliminated?
> 
> Thank you very much for your help
> 
> Kenneth Cabrera
> Universidad Nacional de Colombia
> Sede Medellín
> krcabrer at perseus.unalmed.edu.co
> krcabrer at epm.net.co
> 
> 
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read
> http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> 
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list