Re: [R] RINLA

2021-06-09 Thread David Winsemius



On 6/9/21 8:48 PM, peri He wrote:

Dear Friends,

I am running a simple code for rinla.  The INLA package is installed 
successfully on Rstudio.



Techinically, the package is installed in an R library. You are using 
Rstudio as your IDE, but it does not run packages.



But when I run inla (y~x,..) function, I get the following error: could not find 
function "inla"
Did anybody have the same problem before?

I would appreciate it if any information is shared.

Regards,

install.packages("INLA", repos = "https://inla.r-inla-download.org/R/stable;, 
dep = TRUE)



Despite setting dep=TRUE is still got a warning:

"Warning in install.packages :
  dependencies ‘Ecdat’, ‘mpoly’, ‘symmoments’ are not available"


library(INLA)
N = 100  #500, 5000, 25000, 10
x = rnorm(N, mean=6, sd=2)
y = rnorm(N, mean=x,sd=1)
data = list(x=x, y=y, N=N)
# The likelihood family is �gaussian�
model<- inla(y ~ x, family = c("gaussian"), data = data, 
control.predictor=list(link=1))
Summary <- (model)


Despite the warning, INLA installed and loaded without complaint and the 
code ran without error.


I later ran:

install.packages(c('Ecdat', 'mpoly', 'symmoments'))    # no problems 
here either.


So I'm unable to recreate your error.

sessionInfo()

#---

R version 4.0.4 (2021-02-15)   #I'm admittedly not up-to-date, If 
you are,  then provide details


I did check to see if there are any later versions of pkg:INLA and could 
not find any


Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C LC_TIME=en_US.UTF-8    
LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8 
LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C 
LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C


attached base packages:
[1] parallel  stats graphics  grDevices utils datasets methods   
base


other attached packages:
[1] INLA_21.02.23   sp_1.4-5    foreach_1.5.1 
Matrix_1.3-2    RBGL_1.66.0 graph_1.68.0

[7] BiocGenerics_0.36.0

loaded via a namespace (and not attached):
 [1] lattice_0.20-41 codetools_0.2-18    grid_4.0.4 
MatrixModels_0.5-0  stats4_4.0.4    splines_4.0.4
 [7] iterators_1.0.13    tools_4.0.4 yaml_2.2.1 
compiler_4.0.4  BiocManager_1.30.12





[[alternative HTML version deleted]]



Rhelp is a plain-text mailing list. HTML is not welcome.

--

David.

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

2021-06-09 Thread peri He
Dear Friends,

I am running a simple code for rinla.  The INLA package is installed 
successfully on Rstudio.
But when I run inla (y~x,..) function, I get the following error: could not 
find function "inla"
Did anybody have the same problem before?

I would appreciate it if any information is shared.

Regards,

install.packages("INLA", repos = "https://inla.r-inla-download.org/R/stable;, 
dep = TRUE)

library(INLA)
N = 100  #500, 5000, 25000, 10
x = rnorm(N, mean=6, sd=2)
y = rnorm(N, mean=x,sd=1)
data = list(x=x, y=y, N=N)
# The likelihood family is �gaussian�
model<- inla(y ~ x, family = c("gaussian"), data = data, 
control.predictor=list(link=1))
Summary <- (model)

[[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] Merging multiple .csv files into one dataframe

2021-06-09 Thread Jeff Newmiller
Attachments have been stripped by the mailing list. Read the Posting Guide.

Also, English can help, but R code can be ever so much more clear in indicating 
what you have to work with and even what you want out of the broken/missing 
part of your code.

https://cran.r-project.org/web/packages/reprex/index.html (read the vignette) 

On June 9, 2021 1:28:13 PM PDT, Esthi Erickson  wrote:
>Hi,
>
>I am trying to merge columns from four different .csv files into one
>dataframe. I am trying to do something like this
>https://statisticsglobe.com/merge-csv-files-in-r . I am taking long
>format
>.csv files, 1 being the base file (testing-long.csv) which I change to
>wide
>format first and the three others being supplemental files that should
>add
>columns plight, plightLitter, Root Biomass, NO3Soil, NH4Soil and then
>add
>data to cells where the it matches any one of the values for columns,
>"Exp", "Year", "Field", "Plot", "NTrt", "NAdd", "NitrAdd", "NAtm.NAdd".
>So
>the values for the supplemental files need not match every single one
>of
>the columns listed above and if the value does not match all the
>columns
>exactly the cell for that column/row should not be filled. When I try
>the
>method from that website, I do not see the supplemental columns being
>added. I am wondering if there is a better way to merge multiple .csv
>files. I hope this makes sense, but it is quite confusing even to me,
>so I
>am more than happy to clarify. I am attaching the files in question.
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Merging multiple .csv files into one dataframe

2021-06-09 Thread Bert Gunter
I really think you need to create a simple reprex to show us what you want
to do. In doing so, you may figure out how to get what you want. I suspect
you may also need to spend some more time learning R -- following rote
examples can be a fool's errand if you don't know the basics.

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 Wed, Jun 9, 2021 at 3:41 PM Esthi Erickson 
wrote:

> Hi,
>
> I am trying to merge columns from four different .csv files into one
> dataframe. I am trying to do something like this
> https://statisticsglobe.com/merge-csv-files-in-r . I am taking long format
> .csv files, 1 being the base file (testing-long.csv) which I change to wide
> format first and the three others being supplemental files that should add
> columns plight, plightLitter, Root Biomass, NO3Soil, NH4Soil and then add
> data to cells where the it matches any one of the values for columns,
> "Exp", "Year", "Field", "Plot", "NTrt", "NAdd", "NitrAdd", "NAtm.NAdd". So
> the values for the supplemental files need not match every single one of
> the columns listed above and if the value does not match all the columns
> exactly the cell for that column/row should not be filled. When I try the
> method from that website, I do not see the supplemental columns being
> added. I am wondering if there is a better way to merge multiple .csv
> files. I hope this makes sense, but it is quite confusing even to me, so I
> am more than happy to clarify. I am attaching the files in question.
> __
> 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] Need help to fix the max date filter problem in the date input

2021-06-09 Thread David Winsemius



On 6/9/21 5:06 AM, Biplab Nayak wrote:

Hi Greg,

Please find the objective of the code(bold) and code mentioned below. I was
trying to do to achieve the below objective but somehow it's not working.



The phrase "somehow not working" is not a useful description of an outcome.



1.Order assessment based on the latest due date so select input
automatically shows the order of assessment name.

2.Filter based on the one name or multiple names in the  select input



library(tidyverse)

#library(stringr)# attached with tidyverse

#library(readr)

library(shiny)

library(dplyr)



I'm pretty sure the tidyverse super-package includes most of the others 
with the exception of pkg:shiny (which does not appear to be needed anyway.)


Here's what my version of tidyverse loads:

Imports: broom (>= 0.5.2), cli (>= 1.1.0), crayon (>= 1.3.4), dbplyr (>= 
1.4.2), dplyr (>= 0.8.3), forcats (>= 0.4.0),
 ggplot2 (>= 3.2.1), haven (>= 2.2.0), hms (>= 0.5.2), httr 
