Re: LyX+Scilab
Naw, the issue is just that R is messy. Actually, for this particular case, I was chuckling a bit since it isn't wrong how R did it, it is just the way R does it. C++ is exactly the same. Unfortunately, the answer that I will give for this thread is that the OP should really just learn R or figure out a workaround. I have done a huge amount of work in many languages and basically I would not wish to merge them. Loosely coupled code is much better than tightly coupled. Reading in a CSV or a PDF is much better style than generating it and working with it inside of a document. Eventually you start asking yourself questions like, if I gave this Lyx document to a friend, would they have any idea what I did and could they figure it out in under 2 minutes? If the answer is no, I might suggest finding a different way to attack the problem. I was thinking about this though. For plots, R is one of the best tools you can use. Believe you me, illustrator is probably the best but R does a really good job and is not 800$. What I really recommend for plots is that you save the plot and load it into the document. I have done this many times. That way, you are regenerating the same plot every time you compile your document. Also, as long as you can generate a PDF image, you can include it. Now I bet there is a case where the plot should be dynamic with every compile and if that is the case, I don't really know where to go apart from learning R... if only for the plotting which is some of the best you will find anywhere. I actually find the whole idea of integrating R into Lyx to be interesting but misses the point a bit. For tables I could see it being very useful but within the boundaries of whatever automatically sets up the table formatting. For images, I would save it and import it as a pdf. BTW, I have had no end of problems working with sweave and the stata latex output. It essentially requires me to rewrite the tables anyway. Problems range anywhere from writing off the end of the page to generating tables which are unreadable. BTW, totally off topic but Python is very versatile. It actually makes much more sense with the power behind dictionaries, document parsing, document merging, string manipulations, data management, etc. for it to be included in Lyx. That I am sure was a feat of engineering. I honestly don't know what to tell the OP anymore as latex includes many many ways to integrate PDF images within a document. Generating the PDF outside of the document and importing it seems like far less work than trying to get it all working in Lyx. ~Ben On Wed, Jan 28, 2015 at 10:56 PM, Jerry wrote: > > On Jan 25, 2015, at 2:56 PM, Benedict Holland < > benedict.m.holl...@gmail.com> wrote: > > > On Sun, Jan 25, 2015 at 4:38 PM, Francesco Menoncin < > francesco.menon...@unibs.it> wrote: > > Hello Benedict, > > thank you for your answer. > > I give you an example about how R is difficult for dealing with > matrices: if in Matlab (or Scilab or Octave or simila) I write: > > > > x(2,2)=10 > > > > the following matrix is automatically created: > > > > [0 0 > > 0 2] > > > > while in R > > > > x[2,2]=10 > > > > gives an error because I first have to declare to R that x is a matrix > and, furthermore, give it the right dimension. > > If, afterward, I want to add an element to the matrix x, in Matlab I > simply write: > > > > x(3,1)=5 > > > > and I obtain the matrix: > > > > [0 0 > > 0 10 > > 5 0] > > > > while in R I cannot do that, because x has already been defined as a 2 > by 2 matrix. > > I find all this very inefficient for dealig with matrices. > > This is my point :-) > > > > Francesco > > > I'm not familiar with R but what you are saying about R in comparison with > Matlab or Octave is that Matlab/Octave do not check array bounds. Thus, you > might erroneously write into a matrix element that doesn't exist and > Matlab/Octave does not report an error. Array bounds checking is the price > to pay for having safer code. FWIW, Python and Mathematica are examples of > languages that are only "half-safe" with respect to array indexing, meaning > if you write past the beginning of an array (usually negative indexes) it > assumes you want to index the array backwards, from the end. These are all > conveniences but of course can also cause erroneous results or increased > time spent debugging. I personally am happy to write in a safe language > (Ada) and spend a little bit more time writing code (it's easy to declare a > new array and copy the old one into it; you can write a subroutine if you > want) and virtually zero time chasing bugs, but others prefer otherwise and > that's fine. > > Jerry
Re: LyX+Scilab
On Jan 25, 2015, at 2:56 PM, Benedict Holland wrote: > On Sun, Jan 25, 2015 at 4:38 PM, Francesco Menoncin > wrote: > Hello Benedict, > thank you for your answer. > I give you an example about how R is difficult for dealing with matrices: if > in Matlab (or Scilab or Octave or simila) I write: > > x(2,2)=10 > > the following matrix is automatically created: > > [0 0 > 0 2] > > while in R > > x[2,2]=10 > > gives an error because I first have to declare to R that x is a matrix and, > furthermore, give it the right dimension. > If, afterward, I want to add an element to the matrix x, in Matlab I simply > write: > > x(3,1)=5 > > and I obtain the matrix: > > [0 0 > 0 10 > 5 0] > > while in R I cannot do that, because x has already been defined as a 2 by 2 > matrix. > I find all this very inefficient for dealig with matrices. > This is my point :-) > > Francesco > I'm not familiar with R but what you are saying about R in comparison with Matlab or Octave is that Matlab/Octave do not check array bounds. Thus, you might erroneously write into a matrix element that doesn't exist and Matlab/Octave does not report an error. Array bounds checking is the price to pay for having safer code. FWIW, Python and Mathematica are examples of languages that are only "half-safe" with respect to array indexing, meaning if you write past the beginning of an array (usually negative indexes) it assumes you want to index the array backwards, from the end. These are all conveniences but of course can also cause erroneous results or increased time spent debugging. I personally am happy to write in a safe language (Ada) and spend a little bit more time writing code (it's easy to declare a new array and copy the old one into it; you can write a subroutine if you want) and virtually zero time chasing bugs, but others prefer otherwise and that's fine. Jerry
Re: LyX+Scilab
So then the problem isn't with inefficient matrix computations but with the language itself. On that I can wholehearted agree. I would say though, IMHO Matlab isn't much better, and in fact can be much much worse. I tend to try to avoid R but it is a very powerful language once you get the basics. What you might consider doing is dealing with data frames and then converting into matrices. R is essentially a data frame language with some stuff stapled on the side, like python is a dictionary language with some stuff stapled on the side. Matlab is strange with most variables being fully scoped and that drives me crazy. Honestly, in the long run you will get many benefits with R that you won't get with Matlab. I recommend picking it up. Also, I wouldn't expect any proprietary software to be compatible with lyx. That sort of development is very difficult. What I would recommend doing is using whatever language you want and saving whatever it is as a CSV. From there, I would write a script which will automatically spit out the middle part of a table. Something along the lines of Header 1 & 1 & 2 & 3 \\ & (1) & (2) & (3) \\ Header 2 & 1 & 2 & 3 \\ & (1) & (2) & (3) \\ etc. Then all that is required for you to do is start the tabular environment: \begin{tabular}{l>m{.25cm}...} \end{tabular} The hardest part that lyx and most automated table generators have (including and especially R and Stata) is the header which defines how your table should look and feel. If your table is long, it should use longtable. If you want table notes, you need to use three part table. Do you want it to look nice and want full control over line widths and line placement? Use booktabs. These are highly context dependent and really up to the end user, making them very difficult to automate leaving someone like you and me with the requirement to learn how to typeset tables manually. Look at booktabs and threeparttable for guides. Making a good table takes a very long time and requires you to become good with typesetting. Choosing to read in a CSV and export a latex table middle will allow you to use quite literally whatever software you want, as long as it can produce a CSV. Actually, if it would help, I might be able to whip up a script sometime soon in python. It will not be the most robust script in the whole of scripting, but should at least be usable. I don't really deal with lyx/python interactions as I prefer to leave the two separate. Perhaps though, with the script, it might not be so bad and something worth considering. ~Ben On Sun, Jan 25, 2015 at 4:38 PM, Francesco Menoncin < francesco.menon...@unibs.it> wrote: > Hello Benedict, > thank you for your answer. > I give you an example about how R is difficult for dealing with matrices: > if in Matlab (or Scilab or Octave or simila) I write: > > x(2,2)=10 > > the following matrix is automatically created: > > [0 0 > 0 2] > > while in R > > x[2,2]=10 > > gives an error because I first have to declare to R that x is a matrix > and, furthermore, give it the right dimension. > If, afterward, I want to add an element to the matrix x, in Matlab I > simply write: > > x(3,1)=5 > > and I obtain the matrix: > > [0 0 > 0 10 > 5 0] > > while in R I cannot do that, because x has already been defined as a 2 by > 2 matrix. > I find all this very inefficient for dealig with matrices. > This is my point :-) > > Francesco > > Il 25/01/2015 22:25, Benedict Holland ha scritto: > > R is not so easy to use for big matrix computations? This is a first for > me. R is extremely efficient at dealing with matrices. If you have huge > matrices, I don't think it would perform much better than anything else. If > you need sparse matrix functionality, R comes with it built in. Python is > actually horrible for mathematical computations since it basically runs > everything in FORTRAN and C. The overhead to manipulate the data to call > these libraries is enormous. R might actually be doing the same. Matlab > does this as well. > > Honestly, what I have found is that printing tables and results is best > done by manually coding latex using booktabs and three part table. It isn't > that hard to do either. Write your results as a CSV and if you are good at > scripting, just separate the csv from the data frame into rows. Add a > header and you are good to go. This way, any time you have a CSV, you can > easily get it into tabular format and all you have to do is specify the > header and footer, something that is notoriously difficult to automate. > Trust me, I have tried a dozen or more times and it never just works. > > ~Ben > > On Sun, Jan 25, 2015 at 3:35 PM, Steve Burnham wrote: > >> There is a package on CTAN called pythontex that allows you to run >> python from within a document. I know LyX heavily relies on Python as well >> and I think I have seen mention of people using python code in their >> documents. I used to use Matlab for data processing but have compl
Re: LyX+Scilab
R is not so easy to use for big matrix computations? This is a first for me. R is extremely efficient at dealing with matrices. If you have huge matrices, I don't think it would perform much better than anything else. If you need sparse matrix functionality, R comes with it built in. Python is actually horrible for mathematical computations since it basically runs everything in FORTRAN and C. The overhead to manipulate the data to call these libraries is enormous. R might actually be doing the same. Matlab does this as well. Honestly, what I have found is that printing tables and results is best done by manually coding latex using booktabs and three part table. It isn't that hard to do either. Write your results as a CSV and if you are good at scripting, just separate the csv from the data frame into rows. Add a header and you are good to go. This way, any time you have a CSV, you can easily get it into tabular format and all you have to do is specify the header and footer, something that is notoriously difficult to automate. Trust me, I have tried a dozen or more times and it never just works. ~Ben On Sun, Jan 25, 2015 at 3:35 PM, Steve Burnham wrote: > There is a package on CTAN called pythontex that allows you to run python > from within a document. I know LyX heavily relies on Python as well and I > think I have seen mention of people using python code in their documents. > I used to use Matlab for data processing but have completely switched over > to python so I’m pretty sure you could do everything you want to do in > python. > > > -Steve > > On January 25, 2015 at 7:00:05 AM, Francesco Menoncin ( > francesco.menon...@unibs.it) wrote: > > Dear LyXers, > I use and I like very much the package Knitr for executing R commands in > LyX. Nevertheless, R is not so easy to use for big matrix computation. I > wonder whether there exists a project similar to Knitr but allowing to > code in LyX in other languages like Scilab, or Octave, or Matlab. > > Thank you > > Francesco > > -- > --- > Francesco Menoncin > Associate Professor > University of Brescia > Department of Economics and Management > E-mail: francesco.menon...@unibs.it > Tel. 0039-0302988806 > Fax. 0039-0302988836 > https://sites.google.com/site/francescomenoncin/ > http://www.eco.unibs.it/~menoncin/ > > > -- > Informativa sulla Privacy: http://www.unibs.it/node/8155 > >
Re: LyX+Scilab
There is a package on CTAN called pythontex that allows you to run python from within a document. I know LyX heavily relies on Python as well and I think I have seen mention of people using python code in their documents. I used to use Matlab for data processing but have completely switched over to python so I’m pretty sure you could do everything you want to do in python. -Steve On January 25, 2015 at 7:00:05 AM, Francesco Menoncin (francesco.menon...@unibs.it) wrote: Dear LyXers, I use and I like very much the package Knitr for executing R commands in LyX. Nevertheless, R is not so easy to use for big matrix computation. I wonder whether there exists a project similar to Knitr but allowing to code in LyX in other languages like Scilab, or Octave, or Matlab. Thank you Francesco -- --- Francesco Menoncin Associate Professor University of Brescia Department of Economics and Management E-mail: francesco.menon...@unibs.it Tel. 0039-0302988806 Fax. 0039-0302988836 https://sites.google.com/site/francescomenoncin/ http://www.eco.unibs.it/~menoncin/ -- Informativa sulla Privacy: http://www.unibs.it/node/8155
LyX+Scilab
Dear LyXers, I use and I like very much the package Knitr for executing R commands in LyX. Nevertheless, R is not so easy to use for big matrix computation. I wonder whether there exists a project similar to Knitr but allowing to code in LyX in other languages like Scilab, or Octave, or Matlab. Thank you Francesco -- --- Francesco Menoncin Associate Professor University of Brescia Department of Economics and Management E-mail: francesco.menon...@unibs.it Tel. 0039-0302988806 Fax. 0039-0302988836 https://sites.google.com/site/francescomenoncin/ http://www.eco.unibs.it/~menoncin/ -- Informativa sulla Privacy: http://www.unibs.it/node/8155