I'm looking for a function to dump variables and objects, with human readable explanations of their data types. For instance, in php var_dump
does this.
$foo = array();
$foo[] = 1;
$foo['moo'] = 2;
var_dump($foo);
Yields:
array(2) {
[0]=>
int(1)
["moo"]=>
int(2)
}
Try
deparse
, for example:It's better than
dump
, becausedump
requires a variable name, and it creates a dump file.If you don't want to print it directly, but for example put it inside a string with
sprintf(fmt, ...)
or a variable to use later, then it's better thandput
, becausedput
prints directly.I think you want 'str' which tells you the structure of an r object.
Check out the
dump
command:A few examples:
Output on screen:
print is probably the easiest function to use out of the box; most classes provide a customised print. They might not specifically name the type, but will often provide a distinctive form.
Otherwise, you might be able to write custom code to use the class and datatype functions to retrieve the information you want.