(>= 1.4.1), jsonlite (>= 1.6), lubridate (>=
 1.7.4), magrittr (>= 1.5), modelr (>= 0.1.5), pillar (>= 
1.4.2), purrr (>= 0.3.3), readr (>= 1.3.1), readxl
 (>= 1.3.1), reprex (>= 0.3.0), rlang (>= 0.4.1), 
rstudioapi (>= 0.10), rvest (>= 0.3.5), stringr (>=

 1.4.0), tibble (>= 2.1.3), tidyr (>= 1.0.0), xml2 (>= 1.2.2)


ttclasses <- read_csv("~/tmp/ttclasses.csv")

We do not have your data.


#Filter data

ttclasses <-ttclasses %>%

filter(str_detect(assessment, "Assignment"))

  ttclasses <-ttclasses %>%  filter(str_detect(name, "Name"))
Without a result that summarizes the changes in the data composition at 
each step, we cannot make any guesses as to your problem

##Remove NA values.

ttclasses <-ttclasses %>% drop_na("score")



*## Sort  assessment based on max due_date*

  ttclasses  <- ttclasses [order( - due_date, assessment ),]



#Convert to factor

ttclasses$assessment <- factor(ttclasses$assessment)



# please see the formats in help("strptime")

ttclasses$due_date <-  as.Date(ttclasses$due_date, format = "%m/%d/%y")
Yes, do see ?strptime. That format assumes dates are in MM/DD/YY format, 
i.e slashes as separators and 2 digit years. Getting the date format 
wrong is a common way to create NA values. It is better not to overlay 
such efforts on top of the original column name. That way you can still 
make changes without redoing the entire data steps.


ttclasses$name <- factor(ttclasses$name)

Thanks & Regards
Biplab Nayak






On Wed, Jun 9, 2021 at 12:15 AM Greg Minshall  wrote:


Biplab,

i'm not sure how to help you here, but this list pretty much runs on
plain ASCII (or, these days, utf-8) e-mail.  for the most part, without
attachments.  so, simply-formatted text, including code, with some
mechanism in the code to initialize any data structures (data frames,
matrices, etc.) needed for the example.

some of this is described in the posting guide

https://www.r-project.org/posting-guide.html


formatting your e-mail in this way will likely increase your odds of a
helpful reply.

cheers, Greg


[[alternative HTML version deleted]]

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


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


Re: [R] Need help to fix the max date filter problem in the date input

2021-06-09 Thread Jeff Newmiller
You seem to need to educate yourself as to what "plain text" means, and to read 
the Posting Guide for this mailing list. Word documents are very definitely NOT 
plain text. Stop attempting to communicate via formatted text on this mailing 
list.

For security reasons this mailing list removes most attachments and formatting. 
Your emails sent to the list have such features (e.g Word documents and HTML 
formatting) stripped (removed). If you happen to send such emails directly to 
specific people they might have software that can allow them to view that 
information if they choose to risk opening attachments from a stranger (I will 
not), but for those of us seeing your emails on the list "what you send is not 
what we receive". Such emails are repeatedly violating the Posting Guidelines 
which will make responses much less likely and may increase the chance of a 
negative moderator reaction.

On June 8, 2021 8:47:52 PM PDT, Biplab Nayak  wrote:
>Hi Greg,
>
>Please find the R Code in the word file attached here. Its plain text
>format
>
>Thanks & Regards
>Biplab Nayak
>
>On Wed, Jun 9, 2021 at 12:15 AM Greg Minshall 
>wrote:
>
>> Biplab,
>>
>> i'm not sure how to help you here, but this list pretty much runs on
>> plain ASCII (or, these days, utf-8) e-mail.  for the most part,
>without
>> attachments.  so, simply-formatted text, including code, with some
>> mechanism in the code to initialize any data structures (data frames,
>> matrices, etc.) needed for the example.
>>
>> some of this is described in the posting guide
>> 
>> https://www.r-project.org/posting-guide.html
>> 
>>
>> formatting your e-mail in this way will likely increase your odds of
>a
>> helpful reply.
>>
>> cheers, Greg
>>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

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


[R] Merging multiple .csv files into one dataframe

2021-06-09 Thread Esthi Erickson
Hi,

I am trying to merge columns from four different .csv files into one
dataframe. I am trying to do something like this
https://statisticsglobe.com/merge-csv-files-in-r . I am taking long format
.csv files, 1 being the base file (testing-long.csv) which I change to wide
format first and the three others being supplemental files that should add
columns plight, plightLitter, Root Biomass, NO3Soil, NH4Soil and then add
data to cells where the it matches any one of the values for columns,
"Exp", "Year", "Field", "Plot", "NTrt", "NAdd", "NitrAdd", "NAtm.NAdd". So
the values for the supplemental files need not match every single one of
the columns listed above and if the value does not match all the columns
exactly the cell for that column/row should not be filled. When I try the
method from that website, I do not see the supplemental columns being
added. I am wondering if there is a better way to merge multiple .csv
files. I hope this makes sense, but it is quite confusing even to me, so I
am more than happy to clarify. I am attaching the files in question.
__
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] aggregation of irregular interval time-series

2021-06-09 Thread Bert Gunter
I have *not* followed this in any detail, but this line seems wrong:

arvaia_catture_order <- arvaia_catture[order(arvaia_catture$tempo)]

Perhaps it should be:
arvaia_catture_order <- arvaia_catture[order(arvaia_catture$tempo), ] ##
note the comma!

If I am mistaken, just ignore and move on.

Cheers,
Bert

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 Wed, Jun 9, 2021 at 2:41 PM Rui Barradas  wrote:

> Hello,
>
> I'm not getting your simple sum:
>
>
> arvaia_catture_order[, week := as.integer(format(tempo, "%U"))]
> aggregate(catture ~ week, arvaia_catture_order, sum)
> #  week catture
> #1   19  15
> #2   20   5
> #3   21  78
> #4   22 120
>
>
> Can you explain your result better?
>
> Hope this helps,
>
> Rui Barradas
>
> Às 18:57 de 09/06/21, Enrico Gabrielli escreveu:
> > Hello
> > I just registered on the list.
> > I am an agricultural technician and I am collaborating on a research
> > project on agroforestry and Brown Marmorated Stink Bug (Halyomorpha
> > halys, abbreviated BMSB).
> >
> > Through kobotoolbox we are collecting data of catches in traps on
> > farms. Farms register inconsistently.
> > I am trying to use packages for irregular time series.
> >
> > Here an exemple
> > the data:
> > # variable monitoring time as register an import from kobotoolbox
> > tempo <- as.POSIXct(c("2021-05-29 17:00:00 UTC","2021-06-05 10:52:00
> > UTC","2021-06-01 17:00:00 UTC","2021-05-16 08:34:00 UTC","2021-06-05
> > 17:00:00 UTC","2021-05-29 05:30:00 UTC","2021-05-23 06:30:00
> > UTC","2021-05-20 13:00:00 UTC","2021-05-15 12:09:00 UTC"))
> > # variable capture of BMSB
> > catture <- c(25,92,23,2,5,30,23,3,15)
> > # resulting table
> > library(data.table)
> > arvaia_catture <- data.table(tempo,catture)
> > # order by time
> > arvaia_catture_order <- arvaia_catture[order(arvaia_catture$tempo)]
> >
> > the catches refer to an interval, which goes from the previous
> > monitoring up to the one recorded on the date
> > our aim is to calculate the weekly catch
> > also when a farmer, for example, enters the data on Thursday and
> > Tuesday
> > of the following week, on Tuesday in the trap he will find individuals
> > who were also captured on Friday and Saturday, which formally are to be
> > considered in the previous week.
> >
> > With the data of the example
> > the results (with a spreadsheet) is
> > two possibile solution
> > weeksimple SUM week right SUM week
> > 19  17  19,44027778
> > 20  26  52,9139
> > 21  55  46,4375integrand_2 <- function(x) {0.62 * (1/x)}
>
> integrate(integrand, lower = , upper = 5)
>
> > 22  120 99,2083
> > The right SUM week is right!
> >
> > I have made several attempts
> > with lubridate, padr, xts
> > but the last one seems interesting to me
> > with DTSg
> > doing
> > x_periodic <- alter(x,na.status = 'explicit',from="2021-05-15
> > 12:00:00",by="min")
> > colapply(x_periodic, fun = interpolateLinear)
> > I managed to create a vector with all interpolated hours
> > but with DTSg I still can't aggregate by week
> >
> > Has anyone on the list ever faced such a problem?
> >
> > Thank you
> >
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] aggregation of irregular interval time-series

2021-06-09 Thread Rui Barradas

Hello,

I'm not getting your simple sum:


arvaia_catture_order[, week := as.integer(format(tempo, "%U"))]
aggregate(catture ~ week, arvaia_catture_order, sum)
#  week catture
#1   19  15
#2   20   5
#3   21  78
#4   22 120


Can you explain your result better?

Hope this helps,

Rui Barradas

Às 18:57 de 09/06/21, Enrico Gabrielli escreveu:

Hello
I just registered on the list.
I am an agricultural technician and I am collaborating on a research
project on agroforestry and Brown Marmorated Stink Bug (Halyomorpha
halys, abbreviated BMSB).

Through kobotoolbox we are collecting data of catches in traps on
farms. Farms register inconsistently.
I am trying to use packages for irregular time series.

Here an exemple
the data:
# variable monitoring time as register an import from kobotoolbox
tempo <- as.POSIXct(c("2021-05-29 17:00:00 UTC","2021-06-05 10:52:00
UTC","2021-06-01 17:00:00 UTC","2021-05-16 08:34:00 UTC","2021-06-05
17:00:00 UTC","2021-05-29 05:30:00 UTC","2021-05-23 06:30:00
UTC","2021-05-20 13:00:00 UTC","2021-05-15 12:09:00 UTC"))
# variable capture of BMSB
catture <- c(25,92,23,2,5,30,23,3,15)
# resulting table
library(data.table)
arvaia_catture <- data.table(tempo,catture)
# order by time
arvaia_catture_order <- arvaia_catture[order(arvaia_catture$tempo)]

the catches refer to an interval, which goes from the previous
monitoring up to the one recorded on the date
our aim is to calculate the weekly catch
also when a farmer, for example, enters the data on Thursday and
Tuesday
of the following week, on Tuesday in the trap he will find individuals
who were also captured on Friday and Saturday, which formally are to be
considered in the previous week.

With the data of the example
the results (with a spreadsheet) is
two possibile solution
weeksimple SUM week right SUM week
19  17  19,44027778
20  26  52,9139
21  55  46,4375integrand_2 <- function(x) {0.62 * (1/x)}


integrate(integrand, lower = , upper = 5)


22  120 99,2083
The right SUM week is right!

I have made several attempts
with lubridate, padr, xts
but the last one seems interesting to me
with DTSg
doing
x_periodic <- alter(x,na.status = 'explicit',from="2021-05-15
12:00:00",by="min")
colapply(x_periodic, fun = interpolateLinear)
I managed to create a vector with all interpolated hours
but with DTSg I still can't aggregate by week

Has anyone on the list ever faced such a problem?

Thank you



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


Re: [R] Read fst files

2021-06-09 Thread Jeff Reichman
Bill

 

So I understand that’s just unzipping the file to a temporary dir which then 
would allow read_fst to access the file directly .

 

Jeff

 

From: Bill Dunlap  
Sent: Wednesday, June 9, 2021 1:43 PM
To: reichm...@sbcglobal.net
Cc: Jan van der Laan ; r-help@r-project.org
Subject: Re: [R] Read fst files

 

Try using unzip(zipfile, files="desiredFile", exdir=tf<-tempfile()), not 
unz(zipfile, "desiredFile"), to copy the desired file from the zip file to a 
temporary location and use read_fst(tf) to read the desired file.

 

-Bill

 

On Wed, Jun 9, 2021 at 11:27 AM Jeff Reichman mailto:reichm...@sbcglobal.net> > wrote:

Jan

Makes sense. Its just that I often receive  large zip files that contain a 
variety of file types.

Jef

-Original Message-
From: R-help mailto:r-help-boun...@r-project.org> > On Behalf Of Jan van der Laan
Sent: Wednesday, June 9, 2021 12:56 PM
To: r-help@r-project.org  
Subject: Re: [R] Read fst files



read_fst is from the package fst. The fileformat fst uses is a binary 
format designed to be fast readable. It is a column  oriented format and 
compressed. So, to be able to work fst needs access to the file itself 
and wont accept a file connection as functions like read.table an 
variants accept.

Also, because it is a binary compressed format using a compression 
method that is fast to read, compressing also to zip seems to defeat the 
purpose of fst.

HTH,
Jan


On 09-06-2021 15:28, Duncan Murdoch wrote:
> On 09/06/2021 9:12 a.m., Jeff Reichman wrote:
>> Duncan
>>
>> Yea that will work. It appears to be related to setting my working 
>> dir, for what ever reason neither seem to work
>> (1) knitr::opts_knit$set(root.dir 
>> ="~/My_Reference_Library/Regression") # from R Notebook or
>> (2) 
>> setwd("C:/Users/reichmaj/Documents/My_Reference_Library/Regression") # 
>> from R chunk
>>
>> So it appears I can either (as you suggested) use two steps or combine 
>> but I need to enter the full path. Why other file types don't seem to 
>> need the full path ?
> 
> You need to read the documentation for read_fst() to find what it needs. 
>   If it doesn't explain this, then you should report the issue to its 
> author.
> 
>>
>> myObject <- 
>> read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library/Regression/Datasest.zip",
>>  
>> filename = "myFile.fst"))
>>
>> Thank you. I guess just one of those R things
> 
> No, it's a read_fst() thing.
> 
> Duncan Murdoch
> 
> __
> 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.


[[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] aggregation of irregular interval time-series

2021-06-09 Thread Enrico Gabrielli
Hello
I just registered on the list.
I am an agricultural technician and I am collaborating on a research
project on agroforestry and Brown Marmorated Stink Bug (Halyomorpha
halys, abbreviated BMSB).

Through kobotoolbox we are collecting data of catches in traps on
farms. Farms register inconsistently.
I am trying to use packages for irregular time series.

Here an exemple
the data:
# variable monitoring time as register an import from kobotoolbox
tempo <- as.POSIXct(c("2021-05-29 17:00:00 UTC","2021-06-05 10:52:00
UTC","2021-06-01 17:00:00 UTC","2021-05-16 08:34:00 UTC","2021-06-05
17:00:00 UTC","2021-05-29 05:30:00 UTC","2021-05-23 06:30:00
UTC","2021-05-20 13:00:00 UTC","2021-05-15 12:09:00 UTC"))
# variable capture of BMSB
catture <- c(25,92,23,2,5,30,23,3,15)
# resulting table
library(data.table)
arvaia_catture <- data.table(tempo,catture)
# order by time
arvaia_catture_order <- arvaia_catture[order(arvaia_catture$tempo)]

the catches refer to an interval, which goes from the previous
monitoring up to the one recorded on the date
our aim is to calculate the weekly catch
also when a farmer, for example, enters the data on Thursday and
Tuesday
of the following week, on Tuesday in the trap he will find individuals
who were also captured on Friday and Saturday, which formally are to be
considered in the previous week.

With the data of the example
the results (with a spreadsheet) is
two possibile solution
weeksimple SUM week right SUM week
19  17  19,44027778
20  26  52,9139
21  55  46,4375
22  120 99,2083
The right SUM week is right!

I have made several attempts
with lubridate, padr, xts
but the last one seems interesting to me
with DTSg
doing
x_periodic <- alter(x,na.status = 'explicit',from="2021-05-15
12:00:00",by="min")
colapply(x_periodic, fun = interpolateLinear)
I managed to create a vector with all interpolated hours
but with DTSg I still can't aggregate by week

Has anyone on the list ever faced such a problem?

Thank you

-- 
Perito agrario Enrico Gabrielli
Tessera n. 633 Collegio Periti agrari prov. Di Modena
Biblioteca agricoltura: https://www.zotero.org/groups/aplomb/
https://it.linkedin.com/pub/enrico-gabrielli/9a/186/159
https://enricogabrielli76.wordpress.com/
https://www.inaturalist.org/observations/bonushenricus
skype: enricogabrielli (enricogabrielli76.per...@gmail.com)

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


Re: [R] Need help to fix the max date filter problem in the date input

2021-06-09 Thread Biplab Nayak
Hi Greg,

Please find the objective of the code(bold) and code mentioned below. I was
trying to do to achieve the below objective but somehow it's not working.

1.Order assessment based on the latest due date so select input
automatically shows the order of assessment name.

2.Filter based on the one name or multiple names in the  select input



library(tidyverse)

#library(stringr)# attached with tidyverse

#library(readr)

library(shiny)

library(dplyr)



ttclasses <- read_csv("~/tmp/ttclasses.csv")



#Filter data

ttclasses <-ttclasses %>%

   filter(str_detect(assessment, "Assignment"))

 ttclasses <-ttclasses %>%  filter(str_detect(name, "Name"))



##Remove NA values.

ttclasses <-ttclasses %>% drop_na("score")



*## Sort  assessment based on max due_date*

 ttclasses  <- ttclasses [order( - due_date, assessment ),]



#Convert to factor

ttclasses$assessment <- factor(ttclasses$assessment)



# please see the formats in help("strptime")

ttclasses$due_date <-  as.Date(ttclasses$due_date, format = "%m/%d/%y")

ttclasses$name <- factor(ttclasses$name)

Thanks & Regards
Biplab Nayak

On Wed, Jun 9, 2021 at 12:15 AM Greg Minshall  wrote:

> Biplab,
>
> i'm not sure how to help you here, but this list pretty much runs on
> plain ASCII (or, these days, utf-8) e-mail.  for the most part, without
> attachments.  so, simply-formatted text, including code, with some
> mechanism in the code to initialize any data structures (data frames,
> matrices, etc.) needed for the example.
>
> some of this is described in the posting guide
> 
> https://www.r-project.org/posting-guide.html
> 
>
> formatting your e-mail in this way will likely increase your odds of a
> helpful reply.
>
> cheers, Greg
>

[[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] Need help to fix the max date filter problem in the date input

2021-06-09 Thread Biplab Nayak
Hi Greg,

Please find the objective of the code(bold) and code mentioned below. I was
trying to do to achieve the below objective but somehow it's not working.

1.Order assessment based on the latest due date so select input automatically
shows the order of assessment name.

2.Filter based on the one name or multiple names in the  select input



library(tidyverse)

#library(stringr)# attached with tidyverse

#library(readr)

library(shiny)

library(dplyr)



ttclasses <- read_csv("~/tmp/ttclasses.csv")



#Filter data

ttclasses <-ttclasses %>%

   filter(str_detect(assessment, "Assignment"))

 *ttclasses <-ttclasses %>%  filter(str_detect(name, "Name"))*



##Remove NA values.

ttclasses <-ttclasses %>% drop_na("score")



*## Sort  assessment based on max due_date*

 *ttclasses  <- ttclasses [order( - due_date, assessment ),]*



#Convert to factor

ttclasses$assessment <- factor(ttclasses$assessment)



# please see the formats in help("strptime")

ttclasses$due_date <-  as.Date(ttclasses$due_date, format = "%m/%d/%y")

*ttclasses$name <- factor(ttclasses$name)*





# Define UI 

ui <- fluidPage(



   # App title 

   titlePanel("Assessment Dashboard"),



   # Sidebar layout with input and output definitions 

   sidebarLayout(



 # Sidebar panel for inputs 

 sidebarPanel(



   # Input: Selector for variable to plot the grades for the selected

   # assignment 



 selectInput("assessment", "Assessment:",

 c("Assignment 1" = "Assignment 1",

   "Assignment 2" = "Assignment 2",

   "Assignment 3" = "Assignment 3",

   "Assignment 4" = "Assignment 4",

   "Assignment 5" = "Assignment 5")),

   selectInput("name", "Name:",

   ttclasses[,2]),



   dateRangeInput("due_date",

  "Due-Date:",start = max(ttclasses$due_date) ,

  separator = " - ")

 ),



 # Main panel for displaying outputs 

 mainPanel(



   # Output: Plot of the requested variable against grade 

   plotOutput("gradePlot")



 )

   )

)



# Define server logic to plot  

server <- function(input, output) {

   output$gradePlot <- renderPlot({

 grade_ad = input$assessment

 boxplot(ttclasses$score[ttclasses$assessment==grade_ad],

 frame.plot=FALSE, horizontal=TRUE, col="magenta",

main=grade_ad)

 ttclasses <-ttclasses %>%

   filter(ttclasses$due_date >= input$due_date[1] & ttclasses$due_date

  <= input$due_date[2])

   })

}



# Create Shiny app 

shinyApp(ui, server)


Thanks & Regards
Biplab Nayak

On Wed, Jun 9, 2021 at 12:15 AM Greg Minshall  wrote:

> Biplab,
>
> i'm not sure how to help you here, but this list pretty much runs on
> plain ASCII (or, these days, utf-8) e-mail.  for the most part, without
> attachments.  so, simply-formatted text, including code, with some
> mechanism in the code to initialize any data structures (data frames,
> matrices, etc.) needed for the example.
>
> some of this is described in the posting guide
> 
> https://www.r-project.org/posting-guide.html
> 
>
> formatting your e-mail in this way will likely increase your odds of a
> helpful reply.
>
> cheers, Greg
>

[[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] [R-pkgs] New CRAN Package: NGLVieweR - Interactive 3D Visualization of Molecular Structures

2021-06-09 Thread Niels van der Velden
 Dear all,

I am happy to announce that {NGLVieweR} v1.3.1 is now on CRAN.

{NGLVieweR} provides an 'htmlwidgets' https://www.htmlwidgets.org/
interface to 'NGL.js' http://nglviewer.org/ngl/api/.
{NGLVieweR} can be used to visualize and interact with protein databank
(PDB) and structural files in R and Shiny applications.
It includes a set of API functions to manipulate the viewer after creation
in Shiny.

CRAN: https://cran.r-project.org/web/packages/NGLVieweR/index.html
Documentation: https://nvelden.github.io/NGLVieweR/
Graphical UI for the {NGLVieweR} package:
https://niels-van-der-velden.shinyapps.io/shinyNGLVieweR/
Rationale on the development of the package:
https://community.rstudio.com/t/three-dimensional-3d-interactive-visualization-of-protein-structures-shiny-contest-submission/104697

I hope you find it helpful.

Please feel free to reach out with feedback or questions.

Thanks,

Niels van der Velden

[[alternative HTML version deleted]]

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
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] Need help to fix the max date filter problem in the date input

2021-06-09 Thread Biplab Nayak
Hi Greg,

Please find the R Code in the word file attached here. Its plain text format

Thanks & Regards
Biplab Nayak

On Wed, Jun 9, 2021 at 12:15 AM Greg Minshall  wrote:

> Biplab,
>
> i'm not sure how to help you here, but this list pretty much runs on
> plain ASCII (or, these days, utf-8) e-mail.  for the most part, without
> attachments.  so, simply-formatted text, including code, with some
> mechanism in the code to initialize any data structures (data frames,
> matrices, etc.) needed for the example.
>
> some of this is described in the posting guide
> 
> https://www.r-project.org/posting-guide.html
> 
>
> formatting your e-mail in this way will likely increase your odds of a
> helpful reply.
>
> cheers, Greg
>
__
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] Read fst files

2021-06-09 Thread Duncan Murdoch

On 09/06/2021 1:55 p.m., Jan van der Laan wrote:



read_fst is from the package fst. The fileformat fst uses is a binary
format designed to be fast readable. It is a column  oriented format and
compressed. So, to be able to work fst needs access to the file itself
and wont accept a file connection as functions like read.table an
variants accept.


Thanks for the info.  I think it is possible to handle such a file in a 
binary connection, but doing that in C/C++ would be kind of horrible, so 
I can understand your choice.


Duncan Murdoch



Also, because it is a binary compressed format using a compression
method that is fast to read, compressing also to zip seems to defeat the
purpose of fst.

HTH,
Jan


On 09-06-2021 15:28, Duncan Murdoch wrote:

On 09/06/2021 9:12 a.m., Jeff Reichman wrote:

Duncan

Yea that will work. It appears to be related to setting my working
dir, for what ever reason neither seem to work
(1) knitr::opts_knit$set(root.dir
="~/My_Reference_Library/Regression") # from R Notebook or
(2)
setwd("C:/Users/reichmaj/Documents/My_Reference_Library/Regression") #
from R chunk

So it appears I can either (as you suggested) use two steps or combine
but I need to enter the full path. Why other file types don't seem to
need the full path ?


You need to read the documentation for read_fst() to find what it needs.
   If it doesn't explain this, then you should report the issue to its
author.



myObject <-
read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library/Regression/Datasest.zip",
filename = "myFile.fst"))

Thank you. I guess just one of those R things


No, it's a read_fst() thing.

Duncan Murdoch

__
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] Read fst files

2021-06-09 Thread Bill Dunlap
Try using unzip(zipfile, files="desiredFile", exdir=tf<-tempfile()), not
unz(zipfile, "desiredFile"), to copy the desired file from the zip file to
a temporary location and use read_fst(tf) to read the desired file.

-Bill

On Wed, Jun 9, 2021 at 11:27 AM Jeff Reichman 
wrote:

> Jan
>
> Makes sense. Its just that I often receive  large zip files that contain a
> variety of file types.
>
> Jef
>
> -Original Message-
> From: R-help  On Behalf Of Jan van der Laan
> Sent: Wednesday, June 9, 2021 12:56 PM
> To: r-help@r-project.org
> Subject: Re: [R] Read fst files
>
>
>
> read_fst is from the package fst. The fileformat fst uses is a binary
> format designed to be fast readable. It is a column  oriented format and
> compressed. So, to be able to work fst needs access to the file itself
> and wont accept a file connection as functions like read.table an
> variants accept.
>
> Also, because it is a binary compressed format using a compression
> method that is fast to read, compressing also to zip seems to defeat the
> purpose of fst.
>
> HTH,
> Jan
>
>
> On 09-06-2021 15:28, Duncan Murdoch wrote:
> > On 09/06/2021 9:12 a.m., Jeff Reichman wrote:
> >> Duncan
> >>
> >> Yea that will work. It appears to be related to setting my working
> >> dir, for what ever reason neither seem to work
> >> (1) knitr::opts_knit$set(root.dir
> >> ="~/My_Reference_Library/Regression") # from R Notebook or
> >> (2)
> >> setwd("C:/Users/reichmaj/Documents/My_Reference_Library/Regression") #
> >> from R chunk
> >>
> >> So it appears I can either (as you suggested) use two steps or combine
> >> but I need to enter the full path. Why other file types don't seem to
> >> need the full path ?
> >
> > You need to read the documentation for read_fst() to find what it needs.
> >   If it doesn't explain this, then you should report the issue to its
> > author.
> >
> >>
> >> myObject <-
> >>
> read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library/Regression/Datasest.zip",
>
> >> filename = "myFile.fst"))
> >>
> >> Thank you. I guess just one of those R things
> >
> > No, it's a read_fst() thing.
> >
> > Duncan Murdoch
> >
> > __
> > 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.
>

[[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] Read fst files

2021-06-09 Thread Jeff Newmiller
... but if you are receiving multiple-file zips then you should not be using 
unz() the way you are in your original post.

I have to agree with other responders suggesting that you handle unzipping fst 
zips manually rather than as part of an R one-liner.

On June 9, 2021 11:26:34 AM PDT, Jeff Reichman  wrote:
>Jan
>
>Makes sense. Its just that I often receive  large zip files that
>contain a variety of file types.
>
>Jef
>
>-Original Message-
>From: R-help  On Behalf Of Jan van der
>Laan
>Sent: Wednesday, June 9, 2021 12:56 PM
>To: r-help@r-project.org
>Subject: Re: [R] Read fst files
>
>
>
>read_fst is from the package fst. The fileformat fst uses is a binary 
>format designed to be fast readable. It is a column  oriented format
>and 
>compressed. So, to be able to work fst needs access to the file itself 
>and wont accept a file connection as functions like read.table an 
>variants accept.
>
>Also, because it is a binary compressed format using a compression 
>method that is fast to read, compressing also to zip seems to defeat
>the 
>purpose of fst.
>
>HTH,
>Jan
>
>
>On 09-06-2021 15:28, Duncan Murdoch wrote:
>> On 09/06/2021 9:12 a.m., Jeff Reichman wrote:
>>> Duncan
>>>
>>> Yea that will work. It appears to be related to setting my working 
>>> dir, for what ever reason neither seem to work
>>> (1) knitr::opts_knit$set(root.dir 
>>> ="~/My_Reference_Library/Regression") # from R Notebook or
>>> (2) 
>>> setwd("C:/Users/reichmaj/Documents/My_Reference_Library/Regression")
># 
>>> from R chunk
>>>
>>> So it appears I can either (as you suggested) use two steps or
>combine 
>>> but I need to enter the full path. Why other file types don't seem
>to 
>>> need the full path ?
>> 
>> You need to read the documentation for read_fst() to find what it
>needs. 
>>   If it doesn't explain this, then you should report the issue to its
>
>> author.
>> 
>>>
>>> myObject <- 
>>>
>read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library/Regression/Datasest.zip",
>
>>> filename = "myFile.fst"))
>>>
>>> Thank you. I guess just one of those R things
>> 
>> No, it's a read_fst() thing.
>> 
>> Duncan Murdoch
>> 
>> __
>> 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.

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

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


Re: [R] Read fst files

2021-06-09 Thread Jeff Reichman
Jan

Makes sense. Its just that I often receive  large zip files that contain a 
variety of file types.

Jef

-Original Message-
From: R-help  On Behalf Of Jan van der Laan
Sent: Wednesday, June 9, 2021 12:56 PM
To: r-help@r-project.org
Subject: Re: [R] Read fst files



read_fst is from the package fst. The fileformat fst uses is a binary 
format designed to be fast readable. It is a column  oriented format and 
compressed. So, to be able to work fst needs access to the file itself 
and wont accept a file connection as functions like read.table an 
variants accept.

Also, because it is a binary compressed format using a compression 
method that is fast to read, compressing also to zip seems to defeat the 
purpose of fst.

HTH,
Jan


On 09-06-2021 15:28, Duncan Murdoch wrote:
> On 09/06/2021 9:12 a.m., Jeff Reichman wrote:
>> Duncan
>>
>> Yea that will work. It appears to be related to setting my working 
>> dir, for what ever reason neither seem to work
>> (1) knitr::opts_knit$set(root.dir 
>> ="~/My_Reference_Library/Regression") # from R Notebook or
>> (2) 
>> setwd("C:/Users/reichmaj/Documents/My_Reference_Library/Regression") # 
>> from R chunk
>>
>> So it appears I can either (as you suggested) use two steps or combine 
>> but I need to enter the full path. Why other file types don't seem to 
>> need the full path ?
> 
> You need to read the documentation for read_fst() to find what it needs. 
>   If it doesn't explain this, then you should report the issue to its 
> author.
> 
>>
>> myObject <- 
>> read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library/Regression/Datasest.zip",
>>  
>> filename = "myFile.fst"))
>>
>> Thank you. I guess just one of those R things
> 
> No, it's a read_fst() thing.
> 
> Duncan Murdoch
> 
> __
> 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] Read fst files

