if (FALSE) {
## get/set/del item from Python dict
x <- r_to_py(list(abc = "xyz"))
#' # R expression | Python expression
# -------------------- | -----------------
x["abc"] # x["abc"]
x["abc"] <- "123" # x["abc"] = "123"
x["abc"] <- NULL # del x["abc"]
x["abc"] <- py_none() # x["abc"] = None
## get item from Python list
x <- r_to_py(list("a", "b", "c"))
x[0]
## slice a NumPy array
x <- np_array(array(1:64, c(4, 4, 4)))
# R expression | Python expression
# ------------ | -----------------
x[0] # x[0]
x[, 0] # x[:, 0]
x[, , 0] # x[:, :, 0]
x[NA:2] # x[:2]
x[`:2`] # x[:2]
x[2:NA] # x[2:]
x[`2:`] # x[2:]
x[NA:NA:2] # x[::2]
x[`::2`] # x[::2]
x[1:3:2] # x[1:3:2]
x[`1:3:2`] # x[1:3:2]
}
Run the code above in your browser using DataLab