What R function to use for regex capture groups?

I am doing some text wrangling in R, and for a specific extraction I need to use a capture group. For some reason the base/stringr functions I am familiar with don't seem to support capture groups: str_extract("abcd123asdc", pattern = "([0-9]{3}).+$...
more »

2017-05-14 22:05 (1) Answers

Boxplot with ggplot2

I am working on a boxplot with forecast and observations which is quite long dataset. I am providing a sample format here. > forecasts <- data.frame(f_type = c(rep("A", 9), rep("B", 9)), Date = c(rep(as.Date("2007-01...
more »

2017-05-14 02:05 (1) Answers

How to import numbered files in R

I have multiple files named xdata.ascii and x is a number. How can I import all the files with names from 1data.ascii to, for example, 100data.ascii. I have other .ascii files that have a different name and do not want to import them. ...
more »

2017-05-13 20:05 (1) Answers

Quantstrat applyStrategy failure

I am using quantstart but for some reason the applyStrategy function does not spit out any information. It just goes through. As a result, when I then do the tradeStats function I get null. Here is the code I used: Thanks! library(quantstrat) librar...
more »

2017-05-13 17:05 (1) Answers

R - Filtering data by a composed condition

Lets view the following code: u_id <- c(1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5) i_id <- c(10, 10, 10, 12, 10, 11, 13, 13, 13, 10, 11, 13, 13, 14) clicked <- c(0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1) dframe <- data.frame(u_id, i_id, ...
more »

2017-05-13 16:05 (1) Answers

Use of ..col in a j expression in data.table

I'm having trouble getting the desired behavior from the ..j syntax in the latest version of data.table, when I want to query a column using a variable in the column scope, and then manipulate that variable. By way of example, here is a table: A &l...
more »

2017-05-12 21:05 (1) Answers

How to stop a running query?

I use RODBC to send queries to an SQL-Server. Sometimes they take too much time to run, so I need to cancel them. Clicking the red "stop" button in RStudio yields this error message: R is not responding to your request to interrupt processing so...
more »

2017-05-12 19:05 (3) Answers

Redrawing venn diagram

What would be the easiest way to redraw a venn diagram using R ? I do not have a data which was used to generate venn diagram but the rest of diagrams were drawn in R... I would like to keep the same structure so it means I have to somehow redraw it ...
more »

2017-05-12 13:05 (2) Answers

Identifying required packages from code

I want to follow the tutorial found on this site, but despite being thorough in all other aspects, the author has not included information on what packages need to be used for the code to function. As far as I understand one of them will be the Perf...
more »

2017-05-12 13:05 (3) Answers

Replacing year with English words in R

I need to pre-process a speech transcript for forced-alignment. However, I am having difficulty with replacing year with text representation. For example, 1984 needs to be replaced with "nineteen eighty four". I tried the replace_number function of t...
more »

2017-05-12 06:05 (1) Answers

Anonymous function in lapply

I am reading Wickham's Advanced R book. This question is relating to solving Question 5 in chapter 12 - Functionals. The exercise asks us to: Implement a version of lapply() that supplies FUN with both the name and value of each component. Now,...
more »

2017-05-11 08:05 (1) Answers