I'm a little stuck with creating a new Layer column in the dataset below:
> head(Sites.merge)
Echo_ID Layer Interval Lat_M Lon_M Target_depth_mean Depth_mean ADens
[1,] "20180919_PS-1105_BN_1" "0" "14" "26.28209994" "-97.04343251" "0" " " "0"
[2,] "20180919_PS-1105_BN_1" "0" "15" "26.28205407" "-97.04343251" "0" " " "0"
[3,] "20180919_PS-1105_BN_1" "0" "16" "26.2820098" "-97.04343558" "0" " " "0"
[4,] "20180919_PS-1105_BN_1" "0" "17" "26.28196587" "-97.04344517" "0" " " "0"
[5,] "20180919_PS-1105_BN_1" "0" "18" "26.28192194" "-97.04346068" "0" " " "0"
[6,] "20180919_PS-1105_BN_1" "0" "19" "26.28187837" "-97.04346667" "0" " " "0"
Echo_ID_Layer numID sum Echo_max_depth_m S_type DepthZone
[1,] "20180919_PS-1105_BN_1_Layer_0" "1" "13.4396280406658" "16.79" "Artificial" "Nearshore"
[2,] "20180919_PS-1105_BN_1_Layer_0" "1" "13.4396280406658" "16.79" "Artificial" "Nearshore"
[3,] "20180919_PS-1105_BN_1_Layer_0" "1" "13.4396280406658" "16.79" "Artificial" "Nearshore"
[4,] "20180919_PS-1105_BN_1_Layer_0" "1" "13.4396280406658" "16.79" "Artificial" "Nearshore"
[5,] "20180919_PS-1105_BN_1_Layer_0" "1" "13.4396280406658" "16.79" "Artificial" "Nearshore"
[6,] "20180919_PS-1105_BN_1_Layer_0" "1" "13.4396280406658" "16.79" "Artificial" "Nearshore"
Subregion midLayer school.depth newLayer schoolLayer
[1,] "South" "1.679" " " "1" " "
[2,] "South" "1.679" " " "1" " "
[3,] "South" "1.679" " " "1" " "
[4,] "South" "1.679" " " "1" " "
[5,] "South" "1.679" " " "1" " "
[6,] "South" "1.679" " " "1" " "
The current "Layer" column has some right values but most of them are wrong so I'm trying to essentially piece together a new Layer column using values from other columns that I have created:
#the first one doesn't work
Sites.merge$artLayer = ifelse(Sites.merge$Target_depth_mean == 0 & Sites.merge$school.depth == "NA", Sites.merge$Layer, Sites.merge$newLayer)
Sites.merge$schLayer = ifelse(Sites.merge$Depth_mean != "NA", Sites.merge$schoolLayer, Sites.merge$artLayer)
Sites.merge$Layer = ifelse(Sites.merge$S_type == "Artificial", Sites.merge$artLayer, Sites.merge$Layer)
In the ifelse statements below the "TRUE" statement works but the "FALSE" statement don't. Any help would be greatly appreciated. Thank you!
Aucun commentaire:
Enregistrer un commentaire