Usecase: PXWinR

PXWin as cube explorer

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:

count(across(everything()))

library(tidyverse)

diamonds <- ggplot2::diamonds %>% 
  select(carat,cut,color,clarity) %>% 
  count(across(everything()))

head(diamonds)
# 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.

# install.packages('devtools')
# devtools::install_github('StatisticsGreenland/pxmake')
library(pxmake)

px(diamonds) %>%
  px_save("explore1.px")

Step 2: add totals

before saving, add totals

px(diamonds) %>%
 px_add_totals(c("carat","cut","color","clarity")) %>% 
  px_save("explore2.px")

Step 3: and elimination

eliminate with ‘Total’

px(diamonds) %>%
  px_elimination('Total') %>% 
  px_add_totals(c("carat","cut","color","clarity")) %>% 
  px_save("explore3.px")

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.

# 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")