Quantcast
Channel: Active questions tagged r - Stack Overflow

Looking for a more efficient way to replace matrix elements

I have an RGB image and want to identify 'white pixels' or those which have a value of '255' in each channel. Next I'd like to replace all of those values with '0' to convert white pixels into black...

View Article


Image may be NSFW.
Clik here to view.

quarto bullet list under a list item

I have the following qmd file of bullet lists:---title: "lists"format: htmleditor: visual---# hellothis is my first sentance of lists:- my first list:```{r bulletlist1, echo = FALSE, eval = TRUE,...

View Article


Image may be NSFW.
Clik here to view.

Dissimilarities within the group in the package vegan

I am working with abundance data from oceanographic campaigns and I am starting to work with the data using the vegan package.I know that with the simper function, you can calculate the intra-groups...

View Article

is there a way to set the "base margin" for XgBoost in the MLR framework?

I am trying to fit an XgBoost model within the MLR framework. While the framework is fairly well documented, there are some specifics of the XgBoost library that I cannot replicate within MLR, one in...

View Article

Image may be NSFW.
Clik here to view.

control y-axis title positions when combining several plots with patchwork...

I would like to be able to control the y-axis title position for each plot with respect to the y-axis itself, so that when I input differing antibiotic name lengths into the top plot, the y-axis title...

View Article


R error on start-up 4:52 unrecognised escape in character string [closed]

I've recently come across the following error on start-up and it's preventing running background jobs. It comes up in the terminal / and RGuI / RStudio on start-up.I recently tried installing...

View Article

Image may be NSFW.
Clik here to view.

How to display only two values from several in legend label in ggplot...

I want to display only 2 values from the legend - "A:C9" and "G:C9" and remove the rest (B-F, H, I). Here is my code for the plot. Thanks for helping in advance.ggplot(data, aes(x=AVISITN, y=CHG,...

View Article

Image may be NSFW.
Clik here to view.

kableExtra html table: pack_rows() ignores  

I am rendering an html document in Quarto (engine: knitr). I have added some trailing whitespaces in a kableExtra table using " ". However, as soon as I add pack_rows() to the mix,...

View Article


Image may be NSFW.
Clik here to view.

Plotting multiple equations in R with equation labels, using ggplot2

I'm trying to plot multiple equations using geom_function() in ggplot2, and label them using equations formatted using latex2exp. The problem is that the order is not preserved when I use...

View Article


Image may be NSFW.
Clik here to view.

how to make a topoplot in R with coordinates variable distribution

I would like to adapt the example I have found in this page and readapt it to my data in order to get the final topoplot realized with ggplot2topoplot in ggplot2 – 2D visualisation of e.g. EEG...

View Article

Using rep() to create a sequence when the rows in data frame are not...

I am trying to add some vales into my data frame using rep() to split the data in 2, although my issue here is that the rows in my data are not divisible my my each argument.Here is some data I am...

View Article

The function dplyr mutate does not to apply a function stored in one of the...

I have a data.table object which contains 3 columns (spec_fun, param_1, param_2). I wanted to use mutate to create a new column based on the result of the 3 mentioned columns but I got the error "Error...

View Article

BVAR (Bayesian VAR), Minnesota prior, tuning [closed]

I have been trying to understand more about the BVAR model in R, and I haven´t been successful. I am trying to implement an expanding-window backtesting with fine tuning of hyperparameters. In BVAR,...

View Article


View docstring in google colaboratory

How can I view the docstring or documentation of a function in Google Colab using keyboard shortcut as in shift+tab in Jupyter Notebook?I have tried ctrl + shift + tab and ctrl + space and none of it...

View Article

Image may be NSFW.
Clik here to view.

Using stat_binhex() with ggpairs()

I would like to use the stat_binhex() statistic from ggplot2 with the ggpairs() function (GGally R package). For example, I would like to use stat_binhex() in this plot instead of geom_point(). Is that...

View Article


How to plot a ROC curve for a SVM model in R

I have trained and tested a model using the following codelibrary(e1071)library(readxl)library(caret)class1.svm.model <- svm(Class ~ ., data = class1.trainset,cost=20,...

View Article

R classification tree with Rpart

I have some data which I would like to segment.My first thought was classification tree in R from Rpart package.My training data consists of many explanatory variables and one 0-1 response variable...

View Article


Has anyone managed to install ggpubr in the Docker container rocker/r-base?...

I am new to Docker, but I am trying to install ggpubr and ggplot2 in rocker/r-base container and I cannot install ggpubr. I believe it may be an issue with the dependencies possibly although I have...

View Article

Efficiently running parallelized functions that export large objects to nodes...

I am trying to see if there is a good/better way to run simulations that take large objects as input in parallel in R that cuts down on the time it takes sending large files to and from cpus. My...

View Article

Image may be NSFW.
Clik here to view.

Transparent plot background in Jupyter Notebook with R kernel - How to set...

Issue Description:When generating R plots in Jupyter Notebooks (.ipynb files), the plot backgrounds appear transparent by default, making visualizations hard to read. This issue:❌ Occurs in Jupyter...

View Article

How to get simulated network from siena07 output?

Is there a way to subset simulated network in matrix form from Rsiena07() function output?According to R's documentation, simulated networks are stored as edgelist in sims"If returnDeps=TRUE: list of...

View Article


R: Error in x[[jj]][iseq]

I am trying to run a geographically weighted random forest classification using the function SpatialML::rgf(). However, I am encountering the following error:'Error in x[[jj]][iseq] <- vjj :...

View Article


Image may be NSFW.
Clik here to view.

Conditionally overwrite cell text with gt::gt()

With {gt}, you can conditionally style cells based on the values in another column in your dataframe. Is there a way to conditionally overwrite the cell display values based on a different column? In...

View Article

dplyr: order columns alphabetically in R

If I have a large DF (hundreds and hundreds) columns with different col_names randomly distributed alphabetically:df.x <- data.frame(2:11, 1:10, rnorm(10))colnames(df.x) <- c("ID", "string",...

View Article

Make: forked process died unexpectedly, exit code 0xC0000142 (Error 127)

During R package installation on Windows, make fails on the step of detecting gcc:> devtools::install('c:/Temp/REddyProc-1.3.3')── R CMD build ─────────────────────────────────────────────✔ checking...

View Article


Mean separation (Post hocktest)

I had a simple GLM with covariate.Model<-lm(DBH~Tree species+ age, data=data)anova(Model)...gives a significant resultHow ever when I try to do the post hoc test, I couldn't separate means.I had 5...

View Article

Using arsenal function tableby to create multiple columns and adding specific...

I'd like to point out, that this is my second week into coding so it's all new to me.I've tried to search for answers to my questions, but have failed so far, so I thought I'd try and ask on here. I...

View Article

Replace the last non NA entry of a row with the value from another column

I have a dataset like this: tdf <- data.frame( A = c(1, 2, 5, 4), B = c(NA, 3, 4, 5), C = c(NA, NA, NA, NA), D = c(NA, NA, NA, NA), E = c(10, 20, 30, 40))And I need to replace the last non NA value...

View Article

UPDATED: Microsoft365R and SharePoint - Can you search all document libraries...

UPDATED: I made a bit of progress but now I am stuck with an error due to a drive name being used twice with two different drive ids. They are different folders. I don't have the authority to change...

View Article



Remove unwanted graticule lines on globe with geom_sf()

The following code creates graticule lines for the opposite side of the earth. How can I suppress just those lines, but not all graticules?library(tmap)library(sf)library(dplyr)library(ggplot2)world.sf...

View Article