Quantcast
Channel: Active questions tagged r - Stack Overflow
Browsing all 201839 articles
Browse latest View live
↧

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 Article


extend 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 Article


antuki/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 Article

function 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 Article

Getting 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 Article


How 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 Article

How 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 Article

Image may be NSFW.
Clik here to view.

How 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 Article


How 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 Article


pick 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 Article

applying 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 Article

Changing 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 Article

Image may be NSFW.
Clik here to view.

How 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 Article


Summarise 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 Article

Image may be NSFW.
Clik here to view.

getting 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 Article


Counting 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 Article

Image may be NSFW.
Clik here to view.

Truncation 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 Article


Image may be NSFW.
Clik here to view.

Save 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 Article

Image may be NSFW.
Clik here to view.

My 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 Article

Image may be NSFW.
Clik here to view.

Make 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
Browsing all 201839 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>