-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fBoxplot: error if length(outliers_id) == 1 (line 85) #7
Comments
Thank you very much for reporting this, and for your hint. The error in fBoxplot is now fixed in the development version available here. I will check if I can find any other issues like this, thank you. -Mari |
Mari,
Great. I had another issue with inheritance of curve_set in forder. I will try to track that down.
Brian
Brian S. Yandell ***@***.***)
Calendar: https://go.wisc.edu/gpo59a
http://www.stat.wisc.edu/~yandell
Professor, Statistics
Director, Biometry Program
University of Wisconsin-Madison
…________________________________
From: Mari Myllymäki ***@***.***>
Sent: Thursday, September 29, 2022 3:28:24 PM
To: myllym/GET ***@***.***>
Cc: Brian Yandell ***@***.***>; Author ***@***.***>
Subject: Re: [myllym/GET] fBoxplot: error if length(outliers_id) == 1 (line 85) (Issue #7)
Thank you very much for reporting this! The error in fBoxplot is now fixed in the development version available here. I will check if I can find any other issues like this, thank you. -Mari
—
Reply to this email directly, view it on GitHub<#7 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AACPQZFS75YZW2SI54YTDULWAX3WRANCNFSM6AAAAAAQYJHXSM>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Mari,
My other problem seems to have disappeared, and your fix solved my problem. The one other thing I noticed is that forder seems to require at least 3 columns of data in funcs. Here is a traceback:
Error in if (any(ties)) { : missing value where TRUE/FALSE needed
7: contrank(x)
6: avrank(x)
5: calc_pointwiserank(all_curves[, i])
4: individual_partial_forder(curve_set, measure, alternative, erlhistn)
3: individual_forder(curve_sets, measure = measure, scaling = scaling,
alternative = alternative, use_theo = use_theo, probs = probs,
quantile.type = quantile.type)
2: GET::forder(object, measure = "area") at envelope.R#278
1: ggplot_ewing_envelope(env)
With
str(curve_set)
List of 3
$ r : num [1:252] 0 3 5 6 7 8 9 10 11 12 ...
$ funcs : num [1:252, 1:2] 0 0 0 0.5 0.5 1 1 1.5 2 2 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:2] "1" "2"
$ is1obs: logi FALSE
- attr(*, "class")= chr [1:2] "ewing_envelope" "curve_set"
- attr(*, "species")= chr "host"
- attr(*, "item")= chr "time"
- attr(*, "ordinate")= chr "step"
The problem seems to be in individual_partial_forder() when it creates calc_pointwiserank() based on measure and alternative and applies this to a set of two values that are identical. Not sure I understand what your code is doing there. I am attaching an example curve_set as saveRDS (use readRDS to load) if that is helpful.
Brian
Brian S. Yandell<http://www.stat.wisc.edu/~yandell> ***@***.******@***.***>> View Calendar<https://go.wisc.edu/gpo59a>
https://www.stat.wisc.edu/~yandell
Professor, Statistics
Director, Biometry Program
University of Wisconsin-Madison
From: Brian Yandell ***@***.***>
Date: Thursday, September 29, 2022 at 4:26 PM
To: myllym/GET ***@***.***>, myllym/GET ***@***.***>
Cc: Author ***@***.***>
Subject: Re: [myllym/GET] fBoxplot: error if length(outliers_id) == 1 (line 85) (Issue #7)
Mari,
Great. I had another issue with inheritance of curve_set in forder. I will try to track that down.
Brian
Brian S. Yandell ***@***.***)
Calendar: https://go.wisc.edu/gpo59a
http://www.stat.wisc.edu/~yandell
Professor, Statistics
Director, Biometry Program
University of Wisconsin-Madison
…________________________________
From: Mari Myllymäki ***@***.***>
Sent: Thursday, September 29, 2022 3:28:24 PM
To: myllym/GET ***@***.***>
Cc: Brian Yandell ***@***.***>; Author ***@***.***>
Subject: Re: [myllym/GET] fBoxplot: error if length(outliers_id) == 1 (line 85) (Issue #7)
Thank you very much for reporting this! The error in fBoxplot is now fixed in the development version available here. I will check if I can find any other issues like this, thank you. -Mari
—
Reply to this email directly, view it on GitHub<#7 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AACPQZFS75YZW2SI54YTDULWAX3WRANCNFSM6AAAAAAQYJHXSM>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Dear Brian, Thank you again. I tried to reproduce your example, as follows, but I was not able to replicate your problem. r <- seq(0,756,by=3) Here the equal curves get equal values of the measure (0.5, 0.5 in the above example), too. Is something missing from this example? Could you try to send your example curve_set again for my further testing? I could not find it attached here. Thanks. Best, |
Mari,
I misspoke. The problem occurs when there are NO ties and 2 columns. Try your example with a slight change:
r <- seq(0,756,by=3)
funcs <- cbind(seq(0,126,by=0.5), seq(0,126,by=0.5))
funcs[,2] <- funcs[,2] + 1
curve_set <- create_curve_set(list(r=r, obs=funcs))
forder(curve_set, measure = "area")
It will blow up on line 16 of file forder.r within function contrank. That is because on line 8 you have
ties <- y[1:(n-2)] == y[3:n]
but n = 2, so you will get an NA in ties. Specifically, ties will have values
NA FALSE
When the two values disagree, with any(ties) being NA. If the two funcs values agree, then ties will be
NA TRUE
And any(ties) is TRUE.
Does that make sense?
Brian
Brian S. Yandell<http://www.stat.wisc.edu/~yandell> ***@***.******@***.***>> View Calendar<https://go.wisc.edu/gpo59a>
https://www.stat.wisc.edu/~yandell
Professor, Statistics
Director, Biometry Program
University of Wisconsin-Madison
From: Mari Myllymäki ***@***.***>
Date: Friday, September 30, 2022 at 7:43 AM
To: myllym/GET ***@***.***>
Cc: Brian Yandell ***@***.***>, Author ***@***.***>
Subject: Re: [myllym/GET] fBoxplot: error if length(outliers_id) == 1 (line 85) (Issue #7)
Dear Brian,
Thank you again. I tried to reproduce your example, as follows, but I was not able to replicate your problem.
r <- seq(0,756,by=3)
funcs <- cbind(seq(0,126,by=0.5), seq(0,126,by=0.5))
curve_set <- create_curve_set(list(r=r, obs=funcs))
forder(curve_set, measure = "area")
Here the equal curves get equal values of the measure (0.5, 0.5 in the above example), too. Is something missing from this example? Could you try to send your example curve_set again for my further testing? I could not find it attached here. Thanks.
Best,
Mari
—
Reply to this email directly, view it on GitHub<#7 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AACPQZEVIMJMNXG7E5ZJAL3WA3N7VANCNFSM6AAAAAAQYJHXSM>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Thanks! Right, I was missing a condition on the required number of functions in forder. For a moment I thought that also the case of two functions is handled, even though ordering just two functions with these methods do not really make much sense. Namely,
I will add a condition on the number of functions. Thanks for noting that this is missing. -Mari |
I added the check to forder and it appears in the development version here. Thank you for reporting this and any other problems that you might find. -Mari |
Mari,
Glad I can be of help. There is one other thing that I noticed. One thing I am doing is creating an S3 object that inherits the “curve_set” class. But in some of your code, you use things like “length(class(curve_sets)) == 1”. This seems non-standard. I found an interesting discussion in Stack Exchange
https://stackoverflow.com/questions/61322898/usemethod-vs-inherits-to-determine-an-objects-class-in-r
They talk abut UseMethod() and inherits() a bit. Probably the definitive guide is
http://adv-r.had.co.nz/S3.html
Related: I would want at time to have a “curve_set” object be interpreted as a “list”. However, inherits(curve_sets, "list") returns FALSE for the example you sent me.
Hope this is helpful. Below are examples in your code where you have “length(class(“…
Cheers,
Brian
R/fclustering.r: class(res) <- "fclust"
R/fdr.r: class(res) <- c("fdr_envelope", class(res))
R/fdr.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
R/fdr.r: class(res_ls) <- c("combined_fdr_envelope", "combined_global_envelope", "list")
R/fdr.r: class(res_ls) <- c("combined_global_envelope2d", class(res_ls))
R/forder.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
Brians-MacBook-Pro:GET brianyandell$ grep "length(class(" R/*.r
R/adjusted_envelopes.r: if(!(length(class(X)) == 1 && inherits(X, "list"))) {
R/envelopes.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
R/envelopes.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
R/fboxplot.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
R/fclustering.r: if(!(length(class(curve_sets)) == 1 && inherits(curve_sets, "list"))) {
R/fdr.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
R/forder.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
Brian S. Yandell<http://www.stat.wisc.edu/~yandell> ***@***.******@***.***>> View Calendar<https://go.wisc.edu/gpo59a>
https://www.stat.wisc.edu/~yandell
Professor, Statistics
Director, Biometry Program
University of Wisconsin-Madison
From: Mari Myllymäki ***@***.***>
Date: Sunday, October 2, 2022 at 7:03 AM
To: myllym/GET ***@***.***>
Cc: Brian Yandell ***@***.***>, Author ***@***.***>
Subject: Re: [myllym/GET] fBoxplot: error if length(outliers_id) == 1 (line 85) (Issue #7)
I added the check to forder. Thank you for reporting this and any other problems that you might find. -Mari
—
Reply to this email directly, view it on GitHub<#7 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AACPQZGECEUZZUPB7WS62W3WBF2W3ANCNFSM6AAAAAAQYJHXSM>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Mari,
One more thing (!). I see that you create the main title using an internal env_main_default. Could you please add main as an argument to routines such as plot.fboxplot, such as
#’ @param main title for plot
…
plot.fboxplot( ___, main = env_main, …) {
env_main <- env_main_default(x, digits=digits)
That way, a user can use argument main to set their own title.
Thanks,
Brian
Brian S. Yandell<http://www.stat.wisc.edu/~yandell> ***@***.******@***.***>> View Calendar<https://go.wisc.edu/gpo59a>
https://www.stat.wisc.edu/~yandell
Professor, Statistics
Director, Biometry Program
University of Wisconsin-Madison
From: Brian Yandell ***@***.***>
Date: Monday, October 3, 2022 at 9:55 AM
To: myllym/GET ***@***.***>, myllym/GET ***@***.***>
Cc: Author ***@***.***>
Subject: Re: [myllym/GET] fBoxplot: error if length(outliers_id) == 1 (line 85) (Issue #7)
Mari,
Glad I can be of help. There is one other thing that I noticed. One thing I am doing is creating an S3 object that inherits the “curve_set” class. But in some of your code, you use things like “length(class(curve_sets)) == 1”. This seems non-standard. I found an interesting discussion in Stack Exchange
https://stackoverflow.com/questions/61322898/usemethod-vs-inherits-to-determine-an-objects-class-in-r
They talk abut UseMethod() and inherits() a bit. Probably the definitive guide is
http://adv-r.had.co.nz/S3.html
Related: I would want at time to have a “curve_set” object be interpreted as a “list”. However, inherits(curve_sets, "list") returns FALSE for the example you sent me.
Hope this is helpful. Below are examples in your code where you have “length(class(“…
Cheers,
Brian
R/fclustering.r: class(res) <- "fclust"
R/fdr.r: class(res) <- c("fdr_envelope", class(res))
R/fdr.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
R/fdr.r: class(res_ls) <- c("combined_fdr_envelope", "combined_global_envelope", "list")
R/fdr.r: class(res_ls) <- c("combined_global_envelope2d", class(res_ls))
R/forder.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
Brians-MacBook-Pro:GET brianyandell$ grep "length(class(" R/*.r
R/adjusted_envelopes.r: if(!(length(class(X)) == 1 && inherits(X, "list"))) {
R/envelopes.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
R/envelopes.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
R/fboxplot.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
R/fclustering.r: if(!(length(class(curve_sets)) == 1 && inherits(curve_sets, "list"))) {
R/fdr.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
R/forder.r: if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list")) {
Brian S. Yandell<http://www.stat.wisc.edu/~yandell> ***@***.******@***.***>> View Calendar<https://go.wisc.edu/gpo59a>
https://www.stat.wisc.edu/~yandell
Professor, Statistics
Director, Biometry Program
University of Wisconsin-Madison
From: Mari Myllymäki ***@***.***>
Date: Sunday, October 2, 2022 at 7:03 AM
To: myllym/GET ***@***.***>
Cc: Brian Yandell ***@***.***>, Author ***@***.***>
Subject: Re: [myllym/GET] fBoxplot: error if length(outliers_id) == 1 (line 85) (Issue #7)
I added the check to forder. Thank you for reporting this and any other problems that you might find. -Mari
—
Reply to this email directly, view it on GitHub<#7 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AACPQZGECEUZZUPB7WS62W3WBF2W3ANCNFSM6AAAAAAQYJHXSM>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Dear Brian, library(fda) The same holds, for example, for the x and y labels. Example of that given in ?fBoxplot. -Mari |
Mari,
Thanks for point out the thing with ggtitle. I did not know that would override what you put in.
Cheers,
Brian
Brian S. Yandell<http://www.stat.wisc.edu/~yandell> ***@***.******@***.***>> View Calendar<https://go.wisc.edu/gpo59a>
https://www.stat.wisc.edu/~yandell
Professor, Statistics
Director, Biometry Program
University of Wisconsin-Madison
From: Mari Myllymäki ***@***.***>
Date: Wednesday, October 5, 2022 at 2:12 AM
To: myllym/GET ***@***.***>
Cc: Brian Yandell ***@***.***>, Author ***@***.***>
Subject: Re: [myllym/GET] fBoxplot: error if length(outliers_id) == 1 (line 85) (Issue #7)
Dear Brian,
The package uses ggplot for the plotting. There is a default title, but it can be modified. Namely, the plotting function returns a ggplot object, which can be modified. So, e.g.,
library(fda)
years <- paste(1:18)
curves <- fda::growth[['hgtf']][years,]
Heights
cset1 <- create_curve_set(list(r = as.numeric(years),
obs = curves))
bp <- fBoxplot(cset1, coverage=0.50, type="area", factor=1)
plot(bp)
plot(bp) + ggtitle("My title")
The other thing I must think further.
…-Mari
—
Reply to this email directly, view it on GitHub<#7 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AACPQZEDXDTBVMGKBSWAAALWBUS4TANCNFSM6AAAAAAQYJHXSM>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Dear Brian, Some updates
All these are just in this development version at the moment and up to further changes. Kind regards, |
Mari,
Thanks so much. You can see where I am using your code at
https://data-viz.it.wisc.edu/ewing2/
and the referenced github.
Cheers,
Brian
Brian S. Yandell<http://www.stat.wisc.edu/~yandell> ***@***.******@***.***>> View Calendar<https://go.wisc.edu/gpo59a>
https://www.stat.wisc.edu/~yandell
Professor, Statistics
Director, Biometry Program
University of Wisconsin-Madison
From: Mari Myllymäki ***@***.***>
Date: Sunday, October 9, 2022 at 2:53 PM
To: myllym/GET ***@***.***>
Cc: Brian Yandell ***@***.***>, Author ***@***.***>
Subject: Re: [myllym/GET] fBoxplot: error if length(outliers_id) == 1 (line 85) (Issue #7)
Dear Brian,
Some updates
1. Now the continuous ranks work are defined also for just 1 or 2 functions. Although ordering these functions do not make much sense here, it can be nice that the function returns anyway a result. Thanks to @mikkoku<https://github.com/mikkoku>!
2. The checks "if(length(class(curve_sets)) == 1 && inherits(curve_sets, "list"))" were/are for checking whether the user has provided a curve_set (or object that can be converted to a curve_set) or a list of curve_sets. In the latter case, the curves of the different curve_sets are ordered jointly. I agree this check looked somewhat cryptic, and I have now recoded the above as "!is_a_single_curve_set(curve_sets)", where is_a_single_curve_set is now a helper function that checks if the object given inherits either curve_set or something else that can currently be converted to a curve_set.
3. It seems that there is no problem to add "curve_set" and "fclust" objects to have also the class "list", and I did this. I just had not realised that it might be needed.
All these are just in this development version at the moment and up to further changes.
Kind regards,
Mari
—
Reply to this email directly, view it on GitHub<#7 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AACPQZHOYFFREAXRNVLABCLWCMPDVANCNFSM6AAAAAAQYJHXSM>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
https://github.com/myllym/GET/blob/master/R/fboxplot.r
I had error tracked down to line 85 of fBoxplot
outliers <- funcs[,outliers_id]
Error in
colnames<-
(*tmp*
, value = 15L) :attempt to set 'colnames' on an object with less than two dimensions
if length(outliers_id) == 1, then outliers becomes a vector in recent R versions. Line 87 tries to set colnames:
colnames(outliers) <- outliers_id
solution would be
outliers <- funcs[,outliers_id, drop = FALSE]
See for instance
https://stackoverflow.com/questions/47754509/how-to-use-drop-f-correctly-in-r-to-preserve-matrix-structure-when-subsetting
There may be other issues like this? Brian
The text was updated successfully, but these errors were encountered: