Displaying 2 results from an estimated 2 matches for "brep".
Did you mean:
bnep
2011 Jan 17
1
filling in datasets of differing lengths
g''day all,
I need help with this please.
I have a dataset of site names and years they were trapped in (a subset of
it is bs, below) and a dataset of sites that actually caught animals
(subsetted as brep, below). I need to add to brep, a row with a zero in the
classcount column, for every year each site was trapped but caught nothing.
so for Site 1, I need to add rows that say "Site1 Reptilia 0 2005", "Site1
Reptilia 0 2007", "Site1 Reptilia 0 2008" etc to 2010....
2010 Feb 17
1
lapply to apply a function using a vector
Hi,
First, thank you all for your help.
Here is my problem (simplified):
Say I have a list:
a=list(matrix(50,nrow=5,ncol=5),matrix(25,nrow=5,ncol=5),matrix(10,nrow=5,ncol=5))
I'd like to use rbinom with a different probability for each matrix. I
tried:
b=c(.8,.1,.9)
brep=rep(b,each=25)
lapply(a,function(a) rbinom(25,a,brep))
but that doesn't work-- it just uses the first value of b rather than
applying it over that list.
what I am currently doing is:
c=list()
for (i in 1:3){c[[i]]=rbinom(25,a[[i]],b[i])}
I'm trying to learn how to use the lapply function....