• 検索結果がありません。

Introduction to R; Pivot Table

N/A
N/A
Protected

Academic year: 2018

シェア "Introduction to R; Pivot Table"

Copied!
33
0
0

読み込み中.... (全文を見る)

全文

(1)

Excel 樞紐分析 3D地圖

R 基本操作

陳昱瑾

1

(2)

Outline

Excel

資料剖析

樞紐分析

3D 地圖(Power View)

R 基本介紹

範例

2

(3)

資料剖析

將資料進行分割

作法

選取資料 → 點選資料 → 資料剖析

選分割符號or固定寬度 → 下一步 → 勾選分割符號 → 完成

3

(4)

樞紐分析

利用樞紐分析表,進行資料摘要 分析

作法

插入 → 樞紐分析表

拖 欄 到列 欄 值

4

(5)

3D 地圖(Power View)

利用3D地圖(Power View)將資料以視覺化的方式呈現

作法

插入 → 3D地圖

拖 欄

5

(6)

以經緯度做 置

6

(7)

R 簡介

優點

免費

套件豐富

強大的視覺化工

7

(8)

安裝R

R的官方網站:https://www.r-project.org/

點CRAN

8

(9)

安裝R

找到Taiwan,點選 中一個

9

(10)

安裝R

選擇符合的作業系統下載

10

(11)

安裝R

選base

Download

安裝檔下載後,執行安裝,不需調整設定參數,點擊下一步即可 11

(12)

安裝RStudio

RStudio 是一個開放原始碼的 R 語言整合開發環境 IDE ,它的 能包含程式碼 編輯器 錯工 與視覺化工

Rstudio官方網站:https://www.rstudio.com/home/

Download Rstudio

12

(13)

安裝RStudio

選Desktop

13

(14)

安裝RStudio

選DOWNLOAD RSTDIO DESKTOP

14

(15)

安裝RStudio

選擇適合的 本

執行安裝,不需調整設定參數,點擊下一步即可 15

(16)

Rstudio 介面介紹

16

編輯程式碼

(ctrl+enter 執行程式碼)

記錄執行過程的

變數物件(記憶體)

執行Console

File:所在的工作環境是在哪個目錄 Plots:繪圖的顯示區塊

Packages:管理已安裝(打勾表示)或未安裝套件的區塊 Help:顯示Help()命令的說明內容

Viewer:用來顯示網頁或 html file

(17)

資料屬性

character:文 串,用 “ ” 包起來

numeric:實數

integer:整數

complex:複數

logical:True 或 False

可用class()函數 斷資料屬性

R 是以雙倍精確度來計算,所以必須指定為 integer,不然會被當成 numeric

17

(18)

運算

減乘

次方 平方根 商數與餘數

2^3 #2的3次方

sqrt(4) #4開根號

11%/%5 #11 5的商數

11%%5 #11 5的餘數

sign(): 斷是正(1) 負數(-1)或 0

abs():取絕對值

log()

18

(19)

向量

給予變數值時是利用 <-

x <- 1

c(...) 建立向量,向量中元素屬性必須相

c(1, 2, 3) C(TRUE, FALSE)

透過指標與 稱提取資料

x[i] x[元素 稱]:回傳向量元素所有資訊

x[[i]] x[[元素 稱]]:回傳向量元素的值

減乘 :較長的向量長度是短的向量長度的倍數

> c(1, 2) + c(1, 2, 3, 4) # 1+1 2+2 1+3 2+4 [1] 2 4 4 6

> c(1, 2) * c(1, 2, 3, 4) # 1*1 2*2 1*3 2*4 [1] 1 4 3 8

19

(20)

利用 rbind cbind 與 array 函數建立 列

rbind 是利用 row(橫) 合併

cbind 是利用 column(直) 合併

列可視為多維度的向量變數,跟向量一樣,所有 列元素的資料屬性必須一致

20

(21)

