FAQ Database Discussion Community


dplyr - summarise weighted data

r,dplyr,summary,weight
Is there a possibility to use weights with dplyr summarise function ? Let us imagine I want to calculate a weighted table dta = structure(list(PHHWT14 = c(530, 457, 416, 497, 395, 480, 383, 420, 499, 424, 504, 497, 449, 406, 492, 470, 418, 407, 403, 362, 393, 368, 423, 448,...

Edit default summary function in R gives error for multiple variables

r,function,customization,summary,s
I'm expanding the default summary() function because I need more percentiles. It seems to work fine for one variable, but if I add a dataframe containing multiple variables I get strange values whereas with the default summary() it works. Even if I replicate the default summary function completely, so without...

Aggregate big dataset for a list of columns and using different FUN

r,data.table,aggregate,plyr,summary
I have a big dataset, and I need to summarise most of the columns by one single factor (CODE_PLOT). This is the list of columns I need to aggregate: > names(soil)[4:30] [1] "PH" "CONDUCTIVITY" "K" "CA" "MG" "N_NO3" [7] "S_SO4" "ALKALINITY" "AL" "DOC" "WATER_CONTENT" "Na" [13] "AL_LABILE" "FE" "MN" "P"...

Spark column wise word count

scala,apache-spark,summary
We are trying to generate column wise statistics of our dataset in spark. In addition to using the summary function from statistics library. We are using the following procedure: We determine the columns with string values Generate key value pair for the whole dataset, using the column number as key...

Bootstrap CI for several variables of column in dataframe

r,function,data.frame,dplyr,summary
I would like to bootstrap confidence intervals for a proportion from a data.frame. I would like to get the results for the variables in one of my columns. I have managed to perform the bootstrap for a vector but do not know how to scale it up to a data.frame...

How to sum rows based on multiple conditions - R? [duplicate]

r,sum,data.frame,summary,multiple-conditions
This question already has an answer here: How to sum a variable by group? 7 answers I have a dataframe that contains a plot ID (plotID), tree species code (species), and a cover value (cover). You can see there are multiple records of tree species within one of the...

Grouping Over All Possible Combinations of Several Variables With dplyr

r,dplyr,summary
Given a situation such as the following library(dplyr) myData <- tbl_df(data.frame( var1 = rnorm(100), var2 = letters[1:3] %>% sample(100, replace = TRUE) %>% factor(), var3 = LETTERS[1:3] %>% sample(100, replace = TRUE) %>% factor(), var4 = month.abb[1:3] %>% sample(100, replace = TRUE) %>% factor())) I would like to group `myData'...

Count number of occurences in repeated variables (r)

r,count,summary
I need to summarise the number of days that people have worked during a week. Each variables represent a day. I need to produce a summary of the number of days worked. I am not quite sure what would be a convenient manner to do it (beside summing the table...

Simple Table with dplyr on Sequence Data

r,count,dplyr,summary
I would like to make a simple table with dplyr and summarise But I can't really figure out how ... (Even though it should be quite simple). I have a matrix of sequences. When I simply tabulate table(dta) I have the result I want. dta acquaintance alone child notnotnot nuclear...

R: making a different between categorical and numeric predictors

r,summary,categorical-data
I've got the following code: isNoun <- as.factor(isNoun) isVerb <- as.factor(isVerb) labels <- as.factor(labels) alles <- matrix(c(isNoun, isVerb, length,labels), nrow=388,ncol=4) alles_df <- as.data.frame(alles) summary(alles_df) > summary(alles_df) V1 V2 V3 V4 Min. :0.0000 Min. :0.00000 Min. : 3.000 Min. :0.0000 1st Qu.:1.0000 1st Qu.:0.00000 1st Qu.: 5.000 1st Qu.:0.0000 Median :1.0000...

Graphical representation of test results of phpunit

phpunit,report,summary,phing
I am using phpunit to do functional tests. I use the log-junit option to generate results in JUnit-XML format. I then use phing to read this XML and generate a HTML report. The report is fine and neat. However, I have two questions:-- Can I also show the results in...

Is it possible to reduce “git show --name-status --oneline master” to the summary line only?

git,commit,summary
In the following output, I'd like to exclude lines that start with "A" or "M". Is it possible? $ git show --name-status --oneline master 4e8f3e9 Added: f1.txt, f2.txt; modified: master_1.txt A f1.txt A f2.txt M master_1.txt Using "--summary" helps but it still leaves "extra" stuff in it: $ git show...

Report total summary in XtraReports Devexpress Programmatic?

c#,devexpress,summary,xtrareport
Am trying to populate data to reports programmatically. That's working fine, Now am trying to show Total summary for amount column in XtraReport using this code on BeforePrint & AfterPrint events but i din't get summary total, simply it shows ? or None TXE_Total.Summary = new XRSummary(SummaryRunning.Report, SummaryFunc.Sum, "{0:n2}"); Am...

Nesting aggregate within apply to aggregate multiple columns by multiple variables in R

r,aggregate,nested-loops,apply,summary
I have a dataframe with sets of scores, and sets of grouping variables, something like: s1 s2 s3 g1 g2 g3 4 3 7 F F T 6 2 2 T T T 2 4 9 G G F 1 3 1 T F G I want to run an...

PHP group array by two keys and get total

php,arrays,summary
I have long arrays (could be hundreds) from $_POST and need to summarize the qty. Below is the $_POST result: array(5) { ["Batch_No"]=> array(3) { [0]=> string(7) "AAAV343" [1]=> string(7) "AAAV343" [2]=> string(7) "AAAV347" } ["Expire"]=> array(3) { [0]=> string(0) "" [1]=> string(0) "" [2]=> string(0) "" } ["Prod_ID"]=> array(3)...