[R] Variable and value labels

Anupam Tyagi @nupty@g| @end|ng |rom gm@||@com
Thu Jul 13 08:50:31 CEST 2023


Thanks, Avi. By labels I mean human readable descriptions of variables and
values of factor variables. In a plot, I want labels to be used
for labelling axes on which a factor is plotted, and variable labels for
axes names/descriptions in a plot. I may have borrowed the terminology of
variable and value labels from Stata software, which I use.

I use a lot of packages. So, I have nothing against packages. But for
labelling, I sometimes worry that I may get tied to a package for something
as basic as assigning labels, and some function/packages may not pick up
the labels correctly/well when plotting or displaying results. Maybe I am
worried for nothing.

I have not used R much after 2003. In the past few months I have begun to
use R again with R Studio, mostly for plotting and visualization of data.
So, you can think of me as a new user.

On Thu, 13 Jul 2023 at 00:14, <avi.e.gross using gmail.com> wrote:

> Anupam,
>
> Your question, even after looking at other messages, remains a bit unclear.
>
> What do you mean by "labels"? What you mean by variables and values and how
> is that related to factors?
>
> An example or two would be helpful so we can say more than PROBABLY.
> Otherwise, you risk having many people here waste lots of time sending
> answers to questions you did not ask.
>
> And why an insistence on not using packages? If you are doing something for
> a class, sure, you may need to use the basics you were supposedly taught in
> class or a textbook. Otherwise, a good set of packages makes code much
> easier to write and often more reliable. Realistically, quite a bit of what
> some call base R is actually packages deemed useful enough to be included
> at
> startup and that can change.
>
> If you are new to R, note you can attach arbitrary attributes to a variable
> and you can have things like named lists where some or all the items have
> names as an attribute.
>
> Factors are part of base R and are a completely different concept. You can
> use base R to get or set the base levels of a factor and many other things
> and there are advantages sometimes in using a vector in factor mode than
> plain but also sometimes disadvantages.
>
> If you ask a more specific and properly explained question, maybe we can
> help you.
>
> Specifically, please tell us how you plan on using your labels. As an
> example, if I make a named list like this:
>
> mylist <- list(pi=3.14, e=2.7, 666)
>
> then I can access all elements as in mylist[[2]] without a name but
> mylist$pi lets me access that item by name and mylist[["e"]] and I can also
> change the current values similarly. But without explaining what you want,
> my explanation likely is not what you need.
>
> But do note that even if you do not USE a package, you can sometimes use it
> indirectly by examining the code for a function you like. If it is
> primarily
> written in R, you may see how it does something and take a part of the code
> and use it yourself.
>
>
>
> -----Original Message-----
> From: R-help <r-help-bounces using r-project.org> On Behalf Of Anupam Tyagi
> Sent: Tuesday, July 11, 2023 11:49 PM
> To: r-help mailing list <r-help using r-project.org>
> Subject: [R] Variable and value labels
>
> Hello,
>
> is there an easy way to do variable and value labels (for factor variables)
> in base-R, without using a package. If not, what is an easy and good way to
> do labels, using an add-on package.
>
> --
> Anupam.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using 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.
>
>

-- 
Anupam.

	[[alternative HTML version deleted]]



More information about the R-help mailing list