以matrix()函數建立矩 ,當 列是 2 維的狀況就是所謂的矩

matrix(c(1:4), nrow = 2, ncol = 2) # 預設是按照 column 填入資料

x[,1] #第一行(column)

x[1,] #第一列(row)

t(x):矩 轉置

%*%:矩 相乘

21

(22)

因素向量

因素向量是用來儲 類 型變數的統計資料,主要在處理的統計模型時會用到

以factor()函數來宣告因素向量

類 型變數

目類 型變數:無法在類 之間比較好壞 如:male female

順序類 型變數:變數 有天生的比較特性 如:low high

22

(23)

清單

清單跟向量很相似,最大的不 在於清單可以包含不 資料屬性的資料

以list()函數建立列表

23

(24)

資料框

資料框類似資料表,他是一種特殊的清單,每個分輛長度一樣

以data.frame()函數建立資料框

head:取得資料框架前六筆資料(預設是 6)

colnames:設定 column 稱

rownames:設定 row 的 稱

summary:顯示資料基本資訊

提取資料方法跟矩 或 列的都很類似

24

(25)

Package 安裝

輸入install.packages(“套件 稱”),即安裝

安裝套件後,輸入library(套件 稱),就可使用 能

輸入update.packages()即 新所有套件

25

(26)

範例1:利用Package來計算TF-IDF

TF-IDF:找出一篇文章中,足以代表這篇文章的關鍵 的方法

一個term在文章中出現次數越高,代表越重要,但若在越多文章中出現,則鑑 力降

在一篇文章中,尋找關鍵 ,要考慮以下兩個要素:

1. 這個 在這篇文章中出現的頻率( Term-Frequency TF )

2. 在所有的文章中,有幾篇文章有這個 ( Inverse-Document-Frequency IDF )

26

(27)

27

下載資料:http://www.cs.cornell.edu/People/pabo/movie-review-data/

(28)

範例2:繪圖

R內建資料庫

(https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/00Index.html)

直方圖(Histogram):hist()函數

盒鬚圖(Box Plot):boxplot()函數

散布圖(Scatter Plot) :plot()函數

28

(29)

範例2:直方圖與盒鬚圖

29

(30)

範例2:散布圖

30

(31)

範例2:散布圖

31

(32)

有關R的參考資訊

R-project官方網站: http://www.r-project.org/

中文教學

https://www.datacamp.com/community/open-courses/r-

%E8%AA%9E%E8%A8%80%E5%B0%8E%E8%AB%96

英文教學

https://www.datacamp.com/home

教學影

http://www.r-software.org/movielist

https://www.coursera.org/learn/r-programming

32

(33)

謝謝大家聆聽~~

33

参照

関連したドキュメント

Abstract: In this paper, we investigate the uniqueness problems of meromorphic functions that share a small function with its differential polynomials, and give some results which

Charles Conley once said his goal was to reveal the discrete in the con- tinuous. The idea here of using discrete cohomology to elicit the behavior of continuous dynamical systems

A conformal spin structure of signature (2, 2) is locally induced by a 2- dimensional projective structure via the Fefferman-type construction if and only if any of the

Review of Lawson homology and related theories Suslin’s Conjecture Correspondences Beilinson’s Theorem More on Suslin’s (strong) conjeture.. An Introduction to Lawson

— Completely integrable systems, Korteweg-de Vries equations, harmonic maps, anti-self-dual connections, twistors theory.... that, in the best cases, these non linear equations

Despite this, these contributions did not mention the underlying concept of attribute reduction in ordered decision table with fuzzy decision and only proposed an approach to

At the end of the section, we will be in the position to present the main result of this work: a representation of the inverse of T under certain conditions on the H¨older

We extend the classical Gauss–Bonnet theorem for the Euclidean, elliptic, hyperbolic, and Lorentzian planes to the other three Cayley–Klein geometries of dimension two, all three