Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:57:15+00:00 2026-06-13T10:57:15+00:00

I’m analyzing USA election data, candidates contribution, etc. So I got raw data from

  • 0

I’m analyzing USA election data, candidates contribution, etc. So I got raw data from internet and trying to learn some R executing some exercises in it. This is a CSV file that I successfully loaded and analyzed with ?summary.

I also used ?tapply successfully, to separate candidates money contribution by state:

data_amt_st = tapply(data$contb_receipt_amt, data[c('cand_nm', 'contbr_st')], sum)

?str (for a small sample) tells me the format of this data:

> str(data_amt_st)
 num [1:3, 1:21] NA NA 451 NA NA 201 NA NA 200 NA ...
 - attr(*, "dimnames")=List of 2
  ..$ cand_nm  : chr [1:3] "Bachmann, Michele" "Obama, Barack" "Romney, Mitt"
  ..$ contbr_st: chr [1:21] "33" "46" "48" "7" ...

Now I need to filter out values from data_amt_st. I need states that “Obama, Barack” had more contributions than other candidates, but don’t know how to do. Something with ?subset?

Thank you very much.


EDIT 1: Attending what guys told me, about making a more concrete question: I need a list of the states where Barack Obama achieved a higher contribution level (more money) than other candidates.


EDIT 2: Trying to give you a reproducible example (is it correct?):

x = c("a", "b", "c")
y0 = c(3, 5, 1)
y1 = c(2, 1, 6)
y2 = c(4, 2, 3)
m = cbind(x, y0, y1, y2)
m
#      x   y0  y1  y2 
# [1,] "a" "3" "2" "4"
# [2,] "b" "5" "1" "2"
# [3,] "c" "1" "6" "3"

Now, I need to know, for what y values, a is higher than b and c.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:57:16+00:00Added an answer on June 13, 2026 at 10:57 am

    Maybe

    ## max by column (MARGIN=2)
    max_amt <- apply(data_amt_st,MARGIN=2,max,na.rm=TRUE)  
    data_amt_st[,max_amt==data_amt_st["Obama",]]
    

    ?
    (Not sure how this will work with NA values in the Obama row: using dput to give us a reproducible example ( http://tinyurl.com/reproducible-000 ) would be useful …)

    x <- letters[1:3]
    y0 <- c(3, 5, 1)
    y1 <- c(2, 1, 6)
    y2 <- c(4, 2, 3)
    m <- data.frame(y0, y1, y2)
    rownames(m) <- x
    maxvals <- apply(m,2,max,na.rm=TRUE)
    which(m["a",]==maxvals)  ## or
    names(m)[m["a",]==maxvals]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.