# NOT RUN {
# Create temporary filename
tmpcsv <- tempfile(fileext="csv")
# Generate test data
ntest <- 10
column_types <- c("integer", "integer", "double", "string")
testdata <- data.frame(
a = 1:ntest,
b = sample(1:2, ntest, replace=TRUE),
c = round(runif(ntest), 13),
d = sample(c("jan", "pier", "tjores", "corneel"), ntest, replace=TRUE)
)
# Write test data to csv file
write.table(testdata, file=tmpcsv, row.names=FALSE, col.names=FALSE, sep=',')
# Create LaF-object
laf <- laf_open_csv(tmpcsv, column_types=column_types)
# Read from file using indexing
first_column <- laf[ , 1]
first_row <- laf[1, ]
# Read from file using blockwise operators
begin(laf)
first_block <- next_block(laf, nrows=2)
second_block <- next_block(laf, nrows=2)
# Cleanup
file.remove(tmpcsv)
# }
Run the code above in your browser using DataLab