The new recommended way to do this is to use the
setNames function. See
?setNames. Since this creates a new copy of the
data.frame, be sure to assign the result to the original
data.frame, if that is your intention.
data_frame <- setNames(data_frame, c("premium","change","newprice"))
Newer versions of R will give you warning if you use
colnames in some of the ways suggested by earlier answers.
If this were a
data.table instead, you could use the
setnames, which can modify specific column names or a single column name by reference:
setnames(data_table, "old-name", "new-name")