Re: [R] Fw: inconsistency in nls output....
dear JN, Thanks for the reply. I will consider using the nlsr package. But for now I make did with reducing the exponent. It is working for me. very many thanks for your time and effort yours sincerely, AKSHAY M KULKARNI From: J C Nash Sent: Wednesday, March 6, 2019 10:40 PM To: akshay kulkarni; R help Mailing list Subject: Re: [R] Fw: inconsistency in nls output nls() is a Model T Ford trying to drive on the Interstate. The code is quite old and uses approximations that work well when the user provides a reasonable problem, but in cases where there are mixed large and small numbers like yours could get into trouble. Duncan Murdoch and I prepared the nlsr package to address some of the weaknesses (in particular we try to use analytic derivatives). The output of nlsr also gives the singular values of the Jacobian, though I suspect many R users will have to do some work to interpret those. You haven't provided a reproducible example. That's almost always the way to get definitive answers. Otherwise we're guessing as to the issue. JN On 2019-03-06 7:48 a.m., akshay kulkarni wrote: > dear members, > with reference to the attached message: > > I think I have found out the problem: > YLf13 has the structure: > YLf13 <- a*exp(-1000*LM1); LM1 is another vector. > > most of the YLf13 vector is getting populated with zeros, I think, because of > the very low value of exp(-1000*LM1). Is there any method in R wherein I can > work with these very low values? > > Or is the problem not related to the structure of YLf13? > > very many thanks for your time and effort... > yours sincerely, > AKSHAY M KULKARNI > > > > From: R-help on behalf of akshay kulkarni > > Sent: Wednesday, March 6, 2019 6:02 PM > To: R help Mailing list > Subject: [R] inconsistency in nls output > > dear members, > I have the following nls output: > > Formula: YLf13 ~ (d + e * ((XL)^(1/3)) + f * log(LM3 + 18.81)) > > Parameters: > Estimate Std. Error t value Pr(>|t|) > d 5.892e-09 8.644e-10 6.817 2.06e-11 *** > e -6.585e-09 5.518e-10 -11.934 < 2e-16 *** > f 1.850e-10 2.295e-10 0.806 0.42 > --- > Signif. codes: 0 �***� 0.001 �**� 0.01 �*� 0.05 �.� 0.1 � � 1 > > Residual standard error: 9.57e-10 on 677 degrees of freedom > > Number of iterations to convergence: 2 > Achieved convergence tolerance: 3.973e-08 > > -- > Residual sum of squares: 6.2e-16 > > -- > t-based confidence interval: >2.5% 97.5% > d 4.195378e-09 7.589714e-09 > e -7.668142e-09 -5.501342e-09 > f -2.655647e-10 6.354852e-10 > > -- > Correlation matrix: >d e f > d 1.000 -6.202339e-01 -7.832539e-01 > e -0.6202339 1.00e+00 -2.127301e-05 > f -0.7832539 -2.127301e-05 1.00e+00 > > > if I let XL = 1.1070513 and LM3 = 0.3919 , and consider the coeffs as given > above, the right hand side of the above equation is negative. > But YLf13 is always positive! How is this possible? Am I interpreting the > result of the nls output properly? Should I interpret the coeffs > differently? I have done hours of thinking over the above problem but > couldn't find any results... > > I cannot provide the full values of YLf13, XL and LM3 due to IPR > issuesplease cooperate..however, if the only way to solve the problem > is to give these values, I would indeed give them. > > Also forgive me if there is a minor mistake in my calculations... or a > typo > > very many thanks for your time and effort > yours sincerely, > AKSHAY M KULKARNI > > [[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] strucchange Graph By Week and xts error
On Thu, 7 Mar 2019, Sparks, John wrote: Thanks to Achim's direction I now have a re-producible example. The code below creates a ts object. The x scale of the last graph runs from 0 to 700. Yes, and hence breakpoints() re-uses that scaling. As I wrote in my previous mail you either have to squeeze your data into a regular grid of 52 weekly observations per year or you have to keep track of the time index yourself. See below. So just need a way to get that scale to show the weeks (or some summary of them). Thanks a bunch. --JJS library(strucchange) library(xts) library(lubridate) #rm(list=ls()) data("Nile") class(Nile) plot(Nile) bp.nile <- breakpoints(Nile ~ 1) ci.nile <- confint(bp.nile, breaks = 1) lines(ci.nile) dfNile<-data.frame(as.numeric(Nile)) dfNile$week<-seq(ymd('2012-01-01'),ymd('2013-11-30'),by='weeks') tsNile <- as.xts(x = dfNile[, -2], order.by = dfNile$week) tsNile<-as.ts(tsNile) plot(tsNile) bp.tsNile <- breakpoints(tsNile ~ 1) ci.tsNile <- confint(bp.tsNile, breaks = 1) lines(ci.tsNile) If you want to use your own non-ts time scale, you can use "xts" (as you do above) or "zoo" (as I do below) or keep thing in a plain "data.frame" (or similar). Then you just have to index the times with the breakpoints or their confidence intervals respectively: ## zoo series x <- zoo(Nile, seq(ymd('2012-01-01'),ymd('2013-11-30'),by='weeks')) ## breakpoints and confidence intervals bp <- breakpoints(x ~ 1) ci <- confint(bp, breaks = 1) ## map time index cix <- time(x)[ci$confint] ## visualize plot(x) abline(v = cix[2], lty = 2) arrows(cix[1], min(x), cix[3], min(x), col = 2, angle = 90, length = 0.05, code = 3) Above, the $confint is a vector. If it is a matrix (due to more than one breakpoint) the code needs to be tweaked to make cix also a matrix and then use cix[,i] rather than cix[i] for i = 1, 2, 3. From: Achim Zeileis Sent: Wednesday, March 6, 2019 6:11 PM To: Sparks, John Cc: r-help@r-project.org Subject: Re: [R] strucchange Graph By Week and xts error On Thu, 7 Mar 2019, Sparks, John wrote: Hi R Helpers, I am doing some work at identifying change points in time series data. A very nice example is given in the R Bloggers post https://www.r-bloggers.com/a-look-at-strucchange-and-segmented/ The data for the aswan dam in that example is yearly. My data is weekly. I ran the code switching the data for the analysis to my data and it worked, but the scale of the line chart is not sensible. I have 225 weekly observations and the x-axis of the line graph shows numbers from 0 to over 1500. The information on the ts object is Unfortunately, breakpoints() can only deal automatically with "ts" time series not with zoo/xts/... So either you can squeeze your data onto a regular "ts" grid which may work in the case of weekly data. Or you need to handle the time index "by hand". See https://stackoverflow.com/questions/43243548/strucchange-not-reporting-breakdates/43267082#43267082 for an example for this. As for the as.xts() error below. This is because dfNile[, -2] is still a "ts" object and then as.xts() sets up "order.by" for you. Either you use xts() rather than as.xts() or you make the first column in the data.frame "numeric" rather than "ts", e.g., by starting the transformation with: dfNile<-data.frame(as.numeric(Nile)) Start=1 End=1569 Frequency=0.1428... I can't share the data because it is proprietary. Wanting to be a good member of the list, I attempted to put weekly increments on the Nile data so I could reproduce the x axis of the chart with the axis scale that I am seeing. Unfortunately, in doing so I got another error that I don't understand. library(strucchange) library(lubridate) library(xts) # example from R-Blog runs fine data(???Nile???) plot(Nile) bp.nile <- breakpoints(Nile ~ 1) ci.nile <- confint(bp.nile, breaks = 1) lines(ci.nile) #problem comes in here dfNile<-data.frame(Nile) dfNile$week<-seq(ymd('2012-01-01'),ymd('2013-11-30'),by='weeks') tsNile<-as.xts(x=dfNile[,-2],order.by=dfNile$week) Error in xts(x.mat, order.by = order.by, frequency = frequency(x), ...) : formal argument "order.by" matched by multiple actual arguments Can somebody help me to put together the ts object with weeks so that I can demonstrate the problem with the scale on the x-axis and then try to get some help with that original problem? Much appreciated. --John Sparks [[alternative HTML version deleted]] [[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
[ESS] ESS+Polymode Questions
Hi All, So I finally made the jump to polymode. Still getting use to the changes after having used ESS for circa 15 years or so on Windows, Linux and OSX/macOS. Thanks to those involved in developing and maintaining polymode. Three questions: 1. While the syntax highlighting seems to be generally preserved in terms of fonts and colors from ESS and auctex, the following text: <>= @ that defines the boundary of an R chunk is bolded in black instead of red. I Googled for polymode colors but did not see anything obvious, so was wondering if someone can point me to the fontlock settings for the above to change it from black to red. Red stands out better for my aging eyes... 2. When starting an R session (M-x R), the new R buffer opens in a new frame to the right of the current frame, rather than in the current frame, as was the case with ESS. Is there a way to change this behavior so that it opens in the current frame? I generally work with my R/Rnw files in the top frame and the R session in the lower frame, so this is a quirk that I would like to change, if possible. 3. After opening a Rnw file and starting an R session, I get the following message in the flymake log buffer: Warning [flymake FileName.Rnw[R]]: Disabling backend flymake-proc-legacy-flymake because (error Can’t find a suitable init function) Error [ess-r-flymake *ess-r-flymake*]: Need ‘lintr‘ version > v1.0.3 I do have lintr version 1.0.3 installed from CRAN and, based upon a Google search, I have the following in my .emacs: (remove-hook 'flymake-diagnostic-functions 'flymake-proc-legacy-flymake) prior to both ESS and polymode being loaded. Is this a temporary situation pending a yet to be released version of lintr, or is there something else going on here? Thanks! Marc Schwartz __ ESS-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/ess-help
Re: [R] strucchange Graph By Week and xts error
Thanks to Achim's direction I now have a re-producible example. The code below creates a ts object. The x scale of the last graph runs from 0 to 700. So just need a way to get that scale to show the weeks (or some summary of them). Thanks a bunch. --JJS library(strucchange) library(xts) library(lubridate) #rm(list=ls()) data("Nile") class(Nile) plot(Nile) bp.nile <- breakpoints(Nile ~ 1) ci.nile <- confint(bp.nile, breaks = 1) lines(ci.nile) dfNile<-data.frame(as.numeric(Nile)) dfNile$week<-seq(ymd('2012-01-01'),ymd('2013-11-30'),by='weeks') tsNile <- as.xts(x = dfNile[, -2], order.by = dfNile$week) tsNile<-as.ts(tsNile) plot(tsNile) bp.tsNile <- breakpoints(tsNile ~ 1) ci.tsNile <- confint(bp.tsNile, breaks = 1) lines(ci.tsNile) From: Achim Zeileis Sent: Wednesday, March 6, 2019 6:11 PM To: Sparks, John Cc: r-help@r-project.org Subject: Re: [R] strucchange Graph By Week and xts error On Thu, 7 Mar 2019, Sparks, John wrote: > Hi R Helpers, > > I am doing some work at identifying change points in time series data. > A very nice example is given in the R Bloggers post > > https://www.r-bloggers.com/a-look-at-strucchange-and-segmented/ > > The data for the aswan dam in that example is yearly. My data is > weekly. I ran the code switching the data for the analysis to my data > and it worked, but the scale of the line chart is not sensible. I have > 225 weekly observations and the x-axis of the line graph shows numbers > from 0 to over 1500. The information on the ts object is Unfortunately, breakpoints() can only deal automatically with "ts" time series not with zoo/xts/... So either you can squeeze your data onto a regular "ts" grid which may work in the case of weekly data. Or you need to handle the time index "by hand". See https://stackoverflow.com/questions/43243548/strucchange-not-reporting-breakdates/43267082#43267082 for an example for this. As for the as.xts() error below. This is because dfNile[, -2] is still a "ts" object and then as.xts() sets up "order.by" for you. Either you use xts() rather than as.xts() or you make the first column in the data.frame "numeric" rather than "ts", e.g., by starting the transformation with: dfNile<-data.frame(as.numeric(Nile)) > Start=1 > End=1569 > Frequency=0.1428... > > I can't share the data because it is proprietary. > > Wanting to be a good member of the list, I attempted to put weekly > increments on the Nile data so I could reproduce the x axis of the chart > with the axis scale that I am seeing. Unfortunately, in doing so I got > another error that I don't understand. > > > > library(strucchange) > library(lubridate) > library(xts) > > # example from R-Blog runs fine > data(???Nile???) > plot(Nile) > bp.nile <- breakpoints(Nile ~ 1) > ci.nile <- confint(bp.nile, breaks = 1) > lines(ci.nile) > > #problem comes in here > dfNile<-data.frame(Nile) > dfNile$week<-seq(ymd('2012-01-01'),ymd('2013-11-30'),by='weeks') > tsNile<-as.xts(x=dfNile[,-2],order.by=dfNile$week) > > Error in xts(x.mat, order.by = order.by, frequency = frequency(x), ...) : > formal argument "order.by" matched by multiple actual arguments > > > Can somebody help me to put together the ts object with weeks so that I can > demonstrate the problem with the scale on the x-axis and then try to get some > help with that original problem? > > Much appreciated. > --John Sparks > > > > > > > > >[[alternative HTML version deleted]] > > [[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] strucchange Graph By Week and xts error
On Thu, 7 Mar 2019, Sparks, John wrote: Hi R Helpers, I am doing some work at identifying change points in time series data. A very nice example is given in the R Bloggers post https://www.r-bloggers.com/a-look-at-strucchange-and-segmented/ The data for the aswan dam in that example is yearly. My data is weekly. I ran the code switching the data for the analysis to my data and it worked, but the scale of the line chart is not sensible. I have 225 weekly observations and the x-axis of the line graph shows numbers from 0 to over 1500. The information on the ts object is Unfortunately, breakpoints() can only deal automatically with "ts" time series not with zoo/xts/... So either you can squeeze your data onto a regular "ts" grid which may work in the case of weekly data. Or you need to handle the time index "by hand". See https://stackoverflow.com/questions/43243548/strucchange-not-reporting-breakdates/43267082#43267082 for an example for this. As for the as.xts() error below. This is because dfNile[, -2] is still a "ts" object and then as.xts() sets up "order.by" for you. Either you use xts() rather than as.xts() or you make the first column in the data.frame "numeric" rather than "ts", e.g., by starting the transformation with: dfNile<-data.frame(as.numeric(Nile)) Start=1 End=1569 Frequency=0.1428... I can't share the data because it is proprietary. Wanting to be a good member of the list, I attempted to put weekly increments on the Nile data so I could reproduce the x axis of the chart with the axis scale that I am seeing. Unfortunately, in doing so I got another error that I don't understand. library(strucchange) library(lubridate) library(xts) # example from R-Blog runs fine data(???Nile???) plot(Nile) bp.nile <- breakpoints(Nile ~ 1) ci.nile <- confint(bp.nile, breaks = 1) lines(ci.nile) #problem comes in here dfNile<-data.frame(Nile) dfNile$week<-seq(ymd('2012-01-01'),ymd('2013-11-30'),by='weeks') tsNile<-as.xts(x=dfNile[,-2],order.by=dfNile$week) Error in xts(x.mat, order.by = order.by, frequency = frequency(x), ...) : formal argument "order.by" matched by multiple actual arguments Can somebody help me to put together the ts object with weeks so that I can demonstrate the problem with the scale on the x-axis and then try to get some help with that original problem? Much appreciated. --John Sparks [[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] strucchange Graph By Week and xts error
Hi John, You seem to have 1569 days of data, so perhaps you can get around your axis problem like this: plot(Nile,xaxt="n",xlab="Week") ... axis(1,at=seq(0,200,50),labels=seq(0,200,50)*7) (untested) Jim On Thu, Mar 7, 2019 at 10:46 AM Sparks, John wrote: > > Hi R Helpers, > > I am doing some work at identifying change points in time series data. A > very nice example is given in the R Bloggers post > > https://www.r-bloggers.com/a-look-at-strucchange-and-segmented/ > > The data for the aswan dam in that example is yearly. My data is weekly. I > ran the code switching the data for the analysis to my data and it worked, > but the scale of the line chart is not sensible. I have 225 weekly > observations and the x-axis of the line graph shows numbers from 0 to over > 1500. The information on the ts object is > > Start=1 > End=1569 > Frequency=0.1428... > > I can't share the data because it is proprietary. > > Wanting to be a good member of the list, I attempted to put weekly increments > on the Nile data so I could reproduce the x axis of the chart with the axis > scale that I am seeing. Unfortunately, in doing so I got another error that > I don't understand. > > > > library(strucchange) > library(lubridate) > library(xts) > > # example from R-Blog runs fine > data(“Nile”) > plot(Nile) > bp.nile <- breakpoints(Nile ~ 1) > ci.nile <- confint(bp.nile, breaks = 1) > lines(ci.nile) > > #problem comes in here > dfNile<-data.frame(Nile) > dfNile$week<-seq(ymd('2012-01-01'),ymd('2013-11-30'),by='weeks') > tsNile<-as.xts(x=dfNile[,-2],order.by=dfNile$week) > > Error in xts(x.mat, order.by = order.by, frequency = frequency(x), ...) : > formal argument "order.by" matched by multiple actual arguments > > > Can somebody help me to put together the ts object with weeks so that I can > demonstrate the problem with the scale on the x-axis and then try to get some > help with that original problem? > > Much appreciated. > --John Sparks > > > > > > > > > [[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] Unable to install ggplot2
rlang works with R 3.1 and up, but it does require compilation from source, which I suspect is the root cause of this problem. Hadley On Wed, Mar 6, 2019 at 5:36 PM peter dalgaard wrote: > > Also, R seems to be version 3.2.x i.e. 3-4 years old. Earliest rlang is anno > 2017 as far as I can tell. > > -pd > > > On 6 Mar 2019, at 19:22 , Norberto Hernandez > > wrote: > > > > I have the same issue with ggplot2 and the rlang package, you need to > > have the most updated version of the rlang library in order to get > > installed ggplot2 > > > > Regards > > Norberto > > > > El mar., 5 mar. 2019 a las 14:24, Jeff Newmiller > > () escribió: > >> > >> Please post the text version of the error in the future... your picture is > >> almost unreadable. Also, if it is actually important that you are using > >> RStudio then your question probably doesn't belong here. Also, if the > >> problem is a faulty contributed package then you will need to contact the > >> package maintainer as the Posting Guide mentioned below says. > >> > >> I don't know why the dependency is not being handled correctly, but my > >> suggestion would be to install the rlang package first, and once that is > >> installed try installing ggplot2. Read the errors... it says there is a > >> problem with the rlang package. > >> > >> On March 5, 2019 10:04:41 AM PST, Kamalika Ray > >> wrote: > >>> Hi, > >>> I have been trying to install the ggplot2 package but I am unable to do > >>> so. My Mac OS version is 10.7.4 and I have downloaded the > >>> R-Studio-1.1.463. > >>> I have attached the screenshot of the error message which appears. > >>> > >>> Please help! > >>> > >>> Thank you, > >>> Kamalika > >>> India > >> > >> -- > >> 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-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. > > -- > Peter Dalgaard, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Office: A 4.23 > Email: pd@cbs.dk Priv: pda...@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. -- http://hadley.nz __ 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] strucchange Graph By Week and xts error
Hi R Helpers, I am doing some work at identifying change points in time series data. A very nice example is given in the R Bloggers post https://www.r-bloggers.com/a-look-at-strucchange-and-segmented/ The data for the aswan dam in that example is yearly. My data is weekly. I ran the code switching the data for the analysis to my data and it worked, but the scale of the line chart is not sensible. I have 225 weekly observations and the x-axis of the line graph shows numbers from 0 to over 1500. The information on the ts object is Start=1 End=1569 Frequency=0.1428... I can't share the data because it is proprietary. Wanting to be a good member of the list, I attempted to put weekly increments on the Nile data so I could reproduce the x axis of the chart with the axis scale that I am seeing. Unfortunately, in doing so I got another error that I don't understand. library(strucchange) library(lubridate) library(xts) # example from R-Blog runs fine data(�Nile�) plot(Nile) bp.nile <- breakpoints(Nile ~ 1) ci.nile <- confint(bp.nile, breaks = 1) lines(ci.nile) #problem comes in here dfNile<-data.frame(Nile) dfNile$week<-seq(ymd('2012-01-01'),ymd('2013-11-30'),by='weeks') tsNile<-as.xts(x=dfNile[,-2],order.by=dfNile$week) Error in xts(x.mat, order.by = order.by, frequency = frequency(x), ...) : formal argument "order.by" matched by multiple actual arguments Can somebody help me to put together the ts object with weeks so that I can demonstrate the problem with the scale on the x-axis and then try to get some help with that original problem? Much appreciated. --John Sparks [[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] Unable to install ggplot2
Also, R seems to be version 3.2.x i.e. 3-4 years old. Earliest rlang is anno 2017 as far as I can tell. -pd > On 6 Mar 2019, at 19:22 , Norberto Hernandez > wrote: > > I have the same issue with ggplot2 and the rlang package, you need to > have the most updated version of the rlang library in order to get > installed ggplot2 > > Regards > Norberto > > El mar., 5 mar. 2019 a las 14:24, Jeff Newmiller > () escribió: >> >> Please post the text version of the error in the future... your picture is >> almost unreadable. Also, if it is actually important that you are using >> RStudio then your question probably doesn't belong here. Also, if the >> problem is a faulty contributed package then you will need to contact the >> package maintainer as the Posting Guide mentioned below says. >> >> I don't know why the dependency is not being handled correctly, but my >> suggestion would be to install the rlang package first, and once that is >> installed try installing ggplot2. Read the errors... it says there is a >> problem with the rlang package. >> >> On March 5, 2019 10:04:41 AM PST, Kamalika Ray >> wrote: >>> Hi, >>> I have been trying to install the ggplot2 package but I am unable to do >>> so. My Mac OS version is 10.7.4 and I have downloaded the >>> R-Studio-1.1.463. >>> I have attached the screenshot of the error message which appears. >>> >>> Please help! >>> >>> Thank you, >>> Kamalika >>> India >> >> -- >> 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-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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@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] Zoom In/Out maps library
Also, I forgot that tmap can do interactive maps, see: https://geocompr.robinlovelace.net/adv-map.html#interactive-maps -Roy > On Mar 6, 2019, at 2:48 PM, Roy Mendelssohn - NOAA Federal > wrote: > > see https://r-spatial.github.io/mapview/index.html > > The main thing is the data types that map view supports, so you must have a > raster or an spatial object like an "sf" object. So points would have to > also be an sf object and the two combined (sf has commands to do this) or > perhaps you can do ti directly in mapview, I haven't played with it much. > > The plotly example I sent works with ggplot2, so if you know how to build up > the map in ggplot2 you can try that, though again as far as I can see plotly > for maps needs sf objects. > > Mainly sent you the links to get you started. I haven't played with either > much, just know that they exist and zoom maps. > > HTH, > > -Roy > >> On Mar 6, 2019, at 2:36 PM, >> wrote: >> >> Roy >> >> Thank you - that's helpful. Going to have to read up on sf and mapview >> library. Those are new ones. Then to add a point feature layer (lat/long) >> where would I insert that? >> >> Library(maps) >> Library(sf) # simple features >> Library(mapview) >> >> world.map <- maps::map("world", plot = FALSE, fill = TRUE) >> p <- sf::st_as_sf(world.map, coords = c('x', 'y')) >> mapview::mapview(p, legend=FALSE) >> >> >> >> -Original Message- >> From: rmendelss gmail >> Sent: Wednesday, March 6, 2019 4:11 PM >> To: reichm...@sbcglobal.net >> Cc: R help Mailing list >> Subject: Re: [R] Zoom In/Out maps library >> >> world.map <- maps::map("world", plot = FALSE, fill = TRUE) p <- sf:: >> st_as_sf(world.map, coords = c('x', 'y')) map view::map view(p) >> >> HTH, >> >> -Roy >> >>> On Mar 6, 2019, at 1:44 PM, reichm...@sbcglobal.net wrote: >>> >>> R Help >>> >>> Anyone know if I can add a zoom In/Out function to the maps available via >> the "maps" library? Or do I need to use a different mapping library? >>> >>> world.map <- map_data("world") >>> >>> ggplot(data = world.map) + >>> geom_polygon(mapping = aes(x=long, y=lat, group=group)) >>> >>> Jeff >>> >>> __ >>> 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. > > > > ** > "The contents of this message do not reflect any position of the U.S. > Government or NOAA." > ** > Roy Mendelssohn > Supervisory Operations Research Analyst > NOAA/NMFS > Environmental Research Division > Southwest Fisheries Science Center > ***Note new street address*** > 110 McAllister Way > Santa Cruz, CA 95060 > Phone: (831)-420-3666 > Fax: (831) 420-3980 > e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ > > "Old age and treachery will overcome youth and skill." > "From those who have been given much, much will be expected" > "the arc of the moral universe is long, but it bends toward justice" -MLK Jr. > ** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new street address*** 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr. __ 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] Zoom In/Out maps library
see https://r-spatial.github.io/mapview/index.html The main thing is the data types that map view supports, so you must have a raster or an spatial object like an "sf" object. So points would have to also be an sf object and the two combined (sf has commands to do this) or perhaps you can do ti directly in mapview, I haven't played with it much. The plotly example I sent works with ggplot2, so if you know how to build up the map in ggplot2 you can try that, though again as far as I can see plotly for maps needs sf objects. Mainly sent you the links to get you started. I haven't played with either much, just know that they exist and zoom maps. HTH, -Roy > On Mar 6, 2019, at 2:36 PM, > wrote: > > Roy > > Thank you - that's helpful. Going to have to read up on sf and mapview > library. Those are new ones. Then to add a point feature layer (lat/long) > where would I insert that? > > Library(maps) > Library(sf) # simple features > Library(mapview) > > world.map <- maps::map("world", plot = FALSE, fill = TRUE) > p <- sf::st_as_sf(world.map, coords = c('x', 'y')) > mapview::mapview(p, legend=FALSE) > > > > -Original Message- > From: rmendelss gmail > Sent: Wednesday, March 6, 2019 4:11 PM > To: reichm...@sbcglobal.net > Cc: R help Mailing list > Subject: Re: [R] Zoom In/Out maps library > > world.map <- maps::map("world", plot = FALSE, fill = TRUE) p <- sf:: > st_as_sf(world.map, coords = c('x', 'y')) map view::map view(p) > > HTH, > > -Roy > >> On Mar 6, 2019, at 1:44 PM, reichm...@sbcglobal.net wrote: >> >> R Help >> >> Anyone know if I can add a zoom In/Out function to the maps available via > the "maps" library? Or do I need to use a different mapping library? >> >> world.map <- map_data("world") >> >> ggplot(data = world.map) + >> geom_polygon(mapping = aes(x=long, y=lat, group=group)) >> >> Jeff >> >> __ >> 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. ** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new street address*** 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr. __ 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] Zoom In/Out maps library
Roy Thank you - that's helpful. Going to have to read up on sf and mapview library. Those are new ones. Then to add a point feature layer (lat/long) where would I insert that? Library(maps) Library(sf) # simple features Library(mapview) world.map <- maps::map("world", plot = FALSE, fill = TRUE) p <- sf::st_as_sf(world.map, coords = c('x', 'y')) mapview::mapview(p, legend=FALSE) -Original Message- From: rmendelss gmail Sent: Wednesday, March 6, 2019 4:11 PM To: reichm...@sbcglobal.net Cc: R help Mailing list Subject: Re: [R] Zoom In/Out maps library world.map <- maps::map("world", plot = FALSE, fill = TRUE) p <- sf:: st_as_sf(world.map, coords = c('x', 'y')) map view::map view(p) HTH, -Roy > On Mar 6, 2019, at 1:44 PM, reichm...@sbcglobal.net wrote: > > R Help > > Anyone know if I can add a zoom In/Out function to the maps available via the "maps" library? Or do I need to use a different mapping library? > > world.map <- map_data("world") > > ggplot(data = world.map) + > geom_polygon(mapping = aes(x=long, y=lat, group=group)) > > Jeff > > __ > 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] Zoom In/Out maps library
Or if you prefer plotly: world.map <- maps::map("world", plot = FALSE, fill = TRUE) p <- sf:: st_as_sf(world.map, coords = c('x', 'y')) plotly::ggplotly( ggplot2::ggplot(data = p) + ggplot2::geom_sf() ) > On Mar 6, 2019, at 2:12 PM, Roy Mendelssohn - NOAA Federal > wrote: > > world.map <- maps::map("world", plot = FALSE, fill = TRUE) > p <- sf:: st_as_sf(world.map, coords = c('x', 'y')) > map view::map view(p) > > > HTH, > > -Roy >> On Mar 6, 2019, at 2:10 PM, rmendelss gmail wrote: >> >> world.map <- maps::map("world", plot = FALSE, fill = TRUE) >> p <- sf:: st_as_sf(world.map, coords = c('x', 'y')) >> map view::map view(p) >> >> HTH, >> >> -Roy >> >>> On Mar 6, 2019, at 1:44 PM, reichm...@sbcglobal.net wrote: >>> >>> R Help >>> >>> Anyone know if I can add a zoom In/Out function to the maps available via >>> the "maps" library? Or do I need to use a different mapping library? >>> >>> world.map <- map_data("world") >>> >>> ggplot(data = world.map) + >>> geom_polygon(mapping = aes(x=long, y=lat, group=group)) >>> >>> Jeff >>> >>> __ >>> 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. >> > > ** > "The contents of this message do not reflect any position of the U.S. > Government or NOAA." > ** > Roy Mendelssohn > Supervisory Operations Research Analyst > NOAA/NMFS > Environmental Research Division > Southwest Fisheries Science Center > ***Note new street address*** > 110 McAllister Way > Santa Cruz, CA 95060 > Phone: (831)-420-3666 > Fax: (831) 420-3980 > e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ > > "Old age and treachery will overcome youth and skill." > "From those who have been given much, much will be expected" > "the arc of the moral universe is long, but it bends toward justice" -MLK Jr. > ** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new street address*** 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr. __ 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] Zoom In/Out maps library
world.map <- maps::map("world", plot = FALSE, fill = TRUE) p <- sf:: st_as_sf(world.map, coords = c('x', 'y')) map view::map view(p) HTH, -Roy > On Mar 6, 2019, at 2:10 PM, rmendelss gmail wrote: > > world.map <- maps::map("world", plot = FALSE, fill = TRUE) > p <- sf:: st_as_sf(world.map, coords = c('x', 'y')) > map view::map view(p) > > HTH, > > -Roy > >> On Mar 6, 2019, at 1:44 PM, reichm...@sbcglobal.net wrote: >> >> R Help >> >> Anyone know if I can add a zoom In/Out function to the maps available via >> the "maps" library? Or do I need to use a different mapping library? >> >> world.map <- map_data("world") >> >> ggplot(data = world.map) + >> geom_polygon(mapping = aes(x=long, y=lat, group=group)) >> >> Jeff >> >> __ >> 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. > ** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new street address*** 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr. __ 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] Zoom In/Out maps library
R Help Anyone know if I can add a zoom In/Out function to the maps available via the "maps" library? Or do I need to use a different mapping library? world.map <- map_data("world") ggplot(data = world.map) + geom_polygon(mapping = aes(x=long, y=lat, group=group)) Jeff __ 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] Unable to install ggplot2
I have the same issue with ggplot2 and the rlang package, you need to have the most updated version of the rlang library in order to get installed ggplot2 Regards Norberto El mar., 5 mar. 2019 a las 14:24, Jeff Newmiller () escribió: > > Please post the text version of the error in the future... your picture is > almost unreadable. Also, if it is actually important that you are using > RStudio then your question probably doesn't belong here. Also, if the problem > is a faulty contributed package then you will need to contact the package > maintainer as the Posting Guide mentioned below says. > > I don't know why the dependency is not being handled correctly, but my > suggestion would be to install the rlang package first, and once that is > installed try installing ggplot2. Read the errors... it says there is a > problem with the rlang package. > > On March 5, 2019 10:04:41 AM PST, Kamalika Ray > wrote: > >Hi, > >I have been trying to install the ggplot2 package but I am unable to do > >so. My Mac OS version is 10.7.4 and I have downloaded the > >R-Studio-1.1.463. > >I have attached the screenshot of the error message which appears. > > > >Please help! > > > >Thank you, > >Kamalika > >India > > -- > 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-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] Fw: inconsistency in nls output....
nls() is a Model T Ford trying to drive on the Interstate. The code is quite old and uses approximations that work well when the user provides a reasonable problem, but in cases where there are mixed large and small numbers like yours could get into trouble. Duncan Murdoch and I prepared the nlsr package to address some of the weaknesses (in particular we try to use analytic derivatives). The output of nlsr also gives the singular values of the Jacobian, though I suspect many R users will have to do some work to interpret those. You haven't provided a reproducible example. That's almost always the way to get definitive answers. Otherwise we're guessing as to the issue. JN On 2019-03-06 7:48 a.m., akshay kulkarni wrote: > dear members, > with reference to the attached message: > > I think I have found out the problem: > YLf13 has the structure: > YLf13 <- a*exp(-1000*LM1); LM1 is another vector. > > most of the YLf13 vector is getting populated with zeros, I think, because of > the very low value of exp(-1000*LM1). Is there any method in R wherein I can > work with these very low values? > > Or is the problem not related to the structure of YLf13? > > very many thanks for your time and effort... > yours sincerely, > AKSHAY M KULKARNI > > > > From: R-help on behalf of akshay kulkarni > > Sent: Wednesday, March 6, 2019 6:02 PM > To: R help Mailing list > Subject: [R] inconsistency in nls output > > dear members, > I have the following nls output: > > Formula: YLf13 ~ (d + e * ((XL)^(1/3)) + f * log(LM3 + 18.81)) > > Parameters: > Estimate Std. Error t value Pr(>|t|) > d 5.892e-09 8.644e-10 6.817 2.06e-11 *** > e -6.585e-09 5.518e-10 -11.934 < 2e-16 *** > f 1.850e-10 2.295e-10 0.806 0.42 > --- > Signif. codes: 0 �***� 0.001 �**� 0.01 �*� 0.05 �.� 0.1 � � 1 > > Residual standard error: 9.57e-10 on 677 degrees of freedom > > Number of iterations to convergence: 2 > Achieved convergence tolerance: 3.973e-08 > > -- > Residual sum of squares: 6.2e-16 > > -- > t-based confidence interval: >2.5% 97.5% > d 4.195378e-09 7.589714e-09 > e -7.668142e-09 -5.501342e-09 > f -2.655647e-10 6.354852e-10 > > -- > Correlation matrix: >d e f > d 1.000 -6.202339e-01 -7.832539e-01 > e -0.6202339 1.00e+00 -2.127301e-05 > f -0.7832539 -2.127301e-05 1.00e+00 > > > if I let XL = 1.1070513 and LM3 = 0.3919 , and consider the coeffs as given > above, the right hand side of the above equation is negative. > But YLf13 is always positive! How is this possible? Am I interpreting the > result of the nls output properly? Should I interpret the coeffs > differently? I have done hours of thinking over the above problem but > couldn't find any results... > > I cannot provide the full values of YLf13, XL and LM3 due to IPR > issuesplease cooperate..however, if the only way to solve the problem > is to give these values, I would indeed give them. > > Also forgive me if there is a minor mistake in my calculations... or a > typo > > very many thanks for your time and effort > yours sincerely, > AKSHAY M KULKARNI > > [[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] Benjamini-Hochberg (BH) Q value (false discovery rate)
R is open source so you can look at the code. In this case just typing the function name gets it: > p.adjust function (p, method = p.adjust.methods, n = length(p)) { method <- match.arg(method) if (method == "fdr") method <- "BH" . . . . . Stuff deleted . . . . # The code for Benjamini and Hochberg: }, BH = { i <- lp:1L o <- order(p, decreasing = TRUE) ro <- order(o) pmin(1, cummin(n/i * p[o]))[ro] # A quick example p <- c(0.7723, 0.1992, 0.1821, 0.6947, 0.0932, 0.1484, 0.0006, 0.0004) round(p.adjust(p, method="BH"), 4) # [1] 0.7723 0.2656 0.2656 0.7723 0.2485 0.2656 0.0024 0.0024 n <- length(p) i <- n:1L o <- order(p, decreasing=TRUE)# Order from largest to smallest ro <- order(o) # Reverse the ordering to return the adjusted values pmin(1, cummin(n/i * p[o]))[ro] # Compute the adjusted value The adjustment orders the p-values from largest to smallest and multiplies them by n/i, in this case > n/i [1] 1.00 1.142857 1.33 1.60 2.00 2.67 4.00 8.00 So the largest is multiplied by 1 and the smallest by 8. Then cummin() takes the cumulative minimum so that the multiplication does not change the decreasing order of the values. In this example the last value is the same as the second to last instead of 8 times the original value (.0032). The pmin() function ensures that the adjusted value never exceeds 1. David L Carlson Department of Anthropology Texas A University College Station, TX 77843-4352 -Original Message- From: R-help On Behalf Of David Bars Sent: Wednesday, March 6, 2019 3:16 AM To: r-help@r-project.org Subject: [R] Benjamini-Hochberg (BH) Q value (false discovery rate) Dear everybody, I'm using stats package (version 3.5.2) and in detail their p.adjust() function in order to control the false discovery rate in multiple comparisons. In particular I used the Benjamini-Hochberg method. Nevertheless, the help of the stats package indicates that the adjusting method is based on: Benjamini, Y., and Hochberg, Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society Series B, 57, 289–300. http://www.jstor.org/stable/2346101. But, in the function mentioned above (p.adjust()) there are no possibiity to define the Q value (the false discovery rate). I understand that the Q value is calculated automatically but through which method??? For example, in another package (sgof v.2.3 also deposited on CRAN) indicates that the the false discovery rate is estimated by the method developed by: Dalmasso C, Broet P and Moreau T (2005). A simple procedure for estimating the false discovery rate. *Bioinformatics* 21:660--668. Many thanks for your help, David Bars. [[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-es] Crear una variable tipo factor a partir de un vector de caracteres
Gracias On Wed, 6 Mar 2019 at 15:47, Xavier-Andoni Tibau Alberdi < xaviti...@gmail.com> wrote: > Pues ahí lo tienes. Usa %in% para ver si esta en ese grupo, y en caso de > estarlo pones el nombre del grupo. Aquí un ejemplo. > https://www.datamentor.io/r-programming/ifelse-function/ > > Saludos, > > Xavi > > Missatge de Antonio Rodriguez Andres > del dia dc., 6 de març 2019 a les 15:44: > >> Si lo que quiero es crear una variable llamada por ejemplo region (del >> tipo factor) con esos 5 valores >> >> On Wed, 6 Mar 2019 at 15:41, Xavier-Andoni Tibau Alberdi < >> xaviti...@gmail.com> wrote: >> >>> No, No. Fíjate en el Ifelse(condición, valor si positivo, valor si >>> negativo). >>> >>> Si, x %in% ca entonces el valor devuelto es "ca", un factor. En caso >>> negativo, vamos al siguiente bloque iflese, que comprueba si el país esta >>> en el siguiente grupo, na. Si está en na nos devuelve "na". Vamos, que la >>> función mira en que grupo esta ese país y te devuelve una string, >>> correspondiente al país. Así que ahora tienes un factor, con 5 posibles >>> valores ("ca", "na", ..., "ea"). Es lo que quieres no? >>> >>> Xavier Tibau >>> >>> Missatge de Antonio Rodriguez Andres >>> del dia dc., 6 de març 2019 a les 15:34: >>> Pero eso es para crear variables binarias tipo 0-1 si el pais pertence a un determinado grupo. Lo que quiero es crear una variable de tipo factor con esos 5 niveles, sabiendo que tengo en el dataframe una variable llamada Country, con el nombre del pais. Gracias On Wed, 6 Mar 2019 at 15:27, Xavier-Andoni Tibau Alberdi < xaviti...@gmail.com> wrote: > Buenas, > > Para ello yo uso el operador %in%, que me dice si algo esta dentro de > un vector. Luego hago bucles de if else, pero usando la función iflese(). > Si país X esta en países lista ca, entonces "ca",etc. Puedes crear una > función que englobe ese iflese(), para aplicarla para cada columna del > dataframe. > > Algo así como: > > func1 <- func (x) {ifelse(x %in% ca, "ca", ifelse(x %in% na,"na", ..., > ifelse(x %in% ea, "ea", "otros"))...)} > > espero que te sirva! > > Xavier Tibau > > > > Missatge de Antonio Rodriguez Andres < > antoniorodriguezandre...@gmail.com> del dia dc., 6 de març 2019 a les > 15:10: > >> Hola estimados miembros de la comunidad de R >> >> Tengo un conjunto de datos, donde tengo observaciones por países y >> por año. >> Una de las variables del dataframe es el nombre del país. Queremos >> dividir >> los países, que son países africanos de acuerdo a 5 regiones: norte de >> africa, africa del este, sur africa, etc >> >> Yo lo que he hecho ha sido crear vectores con el nombre de cada uno >> de los >> países en cada uno de ellos, por ejemplo este de Africa Central, >> >> ca <- c("Angola", "Cameroon", "Cabo Verde", "Central African >> Republic", >> "Chad","Equatorial Guinea", "Eritrea", "Ethiopia", >> "Gabon", "Sao Tome and Principe") >> class(ca) >> character >> >> luego hice un ifelse para crear una variable binaria 1 si es pais de >> Central Africa y cero sino lo es >> >> afdata$Country.centralafrica <- ifelse(afdata$Country %in% ca,1,0) >> >> Sin embargo, para el análisis podría ser más interesante crear una >> variable >> nueva por ejemplo region y tratarla como factor,. Mi pregunta es como >> podria pasar esos 5 vectores con el nombre de los paises de cada >> region a >> una sola variable tratada como un factor y con esos 5 niveles ( 5 >> regiones). Lo que he tratado es de hacer esto para genera una nueva >> variable en el dataframe, pero me da que todo es igual false, en el >> valor, >> >> afdata$region <- with(afdata,{ >> (Country == "ca" |Country == "na" | Country == "sa" | Country == >> "wa" | >> Country == "ea") >> }) >> Debo de indicar otra condición? >> >> Agradezco alguna pista >> >> -- >> >> Member, Editorial Committee, *The Economic and Labour Relations >> Review* (a >> SAGE journal) >> >> http://elr.sagepub.com/ >> >> Member, Editorial Committee, African Journal of Economic and >> Management >> Studies >> >> >> http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems >> >> https://www.researchgate.net/profile/Antonio_Andres (Research Gate >> profile) >> >> [[alternative HTML version deleted]] >> >> ___ >> R-help-es mailing list >> R-help-es@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-help-es >> > -- Member, Editorial Committee, *The Economic and Labour Relations Review* (a SAGE journal) http://elr.sagepub.com/ Member, Editorial Committee, African
Re: [R-es] Crear una variable tipo factor a partir de un vector de caracteres
Si lo que quiero es crear una variable llamada por ejemplo region (del tipo factor) con esos 5 valores On Wed, 6 Mar 2019 at 15:41, Xavier-Andoni Tibau Alberdi < xaviti...@gmail.com> wrote: > No, No. Fíjate en el Ifelse(condición, valor si positivo, valor si > negativo). > > Si, x %in% ca entonces el valor devuelto es "ca", un factor. En caso > negativo, vamos al siguiente bloque iflese, que comprueba si el país esta > en el siguiente grupo, na. Si está en na nos devuelve "na". Vamos, que la > función mira en que grupo esta ese país y te devuelve una string, > correspondiente al país. Así que ahora tienes un factor, con 5 posibles > valores ("ca", "na", ..., "ea"). Es lo que quieres no? > > Xavier Tibau > > Missatge de Antonio Rodriguez Andres > del dia dc., 6 de març 2019 a les 15:34: > >> Pero eso es para crear variables binarias tipo 0-1 si el pais pertence a >> un determinado grupo. Lo que quiero es crear una variable de tipo factor >> con esos 5 niveles, sabiendo que tengo en el dataframe una variable llamada >> Country, con el nombre del pais. >> Gracias >> >> On Wed, 6 Mar 2019 at 15:27, Xavier-Andoni Tibau Alberdi < >> xaviti...@gmail.com> wrote: >> >>> Buenas, >>> >>> Para ello yo uso el operador %in%, que me dice si algo esta dentro de un >>> vector. Luego hago bucles de if else, pero usando la función iflese(). Si >>> país X esta en países lista ca, entonces "ca",etc. Puedes crear una función >>> que englobe ese iflese(), para aplicarla para cada columna del dataframe. >>> >>> Algo así como: >>> >>> func1 <- func (x) {ifelse(x %in% ca, "ca", ifelse(x %in% na,"na", ..., >>> ifelse(x %in% ea, "ea", "otros"))...)} >>> >>> espero que te sirva! >>> >>> Xavier Tibau >>> >>> >>> >>> Missatge de Antonio Rodriguez Andres >>> del dia dc., 6 de març 2019 a les 15:10: >>> Hola estimados miembros de la comunidad de R Tengo un conjunto de datos, donde tengo observaciones por países y por año. Una de las variables del dataframe es el nombre del país. Queremos dividir los países, que son países africanos de acuerdo a 5 regiones: norte de africa, africa del este, sur africa, etc Yo lo que he hecho ha sido crear vectores con el nombre de cada uno de los países en cada uno de ellos, por ejemplo este de Africa Central, ca <- c("Angola", "Cameroon", "Cabo Verde", "Central African Republic", "Chad","Equatorial Guinea", "Eritrea", "Ethiopia", "Gabon", "Sao Tome and Principe") class(ca) character luego hice un ifelse para crear una variable binaria 1 si es pais de Central Africa y cero sino lo es afdata$Country.centralafrica <- ifelse(afdata$Country %in% ca,1,0) Sin embargo, para el análisis podría ser más interesante crear una variable nueva por ejemplo region y tratarla como factor,. Mi pregunta es como podria pasar esos 5 vectores con el nombre de los paises de cada region a una sola variable tratada como un factor y con esos 5 niveles ( 5 regiones). Lo que he tratado es de hacer esto para genera una nueva variable en el dataframe, pero me da que todo es igual false, en el valor, afdata$region <- with(afdata,{ (Country == "ca" |Country == "na" | Country == "sa" | Country == "wa" | Country == "ea") }) Debo de indicar otra condición? Agradezco alguna pista -- Member, Editorial Committee, *The Economic and Labour Relations Review* (a SAGE journal) http://elr.sagepub.com/ Member, Editorial Committee, African Journal of Economic and Management Studies http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems https://www.researchgate.net/profile/Antonio_Andres (Research Gate profile) [[alternative HTML version deleted]] ___ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es >>> >> >> -- >> >> Member, Editorial Committee, *The Economic and Labour Relations Review* (a >> SAGE journal) >> >> http://elr.sagepub.com/ >> >> Member, Editorial Committee, African Journal of Economic and Management >> Studies >> >> >> http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems >> >> https://www.researchgate.net/profile/Antonio_Andres (Research Gate >> profile) >> >> >> -- Member, Editorial Committee, *The Economic and Labour Relations Review* (a SAGE journal) http://elr.sagepub.com/ Member, Editorial Committee, African Journal of Economic and Management Studies http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems https://www.researchgate.net/profile/Antonio_Andres (Research Gate profile) [[alternative HTML version deleted]] ___ R-help-es mailing list
Re: [R-es] Crear una variable tipo factor a partir de un vector de caracteres
Con R base: paises <- factor(c("a", "b", "c", "c", "a")) zonas <- c("norte", "norte", "sur") names(zonas) <- c("a", "b", "c") zonas_paises <- paises levels(zonas_paises) <- zonas[levels(zonas_paises)] zonas_paises Un saludo, Carlos J. Gil Bellosta http://www.datanalytics.com El mié., 6 mar. 2019 a las 15:41, Xavier-Andoni Tibau Alberdi (< xaviti...@gmail.com>) escribió: > No, No. Fíjate en el Ifelse(condición, valor si positivo, valor si > negativo). > > Si, x %in% ca entonces el valor devuelto es "ca", un factor. En caso > negativo, vamos al siguiente bloque iflese, que comprueba si el país esta > en el siguiente grupo, na. Si está en na nos devuelve "na". Vamos, que la > función mira en que grupo esta ese país y te devuelve una string, > correspondiente al país. Así que ahora tienes un factor, con 5 posibles > valores ("ca", "na", ..., "ea"). Es lo que quieres no? > > Xavier Tibau > > Missatge de Antonio Rodriguez Andres > del dia dc., 6 de març 2019 a les 15:34: > > > Pero eso es para crear variables binarias tipo 0-1 si el pais pertence a > > un determinado grupo. Lo que quiero es crear una variable de tipo factor > > con esos 5 niveles, sabiendo que tengo en el dataframe una variable > llamada > > Country, con el nombre del pais. > > Gracias > > > > On Wed, 6 Mar 2019 at 15:27, Xavier-Andoni Tibau Alberdi < > > xaviti...@gmail.com> wrote: > > > >> Buenas, > >> > >> Para ello yo uso el operador %in%, que me dice si algo esta dentro de un > >> vector. Luego hago bucles de if else, pero usando la función iflese(). > Si > >> país X esta en países lista ca, entonces "ca",etc. Puedes crear una > función > >> que englobe ese iflese(), para aplicarla para cada columna del > dataframe. > >> > >> Algo así como: > >> > >> func1 <- func (x) {ifelse(x %in% ca, "ca", ifelse(x %in% na,"na", ..., > >> ifelse(x %in% ea, "ea", "otros"))...)} > >> > >> espero que te sirva! > >> > >> Xavier Tibau > >> > >> > >> > >> Missatge de Antonio Rodriguez Andres < > antoniorodriguezandre...@gmail.com> > >> del dia dc., 6 de març 2019 a les 15:10: > >> > >>> Hola estimados miembros de la comunidad de R > >>> > >>> Tengo un conjunto de datos, donde tengo observaciones por países y por > >>> año. > >>> Una de las variables del dataframe es el nombre del país. Queremos > >>> dividir > >>> los países, que son países africanos de acuerdo a 5 regiones: norte de > >>> africa, africa del este, sur africa, etc > >>> > >>> Yo lo que he hecho ha sido crear vectores con el nombre de cada uno de > >>> los > >>> países en cada uno de ellos, por ejemplo este de Africa Central, > >>> > >>> ca <- c("Angola", "Cameroon", "Cabo Verde", "Central African Republic", > >>> "Chad","Equatorial Guinea", "Eritrea", "Ethiopia", > >>> "Gabon", "Sao Tome and Principe") > >>> class(ca) > >>> character > >>> > >>> luego hice un ifelse para crear una variable binaria 1 si es pais de > >>> Central Africa y cero sino lo es > >>> > >>> afdata$Country.centralafrica <- ifelse(afdata$Country %in% ca,1,0) > >>> > >>> Sin embargo, para el análisis podría ser más interesante crear una > >>> variable > >>> nueva por ejemplo region y tratarla como factor,. Mi pregunta es como > >>> podria pasar esos 5 vectores con el nombre de los paises de cada > region a > >>> una sola variable tratada como un factor y con esos 5 niveles ( 5 > >>> regiones). Lo que he tratado es de hacer esto para genera una nueva > >>> variable en el dataframe, pero me da que todo es igual false, en el > >>> valor, > >>> > >>> afdata$region <- with(afdata,{ > >>> (Country == "ca" |Country == "na" | Country == "sa" | Country == > "wa" | > >>> Country == "ea") > >>> }) > >>> Debo de indicar otra condición? > >>> > >>> Agradezco alguna pista > >>> > >>> -- > >>> > >>> Member, Editorial Committee, *The Economic and Labour Relations Review* > >>> (a > >>> SAGE journal) > >>> > >>> http://elr.sagepub.com/ > >>> > >>> Member, Editorial Committee, African Journal of Economic and Management > >>> Studies > >>> > >>> > >>> > http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems > >>> > >>> https://www.researchgate.net/profile/Antonio_Andres (Research Gate > >>> profile) > >>> > >>> [[alternative HTML version deleted]] > >>> > >>> ___ > >>> R-help-es mailing list > >>> R-help-es@r-project.org > >>> https://stat.ethz.ch/mailman/listinfo/r-help-es > >>> > >> > > > > -- > > > > Member, Editorial Committee, *The Economic and Labour Relations Review* > (a > > SAGE journal) > > > > http://elr.sagepub.com/ > > > > Member, Editorial Committee, African Journal of Economic and Management > > Studies > > > > > > > http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems > > > > https://www.researchgate.net/profile/Antonio_Andres (Research Gate > > profile) > > > > > > > > [[alternative HTML version deleted]] > > ___ > R-help-es mailing list >
Re: [R-es] Crear una variable tipo factor a partir de un vector de caracteres
Pues ahí lo tienes. Usa %in% para ver si esta en ese grupo, y en caso de estarlo pones el nombre del grupo. Aquí un ejemplo. https://www.datamentor.io/r-programming/ifelse-function/ Saludos, Xavi Missatge de Antonio Rodriguez Andres del dia dc., 6 de març 2019 a les 15:44: > Si lo que quiero es crear una variable llamada por ejemplo region (del > tipo factor) con esos 5 valores > > On Wed, 6 Mar 2019 at 15:41, Xavier-Andoni Tibau Alberdi < > xaviti...@gmail.com> wrote: > >> No, No. Fíjate en el Ifelse(condición, valor si positivo, valor si >> negativo). >> >> Si, x %in% ca entonces el valor devuelto es "ca", un factor. En caso >> negativo, vamos al siguiente bloque iflese, que comprueba si el país esta >> en el siguiente grupo, na. Si está en na nos devuelve "na". Vamos, que la >> función mira en que grupo esta ese país y te devuelve una string, >> correspondiente al país. Así que ahora tienes un factor, con 5 posibles >> valores ("ca", "na", ..., "ea"). Es lo que quieres no? >> >> Xavier Tibau >> >> Missatge de Antonio Rodriguez Andres >> del dia dc., 6 de març 2019 a les 15:34: >> >>> Pero eso es para crear variables binarias tipo 0-1 si el pais pertence a >>> un determinado grupo. Lo que quiero es crear una variable de tipo factor >>> con esos 5 niveles, sabiendo que tengo en el dataframe una variable llamada >>> Country, con el nombre del pais. >>> Gracias >>> >>> On Wed, 6 Mar 2019 at 15:27, Xavier-Andoni Tibau Alberdi < >>> xaviti...@gmail.com> wrote: >>> Buenas, Para ello yo uso el operador %in%, que me dice si algo esta dentro de un vector. Luego hago bucles de if else, pero usando la función iflese(). Si país X esta en países lista ca, entonces "ca",etc. Puedes crear una función que englobe ese iflese(), para aplicarla para cada columna del dataframe. Algo así como: func1 <- func (x) {ifelse(x %in% ca, "ca", ifelse(x %in% na,"na", ..., ifelse(x %in% ea, "ea", "otros"))...)} espero que te sirva! Xavier Tibau Missatge de Antonio Rodriguez Andres < antoniorodriguezandre...@gmail.com> del dia dc., 6 de març 2019 a les 15:10: > Hola estimados miembros de la comunidad de R > > Tengo un conjunto de datos, donde tengo observaciones por países y por > año. > Una de las variables del dataframe es el nombre del país. Queremos > dividir > los países, que son países africanos de acuerdo a 5 regiones: norte de > africa, africa del este, sur africa, etc > > Yo lo que he hecho ha sido crear vectores con el nombre de cada uno de > los > países en cada uno de ellos, por ejemplo este de Africa Central, > > ca <- c("Angola", "Cameroon", "Cabo Verde", "Central African Republic", > "Chad","Equatorial Guinea", "Eritrea", "Ethiopia", > "Gabon", "Sao Tome and Principe") > class(ca) > character > > luego hice un ifelse para crear una variable binaria 1 si es pais de > Central Africa y cero sino lo es > > afdata$Country.centralafrica <- ifelse(afdata$Country %in% ca,1,0) > > Sin embargo, para el análisis podría ser más interesante crear una > variable > nueva por ejemplo region y tratarla como factor,. Mi pregunta es como > podria pasar esos 5 vectores con el nombre de los paises de cada > region a > una sola variable tratada como un factor y con esos 5 niveles ( 5 > regiones). Lo que he tratado es de hacer esto para genera una nueva > variable en el dataframe, pero me da que todo es igual false, en el > valor, > > afdata$region <- with(afdata,{ > (Country == "ca" |Country == "na" | Country == "sa" | Country == > "wa" | > Country == "ea") > }) > Debo de indicar otra condición? > > Agradezco alguna pista > > -- > > Member, Editorial Committee, *The Economic and Labour Relations > Review* (a > SAGE journal) > > http://elr.sagepub.com/ > > Member, Editorial Committee, African Journal of Economic and Management > Studies > > > http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems > > https://www.researchgate.net/profile/Antonio_Andres (Research Gate > profile) > > [[alternative HTML version deleted]] > > ___ > R-help-es mailing list > R-help-es@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-help-es > >>> >>> -- >>> >>> Member, Editorial Committee, *The Economic and Labour Relations Review* (a >>> SAGE journal) >>> >>> http://elr.sagepub.com/ >>> >>> Member, Editorial Committee, African Journal of Economic and Management >>> Studies >>> >>> >>> http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems >>> >>> https://www.researchgate.net/profile/Antonio_Andres (Research Gate >>> profile) >>> >>> >>> > > -- > > Member,
Re: [R-es] Crear una variable tipo factor a partir de un vector de caracteres
No, No. Fíjate en el Ifelse(condición, valor si positivo, valor si negativo). Si, x %in% ca entonces el valor devuelto es "ca", un factor. En caso negativo, vamos al siguiente bloque iflese, que comprueba si el país esta en el siguiente grupo, na. Si está en na nos devuelve "na". Vamos, que la función mira en que grupo esta ese país y te devuelve una string, correspondiente al país. Así que ahora tienes un factor, con 5 posibles valores ("ca", "na", ..., "ea"). Es lo que quieres no? Xavier Tibau Missatge de Antonio Rodriguez Andres del dia dc., 6 de març 2019 a les 15:34: > Pero eso es para crear variables binarias tipo 0-1 si el pais pertence a > un determinado grupo. Lo que quiero es crear una variable de tipo factor > con esos 5 niveles, sabiendo que tengo en el dataframe una variable llamada > Country, con el nombre del pais. > Gracias > > On Wed, 6 Mar 2019 at 15:27, Xavier-Andoni Tibau Alberdi < > xaviti...@gmail.com> wrote: > >> Buenas, >> >> Para ello yo uso el operador %in%, que me dice si algo esta dentro de un >> vector. Luego hago bucles de if else, pero usando la función iflese(). Si >> país X esta en países lista ca, entonces "ca",etc. Puedes crear una función >> que englobe ese iflese(), para aplicarla para cada columna del dataframe. >> >> Algo así como: >> >> func1 <- func (x) {ifelse(x %in% ca, "ca", ifelse(x %in% na,"na", ..., >> ifelse(x %in% ea, "ea", "otros"))...)} >> >> espero que te sirva! >> >> Xavier Tibau >> >> >> >> Missatge de Antonio Rodriguez Andres >> del dia dc., 6 de març 2019 a les 15:10: >> >>> Hola estimados miembros de la comunidad de R >>> >>> Tengo un conjunto de datos, donde tengo observaciones por países y por >>> año. >>> Una de las variables del dataframe es el nombre del país. Queremos >>> dividir >>> los países, que son países africanos de acuerdo a 5 regiones: norte de >>> africa, africa del este, sur africa, etc >>> >>> Yo lo que he hecho ha sido crear vectores con el nombre de cada uno de >>> los >>> países en cada uno de ellos, por ejemplo este de Africa Central, >>> >>> ca <- c("Angola", "Cameroon", "Cabo Verde", "Central African Republic", >>> "Chad","Equatorial Guinea", "Eritrea", "Ethiopia", >>> "Gabon", "Sao Tome and Principe") >>> class(ca) >>> character >>> >>> luego hice un ifelse para crear una variable binaria 1 si es pais de >>> Central Africa y cero sino lo es >>> >>> afdata$Country.centralafrica <- ifelse(afdata$Country %in% ca,1,0) >>> >>> Sin embargo, para el análisis podría ser más interesante crear una >>> variable >>> nueva por ejemplo region y tratarla como factor,. Mi pregunta es como >>> podria pasar esos 5 vectores con el nombre de los paises de cada region a >>> una sola variable tratada como un factor y con esos 5 niveles ( 5 >>> regiones). Lo que he tratado es de hacer esto para genera una nueva >>> variable en el dataframe, pero me da que todo es igual false, en el >>> valor, >>> >>> afdata$region <- with(afdata,{ >>> (Country == "ca" |Country == "na" | Country == "sa" | Country == "wa" | >>> Country == "ea") >>> }) >>> Debo de indicar otra condición? >>> >>> Agradezco alguna pista >>> >>> -- >>> >>> Member, Editorial Committee, *The Economic and Labour Relations Review* >>> (a >>> SAGE journal) >>> >>> http://elr.sagepub.com/ >>> >>> Member, Editorial Committee, African Journal of Economic and Management >>> Studies >>> >>> >>> http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems >>> >>> https://www.researchgate.net/profile/Antonio_Andres (Research Gate >>> profile) >>> >>> [[alternative HTML version deleted]] >>> >>> ___ >>> R-help-es mailing list >>> R-help-es@r-project.org >>> https://stat.ethz.ch/mailman/listinfo/r-help-es >>> >> > > -- > > Member, Editorial Committee, *The Economic and Labour Relations Review* (a > SAGE journal) > > http://elr.sagepub.com/ > > Member, Editorial Committee, African Journal of Economic and Management > Studies > > > http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems > > https://www.researchgate.net/profile/Antonio_Andres (Research Gate > profile) > > > [[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] Crear una variable tipo factor a partir de un vector de caracteres
Pero eso es para crear variables binarias tipo 0-1 si el pais pertence a un determinado grupo. Lo que quiero es crear una variable de tipo factor con esos 5 niveles, sabiendo que tengo en el dataframe una variable llamada Country, con el nombre del pais. Gracias On Wed, 6 Mar 2019 at 15:27, Xavier-Andoni Tibau Alberdi < xaviti...@gmail.com> wrote: > Buenas, > > Para ello yo uso el operador %in%, que me dice si algo esta dentro de un > vector. Luego hago bucles de if else, pero usando la función iflese(). Si > país X esta en países lista ca, entonces "ca",etc. Puedes crear una función > que englobe ese iflese(), para aplicarla para cada columna del dataframe. > > Algo así como: > > func1 <- func (x) {ifelse(x %in% ca, "ca", ifelse(x %in% na,"na", ..., > ifelse(x %in% ea, "ea", "otros"))...)} > > espero que te sirva! > > Xavier Tibau > > > > Missatge de Antonio Rodriguez Andres > del dia dc., 6 de març 2019 a les 15:10: > >> Hola estimados miembros de la comunidad de R >> >> Tengo un conjunto de datos, donde tengo observaciones por países y por >> año. >> Una de las variables del dataframe es el nombre del país. Queremos dividir >> los países, que son países africanos de acuerdo a 5 regiones: norte de >> africa, africa del este, sur africa, etc >> >> Yo lo que he hecho ha sido crear vectores con el nombre de cada uno de los >> países en cada uno de ellos, por ejemplo este de Africa Central, >> >> ca <- c("Angola", "Cameroon", "Cabo Verde", "Central African Republic", >> "Chad","Equatorial Guinea", "Eritrea", "Ethiopia", >> "Gabon", "Sao Tome and Principe") >> class(ca) >> character >> >> luego hice un ifelse para crear una variable binaria 1 si es pais de >> Central Africa y cero sino lo es >> >> afdata$Country.centralafrica <- ifelse(afdata$Country %in% ca,1,0) >> >> Sin embargo, para el análisis podría ser más interesante crear una >> variable >> nueva por ejemplo region y tratarla como factor,. Mi pregunta es como >> podria pasar esos 5 vectores con el nombre de los paises de cada region a >> una sola variable tratada como un factor y con esos 5 niveles ( 5 >> regiones). Lo que he tratado es de hacer esto para genera una nueva >> variable en el dataframe, pero me da que todo es igual false, en el valor, >> >> afdata$region <- with(afdata,{ >> (Country == "ca" |Country == "na" | Country == "sa" | Country == "wa" | >> Country == "ea") >> }) >> Debo de indicar otra condición? >> >> Agradezco alguna pista >> >> -- >> >> Member, Editorial Committee, *The Economic and Labour Relations Review* (a >> SAGE journal) >> >> http://elr.sagepub.com/ >> >> Member, Editorial Committee, African Journal of Economic and Management >> Studies >> >> >> http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems >> >> https://www.researchgate.net/profile/Antonio_Andres (Research Gate >> profile) >> >> [[alternative HTML version deleted]] >> >> ___ >> R-help-es mailing list >> R-help-es@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-help-es >> > -- Member, Editorial Committee, *The Economic and Labour Relations Review* (a SAGE journal) http://elr.sagepub.com/ Member, Editorial Committee, African Journal of Economic and Management Studies http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems https://www.researchgate.net/profile/Antonio_Andres (Research Gate profile) [[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] Crear una variable tipo factor a partir de un vector de caracteres
Buenas, Para ello yo uso el operador %in%, que me dice si algo esta dentro de un vector. Luego hago bucles de if else, pero usando la función iflese(). Si país X esta en países lista ca, entonces "ca",etc. Puedes crear una función que englobe ese iflese(), para aplicarla para cada columna del dataframe. Algo así como: func1 <- func (x) {ifelse(x %in% ca, "ca", ifelse(x %in% na,"na", ..., ifelse(x %in% ea, "ea", "otros"))...)} espero que te sirva! Xavier Tibau Missatge de Antonio Rodriguez Andres del dia dc., 6 de març 2019 a les 15:10: > Hola estimados miembros de la comunidad de R > > Tengo un conjunto de datos, donde tengo observaciones por países y por año. > Una de las variables del dataframe es el nombre del país. Queremos dividir > los países, que son países africanos de acuerdo a 5 regiones: norte de > africa, africa del este, sur africa, etc > > Yo lo que he hecho ha sido crear vectores con el nombre de cada uno de los > países en cada uno de ellos, por ejemplo este de Africa Central, > > ca <- c("Angola", "Cameroon", "Cabo Verde", "Central African Republic", > "Chad","Equatorial Guinea", "Eritrea", "Ethiopia", > "Gabon", "Sao Tome and Principe") > class(ca) > character > > luego hice un ifelse para crear una variable binaria 1 si es pais de > Central Africa y cero sino lo es > > afdata$Country.centralafrica <- ifelse(afdata$Country %in% ca,1,0) > > Sin embargo, para el análisis podría ser más interesante crear una variable > nueva por ejemplo region y tratarla como factor,. Mi pregunta es como > podria pasar esos 5 vectores con el nombre de los paises de cada region a > una sola variable tratada como un factor y con esos 5 niveles ( 5 > regiones). Lo que he tratado es de hacer esto para genera una nueva > variable en el dataframe, pero me da que todo es igual false, en el valor, > > afdata$region <- with(afdata,{ > (Country == "ca" |Country == "na" | Country == "sa" | Country == "wa" | > Country == "ea") > }) > Debo de indicar otra condición? > > Agradezco alguna pista > > -- > > Member, Editorial Committee, *The Economic and Labour Relations Review* (a > SAGE journal) > > http://elr.sagepub.com/ > > Member, Editorial Committee, African Journal of Economic and Management > Studies > > > http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems > > https://www.researchgate.net/profile/Antonio_Andres (Research Gate > profile) > > [[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
[R-es] Crear una variable tipo factor a partir de un vector de caracteres
Hola estimados miembros de la comunidad de R Tengo un conjunto de datos, donde tengo observaciones por países y por año. Una de las variables del dataframe es el nombre del país. Queremos dividir los países, que son países africanos de acuerdo a 5 regiones: norte de africa, africa del este, sur africa, etc Yo lo que he hecho ha sido crear vectores con el nombre de cada uno de los países en cada uno de ellos, por ejemplo este de Africa Central, ca <- c("Angola", "Cameroon", "Cabo Verde", "Central African Republic", "Chad","Equatorial Guinea", "Eritrea", "Ethiopia", "Gabon", "Sao Tome and Principe") class(ca) character luego hice un ifelse para crear una variable binaria 1 si es pais de Central Africa y cero sino lo es afdata$Country.centralafrica <- ifelse(afdata$Country %in% ca,1,0) Sin embargo, para el análisis podría ser más interesante crear una variable nueva por ejemplo region y tratarla como factor,. Mi pregunta es como podria pasar esos 5 vectores con el nombre de los paises de cada region a una sola variable tratada como un factor y con esos 5 niveles ( 5 regiones). Lo que he tratado es de hacer esto para genera una nueva variable en el dataframe, pero me da que todo es igual false, en el valor, afdata$region <- with(afdata,{ (Country == "ca" |Country == "na" | Country == "sa" | Country == "wa" | Country == "ea") }) Debo de indicar otra condición? Agradezco alguna pista -- Member, Editorial Committee, *The Economic and Labour Relations Review* (a SAGE journal) http://elr.sagepub.com/ Member, Editorial Committee, African Journal of Economic and Management Studies http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems https://www.researchgate.net/profile/Antonio_Andres (Research Gate profile) [[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] Benjamini-Hochberg (BH) Q value (false discovery rate)
Dear everybody, I'm using stats package (version 3.5.2) and in detail their p.adjust() function in order to control the false discovery rate in multiple comparisons. In particular I used the Benjamini-Hochberg method. Nevertheless, the help of the stats package indicates that the adjusting method is based on: Benjamini, Y., and Hochberg, Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society Series B, 57, 289–300. http://www.jstor.org/stable/2346101. But, in the function mentioned above (p.adjust()) there are no possibiity to define the Q value (the false discovery rate). I understand that the Q value is calculated automatically but through which method??? For example, in another package (sgof v.2.3 also deposited on CRAN) indicates that the the false discovery rate is estimated by the method developed by: Dalmasso C, Broet P and Moreau T (2005). A simple procedure for estimating the false discovery rate. *Bioinformatics* 21:660--668. Many thanks for your help, David Bars. [[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.