# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=686

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 687

---

## [Dataframes and categorical, good style?](https://discourse.julialang.org/t/dataframes-and-categorical-good-style/48903)

<div class="topic-metadata">

**Author:** [@StatisticalMouse](https://discourse.julialang.org/u/StatisticalMouse)\
**Replies:** 5\
**Last updated:** [October 24, 2020, 12:24pm UTC](https://discourse.julialang.org/t/dataframes-and-categorical-good-style/48903 "2020-10-24T12:24:47Z")

</div>

I’m trying to write some Kaggle Titanic code and to show context first: datadirectory = "../data/titanic/" train\_df = CSV.read(datadirectory \* "train.csv") describe(train\_df) variable mean min median max nunique nmissi…

---

## [How to use Regex() function?](https://discourse.julialang.org/t/how-to-use-regex-function/48891)

<div class="topic-metadata">

**Author:** [@JianghuiDu](https://discourse.julialang.org/u/JianghuiDu)\
**Replies:** 5\
**Last updated:** [October 24, 2020, 11:18am UTC](https://discourse.julialang.org/t/how-to-use-regex-function/48891 "2020-10-24T11:18:16Z")

</div>

r"(?\<=NH3\\)\\\[)\\w+(?=\\\])" is ok but Regex("(?\<=NH3\\)\\\[)\\w+(?=\\\])") reports ERROR: LoadError: syntax: invalid escape sequence why?

---

## [Plotting Unitful Functions](https://discourse.julialang.org/t/plotting-unitful-functions/48918)

<div class="topic-metadata">

**Author:** [@aatifsyed](https://discourse.julialang.org/u/aatifsyed)\
**Replies:** 8\
**Last updated:** [October 24, 2020, 9:20am UTC](https://discourse.julialang.org/t/plotting-unitful-functions/48918 "2020-10-24T09:20:57Z")

</div>

Hi All, Ramping up on Julia, so forgive any naivety I’m hitting an error when trying to plot a function in a unitful way: julia\> using Unitful, UnitfulRecipes, Plots julia\> """ The Severinghaus Oxygen Dissocia…

---

## [RowEchelon function reef](https://discourse.julialang.org/t/rowechelon-function-reef/48842)

<div class="topic-metadata">

**Author:** [@carloslesmes](https://discourse.julialang.org/u/carloslesmes)\
**Replies:** 7\
**Last updated:** [October 24, 2020, 7:32am UTC](https://discourse.julialang.org/t/rowechelon-function-reef/48842 "2020-10-24T07:32:53Z")

</div>

using RowEchelon A=\[1 2; 3 4\] rref(transpose(A)) throws error

---

## [Cubic interpolation](https://discourse.julialang.org/t/cubic-interpolation/34552)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 18\
**Last updated:** [October 24, 2020, 6:39am UTC](https://discourse.julialang.org/t/cubic-interpolation/34552 "2020-10-24T06:39:42Z")

</div>

Interpolations.jl: The API may be clever, but it isn’t easy to use. How do I interpolate a set of points with a cubic curve? I tried this: npts = size(xyz,1); s = fill(0.0, npts); for j in 2:npts s\[j\] …

---

## [Julia 1.5 on Windows Terminal](https://discourse.julialang.org/t/julia-1-5-on-windows-terminal/44189)

<div class="topic-metadata">

**Author:** [@yutaka](https://discourse.julialang.org/u/yutaka)\
**Replies:** 3\
**Last updated:** [August 3, 2020, 4:47pm UTC](https://discourse.julialang.org/t/julia-1-5-on-windows-terminal/44189 "2020-08-03T16:47:34Z")

</div>

I tried to use Julia 1.5 on Windows Terminal. I put the following entry to settings.json. "commandline": "powershell.exe C:\\\\Users\\\\myname\\\\AppData\\\\Local\\\\Programs\\\\Julia 1.5.0\\\\bin\\\\julia.exe", It didn’t work because…

---

## [How can I do arithmetics with Char objects?](https://discourse.julialang.org/t/how-can-i-do-arithmetics-with-char-objects/48908)

<div class="topic-metadata">

**Author:** [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)\
**Replies:** 15\
**Last updated:** [October 24, 2020, 2:58am UTC](https://discourse.julialang.org/t/how-can-i-do-arithmetics-with-char-objects/48908 "2020-10-24T02:58:41Z")

</div>

Hi, I’m trying to subtract to char, but goting this issue - ERROR: InexactError: trunc(UInt32, -65) Please, may someone help? function generate\_frequencies(data::String) data = replace(strip(lowercase(data)), "\\n"…

---

## [Show an object in extended form vs short form](https://discourse.julialang.org/t/show-an-object-in-extended-form-vs-short-form/48792)

<div class="topic-metadata">

**Author:** [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Replies:** 5\
**Last updated:** [October 23, 2020, 7:49pm UTC](https://discourse.julialang.org/t/show-an-object-in-extended-form-vs-short-form/48792 "2020-10-23T19:49:30Z")

</div>

my problem is the following: I have a type with fields, and i want those fields to be displayed with additional detail when shown alone in the REPL: julia\> a = MyType(;params....) MyType properties, with: a: .... b: ..…

---

## [Function, constants, globals](https://discourse.julialang.org/t/function-constants-globals/48744)

<div class="topic-metadata">

**Author:** [@neo\_abs](https://discourse.julialang.org/u/neo_abs)\
**Replies:** 20\
**Last updated:** [October 23, 2020, 7:02pm UTC](https://discourse.julialang.org/t/function-constants-globals/48744 "2020-10-23T19:02:20Z")

</div>

I wanted to have a function: function test() const global x = 1 end Obviously it does not work. Is there a workaround that would make it feasible to declare constant globals from function? I want to have some sort…

---

## [Array of Structs: getindex, slicing, and broadcasting getfield](https://discourse.julialang.org/t/array-of-structs-getindex-slicing-and-broadcasting-getfield/21887)

<div class="topic-metadata">

**Author:** [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Replies:** 13\
**Last updated:** [October 23, 2020, 6:05pm UTC](https://discourse.julialang.org/t/array-of-structs-getindex-slicing-and-broadcasting-getfield/21887 "2020-10-23T18:05:46Z")

</div>

I have a struct like mutable struct State ID::Int64 kind::Symbol val::Float64 end that contains info about one object, but what I’m interested in is States, a collection of multiple State objects. I am comb…

---

## [Neat way of broadcasting getindex and getfield](https://discourse.julialang.org/t/neat-way-of-broadcasting-getindex-and-getfield/28706)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 4\
**Last updated:** [October 23, 2020, 6:04pm UTC](https://discourse.julialang.org/t/neat-way-of-broadcasting-getindex-and-getfield/28706 "2020-10-23T18:04:43Z")

</div>

I often find myself wanting to broadcast getindex and getfield, which is perfectly doable, but could enjoy a nicer syntax. I figured out if I define the operator .. in the right way, I get a kind-of nice syntax for doing…

---

## [DataType hash differs per patch version and OS](https://discourse.julialang.org/t/datatype-hash-differs-per-patch-version-and-os/48827)

<div class="topic-metadata">

**Author:** [@racinmat](https://discourse.julialang.org/u/racinmat)\
**Replies:** 8\
**Last updated:** [October 23, 2020, 3:28pm UTC](https://discourse.julialang.org/t/datatype-hash-differs-per-patch-version-and-os/48827 "2020-10-23T15:28:55Z")

</div>

I noticed hash(Float32) returns different value on each julia version. While other hash functions return same hash for same value, e.g. julia\> hash("a") 0xfa232f94411b00cd is same for Julia versions 1.3.1, 1.5.0, 1.5.…

---

## [Need to add flexibility to deeply nested functions---global parameter variable a good idea?](https://discourse.julialang.org/t/need-to-add-flexibility-to-deeply-nested-functions-global-parameter-variable-a-good-idea/48868)

<div class="topic-metadata">

**Author:** [@ElectronicTeaCup](https://discourse.julialang.org/u/ElectronicTeaCup)\
**Replies:** 6\
**Last updated:** [October 23, 2020, 2:15pm UTC](https://discourse.julialang.org/t/need-to-add-flexibility-to-deeply-nested-functions-global-parameter-variable-a-good-idea/48868 "2020-10-23T14:15:16Z")

</div>

I have a general programming question (which I need to tacking using Julia). I have a couple of functions (that call other functions) to carry out my analysis (some signal processing tasks and sorting data the way I want…

---

## [String macro to simplify type declarations with units](https://discourse.julialang.org/t/string-macro-to-simplify-type-declarations-with-units/47292)

<div class="topic-metadata">

**Author:** [@MartinOtter](https://discourse.julialang.org/u/MartinOtter)\
**Replies:** 10\
**Last updated:** [October 23, 2020, 1:41pm UTC](https://discourse.julialang.org/t/string-macro-to-simplify-type-declarations-with-units/47292 "2020-10-23T13:41:05Z")

</div>

I am trying to simplify the declaration of struct variables that have units with a string macro. This works: using Unitful macro Float64\_str(str) return :( typeof(Float64(1.0)\*@u\_str($str)) ) end mutable struct Da…

---

## [Concatenating in comprehension](https://discourse.julialang.org/t/concatenating-in-comprehension/48818)

<div class="topic-metadata">

**Author:** [@HenriDeh](https://discourse.julialang.org/u/HenriDeh)\
**Replies:** 14\
**Last updated:** [October 23, 2020, 1:36pm UTC](https://discourse.julialang.org/t/concatenating-in-comprehension/48818 "2020-10-23T13:36:29Z")

</div>

Hello, \[rand(10,10) rand(10,10) rand(10,10) rand(10,10)\] Makes a 20 x 20 Matrix. But \[rand(10,10) for i in 1:2, j in 1:2\] makes a 2×2 Array{Array{Float64,2},2}. I would like to know if there exists a comprehension …

---

## [Check head of an expression](https://discourse.julialang.org/t/check-head-of-an-expression/48852)

<div class="topic-metadata">

**Author:** [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Replies:** 2\
**Last updated:** [October 23, 2020, 12:39pm UTC](https://discourse.julialang.org/t/check-head-of-an-expression/48852 "2020-10-23T12:39:08Z")

</div>

I Often have an expression t = :(y = f(:x)) I want to examine the head of the RHS, I can do this by looking at rhs = t.args\[2\] rhs.head ... Unfortunately, if you have t = :(y = :x)) then rhs is a QuoteNode and I ge…

---

## [1.0 vs Float64(1) versus const rone = 1.0](https://discourse.julialang.org/t/1-0-vs-float64-1-versus-const-rone-1-0/48874)

<div class="topic-metadata">

**Author:** [@grandemundo82](https://discourse.julialang.org/u/grandemundo82)\
**Replies:** 6\
**Last updated:** [October 23, 2020, 12:07pm UTC](https://discourse.julialang.org/t/1-0-vs-float64-1-versus-const-rone-1-0/48874 "2020-10-23T12:07:10Z")

</div>

Hi all; For the longest time, I wondered about something extremely basic. In my code where execution time is really important, I always wondered what is the best way to handle real number like 1.0 or 0.0. What is the f…

---

## [Finding all factors of an integer](https://discourse.julialang.org/t/finding-all-factors-of-an-integer/48841)

<div class="topic-metadata">

**Author:** [@DrXorile](https://discourse.julialang.org/u/DrXorile)\
**Replies:** 4\
**Last updated:** [October 23, 2020, 10:02am UTC](https://discourse.julialang.org/t/finding-all-factors-of-an-integer/48841 "2020-10-23T10:02:32Z")

</div>

I found this question but it didn’t quite answer mine. I want to list all the factors of a number, n. I found Primes.factor(n) which returns all the primes with their powers. And I found Iterators.product which could, i…

---

## [Calculation time of Runge Kutta method](https://discourse.julialang.org/t/calculation-time-of-runge-kutta-method/48869)

<div class="topic-metadata">

**Author:** [@yosuga](https://discourse.julialang.org/u/yosuga)\
**Replies:** 1\
**Last updated:** [October 23, 2020, 8:28am UTC](https://discourse.julialang.org/t/calculation-time-of-runge-kutta-method/48869 "2020-10-23T08:28:35Z")

</div>

I’m trying to calculate a matrix-form ODE, i.e., (∂/∂t)ψ = -iHψ ,where ψ is a vector and H is a (time-independent) matrix. I have two problems. 1. Difference of calculation time between DifferentialEquations.jl and Ru…

---

## [Using \`DataType\` as key in \`Dict\`](https://discourse.julialang.org/t/using-datatype-as-key-in-dict/48796)

<div class="topic-metadata">

**Author:** [@colintbowers](https://discourse.julialang.org/u/colintbowers)\
**Replies:** 10\
**Last updated:** [October 23, 2020, 5:53am UTC](https://discourse.julialang.org/t/using-datatype-as-key-in-dict/48796 "2020-10-23T05:53:40Z")

</div>

Hi all, Just a quick question: Is it a bad idea to use DataType as the key in a Dict if performance is reasonably important? So, something like this: struct MyType ; end d = Dict(Float64=\>"a", MyType=\>"b") Using Bench…

---

## [Unsatisfiable requirements detected for package DifferentialEquations](https://discourse.julialang.org/t/unsatisfiable-requirements-detected-for-package-differentialequations/48860)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 1\
**Last updated:** [October 23, 2020, 5:20am UTC](https://discourse.julialang.org/t/unsatisfiable-requirements-detected-for-package-differentialequations/48860 "2020-10-23T05:20:26Z")

</div>

pkg\> update ERROR: Unsatisfiable requirements detected for package DifferentialEquations \[0c46a032\]: DifferentialEquations \[0c46a032\] log: ├─DifferentialEquations \[0c46a032\] has no known versions! └─restricted to vers…

---

## [Function searchindex not defined?](https://discourse.julialang.org/t/function-searchindex-not-defined/48854)

<div class="topic-metadata">

**Author:** [@KW2P](https://discourse.julialang.org/u/KW2P)\
**Replies:** 2\
**Last updated:** [October 23, 2020, 4:04am UTC](https://discourse.julialang.org/t/function-searchindex-not-defined/48854 "2020-10-23T04:04:42Z")

</div>

This has to be something dumb but I’m not seeing it. I get this error: ERROR: LoadError: UndefVarError: searchindex not defined Stacktrace: \[1\] readConfigFile() at /home/phil/dev/jdev/utils.jl:114 \[2\] top-level scope…

---

## [Computing the rank of a symbolic matrix in Julia](https://discourse.julialang.org/t/computing-the-rank-of-a-symbolic-matrix-in-julia/48651)

<div class="topic-metadata">

**Author:** [@AS90](https://discourse.julialang.org/u/AS90)\
**Replies:** 25\
**Last updated:** [October 22, 2020, 8:58pm UTC](https://discourse.julialang.org/t/computing-the-rank-of-a-symbolic-matrix-in-julia/48651 "2020-10-22T20:58:05Z")

</div>

Hello. The context is that of discrete state space representations. x\_{t}=Ax\_{t-1}+Bu\_{t} y\_{t}=Cx\_{t-1}+Du\_{t} I am making observational assumptions on the rows of x\_{t} and I need to work symbolically. Specifically,…

---

## [Are there idioms in Julia for fast Algebraic Data Types (ADT)?](https://discourse.julialang.org/t/are-there-idioms-in-julia-for-fast-algebraic-data-types-adt/37244)

<div class="topic-metadata">

**Author:** [@jonathan-laurent](https://discourse.julialang.org/u/jonathan-laurent)\
**Replies:** 41\
**Last updated:** [October 22, 2020, 8:11pm UTC](https://discourse.julialang.org/t/are-there-idioms-in-julia-for-fast-algebraic-data-types-adt/37244 "2020-10-22T20:11:51Z")

</div>

Coming from functional programming, one of the features I have been missing the most in Julia are Algebraic Data Types. Packages such as MLStyle are doing a pretty good job at adding them into the language but I am more …

---

## [Warning on Plots in Jupyter](https://discourse.julialang.org/t/warning-on-plots-in-jupyter/48836)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 3\
**Last updated:** [October 22, 2020, 7:18pm UTC](https://discourse.julialang.org/t/warning-on-plots-in-jupyter/48836 "2020-10-22T19:18:34Z")

</div>

Not sure if this merits a bug report, but I recently started having the following warning pop up. It doesn’t seem to interfere with my ability to generate figures, and it does not show up in the REPL: │ MethodError: no…

---

## [Parrallel programming with Distributed Arrays](https://discourse.julialang.org/t/parrallel-programming-with-distributed-arrays/48794)

<div class="topic-metadata">

**Author:** [@hyacykcharel](https://discourse.julialang.org/u/hyacykcharel)\
**Replies:** 5\
**Last updated:** [October 22, 2020, 6:01pm UTC](https://discourse.julialang.org/t/parrallel-programming-with-distributed-arrays/48794 "2020-10-22T18:01:41Z")

</div>

please I need help, I'm trying to do this equation in parallel but it is not working can someone tell what's wrong? thanks #Heat Equation #Numerical Solution using Distributed addprocs(4) @everywhere using LinearAlgebra…

---

## [Dot notation](https://discourse.julialang.org/t/dot-notation/48776)

<div class="topic-metadata">

**Author:** [@rcnlee](https://discourse.julialang.org/u/rcnlee)\
**Replies:** 5\
**Last updated:** [October 22, 2020, 4:38pm UTC](https://discourse.julialang.org/t/dot-notation/48776 "2020-10-22T16:38:32Z")

</div>

Hello, I’m trying to understand the internals of what happens when using the dot notation. There seems to be a few ways to make the call: x = \[1,2,3\]; y=\[0,2,4\] x .\<= y #method 1 .\<=(x,y) #method 2 (\<=).(x,y) #method …

---

## [Load a dependency only when calling a method that needs it](https://discourse.julialang.org/t/load-a-dependency-only-when-calling-a-method-that-needs-it/48804)

<div class="topic-metadata">

**Author:** [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Replies:** 6\
**Last updated:** [October 22, 2020, 3:04pm UTC](https://discourse.julialang.org/t/load-a-dependency-only-when-calling-a-method-that-needs-it/48804 "2020-10-22T15:04:21Z")

</div>

I’m building a package for which I want to minimize using load time. It has a bunch of dependencies that are only needed for some specific functionalities, called via specific methods. Can I somehow delay loading the dep…

---

## [How to debug dead IJulia kernels (julia 1.4.1)](https://discourse.julialang.org/t/how-to-debug-dead-ijulia-kernels-julia-1-4-1/39063)

<div class="topic-metadata">

**Author:** [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)\
**Replies:** 2\
**Last updated:** [October 22, 2020, 1:59pm UTC](https://discourse.julialang.org/t/how-to-debug-dead-ijulia-kernels-julia-1-4-1/39063 "2020-10-22T13:59:00Z")

</div>

I am trying to help two students whom I asked to install julia 1.4.1 and IJulia (one on Windows, and one on Kubuntu 20.04). Both have the issue that the IJulia kernel is crashing directly. Here is a thread of the discus…

---

## [Substituting Expression for Symbol in Nested Expression](https://discourse.julialang.org/t/substituting-expression-for-symbol-in-nested-expression/36366)

<div class="topic-metadata">

**Author:** [@r-b0](https://discourse.julialang.org/u/r-b0)\
**Replies:** 5\
**Last updated:** [October 22, 2020, 12:55pm UTC](https://discourse.julialang.org/t/substituting-expression-for-symbol-in-nested-expression/36366 "2020-10-22T12:55:54Z")

</div>

Let’s suppose I have a situation which necessitates substituting an expression for a symbol in a nested expression. Let’s further suppose that I am unable to acomplish this by acting on the string before parsing using s…

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=685)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=687)
