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.
  • 相关阅读:
    NSIS制作安装程序
    poj_1011木棒
    hdoj_1312Red and Black
    搜索题目推荐及解题报告
    应届生就职前要读的几本书
    poj_1564Sum It Up
    priority_queue用法
    hdoj_2952Counting Sheep
    poj_1154LETTERS
    poj_2362
  • 原文地址:https://www.cnblogs.com/Shinered/p/9203023.html
Copyright © 2011-2022 走看看