Displaying 20 results from an estimated 8000 matches similar to: "k nearest neighbours"
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
2004 Aug 22
1
latitude longitude data
Dear R-helpers,
I get GPS readings with bug counts (bugs meaning
insects in this case) made along rows in crop fields
and use these to make maps of bug distribution. The
GPS readings are not quite accurate enough for my
purpose, so since I know what row each reading is made
in, I adjust the latitudinal coordinate using:
grd<-lm(lat~lon+Row,data)
2010 Mar 09
1
create picture (k -the nearest neighbours)
Hi
I want to create a nice picture about my result of k -the nearest neighbours
algorithm. Here is my easy code:
#################################
library(klaR)
library(ipred)
library(mlbench)
data(PimaIndiansDiabetes2)
dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
dane[,2]=log(dane[,2])
dane[,1:2]=scale(dane[,1:2])
zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)
2004 Jun 22
1
k nearest neighbours
Hi there fellow R-users,
Does anyone know of a function which does exactly what knearneigh{spdep}
(finds the k nearest neighbours) does in the package spdep but for more than
2D data?
Regards
Wayne
KSS Ltd
Seventh Floor St James's Buildings 79 Oxford Street Manchester M1 6SS England
Company Registration Number 2800886
Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305
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
2009 Oct 30
1
Applying a function on n nearest neighbours
I'm having a problem where I have to apply a function to a subset of a
variable, where the subset is defined by the n nearest neighbours of a
second variable.
Here's an example applied to the 'iris' dataset:
$ head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4
2004 Feb 26
1
Distance and Aggregate Data - Again...
I appreciate the help I've been given so far. The issue I face is
that the data I'm working with has 53000 rows, so in calculating
distance, finding all recids that fall within 2km and summing the
population, etc. - a) takes too long and b) have no sense of progress.
Below is a loop that reads each recid one at a time, calculates the
distance and identifies the recids that fall within 2
2018 Dec 12
2
Subset dentro de un for
Gracias a los tres, Raúl, Marcelino y Carlos.
Lo del "get" de Marcelino me da la respuesta a lo que yo exactamente
preguntaba, y funciona, pero ahora tengo problemas con el for, por lo
que probablemente recurra al eval parse de Raúl o Carlos, que ya
tienen el for. Aún así, lo intento 1º con el get.
Con subset(df, subset=get(GT[i])>0) el problema es que en el for hago
un
2018 Dec 12
2
Subset dentro de un for
Gracias Marcelino. Si, (i in 1:length(GT)), lo he utilizado mil veces,
pero se me sigue olvidando de una vez a otra. Lo iba a mirar, pero me
centré primero en que me hiciera bien el mapa.
He probado el for y me da este error:
Error in aes(x = lon, y = lat, color = get(GT[i]), size = 2) +
scale_colour_gradient(low = ("white"), :
non-numeric argument to binary operator
2004 Jul 08
1
k nearest neighbor prediction
Hi there fellow R-users,
Does anyone know if there is a package for k nearest neighbours prediction
as opposed to classification? I have found the package knncat but can't see
a way to adjust it to predict a continuous variable.
Any help would be great,
Regards
Wayne Jones
KSS Ltd
Seventh Floor St James's Buildings 79 Oxford Street Manchester M1 6SS England
Company
2012 Oct 19
3
Newly installed version; can't run lm function
New installation seems to have behavior I cannot figure out. Here is illustrative sequence where I load a small data set (test) from Crawley's files and try to run a simple linear model and get an error message. Oddly, R reports that the variable 'test$ozone' is numeric while, after attaching test, the variable ozone is not numeric. Can someone please help? This behavior is
2013 Feb 13
1
[lattice] display a projected map on a layerplot
summary: I can display a lon-lat map on a lattice::layerplot, and I
can display a Lambert conformal conic (LCC) map on a spam::image, but
I can't display an LCC map on a lattice::layerplot. Example follows.
What am I doing wrong?
details:
I've been using `lattice` (via `rasterVis`) successfully to display
global atmospheric data, which works well enough (though I am
definitely intrigued
2011 Dec 23
2
cast in reshape and reshape2
> library(reshape2)
> x = melt(airquality, id=c('month', 'day'))
With reshape I can cast with multiple functions:
> library(reshape)
> cast(x, month+variable~., c(mean,sd))
month variable mean sd
1 5 ozone 23.615385 22.224449
2 5 solar.r 181.296296 115.075499
3 5 wind 11.622581 3.531450
4 5 temp 65.548387
2005 Jun 02
2
Adding a legend to a symbol plot
I have created a symbol plot with circles that represent the mean temperature
at lat/lon locations over the United States. The radius of the circle
corresponds to the mean temperature. I would like to add a legend that
identifies a range of temperatures (e.g. 0-10, 10-20, etc) with circles of the
appropriate radii next to them. I've read the manual on how to add a legend,
and I'm fine with
2013 Nov 04
1
Subject: Regress multiple independent variables on multiple dependent variables
I want to estimate the effect of several independent variables on several
dependent
variables. In the example below I wanted to estimate the
effect of three independent variables on ozone and temperature. My aim is
to create a list of dependent and independent variables and automate the
process rather than writing every dependent and independent variable in
each model as I have done below.
2008 Mar 24
2
Newbie help with Sweave
I think I've gotten my Emacs/Sweave/R system set up correctly, thanks to
Vincent and Jim, but I haven't been successful getting my first document
produced. I'm trying to use one of Friedrich Leisch's examples,
http://www.ci.tuwien.ac.at/~leisch/Sweave/example-1.Snw. I cut and
pasted the text into a document sweaveexample.Rnw in Emacs. It seemed to
be processed successfully with R:
2007 Sep 16
1
Identifying objects from a data set
Hello
Given the following data for a data set called airquality. To identify the nature of the objects from the data set airquality example "Ozone" would it be best to use the command is. like is.character(airquality$Ozone) ....... I tried attributes(airquality$Ozone) but it came up null. Would there be a better way to identify these objects.
Thanking you in advance for your
2004 Apr 04
1
How to improve this code?
Hi all,
I've got some functioning code that I've literally taken hours to
write. My 'R' coding is getting better...it used to take days :)
I know I've done a poor job of optimizing the code. In addition, I'm
missing an important step and don't know where to put it.
So, three questions:
1) I'd like the resulting output to be sorted on distance (ascending)
and
2013 Feb 17
3
Select components of a list
Hi Gustav,
Try this:
lapply(1:length(models),function(i) lapply(models[[i]],function(x) summary(x)$coef[2,]))[[1]] #1st list component
[[1]]
#??? Estimate?? Std. Error????? z value???? Pr(>|z|) # pm10
#5.999185e-04 1.486195e-04 4.036606e+00 5.423004e-05
#[[2]]
#??? Estimate?? Std. Error????? z value???? Pr(>|z|) #ozone
#0.0010117294 0.0003792739 2.6675428048 0.0076408155
#[[3]]
#???
2017 Jun 26
2
Odd behaviour in within.list() when deleting 2+ variables
>>>>> peter dalgaard <pdalgd at gmail.com>
>>>>> on Mon, 26 Jun 2017 13:43:28 +0200 writes:
> This seems to be due to changes made by Martin Maechler in
> 2008. Presumably this fixed something, but it escapes my
> memory.
Yes: The change set (svn -c46441) also contains the following NEWS entry
BUG FIXES
o