# What is the problem with this Julia code?

**URL:** https://discourse.julialang.org/t/what-is-the-problem-with-this-julia-code/82827
**Category:** General Usage
**Tags:** question
**Created:** [June 15, 2022, 5:50pm UTC](https://discourse.julialang.org/t/what-is-the-problem-with-this-julia-code/82827 "2022-06-15T17:50:37Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [June 15, 2022, 5:50pm UTC](https://discourse.julialang.org/t/what-is-the-problem-with-this-julia-code/82827/1 "2022-06-15T17:50:37Z")

</div>

I wrote a function that plots several boxplots, ordered by the orders of a factor (categorical variable). It works, but VSCode keeps telling me there is a problem in one of the lines. Would someone know the reason?

Here is the code:

```julia

using DataFrames, StatsPlots

varnames = ["Winter", "Spring", "Summer", "Fall"]
df = DataFrame(
    :variable => categorical(repeat(varnames, 20), levels = varnames),
    :value => rand(80)
)

function boxplot_ordered(
    df::DataFrame;
    variable_col::Symbol = :variable,
    value_col::Symbol = :value,
    plotsize::Tuple{Int64,Int64} = (800, 600) # ctrl_parms.PlotSize
)
    msg = "`variable_col` is not a column name of `df`"
    @assert string(variable_col) in names(df) msg

    msg = "`value_col` is not a column name of `df`"
    @assert string(value_col) in names(df) msg

    msg = "Column `variable_col` of `df` is not categorical"
    @assert typeof(df[!, variable_col]) <: CategoricalVector msg

    variable_order = string.(levels(df[!, variable_col]))
    v = collect(1:length(variable_order))
    d = Dict(zip(variable_order, v))
    
    dfc = select(
        df,
        variable_col => ByRow(x -> d[x]) => :Order,
        variable_col => (x -> (string.(x))) => variable_col,
        value_col,
    )

    p = boxplot(
        dfc.Order,
        dfc[!, value_col],
        legend = false,
        size = plotsize
    )
    plot!(xticks = (v, variable_order)) # THIS IS THE LINE FLAGGED AS A PROBLEM

    display(p)

    return p
end # boxplot_ordered

boxplot_ordered(df)

```

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [June 15, 2022, 5:53pm UTC](https://discourse.julialang.org/t/what-is-the-problem-with-this-julia-code/82827/2 "2022-06-15T17:53:09Z")

</div>

I would suggest posting the error message.

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [June 15, 2022, 8:16pm UTC](https://discourse.julialang.org/t/what-is-the-problem-with-this-julia-code/82827/3 "2022-06-15T20:16:04Z")

</div>

I would assume the problem is with VSCode, and not the Julia code.

---

<div class="post-metadata">

### Author: ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)
#### Post date: [June 15, 2022, 8:44pm UTC](https://discourse.julialang.org/t/what-is-the-problem-with-this-julia-code/82827/4 "2022-06-15T20:44:35Z")

</div>

Works for me. I didn’t get any error when running your code.

---

<div class="post-metadata">

### Author: ![A\_C](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@A\_C](https://discourse.julialang.org/u/A_C)
#### Post date: [June 15, 2022, 9:28pm UTC](https://discourse.julialang.org/t/what-is-the-problem-with-this-julia-code/82827/5 "2022-06-15T21:28:07Z")

</div>

I think it is not an error but problem with VS code in windows. I also get the blue underline in windows but it is not present on Linux machine.  
 ![plot_warning](https://global.discourse-cdn.com/julialang/original/3X/d/d/dd7ab003b8d9571727b6f24ea57aa380c37daf59.png)

---

<div class="post-metadata">

### Author: ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)
#### Post date: [June 15, 2022, 10:09pm UTC](https://discourse.julialang.org/t/what-is-the-problem-with-this-julia-code/82827/6 "2022-06-15T22:09:33Z")

</div>

I ran it on VSCode in Windows and had no issue.

---

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [June 15, 2022, 10:18pm UTC](https://discourse.julialang.org/t/what-is-the-problem-with-this-julia-code/82827/7 "2022-06-15T22:18:27Z")

</div>

I don’t get an error when running the code. It is just that VSCode inserts that line in the list of Problems, with the message “Possible method call error.”

---

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [June 15, 2022, 10:21pm UTC](https://discourse.julialang.org/t/what-is-the-problem-with-this-julia-code/82827/8 "2022-06-15T22:21:03Z")

</div>

The message is "“Possible method call error.” It is not an error message, The function runs with no problems. It is a Problem flagged by VSCode.

---

<div class="post-metadata">

### Author: ![A\_C](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@A\_C](https://discourse.julialang.org/u/A_C)
#### Post date: [June 15, 2022, 10:23pm UTC](https://discourse.julialang.org/t/what-is-the-problem-with-this-julia-code/82827/9 "2022-06-15T22:23:57Z")

</div>

Probably related to this issue:

[https://github.com/julia-vscode/julia-vscode/issues/1576](https://github.com/julia-vscode/julia-vscode/issues/1576)

It is the problem with linter. So the code will work.
