Skip to content

The problem with VM.builder #3

@sergeikharchenko

Description

@sergeikharchenko

Hi!

I found a bug with that function.
It doesn't work properly if you have a marker's name, which the grepl function finds twice or more in colnames.

For example: my dataset has such colnames:
Sample_name, Class_decontamination, S, K, Ca, Ti, V, Material

You have your own function VM.proportionate.prop.values here (inside VM.builder):
resu <- fingR::VM.proportionate.prop.values(data = df.sources, class = class, tracers = tracers, contributions = contributions, VM.name = VM.name)

And it contains such code:
for (var in tracers) { df.value[, which(grepl(var, colnames(df.value)))] <- round(df.value[, which(grepl(var, colnames(df.value)))], fingR::lvl.signif(data[[var]])) df.SD[, which(grepl(var, colnames(df.SD)))] <- round(df.SD[, which(grepl(var, colnames(df.SD)))], fingR::lvl.signif(data[[var]])) }
and
for (var in tracers) { df.value[[which(grepl(var, colnames(df.value)))]] <- round(df.value[[which(grepl(var, colnames(df.value)))]], fingR::lvl.signif(data[[var]])) }

In this code and maybe somewhere else grepl gives you two indicies for var == "S" ---- "Sample_name" and "S". And after that the code uses wrong column (first of the ones).

Of coarse I've renamed my variable from "S" to "Sulfur", and it works good.
But it can be useful for you.

Best regards and many thanks for the tool again.
Sergey Kharchenko

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions