How do I change a single value in a data.frame?

Per Månsson picture Per Månsson · Feb 8, 2013 · Viewed 109.8k times · Source

Could anyone explain how to change a single cell in a data.frame to something else. Basically I just want to rename that one cell, not all cells which matches it. I can´t use the edit() command because it will screw up my script since im using the data.frame on several occasions.

Thanks in advance

Answer

Marcel Hebing picture Marcel Hebing · Feb 8, 2013
data.frame[row_number, column_number] = new_value

For example, if x is your data.frame:

x[1, 4] = 5