Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- structure(list(Tattoo.MUM = structure(c(1L, 1L, 1L, 2L, 2L, 2L
- ), .Label = c("1004", "1007", "1011", "1013", "1024", "1027",
- "1031", "1033", "1034", "10454", "1045A", "1045X", "1057", "1063",
- "1064", "1137", "114", "1155", "1168", "1177", "1178", "1187",
- "1194", "1195", "120", "1204", "1207", "121", "1210", "1214",
- "1215", "1217", "1218", "1227", "1230", "1234", "12392", "1240",
- "1247", "1249", "1251", "1257", "126", "1273", "1275", "1282",
- "1285", "1299", "1300", "1310", "1313", "1314", "1337", "134",
- "1365", "140", "1427", "1437", "144", "1495", "150", "154", "156",
- "158", "1582", "1601", "163", "166", "168", "170", "172", "174",
- "175", "180", "183", "19", "190", "197", "198", "199", "20",
- "213", "214", "217", "22", "220", "221", "225", "226", "227",
- "230", "231", "241", "244", "245", "248", "249", "250", "253",
- "264", "27", "276", "277", "278", "279", "284", "286", "29",
- "297", "299", "301", "305", "311", "315", "322", "336", "338",
- "351", "353", "354", "369", "380", "382", "385", "390", "395",
- "397", "399", "400", "406", "407", "409", "41", "417", "42",
- "424X", "426", "42A", "43", "435", "453", "455F", "461", "465",
- "467", "47", "487", "49", "491F", "492", "507F", "513", "522",
- "53", "534", "551", "553", "554", "562", "564", "566", "569",
- "580", "59", "5943", "60", "62", "626", "63", "639", "643", "646",
- "65W", "67", "68", "685", "695", "699", "700", "713", "721",
- "730", "731", "732", "746", "75", "751", "753", "754", "760",
- "765", "767", "770", "771", "773", "774", "782", "789", "790",
- "792", "795", "797", "809", "819", "825", "828", "837", "838F",
- "83X", "84", "840", "840A", "841", "842", "843", "845", "854",
- "856", "858", "859", "86", "869", "872", "88", "883", "885",
- "887", "894", "895", "896", "8F", "904", "910", "911", "912",
- "918", "92", "929", "930", "933", "937", "945", "951", "959",
- "963", "971", "972", "973", "977", "979", "987", "ANN", "D"), class = "factor"),
- YrBIRTH.CUBS = c(2007, 2008, 2009, 2008, 2009, 2010), Offspring = c(2,
- 1, 1, 2, 1, 1), YOB2 = c(2008, 2009, 2010, 2009, 2010, 2011
- )), .Names = c("Tattoo.MUM", "YrBIRTH.CUBS", "Offspring",
- "YOB2"), row.names = c(NA, 6L), class = "data.frame")
- for (i in 1:(nrow(mumCounts)-1))
- {mumCounts$YOB2 <- mumCounts$YrBIRTH.CUBS + 1 #new column with year of birth +1 to check whether there are missing years
- mumCounts <- mumCounts[order(mumCounts$Tattoo.MUM, mumCounts$YrBIRTH.CUBS),]
- {if(mumCounts[i,'Tattoo.MUM']==mumCounts[i+1,'Tattoo.MUM'] && mumCounts[i,'YOB2']!=mumCounts[i+1,'YrBIRTH.CUBS'])
- {
- mumCountsnewRow<-c(mumCounts[i,'Tattoo.MUM'],mumCounts[i,'YOB2'],0) #create new row with the missing year
- mumCounts <- mumCounts[ ,1:3] #arranging dataset so that I keep only columns I need
- mumCounts <- rbind(mumCounts, mumCountsnewRow) #add new row to dataset
- colnames(mumCounts) <- c("Tattoo.MUM", "YrBIRTH.CUBS", "Offspring")
- mumCounts <- mumCounts[order(mumCounts$Tattoo.MUM, mumCounts$YrBIRTH.CUBS),]
- }
- }
- }
- Warning messages:
- 1: In `[<-.factor`(`*tmp*`, ri, value = 4) :
- invalid factor level, NA generated
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement