Re: [R] Help with ggplot error: #Error in FUN(X[[i]], ...) : object 'x' not found

2020-05-19 Thread Poling, William via R-help
Hello Chris, and thank you for your response.
I tried it both TRUE and FALSE given my confusion with the reference I found 
that idea in.

It did not help either way.

Glad you noticed though, thank you.

WHP

William H. Poling Ph.D., MPH  | Senior Data Scientist, Medicare Stars, CVS 
Health 
p 813-777-5030


Proprietary

-Original Message-
From: Chris Evans  
Sent: Tuesday, May 19, 2020 9:08 AM
To: Poling, William 
Cc: Ben Tupper ; r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with ggplot error: #Error in FUN(X[[i]], ...) 
: object 'x' not found

 External Email - Use Caution 



- Original Message -
> From: "Poling, William via R-help" 
> To: "Ben Tupper" 
> Cc: r-help@r-project.org
> Sent: Tuesday, 19 May, 2020 15:04:25
> Subject: Re: [R] Help with ggplot error: #Error in FUN(X[[i]], ...) : 
> object 'x' not found

> Hello Ben and thank you for your response.
> 
> I thought that was what I was doing when I ran this version:
> Test1
> p <- ggplot(c1members2, aes(x,y)) +
>  geom_point()
> 
> p +  geom_line(data = paths, aes(group = trip_id),inherit.aes = FALSE) 
> + #Error in FUN(X[[i]], ...) : object 'x' not found  
> ggtitle(paste0("Optimal route with cost: ", 
> round(objective_value(result), 2)))
> 
> Is this not what you mean?


I'm no expert but isn't "inherit.aes = FALSE" the culprit?  I think that means 
that that line only has a group for the aesthetic as you've turned off 
inheritance of the x and y mapping in the earlier aes().  That would seem to 
fit with the error message.

No time to try it all out but thought I'd throw this in.

Good luck (all!)

Chris

> 
> str(p)
> List of 9
> $ data   :'data.frame':   7 obs. of  3 variables:
>  ..$ id: int [1:7] 1 2 3 4 5 6 7
>  ..$ x : num [1:7] 95.5 90.2 46.8 40.9 43.3 ...
>  ..$ y : num [1:7] 4.65 47.57 8.07 38.43 28.59 ...
> $ layers :List of 1
>  ..$ :Classes 'LayerInstance', 'Layer', 'ggproto', 'gg'  object: Class  LayerInstance, Layer, gg>
>aes_params: list
>compute_aesthetics: function
>compute_geom_1: function
>compute_geom_2: function
>compute_position: function
>compute_statistic: function
>data: waiver
>draw_geom: function
>finish_statistics: function
>geom: 
>aesthetics: function
>default_aes: uneval
>draw_group: function
>draw_key: function
>draw_layer: function
>draw_panel: function
>extra_params: na.rm
>handle_na: function
>non_missing_aes: size shape colour
>optional_aes:
>parameters: function
>required_aes: x y
>setup_data: function
>setup_params: function
>use_defaults: function
>super:  
>geom_params: list
>inherit.aes: TRUE
>layer_data: function
>map_statistic: function
>mapping: NULL
>position: 
>compute_layer: function
>compute_panel: function
>required_aes:
>setup_data: function
>setup_params: function
>super:  
>print: function
>setup_layer: function
>show.legend: NA
>stat: 
>aesthetics: function
>compute_group: function
>compute_layer: function
>compute_panel: function
>default_aes: uneval
>extra_params: na.rm
>finish_layer: function
>non_missing_aes:
>parameters: function
>required_aes:
>retransform: TRUE
>setup_data: function
>setup_params: function
>super:  
>stat_params: list
>super:  
> $ scales :Classes 'ScalesList', 'ggproto', 'gg'  ScalesList, gg>
>add: function
>clone: function
>find: function
>get_scales: function
>has_scale: function
>input: function
>n: function
>non_position_scales: function
>scales: list
>super:  
> $ mapping:List of 2
>  ..$ x: language ~x
>  .. ..- attr(*, ".Environment")=  ..$ y: 
> language ~y  .. ..- attr(*, ".Environment")=
>  ..- attr(*, "class")= chr "uneval"
> $ theme  : list()
> $ coordinates:Classes 'CoordCartesian', 'Coord', 'ggproto', 'gg' 
>  object: Class CoordCartesian, Coord, gg>
>aspect: function
>backtransform_range: function
>clip: on
>default: TRUE
>distance: function
>expand: TRUE
>is_free: function
>is_linear: function
>labels: function
>limits: list
>modify_scales: fun

Re: [R] Help with ggplot error: #Error in FUN(X[[i]], ...) : object 'x' not found

2020-05-19 Thread Poling, William via R-help

Hello Ben and thank you for your response.

I thought that was what I was doing when I ran this version:
Test1
p <- ggplot(c1members2, aes(x,y)) + 
  geom_point() 

p +  geom_line(data = paths, aes(group = trip_id),inherit.aes = FALSE) + #Error 
in FUN(X[[i]], ...) : object 'x' not found
  ggtitle(paste0("Optimal route with cost: ", round(objective_value(result), 
2)))

Is this not what you mean?  

str(p)
List of 9
 $ data   :'data.frame':7 obs. of  3 variables:
  ..$ id: int [1:7] 1 2 3 4 5 6 7
  ..$ x : num [1:7] 95.5 90.2 46.8 40.9 43.3 ...
  ..$ y : num [1:7] 4.65 47.57 8.07 38.43 28.59 ...
 $ layers :List of 1
  ..$ :Classes 'LayerInstance', 'Layer', 'ggproto', 'gg' 
aes_params: list
compute_aesthetics: function
compute_geom_1: function
compute_geom_2: function
compute_position: function
compute_statistic: function
data: waiver
draw_geom: function
finish_statistics: function
geom: 
aesthetics: function
default_aes: uneval
draw_group: function
draw_key: function
draw_layer: function
draw_panel: function
extra_params: na.rm
handle_na: function
non_missing_aes: size shape colour
optional_aes: 
parameters: function
required_aes: x y
setup_data: function
setup_params: function
use_defaults: function
super:  
geom_params: list
inherit.aes: TRUE
layer_data: function
map_statistic: function
mapping: NULL
position: 
compute_layer: function
compute_panel: function
required_aes: 
setup_data: function
setup_params: function
super:  
print: function
setup_layer: function
show.legend: NA
stat: 
aesthetics: function
compute_group: function
compute_layer: function
compute_panel: function
default_aes: uneval
extra_params: na.rm
finish_layer: function
non_missing_aes: 
parameters: function
required_aes: 
retransform: TRUE
setup_data: function
setup_params: function
super:  
stat_params: list
super:   
 $ scales :Classes 'ScalesList', 'ggproto', 'gg' 
add: function
clone: function
find: function
get_scales: function
has_scale: function
input: function
n: function
non_position_scales: function
scales: list
super:   
 $ mapping:List of 2
  ..$ x: language ~x
  .. ..- attr(*, ".Environment")= 
  ..$ y: language ~y
  .. ..- attr(*, ".Environment")= 
  ..- attr(*, "class")= chr "uneval"
 $ theme  : list()
 $ coordinates:Classes 'CoordCartesian', 'Coord', 'ggproto', 'gg' 
aspect: function
backtransform_range: function
clip: on
default: TRUE
distance: function
expand: TRUE
is_free: function
is_linear: function
labels: function
limits: list
modify_scales: function
range: function
render_axis_h: function
render_axis_v: function
render_bg: function
render_fg: function
setup_data: function
setup_layout: function
setup_panel_guides: function
setup_panel_params: function
setup_params: function
train_panel_guides: function
transform: function
super:   
 $ facet  :Classes 'FacetNull', 'Facet', 'ggproto', 'gg' 
compute_layout: function
draw_back: function
draw_front: function
draw_labels: function
draw_panels: function
finish_data: function
init_scales: function
map_data: function
params: list
setup_data: function
setup_params: function
shrink: TRUE
train_scales: function
vars: function
super:   
 $ plot_env   : 
 $ labels :List of 2
  ..$ x: chr "x"
  ..$ y: chr "y"
 - attr(*, "class")= chr [1:2] "gg" "ggplot"














From: Ben Tupper  
Sent: Tuesday, May 19, 2020 7:46 AM
To: Poling, William 
Cc: r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with ggplot error: #Error in FUN(X[[i]], ...) 
: object 'x' not found

 External Email - Use Caution 
Hi,

When you add a new layer to a plot and you provide new data, wouldn't it make 
sense to provide aes() with some indication of the names of the variables to 
use for coordinate plotting?  You have provided a grouping variable for the 
paths, but what of coordinates x and y?  How could geom_path() know that your 
lon/lat variables are to be used as x and y coordinates in the plot? 

Cheers,
Ben



On Tue, May 19, 2020 at 8:29 AM Poling, William via R-help 
<mailto:r-help@r-project.org> wrote:
#RStudio Version Version 1.2.1335 
sessionInfo() 
# R version 4.0.0 P

[R] Help with ggplot error: #Error in FUN(X[[i]], ...) : object 'x' not found

2020-05-19 Thread Poling, William via R-help
#RStudio Version Version 1.2.1335 
sessionInfo() 
# R version 4.0.0 Patched (2020-05-03 r78349)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows 10 x64 (build 17763)

Good morning.

I am testing a small sample of my data using an example found here:
#https://www.r-orms.org/mixed-integer-linear-programming/practicals/problem-tsp/

If needed I can provide my complete script which is simply the same as the 
example only using a few rows from my data, let me know, as I think this is 
just a ggplot issue.

I am getting this error when I use ggplot
#Error in FUN(X[[i]], ...) : object 'x' not found

1. I have reviewed the following with no success.
#Sources referred to for help
#https://github.com/business-science/anomalize/issues/2
#https://stackoverflow.com/questions/38988028/error-in-funxi-object-x-not-found
#https://community.rstudio.com/t/error-in-fun-x-i-object-variable-not-found/62532/3
#https://www.neonscience.org/packages-in-r

2. I have rebooted and re-installed ggplot2 for updates

3. These are the only libraries running
library(knitr)
library(dplyr)
library(ggplot2)
library(ggmap)
library(ompr)
library(ompr.roi)
library(ROI.plugin.glpk)   

Here is the original plot attempt:
ggplot(c1members2, aes(x , y)) + 
  geom_point() + 
  geom_line(data = paths, aes(group = trip_id)) + #Error in FUN(X[[i]], ...) : 
object 'x' not found
  ggtitle(paste0("Optimal route with cost: ", round(objective_value(result), 
2)))

#I have gone through each of the steps one by one and error occurs at --> 
geom_line(data = paths, aes(group = trip_id))

I have also tried the following:
Test1
p <- ggplot(c1members2, aes(x,y)) + 
  geom_point() 

p +  geom_line(data = paths, aes(group = trip_id),inherit.aes = FALSE) + #Error 
in FUN(X[[i]], ...) : object 'x' not found
  ggtitle(paste0("Optimal route with cost: ", round(objective_value(result), 
2)))

Test2
ggplot(c1members2, aes(x,y)) + 
  geom_point() +
geom_line(data = paths, aes(group = trip_id),inherit.aes = TRUE) + #Error in 
FUN(X[[i]], ...) : object 'x' not found
  ggtitle(paste0("Optimal route with cost: ", round(objective_value(result), 
2)))

Here are the data involved.
str(c1members2)
'data.frame':   7 obs. of  3 variables:
 $ id: int  1 2 3 4 5 6 7
 $ x : num  95.5 90.2 46.8 40.9 43.3 ...
 $ y : num  4.65 47.57 8.07 38.43 28.59 ...

str(paths)
data.frame':14 obs. of  6 variables:
 $ trip_id  : int  1 2 3 4 5 6 7 1 2 3 ...
 $ property : chr  "from" "from" "from" "from" ...
 $ idx_val  : int  3 1 5 7 6 4 2 1 2 3 ...
 $ Longitude: num  -122 -122 -122 -122 -122 ...
 $ Latitude : num  47.3 47.2 47.3 47.6 47.6 ...
 $ city : Factor w/ 1337 levels "ABBOTTSTOWN",..: 1169 1169 1169 1069 1069 
1069 1069 1169 1069 1169 ...

Here are the dput()'s

I hope I have provided enough information to elicit a response.

Thank you.

WHP

