How can I download a CSV file and copy its path in read.csv()

In order to do my assignment on customer_churn dataset, it requires that have a cvs file of customer_churn in downloads and cope the path into read.csv() inside the brakets, then assign the customer_churn the name of customer_data.

Though I have installed the customer_churn into R script window. But cannot assign the new name customer_data to it.

Thanks friends I am able to copy path of customer_churn csv file from downloads!

Here is an example, with a file named grist.csv that is in my Desktop folder on an Ubuntu machine. With macOS or Windows, the path name will depend on local configuration. I use the read_csv function from {readr} but it work the same with read.csv.

name_of_object_in_R <- readr::read_csv("~/Desktop/grist.csv")
#> Rows: 3 Columns: 5
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (1): country
#> dbl (4): dog_2022, cat_2023, dog_2023, cat_2024
#> 
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
name_of_object_in_R
#> # A tibble: 3 × 5
#>   country dog_2022 cat_2023 dog_2023 cat_2024
#>   <chr>      <dbl>    <dbl>    <dbl>    <dbl>
#> 1 Norway         1        4        7        2
#> 2 UK             2        5        8        2
#> 3 USA            3        6        9        2
1 Like

I recomend you use file.choose() function.

file.choose()

This open other window, you must find the file and click in open. Next, in the console appear the direction of this file in " ". Copy this.

And paste in the read.csv()

dt<-read.csv("C:\\Users\\Downloads\\customer_data.csv") # Remember copy all  " "

Righ now, your data name is dt

For view the data

View(dt)
head(dt)
summary(dt)
1 Like

Thanks technocrat, I liked the way u gave the specification for column. Good, I will remember the code spec() for retrieval of full column>

1 Like

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.