summary

R convert summary result (statistics with all dataframe columns) into dataframe

对着背影说爱祢 提交于 2019-12-11 02:36:59
问题 [I'm new to R...] I have this dataframe: df1 <- data.frame(c(2,1,2), c(1,2,3,4,5,6), seq(141,170)) #create data.frame names(df1) <- c('gender', 'age', 'height') #column names I want the df1 's summary in a dataframe object that looks like this: count mean std min 25% 50% 75% max age 30.0000 3.5000 1.7370 1.0000 2.0000 3.5000 5.0000 6.0000 gender 30.0000 1.6667 0.4795 1.0000 1.0000 2.0000 2.0000 2.0000 height 30.0000 155.5000 8.8034 141.0000 148.2500 155.5000 162.7500 170.0000 I've generated

A simpler way to achieve a frequency count with mean, sum, length and sd in R

╄→尐↘猪︶ㄣ 提交于 2019-12-10 23:37:25
问题 I've been tasked with creating frequency tables with statistical summaries. My goal is to create a data frame that can be exported simply to excel. Most of this could be in sql using stored procedures but I decided to do this in R. I'm learning R so I might be doing it the long way. This is a follow on question from getting-r-frequency-counts-for-all-possible-answers Given Id <- c(1,2,3,4,5,6,7,8,9,10) ClassA <- c(1,NA,3,1,1,2,1,4,5,3) ClassB <- c(2,1,1,3,3,2,1,1,3,3) R <- c(1,2,3,NA,9,2,4,5

Summarize and Group JSON object in Jquery

倖福魔咒の 提交于 2019-12-10 23:25:51
问题 I am having problems summarizing and grouping my object in Jquery as I would like to group by country and then have a grand total based on subperiods 4,5,and 6 for values within col1. The col1, col2, col3 are dynamic, but using this is an example. What I need is to get the total by country which is stored in the country variable, grand total per subperiod stored in the columns variable, and the total count stored in the averages variable. Here is my code in jsfiddle: http://jsfiddle.net/8vVK7

R aggregate gives differently structured results using subsets from the same data

元气小坏坏 提交于 2019-12-10 19:10:33
问题 I'm making diurnal cycles of windspeed based on a dataframe (ball) of several year's hourly data. I want to plot them by season, so I subset out the dates I need and join them like this: b8 = subset(ball, as.Date(date)>="2008-09-01 00:00:00, GMT" & as.Date(date)<= "2008-11-30 23:00:00, GMT" ) b9 = subset(ball, as.Date(date)>="2009-09-01 00:00:00, GMT" & as.Date(date)<= "2009-11-30 23:00:00, GMT" ) b10 = subset(ball, as.Date(date)>="2010-09-01 00:00:00, GMT" & as.Date(date)<= "2010-11-30 23:00

How to calculate new column depending on aggregate function on group using dplyr (add summary statistics on the summary statistics)?

眉间皱痕 提交于 2019-12-10 04:30:01
问题 Quite often I need to calculate a new column for an R dataframe (in long form), whose value should depend on an aggregate function (e.g. sum) of a group. For instance, I might want to know what fraction of sales a product accounts for on any given day: daily fraction = revenue for product i on day d / sum or revenue for all products on day d My current strategy is to summarise and join: library(dplyr) join_summary <- function(data, ...) left_join(data, summarise(data, ...)) data = data.frame(

How can I set the android preference summary text color?

纵然是瞬间 提交于 2019-12-09 14:05:52
问题 On my preference screen I have a preference that when clicked opens a color picker dialog. What I would like to do is when the user selects a color, that the text summary of the preference is displayed in that color. I know I can have the summary set up like this, Currently <font color="#ff0000">this color</font> and have it display in that color. The problem is the color I am getting back is the android int color. I could use the red(), green(), blue() methods and then convert those to Hex

Summary data tables from wide data.frames

若如初见. 提交于 2019-12-09 01:52:24
问题 I am trying to find lazy/easy ways of creating summary tables/ data.frames from wide data.frames . Assume a following data.frame, but with many more columns so that specifying the column names takes a long time: set.seed(2) x <- data.frame(Rep = rep(1:3, 4), Temp = c(rep(10,6), rep(20,6)), pH = rep(c(rep(8.1, 3), rep(7.6, 3)), 2), Var1 = rnorm(12, 5,2), Var2 = c(rnorm(6,4,1), rnorm(6,3,5)), Var3 = rt(12, 20)) x[1:3] <- as.data.frame(apply(x[1:3], 2, function(x) as.factor(x))) Now I can

How to add a mouse-over summary

邮差的信 提交于 2019-12-08 18:46:37
问题 I'm almost certain this is going to be a very simple answer but I can't seem to find it anywhere. We all know when you hover your mouse over something (like a string) a little summary pops up (if its enabled). For a string, it says: class System.String Represents text as a series of Unicode characters. When I mouse over one of my classes, it simply says: class Namespace.Widget I've tried the two obvious examples I've found: /// <summary> /// This summary does not work, I know it's for html

Devexpress Pivotgrid: How to define custom summary

て烟熏妆下的殇ゞ 提交于 2019-12-08 13:37:20
问题 I have a pivot grid made by ASPxpivotgrid. As anyone whoever made a pivotgrid would know, there is an optional row summary line in pivotgrid. It has some options like Sum, Avg, Min, Max, Var etc. but I need to have Min / Max in the summary line. I know there is another option like "Custom" but although I checked so many examples and pages, I couldn't find any clear example that describes how to define a Custom summary. My question is, how to define a custom summary? 回答1: This should be

R: summary() returns strange 1st Qu

狂风中的少年 提交于 2019-12-08 13:11:37
There's an exercise in Khan Academy' Probability and Statistics course on creating box-and-whisker plot. Here's screenshot representing correct solution. But when I tried to check solution in R I got the following: d <- c(11, 4, 1, 4, 2, 2, 6, 10, 5, 6, 0, 6, 3, 3) summary(d) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.00 2.25 4.00 4.50 6.00 11.00 You can see 2.25 value for 1st Qu. But the correct value is 2. Any other values returned with summary() are correct. Any ideas why summary() returns wrong result? In a nutshell, there are many reasonable ways to compute quantiles. This is evidenced by