Reputation: 21
Ideally with ggplot.
My values are: a = 226.1405 b = 340.9898
Upvotes: 1
Views: 563
Reputation: 887048
We could convert to a data.frame
or tibble
and reshape to 'long' format with pivot_longer
before plotting with ggplot
library(dplyr)
library(ggplot2)
library(tidyr)
tibble(a, b) %>%
pivot_longer(everything()) %>%
ggplot(aes(x = name, y = value)) +
geom_col()
-output
Or using base R
, just create a named vector
and use barplot
barplot(c(a = a, b = b))
a <- 226.1405
b <- 340.9898
Upvotes: 1