Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: DimensionMismatch("index 1 has size (300,), but size(A) = ()") #810

Closed
grero opened this issue Jun 4, 2015 · 2 comments
Closed

Comments

@grero
Copy link

grero commented Jun 4, 2015

I'm having trouble creating a ModelFrame in julia-0.4.0-dev+5194. I'm using the latest master of both DataFrames and DataArrays
Below is a toy example reproducing the error

using DataFrames
df = DataFrame()
df[:counts] = 50*rand(300)
df[:tlabel] = rand(1:8,300)
df[:dlabel] = rand(1:8,300)
f = counts ~ tlabel + dlabel
mf = ModelFrame(f, df)
ERROR: DimensionMismatch("index 1 has size (300,), but size(A) = ()")
in checksize at multidimensional.jl:283
in anonymous at /Users/roger/.julia/v0.4/Compat/src/ngenerate.jl:128
in getindex at /Users/roger/.julia/v0.4/DataArrays/src/indexing.jl:159
in getindex at /Users/roger/.julia/v0.4/DataFrames/src/dataframe/dataframe.jl:265
in na_omit at /Users/roger/.julia/v0.4/DataFrames/src/statsmodels/formula.jl:223
in call at /Users/roger/.julia/v0.4/DataFrames/src/statsmodels/formula.jl:241
in call at /Users/roger/.julia/v0.4/DataFrames/src/statsmodels/formula.jl:247

julia> Pkg.status("DataFrames")

  • DataFrames 0.6.6+ master
    Pkg.status("DataArrays")
  • DataArrays 0.2.15+ master
@gragusa
Copy link

gragusa commented Jun 8, 2015

The problem is with indexing of DatArrays.

data=DataFrame(X=[1,2,3],Y=[2,4,7])
data[:,1]

give the sam error, namely

julia> data[:,1]
ERROR: DimensionMismatch("index 1 has size (3,), but size(A) = ()")
 in checksize at multidimensional.jl:287
 in anonymous at /Users/gragusa/.julia/v0.4/Compat/src/ngenerate.jl:128
 in getindex at /Users/gragusa/.julia/v0.4/DataArrays/src/indexing.jl:159
 in getindex at /Users/gragusa/.julia/v0.4/DataFrames/src/dataframe/dataframe.jl:259

While this work:

DataArrays._getindex(data[:X], Base.to_index([1], [1]))

this does not work

DataArrays._getindex(data[:X], Base.to_index([1,2], [1]))

@nalimilan
Copy link
Member

Works on latest master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants