Category "r"

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

How to use a variable to specify column name in ggplot

I have a ggplot command ggplot( rates.by.groups, aes(x=name, y=rate, colour=majr, group=majr) ) inside a function. But I would like to be able to use a param

Getting the unused argument error while running climpact Rscript?

I was trying to run the sample file of climpact for the historical and I got the error error in create.indices.from.files(infiles, outdir, file.template, author

Rank Biserial Correlation with r

I have a non-normal distribution and two variables: one ordinal and the other a binary categorical, both from same sample population. I've found out that rank b

Refer to the last column in R

I am trying to do some manipulation on the last column in a generic way. I found here on the forums this nice piece of code that returns the name of the last c

Get the rate of change by finding the change in price

UPDATE: I'm getting a strange result in the outcome. Occasionally, the earliest date of the result show after 2 or 3 etc times for example Item Kg Date_1 Price

export data frames to Excel via xlsx with conditional formatting

I want to export data frames to Excel and highlight cells according to certain rules. I don't think this answer to a similar question is correct. I think it is