-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathch1.Rmd
141 lines (95 loc) · 3.44 KB
/
ch1.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
---
title: "建立你的 R 語言開發環境"
author: "郭耀仁"
date: "`r Sys.Date()`"
output: slidy_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## 我們會使用兩個工具
- R
- RStudio
## 安裝 R(OS X)
- 從 The Comprehensive R Archive Network([CRAN](https://cran.r-project.org/))下載 .dmg 檔進行安裝
## 安裝 R(Windows)
- 從 The Comprehensive R Archive Network([CRAN](https://cran.r-project.org/))下載 .exe 檔進行安裝
## 安裝 RStudio(OS X)
- 從 [RStudio](https://www.rstudio.com/products/rstudio/download3/) 下載 .pkg 檔來進行安裝
## 安裝 RStudio(Windows)
- 從 [RStudio](https://www.rstudio.com/products/rstudio/download3/) 下載 .exe 檔來進行安裝
## 第一次執行 RSudio
```{r, out.width = "680px"}
knitr::include_graphics("https://storage.googleapis.com/learn-r-the-easy-way.appspot.com/screenshots_ch1/ch106.png")
```
## 新增一個 R 程式
```{r, out.width = "680px"}
knitr::include_graphics("https://storage.googleapis.com/learn-r-the-easy-way.appspot.com/screenshots_ch1/ch107.png")
```
## 完整的四個區塊
- 來源(Source):位於左上角,編寫程式的區塊
- 命令列(Console):位於左下角,執行程式的區塊
- 環境與歷史:位於右上角
- 檔案、圖形、套件、查詢與預覽器:位於右下角
```{r, out.width = "680px"}
knitr::include_graphics("https://storage.googleapis.com/learn-r-the-easy-way.appspot.com/screenshots_ch1/ch108.png")
```
## 第一個函數 `q()`
- 在命令列(Console)輸入 `q()` 可以離開 RStudio
## 補充閱讀
## Git
- Git 版本管理逐漸成為現代程式設計的必備技能
- 有興趣的同學可以閱讀
- 系統訓練班亦有 Git 版本管理的假日專題班課程(10 小時)
## 安裝 Git(OS X)
- OS X 內建 Git,不需要進行安裝
- 或者至 [git](https://git-scm.com/download/mac) 下載 .dmg 檔來進行安裝
## 安裝 Git(Windows)
- 至 [git](https://git-scm.com/download/win) 下載 .exe 檔來進行安裝
## 申請 GitHub 帳號
- 至 [GitHub](https://github.com/) 申請一個帳戶
## 基本的命令列指令
| 指令 | 說明 |
| ------------- |--------------------------|
| cd | 切換目錄 |
| pwd | 取得目前所在的位置 |
| ls | 列出目前的檔案列表 |
| mkdir | 建立新的目錄 |
| touch | 建立檔案 |
| cp | 複製檔案 |
| mv | 移動檔案 |
| rm | 刪除檔案 |
## 基本的命令列指令(2)
- 打開 Git Bash
- 練習前一頁投影片的命令列指令
## 設定 Git
- 告訴 Git 你的帳戶與電子信箱
- 在終端機輸入:
```
git config --global user.name "YOUR NAME"
git config --global user.email YOUR EMAIL ADDRESS
```
## 建立一個遠端 repository
- 至 [GitHub](https://github.com/) 建立一個遠端 repository
- 將新建的 repository 複製回本機資料夾
```
cd ~
git clone "YOUR REPOSITORY URL"
```
## 將本機新增的檔案推到遠端 repository
- 在本機資料夾新增檔案
- 存檔後在命令列輸入:
```
git add .
git commit -m "first commit"
git push
```
- `git commit -m` 後面的訊息可以自訂
## 練習
- 上傳兩個檔案至 GitHub
- RStudio 螢幕截圖
- hello_world.R
```{r, results = 'hide'}
# hello_world.R
print("Hello world!")
```