R mclapply cores option
This morning, I found the default behavior of the mclapply() function not quite different from the one of the lapply(). After quick investigation, I found is was due to an option not correctly set: the number of core to use.
> getOption("cores")
NULL
I must then overwrite the default mc.cores option of the mclapply()
R read lists from file
[caption id="" align="alignright" width="350"] Doubly-linked list (Photo credit: Wikipedia)[/caption]
This a retranscription of a post on stackoverflow.
The solution I keep is using the following command
a <- strsplit(scan("data.txt", what="", sep="n"), "t")
Read More
SQL like aggregation in R
[caption id="" align="alignright" width="75"] Group by (Photo credit: Wikipedia)[/caption]
The
use case is similar to the one descibe in usual
SQL quick reference guide at the "group by" section.
first of all, I need a dataset as one data.frame:
d <- data.frame(product=sample(c("fruit …
Read More
evaluation of exploration values
For some application, it is usefull to evaluate some physical value over a grid. For each dimension of the grid, the order of magnitude to use is not obvious.Watch movie online The Transporter Refueled (2015)
grid evaluation
the function …
Read More
unfactor R factor
Consider the following R code:
a <- factor(floor(rnorm(100))) class(a) summary(a)
Why should you have that? great question. Maybe because of memory
place. I really don’t know, but I received some R dataset in the form
of a factor. My problem is to revert this process …
Read More
R read.table and special characters
[caption id="" align="alignright" width="350"] read.on.table (Photo credit: Wikipedia)[/caption]
Read More
R convert IPv4 adresses to binary
I want to retrieve the binary representation (as a string of 0 and 1) of
an IPv4 address ( human
readable string
representation) using only R functions.
The following steps and functions can be used:
step |
tool |
separate each octet |
strsplit(x, split=”[.]”) |
convert integer to … |
Read More
[R R R R R R R R R R R R R R R]
[caption id="" align="alignright" width="350"] Spools of thread (Photo credit: Wikipedia)[/caption]
I wanted to use multithreading in R. I'm used to C pthread mechanism, but I want to use some R functions. This functions run independently on separate data, and treatments can take some time.
In short, what …
Read More