統計分析:使用 R 入門/R/函式幫助
外觀
< 統計分析:使用 R 入門 | R
在 R 中,一個常見的問題是知道要使用哪個函式。例如,我們想要一個函式,它可以從 1 到 6 之間生成隨機取樣的數字。以下是一種查詢方法
help.search("random") #list the R functions to do with the word "random"
#The "sample" function is described as “Random Samples and Permutations”: just the thing
help("sample") #get detailed information on the "sample" function
?sample #this is a quicker way of doing the same thing
從幫助頁面中,您將看到 "sample" 從列表中隨機挑選專案,"Usage" 部分顯示 "sample" 函式最多接受 4 個逗號分隔的引數。 "Arguments" 部分描述了它們是什麼
- x(一個向量,指定要從中選擇的專案列表)
- size(挑選專案的次數)
- replace(一個 TRUE 或 FALSE 值,指示每次挑選後是否應將專案放回列表中)
- prob(一個機率向量,如果我們不希望等機率地挑選每個專案,則使用)