510,137 questions
0
votes
0
answers
11
views
R package openxlsx and excel spill formulas
I'm using the R openxlsx to overwrite a single worksheet on an existing excel workbook. The only way I can figure out how to do that is to load the whole workbook as a workbook object remove the ...
0
votes
0
answers
18
views
Seeing something weird in Timezone in R
I'm seeing something weird in force_tz in R:
> TAB_CYCLE$cycle_start
"1901-01-01 UTC" "1990-01-01 UTC" NA NA NA NA
> ...
0
votes
1
answer
11
views
Problems with facet_* when nulls occur in multilayer rasters
When using tidyterra for multi-layer raster plotting, the facet_* function doesn't seem to work effectively when one of the layers has the null value “NA”. I'm not sure if this is a bug or if there is ...
-2
votes
0
answers
12
views
Aalen Aditive Hazard Normal Assumptions [closed]
I am using the Aalen's hazard model from the timereg package in R. I checked for proportional hazards with the Cox model, but this condition does not hold for my dataset. I have been searching for the ...
1
vote
1
answer
22
views
Why do gt tables render differently in Quarto compared to R Markdown, despite consistent settings?
I am planning to move from R Markdown to Quarto for parameterised reporting, but one appearance issue has prevented me from progressing further.
In R Markdown, the preview of a gt table looks ...
1
vote
1
answer
13
views
Does mediate() in r work with a multicategorical predictor?
My data is multilevel (multiple measures for each participant within each condition) with 3 conditions.
DV = continuous; Mediator = continuous; IV = categorical (with 3 conditions: control, condition ...
0
votes
1
answer
33
views
How to Handle Complementary Pairs of Rows and Fill Missing Values Based on Refernce Column?
I have a genetic dataset as shown below, which contains replicates (same genomic positions) in the column pos. I want to group the data by pos and fill missing cells within each group using ...
3
votes
2
answers
33
views
R: Assign column value based on range of values found in columns in another dataframe
For simplicity, in dataframe 1 I have 3 genes (a, b, and c) and their positions in the genome. For instance, gene "a" starts at position 1 (min) and ends at 2 (max). In dataframe 2, I have a ...
-3
votes
0
answers
24
views
Psychology Data Analysis [closed]
I am making a spaghetti plot (in r) for my current analysis project and was have 3 x values. (12, 18, and 24 months of age) I currently have a regression line that covers 12-24 months, but was ...
0
votes
0
answers
19
views
Change Axis Color on Soil Texture Triangle
I am using a soil texture triangle in ggplot from NRCS and am trying to make the axes gray instead of the green, red and blue but nothing works, any advice?
base = ggplot(data = USDA, aes(y=Clay, x=...
0
votes
0
answers
32
views
ggplot: adding regression line and CI when y axis is logged
here is my data:x is input values, y is predicted values using lm() model, upr and lwr are 95% CIs calculated from the lm() model
library(tidyverse)
library(scales)
library(cowplot)
library(ggpmisc)
...
0
votes
1
answer
26
views
Adding space between each category on the Y axis/each ribbon
I am using ggplot and geom_alluvium. I am close but wanted to ask if there is any way I can add space between the ribbons/alluvial on the Y axis.
ggplot(data = mydata, aes(x = Year, y = Category, ...
0
votes
0
answers
21
views
Crowded semplot in r
Any suggestions on how to implement the indicator_spread? I'm new to semplot. Basically, the first row of variables are obviously too close together.
p <- semPaths(model_out, whatLabels="est&...
0
votes
0
answers
18
views
Is there a way to plot the geometric mean of antibody titres with 95% CI in a dataset with multiple groups? [duplicate]
I am trying to plot before and after geometric mean titres with 95% CI in a dataset with multiple groups. My data looks like this:
id d0 d28 group
1 1:20 1:640 A
2 1:320 ...
0
votes
2
answers
30
views
ggplot scale_fill_stepsn color palette not respecting discrete color palette input
I'm plotting a heatmap for countries of the world based on number of publications for a research topic. The map is almost working, but the color bar won't behave... I want 0 values to be grey and ...
0
votes
0
answers
25
views
Internal Server Error with api calls in R
I have the following function in R to GET a response from Api calls from my website
get_results <- function(headers, experiment_id, ontology = "all") {
get_drugs_for_results <- ...
0
votes
0
answers
16
views
Shiny app not working when called as a module, but works when it is run independently
I have a bunch of different shiny apps saved in different scripts which I am trying to integrate in a single app.
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(...
1
vote
2
answers
46
views
Non-mutually exclusive race categories into mutually exclusive categories in R using Dplyr
I was interested in recoding non-mutually exclusive race categories into mutually exclusive race categories.
This post was helpful using baseR, but I was wondering if there was a tidy version to do it:...
1
vote
2
answers
51
views
Adding characters to a string of specific rows in R
I've seen many reproducible examples of both aspects of this, but can't quite get my head to work out how to apply concepts to real data!
I have a dataframe of 2 multiple columns, but the 2 of ...
0
votes
0
answers
7
views
"std::bad_alloc" error when trying to load microdata
I'm using "PNADcIBGE" package to download microdata from Brazillian national household research. But it always fails and shows me this error: std::bad_alloc.
The package has a function ...
0
votes
0
answers
22
views
R usmap package uncompressing
I am trying to use the USmap package in R for US mapping. I would use the maps package, but they don't include Alaska and Hawaii.
When I try to create a df from the usmap package - It results in a ...
0
votes
1
answer
65
views
Why %in% from R has this strange behaviour? [duplicate]
When creating the following code, the
seq1 <- seq(-1,0,0.1)
(-0.1) %in% seq1
I don't understand why the output for this result is FALSE, when
-0.1 %in% c(-0.2, -0.1)
return an output of TRUE
Do ...
0
votes
0
answers
11
views
Interpretation of dotted arrows and negative coefficient in PLS SEM - seminr package
I have obtained the following model. I am struggling to interpret the plot as I can't find an indication of how to interpret dotted lines and negative signs in front of beta and w coefficients.
enter ...
1
vote
1
answer
63
views
Why do people use parentheses surrounding functions and assignments in R? [duplicate]
Lately I've seen several of these instances:
(NCORES <- nb_cores())
Or:
(ldsc <- with(df_beta, snp_ldsc(ld, ld_size = nrow(map_ldref),
chi2 = (beta / beta_se)^2,
...
2
votes
0
answers
13
views
Update a single point of a series in an echarts4r proxy in R Shiny
The code below observes a numeric input and multiplies the value corresponding to the "A" category by this number. Then, the proxy clears the chart (otherwise, it would draw another series) ...
1
vote
0
answers
25
views
How to extract the coodinate origin in `coord_radial()`
I want to align two circular plot in ggplot2 (draw_ggcircle_list), but I cannot extract the coordinate origin (0, 0) of the coord_radial(). Now following two plots won't aligned by the x-axis (theta-...
2
votes
0
answers
20
views
R Reactable add prefix to column based on condition
I have a dataframe with two columns: Condition & Value.
Based on this dataframe I would like to create a reactable object.
The Value column should have a prefix.
It should be preceded by “Check” ...
2
votes
4
answers
51
views
R: Conditional suppression of values across multiple columns
I have a huge data. I like to suppress data across multiple columns by replacing any value less than 6 in each column with -1 such that if in a column, there is only one suppressed value, I want to ...
0
votes
0
answers
43
views
Problem passing SQL string from sqlQuery (RODBC) -- single quote appears to be added [closed]
I am trying to pass a SQL insert query from R to a SQL Server database.
query <- "INSERT INTO table1 SELECT * FROM table2 WHERE UPRN NOT IN (SELECT UPRN FROM table1 ) AND CHANGE_CODE = 'I'&...
0
votes
1
answer
56
views
In R: Manually change data and get corresponding R code
In R Studio (or somewhere else), is there the possibility to manually change entries in a data frame and then get the corresponding code of the changing steps for documentation?
I know the function ...
1
vote
0
answers
44
views
Modification of Random Forest Classifier [closed]
i am trying to change the functionality of a random forest classifier. While usually features are selected at random for each split, i want one specific feature to be evaluated at each split. I know ...
0
votes
1
answer
46
views
Group_by + summarize not working (Looks like a bug in the package dplyr)
My question is rather problematic since I know the code is completely fine. I leave you below what I am doing (very simple stuff):
Means_region <- data %>%
mutate(year_fctr = case_when(edate &...
0
votes
1
answer
17
views
Reset actionButton in module
I have a simple shiny mechanism question and I am not understanding why and how I could answer it.
I have an app where an observeEvent action is inside a module server. This server is associated to a ...
1
vote
1
answer
24
views
How to avoid repetition of reactive code?
My app takes multiple inputs (some fixed, some defined by the user) and produces multiple outputs using a long and complex reactive code. Outputs are stored in a list for convenient referencing.
Among ...
0
votes
0
answers
50
views
Is anyone having problem with the latest update of RStudio Version: 2024.12.0+467 [closed]
I have update the latest version of RStudio 2024.12.0+467 with R 4.4.2. However, when I update this many function haven't run well like import file. Is anyone having the same problem and how can I ...
0
votes
0
answers
7
views
Error-pgmm panel data model-Dynamic estimation
pgmm(log(NY.GDP.PCAP.KD) ~ lag(log(NY.GDP.PCAP.KD), 1) + log(SE.SEC.ENRR) +
log(Trade_to_GDP) + log_inflation_plus_1 + BX.KLT.DINV.WD.GD.ZS| lag(log(NY.GDP.PCAP.KD), 2:5),
data = merged_df,
...
1
vote
1
answer
18
views
Sales data aggregation in R
I have daily sales data for multiple products in three stores. It looks something like this:
item_id
store_id
category_id
dept_id
date
event_name
daiy_price
a
tx_1
food
1
2012/12/24
6
a
tx_1
food
...
0
votes
0
answers
28
views
MICE is not imputing any NAs in my dataset [closed]
I am trying to impute missing values in a dataset using the MICE package. The dataset contains both continuous and binary variables. There are also a couple of variables that I do not want to be ...
0
votes
1
answer
33
views
legendry and ggplot theme_guide Adjustment of height and width failure
It is valid to use the theme to adjust the legend.key.height height and legend.key.width width of the legend at the end.
library(tidyverse)
library(legendry)
library(terra)
m <- matrix(1:25, nrow=...
0
votes
0
answers
10
views
how to run R CMD javareconf in conda environments
on Ubuntu, I have two R versions on my system and use anaconda.
/anaconda/envs/mycondaenv/lib/R/bin/R # 4.4.2, the one I want to configure
/usr/bin/R # used when the default conda env is active
I am ...
2
votes
1
answer
27
views
How can I fix the labels and lines on this radial chart?
I'm trying to create something for my next presentation. It's about average waiting time for a line in a store. I'm using R and ggplot. This is the data and the code that I'm using.
## Data
Store = ...
1
vote
2
answers
64
views
Typos in R can lead to major errors without warning - how to mitigate this?
There are situations in R where a typo can go undetected, resulting in incorrect results without any error or warning. The program runs as if there was no issue, but the output is erroneous.
Is there ...
0
votes
0
answers
19
views
Stacking gtsummary flextable objects [duplicate]
I am attempting to create a single table by concatenating at least two gtsummary tbl_cross tables on the col variable. Once I create the tbl_cross tables, I then convert the tbl_cross objects to ...
0
votes
0
answers
27
views
R / Using pivot_longer in dplyr / I want the count values in my columns to be the number of rows after pivoting [duplicate]
Here is a mock dataset of a much larger dataset I am working with. I am trying to change to a longer format where I have more rows, and each row reflects an observation of a single mosquito.
# Package:...
1
vote
1
answer
43
views
Wrapper around deparse() and substitute()
I'm trying to write a function that would simply wrap around deparse() and substitute() like so:
get_name <- function(x) {
deparse(substitute(x))
}
The point of get_name() is to return the ...
0
votes
0
answers
20
views
R programming: Estimate 95% CI for absolute and relative changes with an interrupted time series as done in Zhang et al, 2009 [closed]
I am taking an online edX course on interrupted time series analysis that makes use of R and part of the course shows us how to derive predicted values from the gls model as well as get the absolute ...
0
votes
0
answers
9
views
T-Test to check if win/draw/loss results (home results) are independent from country/league where football games take place [migrated]
I need to verify if win/draw/loss results (home results) are independent from country/league where football games take place.
I have the following data table:
League win draw loss
...
0
votes
1
answer
39
views
renderPlot: select input from multiple columns in a dataframe
I am creating a shiny app that will display a histogram of all the projects that have been conducted in a particular place across a range of years. However, the data I am using has multiple columns ...
0
votes
1
answer
31
views
How do I get the text label on the leaf nodes for a hclust with ggraph?
I want to make a circular view of a hierarchical clustering with the ggraph package. With base R plotting the non-circular version is made simple enough:
hcity.D2 <- hclust(UScitiesD, "ward.D2&...
-3
votes
0
answers
99
views
Difference between R and C [closed]
I am new, so please be gentle.
I overheard my friends talking about programming and they were talking about C and R, so I was interested, since I like data and R, but C is still too scary for me.
One ...