Loading...
20151216
[Coursera]
R Programming
(11)
整理自
R Programming
(Week
3)
--
Loop Functions
(1)
[ Week 3 課程內容 ]
Loop Functions - lapply
[9:23]
Loop Functions - apply
[7:21]
Loop Functions - mapply
[4:46]
Loop Functions - tapply
[3:17]
Loop Functions - split
[9:09]
Debugging Tools - Diagnosing the Problem
[12:33]
Debugging Tools - Basic Tools
[6:25]
Debugging Tools - Using the Tools
[8:21]
[ 筆記內容 ] Loop Functions
(1)
(一)Loop Functions - lapply
1. lapply()
[ 用法 ]
[ 範例1 ]
"lapply()"
一定會回傳
"列表型態"的結果_(1)
[ 範例2 ] 利用"lapply()"處理多個以上元素所組成的列表
[ 範例3 ]
"lapply()"
搭配
"runif()"_(1)
[ 範例4 ]
"lapply()"
搭配
"runif()"_(2)
[ 範例5 ]
"lapply()"
充分使用了
"匿名函數
(沒有函數名稱)"
2. sapply()
[ 用法 ]
[ 範例 ]
"sapply()"
的使用方式
(二)Loop Functions - apply
1. apply()
[ 用法 ]
[ 範例1 ] 計算矩陣中每一列的平均值
[ 專用函數 ] 將"行(column)"和"列(row)"取
"總和"
或
"平均值"
[ 範例2 ] 計算每一"行"的 25 和 75 百分位數
[ 範例3 ] 對陣列進行操作
(一)
Loop Functions - lapply
[
參考資料
]
課堂講義 :
https://d396qusza40orc.cloudfront.net/rprog/lecture_slides/lapply.pdf
The Uniform Distribution -
https://stat.ethz.ch/R-manual/R-devel/library/stats/html/Uniform.html
[重點整理]
1. lapply()
[ 用法 ]
lapply(X, FUN, ...)
"
X
":列表名稱
(如果"X"不是參數,將會用"as.list()"強制轉化為列表)
"
FUN
":被指定使用的函數
"
...
":傳遞參數
(對列表裡的每個元素做運算)
Please turn on JavaScript to use Paper in all of its awesomeness. ^_^
整理自 R Programming (Week 3) -- Loop Functions (1)
(一)Loop Functions - lapply
lapply(X, FUN, ...)