[R] Listing folders on One Drive

2024-05-20 Thread Nick Wray
Hello I have lots of folders of individual Scottish river catchments on my
uni One Drive.  Each folder is labelled with the river name eg "Tay" and
they are all in a folder named "Scotland"
I want to list the folders on One Drive so that I can cross check that I
have them all against a list of folders on my laptop.
Can I somehow use list.files() - I've tried various things but none seem to
work...
Any help appreciated
Thanks Nick Wray

[[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] Removing polygons from shapefile of Scotland and Islands

2024-05-14 Thread Nick Wray
Hello  I have a shapefile of Scotland, including the islands.  The river
flow data I am using is only for the mainland and for a clearer and larger
map I would like to not plot Orkney and Shetland to the north of the
mainland, as I don't need them.

The map I have I got from
https://borders.ukdataservice.ac.uk/easy_download_data.html?data=infuse_ctry_2011

then I put the uk shapefile onto my laptop with no problems (I have sf
running)

the_uk<-st_read(dsn="C:/Users/nickm/Desktop/Shapefiles/infuse_ctry_2011.shp")

scotland<-the_uk[2,]

plot(scotland$geometry)

This gives me a nice map of Scotland  plus islands but obviously there are
lots of separate polygons and if I go into the points with something like

scot_pts<-unlist(as.data.frame(scotland$geometry))

it's not at all clear how I can get rid of the points I don't want as they
don't seem to be listed in any easy way to find where one polygon stops and
another starts

I am wondering whether this approach is right anyway or whether there is
some sf function which would allow me to identify the polygons I want -
essentially the big one which is the mainland without lots of elaborate
conversions and manipulations

Any pointers, thoughts etc much appreciated

Thanks Nick Wray

[[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] Truncated plots

2024-01-09 Thread Nick Wray
Hello As a postgrad I have been helping an undergraduate student with R
coding but she has a problem with R studio on her laptop which I can't fix
- basically when she runs a plot it appears without a y axis label with the
black line plot frame hard against the plot window and the bottom of the
plot, where you would expect to see the horizontal axis and the x axis
label etc is completely "chopped off" by the bottom edge of the R studio
interface window.  I can't find anything on the net detailing this problem
- can anyone help?  I have a screenshot which could email if anyone needs
to see what it looks like.

Thanks Nick Wray

[[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] Mann Kendall mutation package?

2023-12-01 Thread Nick Wray
Hello - does anyone know whether there are any packages for Mann-Kendall
mutation tests in R available?  The only one I could find online is this
MK_mut_test: Mann-Kendall mutation test in Sibada/sibadaR: Sibada's
accumulated R scripts for next probably use to avoid reinventing the wheel.
(rdrr.io) <https://rdrr.io/github/Sibada/sibadaR/man/MK_mut_test.html> but
there doesn't seem to be a package corresponding to this.  I've tried
installing various permutations of the apparent name Sibada/sibadaR but
nothing comes up, so I'm not sure whether it even exists...

Thanks Nick Wray

[[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] Yamamoto again

2023-10-19 Thread Nick Wray
Aaargh after sending out last message realised that the R code is in fact
on the Cran site.  However, if anyone has an algebraic form that would
still be v useful as it's hard to get an overview of the process by looking
just at the code   Thanks Nick Wray

[[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] Yamamoto test in BreakPoints package

2023-10-19 Thread Nick Wray
Hello I’m not sure whether this strictly speaking counts as an R-help query
but anyway…  I have been using the Yamamoto test in the BreakPoints package
to find breakpoints in flow data for Scottish rivers.  However, I can’t
really just use the Yamamoto test as a “black box” ie data in, data out --
I need to find the actual algorithm which the Yamamoto test uses, either in
algebraic form or as R code, but despite exhaustive searching I can’t find
it.  I’ve tried to find a Github repository and various other things but
nothing comes up to give detailed information about the Yamamoto test as in
the package.  The original 1985 paper

 Climatic Jump: A Hypothesis in Climate Diagnosis

Ryozaburo Yamamoto
<https://www.jstage.jst.go.jp/search/global/_search/-char/en?item=8=Ryozaburo+Yamamoto>
, Tatsuya Iwashima
<https://www.jstage.jst.go.jp/search/global/_search/-char/en?item=8=Tatsuya+Iwashima>
, Sanga-Ngoie Kazadi
<https://www.jstage.jst.go.jp/search/global/_search/-char/en?item=8=Sanga-Ngoie+Kazadi>
, Makoto Hoshiai
<https://www.jstage.jst.go.jp/search/global/_search/-char/en?item=8=Makoto+Hoshiai>



 which is cited on the CRAN R info BreakPoints: Identify Breakpoints in
Series of Data (r-project.org)
<https://cran.r-project.org/web/packages/BreakPoints/BreakPoints.pdf>
doesn’t give any details.


There is another paper by Yamamoto et al (1987) Proc. NIPR Symp. Polar
Meteorol. Glaciol., 1, 91-102, 1987 but the method is not very clear and
whether it’s actually what the package does I can’t tell.

There is info about a Toda-Yamamoto causality test but this doesn’t seem to
be the same thing as the Yamamoto test in the R package BreakPoints

If anyone can point me to where either an algebraic algorithm or the R code
is I’d be v grateful

Thanks Nick Wray

[[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] rnrfa package problems

2023-10-13 Thread Nick Wray
R help email

Hello  I’m trying to work my way through the rnrfa package

RJ-2016-036.pdf (r-project.org)
<https://journal.r-project.org/archive/2016/RJ-2016-036/RJ-2016-036.pdf>

I’ve got it loaded OK and can access the data by the catalogue() command -
gives me a tibble with names, grid refs etc

allStations <- catalogue()

allStations

This works OK



But when I try to run the example codes there are various problems

The code is lifted directly from the document btw it’s not mine

This bit to convert gives an error message:

# Option a: from OS grid reference to WGS84 >

osg_parse(gridRef = "NC581062", CoordSystem = "WGS84")

 # Option b: from OS grid reference to BNG

osg_parse(gridRef = "NC581062", CoordSystem = "BNG")

##

osg_parse seems to be built into the rnrfa package so I don’t know why it
doesn’t work…




Then this bounding box code works but doesn’t seem to capture any stations
although rubric says that it should capture stations in mid Wales - the
tibble is empty

# Define a bounding box.

bbox <- list(lonMin = -3.76, latMin = 52.43, lonMax = -3.67, latMax = 52.48)




The ggmap code following gives an error – this may be because the bbox data
is empty but I’m not sure  The needed packages are loaded:

library(ggmap)

library(ggrepel)

m <- get_map(location = as.numeric(bbox), maptype = 'terrain')

ggmap(m) + geom_point(data = someStations, aes(x = lon, y = lat),

+ col = "red", size = 3, alpha = 0.5) +

geom_text_repel(data = someStations, aes(x = lon, y = lat, label = name),

+ size = 3, col = "red")




I thought that I’d try the next bit to see anyway:

# Select stations with more than 100 years of recordings.

s100Y <- catalogue(minRec = 100, all = FALSE)

# Print s100Y to the screen.

s100Y

But again I get an error message

I haven’t gone any further through the article because there doesn’t seem
much point unless I can sort things.  I am puzzled as to why the examples
don’t work – I’ve got all the needed packages loaded etc

If anyone can help/explain I’d be v grateful

Thanks Nick Wray

[[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] halting with errors

2023-09-18 Thread Nick Wray
Hello  I am downloading flow data from the UK national river flow archive
(NRFA).  I have code which works (thanks to previous help on r-help) but
the problem is that before I make a call for the data for that particular
year I don’t know whether the data exists for that particular year and
catchment

This is a typical url  and it works if you paste it into the top line on a
web page.  15007 is the code for the Pitnacree catchment in Scotland

https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters=queryServices=0=getTimeseriesValues_path=1/15007/Q/15m.Cmd=2015-01-01=2015-01-31=Timestamp,Value,Quality%20Code

It works in R as well with

page<-read_html("
https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters=queryServices=0=getTimeseriesValues_path=1/15007/Q/15m.Cmd=2015-01-01=2015-01-31=Timestamp,Value,Quality%20Code
")

yiq<-page |>

  html_element("table") |>

  html_table(header = TRUE) |>

  (\(x) {

hdr <- unlist(x[3, ])

y <- x[-(1:3), ]

names(y) <- hdr

y

  })()

print(nrow(yiq))

yiq



But if I try to move onto another catchment Kenmore 15006

eg



https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters=queryServices=0=getTimeseriesValues_path=1/15016/Q/15m.Cmd=2015-01-01=2015-01-31=Timestamp,Value,Quality%20Code

So in R

read_html(“
https://timeseries.sepa.org.uk/KiWIS/KiWIS?service=kisters=queryServices=0=getTimeseriesValues_path=1/15016/Q/15m.Cmd=2015-01-01=2015-01-31=Timestamp,Value,Quality%20Code
”)

This doesn’t work because there’s no data for this catchment for this year

I am pasting in different years (from say 1961 to 2017) in a loop (and this
works if the data sets exist) but the problem is that if the data is not
there (and there doesn’t seem to be a way of determining this elsewhere)
and so there’s nothing to read, an error message comes up and halts the
program loop, so that manually I have to reset the url to try to find out
whether there is data for the next year.

What I’d like to know is whether there’s any way in R of seeing whether the
data set exists, and if doesn’t, moving on the next possibility without
halting…

Any thoughts appreciated

Thanks Nick Wray

[[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] Problems with facets in ggplot2

2023-08-04 Thread Nick Wray
Hello  I am wrestling with ggplot – I have produced a facetted plot of
flows under various metrics but I can’t find info on the net which tells me
how to do three things


I have created some simplified mock data to illustrate (and using a
colour-blind palette):


library(ggplot2)

library(forcats)

cb8<- c("#00", "#E69F00", "#56B4E9", "#009E73","#F0E442", "#0072B2",
"#D55E00", "#CC79A7")

set.seed<-(040823)

  mock<- set.seed<-(040823)


mock<-as.data.frame(cbind(rep((1990:1995),8),round(rnorm(48,50,10),3),rep(c(rep("Tweed",6),rep("Tay",6)),4),rep(c("AMAX","Mean","AMIN","Median"),each=12)))

  colnames(mock)<-c("Year","Flow","Stat","Metric")

  mock



  ggplot(mock, aes(Year,Flow, group = factor(Stat), colour = factor(Stat)))+

coord_cartesian(ylim = c(0, 100)) +

geom_line(size=1)+

scale_color_manual(name = "Stat", values = cb8[4:7])+

scale_y_discrete(breaks=c(0,25,50,75,100),labels=c(0,25,50,75,100))+

facet_wrap(vars(Metric),nrow=2,ncol=2)+

ylab("Flow")



1)This gives me a facetted plot but I can’t work out why I’m not getting a
labelled y scale



2)Why are plots down at the bottom of the facets rather than in the middle?



3)And also I’d like the plots to be in the order (top left to bottom right)
of

AMAX MEAN AMIN MEDIAN

but if I add in the line
facet_grid(~fct_relevel(Metric,"AMAX","Mean","AMIN","Median")) before the
line ylab it disrupts the 2x2 layout



Can anyone tell me how to resolve these problems?  Thanks Nick Wray

[[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] Choosing colours for lines in ggplot2

2023-08-02 Thread Nick Wray
Hello - I am trying to plot flows in a number of rivers within the same
plot, and need to colour the lines differently, using a colour-blind
palette.


Code beneath works but has colours assigned by the program I have made some
simple dummy data:
## code 1
cb8<- c("#00", "#E69F00", "#56B4E9", "#009E73","#F0E442", "#0072B2",
"#D55E00", "#CC79A7")  ## this is the colour-blind palette
 set.seed(020823)
 
df<-as.data.frame(cbind(rep(1980:1991,2),c(10*runif(12),10*runif(12)),c(rep(1,12),rep(2,12
 colnames(df)<-c("Year","Flow","Stat")
 df
 ggplot(df,aes(Year,Flow,group=Stat,colour=Stat))+
   coord_cartesian(ylim = c(0, 10)) +
   geom_line()+
   geom_point()
 ## this works

## BUT:
## code 2
col.2<-cb8[4:5]
 ggplot(df,aes(Year,Flow,group=Stat,colour=Stat))+
   coord_cartesian(ylim = c(0, 10)) +
   geom_line()+
   geom_point()+
 scale_color_manual(values =cb8[4:5])+
   theme_bw()
 ## this gives error message Error: Continuous value supplied to discrete
scale

## However this example using code from the net does work so I don't
understand why my ## second code doesn't work.
## code 3
 df.1 <- data.frame(store=c('A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C'),
  week=c(1, 2, 3, 1, 2, 3, 1, 2, 3),
  sales=c(9, 12, 15, 7, 9, 14, 10, 16, 19))
 ggplot(df.1, aes(x=week, y=sales, group=store, color=store)) +
   geom_line(size=2) +
   #scale_color_manual(values=c('orange', 'pink', 'red'))
   scale_color_manual(values=cb8[4:6])

Can anyone help? Thanks Nick Wray

[[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] col2rgb() function

2023-07-23 Thread Nick Wray
Thanks v useful to know Nick

On Sun, 23 Jul 2023 at 21:13, Achim Zeileis 
wrote:

> Just one addition which may or may not be useful: The color palette you
> use is also known as "Okabe-Ito" and it is the default set of colors in
> the palette.colors() function. This function also has an optional alpha
> argument. So if you want to generate these colors with an alpha of 0.3 you
> can also do:
>
> palette.colors(8, alpha = 0.3)
>
> or more explicitly
>
> palette.colors(8, palette = "Okabe-Ito", alpha = 0.3)
>
> On Sun, 23 Jul 2023, Nick Wray wrote:
>
> > Thanks That works nicely  Nick
> >
> > On Sun, 23 Jul 2023 at 19:26, Ben Bolker  wrote:
> >
> >>Does adjustcolor() help?
> >>
> >> cb8<- c("#00", "#E69F00", "#56B4E9", "#009E73","#F0E442", "#0072B2",
> >> "#D55E00", "#CC79A7")
> >> plot(0,0,xlim=c(1,8),ylim=c(0,1))
> >> points(1:8,rep(0.5,8),col=cb8,pch=19,cex=2)
> >> points(1:8,rep(0.75,8),col=adjustcolor(cb8, alpha.f = 0.3),
> pch=19,cex=2)
> >>
> >> On 2023-07-23 2:15 p.m., Nick Wray wrote:
> >>> Hello  I have a palette vector of colour blind colours (in hexadecimal)
> >>> which I’m using for plots, but they are not see-through, and as I
> wanted
> >> to
> >>> overlay some histograms I wanted to convert these colours to rgb, when
> >> you
> >>> can set the opacity.
> >>>
> >>> I have found the function col2rgb(), which works in the sense that it
> >> gives
> >>> a vector of numbers but these don’t work directly in rgb because they
> are
> >>> too big.  If I divide through to make them all less than 1 I don’t get
> >> the
> >>> corresponding colour-blind hue, but something somewhat off.
> >>>
> >>> Here is the colour-blind palette in a plot:
> >>>
> >>>
> >>> *cb8<- c("#00", "#E69F00", "#56B4E9", "#009E73","#F0E442",
> "#0072B2",
> >>> "#D55E00", "#CC79A7")*
> >>>
> >>> *plot(0,0,xlim=c(1,8),ylim=c(0,1))*
> >>>
> >>> *points(1:8,rep(0.5,8),col=cb8,pch=19,cex=2)*
> >>>
> >>>
> >>>
> >>> so if I try to convert the red dot ("#D55E00") (number 7) I get
> >>>
> >>> *col2rgb("#D55E00"*
> >>>
> >>>[,1]
> >>>
> >>> red213
> >>>
> >>> green   94
> >>>
> >>> blue 0
> >>>
> >>> *points(7,0.25,col=rgb(rgb(213,94,0)),pch=19,cex=2)*
> >>>
> >>> gives me an error message and although if  I divide through
> >>>
> >>> *points(7,0.25,col=rgb(213/307,94/307,0),pch=19,cex=2)*
> >>>
> >>> gives me a reddish dot, but not the same as in the colour-blind palette
> >>>
> >>>
> >>>
> >>> Somewhat mystified.  Can anyone help?? Thanks Nick Wray
> >>>
> >>>   [[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.
> >>
> >
> >   [[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] col2rgb() function

2023-07-23 Thread Nick Wray
Thanks That works nicely  Nick

On Sun, 23 Jul 2023 at 19:26, Ben Bolker  wrote:

>Does adjustcolor() help?
>
> cb8<- c("#00", "#E69F00", "#56B4E9", "#009E73","#F0E442", "#0072B2",
> "#D55E00", "#CC79A7")
> plot(0,0,xlim=c(1,8),ylim=c(0,1))
> points(1:8,rep(0.5,8),col=cb8,pch=19,cex=2)
> points(1:8,rep(0.75,8),col=adjustcolor(cb8, alpha.f = 0.3), pch=19,cex=2)
>
> On 2023-07-23 2:15 p.m., Nick Wray wrote:
> > Hello  I have a palette vector of colour blind colours (in hexadecimal)
> > which I’m using for plots, but they are not see-through, and as I wanted
> to
> > overlay some histograms I wanted to convert these colours to rgb, when
> you
> > can set the opacity.
> >
> > I have found the function col2rgb(), which works in the sense that it
> gives
> > a vector of numbers but these don’t work directly in rgb because they are
> > too big.  If I divide through to make them all less than 1 I don’t get
> the
> > corresponding colour-blind hue, but something somewhat off.
> >
> > Here is the colour-blind palette in a plot:
> >
> >
> > *cb8<- c("#00", "#E69F00", "#56B4E9", "#009E73","#F0E442", "#0072B2",
> > "#D55E00", "#CC79A7")*
> >
> > *plot(0,0,xlim=c(1,8),ylim=c(0,1))*
> >
> > *points(1:8,rep(0.5,8),col=cb8,pch=19,cex=2)*
> >
> >
> >
> > so if I try to convert the red dot ("#D55E00") (number 7) I get
> >
> > *col2rgb("#D55E00"*
> >
> >[,1]
> >
> > red213
> >
> > green   94
> >
> > blue 0
> >
> > *points(7,0.25,col=rgb(rgb(213,94,0)),pch=19,cex=2)*
> >
> > gives me an error message and although if  I divide through
> >
> > *points(7,0.25,col=rgb(213/307,94/307,0),pch=19,cex=2)*
> >
> > gives me a reddish dot, but not the same as in the colour-blind palette
> >
> >
> >
> > Somewhat mystified.  Can anyone help?? Thanks Nick Wray
> >
> >   [[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.
>

[[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] col2rgb() function

2023-07-23 Thread Nick Wray
Hello  I have a palette vector of colour blind colours (in hexadecimal)
which I’m using for plots, but they are not see-through, and as I wanted to
overlay some histograms I wanted to convert these colours to rgb, when you
can set the opacity.

I have found the function col2rgb(), which works in the sense that it gives
a vector of numbers but these don’t work directly in rgb because they are
too big.  If I divide through to make them all less than 1 I don’t get the
corresponding colour-blind hue, but something somewhat off.

Here is the colour-blind palette in a plot:


*cb8<- c("#00", "#E69F00", "#56B4E9", "#009E73","#F0E442", "#0072B2",
"#D55E00", "#CC79A7")*

*plot(0,0,xlim=c(1,8),ylim=c(0,1))*

*points(1:8,rep(0.5,8),col=cb8,pch=19,cex=2)*



so if I try to convert the red dot ("#D55E00") (number 7) I get

*col2rgb("#D55E00"*

  [,1]

red213

green   94

blue 0

*points(7,0.25,col=rgb(rgb(213,94,0)),pch=19,cex=2)*

gives me an error message and although if  I divide through

*points(7,0.25,col=rgb(213/307,94/307,0),pch=19,cex=2)*

gives me a reddish dot, but not the same as in the colour-blind palette



Somewhat mystified.  Can anyone help?? Thanks Nick Wray

[[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] weird things in seqMK() and sqmk()

2023-04-01 Thread Nick Wray
Hello  The other say I posted a question about altering confidence limits
in the seqMK() function  in the pheno package.  I didn't get any bites but
in any case I've been trying to use this function.  It seems to me to give
very odd results - sometimes identifying 8 or 9 changepoints in a
relatively short vector of maybe 40 elements, and at other times not giving
any changepoints at all, despite visually there appearing to be
changepoints and other changepoint algorithms (pettitt etc) saying that
there are other changepoints.  Apart from the cran vignette there doesn't
seem to be anything on this function

Has anyone else used the seqMK() function and if so, have they noticed any
weird behaviour with it?

I've also lookedf at sqmk() in trendchange function.  This also seems to
give odd results, and not ones consistent with seqMK() results either

Again has anyone used these and do they know of any sites with further ifo,
as it seems v sparse about these two functions
Thanks Nick Wray

[[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] seqMK function

2023-03-30 Thread Nick Wray
Hello does anyone know how to set the confidence level within the seqMK()
function in the pheno package.  It seems to be set automatically at 0.05
and there seems to be neither an input function to set a different level,
as there are with some changepoint functions, nor an output to give one the
p-value of the changepoint identification which you get with functions ie
func$p_value etc ...
Thanks Nick Wray

[[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] null in rao.test in R

2023-03-11 Thread Nick Wray
Hello  I am testing for the homogeneity of clusters of (yearly) seasonal
data using the rao.test from the circular package.  I can't find anywhere
(including the Cran pages) which specifically mentions the null hypothesis
for this test.  Playing around with it, for example using say the toy code
beneath it would seem that the null is that the data sets tested are not
homogenous, which is fine except that seems to be contrary to normal
practice, where the null would be that the two sets are homogenous unless
there's evidence otherwise.  Has anyone else used this test and can confirm
that the null is that sets are not homogenous?

a<-2*pi*c(1,2,3)/365
b<-a+pi
rt<- rao.test(a,b)
rt$p.value

this gives two p-values of 1 - one for the equality of polar vectors, and
the second for the  test of equality of dispersions.  Although I can guess,
to be honest at the moment i'm not sure what either of these things mean
(not really an R-help question I know) as I've only just begun serious
analysis of circular data but I am surprised that this toy data gives a
p-value of 1 in each case

can anyone cast light on all this?
Thanks Nick Wray

[[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] p-value in changepoint package

2023-02-15 Thread Nick Wray
Hello Does anyone know how to get the p values for changepoints in the
"changepoint" package?  There is guidance in the CRAN vignette
https://cran.r-project.org/web/packages/changepoint/changepoint.pdf but I
can't make it work to get the p value out...  Thanks Nick Wray

[[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] Lazy-load corrupt?

2023-02-03 Thread Nick Wray
Hello  When trying to call various packages eg
library(raster)
library(sp)
library(rgdal)

I get this error message:
Loading required package: sp
Error: package or namespace load failed for ‘sp’ in get0(name, envir =
where, mode = "function", inherits = FALSE):
 lazy-load database 'C:/PROGRA~1/R/R-42~1.1/library/base/R/base.rdb' is
corrupt
Error: package ‘sp’ could not be loaded
In addition: Warning messages:
1: package ‘raster’ was built under R version 4.2.2
2: package ‘sp’ was built under R version 4.2.2
3: In get0(name, envir = where, mode = "function", inherits = FALSE) :
  restarting interrupted promise evaluation
4: In get0(name, envir = where, mode = "function", inherits = FALSE) :
  internal error -3 in R_decompress1


Other packages load fine (and the packages above load OK on my spare
laptop) but I'm imagining that this means that I have to uninstall my
current R and reinstall the latest version - but before I go through all
that can anyone confirm that that is indeed what I need to do or is there
some other problem?

Thanks Nick Wray

[[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] Detpack package

2023-02-01 Thread Nick Wray
I did use "detpack" ie not with a capital

detpack::chi2testuniform(vals,0.05)
gives this:

Error: 'chi2testuniform' is not an exported object from 'namespace:detpack'
??
Thanks Nick


On Wed, 1 Feb 2023 at 16:29, Eric Berger  wrote:

> Detpack or detpack?
>
> What happens when you try detpack::chi2testuniform(...) ?
>
>
> On Wed, Feb 1, 2023 at 6:08 PM Nick Wray  wrote:
>
>> Hello   I've successfully installed the package "Detpack" and remembered
>> to
>> call it via library()  But when I try to use the functions i get this:
>>
>>
>> chi2testuniform(vals, 0.05)
>>
>> Error in chi2testuniform(vals, 0.05) :
>>   could not find function "chi2testuniform"
>>
>>
>> And yet this function (amongst other which also are not recognised) are
>> all
>> listed on the CRAN page:
>> http://cran.nexr.com/web/packages/detpack/detpack.pdf
>>
>> I can't remember anything like this happening before - as far as I can see
>> I don't need to load or write anything else before executing the function
>> and I can't find references to any problems with this package on the net
>> Can anyone cast light on what's happening?  Thanks Nick Wray
>>
>> [[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.


[R] Detpack package

2023-02-01 Thread Nick Wray
Hello   I've successfully installed the package "Detpack" and remembered to
call it via library()  But when I try to use the functions i get this:


chi2testuniform(vals, 0.05)

Error in chi2testuniform(vals, 0.05) :
  could not find function "chi2testuniform"


And yet this function (amongst other which also are not recognised) are all
listed on the CRAN page:
http://cran.nexr.com/web/packages/detpack/detpack.pdf

I can't remember anything like this happening before - as far as I can see
I don't need to load or write anything else before executing the function
and I can't find references to any problems with this package on the net
Can anyone cast light on what's happening?  Thanks Nick Wray

[[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] Scrub last query on yamamoto

2023-01-24 Thread Nick Wray
Ach please scrub my last email - I didn't realise that the package name was
given without it being expicit in the site quoted
Sorry Nick Wray

[[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] yamamoto

2023-01-24 Thread Nick Wray
Hello I am trying to use the yamamoto function, as given in an example: on
this site:
R: Yamamoto (r-project.org)


but it doesn't seem to give the package when the function comes and it
doesn't work in base.  I can't actually find which package (I assume that
it is in a package) it is within.  I've tried "mediation2 and that doesn't
work.  Can anyone help? Thanks Nick WQray

[[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] Topological network Map

2023-01-11 Thread Nick Wray
Hello I'd like to create a simple topological map of a river system, ie all
the waterways, where they join and points on them such as gauging stations
so that it looks something like the London Tube map - where distances are
not important but the relationships of the nodes are.
I could probably Heath-Robinson something together but I wondered whether
there was any kind of package already out there to save me reinventing the
wheel.  I've had a look but I can't find anything which seems to do this.
Does anyone know whether there is already such a thing or is this an
opportunity to create my first candidate R package?
Thanks Nick Wray

[[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] getting information out of Rao test output

2023-01-08 Thread Nick Wray
Hello  I'm using the Rao Spacing test from the circular package on a series
of (circular) data vectors but I can't find a way of simply recording
whether the null is rejected or not for each vector in the series - the
test gives me an individual result but unlike with other tests in R (say
MannKendall or pettitt etc) I can't find a way of delving into the guts of
the output to extract either1)both the test statistic and critical value
or 2)the status of ejection or not of the null eg as T/F

I''ve tried various things including str(rao) and rao[[1]]
as.character(rao) etc

rao<-rao.spacing.test(pi_data,alpha=0.05) ## my input


 Rao's Spacing Test of Uniformity

Test Statistic = 169.6952
Level 0.05 critical value = 155.19
Reject null hypothesis of uniformity-- can't break this down

Des anyone know how I could do this?

Thanks, Nick Wray

[[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] Rate of Reading into R from net

2022-11-14 Thread Nick Wray
Hello I am trying read  nc rainfall  files directly from the UK centre for
hydrology and ecology website -
hourly:about 300Mb
https://catalogue.ceh.ac.uk/datastore/eidchub/fc9423d6-3d54-467f-bb2b-fc7357a3941f/
and daily about 90Mb
https://catalogue.ceh.ac.uk/datastore/eidchub/2ab15bf0-ad08-415c-ba64-831168be7293/precip/

I can download them "by hand" no problem using the ncdf4 package but
there's lots and I wanted to streamline the process

code I've used (which works for "by hand" downloading) is (for example)

nc_data<-nc_open("
https://catalogue.ceh.ac.uk/datastore/eidchub/2ab15bf0-ad08-415c-ba64-831168be7293/precip/chess-met_precip_gb_1km_daily_19610301-19610331.nc
")

However, when I run this I don't get an error message but R just sits there
with the little red circle (at least 30 minutes for the 90Mb files)

What I'm wondering is two things - a)is the data in fact downloading but
it's just taking ages and I need to let it run and go and have a coffee
   b)is there (I can't find
anything) within R which allows me to monitor the progress of the download,
if in fact it is taking place?
Thanks Nick Wray

[[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] (no subject)

2022-11-06 Thread Nick Wray
Hello - I am using the MICE package to impute missing values - the input
data are up to six vectors of parallel hourly temperature measurements for
Scottish weather stations across a calendar year. None of the vectors have
more than 5% NAs as I have filtered ones with more out.  Most of the sets
work fine with MICE but with a few I get an error message:

This data set, which generated the error message has five columns

iter imp variable
  1   1  986Error in terms.formula(tmp, simplify = TRUE) :
  invalid term in model formula


986 is the station number which is the column name here for the first
column.  The third to fifth columns don't have any NAs and the first and
second have fewer than 1% - but they do have the NAs concentrated as
strings of 20 or so near the beginning of the data set.

I am puzzled as to why certain datasets, which don't seem very different
from the others provoke the error message - the only thing which I am
wondering is whether MICE has a problem with a too large concentration of
the NAs in particular regions but I can't find any reference to this in the
literature.  Has anyone else come across this as a problem, and if so, what
did they do about it?  Thanks Nick Wray

[[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] Opening shapefiles in R

2022-10-22 Thread Nick Wray
Hi Micha  Thanks for your ideas which I will look into   I hadn't heard of
r-sig-geo before but I've signed up to it.  I'm a bit of beginner as far as
geospatial in R goes.  What I am ultimately trying to do is this - my PhD
research is into the relative proportions of the effects of climate change
and land use on streamflow in Scottish rivers (I'm based at Edinburgh) and
to this end I need to create a map of catchments eg the Tweed onto which I
can placing flow gauging stations/ weather stations etc .  I have catchment
outline shapefiles and the stations but finding the bit of the whole of the
UK river system shapefile which is the Tweed catchment is tricky, as the
shapefile matrix doesn't have names in it and I am trying to identify the
Tweed and its tributaries from the coordinates of its mouth sources and so
on...  that's why i need to pull out the coordinates.  Any suggestions 'd
be v welcome  Nick

On Sat, 22 Oct 2022 at 10:28, Micha Silver  wrote:

> Hello Nick:
>
>
> First: as Jeff pointed out, you'll probably have better luck posting to
> the r-sig-geo list.
>
>
> On 21/10/2022 14:25, Nick Wray wrote:
> > Hello
> >
> > I have managed to download and plot the outline for the River Tweed In
> the
> > Sottish borders)  catchment using this code.  21009 is a zipfile
> downloaded
> > from the FEH website https://fehweb.ceh.ac.uk/Map:
> >
> > require(rgdal)
> >
> > shape <- readOGR(dsn ="C:/Users/nick/Desktop/PhD Oct 22", layer =
> "21009")
>
>
> Second: The R-spatial "ecosystem" has undergone some major changes
> recent years. You'd be well advised, I think, to switch to using the
> `sf` package for vector data. So reading in a shapefile would be
> `sf::st_read(dsn="...")`
>
>
>
> Third: Regarding your other post about string representations of
> geometries. Can you be more specific as to what your final goal is? The
> "canonical" string representation of geometries is Well Known Text (WKT)
> and can be returned with the `sf::st_as_text()` function. Does that help?
>
>
> Kind regards,
>
> Micha
>
>
> > shape
> >
> > plot(shape)
> >
> > and I get an outline of the Tweed catchment which I can use
> >
> > the zipfile has eight documents all with the name “21009.” and the
> suffixes
> > cpg/dbf/prj/sbn/sbx/shp/shp/shx   There are two .shp docs, one labelled
> as
> > SHP file and one as XML file.
> >
> > However
> >
> > I then have downloaded a file of a plot of all the rivers in the uk from
> > https://osdatahub.os.uk/downloads/open
> >
> > I’ve put this data into a zipfile with the name “rivers”   Within this
> are
> > eight docs – four with the names HydroNode. and suffixes dbf/prj/shp/shx
> > and four with the name WatercourseLink. and the four suffixes.
> >
> > Just subbing in “rivers” for “21009” in my code above doesn’t work and I
> > can’t find a way of getting into the shapefiles and opening them
> >
> >
> > I'd be grateful if anyone can help me get further with this
> >
> > Thanks Nick Wray
> >
> >   [[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.
>
> --
> Micha Silver
> Ben Gurion Univ.
> Sde Boker, Remote Sensing Lab
> cell: +972-523-665918
>
>

[[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] Linestring values to vector

2022-10-21 Thread Nick Wray
Hello I have downloaded a large shapefile dataset of UK rivers and I want
to isolate (as an ordinary R string) the LINESTRING values for particular
lines, corresponding to rivers
Looking at the first line I can isolate the geometry by

Hello I have downloaded a large shapefile dataset of UK rivers and I want
to isolate (as an ordinary R string) the LINESTRING values for particular
lines, corresponding to rivers

Looking at the first line I can isolate the geometry by



st_geometry(rivers[1,8])



Geometry set for 1 feature
Geometry type: LINESTRING
Dimension: XYZ
Bounding box:  xmin: 462010.6 ymin: 1213039 xmax: 462306.5 ymax: 1213199
z_range:   zmin: 0 zmax: 0
Projected CRS: OSGB 1936 / British National Grid

LINESTRING Z (462306.5 1213048 0, 462275.4 1213...


What I need is all the values in the LINESTRING as a common or garden R
vector, but I cannot find a way to do this.

 Does anyone know how?  Thanks, Nick Wray

[[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] Opening shapefiles in R

2022-10-21 Thread Nick Wray
Hello

I have managed to download and plot the outline for the River Tweed In the
Sottish borders)  catchment using this code.  21009 is a zipfile downloaded
from the FEH website https://fehweb.ceh.ac.uk/Map:

require(rgdal)

shape <- readOGR(dsn ="C:/Users/nick/Desktop/PhD Oct 22", layer = "21009")

shape

plot(shape)

and I get an outline of the Tweed catchment which I can use

the zipfile has eight documents all with the name “21009.” and the suffixes
cpg/dbf/prj/sbn/sbx/shp/shp/shx   There are two .shp docs, one labelled as
SHP file and one as XML file.

However

I then have downloaded a file of a plot of all the rivers in the uk from
https://osdatahub.os.uk/downloads/open

I’ve put this data into a zipfile with the name “rivers”   Within this are
eight docs – four with the names HydroNode. and suffixes dbf/prj/shp/shx
and four with the name WatercourseLink. and the four suffixes.

Just subbing in “rivers” for “21009” in my code above doesn’t work and I
can’t find a way of getting into the shapefiles and opening them


I'd be grateful if anyone can help me get further with this

Thanks Nick Wray

[[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] Reading Text files from UK Met Office into R again...

2022-10-09 Thread Nick Wray
Hello I've had some invaluable help from folk about downloading files from
the UK Met Office - unfortunately I now have another one which I can't
solve and I wonder whether anyone's got any ideas.

I'm trying to download hourly weather records from the Met Office

 https://data.ceda.ac.uk/badc/ukmo-midas/data/WH/yearly_files



Up to 2010 everything's fine and dandy - the data is in nice neat columns
and I can download it and filter out what I don't want.  But after 2010 the
format changes (The Met Office in fact say on their guidelines that it
changes)  - it's still a text doc but instead of columns it seems to be one
long vector.  Here is a short sample:



2015-01-01 00:00, 03002, WMO, SYNOP, 1, 12, 1011, 4, 7, 200, 18, 82, , , 8,
, , , , 100, 450, 1005.4, 5, , 102, 4, , 129, , , , , , , , 8.7, 7.5, 8.1,
1003.6, , , , , , , 1, 1, 1, , , 1, , , , , 1, 1, 1, 1, 1, 1, , 1, , 1, 1,
, 1, , , , , , , , 1, , , , , 2014-12-31 23:53, 0, , , , , , , , , , , , K,
, , , , 91.7, A, , , ,
2015-01-01 00:00, 03005, WMO, SYNOP, 1, 9, 1011, 4, 1, 210, 26, 62, 8, 6,
8, 8, , , 8, 30, 700, 1006, 1, 8, 54, 7, 6, 105, , , , , , , , 8.6, 7.3, 8,
996.1, , 01, , , , , 1, 1, 1, 1, 1, 1, 1, , , 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, , , , , , , , 1, , , , , 2014-12-31 23:55, 0, , , , , , , , , ,
, , K, , , , , 91.7, A, , , 0, 1
2015-01-01 00:00, 03006, WMO, SYNOP, 1, 10, 1011, 4, 6, 210, 23, , , , , ,
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , 1, 1, , , , , , ,
, , , , , , , , , , , , , , , , , , , , , , , , , , , 2014-12-31 23:53, 0,
, , , , , , , , , , , , , , , , , A, , , ,
2015-01-01 00:00, 03010, WMO, SYNOP, 1, 17, 1011, 4, 6, 230, 21, , , , , ,
, , , , , 1006.1, , , , , , , , , , , , , , 9.4, 6.2, 7.9, , , , , , , , 1,
1, , , , , , , , , , , 1, 1, 1, 1, , , , , , , , , , , , , , , , , , , ,





If I could download it I should still be able to use it as I could identify
each separate line as it will be headed by a date.   The files are v large
c 1GB and when I start to download in R it works for a while and then
after maybe 30 seconds I get this error message:



Error in read.table("midas_wxhrly_201501-201512.txt", fill = T) :
  duplicate 'row.names' are not allowed


The instruction in the error message works perfectly well up to 2010, and I
can’t see where a “duplicate rowname” would come in this data anyway


Is there a way of either downloading the file without getting the error
message or of being able to identify at what point in the file the error
message is being generated so that I could, by hand possibly, take out
whatever the problem is?



I’ve tried putting the downloaded text doc into other formats but nothing
seems to work

If anyone has any ideas I’d be v grateful   Thanks Nick Wray

[[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] Reading very large text files into R

2022-09-30 Thread Nick Wray
Hello Thanks again for all the suggestions.  The irony is that for the
datasets I'm using the fill=T as suggested by Ivan in the first instance I
think works fine.  They're not particularly sophisticated datasets and
although I don't know what the extra Bs (of which the first one  as Avi
says does occur quite late on) actually mean I don't really need to know -
all I need is the date/time/station id/rainfall accumulation and that's
obvious once I've read the dataset in.  It has been interesting seeing the
takes of people who have a far deeper and wider understanding of R than I
do however and an education in itself... Nick

On Fri, 30 Sept 2022 at 20:16,  wrote:

> Tim and others,
>
> A point to consider is that there are various algorithms in the functions
> used to read in formatted data into data.frame form and they vary. Some do
> a
> look-ahead of some size to determine things and if they find a column that
> LOOKS LIKE all integers for say the first thousand lines, they go and read
> in that column as integer. If the first floating point value is thousands
> of
> lines further along, things may go wrong.
>
> So asking for line/row 16 to have an extra 16th entry/column may work fine
> for an algorithm that looks ahead and concludes there are 16 columns
> throughout. Yet a file where the first time a sixteenth entry is seen is at
> line/row 31,459 may well just set the algorithm to expect exactly 15
> columns
> and then be surprised as noted above.
>
> I have stayed out of this discussion and others have supplied pretty much
> what I would have said. I also see the data as flawed and ask which rows
> are
> the valid ones. If a sixteenth column is allowed, it would be better if all
> other rows had an empty sixteenth column. If not allowed, none should have
> it.
>
> The approach I might take, again as others have noted, is to preprocess the
> data file using some form of stream editor such as AWK that automagically
> reads in a line at a time and parses lines into a collection of tokens
> based
> on what separates them such as a comma. You can then either write out just
> the first 15 to the output stream if your choice is to ignore a spurious
> sixteenth, or write out all sixteen for every line, with the last being
> some
> form of null most of the time. And, of course, to be more general, you
> could
> make two passes through the file with the first one determining the maximum
> number of entries as well as what the most common number of entries is, and
> a second pass using that info to normalize the file the way you want. And
> note some of what was mentioned could often be done in this preprocessing
> such as removing any columns you do not want to read into R later. Do note
> such filters may need to handle edge cases like skipping comment lines or
> treating the row of headers differently.
>
> As some have shown, you can create your own filters within a language like
> R
> too and either read in lines and pre-process them as discussed or continue
> on to making your own data.frame and skip the read.table() type of
> functionality. For very large files, though, having multiple variations in
> memory at once may be an issue, especially if they are not removed and
> further processing and analysis continues.
>
> Perhaps it might be sensible to contact those maintaining the data and
> point
> out the anomaly and ask if their files might be saved alternately in a
> format that can be used without anomalies.
>
> Avi
>
> -Original Message-
> From: R-help  On Behalf Of Ebert,Timothy
> Aaron
> Sent: Friday, September 30, 2022 7:27 AM
> To: Richard O'Keefe ; Nick Wray 
> Cc: r-help@r-project.org
> Subject: Re: [R] Reading very large text files into R
>
> Hi Nick,
>Can you post one line of data with 15 entries followed by the next line
> of data with 16 entries?
>
> Tim
>
> __
> 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] Reading very large text files into R

2022-09-29 Thread Nick Wray
Hello Ivan's suggestion of fill=T seems to do the trick.  Thanks to
everyone who piled in - I'm rather touched by the support seeing as this
was causing me a big headache with furthering my project.  I also feel
humbled by realising how little I know about the R-universe... Nick

On Thu, 29 Sept 2022 at 15:09, Ivan Krylov  wrote:

> В Thu, 29 Sep 2022 14:54:10 +0100
> Nick Wray  пишет:
>
> > although most lines in the text doc consist of 15 elements, every so
> > often there is a sixteenth one and R doesn’t like this and gives me
> > an error message
>
> Does the fill = TRUE argument of read.table() help?
>
> If not, could you construct and share a small file with the same kind
> of problem (16th field) but without the data one has to apply for
> access to? (E.g. cut out a few lines from the original file, then
> replace all digits.)
>
> --
> Best regards,
> Ivan
>

[[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] Reading very large text files into R

2022-09-29 Thread Nick Wray
Hi Bert   Right Thing is, I didn't know that there even was an instruction
like read.csv(text =
"... your text... ")  so at any rate I can paste the original text files in
by hand if there's no shorter cut
Thanks v much Nick

On Thu, 29 Sept 2022 at 16:16, Bert Gunter  wrote:

> I had no trouble reading your text snippet with
> read.csv(text =
> "... your text... ")
>
> There were 15 columns. The last column was all empty except for the row
> containing the "B".
>
> So there seems to be some confusion here.
>
> -- Bert
>
>
>
>
>
>
> On Thu, Sep 29, 2022 at 6:54 AM Nick Wray  wrote:
>
>> Hello   I may be offending the R purists with this question but it is
>> linked to R, as will become clear.  I have very large data sets from the
>> UK
>> Met Office in notepad form.  Unfortunately,  I can’t read them directly
>> into R because, for some reason, although most lines in the text doc
>> consist of 15 elements, every so often there is a sixteenth one and R
>> doesn’t like this and gives me an error message because it has assumed
>> that
>> every line has 15 elements and doesn’t like finding one with more.  I have
>> tried playing around with the text document, inserting an extra element
>> into the top line etc, but to no avail.
>>
>> Also unfortunately you need access permission from the Met Office to get
>> the files in question so this link probably won’t work:
>>
>> https://catalogue.ceda.ac.uk/uuid/bbd6916225e7475514e17fdbf11141c1
>>
>> So what I have done is simply to copy and paste the text docs into excel
>> csv and then read them in, which is time-consuming but works.  However the
>> later datasets are over the excel limit of 1048576 lines.  I can paste in
>> the first 1048576 lines but then trying to isolate the remainder of the
>> text doc to paste it into a second csv doc is proving v difficult – the
>> only way I have found is to scroll down by hand and that’s taking ages.  I
>> cannot find another way of editing the notepad text doc to get rid of the
>> part which I have already copied and pasted.
>>
>> Can anyone help with a)ideally being able to simply read the text tables
>> into R  or b)suggest a way of editing out the bits of the text file I have
>> already pasted in without laborious scrolling?
>>
>> Thanks Nick Wray
>>
>> [[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.


[R] Fwd: Reading very large text files into R

2022-09-29 Thread Nick Wray
-- Forwarded message -
From: Nick Wray 
Date: Thu, 29 Sept 2022 at 15:32
Subject: Re: [R] Reading very large text files into R
To: Ben Tupper 


Hi Ben
Beneath is an example of the text (also in an attachment) and it's the "B",
of which there are quite a few scattered throughout the text doc which
causes the reading in error message (btw I don't need the "RAIN" column or
the 1's after it or the last four elements).   I have also attached the
snippet as text file

1980-01-01 10:00, 225620, RAIN, 1, 1, WAHRAIN, 5091, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 226918, RAIN, 1, 1, WAHRAIN, 5124, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 228562, RAIN, 1, 1, WAHRAIN, 491, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 231581, RAIN, 1, 1, WAHRAIN, 5213, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 232671, RAIN, 1, 1, WAHRAIN, 487, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 232913, RAIN, 1, 1, WAHRAIN, 5243, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 234362, RAIN, 1, 1, WAHRAIN, 5265, 1001, 0, , 10009, 0, ,
, B
1980-01-01 10:00, 234682, RAIN, 1, 1, WAHRAIN, 5271, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 235389, RAIN, 1, 1, WAHRAIN, 5279, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 236466, RAIN, 1, 1, WAHRAIN, 497, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 243350, RAIN, 1, 1, SREW, 484, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 243350, RAIN, 1, 1, WAHRAIN, 484, 1001, 0, 0, 9, 9, , ,

Thanks Nick

On Thu, 29 Sept 2022 at 15:12, Ben Tupper  wrote:

> Hi Nick,
>
> It's hard to know without seeing at least a snippet of the data.
> Could you do the following and paste the result into a plain text
> email?  If you don't set your email client to plain text (from rich
> text or html) then we are apt to see a jumble of output on our email
> clients.
>
>
> ## start
> x <- readLines(filename, n = 20)
> cat(x, sep = "\n")
> ## end
>
> Cheers,
> Ben
>
>
> On Thu, Sep 29, 2022 at 9:54 AM Nick Wray  wrote:
> >
> > Hello   I may be offending the R purists with this question but it is
> > linked to R, as will become clear.  I have very large data sets from the
> UK
> > Met Office in notepad form.  Unfortunately,  I can’t read them directly
> > into R because, for some reason, although most lines in the text doc
> > consist of 15 elements, every so often there is a sixteenth one and R
> > doesn’t like this and gives me an error message because it has assumed
> that
> > every line has 15 elements and doesn’t like finding one with more.  I
> have
> > tried playing around with the text document, inserting an extra element
> > into the top line etc, but to no avail.
> >
> > Also unfortunately you need access permission from the Met Office to get
> > the files in question so this link probably won’t work:
> >
> > https://catalogue.ceda.ac.uk/uuid/bbd6916225e7475514e17fdbf11141c1
> >
> > So what I have done is simply to copy and paste the text docs into excel
> > csv and then read them in, which is time-consuming but works.  However
> the
> > later datasets are over the excel limit of 1048576 lines.  I can paste in
> > the first 1048576 lines but then trying to isolate the remainder of the
> > text doc to paste it into a second csv doc is proving v difficult – the
> > only way I have found is to scroll down by hand and that’s taking ages.
> I
> > cannot find another way of editing the notepad text doc to get rid of the
> > part which I have already copied and pasted.
> >
> > Can anyone help with a)ideally being able to simply read the text tables
> > into R  or b)suggest a way of editing out the bits of the text file I
> have
> > already pasted in without laborious scrolling?
> >
> > Thanks Nick Wray
> >
> > [[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.
>
>
>
> --
> Ben Tupper (he/him)
> Bigelow Laboratory for Ocean Science
> East Boothbay, Maine
> http://www.bigelow.org/
> https://eco.bigelow.org
>
1980-01-01 10:00, 225620, RAIN, 1, 1, WAHRAIN, 5091, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 226918, RAIN, 1, 1, WAHRAIN, 5124, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 228562, RAIN, 1, 1, WAHRAIN, 491, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 231581, RAIN, 1, 1, WAHRAIN, 5213, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 232671, RAIN, 1, 1, WAHRAIN, 487, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 232913, RAIN, 1, 1, WAHRAIN, 5243, 1001, 0, , 9, 0, , ,
1980-01-01 10:00, 234362, RAIN, 1, 1, WAHRAIN, 

[R] Reading very large text files into R

2022-09-29 Thread Nick Wray
Hello   I may be offending the R purists with this question but it is
linked to R, as will become clear.  I have very large data sets from the UK
Met Office in notepad form.  Unfortunately,  I can’t read them directly
into R because, for some reason, although most lines in the text doc
consist of 15 elements, every so often there is a sixteenth one and R
doesn’t like this and gives me an error message because it has assumed that
every line has 15 elements and doesn’t like finding one with more.  I have
tried playing around with the text document, inserting an extra element
into the top line etc, but to no avail.

Also unfortunately you need access permission from the Met Office to get
the files in question so this link probably won’t work:

https://catalogue.ceda.ac.uk/uuid/bbd6916225e7475514e17fdbf11141c1

So what I have done is simply to copy and paste the text docs into excel
csv and then read them in, which is time-consuming but works.  However the
later datasets are over the excel limit of 1048576 lines.  I can paste in
the first 1048576 lines but then trying to isolate the remainder of the
text doc to paste it into a second csv doc is proving v difficult – the
only way I have found is to scroll down by hand and that’s taking ages.  I
cannot find another way of editing the notepad text doc to get rid of the
part which I have already copied and pasted.

Can anyone help with a)ideally being able to simply read the text tables
into R  or b)suggest a way of editing out the bits of the text file I have
already pasted in without laborious scrolling?

Thanks Nick Wray

[[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] reading text files directly into program from net

2022-09-25 Thread Nick Wray
Hello   I am working with daily rainfall data for the UK from 1915 onwards
from the Met Office.  The data is on this site:

https://data.ceda.ac.uk/badc/ukmo-midas-open/data/uk-daily-rain-obs/dataset-version-201901

There are many files for the different counties.  For example there are
seven station files for Berwickshire in this site:

https://data.ceda.ac.uk/badc/ukmo-midas-open/data/uk-daily-rain-obs/dataset-version-201901/berwickshire


The first station in this dataset
 has the name  00265_mertoun
<https://data.ceda.ac.uk/badc/ukmo-midas-open/data/uk-daily-rain-obs/dataset-version-201901/berwickshire/00265_mertoun>
which
is a code and location name, again for example, and inside is a text file

It's easy but time-consuming to download the files one by one - I am sure
that it is possible to read them directly into an R program but whatever
coding or path I try to use I get an error.  I can't find an example online
which I can tweak to allow me to do this.

can anyone help?  Thanks Nick Wray

[[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] removing non-table lines

2022-09-18 Thread Nick Wray
Hello - I am having to download lots of rainfall and temperature data in
csv form from the UK Met Office.  The data isn't a problem - it's in nice
columns and can be read into R easily - the problem is that in each csv
there are 60 or so lines of information first which are not part of the
columnar data.  If I read the whole csv into R the column data is now
longer in columns but in some disorganised form - if I manually delete all
the text lines above and download I get a nice neat data table.  As the
text lines can't be identified in R by line numbers etc I can't find a way
of deleting them in R and atm have to do it by hand which is slow.  It
might be possible to write a complicated and dirty algorithm to rearrange
the meteorological data back into columns but I suspect that it might be
hard to get right and consistent across every csv sheet and any errors
might be hard to spot.   I can't find anything on the net about this - has
anyone else had to deal with this problem and if so do they have any
solutions using R?
Thanks Nick Wray

[[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] opening nimroad tar gz files in R

2022-09-15 Thread Nick Wray
Hello

I am trying to download data sets from the 1 km Resolution UK Composite
Rainfall Data from the Met Office Nimrod System

Eg

CEDA Archive Web Browser
<https://data.ceda.ac.uk/badc/ukmo-nimrod/data/composite/uk-1km/2004>
/badc/ukmo_nimrod/data/composite/uk-1km/2004

I can download an individual file (there are lots for each year) as a
.gz.tar and then it appears as a TAR file in the directory I am using.

I have then used the instruction untar() (targeted on the correct
directory) and what this produces is about a dozen these files which are
labelled as .gz files.  They appear in the same folder as the original TAR
folder but as R files (ie although they have .gz in the name they have the
R icon next to them as do any R progs which I have).  I can’t open them
though as R progs (which I don’t really think they can be) and trying to
just takes me back to the R studio interface.

I’ve tried  -- read.table (gzfile
("metoffice-c-band-rain-radar_uk_200404062250_1km-composite.dat.gz")) but
that just gives a load of error messages and I haven’t found any other way
of opening them as .gz files.

I’m rather baffled – can anyone make any suggestions?  Thanks Nick Wray

[[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] GIS in R

2022-09-01 Thread Nick Wray
I hope that this is an allowable question - for my hydrological research I
need to create and manipulate maps (ideally in raster form), and get
conversant with GIS.  I have for example downloaded QGIS but am finding the
sites on it opaque, and more widely I am finding it hard to find useful
sources of information on GIS processing in R.

Does anyone know of any accessible sites or useful texts on GIS processing
in R?

Thanks Nick Wray

[[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] von Neumann/Bartels/Serial Correlation

2022-08-14 Thread Nick Wray
Hello  Although there is info on the net about the von Neumann test -
VonNeumannTest:
Von Neumann's Successive Difference Test in DescTools: Tools for
Descriptive Statistics (rdrr.io)
<https://rdrr.io/cran/DescTools/man/VonNeumannTest.html>

I can't make the function run and it doesn't say that the VonNeumannTest()
function is ain a package.  ?VonNeumannTest yields nothing

Likewise, although there is a CRAN page for BartelsRankTest() it doesn't
work and again ?BartelsRankTest gives nothing

And again serialCorrelationTest isn't recognise although again there are
Cran pages

Can anyone point me to where I can find these functions and any info?

Thanks Nick Wray

[[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] lfstat package

2022-08-11 Thread Nick Wray
Hello - does anyone know whether the lfstat package is still running and if
so, whence it can be downloaded and installed, as it doesn't seem to be
available from CRAN.  I'm trying to get the function dmcurve() for
hydrological double mass curves - perhaps that's now elsewhere although i
can't find it anywhere but in lfstat

thanks Nick Wray

[[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] bu.test again

2022-06-26 Thread Nick Wray
Hello This is a second message as the first seemed a bit messed up.  i will
not copy anything into this but just ask the simple question -  the
function bu.test() in R - does it come in a package because I can't find it
anywhere and it doesn't work on base R

thanks Nick Wray

[[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] Naming files within R code

2022-03-20 Thread Nick Wray
HelloI have data from various Scottish river catchments in the form of
csv files.  I want to be able to download the files in turn and refer to
each one by an assigned name from a vector of names, but within R.  So, for
example, if my vector of names is c("tay","forth","don") I want to tell R
to refer to the sequences of dataframes as a variable name, ie the table
uploaded from the first csv becomes the object tay *within* R and so on, so
that I could the do things like write print(tay[,1]) etc,rather than having
to refer to a list eg print(riverlist[[1]][,1])  I don't know whether this
is possible but if it is I'd be grateful for any pointers
Thanks, Nick Wray

[[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] Rcpp package problems

2021-09-29 Thread Nick Wray
Hi I am having having problems with the package Rcpp.  Although I have
installed and loaded it, in two different situations it seems to send R
into an endless loop



The first one was trying to run code from a site showing how to use the
stl() function

*http://www.gardner.fyi/blog/STL-Part-I/
<http://www.gardner.fyi/blog/STL-Part-I/>*



The code and data is at

https://github.com/dillongardner/NYTraffic



The first few lines are as follows:



library(feather)
library(dplyr)
library(tidyr)
library(ggplot2)
library(stlplus)
library(dygraphs)
library(lubridate)
library(Rcpp)
##
# Read and format
##

myData <- read_feather("NYTrafficData.feather")

At this point I get the error message: “Error in openFeather(path) :

  function 'Rcpp_precious_remove' not provided by package 'Rcpp'”



BUT – if now I rerun the line

library(Rcpp)

I don’t get the error message but R goes into an endless loop with the red
button thing



Similarly, if I try to run the example code from the R documentation site



https://www.rdocumentation.org/packages/stlplus/versions/0.5.1/topics/stlplus



library(stlplus)
library(Rcpp)
##
co2_stl <- stlplus(co2, t = as.vector(time(co2)), n.p = 12,
   l.window = 13, t.window = 19, s.window = 35, s.degree = 1,
   sub.labels = substr(month.name, 1, 3))

Again I get the error message “Error in c_loess(x[y_idx], y[y_idx],
degree, span, weights[y_idx], m,  :

  function 'Rcpp_precious_remove' not provided by package 'Rcpp'“



BUT again if I rerun the line

library(Rcpp)

I don’t get the error message but R goes into an endless loop with the red
button thing



Can anyone help me to sort this?  Thanks Nick Wray

[[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] Augmented Dickie-Fuller test

2021-08-26 Thread Nick Wray
Hello: I've downloaded this dataset, and when I plot it it is clearly
non-stationary


df <- read.csv('
https://raw.githubusercontent.com/ourcodingclub/CC-time-series/master/monthly_milk.csv
')

plot(df,type="l")

But when I apply the Augmented Dickie-Fuller Test I get a p value of 0.01,
implying that there is evidence to reject the null that the series is
non-stationary. I am puzzled as to why this is happening. Is this because
the confidence level is basically too high or is something else going on?

adf.test(df[,2])

Augmented Dickey-Fuller Test

data: df[, 2] Dickey-Fuller = -9.9714, Lag order = 5, p-value = 0.01
alternative hypothesis: stationary

Thanks Nick Wray

[[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] airGR package

2021-08-19 Thread Nick Wray
Hi  I'm trying to get to grips with the airGR hydrological package - I've
done various searches with various questions and there seems to be a
limited amount of accessible info out there, with every site quoting the
same example run using the GR4J model.  Has anyone out there used this
package and do they have any further examples or just explanatory info
which they would be willing to share?

Thanks, Nick Wray

[[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] Unending loop

2021-07-29 Thread Nick Wray
Hello I don't know whether strictly speaking this is an R-help province
question but anyway...
I am looking at the extRemes package and have some code given beneath.
When I run it on my own laptop it works fine, but when I run it on my uni
laptop (which is pretty new and I only was given a couple of months ago)
when it gets to the thresh.range line it goes into an unending loop (or
something) with the little red Stop button, and just sits there.  I have R
4.0.4 on my uni laptop and R 4.0.5 on my own one.  Could this be the reason?

Thanks, Nick Wray

install.packages("extRemes")
library(extRemes)
data(Fort)
names(Fort)

bmFort <- blockmaxxer(Fort, blocks = Fort$year, which="Prec")
names(bmFort)

plot(Fort$year, Fort$Prec, xlab = "Year",
 ylab = "Precipitation (inches)",
 cex = 1.25, cex.lab = 1.25,
 col = "darkblue", bg = "lightblue", pch = 21)

points(bmFort$year, bmFort$Prec, col="darkred", cex=1.5)

# Fit a GEV distribution to annual maximum Precipitation
# in Fort Collins, Colorado, U.S.A.
fitGEV <- fevd(Prec, data = bmFort)
fitGEV
plot(fitGEV)
plot(fitGEV, "trace")

# Select a threshold for daily data from above.
threshrange.plot(Fort$Prec, c(0.1, 2), type = "PP")

# Fit the PP model to the daily data from above.
fitPP <- fevd(Prec, data = Fort, threshold = 0.395,
  type = "PP", units = "inches")
fitPP
plot(fitPP)

atdf(Fort$Prec, 0.395)

extremalindex(Fort$Prec, 0.395, blocks=Fort$year)

dcFort <- decluster(Fort$Prec, 0.395, r = 9)
plot(dcFort)

[[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] Puzzled over "partial"

2021-07-26 Thread Nick Wray
Hello   I am puzzled about the use or status of "partial" in R.  years ago
I found a little piece of code which gives the pth largest number in a
vector:
x<-c(5,4,7,2,6,9)
n <- length(x)
p<-4
sort(x,partial=n-(n-p))[n-(n-p)]
This works fine, although I have tried playing around with the code and
don't understand what "partial" is doing here.
However, wanted to work out what was going on, so I looked for "partial in
r" on t'internet and got this site:Partial apply a function, filling in
some arguments. — partial • purrr (tidyverse.org)
<https://purrr.tidyverse.org/reference/partial.html#:~:text=Source%3A%20R%2Fpartial.R%20Partial%20function%20application%20allows%20you%20to,that%20an%20argument%20can%20only%20be%20partialised%20once.>
Examples:
# Partial is designed to replace the use of anonymous functions for #
filling in function arguments. Instead of: compact1 <- function(x) discard
<https://purrr.tidyverse.org/reference/keep.html>(x, is.null) # we can
write: compact2 <- partial(discard, .p = is.null) # partial() works fine
with functions that do non-standard # evaluation my_long_variable <- 1:10
plot2 <- partial(plot, my_long_variable) plot2()
when i tried to run the examples on this site I got error messages - R
(studio) did not recognise the "partial" function here.  The site did not
say that I needed a particular package to run the "partial" function.
Are there essentially two different things in R both described as "partial"
but which are actually different entities?
Thanks for any elucidation
Nick Wray

[[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] Magick Package

2021-06-07 Thread Nick Wray
Hello  I'm trying to use the Magick package for animations - it has
downloaded OK but says that it was built under version 4.0.5 and that
fontconfig and x11 features are disabled.  Atm I am using R 1.4.1103   Am I
being naive in assuming that all later versions of R subsume the features
of earlier ones or is it that some packages stop being useable with later
updates?
In any event I have some code for an animation sequence which I have
downloaded from the site -Lesson 39 – Discrete distributions in R: Part I –
dataanalysisclassroom <https://www.dataanalysisclassroom.com/lesson39/>
 the code runs without an error message but it doesn't give the animation
sequence you see on the website
Any help suggestions appreciated   Nick Wray

 Animation #

# Create png files for Binomial distribution png(file="binomial%02d.png",
width=600, height=300)

 n = 181

x = 0:181



p = 0.1

for (i in 1:5)

{

px = dbinom(x,n,p)

 plot(x,px,type="h",xlab="Random Variable X (Number of tickets in 181
days)",ylab="Probability P(X=k)",font=2,font.lab=2)

txt = paste("p=",p,sep="")

text(150,0.04,txt,col="red",cex=2)

p = p+0.2

}

dev.off()



# Combine the png files saved in the folder into a GIF #



library(magick)



binomial_png1 <- image_read("binomial01.png","x150")

binomial_png2 <- image_read("binomial02.png","x150")

binomial_png3 <- image_read("binomial03.png","x150")

binomial_png4 <- image_read("binomial04.png","x150")

binomial_png5 <- image_read("binomial05.png","x150")



frames <- image_morph(c(binomial_png1, binomial_png2, binomial_png3,
binomial_png4, binomial_png5), frames = 15)

animation <- image_animate(frames)



image_write(animation, "binomial.gif")

[[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] DBDA2E-utilities.R file download

2021-05-31 Thread Nick Wray
Hello I am trying to download the file "kyusque/DBDA2E-utilities.R" which
is used in following through John Krushke's book on Bayesian stats.
According to the net (kyusque/DBDA2E-utilities: Packaged One for
DBDA2E-utilities.R in 'Kruschke, J. K. (2015). Doing Bayesian Data
Analysis, Second Edition' version 0.1.0 from GitHub (rdrr.io)
<https://rdrr.io/github/kyusque/DBDA2E-utilities/>) I needed to

install.packages("remotes")
remotes::install_github("kyusque/DBDA2E-utilities")

which i have done, and seem to have done successfully

but I can't get hold of the utilities file.  Does anyone know what I
should now do?

Thanks Nick Wray

[[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] Creating a histogram from a frequency vector

2019-10-09 Thread Nick Wray via R-help
Aargh of course - so obvious I'd completely overlooked that.>.  Thanks Nick
> On 09 October 2019 at 16:21 Ivan Krylov  wrote:
> 
> 
> On Wed, 9 Oct 2019 16:12:57 +0100 (BST)
> Nick Wray via R-help  wrote:
> 
> > I have a vector like say 73,53,42,67,41,50 where these numbers are
> > the number of occurrences of the data values 1,2,3,4,5,6
> 
> > I can't see an elegant way <...> of creating a histogram from this
> > data set.  Is there one?
> 
> A histogram is a bar plot of frequencies of data values falling into
> specific bins, so you can reconstruct one yourself using the barplot()
> function.
> 
> -- 
> Best regards,
> Ivan

__
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] Creating a histogram from a frequency vector

2019-10-09 Thread Nick Wray via R-help
I have a vector like say 73,53,42,67,41,50 where these numbers are the number 
of occurrences of the data values 1,2,3,4,5,6 - so in essence I have the 
frequency bit from the hist() function.  I can't see an elegant way (there are 
clearly messy workarounds like generating a vector of 73 1's, 53 2's etc) of 
creating a histogram from this data set.  Is there one?

Thanks Nick Wray
[[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] Pasting R code lines into labels

2019-06-07 Thread Nick Wray via R-help
lt;- function(x) cos(x)
> >>>> plotFx(x, f)
> >>>> 
> >>>> f <- function(x) exp(x) + 1
> >>>> plotFx(x, f)
> >>>> 
> >>>> 
> >>>> In the case of the first function, you get:
> >>>> 
> >>>>> deparse(f)
> >>>> [1] "function (x) " "x^2"
> >>>> 
> >>>> for the second:
> >>>> 
> >>>>> deparse(f)
> >>>> [1] "function (x) " "cos(x)"
> >>>> 
> >>>> and for the third:
> >>>> 
> >>>>> deparse(f)
> >>>> [1] "function (x) " "exp(x) + 1"
> >>>> 
> >>>> 
> >>>> Thus, the "deparse(fun)[2]" snippet within the internal paste0() 
> function
> >>>> call, gets you the second, textual part of the function body, which 
> can
> >>>> then be passed as a character vector to the titles or other labels as
> >>>> needed.
> >>>> 
> >>>> A potential gotcha that I would envision, is that the default width 
> in the
> >>>> character vector resulting from deparse() is 60. Thus, by default the
> >>>> function body would broken up into multiple character segments, no 
> longer
> >>>> than approximately 60 characters each. Thus, if you envision that 
> you might
> >>>> end up with very long formulae on x, you may need to adjust the
> >>>> width.cutoff argument in the deparse() call, and likely need to do 
> some
> >>>> additional formatting of the labels in the plot as apropos.
> >>>> 
> >>>> There may be other functional nuances that I am missing here, but 
> this may
> >>>> be a suitable approach.
> >>>> 
> >>>> Regards,
> >>>> 
> >>>> Marc
> >>>> 
> >>>> 
> >>>>> On Jun 6, 2019, at 2:11 PM, Bert Gunter  
> wrote:
> >>>>> 
> >>>>> Yes, plot(z,y,..)
> >>>>> 
> >>>>> Bert
> >>>>> 
> >>>>> On Thu, Jun 6, 2019 at 9:21 AM Nick Wray 
> 
> >>>> wrote:
> >>>>> 
> >>>>> Thanks Bert, that is exactly what I wanted.  I think that you meant
> >>>>> plot(z,y... in the last line?
> >>>>> 
> >>>>> Nick
> >>>>> 
> >>>>> On 06 June 2019 at 17:13 Bert Gunter  wrote:
> >>>>> 
> >>>>> ... and if you wanted too streamline the process, something like the
> >>>>> following could be encapsulated in a function:
> >>>>> 
> >>>>> fun <- quote(exp(x))
> >>>>> z <- 1:9
> >>>>> y <- eval(fun,list(x = z) )
> >>>>> plot(x, y, main = paste("Plot of y =", deparse(fun)))
> >>>>> 
> >>>>> Further details can be found in the "Computing on the Language" section
> >>>> of
> >>>>> the "R Language Reference" manual or from suitable tutorials on the web.
> >>>>> 
> >>>>> 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, Jun 6, 2019 at 8:55 AM Nick Wray via R-help <
> >>>> r-help@r-project.org>
> >>>>> wrote:
> >>>>> 
> >>>>> Thanks but that's not quite what I meant
> >>>>> I am trying out different functions and they don't necessarily vary in a
> >>>>> regular way (like say all being powers of x where it'd be simple to just
> >>>>> have a vector for the powers you want)
> >>>>> So I might have
> >>>>> y<-x^2
> >>>>> y<-cos(x)
> >>>>> y<-exp(x+1)
> >>>>> What I am after is a way of running these functions and then calling
> >>>> each
> >>>>> one into the labelling for the appropriate graph as I plot it.  So then
> >>>> I
> >>>>> would have something like
> >>>>> mainlab<-paste("Plot of ",function in question)
> >>>>> ...? Thanks Nick
> >>>>> 
> >>>>>>> On 06 June 2019 at 16:40 Marc Schwartz < marc_schwa...@me.com> 
> wrote:
> >>>>>>> 
> >>>>>>> 
> >>>>>>> 
> >>>>>>>> On Jun 6, 2019, at 11:19 AM, Nick Wray via R-help <
> >>>>> r-help@r-project.org> wrote:
> >>>>>>>> 
> >>>>>>>> Is there any way of taking a line of r code (eg y<-x^2) and 
> pasting
> >>>>> that line of code, as is, into a label, so that for example I could then
> >>>>> have a plot label "Plot of y<-x^2"?
> >>>>>>>> 
> >>>>>>>> Thanks Nick Wray
> >>>>>>> 
> >>>>>>> 
> >>>>>>> Hi,
> >>>>>>> 
> >>>>>>> See ?plotmath
> >>>>>>> 
> >>>>>>> An example:
> >>>>>>> 
> >>>>>>> x <- 1:10
> >>>>>>> y <- x^2
> >>>>>>> 
> >>>>>>> plot(x, y, main = expression(paste("Plot of ", y %<-% x^2)))
> >>>>>>> 
> >>>>>>> 
> >>>>>>> There are other incantations and examples on the help page above.
> >>>>>>> 
> >>>>>>> Regards,
> >>>>>>> 
> >>>>>>> Marc Schwartz
> >>>>>>> 
> 
> > __
> > 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-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] Pasting R code lines into labels

2019-06-06 Thread Nick Wray via R-help
Thanks Bert, that is exactly what I wanted.  I think that you meant plot(z,y... 
in the last line?

Nick

> On 06 June 2019 at 17:13 Bert Gunter  wrote:
> 
> ... and if you wanted too streamline the process, something like the 
> following could be encapsulated in a function:
> 
> fun <- quote(exp(x))
> z <- 1:9
> y <- eval(fun,list(x = z) )
> plot(x, y, main = paste("Plot of y =", deparse(fun)))
> 
> Further details can be found in the "Computing on the Language" section 
> of the "R Language Reference" manual or from suitable tutorials on the web.
> 
> 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, Jun 6, 2019 at 8:55 AM Nick Wray via R-help < 
> r-help@r-project.org mailto:r-help@r-project.org > wrote:
> 
> > > Thanks but that's not quite what I meant
> > I am trying out different functions and they don't necessarily vary 
> > in a regular way (like say all being powers of x where it'd be simple to 
> > just have a vector for the powers you want)
> > So I might have
> > y<-x^2
> > y<-cos(x)
> > y<-exp(x+1)
> > What I am after is a way of running these functions and then 
> > calling each one into the labelling for the appropriate graph as I plot it. 
> >  So then I would have something like
> > mainlab<-paste("Plot of ",function in question)
> >     ...? Thanks Nick
> > 
> > > On 06 June 2019 at 16:40 Marc Schwartz < marc_schwa...@me.com 
> > mailto:marc_schwa...@me.com > wrote:
> > >
> > >
> > >
> > > > On Jun 6, 2019, at 11:19 AM, Nick Wray via R-help < 
> > r-help@r-project.org mailto:r-help@r-project.org > wrote:
> > > >
> > > > Is there any way of taking a line of r code (eg y<-x^2) and 
> > pasting that line of code, as is, into a label, so that for example I could 
> > then have a plot label "Plot of y<-x^2"?
> > > >
> > > > Thanks Nick Wray
> > >
> > >
> > > Hi,
> > >
> > > See ?plotmath
> > >
> > > An example:
> > >
> > > x <- 1:10
> > > y <- x^2
> > >
> > > plot(x, y, main = expression(paste("Plot of ", y %<-% x^2)))
> > >
> > >
> > > There are other incantations and examples on the help page above.
> > >
> > > Regards,
> > >
> > > Marc Schwartz
> > >
> > 
> > __
> > R-help@r-project.org mailto: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] Pasting R code lines into labels

2019-06-06 Thread Nick Wray via R-help
Thanks but that's not quite what I meant
I am trying out different functions and they don't necessarily vary in a 
regular way (like say all being powers of x where it'd be simple to just have a 
vector for the powers you want)
So I might have
y<-x^2
y<-cos(x)
y<-exp(x+1)
What I am after is a way of running these functions and then calling each one 
into the labelling for the appropriate graph as I plot it.  So then I would 
have something like
mainlab<-paste("Plot of ",function in question)
...? Thanks Nick

> On 06 June 2019 at 16:40 Marc Schwartz  wrote:
> 
> 
> 
> > On Jun 6, 2019, at 11:19 AM, Nick Wray via R-help  
> > wrote:
> > 
> > Is there any way of taking a line of r code (eg y<-x^2) and pasting that 
> > line of code, as is, into a label, so that for example I could then have a 
> > plot label "Plot of y<-x^2"?
> > 
> > Thanks Nick Wray 
> 
> 
> Hi,
> 
> See ?plotmath
> 
> An example:
> 
> x <- 1:10
> y <- x^2
> 
> plot(x, y, main = expression(paste("Plot of ", y %<-% x^2)))
> 
> 
> There are other incantations and examples on the help page above.
> 
> Regards,
> 
> Marc Schwartz
>

__
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] Pasting R code lines into labels

2019-06-06 Thread Nick Wray via R-help
Is there any way of taking a line of r code (eg y<-x^2) and pasting that line 
of code, as is, into a label, so that for example I could then have a plot 
label "Plot of y<-x^2"?

Thanks Nick Wray 
[[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] load.wave

2019-02-02 Thread Nick Wray via R-help
I have been given a wav file of train locomotive noise - literally something 
you can play back and hear.  Using the audio package and the load.wave function 
I have got a 1.5 million element vector which visually at least has some 
periodicity in certain parts and does not seem to be completely random.  Most 
elements (99%) are within a range of about -0.14 to +0.14 with occasional 
outliers.  Beneath is a typical short segment.


This is the head:

sample rate: 16000Hz, mono, 16-bits
[1] -3.051851e-05  6.103516e-05 -6.103702e-05  3.051758e-05  3.051758e-05 
-1.220740e-04

Most elements (99%) are within a range of about -0.14 to +0.14 with occasional 
outliers

This is the same kind of output as is illustrated in the documentation: 
https://cran.r-project.org/web/packages/seewave/vignettes/seewave_IO.pdf

What I am not sure about, and I can't find any clear explanation, is what these 
elements actually stand for? 
I would have thought that one needed as a minimum both volume and frequency ie 
a two dimensional vector but as far as I can tell
there is only one single vector.  I'm aware that this question is pushing the 
envelope of R help but...

Thanks, Nick Wray
__
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] load.wave q

2019-02-01 Thread Nick Wray via R-help
Please delete my last question as I have worked out what is going on myself

Thanks Nick Wray
[[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] periodicity

2019-01-30 Thread Nick Wray via R-help
I've found references on websites to an R function "periodicity", but there's 
no such built-in function as far as I can see in R studio.  I can't find 
reference to it being part of any package either.  Can anyone help with this?

Thanks, Nick Wray
[[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] Why does R do this?

2019-01-08 Thread Nick Wray via R-help
y<-c(1,2,3)
z<-which(y>3)
z
y<-y[-z]
y

In the work I'm doing I often have this situation and have to make sure that I 
condition on z being non-zero as y is now numeric(0) rather than the set 
c(1,2,3).  Why does R do this?  Wouldn't it be more sensible for R to simply 
leave the host set unchanged if there are no elements to take out?

Any thoughts?

Thanks, Nick Wray
[[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] Resetting bin size in histogram having already changed to relative frequencies

2018-08-31 Thread Nick Wray via R-help
Hello again.  I am trying to alter the bin size on a histogram where I have 
reset the vertical axis to relative frequency, rather than absolute.  Beneath 
is a simple example (not my real data) of this:

xvals<-rnorm(1000,0,1)
xvals
hist(xvals)
h<-hist(xvals,plot=F)

h
h$counts
h$counts<-h$counts/sum(h$counts)
h$counts
plot(h,freq=T,ylab="Relative Frequency")


This gives me a plot with bin sizes of 0.5 and the relative frequency, but I 
cannot reset the bin size as well.  I don't know whether the only way to do it 
is to reset all the h$mids etc as well but this seems horrendously complicated 
and I wonder whether I am missing something simple

Any ideas I would be thankful for   Nick Wray

[[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] Main label on Cullen and Frey

2018-08-31 Thread Nick Wray via R-help
Hello   Does anyone know how to modify the main label when you plot a Cullen & 
Frey (sounds like an Oxford gentleman's outfitters - statistically significant 
waistcoats a speciality) diagram from the "descdist" function?  I've tried 
setting a variable to the descdist(data) but it just returns the summary 
statistics.

Thanks

Nick Wray
[[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 long can a csv file label be?

2018-06-27 Thread Nick Wray via R-help
Thanks Jim

> On 27 June 2018 at 23:48 Jim Lemon  wrote:
>
>
> Hi Nick,
> You are probably using Windows, for which the maximum path length is
> claimed to be 260 characters. The most common alternative, Linux, has
> a maximum filename length of 255 and a maximum path length of 4096. If
> you are simply writing a file to the current path, it won't make much
> difference.
>
> Jim
>
> On Thu, Jun 28, 2018 at 8:33 AM, Nick Wray via R-help
>  wrote:
> > Hi For various reasons too dull to go into I have been trying to write csv 
> > files from R with very long filenames. However R doesn't seem to like my 
> > doing this, but it is not clear to me what the maximum filename size is, 
> > and I can't find the info on the net. I believe that the maximum pathname 
> > is 255 characters but is that the same thing?
> >
> > Thanks if anyone can enlighten me
> >
> > Nick Wray
> > [[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.


[R] How long can a csv file label be?

2018-06-27 Thread Nick Wray via R-help
Hi For various reasons too dull to go into I have been trying to write csv 
files from R with very long filenames.  However R doesn't seem to like my doing 
this, but it is not clear to me what the maximum filename size is, and I can't 
find the info on the net.  I believe that the maximum pathname is 255 
characters but is that the same thing?

Thanks if anyone can enlighten me

Nick Wray
[[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] Can't open R files

2018-05-21 Thread Nick Wray via R-help
Oh fab it works! thanks v much i'd never used open file like that before Nick

> On 21 May 2018 at 12:24 Duncan Murdoch <murdoch.dun...@gmail.com> wrote:
>
>
> On 21/05/2018 7:20 AM, Nick Wray via R-help wrote:
> > Hello. I'm not sure whether this is strictly the right forum but here 
> > goes... I have got a new (well reconditioned) laptop and have installed R 
> > studio on it. That works fine if I say write a little prog directly into it 
> > or paste R script from a word doc. But if I try to open an R prog (which 
> > I've written elsewhere, the laptop doesn't recognise it as an R prog. 
> > Instead it gives me a little icon with a pair of binoculars and says to try 
> > to find an app for opening said file.
> >
> > But up to now I can't find anything on the net which will open the R files 
> > in the same way as they simply do on my desktop or old laptop.
> >
> > I'd be grateful for any ideas or pointers
>
> If you open RStudio, and use the File | Open File... menu, will it open
> the program?
>
> If so, then the problem is with your file associations. If you're using
> Windows, you need to right click on the file, choose "Open with...",
> then pick RStudio and check the box saying you want to open all files
> that way.
>
> Duncan Murdoch

[[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] Can't open R files

2018-05-21 Thread Nick Wray via R-help
Hello.  I'm not sure whether this is strictly the right forum but here goes...  
 I have got a new (well reconditioned) laptop and have installed R studio on 
it.  That works fine if I say write a little prog directly into it or paste R 
script from a word doc.  But if I try to open an R prog (which I've written 
elsewhere, the laptop doesn't recognise it as an R prog.  Instead it gives me a 
little icon with a pair of binoculars and says to try to find an app for 
opening said file.

But up to now I can't find anything on the net which will open the R files in 
the same way as they simply do on my desktop or old laptop.

I'd be grateful for any ideas or pointers 

Thanks

Nick Wray
[[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.