What's wrong with:
result <- with(df, x/n) ? Do I misunderstand?
(and what's the p = .065 or [[1]] have to do with the estimated prob,
as you are not actually doing any test?)
Finally, if you really do this sort of thing, ?mapply (and ?with) can
be useful; e.g. you could have rewritten your loo
Dear Alain,
The problem is that you save the results of each iteration in df$VAR. So
obviously, you overwrite df$VAR at each iteration.
What you need to do it to create an empty vector that contains the right
number of elements and then iteratively fill this list. You can then
combine df and
Hi Alain,
You are probably storing the result, replicated five times, in df$VAR.
Each cycle of the loop replaces the last value with the current value.
If you really want the entire output of binom.test in the last column:
multi.binom.test<-function(xs,ns) {
reslist<-list()
for(i in 1:length(xs
> On 29 Jul 2016, at 10:52, Alain D. via R-help wrote:
>
> Dear list,
>
> I have a dataframe df:
>
> df<-data.frame(x=c(5,32,18,3,17), n=c(11,200,432,20,60))
>
> Now I want to run n=nrow binom.test() with x being the number of success and n
> the number of trials and then store the results a
Dear list,
I have a dataframe df:
df<-data.frame(x=c(5,32,18,3,17), n=c(11,200,432,20,60))
Now I want to run n=nrow binom.test() with x being the number of success and n
the number of trials and then store the results as a new VAR in df.
I tried
for (i in 1:nrow(df)){
df$VAR<-(binom.test
5 matches
Mail list logo