How do i do a histogram if I have only the frequency table with its respective classes. Something like:
n.sells abs.freq
1 [30-35) 2
2 [35-40) 10
3 [40-45) 18
4 [45-50) 50
5 [50-55) 70
6 [55-60) 30
7 [60-65) 18
8 [65-70) 2
FJCC
December 15, 2021, 4:42pm
2
Here are two versions.
library(tibble)
library(ggplot2)
DF <- tribble(~n.sells, ~abs.freq,
"[30-35)", 2,
"[35-40)", 10,
"[40-45)", 18,
"[45-50)", 50,
"[50-55)", 70,
"[55-60)", 30,
"[60-65)", 18,
"[65-70)", 2)
barplot(abs.freq~n.sells,data = DF)
ggplot(DF,aes(n.sells,abs.freq)) + geom_col()
Created on 2021-12-15 by the reprex package (v2.0.1)
wow!! thanks a lot! However, using only 'hist', how can i do it? I made one using barplot but isn't acceptable. Is there a way to always do it when I have only this type of table?
FJCC
December 15, 2021, 5:04pm
5
Well, having a frequency table you can make a mock data set, as in the code below. I do not see how that would be a useful thing to do, but the world is full of wonders.
DF <- tribble(~n.sells, ~abs.freq,
"[30-35)", 2,
"[35-40)", 10,
"[40-45)", 18,
"[45-50)", 50,
"[50-55)", 70,
"[55-60)", 30,
"[60-65)", 18,
"[65-70)", 2)
Vals <- seq(30,65,5)
DATA <- unlist(mapply(function(V,f) rep(V,f), Vals, DF$abs.freq))
hist(DATA,breaks=Vals,right = FALSE)
system
Closed
December 22, 2021, 5:05pm
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.