In brief, I have a large dataframe (~750,000 rows) most of which have a NA value in the "Age" field. I want to assign the values held in the "AcutalAge" and "InterpAge" field where the "Age" field is empty (prioritizing the "ActualAge" field first). The code snippet below is not working. Any thoughts? All of the fields are ints ranging from 0 to 150 or so.
for (r in seq_len(nrow(TreeData))){
if (is.na(TreeData[r,"Age"])){
TreeData[r,"Age"] <- TreeData[r,"ActualAge"]
}
# use InterpAge field if not a sample age tree or ActualAge tree
if (is.na(TreeData[r,"Age"])){
TreeData[r,"Age"] <- TreeData[r,"InterpAge"]
}
}
Sample Data:
"","Stand_ID","Plot_ID","StandPlot_ID","Tree_ID","District","PlotNumber","DBH","Ht","TreeStatus","Remeasurement","CrRatio","Species","Abbrev","b1","b2","b3","b4","b5","Age","Elevation","Slope","Latitude","Longitude","InterpAge","ActualSpec","ActualCD","ActualSite","ActualAge","DomSpec","Inv_Year","Disturbance","Treatment"
"1","D10P112103","R0","D10P112103R0",59,10,112103,0.551181390613437,6.23359592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"2","D10P112103","R0","D10P112103R0",58,10,112103,0.472441218773127,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"3","D10P112103","R0","D10P112103R0",30,10,112103,0.433071109386563,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"4","D10P112103","R0","D10P112103R0",7,10,112103,0.748031890613437,7.54593184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"5","D10P112103","R0","D10P112103R0",41,10,112103,0.5905515,6.88976368711472,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"6","D10P112103","R0","D10P112103R0",17,10,112103,0.472441218773127,5.24934407822132,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"7","D10P112103","R0","D10P112103R0",20,10,112103,0.157480402346641,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"8","D10P112103","R0","D10P112103R0",67,10,112103,0.354330890613437,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"9","D10P112103","R0","D10P112103R0",47,10,112103,0.393701,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"10","D10P112103","R0","D10P112103R0",16,10,112103,0.472441218773127,5.57742815644264,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"11","D10P112103","R0","D10P112103R0",57,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"12","D10P112103","R0","D10P112103R0",49,10,112103,0.669291718773127,6.88976368711472,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"13","D10P112103","R0","D10P112103R0",62,10,112103,0.393701,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"14","D10P112103","R0","D10P112103R0",36,10,112103,0.393701,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"15","D10P112103","R0","D10P112103R0",53,10,112103,0.1968505,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"16","D10P112103","R0","D10P112103R0",15,10,112103,0.354330890613437,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"17","D10P112103","R0","D10P112103R0",63,10,112103,0.157480402346641,4.26509184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"18","D10P112103","R0","D10P112103R0",43,10,112103,0.393701,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"19","D10P112103","R0","D10P112103R0",4,10,112103,0.472441218773127,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"20","D10P112103","R0","D10P112103R0",79,10,112103,0.433071109386563,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"21","D10P112103","R0","D10P112103R0",66,10,112103,0.236220609386563,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"22","D10P112103","R0","D10P112103R0",28,10,112103,0.472441218773127,6.23359592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"23","D10P112103","R0","D10P112103R0",34,10,112103,0.118110304693282,4.26509184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"24","D10P112103","R0","D10P112103R0",46,10,112103,0.236220609386563,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"25","D10P112103","R0","D10P112103R0",21,10,112103,0.669291718773127,6.23359592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"26","D10P112103","R0","D10P112103R0",81,10,112103,0.275590695306718,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"27","D10P112103","R0","D10P112103R0",77,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"28","D10P112103","R0","D10P112103R0",64,10,112103,0.157480402346641,4.26509184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"29","D10P112103","R0","D10P112103R0",72,10,112103,0.472441218773127,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"30","D10P112103","R0","D10P112103R0",73,10,112103,0.354330890613437,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"31","D10P112103","R0","D10P112103R0",55,10,112103,0.1968505,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"32","D10P112103","R0","D10P112103R0",32,10,112103,1.181103,8.53018368711472,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"33","D10P112103","R0","D10P112103R0",13,10,112103,0.236220609386563,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"34","D10P112103","R0","D10P112103R0",12,10,112103,0.354330890613437,5.57742815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"35","D10P112103","R0","D10P112103R0",70,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"36","D10P112103","R0","D10P112103R0",75,10,112103,0.708661781226873,6.23359592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"37","D10P112103","R0","D10P112103R0",82,10,112103,0.157480402346641,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"38","D10P112103","R0","D10P112103R0",40,10,112103,0.787402,7.54593184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"39","D10P112103","R0","D10P112103R0",52,10,112103,0.551181390613437,5.57742815644264,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"40","D10P112103","R0","D10P112103R0",23,10,112103,0.748031890613437,6.23359592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"41","D10P112103","R0","D10P112103R0",6,10,112103,0.314960804693282,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"42","D10P112103","R0","D10P112103R0",31,10,112103,0.314960804693282,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"43","D10P112103","R0","D10P112103R0",45,10,112103,0.393701,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"44","D10P112103","R0","D10P112103R0",35,10,112103,0.354330890613437,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"45","D10P112103","R0","D10P112103R0",38,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"46","D10P112103","R0","D10P112103R0",80,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"47","D10P112103","R0","D10P112103R0",5,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"48","D10P112103","R0","D10P112103R0",60,10,112103,0.472441218773127,5.57742815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"49","D10P112103","R0","D10P112103R0",19,10,112103,0.748031890613437,6.88976368711472,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"50","D10P112103","R0","D10P112103R0",22,10,112103,0.866142218773127,7.87401631288528,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"51","D10P112103","R0","D10P112103R0",61,10,112103,0.354330890613437,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"52","D10P112103","R0","D10P112103R0",68,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"53","D10P112103","R0","D10P112103R0",33,10,112103,0.236220609386563,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"54","D10P112103","R0","D10P112103R0",76,10,112103,0.551181390613437,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"55","D10P112103","R0","D10P112103R0",3,10,112103,0.9842525,7.54593184355736,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"56","D10P112103","R0","D10P112103R0",51,10,112103,0.157480402346641,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"57","D10P112103","R0","D10P112103R0",27,10,112103,0.393701,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"58","D10P112103","R0","D10P112103R0",48,10,112103,0.511811281226873,6.23359592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"59","D10P112103","R0","D10P112103R0",18,10,112103,0.275590695306718,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"60","D10P112103","R0","D10P112103R0",65,10,112103,0.905512281226873,7.21784815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"61","D10P112103","R0","D10P112103R0",14,10,112103,0.1968505,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"62","D10P112103","R0","D10P112103R0",10,10,112103,0.669291718773127,7.21784815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,10,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"63","D10P112103","R0","D10P112103R0",25,10,112103,0.118110304693282,4.26509184355736,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"64","D10P112103","R0","D10P112103R0",24,10,112103,0.393701,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"65","D10P112103","R0","D10P112103R0",74,10,112103,0.629921609386563,6.88976368711472,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"66","D10P112103","R0","D10P112103R0",42,10,112103,0.314960804693282,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"67","D10P112103","R0","D10P112103R0",1,10,112103,2.755907,10.4986881564426,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"68","D10P112103","R0","D10P112103R0",39,10,112103,0.511811281226873,6.56168,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"69","D10P112103","R0","D10P112103R0",26,10,112103,0.433071109386563,5.57742815644264,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"70","D10P112103","R0","D10P112103R0",83,10,112103,0.314960804693282,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"71","D10P112103","R0","D10P112103R0",56,10,112103,0.275590695306718,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"72","D10P112103","R0","D10P112103R0",54,10,112103,0.157480402346641,4.59317592177868,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"73","D10P112103","R0","D10P112103R0",71,10,112103,0.314960804693282,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"74","D10P112103","R0","D10P112103R0",9,10,112103,0.433071109386563,5.57742815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"75","D10P112103","R0","D10P112103R0",84,10,112103,0.669291718773127,5.90551184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"76","D10P112103","R0","D10P112103R0",8,10,112103,0.275590695306718,4.92126,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"77","D10P112103","R0","D10P112103R0",11,10,112103,0.433071109386563,59.05512,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"78","D10P112103","R0","D10P112103R0",69,10,112103,0.157480402346641,4.26509184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"79","D10P112103","R0","D10P112103R0",50,10,112103,0.1968505,4.59317592177868,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"80","D10P112103","R0","D10P112103R0",44,10,112103,0.393701,5.24934407822132,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"81","D10P112103","R0","D10P112103R0",2,10,112103,0.354330890613437,4.92126,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"82","D10P112103","R0","D10P112103R0",78,10,112103,0.157480402346641,4.26509184355736,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"83","D10P112103","R0","D10P112103R0",29,10,112103,0.0787402011733204,4.26509184355736,0,0,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"84","D10P112103","R0","D10P112103R0",37,10,112103,0.393701,5.57742815644264,0,0,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2012,NA,NA
"85","D10P112103","R1","D10P112103R1",33,10,112103,0.708661781226873,6.56168,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"86","D10P112103","R1","D10P112103R1",48,10,112103,1.02362256245375,8.2021,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"87","D10P112103","R1","D10P112103R1",70,10,112103,0.748031890613437,6.56168,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"88","D10P112103","R1","D10P112103R1",76,10,112103,1.06299271877313,7.87401631288528,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"89","D10P112103","R1","D10P112103R1",71,10,112103,0.629921609386563,6.56168,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"90","D10P112103","R1","D10P112103R1",72,10,112103,0.826772062453747,7.87401631288528,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"91","D10P112103","R1","D10P112103R1",7,10,112103,1.61417406245375,11.48294,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"92","D10P112103","R1","D10P112103R1",111,10,112103,0.551181390613437,6.23359592177868,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"93","D10P112103","R1","D10P112103R1",114,10,112103,0.236220609386563,4.59317592177868,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"94","D10P112103","R1","D10P112103R1",34,10,112103,0.629921609386563,6.23359592177868,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"95","D10P112103","R1","D10P112103R1",74,10,112103,1.25984321877313,9.18635184355736,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"96","D10P112103","R1","D10P112103R1",42,10,112103,0.511811281226873,5.57742815644264,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"97","D10P112103","R1","D10P112103R1",102,10,112103,0.393701,5.57742815644264,0,1,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"98","D10P112103","R1","D10P112103R1",110,10,112103,0.472441218773127,5.57742815644264,0,1,NA,"ABBA","bF",0.4358,1.065,-0.0179,-0.7497,0.0251,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"99","D10P112103","R1","D10P112103R1",5,10,112103,0.629921609386563,8.2021,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,NA,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
"100","D10P112103","R1","D10P112103R1",10,10,112103,1.49606378122687,10.8267718435574,0,1,NA,"PIMA","bS",0.1324,1.1955,-0.0061,-1.2545,-0.0943,14,246,5,49.0973055553436,55.6901944446564,10,"bSbF",3,"M",10,"bS",2016,NA,NA
CodePudding user response:
This worked like a charm (thanks @DennyChen):
setDT(TreeData)[is.na(Age), Age:= ActualAge]
setDT(TreeData)[is.na(Age), Age:= InterpAge]
CodePudding user response:
According to the answer post by @UnsoughtNine :
After setDT()
, the table TreeData
had been changed to a data.table
object.
There is no need to setDT()
again in the secong line of code.
It can also work with combining %>%
pipe operator in magrittr
package :
setDT(TreeData)[is.na(Age), Age:= ActualAge] %>%
.[is.na(Age), Age:= InterpAge]