發表文章

目前顯示的是 12月, 2019的文章

時間資料處理

markdown  ==此處為文章備份用== 有興趣可至 [https://hackmd.io/@LHB-0222/Rdate ](https://hackmd.io/@LHB-0222/Rdate) 觀看全文 ![](https://i.imgur.com/ruBLLMd.jpg) 在R資料處理之中,時常會需要遇到時間格式的處理 實驗數據、股市資料、氣候資訊隨著時間不斷的流逝 各式資料也不斷的生成的情況下時間的判讀就顯得重要 多數時候取得的時間資料就是一長串的數字 如何讓程式讀取時間資料以及對時間資料的處理是今天這文章的重點 # 取得時間資訊 ```R= Sys.Date() #當前日期 lubridate::today() date() #當前系統日期和時間 Sys.time() #當前系統日期和時間 lubridate::now() Sys.timezone() #有關時區的信息將返回當前時區的名稱 ``` :::success [1] "2019-12-13" [1] "Fri Dec 13 21:50:58 2019" [1] "2019-12-13 21:52:04 CST" [1] "Asia/Taipei" ::: ```R=+ head(OlsonNames()) #取得有關時區的信息、時區的名稱 ``` :::success [1] "Africa/Abidjan" "Africa/Accra" "Africa/Addis_Ababa" "Africa/Algiers" [5] "Africa/Asmara" "Africa/Asmera" ::: ## 取得特定日期或時間資訊 :::danger format(date,format): ::: ```R= #輸出年份: format(Sys.Date(),format="%Y") format(Sys.Date(),format="%y") #輸出月份: form...

使用R繪製三元相圖(Ternary plot)結合等高線圖(topographic map)

markdown :::success 三元相圖是帶有三個變量的三角圖,它們通常用於化學,岩石學,礦物學,冶金學,材料科學等領域 **特色為其中任一點的三變量總合為100** ::: ![](https://i.imgur.com/CVGYPVQ.png) 首先準備好所需的數據格式 ![](https://i.imgur.com/6AsoV9t.png) 啟動Rstudio安裝所需的套件 ``` R= ## Version 1.2.1335 ## coding: utf-8 ## 繪製三元相圖(Ternary plot)結合等高線圖(topographic map) # 安裝相關套件 install.packages("AlgDesign") install.packages('ggtern') install.packages('ggplot2') install.packages('RColorBrewer') #載入相關套件 library(AlgDesign) library(ggplot2) library(RColorBrewer) library(ggtern) ``` 讀取所準備好的CSV檔 ```R=+ data_ggtern [ggtern: ternary diagrams in R: What is ggtern?](http://www.ggtern.com/) >>[Ternary Interpolation / Smoothing]([http://www.ggtern.com/2015/08/03/ternary-interpolation-smoothing/](http://www.ggtern.com/2015/08/03/ternary-interpolation-smoothing/)) >>> [name=Nicholas Hamilton] >[ggtern contour plot in R - Stack Overflow](https://stackoverflow.com/questions/38160110/ggtern-contour-...