Remove characters from field in dataframe

0 votes
I'm using superstore dataset from kaggle. Sales and profit column has $ symbol so R stored it as character datatype how to change it back to an integer data type. Can someone help
Oct 14, 2019 in Data Analytics by ch
• 3,380 points
35 views

1 answer to this question.

0 votes

Use the below code to update the sales and profit field data type and values.

superstore$Sales = substring(superstore$Sales,2)
superstore$Profit = substring(superstore$Profit,2)
# Change the data type as integer/ numeric
class(superstore$Sales) = "Numeric"
# Or
superstore$Sales= as.numeric(superstore$Sales)
answered Oct 14, 2019 by anonymous
• 32,440 points

Related Questions In Data Analytics

0 votes
1 answer

How to convert dataframe columns from factors to characters?

To replace all the variables to character ...READ MORE

answered Apr 13, 2018 in Data Analytics by BHARANI
• 410 points
5,384 views
0 votes
1 answer

Reshape dataframe without “timevar” from long to wide format in R

Assuming that the data is in the ...READ MORE

answered Jun 13, 2018 in Data Analytics by CodingByHeart77
• 3,710 points
113 views
0 votes
1 answer

Remove NA values from the output in R programming

Edit your code: columnmean <- function(x, removeNA = ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 51,830 points
60 views
0 votes
1 answer

Filter something from dataframe in an order in R

You can use conditional filtering for this ...READ MORE

answered Dec 12, 2018 in Data Analytics by Maverick
• 10,800 points
69 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
308 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
269 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,720 points
114 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
163 views
0 votes
4 answers

How to remove NA values from a Vector in R?

You can try na.omit() or na.exclude() too. ...READ MORE

answered Jul 31, 2019 in Data Analytics by anonymous
• 32,440 points
19,642 views
0 votes
1 answer

Read data from various csv and store it in one dataframe

Use rbind() to join both data frames ...READ MORE

answered Jul 4, 2019 in Data Analytics by anonymous
• 32,440 points
52 views