nealrichardson commented on a change in pull request #7441: URL: https://github.com/apache/arrow/pull/7441#discussion_r441013359
########## File path: r/vignettes/arrow.Rmd ########## @@ -86,7 +88,73 @@ to other applications and services that use Arrow. One example is Spark: the move data to and from Spark, yielding [significant performance gains](http://arrow.apache.org/blog/2019/01/25/r-spark-improvements/). -# Class structure and package conventions +# Internals + +## Mapping of R <--> Arrow types + +Arrow has a rich data type system that includes direct parallels with R's data types and much more. + +In the tables, entries with a `-` are not currently implemented. + +### R to Arrow + +| R type | Arrow type | +|--------------------------|------------| +| logical | boolean | +| integer | int32 | +| double ("numeric") | float64 | +| character | utf8 | +| factor | dictionary | +| raw | uint8 | +| Date | date32 | +| POSIXct | timestamp | +| POSIXlt | - | +| data.frame | struct | +| list^+^ | list | +| bit64::integer64 | int64 | +| difftime | time32 | +| vctrs::vctrs_unspecified | null | + +^+^: Only lists where all elements are the same type are able to be translated to Arrow list type (which is a "list of" some type). + +### Arrow to R + +| Arrow type | R type | +|-------------------|--------------------------| +| boolean | logical | +| int8 | integer | +| int16 | integer | +| int32 | integer | +| int64 | bit64::integer64 | +| uint8 | integer | +| uint16 | integer | +| uint32 | double | Review comment: Perhaps we could. The `bit64::integer64` class we use for int64 only supports signed integers, so `uint32` could fit in that, though `uint64` could not (cf. https://jira.apache.org/jira/browse/ARROW-9031). I would also like to [pull int64, uint32, and uint64 into an R integer](https://jira.apache.org/jira/browse/ARROW-9083) if they are in bounds (32-bit signed). In any case, this PR is merely documenting the status quo, so if we want to change uint32 behavior, let's open a new JIRA. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
