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
0
votes
2 answers

Elegant way to merge data frames in R?

I would like to take the unique rows of a data frame and then join it with another row of attributes. I'd then like to be able to count up the number of varieties, e.g. the number of unique fruits of a particular type or origin. The first data frame…
setbackademic
  • 143
  • 3
  • 11
0
votes
1 answer

function applied to summarise + group_by doesn't work correctly

I extract my data fluo <- read.csv("data/ctd_SOMLIT.csv", sep=";", stringsAsFactors=FALSE) I display in three columns : the day, the month and the year based on the original date : Y - m - d fluo$day <- day(as.POSIXlt(fluo$DATE, format =…
Loulou
  • 703
  • 5
  • 17
0
votes
0 answers

How to summarize child group by parent group summation using dplyr in r

I have generated data as follows: Group Detail Value Count Count_Avg A P 1.25 2 0.63 A K 0.5 1 0.50 A Y 0.25 1 0.25 B D 0.75 2 0.38 B G 33.5 18 1.86 B …
Austin Overman
  • 163
  • 2
  • 9
0
votes
0 answers

Sum and relates tables DAX

I do have a table(1) containing the cost and the Project number, line number and item number and would like to get the cost summarized in another table(2) in a new column where im having the project number and project line also. The second table…
Jan Boldt
  • 135
  • 10
0
votes
1 answer

Group, Summarize and transpose in one step

I have a dataframe that looks like this Vehicle Model Month Sales A XXY 1 10 A XXY 1 100 A XXY 2 40 A XXY 3 10 A YYX 3 10 A YYX 3 33 B ZZZ 1 …
Elly
  • 129
  • 2
  • 12
0
votes
1 answer

crystal reports count instance by group then sum

My subreport has groupings on Account ID then Invoice No. Within the Account ID I could have several Invoice No's. For example: Account 1234 Invoice 6789 Invoice 5432 Invoice 5432 Invoice 9999 What I want is count of invoices. Using the…
crystalnoob
  • 27
  • 1
  • 8
0
votes
0 answers

How to eliminate warning message when summarizing date based on max(Date)

I am trying to summarize dates by ID based on the max() of ExitDate. When I run the following code, however, I receive this message: In max.default(structure(NA_real_, class = "Date"), na.rm = TRUE) : no non-missing arguments to max; returning…
-1
votes
0 answers

How to recode combined ethnicity variables into single ones

I ran this code to get the breakdown of ethnicities in my sample: dataset %>% group_by(ethnicity) %>% summarise(percent = 100 * n()/nrow(datset)) However, because subjects were able to select multiple ethnicity categories on their…
-1
votes
2 answers

How do I get the percentage of 4 columns of yes/no data in R?

Let us say, I have a data set with the following columns: Columns with "Yes" and "No" Responses Dataset: (https://docs.google.com/spreadsheets/d/1TLw-UG8WOlFQ3dCn4Kmdok6I2rJL3M31oYb4_a_AxjU/edit?usp=sharing) I would like to have the final output of…
John Keya
  • 49
  • 4
-1
votes
2 answers

Using an ifelse in mutate when summarizing

I have a dataframe with one date column and several columns with values (measured concentrations). I am mutating the dataframe and summarizing to years with averages of the values. This works fine: library(dplyr) df <-…
-1
votes
1 answer

Using group_by in summarize

Here is my df. Airline Destination delayed ontime Total_Arrivals Alaska Los Angelos 62 497 559 Alaska Phoenix 12 221 233 Alaska San Diego 20 212 232 Alaska San Francisco 102 503 605 Alaska Seatlle 305 1841 2146 AM West Los…
-1
votes
1 answer

The meaning of Dot in summarise function

I followed this code to create the row total for the dataframe df library(tidyverse) df <- df %>% bind_rows(summarise(., across(where(is.numeric), sum), across(where(is.character), ~'Total'))) If I modified the…
Nemo
  • 1,124
  • 2
  • 16
  • 39
-1
votes
1 answer

Python version of dplyr R code commands for calculations

I am trying to create a separate pandas DataFrame in python using pandas'.groupby function. I am working with basketball data and want to create a column that displays if the home and away teams are on the tail end of a back-to-back. The 0 in the…
Brad
  • 35
  • 4
-1
votes
1 answer

SQL Join/Summarize/Fill empty columns - within one table

I think I need a join statement but all the join information I find is for 2 tables. I have data like this: And the rows refer to each other like this: I would like to combine the rows, and end up with this: I tried it with left join and inner…
user2133561
  • 155
  • 1
  • 10
-1
votes
1 answer

How can I take all the values (Id, Date and Calories) from ONLY the first and last date of a date range, in date formatting?

First off, StackOverFlow keeps saying there are answers already, but I've been looking for 2.5 hours now and nothing is available. I'm attempting to view values from a dataframe with 940 rows. I would like to view the calories associated to the user…
DCosta
  • 63
  • 1
  • 1
  • 10