To create a barplot with ggplot2, you need to use the geom_bar() function and specify the x and y variables. For example, if you have a data frame called df with two columns dose and len, you can create a basic barplot with this code:

library(ggplot2)
ggplot(data = df, aes(x = dose, y = len)) +
  geom_bar(stat = "identity")
  
This will create a vertical barplot where the height of each bar represents the value of len for each level of dose. You can customize the appearance of the barplot by changing the width, color, fill, position, and labels of the bars. You can also create a horizontal barplot by adding coord_flip() to the plot.

If you want to create a barplot of counts, you don’t need to specify the y variable. Instead, you can just map the x variable to a categorical variable and ggplot2 will count the number of cases in each group. For example, if you have a data frame called mtcars with a column cyl indicating the number of cylinders in each car, you can create a barplot of counts with this code:

ggplot(mtcars, aes(x = factor(cyl))) +
  geom_bar()
This will create a vertical barplot where the height of each bar represents the number of cars with 4, 6, or 8 cylinders. You can customize this barplot as well.