Bioinf_15 Bioinf_15 - 1 month ago 5x
R Question

Unusual numbers format in R

I'm working with a data matrix I received from a colleague who no longer works in our research group. The numbers are gene expression values. When I read the data.frame using R, numbers look like this: 715.583.892.852.256, 85.363.547.324.901. I don't know why they look like that. Expected numbers are: 715.5, 85.3. Can anyone explain to me why they appear like that? How can I trim the original numbers in order to obtain the desired ones?

Thanks in advance


Here is a brute force way:

x <- c("715.583.892.852.256", "85.363.547.324.901")

    strsplit(x, "\\."),
    function(x)paste(x[1], paste(x[-1], collapse = ""), sep = ".")

This gives:

[1] 715.58389  85.36355