Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [dplyr]

Use this tag for questions relating to functions from the dplyr package, such as group_by, summarize, filter, and select.

0 votes
0 answers
8 views

aggregation based upon multiple criteria and time range (R)

Ultimately, I want to aggregate the amount column in my data over modular groups that do not yet exist but that are the composite of two existing groups and a time difference dimension. I have a ...
Grum's user avatar
  • 25
0 votes
2 answers
20 views

Why is this part of my code not adding the new columns to my data frame?

I have 13 datasets that are in .XPT format called data2010, data2011, data2012.. data2022. These are the BRFSS datasets from the CDC website. I have been trying to add three new columns to each of my ...
Jalinne's user avatar
0 votes
0 answers
18 views

ggplot line plots are not showing up on proportional secondary axis

I am trying to plot a barplot, and overlay some plots onto it using a secondary axis. I am able to adjust the secondary axis to be proportional to the values but the line plots still seem be squished ...
no_frills_30's user avatar
1 vote
5 answers
87 views

How to count the total entries by group when they are comma-separated

I'm working with the League of Legends Champions dataset name tags Aatrox Fighter Ahri Mage,Assassin Akali Assassin Akshan Marksman,Assassin Alistar Tank,Support And I was wondering how to ...
Hiram Méndez's user avatar
1 vote
1 answer
41 views

Creating a large number of columns in R tidyverse based on a comparison with a specific column

I have a dataset in R tidyverse and I want to create 192 columns based on comparison with the sp column, just like the mp_comp_1 column. How can I do this for 192 columns in tidyverse? library(...
Hamideh's user avatar
  • 697
1 vote
2 answers
51 views

Pattern matching in a dataframe

I am having some trouble conducting pattern matching within a data frame. I am working with grepl function in R. I have a data frame of 5 local districts in two years (2001 and 2002). I want to check ...
YouLocalRUser's user avatar
0 votes
0 answers
55 views

Dealing with duplicate rows when creating a visit column, cartesian multiplication

I'm having trouble with data transformation. What I want to do is go from a data table that created Cartesian multiplications to one that is sorted by column of visit number. The logic: this is a ...
Gal Or's user avatar
  • 1
0 votes
1 answer
31 views

R - Filter to only include grouped rows that contain all values in a vector

Goal: Find all dates where the only color present is blue or yellow If there are 2 colors then they BOTH need to be blue and yellow If there's one color then it can be either one In the example ...
Indescribled's user avatar
1 vote
1 answer
49 views

Create a conditional variable for incomplete data

Attached data: id = c (2, 2, 2, 2, 2, 2, 2, 2, 2, 2), vm = c("13", "14", "15", "16", "17", "19", "20", "21", "22&...
user25334460's user avatar
3 votes
2 answers
39 views

Remove only the rows failed a test inside a group where a row passed the test

Background: I am using R to help me figure out which entries in file A (expected names) map to which entries in file B (possible names). Unfortunately, file B has multiple entries with the same ID ...
David Robie's user avatar
1 vote
1 answer
38 views

Why do case_when() and if_else() appear to evaluate the wrong expression?

I am trying to process some messy date data from a .xlsx file. Some of the dates are pre-1900 because of typos during user entry. This results in Excel storing 1900 and onward dates as numbers and pre-...
Zach Bridgewater's user avatar
0 votes
1 answer
36 views

Using dplyr to keep values above certain threshold in correlation matrix [closed]

I am trying to keep all correlations in my correlation matrix that are above 0.7 or below -0.7. When I try using the filter_all function within dyplr, I'm always left with a data frame with 0 obs. ...
Sarah's user avatar
  • 463
0 votes
1 answer
21 views

How to group aggregate data based of latitude and longitude

I have 2 dataframes in R that both have this type of structure: Lon Lat Measurement 5 7 15 5 8 20 The numbers in the actual dataframes are different from this example but I don't think that should ...
s.eyal's user avatar
  • 33
0 votes
1 answer
25 views

Weighted mean per group with different weights per group using dplyr

I am attempting to modify my code below to a single pipeline using dplyr. I am calculating a weighted mean across two columns per year where each year has a different weighting. How can this been ...
te time's user avatar
  • 485
0 votes
1 answer
56 views

Issue with dplyr filter in R when attempting to filter based on probability

Question: Can you really reliably perform filtering based on a draw inside of the filter, or is it doomed to fail? Objective: Inside of dplyr::filter(), remove rows of type A (versicolor) if a random ...
David Robie's user avatar

15 30 50 per page
1
2 3 4 5
2483