0

Below Data is my working data **

Brand CompanyAdvertising**

Apple $719M

Google $3.6B

Microsoft $3.2B

CocaCola $4B

Facebook $281M

Disney $120M

I want to convert the above data into below data ( in company advertising column want to change all values into Numeric and in same unit i.e in Billions)

Brand CompanyAdvertising

Apple .719

Google 3.6

Microsoft 3.2

CocaCola 4

Facebook .281

Disney .120

I request to please help me. I am currently doing it like this way i am as.numeric(gsub('[$,M]', "", data$CompanyAdevertising))*1e-3.....Now that ouput which i am getting is

**.719 NA NA NA .281 .120

Warning message:

NAs introduced by coercion**

prtkpande
  • 15
  • 3
  • want to do it in R. also not a proper view is coming. both are data frames with columns Brand and Company advertising – prtkpande Dec 03 '16 at 10:17
  • bdw the values in the output mentioned are wrong – joel.wilson Dec 03 '16 at 10:29
  • You would be more likely to get help if you tried something out (with code) and posted that. – Mike Wise Dec 03 '16 at 10:35
  • @ Joel : Thanks i guess now it is corrected. can you please help me with this – prtkpande Dec 03 '16 at 10:37
  • @Mike : Thanks for your suggestion. I am trying like this as.numeric(gsub('[$,M]', "", data$coloumn)) , but it is not working. Really appreciate if you can help me with this. – prtkpande Dec 03 '16 at 10:39
  • No, I mean a complete, but small example. Otherwise know as a MCVE. http://stackoverflow.com/help/mcve. Should be like 10 lines. That is the best way to get people to help you - and it is also the best way to learn. – Mike Wise Dec 03 '16 at 10:50
  • @ Mike : Thanks, will try to mention what i am doing and what error i am getting, may be them i can get help – prtkpande Dec 03 '16 at 10:53

0 Answers0