Skip to content

Replacing a few variable values within a DataFrame...

1 message · Jason Rupert

#
Phil and all, 

Thank you for the responses.  That method worked great!


However, I did try to replace the a few of the "Variables" using the same method and received an error...

test_data2_df[test_data2_df$Location == 'HSV','Variables'] = "YardSize"

Is there something special I need to do in order to replace the string characters? 

Right now it appears "NA" is being used. 

Thank you again.

test_data2_df<-data.frame(Variables=c("SQR Footage","SQR Footage","SQR Footage","SQR Footage","SQR Footage","SQR Footage","SQR Footage","SQR Footage","SQR Footage","SQR Footage","SQR Footage","SQR Footage","SQR Footage","SQR Footage","SQR Footage"), 
HouseSize=c(10, 20, 30, 40, 50, 15, 25, 35, 45, 55, 18, 28, 38, 48, 58), Lot=c(1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 11, 21, 31, 41, 51), 
Location = c("HSV", "ATH", "HSV", "ATH", "FLO", "HSV", "ATH", "HSV", "ATH",
"FLO", "HSV", "ATH", "HSV", "ATH", "FLO"))
--- On Mon, 3/23/09, Phil Spector <spector at stat.berkeley.edu> wrote: