Re: [R] Unintended behaviour (possibly bugs)
Thank you for the detailed explanation. I tend to agree. However, this behavior is relatively easy to remediate: This is the piece of the current code: === if (!(is.null(labels) && is.null(glabels))) { nmai <- par("mai") nmai[2L] <- nmai[4L] + max(linch + goffset, ginch) + 0.1 par(mai = nmai) } === This is my proposal: === yinch <- if (!is.null(ylab)) 0.4 else 0 if (!(is.null(labels) && is.null(glabels))) { nmai <- par("mai") nmai.2.new <- nmai[4L] + max(yinch + linch + goffset, ginch) + 0.1 if (nmai.2.new > nmai[2L]) { nmai[2L] <- nmai.2.new } par(mai = nmai) } === Then margins and y-axis labels start to work normally. I wonder if this (or similar) is possible to introduce into the code? Alexey пн, 17 февр. 2020 г. в 17:37, Deepayan Sarkar : > > On Mon, Feb 17, 2020 at 10:24 AM Rui Barradas wrote: > > > > Hello, > > > > Yes, this is definitely a bug. > > I would argue that the only bug here is that the documentation doesn't > say that 'ylab' may not behave as expected. > > dotchart() is mainly designed for 2-way tables (see the VADeaths > example), but it's implementation is really pretty hackish because it > has to work within the limited traditional graphics framework. The > main problem is that dot plots want to put horizontal y-axis labels > (usually derived from factor levels), which are often longer than the > default margins, so the margins are modified. Unfortunately they are > only re-set on exit, and so the ylab that is plotted inside dotchart() > may be clipped. Traditionally, Cleveland dot plots don't have a y-axis > label; it's assumed that the factor levels are sufficient (and for > 2-way tables, there would be two variables, so there is no sensible > default). > > I doubt that dotchart() is worth fixing (except to maybe disallow > ylab). If you want flexibility, use modern grid-based alternatives > such as lattice::dotplot() or ggplot2. > > -Deepayan > > > Even the matrix plot is puzzling, with a "1" as top row sort-of-label > > but no grid line. I'm trying to follow the source code of dotchart but > > am yet to understand exactly what it does to decide the margins settings. > > > > if (!(is.null(labels) && is.null(glabels))) { > >nmai <- par("mai") > >nmai[2L] <- nmai[4L] + max(linch + goffset, ginch) + > > 0.1 > >par(mai = nmai) > > } > > > > This should be moved to r-devel? > > > > Rui Barradas > > > > Às 03:33 de 17/02/20, Alexey Shipunov escreveu: > > > John and Rui, thanks! > > > > > > However, if we use the proper object, the problem still persists: > > > > > > dotchart(c("3"=1, "2"=2, "1"=3), ylab="Ylab") # ylab is invisible > > > dotchart(c("aa"=1, "b"=2, "cc"=3), ylab="Ylab") # ylab is partly visible > > > (!!!) > > > dotchart(c("aaa"=1, "bbb"=2, "ccc"=3), ylab="Ylab") # ylab is well visible > > > > > > If the object is matrix, ylab is visible: > > > > > > dotchart(matrix(1:3, dimnames=list(c("aa","bb","cc"), NULL)), ylab="Ylab") > > > > > > But the ?dotchart explicitly says that "x: either a vector or matrix > > > of numeric values" and then "labels: a vector of labels for each > > > point. For vectors the default is to use ‘names(x)’ ...". > > > > > > So this is likely a bug. Do you agree? > > > > > > Alexey > > > > > > пн, 17 февр. 2020 г. в 01:55, Rui Barradas : > > >> > > >> Hello, > > >> > > >> I believe you are wrong, the error is not in dotchart, it's in your > > >> code. You assume that to plot an object of class "table" is the same as > > >> to plot an object of class "numeric". > > >> > > >> Inline. > > >> > > >> Às 12:21 de 16/02/20, Alexey Shipunov escreveu: > > >>> Dear list, > > >>> > > >>> I have been advised to share these with R-help instead of filling the > > >>> bug report: > > >>> > > >>> 1) dotchart() does not allow to see the left axis title ('ylab') and > > >>> cannot change the left margin (outer margin 2) of the plot > > >>> > > >>> The code: > > >>> > > >>> aa <- table(c(1, 1, 1, 2, 2, 3)) > > >>> dotchart(aa, ylab="Ylab") # does not show 'ylab' > > >> > > >> You are right, it does *not* show 'ylab' but the user is warned. > > >> > > >> > > >> aa <- table(c(1, 1, 1, 2, 2, 3)) > > >> dotchart(aa, ylab = "Ylab") # does show 'ylab' > > >> #Warning message: > > >> #In dotchart(aa, ylab = "Ylab") : > > >> # 'x' is neither a vector nor a matrix: using as.numeric(x) > > >> > > >> > > >> My code: > > >> > > >> > > >> (mar <- par("mar"))# new R session > > >> #[1] 5.1 4.1 4.1 2.1 # the left margin is 4.1 > > >> > > >> aa <- as.numeric(table(c(1, 1, 1, 2, 2, 3))) > > >> > > >> dotchart(aa, ylab = "Ylab") # It does show 'ylab' > > >> old.par <- par(mar = mar + c(0, 5, 0, 0)) > > >> par("mar") > > >> #[1] 5.1 9.1 4.1 2.1 > > >> > > >> dotchart(aa, ylab = "Ylab") # The left margin is now 9.1, much bigger > > >> > > >> par(old.par) # It does change the left margin > > >> dotchart(aa,
Re: [R-es] Colocar objeto Dates dentro de un vector.
Estimado Jaume Tormo En lo personal yo utilizo un enfoque como el que comenta Carlos Ortega, se me ocurre que posiblemente funcione si a su código le coloca algo de formato, me refiero a esta forma: as.Date("10/21/2012", format = "%m/%d/%Y") Javier Rubén Marcuzzi El lun., 17 feb. 2020 a las 17:55, Jaume Tormo () escribió: > Carlos, muchas gracias, voy a probarlo. > Pero me sigue intrigando por que no puedo ponerlo como elemento de un > vector... Misterios del R. SI lo averiguo os lo digo. > > Jaume. > > El sáb., 15 feb. 2020 a las 19:08, Carlos Ortega (< > c...@qualityexcellence.es>) > escribió: > > > Hola, > > > > Una alternativa que te puede ayudar es enfocar el problema de esta otra > > forma. > > Puedes ir guardando tus vectores "original" en un data.frame y luego > > convertirlo a fechas. > > > > Una vez tienes estas fechas, puedes hacer cálculos o extraer otras > > variables. > > > > > > > original<-c(2019,308,1700, 25) > > > df <- data.frame( > > + Year = original[1], > > + DayNum = original[2], > > + Hour = original[3] > > + ) > > > my_fecha <- strptime( paste(df$Year, df$DayNum, df$Hour, sep = ""), > > "%Y%j%H" ) > > > my_fecha > > [1] "2019-11-04 17:00:00 CET" > > > my_fecha <- strptime( paste(original[1], original[2], original[3], sep > = > > ""), "%Y%j%H" ) > > > my_fecha > > [1] "2019-11-04 17:00:00 CET" > > > > Gracias, > > Carlos Ortega > > www.qualityexcellence.es > > > > > > El sáb., 15 feb. 2020 a las 12:45, Jaume Tormo () > > escribió: > > > >> Hola, > >> > >> Estoy encontrando un problema al intentar poner un objeto Dates en un > >> vector o dataframe. > >> Mi ejemplo > >> # preliminares > >> install.packages( lubridate ); library( lubridate ) > >> v <- c(0, 0, 0) > >> original<-c(2019,308,1700, 25) # c(año, día del año, hora, > temperatura) > >> esto sale así de un sensor de temperatura > >> > >> # convertimos los datos originales en algo que entienda R > >> a <- years(original[1] ) > >> d <- days(original[2]-1 ) # el -1 es un ajuste por como son los datos > >> originales > >> h <- hours( substr(original[3], 1, 2) ) > >> fecha <- a+d+h # Conseguimos una fecha completa > >> fecha.b <- as.Date(fecha, origin="-01-01" ) # convertimos la fecha > >> en > >> días del mes en lugar de días del año > >> # mi problema > >> # Si asigno fecha a un elemento de un vector me sale 0 > >> v[2] <- fecha > >> v[2] > >> # Si asigno fecha.b a un elemento de un vector me da un error > >> v[1] <- fecha.b > >> Me da cosas parecidas si intento asignar un lugar en un dataframe, > >> > >> Entiendo que as.Date convierte la fecha en algo que tiene más de un > >> elemento ¿Puede ser eso? Si es así ¿Cómo veo lo que hay dentro del > objeto > >> para sacar solo lo que me interese? > >> > >> Muchas gracias. > >> > >> -- > >> Jaume Tormo. > >> https://es.linkedin.com/in/jaumetormo > >> https://acercad.wordpress.com/ > >> > >> [[alternative HTML version deleted]] > >> > >> ___ > >> R-help-es mailing list > >> R-help-es@r-project.org > >> https://stat.ethz.ch/mailman/listinfo/r-help-es > >> > > > > > > -- > > Saludos, > > Carlos Ortega > > www.qualityexcellence.es > > > > > -- > Jaume Tormo. > https://es.linkedin.com/in/jaumetormo > https://acercad.wordpress.com/ > > [[alternative HTML version deleted]] > > ___ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es > [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
Re: [R-es] Colocar objeto Dates dentro de un vector.
Carlos, muchas gracias, voy a probarlo. Pero me sigue intrigando por que no puedo ponerlo como elemento de un vector... Misterios del R. SI lo averiguo os lo digo. Jaume. El sáb., 15 feb. 2020 a las 19:08, Carlos Ortega () escribió: > Hola, > > Una alternativa que te puede ayudar es enfocar el problema de esta otra > forma. > Puedes ir guardando tus vectores "original" en un data.frame y luego > convertirlo a fechas. > > Una vez tienes estas fechas, puedes hacer cálculos o extraer otras > variables. > > > > original<-c(2019,308,1700, 25) > > df <- data.frame( > + Year = original[1], > + DayNum = original[2], > + Hour = original[3] > + ) > > my_fecha <- strptime( paste(df$Year, df$DayNum, df$Hour, sep = ""), > "%Y%j%H" ) > > my_fecha > [1] "2019-11-04 17:00:00 CET" > > my_fecha <- strptime( paste(original[1], original[2], original[3], sep = > ""), "%Y%j%H" ) > > my_fecha > [1] "2019-11-04 17:00:00 CET" > > Gracias, > Carlos Ortega > www.qualityexcellence.es > > > El sáb., 15 feb. 2020 a las 12:45, Jaume Tormo () > escribió: > >> Hola, >> >> Estoy encontrando un problema al intentar poner un objeto Dates en un >> vector o dataframe. >> Mi ejemplo >> # preliminares >> install.packages( lubridate ); library( lubridate ) >> v <- c(0, 0, 0) >> original<-c(2019,308,1700, 25) # c(año, día del año, hora, temperatura) >> esto sale así de un sensor de temperatura >> >> # convertimos los datos originales en algo que entienda R >> a <- years(original[1] ) >> d <- days(original[2]-1 ) # el -1 es un ajuste por como son los datos >> originales >> h <- hours( substr(original[3], 1, 2) ) >> fecha <- a+d+h # Conseguimos una fecha completa >> fecha.b <- as.Date(fecha, origin="-01-01" ) # convertimos la fecha >> en >> días del mes en lugar de días del año >> # mi problema >> # Si asigno fecha a un elemento de un vector me sale 0 >> v[2] <- fecha >> v[2] >> # Si asigno fecha.b a un elemento de un vector me da un error >> v[1] <- fecha.b >> Me da cosas parecidas si intento asignar un lugar en un dataframe, >> >> Entiendo que as.Date convierte la fecha en algo que tiene más de un >> elemento ¿Puede ser eso? Si es así ¿Cómo veo lo que hay dentro del objeto >> para sacar solo lo que me interese? >> >> Muchas gracias. >> >> -- >> Jaume Tormo. >> https://es.linkedin.com/in/jaumetormo >> https://acercad.wordpress.com/ >> >> [[alternative HTML version deleted]] >> >> ___ >> R-help-es mailing list >> R-help-es@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-help-es >> > > > -- > Saludos, > Carlos Ortega > www.qualityexcellence.es > -- Jaume Tormo. https://es.linkedin.com/in/jaumetormo https://acercad.wordpress.com/ [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es
[R] object.size vs lobstr::obj_size
I am currently working through Advanced R by H. Wickham and came across the `lobstr::obj_size` function which appears to calculate the size of an object by taking into account whether the same object has been referenced multiple times, e.g. x <- runif(1e6) y <- list(x, x, x) lobstr::obj_size(y) # 8,000,128 B # versus: object.size(y) # 24000224 bytes Reading through `?object.size` in the "Details" it reads: [...] but does not detect if elements of a list are shared [...]. My questions are: (1) is the result of `obj_size()` the "correct" one when it comes to actual size used in memory? (2) And if yes, why wouldn't `object.size()` be updated to reflect the more precise calculation of an object in question similar to `obj_size()`? There are probably valid reasons for this and any insight would be greatly appreciated. __ 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] Problems in writing code for circos plot
Wrong list -- (for which statistical methods question are generally offtopic anyway). Post here instead: https://www.bioconductor.org/help/ 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, Feb 17, 2020 at 6:58 AM pooja sinha wrote: > Hi All, > > > I had previously mentioned that I have large data set with methylation > values ranging from 0-1. The data contains around 3 million rows of values > corresponding to the chromosomal locations. I want to split/sort my data > for plot using circos plot. I thought of doing like sorting the value range > 0.2-0.4 as hypomethylation category and range 0.7-1.0 as hypermethylation > category. However, with this approach the plot again looks cluttered. > Another way is that I can split the data into two parts, one part with > values lower than median, and another part with values larger than median. > > Can anyone suggest me which approach is better or if there are other > approaches I can use in my datasets for circos plot using circlize package. > > > Thanks, > > Puja > > On Sun, Jan 26, 2020 at 5:06 PM Jim Lemon wrote: > > > Hi Puja, > > Three things: > > 1) Your data files are very large. If you do manage to get circular > > plots out of them with the circlize library they will probably be very > > dense. > > 2) The structure of your data includes too many levels in "Chrom" to > > get the circlize functions to work. I had to pare them back to the > > non-random levels. > > 3) You should probably change the subject line of your message to > > "Would anyone care to do my work for me?" > > > > Jim > > > > On Mon, Jan 27, 2020 at 6:47 AM pooja sinha wrote: > > > > > > Hi All, > > > > > > I have attached the three different datasets for Rn6 genome (rat) and I > > > needed to use circos plot by *circlize package in R*. Please anyone > help > > me > > > in writing the code and making the plot. Any help will be highly > > > appreciated. > > > The three file links are below: > > > > > > File 1: YOUNGCONTROL.csv ( > > > https://drive.google.com/open?id=1arQqlzkRJybclikAByB9w9TCnvmD_Y46 ) > > > File 2: YOUNGTREATED.csv ( > > > https://drive.google.com/open?id=1vMidiGmoK4zsYjvf2sT9RbjwF72W0IhO ) > > > File 3: YOUNGTREATED.vs.YOUNGCONTROL.sig.csv ( > > > > > > https://drive.google.com/open?id=0B33BGsdd5x_dOGF0X3BuaWRoMmdSYklOZnJoX09uaWdnNEdN > > > ) > > > > > > The circos plot having the outermost ring contain Rn6 ideogram followed > > by > > > YOUNGCONTROL, YOUNGTREATED & last innermost circle will be of > > > YOUNGTREATED.vs.YOUNGCONTROL.sig > > > > > > Thanks, > > > Puja > > > > > > [[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. > [[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] Problems in writing code for circos plot
Hi All, I had previously mentioned that I have large data set with methylation values ranging from 0-1. The data contains around 3 million rows of values corresponding to the chromosomal locations. I want to split/sort my data for plot using circos plot. I thought of doing like sorting the value range 0.2-0.4 as hypomethylation category and range 0.7-1.0 as hypermethylation category. However, with this approach the plot again looks cluttered. Another way is that I can split the data into two parts, one part with values lower than median, and another part with values larger than median. Can anyone suggest me which approach is better or if there are other approaches I can use in my datasets for circos plot using circlize package. Thanks, Puja On Sun, Jan 26, 2020 at 5:06 PM Jim Lemon wrote: > Hi Puja, > Three things: > 1) Your data files are very large. If you do manage to get circular > plots out of them with the circlize library they will probably be very > dense. > 2) The structure of your data includes too many levels in "Chrom" to > get the circlize functions to work. I had to pare them back to the > non-random levels. > 3) You should probably change the subject line of your message to > "Would anyone care to do my work for me?" > > Jim > > On Mon, Jan 27, 2020 at 6:47 AM pooja sinha wrote: > > > > Hi All, > > > > I have attached the three different datasets for Rn6 genome (rat) and I > > needed to use circos plot by *circlize package in R*. Please anyone help > me > > in writing the code and making the plot. Any help will be highly > > appreciated. > > The three file links are below: > > > > File 1: YOUNGCONTROL.csv ( > > https://drive.google.com/open?id=1arQqlzkRJybclikAByB9w9TCnvmD_Y46 ) > > File 2: YOUNGTREATED.csv ( > > https://drive.google.com/open?id=1vMidiGmoK4zsYjvf2sT9RbjwF72W0IhO ) > > File 3: YOUNGTREATED.vs.YOUNGCONTROL.sig.csv ( > > > https://drive.google.com/open?id=0B33BGsdd5x_dOGF0X3BuaWRoMmdSYklOZnJoX09uaWdnNEdN > > ) > > > > The circos plot having the outermost ring contain Rn6 ideogram followed > by > > YOUNGCONTROL, YOUNGTREATED & last innermost circle will be of > > YOUNGTREATED.vs.YOUNGCONTROL.sig > > > > Thanks, > > Puja > > > > [[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] testing my package : unstated dependency to self in package tests
That worked. Thanks. From: Michael Dewey Sent: Sunday, February 16, 2020 5:54 PM To: Servet Ahmet Çizmeli ; r-help@r-project.org Subject: Re: [R] testing my package : unstated dependency to self in package tests When something similar happened to me I found it went away when I added Suggests: to the DESCRIPTION file. Whether this will work for you I have no idea. Michael On 16/02/2020 11:03, Servet Ahmet Çizmeli wrote: > I am updating my CRAN package geoSpectral. I get the following Warning during > R CMD check : > > ... > * checking for unstated dependencies in �tests� ... WARNING > 'library' or 'require' call not declared from: �geoSpectral� > > > > All the .R files I have under the testhat directory begin by : > library(geoSpectral) > library(testthat) > > and there I call package functions directly (without the prefix geoSpectal:: > ) > See > https://github.com/cran/geoSpectral/blob/master/tests/testthat/Spectra_tests.R > > Searching the web, I found examples where the same Warning has been issued > for some other packages. But in my case the package in question is my own > package I am testing > > Confused and at loss. Anyone with ideas? > regards > Servet > >[[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. > -- Michael http://www.dewey.myzen.co.uk/home.html [[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] Unintended behaviour (possibly bugs)
On Mon, Feb 17, 2020 at 10:24 AM Rui Barradas wrote: > > Hello, > > Yes, this is definitely a bug. I would argue that the only bug here is that the documentation doesn't say that 'ylab' may not behave as expected. dotchart() is mainly designed for 2-way tables (see the VADeaths example), but it's implementation is really pretty hackish because it has to work within the limited traditional graphics framework. The main problem is that dot plots want to put horizontal y-axis labels (usually derived from factor levels), which are often longer than the default margins, so the margins are modified. Unfortunately they are only re-set on exit, and so the ylab that is plotted inside dotchart() may be clipped. Traditionally, Cleveland dot plots don't have a y-axis label; it's assumed that the factor levels are sufficient (and for 2-way tables, there would be two variables, so there is no sensible default). I doubt that dotchart() is worth fixing (except to maybe disallow ylab). If you want flexibility, use modern grid-based alternatives such as lattice::dotplot() or ggplot2. -Deepayan > Even the matrix plot is puzzling, with a "1" as top row sort-of-label > but no grid line. I'm trying to follow the source code of dotchart but > am yet to understand exactly what it does to decide the margins settings. > > if (!(is.null(labels) && is.null(glabels))) { >nmai <- par("mai") >nmai[2L] <- nmai[4L] + max(linch + goffset, ginch) + > 0.1 >par(mai = nmai) > } > > This should be moved to r-devel? > > Rui Barradas > > Às 03:33 de 17/02/20, Alexey Shipunov escreveu: > > John and Rui, thanks! > > > > However, if we use the proper object, the problem still persists: > > > > dotchart(c("3"=1, "2"=2, "1"=3), ylab="Ylab") # ylab is invisible > > dotchart(c("aa"=1, "b"=2, "cc"=3), ylab="Ylab") # ylab is partly visible > > (!!!) > > dotchart(c("aaa"=1, "bbb"=2, "ccc"=3), ylab="Ylab") # ylab is well visible > > > > If the object is matrix, ylab is visible: > > > > dotchart(matrix(1:3, dimnames=list(c("aa","bb","cc"), NULL)), ylab="Ylab") > > > > But the ?dotchart explicitly says that "x: either a vector or matrix > > of numeric values" and then "labels: a vector of labels for each > > point. For vectors the default is to use ‘names(x)’ ...". > > > > So this is likely a bug. Do you agree? > > > > Alexey > > > > пн, 17 февр. 2020 г. в 01:55, Rui Barradas : > >> > >> Hello, > >> > >> I believe you are wrong, the error is not in dotchart, it's in your > >> code. You assume that to plot an object of class "table" is the same as > >> to plot an object of class "numeric". > >> > >> Inline. > >> > >> Às 12:21 de 16/02/20, Alexey Shipunov escreveu: > >>> Dear list, > >>> > >>> I have been advised to share these with R-help instead of filling the > >>> bug report: > >>> > >>> 1) dotchart() does not allow to see the left axis title ('ylab') and > >>> cannot change the left margin (outer margin 2) of the plot > >>> > >>> The code: > >>> > >>> aa <- table(c(1, 1, 1, 2, 2, 3)) > >>> dotchart(aa, ylab="Ylab") # does not show 'ylab' > >> > >> You are right, it does *not* show 'ylab' but the user is warned. > >> > >> > >> aa <- table(c(1, 1, 1, 2, 2, 3)) > >> dotchart(aa, ylab = "Ylab") # does show 'ylab' > >> #Warning message: > >> #In dotchart(aa, ylab = "Ylab") : > >> # 'x' is neither a vector nor a matrix: using as.numeric(x) > >> > >> > >> My code: > >> > >> > >> (mar <- par("mar"))# new R session > >> #[1] 5.1 4.1 4.1 2.1 # the left margin is 4.1 > >> > >> aa <- as.numeric(table(c(1, 1, 1, 2, 2, 3))) > >> > >> dotchart(aa, ylab = "Ylab") # It does show 'ylab' > >> old.par <- par(mar = mar + c(0, 5, 0, 0)) > >> par("mar") > >> #[1] 5.1 9.1 4.1 2.1 > >> > >> dotchart(aa, ylab = "Ylab") # The left margin is now 9.1, much bigger > >> > >> par(old.par) # It does change the left margin > >> dotchart(aa, ylab = "Ylab") # but only when a new graph is plotted. > >> > >> > >> > >>> old.par <- par(mar=c(1, 10, 1, 1)) ; dotchart(aa, ylab="Ylab") ; > >>> par(old.par) # does not change left margin > >>> > >>> Possible solution: > >>> > >>> I researched the problem and think that the dotchart() code will need > >>> few corrections. If there is an interest, I can post it here; or you > >>> can look at the code of shipunov::Dotchart1() function. > >>> > >>> 2) example(hist) includes two "wrong" and "extreme" examples which > >>> slow down and even crash R on some systems; this make it unsuitable > >>> for demonstration in the class and strikes beginners in R who just > >>> want to understand how hist() works. Actually, I did it last week (I > >>> was not aware of these examples), and in the class two computers hang, > >>> and many others were extremely slow. > >>> > >>> The code: > >>> > >>> example(hist) > >>> > >>> Possible solution: > >>> > >>> If R maintainers will enclose parts of "hist" example in \dontrun{}, > >>> this will allow to see the code but in the same time will not
Re: [R] Unintended behaviour (possibly bugs)
Hello, To move to r-devel just send email to r-de...@r-project.org. See https://stat.ethz.ch/mailman/listinfo/r-devel Rui Barradas Às 04:59 de 17/02/20, Alexey Shipunov escreveu: My suggestion (shipunov::Dotchart1()) was: === yinch <- if (!is.null(ylab)) 0.4 else 0 # inserted! if (!(is.null(labels) && is.null(glabels))) { nmai <- par("mai") nmai.2.new <- nmai[4L] + max(yinch + linch + goffset, ginch) + 0.1 # changed! if (nmai.2.new > nmai[2L]) { # changed! nmai[2L] <- nmai.2.new # changed! } par(mai = nmai) } === But I am not sure if this is the best way. Now, how to move to r-devel? I never did it before. Alexey пн, 17 февр. 2020 г. в 13:54, Rui Barradas : Hello, Yes, this is definitely a bug. Even the matrix plot is puzzling, with a "1" as top row sort-of-label but no grid line. I'm trying to follow the source code of dotchart but am yet to understand exactly what it does to decide the margins settings. if (!(is.null(labels) && is.null(glabels))) { nmai <- par("mai") nmai[2L] <- nmai[4L] + max(linch + goffset, ginch) + 0.1 par(mai = nmai) } This should be moved to r-devel? Rui Barradas Às 03:33 de 17/02/20, Alexey Shipunov escreveu: John and Rui, thanks! However, if we use the proper object, the problem still persists: dotchart(c("3"=1, "2"=2, "1"=3), ylab="Ylab") # ylab is invisible dotchart(c("aa"=1, "b"=2, "cc"=3), ylab="Ylab") # ylab is partly visible (!!!) dotchart(c("aaa"=1, "bbb"=2, "ccc"=3), ylab="Ylab") # ylab is well visible If the object is matrix, ylab is visible: dotchart(matrix(1:3, dimnames=list(c("aa","bb","cc"), NULL)), ylab="Ylab") But the ?dotchart explicitly says that "x: either a vector or matrix of numeric values" and then "labels: a vector of labels for each point. For vectors the default is to use ‘names(x)’ ...". So this is likely a bug. Do you agree? Alexey пн, 17 февр. 2020 г. в 01:55, Rui Barradas : Hello, I believe you are wrong, the error is not in dotchart, it's in your code. You assume that to plot an object of class "table" is the same as to plot an object of class "numeric". Inline. Às 12:21 de 16/02/20, Alexey Shipunov escreveu: Dear list, I have been advised to share these with R-help instead of filling the bug report: 1) dotchart() does not allow to see the left axis title ('ylab') and cannot change the left margin (outer margin 2) of the plot The code: aa <- table(c(1, 1, 1, 2, 2, 3)) dotchart(aa, ylab="Ylab") # does not show 'ylab' You are right, it does *not* show 'ylab' but the user is warned. aa <- table(c(1, 1, 1, 2, 2, 3)) dotchart(aa, ylab = "Ylab") # does show 'ylab' #Warning message: #In dotchart(aa, ylab = "Ylab") : # 'x' is neither a vector nor a matrix: using as.numeric(x) My code: (mar <- par("mar"))# new R session #[1] 5.1 4.1 4.1 2.1 # the left margin is 4.1 aa <- as.numeric(table(c(1, 1, 1, 2, 2, 3))) dotchart(aa, ylab = "Ylab") # It does show 'ylab' old.par <- par(mar = mar + c(0, 5, 0, 0)) par("mar") #[1] 5.1 9.1 4.1 2.1 dotchart(aa, ylab = "Ylab") # The left margin is now 9.1, much bigger par(old.par) # It does change the left margin dotchart(aa, ylab = "Ylab") # but only when a new graph is plotted. old.par <- par(mar=c(1, 10, 1, 1)) ; dotchart(aa, ylab="Ylab") ; par(old.par) # does not change left margin Possible solution: I researched the problem and think that the dotchart() code will need few corrections. If there is an interest, I can post it here; or you can look at the code of shipunov::Dotchart1() function. 2) example(hist) includes two "wrong" and "extreme" examples which slow down and even crash R on some systems; this make it unsuitable for demonstration in the class and strikes beginners in R who just want to understand how hist() works. Actually, I did it last week (I was not aware of these examples), and in the class two computers hang, and many others were extremely slow. The code: example(hist) Possible solution: If R maintainers will enclose parts of "hist" example in \dontrun{}, this will allow to see the code but in the same time will not strike beginners in R who just want to understand how hist() works. They will still be possible to run with example(..., run.dontrun=TRUE). Agree, it's annoying. Sometimes there's a Warning section after the Details section. Maybe such a section could get users' attention to those examples? At least it wouldn't hurt... Hope this helps, Rui Barradas With best wishes, Alexey Shipunov __ 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