# Using data read from disk
input_path <- pnds_example(path="input_example.txt")
data_path <- pnds_example(path="exampledata.txt")
dictionary.path <- pnds_example(path="dictionaryexample.xls")
deflator.path <- pnds_example(path="deflatorexample.xls")
pnds.df <- read_pnds(microdata=data_path, input_txt=input_path, vars=c("J007","J009"))
pnds.df <- pnds.df[(pnds.df$M001 == "1" & !is.na(pnds.df$M001)),]
pnds.df <- pnds.df[,!(names(pnds.df) %in% c("V0029", "V00291", "V00292", "V00293"))]
pnds.df <- pnds_labeller(data_pnds=pnds.df, dictionary.file=dictionary.path)
pnds.df <- pnds_deflator(data_pnds=pnds.df, deflator.file=deflator.path)
# \donttest{
pnds.svy <- pnds_design(data_pnds=pnds.df)
# Calculating proportion of people diagnosed with chronic diseases
if (!is.null(pnds.svy)) survey::svymean(x=~J007, design=pnds.svy, na.rm=TRUE)# }
# \donttest{
# Downloading data
pnds.df2 <- get_pnds(year=2023, section="Female", vars=c("J007","J009"),
labels=TRUE, deflator=TRUE, design=FALSE,
reload=TRUE, curlopts=list(), savedir=tempdir())
pnds.svy2 <- pnds_design(data_pnds=pnds.df2)
# Calculating proportion of people diagnosed with chronic diseases
if (!is.null(pnds.svy2)) survey::svymean(x=~J007, design=pnds.svy2, na.rm=TRUE)# }
Run the code above in your browser using DataLab