Skip to main content

R Language Collective

Questions

Browse questions with relevant R Language tags

516,266 questions

0 votes
0 answers
16 views

Download satellite data using http::GET but the files are incomplete

I'm trying to download lots of satellite data from a government website. When I download each file individually, by manually clicking the download button on the site, the files are about 13 MB each. ...
Jonathan Thayn's user avatar
0 votes
1 answer
18 views

How to adjust Fable forecast .mean before autoplot?

I have been following the fpp3 textbook and using packages: fpp3, tidyverse. I have a Fable forecast, but would like to make manual modifications to the .mean. This is easily done by accessing those ...
dolphingang's user avatar
0 votes
0 answers
15 views

Pairwise T-test for Welch's F ANOVA

I need help with pairwise comparison following Welch's F test. For your convenience, my minimal example is drawn from the example given in the R documentation. df <- ToothGrowth df$dose <- as....
Tyrone's user avatar
  • 143
1 vote
1 answer
41 views

how to use pivot functions in R with no proper column names

I have a fairly unconventional list of dataframes, each of which is essentially comprised of about six smaller data frames. Here is a toy example of one of the dataframes in the list: structure(list(....
jvalenti's user avatar
  • 662
3 votes
1 answer
31 views

How to overlay a shapefile on leaflet minimap

Can anyone help me with this? I am trying to overlay a shapefile on the minimap using leaflet (addMiniMap). My code is below. The small sample shapefile can be downloaded from here: https://login....
Salvador's user avatar
  • 1,751
1 vote
1 answer
45 views

Create a string from data in a dataframe column in R

I have a dataset which I am trying to validate. I created a column that contains the written rules for what to check for each row and would like to use paste0 to concatenate the data in that column ...
user30397791's user avatar
-2 votes
0 answers
37 views

How do I resolve object not found problems in R code [closed]

Hello I am trying to define my variables but R cannot find them. I want to do polynomial regression with more than one independent variable. First I wanted to define them as x1 and x2 but R cannot ...
user30494055's user avatar
-1 votes
0 answers
29 views

Query about DSEq2 package in R

I'm facing a problem to construct a DESeqDataSetFromMatrix data object. The code was dds <- DESeqDataSetFromMatrix ( + countData = counts_data, + colData = col_data, + design = ~dex + ) # Error in ...
MD.RAIHAN AHMED's user avatar
0 votes
1 answer
64 views

Why does `tapply` give a different result depending on the parameter of FUN

I am working on data analysis and came across the following. Given a triplet data frame, consisting of indices i, j and value v, create a matrix m[i, j] = v. A matrix element can have multiple values. ...
clp's user avatar
  • 1,592
3 votes
1 answer
29 views

How to dynamically change the width of a bslib sidebar using an input?

I'm trying to implement a dynamic user controlled sidebar width into an app that uses a bslib page_navbar layout with multiple nav_panels. Each nav_panel has a layout_sidebar. I want the user to ...
Helbisch's user avatar
4 votes
1 answer
57 views

How can I set "cr" as the default basis type in mgcv::gam instead of "tp"?

I'm using the mgcv package in R to build generalized additive models (GAMs), and I often use cubic regression splines (cr) instead of the default thin plate regression splines (tp) (mainly because cr ...
Tripartio's user avatar
  • 2,373
0 votes
0 answers
17 views

Repeated measures in RDA (aka "fixed" or "random" effects): why does Condition remove the contraints?

I'm running an RDA on a set of measures that have been taken in a landscape. For each landscape window, we've some parameters that describe the landscape there, and we've conducted, say, 10 measures ...
Jos's user avatar
  • 101
0 votes
0 answers
31 views

Customize flextable XML in Word documents using officer and flextable with new versions

I've extensively worked with older versions of the officer and flextable packages in R to create Word documents with tables. To achieve custom table formatting beyond the packages' default ...
TobiSonne's user avatar
  • 1,117
1 vote
0 answers
46 views

Extracting polar coordinates from contour image in R for GAMMS

I am working with thousands of contour images that I will later use in a GAMMS analysis, so the output has to be structured as such. I'm struggling finding a way to do this, I DO know how to do data ...
green_strings19's user avatar
2 votes
1 answer
60 views

How to find all near-matches between values in the same data frame column in R?

I have a data frame of phonetic transcriptions of words, and for each transcription, I need to find all the words with the same transcription but with "1.M", "1.N", and "1.NG&...
Ian Carpick's user avatar
1 vote
0 answers
41 views

How can I address unevenly spaced temporal autocorrelation in mgcv gam's? [closed]

Data preview and problem at hand Apologies in advance for a long post. I am a wildlife biologist trying to create a model for data collected from foraging seabirds. I have data from around 25 birds, ...
Taylor Azizeh's user avatar
3 votes
2 answers
84 views

Count string values and collapse/aggregate

I have the following data: aa <- data.frame( group = c("asdf", "asdf", "asdf", "asdf", "asdf", "asdf", "asdf", "asdf&...
JontroPothon's user avatar
2 votes
4 answers
87 views

How to functionalize base R function like `with()`?

I am trying to write a function that operates similarly to with() where the function has a data argument, and two other arguments that I would like evaluated in the context of the data frame. I ...
Daniel D. Sjoberg's user avatar
0 votes
1 answer
40 views

re-order factors on y axis of a gantt chart

I am trying to produce a Gantt chart with the locations on the y axis in alphabetical order but nothing I tried worked out. Here is the code: gantt <- read_excel("2025-05-07_gantt_chart.xlsx&...
Fiona's user avatar
  • 25
2 votes
0 answers
84 views

Results changed after updating R

I just finishing a manuscript and getting ready for publication. However, when I updated r from 4.4.2 to 4.5.0 today, I triple checked some results and got different numbers. I am running latent ...
Cloudberries's user avatar
0 votes
0 answers
37 views

Where are the x and y-axis when plotting with ggplot in rmarkdown? [duplicate]

I plot the following figure in rmarkdown with ggplot, however it appears without the x and y axis. Where is the issue? I provide the full code with the chunk setup: ```{r, fig.retina=3} Demand_total ...
José's user avatar
  • 215
3 votes
0 answers
50 views

Why does barplot() add space to x-axis margin even when par(mar=rep(0, 4))? [duplicate]

Base R plotting functions allow control of the plotting area through graphic parameters set with the par function. This allows for e.g. modifying or eliminating margins around the plot through the mar ...
jtatria's user avatar
  • 554
2 votes
1 answer
44 views

How can I increase arrow and edge thickness in plot() with method = "graph" from arulesViz in R?

I'm using the arules and arulesViz packages in R to generate and visualize association rules. When I use plot() with method = "graph", the arrows and edges in the graph are extremely thin ...
AtilaSol's user avatar
1 vote
1 answer
39 views

How to write multiple named sheets to excel workbook using openxlsx

I need to use the openxlsx library due to java issues at my institution. I have a list of dataframes called data_list that are simply named 1, 2, 3, etc. > data_list $`1` Count TaxID ...
aminards's user avatar
  • 457
3 votes
1 answer
59 views

Space when plotting world map shapefile from 'rnaturalearth' package in R

In R, when plotting a shapefile from 'rnaturalearth', I get white space above and below the map. How can I produce the map without it? world <- ne_countries(scale = "small", type="...
ClaireR's user avatar
  • 51
0 votes
1 answer
77 views

Create a two-way table in R base that displays concatenated game results between players

Objective To create a function in R {base} that produces a square matrix showing concatenated game results between players. The matrix should display the result of each pairwise match, concatenating ...
clp's user avatar
  • 1,592
0 votes
0 answers
43 views

R Package doesn't show dataset tooptip message

I'm developing a package that contains datasets, but I can't see the tooltip of each dataset, despite the fact it's well documented, the documentation is right but I can't see it. Here's a screenshot -...
Renzo's user avatar
  • 9
4 votes
3 answers
94 views

Obtaining random sample from all permutations

I have a vector of length 100 and I want to get a sample of certain size like 50, from all permutations of length 20 from elements of my original vector My attempt so far is to first to get all ...
Brian Smith's user avatar
  • 1,485
0 votes
0 answers
60 views

How do I combine three data frames with different columns and in R [duplicate]

I am trying to combine three datasets with different rows and columns, using Email as an identifier. I have just started using R so I am unable to figure out how to do this. I intend to have row-wise ...
Vrinda Khattar's user avatar
1 vote
5 answers
89 views

add suffix to colnames using a column from df in list of dataframes

I have a list of dataframes containing a column that has information and I would like to append to each of the column names in the respective dataframes. The dataframes are held in a list like so: set....
jvalenti's user avatar
  • 662
0 votes
0 answers
56 views

R script issue to extract the data from Google Search Console [closed]

#install.packages("searchConsoleR") #install.packages("RAdwords") #install.packages("googleAuthR") #install.packages("googlesheets") #install.packages("...
Sahil Thakur's user avatar
0 votes
0 answers
23 views

is there a way to do a repeated measures ANOVA with nested random effects in R? [migrated]

Basically the title. I know the anova_test() from the rstatix package can do repeated measures and does have an inclusion for error, but I'm not sure if I'm doing it correctly and I'm not including ...
Kitt's user avatar
  • 39
0 votes
0 answers
31 views

Slingshot: no NA values but still 'Error in if (!useNames) { : missing value where TRUE/FALSE needed'

I am trying to run slingshot on my snRNA-seq data, but I keep getting the following error: sce <- slingshot(sce, clusterLabels = sce$seurat_clusters, reducedDim = "UMAP") Error in if (!...
Toon Leroy's user avatar
1 vote
1 answer
74 views

Adding custom HTML before <div class="main-container">

I am using the includes options in R Markdown to add custom CSS and HTML to my document. My main goal is to add a banner to the top and a pretty background (not the one in the example) to the body of ...
Sobo's user avatar
  • 125
1 vote
1 answer
37 views

Color edge links in ggraph based on specific nodes

I am trying to generate a bipartite graph where I color specific links based on certain nodes (i.e., plant species names). So far, I have been able to color the nodes of interest, but not their ...
J. Lan's user avatar
  • 63
1 vote
2 answers
62 views

How do I check one column in R for a specific word and overwrite or return that word in another column? [closed]

Using R, I want to check the ManufShortName column and if there is the word 'BLANK', then I want to return the word 'BLANK' in another column named AnalysisNotesCode in the same row. If there is a ...
SharonP's user avatar
  • 35
0 votes
0 answers
27 views

Problem with foreach(). Why my simulation function works outside foreach()?

I have a 300-line script that defines the function sim(pars, n.sim). The problem is in my attempt to use more than one core of my laptop. I run my simulation, wrapping the right parameters like this: ...
Gianluca Sala's user avatar
0 votes
2 answers
68 views

How to split overlapping time intervals in R, assign precedence, and fill gaps with dummy events?

I’m working with machine events data in R, where each event has a start and end time, a unique event code, and a precedence level (ordered factor). Events may overlap, and I need to transform this ...
Rahul Premraj's user avatar
-3 votes
0 answers
34 views

Need Help Adding Visual Diff View for Text Changes in Shiny App [closed]

I'm currently working on a Shiny app that compares posts collected over time and highlights changes using Levenshtein distance. The code I've implemented calculates edit distances and uses diffChr() (...
user21081257's user avatar
0 votes
0 answers
42 views

Error message "A Google Drive quota has been exceeded" [closed]

I am getting this error A Google Drive quota has been exceeded in Google CoLab even though i have almost 1Tb of google drive storage. I tried to wait a day, but I am still getting this error. Can ...
ManUtd10's user avatar
0 votes
0 answers
54 views

Many-to-many relationship with unique rows - how does this happen? [closed]

I am trying to understand many-to-many relationships on a theoretical level, as my problem seems to occur due to my specific data frames, which are 90,000+ rows long and hard to duplicate here. I have ...
Autumn's user avatar
  • 23
0 votes
0 answers
37 views

ggplot2: use dynamic nudge_y with geom_text and facet_wrap for later converting with ggplotly()

I want to plot several time series against a benchmark using R. #Example: library(tidyverse) library(lubridate) # Define the date range date_range <- seq.Date(from = as_date("2025-01-01")...
C. Sebastian's user avatar
3 votes
2 answers
106 views

How can I count lines of code in an R package?

How can I count the lines of code in an R package? I have two possible types of input: The raw package code (my own package); I could point the function to the R folder that contains source code. The ...
Tripartio's user avatar
  • 2,373
3 votes
1 answer
72 views

Problems saving in 300 dpi using ggsave

I am having problems saving my plots in 300dpi. I have used a similar code before but now it is saving them in 96pdi Here is a sample code (doesn't matter what type of plot it save it at the same ...
Gabriel's user avatar
  • 73
2 votes
2 answers
47 views

Needing advice on linear regression and then replacing NA's with fitted values

I am quite new to the data analytics stuff and R/RStudio so I am in need of advice. I am doing a project and asked to do: for every variable that has missing value to run a linear regression model ...
petar's user avatar
  • 21
3 votes
2 answers
107 views

In R, does tapply preserve the row order in a dataframe?

In R I have a dataframe, minimal example like this: test <- data.frame(cat=rep(c("A", "B"), each=3), rank=c(1:3, 1:3), data1=5:10, data2=(1:6)^2) I am using a tapply on the ...
quarague's user avatar
  • 357
0 votes
1 answer
63 views

Zoom to selected province, add polylines from shapefiles, and highlight clicked marker

I'm building a Shiny app that visualizes rainfall data using a Leaflet map. Here's what I want to achieve: 1. Zoom to a Province When Selected When a province is selected from a dropdown, I want the ...
Rahmat Hidayat's user avatar
-4 votes
1 answer
59 views

Facet wrap in R for gglikert plot

i have a data frame in R with likert scale responses . Some questions are part of a broader theme. The partial data frame : df # A tibble: 264 × 3 Theme Question ...
Homer Jay Simpson's user avatar
0 votes
0 answers
45 views

Merging large datasets in R [closed]

For my MSc. thesis i am using R studio. The goal is for me to merge a couple (6) of relatively large datasets (min of 200.000 and max of 2mil rows). I have now been able to do so, however I think ...
Mirjam's user avatar
  • 11
0 votes
0 answers
38 views

Remove comma after sprintf statements when knitting to word [duplicate]

I am using sprintf statements for text output. person_trend <- function(data) { data %>% mutate( text = sprintf("The proportion of adults who %s %s %s between %d (%.1f%%) ...
user30468428's user avatar


15 30 50 per page
1
2 3 4 5
10326