R Packages

R Packages



1. dplyr 패키지



출처: http://rfriend.tistory.com/234
출처: http://wsyang.com/2014/02/introduction-to-dplyr/


Txt
require("dplyr")
data("CO2")
C <- CO2
head(C,3)
S1 <- select(C, Type, conc, uptake)                     # 다음의 열을 선택하라
S2 <- filter(C, conc >= 100 | uptake < 30)            # |는 or이다
S2 <- filter(C, Type=="Quebec", conc >= 100)     # ,는 and이다

S3 <- mutate(S2, what = conc - uptake, what_negative = - what)     # 새로운 열 생성
S4 <- arrange(S3, uptake)                                                                 # uptake에 따라 정렬하라, 중복 선택 가능
S5 <- arrange(S4, desc(uptake))                                                       # 내림차순 정렬

SM <- summarise(S5, mean_conc = mean(conc), sd_uptake = sd(uptake)) # DF형식으로 요약 

# Chain 형식으로 데이터 받아서 그대로 사용

T <- S2 %>% mutate(what=conc-uptake) %>% arrange(desc(uptake)) %>% summarise(mean_uptake = mean(uptake))




2.       패키지


























































2. 패키지 목록
1) XML
> readHTMLTable(url): 웹에 있는 HTML로 된 테이블에서 데이터를 읽어오고 싶을 때


2) car
> some( ): 랜덤으로 데이터 추출
> sp( A ~ B \ G): G(그룹)를 기준으로 A와 B의 관계 scatter plot

3) reshape
> rename( df, c("A", "B") ): 데이터프레임 변수명 변경

4) plyr


5) Rcpp
>

6) corplot
> corplot( cor(df, [4:8] ): 시각적 산점도

7) RColorBrewer
> boxplot ( x, col = brewer.pal (6, "Blues"))

8) psych
> summary( ) 기능 확장 

9) Hmisc
>  rcorr( ): cor 상관관계 구할때 두개의 행렬을 한번에 처리 가능
 - 데이터가 행렬이여야 하므로, 주어진 데이터가 다른 형식이라면 as.matrix를 사용할 것

10) cluster
> clusplot( ): Cluster Analysis에서 kmeans 그래프를 그림

11) wordcloud
단어구름

12) tseries
runs.test

13) nortest
정규성 검정

14) ggplo2, lattice, zoo
그래픽스

15) gplots
> barplot2( x, plot.ci = TRUE, ci.l = , ci.u=  )
  - 신뢰구간이 있는 막대그래프

16) lmtest
> dwtest( ) 더빈 왓슨 검정

17) doBy
> summaryBy

18) agricolae
> duncan.test( )
> scheffe.test( )

19) xts, zoo, quantmod
시계열

20) forecast
auto.arima

21) 




댓글

가장 많이 본 글