r

Interactively change axis scale (linear/log) in Plotly image using R

此生再无相见时 提交于 2021-02-18 17:10:34
问题 Goal: To create interactive dropdown/buttons to update the axes' scale for a Plotly figure from R. Issue: There is a lot of documentation on creating buttons and log plots using layout and updatemenus ; however, it was difficult to find one that described how a button could be added specifically for changing the scale of the axes. Some posts on stackoverflow provided solutions for doing this in python but I struggled to find an equivalent one for R. I have provided a solution/example here

Interactively change axis scale (linear/log) in Plotly image using R

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-18 17:10:20
问题 Goal: To create interactive dropdown/buttons to update the axes' scale for a Plotly figure from R. Issue: There is a lot of documentation on creating buttons and log plots using layout and updatemenus ; however, it was difficult to find one that described how a button could be added specifically for changing the scale of the axes. Some posts on stackoverflow provided solutions for doing this in python but I struggled to find an equivalent one for R. I have provided a solution/example here

GPU computing for bootstrapping using “boot” package

倾然丶 夕夏残阳落幕 提交于 2021-02-18 17:10:17
问题 I would like to do a large analysis using bootstrapping. I saw that the speed of bootstrapping is increased using parallel computing as in the following code: Parallel computing # detect number of cpu library(parallel) detectCores() library(boot) # boot function --> mean bt.mean <- function(dat, d){ x <- dat[d] m <- mean(x) return(m) } # obtain confidence intervals # use parallel computing with 4 cpus x <- mtcars$mpg bt <- boot(x, bt.mean, R = 1000, parallel = "snow", ncpus = 4) quantile(bt$t

Interactively change axis scale (linear/log) in Plotly image using R

筅森魡賤 提交于 2021-02-18 17:10:09
问题 Goal: To create interactive dropdown/buttons to update the axes' scale for a Plotly figure from R. Issue: There is a lot of documentation on creating buttons and log plots using layout and updatemenus ; however, it was difficult to find one that described how a button could be added specifically for changing the scale of the axes. Some posts on stackoverflow provided solutions for doing this in python but I struggled to find an equivalent one for R. I have provided a solution/example here

Interactively change axis scale (linear/log) in Plotly image using R

冷暖自知 提交于 2021-02-18 17:09:38
问题 Goal: To create interactive dropdown/buttons to update the axes' scale for a Plotly figure from R. Issue: There is a lot of documentation on creating buttons and log plots using layout and updatemenus ; however, it was difficult to find one that described how a button could be added specifically for changing the scale of the axes. Some posts on stackoverflow provided solutions for doing this in python but I struggled to find an equivalent one for R. I have provided a solution/example here

GPU computing for bootstrapping using “boot” package

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-18 17:09:24
问题 I would like to do a large analysis using bootstrapping. I saw that the speed of bootstrapping is increased using parallel computing as in the following code: Parallel computing # detect number of cpu library(parallel) detectCores() library(boot) # boot function --> mean bt.mean <- function(dat, d){ x <- dat[d] m <- mean(x) return(m) } # obtain confidence intervals # use parallel computing with 4 cpus x <- mtcars$mpg bt <- boot(x, bt.mean, R = 1000, parallel = "snow", ncpus = 4) quantile(bt$t

Possible to animate polygon fill using gganimate in R?

不打扰是莪最后的温柔 提交于 2021-02-18 17:04:21
问题 I have county level data recording the year an invasive insect pest was first detected in that county between 2002 and 2018. I created a map using ggplot2 and the maps package that fills the county polygons with a color according to the year the pest was detected. **Is there a way to use the gganimate package to animate this map with the first frame filling in only polygons with a detection date of 2002, the second frame filling polygons with a detection date of 2003 or earlier (so 2002 and

Is there more efficient or concise way to use tidyr::gather to make my data look 'tidy'?

前提是你 提交于 2021-02-18 16:59:43
问题 I am new to using tidyverse. I want to see if I am being as efficient/concise as possible using the functions in this package. I suspect I am not. My original data has the key sym as part of each column name. day a_x b_x a_y b_y 1 1 -0.56047565 1.2240818 -1.0678237 0.42646422 2 2 -0.23017749 0.3598138 -0.2179749 -0.29507148 ... I would like to make the data look tidy, like so: day sym x y 1 1 a 0.118 0.702 2 2 a -0.947 -0.262 ... 11 1 b 1.44 0.788 12 2 b 0.452 0.769 Here is my code that does

Is there more efficient or concise way to use tidyr::gather to make my data look 'tidy'?

爷,独闯天下 提交于 2021-02-18 16:59:12
问题 I am new to using tidyverse. I want to see if I am being as efficient/concise as possible using the functions in this package. I suspect I am not. My original data has the key sym as part of each column name. day a_x b_x a_y b_y 1 1 -0.56047565 1.2240818 -1.0678237 0.42646422 2 2 -0.23017749 0.3598138 -0.2179749 -0.29507148 ... I would like to make the data look tidy, like so: day sym x y 1 1 a 0.118 0.702 2 2 a -0.947 -0.262 ... 11 1 b 1.44 0.788 12 2 b 0.452 0.769 Here is my code that does

R : combine and save rgl widgets as a single html file

混江龙づ霸主 提交于 2021-02-18 16:05:57
问题 In R, using the rgl and htmlwidgets libraries, I'm trying to extract an HTML file having a widget with toggle buttons . The following example does what I want in the RStudio Viewer. The HTML export works without the toggle buttons, but fails when the rglwidget includes these buttons. The first part is based on these rgl examples, and the export part on the htmlwidgets manual. library(rgl) open3d() x <- sin(1:100) y <- cos(1:100) z <- -100:100/100 # draw a barrel sids1 <- spheres3d(x, y, z,