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 in Data Analytics by ch
• 3,290 points
13 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 by anonymous
• 31,840 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
1,503 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,690 points
64 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
• 42,410 points
51 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,040 points
43 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
116 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
160 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
87 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
104 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 in Data Analytics by anonymous
• 31,840 points
8,500 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 in Data Analytics by anonymous
• 31,840 points
31 views