Category "r"

How to calculate difference in month in dbplyr (R and sql)

I tried to calculate the difference between dates in months for a huge database, using dbplyr package which sends my codes to the sql query. I tried different w

Trouble modifying reactive dataframe in Shiny

I'm working on an app which takes up a CSV via reactiveFileReader and applies some functions. I would like to modify the contents of the data before applying th

How can I extract the numbers from this string?

The question I'm asking is in string1: string1 <- "We have to extract these numbers 12, 47, 48 The integers numbers are also interesting: 189 2036 314 \',\'

Dates error NAs are not allowed in subscripted assignments

Consider the following dataset. It concerns the final date of the unemployment spell, but for now it can simply be seen as changing an enddate when certain char

Insert group-final time measurement from last observation to set limit

This dataframe: df <- structure(list(Subject = c("A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B"), Timestamp = c("00:00:00.146 - 00:00:

How to make expand_limits dynamic in a pyramid chart?

I want to make a population pyramid chart to display differences of age and gender among different jobs in the DF i have (small sample below). I want to make th

cumsum with a condition to restart in R

I have this dataset containing multiple columns. I want to use cumsum() on a column conditioning the sum on another column. That is when X happens I want the su

Problem with adding labels using tm_text function within tmap

I have created a great map using the code below but got a problem with labels. The labels overlaps with each other and become unreadable. How can I fix this? My

Putting data into specific row order in R

I have inherited a mess of a table which looks a little like this: A1 B1 C1 V1 B1 0/1 C1 0/0 A1 1/1 V2 C1 0/1 A1 0/0 B1 0/1 V3 B1 0/0 NA A1 0/1 e

Combine multiple histograms ggplot

I have several character variables with the same dimensions of outcome that I would like to compare. I am able to create a hsitogram for each of these variables

Draw histogram between cluster via R

This is dataset with my variables for analysis. clys<-structure(list(session_price = c(18824.7664, 35584.4106, 21084.4035, 9907.5856, 30806.5486, 15788.1279

Creating axis gap in histograms

I'm trying to create a gap in a histogram between 0.6 and 1 (on the y axis) but don't really know how to go about this. The gap.barplot solution does not seem t

I want to replace dplyr style, but I don't know how to do it in R

I want to replace this code into dplyr style. financials[is.na(ForecastEarningsPerShare), ForecastEarningsPerShare := ForecastEarningsPerShare2] Could you tell

Perform T test on DE genes pathologies in R

I have this: subset_1 <- degs[degs$pathol=='fibrosis'&degs$value==1,] mean_1 <- mean(subset_1$logFC) sd_1 <- sd(subset_1$logFC) tsub_1 <- t.test

Add a title and description to leaflet map

I have attempted to create a leaflet map of the birthplaces of NHL players. However, I would like to add a title and/or a description in the map. I have attempt

Tracking observations across different datasets (e.g. sub-reddits)

I have three datasets from three different sub-reddits, and my goal is 1-to check how many users are active in df1 (i.e. a sub-reddit), active in df2, and/or df

How to plot coefficients with robust standard errors?

I have this LSDV model using the "lm()" function and adding the country dummy variables minus the intercept. Then I made robust standard errors in order to fix

Average a multiple number of rows for every column, multiple times

Here I have a snippet of my dataset. The rows indicate different days of the year. The Substations represent individuals, there are over 500 individuals. The 1

plotting means in a horizontal bar with a vertical line

ID score1 score 2 score 3 score 4 1 200 300 400 -200 2 250 -310 -470 -200 3 210 400 480 -200 4 220 -10 -400 -200 5 150 -50 400 -200 I am new to R, I want to m

plotting means in a horizontal bar with a vertical line

ID score1 score 2 score 3 score 4 1 200 300 400 -200 2 250 -310 -470 -200 3 210 400 480 -200 4 220 -10 -400 -200 5 150 -50 400 -200 I am new to R, I want to m