2012-04-03 19 views
22

Rオブジェクトの構造を印刷するコマンドとは何ですか?オブジェクトは印刷された出力を実行して再作成できますか?Rオブジェクトの構造をコンソールに印刷する方法

出力には多くの場合、structure関数が含まれているため、再現可能な例のオブジェクトを簡単に作成するために、出力をコピーしてコードに貼り付けることができます。

私は知っているべきであるこのコマンドの上で私の頭を全日朝に壊しています。

+3

これは良い質問ですと 'dput'は非常に参考にされていますが、この質問の文言は、それがないと、それは難しいグーグル経由で見つけることができますdiscoveringが「コピーしてコードに貼り付けることができるように、Rオブジェクトを印刷する」のような検索は行わないでください。 – johneric

答えて

27

機能はdput(またはdump)です。

8

私はstr機能(別名構造)がダンプよりも一貫して有用な情報を持っていると思います。 Rヘルプから

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. 

関連する問題