I have a notepad txt file called inflation.txt
.
The file has two columns (delimited with a "space") and looks something like this:
1950-1 0.0084490544865279
1950-2 −0.0050487986543660
1950-3 0.0038461526886055
1950-4 0.0214293914558992
1951-1 0.0232839389540449
1951-2 0.0299121323429455
1951-3 0.0379293285389640
1951-4 0.0212773984472849
I am trying to import this file into R.
Reading this previous stackoverflow post over here Reading text file with multiple space as delimiter in R , I adapted the code for my problem
data <- read.table("inflation.txt", sep = "" , header = F ,
na.strings ="", stringsAsFactors= F)
But when I run the above code, an unwanted character appears ( " −") :
> head(data)
V1 V2
1 1950-1 0.0084490544865279
2 1950-2 −0.0050487986543660
3 1950-3 0.0038461526886055
4 1950-4 0.0214293914558992
5 1951-1 0.0232839389540449
6 1951-2 0.0299121323429455
Can someone please show me what I am doing wrong? Is the data getting corrupted? Is there a way to fix this problem?