0

I was having difficulties importing an excel sheet into R (csv). However, after reading this post, I was able to successfully import it. However, I noticed that some of the numbers in a particular column have transformed into unwanted characters-"Ï52,386.43" "Ï6,887.61" "Ï32,923.45". Any ideas how I can change these to numbers?

Here's my code below:

df <- read.csv("data.csv", header = TRUE, strip.white = TRUE,
                fileEncoding="latin1",  stringsAsFactors=FALSE)

I've also tried fileEncoding = "UTF-8" but this doesn't work-I'm getting the following warning:

Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote,  :
                 invalid input found on input connection 'data.csv'
               2: In read.table(file = file, header = header, sep = sep, quote = quote

I am using a mac with "R version 3.2.4 (2016-03-10)" (if that makes any difference). Here are the first ten entries from the affected column:

 [1] "Ï52,386.43" "Ï6,887.61" "Ï32,923.45" ""           "Ï82,108.44"
 [6] "Ï6,378.10"  ""           "Ï22,467.43" "Ï3,850.14"  "Ï5,547.83" 
Community
  • 1
  • 1
John_dydx
  • 951
  • 1
  • 14
  • 27

1 Answers1

0

It turns out the issue was a pound sign that got changed into Ï in the process of saving an xls file into csv format (in windows-opened in a mac). Thanks for your replies.

John_dydx
  • 951
  • 1
  • 14
  • 27