Re: [R] How to get a proportion of a Vector Member
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 we find the percentage of "o" and "x" in > > that vector in R? > > > table(foo)/length(foo) > > Peter > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get a proportion of a Vector Member
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 https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get a proportion of a Vector Member
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 > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get a proportion of a Vector Member
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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to get a proportion of a Vector Member
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-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.