将此直方图绘制在R中

问题描述 投票:0回答:1

我需要在Rstudio中绘制一个直方图,其中我具有以下值:1 2 34。它们的频率分别为0.2 0.5 0.2 0.1。我该怎么办?

r plot histogram
1个回答
0
投票

library(ggplot2)

df <- data.frame(points= c(1,2,3,4), data = c(0.2, 0.5, 0.2, 0.1))
ggplot(df, aes(x = points, y = data)) + geom_histogram(stat = "identity")

ggplot2是一个程序包,它允许对图形和图形进行很多操作。

© www.soinside.com 2019 - 2024. All rights reserved.