bad 'file' argument in RStudio

Hey All,

I am a true beginner, reached out to my professor and she instructed me to create a post in here, rather than look into it herself....so here I am!

The instructions in our homework say, "Now load the admissions data set, which contains admission information for men and women across six majors and keep only the admitted percentage column: " and provides the code below

 load(admissions)
 dat <- admissions %>% select(-applicants)

I have ensured that I have tidyverse and dslabs already installed. But I continually get this error:

 Error in load(admissions) : bad 'file' argument 

Does anyone know if I am doing something incorrectly? Or could it be an outdated dataset or something?

Try

load("admissions")

I get a different error:

  Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
 In addition: Warning messages:
 1: package ‘dplyr’ was built under R version 4.2.1 
 2: In readChar(con, 5L, useBytes = TRUE) :
   cannot open compressed file 'admissions', probable reason 'No such file or directory'

I told my professor that I suspected this dataset was outdated or may no longer exist as written....but I am not knowledgeable enough to say with 100% certainty

Where is this data supposedly coming from?

You write that the instructions say

*The instructions in our homework say, "Now load the admissions data set, which contains admission information for men and women across six majors and keep only the admitted percentage column: " *

Is there anything in the homework instructions about installing an R package or loading a library? Possibly in earlier instructions? I suspect that we may be dealing with a dataset specifically constructed for your course.

That first warning messaage suggests that you are not using the most recent version of R which is 4.2.1 under which it looks like dplyr was compiled. I do not think is is anything to worry about.

admissions is part of the dslabs package. Load that package using the library() function.

library(tidyverse)
library(dslabs)

dat <- admissions %>% select(-applicants)
dat
#>    major gender admitted
#> 1      A    men       62
#> 2      B    men       63
#> 3      C    men       37
#> 4      D    men       33
#> 5      E    men       28
#> 6      F    men        6
#> 7      A  women       82
#> 8      B  women       68
#> 9      C  women       34
#> 10     D  women       35
#> 11     E  women       24
#> 12     F  women        7

Created on 2022-07-24 by the reprex package (v2.0.1)

Ah, thanks. My googling missed it.

@ KSant1717

Note that you do not need to use load() if you do as @ EconProf suggests and use

library(dslabs)

I had dslabs and tidyverse libraries loaded. Completely removing this line worked!

  load(admissions)

Thank you all!

Great!
Would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

https://support.rstudio.com/hc/en-us/articles/200534577-Resetting-RStudio-Desktop-s-Statehttps://forum.posit.co/t/faq-how-do-i-mark-a-solution/5633

Have fun with R :smiling_imp:

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.