r

Constraints for nls coefficients

三世轮回 提交于 2021-02-11 15:56:19
问题 I'm trying to fit data with nls() function where the nature of data gives me bounds for one coefficient and for sum of two coefficients. Let me introduce short example to see where is the problem. I want parameter b1 to be between 0 and 1 and I want sum of parameters b1 and b2 to be between 0 and 1 as well. set.seed(123) # example where everything is OK x <- 1:200 g <- rbinom(200, 1, 0.5) y <- 3 + (0.7 + 0.2 * g) * x yeps <- y + rnorm(length(y), sd = 0.1) # both parameter b1 and sum of

R: can I update the class of a an object in a magrittr pipe?

痞子三分冷 提交于 2021-02-11 15:54:02
问题 I have a piece of code where I update the class of the object. But I have to break the follow of the code to assign the class. Is there an elegant to to assign the class but continue the pipe so I have one pipe all the way to the final result? I suspect there might be something in {purrr}? library(disk.frame) library(dplyr) library(tidyquery) a = nycflights13::airports %>% as.disk.frame class(a) <- c(class(a), "data.frame") a %>% query("SELECT name, lat, lon ORDER BY lat DESC LIMIT 5") 回答1:

How to plot MULTILINESTRING in leaflet addPolylines?

梦想的初衷 提交于 2021-02-11 15:53:31
问题 The leaflet documentation says: Line and polygon data can come from a variety of sources: [...] MULTIPOLYGON, POLYGON, MULTILINESTRING, and LINESTRING objects (from the sf package) Yet how do I make use of such objects in leaflet? Here is a MULTILINESTRING example: # attach packages--------------------------------------------------------------- library(dplyr) library(sf) library(leaflet) # set up data ------------------------------------------------------------------ set.seed(5) data <-

How to name downloaded files using strings from another column in the same dataframe?

让人想犯罪 __ 提交于 2021-02-11 15:51:57
问题 I have a a dataframe that looks like this: link <- c("http://www.sciencedirect.com/science/article/pii/S1042957318300366", "http://www.sciencedirect.com/science/article/pii/S1042957318300664", "http://www.sciencedirect.com/science/article/pii/S1042957318300627", "http://www.sciencedirect.com/science/article/pii/S002205311830156X", "http://www.sciencedirect.com/science/article/pii/S1090951618303419", "http://hdl.handle.net/10.1093/jjfinec/nby006") repec_id <- c("RePEc:eee:jfinin:v:38:y:2019:i

Circular stacked barplot in R - Aesthetics must be either length 1 or the same as the data (26)

主宰稳场 提交于 2021-02-11 15:45:51
问题 I am trying to create a circular stacked barplot as mentioned here (https://www.r-graph-gallery.com/299-circular-stacked-barplot.html). And I get the following error when when I get to the step of making the plot (in bold below): Error: Aesthetics must be either length 1 or the same as the data (26): hjust Run rlang::last_error() to see where the error occurred. In addition: Warning message: Removed 208 rows containing missing values (position_stack). This is what my data looks like (with 5

Error: Unable to find conda binary. Is Anaconda installed?

余生长醉 提交于 2021-02-11 15:45:01
问题 I am trying to run python scripts in R. I have a macOS Catalina 10.15.4 and I continue to receive this error: "Error in value[[3L]](cond) : Need to install Anaconda from https://www.anaconda.com/download/. Error: Unable to find conda binary. Is Anaconda installed?" I have already downloaded python 3.8 and I have already downloaded anaconda. After exhausting Google searches. I'm learning that the path for my conda might be the issue. Google searches then recommend using "use_condaenv()" to

Error: Unable to find conda binary. Is Anaconda installed?

家住魔仙堡 提交于 2021-02-11 15:44:29
问题 I am trying to run python scripts in R. I have a macOS Catalina 10.15.4 and I continue to receive this error: "Error in value[[3L]](cond) : Need to install Anaconda from https://www.anaconda.com/download/. Error: Unable to find conda binary. Is Anaconda installed?" I have already downloaded python 3.8 and I have already downloaded anaconda. After exhausting Google searches. I'm learning that the path for my conda might be the issue. Google searches then recommend using "use_condaenv()" to

Datatable displays empy selectInput while values are selected by default

删除回忆录丶 提交于 2021-02-11 15:43:39
问题 I have the shiny app below in which I pass the values of a list with characters inside a selectImput() but while all those values seem to be selected (and they should be) by checking their count in the third column the selectize inputs seem to be empty. I think that for this issue is responsible the list words I created. library(shiny) library(DT) library(jsonlite) selector <- function(id, values, items = values){ options <- HTML(paste0(mapply( function(value, item){ as.character(tags$option

R Shiny: display elapsed time while function is running

早过忘川 提交于 2021-02-11 15:40:30
问题 Taking the same idea of this post: R shiny: display "loading..." message while function is running I'd like actually not only display a "loading" message, but also display the elapsed time of the run. And at the end, that the final running time remains displayed. I adapt a MWE from the R-bloggers https://www.r-bloggers.com/long-running-tasks-with-shiny-challenges-and-solutions/ library(shiny) ui <- fluidPage( # Sidebar with a slider input for number of bins sidebarLayout( sidebarPanel(

Error in dyn.load(dllfile) — problem with building a package linking to Rcpp

江枫思渺然 提交于 2021-02-11 15:40:09
问题 My package will not install, either on my machine or on travis-ci.org. The only update from the version on CRAN is that I added a vignette. I have been following the examples of Rcpp - package and R-packages; compiled code. The error is related to these prior questions but not a duplicate. Q40922814 -- problem here was the use of both C and C++ code. I only use C++ code Q36952571 -- I'm on Mac OS, so no access to ldconfig , though perhaps my problem is related. Error: from the package