similar to: Nearest neighbour in a matrix

Displaying 20 results from an estimated 600 matches similar to: "Nearest neighbour in a matrix"

2011 Sep 25
4
Trouble creating and adjacency matrix
Hello all, I'm having trouble creating an adjacency matrix. Basically, I need to turn the following distance matrix into an adjacency matrix based on whether values are >1.5 or not. If they are >1.5, then the returned value should be 0. If they are =<1.5, then the returned value should be 1. DistanceMatrix: A B C D E [1,]
2001 May 16
2
Strange formatting
I've never noticed this before, though it's probably not new. In 1.2.3 for Windows, if I print a short vector the formatting is different than if I print a long one, whether or not they fit on one line. The short/long split appears to be between 9 and 10 elements: > 1:9 [1] 1 2 3 4 5 6 7 8 9 > 1:10 [1] 1 2 3 4 5 6 7 8 9 10 > sqrt(1:9) [1] 1.000000 1.414214
2004 Aug 30
3
Multiple lapply get-around
I am faced with a situation wherein I have to use multiple lapply's. The pseudo-code could be approximated to something as below: For each X from i=1 to n For each Y based on j=1 to m For each F from 1 to f Do some calculation based on Fij Store Xi,Yj = Fij End For F End for Y End for X Is there anyway to optimize the processing logic further? I *guess* using the multiple lapply
2006 Aug 16
1
help about agnes
Hello. I have the following distance matrix between 8 points: [1,] 0.000000 3.162278 7.280110 8.544004 7.071068 9.899495 6.403124 8.062258 [2,] 3.162278 0.000000 5.000000 6.403124 4.472136 8.944272 6.082763 8.062258 [3,] 7.280110 5.000000 0.000000 1.414214 1.000000 5.000000 4.242641 5.830952 [4,] 8.544004 6.403124 1.414214 0.000000 2.236068 4.123106 4.472136 5.656854 [5,] 7.071068 4.472136
2008 Feb 19
1
rJava and matrices
Hi list, I'm wanting to use a matrix as input to some java code, but I seem to be unable to do this (See code below). When searching online for a solution I found that rJava 0.5-2 (the version under development not yet in CRAN) is adding "direct support for raw vectors as method parameters". Is this related? I also tried to use .jarray / .jcast in various combinations to no avail.
2006 Aug 02
1
unbalanced mixed effects models for fully factorial designs
Does anyone know of a way of dealing with unbalanced mixed effects (fixed and random factors) for fully factorial designs. An example of such data is given below; The response variable is SQRTRECRUITS SEASON is a random factor DENSITY is a fixed factor Thus DENSITY:SEASON is a fixed factor. Therefore, whereas the effects of SEASON and DENSITY:SEASON should be tested against the overall
2009 Nov 17
0
Re place NA values in matrix with the value of Nearest Neighbour
I am extracting climate data for coastal areas from 5km grid data for specific xy coordinates that relates to individual study sites (SQ). Code so far: setwd("/Users/roblewis/Documents/PhD/Climate Data") fnamestemp=read.table("Path_Directory_Maxt") fnames=paste(fnamestemp[,1],fnamestemp[,2]) nfiles = length(fnames) xy=as.matrix(read.table("xy_.txt"))
2003 Jan 30
2
nearest neighbour interpolation
Dear Help List, My name is Matt Oliver. I have been using R for about a year and find it very helpful. However, I have a need for a function that I cannot find. I am not very good at programming so I thought I would ask the group. I have an irregular grid of data (x = Longitude, y = Latitude). Each pair of my x,y has a categorical value. Obviously linear or any other numerically based
2011 Jan 20
1
Problems with ecodist
Dear Dr.Goslee and anyone may intrested in matrix manipulate, I am using your ecodist to do mantel and partial mantel test, I have locality data and shape variation data, and the two distance matrixs are given as belowings. When I run the analysis, it is always report that the matrix is not square, but I didn't know what's wrong with my data. Would you please help me on this. I am quite
2012 Jun 20
1
nearest neighbours and their ID
Dear R users, I used nndist() to gain the distance of 2 nearest neighbours of the points in my dataset. Is there a way of getting the ID numbers of these nearest neighbours (along with their distances). The command I used: nn2 <- nndist(X2, k=1:2). This is the output of the nearest neighbour distances I got (the IDs of the given points are there but their IDs aren't). Any help or
2011 Jan 04
5
Help with "For" instruction
Hi, I am having a problem in doing something similar to this example: Suppose I have this vector a, and from it I wish to create 5 other vector each one with less one value than what object a has So I have "a" a<-c(1,2,3,4,5) and I want a1 that shoud have (2,3,4,5) a2 that should have (1,3,4,5) a3 that should have (1,2,4,5) a4 that should have (1,2,3,5) a5 that should have
2008 Jan 25
1
How to execute R code
Hi, I have 'R' code in file. saved it as exmaple.r here is the code....... library("hopach") GSE <- read.table("gene_expression_data",sep="\t",header=TRUE,row.names=TRUE) gene.dist <- distancematrix(t(GSE),d="euclid") gene.hobj <- hopach(t(GSE), dmat=gene.dist, mss="med") labelstosil(gene.hobj$cluster$label,gene.dist) I dont
2009 Aug 10
4
problem selecting rows meeting a criterion
When I try to select only those rows from the following data frame, called "data", in which X > Y X Y V3 2 2 1 8.062258 3 3 1 2.236068 4 4 1 6.324555 5 5 1 5.000000 6 1 2 8.062258 8 3 2 9.486833 9 4 2 2.236068 10 5 2 5.656854 11 1 3 2.236068 12 2 3 9.486833 14 4 3 8.062258 15 5 3 5.099020 16 1 4 6.324555 17 2 4 2.236068 18 3 4 8.062258 20 5 4 5.385165 21 1 5 5.000000
2003 May 31
3
function to populate a matrix based on a lookup to another matrix ?
Hi, This is a beginner R question. I have a 4x4 matrix named 'lookup' with the following values: 1 2 3 4 1 0.000000 2.828427 5.656854 8.485281 2 2.828427 0.000000 2.828427 5.656854 3 5.656854 2.828427 0.000000 2.828427 4 8.485281 5.656854 2.828427 0.000000 I then create a new empty matrix named 'dd' with specfic row and col names :
2012 Feb 26
1
Matrix problem to extract animal associations
Dear List, I have been trying to extract associations from a matrix whereby individual locations are within a certain distance threshold from one another. I have been able to extract those individuals where there is 'no interaction' (i.e. where these individuals are not within a specified distance threshold from another individual) and give these individuals a unique Group ID containing
2016 Oct 21
3
anonymous function parsing bug?
Hi, thx for the reply. Unfortunately that is not a simplified version of the problem. You have a function, call it and get the result (numeric in, numeric out in that case). For simplicity lets use the "return" case: ## foobar<-function(x) { return(sqrt(x)) }(2) ## which is a function (numeric in, numeric out) which is defined, then gets called and the return value is a function
2011 Oct 10
1
Importing from Fortan
Hello all, how do I import a Fortran file (f3.1) into one column in R? I've tried this (I'm a total beginner as you can see): > FortranData<-read.fwf("C:\\Users\\format3_1.txt",rep(3,20)) Warning message: In readLines(file, n = thisblock) : incomplete final line found on 'C:\Users\format3_1.txt' > FortranData V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12
2004 Nov 09
1
gdist and gower distance
Dear All, I would like to ask clarifications on the gower distnce matrix calculated by the function gdistin the library mvpart. Here is a dummy example: > library(mvpart) Loading required package: survival Loading required package: splines mvpart package loaded: extends rpart to include multivariate and distance-based partitioning > x=matrix(1:6, byrow=T, ncol=2) > x [,1]
2009 Nov 20
3
help me avoid nested for() loops!
Hi R folks, I have a massive array (object name "points") in the following form [,1] [,2] [1,] 1369 22 [2,] 1370 22 [3,] 1368 23 [4,] 1369 23 [5,] 1370 23 [6,] 1371 23 (10080 rows truncated) These represent pixel coordinates of interest in a jpeg image. I need to find the distance from each point to all other points of interest. The only way I can see to do this
2004 Feb 25
0
k nearest neighbours between two matrix
I have two dataframes A and B consisting of latitude longitude coordinates of points. For each point in A I want to find the k-nearest neighbours in B. Currently, I calculate the distance from each point in A to all the points in B (using rdist.earth() in fields package), sort the points of B by distance and select the k nearest ones. Is there a more efficient way to do this? Function knearneigh