an error readr function on importing a csv file

Hello R community, am new in R, but have a challenge in importing this CSV file, could you please help me where i could be maiking a mistake

library(tidyverse)
library(readr)
heights <- read_csv("heights.csv")

it brings this error message

Error in vec_as_location():
0s! ... must be empty.
x Problematic argument:

  • call = call
    Run rlang::last_error() to see where the error occurred.

Hey there,

It is hard to know without a reproducible example (see r faq - How to make a great R reproducible example - Stack Overflow). But try a full file path name. So instead of read_csv("heights.csv") try read_csv("C:\Users\something\something\heights.csv"). To get a full path, press shift and right click, then copy as path.

Also, for the future, check https://here.r-lib.org/ and 8 Workflow: projects | R for Data Science.

Best of luck!

Hi @Paulius , if you dont set the work directory you don't load the file in this form.

put this in the console:

file.choose()

This show a new small windows. Here you need find the .csv file, and press open.
The result is a path of this file, like this in my case:

"D:\\OneDrive - CGIAR\\Documents\\ans.csv"

Next you need paste this in read_csv function.

library(tidyverse)
library(readr)
heights <- read_csv("D:\\OneDrive - CGIAR\\Documents\\ans.csv")

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.