Please feel free to ask such questions. This is the purpose of the forum. J does allow 1-column matrices, e.g.
i.4 1 0 1 2 3 What is happening in your example is that you are reading in a table of character data, where each row is the character string representing a single number. The function ". is used to convert each string to a number. If the result of executing such a string is a single number, then it is a atom. If it is more than one number, it is a list, e.g. compare: ". '123' 123 $ ". '123' NB. atom ". '123 45' 123 45 $ ". '123 45' NB. list 2 Now when J executes each row of your table, it sees that every result is an atom, and assembles the atoms into a list. If one or more result was itself a list, the final assembly would be 2-dimensional. On Sun, Apr 16, 2017 at 11:26 AM, Michael Goodrich < [email protected]> wrote: > All, > > In using 'readtable' as defined in the primer I find the following > situation: > > Reading in a square matrix from a file with each row of numbers on a line I > always get the 'correct' answer when asking about the shape of the read in > data, EXCEPT when the data has only one value per line ie is a vector or > de-generate matrix if you will. In that case the shape comes back with a > single number say N whereas I was expecting it to say 'N 1' and indeed the > read in data is not available for linear algebra operations whereas data > with more that one column is without further ado. > > Why does J not treat a column of numbers as a N by 1 'matrix' ie a vector > rather than a list? > > (Pardon me if I sound like I am whining ;-) > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
