당신이 볼 수있는 또 다른 (그리고 하위 키) 대체 기능은 기능에 일부 메타 데이터를 추가하는 comment()
및 attr()
기능입니다.
> attributes(FOO)
$source
[1] "function(x,y) {" " x + y " "}"
$comment
[1] "FOO performs simple addition"
$help
[1] "FOO expects two numbers, and it will add them together"
또는 특정 부분 추출 :
FOO <- function(x,y) {
x + y
}
attr(FOO, "comment") <- "FOO performs simple addition"
#This can be arbitrary. "comment" is special. see ?comment for details.
attr(FOO, "help") <- "FOO expects two numbers, and it will add them together"
그런 다음 attributes()
를 사용하여 FOO
과 관련된 모든 것을 볼 수 있습니다
> attr(FOO, "help")
[1] "FOO expects two numbers, and it will add them together"
attr(FOO, "comment")
[1] "FOO performs simple addition"
을 그리고의 경우 여기에 신속하고 어리석은 예이다 댓글, 사용 comment()
:
> comment(FOO)
[1] "FOO performs simple addition"
장기적으로 볼 때 자신의 패키지를 작성하는 것이 오버 헤드 및 시간 투자의 가치가있는 것은 확실하지만 어떤 이유로 단기적으로 실용적이지 않은 경우 - 여기에 또 다른 옵션이 있습니다.
roxygen echo입니까? 에코? – Chase