Re: [R] introduce axis break lattice plot multipanel
Hi Luigi If you went down the relation = “free” road you could change the panel widths to reflect the scales eg if lhs was 1:200 and rhs was 1:100 then the lhs panel would be twice as wide as the rhs. I have some code reasonably handy I could send it to you if needed. Regards Duncan From: Luigi Marongiu [mailto:marongiu.lu...@gmail.com] Sent: Sunday, 20 December 2015 20:35 To: Duncan Mackay Subject: RE: [R] introduce axis break lattice plot multipanel thank you duncan, but in that case the scale of the two panel would be different. i think ill keep it as it comes. best wishes of a merry xmas luigi On 19 Dec 2015 13:42, "Duncan Mackay"wrote: Hi Luigi I suppose a cheats way out would be to put scales = list(alternating = FALSE, x = list(relation = "free") ), Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Luigi Marongiu Sent: Saturday, 19 December 2015 06:32 To: r-help Subject: [R] introduce axis break lattice plot multipanel Dear all, I am plotting some data using lattice's barchart. One of the counts I am plotting has a very large value with respect to the other variables and I would like to introduce a break in the axis to compensate for this 'anomaly' and give more breath to the other bars. In this example the high count is for the variable 'b' and I would like to introduce a break of 50-100 in the x axis. I have seen from the internet that the common approach is to stack together two figures but in my case I am using a multipanel plot and I think this way won't work for my plot. Is there a simple way to introduce a break in the axis of a multipanel lattice plot? Thank you L the example: >>> A <- c('a','b','c','d','a','b','c','d', 'b','c','d','b','c','d') B <- c(1,1,1,1,1,1,1,1,1,1,1, 1,1,1) C <- c(0,0,0,0,1,1,1,1,0,0,0, 1,1,1) D <- c(4,120,7,23,4,24,3,12,7,1, 1,5,0,0) E <- c(0,0,0,0,0,0,0,0,1,1,1, 1,1,1) DF <- data.frame(A, B, C, D, E, stringsAsFactors = FALSE) library(lattice) barchart( A ~ D|E, DF, groups = C, stack = TRUE, main = "Comparison of test results", xlab = "Count", col = c("yellow", "orange"), par.settings = list( strip.background = list(col="light grey"), superpose.polygon=list(col= c("yellow", "orange")) ), scales = list( alternating = FALSE ), key = list( space="top", columns=2, text=list(c("Single infections", "Multiple infections"), col="black"), rectangles=list(col=c("yellow", "orange")) ), ) __ 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] neuralnet to discriminate a given outcome by giving cutoff outputs
About my previous answer, I should have taken advantage of glm() in place of lm(), as the response is binomial. -- GG [[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] neuralnet to discriminate a given outcome by giving cutoff outputs
Dear all, I am trying to use neural networks to discriminate positive and negative outcomes from a test; this outcome is given in the z variable of the example I am providing. Each outcome is associated with a pair of variables x and y and I was planning to identify the cut-offs that could separate the positive from the negative results by splitting the x/y space into 4 quadrants, the positive results lying in the 2nd quadrant (the top right). In the example, the two cut-offs for x and y are indicated with green lines (the values are absolutely subjective), positive results are in red. I was thinking of using the neural networks (implemented with the neuralnet package) to obtain the x and y cut-offs but the returned weight are off-scale. I tried to increment the number of hidden neurons, to use more replicates and a maximum number of iteractions but the results are never optimal. Since I am completely new in neural networks usage, could you tell me if the implementation is fine, where could I improve the model and whether the neural network is the right approach for the problem I need to solve? Thank you L >>> x<-c(31.1,32.07,33.01,36.05,17.88,26.91,27.35, 38.44,35.92,38.08,26.14,40.35,36.12,21.51, 22.75,37.2,16.94,25.61,25.83,34.73,36.93, 36.02,37.43,36.09,34.74,35.85,16.35,35.25, 26.98,4.74,2.89,40.39,42.18,37.76,2.73, 2.76,2.64,41.94,45,3.78,2.86,45,2.77, 4.61,2.52,42.31,2.92,2.94,3.01,2.61,45, 45,44.54,44.37,36.24,2.11,2,3.97,44.54) y<-c(0.08,0.054,0.082,0.095,0.135,0.129,0.099, 0.072,0.091,0.093,0.104,0.077,0.107,0.108, 0.107,0.088,0.121,0.111,0.069,0.106,0.041, 0.091,0.054,0.083,0.089,0.086,0.073,0.085, 0.091,0.008,0.018,0,0,0.001,0.002,0.011, 0.001,0.002,-0.001,0.005,0.011,0.002,0.008, 0.006,0.006,0.001,0.006,0.003,0.015,0.003, 0.002,0.001,0,0.001,0.002,0.001,-0.001, 0.002,-0.001) z<-c(1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0, 0) m<-data.frame(x,y,z) pos <- subset(m, z == 1) neg <- subset(m, z == 0) # show points X <- max(m$x) Y <- max(m$y) plot(pos$x, pos$y, pch=1, col="red", xlim=c(1,X), ylim=c(0,Y), xlab="x", ylab="y", main ="Training dataset", sub="Red = positive outcome; Black = negative outcome") points(neg$x, neg$y, pch=1, col="black") abline(v=6, lty=2, col="green") abline(h=0.03, lty=2, col="green") library(neuralnet) tnm <- neuralnet(z ~ x + y, data=m, hidden=1, algorithm = "rprop+", err.fct = "ce", act.fct = "logistic", linear.output = FALSE ) tnm$result.matrix co.x <- tnm$result.matrix[5] co.y <- tnm$result.matrix[6] abline(v=co.x, lty=2, col="blue") abline(h=co.y, lty=2, col="blue") __ 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] neuralnet to discriminate a given outcome by giving cutoff outputs
I would tackle the problem in the following way: lm.model <- lm(z~ x + y, data=m) summary(lm.model) Call: lm(formula = z ~ x + y, data = m) Residuals: Min 1Q Median 3Q Max -0.34476713 -0.09571506 -0.01786731 0.05225554 0.51693389 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.071612058 0.041196651 -1.73830 0.0876543 . x0.003952998 0.001336833 2.95699 0.0045417 ** y9.968145059 0.461213516 21.61286 < 0.000222 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.157775 on 56 degrees of freedom Multiple R-squared: 0.905464, Adjusted R-squared: 0.9020877 F-statistic: 268.1834 on 2 and 56 DF, p-value: < 0.00022204 coef.model <- coef(lm.model) z.hat <- coef.model[1]+coef.model[2]*x+coef.model[3]*y z.hat.discrete <- rep(1, length(z.hat)) z.hat.discrete[z.hat <0.4] <- 0 > all.equal(z, z.hat.discrete) [1] TRUE I apologise for using such naif approach in place of neural net. -- GG http://around-r.blogspot.it [[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] Help needed in data cleaning
Hi Your question posted in HTML is somewhat scrambled. Based on what I understand from it, maybe you shall inspect ?merge. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Web Web > Sent: Friday, December 18, 2015 8:15 PM > To: r-help@r-project.org > Subject: [R] Help needed in data cleaning > > Hello, >I need some help in data cleaning using R. my CSV file looks > as > follows. > > "id","gender","age","category1","category2","category3","category4","ca > tegory5","category6","category7","category8","category9","category10"1, > "Male",22,"movies","music","travel","cloths","grocery",2,"Male",28, > "travel","books","movies",,,3,"Female",27,"rent","fuel","grocery"," > cloths",,4,"Female",22,"rent","grocery","travel","movies","cloths", > 5,"Female",22,"rent","online-shopping","utiliy",,, > > I need to reformat as follows. > > id gender age categoryrank1 Male22 movies > 11 Male22 music21 Male22 travel >31 Male22 cloths 41 Male22 grocery > 51 Male22 booksNA1 Male22 rent > NA1 Male22 fuel NA1 Male22 utility > NA1 Male22 online-shopping NA > ...5 Female22 movies > NA5 Female22 music NA5 Female22 travel >NA5 Female22 cloths NA5 Female22 grocery > NA5 Female22 books NA5 Female22 rent > 15 Female22 fuel NA5 Female22 utility >NA5 Female22 online-shopping2 > > So far My efforts are as follows. > > mini <- read.csv("~/MS/coding/mini.csv", header=FALSE) > mini_clean <- mini[-1,] > df_mini <- melt(df_clean, id.vars=c("V1","V2","V3")) > sqldf('select * from df_mini order by "V1"') > > Now I want to know what is the best way to fill all missing categories > for > all users. > > Thanks > Nash > > [[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. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any
Re: [R] Use of "file.choose()" or "change working directory" tab causing stall on Mac
On 12/19/2015 10:39 PM, Vinny Mo wrote: > Hello, > > > I used to use the "file.choose()" command quite a lot, as well as the "change > working directory" drop down tab as part of my workflow with R, but for over > 1 year both of these actions have caused the spinning-wheel to crash R (just > R, not any other program). > > > The issue seems to happen when the GUI pops up, and happens about 80% of the > time I use either of these actions. This issue has remained constant across > different computers (though all macs), different R builds, and different Mac > OS's. I had asked about this issue before, and had hoped that this bug might > be fixed at some point, but it has persisted. The posting guide asks for a reproducible example. This is problematic if you only have only an 80% failure rate. Nevertheless, do you have a verbatim example that has failed at least once? If a particular formulation fails one time for you, does it always fail or can a certain syntax work 1 in 5 times? If this is a mac-only problem you might get more help on that mailing list: *https://stat.ethz.ch/mailman/listinfo/r-sig-mac*** You should install the most recent version of R and reproduce the problem there. When posting again, it would be helpful to supply the results of R.Version() for your setup. > > I know I can work around this issue programmatically by typing these commands > manually, but both of these features represent a nice function that R has > that I'd like to continue to use as was intended. Does anyone have any idea > how I might be able to get this functionality back, or if the R Gods have any > thoughts about addressing this issue? > > [[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.