zoukankan      html  css  js  c++  java
  • R(week 8)

    library(ggplot2)
    library(tidyverse)
    
    mtcars
    dim(mtcars)
    head(mtcars)
    
    ?qplot
    qplot(data = mtcars, x = wt, y = mpg) +
      ggtitle(" sjdklfd skdjskfl  dsfs") + 
      theme(plot.title = element_text(hjust = 0.5)) + 
      xlab("x") + 
      ylab("y")
    
    grep("^geom", objects("package:ggplot2"), value = TRUE)
    
    qplot(mpg, wt, data = mtcars, color = factor(cyl),
      geom = c("point", "line"))
    qplot(mpg, wt, data = mtcars, color = cyl, 
          geom = c("point", "line"))
    p <- qplot(data = mtcars, x = wt, y = mpg, shape = factor(cyl)) +
      scale_shape_manual("Number of
     Clylinder", values = c(3, 5, 8)) +
      scale_color_manual(values = c("red", "blue", "green"))
    qplot(data = mtcars, x = wt, y = mpg, color = factor(gear)) +
      #facet_grid(gear~.)
      facet_grid(gear~cyl, label = label_both)
    qplot(factor(mtcars$cyl), geom = "bar")
    
    qplot(factor(mtcars$cyl), geom = "blank", fill = factor(mtcars$am),
          xlab = "", ylab = "", main = "sdfsdfsf") + 
            geom_bar(position = "dodge") + 
            scale_x_discrete(label = c("V4", "V6", "V8"))+
            scale_y_continuous(breaks = seq(0, 12, 2)) +
            theme_bw() +
            coord_flip()+
            scale_fill_grey(name = "Trans.",
                            labels = c("auto", "manual"))
    ggplot() +
      geom_point(data = mtcars, mapping = aes( x = wt, y = mpg, shape = factor(cyl)),
                 size = 3)+
      geom_smooth(data = mtcars, mapping = aes( x = wt, y = mpg),
                  method = 'lm')
    ggplot(data = mtcars, aes(x=wt, y = mpg)) + 
      geom_point(aes(color = factor(cyl)))+
      geom_smooth(method = 'lm')
                            
                            
                            
                            
                            
                            
          
    

      

  • 相关阅读:
    作业三3
    作业三2(改过)
    第一章
    实验2
    第三章
    例2-11
    例2-10
    例2-8
    例2-9
    例2-7
  • 原文地址:https://www.cnblogs.com/sineagle/p/14677852.html
Copyright © 2011-2022 走看看