多重箱线图

huangapple go评论92阅读模式
英文:

Multiple BoxPlot

问题

It seems like you want to plot a boxplot in R with multiple categories (A, B, C, etc.) together. Here's how you can do it:

# Assuming you have your data in a data frame called 'your_data'
# 'Category' column should contain A, B, C, etc.

# First, you can install and load the necessary library (if not already installed)
# install.packages("ggplot2")
library(ggplot2)

# Create the boxplot
ggplot(your_data, aes(x = Category, y = Value)) +
  geom_boxplot() +
  labs(title = "Boxplot of A, B, C, ...") +
  theme_minimal()

This code uses the ggplot2 library to create a boxplot. Make sure to replace 'your_data' with the actual name of your data frame and 'Category' and 'Value' with the appropriate column names in your data frame that represent the categories and values you want to plot.

If you want to include additional categories like D, E, F, etc., you can simply add them to your data frame and run the same code. It should automatically include them in the boxplot.

Let me know if you encounter any errors or need further assistance!

英文:

I want to plot a boxplot. I really did some research before raise a question at here. At first I tried in Excel but it caused laggy due to the data is so large. So, I decided to R.

My data consist of 180 of 100x2 data frame. So, it has 180000 rows.

Means, I have 100's of A, 100's of B, and so so.

How can I plot a boxplot that have A, B, C,... so on together in R?

多重箱线图

My desired outcome (but want to have D..E..F..together)

多重箱线图

How can I do that in R? Need help...

答案1

得分: 1

我同意这些评论。您可以通过搜索轻松找到这个,除非我误解了您的需求。另外,请提供您的代码或数据。下面,我创建了随机数据来展示制作分组箱线图的框架。

letters <- c('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J')

data <- data.frame(Type = sample(letters, 200, replace = TRUE),
                   Delta = runif(200, min = -0.05, max = 0.2))

ggplot(data, aes(x = Type, y = Delta, fill = Type)) +
  geom_boxplot() +
  labs(title = "Type vs. Delta",
       x = "Type", y = "Delta") +
  theme_minimal()

多重箱线图

英文:

I agree with the comments. you can easily find this by searching, unless I am misunderstanding what you want. Also, please provide you code or data. Below, I created random data to show the skeleton of what you would do for a clustered boxplot.

letters &lt;- c(&#39;A&#39;, &#39;B&#39;, &#39;C&#39;, &#39;D&#39;, &#39;E&#39;, &#39;F&#39;, &#39;G&#39;, &#39;H&#39;, &#39;I&#39;, &#39;J&#39;)

data &lt;- data.frame(Type = sample(letters, 200, replace = TRUE),
                   Delta = runif(200, min = -0.05, max = 0.2))

ggplot(data, aes(x = Type, y = Delta, fill = Type)) +
  geom_boxplot() +
  labs(title = &quot;Type vs. Delta&quot;,
       x = &quot;Type&quot;, y = &quot;Delta&quot;) +
  theme_minimal()

多重箱线图

huangapple
  • 本文由 发表于 2023年7月31日 22:09:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804441.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定