2021-06-09 Thread Jan van der Laan




read_fst is from the package fst. The fileformat fst uses is a binary 
format designed to be fast readable. It is a column  oriented format and 
compressed. So, to be able to work fst needs access to the file itself 
and wont accept a file connection as functions like read.table an 
variants accept.


Also, because it is a binary compressed format using a compression 
method that is fast to read, compressing also to zip seems to defeat the 
purpose of fst.


HTH,
Jan


On 09-06-2021 15:28, Duncan Murdoch wrote:

On 09/06/2021 9:12 a.m., Jeff Reichman wrote:

Duncan

Yea that will work. It appears to be related to setting my working 
dir, for what ever reason neither seem to work
(1) knitr::opts_knit$set(root.dir 
="~/My_Reference_Library/Regression") # from R Notebook or
(2) 
setwd("C:/Users/reichmaj/Documents/My_Reference_Library/Regression") # 
from R chunk


So it appears I can either (as you suggested) use two steps or combine 
but I need to enter the full path. Why other file types don't seem to 
need the full path ?


You need to read the documentation for read_fst() to find what it needs. 
  If it doesn't explain this, then you should report the issue to its 
author.




myObject <- 
read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library/Regression/Datasest.zip", 
filename = "myFile.fst"))


Thank you. I guess just one of those R things


No, it's a read_fst() thing.

Duncan Murdoch

__
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] Beginner problem - using mod function to print odd numbers

2021-06-09 Thread Bill Dunlap
Martin wrote
  Use
  num[num %% 2 == 1]
  instead of much slower and ...@#^$
  num[ifelse(num %% 2 == 1, TRUE, FALSE)]

Read the '[' as 'such that' when the subscript is logical
(=="Boolean"==TRUE/FALSE-values).

[The original post had a typo/thinko, num<-num+i instead of num<-num+1,
which was simply an error, not a matter of style.  R's vectorization makes
it easy to avoid such errors.]

-Bill

On Wed, Jun 9, 2021 at 2:56 AM Martin Maechler 
wrote:

> > David Carlsonon Sun, 6 Jun 2021 15:21:34 -0400 writes:
>
> > There is really no need for a loop:
> > num <- 1:100
> > num[ifelse(num %% 2 == 1, TRUE, FALSE)]
>
> > [1]  1  3  5  7  9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45
> 47 49
> > [26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93
> 95 97 99
>
> Well, and the above "works" but is really another proof of my
> year-long claim that people use  ifelse(.)  *MUCH MUCH* too often,
> and should really learn to use alternatives, in this case,
> "R 101" (*long* before fooverse):
>
> Use
>
> num[num %% 2 == 1]
>
> instead of much slower and ...@#^$
>
> num[ifelse(num %% 2 == 1, TRUE, FALSE)]
>
> Martin Maechler
> ETH Zurich
>
> > On Sat, Jun 5, 2021 at 2:05 PM William Michels via R-help
> >  wrote:
> >>
> >> > i <- 1L; span <- 1:100; result <- NA;
> >> > for (i in span){
> >> + ifelse(i %% 2 != 0, result[i] <- TRUE, result[i] <- FALSE)
> >> + }
> >> > span[result]
> >> [1]  1  3  5  7  9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41
> 43
>
>  []
>
> __
> 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] Read fst files

