Error importing .csv data into RStudio

1

When I'm going to import and create a file my data to R it's error ...

I tried the following path:

 melipona <- paste(system.file(package="dismo"), "/ex/Melipona.csv", sep=";")


 melipona<-read.csv(melipona,header=TRUE,sep=";")

The following error appears:

  

Error in file (file, "rt"): can not open the connection In addition:   Warning message: In file (file, "rt"): can not open file   'C: /Users/N1na3/Documents/R/win-library/3.4/dismo/ex/Melipona.csv': No   such file or directory

I have tried to use file.choose() but it only reads and does not create the file, so a part arrives that it does not work. When I give the command list.files() g it appears my file, I used getwd() to see if it was in the same place and it is ...

    
asked by anonymous 14.07.2017 / 17:04

1 answer

2

The file Melipona.csv is not located in the C:/Users/N1na3/Documents/R/win-library/3.4/dismo/ex/ directory. I have listed the contents of this directory on my computer and there are only two .csv files, called acaule.csv and bradypus.csv .

$ ls /Library/Frameworks/R.framework/Versions/3.4/Resources/library/dismo/ex/
total 1696
-rw-rw-r--  1 root  admin   191K Apr 21 21:02 acaule.csv
-rw-rw-r--  1 root  admin   487B Apr 21 21:02 bio1.grd
-rw-rw-r--  1 root  admin    70K Apr 21 21:02 bio1.gri
-rw-rw-r--  1 root  admin   487B Apr 21 21:02 bio12.grd
-rw-rw-r--  1 root  admin    70K Apr 21 21:02 bio12.gri
-rw-rw-r--  1 root  admin   487B Apr 21 21:02 bio16.grd
-rw-rw-r--  1 root  admin    70K Apr 21 21:02 bio16.gri
-rw-rw-r--  1 root  admin   487B Apr 21 21:02 bio17.grd
-rw-rw-r--  1 root  admin    70K Apr 21 21:02 bio17.gri
-rw-rw-r--  1 root  admin   486B Apr 21 21:02 bio5.grd
-rw-rw-r--  1 root  admin    70K Apr 21 21:02 bio5.gri
-rw-rw-r--  1 root  admin   488B Apr 21 21:02 bio6.grd
-rw-rw-r--  1 root  admin    70K Apr 21 21:02 bio6.gri
-rw-rw-r--  1 root  admin   486B Apr 21 21:02 bio7.grd
-rw-rw-r--  1 root  admin    70K Apr 21 21:02 bio7.gri
-rw-rw-r--  1 root  admin   487B Apr 21 21:02 bio8.grd
-rw-rw-r--  1 root  admin    70K Apr 21 21:02 bio8.gri
-rw-rw-r--  1 root  admin   477B Apr 21 21:02 biome.grd
-rw-rw-r--  1 root  admin    35K Apr 21 21:02 biome.gri
-rw-rw-r--  1 root  admin   4.0K Apr 21 21:02 bradypus.csv

As I do not have access to your computer, I can only speculate on a possible solution to your problem. Do the following:

1) Copy the file Melipona.csv to somewhere known within your computer. For example, a Documents / Dissertation / Melipona / Analyze folder

2) Within RStudio, go to the Session > Set Working Directory > Choose Directory. Navigate to the directory where the Melipona.csv file is stored.

3)Runthecommand

melipona<-read.csv("Melipona.csv", header=TRUE, sep=";")

This should finish reading your file without major problems.

    
14.07.2017 / 19:38