`
sillycat
  • 浏览: 2501449 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Rlang(1)Introduction and Installation - Calculate and Load Data

 
阅读更多
Rlang(1)Introduction and Installation - Calculate and Load Data

Install R Script
Download the file from here http://www.go-parts.com/mirrors-usa/cran/, I get the version R-3.2.2.pkg.

Install Pandoc - Tool to Convert md to Documents
Download the latest package from here https://github.com/jgm/pandoc/releases/tag/1.15.0.6, I get the version pandoc-1.15.0.6-osx.pkg

Follow the docs here http://dapengde.com/r4dummies

1. Introduction
We use R language to do data process, draw diagram and programming.

Anyone can R - anyone can Er/2, haha.

I already install R-3.2.2.pkg, Need I install https://www.rstudio.com/products/rstudio/download/, RStudio, it is a nice tool.

After I install R-3.2.2.pkg, I can verify the version using following command.
> r --version
R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see

2. Use R to do Calculation
Create a new R script file on Rsutdio, it will create a file named similar to Calculate.R, end with .R.

3 * (2 + 2)
sqrt(9)
## comments here.

Some other useful functions, round(), trunc(), sort(), abs(), exp(), log(), log10(), sin(), cos(), tan(), sin(), cos(), tan().

pi
## 3.141593

> options(digits=22)
> pi
[1] 3.141592653589793115998

> options(digits = 3)
> x <- c(61, 45, 55, 46, 56, 79, 86, 57, 56, 56, 57, 71)
> x[4]
[1] 46

Operation on x
> x + 100
[1] 161 145 155 146 156 179 186 157 156 156 157 171

These commands will directly draw the diagram for us.
options(digits = 3)
x <- c(61, 45, 55, 46, 56, 79, 86, 57, 56, 56, 57, 71)
x[4]
x + 100
plot(x)

## calculate the average
sum(x)/length(x)
mean(x)

Some other useful functions provided by R language, sum(), mean(), max(), min(), range(), median(), sd(), var().

3. Manage the Data from File
Reading the document from here http://dapengde.com/archives/14818, Download the sample data file from here
http://dapengde.com/wp-content/uploads/2013/03/dapengde_DummyR_PM25.csv

Put this in the command console, you will see the help information for read.table
>?read.table

This will read the file directly and open the file with default application
mydata <- "/opt/data/dapengde_DummyR_PM25.csv"
mydata
file.show(mydata)

load the csv data directly from file
mydata <- "/opt/data/dapengde_DummyR_PM25.csv"
mydata
##file.show(mydata)

#pm <- read.table(file=mydata, header = TRUE, sep=",")
pm <- read.csv(file=mydata)

The command summary will display a very useful information about the data
> summary(pm)
      time             h8             h100            h325
Min.   : 0.00   Min.   : 46.0   Min.   : 32.0   Min.   : 30.0
1st Qu.: 5.75   1st Qu.: 75.5   1st Qu.: 48.0   1st Qu.: 42.8
Median :11.50   Median : 93.5   Median : 67.5   Median : 54.5
Mean   :11.50   Mean   : 98.7   Mean   : 72.1   Mean   : 65.5
3rd Qu.:17.25   3rd Qu.:128.0   3rd Qu.:100.0   3rd Qu.: 88.5
Max.   :23.00   Max.   :150.0   Max.   :123.0   Max.   :126.0

1st Qu and 3rd Qu
https://zh.wikipedia.org/wiki/%E5%9B%9B%E5%88%86%E4%BD%8D%E6%95%B0

Get the row 10, column 2 data.
> pm[10, 2]
[1] 150

Pick up the C array of data with column 2
> pm[c(0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22), 2]
[1]  80  91 100 144 150 106  68  46  68  92 108

Generate the seq from seq()
> pm[seq(0,22,2),2]
[1]  80  91 100 144 150 106  68  46  68  92 108

All data belong to column 2
> pm[,2]
[1]  97  80  64  91  87 100 128 144 150 150 150 106  78  68  62  46  55  68  84  92  95
[22] 108 128 138

Pick up the column H8
> pm[, "h8"]
[1]  97  80  64  91  87 100 128 144 150 150 150 106  78  68  62  46  55  68  84  92  95
[22] 108 128 138

Similar to the command above
> pm$h8
[1]  97  80  64  91  87 100 128 144 150 150 150 106  78  68  62  46  55  68  84  92  95
[22] 108 128 138

List the Column Name
> names(pm)
[1] "time" "h8"   "h100" "h325"

References:
http://www.go-parts.com/mirrors-usa/cran/
https://www.r-project.org/
http://www.biosino.org/R/R-doc/files/R4beg_cn_2.0.pdf
https://github.com/yihui/r-ninja
http://pandoc.org/

http://dapengde.com/r4dummies
http://dapengde.com/archives/14802
分享到:
评论

相关推荐

    rlang, 面向 R 编程的低层 API.zip

    rlang, 面向 R 编程的低层 API rlang 重要的: rlang API仍在成熟。 请参见 ?rlang::lifecycle 以获得被认为是稳定的函数列表。概述rlang软件包提供了使用 R 和tidyverse的核心语言功能的工具:系统

    javaee笔试题-tblog:技术博客站点

    rlang; Python; rpy2 2017-12-21 rlang; 电阻 2018-02-16 新维; linux 2018-02-03 jupyter; 工作室; 笔记本; 系统 2018-03-08 护目镜; 乌本图 2018-03-19 Python; R; 包裹; 备份; 恢复; 点子; conda 2018-03-19...

    R-for-Data-Science-Lunchbreak-Lessons:LinkedIn学习课程的源文件

    R语言迷你教程 编程是一点点学习的。 您建立在基本概念上。 您将已经拥有的知识转移到另一种语言。 午餐休息课程在短期课程中讲授R(一种用于数据分析和报告的最受欢迎的编程语言),以扩展现有程序员已经知道的知识...

    R语言画图所需的各类型包

    都是我在画图中需要用到的包,如...2.3.0/maps_3.3.0/maptools_0.9-4/memoise_1.1.0/munsell_0.5.0/pillar_1.3.0/plyr_1.8.4/R6_2.2.2/RCurl_1.95-4.11/rlang_0.3.0.1/scales_1.0.0/sp_1.3-1/tibble_1.4.2/withr_2.1.2

    rlang:使用R进行编程的低级API

    rlang:使用R进行编程的低级API

    R语言程序包

    由于R软件版本问题,一些函数不能运用,在此编写了一个程序包可以使那些函数可以用。

    DATA606Spring2021:DATA606 2021Spring

    DATA 606 2021年Spring 课程网站 该课程网站是使用创建的,该扩展了框架,该框架使用RMarkdown文件生成了静态网站。 具体来说,Blogdown将首先将Rmd文件转换为md文件,然后再由Hugo将其转换为HTML。 默认情况下,此...

    三层DLL架构解决方案-示范

    三层DLL架构解决方案-示范,值得研究一下

    Rcpp_0.12.2

    R是用于数据分析的语言,通过Rcpp可以将cpp库引入R中使用,适用于提高性能和接入原有算法库的场合。 Rcpp包提供C++类方便C or C++代码与R软件包进行交互,使用R中提供的.Call() 调用界面。 Rcpp提供R中的基础数据...

    Ritmic:肿瘤微环境组成调节包装

    uga/RiTMIC.gitcd RiTMIC R构建包install.packages( " devtools " )# mixtools htmltools scales yaml lazyeval plyr rlang ggplot2 gtools caTools KernSmooth penda progressdevtools :: load_all(); devtools :: ...

    RiTMIC:调节肿瘤微环境组成的包装

    商标 该RiTMIC [R包进行虚拟从RNA测序的RNA测序数据模拟,数据组学的个性化差异分析随着penda...devtools :: load_all(); devtools :: document(); devtools :: install() 建立小插图 setwd("vignettes") rmarkdown::r

    京东商城API接口(2020)

    京东商城API接口,支持多种语言版(Java,C#,Python,Delphi,RLang,GoLang等语言)接口方式,可以通过配置界面直接配置,非常简单,非常直观,1小时可以上手

    erLang otp_win64_20.2安装包

    Erlang opt_win64 20.2 windows exe 安装包 Erlang 20.2 is the upcoming version of Erlang For Windows x64 installer 截至2018.01.25 groovy最新最稳定版本

    Thinking in Erlang

    A GUIDE TO FUNCTIONAL PROGRAMMING IN E RLANG FOR THE EXPERIENCED PROCEDURAL DEVELOPER.

    dipsaus:R 包 dipsaus 的开发库

    数据分析和可视化的蘸酱 包装dipsaus提供add-ons到各种软件包,如shiny , rlang , future等,以增强这些软件包。 从Github安装开发版本包, devtools :: install_github( ' dipterix/dipsaus ' ) dipsaus从以下...

    ERROR: Package ‘gunicorn’ requires a different Python: 2.7.5 not in ‘>=3.4’

    pip安装gunicorn时出现这个错: Collecting gunicorn (from -r requirements.txt (line 9)) Downloading ... |████████████████████████████████| 81kB 5.3MB/s ERROR: Pac

    ecg:Erlang函数调用图生成器

    ECG是E rlang函数C的所有图G enerator,其自动绘制函数调用和处理程序派生。 ECG利用Erlang强大的跟踪机制和可视化工具graphviz ,确保已安装graphviz ,并且由于此处使用Python绑定,因此还需要安装Digraph软件包。...

    Tutorialspoint 教程 20170416

    backbone cordova drools els erlang idea ip jenkins less meteor mis nginx perl php7 postgresql qc rlang sass scrapy selenium shell smarty solr vuw webgl wxpy zookeeper 计算机基础 软工 数据结构 数据挖掘

Global site tag (gtag.js) - Google Analytics