syntax for importing csv file

New to R - I've been entering code to import and merge some Excel files. But the Posit Cloud console commands are not getting results - numerous attempts all give error messages (or zero characters when I try the list command to see my computer's csv files). I have Excel 2007 - is that too old to be recognized? Here is the code and error messages when trying to import after installing tidyverse, readr, and here. I tried different extensions to see if something would work.

library(tidyverse)
── Attaching core tidyverse packages ─────────────── tidyverse 2.0.0 ──
:heavy_check_mark: dplyr 1.1.2 :heavy_check_mark: readr 2.1.4
:heavy_check_mark: forcats 1.0.0 :heavy_check_mark: stringr 1.5.0
:heavy_check_mark: ggplot2 3.4.2 :heavy_check_mark: tibble 3.2.1
:heavy_check_mark: lubridate 1.9.2 :heavy_check_mark: tidyr 1.3.0
:heavy_check_mark: purrr 1.0.1
── Conflicts ───────────────────────────────── tidyverse_conflicts() ──
:heavy_multiplication_x: dplyr::filter() masks stats::filter()
:heavy_multiplication_x: dplyr::lag() masks stats::lag()
:information_source: Use the conflicted package to force all conflicts to become errors
install.packages("here")
Installing package into ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.3’
(as ‘lib’ is unspecified)
also installing the dependency ‘rprojroot’

trying URL 'http://rspm/default/__linux__/focal/latest/src/contrib/rprojroot_2.0.3.tar.gz'
Content type 'application/x-gzip' length 101201 bytes (98 KB)

downloaded 98 KB

trying URL 'http://rspm/default/__linux__/focal/latest/src/contrib/here_1.0.1.tar.gz'
Content type 'application/x-gzip' length 52764 bytes (51 KB)

downloaded 51 KB

  • installing binary package ‘rprojroot’ ...
  • DONE (rprojroot)
  • installing binary package ‘here’ ...
  • DONE (here)

The downloaded source packages are in
‘/tmp/Rtmpqo5CVD/downloaded_packages’

library(here)
here() starts at /cloud/project
library(readr)
DF <- read_csv("cyclistic_july.csv")
Error: 'cyclistic_july.csv' does not exist in current working directory ('/cloud/project').
d <- read_csv("cyclistic_july.csv")
Error: 'cyclistic_july.csv' does not exist in current working directory ('/cloud/project').
DF <- read_csv("202207-divvy-tripdata.csv")
Error: '202207-divvy-tripdata.csv' does not exist in current working directory ('/cloud/project').
d <- read_csv("202207-divvy-tripdata.csv")
Error: '202207-divvy-tripdata.csv' does not exist in current working directory ('/cloud/project').
library(readxl)
df <- read_excel("path/to/202207-divvy-tripdata.xlsx")
Error: path does not exist: ‘path/to/202207-divvy-tripdata.xlsx’
df <- read_excel("path/to/Cyclistic - July 2022.xlsb")
Error: path does not exist: ‘path/to/Cyclistic - July 2022.xlsb’
df1 <- read_excel("path/to/Cyclistic - July 2022.xlsb")
Error: path does not exist: ‘path/to/Cyclistic - July 2022.xlsb’
df1 <- read_excel("path/to/Cyclistic-July 2022.xlsb")
Error: path does not exist: ‘path/to/Cyclistic-July 2022.xlsb’
list.files(pattern = "csv")
character(0)
list.files(pattern = "xlsb")
character(0)

I assume that you used Excel 2007 on your computer to create the cyclistic_july.csv and other csv files. Did you then upload those files to Posit Cloud? If not, R will not be able to find them. Click on the Files tab in the lower right pane in RStudio, then click on the the Upload tab. Click on the Choose File button and navigate to the csv file on your computer. Select the file and click on Open and then OK. Go back to the Files tab and verify that the file has been uploaded.

Hello EconProf - in case you didn't get my acknowledgement of your reply, thank you. When I studied the instructions I received in my boot-camp and scripts elsewhere, there was no mention of having to do the uploading first. I thought because I was working on the same computer that holds the csv files that the function would "read" those files. I'm surprised that none of the scripts I perused made mention of this basic, initial step.

This topic was automatically closed 21 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.