similar to: How to save row values from a matrix into one vector?

Displaying 20 results from an estimated 10000 matches similar to: "How to save row values from a matrix into one vector?"

2008 Nov 10
2
Make one vector from matrix comparison
Hello R-users, I have a little problem. I compare each row of a matrix with each row of another matrix. testmat1 <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4) testmat2 <- matrix(c(1,2,3,5,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4) Both matrix differs in the last row. Now I create a loop: for (i in (1:4)){ for (j in (1:4)){ b <- (c(setequal(testmat1[j,],testmat2[i,])))
2008 Sep 17
1
Re adout row and column of a matrix value
Hello R users, I want to readout the row and column postion from a certain matrix value into a csv file. I have only found this syntax "which(a == b, arr.ind = T)" so I get a = matrix [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1 1 2 2 2 1 1 2 [2,] 1 2 3 3 3 4 4 3 [3,] 3 3 3 5 5 6 5 4 [4,] 4 4 4 3
2012 Feb 01
6
While loop working with TRUE/FALSE?
Hi R users, is there any possibilty that a while loop is working like that: z <- c(0,1,2,3,4,5,6,7,8,9) r <- 7 while(w == T) { for ( i in 1:10 ){ w <- r == z[i] print(w) } } The loop should stop if w == TRUE best regards -- View this message in context:
2008 Oct 22
3
Substitute problem
hello R users, I didn't find a solution for a special problem. I have two dataframes. dataframe1: X value row col ID 1 8.973498062 5512625 3460000 1 2 11.656658570 5501625 3464000 2 3 11.121777570 5495625 3473000 3 4 9.310465964 5508625 3477000 4 5 8.883483845 5515625 3496000 5 dataframe2: X value
2011 Nov 15
2
points() colored by value
Hi R users, I want to colored points by their value for example: x <- c(1,2,3,4) y <- c(1,2,3,4) z <- c(2,3,4,9) y and x are coordinates z is the value of the coordinates points(x,y,col= rainbow(z)) something like that But haven't found any solution at the moment. Thanks. Chris -- View this message in context:
2008 Sep 21
1
Searching a relativ maximum of a matrix
Hello R users, is there a possibility to get the relativ maximum of a matrix? To get the absolut maximum I use max(matrix) For example: The absolut maximum of this matrix is 6[3,6], but the relativ maximum is 6[3,6] and 4[7,6], because both values are the highest value in comparison to their eight neighbours values. [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1 1 2 2 2
2008 Jul 23
2
Flip Matrix form file?
Hello, I have a problem to flip a 200x200 matrix, which is imported by a .asc file. I want to flip the matrix like in a created example below: > b <- matrix(1:9,3,3,byrow=T) > b [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 [3,] 7 8 9 > b1 <- apply(t(b),1,rev) > b1 [,1] [,2] [,3] [1,] 7 8 9 [2,] 4 5 6 [3,] 1 2 3 but my
2008 Nov 25
1
add string to a list
hello R users, I didn't find a solution for a simple problem I think. I read 224 lines from a file input <- readLines(con,n=224) and now I create a string x <- "\004" which should be line 225 of input. So I have input and x and want to add x to input, so that it looks like this: [1] "string" [2] "string" . . . [224] "string" [225]
2011 Feb 03
2
substring and paste character with a for loop
Hello R users, I have a little problem with a for loop. Below there is an simple example of my problem. I want to delet the commas in the character string. Fore this reason I create a for loop to unpick the string and rebuild him without the commas. The problem is, that "paste" does not work in the loop as I expected. text <- "aaa,bbb,ccc,ddd" characterseq <-
2013 Apr 16
2
R process slow down after a amount of time
Hi R users, I have mentioned that R is getting slower if a process with a loop runs for a while. Is that normal? Let's say, I have a code which produce an output file after one loop run. Now after 10, 15 or 20 loop runs the time between the created files is stongly increasing. Is there maybe any data which fill some memory? Chris -- View this message in context:
2008 Oct 22
3
retrieving matrix elements by giving pairs of row AND column numbers?
Hi, this is probably a very trivial question but I can't figure out the right terms to find the solution in the list archive. I have a matrix or a data.frame or the like: > m <- matrix(ncol=3,seq(1,9)) > m [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 and now I wonder if one can provide somehow two vectors, one containing row numbers, the other
2008 Sep 09
1
Substitute Values in a Matrix?
Hi, I'm searching for a function to subistute Values in a Matrix to new Values. For example: old value new value 1.1 6 1.2 7 . . . . . . 1.9 14 2.0 15 and 2.1 15.5 2.2 16 . . . . 2.9 19.5 3.0 20 There is a difference
2011 Apr 22
2
Matching a vector with a matrix row
Hello I am trying to compare a vector with a Matrix's rows.The vector has the same length as the number of columns of the matrix, and I would like to find the row numbers where the matrix's row us the same as the given vector. What I am doing at the moment is using apply as follows: apply(Matrix,1,function(x)all(x%in%LHS)) but this isn't too fast actually. I would like to know if
2011 Jul 19
3
calculating the mean of a random matrix (by row) and some general questions
Hi everyone! I'm trying to teach myself R in order to do some data analysis. I'm a mathematics student and (only) familiar with matlab and latex. I'm working trough the "official" introduction to R at the moment, while simultaneously solving some exercises I found in the web. Before I post my (probably stupid) question, I'd like to ask you for some general advice. How do
2004 Jul 28
6
elegant matrix creation
Hello everybody. I am trying to reproduce a particular matrix in an elegant way. If I have jj1 <- structure(c(1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2, 3,1,2,3,1,2,3,1,2,3,2,3,1,2,3,1,2,3,1,2,3, 1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,3,1,2,3,1, 2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1, 2),.Dim = as.integer(c(9,9))) [ image(jj1) is good here ] then I can get this with
2009 Mar 30
2
which rows are duplicates?
I would like to know which rows are duplicates of each other, not simply that a row is duplicate of another row. In the following example rows 1 and 3 are duplicates. > x <- c(1,3,1) > y <- c(2,4,2) > z <- c(3,4,3) > data <- data.frame(x,y,z) x y z 1 1 2 3 2 3 4 4 3 1 2 3 I can't figure out how to get R to tell me that observation 1 and 3 are the same.
2009 Mar 30
2
which rows are duplicates?
I would like to know which rows are duplicates of each other, not simply that a row is duplicate of another row. In the following example rows 1 and 3 are duplicates. > x <- c(1,3,1) > y <- c(2,4,2) > z <- c(3,4,3) > data <- data.frame(x,y,z) x y z 1 1 2 3 2 3 4 4 3 1 2 3 I can't figure out how to get R to tell me that observation 1 and 3 are the same.
2005 Mar 28
2
Generating list of vector coordinates
Hi. Can anyone suggest a simple way to obtain in R a list of vector coordinates of the following form? The code below is Mathematica. In[5]:= Flatten[Table[{i,j,k},{i,3},{j,4},{k,5}], 2] Out[5]= {{1,1,1},{1,1,2},{1,1,3},{1,1,4},{1,1,5},{1,2,1},{1,2,2},{1,2,3},{1 ,2,4},{1,2, 5},{1,3,1},{1,3,2},{1,3,3},{1,3,4},{1,3,5},{1,4,1},{1,4,2},{1,4,3}, {1,4,
2012 Apr 09
1
Pairwise comparison matrix elements
Hi!, I'm really hoping someone out there will be able to help me. I recently started my MSc dissertation on Population Projection Matrices, which has been going well until now. I am trying to set-up a general script that does a pairwise comparison of all elements in my matrices. So for example, given that I have the following matrix S: > S [,1] [,2] [,3] [1,]
2005 May 11
3
How to plot a matrix with 18 rows by row vs. a vector in a single graph, resulting 18 lines with different colors?
I have a matrix gene=array(rnorm(180), dim=c(18,10)) and a vector time=c(0, 0.5,2,4,6,8,12,24,48,72). So i can get a plot with plot(time,gene[1,],type="b",col="green") for the first row.So how can i get all the 18 rows in the same plot VS. the same vector time=c(0,0.5,2,4,6,8,12,24,48,72). Any suggestions.Thanks ! [[alternative HTML version deleted]]