Hello I have a dataset of people spending time in places. But most people don't hang out in all the places.
it looks like: > Input<-data.frame(people=c("Marc","Marc","Joe","Joe","Joe","Mary"), + place=c("school","home","home","sport","beach","school"), + time=c(2,4,3,1,5,4)) > Input people place time 1 Marc school 2 2 Marc home 4 3 Joe home 3 4 Joe sport 1 5 Joe beach 5 6 Mary school 4 In order to import it within R's igraph, I must use graph.incidence(), but the data needs to be formatted that way: > Output<-data.frame(school=c(2,0,4),home=c(4,3,0),sport=c(0,1,0),beach=c(0,5,0), + row.names=c("Marc","Joe","Mary")) > Output school home sport beach Marc 2 4 0 0 Joe 0 3 1 5 Mary 4 0 0 0 The Dataset is fairly large (couple hundreds of people and places), and I would very much appreciate if someone could point me to a routine or function that could transform my Input dataset to the required Output, Thank you very much in advance Regards Sylvain PS: sorry for cross-posting this on statnet and then on R help list, but I received a message from statnet pointing out the question was more related to general data management than actual network analysis. Which is true indeed... [[alternative HTML version deleted]] ______________________________________________ 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.