Category "r"

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

How do I replace values in a category by group in R

Hi I have a dataframe sleep_data where I am attempting to change Id values to user1:user33 based on groups. So where Id == 1503960366 change to user_1, Id == 16

Manually estimate probit model with autoregressive structure in R

I would like to write an R algorithm which would perform the Maximum Likelihood estimation of a binary choice model (probit/logit, it does not really matter) wi

How can I make time series plot?

I created a dataset with these variables. Can you help me please.

Merging in R returns columns full of NA values

I am trying to finish a business case in Kaggle but I am having some issues when merging two data frames. Having dataframe "dailyActivity" as: dailyActivity <

Error in tq_get, x = 'MKL', get = 'stock.prices': Error in new.session(): Could not establish session after 5 attempts [duplicate]

I am having difficulties pulling stock data. The code has worked earlier today, however this afternoon I became unable to pull any stock data

Avoid labels overlap in bar chart

How to avoid my y-axis label overlap in this case(top 5 most frequent words for each year)? Because I may need to change the number of words(ie.top10, top20) la

(R) How can a bigger expression be written by combining shorter variable expressions?

Brief introduction, I have multiple data file that can be fitted by models based in mathematical equations that are a combination (by sum, mutiplication, etc...

Statistical Tests in R

I want to run Bonferroni P Adjusted Value Test on a stacked data set. This is my code: stat.2 <- stack.2 %>% group_by(modules) %>% t_test(values ~ phen

Calculate changes in totals of subgroups in R

I have the following dataframe: # A tibble: 8 x 5 Year Group Unit Profit Sales <dbl> <chr> <chr> <dbl> <dbl> 1 2021 One

Configuring reticulate to use conda environment

I'm trying to get R's reticulate package to detect the Python interpreter in one of my conda-environments. Following several posts and questions, I've attempted

Converting categorical data into numerical values

I have a dataset with a lot of categorical mixed with numerical. I am trying to run a regression about obesity where the variables I'm trying to include are sta