这是随机数据
set.seed(123)
# Number of rows in the dataset
num_rows <- 100
# Generate random dataset with 4 columns
random_dataset <- data.frame(
A = runif(num_rows), # Random numbers for column A
B = runif(num_rows), # Random numbers for column B
C = runif(num_rows), # Random numbers for column C
D = sample(c("Male", "Female", "Child"), num_rows, replace = TRUE) # Random values for column D
)
# Display the first few rows of the dataset
head(random_dataset)
library(ggplot2)
# Generate the bar plot with a black border around the bars
ggplot(random_dataset, aes(x = D, y = A)) +
geom_bar(stat = "identity",fill = "skyblue", color = "black") +
geom_errorbar(
aes(ymin = A - sd_A, ymax = A + sd_A),
width = 0.2,
color = "black"
) +
labs(title = "Bar Plot of Column A",
y = "Values for Column A",
x = "Category D") +
theme_classic()
我想要的只是带有误差线的正确条形图,并且每个条上只有一个边框