-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from JuliaInterop/randy3k/convert
major refactoring of conversion related code
- Loading branch information
Showing
31 changed files
with
1,257 additions
and
515 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
julia 0.5 | ||
DataStructures 0.4.3 | ||
DataStructures 0.5.0 | ||
DataFrames 0.9 | ||
NullableArrays 0.0.10 | ||
CategoricalArrays 0.0.6 | ||
NullableArrays 0.1.0 | ||
CategoricalArrays 0.1.0 | ||
AxisArrays 0.0.6 | ||
NamedArrays 0.5.3 | ||
Compat 0.20.0 | ||
@windows WinReg 0.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Conversions | ||
|
||
RCall supports conversions to and from most base Julia types and popular Statistics packages, e.g., `DataFrames`, `DataArrays`, `NullableArrays`, `CategoricalArrays` `NamedArrays` and `AxisArrays`. | ||
|
||
```@setup 1 | ||
using RCall | ||
using DataFrames | ||
using NamedArrays | ||
using AxisArrays | ||
``` | ||
|
||
## Base Julia Types | ||
|
||
```@example 1 | ||
# Julia -> R | ||
a = RObject(1) | ||
``` | ||
|
||
```@example 1 | ||
# R -> Julia | ||
rcopy(a) | ||
``` | ||
|
||
```@example 1 | ||
# Julia -> R | ||
a = RObject([1.0, 2.0]) | ||
``` | ||
|
||
```@example 1 | ||
# R -> Julia | ||
rcopy(a) | ||
``` | ||
|
||
## Dictionaries | ||
|
||
```@example 1 | ||
# Julia -> R | ||
d = Dict(:a => 1, :b => [4, 5, 3]) | ||
r = RObject(d) | ||
``` | ||
|
||
```@example 1 | ||
# R -> Julia | ||
rcopy(r) | ||
``` | ||
|
||
## Date | ||
|
||
```@example 1 | ||
# Julia -> R | ||
d = Date(2012, 12, 12) | ||
r = RObject(d) | ||
``` | ||
|
||
```@example 1 | ||
# R -> Julia | ||
rcopy(r) | ||
``` | ||
|
||
## DateTime | ||
|
||
```@example 1 | ||
# julia -> R | ||
d = DateTime(2012, 12, 12, 12, 12, 12) | ||
r = RObject(d) | ||
``` | ||
|
||
```@example 1 | ||
# R -> Julia | ||
rcopy(r) | ||
``` | ||
|
||
## DataFrames and DataArrays | ||
|
||
```@example 1 | ||
d = DataFrame([[1.0, 4.5, 7.0]], [:x]) | ||
# Julia -> R | ||
r = RObject(d) | ||
``` | ||
|
||
```@example 1 | ||
# R -> Julia | ||
rcopy(r) | ||
``` | ||
|
||
In default, the column names of R data frames are sanitized such that `foo.bar` | ||
would be replaced by `foo_bar`. | ||
|
||
```@example 1 | ||
rcopy(R"data.frame(a.b = 1:3)") | ||
``` | ||
|
||
To avoid the sanitization, use `sanitize` option. | ||
```@example 1 | ||
rcopy(R"data.frame(a.b = 1:10)"; sanitize = false) | ||
``` | ||
|
||
## NamedArrays | ||
|
||
```@example 1 | ||
# Julia -> R | ||
aa = NamedArray([1,2,3], [["a", "b", "c"]], [:id]) | ||
r = RObject(aa) | ||
``` | ||
|
||
```@example 1 | ||
# R -> Julia | ||
rcopy(r) | ||
``` | ||
|
||
|
||
## AxisArrays | ||
|
||
```@example 1 | ||
# Julia -> R | ||
aa = AxisArray([1,2,3], Axis{:id}(["a", "b", "c"])) | ||
r = RObject(aa) | ||
``` | ||
|
||
```@example 1 | ||
# R -> Julia | ||
rcopy(r) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.