R/draw_point.R

#' #' Create scatterplot
#' #' 
#' #' @param data Data set
#' #' @param x Variable in x-axis
#' #' @param y Variable in y-axis
#' #' @param ... Variable which differ by color.
#' #' @param size_point Size of point in a plot. Default size: 4.
#' #' @param legend_title Title of the legend. Default name: "Legend".
#' #' @param y_title_name Title of y-axis. Defalut value: name of y variable.
#' #' @param x_title_name Title of x-axis. Defalut value: name of x variable.
#' #' @param save Do you want to save plot? Default value: FALSE.
#' #' @param file_name Name of file we want to see in directory. Default filename: "plot".
#' 
#' 
#' draw_point <- function(data,x, y, ..., size_point = 4,legend_title = "Legend",
#'                        y_title_name = "", x_title_name = "", save = F,
#'                        file_name = "plot"){
#'   ld <- as.lazy_dots(list(x = lazy(x), y = lazy(y))) 
#'   ld <- c(ld, lazy_dots(...))
#'   ld <- as.lazy_dots(lapply(ld, function(x){ 
#'     try(x$expr <- as.name(x$expr), silent=TRUE)
#'     x
#'   }))
#'   cl <- make_call(quote(aes), ld)
#'   
#'   plot <- ggplot(data, eval(cl$expr))+
#'     theme_peru()
#'   if (length(ld) > 2){
#'     plot <- plot+
#'       geom_point(size = size_point)+
#'       scale_color_manual(name = legend_title, values = cat_colors)
#'   }
#'   else{
#'     plot <- plot+
#'       geom_point(size = size_point, color = cat_colors[1])
#'   }
#'   if (y_title_name != "" | x_title_name != "") plot <- describe_axis(x_title_name, y_title_name, plot)
#'   if (save != F) save_plot(file_name, plot)
#'   plot  
#' }
#' 
AMUFacultyOfEnglish/ENRanalytics documentation built on May 5, 2019, 11:36 a.m.