Category "r"

Predict on test data, using plm package in R, and calculate RMSE for test data

I built a model, using plm package. The sample dataset is here. I am trying to predict on test data and calculate metrics. # Import package library(plm) library

How do I group a list of numbers based on fixed recurrance

I have a list: x <- c("1", "2", "2", "3", "3", "3", "2", "2", "3", "3", "3","2", "2", "2", "2") What I need to do is make them shortened like this. 1 2 3 2

Correct way to create a software install script which can manage dependencies

I'm currently working on an university research related software which uses statistical models in it in order to process some calculations around Item Response

Matching values in different datasets by groups in R

I have the following two datasets: df1 <- data.frame( "group" = c(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5), "numbers" = c(55, 75, 60, 55, 75, 60, 5

fuzzy version of stringr::str_detect for filtering dataframe

I've got a database with free text fields that I want to use to filter a data.frame or tibble. I could perhaps with lots of work create a list of all possible m

Simple fread operation with fill=TRUE fails

The following code generates data files where each row has a different number of columns. The option fill=TRUE appears to work only when a certain character lim

Error in new.session() : Could not establish session after 5 attempts

I've been facing in R the error message for days using getSymbols of the quantmod package: Error in new.session() : Could not establish session after 5 attempts

trouble with labeling axis with strings using ggplot (R)

I'm a college student and we have to create some graphs using Rstudio for an assignment. I've managed to do the core objective for this first task, which is to

gganimate: change state_length in transition_manual

I have this dummy data as example: library(ggplot2) library(gganimate) dummy <- data.frame(year = 2000:2022, inside = rnorm(23),

clip raster by SpatialPolygonDataFrame

I have a raster, and want to only retain the sea part of the raster, and remove the land part or the raster. If my raster is "ras" and my SpatialpolygonDataFRam

How to create a custom example environment for r markdown pdf output?

I am hoping to create a custom-styled example environment within r markdown that renders pdf output. I want something that looks like this or like this, but I s

Problem while plotting in grouped date values in R

I was trying to plot the max values from a dataset with x-axis = Date and the y-axis = max_value grouped by Stations, like the picture I found on this link, but

R efficient Drilldown chart with loop using Highchart

I bring you a problem in which I have found myself when doing a job. I need to perform a 'drilldown' that contains around 100 columns and I am running into an e

Unnest/Unlist column with variable lengths in R

I'm trying to wrangle a json file into a data frame but I'm having trouble when unnesting to a wider format because the columns contain lists of unequal sizes.

An up-to-date method for plotting a transition probability matrix?

I'm trying to find an easy, up-to-date way to plot transition matrices. Could someone please recommend a method or package? I found advice on Stack, but the pos

generate human-frinedly ticks in power scale

I want to find an algorithm to generate ticks in a power scale in a human-friendly way. For example, if the power is 1/2, between the range of [0, 100], without

Creation of an index with a year base

I have a simple features panel data with the murders in the 32 Mexican states through 24 years. I want to create an index taking as a base the first year in my

Convert multidimensional NetCDF to Tif in R

I have .nc file sizing around 651 MB with a couple of datasets (daily) (rr_mrg_19810101_20181231_ENACT.nc) data. I need to convert (rr_mrg_19810101_20181231_EN

Apply zip_distance to every row

I have a dataframe with two columns, zip and CSZip. I am trying to apply a function to each row using: dist <- apply(vf, 1, zip_distance(zip, CSZip, lonlat =

Add row number column to a reactive data frame in Shiny

I am trying to add a row index column to a reactive data frame created on-the-fly from user inputs. I am able to do this outside of Shiny using the tibble::rowi