1

So here's the code in Julia

using CSV

using DataFrames

using PlotlyJS

df= CSV.read("path", DataFrame)

plot(df, x=:Age, kind="box")

#I DO get the box plot for this one, because in the csv that column is headed with "Age"

plot(df, x=:Annual Income (k$), kind="box")

ERROR: syntax: missing comma or ) in argument list Stacktrace: [1] top-level scope @ none:1 #here I get an error asking about syntax, but I don't understand since the x= part is exactly what the column is labeled. If I try 'x=:Annual' I get a box plot of nothing, but the column title is "Annual Income (k$)".

Help is greatly appreciated!

Refrence: https://plotly.com/julia/box-plots/

Jeremy S
  • 141
  • 5

1 Answers1

1

Try:


plot(df, x=Symbol("Annual Income (k\$)"), kind="box")

The : syntax constructs a Symbol, but only upto the next space. So :Annual Income (k$) says to build the Symbol Symbol("Annual"), but then leaves the Income (k$) parts dangling. Instead you can explicitly construct the Symbol yourself like above.

The backslash before the $ symbol is because Julia uses $ usually for interpolation, and here we want to use the raw $ character itself. You can also do plot(df, x=Symbol(raw"Annual Income (k$)"), kind="box") instead, as no interpolation happens inside raw"" strings.

Sundar R
  • 13,776
  • 6
  • 49
  • 76