-1

I have this code so far that gets me everything I need from all donors. Making a new dataframe for each neighborhood isn't really an option since there are 475 of them

mean(data$AMOUNT < 100)
sum(data$AMOUNT < 100)
mean(data$AMOUNT > 100)
sum(data$AMOUNT > 100)
mean(data$AMOUNT == 100)
sum(data$AMOUNT == 100)
mean(data$AMOUNT == 1500)
mean(data$AMOUNT == 320)
mean(data$AMOUNT == 175)
mean(data$AMOUNT)
median(data$AMOUNT)
Kramer
  • 1
  • In order for us to help you, please provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). For example, to produce a minimal data set, you can use `head()`, `subset()`, or the indices. Then use `dput()` to give us something that can be put in R immediately. Also, please make sure you know what to do [when someone answers your question](https://stackoverflow.com/help/someone-answers). More info can be found at Stack Overflow's [help center](https://stackoverflow.com/help). Thank you! – iamericfletcher Nov 19 '20 at 19:22

1 Answers1

0

There's a good chance that using the tidyverse would be helpful for you (really you just need dplyr for this, but might as well).

install.packages("tidyverse")
library(tidyverse)
data %>% group_by(neighborhood) %>% 
  summarize(und100=mean(AMOUNT<100),sumund100=sum(AMOUNT<100), etc...)
iod
  • 7,094
  • 2
  • 15
  • 33
  • mean(data$AMOUNT == 1500) gives me the percentage of donations that were that exact amount – Kramer Nov 19 '20 at 19:34
  • Oh, I misunderstood what you're trying to get. What I wrote now should give you that. – iod Nov 19 '20 at 19:35
  • Thank you! I figured dplyr would help but I'm so out of practice. Should've known group_by would be what I needed. – Kramer Nov 19 '20 at 19:40
  • 1
    @Kramer Welcome to Stack Overflow! If you haven't done so already, please take some time to review what to do [when someone answers your question](https://stackoverflow.com/help/someone-answers). More info for new Stack Overflow users can be found by visiting the [help center](https://stackoverflow.com/help). – iamericfletcher Nov 19 '20 at 20:00