Resampling Raster in Terra: Just resample, or aggregate before resampling?
I'm working with two rasters, both the same projection, but one is at a 4x higher resolution and with a different origin. I need to resample the high resolution raster to match the resolution of the...
View ArticleHow to give plotly both fill and colour aesthetics in a boxplot
Problem:I have a hierarchical set of data, where I want to generate a grouped boxplot. Colour by one variable and fill by another. This can easily be done in ggplot2 (example provided). But I am unable...
View ArticleGet position index of second highest value by row for selected columns
Below is a reproducible example with a test dataframe:ts<-structure(list(OP = c(1, 3, 5), x = c(0.405595375690609, 0.256223899079487, 0.0131878938991576), y = c(0.792096293298528,...
View ArticleIncrease distance between x axis ticks with discrete data and facets
I have the following dataset:structure(list(x = c(75, 77, 84, 73, 62, 74, 55, 20, 73, 89, 36, 49, 72, 92, 54, 76, 40, 40, 46, 85, 19, 25, 75, 16, 84, 58, 85, 26, 87, 20, 39, 61, 88, 89, 81, 73, 60, 87,...
View Articlewhat happened when `separate_wider_regex` in multiple match
I tested the following script, but it displays an error, what happened?I jut want save Y & 33 & N & A (Y33@N(A)) into four separate columns.library('tidyverse')tta <-...
View ArticleCreate Unevaluated Calls with Tidyverse Defusing Operators
Assume I have the following data structure:library(dplyr)d <- tibble(x = paste0("x", 1:3), op = c("f", "g", "h"), y = paste0("y", 1:3), res = paste0("z", 1:3))I want to create a new column cmd which...
View ArticleUnexpected output of dplyr::top_n
This is the expected output of dplyr::top_n !!To select Top 2> mtcars %>% dplyr::arrange(desc(mpg)) %>% dplyr::top_n(2, mpg) mpg cyl disp hp drat wt qsec vs am gear carbToyota Corolla 33.9 4...
View Articlerenv doesn't persist between RStudio sessions [closed]
I have an RStudio project that uses renv. I recently upgraded my core R version, and had to reinstall the packages from the original lockfile. Now each time I open the project I get this message:Using...
View ArticleIs there a way to use NTv2 data to enhance accuracy when transforming spatial...
I have large-scale airborne laser scanning data (*.laz format) which I need to transform from Gauss-Kruger (EPSG 31468) to UTM (EPSG 25832) reference systems. As I want to have the best possible...
View ArticleHow to create a list whose name depends on loop index in a for loop in R?
I would like to create several lists within a for loop and each list should include the loop index in its name. I need to do it because otherwise the list object is apparently too big (>20GB)...
View Article"incomplete final line found by readTableHeader" when using read.delim() on a...
I got this "incomplete final line found by readTableHeader" error message when using read.delim() to read in a tab-delimited text file. There are Traditional Chinese characters in the header and...
View ArticleMarkdown table to data frame in R
There are numerous ways to convert a data frame into a Markdown table.But how does one convert back to a dataframe, given a Markdown tableGiven a table of a form:Table Header | Second...
View ArticleHow do I hide the spinner of shinycssloaders::withSpinner after I have used...
I have a website with a non-constant amount of plots that I show/hide using shinyjs. I also want to have a spinner on the (visible) plots.Here is what I have created:library(shiny)library(ggplot2)ui...
View Articlehow to make lines between stack bar charts?
I have trouble making line between two paired stacked boxplot. Im comparing pre ->post cellular composition change, though hard to draw line between the plots. shown below is my current script. I...
View ArticleWrite mutliple mathematical symbols via bquote in R
I am having trouble placing more than one mathematical symbol via bquote in the scale_color_manual call of ggplot. As an example, I am trying to create a legend that has pvalues labeled and described...
View ArticleCreating ggplot2 map with overlapping features and configuring legend
I am creating a series of species range maps. In some cases, there will be overlapping features for species that occur in different seasons. So far, the best way I have found to represent this is with...
View ArticleBetter methods to identify and swap two values within a variable [closed]
I'm looking for a more efficient way to swap two values within a variable. In the dataframe, each respondent has a unique id.set.seed(1234)test <- data.frame( id = sample(1:10), value = 21:30)test...
View ArticleError in "across( )" when summing multiple columns in R
Using the following data:Distance <- data.frame( DAY = c("1", "2","3"),TEMP = c(25, 27, 26.5),C1Dist01 = c(1, 1, 1),C2Dist01 = c(1, 1, 0),C3Dist01 = c(1, 0,0),C4Dist01 = c(1, 0, 0))I am trying to...
View ArticleCan you please tell me how I get this value extraction in R to work? [closed]
I'm trying to extract sea ice concentration values for a points shapefile in R. I have a geotiff saved in a polar stereographic projection (geotiff from NSIDC). Apparently the geotiff reprojection to...
View ArticleEnabling Autocompletion and Help in Restricted R Environments for Exams under...
This question builds on a previous solution where a method was requested to restrict R functions for use in an exam: Restrict R functions for an exam.The accepted solution works very well. However, I...
View ArticleWhy won't my code produce a graph in R Markdown?
Relatively new R user here, so apologies if this is a silly question!I'm currently producing some bar charts for a uni assignment, using ggplot. I know the code is correct, as I've been able to produce...
View ArticleUsing ISO 8601 compatible LC_TIME throws error when starting R
I have Plasma desktop (Fedora 41 KDE spin) and have set en_SE.UTF8 in the settings for time format in order to have ISO 8601 dates and times.This is the output of locale:➜ localelocale: Cannot set...
View ArticleHow to add density plots for x and z axes in a tensor smooth plot?
I created this plot using tensor smooths..I would like to add a visualization of the data density along the x-axis and z-axis. Ideally, this could be done with either:A rug plot on the respective axes,...
View ArticleHow to accept accented characters in imported shapefile using terra?
I am importing some shapefiles that have bilingual (English/French) province and territory names, which include some accented characters. I want to keep these accented characters, but they are...
View ArticleAdding 1 to the last and second last numbers in my data
I have the following data to which I am trying to as 1 to the last section of numbers split by a -. My data is as follows;dat"4-3" "60-0 2-5" "10-1 3-2" "20-2 3-0" "3-0" "20-5 3-0"What I am trying to...
View ArticleCreate a conditionnal variable with existing and non-existing data
Attached data :id = c (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)vm = c("1", "2", "3", "4", "5", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",...
View ArticleAvoiding NAs in the output of dplyr
I have tried the following to turn my DATA into my Desired_output (reproducible code below). But as you can see, I get a bunch of NA in my output.Is there a way to obtain my...
View ArticleReplace multiple string values in dataframe with alternative strings
I have a large dataframe df1 with string values in multiple columns:df1 <- data.frame(col1 = rep(c("A", "B", "C"),3), col2 = rep(c("C", "A", "B"),3), col3 = 1:9) col1 col2 col31 A C 12 B A 23 C B 34...
View ArticleNo longer able to set up an rsDriver using Rselenium
It's been a few months since I used rSelenium but now what used to work doesn't. I updated both java and the rselenium package thinking that must be it.Here's my...
View ArticleR: how to split strings into three columns using tidyr
Here is how one column in my data looks like:dat <- data.frame(A = c("M24656811 M24677722 GREEN,SMITH34/M/B", "M24654999 DOE,JANE V37/F/W", "M24333107 DOE,JOHN24/M/B"))I'd like to split column A...
View Article