Questions tagged [summarize]

A dplyr instruction ( actually named summarise( ) ) to create a new data frame by grouping data according to given grouping variables. Use this tag along with the dplyr version being used. Mind the spelling in the method name.

summarise() creates a new data frame. It will have one (or more) rows for each combination of grouping variables; if there are no grouping variables, the output will have a single row (or more, as of 1.0.0) summarising all observations in the input. It will contain one column for each grouping variable and one column for each of the summary statistics that you have specified.

836 questions
-1
votes
1 answer

dplyr grouped sum returning wrong value

I incurred in a weird error I could not find a solution for. I already checked several related post here on stack overflow, but they are not really addressing the issue I am facing here. I am trying to create grouped summation from logical vectors.…
Filippo Santi
  • 109
  • 1
  • 8
-1
votes
3 answers

min and max for specific rows in a column

X Y 1: 2 1.973203 2: 2 1.985226 3: 2 1.988916 4: 2 1.998701 5: 2 1.998701 6: 5 4.726402 7: 5 4.854796 8: …
Zohaib
  • 11
  • 3
-1
votes
2 answers

Trying to create a loop for applying this function

In itself the function works, but I am trying to loop through all the columns in the data, I know using ~apply() works and would love your help on using this thanks. library(scales) factorVars <- select_if(df, is.factor) ## function to tidy up to…
-1
votes
1 answer

How to save temporary object within dplyr summarize so that multiple summary functions can refer to it?

I am using dplyr to summarize a dataframe that contains many groups. The original data is density data over time for populations of organisms. For instance (where dots denote many more rows of…
-1
votes
3 answers

Group by function query

Hi guys i am new to R, While i have attached screenshot of the df i am working with (https://i.stack.imgur.com/CUz4l.png), here is a short description I have a data frame with a total of 7 columns, one of which is a month column,…
Iqbal S
  • 1
  • 2
-1
votes
1 answer

Count occurrence in one variable based on another when having duplicated values

I know there are so many threats answering similar questions to mine but none of the answers out there are specific enough to what I want to obtain. I've got the following dataset: I want to count the number of patients (found in "Var_name") that…
-1
votes
1 answer

R dplyr::summarize groups by user defined functions

I have a data.frame with three varibles (genes, samples,copy_number) which i want to make summary statistics of copy_number grouped by gene names. I tried using the summarise function in dplyr but keeps failing. I want number of samples with…
sahuno
  • 321
  • 1
  • 8
-1
votes
2 answers

Add variable with summarise but keep all other variables in R

I have a dataset with donations made to different politicians where each row is a specific donation. donor.sector <- c(sector A, sector B, sector X, sector A, sector B) total <- c(100, 100, 150, 125, 500) year <- c(2006, 2006, 2007, 2007,…
AntVal
  • 583
  • 3
  • 18
-1
votes
1 answer

How to sum values from multiple rows of a variable linked by household ID

I have the following tibble (but in reality with many more rows): it is called education_tibble library(tidyverse) education_tibble <- tibble( ghousecode = c(1011027, 1011017, 1011021, 1011019, 1011025, 1011017, 1011016,…
-1
votes
2 answers

R: Calculating mean from a different column, keeping duplicate values

Using this code from my dataset I was able to separate out each specific ICD10Code for each PatientId: data.code<-data.1 %>% group_by(ICD10Code,PatientId) %>% summarise(ReferralSource=first(ReferralSource), NextAppt=first(NextAppt),…
Brandon
  • 89
  • 2
  • 9
-1
votes
1 answer

Calculate counts and averages by group for various columns in a dataset

I am trying to summarize a dataset. I am looking to produce a table with counts and averages all in one. Example data: df <- data.frame( "Species" = c("A","B","C","D","A","B","C","D"), "Location" = c("A","B","C","B","A","D","D","E"), …
cgxytf
  • 421
  • 4
  • 11
-1
votes
1 answer

Grouping data with missing value

I need to compare questions of two different surveys (t1, t2). Therefore, I have two dataframes like those below: t1 t2 x x x y y z z w y z x x z y z w w x z v This…
h96
  • 1
-1
votes
1 answer

how to parallelize custom lstm (4d input)

After permute layer, dimensions become (None, None, 12, 16) I want to summarize last two dimensions with a LSTM(48 units) with input_shape(12, 16) so that overall dimension becomes (None, None, 48) Currently I have a workaround with custom…
Ceday
  • 1
  • 2
-1
votes
1 answer

Linux bash - Loop though files and summary up a value in that files

how would you do that Loop through files based on a pattern Extract a value from within that files (value is always there and a number) Summarize all these values echo the sum out Many thanks in advance and greetings
-1
votes
1 answer

Summarizing dataframe string values to count in Python 3

in the screenshot below you'll find a dataframe that contains string values in each cell. What i would like to do is to create a new dataframe out of this one that contains 3 columns: 'Very interested' 'Somewhat interested', and 'Not interested'. I…
Miguel 2488
  • 1,410
  • 1
  • 20
  • 41