-2

So I have a text column in data frame:

stocksavailable

140,13-,3-,40-,2- 

The numbers 13-, 2- and 3- are incorrect while extracting, can we get something like this using R code?

stocksavailable
140,-13,-3,-40,-2
Biffen
  • 6,249
  • 6
  • 28
  • 36
  • What have you tried?. also if you want an answer in R please tag it to your question to attract more accurate attention –  Sep 30 '18 at 20:12
  • have you tried any thing, so please share your result so anyone can suggest based on it. – Arif Rathod Oct 01 '18 at 04:59

1 Answers1

-1

Assuming the numbers are integers, try: (\d+)(\-)?

Demo

You should be able to use the gsub method like this

Matt.G
  • 3,586
  • 2
  • 10
  • 23