[R] gdistance::accCost fails on some cases

2020-05-14 Thread Deniz Ugur
Referring to my mail bellow, this situation is not a expected behavior. Do
you think that this is because of a fault in my codes or some bug in
gdistance? What could be the problem?

Thank you for your consideration.

-- Forwarded message -
From: Deniz Uğur 
Date: Thu, May 14, 2020, 02:18
Subject: gdistance::accCost fails when nrows is bigger than 90
To: 


Hello all,

It has been only 2 days since I started using R and I was trying movecost
library. Before explaining the unexpected behavior I should say that I’m
calling R function from Python using rpy2 package. That shouldn’t be an
issue because everything works as expected when a matrix of size 100x90 is
given.

Okay now, basically I’m converting an 2D matrix to RasterLayer with
appropriate CRS and extent properties then transfer it to R runtime. A
modified version of Tobler’s hiking function is applied then a
shortest-path is calculated. This procedure works for a matrix with column
size anywhere between 1 and memory’s limit. However if row size of the
matrix exceeds 90 then function is halted on gdistance::accCost saying that:

"At structural_properties.c:5313 : cannot run Bellman-Ford algorithm,
Negative loop detected while calculating shortest paths”

It’s very interesting issue because I have explicitly tried …88, 89, 90, 91
and it halted on +90

I’ve created a gist in case you want to try the application on your
computer. Also I’ve included a clean version of the R script I was using
bellow.

Thank you.

https://gist.github.com/DenizUgur/01e18edd03321f3d3928c3afb2bd7145

movecost <- function (dtm, origin, destin, time="s") {

altDiff <- function(x){x[2] - x[1]}
hd <- gdistance::transition(dtm, altDiff, 8, symm=FALSE)

slope <- gdistance::geoCorrection(hd)

cost_function <- function(x){ ifelse(x[adj] > 0, 1.3 * exp(-3.5 * abs(x[adj]
+ 0.05)), 5.3 * exp(-3.5 * abs(x[adj] + 0.05))) }

adj <- raster::adjacent(dtm, cells=1:ncell(dtm), pairs=TRUE, directions=8)
speed <- slope
speed[adj] <- cost_function(slope)
speed <- speed * 0.278
Conductance <- gdistance::geoCorrection(speed)

accum_final <- gdistance::accCost(Conductance, sp::coordinates(origin))

accum_final <- raster::mask(accum_final, dtm)

sPath <- gdistance::shortestPath(Conductance, sp::coordinates(origin), sp::
coordinates(destin), output="SpatialLines")
sPath$length <- rgeos::gLength(sPath, byid=TRUE)
destin$cost <- raster::extract(accum_final, destin)
results <- list("accumulated.cost.raster"=accum_final,
"LCPs"=sPath,
"dest.loc.w.cost"=destin)
}

[[alternative HTML version deleted]]

__
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] sort

2020-05-14 Thread Jim Lemon
Hi Val,
Your problem is keeping the orders straight. You want dates decreasing
and names increasing:

DF1<-read.table(text="name ddate
  A  2019-10-28
  A  2018-01-25
  A  2020-01-12
  A  2017-10-20
  B  2020-11-20
  B  2019-10-20
  B  2017-05-20
  B  2020-01-20
  C  2009-10-01  ",header=TRUE)
DF1$Time<-as.POSIXct(DF1$ddate , format = "%Y-%m-%d")
# get dates in decreasing order
DF2<-DF1[order(DF1$Time,decreasing=TRUE),]
# create the final output with the names in increasing order
DF3<-data.frame(name=sort(unique(DF2$name)))
# create a function that returns the first diff of a vector
getdate1diff<-function(x)
 return(ifelse(length(x)>1,abs(diff(x))[1],0))
# apply the function by the unique names in DF2
DF3$date1diff<-by(DF2$Time,DF2$name,getdate1diff)
DF3

Jim

On Fri, May 15, 2020 at 1:00 PM Val  wrote:
>
> HI All,
> I have a sample of data frame
> DF1<-read.table(text="name ddate
>   A  2019-10-28
>   A  2018-01-25
>   A  2020-01-12
>   A  2017-10-20
>   B  2020-11-20
>   B  2019-10-20
>   B  2017-05-20
>   B  2020-01-20
>   c  2009-10-01  ",header=TRUE)
>
> 1. I want sort by name and ddate on decreasing order and the output
> should like as follow
>A  2020-01-12
>A  2019-01-12
>A  2018-01-25
>A  2017-10-20
>B  2020-11-21
>   B  2020-11-01
>   B  2019-10-20
>   B  2017-05-20
>   c  2009-10-01
>
> 2.  Take the top two rows by group( names) and the out put should like
>A  2020-01-12
>A  2019-01-12
>B  2020-11-21
>B  2020-11-01
> c  2009-10-01
>
> 3.  Within each group (name) get the date difference  between the
> first and second rows dates. If a group has only one row then the
> difference should be 0
>
> The final out put is
> Name diff
>A  365
> B  20
> C  0
>
> Here is my attempt and have an issue at the sorting
> DF1$DTime <- as.POSIXct(DF1$ddate , format = "%Y-%m-%d")
> DF2 <- DF1[order(DF1$name, ((as.Date(DF1$DTime, decreasing = TRUE, ]
>
> not working
> Any help?
>
> Thank you
>
> __
> 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@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] [External] sort

2020-05-14 Thread Richard M. Heiberger
## the data you gave us

DF1 <- read.table(text="name ddate
  A  2019-10-28
  A  2018-01-25
  A  2020-01-12
  A  2017-10-20
  B  2020-11-20
  B  2019-10-20
  B  2017-05-20
  B  2020-01-20
  c  2009-10-01  ",
  header=TRUE, colClasses=c("character", "POSIXct"))

DF1

D2 <- split(DF1, DF1$name)
D2

sapply(D2, function(x) {
  DD <- c(sort(x$ddate, decreasing=TRUE), min(x$ddate))
  DD[1]-DD[2]
})


## the data that your intended answer is based on

DF1 <- read.table(text="name ddate
  A  2019-01-12  ## intended value
  A  2018-01-25
  A  2020-01-12
  A  2017-10-20
  B  2020-11-20
  B  2019-10-20
  B  2017-05-20
  B  2020-01-20
  c  2009-10-01  ",
  header=TRUE, colClasses=c("character", "POSIXct"))

DF1

D2 <- split(DF1, DF1$name)
D2

sapply(D2, function(x) {
  DD <- c(sort(x$ddate, decreasing=TRUE), min(x$ddate))
  DD[1]-DD[2]
})

On Thu, May 14, 2020 at 11:00 PM Val  wrote:

> HI All,
> I have a sample of data frame
> DF1<-read.table(text="name ddate
>   A  2019-10-28
>   A  2018-01-25
>   A  2020-01-12
>   A  2017-10-20
>   B  2020-11-20
>   B  2019-10-20
>   B  2017-05-20
>   B  2020-01-20
>   c  2009-10-01  ",header=TRUE)
>
> 1. I want sort by name and ddate on decreasing order and the output
> should like as follow
>A  2020-01-12
>A  2019-01-12
>A  2018-01-25
>A  2017-10-20
>B  2020-11-21
>   B  2020-11-01
>   B  2019-10-20
>   B  2017-05-20
>   c  2009-10-01
>
> 2.  Take the top two rows by group( names) and the out put should like
>A  2020-01-12
>A  2019-01-12
>B  2020-11-21
>B  2020-11-01
> c  2009-10-01
>
> 3.  Within each group (name) get the date difference  between the
> first and second rows dates. If a group has only one row then the
> difference should be 0
>
> The final out put is
> Name diff
>A  365
> B  20
> C  0
>
> Here is my attempt and have an issue at the sorting
> DF1$DTime <- as.POSIXct(DF1$ddate , format = "%Y-%m-%d")
> DF2 <- DF1[order(DF1$name, ((as.Date(DF1$DTime, decreasing = TRUE, ]
>
> not working
> Any help?
>
> Thank you
>
> __
> 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.
>

[[alternative HTML version deleted]]

__
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 map()

2020-05-14 Thread Jim Lemon


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://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 C

[R] sort

2020-05-14 Thread Val
HI All,
I have a sample of data frame
DF1<-read.table(text="name ddate
  A  2019-10-28
  A  2018-01-25
  A  2020-01-12
  A  2017-10-20
  B  2020-11-20
  B  2019-10-20
  B  2017-05-20
  B  2020-01-20
  c  2009-10-01  ",header=TRUE)

1. I want sort by name and ddate on decreasing order and the output
should like as follow
   A  2020-01-12
   A  2019-01-12
   A  2018-01-25
   A  2017-10-20
   B  2020-11-21
  B  2020-11-01
  B  2019-10-20
  B  2017-05-20
  c  2009-10-01

2.  Take the top two rows by group( names) and the out put should like
   A  2020-01-12
   A  2019-01-12
   B  2020-11-21
   B  2020-11-01
c  2009-10-01

3.  Within each group (name) get the date difference  between the
first and second rows dates. If a group has only one row then the
difference should be 0

The final out put is
Name diff
   A  365
B  20
C  0

Here is my attempt and have an issue at the sorting
DF1$DTime <- as.POSIXct(DF1$ddate , format = "%Y-%m-%d")
DF2 <- DF1[order(DF1$name, ((as.Date(DF1$DTime, decreasing = TRUE, ]

not working
Any help?

Thank you

__
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] Automating package updates after major version change

2020-05-14 Thread Rich Shepard

On Thu, 14 May 2020, Jeff Newmiller wrote:


Running R as root, ever, is a completely unnecessary elevation of
privileges... but that discussion is getting OT as it pertains to OS
security and stability rather than R language.


Only to upgrade the core package and install/update CRAN packages. All work
is done as a user.

Rich

__
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] Automating package updates after major version change

2020-05-14 Thread Jeff Newmiller
Running R as root, ever, is a completely unnecessary elevation of privileges... 
but that discussion is getting OT as it pertains to OS security and stability 
rather than R language.

On May 14, 2020 2:21:43 PM PDT, Rich Shepard  wrote:
>On Thu, 14 May 2020, Jeff Newmiller wrote:
>
>> On the contrary... that is the use case in which it makes the least
>sense
>> to muck with system files. System files are maintained using system
>> package management tools which at best lag terribly, while R packages
>are
>> much easier to manage using R's internal package tools with no
>elevated
>> privileges.
>
>Jeff,
>
>I must not be following your thoughts. The slackbuilds.org group
>maintains a
>package for the current R distribution (when the maintainer gets around
>to
>checking that the build script works with the source.) Every library
>not
>provided in the core R distribution I download and install from the
>local
>CRAN mirror.
>
>All Slackware distribution executables are stored in /usr/bin/. Most of
>the
>SBo application packages are also installed there.
>
>Application-specific functions are the province of the user and I let
>root
>download, build, and install R packages.
>
>Regards,
>
>Rich
>
>__
>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.

-- 
Sent from my phone. Please excuse my brevity.

__
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 map()

2020-05-14 Thread Mark Fowler
Any chance you forgot to load a library (e.g. maps) for the second round, or 
maybe changed a loading sequence and overwrote the intended map function? Looks 
like #2 might be trying to use a purrr-style map function.

Sent from Mail for Windows 10

From: Poling, William via R-help
Sent: May 14, 2020 7:23 AM
To: r-help@r-project.org
Subject: [R] Help with map()

#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 C

Re: [R] Automating package updates after major version change

2020-05-14 Thread Rich Shepard

On Thu, 14 May 2020, Jeff Newmiller wrote:


On the contrary... that is the use case in which it makes the least sense
to muck with system files. System files are maintained using system
package management tools which at best lag terribly, while R packages are
much easier to manage using R's internal package tools with no elevated
privileges.


Jeff,

I must not be following your thoughts. The slackbuilds.org group maintains a
package for the current R distribution (when the maintainer gets around to
checking that the build script works with the source.) Every library not
provided in the core R distribution I download and install from the local
CRAN mirror.

All Slackware distribution executables are stored in /usr/bin/. Most of the
SBo application packages are also installed there.

Application-specific functions are the province of the user and I let root
download, build, and install R packages.

Regards,

Rich

__
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] How to find a split point in a curve?

2020-05-14 Thread Gabor Grothendieck
We can use nls2 to try each value in 10:100 as a possible split point
picking the one with lowest residual sum of squares:

library(nls2)
fm <- nls2(Y ~ cbind(1, pmin(X, X0)), start = data.frame(X0 = 10:100),
  algorithm = "plinear-brute")
plot(Y ~ X)
lines(fitted(fm) ~ X, col = "red")

> fm
Nonlinear regression model
  model: Y ~ cbind(1, pmin(X, X0))
   data: parent.frame()
 X0   .lin1   .lin2
18.  6.5570  0.2616
 residual sum-of-squares: 4.999

Number of iterations to convergence: 91
Achieved convergence tolerance: NA

On Thu, May 14, 2020 at 11:13 AM Luigi Marongiu
 wrote:
>
> Dear all,
> I am trying to find a turning point in some data. In the initial phase, the
> data increases more or less exponentially (thus it is linear in a nat log
> transform), then reaches a plateau. I would like to find the point that
> marks the end of the exponential phase.
> I understand that the function spline can build a curve; is it possible
> with it to find the turning points? I have no idea of how to use spline
> though.
> Here is a working example.
> Thank you
>
> ```
> Y = c(259, 716, 1404, 2173, 3944, 5403, 7140, 9121,
>   11220, 13809, 16634, 19869, 23753, 27447,
>   30590, 33975, 36627, 39600, 42067, 44082,
>   58190, 63280, 65921, 67929, 69977, 71865,
>   73614, 74005, 74894, 75717, 76365, 76579,
>   77087, 77493, 77926, 78253, 78680, 79253,
>   79455, 79580, 79699, 79838, 79981, 80080,
>   80124, 80164, 80183, 80207, 80222, 80230,
>   80241, 80261, 80261, 80277, 80290, 80303,
>   80337, 80376, 80422, 80461, 80539, 80586,
>   80653, 80708, 80762, 80807, 80807, 80886,
>   80922, 80957, 80988, 81007, 81037, 81076,
>   81108, 81108, 81171, 81213, 81259, 81358,
>   81466, 81555, 81601, 81647, 81673, 81998,
>   82025, 82041, 82053, 82064, 82094, 82104,
>   82110, 82122, 82133, 82136, 82142, 82164,
>   82168, 82180, 82181, 82184, 82187, 82188,
>   82190, 82192, 82193, 82194)
> Y = log(Y)
> X = 1:length(Y)
> plot(Y ~ X, ylab = "Ln(Y)", xlim=c(0,10, main="zoomed in"))
> abline(lm(Y[1:3] ~ X[1:3]))
> abline(lm(Y[1:5] ~ X[1:5]), lty=2)
> text(7, 6, "After third or fifth point, there is deviance", pos=3)
> text(2.5, 10, "Solid line: linear model points 1:3", pos =3)
> text(2.5, 9, "Dashed line: linear model points 1:5", pos =3)
> plot(Y ~ X, ylab = "Ln(Y)", xlim=c(0,10, main="overall"))
> abline(lm(Y[1:3] ~ X[1:3]))
> ```
>
> [[alternative HTML version deleted]]
>
> __
> 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.



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
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] Automating package updates after major version change

2020-05-14 Thread Jeff Newmiller
On the contrary... that is the use case in which it makes the least sense to 
muck with system files. System files are maintained using system package 
management tools which at best lag terribly, while R packages are much easier 
to manage using R's internal package tools with no elevated privileges.

On May 14, 2020 11:15:02 AM PDT, Rich Shepard  wrote:
>On Thu, 14 May 2020, Jeff Newmiller wrote:
>
>> Why are you mucking with the system-level library? It is quite
>unusual to
>> have a use-case in which you should not be adjusting your personal
>> library.
>
>Jeff,
>
>I'm the only user so there's no difference.
>
>Regards,
>
>Rich
>
>__
>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.

-- 
Sent from my phone. Please excuse my brevity.

__
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] Automating package updates after major version change

2020-05-14 Thread Rich Shepard

On Thu, 14 May 2020, Sarah Goslee wrote:


If you don't mind, I'm curious what didn't work - I would like to be
able to update the document accordingly.


Sarah,

Here's part of the sequence:


install.packages('packagelist')

Warning message:
package ‘packagelist’ is not available (for R version 4.0.0) 

source('newversionupdate.R')

Error in install.packages(packagelist) : object 'packagelist' not found

.libpath

Error: object '.libpath' not found

.libpath()

Error in .libpath() : could not find function ".libpath"

.libpaths()

Error in .libpaths() : could not find function ".libpaths"

libpaths()

Error in libpaths() : could not find function "libpaths"

?libpaths

No documentation for ‘libpaths’ in specified packages and libraries:
you could try ‘??libpaths’

?libpaths()

Error in .helpForCall(topicExpr, parent.frame()) :
  no methods for ‘libpaths’ and no documentation for it as a function

?.libpaths()



When you used
.libPaths()


Oops! I missed the uppercase 'P'.


.libPaths()

[1] "/usr/lib64/R/library"


what did it tell you? Did you edit that result to be for the previous
version, and swap that into the list.files() command? I thought about
automating it, but I can't be sure what previous version you're
upgrading from.


When I upgrade a package, such as R, the old version is removed. My library
has remained the same over many R package upgrades.


I suspect you tried to run the code by copy and paste, and not by putting
in your own path, but if so then I'd like to improve the directions.


No, you're running a different OS than I do so I didn't copy and paste.

I'll get back to this after finishing a document edit that has the highest
priority now.

Thanks,

Rich

__
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] Automating package updates after major version change

2020-05-14 Thread Sarah Goslee
If you don't mind, I'm curious what didn't work - I would like to be
able to update the document accordingly.

When you used

.libPaths()

what did it tell you? Did you edit that result to be for the previous
version, and swap that into the list.files() command? I thought about
automating it, but I can't be sure what previous version you're
upgrading from.

I suspect you tried to run the code by copy and paste, and not by
putting in your own path, but if so then I'd like to improve the
directions.

Sarah

On Thu, May 14, 2020 at 2:19 PM Rich Shepard  wrote:
>
> On Thu, 14 May 2020, Sarah Goslee wrote:
>
> > Note that install.packages requires "character vector of the names of
> > packages whose current versions should be downloaded from the
> > repositories" as stated in the help file.
>
> Sarah,
>
> Ah, yes. I missed that.
>
> > If you aren't going to do it the way I did, then you need to read your
> > text file into R and create that character vector there.
>
> I tried to translate your MacOS R commands to my linux system but failed in
> my attempts.
>
> I'll create a one-line list of packages, demarked as strings, and read that
> into R as a vector.
>
> Thanks,
>
> Rich
>
> __
> 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.



-- 
Sarah Goslee (she/her)
http://www.sarahgoslee.com

__
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] Notational derivative in R

2020-05-14 Thread Duncan Murdoch

On 14/05/2020 1:50 p.m., Eric Berger wrote:

Hi Christofer,
Look at https://cran.r-project.org/web/views/NumericalMathematics.html
and within that page search for Symbolic Mathematics. It shows two
packages: Ryacas and rSymPy.
I have no experience with them but they may be a good place to start.


There's also `D` and related functions in base R.

Duncan Murdoch



HTH,
Eric


On Thu, May 14, 2020 at 8:43 PM Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:


Hi,

I was wondering if R can perform notational derivative something like
Mathematica does as explained in
https://reference.wolfram.com/language/howto/TakeADerivative.html

Any pointer will be highly appreciated.

Thanks,

__
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.



[[alternative HTML version deleted]]

__
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@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] Automating package updates after major version change

2020-05-14 Thread Rich Shepard

On Thu, 14 May 2020, Sarah Goslee wrote:


Note that install.packages requires "character vector of the names of
packages whose current versions should be downloaded from the
repositories" as stated in the help file.


Sarah,

Ah, yes. I missed that.


If you aren't going to do it the way I did, then you need to read your
text file into R and create that character vector there.


I tried to translate your MacOS R commands to my linux system but failed in
my attempts.

I'll create a one-line list of packages, demarked as strings, and read that
into R as a vector.

Thanks,

Rich

__
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] Automating package updates after major version change

2020-05-14 Thread Sarah Goslee
Hi Rich,

Note that install.packages requires "character vector of the names of
packages whose current versions should be downloaded from the
repositories" as stated in the help file.

If you aren't going to do it the way I did, then you need to read your
text file into R and create that character vector there.

Sarah

On Thu, May 14, 2020 at 1:06 PM Rich Shepard  wrote:
>
> On Sun, 26 Apr 2020, Sarah Goslee wrote:
>
> > Not so coincidentally, I just worked thru this for myself.
> > http://numberwright.com/2020/04/clean-and-new/
>
> Sarah,
>
> This isn't working for me on Slackware-14.2/x86_64. My R library is in
> /usr/lib64/R/library/ and I copied the contents to a text file, one package
> per line.
>
> Using the filename, packagelist, as an argument to install.packages() fails:
> > install.packages(packagelist)
> Error in install.packages(packagelist) : object 'packagelist' not found
>
> Adding quotes didn't help.
>
> Creating a script, newversionupdate.R, containing the line,
> install.packages(packagelist)
>
> and sourcing it also failed.
>
> What might I be doing incorrectly?
>
> Regards,
>
> Rich
>
> __
> 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.



-- 
Sarah Goslee (she/her)
http://www.numberwright.com

__
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] Automating package updates after major version change

2020-05-14 Thread Rich Shepard

On Thu, 14 May 2020, Jeff Newmiller wrote:


Why are you mucking with the system-level library? It is quite unusual to
have a use-case in which you should not be adjusting your personal
library.


Jeff,

I'm the only user so there's no difference.

Regards,

Rich

__
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] Notational derivative in R

2020-05-14 Thread Jeff Newmiller
FWIW I have found all such tools to require babysitting... and for interactive 
use I prefer wxMaxima and some manual translation to R.

On May 14, 2020 10:50:56 AM PDT, Eric Berger  wrote:
>Hi Christofer,
>Look at https://cran.r-project.org/web/views/NumericalMathematics.html
>and within that page search for Symbolic Mathematics. It shows two
>packages: Ryacas and rSymPy.
>I have no experience with them but they may be a good place to start.
>
>HTH,
>Eric
>
>
>On Thu, May 14, 2020 at 8:43 PM Christofer Bogaso <
>bogaso.christo...@gmail.com> wrote:
>
>> Hi,
>>
>> I was wondering if R can perform notational derivative something like
>> Mathematica does as explained in
>> https://reference.wolfram.com/language/howto/TakeADerivative.html
>>
>> Any pointer will be highly appreciated.
>>
>> Thanks,
>>
>> __
>> 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.
>>
>
>   [[alternative HTML version deleted]]
>
>__
>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.

-- 
Sent from my phone. Please excuse my brevity.

__
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] Automating package updates after major version change

2020-05-14 Thread Jeff Newmiller
Why are you mucking with the system-level library? It is quite unusual to have 
a use-case in which you should not be adjusting your personal library.

On May 14, 2020 10:05:53 AM PDT, Rich Shepard  wrote:
>On Sun, 26 Apr 2020, Sarah Goslee wrote:
>
>> Not so coincidentally, I just worked thru this for myself.
>> http://numberwright.com/2020/04/clean-and-new/
>
>Sarah,
>
>This isn't working for me on Slackware-14.2/x86_64. My R library is in
>/usr/lib64/R/library/ and I copied the contents to a text file, one
>package
>per line.
>
>Using the filename, packagelist, as an argument to install.packages()
>fails:
>> install.packages(packagelist)
>Error in install.packages(packagelist) : object 'packagelist' not found
>
>Adding quotes didn't help.
>
>Creating a script, newversionupdate.R, containing the line,
>install.packages(packagelist)
>
>and sourcing it also failed.
>
>What might I be doing incorrectly?
>
>Regards,
>
>Rich
>
>__
>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.

-- 
Sent from my phone. Please excuse my brevity.

__
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] Notational derivative in R

2020-05-14 Thread Eric Berger
Hi Christofer,
Look at https://cran.r-project.org/web/views/NumericalMathematics.html
and within that page search for Symbolic Mathematics. It shows two
packages: Ryacas and rSymPy.
I have no experience with them but they may be a good place to start.

HTH,
Eric


On Thu, May 14, 2020 at 8:43 PM Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:

> Hi,
>
> I was wondering if R can perform notational derivative something like
> Mathematica does as explained in
> https://reference.wolfram.com/language/howto/TakeADerivative.html
>
> Any pointer will be highly appreciated.
>
> Thanks,
>
> __
> 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.
>

[[alternative HTML version deleted]]

__
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] Notational derivative in R

2020-05-14 Thread Christofer Bogaso
Hi,

I was wondering if R can perform notational derivative something like
Mathematica does as explained in
https://reference.wolfram.com/language/howto/TakeADerivative.html

Any pointer will be highly appreciated.

Thanks,

__
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] Automating package updates after major version change

