Hi there,
I am not getting anywhere near a solution, so here is my question. I
have searched the archives and didn't find a solution, but maybe my
search didn't use the right words. So here it is:
I have a dataframe with the following structure
factor1 factor2 value
In the (rather large) dataset I have to work on, there are some factor
combinations missing, e.g.
factor1 <- c("2005", "2007", "2009)
factor2 <- c("Area1", "Area2", "Area3")
So in a perfect world there should be values for each combination in
the dataset, eg values for "2005" in "Area1", "Area2" and "Area3", for
"2007" and the three areas and so on.
But in my dataset some combinations are missing, e.g. a value for
"2009" and "Area3".
How can I add complete my dataset with NA or 0 for the missing factor
combinations?
Is there a way to use unstack or do I have to create the combinations
first and then search for each combination within the dataframe and
use rbind to add a row with the missing combination and a value of NA
or 0?
Thanks,
karsten
---
Karsten D. Wolf
Universität Bremen
http://www.ifeb.uni-bremen.de/wolf
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.