Stay up to date
We'll highlight new content in your collectives with a blue activity indicator on navigation items and posts.
Manage preferences
Questions
Browse questions with relevant R Language tags
513,923 questions
1
vote
0
answers
12
views
Efficiently standardize a large matrix in R with foreach/doParallel?
I need to standardize (subtract the mean and divide by the standard deviation) the columns of several large matrices in R (roughly 300,000 rows by 10,000-20,000 columns).
The process has been very ...
0
votes
0
answers
6
views
Issues in my script to analyze a list of stock ticker symbols
The purpose of this script is to gather basic information about all S&P listed stocks from Wikipedia. It then uses the get symbol to extract price data over time, calculates log.return over that ...
0
votes
0
answers
9
views
Error in system(cmd, intern = intern, ignore.stdout = ignore.stdout, ignore.stderr = ignore.stderr)
I am running an R script that uses cifti and am getting this error:
Error in system(cmd, intern = intern, ignore.stdout = ignore.stdout, ignore.stderr = ignore.stderr) :
error in running command
...
0
votes
0
answers
17
views
aggregation based upon multiple criteria and time range (R)
Ultimately, I want to aggregate the amount column in my data over modular groups that do not yet exist but that are the composite of two existing groups and a time difference dimension.
I have a ...
0
votes
0
answers
8
views
Which versions to install to make RandomFields, RandomFieldsUtils, rpy2 compatible?
I am hoping to install some packages that people no longer update.
I need RandomFields (https://cran.r-project.org/src/contrib/Archive/RandomFields/), RandomFieldsUtils (https://cran.r-project.org/src/...
0
votes
2
answers
25
views
Why is this part of my code not adding the new columns to my data frame?
I have 13 datasets that are in .XPT format called data2010, data2011, data2012.. data2022. These are the BRFSS datasets from the CDC website. I have been trying to add three new columns to each of my ...
0
votes
0
answers
19
views
Is there an R program that plot ROC curve nicely? [closed]
Is there any package that allows me to plot ROC curve like this? ?
The 0.95,0.9 are particular threshold values.
I tried the package verification with roc.plot(truth,v,xlab="FDR",ylab="...
1
vote
0
answers
31
views
How can I append duplicated groups of a dataset with changes to existing data in R efficiently?
I have data like this:
key_data <- data.frame(orig_letter=c("A","A","A","A","C","C","F","B","B","B&...
0
votes
0
answers
17
views
How to capture a legend event?
Is it possible to capture a legend activation / deactivation event of an echart using a shiny app?
mtcars |>
head() |>
tibble::rownames_to_column("model") |>
e_charts(model) |>...
1
vote
1
answer
12
views
leaflet() empty geometry Error Don't know how to get polygon data from object of class XY,GEOMETRYCOLLECTION,sfg
I was using the leaflet package in R, and I had this error (in the title) that took some time to track down. I could not find the exact error or solution posted, so I am posting.
I was using a ...
0
votes
1
answer
33
views
move inset plot legend
I have an inset plot with a legend that I want to be shown at the bottom of the overall figure. This legend isn't the same for the larger plot, since I added more layers to the inset plot. How can I ...
0
votes
0
answers
16
views
'Maximum call stack size exceeded' when using tsibble::fill_gaps() in a shinylive webr app
I am using shinylive (v0.2.0) to write a Shiny (v1.8.1.1) app to run in the browser (Safari v17.5, 19618.2.12.11.6) using webr. The app takes data where each row represents an event and counts the ...
1
vote
0
answers
31
views
Combine event binding and dynamic outputs in shiny
My Shiny app consists of selecting a set of parameters to generate outputs based on the corresponding data, where each parameter is dependent on the previous one to narrow down which data needs to be ...
0
votes
0
answers
39
views
Element does not exist in dataset when selected via selectInput
In the shiny app below I try to group by selected input but I get:
Caused by error in `all_of()`:
! Can't subset elements that don't exist.
✖ Element `abs_edu` doesn't exist.
This is my code:
library(...
0
votes
0
answers
38
views
Problem with dynamic linear model -> lagged variable explains 100% of my model [closed]
I created a regression model, which regresses a cycle component onto a lagged cycle component and various other variables.
It looks like this:
regoffice4 <- dynlm(
diff(diff(officecycle,1),1) ~ ...
0
votes
0
answers
42
views
Create a function that converts a dataframe into a format suitable for a treemap structure
I want to create a treemap for a dataframe using the Plotly package. For this purpose, I need to create a function that converts the dataframe into a format suitable for a treemap structure. On the ...
0
votes
0
answers
18
views
ggplot line plots are not showing up on proportional secondary axis
I am trying to plot a barplot, and overlay some plots onto it using a secondary axis. I am able to adjust the secondary axis to be proportional to the values but the line plots still seem be squished ...
0
votes
1
answer
19
views
How to adjust x axis in coefficient plot with sjPlot's plot_model when x value range is smaller than -1,1?
I'm plotting multiple regression coefficients with plot_model and the x axis is automatically set to -1,1 even though the possible range of my values is smaller, which makes the estimates hard to see ...
1
vote
1
answer
19
views
as.ggplot in dendextend does not leave enough room for leaf labels
I've been using ggplot2 for automated report generation, and had been using ggdendro for accompanying dendrograms. However, as ggdendro seem to no longer be actively supported and I encountered this ...
2
votes
2
answers
45
views
Ploting weekly data with base::plot with unique and evenly spaced labels
I am trying to create a simple scatter plot, so weeks on the x-axis and "cases" on the y with each indicated by a dot and note I can only use base R's plot(), no ggplot.
I have data with 156 ...
-1
votes
0
answers
10
views
Regression tree's predicted results interpretation for type = "vector" in R [closed]
I am using rpart to build a CART model (method = "anova") and predict.rpart with type = "vector to make a prediction. I understand that that way is building a regression tree, but I ...
-1
votes
2
answers
45
views
R, ggplot2 - time on x axis
In R I have a data frame with bid and ask prices for a single day. Here is an example:
TimeHM; Bid_Price1; Ask_Price1
08:12; 101; 102
08:13; 101; 102
08:14; 102; 104
...
17:05; 104; 105
So, each new ...
0
votes
0
answers
26
views
Indicator Species Analysis Long Run Time [closed]
I am using the indicspecies R package to run an indicator species analysis on a large dataset to see what species are indicators for 3 different regions over the years 2001 to 2021. My matrix is ~550 ...
0
votes
1
answer
34
views
R package: equation not rendered in helper files of function of html pages
I am building a package and an associated website (via Github Pages). Let say I have a function funX. In R, when I do ?funXI have some equations (using \eqn{} or \deqn{}) in the description files, and ...
-1
votes
1
answer
29
views
How to change the background color of a Datatable header using css?
My question is similar to this question, except that I would like to use a css rule in an external css file.
6
votes
2
answers
93
views
How to capture install.packages output in R with sink()?
I'd like to capture all output and errors when installing a packages. The steps when installing a package, however, do not seem to be captured by the sink() command. Here's an example:
A main.R file:
...
0
votes
0
answers
19
views
R shiny app - rendering is much slower when run on remote server compared to local server
I made an R shiny app which runs perfectly in my local browser on my local server, however the rendering is noticeably slower when I run the same app from my local browser on a remote server. A quick ...
3
votes
1
answer
39
views
Keep ggplot font size constant in different figure dimensions
I'm in a position that requires me to frequently change the dimensions of my plots via the fig.dim=c(...,...) option in each r chunk.
However, I have a problem that I haven't been able to solve yet.
...
0
votes
0
answers
23
views
Issue with Residual Plot Pattern after Fitting beta_family Model in glmmTMB
I'm working with proportion data and have tried several models to address issues of overdispersion and underdispersion. Initially, I used a binomial distribution model which showed overdispersion. ...
0
votes
0
answers
10
views
Grab the user details when a user authenticates an R shiny web app using Azure Active Directory
I am new to the concept of web apps deployed in Azure and related authentications.
I have an R Shiny app, hosted as an app service in Azure cloud using Docker containers. I have few Azure user groups ...
0
votes
0
answers
26
views
Merging PISA 2000 student file with ESCS index file [duplicate]
I am using PISA data from 2000, 2003 & 2018. I am using the ESCS index. For 2000, the ESCS index is not included in the student file and has to be merged with the student file. However, I load ...
0
votes
1
answer
39
views
Table disappearing if inputting special characters [closed]
I am using reactable with custom filtering and regular expression patterns, like in this example:
https://glin.github.io/reactable/articles/custom-filtering.html#regular-expression-pattern-filtering
...
0
votes
0
answers
11
views
Error when using diagnose function from glmmTMB
I'm using glmmTMB (version 1.1.9) to run a step selection analysis with the two-step approach suggested by Muff et al. 2020 (fitting a Poisson model specifying a stratum-specific fixed intercept) ...
1
vote
5
answers
90
views
How to count the total entries by group when they are comma-separated
I'm working with the League of Legends Champions dataset
name
tags
Aatrox
Fighter
Ahri
Mage,Assassin
Akali
Assassin
Akshan
Marksman,Assassin
Alistar
Tank,Support
And I was wondering how to ...
1
vote
1
answer
42
views
Creating a large number of columns in R tidyverse based on a comparison with a specific column
I have a dataset in R tidyverse and I want to create 192 columns based on comparison with the sp column, just like the mp_comp_1 column. How can I do this for 192 columns in tidyverse?
library(...
-1
votes
0
answers
57
views
Interpunct (middle dot) in R [closed]
What is the meaning of an interpunct (middle dot, https://en.wikipedia.org/wiki/Interpunct) in R?
After some troubleshooting with column names that were thought to be identical across dataframes but ...
1
vote
1
answer
20
views
How to Add Significance bars a Bar Plot that have percentage/logical data
I have a dataframe with a categorical variable and a few logical variables. I’ve created an example using the iris dataset:
# Create a new dataframe showing the percentage each variable that is ...
0
votes
0
answers
47
views
Why Does Native Pipe Operator |> Fail with Placeholder _ in R? [duplicate]
I am trying to compare the %>% with the native |>, but I am not too sure why sometimes it only works for %>%. Here is an example:
library(magrittr)
library(stringr)
# Create the sample ...
1
vote
2
answers
51
views
Pattern matching in a dataframe
I am having some trouble conducting pattern matching within a data frame. I am working with grepl function in R.
I have a data frame of 5 local districts in two years (2001 and 2002). I want to check ...
1
vote
6
answers
57
views
Divide one column to three add fill up missing numbers
That's a part of my data:
structure(list(Testa = c(-1L, -1L, -1L,
-1L, -1L, -1L, -1L, -1L), Pre = c(NaN, NaN, NaN,
...
0
votes
1
answer
17
views
How to validate multivariate linear model using split half analysis or cross validation? [closed]
I created a multivariate linear model and am wondering how I can validate the model? The samples are environmental samples and due to a few limitations I am not able to validate by collecting more ...
0
votes
1
answer
25
views
Trying to make a heatmap based on percentage values from zip code area [closed]
I've been trying to use the choroplethrZip package to do this based on a previous post, but my version of R will not support this package. I'm using the data set and code below, and believe I have it ...
0
votes
1
answer
17
views
Direct input elements in shinydashboard sidebar
I was wondering if I could modify the following shiny app and put the sliderInput into the sidebar section :
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "DB manager&...
0
votes
1
answer
16
views
Calculate the predicted probabilities for each class using rpart in R
I am new to use rpart to build CART models. I wonder if the following code is printing the predicted probabilities of each class value = 1 in predictions. And pred_class saves the predicted class (...
0
votes
1
answer
29
views
How to put a ggplot into a Word doc using Officer in R?
I am attempting to use bookmarks in Word to automatically place plots into a report.
I have already used "body_replace_flextable_at_bkm" to add flextables automatically, however I cannot ...
0
votes
1
answer
34
views
R Reference Class Add New Variable by Name
Consider the following R code :
MyClass <- setRefClass("MyClass",
fields = list(
),
methods = list(
initialize = function(x){
#give new attribute x
...
1
vote
3
answers
49
views
Filter function in Base R
I was curious about methods to return duplicate values in a vector, list, or array in R. Focusing on a vector, I defined the following:
myvec <- c('a', letters)
which duplicates the letter 'a' in ...
0
votes
0
answers
55
views
Dealing with duplicate rows when creating a visit column, cartesian multiplication
I'm having trouble with data transformation.
What I want to do is go from a data table that created Cartesian multiplications to one that is sorted by column of visit number.
The logic:
this is a ...
0
votes
1
answer
22
views
mlrMBO Error in validObject(model, complete = TRUE)
I'm trying to recreate the example from here using my data, but I'm getting an error
x <- structure(list(`1` = c(0L, 0L, 0L, 0L, 0L),
`2` = c(0L, 0L, 0L, 0L, 0L),
...
0
votes
1
answer
18
views
Extract stock market data from yahoo finance
I need to extract the symbols from the stocks that appear in this platform:
https://finance.yahoo.com/markets/stocks/most-active/?start=0&count=100
I'm using R to achieve the aforthmentioned using ...
Members can contribute articles
Simply submit a proposal, get it approved, and publish it.
See how the process works
Simply submit a proposal, get it approved, and publish it.
See how the process works