2020-05-14 Thread Rich Shepard

On Sun, 26 Apr 2020, Sarah Goslee wrote:


Not so coincidentally, I just worked thru this for myself.
http://numberwright.com/2020/04/clean-and-new/


Sarah,

This isn't working for me on Slackware-14.2/x86_64. My R library is in
/usr/lib64/R/library/ and I copied the contents to a text file, one package
per line.

Using the filename, packagelist, as an argument to install.packages() fails:

install.packages(packagelist)

Error in install.packages(packagelist) : object 'packagelist' not found

Adding quotes didn't help.

Creating a script, newversionupdate.R, containing the line,
install.packages(packagelist)

and sourcing it also failed.

What might I be doing incorrectly?

Regards,

Rich

__
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] How to find a split point in a curve?

2020-05-14 Thread Bert Gunter
You need to mathematically define 'turning point' first: "end of
exponential phase" is subjective and meaningless. Once you have a precise
mathematical formulation in hand, you can proceed.

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 Thu, May 14, 2020 at 8:12 AM Luigi Marongiu 
wrote:

> Dear all,
> I am trying to find a turning point in some data. In the initial phase, the
> data increases more or less exponentially (thus it is linear in a nat log
> transform), then reaches a plateau. I would like to find the point that
> marks the end of the exponential phase.
> I understand that the function spline can build a curve; is it possible
> with it to find the turning points? I have no idea of how to use spline
> though.
> Here is a working example.
> Thank you
>
> ```
> Y = c(259, 716, 1404, 2173, 3944, 5403, 7140, 9121,
>   11220, 13809, 16634, 19869, 23753, 27447,
>   30590, 33975, 36627, 39600, 42067, 44082,
>   58190, 63280, 65921, 67929, 69977, 71865,
>   73614, 74005, 74894, 75717, 76365, 76579,
>   77087, 77493, 77926, 78253, 78680, 79253,
>   79455, 79580, 79699, 79838, 79981, 80080,
>   80124, 80164, 80183, 80207, 80222, 80230,
>   80241, 80261, 80261, 80277, 80290, 80303,
>   80337, 80376, 80422, 80461, 80539, 80586,
>   80653, 80708, 80762, 80807, 80807, 80886,
>   80922, 80957, 80988, 81007, 81037, 81076,
>   81108, 81108, 81171, 81213, 81259, 81358,
>   81466, 81555, 81601, 81647, 81673, 81998,
>   82025, 82041, 82053, 82064, 82094, 82104,
>   82110, 82122, 82133, 82136, 82142, 82164,
>   82168, 82180, 82181, 82184, 82187, 82188,
>   82190, 82192, 82193, 82194)
> Y = log(Y)
> X = 1:length(Y)
> plot(Y ~ X, ylab = "Ln(Y)", xlim=c(0,10, main="zoomed in"))
> abline(lm(Y[1:3] ~ X[1:3]))
> abline(lm(Y[1:5] ~ X[1:5]), lty=2)
> text(7, 6, "After third or fifth point, there is deviance", pos=3)
> text(2.5, 10, "Solid line: linear model points 1:3", pos =3)
> text(2.5, 9, "Dashed line: linear model points 1:5", pos =3)
> plot(Y ~ X, ylab = "Ln(Y)", xlim=c(0,10, main="overall"))
> abline(lm(Y[1:3] ~ X[1:3]))
> ```
>
> [[alternative HTML version deleted]]
>
> __
> 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.
>

