Category "r"

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

A Function That Check for Complete Cases in Several File Fail When Specifing A File Range

I have created a function that checks a string of CSV files for complete values and creates a table with these values. The function takes 2 arguments, the first

How can I access camera and take photos within my R Shiny App? [closed]

I am willing to make my Shiny App accessing the camera and take photos every 5 seconds in the background. I do not want to see the photos on t

How to plot vectors orthogonal to quadmesh?

I am trying to use the rgl package in R to plot unit vectors orthogonal to each cell in a quadmesh. I've used this page for a bit of guidance, and currently hav

Reading multiple .Rmd scripts including SQL-queries from a separate .Rmd script

I have created a .Rmd script where I try to read multiple external .Rmd scripts that includes a combination of R and SQL syntax. For this I tried to use: rmarkd

Using ggplot2 & geom_bar to change bar color based on 1 factor variable and bar pattern based on another factor variable

I want to use ggplot2 & geom_bar to change bar color based on 1 factor variable and bar pattern based on another factor variable. I can't figure out how to

Making Combinations of Items

Suppose I have the following lists of factor: factor_1 = c("A1", "A2", "A3") factor_2 = c("B1", "B2") factor_3 = c("C1", "C2", "C3", "C4") factor_4 = c("D1", "D

what is the rsconnect command to deploy a learnr site?

I have a simple one-page learnr site containing several quizzes. It works fine and deploys fine when I press the Deploy ("Publish the application") button in rs

Error when updating a dataframe with new column inside a for loop using Dplyr

I have the following R dataframe df: library(tidyquant) start_date <- as.Date('2022-01-01') end_date <- as.Date('2022-03-31') assets_list <- c('DGS30

Ignoring count reset at specified point in time series

I have a dataframe like this (edited; adding a grouping variable measurement_type): data <- data.frame(ID = as.factor(c(rep(1, 10),

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

How can you graph multiple overlapping 18 month periods with daily data?

I am doing an exploratory data analysis for data that is collected at the daily level over many years. The relevant time period is about 18 - 20 months from the

How to fix jagged line from predict_gam in ggplot2?

Data: structure(list(ID = c(19903L, 28185L, 28207L, 28429L, 28522L, 29092L, 29127L, 29219L, 29304L, 30981L, 31166L, 31411L, 32010L, 33231L, 33640L, 33714L, 34

How do I force r to print character strings with single quotes?

I'm writing some code that interfaces with SQL, and I need my character strings to print with single quotes, but R defaults to double quotes. When I go to ?Quot