Hello everyone,
I am new to the survey package and using it to do very simple data visualization. I have simple random sample data (I think? Just the weights are known), where I have made data weights using anesrake package and then created a survey design using the following code:
my_des <- svydesign(data = kysely_hirvi, weights = ~weight, ids = ~1)
I have a weird problem considering the svyboxplot, when I use the following code:
b <- svyboxplot(hirvi_sarvisuositus~factor(riistakeskus), my_des, all.outliers = F)
It draws all the categories identical : exactly same values for each grouping category, which is not true. I have a feeling that it is possibly the last category, which is somehow duplicated for every category?
When I studied the problem subsetting each of my category (15 of them) using the following code:
svyboxplot(hirvi_sarvisuositus~1, subset(my_des, riistakeskus == "Etelä-Häme"), ylim = c(0,10))
the values are different for each area / different boxplots for each area.
Can anyone help me? I am desperate!
PS. Here`s sample to test
library(tidyverse)
col <- tibble(
name = c("seura 1", "seura 2", "seura 3", "seura 4", "seura 5", "seura 6", "seura 7", "seura 8", "seura 9"
, "seura 10", "seura 11", "seura 12"),
riistakeskus = c("Keski-Suomi","Keski-Suomi","Keski-Suomi","Keski-Suomi","Keski-Suomi","Satakunta","Satakunta",
"Satakunta","Uusimaa", "Uusimaa","Uusimaa","Uusimaa"),
hirvi_sarvisuositus = c(1,4,5,3,7,5,3,4,6,5,8,9),
weights = c(1.1461438,1.1461438,1.1461438,1.1461438,1.1461438,0.5107815,0.5107815,0.5107815,2.0461937,
2.0461937,2.0461937,2.0461937)
)
library(survey)
my_des1 <- svydesign(data = col, weights = ~weights, ids = ~1)
b <- svyboxplot(hirvi_sarvisuositus~factor(riistakeskus), my_des1, all.outliers = F, ylim = c(0,10))
svyboxplot(hirvi_sarvisuositus~1, subset(my_des1, riistakeskus == "Keski-Suomi"), ylim = c(0,10))
svyboxplot(hirvi_sarvisuositus~1, subset(my_des1, riistakeskus == "Satakunta"), ylim = c(0,10))
svyboxplot(hirvi_sarvisuositus~1, subset(my_des1, riistakeskus == "Uusimaa"), ylim = c(0,10))