dput(c1members2)
structure(list(id = 1:7, x = c(95.521828085515, 90.2272877161736, 
46.8465689660691, 40.8959155605829, 43.2591531526978, 23.7485886058345, 
64.0406297698986), y = c(4.64803485876031, 47.5678629996171, 
8.0689847051367, 38.4256264258875, 28.5930051512296, 43.5934562642672, 
42.415566619041)), class = "data.frame", row.names = c(NA, -7L

dput(paths) #Although I am only using city %in% c("SEATTLE","TACOMA")) from the 
original 2353 rows = 7 rows in c1members2
structure(list(trip_id = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 
3L, 4L, 5L, 6L, 7L), property = c("from", "from", "from", "from", 
"from", "from", "from", "to", "to", "to", "to", "to", "to", "to"
), idx_val = c(3L, 1L, 5L, 7L, 6L, 4L, 2L, 1L, 2L, 3L, 4L, 5L, 
6L, 7L), Longitude = c(-122.490417, -122.429323, -122.358115, 
-122.37003, -122.41282, -122.299261, -122.390815, -122.429323, 
-122.390815, -122.490417, -122.299261, -122.358115, -122.41282, 
-122.37003), Latitude = c(47.274599, 47.176596, 47.276776, 47.565667, 
47.646222, 47.673056, 47.549377, 47.176596, 47.549377, 47.274599, 
47.673056, 47.276776, 47.646222, 47.565667), city = structure(c(1169L, 
1169L, 1169L, 1069L, 1069L, 1069L, 1069L, 1169L, 1069L, 1169L, 
1069L, 1169L, 1069L, 1069L), .Label = c("ABBOTTSTOWN", "ABILENE", 
"ACWORTH", "ADAMS", "ADDISON", "ADKINS", "ALBANY", "ALBIA", "ALBUQUERQUE", 
"ALEXANDRIA", "ALFRED", "ALIQUIPPA", "ALISO VIEJO", "ALLEN PARK", 
"ALLENTOWN", "ALPHA", "ALPHARETTA", "ALPINE", "ALTOONA", "AMARILLO", 
"AMBLER", "AMBRIDGE", "AMHERST", "AMITYVILLE", "ANAHIEM", "ANDERSON", 
"ANDOVER", "ANGIER", "ANGLETON", "ANKENY", "ANN ARBOR", "ANZA", 
"APEX", "APOLLO", "ARCADIA", "ARCHDALE", "ARDMORE", "ARGYLE", 
"ARKANSAS CITY", "ARLINGTON", "ARNOLD", "ARTHUR", "ASHEBORO", 
"ASHEVILLE", "ASHLAND", "ASHLAND CITY", "ASHTON", "ASTON", "ATHENS", 
"ATLANTA", "ATLANTIC BCH", "AUBORN", "AUGUSTA", "AURORA", "AUSTELL", 
"AUSTIN", "AVENTURA", "AVONDALE ESTATES", "BAKERSFIELD", "BALDWIN CITY", 
"BALDWIN PLACE", "BALLWIN", "BANGOR", "BARBOURSVILLE", "BARNEGAT", 
"BARTLETT", "BARTON", "BARTONVILLE", "BASSETT", "BATAVIA", "BATESBURG", 
"BATON ROUGE", "BAXTER SPRINGS", "BAY CITY", "BAYONNE", "BAYSIDE", 

Re: [R] Help with spTransform() function and final plot colors

2020-05-18 Thread Poling, William via R-help
Thank you Ege, I appreciate your response.

I have move this to r-sig-geo.

WHP

Proprietary

-Original Message-
From: Ege Rubak  
Sent: Monday, May 18, 2020 6:41 AM
To: Poling, William ; r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with spTransform() function and final plot 
colors

 External Email - Use Caution 

You are more likely to get help with specific problems related to
spTransform() on the dedicated list r-sig-geo.

You should provide a minimal reproducible example. Your code refers to e.g. the 
object `tmp1b`, which we don't have. I think the spTransform() part will work 
with this correction:

xy <- SpatialPointsDataFrame(sample[,2:3], sample[,1,drop=FALSE],
 proj4string=CRS("+proj=longlat
+ellps=WGS84 +datum=WGS84"))

xy <- spTransform(xy, CRS("+init=epsg:27700 +datum=WGS84"))

The spatial workflow in R has largely moved to the `sf` package and you are 
probably better off using that in the future if you are new in the game anyway.

Hope this helps,
Ege

On Sun, 2020-05-17 at 09:50 +0000, Poling, William via R-help wrote:
> #RStudio Version Version 1.2.1335
> sessionInfo()
> # R version 4.0.0 Patched (2020-05-03 r78349)
> #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 10 
> x64 (build 17763)
> 
> Hello. I am running my data through a routine I found that finds 
> clusters of data points based on distance rule.
> 
https://urldefense.proofpoint.com/v2/url?u=https-3A__gis.stackexchange.com_questions_64392_finding-2Dclusters-2Dof-2Dpoints-2Dbased-2Ddistance-2Drule-2Dusing-2Dr&d=DwIGaQ&c=wluqKIiwffOpZ6k5sqMWMBOn0vyYnlulRJmmvOXCFpM&r=j7MrcIQm2xjHa8v-2mTpmTCtKvneM2ExlYvnUWbsByY&m=sFygsSovnYNWjYOpjSzuSLI1MUrJN8Lih39pDQN98xI&s=2FCT-JBdWSB66pNvGLTM7Ec5Q7IbXatXBLsQqYT0gng&e=
 
> 
> 1. I get this error when I get to this point in the routine, see 
> complete routine below?
> xy <- spTransform(xy, CRS("+init=epsg:27700 +datum=WGS84")) non finite 
> transformation detected:
> 
> I tried converting columns from numeric to Integer but did not help.
> 
> However, I continue to run the rest of the routine and the final 
> sequence, the plot itself, seems to work Can this error be corrected 
> somehow, despite the fact that it continues to work, just curious what 
> it is I guess"
> 
> 2. However in the plot at the end of the routine the color key appears 
> with the colors but the clusters in the plot are black, see plot call 
> at the end of the routine below?
> 
> Thank you for any advice.
> 
> WHP
> 
> ERROR:
> non finite transformation detected:
>   coords.x1 coords.x2
>  [1,] -119.7339  39.53939 Inf Inf
>  [2,] -119.7665  39.39630 Inf Inf
>  [3,] -119.7794  39.28768 Inf Inf
>  [4,] -121.0234  39.20503 Inf Inf
>  [5,] -122.0047  47.19262 Inf Inf
>  [6,] -122.0135  47.18883 Inf Inf
>  [7,] -122.0379  47.52190 Inf Inf
>  [8,] -122.0578  47.60975 Inf Inf
>  [9,] -122.1330  47.13669 Inf Inf
> [10,] -122.1509  47.55962 Inf Inf
> [11,] -122.1706  47.15546 Inf Inf
> [12,] -122.1846  47.23485 Inf Inf
> [13,] -122.1846  48.15307 Inf Inf
> [14,] -122.1851  47.44870 Inf Inf
> [15,] -122.1954  47.68485 Inf Inf
> [16,] -122.1990  47.51610 Inf Inf
> [17,] -122.2014  47.44772 Inf Inf
> [18,] -122.2025  47.69815 Inf Inf
> [19,] -122.2037  47.67190 Inf Inf
> [20,] -122.2090  47.40378 Inf Inf
> [21,] -122.2108  47.25336 Inf Inf
> [22,] -122.2291  47.63880 Inf Inf
> [23,] -122.2419  47.76870 Inf Inf
> [24,] -122.2722  48.04803 Inf Inf
> [25,] -122.2732  47.87700 Inf Inf
> [26,] -122.2804  47.77620 Inf Inf
> [27,] -122.2839  47.82103 Inf Inf
> [28,] -122.2890  47.86899 Inf Inf
> [29,] -122.2993  47.67306 Inf Inf
> [30,] -122.3180  47.38217 Inf Inf
> [31,] -122.3270  47.40378 Inf Inf
> [32,] -122.3474  47.43884 Inf Inf
> [33,] -122.3484  47.53083 Inf Inf
> [34,] -122.3581  47.27678 Inf Inf
> [35,] -122.3618  47.76735 Inf Inf
> [36,] -122.3700  47.56567 Inf Inf
> [37,] -122.3908  47.54938 Inf Inf
> [38,] -122.4128  47.64622 Inf Inf
> [39,] -122.4293  47.17660 Inf Inf
> [40,] -122.4621  47.44505 Inf Inf
> [41,] -122.4904  47.27460 Inf Inf
> [42,] -122.5515  46.93979 Inf Inf
> [43,] -122.7348  42.37320 Inf Inf
> [44,] -122.7827  47.31059 Inf Inf
> [45,] -122.7987  47.23475 Inf Inf
> [46,] -122.8385  42.35119 Inf Inf
> [47,] -122.8537  42.34495 Inf Inf
> [48,] -122.8904  42.39555 Inf Inf
> [49,] -122.8927  42.33022 Inf Inf
> [50,] -122.9451  47.37574 Inf Inf
> [51,] -122.9594  42.30376 Inf Inf
> [52,] -123.0641  47.16428 Inf Inf
> [53,] -123.3413  42.44117 Inf Inf
> Error in spTransform(xSP, CRSobj, ...) : 
>   failure in points
> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:
> 

Re: [R] Help with spTransform() function and final plot colors

2020-05-17 Thread Poling, William via R-help
Hello again.

I also found this discussion on non-finite transformation error, however, I am 
not sure what to look for in the output after I apply my data?

https://stackoverflow.com/questions/14880294/non-finite-transformation-detected-in-sptransform-in-rgdal-r-package


str(sample)
GPS.Points <- sample[,c(2,3)]

n_chunks <- 3 #number of pieces you will break you data into
n.points <- dim(GPS.Points)[1]
breaks <- seq(1,n.points, by=round(n.points/n_chunks))
breaks <- c(breaks, n.points) #make sure to include last points as well

i=1
for (i in 1:(length(breaks)-1)){
  cat('\n','converting points', breaks[i], "to", breaks[i+1])  
  temp.GPS.Points=GPS.Points[breaks[i]:breaks[i+1],]
  temp.GPS.Points.Spatial.Data <- SpatialPoints(temp.GPS.Points, 
proj4string=CRS("+proj=longlat 
+ellps=WGS84"))
  temp.GPS.Points.UTM.Spatial.Data <- spTransform(temp.GPS.Points.Spatial.Data,
  CRS("+proj=utm +south 
+zone=34 
+ellps=WGS84"))
}

Thank you for any advice.

WHP

Proprietary

-Original Message-
From: Poling, William  
Sent: Sunday, May 17, 2020 5:20 AM
To: r-help@r-project.org
Cc: Poling, William 
Subject: RE: Help with spTransform() function and final plot colors

Hello, I have found an additional problem.

I should be getting 3 columns back in the xy@data at some point.
$ ID   : int  1 2 3 4 5 6 7 8 9 10 ...
# $ Clust  : int  1 1 1 1 1 1 1 1 1 1 ... This is always - 1
# $ Clust.1   : int  1 1 1 1 1 1 1 1 1 1 ... This would be the 
cluster number, like 1-3, I am not getting this column back?


Yet the plot runs and indicates three different clusters?



WHP


Proprietary

-Original Message-
From: Poling, William  
Sent: Sunday, May 17, 2020 4:50 AM
To: r-help@r-project.org
Cc: Poling, William 
Subject: Help with spTransform() function and final plot colors

#RStudio Version Version 1.2.1335
sessionInfo()
# R version 4.0.0 Patched (2020-05-03 r78349)
#Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 10 x64 
(build 17763)

Hello. I am running my data through a routine I found that finds clusters of 
data points based on distance rule.
https://gis.stackexchange.com/questions/64392/finding-clusters-of-points-based-distance-rule-using-r

1. I get this error when I get to this point in the routine, see complete 
routine below?
xy <- spTransform(xy, CRS("+init=epsg:27700 +datum=WGS84")) non finite 
transformation detected:

I tried converting columns from numeric to Integer but did not help.

However, I continue to run the rest of the routine and the final sequence, the 
plot itself, seems to work Can this error be corrected somehow, despite the 
fact that it continues to work, just curious what it is I guess"

2. However in the plot at the end of the routine the color key appears with the 
colors but the clusters in the plot are black, see plot call at the end of the 
routine below?

Thank you for any advice.

WHP

ERROR:
non finite transformation detected:
  coords.x1 coords.x2
 [1,] -119.7339  39.53939 Inf Inf
 [2,] -119.7665  39.39630 Inf Inf
 [3,] -119.7794  39.28768 Inf Inf
 [4,] -121.0234  39.20503 Inf Inf
 [5,] -122.0047  47.19262 Inf Inf
 [6,] -122.0135  47.18883 Inf Inf
 [7,] -122.0379  47.52190 Inf Inf
 [8,] -122.0578  47.60975 Inf Inf
 [9,] -122.1330  47.13669 Inf Inf
[10,] -122.1509  47.55962 Inf Inf
[11,] -122.1706  47.15546 Inf Inf
[12,] -122.1846  47.23485 Inf Inf
[13,] -122.1846  48.15307 Inf Inf
[14,] -122.1851  47.44870 Inf Inf
[15,] -122.1954  47.68485 Inf Inf
[16,] -122.1990  47.51610 Inf Inf
[17,] -122.2014  47.44772 Inf Inf
[18,] -122.2025  47.69815 Inf Inf
[19,] -122.2037  47.67190 Inf Inf
[20,] -122.2090  47.40378 Inf Inf
[21,] -122.2108  47.25336 Inf Inf
[22,] -122.2291  47.63880 Inf Inf
[23,] -122.2419  47.76870 Inf Inf
[24,] -122.2722  48.04803 Inf Inf
[25,] -122.2732  47.87700 Inf Inf
[26,] -122.2804  47.77620 Inf Inf
[27,] -122.2839  47.82103 Inf Inf
[28,] -122.2890  47.86899 Inf Inf
[29,] -122.2993  47.67306 Inf Inf
[30,] -122.3180  47.38217 Inf Inf
[31,] -122.3270  47.40378 Inf Inf
[32,] -122.3474  47.43884 Inf Inf
[33,] -122.3484  47.53083 Inf Inf
[34,] -122.3581  47.27678 Inf Inf
[35,] -122.3618  47.76735 Inf Inf
[36,] -122.3700  47.56567 Inf Inf
[37,] -122.3908  47.54938 Inf Inf
[38,] -122.4128  47.64622 Inf Inf
[39,] -122.4293  47.17660 Inf Inf
[40,] -122.4621  47.44505 Inf Inf
[41,] -122.4904  47.27460 Inf Inf
[42,] -122.5515  46.93979 Inf Inf
[43,] -122.7348  42.37320 Inf Inf
[44,] -122.7827  47.31059 Inf Inf
[45,] -122.7987  47.23475 Inf Inf
[46,] -122.8385  42.35119 Inf Inf
[47,] -122.8537  42.34495 Inf Inf
[48,] -122.8904  42.39555 Inf Inf
[49,] -122.8927  42.33022 Inf Inf
[50,] -122.9451  47.37574 Inf Inf
[51,] -122.9594  42.30376 Inf Inf
[52,] -123.0641  47.16428 Inf Inf
[53,] -123.3413  42.44117 Inf Inf
Error in spTransform(xSP, CRSobj, ...) : 
  failure in points 
1:2:3:4:5:6:7:8:9:10:

Re: [R] Help with spTransform() function and final plot colors

2020-05-17 Thread Poling, William via R-help
Hello, I have found an additional problem.

I should be getting 3 columns back in the xy@data at some point.
$ ID   : int  1 2 3 4 5 6 7 8 9 10 ...
# $ Clust  : int  1 1 1 1 1 1 1 1 1 1 ... This is always - 1
# $ Clust.1   : int  1 1 1 1 1 1 1 1 1 1 ... This would be the 
cluster number, like 1-3, I am not getting this column back?


Yet the plot runs and indicates three different clusters?



WHP


Proprietary

-Original Message-
From: Poling, William  
Sent: Sunday, May 17, 2020 4:50 AM
To: r-help@r-project.org
Cc: Poling, William 
Subject: Help with spTransform() function and final plot colors

#RStudio Version Version 1.2.1335
sessionInfo()
# R version 4.0.0 Patched (2020-05-03 r78349)
#Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 10 x64 
(build 17763)

Hello. I am running my data through a routine I found that finds clusters of 
data points based on distance rule.
https://gis.stackexchange.com/questions/64392/finding-clusters-of-points-based-distance-rule-using-r

1. I get this error when I get to this point in the routine, see complete 
routine below?
xy <- spTransform(xy, CRS("+init=epsg:27700 +datum=WGS84")) non finite 
transformation detected:

I tried converting columns from numeric to Integer but did not help.

However, I continue to run the rest of the routine and the final sequence, the 
plot itself, seems to work Can this error be corrected somehow, despite the 
fact that it continues to work, just curious what it is I guess"

2. However in the plot at the end of the routine the color key appears with the 
colors but the clusters in the plot are black, see plot call at the end of the 
routine below?

Thank you for any advice.

WHP

ERROR:
non finite transformation detected:
  coords.x1 coords.x2
 [1,] -119.7339  39.53939 Inf Inf
 [2,] -119.7665  39.39630 Inf Inf
 [3,] -119.7794  39.28768 Inf Inf
 [4,] -121.0234  39.20503 Inf Inf
 [5,] -122.0047  47.19262 Inf Inf
 [6,] -122.0135  47.18883 Inf Inf
 [7,] -122.0379  47.52190 Inf Inf
 [8,] -122.0578  47.60975 Inf Inf
 [9,] -122.1330  47.13669 Inf Inf
[10,] -122.1509  47.55962 Inf Inf
[11,] -122.1706  47.15546 Inf Inf
[12,] -122.1846  47.23485 Inf Inf
[13,] -122.1846  48.15307 Inf Inf
[14,] -122.1851  47.44870 Inf Inf
[15,] -122.1954  47.68485 Inf Inf
[16,] -122.1990  47.51610 Inf Inf
[17,] -122.2014  47.44772 Inf Inf
[18,] -122.2025  47.69815 Inf Inf
[19,] -122.2037  47.67190 Inf Inf
[20,] -122.2090  47.40378 Inf Inf
[21,] -122.2108  47.25336 Inf Inf
[22,] -122.2291  47.63880 Inf Inf
[23,] -122.2419  47.76870 Inf Inf
[24,] -122.2722  48.04803 Inf Inf
[25,] -122.2732  47.87700 Inf Inf
[26,] -122.2804  47.77620 Inf Inf
[27,] -122.2839  47.82103 Inf Inf
[28,] -122.2890  47.86899 Inf Inf
[29,] -122.2993  47.67306 Inf Inf
[30,] -122.3180  47.38217 Inf Inf
[31,] -122.3270  47.40378 Inf Inf
[32,] -122.3474  47.43884 Inf Inf
[33,] -122.3484  47.53083 Inf Inf
[34,] -122.3581  47.27678 Inf Inf
[35,] -122.3618  47.76735 Inf Inf
[36,] -122.3700  47.56567 Inf Inf
[37,] -122.3908  47.54938 Inf Inf
[38,] -122.4128  47.64622 Inf Inf
[39,] -122.4293  47.17660 Inf Inf
[40,] -122.4621  47.44505 Inf Inf
[41,] -122.4904  47.27460 Inf Inf
[42,] -122.5515  46.93979 Inf Inf
[43,] -122.7348  42.37320 Inf Inf
[44,] -122.7827  47.31059 Inf Inf
[45,] -122.7987  47.23475 Inf Inf
[46,] -122.8385  42.35119 Inf Inf
[47,] -122.8537  42.34495 Inf Inf
[48,] -122.8904  42.39555 Inf Inf
[49,] -122.8927  42.33022 Inf Inf
[50,] -122.9451  47.37574 Inf Inf
[51,] -122.9594  42.30376 Inf Inf
[52,] -123.0641  47.16428 Inf Inf
[53,] -123.3413  42.44117 Inf Inf
Error in spTransform(xSP, CRSobj, ...) : 
  failure in points 
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53
In addition: Warning message:
In spTransform(xSP, CRSobj, ...) : 53 projected point(s) not finite

Here is the data:
dput(sample)
structure(list(ID = 1:53, Longitude = c(-119.733899, -119.766493, -119.779416, 
-121.0234, -122.004736, -122.013456, -122.0379, -122.0578, -122.132971, 
-122.150901, -122.170608, -122.18462, -122.184639, -122.185079, -122.195398, 
-122.198994, -122.201356, -122.202507, -122.20371, -122.209047, -122.210797, 
-122.229095, -122.2419, -122.27216, -122.273164, -122.280355, -122.28389, 
-122.289043, -122.299261, -122.318009, -122.326987, -122.347382, -122.34844, 
-122.358115, -122.361839, -122.37003, -122.390815, -122.41282, -122.429323, 
-122.462136, -122.490417, -122.551483, -122.734847, -122.782736, -122.798669, 
-122.838498, -122.853683, -122.8904, -122.89271, -122.94511, -122.959407, 
-123.064087, -123.341346), Latitude = c(39.53939, 39.396298, 39.287681, 
39.205028, 47.192616, 47.188833, 47.5219, 47.609748, 47.13669, 47.559616, 
47.155455, 47.234849, 48.15307, 47.448697, 47.684854, 47.516104, 47.447723, 
47.698146, 47.6719, 47.403778, 47.253364, 47.638795, 47.768701, 48.048027, 
47.876997, 47.776205, 47.821

[R] Help with spTransform() function and final plot colors

2020-05-17 Thread Poling, William via R-help
#RStudio Version Version 1.2.1335 
sessionInfo() 
# R version 4.0.0 Patched (2020-05-03 r78349)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows 10 x64 (build 17763)

Hello. I am running my data through a routine I found that finds clusters of 
data points based on distance rule.
https://gis.stackexchange.com/questions/64392/finding-clusters-of-points-based-distance-rule-using-r

1. I get this error when I get to this point in the routine, see complete 
routine below?
xy <- spTransform(xy, CRS("+init=epsg:27700 +datum=WGS84"))
non finite transformation detected:

I tried converting columns from numeric to Integer but did not help.

However, I continue to run the rest of the routine and the final sequence, the 
plot itself, seems to work
Can this error be corrected somehow, despite the fact that it continues to 
work, just curious what it is I guess"

2. However in the plot at the end of the routine the color key appears with the 
colors but the clusters in the plot are black, see plot call at the end of the 
routine below?

Thank you for any advice.

WHP

ERROR:
non finite transformation detected:
  coords.x1 coords.x2
 [1,] -119.7339  39.53939 Inf Inf
 [2,] -119.7665  39.39630 Inf Inf
 [3,] -119.7794  39.28768 Inf Inf
 [4,] -121.0234  39.20503 Inf Inf
 [5,] -122.0047  47.19262 Inf Inf
 [6,] -122.0135  47.18883 Inf Inf
 [7,] -122.0379  47.52190 Inf Inf
 [8,] -122.0578  47.60975 Inf Inf
 [9,] -122.1330  47.13669 Inf Inf
[10,] -122.1509  47.55962 Inf Inf
[11,] -122.1706  47.15546 Inf Inf
[12,] -122.1846  47.23485 Inf Inf
[13,] -122.1846  48.15307 Inf Inf
[14,] -122.1851  47.44870 Inf Inf
[15,] -122.1954  47.68485 Inf Inf
[16,] -122.1990  47.51610 Inf Inf
[17,] -122.2014  47.44772 Inf Inf
[18,] -122.2025  47.69815 Inf Inf
[19,] -122.2037  47.67190 Inf Inf
[20,] -122.2090  47.40378 Inf Inf
[21,] -122.2108  47.25336 Inf Inf
[22,] -122.2291  47.63880 Inf Inf
[23,] -122.2419  47.76870 Inf Inf
[24,] -122.2722  48.04803 Inf Inf
[25,] -122.2732  47.87700 Inf Inf
[26,] -122.2804  47.77620 Inf Inf
[27,] -122.2839  47.82103 Inf Inf
[28,] -122.2890  47.86899 Inf Inf
[29,] -122.2993  47.67306 Inf Inf
[30,] -122.3180  47.38217 Inf Inf
[31,] -122.3270  47.40378 Inf Inf
[32,] -122.3474  47.43884 Inf Inf
[33,] -122.3484  47.53083 Inf Inf
[34,] -122.3581  47.27678 Inf Inf
[35,] -122.3618  47.76735 Inf Inf
[36,] -122.3700  47.56567 Inf Inf
[37,] -122.3908  47.54938 Inf Inf
[38,] -122.4128  47.64622 Inf Inf
[39,] -122.4293  47.17660 Inf Inf
[40,] -122.4621  47.44505 Inf Inf
[41,] -122.4904  47.27460 Inf Inf
[42,] -122.5515  46.93979 Inf Inf
[43,] -122.7348  42.37320 Inf Inf
[44,] -122.7827  47.31059 Inf Inf
[45,] -122.7987  47.23475 Inf Inf
[46,] -122.8385  42.35119 Inf Inf
[47,] -122.8537  42.34495 Inf Inf
[48,] -122.8904  42.39555 Inf Inf
[49,] -122.8927  42.33022 Inf Inf
[50,] -122.9451  47.37574 Inf Inf
[51,] -122.9594  42.30376 Inf Inf
[52,] -123.0641  47.16428 Inf Inf
[53,] -123.3413  42.44117 Inf Inf
Error in spTransform(xSP, CRSobj, ...) : 
  failure in points 
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53
In addition: Warning message:
In spTransform(xSP, CRSobj, ...) : 53 projected point(s) not finite

Here is the data:
dput(sample)
structure(list(ID = 1:53, Longitude = c(-119.733899, -119.766493, 
-119.779416, -121.0234, -122.004736, -122.013456, -122.0379, 
-122.0578, -122.132971, -122.150901, -122.170608, -122.18462, 
-122.184639, -122.185079, -122.195398, -122.198994, -122.201356, 
-122.202507, -122.20371, -122.209047, -122.210797, -122.229095, 
-122.2419, -122.27216, -122.273164, -122.280355, -122.28389, 
-122.289043, -122.299261, -122.318009, -122.326987, -122.347382, 
-122.34844, -122.358115, -122.361839, -122.37003, -122.390815, 
-122.41282, -122.429323, -122.462136, -122.490417, -122.551483, 
-122.734847, -122.782736, -122.798669, -122.838498, -122.853683, 
-122.8904, -122.89271, -122.94511, -122.959407, -123.064087, 
-123.341346), Latitude = c(39.53939, 39.396298, 39.287681, 39.205028, 
47.192616, 47.188833, 47.5219, 47.609748, 47.13669, 47.559616, 
47.155455, 47.234849, 48.15307, 47.448697, 47.684854, 47.516104, 
47.447723, 47.698146, 47.6719, 47.403778, 47.253364, 47.638795, 
47.768701, 48.048027, 47.876997, 47.776205, 47.821029, 47.868987, 
47.673056, 47.382165, 47.403785, 47.438836, 47.530831, 47.276776, 
47.76735, 47.565667, 47.549377, 47.646222, 47.176596, 47.445053, 
47.274599, 46.939789, 42.373195, 47.310595, 47.234748, 42.351189, 
42.344953, 42.395547, 42.33022, 47.375736, 42.303755, 47.164278, 
42.441172)), class = "data.frame", row.names = c(NA, -53L))

Here is the routine:
require(sp)
require(rgdal)
#25*1609.34 = 40233.5  
dis <- 40233.5 #Distance threshold 25miles converted to meters

x <- tmp1b[,c(6)]
head(x)
y <- tmp1b[,c(5)]
head(y)
str(y)

xy <- SpatialPointsDataFrame(matrix(c(x,y), ncol=2), 
data.frame(ID=seq(1:length(x))),
 pro

Re: [R] Help with map()

2020-05-14 Thread Poling, William via R-help
ot;,xlim=lonlim,ylim=latlim)
> axis(1)
> axis(2)
> densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
> red=c(0.5,1),green=0,blue=0,pch=15)
> title("Member Geo Density Plot For Cluster1")
>
>
>
>
>
> Proprietary
>
> -Original Message-
> From: Poling, William
> Sent: Thursday, May 14, 2020 6:29 AM
> To: Jim Lemon 
> Cc: r-help@r-project.org; Mark Fowler 
> Subject: RE: [EXTERNAL] Re: [R] Help with map()
>
>
> Hi Jim, and Mark, thank you for your response.
>
> 1. I have restarted R
> 2. I have only initiated library(magrittr)#for %>% function & 
> library(plotrix), no other libraries thinking that another may be overwriting 
> something.
> 3. I have checked the str()
>
> str(radius3)
> 'data.frame':   1990 obs. of  6 variables:
>  $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 590 908 976 509 
> 1674 690 1336 726 1702 2331 ...
>  $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 32 10 25 11 9 32 
> 13 12 12 17 ...
>  $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 932 156 230 698 
> 965 1330 515 1127 1304 1316 ...
>  $ Latitude: num  40.4 31.2 40.8 42.1 26.8 ...
>  $ Longitude   : num  -79.9 -81.5 -74 -91.6 -82.1 ...
>  $ distances_Mi: num  310.3 769.9 16.1 920.4 1057.6 ...
>
> str(clus1)
> tibble [53 x 7] (S3: tbl_df/tbl/data.frame)  $ MBR_SUBSCRIBERID: Factor w/ 
> 2352 levels "101040199600",..: 86 2111 995 899 953 924 769 92 790 1748 ...
>  $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 31 39 4 39 39 39 
> 39 31 39 39 ...
>  $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 727 85 455 1018 
> 1203 604 1169 727 984 295 ...
>  $ clusters: num [1:53] 1 1 1 1 1 1 1 1 1 1 ...
>  $ Latitude: num [1:53] 42.4 47.6 39.2 46.9 48 ...
>  $ Longitude   : num [1:53] -123 -122 -121 -123 -122 ...
>  $ distances_Mi: num [1:53] 2499 2406 2472 2430 2408 ...
>
> 4. I change clus1 to DF
> 'data.frame':   53 obs. of  7 variables:
>  $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 86 2111 995 899 
> 953 924 769 92 790 1748 ...
>  $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 31 39 4 39 39 39 
> 39 31 39 39 ...
>  $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 727 85 455 1018 
> 1203 604 1169 727 984 295 ...
>  $ clusters: num  1 1 1 1 1 1 1 1 1 1 ...
>  $ Latitude: num  42.4 47.6 39.2 46.9 48 ...
>  $ Longitude   : num  -123 -122 -121 -123 -122 ...
>  $ distances_Mi: num  2499 2406 2472 2430 2408 ...
>
> Then try again, no luck?
>
> Weird?
>
> Thanks
>
> WHP
>
> Proprietary
>
> -Original Message-
> From: Jim Lemon 
> Sent: Thursday, May 14, 2020 5:44 AM
> To: Poling, William 
> Cc: r-help@r-project.org
> Subject: [EXTERNAL] Re: [R] Help with map()
>
>  External Email - Use Caution 
>
> Hi Bill,
> Have you compared str(radius3) to str(clus1)? It may be quite different.
>
> Jim
>
> On Thu, May 14, 2020 at 8:24 PM Poling, William via R-help 
>  wrote:
> >
> > #RStudio Version Version 1.2.1335
> > sessionInfo()
> > # R version 4.0.0 Patched (2020-05-03 r78349)
> > #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 
> > 10
> > x64 (build 17763)
> >
> > Good morning.
> >
> > I ran routines like this one yesterday with no errors.
> >
> > #Radius3
> > str(radius3)
> >
> > radius3 <- individual_dets_sf_3X %>%
> >
> >   
> > dplyr::select(MBR_SUBSCRIBERID,state,city,Latitude,Longitude,distances_Mi) 
> > %>%
> >   filter(distances_Mi <= 1200)
> >
> > str(radius3)
> >
> >   geomat<-makeDensityMatrix(radius3[,c("Latitude","Longitude")],
> >
> > xlim=range(radius3$Longitude),ylim=range(radius3$Latitude))
> >
> > latlim<-range(radius3$Latitude)
> > lonlim<-range(radius3$Longitude)
> >
> > <- map("world",xlim=lonlim,ylim=latlim)
> > axis(1)
> > axis(2)
> > densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
> > red=c(0.5,1),green=0,blue=0,pch=15)
> > title("Member Geo Density Plot For Radius3")
> >
> >
> > This morning I am trying slightly new routine and receiving this 
> > error
> >
> > clus1 <- individual_dets_sf_3X %>%
> >
> >   
> > dplyr::select(MBR_SUBSCRIBERID,state,city,clusters,Latitude,Longitude,dis

Re: [R] Help with map()

2020-05-14 Thread Poling, William via R-help
] (S3: tbl_df/tbl/data.frame)  $ MBR_SUBSCRIBERID: Factor w/ 2352 
levels "101040199600",..: 86 2111 995 899 953 924 769 92 790 1748 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 31 39 4 39 39 39 39 
31 39 39 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 727 85 455 1018 
1203 604 1169 727 984 295 ...
 $ clusters: num [1:53] 1 1 1 1 1 1 1 1 1 1 ...
 $ Latitude: num [1:53] 42.4 47.6 39.2 46.9 48 ...
 $ Longitude   : num [1:53] -123 -122 -121 -123 -122 ...
 $ distances_Mi: num [1:53] 2499 2406 2472 2430 2408 ...

4. I change clus1 to DF
'data.frame':   53 obs. of  7 variables:
 $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 86 2111 995 899 
953 924 769 92 790 1748 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 31 39 4 39 39 39 39 
31 39 39 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 727 85 455 1018 
1203 604 1169 727 984 295 ...
 $ clusters: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Latitude: num  42.4 47.6 39.2 46.9 48 ...
 $ Longitude   : num  -123 -122 -121 -123 -122 ...
 $ distances_Mi: num  2499 2406 2472 2430 2408 ...

Then try again, no luck?

Weird?

Thanks

WHP

Proprietary

-Original Message-
From: Jim Lemon 
Sent: Thursday, May 14, 2020 5:44 AM
To: Poling, William 
Cc: r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with map()

 External Email - Use Caution 

Hi Bill,
Have you compared str(radius3) to str(clus1)? It may be quite different.

Jim

On Thu, May 14, 2020 at 8:24 PM Poling, William via R-help 
 wrote:
>
> #RStudio Version Version 1.2.1335
> sessionInfo()
> # R version 4.0.0 Patched (2020-05-03 r78349)
> #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 10
> x64 (build 17763)
>
> Good morning.
>
> I ran routines like this one yesterday with no errors.
>
> #Radius3
> str(radius3)
>
> radius3 <- individual_dets_sf_3X %>%
>
>   dplyr::select(MBR_SUBSCRIBERID,state,city,Latitude,Longitude,distances_Mi) 
> %>%
>   filter(distances_Mi <= 1200)
>
> str(radius3)
>
>   geomat<-makeDensityMatrix(radius3[,c("Latitude","Longitude")],
> 
> xlim=range(radius3$Longitude),ylim=range(radius3$Latitude))
>
> latlim<-range(radius3$Latitude)
> lonlim<-range(radius3$Longitude)
>
> <- map("world",xlim=lonlim,ylim=latlim)
> axis(1)
> axis(2)
> densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
> red=c(0.5,1),green=0,blue=0,pch=15)
> title("Member Geo Density Plot For Radius3")
>
>
> This morning I am trying slightly new routine and receiving this error
>
> clus1 <- individual_dets_sf_3X %>%
>
>   
> dplyr::select(MBR_SUBSCRIBERID,state,city,clusters,Latitude,Longitude,distances_Mi)
>  %>%
>   filter(clusters == 1)
>
> geomat<-makeDensityMatrix(clus1[,c("Latitude","Longitude")],
>   
> xlim=range(clus1$Longitude),ylim=range(clus1$Latitude))
>
> latlim<-range(clus1$Latitude)
> lonlim<-range(clus1$Longitude)
>
> map("world",xlim=lonlim,ylim=latlim)
> axis(1)
> axis(2)
> densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
> red=c(0.5,1),green=0,blue=0,pch=15)
> title("Member Geo Density Plot For Cluster1")
>
>
> geomat<-makeDensityMatrix(clus1[,c("Latitude","Longitude")],
> +   
> + xlim=range(clus1$Longitude),ylim=range(clus1$Latitude))
>
> > latlim<-range(clus1$Latitude)
> > lonlim<-range(clus1$Longitude)
> >
> > map("world",xlim=lonlim,ylim=latlim)
> Error in .C(C_map_type, as.character(mapbase), integer(1)) :
>   Incorrect number of arguments (2), expecting 0 for ''
> > axis(1)
> Error in axis(1) : plot.new has not been called yet
> > axis(2)
> Error in axis(2) : plot.new has not been called yet
> > densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
> + red=c(0.5,1),green=0,blue=0,pch=15)
> Error in plot.xy(xy.coords(x, y), type = type, ...) :
>   plot.new has not been called yet
> > title("Member Geo Density Plot For Cluster1")
> Error in title("Member Geo Density Plot For Cluster1") :
>   plot.new has not been called yet
>
>
> It seems to error at the point of map("world",xlim=lonlim,ylim=latlim)
>
> I find a ref in stack overflow
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com
> _questions_45066628_cannot-2Drun-2Dmap-2Ddatastate&d=DwIBaQ&c=wluqKIiw
> ffOpZ6k5sqMWMBOn0vyYnlulRJmmv

Re: [R] Help with map()

2020-05-14 Thread Poling, William via R-help
Hi, it is working now using just the most necessary pkgs.

 Evidently when there are so few rows (clus1=53) the map does not cooperate, I 
get the plot but no map image?

As I increase records the map begins to appear as it did for Radius1-8 routines

Thank you for your time and trouble my friends.

WHP





Proprietary

-Original Message-
From: Poling, William 
Sent: Thursday, May 14, 2020 6:46 AM
To: Jim Lemon 
Cc: r-help@r-project.org; Mark Fowler 
Subject: RE: [EXTERNAL] Re: [R] Help with map()

Hi, I ran this which is partially successful. I got long & lat  (x&y) with red 
plot values however, no map behind it?

Not sure what I might be missing now in terms of pkgs I suppose?
#Just use the basic pkgs
library(magrittr)#for %>% function
library(plotrix)
library(maps)
library(dplyr)#For filter()
str(individual_dets_sf_3X)
str(radius3)
str(clus1)


#rm(clus1)

clus1 <- individual_dets_sf_3X %>% 
  
  
dplyr::select(MBR_SUBSCRIBERID,state,city,clusters,Latitude,Longitude,distances_Mi)
 %>% #Notice now that these are capitalized <--"L"
  
  filter(clusters == 1)

str(clus1)

clus1 <- as.data.frame(clus1)

geomat<-makeDensityMatrix(clus1[,c("Latitude","Longitude")],
  
xlim=range(clus1$Longitude),ylim=range(clus1$Latitude))
# Range of density (>0) - 1.292155 3.89646 
latlim<-range(clus1$Latitude)
lonlim<-range(clus1$Longitude)

map("world",xlim=lonlim,ylim=latlim)
axis(1)
axis(2)
densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
red=c(0.5,1),green=0,blue=0,pch=15)
title("Member Geo Density Plot For Cluster1")





Proprietary

-Original Message-
From: Poling, William 
Sent: Thursday, May 14, 2020 6:29 AM
To: Jim Lemon 
Cc: r-help@r-project.org; Mark Fowler 
Subject: RE: [EXTERNAL] Re: [R] Help with map()


Hi Jim, and Mark, thank you for your response.

1. I have restarted R
2. I have only initiated library(magrittr)#for %>% function & library(plotrix), 
no other libraries thinking that another may be overwriting something.
3. I have checked the str()

str(radius3)
'data.frame':   1990 obs. of  6 variables:
 $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 590 908 976 509 
1674 690 1336 726 1702 2331 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 32 10 25 11 9 32 13 
12 12 17 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 932 156 230 698 
965 1330 515 1127 1304 1316 ...
 $ Latitude: num  40.4 31.2 40.8 42.1 26.8 ...
 $ Longitude   : num  -79.9 -81.5 -74 -91.6 -82.1 ...
 $ distances_Mi: num  310.3 769.9 16.1 920.4 1057.6 ...

str(clus1)
tibble [53 x 7] (S3: tbl_df/tbl/data.frame)  $ MBR_SUBSCRIBERID: Factor w/ 2352 
levels "101040199600",..: 86 2111 995 899 953 924 769 92 790 1748 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 31 39 4 39 39 39 39 
31 39 39 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 727 85 455 1018 
1203 604 1169 727 984 295 ...
 $ clusters: num [1:53] 1 1 1 1 1 1 1 1 1 1 ...
 $ Latitude: num [1:53] 42.4 47.6 39.2 46.9 48 ...
 $ Longitude   : num [1:53] -123 -122 -121 -123 -122 ...
 $ distances_Mi: num [1:53] 2499 2406 2472 2430 2408 ...

4. I change clus1 to DF
'data.frame':   53 obs. of  7 variables:
 $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 86 2111 995 899 
953 924 769 92 790 1748 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 31 39 4 39 39 39 39 
31 39 39 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 727 85 455 1018 
1203 604 1169 727 984 295 ...
 $ clusters: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Latitude: num  42.4 47.6 39.2 46.9 48 ...
 $ Longitude   : num  -123 -122 -121 -123 -122 ...
 $ distances_Mi: num  2499 2406 2472 2430 2408 ...

Then try again, no luck?

Weird?

Thanks

WHP

Proprietary

-Original Message-
From: Jim Lemon 
Sent: Thursday, May 14, 2020 5:44 AM
To: Poling, William 
Cc: r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with map()

 External Email - Use Caution 

Hi Bill,
Have you compared str(radius3) to str(clus1)? It may be quite different.

Jim

On Thu, May 14, 2020 at 8:24 PM Poling, William via R-help 
 wrote:
>
> #RStudio Version Version 1.2.1335
> sessionInfo()
> # R version 4.0.0 Patched (2020-05-03 r78349)
> #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 10
> x64 (build 17763)
>
> Good morning.
>
> I ran routines like this one yesterday with no errors.
>
> #Radius3
> str(radius3)
>
> radius3 <- individual_dets_sf_3X %>%
>
>   dplyr::select(MBR_SUBSCRIBERID,state,city,Latitude,Longitude,distances_Mi) 
> %>%
>   filter(dis

Re: [R] Help with map()

2020-05-14 Thread Poling, William via R-help
Hi, I ran this which is partially successful. I got long & lat  (x&y) with red 
plot values however, no map behind it?

Not sure what I might be missing now in terms of pkgs I suppose?
#Just use the basic pkgs
library(magrittr)#for %>% function
library(plotrix)
library(maps)
library(dplyr)#For filter()
str(individual_dets_sf_3X)
str(radius3)
str(clus1)


#rm(clus1)

clus1 <- individual_dets_sf_3X %>% 
  
  
dplyr::select(MBR_SUBSCRIBERID,state,city,clusters,Latitude,Longitude,distances_Mi)
 %>% #Notice now that these are capitalized <--"L"
  
  filter(clusters == 1)

str(clus1)

clus1 <- as.data.frame(clus1)

geomat<-makeDensityMatrix(clus1[,c("Latitude","Longitude")],
  
xlim=range(clus1$Longitude),ylim=range(clus1$Latitude))
# Range of density (>0) - 1.292155 3.89646 
latlim<-range(clus1$Latitude)
lonlim<-range(clus1$Longitude)

map("world",xlim=lonlim,ylim=latlim)
axis(1)
axis(2)
densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
red=c(0.5,1),green=0,blue=0,pch=15)
title("Member Geo Density Plot For Cluster1")





Proprietary

-Original Message-
From: Poling, William 
Sent: Thursday, May 14, 2020 6:29 AM
To: Jim Lemon 
Cc: r-help@r-project.org; Mark Fowler 
Subject: RE: [EXTERNAL] Re: [R] Help with map()


Hi Jim, and Mark, thank you for your response.

1. I have restarted R
2. I have only initiated library(magrittr)#for %>% function & library(plotrix), 
no other libraries thinking that another may be overwriting something.
3. I have checked the str()

str(radius3)
'data.frame':   1990 obs. of  6 variables:
 $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 590 908 976 509 
1674 690 1336 726 1702 2331 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 32 10 25 11 9 32 13 
12 12 17 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 932 156 230 698 
965 1330 515 1127 1304 1316 ...
 $ Latitude: num  40.4 31.2 40.8 42.1 26.8 ...
 $ Longitude   : num  -79.9 -81.5 -74 -91.6 -82.1 ...
 $ distances_Mi: num  310.3 769.9 16.1 920.4 1057.6 ...

str(clus1)
tibble [53 x 7] (S3: tbl_df/tbl/data.frame)  $ MBR_SUBSCRIBERID: Factor w/ 2352 
levels "101040199600",..: 86 2111 995 899 953 924 769 92 790 1748 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 31 39 4 39 39 39 39 
31 39 39 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 727 85 455 1018 
1203 604 1169 727 984 295 ...
 $ clusters: num [1:53] 1 1 1 1 1 1 1 1 1 1 ...
 $ Latitude: num [1:53] 42.4 47.6 39.2 46.9 48 ...
 $ Longitude   : num [1:53] -123 -122 -121 -123 -122 ...
 $ distances_Mi: num [1:53] 2499 2406 2472 2430 2408 ...

4. I change clus1 to DF
'data.frame':   53 obs. of  7 variables:
 $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 86 2111 995 899 
953 924 769 92 790 1748 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 31 39 4 39 39 39 39 
31 39 39 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 727 85 455 1018 
1203 604 1169 727 984 295 ...
 $ clusters: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Latitude: num  42.4 47.6 39.2 46.9 48 ...
 $ Longitude   : num  -123 -122 -121 -123 -122 ...
 $ distances_Mi: num  2499 2406 2472 2430 2408 ...

Then try again, no luck?

Weird?

Thanks

WHP

Proprietary

-Original Message-
From: Jim Lemon 
Sent: Thursday, May 14, 2020 5:44 AM
To: Poling, William 
Cc: r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with map()

 External Email - Use Caution 

Hi Bill,
Have you compared str(radius3) to str(clus1)? It may be quite different.

Jim

On Thu, May 14, 2020 at 8:24 PM Poling, William via R-help 
 wrote:
>
> #RStudio Version Version 1.2.1335
> sessionInfo()
> # R version 4.0.0 Patched (2020-05-03 r78349)
> #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 10
> x64 (build 17763)
>
> Good morning.
>
> I ran routines like this one yesterday with no errors.
>
> #Radius3
> str(radius3)
>
> radius3 <- individual_dets_sf_3X %>%
>
>   dplyr::select(MBR_SUBSCRIBERID,state,city,Latitude,Longitude,distances_Mi) 
> %>%
>   filter(distances_Mi <= 1200)
>
> str(radius3)
>
>   geomat<-makeDensityMatrix(radius3[,c("Latitude","Longitude")],
> 
> xlim=range(radius3$Longitude),ylim=range(radius3$Latitude))
>
> latlim<-range(radius3$Latitude)
> lonlim<-range(radius3$Longitude)
>
> <- map("world",xlim=lonlim,ylim=latlim)
> axis(1)
> axis(2)
> densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
> red=c(0.5,1),gre

Re: [R] Help with map()

2020-05-14 Thread Poling, William via R-help


Hi Jim, and Mark, thank you for your response.

1. I have restarted R
2. I have only initiated library(magrittr)#for %>% function & library(plotrix), 
no other libraries thinking that another may be overwriting something.
3. I have checked the str()

str(radius3)
'data.frame':   1990 obs. of  6 variables:
 $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 590 908 976 509 
1674 690 1336 726 1702 2331 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 32 10 25 11 9 32 13 
12 12 17 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 932 156 230 698 
965 1330 515 1127 1304 1316 ...
 $ Latitude: num  40.4 31.2 40.8 42.1 26.8 ...
 $ Longitude   : num  -79.9 -81.5 -74 -91.6 -82.1 ...
 $ distances_Mi: num  310.3 769.9 16.1 920.4 1057.6 ...

str(clus1)
tibble [53 x 7] (S3: tbl_df/tbl/data.frame)
 $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 86 2111 995 899 
953 924 769 92 790 1748 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 31 39 4 39 39 39 39 
31 39 39 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 727 85 455 1018 
1203 604 1169 727 984 295 ...
 $ clusters: num [1:53] 1 1 1 1 1 1 1 1 1 1 ...
 $ Latitude: num [1:53] 42.4 47.6 39.2 46.9 48 ...
 $ Longitude   : num [1:53] -123 -122 -121 -123 -122 ...
 $ distances_Mi: num [1:53] 2499 2406 2472 2430 2408 ...

4. I change clus1 to DF
'data.frame':   53 obs. of  7 variables:
 $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 86 2111 995 899 
953 924 769 92 790 1748 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 31 39 4 39 39 39 39 
31 39 39 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 727 85 455 1018 
1203 604 1169 727 984 295 ...
 $ clusters: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Latitude: num  42.4 47.6 39.2 46.9 48 ...
 $ Longitude   : num  -123 -122 -121 -123 -122 ...
 $ distances_Mi: num  2499 2406 2472 2430 2408 ...

Then try again, no luck?

Weird?

Thanks

WHP

Proprietary

-Original Message-
From: Jim Lemon  
Sent: Thursday, May 14, 2020 5:44 AM
To: Poling, William 
Cc: r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with map()

**** External Email - Use Caution 

Hi Bill,
Have you compared str(radius3) to str(clus1)? It may be quite different.

Jim

On Thu, May 14, 2020 at 8:24 PM Poling, William via R-help 
 wrote:
>
> #RStudio Version Version 1.2.1335
> sessionInfo()
> # R version 4.0.0 Patched (2020-05-03 r78349)
> #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 10 
> x64 (build 17763)
>
> Good morning.
>
> I ran routines like this one yesterday with no errors.
>
> #Radius3
> str(radius3)
>
> radius3 <- individual_dets_sf_3X %>%
>
>   dplyr::select(MBR_SUBSCRIBERID,state,city,Latitude,Longitude,distances_Mi) 
> %>%
>   filter(distances_Mi <= 1200)
>
> str(radius3)
>
>   geomat<-makeDensityMatrix(radius3[,c("Latitude","Longitude")],
> 
> xlim=range(radius3$Longitude),ylim=range(radius3$Latitude))
>
> latlim<-range(radius3$Latitude)
> lonlim<-range(radius3$Longitude)
>
> <- map("world",xlim=lonlim,ylim=latlim)
> axis(1)
> axis(2)
> densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
> red=c(0.5,1),green=0,blue=0,pch=15)
> title("Member Geo Density Plot For Radius3")
>
>
> This morning I am trying slightly new routine and receiving this error
>
> clus1 <- individual_dets_sf_3X %>%
>
>   
> dplyr::select(MBR_SUBSCRIBERID,state,city,clusters,Latitude,Longitude,distances_Mi)
>  %>%
>   filter(clusters == 1)
>
> geomat<-makeDensityMatrix(clus1[,c("Latitude","Longitude")],
>   
> xlim=range(clus1$Longitude),ylim=range(clus1$Latitude))
>
> latlim<-range(clus1$Latitude)
> lonlim<-range(clus1$Longitude)
>
> map("world",xlim=lonlim,ylim=latlim)
> axis(1)
> axis(2)
> densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
> red=c(0.5,1),green=0,blue=0,pch=15)
> title("Member Geo Density Plot For Cluster1")
>
>
> geomat<-makeDensityMatrix(clus1[,c("Latitude","Longitude")],
> +   
> + xlim=range(clus1$Longitude),ylim=range(clus1$Latitude))
>
> > latlim<-range(clus1$Latitude)
> > lonlim<-range(clus1$Longitude)
> >
> > map("world",xlim=lonlim,ylim=latlim)
> Error in .C(C_map_type, as.character(mapbase), integer(1)) :
>   Incorrect number of arguments (2), expecting 0 for &#x

[R] Help with map()

2020-05-14 Thread Poling, William via R-help
#RStudio Version Version 1.2.1335 
sessionInfo() 
# R version 4.0.0 Patched (2020-05-03 r78349)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows 10 x64 (build 17763)

Good morning. 

I ran routines like this one yesterday with no errors.

#Radius3
str(radius3)

radius3 <- individual_dets_sf_3X %>% 
  
  dplyr::select(MBR_SUBSCRIBERID,state,city,Latitude,Longitude,distances_Mi) 
%>% 
  filter(distances_Mi <= 1200)
  
str(radius3)

  geomat<-makeDensityMatrix(radius3[,c("Latitude","Longitude")],

xlim=range(radius3$Longitude),ylim=range(radius3$Latitude))

latlim<-range(radius3$Latitude)
lonlim<-range(radius3$Longitude)

<- map("world",xlim=lonlim,ylim=latlim)
axis(1)
axis(2)
densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
red=c(0.5,1),green=0,blue=0,pch=15)
title("Member Geo Density Plot For Radius3")


This morning I am trying slightly new routine and receiving this error

clus1 <- individual_dets_sf_3X %>% 
  
  
dplyr::select(MBR_SUBSCRIBERID,state,city,clusters,Latitude,Longitude,distances_Mi)
 %>%   
  filter(clusters == 1)

geomat<-makeDensityMatrix(clus1[,c("Latitude","Longitude")],
  
xlim=range(clus1$Longitude),ylim=range(clus1$Latitude))

latlim<-range(clus1$Latitude)
lonlim<-range(clus1$Longitude)

map("world",xlim=lonlim,ylim=latlim)
axis(1)
axis(2)
densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
red=c(0.5,1),green=0,blue=0,pch=15)
title("Member Geo Density Plot For Cluster1")


geomat<-makeDensityMatrix(clus1[,c("Latitude","Longitude")],
+   
xlim=range(clus1$Longitude),ylim=range(clus1$Latitude))

> latlim<-range(clus1$Latitude)
> lonlim<-range(clus1$Longitude)
> 
> map("world",xlim=lonlim,ylim=latlim)
Error in .C(C_map_type, as.character(mapbase), integer(1)) : 
  Incorrect number of arguments (2), expecting 0 for ''
> axis(1)
Error in axis(1) : plot.new has not been called yet
> axis(2)
Error in axis(2) : plot.new has not been called yet
> densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
+ red=c(0.5,1),green=0,blue=0,pch=15)
Error in plot.xy(xy.coords(x, y), type = type, ...) : 
  plot.new has not been called yet
> title("Member Geo Density Plot For Cluster1")
Error in title("Member Geo Density Plot For Cluster1") : 
  plot.new has not been called yet


It seems to error at the point of map("world",xlim=lonlim,ylim=latlim)

I find a ref in stack overflow 
https://stackoverflow.com/questions/45066628/cannot-run-map-datastate
and tried solutions but they do not seem to work?

Here is a sample (MBR_SUBSCRIBERID(factor) is replaced with ID(integer) but of 
no consequence in my routine since not really used.

I hope someone recognizes the problem.

Thank you for any advice 

WHP

> dput(sample)
structure(list(state = structure(c(2L, 22L, 10L, 12L, 6L, 22L, 
11L, 22L, 22L, 32L, 19L, 29L, 9L, 9L, 10L, 30L, 33L, 35L, 41L, 
12L, 12L, 36L, 4L, 9L, 8L, 39L, 36L, 36L, 41L, 28L, 12L, 28L, 
28L, 12L, 11L, 2L, 12L, 22L, 32L, 22L, 12L, 10L, 10L, 22L, 10L
), .Label = c("AL", "AR", "AZ", "CA", "CO", "CT", "DC", "DE", 
"FL", "GA", "IA", "IL", "IN", "KS", "KY", "LA", "MA", "MD", "ME", 
"MI", "MN", "MO", "NC", "NE", "NJ", "NM", "NV", "NY", "OH", "OK", 
"OR", "PA", "SC", "SD", "TN", "TX", "UT", "VA", "WA", "WI", "WV"
), class = "factor"), city = structure(c(838L, 1030L, 262L, 218L, 
166L, 973L, 339L, 451L, 660L, 358L, 281L, 1280L, 129L, 223L, 
989L, 721L, 550L, 731L, 1325L, 688L, 1184L, 281L, 759L, 1171L, 
1305L, 587L, 272L, 581L, 263L, 152L, 217L, 152L, 390L, 5L, 571L, 
1006L, 1162L, 939L, 170L, 1033L, 1002L, 586L, 586L, 192L, 586L
), .Label = c("ABBOTTSTOWN", "ABILENE", "ACWORTH", "ADAMS", "ADDISON", 
"ADKINS", "ALBANY", "ALBIA", "ALBUQUERQUE", "ALEXANDRIA", "ALFRED", 
"ALIQUIPPA", "ALISO VIEJO", "ALLEN PARK", "ALLENTOWN", "ALPHA", 
"ALPHARETTA", "ALPINE", "ALTOONA", "AMARILLO", "AMBLER", "AMBRIDGE", 
"AMHERST", "AMITYVILLE", "ANAHIEM", "ANDERSON", "ANDOVER", "ANGIER", 
"ANGLETON", "ANKENY", "ANN ARBOR", "ANZA", "APEX", "APOLLO", 
"ARCADIA", "ARCHDALE", "ARDMORE", "ARGYLE", "ARKANSAS CITY", 
"ARLINGTON", "ARNOLD", "ARTHUR", "ASHEBORO", "ASHEVILLE", "ASHLAND", 
"ASHLAND CITY", "ASHTON", "ASTON", "ATHENS", "ATLANTA", "ATLANTIC BCH", 
"AUBORN", "AUGUSTA", "AURORA", "AUSTELL", "AUSTIN", "AVENTURA", 
"AVONDALE ESTATES", "BAKERSFIELD", "BALDWIN CITY", "BALDWIN PLACE", 
"BALLWIN", "BANGOR", "BARBOURSVILLE", "BARNEGAT", "BARTLETT", 
"BARTON", "BARTONVILLE", "BASSETT", "BATAVIA", "BATESBURG", "BATON ROUGE", 
"BAXTER SPRINGS", "BAY CITY", "BAYONNE", "BAYSIDE", "BAYTOWN", 
"BEAR", "BEAUMONT", "BEECH CREEK", "BEECHER CITY", "BELFAIR", 
"BELLE VERNON", "BELLEAIR", "BELLEVUE", "BELLMAWR", "BELLMORE", 
"BELLWOOD", "BELMAR", "BELMONT", "BELVIDERE", "BENNET", "BENTON", 
"BENTONVILLE", "BERLIN", "BESSEMER CITY", "BETHANY", "BETHEL", 
"BETHEL PARK", "BETHESDA", "BETHLEHEM", "BETTENDORF", "BIGLERVILLE", 
"BINGHAMTON", "BIRDSBORO", "BIWABIK", "BLACK MOUNTAIN", "B

Re: [R] Help with Radius problem --update

2020-05-13 Thread Poling, William via R-help
Hello Abby and thank you for your response.

Your surly correct.

I have not worked a problem like this previously, however, I am learning fast.

I did not think I would need to apply mathematical formula-calculations for 
this task, math in general not my primary area of expertise, but always very 
curious.

However your point is provocative and now I am interested to learn more in that 
space as well.

By researching the literature on Radii, and disk partial coverage problem, and 
anything in stack overflow remotely relevant to my question I am slowly piecing 
a solution together.

What I described in the string is my best thinking in terms of delivering 
something, anything, at the moment that I can build on, refine, etc.

1. I have data set with 2352 geo locations in 41 states from Maine to California
2. I have determined, using density plot (thank to Jim L), that the most 
reasonable reference point in terms of realizing population density using 
distance among my 2353 is Brooklyn, NY.
3. Calculating distances from that point to the other 2351 based on a script 
referenced in stack over flow I simply plug in, manually-iteratively, distances 
(8 at the moment) and determine how many members are in that radius
4. Then determine the % decay from Max to Min of these 8 distances and settle 
on the one that has the highest concentration with the least decay
4. This piece (Item 3) I would like to make more efficient and was the point of 
my last submission to the R-Help list on this topic

For example: Radius2 = 1500 miles, Radius3 = 1200 miles, Radius4 = 1000 miles
The difference b/w Radius2 in terms of percent missing coverage and Radius3 is 
0.057 while the percent missing coverage b/w Radius2 and Radius4 is 0.204

So my logic is that despite being a larger radius ,Radius3 vs Radius4, the 
trade off is more inclusive of the membership and therefore optimal among the 8 
iterations. For the moment

I appreciate your response and any direction or advice would be most 
appreciated.

WHP

 



Proprietary

-Original Message-
From: Abby Spurdle  
Sent: Wednesday, May 13, 2020 3:17 PM
To: Poling, William 
Cc: r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with Radius problem --update

 External Email - Use Caution 

> "determine the largest concentration of members in the smallest radius"

I haven't read the whole thread, and I'm not familiar with this topic.
However, looking at it from an intuitive perspective, isn't the smallest radius 
zero.
If the concentration means the number of "members" divided by the area...
...then would the largest concentration be undefined, merely because of 
division by zero.

Perhaps your question is a valid one.
But if you're wanting a large pool of people to consider helping, I'd recommend 
a more (mathematically) precise definition of the problem you're trying to 
solve.

NOTICE TO RECIPIENT OF INFORMATION:
This e-mail may contain confidential or privileged information. If you think 
you have received this e-mail in error, please advise the sender by reply 
e-mail and then delete this e-mail immediately.  
This e-mail may also contain protected health information (PHI) with 
information about sensitive medical conditions, including, but not limited to, 
treatment for substance use disorders, behavioral health, HIV/AIDS, or 
pregnancy. This type of information may be protected by various federal and/or 
state laws which prohibit any further disclosure without the express written 
consent of the person to whom it pertains or as otherwise permitted by law. Any 
unauthorized further disclosure may be considered a violation of federal and/or 
state law. A general authorization for the release of medical or other 
information may NOT be sufficient consent for release of this type of 
information.
Thank you. Aetna
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help with R-Markdown please

2020-05-13 Thread Poling, William via R-help
I have R on personal laptop for consultative purposes from time to time, 
however, I cannot move data, confidentiality constraints, as you can imagine.

I have initiated another IT ticket with organization, I think I will get to the 
bottom of this at some point.

Thank you.

WHP


Proprietary

-Original Message-
From: Rasmus Liland  
Sent: Wednesday, May 13, 2020 2:50 PM
To: Poling, William 
Cc: r-help@r-project.org
Subject: [EXTERNAL] Re: Re: [R] Help with R-Markdown please

 External Email - Use Caution 

On 2020-05-13 19:27 +, Poling, William wrote:
> if this is something I can do without IT admin access.

Hi!  O.T. on laptops: Also, perhaps it is easier to find another laptop.  There 
seems to be some great ThinkPads readily available anywhere around the U.S., 
like an X61 or X220 or something, at least that is my impression from various 
Facebook groups ... I mean if it is easier for you to complete your work on 
another machine where you have admin access ... just for making a rmarkdown 
presentation or something, not for working with the sensitive insurance data 
... 

Best,
Rasmus

NOTICE TO RECIPIENT OF INFORMATION:\ This e-mail may con...{{dropped:16}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help with R-Markdown please

2020-05-13 Thread Poling, William via R-help
Hi Rasmus, thank you I will see if this is something I can do without IT admin 
access.

In the mean time I have reloaded rmarkdown. To local

package ‘rmarkdown’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\A436798\AppData\Local\Temp\RtmpYjSy7G\downloaded_packages

library(rmarkdown)

But R is still looking for it in : " Could not fetch 
http://?/UNC/winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library/rmarkdown/rmd/h/default.html";


More recently I have installed other pkgs for the first time use and they have 
gone to local like above for rmarkdown and I have used functions from them so 
they are being searched for correctly I guess?

Very confusing.

Thank you for your response Sir!

WHP

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS 
Member-Geo-Location-Test-V1.utf8.md --to html4 --from 
markdown+autolink_bare_uris+tex_math_single_backslash+smart --output 
Member-Geo-Location-Test-V1.html --email-obfuscation none --self-contained 
--standalone --section-divs --template 
"\\winp-oaf-113\FldrRedir_1$\A436798\Data\R\R-4.0.0patched\library\rmarkdown\rmd\h\default.html"
 --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" 
--include-in-header 
"C:\Users\A436798\AppData\Local\Temp\RtmpglP9GJ\rmarkdown-str314c55414a00.html" 
--mathjax --variable 
"mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
 --lua-filter 
"\\winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library/rmarkdown/rmd/lua/pagebreak.lua"
 --lua-filter 
"\\winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library/rmarkdown/rmd/lua/latex-div.lua"
 
output file: Member-Geo-Location-Test-V1.knit.md

Could not fetch 
http://?/UNC/winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library/rmarkdown/rmd/h/default.html
HttpExceptionRequest Request {
  host = ""
  port = 80
  secure   = False
  requestHeaders   = []
  path = "/"
  queryString  = 
"?/UNC/winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library/rmarkdown/rmd/h/default.html"
  method   = "GET"
  proxy= Nothing
  rawBody  = False
  redirectCount= 10
  responseTimeout  = ResponseTimeoutDefault
  requestVersion   = HTTP/1.1
}
 (InvalidDestinationHost "")
Error: pandoc document conversion failed with error 61
Execution halted


WHP


Proprietary

-Original Message-
From: Rasmus Liland  
Sent: Wednesday, May 13, 2020 2:10 PM
To: Poling, William 
Cc: r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with R-Markdown please

 External Email - Use Caution 

On 2020-05-13 18:46 +, Poling, William via R-help wrote:
> Hello all.
> 
> I am still struggling with this issue.
> 
> It appears that new installations are going to local drive.
> 
> # #Test 05/13/2020
> # install.packages("abjutils")
> # package ‘abjutils’ successfully unpacked and MD5 sums checked # # 
> The downloaded binary packages are in # 
> C:\Users\A436798\AppData\Local\Temp\RtmpCuXNJn\downloaded_packages
> 
> However, when I run .libPaths() it
> indicates our UNC path
> 
> [1] "winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library"
> 
> Is there a way for me to change this myself in my instance of R?

Dear William,

Perhaps you could try to set the variable R_LIBS_USER to some local folder.  I 
do not know how to do this on Windows, but there seems to be some guys in this 
rstudio discussion thread that came to some sort of a
conclusion: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__community.rstudio.com_t_help-2Dregarding-2Dpackage-2Dinstallation-2Drenviron-2Drprofile-2Dr-2Dlibs-2Dr-2Dlibs-2Dsite-2Dand-2Dr-2Dlibs-2Duser-2Doh-2Dmy_13888_8&d=DwIDaQ&c=wluqKIiwffOpZ6k5sqMWMBOn0vyYnlulRJmmvOXCFpM&r=j7MrcIQm2xjHa8v-2mTpmTCtKvneM2ExlYvnUWbsByY&m=q_5fam9luSaeNgs-KOUZS-w-YAVaPzQdZgIlejBCDFA&s=NWDnltFH8cjC-pj6K08lWXC1FjfFcyY1mueSZnor9Ng&e=
  

Since long ago, I have had this line in my ~/.zshrc.local  :)

[ -e /usr/bin/Rscript ] && R_LIBS_USER=`Rscript -e 
'cat(Sys.getenv("R_LIBS_USER"))'`

Best,
Rasmus

NOTICE TO RECIPIENT OF INFORMATION:
This e-mail may contain confidential or privileged information. If you think 
you have received this e-mail in error, please advise the sender by reply 
e-mail and then delete this e-mail immediately.  
This e-mail may also contain protected health information (PHI) with 
information about sensitive medical conditions, including, but not limited to, 
treatment for substance use disorders, behavioral health, HIV/AIDS, or 
pregnancy. This type of information may be protected by various federal and/or 
state laws which prohi

Re: [R] Help with R-Markdown please

2020-05-13 Thread Poling, William via R-help
Hello all.

I am still struggling with this issue.

It appears that new installations are going to local drive.


# #Test 05/13/2020
# install.packages("abjutils")
# package ‘abjutils’ successfully unpacked and MD5 sums checked
# 
# The downloaded binary packages are in
# C:\Users\A436798\AppData\Local\Temp\RtmpCuXNJn\downloaded_packages

However, when I run .libPaths() it indicates our UNC path

[1] "winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library"


Is there a way for me to change this myself in my instance of R?

Thank you.

WHP 



Proprietary

-Original Message-
From: Ege Rubak  
Sent: Tuesday, May 12, 2020 7:43 AM
To: Poling, William ; r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with R-Markdown please

 External Email - Use Caution 

Looks like your files are on a Windows network drive (UNC path). I have 
experienced many problems with this on a Windows laptop from work. If at all 
possible you should avoid this. As an absolute minimum make sure your R library 
(collection of installed packages) is on the local file system and not a UNC 
path. If you are lucky this could be enough to make things work.

You can check your library location(s) with the command .libPaths() in an R 
session.

Good luck.

Ege

On Tue, 2020-05-12 at 10:15 +0000, Poling, William via R-help wrote:
> #UPDATED 05/05/2020
> #RStudio Version Version 1.2.1335 need this one--> 1.2.5019
> sessionInfo()
> # R version 4.0.0 Patched (2020-05-03 r78349)
> #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 10 
> x64 (build 17763)
> 
> Good morning.
> 
> This is the first time I have tried RMarkdown on new laptop with new 
> employer.
> I am not sure how to go about fixing this problem below?
> 
> Would someone please advise course of action.
> 
> Thank you.
> 
> WHP
> 
> 
> 
> processing file: Member-Geo-Location-Test-V1.Rmd
>  
> |..  
>   |  14%
>   ordinary text without R code
> 
>  
> |
>   |  29%
> label: unnamed-chunk-1 (with options) List of 1  $ echo: logi FALSE
> 
>  
> |..  
>   |  43%
>   ordinary text without R code
> 
>  
> |
>   |  57%
> label: setup (with options)
> List of 2
>  $ include: logi FALSE
>  $ warning: logi FALSE
> 
>  
> |..  
>   |  71%
>   ordinary text without R code
> 
>  
> |
>   |  86%
> label: Table1 (with options)
> List of 2
>  $ echo   : logi FALSE
>  $ results: chr "asis"
> 
>  
> |
> ..| 100%
>inline R code fragments
> 
> 
> output file: Member-Geo-Location-Test-V1.knit.md
> 
> "C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Member- 
> Geo-Location-Test-V1.utf8.md --to html4 --from
> markdown+autolink_bare_uris+tex_math_single_backslash+smart --output
> Member-Geo-Location-Test-V1.html --email-obfuscation none --self- 
> contained --standalone --section-divs --template "\\winp-oaf-
> 113\FldrRedir_1$\A436798\Data\R\R-
> 4.0.0patched\library\rmarkdown\rmd\h\default.html" --no-highlight -- 
> variable highlightjs=1 --variable "theme:bootstrap" --include-in- 
> header "C:\Users\A436798\AppData\Local\Temp\RtmpSajZla\rmarkdown-
> str2ae846253313.html" --mathjax --variable "mathjax-url:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__mathjax.rstudio.c
> om_latest_MathJax.js-3Fconfig-3DTeX-2DAMS-2DMML-5FHTMLorMML&d=DwIGaQ&c
> =wluqKIiwffOpZ6k5sqMWMBOn0vyYnlulRJmmvOXCFpM&r=j7MrcIQm2xjHa8v-2mTpmTC
> tKvneM2ExlYvnUWbsByY&m=uBce0mQRO8wdLXO8BDTtjk4R92KVzpjtkQ-NqYiAHCo&s=S
> MNU_B--j9FvBKh-0u1NG5RHd7AtLkvyVsi9ybyUwYU&e=
> " --lua-filter "\\winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-
> 4.0.0patched/library/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter
> "\\winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-
> 4.0.0patched/library/rmarkdown/rmd/lua/latex-div.lua" 
> Could not fetch http://?/UNC/winp-oaf-
> 113/FldrRedir_1$/A436798/Data/R/R-
> 4.0.0patched/library/rmarkdown/rmd/h/default.html
> HttpExceptionRequest Request {
>   host = ""
>   port = 80
>   secure   = False
>   requestHeaders   = []
>   path = "/"
>   queryString  = "?/UNC/winp-oaf-
> 113/FldrRedir_1$/A43

Re: [R] Help with Radius problem --update

2020-05-13 Thread Poling, William via R-help
ESPORT", "MCKINNEY", "MECHANICSBURG", 
"MECHANICSVILLE", "MEDFORD", "MEDIA", "MEDWAY", "MELVILLE", "MEMPHIS", 
"MERIDEN", "MERRIAM", "MERRICK", "MERRILL", "MERRILLVILLE", "MESA", 
"MESQUITE", "MIAMI", "MIAMI GARDENS", "MICHIGAN CITY", "MIDDLETOWN", 
"MIDLAND", "MIFFLINTOWN", "MILFORD", "MILL CREEK", "MILLBROOK", 
"MILLEDGEVILLE", "MILLINOCKET", "MILNER", "MILTON", "MILWAUKEE", 
"MINEOLA", "MINERAL SPGS", "MINERAL WELLS", "MINNEAPOLIS", "MISSION", 
"MISSION HILLS", "MISSION VIEJO", "MISSOURI CITY", "MISSOURI VALLEY", 
"MOLINE", "MONESSEN", "MONROE", "MONROE TOWNSHIP", "MONROEVILLE", 
"MONTCLAIR", "MONTEREY", "MONTICELLO", "MOORESVILLE", "MORGANTON", 
"MORGANTOWN", "MORRIS PLAINS", "MOUND", "MOUND CITY", "MOUNT HOPE", 
"MOUNT JOY", "MOUNT LAUREL", "MOUNT PLEASANT", "MOUNT POCONO", 
"MOUNT UNION", "MOUNT WOLF", "MOUNTVILLE", "MT HOLLY", "MT PLEASANT", 
"MULVANE", "MUNCIE", "MUNSTER", "MURFREESBORO", "MURRAY", "MURRELLS INLT", 
"MUSTANG", "MYERSTOWN", "MYSTIC", "N BRANFORD", "N FT MYERS", 
"NAPERVILLE", "NAPLES", "NAPOLEON", "NASHVILLE", "NATCHITOCHES", 
"NAUGATUCK", "NEOSHO", "NEPTUNE BEACH", "NESCONSET", "NETCONG", 
"NEW BLOOMFIELD", "NEW BRAUNFELS", "NEW BRITAIN", "NEW BRUNSWICK", 
"NEW CASTLE", "NEW CUMBERLAND", "NEW HAVEN", "NEW KENSINGTON", 
"NEW LONDON", "NEW ORLEANS", "NEW PRESTON", "NEW PROVIDENCE", 
"NEW ROCHELLE", "NEW TRIPOLI", "NEW ULM", "NEW WINDSOR", "NEW YORK", 
"NEWARK", "NEWBURGH HEIGHTS", "NEWINGTON", "NEWNAN", "NEWPORT", 
"NEWPORT BEACH", "NEWTON", "NEWTONVILLE", "NIAGARA FALLS", "NIXA", 
"NOANK", "NOKOMIS", "NORCROSS", "NORFOLK", "NORMAN", "NORMANDY PARK", 
"NORTH BABYLON", "NORTH HAVEN", "NORTH HUNTINGDON", "NORTH JACKSON", 
"NORTH LITTLE ROCK", "NORTH MIAMI", "NORTH PORT", "NORTH RICHLAND HILLS", 
"NORTH WALES", "NORTH WATERBORO", "NORTHFIELD", "NORTHRIDGE", 
"NORTON", "NORWALK", "NOTTINGHAM", "NUTLEY", "NYACK", "O FALLON", 
"OAK RIDGE", "OAKDALE", "OCALA", "OCEANSIDE", "OCILLA", "OLATHE", 
"OMAHA", "OMRO", "ONA", "ONALASKA", "OPA LOCKA", "ORADLL", "ORION", 
"ORONO", "ORRINGTON", "OSCEOLA", "OSKALOOSA", "OSSINING", "OSWEGO", 
"OTTAWA", "OVALO", "OVERLAND PARK", "OWASSO", "OWEGO", "OXFORD", 
"OYSTER BAY", "OZARK", "PALERMO", "PALM CITY", "PALM HARBOR", 
"PALMDALE", "PALMYRA", "PALOS HEIGHTS", "PANA", "PAOLA", "PARK RIDGE", 
"PARLIN", "PARMA", "PARRISH", "PARROTT", "PATASKALA", "PAULS VALLEY", 
"PAXTON", "PEA RIDGE", "PEARLAND", "PECULIAR", "PEEKSKILL", "PEKIN", 
"PELION", "PEMBROKE", "PEMBROKE PINES", "PENN YAN", "PENNELLVILLE", 
"PENNSBURG", "PENNSVILLE", "PEORIA", "PERRY", "PERRYOPOLIS", 
"PERRYSBURG", "PERRYVILLE", "PHARR", "PHILADELPHIA", "PHILIPPI", 
"PHOENIX", "PICKENS", "PICKERINGTON", "PIERSON", "PILOT MOUNTAIN", 
"PINE BLUFF", "PINE HILL", "PINEVILLE", "PINNELLAS PARK", "PISCATAWAY", 
"PITMAN", "PITTSBURGH", "PLACIDA", "PLAINFIELD", "PLANO", "PLANT CITY", 
"PLATTEKILL", "PLEASANT

Re: [R] Help with Radius problem

2020-05-13 Thread Poling, William via R-help
Good morning Jim.

This is awesome start, visualization is splendid, thank you very much.

I have signed on to r-sig-geo and submitted my question there. I have no idea 
of the volume of traffic on that list
However, hopefully, I will gain additional insight into how to determine max 
number of member locations in the most minimum radius area.

Have a great day!

WHP



Proprietary

-Original Message-
From: Jim Lemon  
Sent: Wednesday, May 13, 2020 1:39 AM
To: Poling, William 
Cc: r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with Radius problem

 External Email - Use Caution 

Hi Bill,
A while ago I devised a couple of functions to accumulate millions of 
geographic locations of events and then display the resulting matrix of values 
on an existing plot. This may be of use to you, at least in the visualization 
of the density of the locations. As your example data only included a few 
points, the resulting plot looks pretty chunky as I had to use a large symbol 
to make the cells with non-zero counts obvious.

# read in your sample data
source("wp_data.R")
library(plotrix)
geomat<-makeDensityMatrix(geodat[,c("latitude","longitude")],
xlim=range(geodat$longitude),ylim=range(geodat$latitude))
# Range of density (>0) - 1.119816 3.922018
latlim<-range(geodat$latitude)
lonlim<-range(geodat$longitude)
library(maps)
map("world",xlim=lonlim,ylim=latlim)
axis(1)
axis(2)
densityGrid(geomat,range.cex=c(1,5),xlim=lonlim,ylim=latlim,
 red=c(0.5,1),green=0,blue=0,pch=15)

Jim

On Wed, May 13, 2020 at 10:57 AM Poling, William via R-help 
 wrote:
>
> #RStudio Version Version 1.2.1335
> sessionInfo()
> # R version 4.0.0 Patched (2020-05-03 r78349)
> #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 10 
> x64 (build 17763)
>
> Hello I am trying to figure out how to create concentration of ID's in 
> the following data, based on determining the highest concentration in 
> the smallest radius area based on Longitude and Latitude (geo 
> location)
>
> I have reviewed many websites looking for a function or tutorial, (if 
> you are aware of either please let me know)
>

NOTICE TO RECIPIENT OF INFORMATION:
This e-mail may contain confidential or privileged information. If you think 
you have received this e-mail in error, please advise the sender by reply 
e-mail and then delete this e-mail immediately.  
This e-mail may also contain protected health information (PHI) with 
information about sensitive medical conditions, including, but not limited to, 
treatment for substance use disorders, behavioral health, HIV/AIDS, or 
pregnancy. This type of information may be protected by various federal and/or 
state laws which prohibit any further disclosure without the express written 
consent of the person to whom it pertains or as otherwise permitted by law. Any 
unauthorized further disclosure may be considered a violation of federal and/or 
state law. A general authorization for the release of medical or other 
information may NOT be sufficient consent for release of this type of 
information.
Thank you. Aetna
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help with Radius problem

2020-05-13 Thread Poling, William via R-help
Good morning Bert. I will sign up for r-sig-geo and review your suggested link 
as well, thank you very much for your response.

WHP




Proprietary

-Original Message-
From: Bert Gunter  
Sent: Tuesday, May 12, 2020 8:30 PM
To: Poling, William 
Cc: r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with Radius problem

 External Email - Use Caution 

No insight But have you consulted:
https://urldefense.proofpoint.com/v2/url?u=https-3A__CRAN.R-2Dproject.org_view-3DSpatial&d=DwIBaQ&c=wluqKIiwffOpZ6k5sqMWMBOn0vyYnlulRJmmvOXCFpM&r=j7MrcIQm2xjHa8v-2mTpmTCtKvneM2ExlYvnUWbsByY&m=gbt_psl_UbXJa0-nqZs2cDd5cTAtzTGE6OOluljG2U0&s=aT7qePkClGUoKBh0QatR5mvySgsYeUp9gU0WLReStTU&e=
 

Also, I believe this would be better posted on r-sig-geo, not here.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and 
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Tue, May 12, 2020 at 5:57 PM Poling, William via R-help 
 wrote:
>
> #RStudio Version Version 1.2.1335
> sessionInfo()
> # R version 4.0.0 Patched (2020-05-03 r78349)
> #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 10 
> x64 (build 17763)
>
> Hello I am trying to figure out how to create concentration of ID's in 
> the following data, based on determining the highest concentration in 
> the smallest radius area based on Longitude and Latitude (geo 
> location)
>
> I have reviewed many websites looking for a function or tutorial, (if 
> you are aware of either please let me know)
>
> I have worked through the following to see if they are close to what I need, 
> but they are not.
>
> #Possible use 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com
> _questions_21977720_r-2Dfinding-2Dclosest-2Dneighboring-2Dpoint-2Dand-
> 2Dnumber-2Dof-2Dneighbors-2Dwithin-2Da-2Dgiven-2Drad&d=DwIBaQ&c=wluqKI
> iwffOpZ6k5sqMWMBOn0vyYnlulRJmmvOXCFpM&r=j7MrcIQm2xjHa8v-2mTpmTCtKvneM2
> ExlYvnUWbsByY&m=gbt_psl_UbXJa0-nqZs2cDd5cTAtzTGE6OOluljG2U0&s=t6qPeVA_
> C9VbEMtn5earDo2F53CkazDyPAQrL81PifM&e=
>
> #Possible math ref 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__janmatuschek.de_La
> titudeLongitudeBoundingCoordinates&d=DwIBaQ&c=wluqKIiwffOpZ6k5sqMWMBOn
> 0vyYnlulRJmmvOXCFpM&r=j7MrcIQm2xjHa8v-2mTpmTCtKvneM2ExlYvnUWbsByY&m=gb
> t_psl_UbXJa0-nqZs2cDd5cTAtzTGE6OOluljG2U0&s=o5R4BF22ow2gJd8RgJOS0pVRn6
> 6a4uCBcXXgK59Z1SM&e=
>
> #Possible use 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com
> _questions_39008850_find-2Dnumber-2Dof-2Dpoints-2Dwithin-2Da-2Dradius-
> 2Din-2Dr-2Dusing-2Dlon-2Dand-2Dlat-2Dcoordinates&d=DwIBaQ&c=wluqKIiwff
> OpZ6k5sqMWMBOn0vyYnlulRJmmvOXCFpM&r=j7MrcIQm2xjHa8v-2mTpmTCtKvneM2ExlY
> vnUWbsByY&m=gbt_psl_UbXJa0-nqZs2cDd5cTAtzTGE6OOluljG2U0&s=cr5fY67h9cmL
> ZlNVPGcJ5gysN_qVQC-xZetElqwYVhk&e=
>
> # 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__gis.stackexchange
> .com_questions_229453_create-2Da-2Dcircle-2Dof-2Ddefined-2Dradius-2Dar
> ound-2Da-2Dpoint-2Dand-2Dthen-2Dfind-2Dthe-2Doverlapping-2Da&d=DwIBaQ&
> c=wluqKIiwffOpZ6k5sqMWMBOn0vyYnlulRJmmvOXCFpM&r=j7MrcIQm2xjHa8v-2mTpmT
> CtKvneM2ExlYvnUWbsByY&m=gbt_psl_UbXJa0-nqZs2cDd5cTAtzTGE6OOluljG2U0&s=
> xK2iPfFjKfUevj39Uk8ux2OZYYxE3N4kOQU3ecP0W4M&e=
>
> # 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com
> _questions_23071026_drawing-2Da-2Dcircle-2Dwith-2Da-2Dradius-2Dof-2Da-
> 2Ddefined-2Ddistance-2Din-2Da-2Dmap_23072079-2323072079&d=DwIBaQ&c=wlu
> qKIiwffOpZ6k5sqMWMBOn0vyYnlulRJmmvOXCFpM&r=j7MrcIQm2xjHa8v-2mTpmTCtKvn
> eM2ExlYvnUWbsByY&m=gbt_psl_UbXJa0-nqZs2cDd5cTAtzTGE6OOluljG2U0&s=susH1
> Qr4Cz3oohO3OF6Bs6PWuAzo5hc7WMQccLvuX08&e=
>
> My actual data is 2353 records with 41 states and 1337 cities represented. 
> Here is a sample below.
>
> Some might call this a hotspot question I suppose: "What is the maximum 
> number of ID's I can gather in the smallest radius size given the data at 
> hand?
>
> For example it would be useful to have a function that I could use to test 
> different combinations of radius size and concentration of ID #'s by geo 
> location.
>
> Any insight would be very much appreciated.
>
> Thank you.
> WHP
>
> str(sample)
> 'data.frame':   35 obs. of  5 variables:
>  $ state: Factor w/ 41 levels "AL","AR","AZ",..: 19 29 9 9 10 30 33 35 41 
> 12 ...
>  $ city : Factor w/ 1337 levels "ABBOTTSTOWN",..: 281 1280 129 223 989 
> 721 550 731 1325 688 ...
>  $ latitude : num  43.5 40.1 26.5 27.9 31.9 ...
>  $ longitude: num  -7

[R] Help with Radius problem

2020-05-12 Thread Poling, William via R-help
#RStudio Version Version 1.2.1335 
sessionInfo() 
# R version 4.0.0 Patched (2020-05-03 r78349)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows 10 x64 (build 17763)

Hello I am trying to figure out how to create concentration of ID's in the 
following data, based on determining the highest concentration in the smallest 
radius area based on Longitude and Latitude (geo location)

I have reviewed many websites looking for a function or tutorial, (if you are 
aware of either please let me know)

I have worked through the following to see if they are close to what I need, 
but they are not.

#Possible use 
https://stackoverflow.com/questions/21977720/r-finding-closest-neighboring-point-and-number-of-neighbors-within-a-given-rad

#Possible math ref http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates

#Possible use 
https://stackoverflow.com/questions/39008850/find-number-of-points-within-a-radius-in-r-using-lon-and-lat-coordinates

# 
https://gis.stackexchange.com/questions/229453/create-a-circle-of-defined-radius-around-a-point-and-then-find-the-overlapping-a

# 
https://stackoverflow.com/questions/23071026/drawing-a-circle-with-a-radius-of-a-defined-distance-in-a-map/23072079#23072079

My actual data is 2353 records with 41 states and 1337 cities represented. Here 
is a sample below.

Some might call this a hotspot question I suppose: "What is the maximum number 
of ID's I can gather in the smallest radius size given the data at hand?

For example it would be useful to have a function that I could use to test 
different combinations of radius size and concentration of ID #'s by geo 
location.

Any insight would be very much appreciated.

Thank you.
WHP

str(sample)
'data.frame':   35 obs. of  5 variables:
 $ state: Factor w/ 41 levels "AL","AR","AZ",..: 19 29 9 9 10 30 33 35 41 
12 ...
 $ city : Factor w/ 1337 levels "ABBOTTSTOWN",..: 281 1280 129 223 989 721 
550 731 1325 688 ...
 $ latitude : num  43.5 40.1 26.5 27.9 31.9 ...
 $ longitude: num  -70.6 -82.9 -80.1 -82.7 -81.4 ...
 $ ID   : int  2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 ...

dput(sample)
structure(list(state = structure(c(19L, 29L, 9L, 9L, 10L, 30L, 
33L, 35L, 41L, 12L, 12L, 36L, 4L, 9L, 8L, 39L, 36L, 36L, 41L, 
28L, 12L, 28L, 28L, 12L, 11L, 2L, 12L, 22L, 32L, 22L, 12L, 10L, 
10L, 22L, 10L), .Label = c("AL", "AR", "AZ", "CA", "CO", "CT", 
"DC", "DE", "FL", "GA", "IA", "IL", "IN", "KS", "KY", "LA", "MA", 
"MD", "ME", "MI", "MN", "MO", "NC", "NE", "NJ", "NM", "NV", "NY", 
"OH", "OK", "OR", "PA", "SC", "SD", "TN", "TX", "UT", "VA", "WA", 
"WI", "WV"), class = "factor"), city = structure(c(281L, 1280L, 
129L, 223L, 989L, 721L, 550L, 731L, 1325L, 688L, 1184L, 281L, 
759L, 1171L, 1305L, 587L, 272L, 581L, 263L, 152L, 217L, 152L, 
390L, 5L, 571L, 1006L, 1162L, 939L, 170L, 1033L, 1002L, 586L, 
586L, 192L, 586L), .Label = c("ABBOTTSTOWN", "ABILENE", "ACWORTH", 
"ADAMS", "ADDISON", "ADKINS", "ALBANY", "ALBIA", "ALBUQUERQUE", 
"ALEXANDRIA", "ALFRED", "ALIQUIPPA", "ALISO VIEJO", "ALLEN PARK", 
"ALLENTOWN", "ALPHA", "ALPHARETTA", "ALPINE", "ALTOONA", "AMARILLO", 
"AMBLER", "AMBRIDGE", "AMHERST", "AMITYVILLE", "ANAHIEM", "ANDERSON", 
"ANDOVER", "ANGIER", "ANGLETON", "ANKENY", "ANN ARBOR", "ANZA", 
"APEX", "APOLLO", "ARCADIA", "ARCHDALE", "ARDMORE", "ARGYLE", 
"ARKANSAS CITY", "ARLINGTON", "ARNOLD", "ARTHUR", "ASHEBORO", 
"ASHEVILLE", "ASHLAND", "ASHLAND CITY", "ASHTON", "ASTON", "ATHENS", 
"ATLANTA", "ATLANTIC BCH", "AUBORN", "AUGUSTA", "AURORA", "AUSTELL", 
"AUSTIN", "AVENTURA", "AVONDALE ESTATES", "BAKERSFIELD", "BALDWIN CITY", 
"BALDWIN PLACE", "BALLWIN", "BANGOR", "BARBOURSVILLE", "BARNEGAT", 
"BARTLETT", "BARTON", "BARTONVILLE", "BASSETT", "BATAVIA", "BATESBURG", 
"BATON ROUGE", "BAXTER SPRINGS", "BAY CITY", "BAYONNE", "BAYSIDE", 
"BAYTOWN", "BEAR", "BEAUMONT", "BEECH CREEK", "BEECHER CITY", 
"BELFAIR", "BELLE VERNON", "BELLEAIR", "BELLEVUE", "BELLMAWR", 
"BELLMORE", "BELLWOOD", "BELMAR", "BELMONT", "BELVIDERE", "BENNET", 
"BENTON", "BENTONVILLE", "BERLIN", "BESSEMER CITY", "BETHANY", 
"BETHEL", "BETHEL PARK", "BETHESDA", "BETHLEHEM", "BETTENDORF", 
"BIGLERVILLE", "BINGHAMTON", "BIRDSBORO", "BIWABIK", "BLACK MOUNTAIN", 
"BLACKSBURG", "BLAINE", "BLAIRSVILLE", "BLAKESLEE", "BLOOMFIELD", 
"BLUE BELL", "BLUE GRASS", "BLUE POINT", "BLUE SPRINGS", "BOCA RATON", 
"BODFISH", "BOILING SPRINGS", "BOLIVAR", "BON AQUA", "BONNER SPRINGS", 
"BONNEY LAKE", "BOONEVILLE", "BOSSIER CITY", "BOUNTIFUL", "BOWLING GREEN", 
"BOYERTOWN", "BOYNTON BEACH", "BRADENTON", "BRADENVILLE", "BRANDAMORE", 
"BRANDON", "BRANFORD", "BRANSON", "BRASELTON", "BREEZEWOOD", 
"BRENTON", "BRENTWOOD", "BREWSTER", "BRICK", "BRIDGEPORT", "BRIDGETON", 
"BRIGHAM CITY", "BROADDUS", "BROCKPORT", "BROGUE", "BROKEN ARROW", 
"BRONX", "BROOKFIELD", "BROOKHAVEN", "BROOKLYN", "BROWNS MILLS", 
"BROWNSBURG", "BROWNSVILLE", "BRUNSWICK", "BRYAN", "BUCKSPORT", 
"BUDD LAKE", "BUFFALO", "BULVERDE", "BUNKERVILLE", "BURBANK", 
"BURFORD", "BURIEN", "BURLINGTON", "BURR RIDG

Re: [R] Help with Kmeans output and using broom to tidy etc..

2020-05-12 Thread Poling, William via R-help
RY", "DANIA BCH", "DANVILLE", "DAVENPORT",
"DAVIE", "DAVIS JUNCTION", "DAWSON", "DAYTON", "DE SOTO", "DECATUR",
"DEFIANCE", "DEFOREST", "DELAVAN", "DELMAR", "DELRAY BEACH",
"DEMOTTE", "DENISON", "DENVER", "DEPTFORD", "DERBY", "DERRY",
"DES MOINES", "DETROIT", "DICKINSON", "DILLSBURG", "DITTMER",
"DIXON", "DONNA", "DOTHAN", "DOUGLAS", "DOUGLASVILLE", "DOVER",
"DOYLESTOWN", "DREXEL HILL", "DUBLIN", "DUCHESNE", "DULUTH",
"DUNCAN", "DUNCANNON", "DUNCANSVILLE", "DUNEDIN", "DUNNSVILLE",
"DURHAM", "DUTTON", "EAGLE GROVE", "EAST AURORA", "EAST CHICAGO",
"EAST EARL", "EAST HANOVER", "EAST HARTFORD", "EAST HARTLAND",
"EAST LEROY", "EAST LIVERPOOL", "EAST MEADOW", "EAST NORTHPORT",
"EAST ORANGE", "EAST PEORIA", "EAST SAINT LOUIS", "EASTON", "EDGERTON",
"EDISON", "EDMOND", "EGG HBR TWP", "EL DORADO", "EL PASO", "ELDRIDGE",
"ELGIN", "ELIZABETHVILLE", "ELLISVILLE", "ELLSWORTH", "ELLWOOD CITY",
"ELMHURST", "ELMWOOD PARK", "ELOY", "ELY", "EMERSON", "EMORY",
"ENDICOTT", "ENGLEWOOD", "ENID", "ENNICE", "ENOLA", "ENUMCLAW",
"EPHRATA", "ERIE", "ESTERO", "EUREKA SPRINGS", "EVANSVILLE",
"EVERETT", "EXCELSIOR SPRINGS", "EXTON", "FAIRFAX", "FAIRFIELD",
"FAIRHAVEN", "FAIRVIEW", "FAIRVIEW PARK", "FALMOUTH", "FAR HILLS",
"FAR ROCKAWAY", "FARMINGDALE", "FARMINGTON", "FAYETTE", "FAYETTEVILLE",
"FELTON", "FENTON", "FERGUSON", "FIELDALE", "FINDLAY", "FINGERVILLE",
"FLEMINGTON", "FLINT", "FLORENCE", "FLORESVILLE", "FLORISSANT",
"FLOVILLA", "FLOWER MOUND", "FLUSHING", "FOGELSVILLE", "FOLSOM",
"FONTANELLE", "FOREST HILLS", "FOREST PARK", "FORT DODGE", "FORT FAIRFIELD",
"FORT GAY", "FORT LAUDERDALE", "FORT LEE", "FORT MILL", "FORT MOHAVE",
"FORT PAYNE", "FORT PIERCE", "FORT SMITH", "FORT WAYNE", "FORT WORTH",
"FOSTORIA", "FOUNTAIN INN", "FRANKFORT", "FRANKLIN", "FREEDOM",
"FREEHOLD", "FREEPORT", "FREMONT", "FULLERTON", "FULSHEAR", "FULTON",
"GADSDEN", "GAFFNEY", "GAINESVILLE", "GALLOWAY", "GARDEN PRAIRIE",
"GARDNERS", "GARNETT VALLEY", "GARY", "GASTON", "GASTONIA", "GENEVA",
"GETTYSBURG", "GIBSONIA", "GILBERT", "GIRARD", "GLEN BURNIE",
"GLEN CARBON", "GLEN COVE", "GLEN MILLS", "GLENSHAW", "GLENVIEW",
"GLENWOOD", "GOLDEN CITY", "GOLIAD", "GOODSON", "GOODYEAR", "GORHAM",
"GOSHEN", "GRANBURY", "GRANBY", "GRAND PRAIRIE", "GRAND RAPIDS",
"GRANDVIEW", "GRANITE CITY", "GRANITE FALLS", "GRANTS PASS",
"GRASS VALLEY", "GRAVETTE", "GRAYSVILLE", "GREEN LANE", "GREENBRIER",
"GREENLAWN", "GREENSBORO", "GREENSBURG", "GREENUP", "GREENVILLE",
"GREER", "GRIFFIN", "GRIFFITH", "GROTON", "GUADALUPE", "GUILFORD",
"HADLEY", "HAGAN", "HALF WAY", "HALLANDALE BEACH", "HAMBLETON",
"HAMBURG", "HAMDEN", "HAMILTON", "HAMMOND", "HAMMONTON", "HAMPSHIRE",
"HAPEVILLE", "HARBORCREEK", "HARLAN", "HARRISBURG", "HARRISON",
"HARRISONVILLE", "HARTWELL", "HASTINGS", "HATFIELD", "HAVERHILL",
"HAWK POINT", "HAYESVILLE", &q

Re: [R] Help with Kmeans output and using broom to tidy etc..

2020-05-12 Thread Poling, William via R-help
Hello Eric, thank you so much for your consideration.

Here are snippets of data that I hope will be helpful

WHP 

geo1a <- geo1[, c(2:5)] <-- eliminating ID which is not useful for my purposes 
anyway

#This is for R-Help use
geo1a <- geo1a %>% top_n(25)

state   city latitude longitude
1 ME  FAIRFIELD 44.64485 -69.65948
2 ME  JONESPORT 44.57935 -67.56743
3 MECASWELL 46.97529 -67.83023
4 ME  ELLSWORTH 44.52916 -68.38717
5 ME VASSALBORO 44.45095 -69.60629
6 ME  UNION 44.20059 -69.26123
7 MEPALERMO 44.45142 -69.41115
8 ME  ORONO 44.87426 -68.68327
9 MESANGERVILLE 45.10138 -69.33580
10ME  ISLESBORO 44.29015 -68.90812
11METOPSHAM 43.93600 -69.96565
12ME   FREEPORT 43.84089 -70.11160
13ME  SKOWHEGAN 44.76687 -69.71644
14MEMILLINOCKET 45.65501 -68.70261
15ME  ORRINGTON 44.72417 -68.74026
16ME ST. GEORGE 43.96726 -69.20827
17ME FORT FAIRFIELD 46.80911 -67.88079
18ME  MARS HILL 46.56580 -67.89006
19ME   FREEPORT 43.85302 -70.03726
20ME EASTON 46.64143 -67.91203
21ME WATERVILLE 44.53621 -69.65913
22ME  BRUNSWICK 43.87771 -69.96297
23ME  BRUNSWICK 43.91719 -69.89905
24ME  BUCKSPORT 44.60665 -68.81892
25MEFAYETTE 44.46380 -70.12047


trnd1_tbla <- trnd1_tbl %>% top_n(25)
print(trnd1_tbla)
head(trnd1_tbla,n=25)

A tibble: 25 x 5
   city  state Basecountsum Basecount2 prop_of_total
   
 1 ATLANTA   GA2352 12   0.00510
 2 BRADENTON FL2352  8   0.00340
 3 BROOKLYN  NY2352 30   0.0128 
 4 CHARLOTTE NC2352  8   0.00340
 5 CHICAGO   IL2352 17   0.00723
 6 COLUMBUS  OH2352 11   0.00468
 7 CUMMING   GA2352  8   0.00340
 8 DALLASTX2352  8   0.00340
 9 ERIE  PA2352 12   0.00510
10 HOUSTON   TX2352 12   0.00510
# ... with 15 more rows

WHP

From: Eric Berger  
Sent: Tuesday, May 12, 2020 8:39 AM
To: Poling, William 
Cc: r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with Kmeans output and using broom to tidy 
etc..

 External Email - Use Caution 
Can you create a reproducible example? 
Your question involves objects that are unknown to us. (geo1, trnd1_tbl)

On Tue, May 12, 2020 at 2:41 PM Poling, William via R-help 
<mailto:r-help@r-project.org> wrote:
#RStudio Version Version 1.2.1335 need this one--> 1.2.5019
sessionInfo() 
# R version 4.0.0 Patched (2020-05-03 r78349)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows 10 x64 (build 17763)

Hello:

I have data that I am trying to manipulate for Kmeans clustering.

Original data looks like this

str(geo1) 
# 'data.frame': 2352 obs. of  5 variables:
# $ ID: Factor w/ 2352 levels "101040199600",..: 590 908 976 509 1674 690 1336 
86 726 1702 ...
# $ state           : Factor w/ 41 levels "AL","AR","AZ",..: 32 10 25 11 9 32 
13 31 12 12 ...
# $ city            : Factor w/ 1337 levels "ABBOTTSTOWN",..: 932 156 230 698 
965 1330 515 727 1127 1304 ...
# $ latitude        : num  40.4 31.2 40.8 42.1 26.8 ...
# $ longitude       : num  -79.9 -81.5 -74 -91.6 -82.1 ...

I created a subset adding column prop_of_total 
str(trnd1_tbl)
tibble [1,457 x 5] (S3: tbl_df/tbl/data.frame)
 $ city         : Factor w/ 1337 levels "ABBOTTSTOWN",..: 1 2 3 4 5 6 7 8 9 10 
...
 $ state        : Factor w/ 41 levels "AL","AR","AZ",..: 32 36 10 28 12 36 10 
11 26 38 ...
 $ Basecountsum : num [1:1457] 2352 2352 2352 2352 2352 ...
 $ Basecount2   : num [1:1457] 1 1 1 1 1 2 1 1 2 1 ...
 $ prop_of_total: num [1:1457] 0.000425 0.000425 0.000425 0.000425 0.000425 ...


Then I spread it

trnd2_tbl <- trnd1_tbl %>% 
    dplyr::select(city, state, prop_of_total) %>% 
    spread(key = city, value = prop_of_total, fill = 0) #remove the NA's with 
fill

str(trnd2_tbl)#tibble [41 x 1,338] (S3: tbl_df/tbl/data.frame)

Then I run a Kmeans

kmeans_obj1 <- trnd2_tbl  %>% 
  dplyr::select(- state) %>% 
  kmeans(centers = 20, nstart = 100)

str(kmeans_obj1)
List of 9
 $ cluster     : int [1:41] 11 11 9 11 11 4 11 11 16 2 ...
 $ centers     : num [1:20, 1:1337] 0 0 0 0 0 0 0 0 0 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:20] "1" "2" "3" "4" ...
  .. ..$ : chr [1:1337] "ABBOTTSTOWN" "ABILENE" "ACWORTH" "ADAMS" ...
 $ totss       : num 0.00158
 $ withinss    : num [1:20] 0 0 0 0 0 0 0 0 0 0 ...
 $ tot.withinss: num 0.848
 $ betweenss   : num 0.0015
 $ size        : int [1:20] 1 1 1 1 1 1 1 1 1 1 ...
 $ iter        : int 3
 $ ifault    

Re: [R] Help with R-Markdown please

2020-05-12 Thread Poling, William via R-help
Wow, ok, yep 
"winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library"

Thank you Ege. I did not have this issue with previous employer, I will see 
what our IT group says.

Thank you 

WHP


William H. Poling Ph.D., MPH  | Senior Data Scientist, Medicare Stars, CVS 
Health 
p 813-777-5030


Proprietary

-Original Message-
From: Ege Rubak  
Sent: Tuesday, May 12, 2020 7:43 AM
To: Poling, William ; r-help@r-project.org
Subject: [EXTERNAL] Re: [R] Help with R-Markdown please

 External Email - Use Caution 

Looks like your files are on a Windows network drive (UNC path). I have 
experienced many problems with this on a Windows laptop from work. If at all 
possible you should avoid this. As an absolute minimum make sure your R library 
(collection of installed packages) is on the local file system and not a UNC 
path. If you are lucky this could be enough to make things work.

You can check your library location(s) with the command .libPaths() in an R 
session.

Good luck.

Ege

On Tue, 2020-05-12 at 10:15 +0000, Poling, William via R-help wrote:
> #UPDATED 05/05/2020
> #RStudio Version Version 1.2.1335 need this one--> 1.2.5019
> sessionInfo()
> # R version 4.0.0 Patched (2020-05-03 r78349)
> #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows 10 
> x64 (build 17763)
> 
> Good morning.
> 
> This is the first time I have tried RMarkdown on new laptop with new 
> employer.
> I am not sure how to go about fixing this problem below?
> 
> Would someone please advise course of action.
> 
> Thank you.
> 
> WHP
> 
> 
> 
> processing file: Member-Geo-Location-Test-V1.Rmd
>  
> |..  
>   |  14%
>   ordinary text without R code
> 
>  
> |
>   |  29%
> label: unnamed-chunk-1 (with options) List of 1  $ echo: logi FALSE
> 
>  
> |..  
>   |  43%
>   ordinary text without R code
> 
>  
> |
>   |  57%
> label: setup (with options)
> List of 2
>  $ include: logi FALSE
>  $ warning: logi FALSE
> 
>  
> |..  
>   |  71%
>   ordinary text without R code
> 
>  
> |
>   |  86%
> label: Table1 (with options)
> List of 2
>  $ echo   : logi FALSE
>  $ results: chr "asis"
> 
>  
> |
> ..| 100%
>inline R code fragments
> 
> 
> output file: Member-Geo-Location-Test-V1.knit.md
> 
> "C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Member- 
> Geo-Location-Test-V1.utf8.md --to html4 --from
> markdown+autolink_bare_uris+tex_math_single_backslash+smart --output
> Member-Geo-Location-Test-V1.html --email-obfuscation none --self- 
> contained --standalone --section-divs --template "\\winp-oaf-
> 113\FldrRedir_1$\A436798\Data\R\R-
> 4.0.0patched\library\rmarkdown\rmd\h\default.html" --no-highlight -- 
> variable highlightjs=1 --variable "theme:bootstrap" --include-in- 
> header "C:\Users\A436798\AppData\Local\Temp\RtmpSajZla\rmarkdown-
> str2ae846253313.html" --mathjax --variable "mathjax-url:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__mathjax.rstudio.c
> om_latest_MathJax.js-3Fconfig-3DTeX-2DAMS-2DMML-5FHTMLorMML&d=DwIGaQ&c
> =wluqKIiwffOpZ6k5sqMWMBOn0vyYnlulRJmmvOXCFpM&r=j7MrcIQm2xjHa8v-2mTpmTC
> tKvneM2ExlYvnUWbsByY&m=uBce0mQRO8wdLXO8BDTtjk4R92KVzpjtkQ-NqYiAHCo&s=S
> MNU_B--j9FvBKh-0u1NG5RHd7AtLkvyVsi9ybyUwYU&e=
> " --lua-filter "\\winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-
> 4.0.0patched/library/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter
> "\\winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-
> 4.0.0patched/library/rmarkdown/rmd/lua/latex-div.lua" 
> Could not fetch http://?/UNC/winp-oaf-
> 113/FldrRedir_1$/A436798/Data/R/R-
> 4.0.0patched/library/rmarkdown/rmd/h/default.html
> HttpExceptionRequest Request {
>   host = ""
>   port = 80
>   secure   = False
>   requestHeaders   = []
>   path = "/"
>   queryString  = "?/UNC/winp-oaf-
> 113/FldrRedir_1$/A436798/Data/R/R-
> 4.0.0patched/library/rmarkdown/rmd/h/default.html"
>   method   = "GET"
>   proxy= Nothing
>   rawBody  = False
>   redirectCount= 10
>   responseTimeout  = ResponseTime

[R] Help with R-Markdown please

2020-05-12 Thread Poling, William via R-help
#UPDATED 05/05/2020
#RStudio Version Version 1.2.1335 need this one--> 1.2.5019
sessionInfo() 
# R version 4.0.0 Patched (2020-05-03 r78349)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows 10 x64 (build 17763)

Good morning.

This is the first time I have tried RMarkdown on new laptop with new employer.
I am not sure how to go about fixing this problem below?

Would someone please advise course of action.

Thank you.

WHP 



processing file: Member-Geo-Location-Test-V1.Rmd
  |..|  14%
  ordinary text without R code

  |  |  29%
label: unnamed-chunk-1 (with options) 
List of 1
 $ echo: logi FALSE

  |..|  43%
  ordinary text without R code

  |  |  57%
label: setup (with options) 
List of 2
 $ include: logi FALSE
 $ warning: logi FALSE

  |..|  71%
  ordinary text without R code

  |  |  86%
label: Table1 (with options) 
List of 2
 $ echo   : logi FALSE
 $ results: chr "asis"

  |..| 100%
   inline R code fragments


output file: Member-Geo-Location-Test-V1.knit.md

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS 
Member-Geo-Location-Test-V1.utf8.md --to html4 --from 
markdown+autolink_bare_uris+tex_math_single_backslash+smart --output 
Member-Geo-Location-Test-V1.html --email-obfuscation none --self-contained 
--standalone --section-divs --template 
"\\winp-oaf-113\FldrRedir_1$\A436798\Data\R\R-4.0.0patched\library\rmarkdown\rmd\h\default.html"
 --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" 
--include-in-header 
"C:\Users\A436798\AppData\Local\Temp\RtmpSajZla\rmarkdown-str2ae846253313.html" 
--mathjax --variable 
"mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
 --lua-filter 
"\\winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library/rmarkdown/rmd/lua/pagebreak.lua"
 --lua-filter 
"\\winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library/rmarkdown/rmd/lua/latex-div.lua"
 
Could not fetch 
http://?/UNC/winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library/rmarkdown/rmd/h/default.html
HttpExceptionRequest Request {
  host = ""
  port = 80
  secure   = False
  requestHeaders   = []
  path = "/"
  queryString  = 
"?/UNC/winp-oaf-113/FldrRedir_1$/A436798/Data/R/R-4.0.0patched/library/rmarkdown/rmd/h/default.html"
  method   = "GET"
  proxy= Nothing
  rawBody  = False
  redirectCount= 10
  responseTimeout  = ResponseTimeoutDefault
  requestVersion   = HTTP/1.1
}
 (InvalidDestinationHost "")
Error: pandoc document conversion failed with error 61
Execution halted

WHP


Proprietary

NOTICE TO RECIPIENT OF INFORMATION:\ This e-mail may con...{{dropped:16}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Help with Kmeans output and using broom to tidy etc..

2020-05-12 Thread Poling, William via R-help
#RStudio Version Version 1.2.1335 need this one--> 1.2.5019
sessionInfo() 
# R version 4.0.0 Patched (2020-05-03 r78349)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows 10 x64 (build 17763)

Hello:

I have data that I am trying to manipulate for Kmeans clustering.

Original data looks like this

str(geo1) 
# 'data.frame': 2352 obs. of  5 variables:
# $ ID: Factor w/ 2352 levels "101040199600",..: 590 908 976 509 1674 690 1336 
86 726 1702 ...
# $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 32 10 25 11 9 32 
13 31 12 12 ...
# $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 932 156 230 698 
965 1330 515 727 1127 1304 ...
# $ latitude: num  40.4 31.2 40.8 42.1 26.8 ...
# $ longitude   : num  -79.9 -81.5 -74 -91.6 -82.1 ...

I created a subset adding column prop_of_total 
str(trnd1_tbl)
tibble [1,457 x 5] (S3: tbl_df/tbl/data.frame)
 $ city : Factor w/ 1337 levels "ABBOTTSTOWN",..: 1 2 3 4 5 6 7 8 9 10 
...
 $ state: Factor w/ 41 levels "AL","AR","AZ",..: 32 36 10 28 12 36 10 
11 26 38 ...
 $ Basecountsum : num [1:1457] 2352 2352 2352 2352 2352 ...
 $ Basecount2   : num [1:1457] 1 1 1 1 1 2 1 1 2 1 ...
 $ prop_of_total: num [1:1457] 0.000425 0.000425 0.000425 0.000425 0.000425 ...


Then I spread it

trnd2_tbl <- trnd1_tbl %>% 
dplyr::select(city, state, prop_of_total) %>% 
spread(key = city, value = prop_of_total, fill = 0) #remove the NA's with 
fill

str(trnd2_tbl)#tibble [41 x 1,338] (S3: tbl_df/tbl/data.frame)

Then I run a Kmeans

kmeans_obj1 <- trnd2_tbl  %>% 
  dplyr::select(- state) %>% 
  kmeans(centers = 20, nstart = 100)

str(kmeans_obj1)
List of 9
 $ cluster : int [1:41] 11 11 9 11 11 4 11 11 16 2 ...
 $ centers : num [1:20, 1:1337] 0 0 0 0 0 0 0 0 0 0 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:20] "1" "2" "3" "4" ...
  .. ..$ : chr [1:1337] "ABBOTTSTOWN" "ABILENE" "ACWORTH" "ADAMS" ...
 $ totss   : num 0.00158
 $ withinss: num [1:20] 0 0 0 0 0 0 0 0 0 0 ...
 $ tot.withinss: num 0.848
 $ betweenss   : num 0.0015
 $ size: int [1:20] 1 1 1 1 1 1 1 1 1 1 ...
 $ iter: int 3
 $ ifault  : int 0
 - attr(*, "class")= chr "kmeans"

Then I go and try to tidy:

#Tidy, glance, augment
#Just makes it easier to use or view the obj's in the obj list
  
  broom::tidy(kmeans_obj1) %>% glimpse()

broom::glance(kmeans_obj1)
##A tibble: 1 x 4
# totss tot.withinss betweenss  iter
#   
#   1 0.001580.848   0.00150 3

However, when I run this piece I get an error:

broom::augment(kmeans_obj1, trnd2_tbl) %>% 
  dplyr::select(city, .cluster) 

#Error: Must subset columns with a valid subscript vector.
# The subscript has the wrong type `data.frame<
 # u: double
#  x: double
>`.
i It must be numeric or character.

Here is the back trace:

rlang::last_error()

# Backtrace:
#   1. broom::augment(kmeans_obj1, trnd2_tbl)
# 9. dplyr::select(., city, .cluster)
# 11. tidyselect::vars_select(tbl_vars(.data), !!!enquos(...))
# 12. tidyselect:::eval_select_impl(...)
# 20. tidyselect:::vars_select_eval(...)
# 21. tidyselect:::walk_data_tree(expr, data_mask, context_mask)
# 22. tidyselect:::eval_c(expr, data_mask, context_mask)
# 23. tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
# 24. tidyselect:::walk_data_tree(new, data_mask, context_mask)
# 25. tidyselect:::as_indices_sel_impl(...)
# 26. tidyselect:::as_indices_impl(x, vars, strict = strict)
# 27. vctrs::vec_as_subscript(x, logical = "error")

I am not sure what I am supposed to fix?

Maybe someone has had similar error and can advise me please?

Thank you.

WHP







Proprietary

NOTICE TO RECIPIENT OF INFORMATION:\ This e-mail may con...{{dropped:16}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.