1

When i use "read_csv" it removes a value that not match with the column_type and i don´t able to see it after reading it on my new data frame

i´ve read the documentation and it says the function takes the first 1000 rows to determine the data type of the column (correct me if im wrong).

the column that i have issues has Reviews (numeric) but there is one value that contains 3.0M this value returns me "NA"

data1 <- read_csv("googleplaystore.csv", col_names = TRUE, col_types = 
cols(.default = "i"))

i expect the output keep "3.0M" because i will replace it:

data1$Reviews <- gsub("3.0M","3000000",data1$Reviews)

Finally i found the solution to keep the "3.0M"

data1 <- read_csv("googleplaystore.csv",  col_types = cols(.default = "c"))

So i can replace the "3.0M" to "3000000" intead!

data1$Reviews <- gsub("3.0M","3000000",data1$Reviews)
  • 1
    Try reading it as string (`char`) first, then convert those values such as `"3.0M"` to `"3000000"` using functions from `stringr` for instance, and lastly coerce that column to `integer` type. – Ramiro Magno Jan 26 '19 at 17:20
  • 1
    i find a way to resolve that!!! data1 <- read_csv("googleplaystore.csv", col_types = cols(.default = "c")) i hope someone find this helpful! – Raul Guerrero Jan 26 '19 at 17:52
  • Related: [Convert from billion to million and vice versa](https://stackoverflow.com/q/38013217/914686); [Changing Million/Billion abbreviations into actual numbers? ie. 5.12M -> 5,120,000](https://stackoverflow.com/q/45972571/914686) – Werner Jan 26 '19 at 19:06

0 Answers0