Duplicate rows based on splitting condition
I want to duplicate rows based on a splitting condition ideally in SQL or Excel. Is there an easy way to do this? Listed an example of the output I'm expecting below.structure(list(key = 1:3,...
View ArticleScrape Stocks' Historical Data in R for Pakistan Stock Exchange
I am working on Stocks' Analysis in R for Pakistan Stock Exchange. I am using "rvest" library and its tutorial at: https://github.com/hadley/rvestUsing this tutorial, I am trying to fetch the...
View ArticleUnable to Export (or view) Total If-Idf Results for textmining
As part of my efforts to textmine research papers I am interested in looking at Tf-Idf values.So far I have had difficulty using tidytext for tf-idf due to issues with columns/objects not being...
View ArticleScale an axis and merge two graphs into one
I try to put the axis of depth on the scale, but after multiple attempts I can't.Here is the code allowing me to generate the graph:MOZ_Echt <- subset_samples(MOZ, corebis == "CSF_04" | corebis ==...
View ArticleAdd new columns to dataframe with colnames defined from a paste function...
I want to add 4 new columns to a dataframe with their colnames defined from a paste function using one variable called but it doesn't work.# Data sample : Data =...
View ArticleHow do I tabulate a variable in Stata to show all values that are in my...
I am trying to tabulate a variable for a report at work to show the completion rate by municipality of a survey that is currently in the field. A dataset is downloaded each week showing all the...
View ArticleCreating a user-defined total with grand_summary_rows()
I have a table that looks like this: category family amount <chr> <chr> <chr> 1 SALES ONLINE SALES 47 2 SALES IN STORE 72 3 COGS LABOR 28 4 COGS TAXES 35 5 COGS WORKERS COMP 24 6 COGS...
View Articlestat_count function in ggplot2
For the simplest case library(ggplot2) ggplot(data = diamonds) + geom_bar(aes(x = cut, y = ..prop..)) it finds the frequency for each level of cut. Then the proportion is calculated with respect to...
View ArticleGroup and subtract all rows in a dataframe
Consider the following example:t1 t2 t3 t4 t5 t6 A 4 6 7 8 5 A 3 6 8 1 4 A 2 3 5 3 1 A 3 4 3 1 3 B 3 6 8 3 4 B 3 9 3 7 3 B 5 2 3 2 1 I hope to get a dataframe which checks for differences between every...
View Articlehow do I solve the Error in get.current.chob() : improperly set or missing...
Whenever I run the following code: chart_Series(`BTC-USD`, type = "candlesticks", subset='2017',) addSMA(n=30,on=1,col = "blue") , It gives me the following error:Error in get.current.chob() :...
View ArticleAdding multicolumns to my texreg output
I want to make a table with grouped columns via texreg. I can only see options for grouped rows (groups).Here's an example:set.seed(01349) DF <- data.frame(y = rnorm(100), x1A = rnorm(100), x2A =...
View ArticleVarying the number of iterations in a for loop depending on results in the...
Here is the code that I tried, to vary my iterations in a for looprepscount <- value for (i in 1:repscount) { ##certain calculations on x if (x == 0) {repscount <- repscount + 1} else{}##add x to...
View ArticleHow to store Highcharter maps in order to use them without an Internet...
Usually, as the hcmap() function explains, the representation of the map gets downloaded on each Shiny session, unless we change the download_map_data parameter.If we set it to FALSE, then it tries to...
View ArticleShade in R using ggplot2 in R when given a range
I have the following vectorsy_minimum <- c(2.5, 3.6, 2.5, 2.4, 3, 3.1, 3.8) y_maximum <- c(12.5, 13.6, 12.5, 12.4, 13, 13.1, 13.8) x <- c(2,3,4,5,6,7) I want to plot y_minimum, y_maximum with...
View ArticleR, iml, mlr. Feature Importance always returns 1 for every feature
I'm doing something with the mlr framework that causes FeatureImp to return 1 for every feature and I can't put my finger on it. Here's an exemple:library(caret) #> Carregando pacotes exigidos:...
View ArticleCRAN package submission: "Error: C stack usage is too close to the limit"
Right upfront: this is an issue I encountered when submitting an R package to CRAN. So Idont have control of the stack size (as the issue occured on one of CRANs platforms)I cant provide a reproducible...
View ArticleHow to apply WOE in r (both training and test sets)
I am using random forest for my classification problem and I have a data set consisting of categorical variables with too many levels (>100). I want to decrease the number of levels by applying woe....
View ArticleAssign group id to sequence of concecutive unique values in timeseries
I am dealing with a big timeseries with one column containing four different sensors and one column containing the mesured values. I need to assign an id to measurements that belong to the same time....
View ArticleDrawing rectangles on top of image R shiny
I'd like to elaborate on the accepted answer to this question.I'm looking at improving the minimal shiny app below (extracted from the accepted answer) with the following features:1) draw the rectangle...
View Articlesetting seed locally (not globally) in R
I'd like to set seeds in R only locally (inside functions), but it seems that R sets seeds not only locally, but also globally. Here's a simple example of what I'm trying (not) to do.myfunction <-...
View Article