[R] Accessing Data From packages
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Thu Feb 27 16:36:21 CET 2020
On 27/02/2020 10:05 a.m., Phillip Heinrich wrote:
> I am continuing to have problems downloading data as prescribed in books
> about R such as “Analyzing Baseball Data with R”.
>
> In chapter 3 (page 67) the instructions to download baseball Hall of Fame
> data from the package tidyverse are:
>
> library(tidyverse)
> -- Attaching packages --------------------------------------- tidyverse
> 1.3.0 -- v ggplot2 3.2.1
> v purrr 0.3.3 v tibble 2.1.3
> v dplyr 0.8.3 v tidyr 1.0.0 v stringr 1.4.0
> v readr 1.3.1 v forcats 0.4.0
>
> -- Conflicts ------------------------------------------
> tidyverse_conflicts() -- x dplyr::filter() masks stats::filter()
> x dplyr::lag() masks stats::lag()
> Warning messages: 1: package ‘tidyverse’ was built under R version 3.6.2 2:
> package ‘purrr’ was built under R version 3.6.2
>
> The package seems to load correctly but when I try to call up the data I get
> an error message.
> ***********************************************************************************************
>
>> hof <- read_csv("data/hofbatting.csv")
>
> Error: 'data/hofbatting.csv' does not exist in current working directory
> ('C:/Users/Owner/Documents').
>
> ***********************************************************************************************
> I have no idea where the data is hiding. Can someone give me some
> directions.
It's not clear from your message whether you have the file on your disk
or not. If you do, then instead of giving the name, try using the
file.choose() function, e.g.
filename <- file.choose()
hof <- read_csv(filename)
That will open a standard dialog to allow you to specify the filename
correctly. If you don't know where to look for it, I can't help:
presumably instructions are given in the book, but I don't have a copy.
You'll just have to read more of it.
Duncan Murdoch
More information about the R-help
mailing list