代码之家  ›  专栏  ›  技术社区  ›  Indrajeet Patil

正在分析字符中的数值,因为它们与`scipen的值无关`

  •  2
  • Indrajeet Patil  · 技术社区  · 5 年前

    ggplot scipen 选项。

    默认情况下 scipen = 0 (好的)

    library(ggplot2)
    
    # plot is just for illustration and has nothing to do with the statistics being displayed
    ggplot(mtcars, aes(wt, mpg)) + geom_smooth() + geom_point() + 
      labs(subtitle = parse(text = "list(~chi['gof']^2~(8)==617.445, ~italic(p)==4.15e-128)"))
    

    具有 scipen = 999 (不受欢迎)

    library(ggplot2)
    options(scipen = 999)
    
    # plot is just for illustration and has nothing to do with the statistics being displayed
    ggplot(mtcars, aes(wt, mpg)) + geom_smooth() + geom_point() + 
      labs(subtitle = parse(text = "list(~chi['gof']^2~(8)==617.445, ~italic(p)==4.15e-128)"))
    

    2 回复  |  直到 5 年前
        1
  •  1
  •   lroha    5 年前

    library(ggplot2)
    
    options(scipen = 999)
    
    ggplot(mtcars, aes(wt, mpg)) + geom_smooth() + geom_point() + 
      labs(subtitle = parse(text = "list(~chi['gof']^2~(8)==617.445, ~italic(p)=='4.15e-128')"))
    

    enter image description here

        2
  •  1
  •   akrun    5 年前

    我们可以提取当前选项,然后更改它

    op <- options()$scipen
    options(scipen = 0)
    ggplot(mtcars, aes(wt, mpg)) + geom_smooth() +
          geom_point() + 
          labs(subtitle = parse(text = "list(~chi['gof']^2~(8)==617.445, ~italic(p)==4.15e-128)"))
    
    # // change it to current options
    options(scipen = op)