1

I have a lot of code from R, and I'm working on a research project where I need to write down the pseudocode, is there any way to convert these codes into latex?

  • 3
    R code is different from pseudocode, because it is real code. If you want to write pseudocode then you cannot convert it but you need to write the pseudocode from scratch, writing down only the important steps of your algorithm and leaving out all practical implementation details. For such a task you can use packages like algorithm2e or algorithmicx. If you want to print actual code then you can use listings or minted. – Marijn Nov 08 '20 at 22:23
  • Both can be useful (pseudocode and real code), but by definition you cannot convert one into the other. – Marijn Nov 08 '20 at 22:24
  • Pretty good answer, thank you @Marijn – Felipe Augusto Nov 08 '20 at 22:39
  • 1
    Why pseudocode? You can write real code in LaTeX, and show it highlighted and/or execute it. Do you know knitr? A simple example here – Fran Nov 12 '20 at 22:06
  • @Fran good tip! In some cases can be applied, but for mine the code is very big and for those who don't know R it's harder to understand than pseudocode. – Felipe Augusto Nov 14 '20 at 15:03
  • @FelipeAugusto As said, you can show code without evaluating it, so it could be also a not working code, or it can be a working code but show nothing, or all the code, or only some lines of the working code, and show the outputs or hide also even when it is evaluated. Therefore, in which situation cannot be applied? – Fran Nov 14 '20 at 20:14
  • Well, it can be applied, what I mean is that it would be harder for someone who doesn't know R to understand, this is what I meant by "can't be applied in some cases". – Felipe Augusto Nov 15 '20 at 02:05

0 Answers0