Re: [R] Get the names of the columns in a tserie
Have you tried 'str(X)' on the 'X' object that 'read.ts' created for you? If you've done that and still can't solve your problem, I suggest you review the Introduction to R manual, available as the first option on the left from the html file you get from 'help.start()'. If that still does not answer your question, I suggest you review the 'zoo' vignette. For more information about how to access that, I suggest you try http://finzi.psych.upenn.edu/R/Rhelp02a/archive/67006.html; (which was the first of 35 hits that I got just now in response to 'RSiteSearch(graves zoo vignette)'). If you'd like further help from this listserve, please provide commented, minimal, self-contained, reproducible code, as suggested in the posting guide www.R-project.org/posting-guide.html. Your example was not self contained. Also, R is case sensitive, so Tseries is different from tseries. I believe you can increase your chances of getting more and more useful replies quicker by thinking about what someone would have to know to be able to answer your question. In particular, a very short, self contained example sometimes invites people who may never have used the 'tseries' package before to experiment with your example. By doing so, they get a very quick introduction to 'tseries', and with only a little luck, you get a quick answer to your question. It's win-win, and I've learned a lot doing just that. Without a simple, self-contained example, I know it will likely take me a lot longer to even understand what you are asking, and I will likely not be very confident that I even understand your question even if I attempt an answer. Hope this helps. Spencer Graves lvdtime wrote: Please, I need this information, it's important for my work Thank you. lvdtime wrote: Hello everybody, I'm a beginner in R, and I'm currently working on Tseries (analysis of a portfolio) I imported the data like this (library tseries) : X-read.ts(X.dat, start=c(1995,1), frequency=261, header=T, sep=;) There is a header which contains the names of each column (codes of shares) I'd like to know if it is possible to get the names of the columns (to display it in the plots : ylab=name of the col) To summarize, I wonder if a code like label(X[,i]) exists... Thank you for your help LVDTime __ R-help@stat.math.ethz.ch 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.
Re: [R] Get the names of the columns in a tserie
On Thu, 2006-10-26 at 17:17 -0700, lvdtime wrote: Please, I need this information, it's important for my work By that, do you mean that your time/work is more important than that of the other members of this list? Anyway, yes, there is an equivalent of label(X[, i]). You can use colnames, as in colnames(X)[i] or colnames(X[, i, drop = FALSE]), but it won't automagically select the column of the time series you have told R to plot, you'd do it manually: ## dummy data dat - matrix(rnorm(100), ncol = 5) colnames(dat) - LETTERS[1:5] dat - as.ts(dat) dat ## plot column 3 of the time series plot(dat[, 3], ylab = colnames(dat)[3]) If you want to automate this, then you need to write a wrapper to plot.ts, one such, very simple, wrapper might look something like this: my.plot.ts - function(x, series) { plot(x[, series], ylab = colnames(x)[series])} my.plot.ts(dat, series = 3) my.plot.ts(dat, 3) # equivalent of above Is this what you were looking for? Actually, having looked at what happens when you subset a ts object. You are selecting a single time series from a multivariate time series, which follows R's general behaviour of dropping the empty dimension, e.g., contrast : dim(dat[, 1]) dim(dat[, 1, drop = FALSE]) This has the side effect of dropping the colnames of the ts object: str(dat[, 1]) str(dat[, 1, drop = FALSE]) So, all you need is to modify your plot call to include drop = FALSE: plot(dat[, 2, drop = FALSE]) and plot.ts will take care of the labelling for you. G Thank you. lvdtime wrote: Hello everybody, I'm a beginner in R, and I'm currently working on Tseries (analysis of a portfolio) I imported the data like this (library tseries) : X-read.ts(X.dat, start=c(1995,1), frequency=261, header=T, sep=;) There is a header which contains the names of each column (codes of shares) I'd like to know if it is possible to get the names of the columns (to display it in the plots : ylab=name of the col) To summarize, I wonder if a code like label(X[,i]) exists... Thank you for your help LVDTime -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% *Note new Address and Fax and Telephone numbers from 10th April 2006* %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC [f] +44 (0)20 7679 0565 UCL Department of Geography Pearson Building [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street London, UK[w] http://www.ucl.ac.uk/~ucfagls/cv/ WC1E 6BT [w] http://www.ucl.ac.uk/~ucfagls/ %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@stat.math.ethz.ch 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.
Re: [R] Get the names of the columns in a tserie
lvdtime == lvdtime [EMAIL PROTECTED] on Thu, 26 Oct 2006 17:17:01 -0700 (PDT) writes: lvdtime Please, I need this information, it's important for my work Well, then do your home work (read the posting guide and follow it!!), instead of sending this again to the several thousand subscribers of R-help! Martin Maechler, ETH Zurich [] __ R-help@stat.math.ethz.ch 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.
Re: [R] Get the names of the columns in a tserie
Please, I need this information, it's important for my work Thank you. lvdtime wrote: Hello everybody, I'm a beginner in R, and I'm currently working on Tseries (analysis of a portfolio) I imported the data like this (library tseries) : X-read.ts(X.dat, start=c(1995,1), frequency=261, header=T, sep=;) There is a header which contains the names of each column (codes of shares) I'd like to know if it is possible to get the names of the columns (to display it in the plots : ylab=name of the col) To summarize, I wonder if a code like label(X[,i]) exists... Thank you for your help LVDTime -- View this message in context: http://www.nabble.com/Get-the-names-of-the-columns-in-a-tserie-tf2511355.html#a7022436 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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.
[R] Get the names of the columns in a tserie
Hello everybody, I'm a beginner in R, and I'm currently working on Tseries (analysis of a portfolio) I imported the data like this (library tseries) : X-read.ts(X.dat, start=c(1995,1), frequency=261, header=T, sep=;) There is a header which contains the names of each column (codes of shares) I'd like to know if it is possible to get the names of the columns (to display it in the plots : ylab=name of the col) To summarize, I wonder if a code like label(X[,i]) exists... Thank you for your help LVDTime -- View this message in context: http://www.nabble.com/Get-the-names-of-the-columns-in-a-tserie-tf2511355.html#a7003865 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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.