zoukankan      html  css  js  c++  java
  • R语言基础

    载入一些常用的包:

    library(dplyr)
    library(ggplot2)
    library(statsr)

    载入数据:

    data(arbuthnot) 

    查看数据:

    arbuthnot 

    查看数据维度:

    dim(arbuthnot)

    我的输出为: [1]  82  3 .

    查看变量名:

    names(arbuthnot)

     得到的输出:

    [1] "year"  "boys"  "girls"

    函数range: range(data$year)。查看变量的范围。
    dataset$new_column <- dataset$column1 -+ dataset$column2
    

     画图:

    present$total <- present$boys + present$girls
    present$prop_boys <- present$boys / present$total
    ggplot(data = present, aes(x=year,y=boys/total)) + 
      geom_line() + geom_point()

    加列:

    arbuthnot <- arbuthnot %>%
      mutate(total = boys + girls)
    

      

    加边以及降序排列,present是数据集。

    present %>%
      mutate(total=girls+boys) %>%
      arrange(desc(total))
    

      

    The Safest Way to Get what you Want is to Try and Deserve What you Want.
  • 相关阅读:
    使用正则表达式实现(加减乘除)计算器(C#实现)
    asp.net core中间件工作原理
    WPF
    WPF
    WPF
    WPF
    WPF 3D Cube及点击交互
    WPF 3D足球导览
    WPF 3D 球面导览
    WPF 3D球及进阶玩法
  • 原文地址:https://www.cnblogs.com/Shinered/p/9203023.html
Copyright © 2011-2022 走看看