I'm converting my teaching examples over to the readr package's functions. It looks like read_csv can't accept input from either stdin or textConnection. These provide handy ways to put data in the middle of a program so you don't have to worry how students have their paths set. My examples are below. I hope I've made an error or there's a bug in read_csv, but perhaps read_csv just can't work this way as read.csv can.
> mystring <- "id,workshop,gender,q1,q2,q3,q4
+ 1,1,f,1,1,5,1
+ 2,2,f,2,1,4,1
+ 3,1,f,2,2,4,3
+ 4,2,NA,3,1,NA,3
+ 5,1,m,4,5,2,4
+ 6,2,m,5,4,5,5
+ 7,1,m,5,3,4,4
+ 8,2,m,4,5,5,5"
> mydata <- read_csv( textConnection("mystring") )
Error: can only read from a binary connection
> mydata <- read_csv( stdin() )
Error: can only read from a binary connection
> id,workshop,gender,q1,q2,q3,q4
Error: unexpected ',' in "id,"
> 1,1,f,1,1,5,1
Error: unexpected ',' in "1,"
> 2,2,f,2,1,4,1
Error: unexpected ',' in "2,"
> 3,1,f,2,2,4,3
Error: unexpected ',' in "3,"
> 4,2,NA,3,1,NA,3
Error: unexpected ',' in "4,"
> 5,1,m,4,5,2,4
Error: unexpected ',' in "5,"
> 6,2,m,5,4,5,5
Error: unexpected ',' in "6,"
> 7,1,m,5,3,4,4
Error: unexpected ',' in "7,"
> 8,2,m,4,5,5,5
Error: unexpected ',' in "8,"
>
> # Blank line above ends input.
> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] readr_0.1.1
loaded via a namespace (and not attached):
[1] tools_3.2.0 Rcpp_0.11.6