Skip to content

Commit

Permalink
Summary(R_notes)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanganlin00 committed Dec 19, 2023
1 parent 39ab415 commit a48169b
Show file tree
Hide file tree
Showing 86 changed files with 9,585 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1687795504:F:/R/GitHub/Wanganlin00.github.io/R_notes/references.bib
Empty file.
35 changes: 35 additions & 0 deletions R_notes/.Rproj.user/54283FDB/bibliography-index/biblio.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"sources": [
{
"DOI": "10.1093/comjnl/27.2.97",
"ISSN": "0010-4620",
"URL": "https://doi.org/10.1093/comjnl/27.2.97",
"author": [
{
"family": "Knuth",
"given": "Donald E."
}
],
"container-title": "Comput. J.",
"id": "knuth84",
"issue": "2",
"issued": {
"date-parts": [
[
1984,
5
]
]
},
"page": "97-111",
"publisher": "Oxford University Press, Inc.",
"publisher-place": "USA",
"title": "Literate programming",
"type": "article-journal",
"volume": "27"
}
],
"project_biblios": [
"references.bib"
]
}
9 changes: 9 additions & 0 deletions R_notes/.Rproj.user/54283FDB/pcs/files-pane.pper
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"sortOrder": [
{
"columnIndex": 2,
"ascending": true
}
],
"path": "F:/R/GitHub/Wanganlin00.github.io/R_notes"
}
3 changes: 3 additions & 0 deletions R_notes/.Rproj.user/54283FDB/pcs/source-pane.pper
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"activeTab": 0
}
14 changes: 14 additions & 0 deletions R_notes/.Rproj.user/54283FDB/pcs/windowlayoutstate.pper
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"left": {
"splitterpos": 328,
"topwindowstate": "NORMAL",
"panelheight": 784,
"windowheight": 822
},
"right": {
"splitterpos": 454,
"topwindowstate": "NORMAL",
"panelheight": 784,
"windowheight": 822
}
}
5 changes: 5 additions & 0 deletions R_notes/.Rproj.user/54283FDB/pcs/workbench-pane.pper
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"TabSet1": 1,
"TabSet2": 1,
"TabZoom": {}
}
9 changes: 9 additions & 0 deletions R_notes/.Rproj.user/54283FDB/sources/prop/2107E1BD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"rmdVisualMode": "true",
"rmdVisualWrapConfigured": "true",
"source_window_id": "",
"Source": "Source",
"docOutlineVisible": "1",
"rmdVisualCollapsedChunks": "",
"rmdVisualModeLocation": "2:0"
}
6 changes: 6 additions & 0 deletions R_notes/.Rproj.user/54283FDB/sources/prop/BEDFCC1D
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"source_window_id": "",
"Source": "Source",
"cursorPosition": "20,0",
"scrollLine": "15"
}
6 changes: 6 additions & 0 deletions R_notes/.Rproj.user/54283FDB/sources/prop/F12B354C
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"source_window_id": "",
"Source": "Source",
"cursorPosition": "20,0",
"scrollLine": "3"
}
3 changes: 3 additions & 0 deletions R_notes/.Rproj.user/54283FDB/sources/prop/INDEX
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
F%3A%2FR%2FGitHub%2FWanganlin00.github.io%2FR_notes%2F_quarto.yml="F12B354C"
F%3A%2FR%2FGitHub%2FWanganlin00.github.io%2FR_notes%2Findex.qmd="2107E1BD"
F%3A%2FR%2Ftidyverse%2Fr4ds-main%2F_quarto.yml="BEDFCC1D"
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
project:
type: book
output-dir: _book

book:
title: "R for Data Science (2e)"
reader-mode: true

page-footer:
left: |
R for Data Science (2e) was written by Hadley Wickham, Mine
Çetinkaya-Rundel, and Garrett Grolemund.
right: |
This book was built with <a href="https://quarto.org/">Quarto</a>.
cover-image: cover.jpg
favicon: cover.jpg
site-url: https://r4ds.hadley.nz/
repo-url: https://github.com/hadley/r4ds/
repo-branch: main
repo-actions: [edit, issue]
chapters:
- index.qmd
- preface-2e.qmd
- intro.qmd

