[R] [FORGED] bootstrapping results in table format
David Winsemius
dwinsemius at comcast.net
Sat Oct 7 22:49:12 CEST 2017
> On Oct 7, 2017, at 1:32 PM, Rolf Turner <r.turner at auckland.ac.nz> wrote:
>
> On 07/10/17 12:16, Peter Wagey wrote:
>> Hi R users,
>> I was struggling to put the results into table format. Would you mind to
>> show using following data and code how we can put the results into table? I
>> further would like to have a confidence interval for each group.
>> set.seed(1000)
>> data <- as.data.table(list(x1 = runif(200), x2 = runif(200), group =
>> runif(200)>0.5))
>> data.frame(data)
>> head(data)
>> stat <- function(x, i) {x[i, c(m1 = mean(x1))]}
>> A<-data[, list(list(boot(.SD, stat, R = 10))), by = group]$V1
>
> (1) Don't post in html.
>
> (2) Don't send code that makes use of packages that you don't mention
> (in this case "data.table").
Not to mention the boot package.
>
> (3) Don't use "data" as the name of a data object. There is a base function called "data" whence you run the risk of getting toadally incomprehensible error messages as the result of certain syntax errors.
> Also see fortune("dog").
Dear Peter;
Rolf makes good points.
What sort of table do you want? Have you looked at the structure of `A`?
str(A) # output omitted in the interest of brevity
# It's an unnamed list of two 'boot' objects (one for each group), each of which is a named list.
> names(A[[1]])
[1] "t0" "t" "R" "data" "seed" "statistic" "sim"
[8] "call" "stype" "strata" "weights"
> A[[1]]$t0
m1
0.5158232
---
David Winsemius
Alameda, CA, USA
'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law
More information about the R-help
mailing list