Check for occurence in both categories
I have a dataset with two columns source and id. I want to check which of the ids in the id column are present in both categories of the column source.Here is an example:dd <- read.table(text="...
View ArticleCreating a correlation matrix from a corpus in R
I have a large corpus and I would like to create a correlation matrix for all the terms in the entire corpus. I can find correlations for any given word in the corpus using the following code:...
View ArticleShiny app CSS: overflow-x: hidden and tooltip z-index not working
I have a div with smaller hoverable divs inside which each have tooltips. I have a lot of these smaller divs so I applied a max-height and overflow-y:scroll - but this creates unwanted overflow-x...
View ArticleHow to count a change of sign (positive or negative) in vector
I am currently working with daily, relative snow cover values (per km2) in a large dataset of rougly 40 k km2 over 20 years and would like to get the days at which the snow cover increases within a...
View ArticleKeep values until the first record
Using this example:dframe1 <- structure(list(id = c(1L, 1L, 1L, 2L, 2L), name = c("Google", "Yahoo", "Amazon", "Amazon", "Google"), date = c("2008-11-01", "2008-11-01", "2008-11-04", "2008-11-01",...
View ArticleReplacing variable values using newly dated version of the variable [duplicate]
This question already has an answer here:Replacing NAs with latest non-NA value 15 answersI am trying to replace update values for x, q, z using the recently available version of the variable indexed...
View ArticleChanging the format of a weird data frame
I have a csv file that contains a really weird table that I want to format in a proper way.The Background: Students are able to answer questions on an online platform. The questions are labeled Test1,...
View ArticleCheck which rows in a data.table are identical
I need a solution that shows me which rows are identical but I can't find a clever solution (a solution without a bunch of complex loops). I would prefer a data.table solution. What I want to have is a...
View ArticleLoop over list of partial variable names in R
Absolute n00b here... moving over from Stata (where this would be easy):I've got a dataset relating to a list of drugs, "alcohol", "cannabis", "tobacco", "mdma", "cocaine", "amphetamine", "lsd", etc.....
View ArticleCan't convert a `spec_tbl_df/tbl_df/tbl/data.frame` object to function
This question is probably about magrittr but I am not sure. If I pipe data (%>%) into the next function it goes to the first argument as far as I understand. I have this example dataset (df) and...
View ArticleGenerating multiple graphs/plots from uploaded files in Shiny
I'm new to Shiny (worked with R for a few months) and i'm trying to figure out what a 'Shiny' way of handling multiple uploaded files is.My goal is to have an interface where the user can upload...
View ArticleHow to select MySQL version when installing RMySQL in linux
I am running an R application in a Docker container and would like to connect to a MySQL 8 database using the RMySQL library. I can connect to the database from the container using the mysql terminal...
View ArticleSequence x-Axis labels when when 'breaks' has already been defined (R, ggplot)
I used scale() function on my data to avoid high correlation when doing a mixed model. Now I want the original values to appear in my plot. So I reversed the scaling with x * attr(x, 'scaled:scale') +...
View Articleggplot - bar plot with overlaid line graph - grouping, stat_summary
I've seen this question answered a few times, but can't seem to solve it using the advice on the various posts I've found. I have a sample data set attached (dput output at bottom). I'm trying this...
View ArticleWhat is the meaning of the "+" symbol in [A-Z]+? [duplicate]
This question already has an answer here:Regex plus vs star difference? 9 answersWhat is the meaning of [A-Z]+? I know [A-Z] selects all uppercase characters from A to Z, but I don't know what the "+"...
View ArticleHow to replace NA value with previous non NA value given to same ID
I'm working in R and am using data.table. I have a data set that looks like this:ID country_id weight 1 BGD 56 1 NA 57 1 NA 63 2 SA 12 2 NA 53 2 SA 54 If the value in country_id is NA I need to replace...
View ArticleHow to get rows with specific condition?
I have a data set as I've shown below:data <- tribble( ~cat_id, ~clicks, ~price, "1", NA, 1.2, "1", T, 1.4, "1", F, 2.2, "2", F, 2.2, "2", T, 1.5, "2", NA, 1.6, "3", T, 1.7, "3", F, 1.9, "4", F,...
View ArticleConditional cbind() on dates
Assume we have 2 dataframes of 2 cols and 6 rows each and we want to cbind both only when date on the left(lhs) is older than date on the right(rhs), at the same time making sure that each row has no...
View ArticleSelects the row in the data frame that contains a specific value
I have a data.frame like list.1,I want to select the row from list.1, which contain the value of c(101,102,103,104), to create a new data.frame list.2.list.1# ID col1 col2 col3 #1 1 101 102 201 #2 2...
View ArticleR github package w/ devtools: warning unknown macro '\item'
I made a package with the help of RStudio & devtools for namespace, DESCRIPTION & Roxygen2 for the man pages. This worked fine, and the help pages I've recently added worked too. I decided to...
View Article