neversaint
neversaint

Reputation: 64004

Capitalizing text of a specific column in R's data frame

I have a data that looks like this:

GO:2000974 7,8 negative_regulation_of_pro-B_cell_differentiation Notch1 ISS
GO:2000974 7,8 negative_regulation_of_pro-B_cell_differentiation Q9W737 IEA
GO:0001768 4 establishment_of_T_cell_polarity Ccl19 IEA 
GO:0001768 4 establishment_of_T_cell_polarity Ccl19 ISS 
GO:0001768 4 establishment_of_T_cell_polarity Ccl21 IEA

What I want to do is to capitalize the text of the fourth column. So for example now we have Notch1, it'll then be converted to NOTCH1. What's the way to do it in R? I'm stuck with this:

dat<-read.table("http://dpaste.com/1353034/plain/")

Upvotes: 8

Views: 21056

Answers (1)

csgillespie
csgillespie

Reputation: 60462

Just use the toupper function:

R> toupper(c("a", "ab"))
[1] "A"  "AB"

For your data frame, you will have:

dat[,4] = toupper(dat[,4])

Upvotes: 12

Related Questions