How to efficiently collapse a vector of integers into a data.table of...
Given a large vector. For example:set.seed(1) in_vec <- sample(1:10000, 5000, replace = F) How can I efficiently collapse this into a datatable that provides the start and end coordinates for all...
View Articleextend gsub and grepl to ignore substrings between given delimiters
I want to be able to use grepl() and gsub() only outside of given sets of delimiters, for instance I want to be able to ignore text between quotes.Here is my desired output : grepl2("banana", "'banana'...
View Articleantuki/COGugaison: Error in (provisoire[, c(var_num, "ratio")] * provisoire[,...
I want to change the official geographic codes (insee codes) of French communes from 2012 to 2019, within a data frame in R. To do so, I am using the function changement_COG_varNum from...
View Articlefunction to rbind list of dataframes different columns and rows
I want to create a function that merges a list of dataframes with different column numbers and the rows have different names that I'd like to keep. Essentially I want to stack dataframes where the...
View ArticleGetting ROC curve from benchmark results
I have used the mlr and batchtools to benchmark openml datasets for 2 learners namely rpart and logistic regression.rm(list = ls()) detectCores(all.tests = FALSE, logical = TRUE) library(mlr)...
View ArticleHow to save predicted values of H2O.GBM in an existing dataframe?
I have made an H2O model to predict the values of varToBePredicted:data <- h2o.importFile(file) split <- h2o.splitFrame(data, ratios = c(.70, .15)) gbm <- h2o.gbm( training_frame = split[[1]],...
View ArticleHow can we build a timer for 5 different player using closure in R
There are 4 separate function for starting, ending, get their duration and display their result in desc order which needs to be implemented using closure. I was trying to implement three functions...
View ArticleHow can I adjust the dimension of the axes fviz_pca
I'm trying to put the two axes of my biplot exactly equally scaled (i.e., 1 cm on the vertical axis must represent the same 1 cm on the horizontal axis). How can I do that with fviz_pca? or there is...
View ArticleHow to create unique samples (every element appears in one sample only) using R?
I am working with the BTYD model to generate forecast on customer future transactions. Unfortunately, due to the use of mcmc methods I cannot run the forecast on my whole base of customers (hundreds of...
View Articlepick elements cumulatively from a vector in R
I'm using the following to cumulatively (i.e., first pick first 2 elements and each time add 1 more; see output below) pick elements from vector mods below. I wonder if there is a faster or simpler...
View Articleapplying a function across columns by extracting similar column names
My data looks like:[[1]] date germany france germany_mean france_mean germany_sd france_sd 1 2016-01-01 17 25 21.29429 48.57103 30.03026 47.05169 What I am trying to do is to compute the following...
View ArticleChanging columns right to left in a tibble
I have a table - read from an excel file, with column names in English and some variables in Hebrew. As I read the excel file and receive a tibble, the column names don't fit the data. I use the...
View ArticleHow to select the weighted pairs of edges of an igraph in R?
I have a random directed weighted graph g. The adjacency matrix of graph is a transition matrix TM. I need to find the second order of transition matrix. I mean, I need to calcucalete the propability...
View ArticleSummarise a group value into single row
I have a large dataset with longitudinal readings from single individuals. I want to summarise information over time into a binary variable. i.e. if diff in the input table below is >5 for any value...
View Articlegetting all daily oil prices from a dropdown menu in R
I am trying to get oil prices in all counties of Istanbul from this link: https://www.petrolofisi.com.tr/akaryakit-fiyatlariwhich has two dropdown list for selection of cities and counties, with the...
View ArticleCounting and matching over a time interval [closed]
For a +/- 2 month-year interval, I wish to calculate for a given "id", how many times did that "id" appear in the "id2" column. I am wondering if there is an efficient solution in R. myData <-...
View ArticleTruncation of database name and columns while connecting to SQL database from R
I am on macOS Catalina (Version 10.15.1), running R 3.5.0. I am running SQL server on Docker locally. For connecting to the server, I am using odbc:con <- dbConnect(odbc(), Driver = "Simba SQL...
View ArticleSave row multi-diagram to PDF in R without 1:1 ratio
I am trying to generate a PDF image in R of three plots arranged in a row grid. This is what I tried:pdf("fig.pdf") par(mfrow=c(1,3)) plot(rnorm(100), rnorm(100), xlab="Something on X", ylab="Some on...
View ArticleMy ggplot visulisation in my shiny app wont show the points
Hi I'm trying to create a simple shiny dashboard which filters the point chart based on different sitesSite AssetID Category N Site1 A Cat1 3 Site1 B Cat1 5 Site1 A Cat2 6 Site2 B Cat3 10 Site2 B Cat1...
View ArticleMake waffle charts with ggplots
I am trying to reproduce a simple waffle graph like this from Tableau with R: I'm not sure if is doable in waffle package, however I would really appreciate any help on two cases: Is there any way to...
View Article