Category "r"

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

How to make a pie() chart larger in R without it cutting off?

I am currently trying to make a pie chart with the pie() function in base R. How can I make it bigger? I have tried radius = 1.2, but this ends up cutting the c

C-Stack usage is too close to limit - not due to recursive code

I have an intruiging question, and I can not seem to find the answer. I have a specific python function, which runs a sql script, gets the data and transforms i

Using setDT inside a function

I'm writing a function that, among other things, coerces the input into a data.table. library(data.table) df <- data.frame(id = 1:10) f <- function(df){

PCA in R: Error in svd(x, nu=0, nv=k) : Infinite or missing values in 'x'

My dataframe contains about 26k rows with 129 variables. I've made sure all of the variables are numeric and do not have any NA values (used na.omit). Using the

Downscaling sentinel-2 bands to 10m using R language

I'm trying to calculate NDRE using sentinel-2 bands in R language. The formula for NDRE = (nir-re)/(nir+re)nir- Near InfraRed (Band8) re - RedEdge (Band5) My C

Linear graphics

I have a dataset in this way: maximum <- c(10) #for each time minim <- c(2) #for each time Quantity c(4, 2, 10, 2, 10, 6, 2) How can I structure my datas

How do I use regex to match a substring before/after the colon?

I want to split info into Refseq ID, cDNA level change and Protein level change, where Refseq ID represents the substring from the start to the first colon :, c

How do I create a list containing new data frames from an existing data frame?

I have a csv file containing 5 columns, 225 rows containing my data. The columns pertain to the experiments' Subject_ID, treatment (9 types), replicate(5), time

data.table foverlaps with as.yearmon wrong result

I am trying to use foverlaps from the data.table package. When I use it together with as.yearmon I get wrong results. Here is a small example: library(data.tabl

Dynamic `case_when` that allows for different number of conditions and conditions itself

I'm looking for a dynamic way to specify some "condition parameters" and then feed that to a case_when operation or something else if better suited for that pro

Getting word count of doc/docx files in R

I have a stream of doc/docx documents that I need to get the word count of. The procedure so far is to manually open the document and write down the word count

How to change tickmode for all subplots of facet_grid

I want to change the tickmode of all xaxis/yaxis in all subplots to "auto" but the number of subplots changes. I tried the following code. It works for the firs

Convert Canadian Postal Code to Longitude and Latitude

I have a list of 100 Canadian postal codes (e.g. M4B 1C7). Is there anyway to convert these postal codes into approximate longitude and latitude values? Current

package from Bioconductor has a dependency from CRAN that requires version of R that is not compatible

A particular situation we've encountered is when we try to install a specific R package version from Bioconductor. Dependencies of this package may not be pinne