> a)Is there a way to access rownames similar to
'colname(matrix M,
> scalar column)'?
Hm, good question. I don't know why there is no rowname analogue
to
colname(). [...]
> b)I am trying to find a solution to get the observation number
of a
> specific entry of a series in a subsampling (i.e., the integer with
> which I could access this entry in the full sample), [...]
I'm not sure I understand the question. The observation numbers/indices in
the dataset do not depend on subsampling.
I missed a crucial part. I use a bundle structure and attach a series "obsdate =
obs" to the bundle. Now, when I subsample the dataset, the series contained in the
bundle does not work anymore, because it is not sampled alongside (because it is a copy,
not a link). However, the list-idea works great! (see at the end)
> c)Misc. feedback :
[...]
> b.Instead of "varname()" one needs to use
"argname()" to get the name
> of a series (even when passed by pointer). This could be noted in the
> gretl help
You mean inside a function, and you want a cross-reference from the help
for varname() to the help for argname()?
Yes.
> c.neither argname nor varname work on elements contained within
a
> bundle. [...]
If I understand correctly, this is what I meant earlier when I said "if you use
bundles, you need good documentation for what they contain".
I don't think it's possible to get what you want. For example a bundle can
contain many series. Do you want to retrieve all the names in there?
If yes, what are you going to do about it without having some meta
knowledge about what each of them represents?
I would use them for plotting, to provide information for the titles.
> d.A recursive "exists" for bundles would be nice. I.e.
if I ask
> "exists(a.b.x)" it is checked if x exists, but if "b" already
is
> missing, an error is produced.
Are you talking about nested bundles here? Are you aware of the
inbundle() function? (Which isn't recursive AFAIK, though.)
Yes, I am aware of it and used it, but it has the same problem. Btw.: It is not documented
that "strings" and "matrices" have the same type reported as
"array" (6)
But indeed it sounds as if it might be useful to turn the not yet
possible
'exists(b["hey"])' into an alias for something like:
if exists(b)
if inbundle(b, "hey")
return <type code for b.hey>
else
return 0
endif
else
return <new code? NA?>
endif
I even have a bundle inside a bundle, so for checking if "abndl.bbndl.cstring"
exists, I need:
<hansl>
scalar isOK=0 #0==not ok
if exists(abndl)
if inbundle(abndl,bbndl)
isOK = inbundle(abndl.bbndl,cstring)
endif
endif
> d)Misc. questions:
>
> a.When I attach, within a function, a genr element (like series) that
> was passed by pointer to the function, to a bundle, it is in fact
> copied (hansl-primer p.20). Is there a way to instead add pointers to
> the bundle? Perhaps by means of using the array type?
No I don't think so. What you could do is store your own reference to the
series, so for example save the argname() as a string, and then work with
that. Apart from that a gretl list is basically just a set of references to existing
series, and recently it was made possible to add a list to a bundle, so perhaps
that's your solution.
Or also the integer ID via varnum(), but that may change so I tend to avoid it.
(Strictly speaking the string name may also change, but only through explicit
action AFAIK.)
THAT'S IT! thanks! If you assign a series first to a list and then to the bundle, it
is "behind the curtain" a pointer assignment. I can provide a front-end function
where a user only passes a series via pointer now, which is then internally passed to a
list that is stored in the bundle. This way, I can also take care of the problem with
identifying the correct items in case of subsampling (and it is more efficient to not copy
the series). I tested it and it's a perfect solution to my problem.
Some other things I noticed:
A) it would be nice if one could "pipe" return values, i.e. "return
function()" is not a valid statement. This would make things more readable.
B) inbundle(bundle,list) returns "7", but this is not documented.
C) If you have a bundle within a bundle, you cannot save it to inspect it (via gui, icon
view, click on envelop bundle then save.. select the bundle. Nothing happens.) However, if
you assign a new bundle from the bundle directly via the script, it works (inbundle =
bundle.inbundle)
D) If you create an empty bundle like "bundle new" that is fine, but
"bundle new = null" doesn't do anything, but neither report that. Perhaps
just my error, I don't know. But it might be a source for bugs.
E) The error msg for functions with a name that is too long (>31 chars) is not
informative. Names so long CAN happen if working with telling quasi-namespaces... (via
"_" connected), e.g.
F) I have frequent crashes when using the button to move the output window to the front.