Convert Column to R dataframe to lowercase

Here are my details

summary(RecordsWithIssues)
ID             OTHERSTATE        OTHERCOUNTRY      
Length:373         Length:373         Length:373        
Class :character   Class :character   Class :character  
Mode  :character   Mode  :character   Mode  :character

> head(RecordsWithIssues)
# A tibble: 6 × 3
                  ID OTHERSTATE      OTHERCOUNTRY
               <chr>      <chr>             <chr>
1 0034000001uhro2AAA         MO              <NA>
2 0034000001uhyOsAAI       <NA>          reseller
3 0034000001uhyPJAAY       <NA>          AECbytes
4 0034000001uhyPZAAY       <NA>            Friend
5 0034000001uhyPeAAI       <NA>            client
6 0034000001uhyPnAAI       <NA>     good energies

      

I am doing the following

RecordsWithIssues[,3]=tolower(RecordsWithIssues[,3])
RecordsWithIssues[1,3]
# A tibble: 1 × 1
                                                                                                             OTHERCOUNTRY
                                                                                                                    <chr>
1 c(na, "reseller", "aecbytes", "friend", "client", "good energies", "boss", "friend", "linkedin", "aecbytes", "
> 

      

As you can see, the dataframe now has a vector instead of a single text value. How can I just convert the string without getting the text

+3


source to share


2 answers


We need to retrieve using [[

as the dataset also includes a classtbl_df

RecordsWithIssues[[3]] <- tolower(RecordsWithIssues[[3]])

      



Or $

RecordsWithIssues$OTHERCOUNTRY <- tolower(RecordsWithIssues$OTHERCOUNTRY)

      

+6


source


require(tidyverse)

RecordsWithIssues %>% mutate(OTHERCOUNTRY = tolower(OTHERCOUNTRY))

      



+1


source







All Articles