728x90

### 1. 패키지 base의 함수 확인 – help(package=base)

 help(package=base) 이용하면 패키지 base에 들어있는 함수 목록이 HTML헝태로 목록이 나타납니다. 함수를 클릭하면 함수의 기능을 알 수 있습니다.  
<img src='https://wikidocs.net/images/page/252921/r_pac_base_01.jpg' style="width:600px; height:400px; border: 2px solid black;">

abs, apply, args, as.character, as.factor, cos, date 등 수많은 함수들이 들어 있는 것을 볼 수 있습니다.    
해당 함수를 클릭하면 함수의 사용법을 확인할 수 있습니다.    
help(함수이름) 또는 \> ?함수이름 을 실행하여 함수의 기능을 알 수 있습니다. 

### 2. 패키지 base의 함수 확인 – library(help=base)

library(help=base) 를 사용하면 패키지 ‘base’ 의 간단한 설명과 패키지 안에 있는 통계기법의 함수 리스트를 볼 수 있습니다. 

### 3. 도움말 이용하기 - help( ) 또는 ?를 이용

R 의 강점 중 하나가 도움말 기능이 뛰어나다는 점입니다. R 은 방대하기 때문에 필요한 내용을 찾기가 쉽지 않습니다. 패키지와 함수에 대한 도움말을 이용하는 것으로 ‘help()’ 또는 ‘?’를 이용하여 수시로 사용하는 습관을 붙이는 것이 좋습니다.   

\> help(mean) 또는 ?mean   
\> help.search(“mean”)   
\> help.start( )     
\> example(mean)   

\> help(stats) 또는 ? stats    
```
   stats-package {stats} R Documentation                                          
   The R Stats Package                                                              
                                                                                    
   Description                                                                      
                                                                                    
   R statistical functions                                                          
                                                                                    
   Details                                                                          
                                                                                    
   This package contains functions for statistical calculations and random number  
     generation.                                                                    
                                                                                    
   For a complete list of functions, use library(help = "stats").                   
                                                                                    
   Author(s)                                                                        
                                                                                    
   R Core Team and contributors worldwide                                           
                                                                                    
   Maintainer: R Core Team R-core@r-project.org
```

### 4. 샘플 프로그램 실행하기 

패키지 내에는 함수의 설명과 예제가 들어 있어서 실제로 실행해 보면 쉽게 이해할 수 있습니다. 또한 example(mean) 을 실행하면 함수 mean( ) 을 이용한 샘플프로그램을 볼 수 있습니다.   
\> example(mean)
```
          mean>  x <- c(0:10, 50)
          mean>  xm <- mean(x)
          mean>  c(xm, mean(x, trim = 0.10))(1) 
          [1] 8.75 5.50
```
\> example(lm)   
\> example(factor)   
\> example(acf)   

mean 함수의 샘플 프로그램   
```
1  x <- c(0:10, 50)
2  xm <- mean(x)
3  c(xm, mean(x, trim = 0.10))
```
설명
```
1 x <- c(0:10, 50) 
       0부터 10까지 값과 50 으로 구성된 벡터(원소 12개)를 만든다
       [1]  0  1  2  3  4  5  6  7  8  9 10 50

2 xm <- mean(x)  : 벡터 x 의 평균을 구하여 xm 에 저장합니다.
3 c(xm, mean(x, trim = 0.10)) :  실행결과 [1] 8.75 5.50
```
결과
```
[1] 8.75 5.50
```

###  5. 함수기능 키워드 검색 - help.search(“키워드명”)

키워드 검색을 하려면 help.search(“키워드명”) 같이 사용하면 됩니다.

\> help.search("stats")  또는 ??stats 

를 실행하면 패키지 stats 관련된 내용을 HTML 형태로 볼 수 있습니다.   
http://127.0.0.1:28573/library/stats/html/stats-package.html

<img src='https://wikidocs.net/images/page/253341/r_pac_help_01.jpg' style="width:600px; height:400px; border: 2px solid black;">




메모리에 로드되지 않은 패키지(예. cluster) 는 help(패키지이름)을 사용할 수 없습니다.
```
> help(cluster)
No documentation for ‘cluster’ in specified packages and libraries:
you could try ‘??cluster’

 > help.search(“mean”)
```
<img src='https://wikidocs.net/images/page/253341/r_pac_help_05.jpg' style="width:600px; height:400px; border: 2px solid black;">






+ Recent posts