'How to change group text in Vuetify table-data(headers)
How can i change group text in other language? picture
So, this is my v-data-table component. And I need customize language at places like in footer.page-text or group.header.
But idk how get access to "group"-text in headers to change on my language that i need Code screen
Solution 1:[1]
I believe this level of control can be obtained using the future and future.apply packages. The future.apply package replicates the base *apply family of functions in parallel. Specifically, future_lapply is the corollary to lapply and is the more advanced predecessor of parallel::mclapply. It gives pretty fine-grained control over how the futures (in your case the n tasks) are evaluated. Specifically addressing your question, future_lapply provides the future.scheduling argument, which when set to FALSE ensures that each task is evaluated in a fresh R session. We can verify that this is true by initially setting future.scheduling = TRUE:
future::plan("multisession")
invisible(
future.apply::future_lapply(
1:16,
function(i) {
tryCatch(
{
get("a", envir = globalenv())
cat("`a` now exists in R session on", Sys.getpid(), "\n")
},
error = function(e) {
cat("`a` does not yet exist in R session on", Sys.getpid(), "\n")
}
)
assign("a", 1, envir = globalenv())
},
future.scheduling = TRUE
)
)
#> `a` does not yet exist in R session on 4388
#> `a` now exists in R session on 4388
#> `a` does not yet exist in R session on 12032
#> `a` now exists in R session on 12032
#> `a` does not yet exist in R session on 5656
#> `a` now exists in R session on 5656
#> `a` does not yet exist in R session on 3800
#> `a` now exists in R session on 3800
#> `a` does not yet exist in R session on 5940
#> `a` now exists in R session on 5940
#> `a` does not yet exist in R session on 7724
#> `a` now exists in R session on 7724
#> `a` does not yet exist in R session on 17328
#> `a` now exists in R session on 17328
#> `a` does not yet exist in R session on 23492
#> `a` now exists in R session on 23492
What this does is uses a 16-element list (my machine has 8 cores) and maps across this list in parallel. This list is chopped up equally meaning each future handles 2 items in the list. After processing the first element, I assign a variable named a in the global environment and, when processing the second element, I check to make sure that a exists and can be accessed. For each of the 8 futures, we can see that it successfully assigns a into the global environment when processing the first list element and can access it again when processing the second list element. In other words, each of the 2 items in each future is processed in the same (potentially cluttered) environment. However, when we set future.scheduling = FALSE:
future::plan("multisession")
invisible(
future.apply::future_lapply(
1:16,
function(i) {
tryCatch(
{
get("a", envir = globalenv())
cat("`a` now exists in R session on", Sys.getpid(), "\n")
},
error = function(e) {
cat("`a` does not yet exist in R session on", Sys.getpid(), "\n")
}
)
assign("a", 1, envir = globalenv())
},
future.scheduling = FALSE
)
)
#> `a` does not yet exist in R session on 18976
#> `a` does not yet exist in R session on 18292
#> `a` does not yet exist in R session on 21812
#> `a` does not yet exist in R session on 1700
#> `a` does not yet exist in R session on 21780
#> `a` does not yet exist in R session on 17712
#> `a` does not yet exist in R session on 9252
#> `a` does not yet exist in R session on 19336
#> `a` does not yet exist in R session on 18976
#> `a` does not yet exist in R session on 18292
#> `a` does not yet exist in R session on 21812
#> `a` does not yet exist in R session on 1700
#> `a` does not yet exist in R session on 21780
#> `a` does not yet exist in R session on 17712
#> `a` does not yet exist in R session on 9252
#> `a` does not yet exist in R session on 19336
As we can see, each list element is now being processed in a separate, clean R session.
TLDR
If you have a list that you want to be executed on in parallel where each element is processed in its own, clean R session do the following workflow:
library(future)
library(future.apply)
your_list <- list("of", "n", "chunks")
your_function <- function(i) print(i)
future_lapply(
your_list,
your_function,
future.scheduling = FALSE
)
#> [1] "of"
#> [1] "n"
#> [1] "chunks"
I'm really not sure if this answers your question or problem, but hopefully it gets you on the right track!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Daniel Molitor |
