2012-04-03 2 views
22

R 개체의 구조를 인쇄하는 명령은 무엇입니까? 그러면 인쇄 된 출력을 실행하여 개체를 다시 만들 수 있습니까?R 개체의 구조를 콘솔에 인쇄하는 방법

출력에는 종종 structure 함수가 포함되어 있으며 출력을 복사하여 코드에 붙여 넣으면 재생산 가능한 예제의 객체를 쉽게 만들 수 있습니다.

나는이 명령에 대해 매일 아침 내 머리를 아프게하고있다.

+3

이 좋은 질문이고 발견'dput'이 매우 도움이되었습니다 만,이 질문의 표현이이처럼 구글을 통해 찾을 수 열심히하게 다음 R 도움말에서

"R 객체를 복사하여 코드에 붙여 넣을 수 있도록 인쇄"와 같은 검색을하지 마십시오. – johneric

답변

27

이 함수는 dput (또는 dump)입니다.

8

생각해 보면 str 함수 (일명 구조)가 덤프보다 일관되게 유용한 정보를 가지고 있다고 생각합니다.

Compactly Display the Structure of an Arbitrary R Object 

Description 


Compactly display the internal structure of an R object, a diagnostic function and an 
alternative to summary (and to some extent, dput). Ideally, only one line for each 
‘basic’ structure is displayed. It is especially well suited to compactly display the 
(abbreviated) contents of (possibly nested) lists. The idea is to give reasonable 
output for any R object. It calls args for (non-primitive) function objects. 

관련 문제