Summing rows with particular value in grouped data in R
I contain a dataset 'area'House_No. Info_On_Area 1a Names of neighbouringhouse in 100m 1b 1c 1d 1e 1a Area of neighbouringhouse in 100m 500 1000 1500 300 1a Names of neighbouringhouse in 300m 1b 1c 1d...
View ArticleIs there a faster rewrite to deal with missing XML attributes?
I'm dealing with huge XML files e.g. 75GB and more, my point is any small overhead will turn into many minutes if not hours slower processing. The core of my code does the following while parsing a XML...
View Articledifference between k-means and k-folds [closed]
Generally speaking, we can't use all of data in data training model, otherwise, we will have no data set to verify the model, so as to evaluate the prediction effect of our model. so for...
View ArticleExtract the first 2 Characters in a string
I need to extract the 1st 2 characters in a string to later create bin plot distribution. vector:x <- c("75 to 79", "80 to 84", "85 to 89") I have gotten this far:substrRight <- function(x, n){...
View ArticleError in xgb.dump - "unknown feature type, use i for indicator and q for...
I'm using this blogpost to try to use the package xgbfi in R to calculate feature interaction scores using an XGBoost model. When I get to the xgb.dump step, I get an error:Error in xgb.dump(model =...
View ArticleSubset dataset with time condition in R
I have a dataset like this in example.txt"09/Jan/2016""05:00:22""304" 449 "09/Jan/2016""07:00:12""304" 449 "09/Jan/2016""10:00:02""200" 10575 "09/Jan/2016""11:00:03""304" 449...
View ArticleIs there a way to change the absolute path of file_in inputs to drake without...
For my project, sometimes restructuring, or simply changing the mount point of my project data directory is required (Eg - Upgrading to catalina and no longer being able to have non-standard...
View ArticleHow to "translate" variables in one data frame using a second data frame as a...
I have a data frame with two string variables, and would like to convert them to numeric values using a separate "key" data frame. The below example is simplified, but I need to be able to apply it to...
View ArticleOn a column in a data.table, record "by = ..."-stratified and non-stratified...
I am recording an output from R quintile() function for a column of a data.table, stratified by "by = ...":require(data.table) DT <- data.table(iris) tab_strata <-...
View ArticleSubtracting columns in a dataframe (or matrix)
I am trying to do less in Excel and more in R, but get stuck on a simple calculation. I have a dataframe with meter readings over a number of weeks. I need to calculate the consumption in each week,...
View Articlematching and filling in blanks of data frame in R
I have data with double entries, that looks like this:+-----+-------+-----------+-----------+--------+ | id | first | last | birthyear | father | +-----+-------+-----------+-----------+--------+ | a12...
View Articlehow to color the nodes and labels in ggraph
How to specify the color of the edge in ggraph plot like thislibrary(ggraph) library(igraph) df_school = highschool %>% mutate(yr=ifelse(year%%2==0,'purple','blue')) V(graph)$node_label =...
View ArticleCreate a Boolean column by coercing factors to logical types in dataframe?
My dataframe looks like this: location eco Germany eco Netherlands eco USA not-eco Dubai not-eco I would like to create a new column in the dataframe and display TRUE if the location is "eco" and...
View Articleconverting histogram bars to symbols in R
In my function below, from time to time (please run a few times to see), I get an error message from inside the data.frame that says x and y differ by 2 rows.I was wondering how this occasional error...
View ArticleAdding elements to a dataframe in R using Rbind
I am creating a dataframe with 3 columns (char, char, int) called Alleles_df from df1 and df2 using:Alleles_df <- data.frame('refsnp_id'=character(),'allele'=character(), 'chrom_start' =...
View ArticleHow do I insert special character as the result of case_when in R Shiny?
I have this code I put in R Shiny :case_when(tesdata$note <= 10 ~ "≤", tesdata$note > 10 ~ "≥") It should return ≤ if the value is less than or equal to 10 and ≥ if the value is...
View ArticleR plot legend Error in plot.xy(xy, type, ...) : invalid plot type
When I want to add legend to a plot, it has Error in plot.xy(xy, type, ...) : invalid plot type, and the plot has no points showing up. Without legend and directly using pch, I'm able to get the points...
View ArticleCreating a Pareto Chart with ggplot2 and R
I have been struggling with how to make a Pareto Chart in R using the ggplot2 package. In many cases when making a bar chart or histogram we want items sorted by the X axis. In a Pareto Chart we want...
View ArticleHow can I concatenate one row to the previous row in a data frame, if a...
I am an intermediate user of R and have a data set of ~850,000 rows that was edited through Stata, saved as a csv, but about .01% of the rows got split to the following row after column 4. I am trying...
View ArticleHow can I improve the performance of Linux-based Docker Desktop containers...
I'd like to be able to get the same performance with docker as I get in RStudio. I have Docker Desktop installed on Windows 10 and am using Linux containers. The goal is to containerize R scripts for...
View Article