search for: yourmatrix

Displaying 18 results from an estimated 18 matches for "yourmatrix".

2009 May 14
3
memory usage grows too fast
Hi All, I have a 1000x1000000 matrix. The calculation I would like to do is actually very simple: for each row, calculate the frequency of a given pattern. For example, a toy dataset is as follows. Col1 Col2 Col3 Col4 01 02 02 00 => Freq of ?02? is 0.5 02 02 02 01 => Freq of ?02? is 0.75 00 02 01 01 ? My code is quite simple as the following to find the pattern ?02?.
2005 Jan 21
6
Avoiding a Loop?
Dear R-Helpers, I have a matrix where the first column is known. The second column is the result of multiplying this first column with a constant "const". The third column is the result of multiplying the second column with "const"..... So far, I did it like this (as a simplified example): nr.of.columns <- 4 myconstant <- 27.5 mymatrix <- matrix(numeric(0), nrow=5,
2007 Nov 20
1
Process multiple columns of data.frame
Hello, How do I do the following more concisely? Bout[is.na(Bout$bd.n), 'bd.n'] <- 0 Bout[is.na(Bout$ht.n), 'ht.n'] <- 0 Bout[is.na(Bout$dbh.n), 'dbh.n'] <- 0 Would the form of such a command be different between numeric, character and factor columns? . . . between data.frames and matrices? Thanx, DaveT. ************************************* Silviculture
2011 Jan 21
2
ordering a vector
Hi, is there a R function that order a matrix according to some criteria based on the rows(or cols) of that matrix? For example, let's say that my matrix S is composed by n rows S_1, S_2,.., S_n and that I compute some real value g_i=g(S_i) for each row. Then I want to order this set of g_i (from smaller to bigger) and order the correspondent row to the new position. Is it possible (apart
2011 Apr 01
1
Fisher's test
I have a matrix with 2 columns and I want to do fishers exact test for these with the totals for each row being 100 say. The data has the form: 23 12 32 21 12 2 and these represents the tables: 23 12 77 88 32 21 78 79 12 2 88 98 How do I use apply to speed up aclculation of the fisher.exact test? -- Thanks, Jim. [[alternative HTML version deleted]]
2011 Jul 20
3
select element from each row of the matrix
I have a 5 column matrix like 12 10 8 6 3 10 9 8 7 5 14 NA 4 NA NA NA 15 NA 10 NA 5 ... I want to select the position of the first entry for each row <=5 for example, for the first row, I want to select the last element and return its position as 5; for th e third row, I want to select the third element and return its position as 3; similarly for the 4th row, I want to select the fifth
2001 Oct 09
3
Unlisting while preserving object types?
Hi A toy example is probably the least ambiguous way of explaining what I'm trying to do. > library(ts) > zz<-list(a=rnorm(100),b=rt(100,3)) > zz.spec<-lapply(zz,spectrum,plot=F) > summary(zz.spec) Length Class Mode a 15 spec list b 15 spec list I'm looking for an elegant way to fetch components of the sub-lists a and b of zz.spec; e.g. to make a matrix
2008 Aug 22
1
dimension values of an array
Question: I created an array with 164 columns and 70 rows. I would like every column to have unit value 1 and the rows 0.1, 0.2, 0.3 up to 7. How can I define that? Thanks for your help! Good weekend! Akko _________________________________________________________________ [[alternative HTML version deleted]]
2004 May 21
1
Memory usage of R on Windows XP
I am running R 1.8.1 on windows xp. I have been using the 'apply' R function to run a short function against a matrix of 19000 x 340 rows ... yes it is a big matrix. every item in the matrix is a float that can have a maximum value of 2^16 ~ 65k. The function: mask256 <- function(value) { if (value < 256) { result = 0 } else { result = 1 }
2010 Jun 02
3
writing a matrix in a file
Hi, I want to write a matrix (n*m) in a file (Text file) such that the file will be as Result file (below). I use the below command but it write all numbers in one column, > write(paste(matrixname),file="test.txt",append=TRUE) how can I do this? Result file: 5 5 -1 -1 -1 -1 8 8 2 7 6 5 6 6 8 2 7 5 Matrix: [,1] [,2] [,3] [,4] [,5]
2012 Apr 04
3
Remove carriage return in writing tab-delimited file.
Having problems with the write.table function. I can write a tab delimited file just fine, but for each line in my matrix its inputs a carriage return when i dont want it to. For example my matrix might be: ID V1 V2 V3 FARY1004 1 2 3 FARY2067 2 3 1 FARY4587 2 2 2 And I want the written File to be: FARY1004 1 2 3FARY2067 2 3 1FARY4587 2 2 2 TIA -- View this
2002 Aug 22
3
correlation
Dear All, I have a file (a matrix) on which I have to compute the correlations. The function "cov" compute the correlations between the columns of a matrix, but I want to compute the correlations between the raws. Can somebody say to me how I can carry out that? Thanks Laurence -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list --
2009 Jan 29
2
Taking the min of each row in a matrix
Hi, I'm a new user. I've been reading through the manual and looking at various examples but am still trying to make sense of the most efficient ways to handle matrices of data. If I have a 2D matrix of data, how do I get the mean, min, max value of each row? I see the "mean" function on a matrix will give me averages by row, but min and max give me the value for the entire
2007 Mar 07
5
hwo can i get a vector that...
dear all, how can i get a vector that shows the number of the column of matrix that contains the maximum of the row ?? can?t believe in need a loop for this... i have a 100 x 3 matrix and want to get a 100 x 1 vector with values 1,2,3 . there must be a simple solution. i just cannot find it. i think am searching on the wrong end. thx for help in advance. m.
2009 Nov 25
5
How to sum only a few elements in a line
Hello, I have a matrix with the numbers 0,1 and 9 I would like to write a function that could sum each line skiping everytime a number 9 appears for example [0 1 0 1 1 9 1] the sum would be 4. However I cannot replace 9 by 0 otherwise after the sum is done I wouldn?t be able to distiguish which ones were real zeros and which ones were nines replaced by zero just to sum. Thank you very much --
2011 Jan 22
0
how to call BayesX in R to see the graph
...an@gmail.com> To: Francesco Petrogalli <francesco.petrogalli@gmail.com> Cc: r-help@r-project.org Subject: Re: [R] ordering a vector Message-ID: <AANLkTi=bWMJjnCoqpQYBEGTHZ_Sa1rk8SC2Pmks7JS3q@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 look at 'order' yourMatrix[order(yourMatrix[, 'yourCol']), ] On Fri, Jan 21, 2011 at 2:38 PM, Francesco Petrogalli <francesco.petrogalli@gmail.com> wrote: > Hi, > is there a R function that order a matrix according to some criteria > based on the rows(or cols) of that matrix? > > For example, le...
2009 Apr 01
0
回复: R-help Digest, Vol 73, Issue 32
...thanks for pointing this out. cheers, vQ >     cheers, > >         Rolf Turner > > > On 30/03/2009, at 3:55 PM, Bert Gunter wrote: > >> If speed is a consideration,availing yourself of the built-in pmax() >> function via >> >> do.call(pmax,data.frame(yourMatrix)) >> >> will be considerably faster for large matrices. >> >> If you are puzzled by why this works, it is a useful exercise in R to >> figure >> it out. >> >> Hint:The man page for ?data.frame says: >> "A data frame is a list of variables o...
2008 Jun 06
6
Subsetting to unique values
I want to take the first row of each unique ID value from a data frame. For instance > ddTable <- data.frame(Id=c(1,1,2,2),name=c("Paul","Joe","Bob","Larry")) I want a dataset that is Id Name 1 Paul 2 Bob > unique(ddTable) Will give me all 4 rows, and > unique(ddTable$Id) Will give me c(1,2), but not accompanied by the name column.