0

For this project, I have to use just basic r So I am making a bunch of boxplots and want their widths to be varied based on how many people answered each response, but the data is separated by country. So when I use

boxplot(timetravel~country+travel,data=data,varwidth=TRUE)

the width is based on number of the responses out of the whole. However there are twice as many responses from New Zealand than from the US. Is there a way to do something where width is halved if country="New Zealand"

Sorry if this is a confusing question I'm very new to R

This is the current graph, the New Zealand Boxplots are twice as large bc there was a twice as large sample size

current graph

steveb
  • 5,382
  • 2
  • 27
  • 36
Zoe Nepsa
  • 1
  • 1
  • 2
    Welcome to Stackoverflow. Please see [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). It is best to have a small data set provided to reproduce the issue; you can use `dput(some_data_frame)` output to provide the input data. – steveb Oct 30 '18 at 04:49
  • 1
    The use of `varwidth=TRUE` already accounts for varying the width based on the number of samples. If the number of responses in NZ is twice that of the US, then you should want the box to be twice the *area*. This means the width should be 1.41 times the *width*, which is what `varwidth=TRUE` does. If you want to normalize *by country*, then we need more information to help (specifically: representative sample of `data` or similar dataset). – r2evans Oct 30 '18 at 05:07

0 Answers0