#mydata=read.csv(“C:/Users/User/Desktop/LearnR/CA/CAdata/binary.csv”, header=TRUE, sep=“,”)
ctrl+Alt+I 快速插入 新塊 Insert Chunk
ctrl+Shift+c 加注釋#
ctrl+Shift+c 直接knit
執行
dta <- read.table("/Users/User/Desktop/DM_R/hk0413/inclass/inclass2/cigarettes.txt", header=T , stringsAsFactor=F, fill=T )
dim(dta)
## [1] 11 3
str(dta)
## 'data.frame': 11 obs. of 3 variables:
## $ Country : chr "Australia" "Canada" "Denmark" "Finland" ...
## $ consumption: int 480 500 380 1100 1100 230 490 250 300 510 ...
## $ death : int 180 150 170 350 460 60 240 90 110 250 ...
fLoc <- "http://www-stat.stanford.edu/~rag/stat222/BOCKlong.dat"
dta1 <- read.table(fLoc, header = T)
str(dta1)
## 'data.frame': 256 obs. of 4 variables:
## $ vocab : num 1.75 0.9 0.8 2.42 -1.31 -1.56 1.09 -1.92 -1.61 2.47 ...
## $ grade : int 8 8 8 8 8 8 8 8 8 8 ...
## $ student: int 1 2 3 4 5 6 7 8 9 10 ...
## $ isMale : int 1 1 1 1 1 1 1 1 1 1 ...
head(dta1, n = 9); tail(dta1, n = 9)
## vocab grade student isMale
## 1 1.75 8 1 1
## 2 0.90 8 2 1
## 3 0.80 8 3 1
## 4 2.42 8 4 1
## 5 -1.31 8 5 1
## 6 -1.56 8 6 1
## 7 1.09 8 7 1
## 8 -1.92 8 8 1
## 9 -1.61 8 9 1
## vocab grade student isMale
## 248 1.16 11 56 0
## 249 2.18 11 57 0
## 250 2.61 11 58 0
## 251 3.91 11 59 0
## 252 1.86 11 60 0
## 253 3.89 11 61 0
## 254 4.98 11 62 0
## 255 2.31 11 63 0
## 256 2.64 11 64 0
knitr::include_graphics("C:/Users/User/Desktop/LearnR/2.png")
A caption
#install.packages("kableExtra")
library(knitr)
library(dplyr)
library(kableExtra)
knitr::opts_chunk$set(echo = TRUE)
options(knit.table.format = "html")
kable(cars) %>%
kable_styling() %>%
scroll_box(height = "200px")
| speed | dist |
|---|---|
| 4 | 2 |
| 4 | 10 |
| 7 | 4 |
| 7 | 22 |
| 8 | 16 |
| 9 | 10 |
| 10 | 18 |
| 10 | 26 |
| 10 | 34 |
| 11 | 17 |
| 11 | 28 |
| 12 | 14 |
| 12 | 20 |
| 12 | 24 |
| 12 | 28 |
| 13 | 26 |
| 13 | 34 |
| 13 | 34 |
| 13 | 46 |
| 14 | 26 |
| 14 | 36 |
| 14 | 60 |
| 14 | 80 |
| 15 | 20 |
| 15 | 26 |
| 15 | 54 |
| 16 | 32 |
| 16 | 40 |
| 17 | 32 |
| 17 | 40 |
| 17 | 50 |
| 18 | 42 |
| 18 | 56 |
| 18 | 76 |
| 18 | 84 |
| 19 | 36 |
| 19 | 46 |
| 19 | 68 |
| 20 | 32 |
| 20 | 48 |
| 20 | 52 |
| 20 | 56 |
| 20 | 64 |
| 22 | 66 |
| 23 | 54 |
| 24 | 70 |
| 24 | 92 |
| 24 | 93 |
| 24 | 120 |
| 25 | 85 |
https://medium.com/@kstseng/r-markdown-template-a4b0449a56d5
# ---
# title: "Ca7_Logistic Regression_0422"
# author: "Tung-Han Wu"
# date: "2020/4/22"
# output:
# html_document:
# toc: true
# toc_depth: 2
# toc_float:
# collapsed: false
# smooth_scroll: false
# ---
單星號 *代表斜體字體,雙星號 ** 代表加粗字體。
斜體字體
雙星號
rgb()函數中參數alpha是用來設置透明度的,對於特別密集的散點圖很常用。
colors() 顏色抓取 http://www3.nccu.edu.tw/~99354011/R%20commands%2811.09.13%29.pdf
pie(…..radius,clockwise…)
https://kknews.cc/zh-tw/code/grvxg2l.html
https://blog.csdn.net/weixin_34341229/article/details/85978263?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522158732931319724845052216%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=158732931319724845052216&biz_id=0&utm_source=distribute.pc_search_result.none-task-blog-2blogfirst_rank_v2~rank_v25-3
https://blog.csdn.net/happywlg123/article/details/84107375
R函數-sql(),rep() https://blog.csdn.net/lili_wuwu/article/details/51907715 https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/rep
mai 設置圖形空白邊界,mai =c(bottom, left, top, right),單位為英寸。 缺省為mai= c(1.02,0.82,0.82,0.42)。 mar 設置圖形空白邊界行數,mar = c(bottom, left, top, right)。缺省為mar = c(5.1,4.1,4.1,2.1)。 http://newtomaso.blogspot.com/2015/02/par-in-r-rpar.html
繪圖參考網址 https://kknews.cc/code/9oemv35.html https://www.rdocumentation.org/packages/graphics/versions/3.6.2/topics/par https://kknews.cc/code/zbbn6op.html https://kknews.cc/zh-tw/news/mpnzp99.html # bg op
#畫圖,bg控制顏色 op <- par(bg=“red”)