callr | Call R from R | Reactive Programming library

 by   r-lib R Version: v3.7.0 License: Non-SPDX

kandi X-RAY | callr Summary

kandi X-RAY | callr Summary

callr is a R library typically used in Programming Style, Reactive Programming applications. callr has no bugs, it has no vulnerabilities and it has low support. However callr has a Non-SPDX License. You can download it from GitHub.

Call R from R. It is sometimes useful to perform a computation in a separate R process, without affecting the current R process at all. This packages does exactly that.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              callr has a low active ecosystem.
              It has 234 star(s) with 27 fork(s). There are 16 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 10 open issues and 158 have been closed. On average issues are closed in 63 days. There are 3 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of callr is v3.7.0

            kandi-Quality Quality

              callr has 0 bugs and 0 code smells.

            kandi-Security Security

              callr has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              callr code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              callr has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              callr releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of callr
            Get all kandi verified functions for this library.

            callr Key Features

            No Key Features are available at this moment for callr.

            callr Examples and Code Snippets

            No Code Snippets are available at this moment for callr.

            Community Discussions

            QUESTION

            running background process in R Shiny
            Asked 2022-Mar-16 at 14:05

            I wrote a script that is supposed to run a background process if a button is pressed. After the process is finished, I would like to work further with the results.

            Below is my script. The process in this script is 10 seconds sleeping followed by retrieving a list of the names of the files in the current folder. The background process is found in the function printLS(). This is performed in the background by the function r_bg().

            ...

            ANSWER

            Answered 2022-Mar-16 at 10:18

            As explained in the examples here, wait() means that we have to wait for the result of the background job before continuing the rest of the processes.

            One way to keep the clock updating while running the background job is to use poll_io() to check whether the job is finished (note that it is better to use poll_io() than is_alive(), as explained in this Github comment). I have done something similar in this question, although the general app is a bit more complicated.

            Here's what you need to modify in the server:

            Source https://stackoverflow.com/questions/71489024

            QUESTION

            How to show a loading screen when the output is being calculated in a background process?
            Asked 2022-Feb-15 at 09:06

            This question is in the continuity of this one: Is it possible to stop executing of R code inside shiny (without stopping the shiny process)?.

            The plot that I display in my app takes some time to produce, and I want the users to be able to stop its creation (for instance if they made a mistake in the options). I found this blog post about using callr in Shiny. The workflow is the following:

            • create an empty list of jobs/plots
            • clicking on "start" creates a background process to create the plot
              • if the user doesn't do anything, the plot is computed in the background. I use invalidateLater() every second to check if the background process is finished. If it is, then I display the plot.
              • if the user clicks on "stop" before the end of the process, the process is killed, removed from the list, and the previous plot is displayed (if there was no plot produced before, nothing is displayed)

            First, I'm not sure how this would scale when several people use the app at the same time. Since every background process is independent, I don't think one user would be blocking the others, but I may be wrong.

            Second, I'd like to show a waiting indicator on the plot. So far, I used the package waiter to do that, but the problem here is that renderPlot() is being invalidated every second to check if the background process is finished. Therefore, waiter appears and disappears repeatedly as the output is being invalidated.

            Below is an example app that mimics the behavior I'd like to have:

            ...

            ANSWER

            Answered 2022-Feb-15 at 09:06

            Regarding your first concern: this approach won't block other sessions. However, the polling via invalidateLater() will create some load.

            A great library to look at in this context is ipc and its introductory vignette.

            Regarding the second issue: There is a simple fix for this behaviour. We can use req and its cancelOutput parameter - see ?req:

            cancelOutput: If TRUE and an output is being evaluated, stop processing as usual but instead of clearing the output, leave it in whatever state it happens to be in.

            Source https://stackoverflow.com/questions/71091020

            QUESTION

            How to use callr::r_bg within a downloadHandler in a Shiny App
            Asked 2022-Jan-31 at 22:38

            The scenario I'm emulating with the below minimal example is allowing a user to engage with a Shiny App (click the numericInput control and see server-side events occur) while a long-running download is occurring (simulated with Sys.sleep(10) within downloadHandler).

            In a synchronous setting, when the "Download" button is clicked, the user can still interact with UI elements, but other Shiny calculations (in this case, renderText), get put in a queue. I'd like the asynchronous setting, where the download occurs in the background, and users can still interact with the UI elements and get desired output (e.g. renderText).

            I'm using callr::r_bg() to achieve asynchronicity within Shiny, but the issue is that my current code of the downloadHandler is incorrect (mtcars should be getting downloaded, but the code is unable to complete the download, 404 error message), I believe it's due to the specific way in which downloadHandler expects the content() function to be written, and the way I've written callr::r_bg() is not playing nicely with that. Any insights would be appreciated!

            Reference:

            https://www.r-bloggers.com/2020/04/asynchronous-background-execution-in-shiny-using-callr/

            Minimal Example:

            ...

            ANSWER

            Answered 2021-Nov-04 at 14:25

            I figured out a solution, and learned the following things:

            • Because downloadHandler doesn't have a traditional input$X, it can be difficult to include reactivity in the traditional way. The workaround was to present the UI as a hidden downlodButton masked by an actionButton which the user would see. Reactivity was facilitated in the following process: user clicks actionButton -> reactive updates -> when the reactive finishes (reactive()$is_alive() == FALSE), use shinyjs::click to initiate the downloadHandler
            • Instead of placing the callr function within the downloadHandler, I kept the file within the content arg. There seems to be some difficulties with scoping because the file needs to be available within the content function environment
            • I'm using a reactive function to track when the background job (the long-running computation) is finished to initiate the download using the syntax: reactive()$is_alive()
            • The invalidateLater() and toggling of a global variable (download_once) is important to prevent the reactive from constantly activating. Without it, what will happen is your browser will continually download files ad infinitum -- this behavior is scary and will appear virus-like to your Shiny app users!
            • Note that setting global variables is not a best practice for Shiny apps (will think of a better implementation)

            Code Solution:

            Source https://stackoverflow.com/questions/69760709

            QUESTION

            Improve parallel performance with batching in a static-dynamic branching pipeline
            Asked 2021-Dec-10 at 22:07

            BLUF: I am struggling to understand out how to use batching in the R targets package to improve performance in a static and dynamic branching pipeline processed in parallel using tar_make_future(). I presume that I need to batch within each dynamic branch but I am unsure how to go about doing that.

            Here's a reprex that uses dynamic branching nested inside static branching, similar to what my actual pipeline is doing. It first branches statically for each value in all_types, and then dynamically branches within each category. This code produces 1,000 branches and 1,010 targets total. In the actual workflow I obviously don't use replicate, and the dynamic branches vary in number depending on the type value.

            ...

            ANSWER

            Answered 2021-Dec-10 at 22:07

            You are on the right track with batching. In your case, that is a matter of breaking up your list of 100 datasets into groups of, say, 10 or so. You could do this with a nested list of datasets, but that's a lot of work. Luckily, there is an easier way.

            Your question is actually really well-timed. I just wrote some new target factories in tarchetypes that could help. To access them, you will need the development version of tarchetypes from GitHub:

            Source https://stackoverflow.com/questions/70308266

            QUESTION

            Dealing with zip files in a targets workflow
            Asked 2021-Dec-09 at 17:56

            I'm trying to set up a workflow that involves downloading a zip file, extracting its contents, and applying a function to each one of its files.

            There are a few issues I'm running into:

            1. How do I set up an empty file system reproducibly? Namely, I'm hoping to be able to create a system of empty directories to which files will later be downloaded to. Ideally, I'd like to do something like tar_target(my_dir, fs::dir_create("data"), format = "file"), but I know from the documentation that empty directories are not able to be used with format = "file". I know I could just do a dir_create at every instance which I need it, but this seems clumsy.

            2. In the reprex below I'd like to operate individually on each file using pattern = map(x). As the error suggests, I'd need to specify a pattern for the parent target, since format = "file". You can see that if I did specify a pattern for the parent target, I would again need to do it for its parent target. As far as I know, a pattern cannot be set for a target that has no parents (but I have been wrong many times before).

            I have a feeling I'm going about this all wrong - thank you for your time.

            ...

            ANSWER

            Answered 2021-Dec-09 at 17:56
            Original answer

            Here's an idea: you could track that URL with format = "url" and then make the URL a dependency of all the file branches. Below, all of files should rerun then the upstream online data changes. That's fine because all that does is just re-hash stuff. But then not all branches of stuff_done should run if only some of those files actually changed.

            Edit

            On second thought, we probably need to hash the local files all in bulk. Not the most efficient, but it gets the job done. targets wants you to use its own built-in storage system instead of external files, so if you can read the data in and return it in a non-file format, dynamic branching will be easier.

            Source https://stackoverflow.com/questions/70281450

            QUESTION

            ggplot2 png file without background
            Asked 2021-Nov-11 at 14:11

            Since a few months, ggplot2 started to save png files with a transparent background. The code output in Rstudio and when saved as pdf looks great. It happens mainly with the use of themes when I omit the gray panel background. I tested it on my macbook with "Preview" and on a Windows Computer with the "foto viewer" there.

            ...

            ANSWER

            Answered 2021-Nov-11 at 14:11

            Maybe indeed worth an answer for posterity...

            Specify ggsave("test.png", dpi = 300, bg = "white")

            Background (pun intended): the argument will be passed to grDevices::png via the ... argument. bg controls the background of the device.

            Source https://stackoverflow.com/questions/69928739

            QUESTION

            implications of using callr_function = NULL in targets package
            Asked 2021-Oct-13 at 17:54

            I was wondering what happens when callr_function = NULL? Is it just issues with things maybe being in the environment/side effects?

            Mainly wondering because I was passing quite large spatio-temporal arrays (0.5 to 5 gigs) and callr serialization via saveRDS is quite slow.

            The two things I was thinking about was forking callr and dropping in a different save function or just using callr_function = NULL.

            ...

            ANSWER

            Answered 2021-Oct-13 at 17:54

            Ordinarily, targets runs the pipeline in a fresh new reproducible external R session. callr_function = NULL just says to run the pipeline in the current R session. I only recommend this for debugging because in serious use cases you could accidentally invalidate some targets based on changed data in your global environment. callr_function = NULL will probably not help solve issues with large memory. For that, I recommend selecting a more efficient storage format for your data, e.g. tar_target(..., format = "feather"). You could also try tar_option_set(memory = "transient", garbage_collection = TRUE) for better memory efficiency.

            Source https://stackoverflow.com/questions/69558291

            QUESTION

            SVM prediction running fine in my computer but not in R Connect
            Asked 2021-Aug-06 at 04:41

            I’m creating a Shiny app that uses the caret package to do some SVM free-text analysis.

            The app runs fine without any error in my computer. I’m using R x64 4.0.4 and R studio 1.3.1093

            I’m deploying app to an internal enterprise server https://rconnect.xxxx.com/connect/#/apps/####

            This app is deployed in the server and started.
            But when I reach the line where I run the train function:

            ...

            ANSWER

            Answered 2021-Aug-05 at 01:15

            Errors like this in Shiny apps are almost always a result of missing packages, which the logs confirm.

            Turns out in this case I think the missing package is kernlab, which I only found by reading the documentation given here: https://topepo.github.io/caret/train-models-by-tag.html#Support_Vector_Machines. It's a suggested package, not imported, so the command suggested in the comments by heds1 would sort this out.

            Source https://stackoverflow.com/questions/68659043

            QUESTION

            Can you extract defective rows using AssertR in R?
            Asked 2021-May-02 at 08:46

            The example below is a simple one which tries to assert the column y is always positive (y>0). How can I extract the errored data (row 3 with the negative value,into a dataframe maybe, or any convenient object) while allowing the workflow to continue with "cleaned" data?

            ...

            ANSWER

            Answered 2021-Apr-12 at 09:23

            This is tricky, and the answer below doesn't solve this 100%. Now there are a number of different ways assertr lets you handle errors/stops, just see ?error_stop (which is the default).

            You need to not only filter out rows that fail, but also collect them (all) for later inspection.

            Below I wrote my own error handler. It fetches those rows that fail, filter them away, and stores them in the global environment under the varibale my.failed.rows.

            Source https://stackoverflow.com/questions/67053792

            QUESTION

            R - Intermittent Missig Bar Plot ggplot
            Asked 2021-Mar-23 at 18:43

            I ran into a missing graph issue while developing histograms and geometry bar plots in r using the ggplot function. The issue is intermittent and occurs across multiple data sets. One data set, the largest, is described here.

            My initial code, used to generate randomized data, is this:

            ...

            ANSWER

            Answered 2021-Mar-23 at 18:43

            The issue is that you are using scale_y_binned(). The rest of the code works fine for me, except when I add this particular line to the plot. The "binning" is working (your y axis has %'s), but you see no geoms because ultimately, ggplot2 is plotting the histogram using the same geom used for geom_bar/geom_col. This geom requires a continuous y axis, and scale_y_binned() is designed to "bin" or "discretize" the y axis. So... the bars are being plotting on both charts, but once binned, ggplot2 has no idea how to draw your geom.

            As for why you're seeing the inconsistency... not sure. Sometimes there is a time component to executing the code. When I run your code, it consistently gives me the second chart (no bars).

            To fix, you need to use scale_y_continuous() and set the labels.

            Source https://stackoverflow.com/questions/66768548

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install callr

            Install the stable version from CRAN:.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/r-lib/callr.git

          • CLI

            gh repo clone r-lib/callr

          • sshUrl

            git@github.com:r-lib/callr.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Reactive Programming Libraries

            axios

            by axios

            RxJava

            by ReactiveX

            async

            by caolan

            rxjs

            by ReactiveX

            fetch

            by github

            Try Top Libraries by r-lib

            devtools

            by r-libR

            lintr

            by r-libR

            httr

            by r-libR

            testthat

            by r-libR

            actions

            by r-libJavaScript