Category "r"

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

How to create columns from anothers columns?

I want to built a dataframe like df2 from df1, looking always for the name of the column where the value is closet to 0: Where clossets_1 - closer value to 0 of

R How can I substract date time rows from each other dependent on Participant ID?

Starting with disclaimers here: I am completely new to R and have already read other questions & answers here concerning similar topics but can't seem to fi

from one language to another : I currently have a program in R, but I need to convert it in Python

I am already familiar with the possibility to "call" some R functions from python, but what I'm looking for is a way to convert R code to Python code. I doubt t

How to adjust the ratio of my x axis in my line graph in r?

I am creating a line graph in R using ggplot2. So far the graph is looking fine (I am relatively new to all this), but I have run into an issue trying to adjust

dplyr: Replace multiple values based on condition in a selection of columns

I try to conditionally replace multiple values in a data frame. In the following data set, I want to replace in columns 3:5 all values of 2 by "X" and all value

When i use GetReportData from the Package ‘RGoogleAnalytics’, the data stop being fetched after sometime

When i use GetReportData from the Package ‘RGoogleAnalytics’, the data stop being fetched after sometime. E.g If the data to be fetched has 100,000

Is `RefManageR` the new `citr` package in R?

I konw that's kind of a meta question but here it is: Is RefManageR the new citr package in R? I am using citr since 1 year now and I just realized that it is n

How to find AR,MA,ARIMA.ARMA,SARIMA,SARMA of a time series data in r

library(readxl) export1 <- read_excel("C:/Users/Hazeeb/OneDrive/Desktop/data/export1.xlsx") View(export1) class(export1) #> [1] "tbl_df" "tbl"

Styling of Ms Word not working in R Markdown

Have tried styling MS Word document from the markdown but I don't seem to get it write. What could I not be doing right? Below is the code --- title: "Test Docu

Using dplyr and mutate to create new columns based on groups and last n rows

I have the following data frame as an example: match_id <- c("match_1", "match_1","match_1","match_2","match_2","match_2","match_3","match_3","match_3", "mat

How can I install tidyverse on Archlinux?

I'm running since a few days archlinux and installed R-Studio today. I'm not able to install the tidyverse packages. Error in library(tidyverse) : there is no p

In R - How do I plot the data from the row where the date=='"2020 Q1' to the last row of the dataframe?

example of the data: Date Inflation 2020 Q1 2 2020 Q2 2.1 2020 Q3 2 2020 Q4 2.1 I am using ggplot ggplot(CPI,aes(x=date,y=inflation,group=1))+geom_line() but

The values in a fviz_cluster figure do not correspond with the datapoints of the dataset

I have composed the following script for a clustered scatter plot with fviz_cluster. According to the plot, there are negative values for x and negative values

Number of items to replace is not a multiple of replacement length when using a for loop

First, I parsed the AAChange.refGene column from the variant_calls dataframe and then extract the Refseq ID, cDNA level change, and Protein level change informa

Overloading `[[<- ` leads to C stack usage error

Basically, this: `[[<-.my_env` = function(env, name, value) { base::`[[<-`(env, name, value) } e = new.env() class(e) = "my_env" e[["x"]] = 1 #> E