[[alternative HTML version deleted]]

__
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] How to find a split point in a curve?

2020-05-14 Thread Rui Barradas

Hello,

Are you looking for a segmented regression?

fit <- lm(Y ~ X)
seg <- segmented::segmented(fit, seg.Z = ~X)
seg$psi[, 'Est.']
#[1] 29.21595

plot(X, Y)
plot(seg, add = TRUE)


Hope this helps,

Rui Barradas


Às 16:12 de 14/05/20, Luigi Marongiu escreveu:

Dear all,
I am trying to find a turning point in some data. In the initial phase, the
data increases more or less exponentially (thus it is linear in a nat log
transform), then reaches a plateau. I would like to find the point that
marks the end of the exponential phase.
I understand that the function spline can build a curve; is it possible
with it to find the turning points? I have no idea of how to use spline
though.
Here is a working example.
Thank you

```
Y = c(259, 716, 1404, 2173, 3944, 5403, 7140, 9121,
   11220, 13809, 16634, 19869, 23753, 27447,
   30590, 33975, 36627, 39600, 42067, 44082,
   58190, 63280, 65921, 67929, 69977, 71865,
   73614, 74005, 74894, 75717, 76365, 76579,
   77087, 77493, 77926, 78253, 78680, 79253,
   79455, 79580, 79699, 79838, 79981, 80080,
   80124, 80164, 80183, 80207, 80222, 80230,
   80241, 80261, 80261, 80277, 80290, 80303,
   80337, 80376, 80422, 80461, 80539, 80586,
   80653, 80708, 80762, 80807, 80807, 80886,
   80922, 80957, 80988, 81007, 81037, 81076,
   81108, 81108, 81171, 81213, 81259, 81358,
   81466, 81555, 81601, 81647, 81673, 81998,
   82025, 82041, 82053, 82064, 82094, 82104,
   82110, 82122, 82133, 82136, 82142, 82164,
   82168, 82180, 82181, 82184, 82187, 82188,
   82190, 82192, 82193, 82194)
Y = log(Y)
X = 1:length(Y)
plot(Y ~ X, ylab = "Ln(Y)", xlim=c(0,10, main="zoomed in"))
abline(lm(Y[1:3] ~ X[1:3]))
abline(lm(Y[1:5] ~ X[1:5]), lty=2)
text(7, 6, "After third or fifth point, there is deviance", pos=3)
text(2.5, 10, "Solid line: linear model points 1:3", pos =3)
text(2.5, 9, "Dashed line: linear model points 1:5", pos =3)
plot(Y ~ X, ylab = "Ln(Y)", xlim=c(0,10, main="overall"))
abline(lm(Y[1:3] ~ X[1:3]))
```

