Rstudio에서 R 패키지를 만들어 보자 1 ~자작 함수 실행~
4905 단어 RRStudioHelloWorld
목차
소개
R을 어느 정도 사용한 적이 있다면 패키지를 도입한 적이 있을까 생각합니다.
require(ggplot2)
library(dplyr)
이 패키지, 실은 자작도 가능하다는 것을 알고 계셨습니까?
이번에는 Rstudio를 사용하여 패키지를 사용해보십시오.
패키지 자체 제작
먼저 Rstudio의 File 메뉴에서 New Project를 선택합니다.

New directory를 선택합니다.

R 패키지를 선택합니다.

패키지 이름을 입력합니다. 여기에서는 HelloWorld로했습니다.

Create Project를 누르면 패키지 작성 화면이 열립니다.

require(ggplot2)
library(dplyr)
먼저 Rstudio의 File 메뉴에서 New Project를 선택합니다.

New directory를 선택합니다.

R 패키지를 선택합니다.

패키지 이름을 입력합니다. 여기에서는 HelloWorld로했습니다.

Create Project를 누르면 패키지 작성 화면이 열립니다.

여기서 이미 Hello world를 표시하는 프로그램이 완성되고 있습니다만, 이대로는 재미있지 않기 때문에 한 번 더 합시다.
hello <- function() {
# Hello world を10回表示
for(i in 1:10){
print("Hello, world!")
}
}
이제 Build 창에서 Build & Reload 버튼을 누르면 빌드가 시작됩니다. Console에 > library(HelloWorld)로 표시되어야 합니다. 작성된 패키지가 R로 로드되었습니다. 자, hello()를 입력하여 함수를 시작해 보겠습니다.
> hello()
[1] "Hello, world!"
[1] "Hello, world!"
[1] "Hello, world!"
[1] "Hello, world!"
[1] "Hello, world!"
[1] "Hello, world!"
[1] "Hello, world!"
[1] "Hello, world!"
[1] "Hello, world!"
[1] "Hello, world!"
무사히 패키지의 자체 제작 함수가 시작되었습니다.
다음은 매뉴얼 작성에 대해 씁니다. 그럼!
Reference
이 문제에 관하여(Rstudio에서 R 패키지를 만들어 보자 1 ~자작 함수 실행~), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/Dixhom/items/918f18ca22150e43c662텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)