0

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?

KaC
  • 287
  • 1
  • 5
  • 19
  • you are not updating your vector by replacing them with `toupper` output. Maybe, `dataframe$columnname <- toupper(dataframe$columnname)` will work – Jilber Urbina Apr 13 '18 at 16:33

1 Answers1

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))
Felipe Alvarenga
  • 2,572
  • 1
  • 17
  • 36