Category "r"

PCA - All variables with same signal on PC1 coordinates

So, I am analyzing a dataset that consists of 160 observations and 20 variables and am performing a PCA. It is about patients affected by a disease and the vari

Communication between modules and looping through values to create several modules

Goal I have five expectations: Solution using modules Communication between modules Dynamic creation of modules local storage using shinyStore Export result in

Internal link between tabs to specific section in R Shiny app

I want to link to a specific content of another tabPanel within an R Shiny app. I've found plenty of advice on how to do the half part of it respectively: there

Perform row-wise operation in datatable with multiple elements

I have the following data table: library(data.table) set.seed(1) DT <- data.table(ind=1:100,x=sample(100),y=sample(100),group=c(rep("A",50),rep("B",50))) No

Problems with excessive white space in Quarto document

I have a Quarto (RMarkdown) document which is supposed to display a table showing task completion. The code works well but there is excessive white space displa

Rowbinding all combinations of two vectors for each variation in a third vector

I have data as follows: cat <- structure(c("east", "north", "south", "west"), .Dim = c(1L, 4L ), .Dimnames = list("categories", NULL)) down <- structure(c

How can I draw a similar graph with ggplot2 to find the difference between two works?

I am reading the book Text Mining with R: A Tidy Approach by Julia Silge & David Robinson to try to find the difference between two works, and not the three

Add additional labels from a DataFrame to a facet_grid with existing label

I have a set data that I need to add to levels of labels. One on a single chart within the facet grid, and one from a small dataframe with entries for for each

Why is updateTabsetPanel running last inside an observeEvent?

I am looking to: Insert UI elements Update UI elements Run a long calculation All after pressing one button. Example app: #EXAMPLE APP---- #Libraries---- librar

r Caret Package - GLM - ERROR In Ops.factor(y, 0.5) : ‘-’ not meaningful for factors

I have following simplified dataset as example: > str(one_year_before) 'data.frame': 3359 obs. of 3 variables: $ Default_status : Factor w/ 2

why ggplot and geom_tile create lines on the map?

Data: https://github.com/yuliaUU/data/blob/main/test.csv griddf <- read_csv("test.csv") create a map: world <- rnaturalearth::ne_countries(scale = "medi

How to solve a math sequence in R?

EDIT: I could not come up with a more precise question title but please let me know what better title I could use, thanks! I have a "basic" math problem that I

Create separate DF with data from original - remove original data at same time

I am trying to move test DF data to test2 DF data in one code chunk - Right now, I have this going as two separate code chunks - the top one creates the test2 d

Fill in missing variables of family relationship matrix

I have a dataframe of family relationships (parent, child, spouse, etc.) which is partially filled as per example below. I am trying to use R to fill in the mis

How do I deal with special characters like \^$.?*|+()[{ in my regex?

I want to match a regular expression special character, \^$.?*|+()[{. I tried: x <- "a[b" grepl("[", x) ## Error: invalid regular expression '[', reason 'M

How to subset text from a word docx AFTER a matching phrase

I would like to subset text from an original word docx ("original.docx") into a new word docx ("desired.docx"), AFTER the match of the phrase "Drop Text Before

Merging sheets (2) from multiple excel workbooks in one while using information from sheet (1)

I have 200 workbooks (1 per subject) with two sheets each. I was able to merge all sheets 1 and all sheets 2 in two separate data frames using the following scr

R : How loop a function creating named dataframes according to dataframes contained in a list passed in argument?

I made a function that takes a dataframe as argument, and creates two dataframes in output according to a threshold value of one of the columns. These 2 output

R Objects not in global environment in VS Code

I am trying to use VS Code to run R. When I open R terminal in VS Code, I cannot find R icon on the left most column. I created a .r file, loaded that into VS

R 4.2.0: write.table() "clipboard-1024" copies only columns name

I used write.table(mat, "clipboard-1024", sep="\t", row.names=FALSE) to copy from R to Excel in previous versions. After updating to 4.2.0 it copies columns nam