[R] Variable labels

John Dougherty jwd @end|ng |rom @urewe@t@net
Sat May 15 00:31:06 CEST 2021

On Fri, 14 May 2021 17:20:20 +0800
Steven Yen <styen using ntu.edu.tw> wrote:

> Thanks to all, for bearing with me.
> Now I realize expss may not be what I need. I have now written a 
> self-runnable, replicable set of codes (listed below). Perhaps that 
> gives an idea of what I need. Question is, whethet this is the right
> way to do this (to have a clickable object to learn about variable 
> definitions) or whether there are better ways. Thanks!
> Steven
From your example, after loading "try1.RData" you see a
"definitions" entry in the Environment pane.  Clicking on the name
"definitions" as opposed to the icon to expand the entry opens the
"definitions" data frame in its own tab in a pane on the upper left
where files such as scripts are displayed.  Clicking that tab opens the
list of "definitions" which is a list of three entries, where the
variable ids from the "mydata" file are row names.  

That will be the case in any session accessed using RStudio and opening
your saved .RData file.

If you are concerned about non-RStudio users being able to access that
data.frame in the Windows version R, if they load the .RData file that
will load the "definitions" data frame, which can be listed simply
typing "definitions" at the command prompt.

There is no "right way" do this.  Your approach works, though it will
get awkward if the data frame contains very many definitions.  If you
look at SPSS (or PSPP) for instance the Data Name and Label are both
elements of the definition of the variable, and the Label element of
the SPSS variable definition is essentially what your example seems to
use as a definition.  Otherwise you seem to be treading around the edges
of metadata which is also a set of data definitions.

R is more flexible about these things, which makes it somewhat more of
a chore at times.  

More information about the R-help mailing list