Aesthetics must be either length 1 or the same as the data (50): y

Hello my friends,

I have read same question that have been asked by other members. But unfortunately I could not find a solution to my problem. i have written some code to draw a graph and R showed the Fehler: Aesthetics must be either length 1 or the same as the data (50): y
My Codes are:
Code 1.
ifr_for_all <- (service[service$service == "Warehousing", ]$QExecuted / service[service$service == "Warehousing", ]$QScheduled)

error_for_all <- cbind(service [service$service == "Warehousing", ], ifr_for_all)

kpi_warehousing_for_all <-

cbind(sort(unique(error_for_all$vendor)), aggregate(QExecuted ~ vendor + Year, data = error_for_all, sum)[2],

(aggregate(QExecuted ~ vendor + Year, data = error_for_all, sum)[3])/(aggregate(QScheduled ~ vendor + Year, data = error_for_all, sum)[3]))

colnames(kpi_warehousing_for_all) <- c("vendor", "Year" , " IFR ")

ggplot(kpi_warehousing_for_all, aes(Year, ifr, group = vendor, color= vendor)) + geom_point() + geom_line()
Code 2
kpi_warehousing_perRegion <-
cbind(sort(unique(error_for_all$vendor)), aggregate(QExecuted ~ vendor + region, data = error_for_all, sum)[2],
(aggregate(QExecuted ~ vendor + region, data = error_for_all, sum)[3])/(aggregate(QScheduled ~ vendor + region, data = error_for_all, sum)[3]))
colnames(kpi_warehousing_perRegion) <- c("vendor", "region", " IFR ")
ggplot(kpi_warehousing_perRegion, aes(region, ifr_for_all, group = vendor, color= vendor, fill = vendor)) + geom_bar(stat = "identity", position ="dodge") + scale_fill_brewer(palette = "Paired") + scale_color_brewer(palette = "Paired") + coord_cartesian(ylim = c(0.1, 0.215))
If you help me to solve thoes problems, I will be greatful


To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue that includes sample data? Please have a look at this guide, to see how to create one:

1 Like

There's a hint in the error message that the problem is with the y aestethics. Looking at your code you use ifr for y in the kpi_warehousing_for_all, but you have just set the column name to IFR. In kpi_warehousing_perRegion you use ifr_for_all for y, again your column name is IFR. Of course, without af reprex I can only guess.


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.