Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (50.2k points)
edited by
How can I change string variable datatype to integer datatype in a .csv data-set. For example:

The original data is ">200000" and I want to remove that '>" from the data. The desired output should be: 200000

1 Answer

0 votes
by (107k points)

I don't know about your data-set, so I will provide you the common solution.

In the below r programming code, the df is the data-frame on which I have imported my .csv data-set.

df$col[df$col == ">200000"] <- 200000

Or:

df$col <- replace(as.numeric(df$col), df$col == ">200000", "200000")

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...