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

Finding percentage using group_by and summarise in R through dplyr

I have some data about peoples' academic background. The user information can have duplicates so I use Unique_Elements to extract each entry only once. demographics %>% group_by(Academic_Level) %>% summarise(Unique_Elements =…
Sandy
  • 1,100
  • 10
  • 18
-1
votes
1 answer

Dynamic groupby function with brackets

df1 <- mtcars %>% group_by(gear) %>% summarise(Mittelwert = mean(mpg, na.rm = TRUE)) df1 df2 <- mtcars %>% group_by(mtcars[[10]]) %>% summarise(Mittelwert = mean(mtcars[[1]]), na.rm = TRUE) df2 The last code gives me the mean of…
user7353167
-1
votes
1 answer

R: How to list all levels of a factor variable by summarise function

Neighorhood is a factor variable with more than 20 levels and I want to see the standard deviation of all levels but I can only see 10 rows by the summarise function. How can I deal with the problem? train %>% group_by(Neighborhood) …
Shea
  • 3
  • 2
-1
votes
3 answers

Summarize data in a list in python

In python i need to summarize data in count_list this way (like a histogram): """ number | occurence 0 | * 1 | ** 2 | *** 3 | ** 4 | ** 5 | * 6 | * 7 | ** 8 | *** 9 | * 10 | ** """ But instead I get this wrong…
-1
votes
2 answers

How to group a dataframe, and then count the distinct values in R

I have a dataframe in R that has 43 Variables and over 80 rows. I would like to group the data, based on one variable - geographical region, and then count the distinct values of a variable (How many 0s, 1s, 2s, 3s and NAs, etc). I know the group_by…
user1778351
  • 143
  • 7
-1
votes
1 answer

Summarize number of unique rows in data frame r

Need your best advice. Trying to map bike routes in NY. library(tidyverse) bikes <- read.csv("August.csv", header = TRUE) str(bikes) # 1557663 obs. of 15 variables summary(bikes) names(bikes) That is how one route looks like # Sample route…
Anakin Skywalker
  • 2,400
  • 5
  • 35
  • 63
-1
votes
1 answer

HOW can i sum a categorical variable and aggregate by factor

So let me be a little more specific..... i have a dataset that has SOCCERTEAM -PLAYERS BARCA - MESSI BARCA - MESSI BARCA - MESSI BARCA - XAVI -RM - CR -RM - CR -RM - PEPE -RM -HIQUAIN etc(just an…
Fallen Greg
  • 23
  • 1
  • 7
-1
votes
1 answer

summarize functions in js

I would like to summarize some JavaScript functions. For example: document.getElementByClassName("lamp")[0]; == selector(".lamp")[0]; In this example I haven't problem, my problem is the following…
hamidb80
  • 302
  • 3
  • 16
-2
votes
1 answer

R code to group multicode question responses by

I have a dataframe containing responses to a multicode question by month, where: 1 = Yes; 0 = No. The output I'm after is a contingency table (with %s) detailing the proportion of 1 ('Yes') responses by month for each of the multicode…
-2
votes
1 answer

Jquery summarize array by id

I have following array [ "1", "132", "151.79999999999998", "1", "10", "11.5", "2", "100", "121" ] When it starts with VAT_id, price_without_VAT and price_with_VAT (it is table ID_VAT, price without VAT and price with VAT}. I want…
Hyp
  • 7
  • 1
-2
votes
1 answer

I used GROUPBY then SUMMARISE to add a total label to dataframe. BUT means the % data on total level is wrong

I used GROUPBY then SUM then SUMMARISE to add a total label to dataframe. BUT means the % data on total level is wrong. So, I would like to overwrite the percentage variable 'percentage absent staff' with a calculation with the correct result. …
-2
votes
1 answer

Creating proportion variables of panel data in R (state/year)

I have census data for race in state populations since 1990. I want to do two things at the year/state level in R studio: 1. aggregate all those who are hispanic/latino of any racial group into an entirely new racial group, "Hispanic/Latino," 2.…
user255824
  • 1
  • 1
  • 1
-2
votes
1 answer

"Error: n() should only be called in a data context" when using group_by and summarize

I have a homework question: "For each age range find the percent of patients who were readmitted after 30 days and display the results in a bar chart." I ran the following code and got "Error: n() should only be called in a data…
-2
votes
2 answers

Obtain more variables after grouping, summarising with select (dplyr)

My data frame: date | weekday | price 2018 | 1 | 25 2018 | 1 | 35 2019 | 2 | 40 I try to run this code under dplyr: pi %>% group_by(date) %>% group_by(date) %>% summarise(price = sum(price, na.rm = T)) %>% …
R. Ladwein
  • 21
  • 3
-2
votes
1 answer

How to plot arrest rate (%) for the top 20 crime types (crimes of chicago dataset)?

I am working with R in RStudio and would like to plot via highchart package a graphic that includes on the x-Axis the crime type, and on the y-Axis the arrest rate in %. So to see on which crime type the highest arrest was made. I am working with…
S002
  • 31
  • 7
1 2 3
55
56