2021-06-09 Thread Duncan Murdoch

On 09/06/2021 9:12 a.m., Jeff Reichman wrote:

Duncan

Yea that will work. It appears to be related to setting my working dir, for 
what ever reason neither seem to work
(1) knitr::opts_knit$set(root.dir ="~/My_Reference_Library/Regression") # from 
R Notebook or
(2) setwd("C:/Users/reichmaj/Documents/My_Reference_Library/Regression") # from 
R chunk

So it appears I can either (as you suggested) use two steps or combine but I 
need to enter the full path. Why other file types don't seem to need the full 
path ?


You need to read the documentation for read_fst() to find what it needs. 
 If it doesn't explain this, then you should report the issue to its 
author.




myObject <- 
read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library/Regression/Datasest.zip", 
filename = "myFile.fst"))

Thank you. I guess just one of those R things


No, it's a read_fst() thing.

Duncan Murdoch

__
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] Read fst files

2021-06-09 Thread Jeff Reichman
Duncan

Yea that will work. It appears to be related to setting my working dir, for 
what ever reason neither seem to work
(1) knitr::opts_knit$set(root.dir ="~/My_Reference_Library/Regression") # from 
R Notebook or
(2) setwd("C:/Users/reichmaj/Documents/My_Reference_Library/Regression") # from 
R chunk

