Domanda

How could I obtain the mean with confidence intervals not only with a graphical plot, but also with numerical data as a result of the following expression?

m <- melt(x, id="time")
k <- ggplot(m, aes(x=time, y=value)) +
     stat_summary(fun.data="mean_cl_boot", geom="smooth")
k

I've tried to examine the contents of k, but I've only found my initial data, and not the final results.

È stato utile?

Soluzione

Just apply the function you have used in stat_summary:

tapply(m$value, m$time, mean_cl_boot)

The function tapply is used to apply a function to subsets of data. Here, the data is m$value. The subsets are defined by m$time. The function mean_cl_boot is applied to all subsets of the data separately.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top