PROPOSED Create simple vectors in R?

  • State "PROPOSED" from "" 2010-09-27 Mon 13:38

Currently all variables are received in R as data frames: we cannot create simple vectors and we cannot create matrices (i.e. simple vectors with a dimension attribute).

Proposals

CurrentAB
Create data framesYesYesNo
Create R vectors?NoYesNo
Pass arbitrarily nested lists?NoNoYes

NA = no native representation

Current behaviour

OrgelispRpython
stringstringlength 1 character vectorstring
numbernumberlength 1 numeric vectornumber
NAlistdata framelist
tablelist of listsdata framelist of lists
NAother nested listERRORother nested list

Rows omitted from the proposals below are the same as in the current behaviour above.

  • Advantages
  • Disadvantages
    Cannot create vectors
    Cannot pass arbitrarily nested lisp lists

Proposal A: My initial patch in this thread

OrgelispR
NAlistvector
  • Advantages
    Simple way to create vectors in R
  • Disadvantages
    Cannot pass arbitrarily nested lisp lists

Proposal B: Using R lists

OrgelispR
NAlistlist
tablelist of listslist of lists
NAother nested listother nested list
  • Advantages
    Conceptually simple

    lisp lists == R lists

    Appropriate

    These are the analogous data structures in the two languages (mutable, mixed-type, arbitrarily nested lists). It solves the problem of sending nested lisp structures to R.

  • Disadvantages
    Unnatural conversion to data frame
    ab
    12

    is '((a b) (1 2))

    which becomes list(list("a", "b"), list(1,2))

    It would be natural to use data.frame(lapply(x, unlist)) but this would give us the transpose of what we want.

Cases

integer

print(str(x))

1D vector

print(str(x))

Column table

1
2
x
print(str(x))

Row table

12
x
print(str(x))

2D table

13
24
x
print(str(x))