How do I make stacked bar chart in specific order in ggplot/R while...
I have a stacked bar chart with percentages explaining the reason someone left a bad review. Based on this SO answer, I have rigged my plot to be a single, stacked bar chart. However, I now want to...
View Articleempty name in directive 'import' in 'NAMESPACE' file
When trying to install my package from gitlab I am getting the error messageFehler in asChar(e[-1L]) : empty name in directive 'import' in 'NAMESPACE' fileresulting ininstallation of package ‘...’ had...
View ArticleUsing across() to apply Recode then rescale variables
I would like to first recode a value in a battery of questions and then rescale the results from 0 to 1. I read through here to learn how to apply sequential functions but my results are not...
View ArticleHow to take an average of 7 days for entire observations by ID (R)
I am receiving cow data and would like to make weekly averages, but not using dates.For example, I have days since calving (DIM) and I would like to average the daily observations into week...
View ArticleAre there alternative (other than XML library) ways to parse XML file in R?
There are reasons why I cannot use XML package. I have a code using XML library. However, is it possible somehow to rewrite the code for rows below # XML package and still get the same results?...
View ArticleSet Working Directory to Mac Smart Folder - R
Looking for a way to change my working directory in R to a Mac Smart Folder. Smart Folders are a way to consolidate files meeting a search criteria. For example: I have photos all over the place on my...
View Articledensity plots for psm balance diagnostics
I am trying to make a series of nice density plots to show balance for variables in a psm analysis.full_match <- matchit(buyout_flag ~ tsale + sfincs_avg + logprox + tenure + age +...
View ArticleAdd line segment to plot
I would like to add a line to my plot that indicates the mean:X1 <- rnorm(100)# Kernel density estimatesdensity_X1 <- density(X1)# Compute modemode_X1 <- density_X1$x[which.max(density_X1$y)];...
View ArticleIs it possible to use lqmm with a mira object?
I am using the package lqmm, to run a linear quantile mixed model on an imputed object of class "mira" from the package mice. I tried to make a reproducible...
View ArticleMultiple regressions with lag in R
I would like to perform multiple rolling regression for different variables. My data is structured as follows:Prices: Date Stock1 Stock2 Stock3 Stocki1990...2000 10000 1200 13000 9002001 90000 1300...
View ArticleHow to predict a glm using a function to go through different combination of...
For background, I asked this questions a couple of weeks ago: How to create a for loop to go through multiple year combinations for a glm in R?In summary, I have 7 years of data and am trying to create...
View ArticleRemove part of string after 3-digit number
I would like to substitute the strings in the list by cutting each string after the first 3-digit number.a <- c("MTH314PHY410","LB471LB472","PHY472CHM141")I would like for it to look something likea...
View ArticleCombining two dataframes with alternating column position
I have these two dataframes:df1 <- tibble(b = 1:4, a = 1:4, c = 1:4)df2 <- tibble(b_B = 1:4, a_A = 1:4, c_C = 1:4)> df1# A tibble: 4 x 3 b a c<int> <int> <int>1 1 1 12 2 2 23...
View ArticleHow can I check that two columns in one dataframe both match two columns in...
I have one dataframe A like this:name <- c("John", "Bill", "Amy", "Bill", "Mia") Present.ID <- c(12345, 678910, 12345, 8090100, 246810) A <- as.data.frame(cbind(name, Present.ID))And one...
View ArticleHow to plot age-depth model using Bchron in R when dates are far apart?
I'm trying to construct an age-depth model for a sediment core. The first 10 dates were determined using Pb210, the last date is from C14 dating.Data:dates <- tribble( ~sample_id, ~depth, ~age_BP,...
View ArticleEstimated averages of a glmm by the emmeans package
I am trying to plot the estimated means using a negative binomial random effects model with their respective confidence intervals, in which the data and the fit were defined as follows:d.AD <-...
View ArticleIdentify if a list of time series is equal to another list of time series
I have two list: list_1 and list_2 the elements of each one are timeseries. Time series en list_1 may or may not be in list_2. Time series in both list looks like this:2007-07-03 1270.90602007-07-04...
View ArticleSearch_tweets() (rtweet package) does not return all expected columns
I'm using the rtweet package and it's not returning the database with all columns with the search_tweets() function. The database has only 35 columns and no columns "screen_name" and...
View ArticleSelecting items from a dropdown menu with RSelenium
I am using the code snippet below to select an item from a dropdown menu but it's not working consistently:#OUTPUT TO Output <- remDr$findElement(using = 'id', value = 'ddlOutputType')...
View ArticleInterleave columns of two data frames
I have two identical data frames. Same column and row headings. One has correlations in it and one has p-values. I want to merge these two tables in an interleaved manner, so that the first column is...
View Article