1

I am working with [tag: R] on the [tag: Arab Barometer] wave 5, and I'm trying to visualize the political party labels. However, I'm not able to display them.

If I code table(dataset$Q503) or, for a single country, table(country1$Q503), the numerical codes assigned to the parties appear, as well as if I use the command as.factor(). In order to display the labels associated with the numeric codes, I was advised to download the R package [tag: expss] and use the command val_lab(). However, when I input val_lab(dataset$Q503) or val_lab(country1$Q503) in both cases the answer is NULL. Any ideas on how to display labels?

The code:

library(tidyverse)
library(expss)

setwd("C:/Users/my_name/Dropbox/work_space/")
Dataset <- read.csv("CodeR/_Databases/Dataset.csv") 

Country1 <- subset(Dataset, country==1)
table(Country1$Q503A)

Result:

 0  10001  10002  10003  10004  10005  10006  10007  10008  10009  10010
1237    578     60    118     21     18     13     12     17      1      8

So far so good. When I try to identify the corresponding labels, I have problems.

val_lab(Country1$Q503A)

Result:

NULL
Enosky
  • 11
  • 3

1 Answers1

0

The .csv version of the survey doesn't include labels; labels are in the .sav version of the data. Here's a pretty great short resource on labels, for future ref: https://martinctc.github.io/blog/working-with-spss-labels-in-r/

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/34513958) – user12256545 Jun 10 '23 at 13:07