Assesment of the sphericity with r
I have these data and I want to assess the sphericity as a condition to apply an ANOVA for repeated measures.EGPRE<-c(4, 6, 2, 6) EGPOST<-c(7, 3, 2, 6) EGRE<-c(6, 2, 1, 4) What test do I have...
View ArticleHow do I color edges and vertices in igraph?
I have a large data set that I want to represent with a network graph using igraph. I just don't understand how to get the colors right. My data is in this format:df <- data.frame(name = c("john",...
View Articleusing lag function to predict the next value in R
I'm trying to use the lag function on my dataset so I can do Neural Network analysis after it but im facing a problem with the output of the lag function the data-set contains 500 rows and 3 columns...
View ArticleR: Moving average length of time between two dates
I have a dataset of observations with start and end dates. I would like to calculate the moving average difference between the start and end dates. I've included an example dataset below....
View ArticleRmarkdown beamer: How to left justify the title page
How is it possible to align the title page of my Rmarkdown beamer presentation to the LEFT instead of the default center?Example , default is center:--- title: "Untitled" author: "S SS" date:...
View ArticleIs there a way to tell R to use sock5 for connecting to a remote PostgresDB?
I'm looking for the environment vars to make R use the following packages with a sock5 proxy.install.packages("RPostgres") library(DBI)Normally with http/https I can pass the http_proxy or https_proxy...
View ArticleR raster / rasterize creating GeoTIFF with Null Value "grid lines"
I am attempting the seemingly simple task of converting a .csv with lat, lon and population values into a .tif (raster).Here's my R code:geoName <- read.csv("/pathToData/geoName.csv") geoName_raster...
View ArticleChanging an specific numeric error in a given variable
I want to change all the zeros (0) and 36.1 in a given variable to another number.To give you a better picture, this is what i tried to do:transacciones_diarias$TIPO_CAMBIO_POOL <-...
View ArticleHow to apply the same function to several variables in R?
I know that similar questions have already been asked (e.g. Passing list element names as a variable to functions within lapply or R - iteratively apply a function of a list of variables), but I...
View ArticleHow do you specify the ca cert when connecting to RDS via R Postgres?
#https://cran.r-project.org/web/packages/RPostgres/README.html library(DBI) # Connect to a specific postgres database i.e. Heroku con <- dbConnect(RPostgres::Postgres(),dbname = 'DATABASE_NAME',...
View ArticleMoving rows to columns in R using identifier
I have a dataset in r with two columns of numerical data and one with an identifier. Some of the rows share the same identifier (i.e. they are the same individual), but contain different data. I want...
View ArticleFaster matrix multiplication by replacing a double loop
I have a dataframe which looks a bit as produced by the following code (but much larger)set.seed(10) mat <- matrix(rbinom(200, size=1, prob = .5), ncol = 10) In the columns are issues and 1...
View ArticleUse reactive data inside eventReactive
I am very new to Shiny and struggle to understand reactivity.Context : I want user to choose a name for a column, add this column to a reactive table and then edit this table. The table is reactive (it...
View ArticleSplit string on both sides of a number
Let's say we have strings like these:data X3Y X33U Y231Z I want to split data into three columns first.letter, number, last.letter, so in this case:first.letter number last.letter X 3 Y X 33 U Y 231 Z...
View ArticleGetting the top values by group
Here's a sample data frame:d <- data.frame( x = runif(90), grp = gl(3, 30) ) I want the subset of d containing the rows with the top 5 values of x for each value of grp.Using base-R, my approach...
View ArticleFinding the perfect parameter by fitting the Maximum Likelihood mle
I was wondering if someone could help me solve my problem. So I am looking to find the perfect fit for my function on my variables in my dataframe (see example below). With looking around I came upon...
View ArticleHow would I find the number of 1s that are connected by 6 or more 1s in a...
I have my attempt to find the number of 1s connected by 6 or more other 1s below...6_or_more <- function(x) { diff <- diff(x) == 0 (c(0,diff) + c(diff,0)) * x } mat <-matrix(rbinom(10 * 5, 1,...
View ArticlePurrr - conditionally mutate a column in a list of data frames when it exists
Consider the following list of data frames:library(tidyverse) df1 <- tibble( id = 1:5, A = LETTERS[1:5], B = letters[10:14] ) df2 <- tibble( id = 1:3, A = LETTERS[1:3], B = paste(LETTERS[1:3],...
View ArticleHow drop columns by CLASSES [duplicate]
This question already has an answer here:How to remove columns from a data.frame by data type? 1 answerI have the following data.frame:data_1 <- structure(list(Line = structure(1:4, .Label = c("K1",...
View ArticleDetermine the number of NA values in a column
I want to count the number of NA values in a data frame column. Say my data frame is called df, and the name of the column I am considering is col. The way I have come up with is following:...
View Article