Hi, people!
I will appreciate that someone could help me with this problem. I have a data with 4 columns and I want to create the 5 th new with some condictions.
This input data is in data.frame format is:
ALT_ORT,ALTGEOM,ALT_NORMAL,N,
2.8,,,-33.62,
3.2,,,-33.65,
,,46.4603,-7.88,
514.17,,,-6.09,
I tried to used this scrip
if (is.na("ALTGEOM")==FALSE){
t1$ALTGEOM2 <- t1$ALTGEOM
} else if (is.na("ALT_ORT")==FALSE) {
t1$ALTGEOM2 <-t1$ALT_ORT+ t1$N
} else {
t1$ALTGEOM2 <-t1$ALT_NORMAL + t1$N
}
And I would like this output file:
ALT_ORT,ALTGEOM,ALT_NORMAL,N,ALTGEOM2
2.8, , ,-33.62,-30.82
3.2, , ,-33.65,-30.45
, ,46.4603,-7.88, 38.5803
,514.17, , ,514.17
However, the real output is that:
ALT_ORT,ALTGEOM,ALT_NORMAL,N,ALTGEOM2
2.8, , ,-33.62,
3.2, , ,-33.65,
, ,46.4603,-7.88,
,514.17, , ,514.17
Does someone knows how can I do?
Thanks in advanced,
Elaine Loureiro