Likert Plot - Age as y axis, response as x axis

34 views Asked by At

enter image description hereI've conducted surveys of fishers based to understand their fishing preferences and am analysing the data in R.

I'd like to make likert plots but divide them into "years fishing" categories (see image). IE have the usual likert plot layout, but have the factors on the y axis be the different amount of time fishing ("0-5", "6-10", "11-15", "16-20", "21-25", "26-30", "31-35", "36-40", "40+")

For example:

One of my questions, is "Has there been any change in the average size of the boat you most commonly fish from?"

The potential responses are:

  1. On average, I fish from smaller boats than I used to
  2. On average, there’s been no change in the size of the boats I fish from
  3. On average, I fish from bigger boats than I used to

I also have a column which asked anglers how many years they have been fishing, values range from 1 to 50.

I'm using the likert package and manage to make the plot without years on the y axis, but am really struggling to layout the data in a way that I can create the plot broken down by year groups.

If anyone has any idea how to do so please let me know.

I used the following code to make Likert Plots successfully:

likert_data <-  select(interview_data, starts_with("Q5."))
likert_data <- likert_data %>%
  mutate(across(everything(), as.factor))
likert_obj <- likert(likert_data)
plot(likert_obj)
1

There are 1 answers

0
jay.sf On

This is fairly easy using barplot. Create a table with proportions first.

> (dat_tb <- with(dat, table(y_fish_cat, any_change)) |> proportions(margin=1))
          any_change
y_fish_cat   smaller no change    bigger
     0-5   0.1428571 0.5714286 0.2857143
     6-10  0.3750000 0.3750000 0.2500000
     11-15 0.0000000 0.5000000 0.5000000
     16-20 0.1250000 0.5000000 0.3750000
     21-25 0.5000000 0.2500000 0.2500000
     26-30 0.4000000 0.5000000 0.1000000
     31-35 0.1428571 0.7142857 0.1428571
     36-40 0.3888889 0.3333333 0.2777778
     40+   0.4761905 0.3333333 0.1904762
> b <- barplot(t(dat_tb), beside=FALSE, horiz=TRUE, col=c(4, 8, 2), las=1)
> xm <- dat_tb/2 + cbind(0, matrixStats::rowCumsums(dat_tb[, -3]))
> text(replace(xm, xm == 0, NA), b, labels=sprintf('%s%%', round(dat_tb*100, 1)))

enter image description here


Data:

n <- 100
set.seed(42)
dat <- data.frame(
  y_fishing=sample.int(50, n, replace=TRUE),
  any_change=factor(sample(c('smaller', 'no change', 'bigger'), n, replace=TRUE),
                    levels=c('smaller', 'no change', 'bigger'))
)
dat <- transform(dat,
                 y_fish_cat=cut(y_fishing, c(seq(0, 40, 5), Inf),
                                labels=c("0-5", "6-10", "11-15", "16-20", 
                                         "21-25", "26-30", "31-35", "36-40", 
                                         "40+")))