Category "r"

Replace values in a dataframe based on lookup table

I am having some trouble replacing values in a dataframe. I would like to replace values based on a separate table. Below is an example of what I am trying to d

How to display statistical significance and the mean score using ggstatsplot

I have the following R code: ##Installe the package install.packages("ggstatsplot") library(ggstatsplot) ## Create data df <- data.frame(replicate(2,sample(

How to left join two data frames conditionally - by rows that fall within a date range - and by two variables found in each data frame

I have two simulated data frames: d, created below, which has all the rows of longitudinal data for two different people. Each row has a start and end date. Som

Get dput data assigned to variable

When I try to assign dput to object, it assigns and then prints the values below. It should ne happen.It should just pass to the object get_ls <- dput(head(i

Coerce R matrix to dgTMatrix inside a function

Given a matrix object in R, it's easy to coerce it to a sparse matrix in triplet format: library(Matrix) m <- matrix(rbinom(100,1,0.5),10,10) m <- as(1*m,

how to add density line over real count value (maybe with 2 y-axis)

I would like to plot a density plot over counts histogram using following sample data: However my density line was not readable in my plot. if I use ..ncount..,

Missing list entry in loop causes ggplot2 and patchwork failure

I am trying to write a script that will generate violin plots with seurat for single cell sequencing data. I am looking for cell type clusters. Seurat makes a

What kind of object i get with input$checkboxGroupInput in shiny?

I want to do a TA dashboard in shiny and i wish to plot each indicator checked from the checkboxGroupInput the problem is when using input$my_checkboxGroupInput

Indexing dataframe within a loop

I'ld like to extract specific data from a log-data. In R it looks like that Data Frame I need values from Data$Time of the cases, where Data$Data_Type == "DATA"

Make a list out of frequencies, concatenating categories to that list

I am trying to adapt this solution, by onyambu: New data dat_in_new <- structure(list(rn = c("Type_A", "Type_B" ), `[0,25) east` = c(1269L, 85L), `[0,25)

Why are "--slave" and "--no-restore" being used by commandArgs when I call my R file with Rscript

I am running an R script using Rscript from the command line (linux) like this: Rscript myscript.R inputfile1.csv inputfile.csv integerArg My command args are

How to join two very large dataframes together with same columns?

I have two datasets that look like this: df1: Date City State Quantity 2019-01 Chicago IL 35 2019-01 Orlando FL 322 ... .... ... ... 2021-07 Chicago IL 334 202

Unable to create a for loop to convert multiple varialbe into as.factor

I am trying to write a for loop in r to convert multiple variables with similar character pattern in r to as.factor. Below is the function I wrote, R runs the c

R plot graph for data coordinates not showing up

I have a set of data coordinates I'm trying to show on Rstudio.The issue starts when I try to run the plot function for a dataframe since that format does not s

LabVIEW generated Excel files unable to be read by pandas.read_excel

I'm having an issue when I save LabVIEW outputs as .xlsx files. When I try to import with Pandas I get the following error: expected <class 'openpyxl.styles.

lrtest() not working: posthoc testing for multinomial with vglm() not working with lrtest()

I am running a multinomial analysis with vglm(). It all works, but then I try to follow the instructions from the following website (https://rcompanion.org/hand

match rownames and colnames of correlation matrix

I have a vector with 3990 names (these are the column names of my dataframe) and I want to match them with the rows of my data. My data contains correlation val

Create new column based on presence/absence of string in other column by group

I have this dataset about vessels locations, where the same "id" can correspond to two levels. Corresponds to a defined category, such as "fishing" and may also

Sequence with stopping values

This is like a regular tribonacci sequence, however, I want the sequence to stop whenever the term is at the min or max value. This is what I have started seque

Comparing Dates Across Multiple Variables

I'm attempting to figure out the amount of days in between games and if that has an impact on wins/losses, this is the information I'm starting with: schedule: