0
votes

I'm trying to read this csv file in R. (scores.csv)

ALVO,P,Prediction,fold
1,0.9079557994069131,"1",0
1,0.4323657303144317,"0",0
1,0.9944246408740756,"1",0
1,0.8025072441292207,"1",0
1,0.8687043760021418,"1",0
1,0.8728815023271057,"1",0
1,0.9998157504312343,"1",0
1,0.6610699528239422,"1",0
1,0.9994385364719802,"1",0

I've tried this:

result <- read.csv("C:/scores.csv", header = TRUE, sep = ",", quote = "\"")

AND THIS:

result <- read.csv("C:/scores.csv")

It's not working, I'm getting the P,Prediction,fold with NA values

head(result)

but I got this:

                        ALVO  P Prediction fold
1 1,0.9079557994069131,"1",0 NA         NA   NA
2 1,0.4323657303144317,"0",0 NA         NA   NA
3 1,0.9944246408740756,"1",0 NA         NA   NA
4 1,0.8025072441292207,"1",0 NA         NA   NA
5 1,0.8687043760021418,"1",0 NA         NA   NA
6 1,0.8728815023271057,"1",0 NA         NA   NA

Someone already have done that?

please help!

1
Simple read.csv with just the file name reads it fine. Is that not what you want?Gopala
I already tried that, but I getting the P, Prediction and fold columns ans NA it's not separating the variables between commas @user3949008Alvaro Joao
It may be that there is more to this data and an error somewhere else in the file. Your sample input is being read properly in my console. Perhaps restarting your R console and trying is worth it?Gopala
@user3949008 it worked !! Do you know why this kind of sh*t happens?Alvaro Joao
@AlvaroJoao "Do you know why" : yep. Windows.hrbrmstr

1 Answers

2
votes

Unix cat output is below:

> cat input.csv 
ALVO,P,Prediction,fold
1,0.9079557994069131,"1",0
1,0.4323657303144317,"0",0
1,0.9944246408740756,"1",0
1,0.8025072441292207,"1",0
1,0.8687043760021418,"1",0
1,0.8728815023271057,"1",0
1,0.9998157504312343,"1",0
1,0.6610699528239422,"1",0
1,0.9994385364719802,"1",0

R output is below:

read.csv('input.csv')
  ALVO         P Prediction fold
1    1 0.9079558          1    0
2    1 0.4323657          0    0
3    1 0.9944246          1    0
4    1 0.8025072          1    0
5    1 0.8687044          1    0
6    1 0.8728815          1    0
7    1 0.9998158          1    0
8    1 0.6610700          1    0
9    1 0.9994385          1    0