dataframe/0000755000175000017500000000000011715233166014007 5ustar carandraugcarandraugdataframe/inst/0000755000175000017500000000000011713521330014753 5ustar carandraugcarandraugdataframe/inst/@dataframe/0000755000175000017500000000000011713521330016777 5ustar carandraugcarandraugdataframe/inst/@dataframe/private/0000755000175000017500000000000011715233166020462 5ustar carandraugcarandraugdataframe/NEWS0000600000175000017500000000026111721452250014467 0ustar carandraugcarandraugSummary of important user-visible changes for dataframe 0.9.1: ------------------------------------------------------------------- ** dataframe 0.9.1 is a bug fixing release. dataframe/COPYING0000644000175000017500000010451311426562206015045 0ustar carandraugcarandraug GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . dataframe/INDEX0000644000175000017500000000072711466450516014612 0ustar carandraugcarandraugdataframe >> Data manipulation toolbox similar to R data.frame Dataframe @dataframe/cat @dataframe/dataframe @dataframe/display @dataframe/end @dataframe/fold @dataframe/isempty @dataframe/ldivide @dataframe/minus @dataframe/mldivide @dataframe/mrdivide @dataframe/mtimes @dataframe/numel @dataframe/plus @dataframe/rdivide @dataframe/size @dataframe/subsasgn @dataframe/subsref @dataframe/summary @dataframe/times @dataframe/uminus @dataframe/uplus dataframe/DESCRIPTION0000600000175000017500000000052511715233166015507 0ustar carandraugcarandraugName: dataframe Version: 0.9.1 Date: 2012-02-10 Author: Pascal Dupuis Maintainer: The Octave Community Title: Data Frame Description: Data manipulation toolbox similar to R data.frame Categories: data manipulation, statistics Depends: octave (>= 3.2.0) License: GPL version 3 or later Url: http://octave.sf.net SVNRelease: $Revision: 9615 $ dataframe/inst/dataframe0000600000175000017500000002057611713521330016624 0ustar carandraugcarandraug%# -*- mode: Octave -*- %!shared a, b, x, xl, y, yl, Y, z %! x=dataframe(randn(3, 3), 'rownames', (7:-1:5).'); %! x(1:3, 1) = 3; %! x(1:3, 1) = (4:6).'; %!assert(x.array(2, 1), 5); %! x(1, 1:3) = 3; %! x(1, 1:3) = (4:6).'; %!assert(x.array(1, 2), 5); %!assert(isempty(x.rowidx), false); %! x.types(2) ='single'; %!assert(class(x.array(1, 2)), 'single') %! x=dataframe('octave_frame/data_test.csv'); %!assert(isna(x.array(9, 4))) %! # remove rownames %! x.rownames = []; %!assert(size(x.rownames), [0 0]) %! # remove a column through '.' access %! y = x; y.DataName = []; %!assert(size(y(:, '_IBIAS_')), [10 1]) %!assert(size(y), [10 6]); %! y = x{}; %!assert(size(y), [10 7]); %! y = x{[2 5], [2 7]}; %!assert(y, {-5.8, "E"; -5.2, "C"}); %! y = x{}([2 5], [2 7]); %!assert(y, {-5.8, "E"; -5.2, "C"}); %! y = x{1:2, 1:2}(4); %!assert(y, {-5.8}); %! # remove a column through (:, name) access %! y = x; y(:, "DataName") = []; %!assert(size(y), [10 6]); %! # create an empty dataframe %! y = dataframe([]); %!assert(isempty(y), true); %! y = x.df(:, 2:6); %! Y = 2*pi*double(y.Freq).*y.C+y.GOUT; %! z = dataframe(y,{{'Y'; Y}}); %!assert(size(z), [10 6]); %!assert(abs(z(1, "Y") - Y(1)).array, 0); %! # direct matrix setting through struct access %! y.Freq=[(1:10).' (10:-1:1).']; %! # verify the "end" operator on the third dim %!assert(y.array(2, 2, end), 9); %! # direct setting through 3D matrix %! y(:, ["C"; "G"], 1:2) = repmat(y(:, ["C"; "G"]), [1 1 2]); %! y(4:5, 4:5) = NaN; %!test %! if any(size(x) != [10 7]), %! error('x: wrong input size') %! endif %! if any(size(y) != [10 5 2]), %! error('y: wrong input size') %! endif %!#assert(numel(x), 1); %! # test simple slices %!assert(x.VBIAS(1:6), (-6:.2:-5).'); %!assert(x.array(6:10, 2), (-5:.2:-4.2).'); %!assert(x.array(6, "OK_"), 'B'); %!assert(x.array(2, logical([0 0 1 1])), x.array(2, 3:4)) %!assert(size(y.array(:, :, :)), [10 5 2]); %!assert(size(y.array(:, :)), [10 10]); %!assert(size(y.array(:, 2, 2)), [10 1]); %!assert(size(y.array(:, 2)), [10 1]); %!assert(y.C(4:5), [NaN NaN]); %!error error("Accessing past limits") %! x(1, 8) %! x(11, 1) %! x(1, logical(ones(1, 7))) %! x.types{"FReq*"} %! x(1, :) %!test %! #!! removed -- output format may only be specified before selection %! #select one column %! #assert(x(1:3, 1).cell(:), x.cell(1:3)(:)) %! #assert(x(33:35).cell.', x(33:35).cell(:)) %! #select two columns %!assert(x.cell(1:10, 2:3)(:), x.cell(11:30)(:)) %!error error("Complex accesses"); %! x(:); %! x.dataframe(:); %! x.dataframe.cell %!test %! # test modifying column type %! x.types("Freq") = 'uint32'; x.types(2) = 'single'; %! # downclassing must occur ! %!assert(class(x.array(1, ["Freq"; "C"])), 'uint32') %! # upclassing must occur ! %!assert(class(x.as.double(1, ["Freq"; "C"])), 'double') %!error error("Incorrect internal field sub-referencing") %! x.types{"Freq"} %!error error("mixing different types") %! x([12:18 22:28 32:38]); %!error error("non-square access") %! x([22:28 32:37]).dataframe; %! x.cell([1:19]); %!error error("Single-dimension name access") %! x("Freq"); %!test %! # complex access %! x(x(:, "OK_") == '?', ["C"; "G"]) = NaN; %!assert(x.array(4, 5:6), [NaN NaN]) %! # extract values %! y = x.dataframe(x(:, "OK_") =='A', {"Freq", "VB*", "C", "G"}); %! #comparison using cell output class, because assert use (:) %!assert(y.cell(:, 2:3), x.cell([1 7], ["VB*"; "C"])) %!assert(x.array((33:35).'), x.array(3:5, 4)) %! #test further dereferencing %!assert(x.array(:, "C")(2:4), x.array(2:4, "C")) %! # complex modifications through cell access %! z = dataframe(x, {"VB*", {"Polarity" ,"Sense"; ones(12,2), zeros(10,2)}}); %!assert(size(z), [12 9 2]); %!assert(z.Sense(11:12, :), NA*ones(2, 2)); %!assert(size(z._over{2}, 2) - size(x._over{2}, 2), 2); %! x = dataframe(randn(3, 3)); y = x.array; %! xl = x > 0; yl = y > 0; %! a = zeros(size(yl)); b = a; %! a(xl) = 1; b(yl) = 1; %!assert(a, b); %! [a, b] = sort(y(:)); y = reshape(b, 3, 3); x = dataframe(y); %! a = zeros(size(yl)); b = a; %! a(x) = 10:-1:2; b(y) = 10:-1:2; %!assert(a, b); %! x = dataframe(randn(3, 3)); y = randn(3, 3); z = dataframe(y); %!assert((x+y(1)).array, x.array+y(1)) %!assert((y(1)+x).array, y(1)+x.array) %!assert((x+y).array, x.array+y) %!assert((y+x).array, y+x.array) %!assert((x+z).array, x.array+z.array) %!assert((bsxfun(@plus, x, z(1,:))).array, bsxfun(@plus, x.array, z.array(1,:))) %!assert((bsxfun(@plus, x, z(:,1))).array, bsxfun(@plus, x.array, z.array(:,1))) %!assert((bsxfun(@minus,z(1,:),x)).array, bsxfun(@minus,z.array(1,:),x.array)) %!assert((bsxfun(@minus,z(:,1),x)).array, bsxfun(@minus,z.array(:,1),x.array)) %!assert((x > 0).array, x.array > 0) %!assert((0 > x).array, 0 > x.array) %!assert((x > y).array, x.array > y); %!assert((y > x).array, y > x.array); %!assert((x > z).array, x.array > z.array) %!assert((x*y(1)).array, x.array*y(1)) %!assert((y(1)*x).array, y(1)*x.array) %!assert((x.*y).array, x.array.*y) %!assert((y.*x).array, y.*x.array) %!assert((z.*x).array, z.array.*x.array) %!assert((x*y).array, x.array*y) %!assert((y*x).array, y*x.array) %!assert((x*z).array, x.array*z.array) %!assert((x/y(1)).array, x.array/y(1)) %!assert((x./y).array, x.array./y) %!assert((y./x).array, y./x.array) %!assert((z./x).array, z.array./x.array) %!assert((x/y).array, x.array/y) %!assert((y/x).array, y/x.array) %!assert((x/z).array, x.array/z.array) % # left division is a bit more complicated %!assert((x(1, 1)\y).array, x.array(1, 1)\y) %!assert((x(:, 1)\y).array, x.array(:, 1)\y, sqrt(eps)) %!assert((x\y).array, x.array\y) %!assert((y\x).array, y\x.array) %!assert((x\z).array, x.array\z.array) % x=dataframe(randn(4, 3, 2)); y=randn(4, 3, 2); z=dataframe(y); %!assert((abs(sum(center(x)) < sqrt(eps)).array)) %!assert((x+y).array, x.array+y) %!assert((y+x).array, y+x.array) %!assert((x+z).array, x.array+z.array); %!assert((bsxfun(@plus,x,z(1,:,:))).array, bsxfun(@plus,x.array,z.array(1,:,:))); %!assert((bsxfun(@plus,x,z(:,1,:))).array, bsxfun(@plus,x.array,z.array(:,1,:))); %!assert((bsxfun(@plus,z(1,:,:),x)).array, bsxfun(@plus,z.array(1,:,:),x.array)); %!assert((bsxfun(@plus,z(:,1,:),x)).array, bsxfun(@plus,z.array(:,1,:),x.array)); %! [a, b] = sort(x(:)); x=dataframe(reshape((1:9)(b), [3 3])); %! y = reshape((1:9)(b), [3 3]); z = dataframe(y); %!assert(x(x(:)), y(x(:))); %!assert(x(y(:)), y(y(:))); %! z= x(x); %!assert(z.array, y(x)); %! z = x(y); %!assert(z.array, y(y)); %!demo %! x=dataframe('octave_frame/data_test.csv') %! disp("Access as a struct: x.VBIAS(1:6)") %! x.VBIAS(1:6) %! pause; disp("Access as a matrix: x(6, 'OK')") %! x(6, "OK?") %! pause; disp("Removing the row names: x.rownames = []"); %! x.rownames = [] %! pause; disp("Modifying column type: x.types['Freq']='uint32'"); %! x.types("Freq")='uint32' %! pause; disp("Partial extract"); %! disp("y = x(x(:, 'OK.') == 'A'|x(:, ""OK?"") == 'B', {'Freq', 'VB*', 'C', 'G'}") %! y = x(x(:, 'OK.') == 'A'|x(:, "OK?") == 'B', {'Freq', 'VB*', 'C', 'G'}) %! disp("y.rownames = char({'low', 'med', 'med', 'high'})"); %! y.rownames = char({'low', 'med', 'med', 'high'}) %! pause; disp("Partial modification of one column") %! disp("y.Freq('med')=[290e3; 310e3]") %! y.Freq('med') = [290e3; 310e3] %! pause; disp('Complex access'); %! disp("y.C('med')([2 1])"); %! y.C('med')([2 1]) %! pause; disp('Print stats about a dataframe: summary(y)'); %! summary(y) %!demo %! disp('Modifying a dataframe from a cell array') %! RHS={ 'don''t care', 'idx', 'Vb', 'freq', 'Ib', 'C', 'status', 'comment' %! 'yes', uint16(5), single(3.2), 10000, 1e-11, 6e-13, 'bla', '@' %! 'no', uint16(16), 4, 12000, 2e-11, 4e-13, 7, 'X'}; %! disp("Resetting a dataframe: x=dataframe([])"); %! x = dataframe([]); %! x(:, :) = RHS %! disp("Overwriting the second line") %! RHS{1, 2} = "idg"; RHS{3, 1}= "No!"; %! disp("'x(2, :) = RHS(1:2, :)' will produce two warnings") %! disp("Notice that only the second line content will change"); %! disp("x(2, :) = RHS(1:2, :)") %! x(2, :) = RHS(1:2, :) %! pause; disp('same effect, but skipping first column'); %! disp("x(1, :) = RHS([1 3], 2:end)"); %! x(1, []) = RHS([1 3], 2:end) %!demo %! disp("same game, but using row indexes.") %! disp("Notice the first field name is empty") %! RHS= { '', 'idx', 'Vb', 'freq', 'Ib', 'C', 'status', 'comment' %! 5, uint32(16), 5.3, 11000, 3e-12, 5e-12, "may", "8th"}; %! disp("x= dataframe(RHS)") %! x = dataframe(RHS) %! pause; disp("The same effect is achieved by assigning to an empty dataframe") %! x = dataframe([]); %! x(:, :) = RHS dataframe/inst/data_test.csv0000644000175000017500000000151511501365041017442 0ustar carandraugcarandraug#notice there is a extra separator DataName, VBIAS, Freq, |IBIAS|, C, GOUT, OK?, DataValue, -6, 300000, 1.6272E-11, 7.02154E-13, 1.60436E-07, 'A', DataValue, -5.8, 300000, 1.599E-11, 6.96065E-13, 1.5728E-07, 'E', # a comment line, and an empty one DataValue, -5.6, 300000, 1.379E-11, 6.90475E-13, 1.54887E-07, '!', DataValue, -5.4, 300000, 1.442E-11, 6.85165E-13, 1.54777E-07, '?', # the next lines use \r\n, \r and \f as linefeed DataValue, -5.2, 300000, 1.293E-11, 6.79655E-13, 1.51887E-07, 'C', DataValue, -5, 300000, 1.261E-11, 6.74438E-13, 1.49309E-07, 'B', DataValue, -4.8, 300000, 1.439E-11, 6.70105E-13, 1.48758E-07, 'A', DataValue, -4.6, 300000, 1.089E-11, 6.64158E-13, 1.489E-07, '3', # one empty input field DataValue, -4.4, 300000, , 6.5859E-13, 1.45578E-07, 'C', DataValue, -4.2, 300000, 1.061E-11, 6.53547E-13, 1.44306E-07, 'B', dataframe/inst/@dataframe/isscalar.m0000600000175000017500000000214511713521330020750 0ustar carandraugcarandraugfunction resu = isscalar(df) %# function resu = isscalar(df) %# returns true if the dataframe can be converted to a vector %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: isscalar.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = ismatrix(df) & (length(find(df._cnt > 1)) < 1); endfunction dataframe/inst/@dataframe/prod.m0000600000175000017500000000206611713521330020115 0ustar carandraugcarandraugfunction resu = prod(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: prod.m 9585 2012-02-05 15:32:46Z cdemills $ %# if !isa(df, 'dataframe'), resu = []; return; endif resu = df_mapper2(@prod, df, varargin{:}); endfunction dataframe/inst/@dataframe/atan.m0000600000175000017500000000176711713521330020103 0ustar carandraugcarandraugfunction resu = atan(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: atan.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@atan, df, varargin{:}); endfunction dataframe/inst/@dataframe/fix.m0000600000175000017500000000176411713521330017743 0ustar carandraugcarandraugfunction resu = fix(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: fix.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@fix, df, varargin{:}); endfunction dataframe/inst/@dataframe/ldivide.m0000600000175000017500000000233611713521330020571 0ustar carandraugcarandraugfunction resu = ldivide(A, B); %# function resu = ldivide(A, B) %# Implements the dotted '\' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: ldivide.m 9585 2012-02-05 15:32:46Z cdemills $ %# try resu = df_func(@ldivide, A, B); catch disp(lasterr()); error("Operator .\\ problem for %s vs. %s", class(A), class(B)); end_try_catch endfunction dataframe/inst/@dataframe/repmat.m0000600000175000017500000000404311713521330020436 0ustar carandraugcarandraugfunction resu = repmat(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: repmat.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df; idx = horzcat(varargin{:}); %# for the second dim, use either 1 either the 3rd one dummy = idx; if (length(dummy) > 2), dummy(2) = []; else dummy(2) = 1; endif %# operate on first dim if (idx(1) > 1), resu = df_mapper(@repmat, df, [idx(1) 1]); if (!isempty(df._name{1})), resu._name{1} = feval(@repmat, df._name{1}, [idx(1) 1]); resu._over{1} = feval(@repmat, df._over{1}, [idx(1) 1]); endif resu._cnt(1) = resu._cnt(1) * idx(1); endif if (dummy(2) > 1), for indi = 1:resu._cnt(2), resu._rep{indi} = feval(@repmat, resu._rep{indi}, [1 dummy(2)]); endfor endif %# operate on ridx resu._ridx = feval(@repmat, resu._ridx, idx); %# operate on second dim if (length(idx) > 1 && idx(2) > 1), resu._data = feval(@repmat, resu._data, [1 idx(2)]); resu._name{2} = feval(@repmat, df._name{2}, [idx(2) 1]); resu._over{2} = feval(@repmat, df._over{2}, [1 idx(2)]); resu._type = feval(@repmat, df._type, [1 idx(2)]); resu._cnt(2) = resu._cnt(2) * idx(2); endif resu = df_thirddim(resu); endfunction dataframe/inst/@dataframe/cat.m0000600000175000017500000001406411713521330017721 0ustar carandraugcarandraugfunction resu = cat(dim, A, varargin) %# function resu = cat(dim, A, varargin) %# This is the concatenation operator for a dataframe object. "Dim" %# has the same meaning as ordinary cat. Next arguments may be %# dataframe, vector/matrix, or two elements cells. First one is taken %# as row/column name, second as data. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: cat.m 9585 2012-02-05 15:32:46Z cdemills $ %# if (!isa(A, 'dataframe')), A = dataframe(A); endif switch dim case 1 resu = A; for indi = 1:length(varargin), B = varargin{indi}; if !isa(B, 'dataframe'), if iscell(B) && 2 == length(B), B = dataframe(B{2}, 'rownames', B{1}); else B = dataframe(B, 'colnames', inputname(2+indi)); endif endif if resu._cnt(2) != B._cnt(2), error('Different number of columns in dataframes'); endif %# do not duplicate empty names if !isempty(resu._name{1}) || !isempty(B._name{1}), if length(resu._name{1}) < resu._cnt(1), resu._name{1}(end+1:resu._cnt(1), 1) = {''}; endif if length(B._name{1}) < B._cnt(1), B._name{1}(end+1:B._cnt(1), 1) = {''}; endif resu._name{1} = vertcat(resu._name{1}(:), B._name{1}(:)); resu._over{1} = [resu._over{1} B._over{1}]; endif resu._cnt(1) = resu._cnt(1) + B._cnt(1); if size(resu._ridx, 2) < size(B._ridx, 2), resu._ridx(:, end+1:size(B._ridx, 2)) = NA; elseif size(resu._ridx, 2) > size(B._ridx, 2), B._ridx(:, end+1:size(resu._ridx, 2)) = NA; endif resu._ridx = [resu._ridx; B._ridx]; %# find data with same column names dummy = A._over{2} & B._over{2}; indA = true(1, resu._cnt(2)); indB = true(1, resu._cnt(2)); for indj = 1:resu._cnt(2), if (dummy(indj)), indk = strmatch(resu._name{2}(indj), B._name{2}, 'exact'); if (~isempty(indk)), indk = indk(1); if ~strcmp(resu._type{indj}, B._type{indk}), error("Trying to mix columns of different types"); endif endif else indk = indj; endif resu._data{indj} = [resu._data{indj}; B._data{indk}]; indA(indj) = false; indB(indk) = false; endfor if any(indA) || any(indB) error('Different number/names of columns in dataframe'); endif endfor case 2 resu = A; for indi = 1:length(varargin), B = varargin{indi}; if !isa(B, 'dataframe'), if iscell(B) && 2 == length(B), B = dataframe(B{2}, 'colnames', B{1}); else B = dataframe(B, 'colnames', inputname(2+indi)); endif B._ridx = resu._ridx; %# make them compatibles endif if resu._cnt(1) != B._cnt(1), error('Different number of rows in dataframes'); endif if any(resu._ridx(:) - B._ridx(:)) error('dataframes row indexes not matched'); endif resu._name{2} = vertcat(resu._name{2}, B._name{2}); resu._over{2} = [resu._over{2} B._over{2}]; resu._data(resu._cnt(2)+(1:B._cnt(2))) = B._data; resu._type(resu._cnt(2)+(1:B._cnt(2))) = B._type; resu._cnt(2) = resu._cnt(2) + B._cnt(2); endfor case 3 resu = A; for indi = 1:length(varargin), B = varargin{indi}; if (!isa(B, 'dataframe')), if (iscell(B) && 2 == length(B)), B = dataframe(B{2}, 'rownames', B{1}); else B = dataframe(B, 'colnames', inputname(indi+2)); endif endif if (resu._cnt(1) != B._cnt(1)), error('Different number of rows in dataframes'); endif if (resu._cnt(2) != B._cnt(2)), error('Different number of columns in dataframes'); endif %# to be merged against 3rd dim, rownames must be equals, if %# non-empty. Columns are merged based upon their name; columns %# with identic content are kept. if size(resu._ridx, 2) < size(B._ridx, 2), resu._ridx(:, end+1:size(B._ridx, 2)) = NA; elseif size(resu._ridx, 2) > size(B._ridx, 2), B._ridx(:, end+1:size(resu._ridx, 2)) = NA; endif resu._ridx = cat(3, resu._ridx, B._ridx); %# find data with same column names indA = true(1, resu._cnt(2)); indB = true(1, resu._cnt(2)); dummy = A._over{2} & B._over{2}; for indj = 1:resu._cnt(2), if (dummy(indj)), indk = strmatch(resu._name{2}(indj), B._name{2}, 'exact'); if (~isempty(indk)), indk = indk(1); if (~strcmp(resu._type{indj}, B._type{indk})), error("Trying to mix columns of different types"); endif endif else indk = indj; endif if (all([isnumeric(resu._data{indj}) isnumeric(B._data{indk})])), %# iterate over the columns of resu and B op1 = resu._data{indj}; op2 = B._data{indk}; for ind2=1:columns(op2), indr = false; for ind1=1:columns(op1), if (all(abs(op1(:, ind1) - op2(:, ind2)) <= eps)), resu._rep{indj} = [resu._rep{indj} ind1]; indr = true; break; endif endfor if (!indr), %# pad in the second dim resu._data{indj} = [resu._data{indj}, B._data{indk}]; resu._rep{indj} = [resu._rep{indj} 1+length(resu._rep{indj})]; endif endfor else resu._data{indj} = [resu._data{indj} B._data{indk}]; resu._rep{indj} = [resu._rep{indj} 1+length(resu._rep({indj}))]; endif indA(indj) = false; indB(indk) = false; endfor if (any(indA) || any(indB)), error('Different number/names of columns in dataframe'); endif endfor resu = df_thirddim(resu); otherwise error('Incorrect call to cat'); endswitch %# disp('End of cat'); keyboard endfunction dataframe/inst/@dataframe/erfcx.m0000600000175000017500000000177211713521330020263 0ustar carandraugcarandraugfunction resu = erfcx(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: erfcx.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@erfcx, df, varargin{:}); endfunction dataframe/inst/@dataframe/isfield.m0000600000175000017500000000545311713521330020573 0ustar carandraugcarandraugfunction [resu, idx] = isfield(df, name, strict) %# -*- texinfo -*- %# @deftypefn {Function File} [@var{resu}, @var{idx}] = isfield %# (@var{df}, @var{name}, @var{strict}) %# Return true if the expression @var{df} is a dataframe and it %# includes an element matching @var{name}. If @var{name} is a cell %# array, a logical array of equal dimension is returned. @var{idx} %# contains the column indexes of number of fields matching %# @var{name}. To enforce strict matching instead of regexp matching, %# set the third argument to 'true'. %# @end deftypefn %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: isfield.m 9585 2012-02-05 15:32:46Z cdemills $ %# if !isa(df, 'dataframe'), resu = false; return; endif if nargin <2 || nargin > 3, print_usage(); resu = false; return; endif if 2 == nargin, strict = false; endif if isa(name, 'char'), if strict, %# use strmatch to get indexes for indi = size(name, 1):-1:1, dummy = strmatch(name(indi, :), df._name{2}, "exact"); resu(indi, 1) = !isempty(dummy); for indj = 1:length(dummy), idx(indi, indj) = dummy(indj); endfor endfor else for indi = size(name, 1):-1:1, try dummy = df_name2idx(df._name{2}, name(indi, :), \ df._cnt(2), 'column'); resu(indi, 1) = !isempty(dummy); for indj = 1:length(dummy), idx(indi, indj) = dummy(indj); endfor catch resu(indi, 1) = false; idx(indi, 1) = 0; end_try_catch endfor endif elseif isa(name, 'cell'), if strict, %# use strmatch to get indexes for indi = size(name, 1):-1:1, dummy = strmatch(name{indi}, df._name{2}, "exact"); resu{indi, 1} = !isempty(dummy); idx{indi, 1} = dummy; endfor else for indi = length(name):-1:1, try dummy = df_name2idx(df._name{2}, name{indi}, \ df._cnt(2), 'column'); keyboard resu{indi, 1} = !isempty(dummy); idx{indi, 1} = dummy; catch resu{indi, 1} = false; cnt{indi, 1} = 0; end_try_catch endfor endif endif endfunction dataframe/inst/@dataframe/reshape.m0000600000175000017500000000224411713521330020576 0ustar carandraugcarandraugfunction resu = reshape(df, varargin) %# function resu = reshape(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: reshape.m 9585 2012-02-05 15:32:46Z cdemills $ %# dummy = horzcat(varargin{:}); if (any(dummy != df._cnt)), error('Function not yet implemented on dataframe'); else resu = df; %# blank operation endif endfunction dataframe/inst/@dataframe/tanh.m0000600000175000017500000000176711713521330020112 0ustar carandraugcarandraugfunction resu = tanh(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: tanh.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@tanh, df, varargin{:}); endfunction dataframe/inst/@dataframe/lt.m0000600000175000017500000000211411713521330017562 0ustar carandraugcarandraugfunction resu = lt(A, B); %# function resu = minus(A, B) %# Implements the '<' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: lt.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_func(@lt, A, B); endfunction dataframe/inst/@dataframe/finite.m0000600000175000017500000000177511713521330020435 0ustar carandraugcarandraugfunction resu = finite(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: finite.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@finite, df, varargin{:}); endfunction dataframe/inst/@dataframe/cos.m0000600000175000017500000000176411713521330017741 0ustar carandraugcarandraugfunction resu = cos(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: cos.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@cos, df, varargin{:}); endfunction dataframe/inst/@dataframe/mldivide.m0000600000175000017500000000236111713521330020744 0ustar carandraugcarandraugfunction resu = mldivide(A, B); %# function resu = mldivide(A, B) %# Implements the '\' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: mldivide.m 9585 2012-02-05 15:32:46Z cdemills $ %# try resu = df_func(@mldivide, A, B, false, [true false]); catch disp(lasterr()); error("Operator \\ problem for %s vs. %s", class(A), class(B)); end_try_catch endfunction dataframe/inst/@dataframe/isempty.m0000644000175000017500000000046211466455350020666 0ustar carandraugcarandraugfunction resu = isempty(df) %# -*- texinfo -*- %# @deftypefn {Function File} isempty(@var{df}) %# Return 1 if df is an empty dataframe (either the number of rows, or %# the number of columns, or both are zero). Otherwise, return 0. %# @end deftypefn resu = any(0 == size(df)); endfunction dataframe/inst/@dataframe/subsref.m0000600000175000017500000006502411713521330020625 0ustar carandraugcarandraugfunction resu = subsref(df, S) %# function resu = subsref(df, S) %# This function returns a subpart of a dataframe. It is invoked when %# calling df.field, df(value), or df{value}. In case of fields, %# returns either the content of the container with the same name, %# either the column with the same name, priority being given to the %# container. In case of range, selection may occur on name or order %# (not rowidx for rows). If the result is homogenous, it is %# downclassed. In case an extra field is given, is it used to %# determine the class of the return value. F.i., %# df(1, 2, 'dataframe') %# does not return a scalar but a dataframe, keeping all the meta-information %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: subsref.m 9585 2012-02-05 15:32:46Z cdemills $ %# %# what kind of object should we return ? asked_output_type = ''; asked_output_format = []; if (strcmp (S(1).type, '.')) %# struct access indi = strmatch (S(1).subs, 'as'); if (~isempty (indi)) if (length (S) < 2 || ~strcmp (S(2).type, '.')) error ("The output format qualifier 'as' must be followed by a type"); endif asked_output_type = "array"; asked_output_format = S(2).subs; S = S(3:end); else indi = strmatch(S(1).subs, 'array'); if (~isempty (indi)) asked_output_type = "array"; S = S(2:end); else indi = strmatch (S(1).subs, char ('df', class (df))); if (~isempty (indi)) %# requiring a dataframe if (1 == indi) %# 'df' = short for 'dataframe' asked_output_type = 'dataframe'; else asked_output_type = S(1).subs; endif S = S(2:end); if (isempty (S) && strcmp (asked_output_type, class (df))) resu = df; return; endif else indi = strmatch(S(1).subs, 'cell'); if (~isempty (indi)) asked_output_type = S(1).subs; S = S(2:end); else %# access as a pseudo-struct resu = struct(df); %# avoid recursive calls if (1 == strfind(S(1).subs, '_')) %# its an internal field name %# FIXME: this should only be called from class members and friends %# FIXME -- in case many columns are asked, horzcat them resu = horzcat (feval (@subsref, resu, S)); else %# direct access through the exact column name indi = strmatch(S(1).subs, resu._name{2}, "exact"); if (~isempty (indi)) resu = df._data{indi}; %# extract colum; if (strcmp (df._type{indi}, 'char') \ && 1 == size (df._data{indi}, 2)) resu = char (resu) endif if (length (S) > 1) dummy = S(2:end); S = S(1); switch dummy(1).type case '()' if (isa(dummy(1).subs{1}, "char")) [indr, nrow, dummy(1).subs{1}] = \ df_name2idx(df._name{1}, dummy(1).subs{1}, df._cnt(1), 'row'); endif resu = feval(@subsref, resu, dummy); otherwise error ("Invalid column access"); endswitch endif else %# access of an attribute dummy = S(2:end); S = S(1); postop = ''; further_deref = false; %# translate the external to internal name switch S(1).subs case "rownames" S(1).subs = "_name"; S(2).type = "{}"; S(2).subs{1}= 1; postop = @(x) char (x); case "colnames" S(1).subs = "_name"; S(2).type = "{}"; S(2).subs{1}= 2; postop = @(x) char (x); further_deref = true; case "rowcnt" S(1).subs = "_cnt"; S(2).type = "()"; S(2).subs{1}= 1; case "colcnt" S(1).subs = "_cnt"; S(2).type = "()"; S(2).subs{1}= 2; case "rowidx" S(1).subs = "_ridx"; further_deref = true; case "types" %# this one should be accessed as a matrix S(1).subs = "_type"; further_deref = true; case "source" S(1).subs = "_src"; further_deref = true; case "comment" S(1).subs = "_cmt"; further_deref = true; case "new" if (isempty (dummy)) resu = dataframe([]); else if (!strcmp (dummy(1).type, "()")) error ("Bogus constructor call"); endif resu = dataframe(dummy(1).subs{:}); endif if (length (dummy) > 1) resu = subsref(resu, dummy(2:end)); endif return; otherwise error ("Unknown column name: %s", S(1).subs); endswitch if (!isempty (dummy)) if ~further_deref, error ("Invalid sub-dereferencing"); endif if (isa(dummy(1).subs{1}, "char")) [indc, ncol, dummy(1).subs{1}] = \ df_name2idx(df._name{2}, dummy(1).subs{1}, \ df._cnt(2), 'column'); if (isempty (indc)) %# should be already catched inside df_name2idx error ("Unknown column name: %s", dummy(1).subs{1}); endif endif if (!strcmp (dummy(1).type, '()')) error ("Invalid internal field name sub-access, use () instead"); endif endif %# workaround around bug 30921, fixed in hg changeset 10937 %# if !isempty (dummy) S = [S dummy]; %# endif resu = feval(@subsref, resu, S); if (!isempty (postop)) resu = postop(resu); endif endif endif return endif endif endif endif endif %# disp('line 103 '); keyboard IsFirst = true; while 1, %# avoid recursive calls on dataframe sub-accesses %# a priori, performs whole accesses nrow = df._cnt(1); indr = 1:nrow; ncol = df._cnt(2); indc = 1:ncol; %# linear indexes [fullindr, fullindc, fullinds, onedimidx] = deal([]); %# iterate over S, sort out strange constructs as x()()(1:10, 1:4) while length (S) > 0, if (strcmp (S(1).type, '{}')) if (!IsFirst || !isempty (asked_output_format)) error ("Illegal dataframe dereferencing"); endif [asked_output_type, asked_output_format] = deal('cell'); elseif (!strcmp (S(1).type, '()')) %# disp(S); keyboard error ("Illegal dataframe dereferencing"); endif if (isempty (S(1).subs)) %# process calls like x() if (isempty (asked_output_type)) asked_output_type = class (df); endif if (length (S) <= 1) if (strcmp (asked_output_type, class (df))) %# whole access without conversion resu = df; return; endif break; %# no dimension specified -- select all, the %# asked_output_type was set in a previous iteration else %# avoid recursive calls S = S(2:end); IsFirst = false; continue; endif endif %# generic access if (isempty (S(1).subs{1})) error ('subsref: first dimension empty ???'); endif if (length (S(1).subs) > 1) if (isempty (S(1).subs{2})) error ('subsref: second dimension empty ???'); endif [indr, nrow, S(1).subs{1}] = \ df_name2idx(df._name{1}, S(1).subs{1}, df._cnt(1), 'row'); if (!isa(indr, 'char') && max (indr) > df._cnt(1)) error ("Accessing dataframe past end of lines"); endif [indc, ncol, S(1).subs{2}] = \ df_name2idx(df._name{2}, S(1).subs{2}, df._cnt(2), 'column'); if (max (indc) > df._cnt(2)) %# is it a two index access of a 3D structure ? if (length (df._cnt) > 2) [fullindc, fullinds] = ind2sub (df._cnt(2:3), indc); if (fullindc <= df._cnt(2)) indc = fullindc; inds = fullinds; endif endif %# retest if (max (indc) > df._cnt(2)) error ("Accessing dataframe past end of columns"); endif endif else %# one single dim -- probably something like df(:), df(A), ... fullindr = 1; onedimidx = S(1).subs{1}; switch class (S(1).subs{1}) case {'char'} %# one dimensional access, disallow it if not ':' if (strcmp (S(1).subs{1}, ':')) fullindr = []; fullindc = []; asked_output_type = "array"; else error (["Accessing through single dimension and name " \ S(1).subs{1} " not allowed\n-- use variable(:, 'name') instead"]); endif case {'logical'} S(1).subs{1} = find(S(1).subs{1}); case {'dataframe'} S(1).subs{1} = subsindex(S(1).subs{1}, 1); endswitch if (isempty (S(1).subs{1})) resu = df_colmeta(df); return; endif if (!isempty (fullindr)) %# convert linear index to subscripts if (length (df._cnt) <= 2) [fullindr, fullindc] = ind2sub (df._cnt, S(1).subs{1}); fullinds = ones (size (fullindr)); else dummy = max (cellfun(@length, df._rep)); [fullindr, fullindc, fullinds] = ind2sub\ ([df._cnt dummy], S(1).subs{1}); endif indr = unique (fullindr); nrow = length (indr); %# determine on which columns we'll iterate indc = unique (fullindc)(:).'; ncol = length (indc); if (!isempty (asked_output_type) && ncol > 1) %# verify that the extracted values form a square matrix dummy = zeros(indr(end), indc(end)); for indi = (1:ncol) indj = find (fullindc == indc(indi)); dummy(fullindr(indj), indc(indi)) = 1; endfor dummy = dummy(indr(1):indr(end), indc(1):indc(end)); if (any (any (dummy!= 1))) error ("Vector-like selection is not rectangular for the asked output type"); else fullindr = []; fullindc = []; endif endif endif endif %# at this point, S is either empty, either contains further dereferencing break; endwhile %# we're ready to extract data %# disp('line 211 '); keyboard if (isempty (asked_output_type)) output_type = class (df); %# force df output else if (!strcmp (asked_output_type, "array") \ || !isempty (asked_output_format)) %# override the class of the return value output_type = asked_output_type; else %# can the data be merged ? output_type = df._data{indc(1)}(1); dummy = isnumeric(df._data{indc(1)}); for indi = (2:ncol) dummy = dummy & isnumeric (df._data{indc(indi)}); if (~strcmp (class (output_type), df._type{indc(indi)})) if (dummy) %# let downclassing occur output_type = horzcat (output_type, df._data{indc(indi)}(1)); continue; endif %# unmixable args -- falls back to type of parent container error ("Selected columns %s not compatible with cat() -- use 'cell' as output format", mat2str (indc)); %# dead code -- suppress previous line for switching automagically the output format to df output_type = class (df); break; endif endfor asked_output_format = class (output_type); output_type = "array"; endif endif if (any(strcmp ({output_type, asked_output_type}, class (df)))) if (!isempty (S) && (1 == length (S(1).subs))) %# is the selection index vector-like ? if ((isnumeric(S(1).subs{1}) && isvector(S(1).subs{1}) && df._cnt(1) > 1) && isempty (asked_output_type)) %# in the case of vector input, favor array output [asked_output_type, output_type] = deal("array"); endif endif endif indt = {}; %# in case we have to mix matrix of different width if (!isempty (fullinds)) inds = unique (fullinds); nseq = length (inds); indt(1, 1:df._cnt(2)) = inds; else inds = 1; indt(1, 1:df._cnt(2)) = inds; nseq = 1; if (isempty (S) || all(cellfun('isclass', S(1).subs, 'char'))) inds = ':'; indt(1, 1:df._cnt(2)) = inds; nseq = max (cellfun(@length, df._rep(indc))); else if (length (S(1).subs) > 1) %# access-as-matrix if (length (S(1).subs) > 2) inds = S(1).subs{3}; if (isa(inds, 'char')) nseq = max (cellfun(@length, df._rep(indc))); indt(1, 1:df._cnt(2)) = inds; else %# generate a specific index for each column nseq = length (inds); dummy = cellfun(@length, df._rep(indc)); indt(1, 1:df._cnt(2)) = inds; indt(1==dummy) = 1; endif endif endif endif endif if (strcmp (output_type, class (df))) %# disp('line 295 '); keyboard %# export the result as a dataframe resu = dataframe ([]); resu._cnt(1) = nrow; resu._cnt(2) = ncol; if (isempty (fullindr)) for indi = (1:ncol) resu._data{indi} = df._data{indc(indi)}\ (indr, df._rep{indc(indi)}(indt{indc(indi)})); resu._rep{indi} = 1:size (resu._data{indi}, 2); resu._name{2}(indi, 1) = df._name{2}(indc(indi)); resu._over{2}(1, indi) = df._over{2}(indc(indi)); resu._type{indi} = df._type{indc(indi)}; endfor if (!isempty (df._ridx) && size (df._ridx, 2) >= inds) resu._ridx = df._ridx(indr, inds); endif if (length (df._name{1}) >= max (indr)) resu._name{1}(1:nrow, 1) = df._name{1}(indr); resu._over{1}(1, 1:nrow) = df._over{1}(indr); endif else dummy = df_whole(df); dummy = dummy(onedimidx); for indi = (1:resu._cnt(2)) indc = unique (fullindc(:, indi)); if (1 == length (indc)) resu._name{2}(indi)= df._name{2}(indc); resu._over{2}(indi)= df._over{2}(indc); unfolded = df._data{indc}(:, df._rep{indc}); indj = sub2ind (size (unfolded), fullindr(:, indi), \ fullinds(:, indi)); resu._data{indi} = unfolded(indj); resu._type{indi} = df._type{indc}; resu._rep{indi} = 1:size (resu._data{indi}, 2); else resu._name{2}(indi)= ["X" num2str(indi)]; resu._over{2}(indi)= true; resu._data{indi} = squeeze(dummy(:, indi, :)); resu._type{indi} = class (dummy(1, indi, 1)); resu._rep{indi} = 1:size (resu._data{indi}, 2); endif endfor if (1 == size (df._ridx, 2)) resu._ridx = repmat (df._ridx, [1 ncol 1]); else resu._ridx = df._ridx; endif if (!isempty (resu._ridx)) if (size (resu._ridx, 2) > 1) resu._ridx = resu._ridx(indr, indc); else resu._ridx = resu._ridx(indr); endif endif endif %# to be verified : keyboard resu._src = df._src; resu._cmt = df._cmt; resu = df_thirddim(resu); if (length (S) > 1) %# perform further access, if required df = resu; S = S(2:end); %# avoid recursive calls continue; %# restart the loop around line 150 endif return; elseif (strcmp (output_type, 'cell')) %# export the result as a cell array if (isempty (asked_output_format)) resu = cell (2+nrow, 2+ncol); resu(1:end, 1:2) = {''}; resu(2, 3:end) = df._type(indc); %column type row_offs = 2; col_offs = 2; for indi = (1:ncol) resu{1, 2+indi} = df._name{2}{indc(indi)}; % column name endfor resu(3:end, 1) = mat2cell (df._ridx(indr), ones (nrow, 1), 1); if (length (df._name{1}) >= max (indr)) resu(3:end, 2) = df._name{1}{indr}; endif else resu = cell (nrow, ncol); row_offs = 0; col_offs = 0; endif for indi = (1:ncol) switch df._type{indc(indi)} % cell content case {'char' } %# dummy = cellstr(df._data{indc(indi)}(indr, :)); dummy = df._data{indc(indi)}(indr, :); resu(1+row_offs:end, indi+col_offs) = dummy; otherwise dummy = df._data{indc(indi)}(indr, :); resu(1+row_offs:end, indi+col_offs) = \ mat2cell (dummy, ones (nrow, 1), size (dummy, 2)); endswitch endfor %# did we arrive here by x.cell ? if (0 == length (S)) return; endif %# perform the selection on the content, keeping the header if (length (S) > 1) %# perform further access, if required if (~strcmp (S(2).type, '()')) error ("Illegal dataframe-as-cell sub-dereferencing"); endif if (!isempty (asked_output_format)) resu = feval(@subsref, resu, S(2:end)); else if (length (S(2).subs) != 1) %# normal, two-dimensionnal access apply the selection on the %# zone containing the data dummy = S; if (!isempty (dummy(2).subs)) dummy(2).subs{2} = ':'; endif resuf = cat (2, \ %# reselect indexes feval (@subsref, resu(3:end, 1), dummy(2:end)), \ %# reselect rownames feval (@subsref, resu(3:end, 2), dummy(2:end)), \ %# extract - reorder - whatever feval (@subsref, resu(3:end, 3:end), S(2:end)) \ ); dummy = S; if (!isempty (dummy(2).subs)) dummy(2).subs{1} = [1 2]; endif resuf = cat(1, \ %# reselect column names and types [cell(2, 2) feval(@subsref, resu(1:2, 3:end), \ dummy(2:end))], \ resuf \ ); resuf(1:2, 1:2) = {''}; resu = resuf; else %# one dimensionnal access of the whole 2D cell array -- you %# asked it, you got it resu = feval(@subsref, resu(:), S(2:end)); if (!isa(S(2).subs{1}, 'char') \ && size (S(2).subs{1}, 2) > 1) resu = resu.'; endif endif endif elseif (1 == length (S(1).subs)) resu = resu(:); if (!isa(S(1).subs{1}, 'char') \ && size (S(1).subs{1}, 2) > 1) resu = resu.'; endif endif return; %# no more iteration required else %# export the result as a vector/matrix. Rules: %# * x(:, :, :) returns a 3D matrix %# * x(:, n:m, :) returns a 3D matrix %# * x(:, :) returns a horzcat of the third dimension %# * x(:, n:m) select only the first sequence %# * x(:) returns a vertcat of the columns of x(:, :) %# disp('line 403 '); keyboard if (isempty (S) || isempty (S(1).subs) || \ length (S(1).subs) > 1 || \ (isnumeric(S(1).subs{1}) && !isvector(S(1).subs{1}))) %# access-as-matrix df = struct(df); %# remove the magic, avoid recursive calls if (isempty (fullindr)) %# two index access if (~isempty (asked_output_format)) %# force a conversion if (strmatch(asked_output_format, 'cell')) extractfunc = @(x) mat2cell\ (df._data{indc(x)}(indr, df._rep{indc(x)}(inds)), \ ones (nrow, 1)); else extractfunc = @(x) cast ( df._data{indc(x)}\ (indr, df._rep{indc(x)}(inds)),\ asked_output_format); endif else %# let the usual downclassing occur extractfunc = @(x) df._data{indc(x)}(indr, df._rep{indc(x)}(inds)); endif try if (nseq > 1) dummy = reshape (extractfunc (1), nrow, 1, []); if (size (dummy, 3) < nseq) dummy = repmat (dummy, [1 1 nseq]); endif else dummy = extractfunc (1); endif catch error ("Column %d format (%s) can't be converted to %s", \ indc(1), df._type{indc(1)}, asked_output_format); end_try_catch if (ncol > 1) %# dynamic allocation with the final type resu = repmat (dummy, [1 ncol]); for indi = (2:ncol) try if (nseq > 1) dummy = reshape (extractfunc (indi), nrow, 1, []); if (size (dummy, 3) < nseq) dummy = repmat (dummy, [1 1 nseq]); endif else dummy = extractfunc (indi); endif catch error ("Column %d format (%s) can't be converted to %s", \ indc(indi), df._type{indc(indi)}, asked_output_format); end_try_catch resu(:, indi, :) = dummy; endfor else if (strcmp (df._type{indc(1)}, 'char')) resu = char (dummy); else resu = dummy; endif endif if (!isempty (S) && 2 == length (S(1).subs) \ && all(cellfun('isclass', S(1).subs, 'char'))) resu = reshape (resu, nrow, ncol*nseq); endif else %# one index access %# disp('line 557'); keyboard if (~isempty (asked_output_format)) %# force a conversion if (strmatch (asked_output_format, 'cell')) extractfunc = @(x, y) mat2cell (df._data{x}(:, df._rep{x}(y)), \ ones (length (y), 1)); else extractfunc = @(x, y) cast (df._data{x}(:, df._rep{x})(y), \ asked_output_format); endif else %# let the usual downclassing occur extractfunc = @(x, y) df._data{x}(:, df._rep{x})(y); endif try resu = zeros(0, class (sum (cellfun (@(x) zeros (1, class (x(1))),\ df._data(indc))))); for indi = (indc) dummy = find (indi == fullindc); %# linear global index %# linear index for this matrix idx = sub2ind (size (df._data{indi}), fullindr(dummy), \ fullinds(dummy)); resu(dummy) = extractfunc (indi, idx); endfor catch disp (lasterr); error ("Column %d format (%s) can't be converted to %s", \ indi, df._type{indi}, asked_output_format); end_try_catch resu = reshape (resu, size (onedimidx)); endif else %# access-as-vector %# disp('line 548 '); keyboard if (!isempty (fullindr)) switch df._type{indc(1)} case {'char'} resu = df._data{indc(1)}(fullindr(1), \ df._rep{indc(1)}(fullinds(1))); for indi = (2:length (fullindr)) resu = char (resu, df._data{indc(indi)}\ (fullindr(indi), df._rep{indc(indi)}(fullinds(indi)))); endfor otherwise if (isempty (asked_output_format)) resu = df._data{fullindc(1)}\ (fullindr(1), df._rep{fullindc(1)}(fullinds(1))); else %# this type will propagate with subsequent cat resu = cast (df._data{fullindc(1)}\ (fullindr(1), df._rep{fullindc(1)}(fullinds(1))),\ asked_output_format); endif for indi = (2:length (fullindr)) resu = cat(1, resu, df._data{fullindc(indi)}\ (fullindr(indi), \ df._rep{fullindc(indi)}(fullinds(indi)))); endfor endswitch else %# using the (:) operator resu = df_whole(df)(:); endif if (!isa(S(1).subs{1}, 'char') \ && size (S(1).subs{1}, 2) > 1) resu = resu.'; endif endif if (length (S) > 1) %# perform further access, if required %# disp('line 442 '); keyboard resu = feval(@subsref, resu, S(2:end)); endif endif return; %# no more iteration required endwhile %# disp("line 343 !?!"); %# keyboard return endfunction dataframe/inst/@dataframe/times.m0000600000175000017500000000232511713521330020270 0ustar carandraugcarandraugfunction resu = times(A, B); %# function resu = times(A, B) %# Implements the dotted '*' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: times.m 9585 2012-02-05 15:32:46Z cdemills $ %# try resu = df_func(@times, A, B); catch disp(lasterr()); error("Operator .* problem for %s vs. %s", class(A), class(B)); end_try_catch endfunction dataframe/inst/@dataframe/uminus.m0000600000175000017500000000211311713521330020462 0ustar carandraugcarandraugfunction resu = uminus(df); %# function resu = uminus(df) %# Implements the unitary '-' operator for a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: uminus.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@uminus, df); endfunction dataframe/inst/@dataframe/isna.m0000600000175000017500000000176711713521330020112 0ustar carandraugcarandraugfunction resu = isna(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: isna.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@isna, df, varargin{:}); endfunction dataframe/inst/@dataframe/conj.m0000600000175000017500000000176711713521330020111 0ustar carandraugcarandraugfunction resu = conj(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: conj.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@conj, df, varargin{:}); endfunction dataframe/inst/@dataframe/rationale.txt0000644000175000017500000001224311426564155021535 0ustar carandraugcarandraug1) Context I was recently performing I-V measurements of a MOS (Metal-Oxide-Semiconductor) structure. A full set of measurements contained a DC biaising voltage, a AC frequency, a small signal capacitance and conductance. I had to change a few times the measurement device configuration, so sometimes the sweeping occured first on frequency, then on voltage, sometimes in the reverse order. To make it short, I had to deal with many input files with inconsistent columns order. The code to identify this order quickly became clumsy. The idea of a dataframe is to implement a mix between matrix and cells. Its' like a matrix, where each column contains elements of the same type. Unlike a matrix, columns type may be dissimilar. Also, each colum MUST have a name, and rows MAY have a name. Moreover, to make it easy to interface with databases, each row must have an unique identifier. The goal is to make possible to use constructs like y(:, ["Fr*"; "VB*"; "C";"G"]) where y is the dataframe, and column selection is based on regexp. This way, the translation between names and indexes uses all the power of regexpes. 2) Implementation a dataframe is a class containing the following members: _cnt = [0 0] : row count, column count, ... nth dimension count _name = cell(1, 2) : row names, column names, ... _ridx = [] : a unique Id for each row _data = cell(0, 0) : a container for each column _type = cell(0, 0) : the type of each column The constructor can be used as - no argument: convert the whole workspace to a dataframe (TBD) - one null argument: return an empty dataframe - one numeric or cell argument: transform it to a dataframe; tries to infer column names from the name of the input argument. - one char array with more than one line: uses it as rownames - one single line char array: take it as the name of a file to read data from. Expected format is csv, try to be carefull with quoted/unquoted strings, also tries to remove trailing and leading spaces from string entries. Do not try to cope with things such as separator INSIDE quoted strings. -supplemental arguments may occur either as pairs (string, value), either as vectors. In the first case, the string contains an optional parameter whose value is contained in the next argument. In the second case, the argument is right-appended to the dataframe. Valid optional parameters are - rownames: a character array with the row names - unquot: a logical to indicate if strings must be unquoted, default=true - seeked: a string which must occur in the first row to start considering values. Previous lines are skipped. 3) Access (reading) - like a single matrix: df(:, 3); df(3, :). If all the results are of the same type, returns a matrix, otherwise a dataframe. This behavior can be inhibited by having the last argument set to 'dataframe': df(3, 3, 'dataframe') will return a one-by-one dataframe - by columnames: df(:, ["Fr*"; "VB*"; "C";]) will try to match a columname beginning by "F" followed by an optional 'r', thus 'F', 'Fréquence' and 'Freqs'; then a columname starting by "V" with an optional "B", like f.i. "VBias", then a columname with is the exact string 'C'. - by rownames: same principle - either member selector may also be logical: df(df.OK=='A', ['C';'G']) - as a struct: either use one of the column name (df.C), either use one of the allowed accessor for internal fields: "rownames", "colnames", "rowcnt", "colcnt", "rowidx", "types". Direct access to the members like y._type is allowed, but should be restricted to class members and friends. "types" accept both numeric and strings arguments, the latter being converter to column order based upon columns name. - as a cell: TODO: define how to fill the cell array with all the fields. 4) Modifying - as a matrix, using '()': use the same syntax as reading: df(3, 'Fr*') = 200 df(df.OK=='?', ['C'; 'G']) = NaN; Note that removing elements may only occur on a full row of colum basis. Removing a single element is not allowed. - as a struct: either access a columname, as df.C = []; either accessing the internal fields through entry points 'rownames' and 'colnames', where care is taken to adapt the strings width in order to make them compatibles. The entry point "types", with arguments numeric or strings, has the effect to cast whole column(s) to a new type: df.types{[3 5]} = 'uint16' df.type{"Freq"} = "uint32" - as a cell: TBD 5) other overloaded functions: display, size, numel, cat. The latter has to be thoroughfully tested. In particular, I've put the restriction that horizontal cat requires that the row indexes are the same for both elems. For vertical cat, how should we proceed ? Require uniqueness of row indexes, and sorting ? Other ? 6) to be done: - the 'load' function is in fact contained inside the constructor; maybe we should have a specific load function ? - be able to load a dataframe from a URI specification - write a simple 'save' function - adding data to a dataframe: R doesn't seems to allow adding rows to a data.frame, should we follow it ? - add test cases - implement a 'factor' class for categorised data - make all functions below statistics/ dataframe compatible Pascal Dupuis Louvain-la-Neuve, July First, 2010. dataframe/inst/@dataframe/angle.m0000600000175000017500000000177211713521330020242 0ustar carandraugcarandraugfunction resu = angle(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: angle.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@angle, df, varargin{:}); endfunction dataframe/inst/@dataframe/cumsum.m0000600000175000017500000000177511713521330020470 0ustar carandraugcarandraugfunction resu = cumsum(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: cumsum.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@cumsum, df, varargin{:}); endfunction dataframe/inst/@dataframe/log.m0000600000175000017500000000176411713521330017736 0ustar carandraugcarandraugfunction resu = log(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: log.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@log, df, varargin{:}); endfunction dataframe/inst/@dataframe/erf.m0000600000175000017500000000176411713521330017731 0ustar carandraugcarandraugfunction resu = erf(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: erf.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@erf, df, varargin{:}); endfunction dataframe/inst/@dataframe/log10.m0000600000175000017500000000177211713521330020076 0ustar carandraugcarandraugfunction resu = log10(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: log10.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@log10, df, varargin{:}); endfunction dataframe/inst/@dataframe/isvector.m0000600000175000017500000000214611713521330021006 0ustar carandraugcarandraugfunction resu = isvector(df) %# function resu = isvector(df) %# returns true if the dataframe can be converted to a vector %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: isvector.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = ismatrix(df) & (length(find(df._cnt > 1)) <= 1); endfunction dataframe/inst/@dataframe/rows.m0000600000175000017500000000204411713521330020137 0ustar carandraugcarandraugfunction resu = rows(df) %# function resu = rows(df) %# returns the number of rows of a dataframe %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: rows.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df._cnt(1); endfunction dataframe/inst/@dataframe/asinh.m0000600000175000017500000000177211713521330020256 0ustar carandraugcarandraugfunction resu = asinh(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: asinh.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@asinh, df, varargin{:}); endfunction dataframe/inst/@dataframe/asin.m0000600000175000017500000000176711713521330020112 0ustar carandraugcarandraugfunction resu = asin(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: asin.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@asin, df, varargin{:}); endfunction dataframe/inst/@dataframe/vertcat.m0000600000175000017500000000225511713521330020621 0ustar carandraugcarandraugfunction resu = vertcat(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: vertcat.m 9585 2012-02-05 15:32:46Z cdemills $ %# %# do the conversion now, in order not to loose inputnames for indi = 1:length(varargin), varargin{indi} = dataframe(varargin{indi}, 'colnames', inputname(1+indi));, endfor resu = cat(1, df, varargin{:}); endfunction dataframe/inst/@dataframe/mrdivide.m0000600000175000017500000000237111713521330020753 0ustar carandraugcarandraugfunction resu = mrdivide(A, B); %# function resu = mrdivide(A, B) %# Implements the '/' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: mrdivide.m 9585 2012-02-05 15:32:46Z cdemills $ %# try resu = df_func(@mrdivide, A, B, [false true], [false true]); catch disp(lasterr()); error("Operator / problem for %s vs. %s", class(A), class(B)); end_try_catch endfunction dataframe/inst/@dataframe/ceil.m0000600000175000017500000000176711713521330020074 0ustar carandraugcarandraugfunction resu = ceil(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: ceil.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@ceil, df, varargin{:}); endfunction dataframe/inst/@dataframe/isnan.m0000600000175000017500000000177211713521330020264 0ustar carandraugcarandraugfunction resu = isnan(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: isnan.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@isnan, df, varargin{:}); endfunction dataframe/inst/@dataframe/display.m0000600000175000017500000001652611713521330020624 0ustar carandraugcarandraugfunction resu = display(df) %# function resu = display(df) %# Tries to produce a nicely formatted output of a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: display.m 9585 2012-02-05 15:32:46Z cdemills $ %# %# generate header name dummy = inputname (1); if (isempty(dummy)) dummy = "ans"; endif if (2 == length (df._cnt)) head = sprintf ("%s = dataframe with %d rows and %d columns", \ dummy, df._cnt); else head = sprintf ("%s = dataframe with %d rows and %d columns on %d pages", \ dummy, df._cnt); endif if (!isempty (df._src)) for indi = (1:size (df._src, 1)) head = strvcat\ (head, [repmat("Src: ", size (df._src{indi, 1}, 1), 1)\ df._src{indi, 1}]); endfor endif if (!isempty (df._cmt)) for indi = (1:size(df._cmt, 1)) head = strvcat\ (head, [repmat("Comment: ", size (df._cmt{indi, 1}, 1), 1)\ df._cmt{indi, 1}]); endfor endif if (all (df._cnt > 0)) %# stop for empty df dummy=[]; vspace = repmat (' ', df._cnt(1), 1); indi = 1; %# the real, unfolded index %# loop over columns where the corresponding _data really exists for indc = (1:min (df._cnt(2), size (df._data, 2))) %# emit column names and type if (1 == length (df._rep{indc})) dummy{1, 2+indi} = deblank (disp (df._name{2}{indc})); dummy{2, 2+indi} = deblank (df._type{indc}); else %# append a dot and the third-dimension index to column name tmp_str = [deblank(disp (df._name{2}{indc})) "."]; tmp_str = arrayfun (@(x) horzcat (tmp_str, num2str(x)), ... (1:length (df._rep{indc})), 'UniformOutput', false); dummy{1, 2+indi} = tmp_str{1}; dummy{2, 2+indi} = deblank (df._type{indc}); for indk = (2:length (tmp_str)) dummy{1, 1+indi+indk} = tmp_str{indk}; dummy{2, 1+indi+indk} = dummy{2, 2+indi}; endfor endif %# "print" each column switch df._type{indc} case {'char'} indk = 1; while (indk <= size (df._data{indc}, 2)) tmp_str = df._data{indc}(:, indk); %#get the whole column indj = cellfun ('isprint', tmp_str, 'UniformOutput', false); indj = ~cellfun ('all', indj); for indr = (1:length(indj)) if (indj(indr)), if (isna (tmp_str{indr})), tmp_str{indr} = "NA"; else if (~ischar (tmp_str{indr})) tmp_str{indr} = char (tmp_str{indr}); endif tmp_str{indr} = undo_string_escapes (tmp_str{indr}); endif endif endfor %# keep the whole thing, and add a vertical space dummy{3, 2+indi} = disp (char (tmp_str)); dummy{3, 2+indi} = horzcat... (vspace, char (regexp (dummy{3, 2+indi}, '.*', ... 'match', 'dotexceptnewline'))); indi = indi + 1; indk = indk + 1; endwhile otherwise %# keep only one horizontal space per line unfolded = df._data{indc}(:, df._rep{indc}); indk = 1; while (indk <= size (unfolded, 2)) dummy{3, 2+indi} = disp (unfolded(:, indk)); tmp_str = char (regexp (dummy{3, 2+indi}, \ '[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(\s??[-+]\s??[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?i)?', \ 'match', 'dotexceptnewline')); tmp_str = horzcat... (vspace, char (regexp (dummy{3, 2+indi}, '\S.*', ... 'match', 'dotexceptnewline'))); dummy{3, 2+indi} = tmp_str; indi = indi + 1; indk = indk + 1; endwhile endswitch endfor %# put everything together vspace = [' '; ' '; vspace]; %# second line content resu = []; if (!isempty (df._ridx)) for (ind1 = 1:size (df._ridx, 2)) if ((1 == size(df._ridx, 3)) && \ (any (!isna (df._ridx(1:df._cnt(1), ind1))))) dummy{2, 1} = [sprintf("_%d", ind1) ; "Nr"]; dummy{3, 1} = disp (df._ridx(1:df._cnt(1), ind1)); indi = regexp (dummy{3, 1}, '\b.*\b', 'match', 'dotexceptnewline'); if (isempty (resu)) resu = strjust (char (dummy{2, 1}, indi), 'right'); else resu = horzcat(resu, vspace, strjust (char (dummy{2, 1}, indi), \ 'right'), vspace); endif else for ind2 = (1:size (df._ridx, 3)) if (any (!isna (df._ridx(1:df._cnt(1), ind1, ind2)))), dummy{2, 1} = [sprintf("_%d.%d", ind1, ind2) ; "Nr"]; dummy{3, 1} = disp (df._ridx(1:df._cnt(1), ind1, ind2)); indi = regexp (dummy{3, 1}, '\b.*\b', 'match', 'dotexceptnewline'); if (isempty (resu)) resu = strjust (char (dummy{2, 1}, indi), 'right'); else resu = horzcat (resu, vspace, strjust (char(dummy{2, 1}, indi), \ 'right'), vspace); endif endif endfor endif endfor endif %# emit row names if (isempty (df._name{1})), dummy{2, 2} = []; dummy{3, 2} = []; else dummy{2, 2} = [" ";" "]; dummy{3, 2} = df._name{1}; endif %# insert a vertical space if (!isempty(dummy{3, 2})) indi = ~cellfun ('isempty', dummy{3, 2}); if (any (indi)) try resu = horzcat (resu, vspace, strjust (char(dummy{2, 2}, dummy{3, 2}),\ 'right')); catch disp ('line 172 '); keyboard end_try_catch endif endif %# emit each colum for indi = (1:size (dummy, 2) - 2) %# was max(df._cnt(2:end)), try %# avoid this column touching the previous one if (any (cellfun ('size', dummy(1:2, 2+indi), 2) >= \ size (dummy{3, 2+indi}, 2))) resu = horzcat (resu, vspace); endif resu = horzcat (resu, strjust (char (dummy{:, 2+indi}), 'right')); catch tmp_str = sprintf ("Emitting %d lines, expecting %d", ... size (dummy{3, 2+indi}, 1), df._cnt(1)); keyboard error (tmp_str); end_try_catch endfor else resu = ''; endif resu = char (head, resu); disp (resu) endfunction dataframe/inst/@dataframe/signum.m0000600000175000017500000000177511713521330020461 0ustar carandraugcarandraugfunction resu = signum(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: signum.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@signum, df, varargin{:}); endfunction dataframe/inst/@dataframe/cosh.m0000600000175000017500000000176711713521330020114 0ustar carandraugcarandraugfunction resu = cosh(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: cosh.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@cosh, df, varargin{:}); endfunction dataframe/inst/@dataframe/subsindex.m0000600000175000017500000000260411713521330021153 0ustar carandraugcarandraugfunction resu = subsindex(df, base) %# function resu = subsindex(df) %# This function convert a dataframe to an index. Do not expect a %# meaningfull result when mixing numeric and logical columns. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: subsindex.m 9585 2012-02-05 15:32:46Z cdemills $ %# if nargin < 2, base = 1.0; else base = base - 1.0; endif %# extract all values at once dummy = df_whole(df); if isa(dummy, 'logical'), resu = sort(find(dummy)-base); %# resu = dummy - base; else resu = dummy - base; endif endfunction dataframe/inst/@dataframe/dataframe.m0000600000175000017500000003771311713521330021104 0ustar carandraugcarandraugfunction df = dataframe(x = [], varargin) %# -*- texinfo -*- %# @deftypefn {Function File} @var{df} = dataframe(@var{x = []}, ...) %# This is the default constructor for a dataframe object, which is %# similar to R 'data.frame'. It's a way to group tabular data, then %# accessing them either as matrix or by column name. %# Input argument x may be: @itemize %# @item a dataframe => use @var{varargin} to pad it with suplemental %# columns %# @item a matrix => create column names from input name; each column %# is used as an entry %# @item a cell matrix => try to infer column names from the first row, %# and row indexes and names from the two first columns; %# @item a file name => import data into a dataframe; %# @item a matrix of char => initialise colnames from them. %# @item a two-element cell: use the first as column as column to %# append to, and the second as initialiser for the column(s) %# @end itemize %# If called with an empty value, or with the default argument, it %# returns an empty dataframe which can be further populated by %# assignement, cat, ... If called without any argument, it should %# return a dataframe from the whole workspace. %# @*Variable input arguments are first parsed as pairs (options, values). %# Recognised options are: @itemize %# @item rownames : take the values as initialiser for row names %# @item colnames : take the values as initialiser for column names %# @item seeked : a (kept) field value which triggers start of processing. %# @item trigger : a (unkept) field value which triggers start of processing. %# Each preceeding line is silently skipped. Default: none %# @item unquot: a logical switch telling wheter or not strings should %# be unquoted before storage, default = true; %# @item sep: the elements separator, default '\t,' %# @end itemize %# The remaining data are concatenated (right-appended) to the existing ones. %# @end deftypefn %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: dataframe.m 9585 2012-02-05 15:32:46Z cdemills $ %# if (0 == nargin) disp ('FIXME -- should create a dataframe from the whole workspace') df = dataframe ([]); return endif if (isempty (x) && 1 == nargin) %# default constructor: initialise the fields in the right order df._cnt = [0 0]; df._name = {cell(0, 1), cell(1, 0)}; %# rows - cols df._over = cell (1, 2); df._ridx = []; df._data = cell (0, 0); df._rep = cell (0, 0); %# a repetition index df._type = cell (0, 0); %# the type of each column df._src = cell (0, 0); df._cmt = cell (0, 0); %# to put comments df = class (df, 'dataframe'); return endif if (isa (x, 'dataframe')) df = x; elseif (isa (x, 'struct')) df = class (x, 'dataframe'); return else df = dataframe ([]); %# get the right fields endif %# default values seeked = []; trigger =[]; unquot = true; sep = "\t,"; cmt_lines = []; locales = "C"; if (length(varargin) > 0) indi = 1; %# loop over possible arguments while (indi <= size (varargin, 2)) if (isa (varargin{indi}, 'char')) switch(varargin{indi}) case 'rownames' switch class (varargin{indi+1}) case {'cell'} df._name{1} = varargin{indi+1}; case {'char'} df._name{1} = cellstr (varargin{indi+1}); otherwise df._name{1} = cellstr (num2str (varargin{indi+1})); endswitch df._name{1} = genvarname (df._name{1}); df._over{1}(1, 1:length (df._name{1})) = false; df._cnt(1) = size (df._name{1}, 1); df._ridx = (1:df._cnt(1))'; varargin(indi:indi+1) = []; case 'colnames' switch class(varargin{indi+1}) case {'cell'} df._name{2} = varargin{indi+1}; case {'char'} df._name{2} = cellstr (varargin{indi+1}); otherwise df._name{2} = cellstr (num2str (varargin{indi+1})); endswitch %# detect assignment - functions calls - ranges dummy = cellfun ('size', cellfun (@(x) strsplit (x, ":=("), df._name{2}, \ "UniformOutput", false), 2); if (any(dummy > 1)) warning('dataframe colnames taken literally and not interpreted'); endif df._name{2} = genvarname (df._name{2}); df._over{2}(1, 1:length (df._name{2})) = false; varargin(indi:indi+1) = []; case 'seeked', seeked = varargin{indi + 1}; varargin(indi:indi+1) = []; case 'trigger', trigger = varargin{indi + 1}; varargin(indi:indi+1) = []; case 'unquot', unquot = varargin{indi + 1}; varargin(indi:indi+1) = []; case 'sep', sep = varargin{indi + 1}; varargin(indi:indi+1) = []; case 'locales' locales = varargin{indi + 1}; varargin(indi:indi+1) = []; otherwise %# FIXME: just skip it for now disp (sprintf ("Ignoring unkown argument %s", varargin{indi})); indi = indi + 1; endswitch else indi = indi + 1; %# skip it endif endwhile endif if (!isempty (seeked) && !isempty (trigger)) error ('seeked and trigger are mutuallly incompatible arguments'); endif indi = 0; while (indi <= size(varargin, 2)) indi = indi + 1; if (~isa (x, 'dataframe')) if (isa(x, 'char') && size(x, 1) < 2) %# read the data frame from a file try dummy = tilde_expand (x); x = load (dummy); df._src{end+1, 1} = dummy; catch %# try our own method UTF8_BOM = char([0xEF 0xBB 0xBF]); unwind_protect dummy = tilde_expand (x); fid = fopen (dummy); if (fid != -1) df._src{end+1, 1} = dummy; dummy = fgetl (fid); if (!strcmp (dummy, UTF8_BOM)) frewind (fid); endif %# slurp everything and convert doubles to char, avoiding %# problems with char > 127 in = char (fread (fid).'); else in = []; endif unwind_protect_cleanup if (fid != -1) fclose (fid); endif end_unwind_protect if (!isempty (in)) %# explicit list taken from 'man pcrepattern' -- we enclose all %# vertical separators in case the underlying regexp engine %# doesn't have them all. eol = '(\r\n|\n|\v|\f|\r|\x85)'; %# cut into lines -- include the EOL to have a one-to-one %# matching between line numbers. Use a non-greedy match. lines = regexp (in, ['.*?' eol], 'match'); dummy = cellfun (@(x) regexp (x, eol), lines); %# remove the EOL character(s) lines(1 == dummy) = {""}; %# use a positive lookahead -- eol is not part of the match lines(dummy > 1) = cellfun (@(x) regexp (x, ['.*?(?=' eol ')'], \ 'match'), lines(dummy > 1)); %# a field either starts at a word boundary, either by + - . for %# a numeric data, either by ' for a string. %# content = cellfun(@(x) regexp(x, '(\b|[-+\.''])[^,]*(''|\b)', 'match'),\ %# lines, 'UniformOutput', false); %# extract fields content = cellfun (@(x) strsplit (x, sep), lines, \ 'UniformOutput', false); %# extract fields indl = 1; indj = 1; %# disp('line 151 '); keyboard if (~isempty (seeked)) while (indl <= length (lines)) dummy = content{indl}; if (all (cellfun ('size', dummy, 2) == 0)) indl = indl + 1; continue; endif dummy = content{indl}; if (strcmp (dummy{1}, seeked)) break; endif indl = indl + 1; endwhile elseif (~isempty (trigger)) while (indl <= length (lines)) dummy = content{indl}; indl = indl + 1; if (all (cellfun ('size', dummy, 2) == 0)) continue; endif if (strcmp (dummy{1}, trigger)) break; endif endwhile endif x = cell (1+length (lines)-indl, size(dummy, 2)); empty_lines = []; cmt_lines = []; while (indl <= length(lines)) dummy = content{indl}; if (all (cellfun ('size', dummy, 2) == 0)) empty_lines = [empty_lines indj]; indl = indl + 1; indj = indj + 1; continue; endif %# does it looks like a comment line ? if (regexp (dummy{1}, ['^\s*' char(35)])) empty_lines = [empty_lines indj]; cmt_lines = strvcat (cmt_lines, horzcat (dummy{:})); indl = indl + 1; indj = indj + 1; continue; endif %# try to convert to float the_line = cellfun (@(x) sscanf (x, "%f", locales), dummy, \ 'UniformOutput', false); for indk = (1:size (the_line, 2)) if (isempty (the_line{indk}) || any (size (the_line{indk}) > 1)) %#if indi > 1 && indk > 1, disp('line 117 '); keyboard; %#endif if (unquot) try %# remove quotes and leading space(s) x(indj, indk) = regexp (dummy{indk}, '[^'' ].*[^'']', 'match'){1}; catch %# if the previous test fails, try a simpler one in = regexp (dummy{indk}, '[^'' ]+', 'match'); if (!isempty(in)) x(indj, indk) = in{1}; %# else %# x(indj, indk) = []; endif end_try_catch else %# no conversion possible, store and remove leading space(s) x(indj, indk) = regexp (dummy{indk}, '[^ ].*', 'match'); endif else if (!isempty (regexp (dummy{indk}, '[/:]'))) %# try to convert to a date [timeval, nfields] = strptime( dummy{indk}, [char(37) 'd/' char(37) 'm/' char(37) 'Y ' char(37) 'T']); if (nfields > 0) %# at least a few fields are OK timestr = strftime ([char(37) 'H:' char(37) 'M:' char(37) 'S'], timeval); %# try to extract the usec field, if any idx = regexp (dummy{indk}, timestr, 'end'); if (!isempty (idx)) idx = idx + 1; if (ispunct (dummy{indk}(idx))) idx = idx + 1; endif timeval.usec = str2num(dummy{indk}(idx:end)); endif x(indj, indk) = str2num (strftime ([char(37) 's'], timeval)) + ... timeval.usec * 1e-6; endif else x(indj, indk) = the_line{indk}; endif endif endfor indl = indl + 1; indj = indj + 1; endwhile if (!isempty(empty_lines)) x(empty_lines, :) = []; endif %# detect empty columns empty_lines = find (0 == sum (cellfun ('size', x, 2))); if (!isempty(empty_lines)) x(:, empty_lines) = []; endif clear UTF8_BOM fid in lines indl the_line content empty_lines clear timeval timestr nfields idx endif end_try_catch endif %# fallback, avoiding a recursive call idx.type = '()'; if (!isa (x, 'char')) indj = df._cnt(2)+(1:size (x, 2)); else %# at this point, reading some filename failed error("dataframe: can't open '%s' for reading data", x); endif; if (iscell(x)) if (2 == length (x)) %# use the intermediate value as destination column [indc, ncol] = df_name2idx (df._name{2}, x{1}, df._cnt(2), "column"); if (ncol != 1) error (["With two-elements cell, the first should resolve " ... "to a single column"]); endif try dummy = cellfun ('class', x{2}(2, :), 'UniformOutput', false); catch dummy = cellfun ('class', x{2}(1, :), 'UniformOutput', false); end_try_catch df = df_pad (df, 2, [length(dummy) indc], dummy); x = x{2}; indj = indc + (1:size(x, 2)); %# redefine target range else if (isa (x{1}, 'cell')) x = x{1}; %# remove one cell level endif endif if (length (df._name{2}) < indj(1) || isempty (df._name{2}(indj))) [df._name{2}(indj, 1), df._over{2}(1, indj)] ... = df_colnames (inputname(indi), indj); df._name{2} = genvarname (df._name{2}); endif %# allow overwriting of column names df._over{2}(1, indj) = true; else if (!isempty(indj)) if (1 == length (df._name{2}) && length (df._name{2}) < \ length (indj)) [df._name{2}(indj, 1), df._over{2}(1, indj)] ... = df_colnames (char(df._name{2}), indj); elseif (length (df._name{2}) < indj(1) || isempty (df._name{2}(indj))) [df._name{2}(indj, 1), df._over{2}(1, indj)] ... = df_colnames (inputname(indi), indj); endif df._name{2} = genvarname (df._name{2}); endif endif if (!isempty (indj)) %# the exact row size will be determined latter idx.subs = {'', indj}; %# use direct assignement if (ndims (x) > 2), idx.subs{3} = 1:size (x, 3); endif %# df = subsasgn(df, idx, x); <= call directly lower level df = df_matassign (df, idx, indj, length(indj), x); if (!isempty (cmt_lines)) df._cmt = vertcat(df._cmt, cellstr(cmt_lines)); cmt_lines = []; endif else df._cnt(2) = length (df._name{2}); endif elseif (indi > 1) error ('Concatenating dataframes: use cat instead'); endif try %# loop over next variable argument x = varargin{1, indi}; catch %# disp('line 197 ???'); end_try_catch endwhile endfunction function [x, y] = df_colnames(base, num) %# small auxiliary function to generate column names. This is required %# here, as only the constructor can use inputname() if (any ([index(base, "=")])) %# takes the left part as base x = strsplit (base, "="); x = deblank (x{1}); if (isvarname (x)) y = false; else x = 'X'; y = true; endif else %# is base most probably a filename ? x = regexp (base, '''[^''].*[^'']''', 'match'); if (isempty (x)) if (isvarname (base)) x = base; y = false; else x = 'X'; y = true; %# this is a default value, may be changed endif else x = x{1}; y = true; endif endif if (numel (num) > 1) x = repmat (x, numel (num), 1); x = cstrcat (x, strjust (num2str (num(:)), 'left')); y = repmat (y, 1, numel (num)); endif x = cellstr (x); endfunction dataframe/inst/@dataframe/minus.m0000600000175000017500000000231511713521330020301 0ustar carandraugcarandraugfunction resu = minus(A, B); %# function resu = minus(A, B) %# Implements the '-' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: minus.m 9585 2012-02-05 15:32:46Z cdemills $ %# try resu = df_func(@minus, A, B); catch disp(lasterr()); error("Operator - problem for %s vs. %s", class(A), class(B)); end_try_catch endfunction dataframe/inst/@dataframe/max.m0000600000175000017500000000176711713521330017745 0ustar carandraugcarandraugfunction resu = max(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: max.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper2(@max, df, varargin{:}); endfunction dataframe/inst/@dataframe/columns.m0000600000175000017500000000206011713521330020623 0ustar carandraugcarandraugfunction resu = columns(df) %# function resu = columns(df) %# returns the number of columns of a dataframe %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: columns.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df._cnt(end); endfunction dataframe/inst/@dataframe/sqrt.m0000600000175000017500000000176711713521330020151 0ustar carandraugcarandraugfunction resu = sqrt(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: sqrt.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@sqrt, df, varargin{:}); endfunction dataframe/inst/@dataframe/erfinv.m0000600000175000017500000000177511713521330020450 0ustar carandraugcarandraugfunction resu = erfinv(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: erfinv.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@erfinv, df, varargin{:}); endfunction dataframe/inst/@dataframe/arg.m0000600000175000017500000000176411713521330017726 0ustar carandraugcarandraugfunction resu = arg(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: arg.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@arg, df, varargin{:}); endfunction dataframe/inst/@dataframe/eq.m0000600000175000017500000000211311713521330017547 0ustar carandraugcarandraugfunction resu = eq(A, B); %# function resu = eq(A, B) %# Implements the '==' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: eq.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_func(@eq, A, B); endfunction dataframe/inst/@dataframe/ne.m0000600000175000017500000000211211713521330017543 0ustar carandraugcarandraugfunction resu = ne(A, B); %# function resu = ne(A, B) %# Implements the '!=' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: ne.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_func(@ne, A, B); endfunction dataframe/inst/@dataframe/sinh.m0000600000175000017500000000176711713521330020121 0ustar carandraugcarandraugfunction resu = sinh(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: sinh.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@sinh, df, varargin{:}); endfunction dataframe/inst/@dataframe/mtimes.m0000600000175000017500000000234611713521330020450 0ustar carandraugcarandraugfunction resu = mtimes(A, B); %# function resu = mtimes(A, B) %# Implements the '*' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: mtimes.m 9585 2012-02-05 15:32:46Z cdemills $ %# try resu = df_func(@mtimes, A, B, false, [true false]); catch disp(lasterr()); error("Operator * problem for %s vs. %s", class(A), class(B)); end_try_catch endfunction dataframe/inst/@dataframe/permute.m0000600000175000017500000000641111713521330020630 0ustar carandraugcarandraugfunction resu = permute(df, perm) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: permute.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = dataframe([]); if (length(df._cnt) >= length(perm)), resu._cnt = df._cnt(perm); else resu._cnt = [df._cnt 1](perm); endif if (ndims(df._ridx) < 3), resu._ridx = permute(df._ridx, [min(perm(1), 2) min(perm(2:end))]); else resu._ridx = permute(df._ridx, perm); endif if (size(resu._ridx, 1) < resu._cnt(1)), %# adjust index size, if required resu._ridx(end+1:resu._cnt(1), :, :) = NA; endif if (2 == perm(1)), resu._name{1} = df._name{2}; resu._over{1} = df._over{2}; indc = length(resu._name{1}); indi = resu._cnt(1) - indc; if (indi > 0), %# generate a name for the new row(s) dummy = cstrcat(repmat('_', indi, 1), ... strjust(num2str(indc + (1:indi).'), 'left')); resu._name{1}(indc + (1:indi)) = cellstr(dummy); resu._over{1}(1, indc + (1:indi)) = true; endif else resu._name{1} = df._name{1}; resu._over{1} = df._over{1}; endif if (2 == perm(2)), resu._name{2} = df._name{2}; resu._over{2} = df._over{2}; else resu._name{2} = df._name{1}; resu._over{2} = df._over{1}; endif if (isempty(resu._name{2})), indc = 0; else indc = length(resu._name{2}); endif indi = resu._cnt(2) - indc; if (indi > 0), %# generate a name for the new column(s) dummy = cstrcat(repmat('_', indi, 1), ... strjust(num2str(indc + (1:indi).'), 'left')); resu._name{2}(indc + (1:indi)) = cellstr(dummy); resu._over{2}(1, indc + (1:indi)) = true; endif if (2 != perm(2)), %# recompute the new type dummy = zeros(0, class(sum(cellfun(@(x) zeros(1, class(x(1))),\ df._data)))); resu._type(1:resu._cnt(2)) = class(dummy); dummy = permute(df_whole(df), perm); for indi = 1:resu._cnt(2), resu._data{indi} = squeeze(dummy(:, indi, :)); resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor else %# 2 == perm(2) if (1 == perm(1)), %# blank operation resu._type = df._type; resu._data = df._data; resu._rep = df._rep; else for indi = 1:resu._cnt(2), unfolded = df._data{indi}(:, df._rep{indi}); resu._data{indi} = permute(unfolded, [2 1]); resu._rep{indi} = 1:size(resu._data{indi}, 2); resu._type{indi} = df._type{indi}; endfor endif endif resu._src = df._src; resu._cmt = df._cmt; endfunction dataframe/inst/@dataframe/xor.m0000600000175000017500000000211611713521330017755 0ustar carandraugcarandraugfunction resu = xor(A, B); %# function resu = xor(A, B) %# Implements the '??' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: xor.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_func(@xor, A, B); endfunction dataframe/inst/@dataframe/log2.m0000600000175000017500000000176711713521330020023 0ustar carandraugcarandraugfunction resu = log2(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: log2.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@log2, df, varargin{:}); endfunction dataframe/inst/@dataframe/fold.m0000600000175000017500000000554011713521330020075 0ustar carandraugcarandraugfunction resu = fold(df, dim, indr, indc) %# function resu = subasgn(df, S, RHS) %# The purpose is to fold a dataframe. Part from (1:indr-1) doesn't %# move, then content starting at indr is moved into the second, %# third, ... sheet. To be moved, there must be equality of rownames, %# if any, and of fields contained in indc. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: fold.m 9585 2012-02-05 15:32:46Z cdemills $ %# switch dim case 1 [indr, nrow] = df_name2idx(df._name{1}, indr, df._cnt(1), 'row'); [indc, ncol] = df_name2idx(df._name{2}, indc, df._cnt(2), 'column'); if (indr(1) > 1), slice_size = indr(1) - 1; %# we can't use directly resu = df(1:slice_size, :, :) S.type = '()'; S.subs = { 1:slice_size, ':', ':', 'dataframe'}; resu = subsref(df, S); %# how many columns for each slice targets = cellfun(@length, df._rep); %# a test function to determine if the location is free for indj = 1:df._cnt(2), if (any(indj == indc)), continue; endif switch df._type{indj} case { 'char' } testfunc{indj} = @(x, indr, indc) ... !isna(x{indr, indc}); otherwise testfunc{indj} = @(x, indr, indc) ... !isna(x(indr, indc)); endswitch endfor for indi = indr, %# where does this line go ? where = find(df._data{indc}(1:slice_size, 1) ... == df._data{indc}(indi, 1)); if (!isempty(where)), %# transfering one line -- loop over columns for indj = 1:df._cnt(2), if any(indj == indc), continue; endif if (testfunc{indj}(resu._data{indj}, where, targets(indj))), %# add one more sheet resu = df_pad(resu, 3, 1, indj); targets(indj) = targets(indj) + 1; endif %# transfer field stop resu._data{indj}(where, targets(indj)) = ... df._data{indj}(indi, 1); endfor %# update row index resu._ridx(where, max(targets)) = df._ridx(indi); else disp('line 65: FIXME'); keyboard; endif endfor else disp('line 70: FIXME '); keyboard endif endswitch dataframe/inst/@dataframe/ipermute.m0000600000175000017500000000200611713521330020775 0ustar carandraugcarandraugfunction resu = ipermute(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: ipermute.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper2(@ipermute, df, varargin{:}); endfunction dataframe/inst/@dataframe/summary.m0000600000175000017500000000552611713521330020652 0ustar carandraugcarandraugfunction resu = summary(df) %# function resu = summary(df) %# This function prints a nice summary of a dataframe, on a %# colum-by-column basis. For continuous varaibles, returns basic %# statistics; for discrete one (char, factors, ...), returns the %# occurence count for each element. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: summary.m 9585 2012-02-05 15:32:46Z cdemills $ %# dummy = df._type; resu = []; for indi = 1:length(dummy), switch dummy{indi} case {'char' 'factor'} [sval, sidxi, sidxj] = unique(df._data{:, indi}); %# compute their occurences sidxj = hist(sidxj, min(sidxj):max(sidxj)); %# generate a column with unique values resuR = strjust(char(regexp(disp(sval), '\S.*', 'match', ... 'dotexceptnewline')), 'right'); resuR = horzcat(resuR, repmat(':', size(resuR, 1), 1), strjust(char(regexp(disp(sidxj.'), '\b.*', 'match', ... 'dotexceptnewline')), ... 'right')); %# now put the name above all resuR = strjust([deblank(df._name{1, 2}(indi, :)); resuR], 'right'); resuR = horzcat(resuR, repmat(' ', size(resuR, 1), 1)); resu = horzcat_pad(resu, resuR); otherwise s = statistics(df._data{:, indi}); s = s([1:3 6 4:5]); %# generate a column with name and fields name resuR = strjust([deblank(df._name{1, 2}{indi, :}); "Min. :"; "1st Qu.:"; "Median :"; "Mean :"; "3rd Qu.:"; "Max. :"], 'right'); %# generate a column with a blank line and the values resuR = horzcat(resuR, repmat(' ', size(resuR, 1), 1), strjust(char(' ', regexp(disp(s), '\S.*', 'match', ... 'dotexceptnewline')), 'right'),... repmat(' ', size(resuR, 1), 1)); resu = horzcat_pad(resu, resuR); endswitch endfor endfunction function resu = horzcat_pad(A, B) %# small auxiliary function to cat horizontally tables of different height dx = size(A, 1) - size(B, 1); if dx < 0, %# pad A A = strvcat(A, repmat(' ', -dx, size(A, 2))); elseif dx > 0 B = strvcat(B, repmat(' ', dx, size(B, 2))); endif resu = horzcat(A, B); endfunction dataframe/inst/@dataframe/le.m0000600000175000017500000000211211713521330017541 0ustar carandraugcarandraugfunction resu = le(A, B); %# function resu = le(A, B) %# Implements the '<=' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: le.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_func(@le, A, B); endfunction dataframe/inst/@dataframe/sort.m0000600000175000017500000001057611713521330020145 0ustar carandraugcarandraugfunction [resu, idx] = sort(df, varargin) %# -*- texinfo -*- %# @deftypefn {Loadable Function} {[@var{s}, @var{i}] =} sort (@var{x}) %# @deftypefnx {Loadable Function} {[@var{s}, @var{i}] =} sort (@var{x}, @var{dim}) %# @deftypefnx {Loadable Function} {[@var{s}, @var{i}] =} sort (@var{x}, @var{mode}) %# @deftypefnx {Loadable Function} {[@var{s}, @var{i}] =} sort (@var{x}, @var{dim}, @var{mode}) %# Return a copy of @var{x} with the elements arranged in increasing %# order. For matrices, @code{sort} orders the elements in each column. %# %# For example: %# %# @example %# @group %# sort ([1, 2; 2, 3; 3, 1]) %# @result{} 1 1 %# 2 2 %# 3 3 %# %# @end group %# @end example %# %# The @code{sort} function may also be used to produce a matrix %# containing the original row indices of the elements in the sorted %# matrix. For example: %# %# @example %# @group %# [s, i] = sort ([1, 2; 2, 3; 3, 1]) %# @result{} s = 1 1 %# 2 2 %# 3 3 %# @result{} i = 1 3 %# 2 1 %# 3 2 %# @end group %# @end example %# %# If the optional argument @var{dim} is given, then the matrix is sorted %# along the dimension defined by @var{dim}. The optional argument @code{mode} %# defines the order in which the values will be sorted. Valid values of %# @code{mode} are `ascend' or `descend'. %# %# For equal elements, the indices are such that the equal elements are listed %# in the order that appeared in the original list. %# %# The @code{sort} function may also be used to sort strings and cell arrays %# of strings, in which case the dictionary order of the strings is used. %# %# The algorithm used in @code{sort} is optimized for the sorting of partially %# ordered lists. %# @end deftypefn %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: sort.m 9585 2012-02-05 15:32:46Z cdemills $ %# if !isa(df, 'dataframe'), resu = []; return; endif dim = []; mode = []; vout= varargin; indi = 1; while indi <= length(varargin) if isnumeric(varargin{indi}), if !isempty(dim), print_usage('@dataframe/sort'); resu = []; return else dim = varargin{indi}; if 3 == dim, vout(indi) = 2; endif endif else if !isempty(mode), print_usage('@dataframe/sort'); resu = []; return else sort = varargin{indi}; endif endif indi = indi + 1; endwhile; if isempty(dim), dim = 1; endif; %# pre-assignation resu = struct(df); switch(dim) case {1}, for indi = 1:resu._cnt(2), [resu._data{indi}, idx(:, indi, :)] = sort\ (resu._data{indi}(:, resu._rep{indi}), varargin{:}); resu._data{indi} = squeeze(resu._data{indi}); resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor if (all([1 == size(idx, 2) 1 == size(idx, 3)])), if (size(resu._ridx, 1) == resu._cnt(1)), resu._ridx = resu._ridx(idx, :); endif if (!isempty(resu._name{1, 1})), resu._name{1, 1} = resu._name{1, 1}(idx); resu._over{1, 1} = resu._over{1, 1}(idx); endif else %# data where mixed resu._ridx = idx; resu._name{1, 1} = []; resu._over{1, 1} = []; endif case {2}, error('Operation not implemented'); case {3}, for indi = 1:resu._cnt(2), [resu._data{1, indi}, idx(:, indi)] = sort(resu._data{1, indi}, vout(:)); endfor otherwise error("Invalid dimension %d", dim); endswitch dummy = dbstack(); if (any(strmatch('quantile', {dummy.name}))), resu = df_whole(resu); else resu = dataframe(resu); endif endfunction dataframe/inst/@dataframe/erfc.m0000600000175000017500000000176711713521330020077 0ustar carandraugcarandraugfunction resu = erfc(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: erfc.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@erfc, df, varargin{:}); endfunction dataframe/inst/@dataframe/bsxfun.m0000600000175000017500000000303311713521330020451 0ustar carandraugcarandraugfunction resu = bsxfun(func, A, B) %# function resu = bsxfun(func, A, B) %# Implements a wrapper around internal bsxfun %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: bsxfun.m 9585 2012-02-05 15:32:46Z cdemills $ %# try [A, B, resu] = df_basecomp(A, B, true, @bsxfun); for indi = 1:max(A._cnt(2), B._cnt(2)), indA = min(indi, A._cnt(2)); indB = min(indi, B._cnt(2)); Au = A._data{indA}(:, A._rep{indA}); Bu = B._data{indB}(:, B._rep{indB}); resu._data{indi} = bsxfun(func, Au, Bu); resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor resu = df_thirddim(resu); catch disp(lasterr()); error('bsxfun: non-compatible dimensions') end_try_catch endfunction dataframe/inst/@dataframe/plus.m0000600000175000017500000000231111713521330020125 0ustar carandraugcarandraugfunction resu = plus(A, B); %# function resu = plus(A, B) %# Implements the '+' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: plus.m 9585 2012-02-05 15:32:46Z cdemills $ %# try resu = df_func(@plus, A, B); catch disp(lasterr()); error("Operator + problem for %s vs. %s", class(A), class(B)); end_try_catch endfunction dataframe/inst/@dataframe/isnumeric.m0000600000175000017500000000256511713521330021153 0ustar carandraugcarandraugfunction resu = ismatrix(df) %# function resu = isnumeric(df) %# returns true if the dataframe contains only numeric columns %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: isnumeric.m 9585 2012-02-05 15:32:46Z cdemills $ %# df_is_num = isnumeric(df._data{1}); df_is_char = ischar(df._data{1}); for indi = df._cnt(2):-1:2, df_is_num = df_is_num & isnumeric(df._data{indi}); df_is_char = df_is_char & ischar(df._data{indi}); endfor resu = isnumeric(zeros(0, class(sum(cellfun(@(x) zeros(1, class(x(1))),\ df._data))))); endfunction dataframe/inst/@dataframe/ismatrix.m0000600000175000017500000000245611713521330021014 0ustar carandraugcarandraugfunction resu = ismatrix(df) %# function resu = ismatrix(df) %# returns true if the dataframe can be converted to a matrix %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: ismatrix.m 9585 2012-02-05 15:32:46Z cdemills $ %# df_is_num = isnumeric(df._data{1}); df_is_char = ischar(df._data{1}); for indi = df._cnt(2):-1:2, df_is_num = df_is_num & isnumeric(df._data{indi}); df_is_char = df_is_char & ischar(df._data{indi}); endfor resu = df_is_num | df_is_char; endfunction dataframe/inst/@dataframe/round.m0000600000175000017500000000177211713521330020303 0ustar carandraugcarandraugfunction resu = round(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: round.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@round, df, varargin{:}); endfunction dataframe/inst/@dataframe/expm1.m0000600000175000017500000000177211713521330020206 0ustar carandraugcarandraugfunction resu = expm1(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: expm1.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@expm1, df, varargin{:}); endfunction dataframe/inst/@dataframe/isinf.m0000600000175000017500000000177211713521330020264 0ustar carandraugcarandraugfunction resu = isinf(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: isinf.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@isinf, df, varargin{:}); endfunction dataframe/inst/@dataframe/sumsq.m0000600000175000017500000000207111713521330020315 0ustar carandraugcarandraugfunction resu = sumsq(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: sumsq.m 9585 2012-02-05 15:32:46Z cdemills $ %# if !isa(df, 'dataframe'), resu = []; return; endif resu = df_mapper2(@sumsq, df, varargin{:}); endfunction dataframe/inst/@dataframe/floor.m0000600000175000017500000000177211713521330020275 0ustar carandraugcarandraugfunction resu = floor(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: floor.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@floor, df, varargin{:}); endfunction dataframe/inst/@dataframe/kron.m0000600000175000017500000000211411713521330020114 0ustar carandraugcarandraugfunction resu = kron(A, B) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: kron.m 9585 2012-02-05 15:32:46Z cdemills $ %# if (isa(A, 'dataframe')), A = df_whole(A); endif if (isa(B, 'dataframe')), B = df_whole(B); endif resu = kron(A, B); endfunction dataframe/inst/@dataframe/acos.m0000600000175000017500000000176711713521330020105 0ustar carandraugcarandraugfunction resu = acos(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: acos.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@acos, df, varargin{:}); endfunction dataframe/inst/@dataframe/roundb.m0000600000175000017500000000177511713521330020450 0ustar carandraugcarandraugfunction resu = roundb(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: roundb.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@roundb, df, varargin{:}); endfunction dataframe/inst/@dataframe/end.m0000600000175000017500000000244711713521330017722 0ustar carandraugcarandraugfunction resu = end(df, k, n) %# function resu = end(df, k, n) %# This is the end operator for a dataframe object, returning the %# maximum number of rows or columns %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: end.m 9585 2012-02-05 15:32:46Z cdemills $ %# try if k < 3, resu = df._cnt(k); else resu = max(cellfun(@length, df._rep)); endif catch error("incorrect call to end, index greater than number of dimensions"); end_try_catch endfunction dataframe/inst/@dataframe/ge.m0000600000175000017500000000211211713521330017534 0ustar carandraugcarandraugfunction resu = ge(A, B); %# function resu = ge(A, B) %# Implements the '>=' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: ge.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_func(@ge, A, B); endfunction dataframe/inst/@dataframe/gamma.m0000600000175000017500000000177211713521330020236 0ustar carandraugcarandraugfunction resu = gamma(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: gamma.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@gamma, df, varargin{:}); endfunction dataframe/inst/@dataframe/not.m0000600000175000017500000000176411713521330017755 0ustar carandraugcarandraugfunction resu = not(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: not.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@not, df, varargin{:}); endfunction dataframe/inst/@dataframe/exp.m0000600000175000017500000000176411713521330017751 0ustar carandraugcarandraugfunction resu = exp(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: exp.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@exp, df, varargin{:}); endfunction dataframe/inst/@dataframe/subsasgn.m0000600000175000017500000001500211713521330020770 0ustar carandraugcarandraugfunction df = subasgn(df, S, RHS) %# function df = subasgn(df, S, RHS) %# This is the assignement operator for a dataframe object, taking %# care of all the housekeeping of meta-info. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: subsasgn.m 9585 2012-02-05 15:32:46Z cdemills $ %# if (isnull (df)) error ('dataframe subsasgn: first argument may not be empty'); endif switch (S(1).type) case '{}' error ('Invalid dataframe as cell assignement'); case '.' %# translate the external to internal name switch (S(1).subs) case "rownames" if (~isnull (RHS) && isempty (df._name{1})) df._name{1}(1:df._cnt(1), 1) = {''}; df._over{1}(1, 1:df._cnt(1)) = true; endif [df._name{1}, df._over{1}] = df_strset \ (df._name{1}, df._over{1}, S(2:end), RHS); return case "rowidx" if (1 == length(S)) df._ridx = RHS; else df._ridx = feval (@subsasgn, df._ridx, S(2:end), RHS); endif return case "colnames" if (isnull(RHS)) error ("Colnames can't be nulled"); endif [df._name{2}, df._over{2}] = df_strset \ (df._name{2}, df._over{2}, S(2:end), RHS, '_'); df._name{2} = genvarname (df._name{2}); return case "types" if (isnull(RHS)) error("Types can't be nulled"); endif if (1 == length (S)) %# perform explicit cast on each column df._data = cellfun (@(x) cast (x, RHS), df._data, "UniformOutput", false); df._type(1:end) = RHS; else if (~strcmp (S(2).type, '()')) error ("Invalid internal type sub-access, use () instead"); endif if (length (S) > 2 || length (S(2).subs) > 1) error("Types can only be changed as a whole"); endif if (~isnumeric(S(2).subs{1})) [indj, ncol, S(2).subs{1}] = df_name2idx\ (df._name{2}, S(2).subs{1}, df._cnt(2), 'column'); else indj = S(2).subs{1}; ncol = length (indj); endif df._data(indj) = cellfun (@(x) cast (x, RHS), df._data(indj), "UniformOutput", false); df._type(indj) = {RHS}; endif return case "source" if (length(S) > 1) df._src = feval (@subsasgn, df._src, S(2:end), RHS); else df._src = RHS; endif return case "comment" if (length(S) > 1) df._cmt = feval (@subsasgn, df._cmt, S(2:end), RHS); else df._cmt = RHS; endif return otherwise if (~ischar (S(1).subs)) error ("Congratulations. I didn't see how to produce this error"); endif %# translate the name to column [indc, ncol] = df_name2idx (df._name{2}, S(1).subs, \ df._cnt(2), 'column', true); if (isempty(indc)) %# dynamic allocation df = df_pad (df, 2, 1, class (RHS)); indc = df._cnt(2); ncol = 1; df._name{2}(end) = S(1).subs; df._name{2} = genvarname(df._name{2}); df._over{2}(end) = false; endif if (length(S) > 1) if (1 == length (S(2).subs)), %# add column reference S(2).subs{2} = indc; else S(2).subs(2:3) = {indc, S(2).subs{2}}; endif else %# full assignement S(2).type = '()'; S(2).subs = { '', indc, ':' }; if (ndims (RHS) < 3) if (isnull (RHS)) S(2).subs = {':', indc}; elseif (1 == size (RHS, 2)) S(2).subs = { '', indc }; elseif (1 == ncol && 1 == size (df._data{indc}, 2)) %# force the padding of the vector to a matrix S(2).subs = {'', indc, [1:size(RHS, 2)]}; endif endif endif %# do we need to "rotate" RHS ? if (1 == ncol && ndims (RHS) < 3 \ && size (RHS, 2) > 1) RHS = reshape (RHS, [size(RHS, 1), 1, size(RHS, 2)]); endif df = df_matassign (df, S(2), indc, ncol, RHS); endswitch case '()' [indr, nrow, S(1).subs{1}] = df_name2idx (df._name{1}, S(1).subs{1}, \ df._cnt(1), 'row'); if (isempty (indr) && df._cnt(1) > 0) %# this is not an initial assignment df = df; return; endif if (length (S(1).subs) > 1) if (~isempty (S(1).subs{2})) [indc, ncol, S(1).subs{2}] = \ df_name2idx (df._name{2}, S(1).subs{2}, df._cnt(2), 'column'); %# if (isempty (indc) && df._cnt(2) > 0) %# this is not an initial assignment %# df = df; return; else [indc, ncol] = deal ([]); endif else mz = max (cellfun (@length, df._rep)); [fullindr, fullindc, fullinds] = ind2sub ([df._cnt(1:2) mz], indr); indr = unique( fullindr); indc = unique (fullindc); inds = unique (fullinds); ncol = length (indc); if (any (inds > 1)) S(1).subs{3} = inds; endif endif %# avoid passing ':' as selector on the two first dims if (~isnull (RHS)) S(1).subs{1} = indr; S(1).subs{2} = indc; endif df = df_matassign (df, S, indc, ncol, RHS); endswitch %# disp("end of subasgn"); keyboard endfunction dataframe/inst/@dataframe/sin.m0000600000175000017500000000176411713521330017746 0ustar carandraugcarandraugfunction resu = sin(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: sin.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@sin, df, varargin{:}); endfunction dataframe/inst/@dataframe/size.m0000600000175000017500000000433011713521330020117 0ustar carandraugcarandraugfunction varargout = size(df, varargin) %# function resu = size(df, varargin) %# This is size operator for a dataframe object. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: size.m 9585 2012-02-05 15:32:46Z cdemills $ %# switch nargin case 1 switch nargout case {0, 1} varargout{1} = df._cnt; case {2} varargout{1} = df._cnt(1); if (1 == df._cnt(2) && length(df._cnt) > 2), varargout{2} = df._cnt(3); else varargout{2} = df._cnt(2); endif case {3} varargout{1:2} = df._cnt(1:2); if 2==length(df._cnt), varargout{3} = 1; else varargout{3} = df._cnt(3); endif otherwise error(print_usage()); endswitch case 2 switch nargout case {0 1} varargout{1} = df._cnt; try varargout{1} = varargout{1}(varargin{1}); catch error(print_usage()); end_try_catch otherwise error(print_usage()); endswitch case 3 switch nargout case {0 1} if (length(df._cnt) < 3), varargout{1} = 1; else varargout{1} = df._cnt; endif try varargout{1} = varargout{1}(varargin{1}); catch error(print_usage()); end_try_catch otherwise error(print_usage()); endswitch otherwise error(print_usage()); endswitch endfunction function usage = print_usage() usage = strcat('Invalid call to size. Correct usage is: ', ' ', ... '-- Overloaded Function: size (A, N)'); endfunction dataframe/inst/@dataframe/log1p.m0000600000175000017500000000177211713521330020176 0ustar carandraugcarandraugfunction resu = log1p(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: log1p.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@log1p, df, varargin{:}); endfunction dataframe/inst/@dataframe/ndims.m0000644000175000017500000000042211501365041020265 0ustar carandraugcarandraugfunction resu = ndims(df) %# -*- texinfo -*- %# @deftypefn {Function File} ndims(@var{df}) %# overloaded function implementing ndims for a dataframe %# @end deftypefn resu = 2; nseq = max(cellfun(@length, df._rep)); if nseq > 1, resu = 3; endif endfunction dataframe/inst/@dataframe/find.m0000600000175000017500000000401411713521330020064 0ustar carandraugcarandraugfunction varargout = find(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: find.m 9585 2012-02-05 15:32:46Z cdemills $ %# switch nargout case {0, 1} resu = []; mz = max(cellfun(@length, df._rep)); for indc = 1:df._cnt(2), [indr, inds] = feval(@find, df._data{indc}(:, df._rep{indc})); %# create a vector the same size as indr dummy = indr; dummy(:) = indc; resu = [resu; sub2ind([df._cnt(1:2) mz], indr, dummy, inds)]; endfor varargout{1} = sort(resu); case 2 nz = 0; idx_i = []; idx_j = []; for indc = 1:df._cnt(2), [dum1, dum2] = feval(@find, df._data{indc}(:, df._rep{indc})); idx_i = [idx_i; dum1]; idx_j = [idx_j; nz + dum2]; nz = nz + df._cnt(1)*length(df._rep{indc}); endfor varargout{1} = idx_i; varargout{2} = idx_j; case 3 nz = 0; idx_i = []; idx_j = []; val = []; for indc = 1:df._cnt(2), [dum1, dum2, dum3] = feval(@find, df._data{indc}(:, df._rep{indc})); idx_i = [idx_i; dum1]; idx_j = [idx_j; nz + dum2]; val = [val; dum3]; nz = nz + df._cnt(1)*length(df._rep{indc}); endfor varargout{1} = idx_i; varargout{2} = idx_j; varargout{3} = val; otherwise print_usage('find'); endswitch endfunction dataframe/inst/@dataframe/horzcat.m0000600000175000017500000000216111713521330020617 0ustar carandraugcarandraugfunction resu = horzcat(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: horzcat.m 9585 2012-02-05 15:32:46Z cdemills $ %# for indi = 1:length(varargin), varargin{indi} = dataframe(varargin{indi}, 'colnames', inputname(1+indi));, endfor resu = cat(2, df, varargin{:}); endfunction dataframe/inst/@dataframe/tan.m0000600000175000017500000000176411713521330017737 0ustar carandraugcarandraugfunction resu = tan(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: tan.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@tan, df, varargin{:}); endfunction dataframe/inst/@dataframe/acosh.m0000600000175000017500000000177211713521330020251 0ustar carandraugcarandraugfunction resu = acosh(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: acosh.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@acosh, df, varargin{:}); endfunction dataframe/inst/@dataframe/imag.m0000600000175000017500000000176711713521330020075 0ustar carandraugcarandraugfunction resu = imag(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: imag.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@imag, df, varargin{:}); endfunction dataframe/inst/@dataframe/min.m0000600000175000017500000000176711713521330017743 0ustar carandraugcarandraugfunction resu = min(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: min.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper2(@min, df, varargin{:}); endfunction dataframe/inst/@dataframe/and.m0000600000175000017500000000211511713521330017706 0ustar carandraugcarandraugfunction resu = and(A, B); %# function resu = and(A, B) %# Implements the '&' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: and.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_func(@and, A, B); endfunction dataframe/inst/@dataframe/uplus.m0000600000175000017500000000210711713521330020315 0ustar carandraugcarandraugfunction resu = uplus(df); %# function resu = uplus(df) %# Implements the unitary '+' operator for a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: uplus.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@uplus, df); endfunction dataframe/inst/@dataframe/gt.m0000600000175000017500000000211111713521330017552 0ustar carandraugcarandraugfunction resu = gt(A, B); %# function resu = gt(A, B) %# Implements the '>' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: gt.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_func(@gt, A, B); endfunction dataframe/inst/@dataframe/inv.m0000600000175000017500000000341311713521330017742 0ustar carandraugcarandraugfunction [resu, rcond] = inv(df); %# function [x, rcond] = inv(df) %# Overloaded function computing the inverse of a dataframe. To %# succeed, the dataframe must be convertible to an square array. Row %# and column meta-information are exchanged. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: inv.m 9585 2012-02-05 15:32:46Z cdemills $ %# if (length(df._cnt) > 2 || (df._cnt(1) != df._cnt(2))), error("Dataframe is not square"); endif %# quick and dirty conversion [dummy, rcond] = inv(horzcat(df._data{:})); resu = df_allmeta(df); [resu._name{2}, resu._name{1}] = deal(resu._name{1}, resu._name{2}); [resu._over{2}, resu._over{1}] = deal(resu._over{1}, resu._over{2}); if (isempty(resu._name{2})), resu._name{2} = cellstr(repmat('_', resu._cnt(2), 1)); resu._over{2} = ones(1, resu._cnt(2)); endif for indi = resu._cnt(1):-1:1, resu._data{indi} = dummy(:, indi); endfor resu._type(:) = class(dummy); endfunction dataframe/inst/@dataframe/sum.m0000600000175000017500000000206311713521330017752 0ustar carandraugcarandraugfunction resu = sum(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: sum.m 9585 2012-02-05 15:32:46Z cdemills $ %# if !isa(df, 'dataframe'), resu = []; return; endif resu = df_mapper2(@sum, df, varargin{:}); endfunction dataframe/inst/@dataframe/atanh.m0000600000175000017500000000177211713521330020247 0ustar carandraugcarandraugfunction resu = atanh(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: atanh.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@atanh, df, varargin{:}); endfunction dataframe/inst/@dataframe/power.m0000600000175000017500000000177211713521330020310 0ustar carandraugcarandraugfunction resu = power(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: power.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@power, df, varargin{:}); endfunction dataframe/inst/@dataframe/lgamma.m0000600000175000017500000000177511713521330020415 0ustar carandraugcarandraugfunction resu = lgamma(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: lgamma.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@lgamma, df, varargin{:}); endfunction dataframe/inst/@dataframe/cumprod.m0000600000175000017500000000200011713521330020606 0ustar carandraugcarandraugfunction resu = cumprod(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: cumprod.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@cumprod, df, varargin{:}); endfunction dataframe/inst/@dataframe/real.m0000600000175000017500000000176711713521330020103 0ustar carandraugcarandraugfunction resu = real(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: real.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@real, df, varargin{:}); endfunction dataframe/inst/@dataframe/rdivide.m0000600000175000017500000000233511713521330020576 0ustar carandraugcarandraugfunction resu = rdivide(A, B); %# function resu = rdivide(A, B) %# Implements the dotted '\' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: rdivide.m 9585 2012-02-05 15:32:46Z cdemills $ %# try resu = df_func(@rdivide, A, B); catch disp(lasterr()); error("Operator ./ problem for %s vs. %s", class(A), class(B)); end_try_catch endfunction dataframe/inst/@dataframe/or.m0000600000175000017500000000211111713521330017560 0ustar carandraugcarandraugfunction resu = or(A, B); %# function resu = or(A, B) %# Implements the '|' operator when at least one argument is a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: or.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_func(@or, A, B); endfunction dataframe/inst/@dataframe/abs.m0000600000175000017500000000176411713521330017722 0ustar carandraugcarandraugfunction resu = abs(df, varargin) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: abs.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_mapper(@abs, df, varargin{:}); endfunction dataframe/inst/@dataframe/private/df_thirddim.m0000600000175000017500000000242211713521330023074 0ustar carandraugcarandraugfunction [df] = df_thirddim(df) %# function [resu] = df_thirddim(df) %# This is a small helper function which recomputes the third dim each %# time a change may have occured. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_thirddim.m 9585 2012-02-05 15:32:46Z cdemills $ %# %# sanity check dummy = max(cellfun(@length, df._rep)); if (dummy != 1), df._cnt(3) = dummy; elseif (length(df._cnt) > 2), df._cnt = df._cnt(1:2); endif endfunction dataframe/inst/@dataframe/private/df_pad.m0000600000175000017500000001254711713521330022045 0ustar carandraugcarandraugfunction df = df_pad(df, dim, n, coltype=[]) %# function resu = df_pad(df, dim, n, coltype = []) %# given a dataframe, insert n rows or columns, and adjust everything %# accordingly. Coltype is a supplemental argument: %# dim = 1 => not used %# dim = 2 => type of the added column(s) %# dim = 3 => index of columns receiving a new sheet (default: all) %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_pad.m 9585 2012-02-05 15:32:46Z cdemills $ %# switch dim case 1 if (!isempty(df._name{1})), if (length(df._name{1}) < df._cnt(1)+n), %# generate a name for the new row(s) df._name{1}(df._cnt(1)+(1:n), 1) = {'_'}; df._over{1}(1, df._cnt(1)+(1:n), 1) = true; endif endif %# complete row indexes: by default, row number. if (isempty(df._ridx)), dummy = (1:n)(:); else dummy = vertcat(df._ridx, repmat(size(df._ridx, 1)+(1:n)(:), ... 1, size(df._ridx, 2))); endif df._ridx = dummy; %# pad every line for indi = 1:min(size(df._data, 2), df._cnt(2)), neff = n + df._cnt(1) - size(df._data{indi}, 1); if (neff > 0), m = size(df._data{indi}, 2); switch df._type{indi} case {'char'} dummy = {}; dummy(1:neff, 1:m) = NA; dummy = vertcat(df._data{indi}, dummy); case { 'double' } dummy = vertcat(df._data{indi}, repmat(NA, neff, m)); otherwise dummy = cast(vertcat(df._data{indi}, repmat(NA, neff, m)), ... df._type{indi}); endswitch df._data{indi} = dummy; endif endfor df._cnt(1) = df._cnt(1) + n; case 2 %# create new columns if (isempty(coltype)) error("df_pad: dim equals 2, and coltype undefined"); endif if (length(n) > 1), %#second value is an offset indc = n(2); n = n(1); if (indc < df._cnt(2)), %# shift to the right df._name{2}(n + (indc+1:end)) = df._name{2}(indc+1:end); df._over{2}(n + (indc+1:end)) = df._over{2}(indc+1:end); dummy = cstrcat(repmat('_', n, 1), ... strjust(num2str(indc + (1:n).'), 'left')); df._name{2}(indc + (1:n)) = cellstr(dummy); df._over{2}(indc + (1:n)) = true; df._type(n+(indc+1:end)) = df._type(indc+1:end); df._type(indc + (1:n)) = NA; df._data(n + (indc+1:end)) = df._data(indc+1:end); df._rep(n + (indc+1:end)) = df._rep(indc+1:end); df._data(indc + (1:n)) = NA; df._rep(indc + (1:n)) = 1; endif else %# add new values after the last column indc = min(size(df._data, 2), df._cnt(2)); endif if (!isa(coltype, 'cell')), coltype = {coltype}; endif if (isscalar(coltype) && n > 1), coltype = repmat(coltype, 1, n); endif for indi = (1:n), switch coltype{indi} case {'char'} dummy = {repmat(NA, df._cnt(1), 1) }; dummy(:, 1) = '_'; case { 'double'} dummy = repmat(NA, df._cnt(1), 1); case {'logical'} %# there is no NA in logical type dummy = repmat(false, df._cnt(1), 1); otherwise dummy = cast(repmat(NA, df._cnt(1), 1), coltype{indi}); endswitch df._data{indc+indi} = dummy; df._rep{indc+indi} = 1; df._type{indc+indi} = coltype{indi}; endfor if (size(df._data, 2) > df._cnt(2)), df._cnt(2) = size(df._data, 2); endif if (length(df._name{2}) < df._cnt(2)), %# generate a name for the new column(s) dummy = cstrcat(repmat('_', n, 1), ... strjust(num2str(indc + (1:n).'), 'left')); df._name{2}(indc + (1:n)) = cellstr(dummy); df._over{2}(1, indc + (1:n)) = true; endif case 3 if (n <= 0), return; endif if (isempty(coltype)), coltype = 1:df._cnt(2); endif dummy = max(n+cellfun(@length, df._rep(coltype))); if (size(df._ridx, 2) < dummy), df._ridx(:, end+1:dummy) = NA; endif for indi = coltype, switch df._type{indi} case {'char'} if (isa(df._data{indi}, 'char')), dummy = horzcat(df._data{indi}(:, df._rep{indi}), \ {repmat(NA, df._cnt(1), 1)}); else dummy = df._data{indi}; endif case { 'double' } dummy = horzcat(df._data{indi}(:, df._rep{indi}), \ repmat(NA, df._cnt(1), 1)); case { 'logical' } %# there is no logical 'NA' -- fill empty elems with false dummy = horzcat(df._data{indi}(:, df._rep{indi}), \ repmat(false, df._cnt(1), 1)); otherwise dummy = cast(horzcat(df._data{indi}(:, df._rep{indi}), \ repmat(NA, df._cnt(1), 1)), \ df._type{indi}); endswitch df._data{indi} = dummy; df._rep{indi} = [df._rep{indi} length(df._rep{indi})+ones(1, n)]; endfor df = df_thirddim(df); otherwise error('Invalid dimension in df_pad'); endswitch endfunction dataframe/inst/@dataframe/private/df_strjust.m0000600000175000017500000000231211713521330023004 0ustar carandraugcarandraugfunction [a, b] = df_strjust(a, b) %# small auxiliary function: make two char arrays the same width %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_strjust.m 9585 2012-02-05 15:32:46Z cdemills $ %# indi = size(a, 2) - size(b, 2); if indi < 0 a = horzcat(repmat(' ', size(a, 1), -indi), a); elseif indi > 0, b = horzcat(repmat(' ', size(b, 1), indi), b); endif endfunction dataframe/inst/@dataframe/private/df_allmeta.m0000600000175000017500000000366711713521330022723 0ustar carandraugcarandraugfunction resu = df_allmeta(df, dim = []) %# function resu = df_allmeta(df) %# Returns a new dataframe, initalised with the all the %# meta-information but with empty data %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_allmeta.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = dataframe([]); if (isempty(dim)), dim = df._cnt(1:2); else dim = dim(1:2); %# ignore third dim, if any endif resu._cnt(1:2) = min(dim, df._cnt(1:2)); if (!isempty(df._name{1})), resu._name{1} = df._name{1}(1:resu._cnt(1)); resu._over{1} = df._over{1}(1:resu._cnt(1)); endif if (!isempty(df._name{2})), resu._name{2} = df._name{2}(1:resu._cnt(2)); resu._over{2} = df._over{2}(1:resu._cnt(2)); endif if (!isempty(df._ridx)), if (size(df._ridx, 2) >= resu._cnt(2)), resu._ridx = df._ridx(1:resu._cnt(1), :, :); else resu._ridx = df._ridx(1:resu._cnt(1), 1, :); endif endif %# init it with the right orientation resu._data = cell(size(df._data)); resu._rep = cell(size(df._rep)); resu._type = df._type(1:resu._cnt(2)); resu._src = df._src; resu._cmt = df._cmt; endfunction dataframe/inst/@dataframe/private/df_func.m0000600000175000017500000002143511713521330022230 0ustar carandraugcarandraugfunction resu = df_func(func, A, B, itercol=true, whole=logical([0 0])); %# function resu = df_func(func, A, B, whole) %# Implements an iterator to apply some func when at %# least one argument is a dataframe. The output is a dataframe with %# the same metadata, types may be altered, like f.i. double=>logical. %# When itercol is 'true', the default, LHS is iterated by columns, %# otherwise by rows. 'Whole' is a two-elements logical vector with %# the meaning that LHS and or RHS must be iterated at once or not %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_func.m 9585 2012-02-05 15:32:46Z cdemills $ %# [A, B, resu] = df_basecomp(A, B, itercol, func); itercol = itercol(1); %# drop second value if (isa(B, 'dataframe')) if (!isa(A, 'dataframe')), if (isscalar(A)), for indi = resu._cnt(2):-1:1, switch resu._type{indi} case "char" resu._data{indi} = feval(func, A, char(B._data{indi})); otherwise resu._data{indi} = feval(func, A, B._data{indi}); endswitch endfor resu._rep = B._rep; else if (whole(1) && !whole(2)), for indi = resu._cnt(2):-1:1, switch resu._type{indi} case "char" resu._data{indi} = feval(func, A, \ char(B._data{indi}(:, B._rep{indi}))); otherwise resu._data{indi} = feval(func, A, \ B._data{indi}(:, B._rep{indi})); endswitch resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor elseif (itercol && !whole(2)), for indi = resu._cnt(2):-1:1, switch resu._type{indi} case "char" resu._data{indi} = feval(func, squeeze(A(:, indi, :)), \ char(B._data{indi}(:, B._rep{indi}))); otherwise resu._data{indi} = feval(func, squeeze(A(:, indi, :)), \ B._data{indi}(:, B._rep{indi})); endswitch resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor elseif (!whole(2)), warning("no 3D yet"); for indi = resu._cnt(2):-1:1, switch resu._type{indi} case "char" resu._data{indi} = feval(func, A(indi, :), char(B._data{indi})); otherwise resu._data{indi} = feval(func, A(indi, :), B._data{indi}); endswitch endfor else dummy = feval(func, A, df_whole(B)); for indi = resu._cnt(2):-1:1, %# store column-wise resu._data{indi} = squeeze(dummy(:, indi, :)); resu._rep{indi} = 1:size(resu._data{indi}, 2); resu._type{indi} = class(dummy); endfor endif endif else if (itercol), for indi = resu._cnt(2):-1:1, switch resu._type{indi} case "char" resu._data{indi} = feval\ (func, char(A._data{indi}(:, A._rep{indi})), \ char(B._data{indi}(B._rep{indi}))); otherwise resu._data{indi} = feval\ (func, A._data{indi}(:, A._rep{indi}), \ B._data{indi}(:, B._rep{indi})); endswitch resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor else %# itercol is false dummy = df_whole(A); if whole(1), for indi = resu._cnt(2):-1:1, switch resu._type{indi} case "char" resu._data{indi} = feval(func, dummy, \ char(B._data{indi}(:, B._rep{indi}))); otherwise resu._data{indi} = feval(func, dummy, \ B._data{indi}(:, B._rep{indi})); endswitch resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor elseif (!whole(2)), for indi = resu._cnt(2):-1:1, switch resu._type{indi} case "char" resu._data{indi} = squeeze\ (feval(func, dummy(indi, :, :),\ char(B._data{indi}(:, B._rep{indi})))); otherwise resu._data{indi} = squeeze\ (feval(func, dummy(indi, :, :), \ B._data{indi}(:, B._rep{indi}))); endswitch resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor else dummy = feval(func, dummy, df_whole(B)); for indi = resu._cnt(2):-1:1, %# store column-wise resu._data{indi} = squeeze(dummy(:, indi, :)); resu._rep{indi} = 1:size(resu._data{indi}, 2); resu._type{indi} = class(dummy); endfor endif endif endif else %# B is not a dataframe if (isscalar(B)), for indi = resu._cnt(2):-1:1, switch resu._type{indi} case "char" resu._data{indi} = feval(func, char(A._data{indi}), B); otherwise resu._data{indi} = feval(func, A._data{indi}, B); endswitch endfor resu._rep = A._rep; else if (itercol), if (whole(2)), for indi = resu._cnt(2):-1:1, switch resu._type{indi} case "char" unfolded = char(A._data{indi}(:, A._rep{indi})); otherwise unfolded = A._data{indi}(:, A._rep{indi}); endswitch resu._data{indi} = squeeze(feval(func, unfolded, B)); resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor else for indi = resu._cnt(2):-1:1, switch resu._type{indi} case "char" unfolded = char(A._data{indi}(:, A._rep{indi})); otherwise unfolded = A._data{indi}(:, A._rep{indi}); endswitch resu._data{indi} = feval(func, unfolded, \ squeeze(B(:, indi, :))); resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor endif else dummy = df_whole(A); if whole(1), for indi = columns(B):-1:1, resu._data{indi} = squeeze(feval(func, dummy, B(:, indi, :))); resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor else if !whole(2), for indi = resu._cnt(1):-1:1, resu._data{indi} = squeeze(feval(func, dummy(indi, :, :), \ B(:, indi, :))); resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor else for indi = resu._cnt(1):-1:1, %# in place computation dummy(indi, :, :) = feval(func, dummy(indi, :, :), B); endfor for indi = resu._cnt(2):-1:1, %# store column-wise resu._data{indi} = squeeze(dummy(:, indi, :)); resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor endif endif %# verify that sizes match, this is required for "\" resu._cnt(2) = length(resu._data); resu._cnt(1) = max(cellfun('size', resu._data, 1)); if (length(resu._ridx) < resu._cnt(1)), if (1 == length(resu._ridx)), resu._ridx(end+1:resu._cnt(1), 1) = resu._ridx(1); else resu._ridx(end+1:resu._cnt(1), 1) = NA; endif endif if (length(resu._name{2}) < resu._cnt(2)), if (1 == length(resu._name{2})), resu._name{2}(end+1:resu._cnt(2), 1) = resu._name{2}; resu._over{2}(end+1:resu._cnt(2), 1) = resu._over{2}; else resu._name{2}(end+1:resu._cnt(2), 1) = '_'; resu._over{2}(end+1:resu._cnt(2), 1) = true; endif endif endif endif endif resu._type = cellfun(@class, resu._data, "UniformOutput", false); resu = df_thirddim(resu); endfunction dataframe/inst/@dataframe/private/df_whole.m0000600000175000017500000000316211713521330022410 0ustar carandraugcarandraugfunction resu = df_whole(df); %# function resu = df_whole(df) %# Generate a full matrix from a column-compressed version of a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_whole.m 9585 2012-02-05 15:32:46Z cdemills $ %# inds = max(cellfun(@length, df._rep)); resu = df._data{1}(:, df._rep{1}); if (inds > 1), resu = reshape(resu, df._cnt(1), 1, []); if (1 == size(resu, 3)), resu = repmat(resu, [1 1 inds]); endif endif if df._cnt(2) > 1, resu = repmat(resu, [1 df._cnt(2)]); for indi = 2:df._cnt(2), dummy = df._data{indi}(:, df._rep{indi}); if (inds > 1), dummy = reshape(dummy, df._cnt(1), 1, []); if (1 == size(dummy, 3)), dummy = repmat(dummy, [1 1 inds]); endif endif resu(:, indi, :) = dummy; endfor endif endfunction dataframe/inst/@dataframe/private/df_mapper2.m0000600000175000017500000000465311713521330022646 0ustar carandraugcarandraugfunction resu = df_mapper2(func, df, varargin) %# resu = df_mapper2(func, df) %# small interface to iterate some vector func over the elements of a %# dataframe. This one is specifically adapted to all functions where %# the first argument, if numeric, is 'dim'. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_mapper2.m 9585 2012-02-05 15:32:46Z cdemills $ %# dim = 1; resu = []; vout = varargin; %# take care of constructs as min(x, [], dim) if (!isempty(varargin)), indk = 1; while indk <= length(varargin), if (isnumeric(varargin{indk})), if (isempty(varargin{indk})), indk = indk + 1; continue; endif dim = varargin{indk}; %# the "third" dim is the second on stored data if 3 == dim, vout(indk) = 2; endif endif break; endwhile endif switch(dim) case {1}, resu = df_colmeta(df); for indi = 1:df._cnt(2), resu._data{indi} = feval(func, df._data{indi}(:, df._rep{indi}), \ vout{:}); resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor resu._cnt(1) = max(cellfun('size', resu._data, 1)); if (resu._cnt(1) == df._cnt(1)), %# the func was not contracting resu._ridx = df._ridx; resu._name{1} = resu._name{1}; resu._over{1} = resu._over{1}; endif case {2}, error('Operation not implemented'); case {3}, resu = df_allmeta(df); for indi = 1:df._cnt(2), resu._data{indi} = feval(func, df._data{indi}(:, df._rep{indi}), \ vout{:}); resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor otherwise error("Invalid dimension %d", dim); endswitch resu = df_thirddim(resu); endfunction dataframe/inst/@dataframe/private/df_matassign.m0000600000175000017500000004255511715233166023302 0ustar carandraugcarandraugfunction df = df_matassign(df, S, indc, ncol, RHS) %# auxiliary function: assign the dataframe as if it was a matrix %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_matassign.m 9615 2012-02-10 15:22:57Z cdemills $ %# if (isnull (RHS)) if (1 == ncol) if (sum (~strcmp (S.subs, ':')) > 2) error("A null assignment can only have one non-colon index."); endif elseif (sum (~strcmp (S.subs, ':')) > 1) error("A null assignment can only have one non-colon index."); endif if (strcmp (S.subs(1), ':')) %# removing column/matrix RHS = S; RHS.subs(2) = []; for indi = (indc) unfolded = df._data{indi}(:, df._rep{indi}); unfolded = feval (@subsasgn, unfolded, RHS, []); df._data{indi} = unfolded; if (~isempty (unfolded)) df._rep(indi) = 1:size (unfolded, 2); endif endfor %# remove empty elements indi = cellfun ('isempty', df._data); if (any (indi)) %# nothing left, remove this column df._cnt(2) = df._cnt(2) - sum (indi); indi = ~indi; %# vector of kept data df._name{2} = df._name{2}(indi); df._over{2} = df._over{2}(indi); df._type = df._type(indi); df._data = df._data(indi); df._rep = df._rep(indi); endif if (size (df._ridx, 3) > 1) df._ridx(:, indc, :) = []; endif elseif (strcmp (S.subs(2), ':')) %# removing rows indr = S.subs{1}; if (~isempty (df._name{1})) df._name{1}(indr, :) = []; df._over{1}(indr) = []; endif df._ridx(indr, :, :) = []; %# to remove a line, iterate on each column df._data = cellfun (@(x) feval(@subsasgn, x, S, []), \ df._data, "UniformOutPut", false); if (isa (indr, 'char')) df._cnt(1) = 0; else df._cnt(1) = df._cnt(1) - length (indr); endif endif df = df_thirddim (df); return; endif indc_was_set = ~isempty (indc); if (~indc_was_set) %# initial dataframe was empty ncol = size (RHS, 2); indc = 1:ncol; endif indr = S.subs{1, 1}; indr_was_set = ~isempty (indr); %# initial dataframe was empty ? if (~indr_was_set || strcmp (indr, ':')) if (iscell (RHS)) nrow = max (sum (cellfun ('size', RHS, 1))); else if (isvector (RHS)) if (0 == df._cnt(1)) nrow = size (RHS, 1); else nrow = df._cnt(1); %# limit to df numbner of rows endif else %# deduce limit from RHS nrow = size (RHS, 1); endif endif indr = 1:nrow; elseif (~isempty (indr)) if (~isnumeric (indr)) %# translate row names to row index [indr, nrow] = df_name2idx (df._name{1}, indr, df._cnt(1), 'row'); S.subs{1, 1} = indr; else nrow = length (indr); endif endif if (length (S.subs) > 2) inds = S.subs{1, 3}; else inds = []; endif rname = cell(0, 0); rname_width = max (1, size (df._name{2}, 2)); ridx = []; cname = rname; ctype = rname; if (iscell (RHS)) if ((length (indc) == df._cnt(2) && size (RHS, 2) >= df._cnt(2)) \ || 0 == df._cnt(2) || isempty (S.subs{1}) || isempty (S.subs{2})) %# providing too much information -- remove extra content if (size (RHS, 1) > 1) %# at this stage, verify that the first line doesn't contain %# chars only; use them for column names dummy = cellfun ('class', \ RHS(1, ~cellfun ('isempty', RHS(1, :))), \ 'UniformOutput', false); dummy = strcmp (dummy, 'char'); if (all (dummy)) if (length (df._over{2}) >= max (indc) \ && ~all (df._over{2}(indc)) && ~isempty (S.subs{2})) warning("Trying to overwrite colum names"); endif cname = RHS(1, :).'; RHS = RHS(2:end, :); if (~indr_was_set) nrow = nrow - 1; indr = 1:nrow; else %# we know indr, there is no reason that RHS(:, 1) contains %# row names. if (isempty (S.subs{2})) %# extract columns position from columns names [indc, ncol, S.subs{2}, dummy] = ... df_name2idx (df._name{2}, cname, df._cnt(2), 'column'); if (length (dummy) ~= sum (dummy)) warning ("Not all RHS column names used"); cname = cname(dummy); RHS = RHS(:, dummy); endif endif endif endif %# at this stage, verify that the first line doesn't contain %# chars only; use them for column types dummy = cellfun ('class', \ RHS(1, ~cellfun ('isempty', RHS(1, :))), \ 'UniformOutput', false); dummy = strcmp (dummy, 'char'); if (all (dummy)) if (length (df._over{2}) >= max (indc) \ && ~all (df._over{2}(indc))) warning ("Trying to overwrite colum names"); endif ctype = RHS(1, :); RHS = RHS(2:end, :); if (~indr_was_set) nrow = nrow - 1; indr = 1:nrow; endif endif endif %# more elements than df width -- try to use the first two as %# row index and/or row name if (size (RHS, 1) > 1) dummy = all (cellfun ('isnumeric', \ RHS(~cellfun ('isempty', RHS(:, 1)), 1))); else dummy = isnumeric(RHS{1, 1}); endif dummy = dummy && (~isempty (cname) && size (cname{1}, 2) < 1); if (dummy) ridx = cell2mat (RHS(:, 1)); %# can it be converted to a list of unique numbers ? if (length (unique (ridx)) == length (ridx)) ridx = RHS(:, 1); RHS = RHS(:, 2:end); if (length (df._name{2}) == df._cnt(2) + ncol) %# columns name were pre-filled with too much values df._name{2}(end) = []; df._over{2}(end) = []; if (size (RHS, 2) < ncol) ncol = size (RHS, 2); indc = 1:ncol; endif elseif (~indc_was_set) ncol = ncol - 1; indc = 1:ncol; endif if (~isempty (cname)) cname = cname(2:end); endif if (~isempty (ctype)) ctype = ctype(2:end); endif else ridx = []; endif endif if (size (RHS, 2) > df._cnt(2)) %# verify the the first row doesn't contain chars only, use them %# for row names dummy = cellfun ('class', \ RHS(~cellfun ('isempty', RHS(:, 1)), 1), \ 'UniformOutput', false); dummy = strcmp (dummy, 'char') \ && (~isempty (cname) && size (cname{1}, 2) < 1); if (all (dummy)) if (length (df._over{1}) >= max (indr) \ && ~all (df._over{1}(indr))) warning("Trying to overwrite row names"); else rname = RHS(:, 1); endif rname_width = max ([1; cellfun('size', rname, 2)]); RHS = RHS(:, 2:end); if (length (df._name{2}) == df._cnt(2) + ncol) %# columns name were pre-filled with too much values df._name{2}(end) = []; df._over{2}(end) = []; if (size (RHS, 2) < ncol) ncol = size (RHS, 2); indc = 1:ncol; endif elseif (~indc_was_set) ncol = ncol - 1; indc = 1:ncol; endif if (~isempty (cname)) cname = cname(2:end); endif if (~isempty (ctype)) ctype = ctype(2:end); endif endif endif endif endif %# perform row resizing if columns are already filled if (~isempty (indr) && isnumeric(indr)) if (max (indr) > df._cnt(1) && size (df._data, 2) == df._cnt(2)) df = df_pad (df, 1, max (indr)-df._cnt(1), rname_width); endif endif if (iscell(RHS)) %# we must pad on a column-by-column basis %# verify that each cell contains a non-empty vector, and that sizes %# are compatible %# dummy = cellfun ('size', RHS(:), 2); %# if any (dummy < 1), %# error("cells content may not be empty"); %# endif %# dummy = cellfun ('size', RHS, 1); %# if any (dummy < 1), %# error("cells content may not be empty"); %# endif %# if any (diff(dummy) > 0), %# error("cells content with unequal length"); %# endif %# if 1 < size (RHS, 1) && any (dummy > 1), %# error("cells may only contain scalar"); %# endif if (size(RHS, 2) > indc) keyboard endif %# the real assignement if (1 == size (RHS, 1)) %# each cell contains one vector fillfunc = @(x) RHS{x}; idxOK = logical(indr); else %# use cell2mat to pad on a column-by-column basis fillfunc = @(x) cell2mat (RHS(:, x)); endif indj = 1; for indi = (1:ncol) if (indc(indi) > df._cnt(2)) %# perform dynamic resizing one-by-one, to get type right if (isempty (ctype) || length (ctype) < indc(indi)) df = df_pad(df, 2, indc(indi)-df._cnt(2), class(RHS{1, indj})); else df = df_pad(df, 2, indc(indi)-df._cnt(2), ctype{indj}); endif endif if (nrow == df._cnt(1)) %# whole assignement try if (size (RHS, 1) <= 1) switch df._type{indc(indi)} case {'char' } %# use a cell array to hold strings dummy = RHS(:, indj); case {'double' } dummy = fillfunc (indj); otherwise dummy = cast(fillfunc (indj), df._type{indc(indi)}); endswitch else %# keeps indexes in sync as cell elements may be empty idxOK = ~cellfun ('isempty', RHS(:, indj)); %# intialise dummy so that it can receive "anything" dummy = []; switch (df._type{indc(indi)}) case {'char' } %# use a cell array to hold strings dummy = RHS(:, indj); case {'double' } dummy(idxOK, :) = fillfunc (indj); dummy(~idxOK, :) = NA; otherwise dummy(idxOK, :) = fillfunc (indj); dummy(~idxOK, :) = NA; dummy = cast(dummy, df._type{indc(indi)}); endswitch endif catch dummy = \ sprintf ("Assignement failed for colum %d, of type %s and length %d,\nwith new content\n%s", \ indj, df._type{indc(indi)}, length (indr), disp (RHS(:, indj))); error (dummy); end_try_catch if (size (dummy, 1) < df._cnt(1)) dummy(end+1:df._cnt(1), :) = NA; endif else %# partial assignement -- extract actual data and update dummy = df._data{indc(indi)}; try switch (df._type{indc(indi)}) case {'char' } %# use a cell array to hold strings dummy(indr, 1) = RHS(:, indj); case {'double' } dummy(indr, :) = fillfunc (indj); otherwise dummy(indr, :) = cast(fillfunc (indj), df._type{indc(indi)}); endswitch catch dummy = \ sprintf ("Assignement failed for colum %d, of type %s and length %d,\nwith new content\n%s", \ indj, df._type{indc(indi)}, length (indr), disp(RHS(:, indj))); error (dummy); end_try_catch endif df._data{indc(indi)} = dummy; df._rep{indc(indi)} = 1:size (dummy, 2); indj = indj + 1; endfor else %# RHS is either a numeric, either a df if (any (indc > min (size (df._data, 2), df._cnt(2)))) df = df_pad(df, 2, max (indc-min (size (df._data, 2), df._cnt(2))),\ class(RHS)); endif if (~isempty (inds) && isnumeric(inds) && any (inds > 1)) for indi = (1:length (indc)) if (max (inds) > length (df._rep{indc(indi)})) df = df_pad(df, 3, max (inds)-length (df._rep{indc(indi)}), \ indc(indi)); endif endfor endif if (isa (RHS, 'dataframe')) %# block-copy index S.subs(2) = 1; if (any (~isna(RHS._ridx))) df._ridx = feval(@subsasgn, df._ridx, S, RHS._ridx); endif %# skip second dim and copy data S.subs(2) = []; Sorig = S; for indi = (1:length (indc)) [df, S] = df_cow(df, S, indc(indi)); if (strcmp (df._type(indc(indi)), RHS._type(indi))) try df._data{indc(indi)} = feval(@subsasgn, df._data{indc(indi)}, S, \ RHS._data{indi}(:, RHS._rep{indi})); catch disp(lasterr()); disp('line 516 ???'); keyboard end_try_catch else df._data{indc(indi)} = feval(@subsasgn, df._data{indc(indi)}, S, \ cast(RHS._data{indi}(:, RHS._rep{indi}),\ df._type(indc(indi)))); endif S = Sorig; endfor if (~isempty (RHS._name{1})) df._name{1}(indr) = genvarname(RHS._name{1}(indr)); df._over{1}(indr) = RHS._over{1}(indr); endif if (~isempty (RHS._src)) if (~any (strcmp (cellstr(df._src), cellstr(RHS._src)))) df._src = vertcat(df._src, RHS._src); endif endif if (~isempty (RHS._cmt)) if (~any (strcmp (cellstr(df._cmt), cellstr(RHS._cmt)))) df._cmt = vertcat(df._cmt, RHS._cmt); endif endif else %# RHS is homogenous, pad at once if (isvector (RHS)) %# scalar - vector if (isempty (S.subs)) fillfunc = @(x, y) RHS; else %# ignore 'column' dimension -- force colum vectors -- use a %# third dim just in case if (isempty (S.subs{1})) S.subs{1} = ':'; endif S.subs(2) = []; if (length (S.subs) < 2) S.subs{2} = 1; endif if (length (indc) > 1 && length (RHS) > 1) %# set a row from a vector fillfunc = @(x, S, y) feval (@subsasgn, x, S, RHS(y)); else fillfunc = @(x, S, y) feval (@subsasgn, x, S, RHS); endif endif Sorig = S; for indi = (1:length (indc)) try [df, S] = df_cow(df, S, indc(indi)); df._data{indc(indi)} = fillfunc (df._data{indc(indi)}, S, indi); S = Sorig; catch disp(lasterr) disp('line 470 '); keyboard end_try_catch # catch # if ndims(df._data{indc(indi)}) > 2, # %# upstream forgot to give the third dim # dummy = S; dummy.subs(3) = 1; # df._data{indc(indi)} = fillfunc(df._data{indc(indi)}, \ # dummy, indi); # else # rethrow(lasterr()); # endif # end_try_catch endfor else %# 2D - 3D matrix S.subs(2) = []; %# ignore 'column' dimension if (isempty (S.subs{1})) S.subs{1} = indr; endif %# rotate slices in dim 1-3 to slices in dim 1-2 fillfunc = @(x, S, y) feval(@subsasgn, x, S, squeeze(RHS(:, y, :))); Sorig = S; for indi = (1:length (indc)) [df, S] = df_cow(df, S, indc(indi)); df._data{indc(indi)} = fillfunc (df._data{indc(indi)}, S, indi); S = Sorig; endfor endif if (indi < size (RHS, 2) && ~isa (RHS, 'char')) warning (' not all columns of RHS used'); endif endif endif %# delayed row padding -- column padding occured before if (~isempty (indr) && isnumeric (indr)) if (max (indr) > df._cnt(1) && size (df._data, 2) < df._cnt(2)) df = df_pad(df, 1, max (indr)-df._cnt(1), rname_width); endif endif %# adjust ridx and rnames, if required if (~isempty (ridx)) dummy = df._ridx; if (1 == size (RHS, 1)) dummy(indr) = ridx{1}; else dummy(indr) = vertcat(ridx{indr}); endif if (length (unique (dummy)) ~= length (dummy)) %# || \ %# any (diff(dummy) <= 0), error("row indexes are not unique or not ordered"); endif df._ridx = dummy; endif if (~isempty (rname) && (length (df._over{1}) < max (indr) || \ all (df._over{1}(indr)))) df._name{1}(indr, 1) = genvarname(rname); df._over{1}(1, indr) = false; endif if (~isempty (cname) && (length (df._over{2}) < max (indc) || \ all (df._over{2}(indc)))) try df._name{2}(indc, 1) = genvarname (cname); catch disp('line 472 '); keyboard end_try_catch df._over{2}(1, indc) = false; endif df = df_thirddim (df); endfunction dataframe/inst/@dataframe/private/df_check_char_array.m0000600000175000017500000000312611713521330024542 0ustar carandraugcarandraugfunction resu = df_check_char_array(x, nelem, required) %# auxiliary function: pad a char array to some width %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_check_char_array.m 9585 2012-02-05 15:32:46Z cdemills $ %# if 2 == nargin, required = [nelem 1]; endif if nelem < required(1), error("Too many elements to assign"); endif %# a zero-length element is still considered as a space by char if isempty(x), x = ' '; endif if size(x, 1) < max(required(1), nelem) %# pad vertically dummy = repmat(' ', nelem-size(x, 1), 1); resu = char(x, dummy); else resu = x; endif if size(resu, 2) < required(2), %# pad horizontally dummy = repmat(' ', nelem, required(2)-size(resu, 2)); resu = horzcat(resu, dummy); endif endfunction dataframe/inst/@dataframe/private/df_basecomp.m0000600000175000017500000001274011713521330023065 0ustar carandraugcarandraugfunction [A, B, C] = df_basecomp(A, B, itercol=true, func=@plus); %# function [A, B, C] = df_basecomp(A, B, itercol) %# Basic size and metadata compatibility verifications for %# two-arguments operations on dataframe. Returns a scalar, a matrix, %# or a dataframe. Cell arrays are converted to df. Third output %# contains a merge of the metadata. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_basecomp.m 9585 2012-02-05 15:32:46Z cdemills $ %# if 1 == length(itercol), strict = false; else strict = itercol(2); itercol = itercol(1); endif if (iscell(A)), A = dataframe(A); endif if (iscell(B)), B = dataframe(B); endif switch (func2str(func)), case 'bsxfun' %# bsxfun compatibility rule: if there is at least one singleton %# dim, the smallest is repeated to reach the size of the %# greatest. Otherwise, all dims must be equal. if (any(size(A)(1:2) != size(B)(1:2))) if (!any (1 == [size(A) size(B)])) error('bsxfun: both arguments must have the same dim, of one of them must have at least one singleton dim'); else Csize = max([size(A)(1:2); size(B)(1:2)]); endif else Csize = size(A)(1:2); endif case 'mldivide' if (isscalar(A)), Csize = size(B)(1:2); else if (size(A, 1) != size(B, 1)), error("Non compatible row sizes (op1 is %dx%d, op2 is %dx%d)",\ size(A), size(B)(1:2)); endif Csize = [size(A, 2) size(B, 2)]; endif otherwise %# if strict is set, B may not be non-scalar vs scalar if ((!(isscalar(A) || isscalar(B)))||(strict && isscalar(A))), if (itercol), %# requires full compatibility Csize = size(A)(1:2); if (any(Csize - size(B)(1:2))), %# disp([size(A) size(B)]) error("Non compatible row and columns sizes (op1 is %dx%d, op2 is %dx%d)",\ Csize, size(B)); endif else %# compatibility with matrix product if (size(A, 2) - size(B, 1)), error("Non compatible columns vs. rows size (op1 is %dx%d, op2 is %dx%d)",\ size(A)(1:2), size(B)(1:2)); endif Csize = [size(A, 1) size(B, 2)]; endif endif endswitch if !(isscalar(A) || isscalar(B)) C = []; if (isa(A, 'dataframe')) if (nargout > 2 && all(Csize == size(A)(1:2))), C = df_allmeta(A, Csize); endif if (isa(B, 'dataframe')) if (nargout > 2 && isempty(C) && all(Csize == size(B)(1:2))), C = df_allmeta(B, Csize); endif if (strict), %# compare indexes if both exist if (!isempty(A._ridx)) if (!isempty(B._ridx) && itercol), if (any(A._ridx-B._ridx)), error("Non compatible indexes"); endif endif else if (nargout > 2 && itercol), C._ridx = B._ridx; endif endif if (itercol), idxB = 1; %# row-row comparison else idxB = 2; %# row-col comparsion endif if (!isempty(A._name{1})) if (!isempty(B._name{idxB})) dummy = !(strcmp(cellstr(A._name{1}), cellstr(B._name{idxB}))\ | (A._over{1}(:)) | (B._over{idxB}(:))); if (any(dummy)), if (itercol), error("Incompatible row names"); else error("Incompatible row vs. column names"); endif endif dummy = A._over{1} > B._over{idxB}; if (any(dummy)), C._name{1}(dummy) = B._name{idxB}(dummy); C._over{1}(dummy) = B._over{idxB}(dummy); endif endif else if (nargout > 2), C._name{1} = B._name{idxB}; C._over{1} = B._over{idxB}; endif endif idxB = 3-idxB; if (!isempty(A._name{2})) if (!isempty(B._name{idxB})) dummy = !(strcmp(cellstr(A._name{2}), cellstr(B._name{2}))\ | (A._over{2}(:)) | (B._over{2}(:))); if (any(dummy)), if (itercol), error("Incompatible column vs row names"); else error("Incompatible column names"); endif endif dummy = A._over{2} > B._over{idxB}; if (any(dummy)), C._name{2}(dummy) = B._name{idxB}(dummy); C._over{2}(dummy) = B._over{idxB}(dummy); endif endif else if (nargout > 2 && !isempty(B._name{idxB})), C._name{2} = B._name{idxB}; C._over{2} = B._over{idxB}; endif endif endif if (isempty(A._src) && nargout > 2 && !isempty(B._src)), C._src = B._src; endif if (isempty(A._cmt) && nargout > 2 && !isempty(B._cmt)), C._cmt = B._cmt; endif else %# B is not a df if (nargout > 2 && isempty(C)), C = df_allmeta(A); endif endif else %# A is not a df if (nargout > 2), if (all(Csize==size(B)(1:2))), C = df_allmeta(B, Csize); else C = df_allmeta(B); endif endif endif else %# both arg are scalar if (nargout > 2), if (isa(A, 'dataframe')) C = df_allmeta(A); else C = df_allmeta(B); endif endif endif endfunction dataframe/inst/@dataframe/private/df_cow.m0000600000175000017500000000455611713521330022072 0ustar carandraugcarandraugfunction [df, S] = df_cow(df, S, col) %# function [resu, S] = df_cow(df, S, col) %# Implements Copy-On-Write on dataframe. If one or more columns %# specified in inds is aliased to another one, duplicate it and %# adjust the repetition index to remove the aliasing %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_cow.m 9585 2012-02-05 15:32:46Z cdemills $ %# if length(col) > 1, error("df_cow must work on a column-by-column basis"); endif if (1 == length(S.subs)), inds = 1; else inds = S.subs{2}; endif if (!isnumeric(inds)), if !strcmp(inds, ':'), error("Unknown sheet selector %s", inds); endif inds = 1:length(df._rep(col)); endif for indi = inds(:).', dummy = df._rep{col}; dummy(indi) = 0; [t1, t2] = ismember(df._rep{col}(indi)(:), dummy); for indj = t2(find(t2)), %# Copy-On-Write %# determines the index for the next column t1 = 1+max(df._rep{col}); %# duplicate the touched column df._data{col} = horzcat(df._data{col}, \ df._data{col}(:, df._rep{col}(indj))); if (indi > 1), %# a new column has been created df._rep{col}(indi) = t1; else %# update repetition index aliasing this one df._rep{col}(find(dummy == indi)) = t1; endif endfor endfor %# reorder S if (length(S.subs) > 1), if (S.subs{2} != 1 || length(S.subs{2}) > 1), %# adapt sheet index according to df_rep S.subs{2} = df._rep{col}(S.subs{2}); endif endif df = df_thirddim(df); endfunction dataframe/inst/@dataframe/private/df_name2idx.m0000700000175000017500000001067411713521330023010 0ustar carandraugcarandraugfunction [idx, nelem, subs, mask] = df_name2idx(names, subs, count, dimname, missingOK=false); %# This is a helper routine to translate rownames or columnames into %# real index. Input: names, a char array, and subs, a cell array as %# produced by subsref and similar. This routine can also detect %# ranges, two values separated by ':'. On output, subs is %# 'sanitised' from names, and is either a vector, either a single ':' %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_name2idx.m 9585 2012-02-05 15:32:46Z cdemills $ %# if (isempty (subs)) %# not caring about rownames ? Avoid generating an error. idx = []; nelem = 0; return endif if (isa (subs, 'char')), orig_name = subs; if (1 == size (subs, 1)) if (strcmp(subs, ':')) %# range operator idx = 1:count; nelem = count; return endif endif subs = cellstr (subs); else if (~isvector(subs)) %# yes/no ? %# error("Trying to access column as a matrix"); endif switch (class (subs)) case {"cell"} orig_name = char (subs); case {"dataframe"} orig_name = "elements indexed by a dataframe"; otherwise orig_name = num2str (subs); endswitch endif if (isa (subs, 'cell')) subs = subs(:); idx = []; mask = logical (zeros (size (subs, 1), 1)); %# translate list of variables to list of indices for indi = (1:size(subs, 1)) %# regexp doesn't like empty patterns if (isempty (subs{indi})) continue; endif %# convert from standard pattern to regexp pattern subs{indi} = regexprep (subs{indi}, '([^\.\\])(\*|\?)', "$1.$2"); %# quote repetition ops at begining of line, otherwise the regexp %# will stall forever/fail subs{indi} = regexprep (subs{indi}, \ '^([\*\+\?\{\}\|])', "\\$1"); %# detect | followed by EOL subs{indi} = regexprep (subs{indi}, '([^\\])\|$', "$1\\|"); if (0 == index (subs{indi}, ':')) for indj = (1:min (length (names), count)) %# sanity check if (~isempty (regexp (names{indj}, subs{indi}))) idx = [idx indj]; mask(indi) = true; endif endfor else dummy = strsplit (subs{indi}, ':'); ind_start = 1; if (!isempty (dummy{1})) ind_start = sscanf (dummy{1}, "%d"); if (isempty (ind_start)) ind_start = 1; for indj = (1:min(length (names), count)) %# sanity check if (~isempty (regexp (names{indj}, subs{indi}))), ind_start = indj; break; %# stop at the first match endif endfor endif endif if (isempty (dummy{2}) || strcmp (dummy{2}, 'end')) ind_stop = count; else ind_stop = sscanf(dummy{2}, "%d"); if (isempty (ind_stop)) ind_stop = 1; for indj = (min (length (names), count):-1:1) %# sanity check if (~isempty (regexp (names{indj}, subs{indi}))) ind_stop = indj; break; %# stop at the last match endif endfor endif endif idx = [idx ind_start:ind_stop]; endif endfor if (isempty (idx) && ~missingOK) dummy = sprintf ("Unknown %s name while searching for %s", ... dimname, orig_name); error (dummy); endif elseif (isa (subs, 'logical')) idx = 1:length (subs(:)); idx = reshape (idx, size (subs)); idx(~subs) = []; mask = subs; elseif (isa (subs, 'dataframe')) idx = subsindex (subs, 1); else idx = subs; endif subs = idx; nelem = length (idx); endfunction dataframe/inst/@dataframe/private/df_colmeta.m0000600000175000017500000000263011713521330022715 0ustar carandraugcarandraugfunction resu = df_colmeta(df) %# function resu = df_colmeta(df) %# Returns a new dataframe, initalised with the meta-information %# about columns from the source, but with empty data %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_func.m 7943 2010-11-24 15:33:54Z cdemills $ %# resu = dataframe([]); resu._cnt(2) = df._cnt(2); resu._name{2} = df._name{2}; resu._over{2} = df._over{2}; resu._type = df._type; %# init it with the right orientation resu._data = cell(size(df._data)); resu._rep = cell(size(df._rep)); resu._src = df._src; resu._cmt = df._cmt; endfunction dataframe/inst/@dataframe/private/df_strset.m0000600000175000017500000000471211713521330022620 0ustar carandraugcarandraugfunction [x, over] = df_strset(x, over, S, RHS, pad = ' ') %# x = df_strset(x, over, S, RHS, pad = " ") %# replaces the strings in cellstr x at indr by strings at y. Adapt %# the width of x if required. Use x 'over' attribute to display a %# message in case strings are overwritten. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_strset.m 9585 2012-02-05 15:32:46Z cdemills $ %# %# adjust x size, if required if isnull(RHS), %# clearing if isempty(S), x = cell(0, 1); over = zeros(1, 0); return endif dummy = S; dummy(1).subs(2:end) = []; over = builtin('subsasgn', over, dummy, true); else if isempty(S), %# complete overwrite if ischar(RHS), RHS = cellstr(RHS); endif nrow = length(RHS); if any(~over(nrow)), warning('going to overwrite names'); endif x(1:nrow) = RHS; over(1:nrow) = false; if nrow < length(x), x(nrow+1:end) = {pad}; endif return else dummy = S(1); dummy.subs(2:end) = []; % keep first dim only if any(~(builtin('subsref', over, dummy))); warning('going to overwrite names'); endif over = builtin('subsasgn', over, dummy, false); endif endif %# common part if ischar(RHS) && length(S(1).subs) > 1, %# partial accesses to a char array dummy = char(x); dummy = builtin('subsasgn', dummy, S, RHS); if isempty(dummy), x = cell(0, 1); over = zeros(1, 0); return endif if size(dummy, 1) == length(x), x = cellstr(dummy); return endif %# partial clearing gone wrong ? retry RHS = { RHS }; endif x = builtin('subsasgn', x, S, RHS); endfunction dataframe/inst/@dataframe/private/df_mapper.m0000600000175000017500000000254211713521330022557 0ustar carandraugcarandraugfunction resu = df_mapper(func, df, varargin) %# resu = df_mapper(func, df) %# small interface to iterate some func over the elements of a dataframe. %% Copyright (C) 2009-2012 Pascal Dupuis %% %% This file is part of Octave. %% %% Octave is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public %% License as published by the Free Software Foundation; %% either version 2, or (at your option) any later version. %% %% Octave is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR %% PURPOSE. See the GNU General Public License for more %% details. %% %% You should have received a copy of the GNU General Public %% License along with Octave; see the file COPYING. If not, %% write to the Free Software Foundation, 51 Franklin Street - %% Fifth Floor, Boston, MA 02110-1301, USA. %# %# $Id: df_mapper.m 9585 2012-02-05 15:32:46Z cdemills $ %# resu = df_allmeta(df); resu._data = cellfun(@(x) feval(func, x, varargin{:}), df._data, \ "UniformOutput", false); resu._rep = df._rep; %# things didn't change resu._type = cellfun(@(x) class(x(1)), resu._data, "UniformOutput", false); resu = df_thirddim(resu); endfunction