-1
$\begingroup$

I am trying to convert a column from lower case to upper case, but it is not working.

My code:

#Change all city name in city to uppercase.
library(magrittr)
city %>% `colnames<-`(tolower(names(name))) %>% head
$\endgroup$
1
$\begingroup$

I do not understand your question completely, however if you are trying to convert text to upper case you should not use the tolower() function rather you should use the toupper() function.

For example:

toupper("A")

and if you want to make the column names uppercase I guess the syntax would be:

toupper(colnames(dataframe))
| improve this answer | |
$\endgroup$
  • $\begingroup$ Yea I have a cab file named city. In city.csv I have a Colname that is called name. I want all data under that colname name to be upper. $\endgroup$ – Chris Kehl Dec 4 '18 at 15:04
  • 1
    $\begingroup$ in that case all you need to do is colnames(dataframe) <- toupper(colnames(dataframe)) $\endgroup$ – Mohammed.T Dec 4 '18 at 15:11
  • $\begingroup$ didn't work. colnames(city$name) <- toupper(colnames(city$name)) $\endgroup$ – Chris Kehl Dec 4 '18 at 23:22
  • $\begingroup$ city[,2] = toupper(city[,2]) worked $\endgroup$ – Chris Kehl Dec 5 '18 at 0:29
  • $\begingroup$ Again your question was quite unclear, please try to be more clear. $\endgroup$ – Mohammed.T Dec 5 '18 at 9:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.