Ggplot2 - How to plot computed column

Hi everyone

In my data frame, I computed more columns and want to plot them on the graph.
But it keeps telling me that

Error in FUN(X[[i]], ...) : object 'ABC' not found

It seems that only works on the raw data column
Please help
Thank you

Hi, welcome to the forum

We need a reproducible example (reprex)

It´s necessary to see your ggplot code, because it could has many lack examples, like:

  • To write the aesthetics mapping: aes()
  • The object ABC must have commas if you have a dataframe: ""
  • Write in your ggplot as your data uppercase and lowercase: ABC or abc

I think the variable not found, perhaps ABC should be uppercase or lowercase.

Greetings!! =)

Sorry, this is the first time I posted the question.
As you can see Renevuepervisit is the column I computed.
Whenever I tried to plot it, it would show the error

# A tibble: 91 × 8
    Week Campaign  Visits Revenue  Cost Renevuepervisit Costpervisit  
   <dbl> <chr>      <dbl>   <dbl> <dbl>           <dbl>        <dbl> 
 1     1 Aldebaran     27    2.27  3.76            0.08         0.14 
 2     2 Aldebaran     64   10.8  15.3             0.17         0.24  
 3     3 Aldebaran     80    7.13 10.8             0.09         0.13  
 4     4 Aldebaran     93   11.1  16.9             0.12         0.18  
 5     5 Aldebaran    120   14.3  21.4             0.12         0.18  

The code I run was

ggplot(data = marketing_campaigns, aes(x = Week))+
+     geom_line(aes(y = Revenuepervisit, colour="#606060"))+
+     geom_line(aes(y = Costpervisit, colour="#303030"))+
+     facet_grid(Campaign ~ .)

Thank you

The variable is spelled Renevuepervisit in the tibble but Revenuepervisit in ggplot.

This one's easy, you have a typo. The variable is spelled differently in the tibble and in ggplot.

1 Like

Thank you for spotting this :metal:t3::metal:t3::metal:t3:

This topic was automatically closed 7 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.