I am using the Survey
Package in R to do some initial descriptive stats for my dissertation. With the outputs for both the svymean
and the barplot
, I would like the value labels to be displayed for the variable-it would make the descriptive statistics much easier to interpret. Instead of the output labels of: F1RTRCC1, F1RTRCC2-I
would like to see the value labels of "academic" and "occupational" to be displayed.
How do I go about making this happen? I am including a minimal reproducible example with a small subset of my actual data:
#Calling Survey Package
library (survey)
#Using dput to display a subset of my actual data
MRE1 <- structure(list(ï..STU_ID = c(101101L, 101102L, 101104L, 101105L, 101106L, 101107L),
PSU = c(1L, 1L, 1L, 1L, 1L, 1L), STRAT_ID = c(101L,
101L, 101L, 101L, 101L, 101L), BYSCTRL = c(1L, 1L, 1L, 1L, 1L,
1L), G10COHRT = c(1L, 1L, 1L, 1L, 1L, 1L), F1RTRCC = c(2L, 1L,
4L, 2L, 2L, 4L), F1SEX = c(2L, 2L, 2L, 2L, 2L, 1L), F1RACE = c(5L,
2L, 7L, 3L, 4L, 4L), F1PARED = c(5L, 5L, 2L, 2L, 1L, 2L), F1SES2QU = c(2L,
4L, 1L, 1L, 1L, 1L), F1HIMATH = c(5L, 6L, 6L, 4L, 5L, 4L), F1RGPP2 = c(2L,
4L, 4L, 4L, 4L, 1L), F3ATTAINMENT = c(3L, 10L, 6L, 4L, 4L, 3L
), F3EDSTAT = c(5L, 5L, 5L, 2L, 2L, 5L)), .Names = c("ï..STU_ID",
"PSU", "STRAT_ID", "BYSCTRL", "G10COHRT", "F1RTRCC", "F1SEX",
"F1RACE", "F1PARED", "F1SES2QU", "F1HIMATH", "F1RGPP2", "F3ATTAINMENT",
"F3EDSTAT"), row.names = c(NA, 6L), class = "data.frame")
#Svymean of Variable F1RTRCC
#There is an error coming here: Error in UseMethod("svymean", design) :
#no applicable method for 'svymean' applied to an object of class "data.frame"-I
#think this is likely related to my dput subset of my data, as when I am using
#this function with my full dataset, this error does not display.
CC <- svymean(~F1RTRCC, MRE1, na.rm=T)
CC
#Barplot for F1RTRCC
barplot(CC)
With the outputs for both the svymean and the barplot, I would like the value labels to be displayed.
Instead of F1RTRCC1, F1RTRCC2-I would like to see the value labels of "academic" and "occupational" to be displayed.
How do I go about making this happen?