Outputting data in bar chart



I am trying to ouput my data into a graph. I have looked at a few examples like:

The below code outputs my data into the table that you can see on the attached image.

If I wanted to get "date_start" on the X axis and "clicks" on the Y axis what is the simplest way todo that?

  # Getting the output into a tidy dataframe
  content_result <- content(report)
  content_result[["paging"]] <- NULL
  result_data <- content_result$data
  result_data <- result_data %>% reduce(bind_rows)
  # Setting classes of variables - numerical, data, etc and putting into a frame called 'import'
  result_data$impressions <- as.numeric(result_data$impressions)
  result_data$unique_clicks <- as.numeric(result_data$unique_clicks)
  result_data$clicks <- as.numeric(result_data$clicks)
  result_data$spend <- as.numeric(result_data$spend)
  result_data$date_start <- as.Date(result_data$date_start)
  result_data$date_stop <- as.Date(result_data$date_stop)
  import <- result_data

sum_by_day <- import  %>%
    group_by(date_start) %>%
    summarise(clicks = sum(clicks), impressions = sum(impressions), spend=sum(spend)) %>%
    mutate(CPC_new=spend/clicks) %>%
    mutate(CTR_new=clicks / impressions)

I asumed from the example https://shiny.rstudio.com/gallery/telephones-by-region.html the below would of been ok, but it just throws back errors.

   output$phonePlot <- renderPlot({
    # Render a barplot
            ylab="Number of clicks",


Any help much apreciated.




You are trying to debug R code while at the same time writing a shiny app. Stop. You're making your life more difficult. Drop back to R and try to do the data manipulations you want to do. Then make the graphs you want. THEN (and only then) wrap them up in a Shiny script.

Your example is completely unreproducible to anyone else. To get good help, try to create an example we can run and see your errors. Here's an example that creates dummy data then produces a barplot that may, or may not resemble what you want. Try following the pattern and creating an illustration we can reproduce. Happy to help as much as I can, but it's hard to help you with what you've provided.

sum_by_day <- data.frame(date_start = 10001:10010,
                         clicks = sample(100:1000, 10)
                   main="clicks per day",
                   ylab="Number of clicks",