Fairly new to R, so apologies if this is straightforward. I have a survey dataset, and am trying to plot an awareness question with applied weights. I created a separate dataframe for the question (how did you first hear about "x"?), but don't know where to input the weights column
first_heard <- df[!is.na(df$first_heard_numeric), ] %>%
group_by(first_heard_numeric) %>%
summarize(Freq = n()) %>%
mutate(Prop = Freq/sum(Freq)) %>%
arrange(desc(Prop))
this produces a tibble, but it does not have the weights applied:
# A tibble: 8 × 3
first_heard_numeric Freq Prop
<int> <int> <dbl>
1 4 5444 0.579
2 1 1365 0.145
3 2 716 0.0762
4 6 584 0.0621
5 8 466 0.0496
6 3 333 0.0354
7 5 307 0.0327
8 7 187 0.0199
I also eventually want to plot this as a histogram with confidence interval bars, in descending order. I'm unsure on:
- how to calculate and include 95% confidence error bars
- how to convert numeric scores (e.g., 1, 2, 3, etc.) into labels (e.g., 1 = friend, 2 = family, 3 = website, 4 = other, etc.)
- how to sort in descending order
thanks in advance for any suggestions!