Q:

Extracting values of one point dataset to second point dataset based on proximity using R or ArcGIS Desktop?

I have to point shapefiles and would like to extract values from one point shapefile to another one based on some measure of proximity, i.e. for any given point in dataset x, extract the mean value for all points in dataset y within a 10km radius of the given point in dataset x.  Or, for any given point in x, extract the value of the closest point in y and add to x.  
I'm familiar with extract function in r to extract raster values to point. Not sure if sample data would help in this one, but would like to do this in r, or failing that, ArcGIS Desktop.

A:

R solution is rather straightforward:
# needs rgeos library
library(rgeos)

### create sample data
df1 <- data.frame(x=runif(100), y=runif(100), id=1:100)
df2 <- data.frame(x=runif(200), y=runif(200), value=runif(200,min=10,max=100))

coordinates(df1) <- ~x+y
coordinates(df2) <- ~x+y

### value of closest point:
# find closest point in second layer
closest <- apply(gDistance(df1, df2, byid=T), MARGIN=2, FUN=which.min)
# set the value
df1$closest_value <- df2$value[closest]

### mean value in radius
mv <- rep(NA, length(df1))
# for every point, create buffer and calculate mean from points inside the buffer
for (i in 1:length(df1)){
  bf <- gBuffer(df1[i,], width=0.1)
  mv[i] <- mean(df2$value[gCoveredBy(df2, bf, byid=T)])
}
# set values
df1$mean_near <- mv

