[R] How to use tapply with more than one variables grouped

2012-10-21 Thread noobmin
I'm studying alone the R language for data preparation. I found a course at
MIT for data preparation that uses python but I'm using R to learning. The
first exercise is the preparation of data from a database that shows the
contributions made to candidates for U.S. president. The database is
described in FORMART
ftp://ftp.fec.gov/FEC/Presidential_Map/2012/DATA_DICTIONARIES/CONTRIBUTOR_FORMAT.txt
link. I wonder how to print the table showing how many states are President
Obama the top candidate (by full amount of donations received) with R
language?

I try using tapply method but, i dont understand how to working with more
than one variable grouped. Could anyone help me in advance of the studies?



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-tapply-with-more-than-one-variables-grouped-tp4646948.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 use tapply with more than one variables grouped

2012-10-22 Thread noobmin
interTable <-data.frame (Tapply ($ contb_receipt_amt date, list ($ cand_nm
date, $ contbr_st date), sum))

I got create a table with the sum total contribution (contb_receipt_amt) of
each presidential candidate (cand_nm) in each state (contbr_st). How could
from interTable create a table of  states where candidate 'Obama' has
received greater Contribution?

thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-tapply-with-more-than-one-variables-grouped-tp4646948p4646985.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 use tapply with more than one variables grouped

2012-10-23 Thread noobmin
I believe that previously could not be understood. To facilitate'll give you
an example. Assuming my table is presented below with the amount received
from each candidate for president in a particular country state.


   AL  AR  CA  NY
Doug 250 250 250  NA
Jennifer  20 340 300 100
Michele  250 500 250  60
Obama 15  45 520 600

I would like to list the states where Obama has higher amount received (ie
in CA and NY) and also the number of states, in this case 2. How to do this?

Thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-tapply-with-more-than-one-variables-grouped-tp4646948p4647111.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 use tapply with more than one variables grouped

2012-10-23 Thread noobmin
To take this example I reduced the number of records absurdly. In the
original database there are 48 000 candidates and dozens of states. There is
no way to analyze data visually. I would not put 400 mb of tables here. But
based on the example how could list the states where obama received more
contribution?




--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-tapply-with-more-than-one-variables-grouped-tp4646948p4647175.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 use tapply with more than one variables grouped

2012-10-23 Thread noobmin
The criteria is to list where Obama has a higher number of contributions. The
table shows the number of contribution that each presidential candidate
received in a state of the country.

The table shown is an example, the query should be generic to a database
with hundreds of candidates and dozens of states of the country. The
original base has 450 mb, in real database I'm don't know  how many contry
states Obama has more donations, but in sample is in CA and NA. Michelle
wins more contribution on AR

Thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-tapply-with-more-than-one-variables-grouped-tp4646948p4647196.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 use tapply with more than one variables grouped

2012-10-23 Thread noobmin
Thank you! This seems to work, just do not understand why you used a
threshold?

I will study your solution, thanks again!



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-tapply-with-more-than-one-variables-grouped-tp4646948p4647199.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 use tapply with more than one variables grouped

2012-10-23 Thread noobmin
I meant where obama has higher value compared to other candidates. Looking at
the column NY, Obama has the highest. So to state that he wins. Looking for
AR column, Michelle wins. I JUST want to list where obama wins.

Thank you! This seems to work, just do not understand why you used a
threshold? 

I will study your solution, thanks again!



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-tapply-with-more-than-one-variables-grouped-tp4646948p4647203.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.