Hello, I am a new R user, still not familiar with the commands of R. In the picture attached, I followed what has been taught by the lecturer to come out with this chart. However, the legend took up too many space. I would like to know if there is any way to make the columns from three to one, so that all the keys will be only in one column.
Welcome to R))
Yes, it is possible to make it one column. Add + guides(fill = guide_legend(ncol = 1)) to the code for your plot and it should solve your problem.
Hint, 99% of the questions regarding ggplot can be solved by simple googling. You, most likely, will find a solution in top 3 (sometimes top 1) of the googles return. For this instance I googled "ggplot legend one column" because I didn't remember exact command)