On 01/08/2016 9:28 AM, Marco Silva wrote:
Sometimes I comeback with a session months later. I would like to know
the type of variables I have in. So I tried:
sapply(ls(), typeof)
ago_ts ago_ts.1 ago_ts.2 annualy conn
"character" "character" "character" "character" "character"
d_jul df diffs f fit
"character" "character" "character" "character" "character"
i ibm ibm_url increments increments_jul
"character" "character" "character" "character" "character"
jul_ts lago lnkd_url model model_jul
"character" "character" "character" "character" "character"
op rain t t2 ts_
"character" "character" "character" "character" "character"
And I noticed everything is type "character".
Obviously wrong answer. So How can I have the right answer ?
Thanks
The ls.str() function probably does what you want.
If you wanted to do it with sapply (e.g. because you want just typeof(),
not everything else), you need to take account of the fact that ls()
returns a character vector, so you have to get the objects with those
names before calling typeof. For example,
sapply(ls(), function(name) typeof(get(name)))
Duncan Murdoch
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.