Displaying 13 results from an estimated 13 matches for "my_matrix".
2010 Sep 27
3
name ONLY one column
Hi R-users
I can not change the name of one column only of my matrix.
my_matrix <- matrix (1:12,ncol=3)
colnames(my_matrix)[1] <- 'myname'
Error in dimnames(x) <- dn :
length of 'dimnames' [2] not equal to array extent
thank you for your help
Lorenzo
[[alternative HTML version deleted]]
2010 Jun 08
3
Matrix to "database" -- best practices/efficiency?
I have a matrix of, say, M and N dimensions:
my_matrix=matrix(c(1:60),nrow=6,ncol=10)
I have two "id" vectors corresponding to the rows and columns, e.g.:
id_m=seq(10,60,by=10)
id_n=seq(100,1000,by=100)
I would like to create a "proper" database (let's say a data.frame for
this example -- i'm going to be loading these int...
2009 May 15
2
Printing to screen a matrix or data.frame in one chunk (not splitting columns)
...lost the source and I hope
one of you can point me to the solution. My problem is that I don't know
the correct words to query this.
When I print to screen a matrix or data.frame the columns are split and
printed below the previous ones; even though I have plenty of screen left.
E.g.,
> my_matrix = matrix(runif(30),nrow=3,ncol=10)
> my_matrix
[,1] [,2] [,3] [,4] [,5] [,6]
[,7]
[1,] 0.4979305 0.1155717 0.4484069 0.29986049 0.5427566 0.4324351
0.269171456
[2,] 0.8405987 0.3605237 0.6615507 0.75305248 0.8569482 0.3401004
0.192526423
[3,] 0.5608779 0.39539...
2012 Sep 11
1
lapply with different size lists?
...>my.matrix
> [,1] [,2]
> [1,] 0.708060983 0.3242221
> [2,] 0.356736311 0.1454096
> [3,] 0.402880340 0.4763676
> [4,] 0.795947223 0.4052168
> [5,] 0.001620093 0.2618591
> [6,] 0.192215589 0.6595275
> [7,] 0.539199304 0.5402015
>
> > b (m=6,matrix=my_matrix)
> [[1]]
> matrix.lapply.inf.sup..function.i..c.i..Inf..matrix.i..1...matrix.i..
> 1 1.0000000, Inf, 0.7080610, 0.3242221
> 2 2.0000000, Inf, 0.3567363, 0.1454096
> 3 3.0000000, Inf,...
2011 Mar 28
2
How to save heatmap as image or pdf
Hello Everyone,
I am using R for creating heatmap from a square matrix. Below is my script
to do so
my_map <- read.csv("Desktop/input.csv", sep=",")
my_matrix <- data.matrix(my_map)
my_heatmap <- heatmap(my_matrix, Rowv=NA, Colv=NA, col = cm.colors(256),
scale="column", margins=c(5,10))
I get a beautiful plot as output, but I could not save this plot as an
image. I would like it to be in either jpg/png/svg/bitmap/ or PDF format.
Can so...
2011 Nov 28
2
Principal componet plot from lower triangular matrix file
...efficient way to 1) read file 2) compute first and second principal
components and 3) and plot first vs second PC's ?
In the past, I could do this by :
b <- read.csv("distance.csv", sep=",", head=F) # distance.csv file is
complete data matrix, so this command worked !!
my_matrix <- data.matrix(b)
pca2 <- princomp(my_matrix)
plot(pca2$scores[,1],pca2$scores[,2])
text(pca2$scores[,1],pca2$scores[,2],rownames(nba_matrix), cex=0.5, pos=1)
This time, I don't have a complete file. So, I was wondering, how to do this
?
Any help is much appreciated
TIA
M
--
View this...
2005 Oct 15
1
solve() versus ginv()
Dear All,
While inverting a matrix the following error appears on my console:
Error in solve.default(my_matrix) : Lapack routine dgesv: system is exactly singular
With this respect, I have been replacing the solve() function with ginv(): the Moore-Penrose generalized inverse of a matrix.
These are the questions I would like to ask you:
1. Would you also replace solve() with ginv() in these scenarios...
2012 Sep 28
1
Heatmap Colors
...ro, below zero is blue of
increasing intensity towards -1 and above zero is red of increasing
intensity towards red?
I tried like this (using the marray and gplots packages from bioconductor):
mcol <- maPalette(low="blue", mid="white", high="red",k=100)
heatmap.2(my_matrix, col=mcol)
But white does not correspond to zero, because the value distribution is
not symmetrical, so that zero is not in the middle.
Is it somehow possible to create a color palette with white centered at
zero?
Nick Fankhauser
2008 Jan 31
1
decrease amount of ticks on y axis in lattice levelplot
...w
to solve it.
I tried to change the amount of ticks using yscale.components, but this
doesn't work:
yscale.components.myY <- function(...) {
Y <- yscale.components.default(...)
Y$left$ticks$at <- pretty(1,n=10)
Y$left$labels$at <- pretty(1,n=10)
return(Y)
}
print(levelplot(my_matrix),cuts=100,yscale.components=yscale.components.myY)
My full code can be found on pastebin:
http://pastebin.com/m16b267f9
thanks in advance for any help on this,
Bram Kuijper
2005 Apr 18
1
Storing vectors as vectors and iterating through them
Hi all,
I have a bunch of int vectors. Each vector holds a bunch of ints that
correspond to row numbers of an existing matrix. I use the int vectors to
pull out rows of data from a matrix, i.e.
data <- my_matrix[int_vector,]
I would like to store these int vectors in some sort of data structure that
will preserve them as-is and allow iteration. I guess what I'm looking for
would be something analogous to the java Vector class, as in this java-like
pseudocode :
Vector V = new Vector;
V.add(a,b,c) /...
2011 May 21
1
'apply' with additional class variable
...something like this:
carmake<-c("Toyota","Ford","Chevy")
x<-matrix(1:12,nrow=4)
colnames(x)<-c("Car1","Car2","Car3")
rownames(x)<-c("Horsepower","TopSpeed","Weight","Cost")
res<-apply(my_matrix,2,my_func,carmake)
The obvious problem with this is that I cannot know which column 'my_func' is working on, in order to know which column to get the car make from. I then thought I could try and match on column name, but when the column is passed into 'my_func' it loses the column...
2008 Sep 21
1
Calculating interval for conditional/unconditional correlation matrix
Hi there,
Could anyone please help me to understand what should be done in order not to get this error message: Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
Here is my code:
determinant<-
function(x){det(matrix(c(1.0,0.2,0.5,0.8,0.2,1.0,0.5,0.6,0.5,0.5,0.5,1.0,x,0.8,0.6,x,1.0),ncol=4,byrow=T))}
matrix<-
2008 Sep 22
1
R-help Digest, Vol 67, Issue 23
...t;
Content-Type: text/plain; charset=utf-8
Hi Ana,
There are two problems:
First of all, if you want your matrix to have 4 columns it's number of elem[[elided Yahoo spam]]
Secondly, and this is what causes your error message, you should not call your second function matrix. Call it matrix1, my_matrix, whatever. Otherwise R thinks that you are calling your matrix function within itself.
> Subject: [R] Calculating interval for conditional/unconditional correlation matrix
> To: "R" <r-help@r-project.org>
> Received: Sunday, 21 September, 2008, 8:05 PM
> Hi there,
&...