Category "r"

How to safely shutdown mlflow ui?

After running mlflow ui on a remote server, I'm unable to reopen the mlflow ui again. A workaround is to kill all my processes in the server using pkill -u MyUs

Reshape wide data to panel format with multiple paired columns using tidyr

In a large survey, the data are encoded as (Respondent, question, year binary, question, year binary). As in: R Question1 | 2008 Bin. | Question2 | 2009

Is there a faster way to find synonyms for a large list of taxa in R?

I have a list of about ~96,000 species names I need to collect all synonyms for. I have tried the 'taxize' package with the synonyms() function, which outputs t

Stacked histograms with ggridges package in R

The following code produces histograms that overlap. How can I modify this code to make the histograms stack on top of each other? library(tidyverse) library(gg

Set the width of regulartable() when exported in word document

Im trying to export a dataframe to word using knitr and regulartable() but my table does not fit in the word page. --- title: "Correlation table" author: "mk" d

Using R to Calculate the time since binary output=1

I have binary data in a dataframe with a time feature and I'm looking to produce a dataframe like below with a new column "duration since =1". I was able to fi

Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, : invalid value 0 for 'digits' argument

When I submit priceR to R-hub, I see the following logs: ### ** Examples > > > format_currency("2423562534234", "$") Error in prettyNum(.Internal(for

How to sum email opt-in per customer per month

For my master thesis I try to sum the total opt-ins a customer has for all possible newsletters over-time (monthly). I fail in doing so. Dput() data to Replicat

RStudio hangs, won't start on Ubuntu 22.04LTS (R compiled from source)

Just another post about RStudio does not start. I'm using Ubuntu Linux 22.04LTS "jammy". Since the new R version (currently 4.2.0) wasn't available in the repos

kableExtra: Vertical alignment not working in PDF output with many columns

I would like to align all columns in a kableExtra table to the top. The valign = "top" option does not seem to solve the issue here. Also, the third column is

Reference Cell value assign in particular cell

Is it possible to get this output in R? =INDIRECT((CONCATENATE(V4, AH4)),TRUE)

R Shiny: downloadHandler - problem in content argument

I have a Shiny App and want to download a plot as png using a downloadButton and the command "downloadHandler". As you can see in the code below it should use i

How can I use magrittr pipe (%>%) in my package?

I am trying to create a package ("packagename") to host some custom R functions and R markdown templates. I am trying to use magrittr pipe in one of the functio

R: identifying cases where the row contains more than one character from a list

I'm working on a large dataset where I need to create a new column and assign appropriate labels. So for instance, I have rows containing a mixture of fruits an

R: How to randomly sample one value from each column and bootstrap

I have 18 columns and 100 rows, where columns stand for 18 students and rows stand for their grades in 100 exams. Here is what I want: for each student, I want

Vectorised argument for a function in R. The function gives out multiple data frames, whereas I'd like it to output only one

I'd like to compute trimmed mean for each trimming proportion alpha, and then see which trimming proportion gives the minimal variance of the trimmed means, whe

fastshap: Error in UseMethod("explain") : no applicable method for 'explain' applied to an object of class "xgb.Booster"

After fitting a xgboost model (model_n) I try to run the code below to obtain shap-values, where trainval is a dataframe with my traindata without the Y variabe

Concatenate strings with quotation marks separated by commas

I want to write a function that concatenates multiple strings into one one string, but each part is marked with quotation marks and separated by a comma. The fu

How to read multiple files with specific character or number using a loop in R

I have a directory with a bunch of .tif files like: tnt_xxx_2015.tif, tnt_xxx_2016.tif, tnt_xxx_2017.tif......tnt_xxx_2100.tif. 'tnt' is one of the variable nam

Unexpected behavior with n_distinct inside pipe

I am trying to use the n_distinct function from dplyr inside a pipe in a function and am finding it to be sensitive to my choice of syntax in a way I didn't exp