title: converting old ggplot2 code to new in R
body: <p>I am trying to use following code from <a href="https://gist.github.com/adamwespiser/3077780" rel="nofollow">https://gist.github.com/adamwespiser/3077780</a> : </p>
  
  <pre><code>theme_publish &lt;- function(base_size = 12) {
      structure(list(
      axis.line = theme_blank(),
      axis.text.x = theme_text(size = base_size * 0.8 , lineheight = 0.9, vjust = 1),
      axis.text.y = theme_text(size = base_size * 0.8, lineheight = 0.9, hjust = 1),
      axis.ticks = theme_segment(colour = "black", size = 0.2),
      axis.title.x = theme_text(size = base_size, vjust = 1),
      axis.title.y = theme_text(size = base_size, angle = 90, vjust = 0.5),
      axis.ticks.length = unit(0.3, "lines"),
      axis.ticks.margin = unit(0.5, "lines"),
      legend.background = theme_rect(colour=NA),
      legend.key = theme_rect(colour = "grey80"),
      legend.key.size = unit(1.2, "lines"),
      legend.text = theme_text(size = base_size * 0.8,family = "sans"),
      legend.title = theme_text(size = base_size * 0.8, face = "bold", hjust = 0),
      legend.position = "right",
      panel.background = theme_rect(fill = "white", colour = NA),
      panel.border = theme_rect(fill = NA, colour="grey50"),
      panel.grid.major = theme_blank(),
      panel.grid.minor = theme_blank(),
      panel.margin = unit(0.25, "lines"),
      strip.background = theme_rect(fill = "grey80", colour = "grey50"),
      strip.text.x = theme_text(size = base_size * 0.8),
      strip.text.y = theme_text(size = base_size * 0.8, angle = -90),
      plot.background = theme_rect(colour = NA),
      plot.title = theme_text(size = base_size * 1.2),
      plot.margin = unit(c(1, 1, 0.5, 0.5), "lines")
      ), class = "options")
  } 
  </code></pre>
  
  <p>I am trying to use this function as follows: </p>
  
  <pre><code>ggplot(mtcars,aes(mpg,hp,size=wt))+geom_point()+theme_publish()
  </code></pre>
  
  <p>However, it does not work and there are errors like: </p>
  
  <pre><code>Error: Use 'element_text' instead. (Defunct; last used in version 0.9.1)
  </code></pre>
  
  <p>Can I correct these all at once or do I need to change every line to new code format? Thanks for your help. </p>
  
  <p>Edit: 
  According to comments from @Metrics, I tried to replace all 'theme_' with 'element_', change theme_segment to element_line, load the grid package, change the class to 'theme'. The modified function is:</p>
  
  <pre><code>theme_publish &lt;- function(base_size = 12) {
      structure(list(
      axis.line = element_blank(),
      axis.text.x = element_text(size = base_size * 0.8 , lineheight = 0.9, vjust = 1),
      axis.text.y = element_text(size = base_size * 0.8, lineheight = 0.9, hjust = 1),
      axis.ticks = element_line(colour = "black", size = 0.2),
      axis.title.x = element_text(size = base_size, vjust = 1),
      axis.title.y = element_text(size = base_size, angle = 90, vjust = 0.5),
      axis.ticks.length = unit(0.3, "lines"),
      axis.ticks.margin = unit(0.5, "lines"),
      legend.background = element_rect(colour=NA),
      legend.key = element_rect(colour = "grey80"),
      legend.key.size = unit(1.2, "lines"),
      legend.text = element_text(size = base_size * 0.8,family = "sans"),
      legend.title = element_text(size = base_size * 0.8, face = "bold", hjust = 0),
      legend.position = "right",
      panel.background = element_rect(fill = "white", colour = NA),
      panel.border = element_rect(fill = NA, colour="grey50"),
      panel.grid.major = element_blank(),
      panel.grid.minor = element_blank(),
      panel.margin = unit(0.25, "lines"),
      strip.background = element_rect(fill = "grey80", colour = "grey50"),
      strip.text.x = element_text(size = base_size * 0.8),
      strip.text.y = element_text(size = base_size * 0.8, angle = -90),
      plot.background = element_rect(colour = NA),
      plot.title = element_text(size = base_size * 1.2),
      plot.margin = unit(c(1, 1, 0.5, 0.5), "lines")
      ), class = "theme")
  } 
  </code></pre>
  
  <p>But now I get the error: </p>
  
  <pre><code>Error in if (attr(newtheme, "complete")) return(newtheme) : argument is of length zero 
  </code></pre>
  
  <p>I am not able to make out from which line it is coming from.</p>