[r] ggplot drawing error "object 'viewsCount' not found"

histogram_plot <- function(varnames,binwidth,dataset){
  graph <- ggplot(aes(x = varnames),data = dataset)+
  geom_histogram(binwidth = binwidth)
  return(graph)
}

histgram_plot(viewsCount,50,timeline)+
  xlim(c(0,8000))

Code as above, create a new function histogram_plot, and call this function in error. Checked for the variable viewsCount in the timeline data box.

if timeline$viewsCount is passed in, the graph can be drawn normally.

Jun.02,2022

ggplot (aes (x = varnames), data = dataset)
modify to
ggplot (aes_string (x = varnames), data = dataset)

ref: What is the difference between aes and aes_string (ggplot2) in R-Stack Overflow

  • Questions about ggplot2 theme setting

    copy the theme setting code in "R language practice " by hand. I don t know why I always report an error. The code is as follows: library(ggplot2) data(Salaries, package= car ) mytheme<-(plot.title=element_text(face= bold.italic ,size=14,colo...

    Mar.01,2021
  • R language, calculating the mean of an element in data.frame

    topic description data source, the diamonds, preview of the ggplot2 package is as follows mean(diamonds[which(diamonds$cut== Ideal ),]$price) problem description 1, is there a more convenient way to calculate the mean value of the y-axis of a ba...

    Oct.25,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c0c6b6-4707e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c0c6b6-4707e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?