Help for an R studio

I got below project for an ongoing course and facing some difficulties to solve it.

Simply I'm trying to create different types of graphs based on a give excel sheet. When I run the code I


the error shown in the photo. Any help on how it can be resolved?

Below is the code I developed

# Changing format
Data1$Date <- as.Date(Data1$Date)
Data1$Department <- as.factor(Data1$Department)
Data1$Category <- as.factor(Data1$Category)
Data1$CustomerCode <- as.character(Data1$CustomerCode)
Data1$Price <- as.factor(Data1$Price)
Data1$Quantity <- as.factor(Data1$Quantity)

# Summary statistics of a column in R
summary(Data1$Quantity)
summary(Data1$Price)

#count of NA values in each column
sum(is.na(df$Date))
sum(is.na(df$Department))
sum(is.na(df$Category))
sum(is.na(df$CustomerCode))
sum(is.na(df$Price))
sum(is.na(df$Quantity))

#Display a bar chart for Category column.
ggplot(Data1, aes(x = Category))
geom_bar()

#Display the Departments and their revenue using a bar chart
barplot(Data1$Department)

#Create a histogram and box and whisker plot of the Price and Quantity columns
hist(Data1$Price, prob = TRUE, col = "white",main = "")
boxplot(Data1$Price, horizontal = TRUE, axes = FALSE, col = rgb(0, 0.8, 1, alpha = 0.5))
hist(Data1$Quantity, prob = TRUE, col = "white",main = "")
boxplot(Data1$Quantity, horizontal = TRUE, axes = FALSE, col = rgb(0, 0.8, 1, alpha = 0.5))

Hi, welcome!

Please have a look to our homework policy, homework inspired questions are welcome but they should not include verbatim instructions from your course.

The Homework Policy mentions a reproducible example. It is well worth reading it very carefully. It is often impossible to help someone without the information asked for there.

Many thanks for the clarification, I updated the post accordingly

Why does your script of code manipulate Data1 and then report some facts about an df before attempting to plot with Data1 ; is df at all relevant ? Not sure if its a case of you not cleaning up your code; or if its a sign of confusion about how your code works. On its face your error seems impossible as its a claim that Data1$Date is both zero length and length 34433; I struggle to see how I could make my R session believe this about any variable of mine... the closest I can get is if I clearly mistype the variable on the right , so the non-existant column is zero length; but yours doesnt appear to be mistyped.

Its hard to fix any bug that can not be reproduced, to read about reproducing bugs; please read:

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.