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
1 answer

Wide Format Summary in tidyverse

Hi I have a dataframe in wide format that is grouped by Site. Each column represents the abundance a different species(85 total). I am trying to summarize the dataframe to calculate the total number of individuals regardless of species in my data.…
I Del Toro
  • 913
  • 4
  • 15
  • 36
0
votes
1 answer

R Dplyr Summarize w/ Sum is not counting some rows. Why?

I am new to stackoverflow, but not new to googling the heck out of my R script issues. This one has me stumped. I am trying to find out why my current script doesn't work: SCRIPT: My example is a tibble (called "Squishframe") of 13 columns (11 of…
micoo
  • 11
  • 4
0
votes
1 answer

How to count factors frequency and organize in a new dataframe in R

I have a dataframe like this: test1 = data.frame("id" = c("FC01", "FC01", "FC22", "FC03", "FC01"), "product" = c("p01", "p02", "p03", "p01", "p03"), "year" = c("2018", "2017", "2015", "2018", "2016")) I need…
Falves
  • 37
  • 1
  • 8
0
votes
2 answers

Extract class of each field in data.frame; summarize classes in new data.frame

I have a number of very similar .csv's that I want to check through programatically to determine if their column types are the same. Say I've imported a .csv as a data.frame and I want to check the column classes: library(tidyverse) test <-…
Nova
  • 5,423
  • 2
  • 42
  • 62
0
votes
2 answers

Collapse based on a condition

This question is similar to a question already posted few days ago, Collapse rows from 0 to 0 The new twist here which is different from the previous question is this, how do we collapse rows by Id for only those rows where the time different is…
Sundown Brownbear
  • 491
  • 1
  • 5
  • 15
0
votes
1 answer

How can I create a plot with data located in one column of a table with R?

I would like to extract information from a csv table that contains survey answers. The goal is to create informal graphs for my shiny app to show the result of the survey. To simplify the process I want to create the plots in a standard R file…
Julie
  • 1
  • 1
0
votes
3 answers

SQL summarise based on condition

Let's say I have a table called Table1 that contains three columns, VALUE, CODE and TYPE. The column VALUE contains scores ranging from 1-4 for different questions. The column CODE contains the code pertaining to the question. The column TYPE…
Varun
  • 1,211
  • 1
  • 14
  • 31
0
votes
1 answer

Selecting data in summarize based on another column in R if it == max(salary)

First of all thanks for browsing through my question. I'm currently exploring 19 years of NBA data that has 7978 observations and 56 variables. The information is collected from the 2000 to 2018 NBA regular season. I'm currently exploring how…
黄日华
  • 1
  • 1
0
votes
1 answer

Passing an external function (and arguments) to dplyr summarize or mutate

I am trying to summarize a large set of data with an external function (sii package). What I need to do is calculate SII for each subject, with each system, at each presentation level. Example data: data <- structure(list(Subject = structure(c(1L,…
JLC
  • 661
  • 7
  • 16
0
votes
1 answer

How to summarise taking a random value from a categorical column?

I have two species and some values for them. values <- c(1,2,3,4,5,6,7,8,9,10) spp <- c(rep("a",5), rep("b",5)) df <- data.frame(spp, values, stringsAsFactor = FALSE) I want to summarise the data frame, grouping by these species. My idea is…
tales_alencar
  • 141
  • 1
  • 10
0
votes
3 answers

How to find the quantiles of each variable of a data.frame

I have a dataframe with multiple variables and I would like to find the quantiles () of each of these variables Sample code: testtable = data.frame(groupvar = c(rep('x',100), rep('y',100)), numericvar = rnorm(200)) I want to…
Amazonian
  • 391
  • 2
  • 8
  • 22
0
votes
2 answers

SQL Server: summarize results using max of other column

I'm struggling with this one. I have the following data in the table (actually much more columns to be reduced to): The question is how do I get to the result? The rules are that I only want just one row per subproduct taking only the…
Agustin
  • 5
  • 1
0
votes
1 answer

Calculate percentage summaries in data.table

If this is my dataset: library(data.table) dt <- data.table( record=c(1:20), area=rep(LETTERS[1:4], c(4, 6, 3, 7)), score=c(1,1:3,2:3,1,1,1,2,2,1,2,1,1,1,1,1:3), cluster=c("X", "Y", "Z")[c(1,1:3,3,2,1,1:3,1,1:3,3,3,3,1:3)] ) What is…
Chris
  • 1,197
  • 9
  • 28
0
votes
1 answer

Summary statistics from aggregated groups using data.table

I have a dataset with this structure: library(data.table) dt <- data.table( record=c(1:20), area=rep(LETTERS[1:4], c(4, 6, 3, 7)), score=c(1,1:3,2:3,1,1,1,2,2,1,2,1,1,1,1,1:3), cluster=c("X", "Y",…
Chris
  • 1,197
  • 9
  • 28
0
votes
2 answers

Calculate total values when summarising grouped data

I have a dataframe where I have grouped data, I am running summary statistics by group but also want to get summary statistics for everything combined. Is there a simpler way of doing it than doing it twice and combining like follows? dataDF <-…
user1165199
  • 6,351
  • 13
  • 44
  • 60