Christian Schulz
2004-Jul-02 15:03 UTC
[R] replace values but different replacement length
Hi, have anybody a hint/help how it's possible replace i.e. the NA values from BL02DATE with non-Missing values from BLOCKED and vice versa. Both variables are with an id in a 188.249 rows data.frame and my fr function didn't count the NA's. Many thanks Christian>>fr(BL02DATE)Count Prcnt 1 140660 84.6 2 25589 15.4 Total 166249 100.0>>fr(BLOCKED)Count Prcnt 1 151982 85.4 2 25976 14.6 Total 177958 100.0>>match02$BL02DATE[is.na(match02$BL02DATE)] <- match02$BLOCKEDWarning message: number of items to replace is not a multiple of replacement length
What are the lengths of match02$BL02DATE[is.na(match02$BL02DATE)] and match02$BLOCKED? In particular, have you considered the following: match02$BL02DATE[is.na(match02$BL02DATE)] <- match02$BLOCKED[is.na(match02$BL02DATE)] hope this helps. spencer graves Christian Schulz wrote:>Hi, > >have anybody a hint/help how it's possible replace i.e. >the NA values from BL02DATE with non-Missing >values from BLOCKED and vice versa. >Both variables are with an id in a 188.249 rows data.frame and >my fr function didn't count the NA's. > >Many thanks >Christian > > > > >>>fr(BL02DATE) >>> >>> > Count Prcnt >1 140660 84.6 >2 25589 15.4 >Total 166249 100.0 > > > >>>fr(BLOCKED) >>> >>> > Count Prcnt >1 151982 85.4 >2 25976 14.6 >Total 177958 100.0 > > > >>>match02$BL02DATE[is.na(match02$BL02DATE)] <- match02$BLOCKED >>> >>> >Warning message: number of items to replace is not a multiple of >replacement length > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >