Advertisements
I have a data that look like this:
cis_distance_freq4
# A tibble: 6 × 2
distance freq
<dbl> <dbl>
1 0 NA
2 1000 4380
3 10000 4381
4 40000 4535
5 80000 4536
6 1000000 4558
hist(cis_distance$freq)
I want to plot in such a way that x axis is distance and y axis is freq.
Does anyone know how to plot this.
>Solution :
Here’s the ggplot()
solution, using geom_bar()
with stat="identity"
.
library(ggplot2)
cis_distance_freq4 <- tibble::tribble(
~distance, ~freq,
0, NA,
1000, 4380,
10000, 4381,
40000, 4535,
80000, 4536,
1000000, 4558)
ggplot(cis_distance_freq4, aes(x=as.factor(distance), y=freq)) +
geom_bar(stat="identity", width=.99)
#> Warning: Removed 1 rows containing missing values (`position_stack()`).
Created on 2023-03-28 with reprex v2.0.2