I am learning R programming and have imported the CSV file. Now, I would like to change the variable value for symbol column. If the value is "ABCD.BO" then "Stock_T". If the value is "XYZ.BO" then "Stock_Y". I tried the below code but, I am getting a warning message and I checked the dataframe contains "NA" after changing.
df$symbol[df$symbol == "ABCD.BO"] <- "Stock_T"
df$symbol[df$symbol == "XYZ.BO"] <- "Stock_Y"
Warning message:
In `[<-.factor`(`*tmp*`, df$symbol == "ABCD.BO", :
invalid factor level, NA generated
symbol Date Adj.Close
ABCD.BO 9/21/2011 201.33
ABCD.BO 9/22/2011 192.9
ABCD.BO 9/23/2011 190.47
ABCD.BO 9/26/2011 185.95
ABCD.BO 9/27/2011 190.52
ABCD.BO 9/28/2011 191.82
ABCD.BO 9/29/2011 189.49
ABCD.BO 9/30/2011 186.74
XYZ.BO 2/10/2012 334.11
XYZ.BO 2/13/2012 336.14
XYZ.BO 2/14/2012 343.74
XYZ.BO 2/15/2012 351.83
XYZ.BO 2/16/2012 352.8
XYZ.BO 2/17/2012 350
XYZ.BO 2/20/2012 350
XYZ.BO 2/21/2012 354.63
XYZ.BO 2/22/2012 333.68
XYZ.BO 2/23/2012 340.57
XYZ.BO 2/24/2012 327.9