> table(scrounging) substr behav air ground tree vine active 1 5 3 6 foraging 2 6 3 0 inactive 6 1 1 3 snoozing 2 1 3 7 > likert(t(table(scrounging)))
________________________________________ From: R-help <r-help-boun...@r-project.org> on behalf of Jim Lemon <drjimle...@gmail.com> Sent: Wednesday, March 10, 2021 19:35 To: Areti Panopoulou; r-help mailing list Subject: [External] Re: [R] Help please Hi Areti, Maybe this will help: scrounging<-data.frame( behav=sample(c("inactive","active","foraging","snoozing"),50,TRUE), substr=sample(c("tree","ground","vine","air"),50,TRUE)) scrounge.tab<-table(scrounging) barplot(scrounge.tab) legend(3.8,14,c("inactive","active","foraging","snoozing"), fill=c("gray80","gray60","gray40","gray20")) Jim On Thu, Mar 11, 2021 at 9:54 AM Areti Panopoulou <aretipanopou...@gmail.com> wrote: > > Hello, > > I am trying to make a stacked barplot with different behaviours > ("inactive", "active", "foraging" etc) on different substrates ("tree", > "ground" etc). I have found this function: > > # Stacked Bar Plot with Colors and Legend > counts <- table(mtcars$vs, mtcars$gear) > barplot(counts, main="Car Distribution by Gears and VS", > xlab="Number of Gears", col=c("darkblue","red"), > legend = rownames(counts)) > > But don't know how to apply it. Can anybody help me apply the function to > work with my variables ( I can send more information if necessary, or make > any clarifications). > > This is a great help, thanks a lot. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.