Message-ID: <955009.41605.qm@web56002.mail.re3.yahoo.com>
Date: 2009-03-23T17:39:42Z
From: Jason Rupert
Subject: Replacing a few variable values within a DataFrame...
I would like to replace a few varaibles within a data frame.
For example, in the dataframe below (contrived) I would like to replace the current housesize value only if the Location is HSV. However, I would like to leave the other values intact.
I tried "ifelse", but I don't really need the else condition.
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"))
Moreover, I want to preserve the rest of the values within the data. I thought some combination using the subset would get me there, but I ended up with a long and ungangly looking code.
Thanks for any help that is offered.