- part: whole-game.qmd
chapters:
- data-visualize.qmd
- workflow-basics.qmd
- data-transform.qmd
- workflow-style.qmd
- data-tidy.qmd
- workflow-scripts.qmd
- data-import.qmd
- workflow-help.qmd

- part: visualize.qmd
chapters:
- layers.qmd
- EDA.qmd
- communication.qmd

- part: transform.qmd
chapters:
- logicals.qmd
- numbers.qmd
- strings.qmd
- regexps.qmd
- factors.qmd
- datetimes.qmd
- missing-values.qmd
- joins.qmd

- part: import.qmd
chapters:
- spreadsheets.qmd
- databases.qmd
- arrow.qmd
- rectangling.qmd
- webscraping.qmd

- part: program.qmd
chapters:
- functions.qmd
- iteration.qmd
- base-R.qmd

- part: communicate.qmd
chapters:
- quarto.qmd
- quarto-formats.qmd

format:
html:
theme:
- cosmo
- r4ds.scss
code-link: true

author-meta: "Hadley Wickham, Mine Çetinkaya-Rundel, and Garrett Grolemund"
include-in-header: "plausible.html"
callout-appearance: simple

editor: visual

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
project:
type: book

book:
title: "R_notes"
author: "Norah Jones"
date: "2023/12/19"
chapters:
- part: index.qmd
chapters:
- intro.qmd
- basics.qmd
- summary.qmd
- references.qmd

bibliography: references.bib

format:
html:
theme: cosmo
pdf:
documentclass: scrreprt

editor: visual

26 changes: 26 additions & 0 deletions R_notes/.Rproj.user/54283FDB/sources/session-ce08ca9e/D1B599F4
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"id": "D1B599F4",
"path": "F:/R/GitHub/Wanganlin00.github.io/R_notes/_quarto.yml",
"project_path": "_quarto.yml",
"type": "yaml",
"hash": "0",
"contents": "",
"dirty": false,
"created": 1702964481355.0,
"source_on_save": false,
"relative_order": 2,
"properties": {
"source_window_id": "",
"Source": "Source",
"cursorPosition": "20,0",
"scrollLine": "3"
},
"folds": "",
"lastKnownWriteTime": 1702964636,
"encoding": "UTF-8",
"collab_server": "",
"source_window": "",
"last_content_update": 1702964635066,
"read_only": false,
"read_only_alternatives": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
project:
type: book

book:
title: "R_notes"
author: "Wang Anlin"
date: "2023/12/19"
chapters:
- index.qmd
- intro.qmd
- basics.qmd
- summary.qmd
- references.qmd
bibliography: references.bib

format:
html:
theme: cosmo
pdf:
documentclass: scrreprt

editor: visual

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Preface {.unnumbered}

This is a Quarto book.

To learn more about Quarto books visit <https://quarto.org/docs/books>.

```{r}
1 + 1
```
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions R_notes/.Rproj.user/shared/notebooks/paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
F:/R/GitHub/Wanganlin00.github.io/R_notes/_quarto.yml="9C734D88"
F:/R/GitHub/Wanganlin00.github.io/R_notes/index.qmd="D580FCA1"
F:/R/tidyverse/r4ds-main/_quarto.yml="DFFCB474"
16 changes: 16 additions & 0 deletions R_notes/.quarto/_freeze/basics/execute-results/html.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"hash": "c02a8815f5653d69be8398468425f56c",
"result": {
"markdown": "---\n knitr:\n opts_chunk:\n comment: \"#>\"\n collapse: true\n format: \n html: \n code-fold: true\n code-tools: true\n code-link: true\n---\n\n\n# base R {.unnumbered}\n\n# 最重要的是帮助文档\n\nThe Comprehensive R Archive Network [CRAN](https://cran.r-project.org/)\n\n\n::: {.cell}\n\n```{.r .cell-code}\nhelp.start()\nhelp()\n?c\n```\n:::\n\n\n# 包的安装和使用\n\n\n::: {.cell}\n\n```{.r .cell-code}\ninstalled.packages()\ninstall.packages(\"ggplot2\") \nlibrary(ggplot2) # 载入包\nrequire(ggplot2) # 另一种载入方式\nhelp(package = \"ggplot2\") # R包ggplot2的帮助文档\n?ggplot2\ndata(package=\"ggplot2\") #查看R包ggplot2中的数据集\n\ndata(mpg,package=\"ggplot2\") #加载数据集\nhelp(mpg) # 数据集mpg的帮助文档\n?mpg\nmpg\n```\n:::\n\n\n# 变量类型\n\n**数据类型(mode)**:表示对象在计算机内存中的存储类型\n\n- **numeric -- 数值型(Integer/double)integer -- 整型 L**\n\n\n::: {.cell}\n\n```{.r .cell-code}\nmode(4.3)\n#> [1] \"numeric\"\nclass(4.3)\n#> [1] \"numeric\"\nmode(1L)\n#> [1] \"numeric\"\nclass(1L)\n#> [1] \"integer\"\n```\n:::\n\n\n- **character -- 字符型**\n\n\n::: {.cell}\n\n```{.r .cell-code}\nmode(c(\"car\"))\n#> [1] \"character\"\nclass(\"car\")\n#> [1] \"character\"\n```\n:::\n\n\n- **logical --逻辑型**\n\n\n::: {.cell}\n\n```{.r .cell-code}\nmode(c(TRUE,FALSE))\n#> [1] \"logical\"\nclass(c(TRUE,FALSE))\n#> [1] \"logical\"\n```\n:::\n\n\n- **factor--因子**\n\n\n::: {.cell}\n\n```{.r .cell-code}\nmode(factor((c(1,2,3)))) \n#> [1] \"numeric\"\nclass(factor((c(1,2,3)))) \n#> [1] \"factor\"\n```\n:::\n\n\n- **date/datetime--日期/日期时间**\n\n默认格式:`\"%Y-%m-%d\" xxxx-xx-xx,例如:2023-03-15`\n\n\n::: {.cell}\n\n```{.r .cell-code}\nmode(as.Date(\"2023-12-11\"))\n#> [1] \"numeric\"\nclass(as.Date(\"2023-12-11\")) \n#> [1] \"Date\"\n\nSys.Date()\n#> [1] \"2023-12-19\"\nas.Date(c(\"02 14-2002\",\"01 04-2013\"),\"%m %d-%Y\") #以\"%m %d-%Y\"格式读入\n#> [1] \"2002-02-14\" \"2013-01-04\"\nformat(Sys.Date(),\"%Y/%m/%d\") #以\"%Y/%m/%d\"格式输出\n#> [1] \"2023/12/19\"\n```\n:::\n\n\n- **function--函数**\n\n\n::: {.cell}\n\n```{.r .cell-code}\nmode(c)\n#> [1] \"function\"\nclass(c)\n#> [1] \"function\"\n```\n:::\n\n\n- **list--列表**\n\n\n::: {.cell}\n\n```{.r .cell-code}\nmode(mpg)\n#> [1] \"list\"\nclass(mpg)\n#> [1] \"tbl_df\" \"tbl\" \"data.frame\"\n```\n:::\n\n\n- **complex -- 复数型**\n\n\n::: {.cell}\n\n```{.r .cell-code}\n\nmode(c(1+2i,3-4i)) \n#> [1] \"complex\"\nclass(c(1+2i,3-4i))\n#> [1] \"complex\"\n```\n:::\n\n\n- **raw--原始型**\n\n\n::: {.cell}\n\n```{.r .cell-code}\ncharToRaw(\"abcde12345\") #字符串中每个字符的原始存储格式(十六进制?)\n#> [1] 61 62 63 64 65 31 32 33 34 35\nmode(charToRaw(\"abcde12345\")) \n#> [1] \"raw\"\nclass(charToRaw(\"abcde12345\"))\n#> [1] \"raw\"\n```\n:::\n\n\n# 数据结构\n\n**数据结构(class)**:是一种基于*面向对象*的R的抽象类型划分,或者理解为一种数据结构。\n\n- **vector --向量**,同一类元素的集合。\n\n`?c #Combine Values into a Vector or List`\n\n\n::: {.cell}\n\n```{.r .cell-code}\n#单元素向量\n1\n#> [1] 1\n\nis.vector(1)\n#> [1] TRUE\n\n\"a\"\n#> [1] \"a\"\nis.vector(\"a\")\n#> [1] TRUE\n\n#使用函数c()创建向量\n\nc(1)\n#> [1] 1\nc(1,2,3,4,5)\n#> [1] 1 2 3 4 5\nc(\"a\",\"b\",\"c\")\n#> [1] \"a\" \"b\" \"c\"\n```\n:::\n\n\n- **factor --因子**,分类变量,其中每个级别都是一类。\n\n`?factor`\n\n`factor(vector,order=FALSE,levels=c(v1,v2,…),labels= ,...)` ,在内存中以整数`c(1,2,3,...,k)`形式存储。\n\n\n::: {.cell}\n\n```{.r .cell-code}\n#类别(名义型)变量\ndiabetes<-c(\"t1\",\"t2\",\"t1\",\"t1\") \nstr(diabetes)\n#> chr [1:4] \"t1\" \"t2\" \"t1\" \"t1\"\ndiabetes<-factor(diabetes)\nstr(diabetes)\n#> Factor w/ 2 levels \"t1\",\"t2\": 1 2 1 1\n\n\n#有序型变量 默认水平根据字母顺序而定\nstatus<-c(\"poor\",\"better\",\"best\",\"poor\")\nstatus<-factor(status,order=TRUE) \nstr(status) \n#> Ord.factor w/ 3 levels \"best\"<\"better\"<..: 3 2 1 3\nstatus<-factor(status,order=TRUE,levels = c(\"poor\",\"better\",\"best\")) \nstr(status) \n#> Ord.factor w/ 3 levels \"poor\"<\"better\"<..: 1 2 3 1\n\n#改变外在标签\nsex<-c(1,2,2,1)\nsex\n#> [1] 1 2 2 1\nsex<-factor(sex,levels=c(1,2),labels = c(\"男\",\"女\")) \nstr(sex) \n#> Factor w/ 2 levels \"男\",\"女\": 1 2 2 1\nsex\n#> [1] 男 女 女 男\n#> Levels: 男 女\n```\n:::\n\n\n- **matrix --矩阵**,所有元素必须是同一类型。\n\n`?matrix`\n\n`matrix(data= ,nrow=1 ,ncol=1 ,byrow=FALSE ,dimnames=list(rnames,cnames) ,...)`\n\n\n::: {.cell}\n\n```{.r .cell-code}\nnum<-c(16,22,24,28)\nrnames<-c(\"R1\",\"R2\")\ncnames<-c(\"C1\",\"C2\")\nmymatrix<-matrix(num,nrow=2,ncol=2,byrow=TRUE,dimnames=list(rnames,cnames))\nmymatrix \n#> C1 C2\n#> R1 16 22\n#> R2 24 28\n```\n:::\n\n\n- **array--数组**,所有元素必须是同一类型。\n\n`?array`\n\n`array(data,dim_numeric_vector,dimnames = list(dim1,dim2,...),...)`\n\n\n::: {.cell}\n\n```{.r .cell-code}\nv<-1:24 \ndim1<-c(\"A1\",\"A2\",\"A3\") \ndim2<-c(\"B1\",\"B2\",\"B3\",\"B4\")\ndim3<-c(\"C1\",\"C2\") \nmyarray<-array(v,c(3,4,2),dimnames = list(dim1,dim2,dim3)) \nmyarray\n#> , , C1\n#> \n#> B1 B2 B3 B4\n#> A1 1 4 7 10\n#> A2 2 5 8 11\n#> A3 3 6 9 12\n#> \n#> , , C2\n#> \n#> B1 B2 B3 B4\n#> A1 13 16 19 22\n#> A2 14 17 20 23\n#> A3 15 18 21 24\n```\n:::\n\n\n- **data.frame/tibble-- 数据框**, 由列向量组成,每一列元素必须是同一类型,列与列之间长度必须相同,但类型可以不同。\n\n`?data.frame`\n\n`data.frame(name1=col1,name2=col2,...,row.names = ,...)`\n\n`?tibble`,`tibble()`是tidyverse风格的数据框,用法类似。\n\n\n::: {.cell}\n\n```{.r .cell-code}\nid<-c(1,2,3,4) \nage<-c(21,14,52,15) \ndiabetes<-c(\"t1\",\"t2\",\"t1\",\"t1\") \nstatus<-c(\"poor\",\"better\",\"best\",\"poor\") \npatient<-data.frame(patientID=id,age,diabetes,status,row.names = id) # 4个列向量组成数据框 \npatient\n#> patientID age diabetes status\n#> 1 1 21 t1 poor\n#> 2 2 14 t2 better\n#> 3 3 52 t1 best\n#> 4 4 15 t1 poor\n```\n:::\n\n\nlist --列表,由以上各种数据结构组成\n\n`?list`\n\n`list(name1=object1,name2=object2,...)`\n\n\n::: {.cell}\n\n```{.r .cell-code}\nmylist<-list(title=\"My list\",\n matr=matrix(c(\"a1\",\"b1\",\"a2\",\"b2\"),nrow=2,ncol=2,byrow=TRUE,\n dimnames = list(c(\"X1\",\"X2\"),c(\"Y1\",\"Y2\"))\n ),\n df=data.frame(id=matrix(c(\"Lisa\",\"BOb\",\"John\",\"Jule\"),\n nrow=4,ncol=1,byrow=TRUE\n ),\n int=c(3,5,7,9),\n TF=c(T,T,T,F)\n ),\n list=list(a=c(1,2,3),b=c(\"A\",\"B\"))\n)\nmylist\n#> $title\n#> [1] \"My list\"\n#> \n#> $matr\n#> Y1 Y2 \n#> X1 \"a1\" \"b1\"\n#> X2 \"a2\" \"b2\"\n#> \n#> $df\n#> id int TF\n#> 1 Lisa 3 TRUE\n#> 2 BOb 5 TRUE\n#> 3 John 7 TRUE\n#> 4 Jule 9 FALSE\n#> \n#> $list\n#> $list$a\n#> [1] 1 2 3\n#> \n#> $list$b\n#> [1] \"A\" \"B\"\n```\n:::\n\n\n# qmd_format\n\n| | |\n|------------------------------------------------------------|---------------------------------------------------------|\n| 输出 | 语法 |\n| `code` | \\``code`\\` |\n| **粗体** | `**粗体**` |\n| *斜体* | `*斜体*` |\n| [下横线]{.underline} | `[下横线]{.underline}` |\n| ~~删除线~~ | `~~删除线~~` |\n| 上标X^2^ | `X^2^` |\n| 下标 X~1~ | `X~1~` |\n| [SAMALL small caps]{.smallcaps} | 与小写字母同等高度的大写字母 `[small caps]{.smallcaps}` |\n| <https://r4ds.hadley.nz/> | `<https://r4ds.hadley.nz/>` |\n| [quarto](https://quarto.org) | `[quarto](https://quarto.org)` |\n| ![data science](images/whole-game.png){alt=\"data science\"} | `![data science](images/whole-game.png)` |\n",
"supporting": [
"basics_files"
],
"filters": [
"rmarkdown/pagebreak.lua"
],
"includes": {},
"engineDependencies": {},
"preserve": {},
"postProcess": true
}
}
Loading

0 comments on commit a48169b

Please sign in to comment.