Search

Paul Apivat
Paul Apivat
  • Start Here
  • About
  • Posts
  • Data Viz
  • Technical Notes
  • Contact
  • Light Dark Automatic
Technical Notes Overview
Data Cleaning Tips
  • Data Cleaning
Data Viz Tips
  • 2 y-axes
  • Add comma separator in geom_text label
  • Circular Dendrogram
  • Extend Color Palettes
  • reactable
  • scale_x_continuous (ggplot2)
  • Scatterplots & Marginal Distribution
  • Treemaps
  • Visualize Dendrograms
  • White background for ggplot
Database
  • Database Connection with Python
  • Database Design Course
  • Testing Database in Docker
Example Topic
  • Tips 1-2
  • Tips 3-4
Git & GitHub
  • Creating a Github Repo
  • Git Commit Message
  • Git Stash
  • Making a Pull Request
  • Show ahead/behind all branches
  • Update local branch to origin
Google Cloud Tips
  • Connect BigQuery to Data Studio
GraphQL
  • Comparison Operators
Mongodb
  • Aggregation Pipeline
  • Categorical Buckets
  • Concatenate String
  • CRUD Operations
  • Data Retrieval
  • Data Types & Common Commands (Mongo)
  • Display data in order
  • Filter multiple conditions
  • Get past 7-days data
  • Get unique users
  • Importing Data
  • Joins in Mongo
  • Nested Documents in Arrays
  • Retrieve latest document
  • Show current user
  • Subtract Timestamps
Pandas
  • Merge several dataframes into one
  • Picking df cells in Pandas
Pipeline
  • Prep dataframe to insert to database
PostgreSQL
  • Create a table (establish connection)
  • Delete a table
  • Duplicate a table
  • Establish connection (SQLAlchemy)
  • Insert data to database
  • Select Range of Rows
  • Sort by Two Column
  • Upload DataFrame (SQLAlchemy)
Python Tips
  • Connect to API
  • Connect to MongoDB
  • Creating and Looping through DataFrames
  • Faker in Python
  • Functions in Python
  • Installing Poetry
  • Iterating and Updating data structures
  • Joining Sets
  • JSON to Dataframes with Pandas
  • Nested JSON to dataframe
  • Prevent sensitive info pushed to GitHub
  • Python Setup
  • Python Starter Pack
  • Querying GraphQL
  • Reproducibility in Python
  • String Interpolation GraphQL
  • Virtual Environments in Python
Rstats Tip
  • Calculating Percentiles
  • Continuous to Discrete Plotting
  • Format Dates
  • Manually Order Factors
  • Non-Matching Rows between Two Columns
  • Open API with R
  • Order of Dplyr Functions
  • Reproducibility
  • Reverse Plotting
  • Sum variable by group
  • Tidy Data - pivot_wider
  • Tidy Data - Spread
  • Unnest JSON data
SQL
  • Check for duplicates
  • SQL and Pandas
  • SQL Check Columns Equality
  • Upload CSV to Postgres with pgAdmin
Webdev
  • Fix Linting Error
  • Install Error Tracking
  • Contents
  • Sum variable by group

Sum variable by group

Sum variable by group

Situation: You want to sum by group. Assuming the dataframe has at least two columns, category and value.

Check out original answer on stack overflow.

library(dplyr)

df %>%
   group_by(category) %>%
   summarise(summed_value = sum(value))

For more content on data, tech and web3 find me on Twitter.

Previous
Add comma separator in geom_text label
Next
Manually insert data to database

Last updated on Jan 21, 2022

Edit this page

© 2022 Paul Apivat Hanvongse. All Rights Reserved.

Powered by the Academic theme for Hugo.

Cite
Copy Download