IT/R
[R] 질문하는 법 - 코드 재현하는 법 (reprex 패키지)
Jany
2020. 8. 12. 06:27
반응형
R 초보자를 위한 필수 패키지!
tidyverse 에서 만든 reprex 패키지 이다.
https://reprex.tidyverse.org/reference/reprex.html
Render a reprex — reprex
Run a bit of R code using rmarkdown::render() and write the rendered result to user's clipboard. The goal is to make it easy to share a small reproducible example ("reprex"), e.g., in a GitHub issue. Reprex source can be read from clipboard read from curre
reprex.tidyverse.org
이 패키지는 사용법도 매우 쉽다.
1. 패키지 설치
install.packages("reprex")
또는
devtools::install_github("tidyverse/reprex")
당연히 devtools로 설치할때는 devtools 이 설치되어 있어야 한다.
2. 사용법
설치한 reprex 패키지를 불러온다.
library(reprex)
공유하고자 하는 코드를 클립보드로 복사한다.
Ctrl+c 혹은 CMD+c
그리고 나서 함수를 실행해준다.
reprex()
클립보드로 저장됐다는 문구가 나오면
R studio viewer에서 클립보드 내용을 확인할 수 있다.
실제 붙여넣기를 해보면 markdown으로 저장된 값을 확인할 수 있다.
``` r
y<-c(1:4)
mean(y)
#> [1] 2.5
```
<sup>Created on 2020-08-12 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0)</sup>
github 등 markdown을 지원하면 sniffet으로 바로 저장이 된다.
반응형