Skip to content

Commit

Permalink
Remove fixcolnames option added in #751
Browse files Browse the repository at this point in the history
This was discussed and intentionally left out for all IO methods.

The plan is for `df.colname` to be the idiomatic way of specifying
a column in the near future (it already works on some experimental
AbstractDataFrame types), and `df.col.name`, for example, can't be
parsed as desired. (`.` is meaningful syntax in Julia, so using
`col.name` in place of a valid identifier is like using `col+name`
which wouldn't be valid in R, for example.

It's trivial to work around in user code if the user insists, but
it doesn't belong in any package code for now, though adding it
uniformly to all IO methods may be revisited later if the roadmap
changes.
  • Loading branch information
garborg committed Dec 31, 2014
1 parent d986ee8 commit f3a89d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 6 additions & 8 deletions src/RDA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ type RDAContext # RDA reading context

# behaviour
convertdataframes::Bool # if R dataframe objects should be automatically converted into DataFrames
fixcolnames::Bool # if dataframe column names are fixed when creating DataFrame objects

# intermediate data
symtab::Array{RSymbol,1} # symbols array
Expand All @@ -203,7 +202,6 @@ type RDAContext # RDA reading context
VersionNumber( div(rver,65536), div(rver%65536, 256), rver%256 ),
VersionNumber( div(rminver,65536), div(rminver%65536, 256), rminver%256 ),
get(kwdict,:convertdataframes,false),
get(kwdict,:fixcolnames,true),
Array(RSymbol,0))
end
end
Expand Down Expand Up @@ -269,10 +267,10 @@ function readlist(ctx::RDAContext, fl::RDATag)
n = readuint32(ctx.io)
res = RList([readitem(ctx) for i in 1:n],
readattrs(ctx, fl))
if (ctx.convertdataframes && isdataframe(res))
DataFrame(res, fixcolnames=ctx.fixcolnames)
if ctx.convertdataframes && isdataframe(res)
DataFrame(res)
else
res
res
end
end

Expand Down Expand Up @@ -377,7 +375,7 @@ function DataArrays.data(ri::RInteger)
return PooledDataArray(DataArrays.RefArray(refs), pool)
end

function DataFrame(rl::RList; fixcolnames=true)
DataFrame( map(data, rl.data),
Symbol[fixcolnames ? identifier(x) : x for x in names(rl)] )
function DataFrame(rl::RList)
DataFrame(map(data, rl.data),
Symbol[identifier(x) for x in names(rl)])
end
2 changes: 0 additions & 2 deletions test/RDA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,4 @@ module TestRDA
rda_names = names(DataFrame(read_rda("$testdir/data/RDA/names.rda")["df"]))
@test rda_names == [:_end, :x!, :x1, :_B_C_]

rda_names = names(DataFrame(read_rda("$testdir/data/RDA/names.rda")["df"], fixcolnames=false))
@test rda_names == [symbol("end"), :!, symbol("1"), symbol("%_B*\tC*")]
end

0 comments on commit f3a89d7

Please sign in to comment.