Category "r"

Checking the normality assumption of a linear mixed effects model

I have the following code for an LME: IDRTlme <- lme(Score ~ Group*Condition, random = ~1|ID, data=IDRT) I want to check the normality assumption, and so I h

An R Loop to wrap text in multiple saved excel files

I have hundreds of excel files with a single column and a single sheet containing text. I am trying to write a loop that will 'Wrap Text' and align the single c

Why doesn't R dplyr arrange sort properly using a vector element within a for loop

I'm having trouble getting r's dplyr::arrange() to sort properly when used in a for loop. I found many posts discussing this issue (like ex.1 with the .by_grou

Merging data frames by selecting for correct value

I have a data frame called "ref" that contains information that allows mapping of gene entrez ID to the gene's start and end positions. I have another data fram

Is there an R function to convert 'flowFrame' structure of 'flowCore' package to a 'data.frame'?

Objective: To view .fcs data as a dataframe using R language. Flow Cytometry data comes in .fcs file format. The file is read in the flowFrame structure produce

What is the python equivalent for names() function in R

I have a code in R, where in the data frame "inputdata" there are multiple columns, and we are replacing the word "new" with "old" in the entire data frame: nam

How to return a reactive dataframe from within a shiny module that depends on a button click?

Aim: Return a reactive dataframe object from within the module named "modApplyAssumpServer" Problem: I am getting an endless loop. Even if I wrap everything wi

Create different xlsx sheet header colors in R

I would like to have different header colors for the xlsx sheet I'm creating. However, I'm only able to create a single color for the header with the below code

Removing nested variables if there are NAs in certain variables inside the nested variable

I have a dataframe that looks something like this: df <- data.frame(gvkey = c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6), date = c(01,02,03,01,02,03,01,02,03,01,0

Specifying fill color independent of mapping aesthetics in boxplot (R ggplot)

I have a lot of categorical variables that are going into a single graph, which is split on a particular status. Something like this, but with many more groups

In R, transform a vector with repeated values to a vector of single ordered values including the repetitions?

I have a vector x <- c(5, 5, 5, 3, 2, 2, 5, 5, 2). I need to get a new vector with the ordered distinct (but duplicates allowed) values: y <- c(5, 3, 2, 5

Joining two datasets by (non-uniform) names

I need to join two datasets and the only identifier in both are the company names. For example: db1 <- tibble( Company = c('Bombardier Inc.','Honeywell Dev

How can I apply the decile cuts from one dataframe to another using R

I have a dataframe (df1) and have calculated the deciles for each row using the following: #create a function to calculate the deciles decilefun <- function(

Do you have recommendations for printing tables based on analysis using lm_robust (OLS with clustered standard errors) and cjoint (AMCE-analysis)?

I have encountered some problems with printing my regressions in R with two different analysis. Usually I would use the stargazer to print the table and/or hand

Set a time varying variable to its initial value in a dataframe

I have this dataframe, which I have data for US's states population for different time periods, I want to set the population of every state to its initial value

Cosine similarity between rows of two large dataframes in R

I've two dataframes DF1 and DF2. One of them is a very large DF. I've created examples DF1 and 2 like this: library(tidyverse) A<-rep(c('Mavs', 'Spurs', 'La

Mean calculation between dataframes in list in R

I have a list of dataframes that all have the same format (same number of rows, same number of columns and columns have the same name). I would like to create a

How to read CSV file in R without losing data?

I'm importing CSV file to Rstudio. I use this command df <- read.csv("C:/Users/Ibad/Desktop/corona.csv") But I see there are many missing(NA) values in Rstu

reorder bar plot by fill in R

How to set this plot in ascending order? many thanks in advance. library(ggplot2) library(reshape2) iris2 <- melt(iris, id.vars="Species"); iris2 ggplot(da

How to add pooled standard error in tbl_summary() and eta effect size?

I am trying to include Pooled Standard Error (PSE) and Eta square to tbl_summary(). PSE is calculated by sqrt(mean(residuals^2)/n), I tried to calculate step by