Category "r"

Rolling mean, standard deviation in dbplyr

I want to set a new variable with rolling function (rolling mean, stdev...etc.) in dbplyr Here is a database library(odbc) library(DBI) library(tidyverse) libra

R ggplot date time major and minor axis breaks not aligning

I'm having a problem that I am surprised I haven't encountered before and that I can't see any answers about. I am plotting some date time data in ggplot and wa

Plotting the “Average ” curve of set of curves in ggplot2

My Question is exactly this one: Plotting the "Average " curve of set of curves but I am looking to implement the accepted answer (below) in ggplot. is it pos

`rgl` crashes R 4.2.0 in RStudio

The new release of R version 4.2.0 will crash when loading the rgl package if in RStudio. What can I do about it?

Compute the size of directory in R

I want to compute the size of a directory in R. I tried to use the list.info function, by unfortunably that follows the symbolic links so my results are biased:

Plotting multiple wordcloud (ggwordcloud) with other types of plots in ggplot2

I am trying to plot several wordclouds in a scatterplot and I wonder if one can control the position of a wordcloud in ggplot? As an example the code below over

Using sparse matrix in random forest

For efficient memory utilization, I have used “matrix" package in R to create sparse matrix using code: library(randomForest) library(Matrix) documentTe

R Buffer/Enlarge a polygon

I have a simple polygon. dfr <- data.frame(x=c(2,2.5,4,5,4.5,3,2),y=c(2,3,3.5,3,2.8,2.5,2)) plot(dfr) polygon(dfr) Are there any R functions to increase

problem installing nloptr 2.0.0 on debian 9 with R 4.2.0 and cmake 3.23.1

on my machine debian 9 (stretch), i have installed R4.2.0 from source. i have problem to install nloptr 2.0.0 using syntax: if (!require("nloptr", quietly = TRU

Teradata JDBC Error 1338 after certain number of batch executions

I am trying to insert 3.8M records into a Teradata table containing 14 columns, through a batch of 10000 records using RJDBC package of R. It always crashes aft

Extracting all matrices out of a nested list with varying sublist lengths in R

I have a nested list of matrices. More specifically, I have a list of matrix lists, each with a variable number of matrices. I would like to extract all the mat

I wonder how to create a proportional table for one categorical variable and one numerical variable (numerical data is proportion)?

library(ggplot2) library(tidyverse) library(dplyr) aqi <- read.csv("aqi12_21.csv") aqi <- select(aqi,State.Name,county.Name,Date,AQI,Category,Defining.Par

I wonder how to create a proportional table for one categorical variable and one numerical variable (numerical data is proportion)?

library(ggplot2) library(tidyverse) library(dplyr) aqi <- read.csv("aqi12_21.csv") aqi <- select(aqi,State.Name,county.Name,Date,AQI,Category,Defining.Par

Cannot see any objects on DB2 (AS400) database after updating to R 4.2.0

When I connect to a DB2 database via ODBC using the recently released R 4.2.0 the database appears to have no objects. Connecting to AWS has no such issues, and

igraph: Resolving tight overlapping nodes

I have a graph with few hundred nodes and edges. The disconnected subgraphs separate out and resolve well but the nodes within subgraphs overlap and do not reso

Making multiple assignments to objects named as strings

We can assign a value to a single object using that object's name - assign("x", 1) - and we can efficiently assign different values to multiple object thanks to

How to map values from a data.table to a data.table (R)

I have two map/data.tables. One consists of key-values and another one just of some keys. I want to map the values from the first map to the keys of the second.

Earliest Date for each id in R

I have a dataset where each individual (id) has an e_date, and since each individual could have more than one e_date, I'm trying to get the earliest date for ea

Is it possible to reorder only the facets of facet_wrap, without reordering the underlying factor levels?

Sample data frame: df <- data.frame(x=rep(1:10,4),y=rnorm(40),Case=rep(c("B","L","BC","R"),each=10)) I can plot each time series in its own facet with: g

Taking only the maximum values of duplicate IDs for all columns of a data frame in R

I have data frame of 24525 rows and 22 columns. Last column is the ID column, other are numeric. Number of unique IDs is 18414 and some IDs are repeated more th