[R] Issue with Transform function in R
    Bhaskar Mitra 
    bhaskar.kolkata at gmail.com
       
    Thu Jul 21 03:00:58 CEST 2016
    
    
  
Hello Everyone,
I am trying to replace the values in the 2nd column (Variable 1)
corresponding to certain dates  (Date)
with NAs as shown below. Both Date and Variable1 are numeric vectors . I am
trying to use the transform function
as shown below but it doesn’t seem to work even though if I am not getting
any error
Any suggestions/help in this regard?
regards,
---------------------------------------------------------------------------------------------------------------------------------------------------------
Df1 <- data.frame(Date, Variable1)
a1 <- transform(Df1, ifelse(Date  > "010301000300 " && Date <
"010501000300", Variable1 ==NA, Variable1))
Original Data frame
     Date                          Variable1
010101000300                     1
010201000300                     2
010301000300                     3
010401000300                     4
010501000300                     5
010601000300                     6
010701000300                     7
 .
.
.
……….
Transformed data frame (i hope to transform)
      Date                       Variable1
010101000300                    1
010201000300                    2
010301000300                   NA
010401000300                   NA
010501000300                    NA
010601000300                    6
010701000300                    7
……….
	[[alternative HTML version deleted]]
    
    
More information about the R-help
mailing list