Dear Yawo,

I would suggest that you learn to use R, rather than thrashing around blindly and expecting or hoping to get others to do your work for you.

To get you started, the characteristics that you call "labels" are stored as *attributes* of the columns of your tibble/data frame. E.g.
X$Animal prints as

 [1] 0 0 0 0 0 0 0 0 0 0
attr(,"label")
[1] "Animal"
attr(,"labels")
Cat Dog 0 1 attr(,"class")
[1] "haven_labelled"

(where "X" is the head of CatsDogs that you dput()-ed and sent to the list.)

I would start by doing something like

CatsDogs$Animal <- factor(CatsDogs$Animal,levels=c(0,1),
                          labels=c("Cat","Dog"))
and similarly for the other columns. When you have learnt a bit about R, doing your frequency tabulations and barplots will then be easy.

cheers,

Rolf Turner

On 8/02/20 7:03 pm, Yawo Kokuvi wrote:
Thanks for all. Here is output from dput.  I used a different dataset
containing categorical variables since the previous one is on a different
computer.

In the following dataset, my interest is in getting frequencies and
barplots for the two variables: Training and Dance, with value labels
displayed.

thanks again - cY


=========
dput(head(CatsDogs, n = 10))
structure(
   list(
     Animal = structure(
       c(0, 0, 0, 0, 0, 0, 0, 0, 0,
         0),
       label = "Animal",
       labels = c(Cat = 0, Dog = 1),
       class = "haven_labelled"
     ),
     Training = structure(
       c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
       label = "Type of Training",
       labels = c(`Food as Reward` = 0,
                  `Affection as Reward` = 1),
       class = "haven_labelled"
     ),
     Dance = structure(
       c(1,
         1, 1, 1, 1, 1, 1, 1, 1, 1),
       label = "Did they dance?",
       labels = c(No = 0,
                  Yes = 1),
       class = "haven_labelled"
     )
   ),
   row.names = c(NA,-10L),
   class = c("tbl_df", "tbl", "data.frame")
)

<SNIP>

______________________________________________
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.

Reply via email to