Reputation: 181
Here is my data
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 do 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 data frame now has a vector instead of single text value. How can I simply convert the string without getting the text
Upvotes: 13
Views: 58238
Reputation: 3973
The data.table way:
require(data.table)
setDT(RecordsWithIssues)
RecordsWithIssues[ , OTHERCOUNTRY := tolower(OTHERCOUNTRY) ]
Upvotes: 1
Reputation: 11
Here is my data
head(rounds2)
rounds2_lower <-data.frame(tolower(rounds2$company_permalink))
rounds2_final <- cbind(rounds2,rounds2_lower)
> names(rounds2_final)
[1] "company_permalink" "funding_round_permalink"
[3] ""tolower.rounds2.company_permalink."
names(rounds2_final)[3] <- "company_permalink_lower"
Upvotes: 0
Reputation: 21497
require(tidyverse)
RecordsWithIssues %>% mutate(OTHERCOUNTRY = tolower(OTHERCOUNTRY))
Upvotes: 10
Reputation: 887118
We need to extract with [[
as the dataset also include the tbl_df
class
RecordsWithIssues[[3]] <- tolower(RecordsWithIssues[[3]])
Or $
RecordsWithIssues$OTHERCOUNTRY <- tolower(RecordsWithIssues$OTHERCOUNTRY)
Upvotes: 20