search for: newpets

Displaying 1 result from an estimated 1 matches for "newpets".

Did you mean: newnets
2008 Dec 18
1
inserting zero instances with zeroes in a matrix
...ot;,"dogs","budgie","cat","hamster") d.f<-data.frame(house,pet,count) How would I acheive a dataframe that had every instance of house in column 1, all possible pets in column 2 and counts in column 3 like this... newhouse<-rep(unique(house),1,each=4) newpets<-rep(unique(pet),4) newcount<-c(2,1,0,0,2,0,0,0,1,0,0,0,0,3,2,4) newdf<-data.frame(newhouse,newpets,newcount) Is there a way of doing this without creating a new matrix and using programming loops? Thanks in advance, Simon. [[alternative HTML version deleted]]