From ae3413bf0736e58ed3efc87121d258deb09361a4 Mon Sep 17 00:00:00 2001 From: pvictor Date: Thu, 16 May 2024 11:29:54 +0200 Subject: [PATCH] updated smaple module + translations --- R/sample-data.R | 42 +++++++++++++++++++++++++++--------------- examples/sample.R | 11 ++++------- inst/i18n/al.csv | 4 +++- inst/i18n/cn.csv | 6 ++++-- inst/i18n/de.csv | 4 +++- inst/i18n/es.csv | 4 +++- inst/i18n/fr.csv | 8 +++++--- inst/i18n/kr.csv | 4 +++- inst/i18n/mk.csv | 4 +++- inst/i18n/pl.csv | 4 +++- inst/i18n/pt.csv | 4 +++- inst/i18n/tr.csv | 4 +++- man/module-sample.Rd | 11 ++++------- 13 files changed, 68 insertions(+), 42 deletions(-) diff --git a/R/sample-data.R b/R/sample-data.R index 4745b5f..1ff5c1a 100644 --- a/R/sample-data.R +++ b/R/sample-data.R @@ -68,9 +68,11 @@ sample_ui <- function(id) { radioGroupButtons( inputId = ns("choice"), label = i18n("Sample data by :"), - choices = c("number of rows", "proportion of rows"), - justified = FALSE, - size = "xs" + choiceNames = c(i18n("number of rows"), i18n("proportion of rows")), + choiceValues = c("number of rows", "proportion of rows"), + justified = TRUE, + size = "xs", + width = "100%" ), conditionalPanel( @@ -79,9 +81,12 @@ sample_ui <- function(id) { sliderInput( inputId = ns("proportion_rows"), label = i18n("Choose a percentage :"), - min = 0, max = 100, value = 100, - post = " %" - ), + min = 0, + max = 100, + value = 100, + post = " %", + width = "100%" + ), uiOutput(outputId = ns("feedback_proportion_rows")) ), @@ -91,8 +96,11 @@ sample_ui <- function(id) { sliderInput( inputId = ns("number_rows"), label = i18n("Choose a number of rows :"), - min = 0, max = 10, value = 10 - ), + min = 0, + max = 10, + value = 10, + width = "100%" + ), uiOutput(outputId = ns("feedback_number_rows")) ) ) @@ -120,20 +128,24 @@ sample_server <- function(id, data_r = reactive(NULL)) { updateSliderInput( session, inputId = "number_rows", - min = 0, max = nrow(data_r()), value = nrow(data_r()) + min = 0, + max = nrow(data_r()), + value = nrow(data_r()) ) }) output$feedback_proportion_rows <- renderUI({ - req(data_r()) - value <- nrow(data_r()) * (input$proportion_rows/100) - tags$div(paste(input$proportion_rows, i18n("% of the total, i.e."), round(value), i18n("rows"))) + sample <- req(sample_r()) + tags$div( + paste(input$proportion_rows, i18n("% of the total, i.e."), nrow(sample), i18n("rows")) + ) }) output$feedback_number_rows <- renderUI({ - req(data_r()) - value <- input$number_rows / nrow(data_r()) * 100 - tags$div(paste(input$number_rows, i18n("lines, i.e."), round(value, 1), i18n("% of the total"))) + data <- req(data_r()) + tags$div( + paste(input$number_rows, i18n("lines, i.e."), round(input$number_rows / nrow(data) * 100, 1), i18n("% of the total")) + ) }) sample_r <- reactive({ diff --git a/examples/sample.R b/examples/sample.R index 8442d59..cef5b81 100644 --- a/examples/sample.R +++ b/examples/sample.R @@ -1,28 +1,25 @@ library(shiny) +library(datamods) library(reactable) -##### ui.R ##### ui <- fluidPage( - titlePanel("Sampling"), + tags$h2("Sampling"), fluidRow( column( - width = 4, + width = 3, sample_ui("myID") ), column( - width = 8, + width = 9, reactableOutput("table") ) ) ) - -##### server.R ##### - server <- function(input, output, session) { result_sample <- sample_server("myID", reactive(iris)) diff --git a/inst/i18n/al.csv b/inst/i18n/al.csv index a5ba441..b33ed97 100644 --- a/inst/i18n/al.csv +++ b/inst/i18n/al.csv @@ -136,5 +136,7 @@ "if several use a comma ',' to separate them","nëse disa përdorin presje ',' për t'i ndarë","Automacally translated" "lines, i.e.","vijat, d.m.th.","Automacally translated" "rows","rreshtave","Automacally translated" -"to delete it.","për ta fshirë.","Automacally translated" "then enter an expression before clicking on the button above to validate or on ","pastaj futni një shprehje përpara se të klikoni në butonin e mësipërm për të vërtetuar ose aktivizuar","Automacally translated" +"to delete it.","për ta fshirë.","Automacally translated" +"number of rows","numri i rreshtave","Automacally translated" +"proportion of rows","proporcioni i rreshtave","Automacally translated" diff --git a/inst/i18n/cn.csv b/inst/i18n/cn.csv index e554954..b0ce314 100644 --- a/inst/i18n/cn.csv +++ b/inst/i18n/cn.csv @@ -33,7 +33,7 @@ "Dataset validation:","鏁版嵁闆嗛獙璇侊細","Automacally translated" "Date format:","日期格式:","" "Date to use as origin to convert date/datetime:","日期转换的起始时间:","" -"Decimal separator:","小数点:""""","" +"Decimal separator:","小数点:""""""""","" "Delete","删除","" "Do you want to delete the selected row ?","您要删除选定的行吗?","" "Encoding:","文件编码:","" @@ -136,5 +136,7 @@ "if several use a comma ',' to separate them","濡傛灉澶氫釜浣跨敤閫楀彿鈥�,鈥濆垎闅�","Automacally translated" "lines, i.e.","绾匡紝鍗�","Automacally translated" "rows","琛�","Automacally translated" -"to delete it.","鍒犻櫎瀹冦€�","Automacally translated" "then enter an expression before clicking on the button above to validate or on ","鐒跺悗杈撳叆涓€涓〃杈惧紡锛岀劧鍚庡崟鍑讳笂闈㈢殑鎸夐挳杩涜楠岃瘉鎴�","Automacally translated" +"to delete it.","鍒犻櫎瀹冦€�","Automacally translated" +"number of rows","琛屾暟","Automacally translated" +"proportion of rows","琛岀殑姣斾緥","Automacally translated" diff --git a/inst/i18n/de.csv b/inst/i18n/de.csv index 2e6e1f3..4d46f87 100644 --- a/inst/i18n/de.csv +++ b/inst/i18n/de.csv @@ -136,5 +136,7 @@ "if several use a comma ',' to separate them","Bei mehreren verwenden Sie zur Trennung ein Komma „,“.","Automacally translated" "lines, i.e.","Linien, d.h.","Automacally translated" "rows","Reihen","Automacally translated" -"to delete it.","um es zu löschen.","Automacally translated" "then enter an expression before clicking on the button above to validate or on ","Geben Sie dann einen Ausdruck ein, bevor Sie zum Bestätigen oder Einschalten auf die Schaltfläche oben klicken","Automacally translated" +"to delete it.","um es zu löschen.","Automacally translated" +"number of rows","Anzahl der Reihen","Automacally translated" +"proportion of rows","Anteil der Reihen","Automacally translated" diff --git a/inst/i18n/es.csv b/inst/i18n/es.csv index cd4bd2c..6f82994 100644 --- a/inst/i18n/es.csv +++ b/inst/i18n/es.csv @@ -139,5 +139,7 @@ "if several use a comma ',' to separate them","si son varios use una coma ',' para separarlos","Automacally translated" "lines, i.e.","líneas, es decir","Automacally translated" "rows","filas","Automacally translated" -"to delete it.","para borrarlo.","Automacally translated" "then enter an expression before clicking on the button above to validate or on ","luego ingrese una expresión antes de hacer clic en el botón de arriba para validar o en","Automacally translated" +"to delete it.","para borrarlo.","Automacally translated" +"number of rows","número de filas","Automacally translated" +"proportion of rows","proporción de filas","Automacally translated" diff --git a/inst/i18n/fr.csv b/inst/i18n/fr.csv index b78c3c7..5c20f1f 100644 --- a/inst/i18n/fr.csv +++ b/inst/i18n/fr.csv @@ -93,7 +93,7 @@ "Row has been saved","La ligne a été enregistrée","" "Row was not deleted","La ligne n'a pas été supprimée","" "Rows to skip before reading data:","Lignes à ignorer avant de lire les données :","Automacally translated" -"Sample data by :","Exemple de données par :","Automacally translated" +"Sample data by :","Echantillonner les données selon :","" "Save","Enregistrer","" "Select","Sélectionner","" "Select a data.frame:","Sélectionner un data.frame :","" @@ -135,6 +135,8 @@ "data has %s obs. of %s variables.","les données ont %s observations et %s colonnes.","" "if several use a comma ',' to separate them","si plusieurs utilisent une virgule ',' pour les séparer","Automacally translated" "lines, i.e.","lignes, c'est-à-dire","Automacally translated" -"rows","Lignes","Automacally translated" -"to delete it.","pour le supprimer.","Automacally translated" +"rows","lignes","Automacally translated" "then enter an expression before clicking on the button above to validate or on ","puis saisissez une expression avant de cliquer sur le bouton ci-dessus pour valider ou sur","Automacally translated" +"to delete it.","pour le supprimer.","Automacally translated" +"number of rows","Nombre de lignes","" +"proportion of rows","Proportion de lignes","" diff --git a/inst/i18n/kr.csv b/inst/i18n/kr.csv index 12d6bbe..a54ec09 100644 --- a/inst/i18n/kr.csv +++ b/inst/i18n/kr.csv @@ -136,5 +136,7 @@ "if several use a comma ',' to separate them","�щ윭 紐낆씠 �쇳몴 ','瑜� �ъ슜�섏뿬 援щ텇�섎뒗 寃쎌슦","Automacally translated" "lines, i.e.","�쇱씤, 利�","Automacally translated" "rows","��","Automacally translated" -"to delete it.","��젣�섎젮硫�","Automacally translated" "then enter an expression before clicking on the button above to validate or on ","洹몃윴 �ㅼ쓬 �꾩쓽 踰꾪듉�� �대┃�섍린 �꾩뿉 �쒗쁽�앹쓣 �낅젰�섏뿬 �좏슚�깆쓣 寃€�ы븯嫄곕굹","Automacally translated" +"to delete it.","��젣�섎젮硫�","Automacally translated" +"number of rows","�� ��","Automacally translated" +"proportion of rows","�됱쓽 鍮꾩쑉","Automacally translated" diff --git a/inst/i18n/mk.csv b/inst/i18n/mk.csv index 216581b..bc00e93 100644 --- a/inst/i18n/mk.csv +++ b/inst/i18n/mk.csv @@ -136,5 +136,7 @@ "if several use a comma ',' to separate them","ако неколку користат запирка ',' за да ги разделат","Automacally translated" "lines, i.e.","линии, т.е.","Automacally translated" "rows","редови","Automacally translated" -"to delete it.","да го избришете.","Automacally translated" "then enter an expression before clicking on the button above to validate or on ","потоа внесете израз пред да кликнете на копчето погоре за да потврдите или да го вклучите","Automacally translated" +"to delete it.","да го избришете.","Automacally translated" +"number of rows","број на редови","Automacally translated" +"proportion of rows","пропорција на редови","Automacally translated" diff --git a/inst/i18n/pl.csv b/inst/i18n/pl.csv index ed59d15..1b5672f 100644 --- a/inst/i18n/pl.csv +++ b/inst/i18n/pl.csv @@ -136,5 +136,7 @@ "if several use a comma ',' to separate them","jeśli kilka z nich użyje przecinka „,” aby je oddzielić","Automacally translated" "lines, i.e.","linie, tj.","Automacally translated" "rows","wydziwianie","Automacally translated" -"to delete it.","aby go usunąć.","Automacally translated" "then enter an expression before clicking on the button above to validate or on ","następnie wprowadź wyrażenie przed kliknięciem przycisku powyżej, aby zatwierdzić lub włączyć","Automacally translated" +"to delete it.","aby go usunąć.","Automacally translated" +"number of rows","Liczba rzędów","Automacally translated" +"proportion of rows","proporcja rzędów","Automacally translated" diff --git a/inst/i18n/pt.csv b/inst/i18n/pt.csv index f97dffe..2655e56 100644 --- a/inst/i18n/pt.csv +++ b/inst/i18n/pt.csv @@ -136,5 +136,7 @@ "if several use a comma ',' to separate them","se vários usarem uma vírgula ',' para separá-los","Automacally translated" "lines, i.e.","linhas, ou seja,","Automacally translated" "rows","linhas","Automacally translated" -"to delete it.","para excluí-lo.","Automacally translated" "then enter an expression before clicking on the button above to validate or on ","em seguida, insira uma expressão antes de clicar no botão acima para validar ou em","Automacally translated" +"to delete it.","para excluí-lo.","Automacally translated" +"number of rows","numero de linhas","Automacally translated" +"proportion of rows","proporção de linhas","Automacally translated" diff --git a/inst/i18n/tr.csv b/inst/i18n/tr.csv index 0949dba..ca7f014 100644 --- a/inst/i18n/tr.csv +++ b/inst/i18n/tr.csv @@ -136,5 +136,7 @@ "if several use a comma ',' to separate them","birkaç kişi onları ayırmak için ',' virgülünü kullanıyorsa","Automacally translated" "lines, i.e.","çizgiler, yani","Automacally translated" "rows","satırlar","Automacally translated" -"to delete it.","silmek için.","Automacally translated" "then enter an expression before clicking on the button above to validate or on ","ardından doğrulamak için yukarıdaki düğmeye tıklamadan önce bir ifade girin veya","Automacally translated" +"to delete it.","silmek için.","Automacally translated" +"number of rows","satır sayısı","Automacally translated" +"proportion of rows","satırların oranı","Automacally translated" diff --git a/man/module-sample.Rd b/man/module-sample.Rd index c6d4142..8eb7699 100644 --- a/man/module-sample.Rd +++ b/man/module-sample.Rd @@ -26,30 +26,27 @@ Allow to take a sample of \code{data.frame} for a given number or proportion of } \examples{ library(shiny) +library(datamods) library(reactable) -##### ui.R ##### ui <- fluidPage( - titlePanel("Sampling"), + tags$h2("Sampling"), fluidRow( column( - width = 4, + width = 3, sample_ui("myID") ), column( - width = 8, + width = 9, reactableOutput("table") ) ) ) - -##### server.R ##### - server <- function(input, output, session) { result_sample <- sample_server("myID", reactive(iris))