r

ggiraph: tooltip with hyperlink?

帅比萌擦擦* 提交于 2021-02-11 15:26:23
问题 I am trying to create an interactive scatterplot with ggiraph where the tooltip allows me to navigate to a webaddress (which pertains to the specific selected dot). Any idea whether this is actually possible and how to go about it? Many thanks for any advice! library(tidyverse) library(ggiraph) my_df <- data.frame(stringsAsFactors=FALSE, x = c(0.5, 0.1), y = c(0.2, 0.9), link = c("bbcnews.com", "nyt.com"), link_name = c("bbc news", "nytimes") ) my_plot <- my_df %>% ggplot()+ geom_point

R: lme, cannot evaluate groups for desired levels on 'newdata'

二次信任 提交于 2021-02-11 15:25:33
问题 I'm running an lme -model from the package nlme on R v.3.0.2. I'm trying to extract the model estimates with predict.lme , but it returns an error. Here's the code to replicate the error: my.model = lme(fixed = Maxi ~ Time*Origin, random = ~ 1 |Genotype, method = "REML", weights=varPower(), data=dd) new.my.model <- data.frame(Origin = c("Ka", "Ka", "La", "La"), Time = c("mor", "eve", "mor", "eve")) predict(my.model, new.my.model, level = 0:1) #Error in predict.lme(my.model, new.my.model,

R nested foreach loop

亡梦爱人 提交于 2021-02-11 15:21:46
问题 I have an input dataset: # environment require(pacman) p_load( data.table , doParallel , foreach ) doParallel::registerDoParallel(makeCluster(4)) # create input runDT <- data.table(run = c(F,T,F,T) , input1 = 1:4 , run_id = 1:4) print(runDT) run input1 run_id 1: FALSE 1 1 2: TRUE 2 2 3: FALSE 3 3 4: TRUE 4 4 and this is another raw dataset: dataDT <- data.table( ID = 1:4 , c1 = c(1:4)) print(dataDT) ID c1 1: 1 1 2: 2 2 3: 3 3 4: 4 4 I would like to run nested foreach loops, but it's giving me

recipes::step_dummy + caret::train -> Error:Not all variables in the recipe are present

痴心易碎 提交于 2021-02-11 15:21:03
问题 I am getting the following error when using recipes::step_dummy with caret::train (first attempt at combining the two packages): Error: Not all variables in the recipe are present in the supplied training set Not sure what is causing the error nor the best way to debug. Help to train model would be much appreciated. library(caret) library(tidyverse) library(recipes) library(rsample) data("credit_data") ## Split the data into training (75%) and test sets (25%) set.seed(100) train_test_split <-

How can I reactively update the active menuItem in a Shiny app using `renderUI`?

此生再无相见时 提交于 2021-02-11 15:19:09
问题 I am building a shiny app that dynamically creates reactive bs4Box elements from a data frame. I want to make those boxes clickable by the user so that automatic redirection to a different menuItem occurs. I have read and followed similar previous SO questions like this one or this issue without success. A JavaScript solution like this one could also work? Here's my attempt so far using the updatebs4ControlbarMenu function: library(shiny) #> Warning: package 'shiny' was built under R version

Receiving “Unmet dependency” while installing r-base on Ubuntu 14.10

◇◆丶佛笑我妖孽 提交于 2021-02-11 15:17:59
问题 I am trying to install R on Ubuntu 14.10 When I am giving the command to download r-base, I get the following error roy@laptop:~$ sudo apt-get install r-base Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following

kableExtra : How can i set to bold the biggest value of the row?

↘锁芯ラ 提交于 2021-02-11 15:17:52
问题 Suppose i have a table that looks like : x = matrix(runif(10*5),nrow=10,ncol=5) When i display the matrix using kableextra , i want the highest value, per row, of say the last 2 rows, to be bolded. I looked at this document https://rdrr.io/cran/kableExtra/f/inst/doc/awesome_table_in_pdf.pdf a lot and i did not found how to use cell_spec correctly to perform this goal. 回答1: I thought this would be easier than it turned out to be. As far as I can see, this is how to do it: --- title: "Untitled"

Receiving “Unmet dependency” while installing r-base on Ubuntu 14.10

雨燕双飞 提交于 2021-02-11 15:16:31
问题 I am trying to install R on Ubuntu 14.10 When I am giving the command to download r-base, I get the following error roy@laptop:~$ sudo apt-get install r-base Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following

Combine several datasets in R

十年热恋 提交于 2021-02-11 15:15:55
问题 I have a number of datasets with identical variable names and want to combine them by rbind (row-wise) with a new column to identify the dataset by its name. e.g. iris0 <- iris iris1 <- cbind(log(iris[,1:4]),iris[5]) iris2 <- cbind(sqrt(iris[,1:4]),iris[5]) The desired output is the same irisR as the output of irisR <- rbind( (iris0 %>% mutate(DS="iris0")), (iris1 %>% mutate(DS="iris1")), (iris2 %>% mutate(DS="iris2")) But I need to do this automatically, because I have a lot more than three

How to make custom y-axis scale in base R

感情迁移 提交于 2021-02-11 15:14:37
问题 I am trying to figure out how to make a plot in R with a custom y-axis scale. For, example I would like to make a plot with the same y-axis as below. You can the distance between the tick marks is the same even though the actual numerical distance is not. In order to achieve the same axis look, I can do the following: set.seed(1) n <- 10 x <- 1:n y <- rnorm(n) ticks <- c("1/30","1/10","1/3","1","3","10","30") plot(x, y, axes = FALSE, ylim = c(-3,3)) axis(1) axis(2, seq(-3,3,1), ticks) which