##Create 4x4 matrix
mtx<-matrix(sample(0:1, 16, replace=T), nrow=4)
##Create distributed frame spread across the cluster
df<-as.dframe(mtx)
psize(df)
##Create distributed frame with single partition
db<-as.dframe(mtx, psize=dim(mtx))
psize(db)
##Create distributed frame with two partitions
dc<- as.dframe(mtx, psize=c(2,4))
psize(dc)
##Fetch first partition
collect(dc,1)
#creating of dframe with data.frame
dfa <- c(2,3,4)
dfb <- c("aa","bb","cc")
dfc <- c(TRUE,FALSE,TRUE)
df <- data.frame(dfa,dfb,dfc)
#creating dframe from data.frame with default block size
ddf <- as.dframe(df)
collect(ddf)
#creating dframe from data.frame with 1x1 block size
ddf <- as.dframe(df,psize=c(1,1))
collect(ddf)
Run the code above in your browser using DataLab