Hi
or
prop.table(table(foo))
Regards
Petr
r-help-boun...@r-project.org napsal dne 30.09.2010 03:45:30:
> On Wed, Sep 29, 2010 at 6:43 PM, Gundala Viswanath
wrote:
> > I have a vector that looks like this:
> >
> >> foo
> > [1] "o" "o" "o" "x" "o" "o" "o" "o" "o" "x" "x" "o" "x
> >
> > How can
sum(foo=="o")/length(foo)
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-get-a-proportion-of-a-Vector-Member-tp2720060p2720067.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
Try this:
prop.table(table(foo))
On Wed, Sep 29, 2010 at 10:43 PM, Gundala Viswanath wrote:
> I have a vector that looks like this:
>
> > foo
> [1] "o" "o" "o" "x" "o" "o" "o" "o" "o" "x" "x" "o" "x
>
> How can we find the percentage of "o" and "x" in
> that vector in R?
>
> - G.V
>
> _
On Wed, Sep 29, 2010 at 6:43 PM, Gundala Viswanath wrote:
> I have a vector that looks like this:
>
>> foo
> [1] "o" "o" "o" "x" "o" "o" "o" "o" "o" "x" "x" "o" "x
>
> How can we find the percentage of "o" and "x" in
> that vector in R?
table(foo)/length(foo)
Peter
I have a vector that looks like this:
> foo
[1] "o" "o" "o" "x" "o" "o" "o" "o" "o" "x" "x" "o" "x
How can we find the percentage of "o" and "x" in
that vector in R?
- G.V
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-he
5 matches
Mail list logo