[[alternative HTML version deleted]]

__
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@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] How to find a split point in a curve?

2020-05-14 Thread Luigi Marongiu
Dear all,
I am trying to find a turning point in some data. In the initial phase, the
data increases more or less exponentially (thus it is linear in a nat log
transform), then reaches a plateau. I would like to find the point that
marks the end of the exponential phase.
I understand that the function spline can build a curve; is it possible
with it to find the turning points? I have no idea of how to use spline
though.
Here is a working example.
Thank you

```
Y = c(259, 716, 1404, 2173, 3944, 5403, 7140, 9121,
  11220, 13809, 16634, 19869, 23753, 27447,
  30590, 33975, 36627, 39600, 42067, 44082,
  58190, 63280, 65921, 67929, 69977, 71865,
  73614, 74005, 74894, 75717, 76365, 76579,
  77087, 77493, 77926, 78253, 78680, 79253,
  79455, 79580, 79699, 79838, 79981, 80080,
  80124, 80164, 80183, 80207, 80222, 80230,
  80241, 80261, 80261, 80277, 80290, 80303,
  80337, 80376, 80422, 80461, 80539, 80586,
  80653, 80708, 80762, 80807, 80807, 80886,
  80922, 80957, 80988, 81007, 81037, 81076,
  81108, 81108, 81171, 81213, 81259, 81358,
  81466, 81555, 81601, 81647, 81673, 81998,
  82025, 82041, 82053, 82064, 82094, 82104,
  82110, 82122, 82133, 82136, 82142, 82164,
  82168, 82180, 82181, 82184, 82187, 82188,
  82190, 82192, 82193, 82194)
Y = log(Y)
X = 1:length(Y)
plot(Y ~ X, ylab = "Ln(Y)", xlim=c(0,10, main="zoomed in"))
abline(lm(Y[1:3] ~ X[1:3]))
abline(lm(Y[1:5] ~ X[1:5]), lty=2)
text(7, 6, "After third or fifth point, there is deviance", pos=3)
text(2.5, 10, "Solid line: linear model points 1:3", pos =3)
text(2.5, 9, "Dashed line: linear model points 1:5", pos =3)
plot(Y ~ X, ylab = "Ln(Y)", xlim=c(0,10, main="overall"))
abline(lm(Y[1:3] ~ X[1:3]))
```

[[alternative HTML version deleted]]

__
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 map()

2020-05-14 Thread Poling, William via R-help
Hi Jim, thanks for the advice, those modifications are outside my capabilities 
at the moment but I will play around with it I guess.

Thank you.

WHP



Proprietary

-Original Message-
From: Jim Lemon  
Sent: Thursday, May 14, 2020 7:27 AM
To: Poling, William ; r-help mailing list 

Subject: [EXTERNAL] Re: Re: [R] Help with map()

 External Email - Use Caution 

Hi Bill,
I guess if you run makeDensityMatrix on subsets of the geographic locations and 
then overlay the different results with densityGrid using different colors, it 
should work as long as the regions don't overlap.

Jim

On Thu, May 14, 2020 at 10:20 PM Poling, William  wrote:
>
> Hello Jim, et.al, again.
>
> One last question please.
>
> Since this routine works best with larger volume of geo points, is there a 
> way to modify this routine to accommodate more than one cluster and 
> differentiated by different colors?
>
> #Single cluster routine
> clus3 <- individual_dets_sf_3X %>%
>
>   
> dplyr::select(MBR_SUBSCRIBERID,state,city,clusters,Latitude,Longitude,distances_Mi)
>  %>% #Notice now that these are capitalized <--"L"
>
>   filter(clusters == 3)
>
> str(clus3)
>
> clus3 <- as.data.frame(clus3)
>
> geomat<-makeDensityMatrix(clus3[,c("Latitude","Longitude")],
>   
> xlim=range(clus3$Longitude),ylim=range(clus3$Latitude))
> # Range of density (>0) - 1.292155 3.89646
> latlim<-range(clus3$Latitude)
> lonlim<-range(clus3$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 Cluster3")
>
> knitr::kable(individual_dets_sf_3X %>% group_by(clusters) %>% 
> tally(sort = TRUE))
>
> #   | clusters|   n|
> #   |:|---:|
> #   |3| 384|
> #   |5| 335|
> #   |9| 305|
> #   |7| 298|
> #   |   10| 286|
> #   |6| 279|
> #   |4| 168|
> #   |8| 131|
> #   |2| 113|
> #   |1|  53|
>
> 'data.frame':   384 obs. of  7 variables:
>  $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 908 2272 1613 
> 1357 1952 1437 795 1634 1160 902 ...
>  $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 10 23 23 10 33 10 
> 10 23 10 10 ...
>  $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 156 496 354 827 
> 670 1161 897 970 249 494 ...
>  $ clusters: num  3 3 3 3 3 3 3 3 3 3 ...
>  $ Latitude: num  31.2 35.3 36.5 33.4 34.2 ...
>  $ Longitude   : num  -81.5 -82.4 -81 -84.7 -80.7 ...
>  $ distances_Mi: num  770 586 471 769 573 ...
>
>
>
>
>
> Proprietary
>
> -Original Message-
> From: Poling, William
> Sent: Thursday, May 14, 2020 7:03 AM
> To: Jim Lemon 
> Cc: r-help@r-project.org; Mark Fowler 
> Subject: RE: [EXTERNAL] Re: [R] Help with map()
>
> 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 

Re: [R] Help with map()

2020-05-14 Thread Jim Lemon
Hi Bill,
I guess if you run makeDensityMatrix on subsets of the geographic
locations and then overlay the different results with densityGrid
using different colors, it should work as long as the regions don't
overlap.

Jim

On Thu, May 14, 2020 at 10:20 PM Poling, William  wrote:
>
> Hello Jim, et.al, again.
>
> One last question please.
>
> Since this routine works best with larger volume of geo points, is there a 
> way to modify this routine to accommodate more than one cluster and 
> differentiated by different colors?
>
> #Single cluster routine
> clus3 <- individual_dets_sf_3X %>%
>
>   
> dplyr::select(MBR_SUBSCRIBERID,state,city,clusters,Latitude,Longitude,distances_Mi)
>  %>% #Notice now that these are capitalized <--"L"
>
>   filter(clusters == 3)
>
> str(clus3)
>
> clus3 <- as.data.frame(clus3)
>
> geomat<-makeDensityMatrix(clus3[,c("Latitude","Longitude")],
>   
> xlim=range(clus3$Longitude),ylim=range(clus3$Latitude))
> # Range of density (>0) - 1.292155 3.89646
> latlim<-range(clus3$Latitude)
> lonlim<-range(clus3$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 Cluster3")
>
> knitr::kable(individual_dets_sf_3X %>% group_by(clusters) %>% tally(sort = 
> TRUE))
>
> #   | clusters|   n|
> #   |:|---:|
> #   |3| 384|
> #   |5| 335|
> #   |9| 305|
> #   |7| 298|
> #   |   10| 286|
> #   |6| 279|
> #   |4| 168|
> #   |8| 131|
> #   |2| 113|
> #   |1|  53|
>
> 'data.frame':   384 obs. of  7 variables:
>  $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 908 2272 1613 
> 1357 1952 1437 795 1634 1160 902 ...
>  $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 10 23 23 10 33 10 
> 10 23 10 10 ...
>  $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 156 496 354 827 
> 670 1161 897 970 249 494 ...
>  $ clusters: num  3 3 3 3 3 3 3 3 3 3 ...
>  $ Latitude: num  31.2 35.3 36.5 33.4 34.2 ...
>  $ Longitude   : num  -81.5 -82.4 -81 -84.7 -80.7 ...
>  $ distances_Mi: num  770 586 471 769 573 ...
>
>
>
>
>
> Proprietary
>
> -Original Message-
> From: Poling, William
> Sent: Thursday, May 14, 2020 7:03 AM
> To: Jim Lemon 
> Cc: r-help@r-project.org; Mark Fowler 
> Subject: RE: [EXTERNAL] Re: [R] Help with map()
>
> 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 "

Re: [R] Help with map()

2020-05-14 Thread Poling, William via R-help
Hello Jim, et.al, again.

One last question please.

Since this routine works best with larger volume of geo points, is there a way 
to modify this routine to accommodate more than one cluster and differentiated 
by different colors?

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

str(clus3)

clus3 <- as.data.frame(clus3)

geomat<-makeDensityMatrix(clus3[,c("Latitude","Longitude")],
  
xlim=range(clus3$Longitude),ylim=range(clus3$Latitude))
# Range of density (>0) - 1.292155 3.89646 
latlim<-range(clus3$Latitude)
lonlim<-range(clus3$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 Cluster3")

knitr::kable(individual_dets_sf_3X %>% group_by(clusters) %>% tally(sort = 
TRUE))

#   | clusters|   n|
#   |:|---:|
#   |3| 384|
#   |5| 335|
#   |9| 305|
#   |7| 298|
#   |   10| 286|
#   |6| 279|
#   |4| 168|
#   |8| 131|
#   |2| 113|
#   |1|  53|

'data.frame':   384 obs. of  7 variables:
 $ MBR_SUBSCRIBERID: Factor w/ 2352 levels "101040199600",..: 908 2272 1613 
1357 1952 1437 795 1634 1160 902 ...
 $ state   : Factor w/ 41 levels "AL","AR","AZ",..: 10 23 23 10 33 10 
10 23 10 10 ...
 $ city: Factor w/ 1337 levels "ABBOTTSTOWN",..: 156 496 354 827 
670 1161 897 970 249 494 ...
 $ clusters: num  3 3 3 3 3 3 3 3 3 3 ...
 $ Latitude: num  31.2 35.3 36.5 33.4 34.2 ...
 $ Longitude   : num  -81.5 -82.4 -81 -84.7 -80.7 ...
 $ distances_Mi: num  770 586 471 769 573 ...





Proprietary

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

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 

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(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)
> density

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),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$Longitu

Re: [R] (no subject)

2020-05-14 Thread Ivan Krylov
Dear Luigi,

These questions (and your previous one about R on Chromebook) are best
directed to the R-SIG-Debian mailing list [*], or maybe Ubuntu forums
[**]. I think that they are off-topic here on R-help.

Here is a short advice: try to make sure that you have the
r-recommended package installed from CRAN, not Ubuntu repository. If
that doesn't help, try to raise the priority [***] of packages from the
CRAN repository in order to avoid them being superseded by Ubuntu
packages. Another workaround would be removing the *.deb kernsmooth and
nnet packages from the system and installing them manually from CRAN in
the personal library by means of install.packages().

>   [[alternative HTML version deleted]]

Please don't post in HTML (see link to posting guide below).

-- 
Best regards,
Ivan

[*] https://stat.ethz.ch/mailman/listinfo/r-sig-debian
[**] https://ubuntuforums.org/
[***] https://jaqque.sbih.org/kplug/apt-pinning.html

__
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 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 ''
> > 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)

[R] (no subject)

2020-05-14 Thread Luigi Marongiu
Dear all,
I am trying to upgrade from ubuntu 19 to 20 but I got some R stuff that
stop the process:
```
$ apt list --upgradable
Listing... Done
r-cran-kernsmooth/xenial 2.23-15-3xenial0 amd64 [upgradable from:
2.23-15-3build2]
r-cran-nnet/xenial 7.3-12-2xenial0 amd64 [upgradable from: 7.3-12-2build2]
$ R --version
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
```
Since I have R 3.6 how can I remove or update these r-cran things?



-- 
Best regards,
Luigi

[[alternative HTML version deleted]]

__
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 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

[R] Resolve unmet dependencies and install R 3.6 on chromebook

2020-05-14 Thread Luigi Marongiu
I tried to upgrade R from 3,3 to 3.6 on a Chromebook but I am getting this
error
```
.org/debian stretch InRelease
Hit:4 https://deb.debian.org/debian-security stretch/updates InRelease
Hit:5 https://deb.debian.org/debian stretch-backports InRelease
Hit:6 http://cran.wustl.edu/bin/linux/ubuntu xenial/ InRelease
Hit:7 https://deb.debian.org/debian stretch Release
Hit:8 https://deb.nodesource.com/node_13.x stretch InRelease
Hit:9 https://desktop-download.mendeley.com/download/apt stable InRelease
Ign:10 https://storage.googleapis.com/cros-packages/81 stretch InRelease
Hit:11 https://storage.googleapis.com/cros-packages/81 stretch Release
Hit:12 https://apt.llvm.org/stretch llvm-toolchain-stretch-7 InRelease
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/kivy-team/kivy/ubuntu focal
Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore
disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration
details.
W: Target Packages (Packages) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
W: Target Translations (en_US) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
W: Target Translations (en) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
W: Target Packages (Packages) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
W: Target Translations (en_US) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
W: Target Translations (en) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
marongiuluigi@penguin:~$ sudo apt upgrade r-base r-base-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
  404  Not Found [IP: 2001:67c:1560:8008::15 80]
Ign:14 http://ppa.launchpad.net/kivy-team/kivy/ubuntu focal/main
Translation-en
Ign:15 http://ppa.launchpad.net/kivy-team/kivy/ubuntu focal/main
Translation-en_US
Ign:17 http://ppa.launchpad.net/kivy-team/kivy/ubuntu focal/main amd64
DEP-11 Metadata
Ign:18 http://ppa.launchpad.net/kivy-team/kivy/ubuntu focal/main all DEP-11
Metadata
Reading package lists... Done
W: The repository 'http://ppa.launchpad.net/kivy-team/kivy/ubuntu focal
Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore
potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration
details.
W: Target Packages (Packages) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
W: Target Translations (en_US) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
W: Target Translations (en) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
E: Failed to fetch
http://ppa.launchpad.net/kivy-team/kivy/ubuntu/dists/focal/main/binary-amd64/Packages
404  Not Found [IP: 2001:67c:1560:8008::15 80]
E: Some index files failed to download. They have been ignored, or old ones
used instead.
W: Target Packages (Packages) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
W: Target Translations (en_US) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
W: Target Translations (en) is configured multiple times in
/etc/apt/sources.list:3 and /etc/apt/sources.list:4
marongiuluigi@penguin:~$ sudo apt-get install r-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 r-base : Depends: r-base-core (>= 3.4.4-1xenial0) but it is not going to
be installed
  Depends: r-recommended (= 3.4.4-1xenial0) but it is not going to
be installed
  Recommends: r-base-html but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
```
These packages are not even available because in theory I have uninstalled
R:
```
$ sudo apt remove purge r-base-core
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package purge
$ sudo apt remove purge r-base-recommended
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package purge
E: Unable to locate package r-base-recommended
$ sudo apt remove purge r-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package purge
$ sudo apt remove purge r-base-dev
Reading package lists... Done