RDataset: Error while running examples

Hi,

I am trying to use RDatasets. In the github README, the following code is given as an example

using RDatasets
iris = dataset("datasets", "iris")
neuro = dataset("boot", "neuro")

But I’m getting the following error:

julia> using RDatasets

julia> iris = dataset("datasets", "iris")
Error encountered while loading "/home/vish/.julia/packages/RDatasets/1Ih8s/src/../data/datasets/iris.rda".

Fatal error:
ERROR: UndefVarError: identifier not defined
Stacktrace:
 [1] handle_error(::UndefVarError, ::FileIO.File{FileIO.DataFormat{:RData}}) at /home/vish/.julia/packages/FileIO/ZknoK/src/error_handling.jl:82
 [2] handle_exceptions(::Array{Any,1}, ::String) at /home/vish/.julia/packages/FileIO/ZknoK/src/error_handling.jl:77
 [3] load(::FileIO.Formatted; options::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/vish/.julia/packages/FileIO/ZknoK/src/loadsave.jl:186
 [4] load at /home/vish/.julia/packages/FileIO/ZknoK/src/loadsave.jl:166 [inlined]
 [5] #load#13 at /home/vish/.julia/packages/FileIO/ZknoK/src/loadsave.jl:118 [inlined]
 [6] load at /home/vish/.julia/packages/FileIO/ZknoK/src/loadsave.jl:118 [inlined]
 [7] dataset(::String, ::String) at /home/vish/.julia/packages/RDatasets/1Ih8s/src/dataset.jl:21
 [8] top-level scope at REPL[2]:1

julia> neuro = dataset("boot", "neuro")
ERROR: UndefVarError: File not defined
Stacktrace:
 [1] getproperty at ./Base.jl:26 [inlined]
 [2] (::RDatasets.var"#1#2"{String,String})(::IOStream) at /home/vish/.julia/packages/RDatasets/1Ih8s/src/dataset.jl:28
 [3] open(::RDatasets.var"#1#2"{String,String}, ::String, ::Vararg{String,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at ./io.jl:298
 [4] open at ./io.jl:296 [inlined]
 [5] dataset(::String, ::String) at /home/vish/.julia/packages/RDatasets/1Ih8s/src/dataset.jl:26
 [6] top-level scope at REPL[3]:1

Further, trying to run RDatasets.packages() results in

julia> RDatasets.packages()
┌ Warning: `T` is deprecated, use `nonmissingtype` instead.
│   caller = #26 at Source.jl:172 [inlined]
└ @ Core ~/.julia/packages/CSV/tT4Xy/src/Source.jl:172
┌ Warning: `T` is deprecated, use `nonmissingtype` instead.
│   caller = #26 at Source.jl:172 [inlined]
└ @ Core ~/.julia/packages/CSV/tT4Xy/src/Source.jl:172
┌ Warning: `T` is deprecated, use `nonmissingtype` instead.
│   caller = CSV.Source(; fullpath::String, options::CSV.Options{Nothing}, header::Int64, datarow::Int64, types::Array{Type,1}, allowmissing::Symbol, nullable::Nothing, categorical::Bool, weakrefstrings::Nothing, strings::Symbol, footerskip::Int64, rows_for_type_detect::Int64, rows::Int64, use_mmap::Bool) at Source.jl:210
└ @ CSV ~/.julia/packages/CSV/tT4Xy/src/Source.jl:210
┌ Warning: `T` is deprecated, use `nonmissingtype` instead.
│   caller = CSV.Source(; fullpath::String, options::CSV.Options{Nothing}, header::Int64, datarow::Int64, types::Array{Type,1}, allowmissing::Symbol, nullable::Nothing, categorical::Bool, weakrefstrings::Nothing, strings::Symbol, footerskip::Int64, rows_for_type_detect::Int64, rows::Int64, use_mmap::Bool) at Source.jl:216
└ @ CSV ~/.julia/packages/CSV/tT4Xy/src/Source.jl:216
┌ Warning: `T` is deprecated, use `nonmissingtype` instead.
│   caller = (::DataStreams.Data.var"#7#8")(::Type{T} where T) at DataStreams.jl:68
└ @ DataStreams.Data ~/.julia/packages/DataStreams/mEqAy/src/DataStreams.jl:68
ERROR: MethodError: no method matching streamtypes(::Type{DataFrame})
Closest candidates are:
  streamtypes(::Type{Array}) at /home/vish/.julia/packages/DataStreams/mEqAy/src/namedtuples.jl:11
  streamtypes(::Type{#s16} where #s16<:NamedTuple) at /home/vish/.julia/packages/DataStreams/mEqAy/src/namedtuples.jl:53
  streamtypes(::Type{CSV.Sink}) at /home/vish/.julia/packages/CSV/tT4Xy/src/Sink.jl:34
Stacktrace:
 [1] stream!(::CSV.Source{Base.GenericIOBuffer{Array{UInt8,1}},Nothing}, ::DataStreams.Data.Query{0x01,Tuple{DataStreams.Data.QueryColumn{0x01,Union{Missing, String},1,1,:Package,nothing,()},DataStreams.Data.QueryColumn{0x01,Union{Missing, String},2,2,:Title,nothing,()}},(),nothing,nothing}, ::Type{DataFrame}; append::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/vish/.julia/packages/DataStreams/mEqAy/src/query.jl:574
 [2] stream!(::CSV.Source{Base.GenericIOBuffer{Array{UInt8,1}},Nothing}, ::Type{DataFrame}; append::Bool, transforms::Dict{Int64,Function}, filter::Function, columns::Array{Any,1}, actions::Array{Any,1}, limit::Nothing, offset::Nothing, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/vish/.julia/packages/DataStreams/mEqAy/src/query.jl:538
 [3] read(::String, ::Type{T} where T; append::Bool, transforms::Dict{Int64,Function}, transpose::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/vish/.julia/packages/CSV/tT4Xy/src/Source.jl:348
 [4] read at /home/vish/.julia/packages/CSV/tT4Xy/src/Source.jl:347 [inlined] (repeats 2 times)
 [5] packages() at /home/vish/.julia/packages/RDatasets/1Ih8s/src/packages.jl:4
 [6] top-level scope at REPL[4]:1

How to solve these problems?

julia> versioninfo()
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)

(@v1.4) pkg> st
Status `~/.julia/environments/v1.4/Project.toml`
  [a93c6f00] DataFrames v0.21.0
  [91a5bcdd] Plots v1.2.3
  [d330b81b] PyPlot v2.8.2
  [ce6b1742] RDatasets v0.6.1

RDatasets doesn’t work with DataFrames 0.21 yet. Version bounds should ideally be fixed to reflect that, but until then you can downgrade to 0.20. A fix is coming here.

EDIT: I’ve filed a PR to fix the version bounds.

Thanks a lot. It worked. :slight_smile: