[R] Manage time frame package deSolve

2020-05-26 Thread Luigi Marongiu
Hello,
I have set a model with deSolve's ode. I have set the time as `period
= seq(1, 10, 1)` but the times I get from the ode are like 1,
1.000173...
Is it possible to run ode with the time points provided by `period`?


-- 
Best regards,
Luigi

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


Re: [R] [External] Help with sub-setting

2020-05-26 Thread Burgess, Jamie
Dear all,


Apologies for the late reply - I have just got back from my shift. I am 
unfortunately a little sleep deprived hehe


Hi Bert,

Thank-you for your reply


Yes, apologies - the syntax was lost in translation whilst changing the names 
of the groups, imported data-set file name and variables.


data<-data.frame(X=sample(1:2,100,TRUE),Y=sample(1:2,100,TRUE),
>  Z=rnorm(100))

by(data$Z,data[,c("X","Y")],summary)


In your example, if one of my variables recorded integer data and the other 
continuous data, does "1:2" specify columns, and "100" the number of entries I 
would like to select?


Dear Richard,


Thank-you for your reply


I have had previous success sub-grouping by one variable using the following:


group1<-subset(dataset1,dataset1$A==1)


I have subsequently been summarising the data using:


table(group1$variable) or summarise(group1$variable)


Using your suggestion I have managed to sub-group using the following:


GroupAB<-subset(data,data$A==1 & is.na (data$B)==FALSE)




I will also try your suggestion datasubset <- data[data$A ==1 & data$B ==  1 
,]) it is much appreciated. Does my entry do the same thing as yours?


I thought the problem was to do with the size of my data-set (4.9GB) and the 
presence of ~500,000 entries. However, as another command worked I am unsure 
what the problems was

I am only actually interested in around one third of these which is the reason 
I wish to sub-group by the two variables I have selected.

I was wondering why this new script worked.



Kind regards,


Jamie




From: Bert Gunter 
Sent: 25 May 2020 18:36:18
To: Richard M. Heiberger
Cc: Burgess, Jamie; r-help@r-project.org
Subject: Re: [R] [External] Help with sub-setting

Yes. In particular:

data$variable==1 & data

makes no sense (data is a data frame). A typo perhaps? Or as Richard indicated, 
consult references/tutorials to learn proper syntax for (vectorized) predicates.

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 Mon, May 25, 2020 at 10:20 AM Richard M. Heiberger 
mailto:r...@temple.edu>> wrote:
I think the syntax you are looking for is

datasubset <- data[ data$A ==1 & data$B ==  1 , ] )

This gives the subset of your original data for variable A with value
1 and variable B with value 1.


On Mon, May 25, 2020 at 12:57 PM Burgess, Jamie
mailto:jamie.burg...@liverpool.ac.uk>> wrote:
>
> Dear all,
>
> I hope this message finds you well. I am currently trying to subset my data 
> by two variables, so far, I have tried two different ways to stratify 
> participants into groups. I would like to use the �summary� and �table� 
> arguments to characterise the data of participants based on the presence of 
> two variables and summarise this sub-set against a third variable.
> I have used this method:
>
> dgb001<-subset(data,data$variable==1 & data,data$variable)
>
>
> However, I get the following error: �Error: cannot allocate vector of size 
> 16.0 Gb�. Is there another method I can try?
>
>
> Kind regards,
>
>
> Jamie Burgess
>
> PhD Student Endocrinology and Diabetes
>
> University of Liverpool
>
> Aintree University Hospital &
>
> The Walton Centre
>
> Institute of Ageing & Chronic Disease
>
> 0151 529 5936
>
>
> [[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] Partial matching list elements in R 4.0

2020-05-26 Thread John Harrold
Hello,


I'm testing some code in R 4.0, and I'm having an issue with the following"

# -
rm(list=ls())
graphics.off()
#load("/tmp/post.RData")
var = list();
# If I uncomment this it fixes things:
# var$options = list(mi   = list(),
#misc = list())
#
var$options$misc$abc = "123"
var$options$mi$something= 13
#

This is a stripped down example but it exhibits the issue I"m having.
Basically when I create the list element var$options$mi the contents of
var$options$misc move over to var$options$mi. And what was in
var$options$misc become NULL:

So now var$options looks like:

var$options
$misc
$misc$abc
NULL

$mi
$mi$abc
[1] "123"
$mi$something
[1] 13

This worked (still works) in R 3.5.1. I understand partial matching, but is
this normal lists moving over to elements like this? I can uncomment the
text mentioned in the example and it seems to fix it, but I'm wondering if
this is a bug or just my poor programming coming back to bite me.

I've included my sessionInfo() at the bottom.

Thanks
John
:wq


sessionInfo()

R version 4.0.0 (2020-04-24)

Platform: x86_64-apple-darwin17.0 (64-bit)

Running under: macOS Mojave 10.14.5


Matrix products: default

BLAS:
/Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib

LAPACK:
/Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib


locale:

[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8


attached base packages:

[1] stats graphics  grDevices utils datasets  methods   base


other attached packages:

[1] gdata_2.18.0  ggplot2_3.3.0 deSolve_1.28


loaded via a namespace (and not attached):

 [1] Rcpp_1.0.4.6 gtools_3.8.2 withr_2.2.0  assertthat_0.2.1

 [5] dplyr_0.8.5  digest_0.6.25crayon_1.3.4 grid_4.0.0

 [9] R6_2.4.1 lifecycle_0.2.0  gtable_0.3.0 magrittr_1.5

[13] scales_1.1.1 pillar_1.4.4 rlang_0.4.6  vctrs_0.3.0

[17] ellipsis_0.3.1   glue_1.4.1   purrr_0.3.4  munsell_0.5.0

[21] compiler_4.0.0   pkgconfig_2.0.3  colorspace_1.4-1 tidyselect_1.1.0

[25] tibble_3.0.1

[[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] 3D NURBS import as B-spline

2020-05-26 Thread Дмитрий Пономаренко
 Dear R-help list,

I have 3D NURBS curves that I would like to import into R as B-splines. The
curves are in Rhinoceros 3dm format but can be converted to IGES format.

Can 3D NURBS curves be imported into R?

Thank you,
Zemleroi

[[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] Partial matching list elements in R 4.0

2020-05-26 Thread Bert Gunter
I can't answer your question (about your R programming skills) but the
behavior you complain about is as documented. In particular:

"Thus the default behaviour is to use partial matching only when extracting
from recursive objects (except environments) by $. Even in that case,
warnings can be switched on by options
(warnPartialMatchDollar
= TRUE)."

So the solution is not to use $ for list extraction/replacement. Though
convenient, it is prone to such issues. Instead, the following works (as
does your suggested solution, of course):

> var <- list()
> var[["options"]][["misc"]][["abc"]] <- "123"
> var[["options"]][["mi"]][["something"]] <- 13
> var
$options
$options$misc
$options$misc$abc
[1] "123"


$options$mi
$options$mi$something
[1] 13

Bert Gunter

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


On Tue, May 26, 2020 at 10:45 AM John Harrold 
wrote:

> Hello,
>
>
> I'm testing some code in R 4.0, and I'm having an issue with the following"
>
> # -
> rm(list=ls())
> graphics.off()
> #load("/tmp/post.RData")
> var = list();
> # If I uncomment this it fixes things:
> # var$options = list(mi   = list(),
> #misc = list())
> #
> var$options$misc$abc = "123"
> var$options$mi$something= 13
> #
>
> This is a stripped down example but it exhibits the issue I"m having.
> Basically when I create the list element var$options$mi the contents of
> var$options$misc move over to var$options$mi. And what was in
> var$options$misc become NULL:
>
> So now var$options looks like:
>
> var$options
> $misc
> $misc$abc
> NULL
>
> $mi
> $mi$abc
> [1] "123"
> $mi$something
> [1] 13
>
> This worked (still works) in R 3.5.1. I understand partial matching, but is
> this normal lists moving over to elements like this? I can uncomment the
> text mentioned in the example and it seems to fix it, but I'm wondering if
> this is a bug or just my poor programming coming back to bite me.
>
> I've included my sessionInfo() at the bottom.
>
> Thanks
> John
> :wq
>
>
> sessionInfo()
>
> R version 4.0.0 (2020-04-24)
>
> Platform: x86_64-apple-darwin17.0 (64-bit)
>
> Running under: macOS Mojave 10.14.5
>
>
> Matrix products: default
>
> BLAS:
> /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
>
> LAPACK:
> /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
>
>
> locale:
>
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
>
> attached base packages:
>
> [1] stats graphics  grDevices utils datasets  methods   base
>
>
> other attached packages:
>
> [1] gdata_2.18.0  ggplot2_3.3.0 deSolve_1.28
>
>
> loaded via a namespace (and not attached):
>
>  [1] Rcpp_1.0.4.6 gtools_3.8.2 withr_2.2.0  assertthat_0.2.1
>
>  [5] dplyr_0.8.5  digest_0.6.25crayon_1.3.4 grid_4.0.0
>
>  [9] R6_2.4.1 lifecycle_0.2.0  gtable_0.3.0 magrittr_1.5
>
> [13] scales_1.1.1 pillar_1.4.4 rlang_0.4.6  vctrs_0.3.0
>
> [17] ellipsis_0.3.1   glue_1.4.1   purrr_0.3.4  munsell_0.5.0
>
> [21] compiler_4.0.0   pkgconfig_2.0.3  colorspace_1.4-1 tidyselect_1.1.0
>
> [25] tibble_3.0.1
>
> [[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] Partial matching list elements in R 4.0

2020-05-26 Thread William Dunlap via R-help
Another symptom of this problem is:

> {x <- list(Abc=list(Pqr="Old Abc$Pqr")); x$Ab$Pqr <- "New Ab$Pqr" ; x}
R version 3.6.2 (2019-12-12) | R version 4.0.0 (2020-04-24)
List of 2| List of 2
 $ Abc:List of 1 |  $ Abc:List of 1
  ..$ Pqr: chr "Old Abc$Pqr" |   ..$ Pqr: chr "New Ab$Pqr"
 $ Ab :List of 1 |  $ Ab :List of 1
  ..$ Pqr: chr "New Ab$Pqr"  |   ..$ Pqr: chr "New Ab$Pqr"

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Tue, May 26, 2020 at 10:45 AM John Harrold 
wrote:

> Hello,
>
>
> I'm testing some code in R 4.0, and I'm having an issue with the following"
>
> # -
> rm(list=ls())
> graphics.off()
> #load("/tmp/post.RData")
> var = list();
> # If I uncomment this it fixes things:
> # var$options = list(mi   = list(),
> #misc = list())
> #
> var$options$misc$abc = "123"
> var$options$mi$something= 13
> #
>
> This is a stripped down example but it exhibits the issue I"m having.
> Basically when I create the list element var$options$mi the contents of
> var$options$misc move over to var$options$mi. And what was in
> var$options$misc become NULL:
>
> So now var$options looks like:
>
> var$options
> $misc
> $misc$abc
> NULL
>
> $mi
> $mi$abc
> [1] "123"
> $mi$something
> [1] 13
>
> This worked (still works) in R 3.5.1. I understand partial matching, but is
> this normal lists moving over to elements like this? I can uncomment the
> text mentioned in the example and it seems to fix it, but I'm wondering if
> this is a bug or just my poor programming coming back to bite me.
>
> I've included my sessionInfo() at the bottom.
>
> Thanks
> John
> :wq
>
>
> sessionInfo()
>
> R version 4.0.0 (2020-04-24)
>
> Platform: x86_64-apple-darwin17.0 (64-bit)
>
> Running under: macOS Mojave 10.14.5
>
>
> Matrix products: default
>
> BLAS:
> /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
>
> LAPACK:
> /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
>
>
> locale:
>
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
>
> attached base packages:
>
> [1] stats graphics  grDevices utils datasets  methods   base
>
>
> other attached packages:
>
> [1] gdata_2.18.0  ggplot2_3.3.0 deSolve_1.28
>
>
> loaded via a namespace (and not attached):
>
>  [1] Rcpp_1.0.4.6 gtools_3.8.2 withr_2.2.0  assertthat_0.2.1
>
>  [5] dplyr_0.8.5  digest_0.6.25crayon_1.3.4 grid_4.0.0
>
>  [9] R6_2.4.1 lifecycle_0.2.0  gtable_0.3.0 magrittr_1.5
>
> [13] scales_1.1.1 pillar_1.4.4 rlang_0.4.6  vctrs_0.3.0
>
> [17] ellipsis_0.3.1   glue_1.4.1   purrr_0.3.4  munsell_0.5.0
>
> [21] compiler_4.0.0   pkgconfig_2.0.3  colorspace_1.4-1 tidyselect_1.1.0
>
> [25] tibble_3.0.1
>
> [[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] 3D NURBS import as B-spline

2020-05-26 Thread Jeff Newmiller
The unhelpful answer is yes, because R is a programming language that just 
requires someone with an itch. The more helpful answer is that the rgl package 
could be a good place to investigate making those connections... it looks like 
that might have been a "future work item" some time back.

On May 26, 2020 10:01:37 AM PDT, "Дмитрий Пономаренко"  
wrote:
> Dear R-help list,
>
>I have 3D NURBS curves that I would like to import into R as B-splines.
>The
>curves are in Rhinoceros 3dm format but can be converted to IGES
>format.
>
>Can 3D NURBS curves be imported into R?
>
>Thank you,
>Zemleroi
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Partial matching list elements in R 4.0

2020-05-26 Thread John Harrold
Hello Bert,

I've read the documentation and I didn't think it applied here. Perhaps
it's my reading of that documentation I'm confused by. I stays *only when
extracting*. What I'm doing here is assigning values. Is the expected
behavior really to create a copy of the "misc" element in "mi" and then set
all of the values in "misc" to NULL?

Thanks,
John

On Tue, May 26, 2020 at 11:32 AM Bert Gunter  wrote:

> I can't answer your question (about your R programming skills) but the
> behavior you complain about is as documented. In particular:
>
> "Thus the default behaviour is to use partial matching only when
> extracting from recursive objects (except environments) by $. Even in
> that case, warnings can be switched on by options
> (warnPartialMatchDollar
> = TRUE)."
>
> So the solution is not to use $ for list extraction/replacement. Though
> convenient, it is prone to such issues. Instead, the following works (as
> does your suggested solution, of course):
>
> > var <- list()
> > var[["options"]][["misc"]][["abc"]] <- "123"
> > var[["options"]][["mi"]][["something"]] <- 13
> > var
> $options
> $options$misc
> $options$misc$abc
> [1] "123"
>
>
> $options$mi
> $options$mi$something
> [1] 13
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Tue, May 26, 2020 at 10:45 AM John Harrold 
> wrote:
>
>> Hello,
>>
>>
>> I'm testing some code in R 4.0, and I'm having an issue with the
>> following"
>>
>> # -
>> rm(list=ls())
>> graphics.off()
>> #load("/tmp/post.RData")
>> var = list();
>> # If I uncomment this it fixes things:
>> # var$options = list(mi   = list(),
>> #misc = list())
>> #
>> var$options$misc$abc = "123"
>> var$options$mi$something= 13
>> #
>>
>> This is a stripped down example but it exhibits the issue I"m having.
>> Basically when I create the list element var$options$mi the contents of
>> var$options$misc move over to var$options$mi. And what was in
>> var$options$misc become NULL:
>>
>> So now var$options looks like:
>>
>> var$options
>> $misc
>> $misc$abc
>> NULL
>>
>> $mi
>> $mi$abc
>> [1] "123"
>> $mi$something
>> [1] 13
>>
>> This worked (still works) in R 3.5.1. I understand partial matching, but
>> is
>> this normal lists moving over to elements like this? I can uncomment the
>> text mentioned in the example and it seems to fix it, but I'm wondering if
>> this is a bug or just my poor programming coming back to bite me.
>>
>> I've included my sessionInfo() at the bottom.
>>
>> Thanks
>> John
>> :wq
>>
>>
>> sessionInfo()
>>
>> R version 4.0.0 (2020-04-24)
>>
>> Platform: x86_64-apple-darwin17.0 (64-bit)
>>
>> Running under: macOS Mojave 10.14.5
>>
>>
>> Matrix products: default
>>
>> BLAS:
>> /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
>>
>> LAPACK:
>>
>> /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
>>
>>
>> locale:
>>
>> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>>
>>
>> attached base packages:
>>
>> [1] stats graphics  grDevices utils datasets  methods   base
>>
>>
>> other attached packages:
>>
>> [1] gdata_2.18.0  ggplot2_3.3.0 deSolve_1.28
>>
>>
>> loaded via a namespace (and not attached):
>>
>>  [1] Rcpp_1.0.4.6 gtools_3.8.2 withr_2.2.0  assertthat_0.2.1
>>
>>  [5] dplyr_0.8.5  digest_0.6.25crayon_1.3.4 grid_4.0.0
>>
>>  [9] R6_2.4.1 lifecycle_0.2.0  gtable_0.3.0 magrittr_1.5
>>
>> [13] scales_1.1.1 pillar_1.4.4 rlang_0.4.6  vctrs_0.3.0
>>
>> [17] ellipsis_0.3.1   glue_1.4.1   purrr_0.3.4  munsell_0.5.0
>>
>> [21] compiler_4.0.0   pkgconfig_2.0.3  colorspace_1.4-1 tidyselect_1.1.0
>>
>> [25] tibble_3.0.1
>>
>> [[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.
>>
>

-- 
John
:wq

[[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] Partial matching list elements in R 4.0

2020-05-26 Thread Bert Gunter
Hmmm... yes. I read (past tense) that passage as meaning that **when
extracting** partial matching is only done with $. I did not read  it as
also saying that with assignment, partial matching with $ is not done, but
I see how you could. As Bill D.'s example showed, even R seems confused
about how $ should behave on assignment. As I said, best to avoid the issue
altogether by using [[ ]], where matching behavior can be explicitly
controlled and the default is "exact, "which has been recommended here from
time to time by others also. I grant you that such ambiguity is not
desirable, though.

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 Tue, May 26, 2020 at 12:54 PM John Harrold 
wrote:

> Hello Bert,
>
> I've read the documentation and I didn't think it applied here. Perhaps
> it's my reading of that documentation I'm confused by. I stays *only when
> extracting*. What I'm doing here is assigning values. Is the expected
> behavior really to create a copy of the "misc" element in "mi" and then set
> all of the values in "misc" to NULL?
>
> Thanks,
> John
>
> On Tue, May 26, 2020 at 11:32 AM Bert Gunter 
> wrote:
>
>> I can't answer your question (about your R programming skills) but the
>> behavior you complain about is as documented. In particular:
>>
>> "Thus the default behaviour is to use partial matching only when
>> extracting from recursive objects (except environments) by $. Even in
>> that case, warnings can be switched on by options
>> (warnPartialMatchDollar
>> = TRUE)."
>>
>> So the solution is not to use $ for list extraction/replacement. Though
>> convenient, it is prone to such issues. Instead, the following works (as
>> does your suggested solution, of course):
>>
>> > var <- list()
>> > var[["options"]][["misc"]][["abc"]] <- "123"
>> > var[["options"]][["mi"]][["something"]] <- 13
>> > var
>> $options
>> $options$misc
>> $options$misc$abc
>> [1] "123"
>>
>>
>> $options$mi
>> $options$mi$something
>> [1] 13
>>
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Tue, May 26, 2020 at 10:45 AM John Harrold 
>> wrote:
>>
>>> Hello,
>>>
>>>
>>> I'm testing some code in R 4.0, and I'm having an issue with the
>>> following"
>>>
>>> # -
>>> rm(list=ls())
>>> graphics.off()
>>> #load("/tmp/post.RData")
>>> var = list();
>>> # If I uncomment this it fixes things:
>>> # var$options = list(mi   = list(),
>>> #misc = list())
>>> #
>>> var$options$misc$abc = "123"
>>> var$options$mi$something= 13
>>> #
>>>
>>> This is a stripped down example but it exhibits the issue I"m having.
>>> Basically when I create the list element var$options$mi the contents of
>>> var$options$misc move over to var$options$mi. And what was in
>>> var$options$misc become NULL:
>>>
>>> So now var$options looks like:
>>>
>>> var$options
>>> $misc
>>> $misc$abc
>>> NULL
>>>
>>> $mi
>>> $mi$abc
>>> [1] "123"
>>> $mi$something
>>> [1] 13
>>>
>>> This worked (still works) in R 3.5.1. I understand partial matching, but
>>> is
>>> this normal lists moving over to elements like this? I can uncomment the
>>> text mentioned in the example and it seems to fix it, but I'm wondering
>>> if
>>> this is a bug or just my poor programming coming back to bite me.
>>>
>>> I've included my sessionInfo() at the bottom.
>>>
>>> Thanks
>>> John
>>> :wq
>>>
>>>
>>> sessionInfo()
>>>
>>> R version 4.0.0 (2020-04-24)
>>>
>>> Platform: x86_64-apple-darwin17.0 (64-bit)
>>>
>>> Running under: macOS Mojave 10.14.5
>>>
>>>
>>> Matrix products: default
>>>
>>> BLAS:
>>> /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
>>>
>>> LAPACK:
>>>
>>> /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
>>>
>>>
>>> locale:
>>>
>>> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>>>
>>>
>>> attached base packages:
>>>
>>> [1] stats graphics  grDevices utils datasets  methods   base
>>>
>>>
>>> other attached packages:
>>>
>>> [1] gdata_2.18.0  ggplot2_3.3.0 deSolve_1.28
>>>
>>>
>>> loaded via a namespace (and not attached):
>>>
>>>  [1] Rcpp_1.0.4.6 gtools_3.8.2 withr_2.2.0  assertthat_0.2.1
>>>
>>>  [5] dplyr_0.8.5  digest_0.6.25crayon_1.3.4 grid_4.0.0
>>>
>>>  [9] R6_2.4.1 lifecycle_0.2.0  gtable_0.3.0 magrittr_1.5
>>>
>>> [13] scales_1.1.1 pillar_1.4.4 rlang_0.4.6  vctrs_0.3.0
>>>
>>> [17] ellipsis_0.3.1   glue_1.4.1   purrr_0.3.4  munsell_0.5.0
>>>
>>> [21] compiler_4.0.0   pkgconfig_2.0.3  colorspace_1.4-1 tidyselect_1.1.0
>>>
>>> [25] tibble_3.0.1
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> _

[R] read_excel() ignore case of worksheet name?

2020-05-26 Thread Ravi Jeyaraman
Hello All, Is there any parameter to make read_excel() ignore the 
case-sensitiveness of the worksheet?   I'm using the below to ready in multiple 
spreadsheets and it works perfectly fine if the worksheet is named 'Tables', 
but fails when it's named ' TABLES'.  Any thoughts?

lapply(1:nrow(SIS), function(x) readxl::read_excel(SIS$FULL_FILEPATH[x], 
sheet='Tables', .name_repair = fixColNames))

Thanks in advance for your response.

Cheers
Ravi



-- 
This email has been checked for viruses by AVG.
https://www.avg.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] read_excel() ignore case of worksheet name?

2020-05-26 Thread Erin Hodgess
Here’s a thought, please.  Could you use the tolower function and make them
all lower case?

Thanks,
Erin

On Tue, May 26, 2020 at 8:21 PM Ravi Jeyaraman  wrote:

> Hello All, Is there any parameter to make read_excel() ignore the
> case-sensitiveness of the worksheet?   I'm using the below to ready in
> multiple spreadsheets and it works perfectly fine if the worksheet is named
> 'Tables', but fails when it's named ' TABLES'.  Any thoughts?
>
> lapply(1:nrow(SIS), function(x) readxl::read_excel(SIS$FULL_FILEPATH[x],
> sheet='Tables', .name_repair = fixColNames))
>
> Thanks in advance for your response.
>
> Cheers
> Ravi
>
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.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.
>
-- 
Erin Hodgess, PhD
mailto: erinm.hodg...@gmail.com

[[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_excel() ignore case of worksheet name?

2020-05-26 Thread Ravi Jeyaraman
I’ve already tried that and doesn’t work

 

From: Erin Hodgess [mailto:erinm.hodg...@gmail.com] 
Sent: Tuesday, May 26, 2020 10:55 PM
To: Ravi Jeyaraman 
Cc: r-help@r-project.org
Subject: Re: [R] read_excel() ignore case of worksheet name?

 

Here’s a thought, please.  Could you use the tolower function and make them all 
lower case?

 

Thanks, 

Erin 

 

On Tue, May 26, 2020 at 8:21 PM Ravi Jeyaraman mailto:rav...@gmail.com> > wrote:

Hello All, Is there any parameter to make read_excel() ignore the 
case-sensitiveness of the worksheet?   I'm using the below to ready in multiple 
spreadsheets and it works perfectly fine if the worksheet is named 'Tables', 
but fails when it's named ' TABLES'.  Any thoughts?

lapply(1:nrow(SIS), function(x) readxl::read_excel(SIS$FULL_FILEPATH[x], 
sheet='Tables', .name_repair = fixColNames))

Thanks in advance for your response.

Cheers
Ravi



-- 
This email has been checked for viruses by AVG.
https://www.avg.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.

-- 

Erin Hodgess, PhD

mailto: erinm.hodg...@gmail.com  


[[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_excel() ignore case of worksheet name?

2020-05-26 Thread Erin Hodgess
What about getSheets, please?

That will get the sheet names.

On Tue, May 26, 2020 at 8:59 PM Ravi Jeyaraman  wrote:

> I’ve already tried that and doesn’t work
>
>
>
> *From:* Erin Hodgess [mailto:erinm.hodg...@gmail.com]
> *Sent:* Tuesday, May 26, 2020 10:55 PM
> *To:* Ravi Jeyaraman 
> *Cc:* r-help@r-project.org
> *Subject:* Re: [R] read_excel() ignore case of worksheet name?
>
>
>
> Here’s a thought, please.  Could you use the tolower function and make
> them all lower case?
>
>
>
> Thanks,
>
> Erin
>
>
>
> On Tue, May 26, 2020 at 8:21 PM Ravi Jeyaraman  wrote:
>
> Hello All, Is there any parameter to make read_excel() ignore the
> case-sensitiveness of the worksheet?   I'm using the below to ready in
> multiple spreadsheets and it works perfectly fine if the worksheet is named
> 'Tables', but fails when it's named ' TABLES'.  Any thoughts?
>
> lapply(1:nrow(SIS), function(x) readxl::read_excel(SIS$FULL_FILEPATH[x],
> sheet='Tables', .name_repair = fixColNames))
>
> Thanks in advance for your response.
>
> Cheers
> Ravi
>
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.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.
>
> --
>
> Erin Hodgess, PhD
>
> mailto: erinm.hodg...@gmail.com
>
>
> 
>  Virus-free.
> www.avg.com
> 
> <#m_-1767373775547039939_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
-- 
Erin Hodgess, PhD
mailto: erinm.hodg...@gmail.com

[[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_excel() ignore case of worksheet name?

2020-05-26 Thread Erin Hodgess
Nice!

On Tue, May 26, 2020 at 9:37 PM Ista Zahn  wrote:

> How about
>
> read_excel_table <- function(x) {
>   readxl::read_excel(
> x,
> sheet=grep("tables",
>excel_sheets(x),
>ignore.case = TRUE,
>value = TRUE),
> .name_repair = fixColNames
>   )
> }
>
> lapply(SIS$FULL_FILEPATH, read_excel_table)
>
>
> --Ista
>
> On Tue, May 26, 2020 at 11:05 PM Ravi Jeyaraman  wrote:
> >
> > I’ve already tried that and doesn’t work
> >
> >
> >
> > From: Erin Hodgess [mailto:erinm.hodg...@gmail.com]
> > Sent: Tuesday, May 26, 2020 10:55 PM
> > To: Ravi Jeyaraman 
> > Cc: r-help@r-project.org
> > Subject: Re: [R] read_excel() ignore case of worksheet name?
> >
> >
> >
> > Here’s a thought, please.  Could you use the tolower function and make
> them all lower case?
> >
> >
> >
> > Thanks,
> >
> > Erin
> >
> >
> >
> > On Tue, May 26, 2020 at 8:21 PM Ravi Jeyaraman   > wrote:
> >
> > Hello All, Is there any parameter to make read_excel() ignore the
> case-sensitiveness of the worksheet?   I'm using the below to ready in
> multiple spreadsheets and it works perfectly fine if the worksheet is named
> 'Tables', but fails when it's named ' TABLES'.  Any thoughts?
> >
> > lapply(1:nrow(SIS), function(x) readxl::read_excel(SIS$FULL_FILEPATH[x],
> sheet='Tables', .name_repair = fixColNames))
> >
> > Thanks in advance for your response.
> >
> > Cheers
> > Ravi
> >
> >
> >
> > --
> > This email has been checked for viruses by AVG.
> > https://www.avg.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.
> >
> > --
> >
> > Erin Hodgess, PhD
> >
> > mailto: erinm.hodg...@gmail.com 
> >
> >
> > [[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.
>
-- 
Erin Hodgess, PhD
mailto: erinm.hodg...@gmail.com

[[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_excel() ignore case of worksheet name?

2020-05-26 Thread Ista Zahn
How about

read_excel_table <- function(x) {
  readxl::read_excel(
x,
sheet=grep("tables",
   excel_sheets(x),
   ignore.case = TRUE,
   value = TRUE),
.name_repair = fixColNames
  )
}

lapply(SIS$FULL_FILEPATH, read_excel_table)


--Ista

On Tue, May 26, 2020 at 11:05 PM Ravi Jeyaraman  wrote:
>
> I’ve already tried that and doesn’t work
>
>
>
> From: Erin Hodgess [mailto:erinm.hodg...@gmail.com]
> Sent: Tuesday, May 26, 2020 10:55 PM
> To: Ravi Jeyaraman 
> Cc: r-help@r-project.org
> Subject: Re: [R] read_excel() ignore case of worksheet name?
>
>
>
> Here’s a thought, please.  Could you use the tolower function and make them 
> all lower case?
>
>
>
> Thanks,
>
> Erin
>
>
>
> On Tue, May 26, 2020 at 8:21 PM Ravi Jeyaraman   > wrote:
>
> Hello All, Is there any parameter to make read_excel() ignore the 
> case-sensitiveness of the worksheet?   I'm using the below to ready in 
> multiple spreadsheets and it works perfectly fine if the worksheet is named 
> 'Tables', but fails when it's named ' TABLES'.  Any thoughts?
>
> lapply(1:nrow(SIS), function(x) readxl::read_excel(SIS$FULL_FILEPATH[x], 
> sheet='Tables', .name_repair = fixColNames))
>
> Thanks in advance for your response.
>
> Cheers
> Ravi
>
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.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.
>
> --
>
> Erin Hodgess, PhD
>
> mailto: erinm.hodg...@gmail.com 
>
>
> [[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] [FORGED] Re: read_excel() ignore case of worksheet name?

2020-05-26 Thread Rolf Turner



There is a function excel_sheets() in the readxl package which will tell 
you the names of the sheets.


Using that you should probably be able to take the appropriate evasive 
action.


cheers,

Rolf Turner

On 27/05/20 2:59 pm, Ravi Jeyaraman wrote:

I’ve already tried that and doesn’t work

  


From: Erin Hodgess [mailto:erinm.hodg...@gmail.com]
Sent: Tuesday, May 26, 2020 10:55 PM
To: Ravi Jeyaraman 
Cc: r-help@r-project.org
Subject: Re: [R] read_excel() ignore case of worksheet name?

  


Here’s a thought, please.  Could you use the tolower function and make them all 
lower case?

  


Thanks,

Erin

  


On Tue, May 26, 2020 at 8:21 PM Ravi Jeyaraman mailto:rav...@gmail.com> > wrote:

Hello All, Is there any parameter to make read_excel() ignore the 
case-sensitiveness of the worksheet?   I'm using the below to ready in multiple 
spreadsheets and it works perfectly fine if the worksheet is named 'Tables', 
but fails when it's named ' TABLES'.  Any thoughts?

lapply(1:nrow(SIS), function(x) readxl::read_excel(SIS$FULL_FILEPATH[x], 
sheet='Tables', .name_repair = fixColNames))

Thanks in advance for your response.

Cheers
Ravi


__
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_excel() ignore case of worksheet name?

2020-05-26 Thread Jim Lemon
Hi Ravi,
The simplest way seems to be the excel_sheets function in the readxl
package. If you know that the sheet name will be some form of "Table",
something like this may do it:

getSheetCase<-function(filepath,sheetname) {
 localnames<-c(sheetname,
  paste0(toupper(substr(sheetname,1,1)),substr(sheetname,2,nchar(sheetname))),
  toupper(sheetname),tolower(sheetname))
 xlnames<-readxl::excel_sheets(filepath)
 namepos<-0
 for(pos in 1:length(localnames)) {
  if(length(grep(localnames[pos],xlnames))) namepos<-pos
  cat(localnames[pos],namepos,"\n")
 }
 if(is.null(namepos)) return(NULL)
 else return(read_excel(filepath,
  sheet=localnames[namepos]))
}
getSheetCase("GS_SS2.xlsx","intent")

This example works on an excel spreadsheet I have as in the last line.
Just as I was about to send this, three messages came in. One was
Ista's excellent solution that blew mine away. Maybe next time.

Jim

On Wed, May 27, 2020 at 1:05 PM Ravi Jeyaraman  wrote:
>
> I’ve already tried that and doesn’t work
>
>
>
> From: Erin Hodgess [mailto:erinm.hodg...@gmail.com]
> Sent: Tuesday, May 26, 2020 10:55 PM
> To: Ravi Jeyaraman 
> Cc: r-help@r-project.org
> Subject: Re: [R] read_excel() ignore case of worksheet name?
>
>
>
> Here’s a thought, please.  Could you use the tolower function and make them 
> all lower case?
>
>
>
> Thanks,
>
> Erin
>
>
>
> On Tue, May 26, 2020 at 8:21 PM Ravi Jeyaraman   > wrote:
>
> Hello All, Is there any parameter to make read_excel() ignore the 
> case-sensitiveness of the worksheet?   I'm using the below to ready in 
> multiple spreadsheets and it works perfectly fine if the worksheet is named 
> 'Tables', but fails when it's named ' TABLES'.  Any thoughts?
>
> lapply(1:nrow(SIS), function(x) readxl::read_excel(SIS$FULL_FILEPATH[x], 
> sheet='Tables', .name_repair = fixColNames))
>
> Thanks in advance for your response.
>
> Cheers
> Ravi
>
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.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.
>
> --
>
> Erin Hodgess, PhD
>
> mailto: erinm.hodg...@gmail.com 
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] Output multiple sheets to Excel files with openxlsx::write.xlsx

2020-05-26 Thread John
Hi,

   This is my code a few years ago. I was able to output multiple sheet to
an excel file. Nevertheless, the "append" argument appears to be obsolete.
Now I see only one sheet, the latest added sheet, in the output. Is there
any other way to do it with openxlsx::write.xlsx or other
functions/packages?


openxlsx::write.xlsx(df1, file=fl_out, sheetName="a",
 col.names=TRUE, row.names=FALSE, append=TRUE, showNA=FALSE)

openxlsx::write.xlsx(df2, file=fl_out, sheetName="b",
 col.names=TRUE, row.names=FALSE,
append=TRUE, showNA=FALSE)

Thanks!!

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