summarize

Auto Sort/Auto Summarize Excel

流过昼夜 提交于 2020-01-16 07:25:09
问题 I tried the following code and I can't seem to get things to work... I am needing help to 1) Auto Sort and then 2) Auto Summarize "like-with-like" based on the following column criteria. . . A few things about this list. . . -I need the item list to sort by alphabetical order -Then I need "like" items and quantities to be summarized. -If there is something I type in the NOTE column I need those quantities to be listed separate (Ex: the item LUS26 in the AFTER picture below) -Also, I need this

Dplyr summarise with list of function and dependence on other data column

假装没事ソ 提交于 2020-01-15 10:15:30
问题 Sorry for the terrible title, but it's hard to explain. I have the following data and functions I want to summarize the data with: library(tidyverse) # generate data df <- map(1:4, ~ runif(100)) %>% set_names(c(paste0('V', 1:3), 'threshold')) %>% as_tibble() %>% mutate(group = sample(c('a', 'b'), 100, replace = T)) # generate function list fun_factory_params <- 1:10 fun_factory <- function(param){ function(v, threshold){ sum((v * (threshold >= 1/2))^param) } } fun_list <- map(fun_factory

Dplyr summarise with list of function and dependence on other data column

…衆ロ難τιáo~ 提交于 2020-01-15 10:15:28
问题 Sorry for the terrible title, but it's hard to explain. I have the following data and functions I want to summarize the data with: library(tidyverse) # generate data df <- map(1:4, ~ runif(100)) %>% set_names(c(paste0('V', 1:3), 'threshold')) %>% as_tibble() %>% mutate(group = sample(c('a', 'b'), 100, replace = T)) # generate function list fun_factory_params <- 1:10 fun_factory <- function(param){ function(v, threshold){ sum((v * (threshold >= 1/2))^param) } } fun_list <- map(fun_factory

Why does `summarize` drop a group?

假如想象 提交于 2020-01-11 06:13:10
问题 I'm fooling around with babynames pkg. A group_by command works, but after the summarize , one of the groups is dropped from the group list. library(babynames) babynames[1:10000, ] %>% group_by(year, name) %>% head(1) # A tibble: 1 x 5 # Groups: year, name [1] year sex name n prop <dbl> <chr> <chr> <int> <dbl> 1 1880 F Mary 7065 0.07238433 This is fine---two groups, year, name . But after a summarize (which respects the groups correctly), the name group is dropped. Am I missing an easy

How to obtain species richness and abundance for sites with multiple samples using dplyr

℡╲_俬逩灬. 提交于 2019-12-24 00:56:57
问题 Problem: I have a number of sites, with 10 sampling points at each site. Site Time Sample Species1 Species2 Species3 etc Home A 1 1 0 4 ... Home A 2 0 0 2 ... Work A 1 0 1 1 ... Work A 2 1 0 1 ... Home B 1 1 0 4 ... Home B 2 0 0 2 ... Work B 1 0 1 1 ... Work B 2 1 0 1 ... ... I would like to obtain the richness and abundance of each site. Richness is the total number of species at a site, and abundance is the total number of all individuals of all species at a site, like this: Site Time

Using dplyr to summarize and keep the same variable name

蹲街弑〆低调 提交于 2019-12-23 09:57:26
问题 I have found that data.table and dplyr have differing results when trying to do the same thing. I would like to use dplyr syntax, but have it compute in the way that data.table does. The use case is that I want to add subtotals to a table. To do that, I need to do some aggregation to each variable, but then keep the same variable names (in the transformed version). Data.table allows me to perform some aggregation on a variable and keep the same name. Then do another aggregation with that same

R - dplyr Summarize and Retain Other Columns [closed]

时光总嘲笑我的痴心妄想 提交于 2019-12-22 01:58:41
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . I am grouping data and then summarizing it, but would also like to retain another column. I do not need to do any evaluations of that column's content as it will always be the same as the group_by column. I can add it to the group_by statement but that does not seem "right".

Summarize data in R

此生再无相见时 提交于 2019-12-13 17:16:08
问题 I have a dataset which contains weekly sale of various products by outlet. Here is how the data looks like: Store ID Week ID Item Code Sales in $ 253422 191 41130 2.95 272568 188 41130 2.95 272568 188 41160 2.95 272568 189 41130 2.95 272568 189 41160 2.95 272568 190 41160 2.95 217460 188 41110 2.95 217460 188 41130 5.9 217460 188 41160 5.9 217460 189 41110 11.8 217460 189 41130 8.85 217460 189 41160 11.8 217460 191 41130 5.95 217460 191 41160 8.93 This is a very large dataset and I would like

R: Cleaning up a wide and untidy dataframe

☆樱花仙子☆ 提交于 2019-12-12 19:16:11
问题 I have a data frame that looks like: d<-data.frame(id=(1:9), grp_id=(c(rep(1,3), rep(2,3), rep(3,3))), a=rep(NA, 9), b=c("No", rep(NA, 3), "Yes", rep(NA, 4)), c=c(rep(NA,2), "No", rep(NA,6)), d=c(rep(NA,3), "Yes", rep(NA,2), "No", rep(NA,2)), e=c(rep(NA, 7), "No", NA), f=c(NA, "No", rep(NA,3), "No", rep(NA,2), "No")) >d id grp_id a b c d e f 1 1 1 NA No <NA> <NA> <NA> <NA> 2 2 1 NA <NA> <NA> <NA> <NA> No 3 3 1 NA <NA> No <NA> <NA> <NA> 4 4 2 NA <NA> <NA> Yes <NA> <NA> 5 5 2 NA Yes <NA> <NA>

Using R & dplyr to summarize - group_by, count, mean, sd [closed]

♀尐吖头ヾ 提交于 2019-12-12 17:18:53
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 months ago . Good day and greetings! This is my first post on Stack Overflow. I am fairly new to R and even newer dplyr. I have a small data set comprised of 2 columns - var1 and var2. The var1 column is comprised of num values. The var2 column is comprised of factors with 3 levels - A, B, and C. var1 var2 1 1.4395244 A 2 1