Skip to content

Commit

Permalink
convert R logical vector to DataVector{Bool}
Browse files Browse the repository at this point in the history
  • Loading branch information
alyst committed Nov 4, 2017
1 parent a15cc54 commit 54d6e2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Updated to Julia v0.6 (older versions not supported).

##### Changes
* R logical vectors are converted to `DataVector{Bool}` (instead of `DataVector{Int32}`) [#32]
* dropped compatibility with Julia versions prior v0.6 [#32]

[#32]: https://github.com/JuliaStats/RData.jl/issues/32
Expand Down
4 changes: 4 additions & 0 deletions src/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ function DataArrays.data(ri::RIntegerVector)
return PooledDataArray(DataArrays.RefArray(refs), pool)
end

# convert R logical vector (uses Int32 to store values) into DataVector{Bool}
DataArrays.data(rl::RLogicalVector) =
return DataArray(Bool[x != 0 for x in rl.data], namask(rl))

function sexp2julia(rex::RSEXPREC)
warn("Conversion of $(typeof(rex)) to Julia is not implemented")
return nothing
Expand Down

0 comments on commit 54d6e2b

Please sign in to comment.