similar to: print matrix values and if statement

Displaying 20 results from an estimated 30000 matches similar to: "print matrix values and if statement"

2011 Dec 21
1
Gps fraction of degrees function
Dear all,   I have the following written example > coords <- "51°30'48.58\"N" > > as.integer(strsplit(coords, "°")[[1]][1]) [1] 51 > as.integer(strsplit(strsplit(coords, "°")[[1]][2], "'")[[1]][1]) [1] 30 > as.numeric(strsplit(strsplit(strsplit(coords, "°")[[1]][2], "'")[[1]][2],
2005 Dec 19
1
How to draw partial grid in plot for spatial-binomial experiment?
DeaR comRades: I have a 2D spatial binomial process as shown in the data and code below. I am plotting the number of trials and the number of successes in the spatial binomial experiments and would like to draw the spatial cells were the trials and successes were counted, i.e. a partial grid in the plot only for those cells where there is a number. The cells are 2x2 km cells. The count of Trials
2006 Jun 15
1
Compact sums in functions definitions
I'm trying to make more compact the definition of a function as for example: f <- function(x) 2/x+3/x by simply defining the array of coefficients arr = c(2,3) and setting: g <- function(x) sum((arr/x)) Everything seems to work fine because the values returned by f and g result coincident for different values of their argument, but when I try to plot the function g using: x =
2008 Jul 07
5
Basic Vector and Matrix Operations
I am wondering if it is possible to perform the following two basic functions with primitive R functions. I know I could write functions for either, but it seems as though they are probably built-in somewhere. 1) Fill out a vector to a desired length with missing values or zeros. So, x<-c(3,4,5) f(x,5) 3,4,5,NA,NA 2) Find the [row,col] location of a particular value in a matrix, eg
2008 Jun 11
3
Finding Coordinate of Max/Min Value in a Data Frame
Hi, Suppose I have the following data frame. __BEGIN__ > library(MASS) > data(crabs) > crab.pca <- prcomp(crabs[,4:8],retx=TRUE) > crab.pca$rotation PC1 PC2 PC3 PC4 PC5 FL 0.2889810 0.3232500 -0.5071698 0.7342907 0.1248816 RW 0.1972824 0.8647159 0.4141356 -0.1483092 -0.1408623 CL 0.5993986 -0.1982263 -0.1753299 -0.1435941 -0.7416656 CW
2003 Aug 12
4
print points from a huge matrix
Hi All, I have a 8000*8000 matrix and I want to print out a file with the row name, column name and the value for those point with values satisfying a condition. I tried using a for loop, however, it took me forever to get the result. Is there a fast way to do this? Thanks! Bing --------------------------------- 1060 Commerce Park Oak Ridge National Laboratory P.O. Box 2008, MS 6480 Oak
2004 Oct 09
2
which() and value replacement in a matrix
Hi, I cannot go through the archives with which() as key-word... so common. Though I am sure to have seen something about this subject in the past could somebody put me on the track. I have a matrix (actually a data.frame) in which I would replace the non-null values by 1. I tried the following: indices<-which(myforetbin > 0,arr.ind=T) myforetbin[indices[,1],indices[,2]]<-1 and get
2008 Jun 11
4
Matrix transformation problem
ng, I have a matrix (x) with binary content. Each row of the matrix holds exactly one 1, and the rest of the row is zeros. The thing is that I need to 'collapse' the matrix to one column where each row holds the original column index of the 1's (y). Sometimes, the matrix is quite large, so I have a perfomance problem. x <- matrix(c(1,0,0, 0,0,1, 0,1,0, 0,0,1, 0,1,0,
2010 Oct 05
4
Linear Integration
Hello I would like to calculate a weighted line integral. The integral is calculated by the cells that this lines trasverses (the small cells belong to matrix (m*n) that represent the value that a specific area has. I need to calculate the weights by finding out how much the line touches or impinges inside a cell. The weight is less if a line just touches one of the four edges of a square
2007 Dec 12
2
problem applying a conditional formula to each element of a matrix
I'm applying a function (Cov.f) defined below to each element of a distance matrix. When I run the code below, I get a warning message (below) and elements of returned matrix [2,3] and [3,2] are not zero as I would expect. Clearly, there is an error... What am I doing wrong? Thanks. --Dale Warning message: In if (h <= phi) { : the condition has length > 1 and only the first element
2013 Feb 14
2
Plot a Matrix as an Image with ggplot
Dear all, I am trying to plot a matrix I have? as an image str(matrixToPlot) ?num [1:21, 1:66] 0 0 0 0 0 0 0 0 0 0 . ?that contains only 0s and 1s, where the xlabel will be Labeled as str(xLabel) ?num [1:66] 1e+09 1e+09 1e+09 1e+09 1e+09 ... and the yLabels will be labeled as str(yLabel) ?num [1:21] -88 -87 -86 -85 -84 -83 -82 -81 -80 -79 ... I have found on the internet that I can do
2018 Feb 06
1
gdistance::shortestPath throws error "not a symmetric matrix"
Hi, Calling gdistance::shortestPath gives me the error Error in asMethod(object) : not a symmetric matrix; consider forceSymmetric() or symmpart() The output of dput(.traceback()) is pairlist("stop(\"not a symmetric matrix; consider forceSymmetric() or symmpart()\")", "asMethod(object)", "as(Laplacian,\"symmetricMatrix\")",
2011 Apr 29
1
matrix evaluation using if function
Hi All, I am trying to create a function which evaluates whether the values (which are equal to one) of a matrix are the same as their mirror values. Consider the following matrix: > n<-matrix(cbind(c(0,1,1),c(1,0,0),c(0,1,0)),3,3) > colnames(n)<-cbind("A","B","C");rownames(n)<-cbind("A","B","C") > n A B C A 0 1 0 B
2011 Apr 11
1
Mclapply and print statement
Dear all. I am using the mclapply function to split my code to the many cores my system has. It seems that is working fine. This is the parallel version of lcapply. The only problem that I seem to have is that the printf cannot print messages. The ideal to me is to have fro my function an output of the form Shadowlist<-mclapply(1:dimz, function(i) { print(sprintf('Creating the
2005 Apr 15
1
treatment of zero and negative elements in matrix indices
Matrix indexing seems to give rather "variable" results when zeros or negative values are included among the indices (in terms of both error messages and in terms of the number of returned values when there is no error message). Is this the intended behavior? I couldn't see any comments about zeros or negative values in matrix indices in either ?"[" or Section 3.4.2
2008 May 28
2
Unexpected behaviour in reading genomic coordinate files of R-2.7.0
Great R people, I have noticed a strange behaviour in read.delim() and friends in the R 2.7.0 version. I will describe you the problem and also the solution I already found, just to be sure it is an expected behaviour and also to tell people, who may experience the same difficulty, a way to overcome it. And also to see if it is a proper behaviour or maybe a correction is needed. Here is the
2003 Apr 28
2
sum(..., na.rm=TRUE) oddity
Hi all, I get two different results when using sum() and the switch na.rm. The result is correct when na.rm=FALSE. Linux Redhat 7.3, R version 1.6.1. I've had no luck searching the mail archives, so I was hoping somebody could explain/check this one for me. I will need to apply the function to missing data, simple as it is. Code: x<-matrix(runif(20,0,5)%/%1,4,5) # random matrix
2006 Jun 04
4
xy.coords(MATRIX) bug in code or documentation (PR#8937)
Hi, people. xy.coords() does not behave like its documentation says, when given some matrices. ?xy.coords says: If 'y' is 'NULL' and 'x' is a [...] formula [...] list [...] time series [...] matrix with two columns [...] In any other case, the 'x' argument is coerced to a vector and returned as *y* component [...] Now, consider this short
2006 Nov 03
3
identify extremes positions of values into matrix
Um texto embutido e sem conjunto de caracteres especificado associado... Nome: n?o dispon?vel Url: https://stat.ethz.ch/pipermail/r-help/attachments/20061103/39e6883b/attachment.pl
2011 Jan 26
0
Fwd: MAtrix addressing
Begin forwarded message: > From: David Winsemius <dwinsemius at comcast.net> > Date: January 26, 2011 8:32:30 AM EST > To: Alaios <alaios at yahoo.com> > Subject: Re: [R] MAtrix addressing > > > On Jan 26, 2011, at 7:58 AM, Alaios wrote: > >> Unfortunately right now is convoluted... by I was trying to find >> some solution. >> Bring again