# A tibble: 18 x 4
sex age time value
<chr> <chr> <chr> <dbl>
1 F 0 2021 31
2 F 0 2022 17
3 F 0 2023 22
4 F 16 2021 22
5 F 16 2022 25
# i 13 more rows
use the pxmake library to convert the dataframe to a r-object .rds, .px and .xlsx, like this:
# devtools::install_github('StatisticsGreenland/pxmake')library(pxmake)# from dataframe to rdsrds <-metamake(df)# MATRIX - used also for filename in this examplepx_matrix <-"BEXFIRSTML"# from dataframe to xlsxmetamake(df, paste0(px_matrix,".xlsx"))# from rds to pxpxmake(rds,paste0(px_matrix,".px"))# view(rds$metadata)# view(rds$data)
Some keywords in the r-object (rds) are preset with default values and generated by code. The metadata can be seen using view(rds$metadata)
The sample dataframe can be edited in Excel or R. Metadata is still too vaguely defined for pxwin to show the file, but pxedit does (of course).
For pxwin to show the px-file, these keywords cannot be blank:
MATRIX, CONTENTS, UNITS, SUBJECT-CODE, SUBJECT-AREA
MATRIX & SUBJECT-CODE are not multilingual, but CONTENTS, UNITS & SUBJECT-AREA is.
So update the keywords and add necessary keywords: