Hello guys, I wanted to thank you, each one of you led me step by step to the
core of the problem. The matrix I was working on was made of rows obtained
each one by the lapply function. So by using lapply I was getting a matrix
which rows were not numeric vectors but lists. To solve this I used a
On Jan 29, 2010, at 6:53 PM, anna wrote:
Well I just tried to convert it with data.frame and then data.matrix
and it
returned me a numeric vector but I am not done yet, let's see if it
works,
if it doesn't I will try sapply. I think I didn't use sapply because
the
vectors I am using in
Well I just tried to convert it with data.frame and then data.matrix and it
returned me a numeric vector but I am not done yet, let's see if it works,
if it doesn't I will try sapply. I think I didn't use sapply because the
vectors I am using in lapply are of different lengths.
-
Anna Lippel
On Jan 29, 2010, at 6:14 PM, anna wrote:
Bill this is exactly what is happening, by using lapply I am having
a list
and not a numeric vector, I want a numeric vector, is there a way to
convert
that list to a numeric vector?
You could see if substituting sapply would yield a matrix. It w
Bill this is exactly what is happening, by using lapply I am having a list
and not a numeric vector, I want a numeric vector, is there a way to convert
that list to a numeric vector?
-
Anna Lippel
--
View this message in context:
http://n4.nabble.com/Simple-question-on-replace-a-matrix-row-
Dennis, as soon as I do : > mat3[1, ] <- mat1 and class(mat3) I get a list
and not a matrix anymore...So yes you drove me to the problem, mat1 is not
one-row numeric matrix but a list.
-
Anna Lippel
--
View this message in context:
http://n4.nabble.com/Simple-question-on-replace-a-matrix-
David, I think I am going close to the problem, at the end of the function
ComputeSignalReturns I build the matrix summary with cbind. So when I make
class(summary) I get "matrix" but when I make class(summary[1,]) I get
"list"
Excuse me if I didn't show the problem the right way, I am still new a
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of anna
> Sent: Friday, January 29, 2010 2:46 PM
> To: r-help@r-project.org
> Subject: Re: [R] Simple q
On Jan 29, 2010, at 4:54 PM, anna wrote:
I was trying to avoid the code because I wanted to simplify it but
here we
go:
mat2<- matrix(nrow = 30, ncol = 7)
colnames(mat2) <-c( "A", "B", "C", "D", "E", "F", "G")
mat1<-mainMat[1,]
I get mainMat[1,] from the following function:
Comput
What I did now is that I checked the class of both matrix before assigning
the first row of mat2:
class(mainMat) --> "matrix"
class(mainMat[1,]) --> "list"
class(mat2) --> "matrix"
mat2[1,]<-mainMat[1,]
class(mat2) --> "list"
I think the problem comes from mainMat[1,] that should be of class "mat
I was trying to avoid the code because I wanted to simplify it but here we
go:
mat2<- matrix(nrow = 30, ncol = 7)
colnames(mat2) <-c( "A", "B", "C", "D", "E", "F", "G")
mat1<-mainMat[1,]
I get mainMat[1,] from the following function:
ComputeSignalReturns <- function(vec1
Hi:
Check the class and dimensions of your objects. If mat1 is either
an eight element numeric vector or a one-row matrix, you should
have no problem:
> mat1 <- 1:8 # vector
> mat2 <- matrix(rnorm(240), nrow =30)
> class(mat1)
[1] "integer"
> class(mat2)
[1] "matrix"
> mat3 <- mat2
> mat3
On Jan 29, 2010, at 4:33 PM, anna wrote:
Here is how I get mat1: I have a matrix mainMat of 4 rows and 8
columns, I
take the first row of it to build mat1. The problem might come from
how I
build mainMat --> each column comes from an lapply function which
returns a
list but I convert i
Here is how I get mat1: I have a matrix mainMat of 4 rows and 8 columns, I
take the first row of it to build mat1. The problem might come from how I
build mainMat --> each column comes from an lapply function which returns a
list but I convert it to a matrix [4,1]...
-
Anna Lippel
--
View t
I convert them both before making matrix() on them. Let me try to send you
more details
-
Anna Lippel
--
View this message in context:
http://n4.nabble.com/Simple-question-on-replace-a-matrix-row-tp1427857p1430130.html
Sent from the R help mailing list archive at Nabble.com.
__
On Jan 29, 2010, at 3:55 PM, anna wrote:
Hello, I have a matrix mat1 of dim [1,8] and mat2 of dim[30,8], I
want to
replace the first row of mat2 with mat1, this is what I do:
mat2[1,]<-mat1 but it transforms mat2 in a list I don't understand,
I want
it to stay a matrix...
What makes yo
Hello, I have a matrix mat1 of dim [1,8] and mat2 of dim[30,8], I want to
replace the first row of mat2 with mat1, this is what I do:
mat2[1,]<-mat1 but it transforms mat2 in a list I don't understand, I want
it to stay a matrix...
-
Anna Lippel
--
View this message in context:
http://n4.na
17 matches
Mail list logo