Dear all, I have the following matrix.> datA A A A A A A A A A [1,] 0 0 0 0 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 0 0 0 1 [3,] 0 0 0 0 0 0 0 0 0 2 How can I change it into: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0 0 0 0 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 0 0 0 1 [3,] 0 0 0 0 0 0 0 0 0 2 I tried:> as.matrix(x)But failed. - Gundala Viswanath Jakarta - Indonesia
Hi Gundala, try chopping off the top row like newx<-as.matrix(x[2:dim(x)[1],]) OR try changing it to a data frame... new x<-data.frame(x,row.names=NULL) #pretty sure its not row.names but there is probably an equivalent for col.names OR look into ?read.table and specify header = F Cheers, Si. ----- Original Message ----- From: "Gundala Viswanath" <gundalav at gmail.com> To: <r-help at stat.math.ethz.ch> Sent: Tuesday, January 06, 2009 8:14 AM Subject: [R] Changing Matrix Header> Dear all, > > I have the following matrix. > >> dat > A A A A A A A A A A > [1,] 0 0 0 0 0 0 0 0 0 0 > [2,] 0 0 0 0 0 0 0 0 0 1 > [3,] 0 0 0 0 0 0 0 0 0 2 > > How can I change it into: > [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] > [1,] 0 0 0 0 0 0 0 0 0 0 > [2,] 0 0 0 0 0 0 0 0 0 1 > [3,] 0 0 0 0 0 0 0 0 0 2 > > > I tried: > >> as.matrix(x) > > But failed. > > > - Gundala Viswanath > Jakarta - Indonesia > > ______________________________________________ > 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. >
Dear Gundala,
Try this:
# Original matrix
set.seed(123)
X=matrix(rnorm(100),ncol=10)
colnames(X)<-paste('X',1:10,sep="")
X
# No headers
colnames(X)<-NULL
X
HTH,
Jorge
On Tue, Jan 6, 2009 at 3:14 AM, Gundala Viswanath
<gundalav@gmail.com>wrote:
> Dear all,
>
> I have the following matrix.
>
> > dat
> A A A A A A A A A A
> [1,] 0 0 0 0 0 0 0 0 0 0
> [2,] 0 0 0 0 0 0 0 0 0 1
> [3,] 0 0 0 0 0 0 0 0 0 2
>
> How can I change it into:
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
> [1,] 0 0 0 0 0 0 0 0 0 0
> [2,] 0 0 0 0 0 0 0 0 0 1
> [3,] 0 0 0 0 0 0 0 0 0 2
>
>
> I tried:
>
> > as.matrix(x)
>
> But failed.
>
>
> - Gundala Viswanath
> Jakarta - Indonesia
>
> ______________________________________________
> R-help@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.
>
[[alternative HTML version deleted]]
Hello, colnames( dat ) <- NULL will do the trick. Carlos J. Gil Bellosta http://www.datanalytics.com On Tue, 2009-01-06 at 17:14 +0900, Gundala Viswanath wrote:> Dear all, > > I have the following matrix. > > > dat > A A A A A A A A A A > [1,] 0 0 0 0 0 0 0 0 0 0 > [2,] 0 0 0 0 0 0 0 0 0 1 > [3,] 0 0 0 0 0 0 0 0 0 2 > > How can I change it into: > [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] > [1,] 0 0 0 0 0 0 0 0 0 0 > [2,] 0 0 0 0 0 0 0 0 0 1 > [3,] 0 0 0 0 0 0 0 0 0 2 > > > I tried: > > > as.matrix(x) > > But failed. > > > - Gundala Viswanath > Jakarta - Indonesia > > ______________________________________________ > 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.
Try this: unname(dat) On Tue, Jan 6, 2009 at 6:14 AM, Gundala Viswanath <gundalav@gmail.com>wrote:> Dear all, > > I have the following matrix. > > > dat > A A A A A A A A A A > [1,] 0 0 0 0 0 0 0 0 0 0 > [2,] 0 0 0 0 0 0 0 0 0 1 > [3,] 0 0 0 0 0 0 0 0 0 2 > > How can I change it into: > [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] > [1,] 0 0 0 0 0 0 0 0 0 0 > [2,] 0 0 0 0 0 0 0 0 0 1 > [3,] 0 0 0 0 0 0 0 0 0 2 > > > I tried: > > > as.matrix(x) > > But failed. > > > - Gundala Viswanath > Jakarta - Indonesia > > ______________________________________________ > R-help@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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
Hi,
I'm trying to create a time series that will work with ohlcPlot:
mts<-ts(data=c(results$OpenPrice,results$HighPrice,results$LowPrice,
results$ClosePrice),c="mts",names=c("Open",
"High", "Low","Close"))
ohlcPlot(mts) fails with: Error in if ((!is.mts(x)) || (colnames(x)[1] !=
"Open") || (colnames(x)[2] != : ...
is.mts(mts) returns true but colnames(mts) returns NULL.
I've trawled the archive for an example of using this function to no avail
and it's not apparent from the docs what the data needs to look like. Does
anyone have an example of code that will work with this function?
Thanks
Neil
.
This message is intended only for the use of the person(s) to whom it is
addressed. It may contain information which is privileged and confidential.
Accordingly any unauthorised use is strictly prohibited. If you are not the
intended recipient, please contact the sender as soon as possible.
It is not intended as an offer or solicitation for the purchase or sale of any
financial instrument or as an official confirmation of any transaction, unless
specifically agreed otherwise. All market prices, data and other information are
not warranted as to completeness or accuracy and are subject to change without
notice. Any opinions or advice contained in this Internet email are subject to
the terms and conditions expressed in any applicable governing Marble Bar Asset
Management LLP's terms and conditions of business or client agreement
letter. Any comments or statements made herein do not necessarily reflect those
of Marble Bar Asset Management LLP.
Marble Bar Asset Management LLP is regulated and authorised by the FSA.