Skip to content

Commit

Permalink
update factor: added winbox options + translations
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed May 16, 2024
1 parent ae3413b commit cd2f60d
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 37 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export(validation_server)
export(validation_ui)
export(winbox_create_column)
export(winbox_cut_variable)
export(winbox_update_factor)
importFrom(classInt,classIntervals)
importFrom(data.table,":=")
importFrom(data.table,.N)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# datamods 1.5.1

* New module `update_factor_ui()` / `update_factor_server()` to reorder levels of a factor.
* i18n: Updated translations files with new labels, which are automatically translated, if you see incorrect translations, please open an issue or PR : https://github.com/dreamRs/datamods


# datamods 1.5.0
Expand Down
2 changes: 1 addition & 1 deletion R/create-column.R
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ modal_create_column <- function(id,
#' @importFrom htmltools tagList
#' @rdname create-column
winbox_create_column <- function(id,
title =i18n( "Create a new column"),
title = i18n("Create a new column"),
options = shinyWidgets::wbOptions(),
controls = shinyWidgets::wbControls()) {
ns <- NS(id)
Expand Down
36 changes: 34 additions & 2 deletions R/update-factor.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ update_factor_ui <- function(id) {
inputId = ns("sort_levels"),
label = tagList(
ph("sort-ascending"),
i18n("Sort levels")
i18n("Sort by levels")
),
class = "btn-outline-primary mb-3",
width = "100%"
Expand All @@ -55,7 +55,7 @@ update_factor_ui <- function(id) {
inputId = ns("sort_occurrences"),
label = tagList(
ph("sort-ascending"),
i18n("Sort count")
i18n("Sort by count")
),
class = "btn-outline-primary mb-3",
width = "100%"
Expand Down Expand Up @@ -236,3 +236,35 @@ modal_update_factor <- function(id,
footer = footer
))
}


#' @inheritParams shinyWidgets::WinBox
#' @export
#'
#' @importFrom shinyWidgets WinBox wbOptions wbControls
#' @importFrom htmltools tagList
#' @rdname create-column
winbox_update_factor <- function(id,
title = i18n("Update levels of a factor"),
options = shinyWidgets::wbOptions(),
controls = shinyWidgets::wbControls()) {
ns <- NS(id)
WinBox(
title = title,
ui = tagList(
update_factor_ui(id),
tags$div(
style = "display: none;",
textInput(inputId = ns("hidden"), label = NULL, value = genId())
)
),
options = modifyList(
shinyWidgets::wbOptions(height = "615px", modal = TRUE),
options
),
controls = controls,
auto_height = FALSE
)
}


13 changes: 12 additions & 1 deletion examples/update_factor.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ library(ggplot2)

ui <- fluidPage(
theme = bslib::bs_theme(version = 5L, preset = "bootstrap"),
shinyWidgets::html_dependency_winbox(),
tags$h2("Reorder the Levels of a Factor"),
fluidRow(
column(
width = 6,
update_factor_ui("id"),
actionButton("modal", "Or click here to open a modal to update factor's level")
actionButton("modal", "Or click here to open a modal to update factor's level"),
tags$br(), tags$br(),
actionButton("winbox", "Or click here to open a WinBox to create a column")
),
column(
width = 6,
Expand Down Expand Up @@ -50,6 +53,14 @@ server <- function(input, output, session) {
rv$data <- data_modal_r()
})

# winbox mode
observeEvent(input$winbox, winbox_update_factor("winbox"))
data_winbox_r <- update_factor_server(
id = "winbox",
data_r = reactive(rv$data)
)
observeEvent(data_winbox_r(), rv$data <- data_winbox_r())

# Plot results
output$plot <- renderPlot({
req(input$var, rv$data)
Expand Down
7 changes: 4 additions & 3 deletions inst/i18n/al.csv
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
"Some operations are not allowed","Disa operacione nuk lejohen","Automacally translated"
"Something went wrong...","Diçka shkoi keq...",""
"Sort count","Rendit numërimin","Automacally translated"
"Sort levels","Renditni nivelet","Automacally translated"
"The URL that appear in your browser, in that case the current sheet will be read","URL-ja që shfaqet në shfletuesin tuaj, në këtë rast do të lexohet fleta e parë",""
"The row has been deleted","Rreshti është fshirë",""
"The row wasn't added to the data","Rreshti nuk u shtua te të dhënat","Automacally translated"
Expand Down Expand Up @@ -135,8 +134,10 @@
"data has %s obs. of %s variables.","Të dhënat kanë %vëzhgime dhe %variabla",""
"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"
"number of rows","numri i rreshtave","Automacally translated"
"proportion of rows","proporcioni i rreshtave","Automacally translated"
"rows","rreshtave","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"
"Sort by count","Rendit sipas numërimit","Automacally translated"
"Sort by levels","Rendit sipas niveleve","Automacally translated"
9 changes: 5 additions & 4 deletions inst/i18n/cn.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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:","文件编码:",""
Expand Down Expand Up @@ -103,7 +103,6 @@
"Some operations are not allowed","鏈変簺鎿嶄綔鏄笉鍏佽鐨�","Automacally translated"
"Something went wrong...","出错了...",""
"Sort count","鎺掑簭璁℃暟","Automacally translated"
"Sort levels","鎺掑簭绾у埆","Automacally translated"
"The URL that appear in your browser, in that case the current sheet will be read","浏览器复制链接,我们将导入当前工作簿的数据",""
"The row has been deleted","该行已被删除",""
"The row wasn't added to the data","璇ヨ鏈坊鍔犲埌鏁版嵁涓�","Automacally translated"
Expand Down Expand Up @@ -135,8 +134,10 @@
"data has %s obs. of %s variables.","数据有 %s 行 %s 列.",""
"if several use a comma ',' to separate them","濡傛灉澶氫釜浣跨敤閫楀彿鈥�,鈥濆垎闅�","Automacally translated"
"lines, i.e.","绾匡紝鍗�","Automacally translated"
"number of rows","琛屾暟","Automacally translated"
"proportion of rows","琛岀殑姣斾緥","Automacally translated"
"rows","琛�","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"
"Sort by count","鎸夋暟閲忔帓搴�","Automacally translated"
"Sort by levels","鎸夌骇鍒帓搴�","Automacally translated"
7 changes: 4 additions & 3 deletions inst/i18n/de.csv
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
"Some operations are not allowed","Einige Vorgänge sind nicht zulässig","Automacally translated"
"Something went wrong...","Etwas ist schief gelaufen...",""
"Sort count","Anzahl sortieren","Automacally translated"
"Sort levels","Sortierebenen","Automacally translated"
"The URL that appear in your browser, in that case the current sheet will be read","Die URL die im Browser aufscheint, in diesem Fall wird das aktuielle Arbeitsblatt eingelesen",""
"The row has been deleted","Die Zeile wurde gelöscht",""
"The row wasn't added to the data","Die Zeile wurde nicht zu den Daten hinzugefügt","Automacally translated"
Expand Down Expand Up @@ -135,8 +134,10 @@
"data has %s obs. of %s variables.","Daten haben %s Einträge und %s Variablen.",""
"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"
"number of rows","Anzahl der Reihen","Automacally translated"
"proportion of rows","Anteil der Reihen","Automacally translated"
"rows","Reihen","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"
"Sort by count","Nach Anzahl sortieren","Automacally translated"
"Sort by levels","Nach Ebenen sortieren","Automacally translated"
7 changes: 4 additions & 3 deletions inst/i18n/es.csv
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
"Some operations are not allowed","Algunas operaciones no están permitidas.","Automacally translated"
"Something went wrong...","Algo salió mal...",""
"Sort count","Ordenar recuento","Automacally translated"
"Sort levels","Ordenar niveles","Automacally translated"
"The URL that appear in your browser, in that case the current sheet will be read","La URL que aparece en su navegador, en ese caso, la hoja actual se leerá",""
"The row has been deleted","La fila ha sido eliminada",""
"The row wasn't added to the data","La fila no se agregó a los datos.","Automacally translated"
Expand Down Expand Up @@ -138,8 +137,10 @@
"data has %s obs. of %s variables.","Los datos tienen %s obs. de %s variables.",""
"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"
"number of rows","número de filas","Automacally translated"
"proportion of rows","proporción de filas","Automacally translated"
"rows","filas","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"
"Sort by count","Ordenar por conteo","Automacally translated"
"Sort by levels","Ordenar por niveles","Automacally translated"
7 changes: 4 additions & 3 deletions inst/i18n/fr.csv
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
"Some operations are not allowed","Certaines opérations ne sont pas autorisées","Automacally translated"
"Something went wrong...","Un problème est survenu...",""
"Sort count","Nombre de tris","Automacally translated"
"Sort levels","Niveaux de tri","Automacally translated"
"The URL that appear in your browser, in that case the current sheet will be read","L'URL qui apparaît dans votre navigateur, dans ce cas la feuille active sera lue",""
"The row has been deleted","La ligne a été supprimée",""
"The row wasn't added to the data","La ligne n'a pas été ajoutée aux données","Automacally translated"
Expand Down Expand Up @@ -135,8 +134,10 @@
"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"
"number of rows","Nombre de lignes",""
"proportion of rows","Proportion de lignes",""
"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",""
"Sort by count","Trier par nombre","Automacally translated"
"Sort by levels","Trier par niveaux","Automacally translated"
7 changes: 4 additions & 3 deletions inst/i18n/kr.csv
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
"Some operations are not allowed","�쇰� �묒뾽�€ �덉슜�섏� �딆뒿�덈떎","Automacally translated"
"Something went wrong...","臾몄젣媛€ 諛쒖깮�덉뒿�덈떎.","Automacally translated"
"Sort count","�뺣젹 �잛닔","Automacally translated"
"Sort levels","�섏� �뺣젹","Automacally translated"
"The URL that appear in your browser, in that case the current sheet will be read","브라우저에 나타난 URL을 붙여넣으면 현재 보고 있는 Sheet가 사용됩니다.",""
"The row has been deleted","행이 삭제되었습니다.",""
"The row wasn't added to the data","�됱씠 �곗씠�곗뿉 異붽��섏� �딆븯�듬땲��.","Automacally translated"
Expand Down Expand Up @@ -135,8 +134,10 @@
"data has %s obs. of %s variables.","%s행 변수 %s",""
"if several use a comma ',' to separate them","�щ윭 紐낆씠 �쇳몴 ','瑜� �ъ슜�섏뿬 援щ텇�섎뒗 寃쎌슦","Automacally translated"
"lines, i.e.","�쇱씤, 利�","Automacally translated"
"number of rows","�� ��","Automacally translated"
"proportion of rows","�됱쓽 鍮꾩쑉","Automacally translated"
"rows","��","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"
"Sort by count","媛쒖닔蹂꾨줈 �뺣젹","Automacally translated"
"Sort by levels","�덈꺼蹂꾨줈 �뺣젹","Automacally translated"
7 changes: 4 additions & 3 deletions inst/i18n/mk.csv
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
"Some operations are not allowed","Некои операции не се дозволени","Automacally translated"
"Something went wrong...","Тука нема податоци...",""
"Sort count","Броење сортирање","Automacally translated"
"Sort levels","Подреди нивоа","Automacally translated"
"The URL that appear in your browser, in that case the current sheet will be read","URL коешто се појавува во вашиот пребарарувач, во овој случај првата страна ќе биде прочитана",""
"The row has been deleted","Редот е избришан",""
"The row wasn't added to the data","Редот не беше додаден на податоците","Automacally translated"
Expand Down Expand Up @@ -135,8 +134,10 @@
"data has %s obs. of %s variables.","Податоците имаат % обсерваци и % променливи",""
"if several use a comma ',' to separate them","ако неколку користат запирка ',' за да ги разделат","Automacally translated"
"lines, i.e.","линии, т.е.","Automacally translated"
"number of rows","број на редови","Automacally translated"
"proportion of rows","пропорција на редови","Automacally translated"
"rows","редови","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"
"Sort by count","Подреди по број","Automacally translated"
"Sort by levels","Подреди по нивоа","Automacally translated"
7 changes: 4 additions & 3 deletions inst/i18n/pl.csv
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
"Some operations are not allowed","Niektóre operacje są niedozwolone","Automacally translated"
"Something went wrong...","Coś poszło nie tak...",""
"Sort count","Liczba sortowań","Automacally translated"
"Sort levels","Poziomy sortowania","Automacally translated"
"The URL that appear in your browser, in that case the current sheet will be read","Linku z przeglądarki (zostanie odczytany aktualny arkusz)",""
"The row has been deleted","Wiersz został usunięty",""
"The row wasn't added to the data","Wiersz nie został dodany do danych","Automacally translated"
Expand Down Expand Up @@ -135,8 +134,10 @@
"data has %s obs. of %s variables.","dane zawierają %s obserwacji %s zmiennych.",""
"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"
"number of rows","Liczba rzędów","Automacally translated"
"proportion of rows","proporcja rzędów","Automacally translated"
"rows","wydziwianie","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"
"Sort by count","Sortuj według liczby","Automacally translated"
"Sort by levels","Sortuj według poziomów","Automacally translated"
7 changes: 4 additions & 3 deletions inst/i18n/pt.csv
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
"Some operations are not allowed","Algumas operações não são permitidas","Automacally translated"
"Something went wrong...","Algo deu errado...",""
"Sort count","Contagem de classificação","Automacally translated"
"Sort levels","Classificar níveis","Automacally translated"
"The URL that appear in your browser, in that case the current sheet will be read","A URL que aparece no seu navegador, nesse caso a aba atual será lida",""
"The row has been deleted","A linha foi excluída",""
"The row wasn't added to the data","A linha não foi adicionada aos dados","Automacally translated"
Expand Down Expand Up @@ -135,8 +134,10 @@
"data has %s obs. of %s variables.","dados possuem %s observações de %s variáveis.",""
"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"
"number of rows","numero de linhas","Automacally translated"
"proportion of rows","proporção de linhas","Automacally translated"
"rows","linhas","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"
"Sort by count","Classificar por contagem","Automacally translated"
"Sort by levels","Classificar por níveis","Automacally translated"
Loading

0 comments on commit cd2f60d

Please sign in to comment.