Multilingual support?
Can I write multilingual px files with pxR?
We have developed pxmake to handle multilingual files. On CRAN
Does it cover all the functionality in pxR? In such case, I'd like to deprecate pxR and invite all existing users to move to pxmake.
I believe pxmake does - with differencies. You can check out articles on : https://statisticsgreenland.github.io/pxmake/
library(tidyverse)
library(pxR)
library(pxmake)
# pxR
my.px.object <- read.px(system.file("extdata", "example2.px",
package = "pxR") )
my.px.data <- as.data.frame(my.px.object )
# pxmake
my.pxmake.object <- px(system.file("extdata", "example2.px",package = "pxR"))
my.pxmake.data <- px_data( my.pxmake.object )
# saving
write.px(my.px.object,"my.px.data.px")
px_save(px(my.pxmake.data),"my.pxmake.data.px")
# pxmake, adding metadata
my.pxmake.data %>%
px() %>%
px_matrix("example2") %>%
px_contents("unknown contents") %>%
px_save("my.pxmake.px")
# pxmake, adding multilingual metadata
my.pxmake.data %>%
px() %>%
px_matrix("example2") %>%
px_language("en") %>%
px_languages(c("en","es")) %>%
px_contents(tribble(~language, ~value,
'en', 'unknown contents',
'es', 'contenido desconocido')) %>%
px_save("my.pxmake_multilang.px")
:-) Lars
Hi Carlos,
Can you think of an example, I should try?
Here is one:
library(tidyverse)
library(pxR)
library(pxmake)
my.px.object <- read.px(system.file("extdata", "example2.px",
package = "pxR") )
my.px.data <- as_tibble(my.px.object) %>%
mutate(across(where(is.factor), as.character))
my.px.data %>%
px() %>%
px_axis_version(my.px.object$AXIS.VERSION[[1]]) %>%
px_charset(my.px.object$CHARSET[[1]]) %>%
px_contents(my.px.object$CONTENTS[[1]]) %>%
px_creation_date(my.px.object$CREATION.DATE[[1]]) %>%
px_decimals(my.px.object$DECIMALS[[1]]) %>%
px_heading(my.px.object$HEADING[[1]]) %>%
px_last_updated(my.px.object$LAST.UPDATED[[1]]) %>%
px_matrix(my.px.object$MATRIX[[1]]) %>%
px_showdecimals(my.px.object$SHOWDECIMALS[[1]]) %>%
px_source(my.px.object$SOURCE[[1]]) %>%
px_subject_code(my.px.object$SUBJECT.CODE[[1]]) %>%
px_subject_area(my.px.object$SUBJECT.AREA[[1]]) %>%
px_title(my.px.object$TITLE[[1]]) %>%
px_units(my.px.object$UNITS[[1]]) %>%
px_save(file.path(getwd(),"my_pxmake_frompxR.px"))
:-) Lars
Hi again @cjgb,
Check out the learning material on https://thranholm.quarto.pub/rwanda-px-files-and-r/ that Emil has written
Best regards
Lars