Category "r"

How to recover fitted values from BSTS poisson model (in R)?

I am trying to recover in-sample predictions (fitted values) from a bsts model with a specified poisson response using the bsts package in R. The following res

Subset with only consecutive numbers

I want to generate all subset of {1,2,3,4} with only consecutive numbers. (For example I want subset {1}, {1,2} or {2,3,4} but not {2,4}. ) This is what I have

How to correctly use data in extdata/data folder

I am working on an R package that I would like to submit to CRAN and have had issues with the size of the data, therefore I moved it into the extdata/data folde

lme4 1.1-27.1 error: pwrssUpdate did not converge in (maxit) iterations

Sorry that this error has been discussed before, each answer on stackoverflow seems specific to the data I'm attempting to run the following negative binomial m

R - Use Twitter API to get every tweet from an account

My goal is to get EVERY tweet ever for any twitter account. I picked the NYTimes for this example. The code below works, but it only pulls the last 100 tweets.

Issue installing spacyr on R 4.2

I am having trouble installing spacyr on R version 4.2. What is strange is that I've used this package in the past just fine. The installation is pretty basic.

1 of the 5 plots are missing in the graphic

I want to plot all ROC curves in one graphic with the plot function, but the first plot (tree.perf in blue) is separate from the others. Can someone help me out

Convert data frame into adjacency matrix format in R

My data looks like this: Sample_A Sample_B Value Rabbit Mouse 1.2 Mouse Tiger 7.89 Tiger Lion -0.9 Mouse Rabbit

How do I assign group level value - based on row level values - to df using dplyr

I have the following decision rules: RELIABILITY LEVEL DESCRIPTION LEVEL I Multiple regression LEVEL II Multiple regression + mec

Formatting the elements of a panel

This is a snippet of my interface (if choices = c () it means that the choice is managed on the server side): sidebarPanel( selectizeInput( "s1",

extract_parameter_set_dials() fails for self-written gbm engine for boost_tree()

I followed this vignette of the tidymodels package to make the gbm an engine for the boost_tree() function. I came up with the following for regression tasks: l

Calculation between vectors in nested for loops

I am struggling with an issue concerned with nested for loops and calculation with conditions. Let's say I have a data frame like this: df = data.frame("a" = c(

Pivot Longer in R Issues

I've looked quite a few different questions on here around Pivot Longer but I can't seem to figure out how to get my scenario to work. For example R Pivot multi

Column name being duplicated in recipe

This is the piece of code i'm having troubles with: pump_recipe <- recipe(status_group ~ ., data = data) %>% step_impute_median(all_numeric_predictors()

Randomizing within and across groups using group_by and sample

I'm running a study in which each participant will be presented with stimuli that have been randomized at two different levels: blocks (3 unique blocks) and tri

How do I fix this error for reticulate in Rstudio?

I searched Stack Overflow for fixes to this error and will put all the things that I have tried below that did not solve the issue. I have not had an issue on o

Add specific hovering behaviour to R plotly graphic

I am having troubles defining a specific behaviour when hovering an R Plotly graphic. Here is what I would like to do : I would like the full arrow to be respon

How to have a single download button for all datatables in R shiny webpage

I am working with a shiny app where it is desired to have a single downloadButton in the header of the application that downloads the data table present in the

fast partial match checking in R (or Python or Julia)

I have two dataset with names and I need to compare names in both datasets. I just need to keep the union of the two datasets based on the names. However, a nam

How would I create a subset by matching multiple patterns at a specific location in column names?

Sample code using dput: df <- structure(list (TCGA.OR.A5JP.01A = c(0.0980697379293791, NA, NA,0.883701102465278, 0.920634671107133),