I want to transform the contents of a factor column in a dataframe from lowercase to upper case. The function toupper(dataframe$columnname) prints the contents in uppercase, but nothing actually seems to happen to the contents. When I check using levels(dataframe$columnname) or just visually inspecting the dataframe, the contents are still in lowercase. What I am doing wrong?
Asked
Active
Viewed 725 times
1 Answers
1
To change your data.taframe's content you must alter the columns values
dataframe$columnname <- toupper(dataframe$columnname)
Although, if you want to play with characters, do it like
dataframe$columnname <- toupper(as.character(dataframe$columnname))

Roberto Moratore
- 178
- 10

Felipe Alvarenga
- 2,572
- 1
- 17
- 36