2 years ago

#75947

test-img

jbryzek

Aggregating Data in R while retaining other fields

I have a data file with 7 fields. I am trying to aggregate the data based on one field (Individual) and summarize the data by another field (Diameter). My new data file gets rid of the other 5 fields from the original file. Is there a way to retain other fields when doing an aggregate function? See R code below.

Current R Code:

#add in data and verify 
SAG_v1 <- read_csv("C:/Users/jbryz/Downloads/SAG_v1.csv", show_col_types = FALSE)
head(SAG_v1)
#dissolve by field=individual to accounts for multi-stemmed measurements
library(dplyr)
SAG_sum <- SAG_v1 %>% 
  group_by(Individual) %>% 
  summarise(Diameter = sum(Diameter))

r

aggregate

0 Answers

Your Answer

Accepted video resources