2010-02-22 1 views

답변

35

Roxygen은 R 파일 내 어디에서나 사용할 수 있습니다 (달리 말하면 함수가 오지 않아도됩니다). 또한 R 문서의 모든 docType을 문서화하는 데 사용할 수 있습니다.

그래서 그냥 별도의 블록 데이터 (이 같은) 문서화 할 수 있습니다 roxygen2> 4.0.0의로

#' This is data to be included in my package 
#' 
#' @name data-name 
#' @docType data 
#' @author My Name \email{[email protected]@roxygen.org} 
#' @references \url{data_blah.com} 
#' @keywords data 
NULL 
+8

을'NULL' 'roxygen()'대신'roxygen'에 런타임 의존성을 유발하지 않도록하십시오. – hadley

+1

우수 점, 고마워요. 변화를 만들었습니다. – Shane

+3

@hadley : 다음과 같은 예제를 roxygen 비 네트에 추가하고 roxygen 의존성에 대한 요점을 말하면 좋을까요? 파일을 구조화하는 방법에있어 다소 혼란 스럽습니다. – Shane

27

을, 당신은 다른 곳의 이름을 문서화하여 데이터 객체가 를 정의 문서화 할 수 문자열로 정의 된 객체 :

#' This is data to be included in my package 
#' 
#' @author My Name \email{[email protected]@roxygen.org} 
#' @references \url{data_blah.com} 
"data-name" 
16

ggplot2 패키지의 예제를 연구하면 유용합니다. 데이터 세트의 모든 Roxygen 코드가 패키지의 R 디렉토리에 하나의 .r 파일에 포함 할 수

  • :

    는 노트의 ggplot2.r on github

    몇 가지를 참조하십시오. 이것은 다음과 같습니다 도움말 파일이 만들어

    #' Prices of 50,000 round cut diamonds 
    #' 
    #' A dataset containing the prices and other attributes of almost 54,000 
    #' diamonds. The variables are as follows: 
    #' 
    #' \itemize{ 
    #' \item price. price in US dollars (\$326--\$18,823) 
    #' \item carat. weight of the diamond (0.2--5.01) 
    #' \item cut. quality of the cut (Fair, Good, Very Good, Premium, Ideal) 
    #' \item colour. diamond colour, from J (worst) to D (best) 
    #' \item clarity. a measurement of how clear the diamond is (I1 (worst), SI1, SI2, VS1, VS2, VVS1, VVS2, IF (best)) 
    #' \item x. length in mm (0--10.74) 
    #' \item y. width in mm (0--58.9) 
    #' \item z. depth in mm (0--31.8) 
    #' \item depth. total depth percentage = z/mean(x, y) = 2 * z/(x + y) (43--79) 
    #' \item table. width of top of diamond relative to widest point (43--95) 
    #' } 
    #' 
    #' @docType data 
    #' @keywords datasets 
    #' @name diamonds 
    #' @usage data(diamonds) 
    #' @format A data frame with 53940 rows and 10 variables 
    NULL 
    

    :

는, 예를 위해 diamonds 데이터 세트를 참조하십시오 사용 더 낫다 제외

roxygen documentation example