data.table - Create a table for N, Min/Max, SD, Mean, and Median in R -


i'm new r, please bear me on basic question. have dataset, data, created using data.table package. created 200 random numbers between 0 , 1, did 10000 times, creating data table descriptive statistics each iteration. code looked this:

rndm<-runif(200, min=0, max=1) reps <- data.table(x=runif(200*10000),iter=rep(1:200,each=10000)) data <- reps[,list(mean=mean(rndm),median=median(rndm),sd=sd(rndm),min=min(rndm), max=max(rndm)),by=iter] 

the data looks this:

    mean    median     sd    min    max 1   0.521    0.499   0.287  0.010  0.998 2   0.511    0.502   0.290  0.009  0.996 .    ...     ...  

etc.

what want create table finds n, mean, median, standard deviation, minimum, , maximum of accumulated sample means (not of each column above). need output this:

   n     mean   median    sd    min    max  10000  .502     .499    .280  .002   .999 

how can accomplish this?

you define function. approach allows make same table different variable.

summaryfun <- function(x)list(n=length(x),mean=mean(x),median=median(x),sd=sd(x),min=min(x),max=max(x)) data[,summaryfun(mean)] 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -