Re: [R] Plotting in LaTeX with ggplot2 in R and using tikzdevice

2016-08-04 Thread Richard M. Heiberger
I suggest the microplot package that I placed on CRAN several weeks ago. Description: Prepare lists of R graphics files to be used as microplots (sparklines) in tables in either LaTeX or HTML files. For LaTeX use the Hmisc::latex() function or xtable::xtable() with Sweave, kn

Re: [R] Fwd: only plot borders of a region in a scatter plot

2016-08-04 Thread Jim Lemon
Hi Zun Yin, A slight improvement follows, which tries to "inflate" the pixellation locally. This, in addition to the offset, might do it for you. pixel8<-function(x,y) { nsteps<-length(x)-1 newx<-x[1] newy<-y[1] lastdx<-lastdy<-0 for(i in 1:nsteps) { dx<-diff(x[i:(i+1)]) dy<-diff(y[i:(i+1

Re: [R] how to plot annual values directly

2016-08-04 Thread Duncan Mackay
Hi By coincidence I will very soon have to do something similar. So I thought this would be a practice run Data is 10 years of daily rainfall data str(arm) 'data.frame': 3640 obs. of 7 variables: $ date : Date, format: "1990-01-01" "1990-01-02" "1990-01-03" "1990-01-04" ... $ year : int 19

Re: [R] Fwd: only plot borders of a region in a scatter plot

2016-08-04 Thread Jim Lemon
Hi Zun Yin, The first problem requires something like this: pixel8<-function(x,y,pixsize=1) { nsteps<-length(x)-1 newx<-x[1] newy<-y[1] for(i in 1:nsteps) { dx<-diff(x[i:(i+1)]) dy<-diff(y[i:(i+1)]) if(dx && dy) { newx<-c(newx,x[i]+dx,x[i]+dx) newy<-c(newy,y[i],y[i]+dy) } else

Re: [R] foreach {parallel} nested with for loop to update data.frame column

2016-08-04 Thread Alexander.Herr
Hiya, This now works... test<-foreach(i=unique(xyz[,1]), .combine=rbind, .verbose=T) %dopar% { for( j in unique(xyz[,2])) { xyz[xyz[,2] == j & xyz[,1] == i ,4]<-min(xyz[xyz[,2] == j & xyz[,1] == i,3]) nr=nrow(xyz[xyz[,2] == j & xyz[,1] == i ,4]) } retu

Re: [R] difftime in years

2016-08-04 Thread Jim Lemon
Hi Thomas, Be aware that if you are attempting to calculate "birthday age", it is probably better to do it like this: bdage<-function(dob,now) { dobbits<-as.numeric(unlist(strsplit(dob,"/"))) nowbits<-as.numeric(unlist(strsplit(now,"/"))) return(nowbits[3]-dobbits[3]- (nowbits[2] wrote: > dif

Re: [R] foreach {parallel} nested with for loop to update data.frame column

2016-08-04 Thread Alexander.Herr
Hiya, Yes that would work, also an aggregate with merge can work, but I really would like to make this a parallel calculation with farming out the first loop to different workers and put the output together again into the data.frame with additional columns. This will speed up work with very larg

Re: [R] Error code 100 when using the function “fitdist” from the fitdistrplus package

2016-08-04 Thread Jim Lemon
Hi Nelly, The message David suggested was about scaling the values, not adjusting the parameters. It is quite possible that the empirical distribution is nothing like beta or Weibull. Have you tried plotting the values with "density"? Jim On Fri, Aug 5, 2016 at 6:56 AM, Nelly Reduan wrote: > He

Re: [R] Odds ratios in logistic regression models with interaction

2016-08-04 Thread peter dalgaard
> On 04 Aug 2016, at 22:00 , Laviolette, Michael > wrote: > > Thanks. I came to the same realization after the original post and was able > to get the correct results with the coefficient vector and covariance matrix > by setting up as a contrast. Linear model contrast estimation in R doesn't

Re: [R] Error code 100 when using the function “fitdist” from the fitdistrplus package

2016-08-04 Thread Nelly Reduan
Hello, Thanks David for your answer. I tested different parameters for Beta and Weibull distributions based on forums but I didn't find solutions. Thank you very much for your time. Have a nice day Nell De : David Winsemius Envoy� : jeudi 4 ao�t 2016 08:45:

Re: [R] difftime in years

2016-08-04 Thread William Dunlap via R-help
difftime objects do not accept 'years' as a value for 'units', so you have to change it to numeric. as.numeric(age_days, units="days") / 365.242 The units="days" is not needed since you specified it in the call to difftime, but it needs to be in one of those places. Bill Dunlap TIBCO Softwar

Re: [R] Fwd: only plot borders of a region in a scatter plot

2016-08-04 Thread Duncan Murdoch
On 04/08/2016 11:46 AM, Zun Yin wrote: Dear William, Duncan and Bert, Thanks a lot for your help and tips :D In fact the contour() plot still cannot solve my problem perfectly. As the resolution of my plot is very coarse, I want to a contour perfectly surround all grid cells in the river basin.

Re: [R] Odds ratios in logistic regression models with interaction

2016-08-04 Thread Laviolette, Michael
Thanks. I came to the same realization after the original post and was able to get the correct results with the coefficient vector and covariance matrix by setting up as a contrast. Linear model contrast estimation in R doesn't seem straightforward. I turned up several packages, but any recommen

Re: [R] Fwd: only plot borders of a region in a scatter plot

2016-08-04 Thread Zun Yin
Dear William, Duncan and Bert, Thanks a lot for your help and tips :D In fact the contour() plot still cannot solve my problem perfectly. As the resolution of my plot is very coarse, I want to a contour perfectly surround all grid cells in the river basin. In another word, I want all angle of the

[R] difftime in years

2016-08-04 Thread Thomas Subia via R-help
Colleagues, age_days <- difftime(Date,DOM,units="days") date_vals$age_yrs <- age_days/365.242 I'm trying to calculate the number of years between DOM and Date. The output reads DOM Date age_yrs 1 2005-04-04 2015-05-13 10.10563 days How doe

Re: [R] Help with the RMD Output & rCharts Package

2016-08-04 Thread Shivi Bhatia
Found an alternative, error A) was because the score.sentiment was calling the stringr package so called it at the start of the RMD file error B) looked for other alternative as rcharts didnt worked On Thu, Aug 4, 2016 at 6:39 PM, Shivi Bhatia wrote: > Dear Team, > > I am in need of urgent help

Re: [R] Error code 100 when using the function “fitdist” from the fitdistrplus package

2016-08-04 Thread David Winsemius
> On Aug 3, 2016, at 4:42 PM, Nelly Reduan wrote: > > Nelly Reduan has shared OneDrive?files with you. To view them, click the link > or image below. > > > > [https://bzmvxw.by3301.livefilestore.com/y3mor2T_TYssPck9iMngzQsuiM_z140uCxN_MOvDhcR

Re: [R] Fwd: only plot borders of a region in a scatter plot

2016-08-04 Thread Duncan Murdoch
On 04/08/2016 11:03 AM, William Dunlap via R-help wrote: If 'basinID' is the matrix of basin identifiers you could draw an outline of the basin with identifier 'ID' with coutour( basiinID == ID, level=0.5) Note the typo: that should be contour( basiinID == ID, level=0.5) Duncan Murdoch

Re: [R] Fwd: only plot borders of a region in a scatter plot

2016-08-04 Thread Bert Gunter
... note the typo. It's: contour( basiinID == ID, level=0.5) :-) -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Aug 4, 2016 at 8:03 AM, Will

Re: [R] Fwd: only plot borders of a region in a scatter plot

2016-08-04 Thread William Dunlap via R-help
If 'basinID' is the matrix of basin identifiers you could draw an outline of the basin with identifier 'ID' with coutour( basiinID == ID, level=0.5) Add 'add=TRUE' if you are overlaying this on an existing plot. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Aug 4, 2016 at 1:51 AM, Zun Y

[R] ggplot2 - unexpected beahviour with facet_grid

2016-08-04 Thread Alain Guillet
Hello, I use ggplot2 in order to represent the same data during 3 periods so I call facet_grid to get one subgraph by period. But when I do so, I get different results between the call on the whole data and the one on only one period (I expect to get one of the subgraphs to be identical to the

[R] Error code 100 when using the function “fitdist” from the fitdistrplus package

2016-08-04 Thread Nelly Reduan
Nelly Reduan has shared OneDrive?files with you. To view them, click the link or image below. [https://bzmvxw.by3301.livefilestore.com/y3mor2T_TYssPck9iMngzQsuiM_z140uCxN_MOvDhcRAILsrvwtWQ8cMMtzUvEuWjFYFytobNNvH8TJGzIrV7tjUHcKnVG_E76ru3RJEpGNPM3

Re: [R] Homals: Nonlinear PCA

2016-08-04 Thread Zhaoju Deng
Hi Lucia, It is another problem with Homals on my own data. Have you ever got a eigenvalue above one? Because in my analysis homals consistently gave me very small eigenvalues(far below 1), I compared the eigenvalues in Homals and Psych, there were different, Psych always gave me high eigenvalue

Re: [R] Odds ratios in logistic regression models with interaction

2016-08-04 Thread Laviolette, Michael
Thanks. I ended up doing it as a contrast directly from the covariance matrix. There's probably a package that provides a better way, maybe the "contrast" package. For now, this works. a <- 25 # age # contrast for estimating OR's for given age d <- c(1, 1, a, a) - c(1, 0, a, 0) # estimate of l

Re: [R] Three way correspondence analyses?

2016-08-04 Thread Michael Friendly
You haven't supplied any data, and we can only guess which cca() function you are using (ade4::cca, ..., vegan::cca(), yacca::cca), and the term 'cca' generally refers to canonical correspondence analysis, which is not quite the same thing as 'three-way correspondence analysis'. For three-way t

Re: [R] Odds ratios in logistic regression models with interaction

2016-08-04 Thread peter dalgaard
I suspect that "you can't get there from here"... a1$fit and a2$fit are not independent, so you can't work out the s.e. of their difference using sqrt(a1$se.fit^2+a2$se.fit^2). You need to backtrack a bit and figure out how a1$fit-a2$fit relates to coef(fit3.16). I suspect it is actually just

[R] Help with the RMD Output & rCharts Package

2016-08-04 Thread Shivi Bhatia
Dear Team, I am in need of urgent help on RMD output in html. A) I am working on a sentiment analysis problem and have built a sentiment model which works perfectly on R Studio however the same on the RMD shows all the processing steps and details. I have used echo= FALSE but i still the see the

Re: [R] Odds ratios in logistic regression models with interaction

2016-08-04 Thread Michael Dewey
Laviolette, Michael wrote : > I'm trying to reproduce some results from Hosmer & Lemeshow's "Applied > Logistic > Regression" second edition, pp. 74-79. The objective is to estimate odds > ratios > for low weight births with interaction between mother's age and weight > (dichotomized at 110 lb.

Re: [R] cpquery problem

2016-08-04 Thread Ross Chapman
Hi Marco Thank you very much for your helpful advice. I have tried you suggestion of using method = 'lw' with cpquery and can now obtain conditional probabilities. However, I am still puzzled over the outputs from the predict() and cpquery functions. The network that I am working on has the fol

Re: [R] foreach {parallel} nested with for loop to update data.frame column

2016-08-04 Thread PIKAL Petr
Hi I may be completely wrong but isn't it work for ave? With your example I get > fac<-interaction(xyz[,1], xyz[,2], drop=TRUE) > xyz[,4]<-ave(xyz$z, fac, FUN= min) > head(xyz) x y z mins 1 13 15 1.97 -2.91 2 17 9 14.90 -2.81 3 9 10 34.68 -1.97 4 17 6 4.26 -2.63 5 3 12 0.12 0.12