R moving average between data frame variables
I am trying to find a solution but haven't, yet. I have a dataframe structured as follows: country City 2014 2015 2016 2017 2018 2019 France Paris 23 34 54 12 23 21 US NYC 1 2 2 12 95 54 I want to find...
View ArticlePassing multiple column names to "by" in a data.table function
I've read many posts on passing column names to a data.table function, but I did not see a post dealing with passing multiple variables to "by". I commonly use code like this to calculate summary...
View ArticleR: Sum each column, average cover value and relative average cover value
I have a dataframe that contains percent cover data of many plant species in several plots:Example sp1 sp2 sp3 sp4 PlotA 1 12 0 0 PlotB 0 3 5 0 PlotC 3 0 0 1 PlotD 0 6 0 0 PlotE 1 1 0 0 I would like to...
View ArticleWhat is the best way to treat labelled variables imported with haven?
I have about 15 SPSS election studies files saved as .sav files. My group and I will be recoding about 10 variables for each study to run some logistic regressions.I have used haven() to import all the...
View Articleget the real maxima from a set of local maxima in R
I posted this earlier but I think I wasn't too clear with my question so I am updating it and included the progress I made. I have a data where I obtained local maxima designated by a TRUE value in my...
View ArticleDifference between two dates in Months in R
I have a sample dataset as the one below:df= data.frame("Finish_Date"=c("10/2019", "07/2005", "09/2008"), "Recent_Date"="01/2020", stringsAsFactors = F) I need to create a new column and calculate the...
View ArticleDivide timeseries data by first value of each year
I'm working to figure out how to divide each value of each year in a multi-year time series of data by the first value of each year. A simple example is below: library(dplyr) library(lubridate) date...
View ArticleForvalues loop in R: how to loop through data frames in R with name stubs and...
I would like to loop through data frames in R (each with the same name stub and a different identifying number/index at the end of the name) to create new dataframes with different name stubs and the...
View ArticleFilter each dataframe in a list by a column value in R
I have a list of 18 dataframes all looking something akin to this: Gene ID HMMER Hotpep DIAMOND #ofTools actino_5_2__00070 GT20(2-473) GT20(5) GT20 3 actino_5_2__00270 CE1(65-331) - - 1...
View ArticleShinydashboard: Incorrect vertical rendering of items in tabbox
I am using shinydashboards tabboxes and having issues with the vertical alignment of fluidrows within the tabbox such that a button renders on top of my plot.The first tab in the tabbox contains a plot...
View Articlehow to save multiple columns in R as csv file?
I have a list of data frames "181", and i want to extract the 2nd column and save it in a csv file and label it, the labels for those 181 dfs are 0,1,2,3,4,5,6. The problem is i have different length...
View ArticleAdd upgraded legend to map ggplot
I have a MAP created with this code, and this file in MSEXCEL (LINK TO THE CORRESPONDING FILE): Add an upgraded legend to map ggplot:This map contains information about qualifications of languajes by...
View ArticleSplit double-columns into separate columns and merge same-named columns
This has been a tricky problem for which I am really excited to hear solutions. I have what I call "double-columns", i.e. columns of which the content can be split into two separate columns. This is my...
View Articledifferent alpha values per group in plot
I have the below data mean lower upper x cat 1 0.02298658 0.02001936 0.02629616 0 A 2 0.02299030 0.02002340 0.02629639 0 B 3 0.02299402 0.02002744 0.02629662 0 C 4 0.02299774 0.02003149 0.02629685 0 D...
View ArticleMaking a new column in R populated from another column, and conditional on...
I need to make a new column (col.4) that is populated with values from an existing column (col.2) chosen as a condition of the original neighboring column (col.1) and the same values in a new (longer)...
View ArticleSEM/CFA in R (lavaan): lv variances are negativ (higher-order model)
I'm trying to fit a higher order model with five correlated secondary order factors and 14 primary order factors, but I receive following warning in R using cfa() in lavaan package in R: lavaan...
View ArticlePyper: prediction returns None though the model works well in R
I am struggling with the following issue. I trained a model and loaded the trained model in R as follows:model <- readRDS("C://tests/my_model.rds") result <- predict(model, trainset, type =...
View ArticleCalculate age standardised rates by sub-group with confidence intervals in R
I have a dataframe which looks like this:df <- data.frame ( time = rep(c("2010", "2011", "2012", "2013", "2014"),4), age = rep(c("40-44", "45-49", "50-54", "55-59", "60-64"),4), weight = rep(c(0.38,...
View ArticleIs this a Potential code error or machine set up error? Not sure
I am working through section 19.2.3 of HOML/autoencoders.html and found an error message pop up.In section: 19.2.3 Visualizing the reconstruction, I found an error associated with the line:# Predict...
View ArticleBlack bar on Y-axis when using scale_x_log10
I’m working on a plot using ggplot2 where I have the data in bins, but I’m having some issues with the graphics. The issue is this: I wanted to add tick marks to the bottom of my x axis as I currently...
View Article