[R] Variable and value labels

@vi@e@gross m@iii@g oii gm@ii@com @vi@e@gross m@iii@g oii gm@ii@com
Wed Jul 12 20:44:42 CEST 2023


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


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.


	[[alternative HTML version deleted]]

R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list