Splitting Data Frame based on a specific group ID(In R)
I have a data frame where I want to split by a group based on a single group and would like to split it so I can encapsulate everything from Valley 1 to Valley 2, Valley 2 to Valley 3 and so on. Time...
View ArticleHow to solve school bus rout optimization using R Algorithims
Can not find R algorithms to use for optimizing the school bus routing. I have the following data: school names and locations. list of student pickup locations for each bus.objective is to come up with...
View ArticleRandom number generation from multinomial distribution in R using rmultinom()...
I would like to generate a sample of size 20 from the multinomial distribution with three values such as 1,2 and 3. For example, the sample can be like this...
View ArticleOptimize/Vectorize Database Query with R
I am attempting to use R to query a large database. Due to the size of the database, I have written the query to fetch 100 rows at a time My code looks something like:library(RJDBC) library(DBI)...
View ArticleHow to stack columns of data-frame in r?
I have a data-frame with these characteristics:Z Y X1 X2 X3 X4 X5 ... X30 A n1 1 2 1 2 1 2 1 2 B n2 1 2 1 2 1 2 1 2 C n3 1 2 1 2 1 2 1 2 D n4 1 2 1 2 1 2 1 2 . . . My purpose is to stack the column x1,...
View ArticleHow to split and paste a string while mutating a dataframe?
I have a dataframe like this one:x <- data.frame(filename = c("aa-b-c x", "c-dd-e y"), number=c(1,2)) filename number 1 aa-b-c x 1 2 c-dd-e y 2 I want to mutate the filename column so it looks like...
View Articlelook for common entries in two data frames
df1: state group species 1 CA 2 cat, dog, chicken, mouse 2 CA 1 cat 3 NV 1 dog, chicken 4 NV 2 chicken 5 WA 1 chicken, rat, mouse, lion 6 WA 2 dog, cat 7 WA 3 dog, chicken 8 WA 4 cat, chicken df2:...
View ArticleManually setting group colors for ggplot2
I have a data set from which I have to make several dozen plots. The data consists of 30 Groups and several measurements within each group. Most plots will not use all the groups at once. My goal is to...
View ArticleLinear Mixed Models in R - how to add a covariance
I am doing a LMM analysis with data from an attentional task. The response time is the dependent variable and the group (bipolar patients vs. controls), perceptual load (high perceptual load vs. low...
View ArticleRegression in a specific equation
I have values from field tests.And I need to do the regression fitting in the next equation:y = ax^n + bxBut I try with linear regression, no linear, etc and not works.Data for the...
View ArticleR factors and df
New to R, trying to iterate through a DF and see if the data type of the row is empty ('') If so, I would like to add a factor and if not then do nothing. My expected output is for df$data_type[i] to...
View ArticleWhy XGB model is not giving output on validation dataset but work better for...
Currently i am working on a project whose objective is to find the customer who has more probability to purchase your project.Its a classification model (0 & 1 ). I have created model with RF and...
View ArticleHow do you serialize a ggplot2 object?
How would you serialize a ggplot2 object to a file and then restore it back from that file?
View ArticleError in seq.default when trying to use a function after grouping per day
I have a dataframe with some values per time.library(flux) library(dplyr) library(lubridate) mydf <- tibble(mydate = as.Date(c("2019-05-11 23:55:00", "2019-05-11 23:56:00", "2019-05-11 23:57:00",...
View ArticleAdding specific column value according to row value
I have a dataframe HGenotype Preference Rice 1 Rice 2 Lr 3 Lr 3 th 4 th 7 I want the dataframe to look like Genotype Preference Haplotype Rice 1 1 Rice 2 1 Lr 3 2 Lr 3 2 th 4 0.5 th 7 0.5 That is I...
View ArticleHow to round off labels in cut function in R
I am trying to round off my labels from cut function in R using dig.lab argument. I have given value as 20 but I get lot of decimal places after number in labels e.g. (114126.30000000001746,5248999] ....
View ArticleAdd `RasterLayer` to `addLayersControl` in leaflet
I have to RasterLayer-objects (raster1 and raster2) in R. And I want to add them both to a leaflet-map. I also wanted to have the option to show or hide them. So I thought I'd add them with their names...
View ArticleR problem with unused arguments (nrows = # ) in subplot function
I am working on an R project, and I am trying to use plot_ly and subplot for my project, but#Plot for samples plot.x10 <- plot_ly(x = xbar.1x10, type = "histogram", name = "10") plot.x20 <-...
View ArticleCompute activity blocks coming from IoT device
Here is a toy data.datetime <- c('2019-11-06 13:05:07', '2019-11-06 13:05:08', '2019-11-06 13:05:09', '2019-11-06 13:05:10', '2019-11-06 13:05:11', '2019-11-06 13:05:12', '2019-11-06 13:05:13',...
View ArticleR internal handling of sparse matrices
I have been comparing the performance of several PCA implementations from both Python and R, and noticed an interesting behavior: While it seems impossible to compute the PCA of a sparse matrix in...
View Article