Questions tagged [dplyr]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
63 views

How to quickly create hundreds of binary variables from continuous

I have 342 continuous variables for proteins for which I would like to create a binary variable for a predetermined cut-off. E.g., if the continuous variable "HsCD00076570" has a value > ...
Jack Murphy's user avatar
0 votes
0 answers
18 views

Finding Weekly Inventory from Sold Date and Inventory Added Date

I am aggregating data by week and need to find the number of items in inventory for each week. I have the date sold(Contract Date) and the date the item was added ...
talkingtoducks's user avatar
0 votes
0 answers
51 views

Aggregating variables by two other variables in R using pivot_wider

I have data on cancer case counts in R that I would like to pivot from long to wide, such that a new count variable is created for each five-year age group within race/ethnicity groups. I have tried ...
Jack Murphy's user avatar
1 vote
0 answers
23 views

More efficient way to create frequency column based on different groupings

I have code below that calculates a frequency for each column element (respective to it's own column) and adds all five frequencies together in a column. The code works but is very slow and the ...
Curt's user avatar
  • 11
0 votes
0 answers
3k views

R error with filter: x comparison (1) is possible only for atomic and list types

I'm working through an error that I just can't seem to troubleshoot properly. I have a dataset from Stata that I'm working with in R. I have also converted it to a csv for my own different needs in ...
NB3's user avatar
  • 1
1 vote
1 answer
1k views

Flag consecutive dates by group

Below is an example of my data (Room and Date). I would like to generate variables Goal1 , <...
Mar355's user avatar
  • 37
0 votes
1 answer
391 views

How to add a column for descending row numbers into dataset in R

I am new to R and would like to insert a new column that numbers the row to a large dataset. I have no idea how to use 'mutate()' to insert this. Would appreciate ...
BioIsaac's user avatar
2 votes
1 answer
102 views

How to split data in R using dplyr if we want to have rows of the same group to belong to the same split?

In my current pipeline, I have sensed that there is data leakage. This is because the same person, though with slightly different values, is in both training and testing set. As a result, my model is ...
Dee's user avatar
  • 41
0 votes
1 answer
74 views

How to create a barplot using multiple column [closed]

My data is about boardgames which contain 1 to many catgeories each like this : ...
thoms's user avatar
  • 1
0 votes
1 answer
2k views

R: Rates of change from an initial value

I have a collection of csvs and must produce yearly rates of change per group within each csv, as well as a rate of change compared to the initial value. I am using the function below to calculate ...
Kota_K's user avatar
  • 35
1 vote
2 answers
4k views

Sort a data frame column based on another sorted column value in R

I have a data frame that is sorted based on one column (numeric column) to assign the rank. If this column value is zero then arrange the data frame based on another character column for those rows ...
Sddr's user avatar
  • 11
1 vote
1 answer
2k views

Find the mode value and frequency in R

I'm trying to come up with a function in R that gives the mode value of a column along with the number of times (or frequency) that the value occurs. I want it to exclude missing (or blank) values, ...
DataGuy23's user avatar
1 vote
1 answer
486 views

Group_by 2 variables and pivot_wider distribution based on 2 others

Performing some calculations on a dataframe and stuck trying to calculate a few percentages. Trying to append 3 additional columns added for %POS/NEG/NEU. E.g., the sum of amount col for all ...
DataGuy23's user avatar
1 vote
2 answers
272 views

R: Producing multiple plots (ggplot, geom_point) from a single CSV with multiple subcategories

I have a collection of bacteria data from approximately 140 monitoring locations in California. I would like to produce a scatterplot for each monitoring location with the Sampling Date on the Y-axis ...
Kota_K's user avatar
  • 35
1 vote
2 answers
2k views

Mutate with dynamic column names dplyr

Hi I have this dataset (It has many more columns) ...
3nomis's user avatar
  • 531
3 votes
1 answer
8k views

Weighted mean with summarise_at dplyr

I strictly need to use the summarise_at to compute a weighted mean, with weights based on the values of another column ...
3nomis's user avatar
  • 531
2 votes
2 answers
1k views

Divide a column by itself with mutate_at dplyr

Hi I'd like to turn each non zero value of my selected columns to a 1 using mutate_at() ...
3nomis's user avatar
  • 531
1 vote
4 answers
8k views

Mutate with custom function in R does not work

I have a data frame, containing a column called: "Frequency". Frequency has values like "Year", "Week", "Month" etc. Now I want to create a new column based on the Frequency column where Year's new ...
Nuibb's user avatar
  • 125
1 vote
2 answers
1k views

Theoretical Question: Data.table vs Data.frame with Big Data

I know that I can read in a very large csv file much faster with fread using the data.table ...
Bear's user avatar
  • 145
2 votes
3 answers
4k views

R summarise with condition

I have customer data with the products they purchased and the purchase date. I want to extract a result that shows each customer and the first two fruits they purchased. My actual set has 90000 ...
nut get's user avatar
  • 21
2 votes
0 answers
751 views

Group_by field is not showing in the summarise output in R

In R,using dplyr package, I tried the function "summarise" and I expect the result to show along with the groupby field. However, all of a sudden I see summarized output but without the groupby filed ...
snehal sharma's user avatar