Today, PX-Win has taken over the offline handling of PX files from PC-Axis and shares a codebase with PXWeb, but still remains somewhat in the shadows.
The lack of showcases for PX-Win limits its potential use in operations.
Often, the producer of a PX file does not have direct access to a server with PXWeb and, therefore, cannot fully benefit from PXWeb as cube explorer. A dataset does not need extensive metadata for PXWin to be useful, but naturally, more detail is required before it can be used for dissemination on PXWeb.
Step 1: Prepare data
In this case, simply get selected columns from the diamond dataset in ggplot2 (part of tidyverse)
next add these magic functions in one line of code:
# A tibble: 6 x 5
carat cut color clarity n
<dbl> <ord> <ord> <ord> <int>
1 0.2 Very Good E VS2 1
2 0.2 Premium D VS2 2
3 0.2 Premium E SI2 1
4 0.2 Premium E VS2 4
5 0.2 Premium F VS2 1
6 0.2 Ideal D VS2 1
Step 2: add pxmake
use 2 functions from pxmake:
px() - Create a px object from a px file, an Excel metadata workbook, a data frame or a Parquet file.
px_save - Save px object to file
for help, check vignettes ’?px’and open with Pxwin.
---title: "Usecase: PXWinR"always_allow_html: trueformat: html: code-tools: true self-contained: trueoutput: statgl::statgl_report: output: "pretty_html"execute: echo: trueeditor: source---## PXWin as cube explorerToday, PX-Win has taken over the offline handling of PX files from PC-Axis and shares a codebase with PXWeb, but still remains somewhat in the shadows.The lack of showcases for PX-Win limits its potential use in operations.Often, the producer of a PX file does not have direct access to a server with PXWeb and, therefore, cannot fully benefit from PXWeb as cube explorer. A dataset does not need extensive metadata for PXWin to be useful, but naturally, more detail is required before it can be used for dissemination on PXWeb.**Step 1: Prepare data**\In this case, simply get selected columns from the diamond dataset in ggplot2 (part of tidyverse)next add these magic functions in one line of code:count(across(everything()))```{r, warning=FALSE, error=FALSE, message=FALSE}library(tidyverse)diamonds <- ggplot2::diamonds %>% select(carat,cut,color,clarity) %>% count(across(everything()))head(diamonds)```**Step 2: add pxmake**use 2 functions from pxmake:px() - Create a px object from a px file, an Excel metadata workbook, a data frame or a Parquet file.\px_save - Save px object to file\ \for help, check vignettes '?px'and open with Pxwin. \\```{r, warning=FALSE, error=FALSE, message=FALSE}# install.packages('devtools')# devtools::install_github('StatisticsGreenland/pxmake')library(pxmake)px(diamonds) %>% px_save("explore1.px")```{width="500"}**Step 2: add totals**before saving, add totals```{r, warning=FALSE, error=FALSE, message=FALSE}px(diamonds) %>% px_add_totals(c("carat","cut","color","clarity")) %>% px_save("explore2.px")```{width="500"}**Step 3: and elimination**eliminate with 'Total'```{r, warning=FALSE, error=FALSE, message=FALSE}px(diamonds) %>% px_elimination('Total') %>% px_add_totals(c("carat","cut","color","clarity")) %>% px_save("explore3.px")```{width="500"}**Step 4: play**Go ahead, get PXWin for windows, unpack and play:<https://www.scb.se/en/services/statistical-programs-for-px-files/install-px-win/>## My files are bigger than yours!That's what they usually say, and then I tell them—go work your magic somewhere else, save it as a Parquet file, and load it into pxmake. ```{r, warning=FALSE, error=FALSE, message=FALSE}# install.packages('arrow')library(arrow)write_parquet(diamonds,"magic.parquet")px("magic.parquet") %>% px_elimination('Total') %>% px_add_totals(c("carat","cut","color","clarity")) %>% px_save("magic.px")```