So it appears I can either (as you suggested) use two steps or combine but I 
need to enter the full path. Why other file types don't seem to need the full 
path ?

myObject <- 
read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library/Regression/Datasest.zip",
 filename = "myFile.fst"))

Thank you. I guess just one of those R things

Jeff



-Original Message-
From: Duncan Murdoch  
Sent: Wednesday, June 9, 2021 7:27 AM
To: reichm...@sbcglobal.net; 'Eric Berger' 
Cc: 'R mailing list' 
Subject: Re: [R] Read fst files

It looks as though read_fst wants a filename, not a connection.

You should do it in two steps:

  unzip("Dataset.zip", files = "myFile.fst")
  myObject <- read_fst("myFile.fst")

This is obviously untested; you didn't even say what package read_fst() comes 
from.

Duncan Murdoch

On 09/06/2021 8:18 a.m., Jeff Reichman wrote:
> Eric
> 
>   
> 
> Typo on my point.
> 
>   
> 
> setwd("C:/Users/reichmaj/Documents/My_Reference_Library /Regression")
> 
> myObject <- read_fst(unz("Dataset.zip", filename = "myFile.fst")) # 
> read fst file
> 
>   
> 
> Error in path.expand(path) : invalid 'path' argument
> 
>   
> 
> So then I tried
> 
>   
> 
> myObject <- 
> read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library 
> /Regression /Dataset.zip", filename = "myFile.fst"))
> 
>   
> 
> Error in path.expand(path) : invalid 'path' argument
> 
>   
> 
> Error in the path??
> 
>   
> 
> Because this works just fine
> 
>   
> 
> myObject <- 
> read.csv(unz("C:/Users/reichmaj/Documents/My_Reference_Library 
> /Regression /Dataset.zip", filename = "myFile.csv"))
> 
>   
> 
> My only though is I can’t use the two function s together when dealing with 
> fst files ??
> 
>   
> 
> From: Eric Berger 
> Sent: Wednesday, June 9, 2021 3:50 AM
> To: reichm...@sbcglobal.net
> Cc: R mailing list 
> Subject: Re: [R] Read fst files
> 
>   
> 
> You are missing the second closing parenthesis. This is what the error 
> message is telling you.
> 
>   
> 
>   
> 
> On Wed, Jun 9, 2021 at 2:44 AM Jeff Reichman   > wrote:
> 
> R-Help Forum
> 
> 
> 
> Anyone know why the following line of code would error out:  myObject 
> <- read_fst(unz("Dataset.zip", filename = "filename.fst"))
> 
> 
> 
> Error: Incomplete expression: filename <- read_fst(unz("Dataset.zip", 
> filename = "filename.fst")
> 
> 
> 
> I often use similar code with *.csv files in a zipped folder. For example:
> myObject <- read.csv(unz("Dataset.zip", filename = "filename.csv")), 
> which works just fine.
> 
> 
> 
> Jeff Reichman
> 
> 
> 
> 
>  [[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-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] Read fst files

2021-06-09 Thread Duncan Murdoch

It looks as though read_fst wants a filename, not a connection.

You should do it in two steps:

 unzip("Dataset.zip", files = "myFile.fst")
 myObject <- read_fst("myFile.fst")

This is obviously untested; you didn't even say what package read_fst() 
comes from.


Duncan Murdoch

On 09/06/2021 8:18 a.m., Jeff Reichman wrote:

Eric

  


Typo on my point.

  


setwd("C:/Users/reichmaj/Documents/My_Reference_Library /Regression")

myObject <- read_fst(unz("Dataset.zip", filename = "myFile.fst")) # read fst 
file

  


Error in path.expand(path) : invalid 'path' argument

  


So then I tried

  


myObject <- read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library /Regression 
/Dataset.zip", filename = "myFile.fst"))

  


Error in path.expand(path) : invalid 'path' argument

  


Error in the path??

  


Because this works just fine

  


myObject <- read.csv(unz("C:/Users/reichmaj/Documents/My_Reference_Library /Regression 
/Dataset.zip", filename = "myFile.csv"))

  


My only though is I can’t use the two function s together when dealing with fst 
files ??

  


From: Eric Berger 
Sent: Wednesday, June 9, 2021 3:50 AM
To: reichm...@sbcglobal.net
Cc: R mailing list 
Subject: Re: [R] Read fst files

  


You are missing the second closing parenthesis. This is what the error message 
is telling you.

  

  


On Wed, Jun 9, 2021 at 2:44 AM Jeff Reichman mailto:reichm...@sbcglobal.net> > wrote:

R-Help Forum



Anyone know why the following line of code would error out:  myObject <-
read_fst(unz("Dataset.zip", filename = "filename.fst"))



Error: Incomplete expression: filename <- read_fst(unz("Dataset.zip",
filename = "filename.fst")



I often use similar code with *.csv files in a zipped folder. For example:
myObject <- read.csv(unz("Dataset.zip", filename = "filename.csv")), which
works just fine.



Jeff Reichman




 [[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-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] Read fst files

2021-06-09 Thread Eric Berger
Even if ultimately you want to use the functions together, for debugging
the problem you should split them into two, as in

a <- unz("C:/Users/reichmaj/Documents/My_Reference_Library /Regression
/Dataset.zip", filename = "myFile.fst")
See if that works, and examine 'a'.

And once that is working

read_fst(a)

to see what that does.

Let us know.


On Wed, Jun 9, 2021 at 3:18 PM Jeff Reichman 
wrote:

> Eric
>
>
>
> Typo on my point.
>
>
>
> setwd("C:/Users/reichmaj/Documents/My_Reference_Library /Regression")
>
> myObject <- read_fst(unz("Dataset.zip", filename = "myFile.fst")) # read
> fst file
>
>
>
> Error in path.expand(path) : invalid 'path' argument
>
>
>
> So then I tried
>
>
>
> myObject <- read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library
> /Regression /Dataset.zip", filename = "myFile.fst"))
>
>
>
> Error in path.expand(path) : invalid 'path' argument
>
>
>
> Error in the path??
>
>
>
> Because this works just fine
>
>
>
> myObject <- read.csv(unz("C:/Users/reichmaj/Documents/My_Reference_Library
> /Regression /Dataset.zip", filename = "myFile.csv"))
>
>
>
> My only though is I can’t use the two function s together when dealing
> with fst files ??
>
>
>
> *From:* Eric Berger 
> *Sent:* Wednesday, June 9, 2021 3:50 AM
> *To:* reichm...@sbcglobal.net
> *Cc:* R mailing list 
> *Subject:* Re: [R] Read fst files
>
>
>
> You are missing the second closing parenthesis. This is what the error
> message is telling you.
>
>
>
>
>
> On Wed, Jun 9, 2021 at 2:44 AM Jeff Reichman 
> wrote:
>
> R-Help Forum
>
>
>
> Anyone know why the following line of code would error out:  myObject <-
> read_fst(unz("Dataset.zip", filename = "filename.fst"))
>
>
>
> Error: Incomplete expression: filename <- read_fst(unz("Dataset.zip",
> filename = "filename.fst")
>
>
>
> I often use similar code with *.csv files in a zipped folder. For example:
> myObject <- read.csv(unz("Dataset.zip", filename = "filename.csv")), which
> works just fine.
>
>
>
> Jeff Reichman
>
>
>
>
> [[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] Read fst files

2021-06-09 Thread Jeff Reichman
Eric

 

Typo on my point. 

 

setwd("C:/Users/reichmaj/Documents/My_Reference_Library /Regression")

myObject <- read_fst(unz("Dataset.zip", filename = "myFile.fst")) # read fst 
file

 

Error in path.expand(path) : invalid 'path' argument

 

So then I tried

 

myObject <- read_fst(unz("C:/Users/reichmaj/Documents/My_Reference_Library 
/Regression /Dataset.zip", filename = "myFile.fst"))

 

Error in path.expand(path) : invalid 'path' argument

 

Error in the path??

 

Because this works just fine

 

myObject <- read.csv(unz("C:/Users/reichmaj/Documents/My_Reference_Library 
/Regression /Dataset.zip", filename = "myFile.csv"))

 

My only though is I can’t use the two function s together when dealing with fst 
files ??

 

From: Eric Berger  
Sent: Wednesday, June 9, 2021 3:50 AM
To: reichm...@sbcglobal.net
Cc: R mailing list 
Subject: Re: [R] Read fst files

 

You are missing the second closing parenthesis. This is what the error message 
is telling you.

 

 

On Wed, Jun 9, 2021 at 2:44 AM Jeff Reichman mailto:reichm...@sbcglobal.net> > wrote:

R-Help Forum



Anyone know why the following line of code would error out:  myObject <-
read_fst(unz("Dataset.zip", filename = "filename.fst"))



Error: Incomplete expression: filename <- read_fst(unz("Dataset.zip",
filename = "filename.fst") 



I often use similar code with *.csv files in a zipped folder. For example:
myObject <- read.csv(unz("Dataset.zip", filename = "filename.csv")), which
works just fine.



Jeff Reichman




[[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] Beginner problem - using mod function to print odd numbers

2021-06-09 Thread Eric Berger
It's also possible to save a character and gain the added advantage of
being less understandable :-)

num[!!num%%2]



On Wed, Jun 9, 2021 at 12:56 PM Martin Maechler 
wrote:

> > David Carlsonon Sun, 6 Jun 2021 15:21:34 -0400 writes:
>
> > There is really no need for a loop:
> > num <- 1:100
> > num[ifelse(num %% 2 == 1, TRUE, FALSE)]
>
> > [1]  1  3  5  7  9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45
> 47 49
> > [26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93
> 95 97 99
>
> Well, and the above "works" but is really another proof of my
> year-long claim that people use  ifelse(.)  *MUCH MUCH* too often,
> and should really learn to use alternatives, in this case,
> "R 101" (*long* before fooverse):
>
> Use
>
> num[num %% 2 == 1]
>
> instead of much slower and ...@#^$
>
> num[ifelse(num %% 2 == 1, TRUE, FALSE)]
>
> Martin Maechler
> ETH Zurich
>
> > On Sat, Jun 5, 2021 at 2:05 PM William Michels via R-help
> >  wrote:
> >>
> >> > i <- 1L; span <- 1:100; result <- NA;
> >> > for (i in span){
> >> + ifelse(i %% 2 != 0, result[i] <- TRUE, result[i] <- FALSE)
> >> + }
> >> > span[result]
> >> [1]  1  3  5  7  9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41
> 43
>
>  []
>
> __
> 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] Beginner problem - using mod function to print odd numbers

2021-06-09 Thread Martin Maechler
> David Carlsonon Sun, 6 Jun 2021 15:21:34 -0400 writes:

> There is really no need for a loop:
> num <- 1:100
> num[ifelse(num %% 2 == 1, TRUE, FALSE)]

> [1]  1  3  5  7  9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49
> [26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 
> 99

Well, and the above "works" but is really another proof of my
year-long claim that people use  ifelse(.)  *MUCH MUCH* too often,
and should really learn to use alternatives, in this case,
"R 101" (*long* before fooverse):

Use

num[num %% 2 == 1]

instead of much slower and ...@#^$

num[ifelse(num %% 2 == 1, TRUE, FALSE)]

Martin Maechler
ETH Zurich 

> On Sat, Jun 5, 2021 at 2:05 PM William Michels via R-help
>  wrote:
>> 
>> > i <- 1L; span <- 1:100; result <- NA;
>> > for (i in span){
>> + ifelse(i %% 2 != 0, result[i] <- TRUE, result[i] <- FALSE)
>> + }
>> > span[result]
>> [1]  1  3  5  7  9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43

 []

__
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] Read fst files

2021-06-09 Thread Eric Berger
You are missing the second closing parenthesis. This is what the error
message is telling you.


On Wed, Jun 9, 2021 at 2:44 AM Jeff Reichman 
wrote:

> R-Help Forum
>
>
>
> Anyone know why the following line of code would error out:  myObject <-
> read_fst(unz("Dataset.zip", filename = "filename.fst"))
>
>
>
> Error: Incomplete expression: filename <- read_fst(unz("Dataset.zip",
> filename = "filename.fst")
>
>
>
> I often use similar code with *.csv files in a zipped folder. For example:
> myObject <- read.csv(unz("Dataset.zip", filename = "filename.csv")), which
> works just fine.
>
>
>
> Jeff Reichman
>
>
>
>
> [[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.