Hi, I want to plot this matrix (I attach the data), it is suposed that each column is a different time series. If I do g<-read.table("dataADF.txt", header=F) and plot(g[,1],type="l") it plots the first column plot if I want in a unique graph each colums of dataA, all in one. How should I proceed?There is a direct pre-defined code? And If I wanted a plot by each column? -------------- next part -------------- 0.2511961 0.1048791 0.4444765 -0.5028332 -0.7088881 -1.123753 -1.700311 -2.526869 -1.423521 -1.465493 0.8252483 -0.6009678 -0.3566733 0.6114906 0.2656402 1.484138 2.461375 2.330355 2.316502 3.064682 0.4611107 -0.4868384 -0.7425801 -1.013957 0.5306794 1.062024 -0.1228905 -0.6351344 -2.337925 -1.641356 0.807893 -0.4622856 -0.3603809 -0.09382346 0.8860349 1.559422 2.468511 2.243987 1.234574 1.071196 -1.278776 -0.3438066 -0.6652522 0.06149792 -0.4490245 -1.460568 -1.962731 -2.070915 -2.865564 -1.374446 0.7438826 0.2349084 0.4044747 1.316407 0.2948463 0.7690822 -0.401027 0.2678625 -0.3589178 -1.286359 1.371723 1.139646 1.151194 1.30271 0.5325713 1.626423 4.161854 2.820054 1.407645 2.667657 -1.347965 -1.405399 -0.2255252 -0.4259673 -0.0107949 0.5113069 -0.6986957 -2.576082 -1.346436 -2.810367 0.8487415 0.9173517 -0.3868673 0.8938204 1.069388 0.2426122 0.3073049 -0.5796228 -0.613714 -1.295075 1.668746 2.007692 2.566654 0.347605 -1.316739 -1.690626 -1.34602 0.6525972 1.774055 2.422681 -0.2921904 -0.4572776 -0.0831 1.607965 2.697473 1.939636 3.634388 1.866071 0.7101437 -0.006232612 -0.5779149 -2.395087 -2.908561 -0.6105899 -0.8946739 -1.559014 -0.8202216 -0.378958 -1.631353 -0.8313268 -0.07078964 0.2010555 0.4663083 -1.437317 -2.610306 -3.460783 -3.83733 -3.895193 -3.174727 -2.667111 -2.285285 -1.127765 0.2660168 1.057333 -1.030778 -0.2747985 -1.291233 -0.8445686 -0.8744957 -1.280194 2.184299 -0.07775514 1.662162 0.5338424 -0.1041343 -0.05387169 1.154848 2.091877 2.732227 3.03888 -0.66068 0.8348062 1.089835 -1.08487 -0.1976554 -1.295102 -1.885944 -1.980454 -0.5368697 0.598854 -0.7463209 -0.6438774 -1.153221 0.07912086 1.496398 2.282352 1.574552 1.672754 0.9082801 2.105731 -0.2762997 -0.5857024 1.860109 0.9031891 -0.7805179 0.7164917 0.01293016 0.5195865 1.970231 2.468315 -0.3157311 -0.5701688 -0.1400543 0.2648969 0.9611559 0.6384742 0.08256517 1.125626 0.9181709 0.598844 1.014989 1.05152 -0.1168147 -0.0490423 0.9219626 1.861006 2.117454 1.766117 1.504658 0.1686698 -0.8992469 -0.135503 -0.8978528 0.6448676 0.9275989 0.80251 -0.08876881 -1.916651 -2.928887 -1.365382 2.043848 0.1651317 1.290125 2.229226 -0.0944308 0.2114113 0.3230081 -0.4566316 -1.847595 -1.074677 -1.018266 -0.06229867 -2.705829 -1.88546 0.8305156 -0.8986512 -0.3576629 -1.215976 -1.64835 -0.3357197 -2.428899 -2.461352 -1.052128 -0.797792 -0.02897585 0.2429339 -0.8937704 -1.597596 -1.264315 -0.1774461 0.9512131 1.489619 0.1525331 1.867675 0.6770682 1.455974 0.6509501 0.9685468 -0.3988205 1.129755 -1.496245 -0.5946097 0.05279458 -0.328852 -0.05792646 1.034132 0.6637048 1.129939 0.06336816 1.967753 -0.4406342 -0.4599942 1.287785 0.02805429 0.6106788 0.8343703 2.190842 0.9320417 1.486103 1.067876 0.4226051 0.1187309 -0.9908855 -0.4140583 0.03438669 0.2648257 -0.7758414 -1.938909 -1.428154 -1.042515 -0.3868041 -0.4329471 -1.63597 0.2448105 -0.2206876 -0.1556046 0.9957222 -0.1023034 0.814409 0.3461726 -1.301615 -2.610443 -2.237365 0.1296341 -0.1264283 -0.2330937 -0.6713151 -0.9043897 -2.636979 -3.697701 -0.3045346 0.1719403 -0.3931392 1.404483 -0.5422808 -0.4640257 -0.197192 -0.7009865 -2.75533 -3.337157 -2.525135 -2.584804 -2.949444 -1.205625 0.3389667 0.8986387 3.395926 1.818016 1.809293 1.631724 0.3919598 -0.900386 -0.3002419 0.04291678 0.7548589 -0.1586918 0.06735728 1.094125 2.123835 0.9874293 -0.7251489 -0.728092 -0.5626847 -0.7873589 0.0276604 0.9796381 2.571208 3.410983 2.600696 2.817994 -0.8901359 -1.825336 0.6855008 0.02204143 0.8999701 -0.6549752 -1.376338 -1.616452 -2.705169 -3.073808 0.8321419 -1.203327 -1.89387 -1.81901 0.1073112 -0.1083719 2.900365 3.273763 2.528639 5.058792 0.2519627 0.3563369 0.1663799 1.204814 1.250117 2.07772 2.177774 1.46357 3.229399 3.594515 -0.3436965 0.4533092 -0.4032535 2.512352 1.762501 1.542535 0.38002 0.0950009 -1.067111 0.8056887 -1.014454 0.3004921 0.2424574 0.6182488 0.5867852 1.325407 0.8636 -1.321926 -0.8127554 0.05006794 -0.7442625 -1.370238 -1.749684 -0.9233801 0.7940143 0.939864 0.2998892 1.850689 1.619476 1.321874 0.3796972 0.309221 1.002049 1.452987 -0.6044611 0.7374052 1.008338 0.2325502 -1.730755 -1.972615 -1.032366 -0.05345409 -0.7619548 -0.5983643 0.1822438 -0.3535287 0.3084443 -0.2422834 -0.9808616 -2.558784 0.1795273 0.8485714 1.982958 0.3688042 2.305633 2.236836 0.8664433 -1.09051 -1.191064 -1.952406 0.1006642 -0.5067429 -1.01859 -0.8602427 -0.07249596 1.771547 1.657481 0.1603193 1.337994 1.823145 -0.8189969 -1.040135 -0.3819819 1.363684 -0.54537 -1.017352 -1.432199 1.141051 0.02111763 -0.4318049 -1.26329 -0.4038025 -0.2005296 -0.8978298 -0.1379912 0.2989914 -0.7765947 -0.4860602 -1.270427 0.1009455 -1.226049 -0.7934141 -2.594027 0.374571 -0.04219506 0.4360105 -0.9972678 -0.1279983 -0.3580799 -0.2040566 2.028598 0.3194614 -0.4399323 -0.7004187 -2.444222 -2.092732 -2.053109 -2.404441 -0.5201437 -2.046386 0.6570714 -2.225083 0.3314136 -0.3032262 0.3235993 -0.7064742 -1.506104 -0.8935496 -0.9567884 0.3009565 -0.5890851 1.820413 1.954955 1.968836 2.004576 1.052675 1.586895 2.16656 2.362869 2.178793 -0.1168226 -0.6637947 -2.562467 -1.011358 -1.116703 -1.190843 -1.357887 1.77136 1.613135 1.440933 -1.783944 -2.173975 -1.71635 -1.401795 -1.831666 -0.7404467 -2.185332 -1.448042 -2.080547 -2.3138 0.7204281 -0.4396781 -0.5221366 1.210863 1.708158 3.906707 3.662374 3.223987 3.588267 4.547022 0.3416084 2.046663 0.9675454 1.067965 1.296799 1.911463 1.688053 2.87796 3.962909 2.343482 0.7501417 1.679632 0.6896593 -0.09328959 -0.8915438 1.029259 0.2200214 0.2459938 0.2224986 0.1653553 0.9460524 0.4371484 0.1065727 -0.3753563 -0.3841007 -0.485705 -0.0002818117 0.8536846 1.604856 1.073465 -0.1427103 -1.249515 -1.810421 -0.3704569 1.885878 1.316749 0.6522163 2.928096 3.228225 3.784995 -0.1639963 1.201742 1.829828 1.931488 1.315725 1.345699 2.256795 1.599672 3.478213 1.821849 -0.3231009 -0.2753681 0.5276878 -0.3023528 0.01838051 -0.06948359 -1.822717 -2.226174 -2.469202 -2.30871 0.2007962 1.774227 1.617044 -1.412431 0.1862659 -0.09396879 -1.077459 -1.570941 -2.031175 -2.680153 -0.0625282 0.9028823 -0.858481 -0.5769917 -0.5360417 -0.0715664 1.349147 1.137278 1.32029 0.9765919 0.5713189 0.1025353 -0.774071 0.03069902 0.5437631 -0.3775642 -0.2219862 -1.163931 -0.0735203 0.8490562 -1.116672 -0.4866982 -0.06888025 -1.529498 -2.388236 -3.646124 -2.447324 -0.3604848 1.461354 2.482956 0.5142699 -0.7992943 -1.209494 -2.354721 -0.08656133 0.6661553 0.482167 1.523764 1.251777 2.943097 1.357855 3.742398 3.2618 1.132825 0.8222153 1.108848 1.060152 0.08677264 -0.2943017 -2.120647 -0.221949 0.132581 -0.7841645 0.9473683 -0.9033718 -0.6759804 -1.163927 -1.146036 -1.073206 -1.965786 0.3562794 0.3990341 -0.7898226 -1.263171 -0.3120946 0.416211 1.338793 1.904756 0.7601102 1.707156 -1.402229 -1.514117 -1.860788 -0.931904 -0.3013717 0.8965165 0.8841076 0.8465931 1.280036 -0.3260276 0.5427829 1.683833 1.683465 -0.280675 -2.176007 -3.47354 -1.991893 -2.871522 -2.633139 -3.220713 -0.7271739 1.25558 0.5867731 -0.1757405 -2.022207 -1.367083 -2.259811 -2.678198 -1.51338 -0.5068852 -0.9825846 -0.237876 -1.330325 -1.746969 -1.595545 -1.507567 -0.8584496 -0.4024805 -0.05311953 -0.1765004 1.05146 0.7118633 0.2771668 0.3204355 -0.3317522 0.7629083 -0.05079541 -1.379652 -3.274641 -3.399406 -0.6476576 -0.8648311 -0.6254295 1.41874 1.612948 0.511464 0.1084339 0.9078435 2.345317 1.099928 -0.9237051 0.5014207 -0.4967625 -0.2006566 1.810054 1.68685 -0.02219957 1.894275 1.894309 0.8913859 -0.7534309 -0.03691192 0.383259 0.2835365 0.6579445 -1.141977 -0.04195988 1.526774 0.4017206 0.5764767 -0.02958585 0.9520364 1.646413 2.356656 0.4888843 1.420558 1.509638 3.082824 3.537648 4.135403 -0.29164 -0.4681843 -0.8408159 -0.3515668 -0.9831532 -1.576609 0.3602132 0.4977409 0.03025407 -0.4834633 -0.003988457 0.1480583 -0.357467 0.8960289 1.856889 1.608086 3.818911 2.623925 5.840486 6.36875 1.349021 3.478761 2.677433 1.878038 -0.2329638 0.3531567 -0.7901475 -1.962974 -1.419822 -1.313247 -0.8587387 -0.07615261 1.212159 0.6853712 1.083454 2.798248 2.517478 1.652053 1.216484 0.9032742 1.645 2.216733 0.9936396 0.7243947 1.700457 2.687727 3.463481 2.384446 1.685148 0.8424114 2.034478 0.4963606 0.7249985 -0.7685928 -3.476439 -3.828354 -3.61916 -3.637307 -3.1517 -1.3896 -0.3454733 -0.4638766 -0.5953038 0.3050554 0.9685634 0.0857916 0.3426629 0.2905031 -1.113175 -0.16091 -2.553447 -2.136357 -0.9749409 0.07648461 -1.27032 -1.598432 -2.395385 -1.907443 -2.942562 -1.08473 -0.003701295 -1.074696 0.2488986 0.5816033 0.04048274 0.4060821 1.02363 1.689489 2.05304 2.362107 0.756817 -1.400468 -0.8348977 -0.5897572 0.9448275 3.159139 3.128692 3.501721 1.87156 -0.7193778 0.8920808 1.536263 0.6910603 0.2994706 -0.1033534 0.4197272 1.460811 1.593791 1.984216 3.852624 1.871607 0.4800072 -0.3932829 0.3137584 0.8639656 1.177193 2.131524 1.712983 1.309821 0.6941797 -0.2446329 -1.460697 -1.807829 -0.04332757 1.443316 2.139433 2.299493 3.026607 3.684475 3.624224 -0.4788317 -1.446362 -0.9632968 0.6104501 -0.06246096 -0.7800945 -0.7801438 -1.528694 -0.6514429 -1.9107 1.569358 2.135923 1.236362 1.801445 1.796154 2.393356 1.842175 1.017701 0.6383 -0.05532597 -1.67454 0.1298886 0.441451 -0.8970052 -0.8793847 -1.428624 -1.626881 -0.8630489 -0.535461 -0.5553176 -1.89918 -2.228211 -2.862295 -2.084727 -3.99879 -4.508655 -5.709236 -6.869308 -4.975754 -5.172185 0.8113193 0.7802483 0.4323996 1.403743 1.77807 1.065285 1.388811 1.034798 -0.0138674 -0.7680109 1.280809 1.86594 2.341253 1.373695 2.871323 5.024834 4.919921 4.278487 4.314998 3.983083 -0.8183555 1.137801 -0.04422513 0.4150169 1.998412 2.61466 3.217646 3.169887 4.225107 2.687762 0.3940196 -0.737668 -0.6955391 -0.3264166 0.5407346 -0.3903149 -0.8981012 -0.8494889 0.6332726 0.3981506 0.8740766 -0.07339155 -0.9387463 0.2153409 1.831464 2.050824 2.481489 2.454991 2.70569 1.878294 -1.096188 -1.545322 -0.4245915 -0.008948192 -0.9049364 -1.227973 -1.273673 -2.758998 -2.142578 -0.9659093 -0.3869687 2.057933 1.788824 2.245819 1.30065 2.492583 2.183231 1.162998 2.62196 0.3772096
You can use lines() to add additional lines to your plot. Sarah On Sun, May 6, 2012 at 11:39 AM, Trying To learn again <tryingtolearnagain at gmail.com> wrote:> Hi, > > I want to plot this matrix (I attach the data), it is suposed that each > column is a different time series. > > If I do > > g<-read.table("dataADF.txt", header=F) > > and > > plot(g[,1],type="l") > > it ?plots the first column plot if I want in a unique graph each colums of > dataA, all in one. How should I proceed?There is a direct pre-defined code? > > And ?If I wanted a plot by each column? >-- Sarah Goslee http://www.functionaldiversity.org
On Sun, May 6, 2012 at 11:39 AM, Trying To learn again <tryingtolearnagain at gmail.com> wrote:> Hi, > > I want to plot this matrix (I attach the data), it is suposed that each > column is a different time series. > > If I do > > g<-read.table("dataADF.txt", header=F) > > and > > plot(g[,1],type="l") > > it ?plots the first column plot if I want in a unique graph each colums of > dataA, all in one. How should I proceed?There is a direct pre-defined code? > > And ?If I wanted a plot by each column? >Try this: library(zoo) URL <- "http://r.789695.n4.nabble.com/attachment/4613171/0/dataA.txt" z <- read.zoo(URL, index = 0) plot(z) # multi-panel plot(z, screen = 1, col = 1:5) # single panel See ?plot.zoo for more details. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Assuming Windows OS with the data you attached copied to the clipboard: TSdata <- read.table("clipboard", header=FALSE, sep="", na.strings="NA", dec=".", strip.white=TRUE) Then just matplot(TSdata, type="l") But you will probably want to select your own colors, line types, and add a legend: ?matplot ?legend If you want separate plots in one plot window: par(mfrow=c(2, 3)) for (i in 1:5) { plot(TSdata[,i], ylab=paste("V", i, sep=""), type="l") } ---------------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Gabor Grothendieck > Sent: Sunday, May 06, 2012 12:16 PM > To: Trying To learn again > Cc: r-help at r-project.org > Subject: Re: [R] PLot a matrix > > On Sun, May 6, 2012 at 11:39 AM, Trying To learn again > <tryingtolearnagain at gmail.com> wrote: > > Hi, > > > > I want to plot this matrix (I attach the data), it is suposed that > each > > column is a different time series. > > > > If I do > > > > g<-read.table("dataADF.txt", header=F) > > > > and > > > > plot(g[,1],type="l") > > > > it ?plots the first column plot if I want in a unique graph each > colums of > > dataA, all in one. How should I proceed?There is a direct pre-defined > code? > > > > And ?If I wanted a plot by each column? > > > > > Try this: > > library(zoo) > URL <- "http://r.789695.n4.nabble.com/attachment/4613171/0/dataA.txt" > z <- read.zoo(URL, index = 0) > > plot(z) # multi-panel > plot(z, screen = 1, col = 1:5) # single panel > > See ?plot.zoo for more details. > > > -- > Statistics & Software Consulting > GKX Group, GKX Associates Inc. > tel: 1-877-GKX-GROUP > email: ggrothendieck at gmail.com > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code.