how to filter for a vector within a data frame that contains some but not all...
I have a large data set that contains a lot of information about departure times of bus stops. I have a main data set that contains information regarding Trip_ID, Bus_sign as well as stop_ID. I further...
View ArticleRandom effect with gam() with betar family in R
I'm having trouble with my gam() analysis with betar family and the weird thing is that it worked perfectly before. After I restarted R, all kinds of error and warning messages showed up.I'm analysing...
View ArticleHow do I make a Faceted Scatterplot in R?
I'm quite new to R and I've been working at this problem for some time and could use some help. I have a CSV file (called cleaned_doc) which contains the rating and percent of a product sold per...
View ArticleHow to extract the name of a column from a data frame? Name to be used as...
I would like to copy the text of a data frame's column names one-by-one in a for loop. My code seems to return NULL values from the column name argument.More broadly, I want to create a summary by...
View ArticleUsing dplyr window functions to calculate percentiles
I have a working solution but am looking for a cleaner, more readable solution that perhaps takes advantage of some of the newer dplyr window functions.Using the mtcars dataset, if I want to look at...
View ArticleUse group mean to conduct one-sample t.test across multiple groups
I'm interested in how results may differ when means are compared by using a two sample t-test as opposed to a one sample t-test from the same data. Two assessments where "counts" are sampled randomly...
View ArticleTwo color gradients with geom_raster and geom_point
I have a pretty simple question but I've been struggling to find answers online.I have a heatmap made with ggplot + geom_raster. I want to insert a symbol inside each rectangle, so they can convey...
View ArticleCompare dates in R if I only have the month and year
I am given a data frame where one of the column parameters is a year and month value (ex "2019-05"). I need to only display rows where the date value is later than a certain value. For instance, if I...
View Articleleft_join based on closest LAT_LON in R
I am trying to find the ID of the closest LAT_LON in a data-frame with reference to my original data-frame. I have already figured this out by merging both data-frames on a unique identifier and the...
View Articleperforming mathematical functions across a data_frame
I have the following df. I would like to group by ID and do Fy=(Fyb+Fya)/2 for every column that ends with charts. If any of the two values is NA, an NA output would do.DATAdf <- structure(list(ID =...
View ArticleHow can I calculate the duration of a column, grouping by another column...
I have a dataframe, df, with the following data: ID DateTime A 12/13/2019 6:35:48PM A 12/13/2019 6:35:49PM A 12/13/2019 6:35:50PM B 12/13/2019 7:00:00PM B 12/13/2019 7:00:05PM C 12/13/2019 8:00:05PM...
View ArticleRaster: Extract center of raster images (geoTIFF) and draw its borders
I've like to extract coordinates (and create a data frame) of the center of 4 raster sub-images in geoTIFF and draw the border of 2 selected sub-images, originally split in the r2 image, for this I...
View ArticleHow can I use an R Shiny action button to run a R script
I have an R script that performs ETL process and pushes the data to a MySQl database. I want a button in my shiny app to run this script (on click of a button) and update push the updated data to the...
View ArticleHow to to show hour term when only minutes and seconds is known in a dataframe?
I have a dataframe, dfstr(df) 'data.frame': 1577 obs. of 2 variables: $ DATE: Date, format: "2016-02-01""2016-02-01" ... $ TIME: Factor w/ 1577 levels "00:01.3","00:01.7",..: 448 449 450 451 453 454...
View ArticleHow to extract the name of a column from a data frame to be used in the loop?
I would like to copy the text of a data frame's column names one-by-one in a for loop. My code seems to return NULL values from the column name argument.More broadly, I want to create a summary by...
View ArticleAdd page numbers to pdf using pagedown::chrome_print (R package)?
I am using pagedown::chrome_print() to convert slidy presentations created with Rmarkdown to pdf -- it does a better job than saving as PDF from Chrome. However, despite studying the help file, I...
View ArticleUsing an if statement in apply in R for every value in a data frame
I have a data frame that I created using the read_excel function and then duplicated it. I'm going to explain it as if I was using Excel, because it's so easy to do this in Excel. I want to check if...
View ArticleHow to determine if the value for a variable is the same in a different row...
I would like to determine if the value for a variable is the same in multiple rows for the same id variable. The dataset currently looks like: id score date within_year 1 2 01/20/2016 NA 1 2 04/30/2016...
View ArticleFind the closest value for a certain year in R
I have this type of data:iso3year UHC cata10 AFG 2010 0.3551409 NA AFG 2011 0.3496452 NA AFG 2012 0.3468012 NA AFG 2013 0.3567721 14.631331 AFG 2014 0.3647436 NA AFG 2015 0.3717983 NA AFG 2016...
View Articlebeginner question: trying to subset the column names in my dataframe in R
I want the column names 2 through 9, and 18 through 25 and i tried: colnames(df)[2:9,18:25] but it returns error of incorrect dimensions, how would i do this in a simple manner?
View Article