Re: [R] offset in nlme

2016-12-28 Thread Jeff Newmiller
You don't need to post WORKING code... just code that leads to the problem you 
want help with. The ability to create the error and then eliminate the error 
greatly reduces guessing on both sides of the conversation about the nature of 
the question. (Things the asker did not know were important become clear to the 
answerer and can be highlighted.)

I think you can also forgo the little function definition if you simply remove 
R0 from the start list in your original call to nlme and put a zero in the 
function call. 
-- 
Sent from my phone. Please excuse my brevity.

On December 27, 2016 11:39:29 PM PST, PIKAL Petr  wrote:
>Hi Jeff.
>
>Yes, if it had been reproducible I would not post it as I had known
>solution myself. (Uff, I hope I used this conditional clause
>correctly).
>
>OTOH your suggestion works and seems to arrive to desired result even
>that you said you do not know what I am talking about. R (and this
>smart community) sometimes surprise me even after quite a long time
>experience.
>
>Thanks.
>Petr
>
>> -Original Message-
>> From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
>> Sent: Tuesday, December 27, 2016 4:21 PM
>> To: PIKAL Petr ; r-help mailing list
>> project.org>
>> Subject: Re: [R] offset in nlme
>>
>> Not reproducible. Tsk!
>>
>> I really don't know what you are taking about,  but some ideas are:
>>
>> mySSasymp <- function( doba, Asym, lrc ) {
>>   SSasymp(doba, Asym, 0, lrc)
>> }
>>
>> Another idea is to use log( time ) rather than time.
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>> On December 27, 2016 6:47:12 AM PST, PIKAL Petr
>
>> wrote:
>> >Dear all
>> >
>> >I would like to fit SSasymp model to some data by nlme. I did not
>find
>> >any clue how to set one of parameters to fixed constant value
>(R0=0).
>> >
>> >One suitable way could be to use SSlogis as it has one parameter
>zero,
>> >however it is not correct AFAIK logistics is defined from -Inf to
>Inf
>> >and my x value is time, starting from 0.
>> >
>> >The only option I found is to define my own growth function which is
>> >constrained by some fixed starting point. Does anybody know other
>way
>> >around? Like persuading nlme not optimize R0 and be happy with the
>> >value set in the function call.
>> >
>> >something like
>> >
>> >nlsList(rutrtg ~ SSasymp(doba, Asym, R0, lrc), data=rutil.g,
>> >start=c(Asym=100, R0= 10, lrc=-2), offset=c(R0=10))
>> >
>> >which obviously does not work.
>> >
>> >I could put some data but it is more a matter of nlme or other R
>> >functions then real data.
>> >
>> >Looking forward to some answer.
>> >Happy New year 2017
>> >
>> >Petr Pikal
>> >
>> >
>> >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 of

[R] Rbbg usurped ?

2016-12-28 Thread Tolga Uzuner

Dear R users,

I have some old code that was using Rbbg, which no longer appears to be 
working.


I tried to download Rbbg using the line:
install.packages("Rbbg", repos = "http://r.findata.org";)

in R version 3.3.2 on a Windows 10 machine and got the following error:

> install.packages("Rbbg", repos = "http://r.findata.org";)
Installing package into ‘C:/Users/Tolga/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository 
http://r.findata.org/src/contrib:

  cannot open URL 'http://r.findata.org/src/contrib/PACKAGES'
Warning: unable to access index for repository 
http://r.findata.org/bin/windows/contrib/3.3:

  cannot open URL 'http://r.findata.org/bin/windows/contrib/3.3/PACKAGES'
Warning message:
package ‘Rbbg’ is not available (for R version 3.3.2)
>

Is Rbbg no longer supported ? Has it been usurped by something else ? 
Does this mean I have to rewrite code or is the new package compatible 
with code written for Rbbg ?


Thanks in advance

__
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] offset in nlme

2016-12-28 Thread PIKAL Petr
Hi

> -Original Message-
> From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
> Sent: Wednesday, December 28, 2016 10:13 AM
> To: PIKAL Petr ; r-help mailing list  project.org>
> Subject: RE: [R] offset in nlme
>
> You don't need to post WORKING code... just code that leads to the problem
> you want help with. The ability to create the error and then eliminate the
> error greatly reduces guessing on both sides of the conversation about the
> nature of the question. (Things the asker did not know were important
> become clear to the answerer and can be highlighted.)
>
> I think you can also forgo the little function definition if you simply 
> remove R0
> from the start list in your original call to nlme and put a zero in the 
> function
> call.


Yes, you are correct. I am not sure if it is intended but I did not find any 
mention about this feature in help pages nor in Pinheiro, Bates book.

fit<-nlsList(rutrtg ~ SSasymp(doba, Asym, R0=5, lrc), data=rutil.g, 
start=c(Asym=100, lrc=-3))
fit1<-nlme(fit, random=Asym+lrc~1)
fixef(fit1)
Asym  lrc
73.77617 -3.31942

Cheers
Petr

For completeness, here are the data.
dput(rutil.g)
structure(list(vzorek = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 5L, 7L, 9L, 11L, 13L,
6L, 8L, 10L, 12L, 14L), .Label = c("01.I", "02.I", "1", "2",
"2/1*A/900C", "2/1*A/950C", "2/1*B/900C", "2/1*B/950C", "2/1*C/900C",
"2/1*C/950C", "2/1*D/900C", "2/1*D/950C", "2/1*E/900C", "2/1*E/950C",
"3", "4"), class = "factor"), promot = c(3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L), teplota = c(875L, 875L, 875L, 875L, 875L, 925L, 925L, 925L,
925L, 925L, 875L, 875L, 875L, 875L, 875L, 925L, 925L, 925L, 925L,
925L, 875L, 875L, 875L, 875L, 875L, 925L, 925L, 925L, 925L, 925L,
875L, 875L, 875L, 875L, 875L, 925L, 925L, 925L, 925L, 925L, 875L,
875L, 875L, 875L, 875L, 925L, 925L, 925L, 925L, 925L, 875L, 875L,
875L, 875L, 875L, 925L, 925L, 925L, 925L, 925L, 875L, 875L, 875L,
875L, 875L, 925L, 925L, 925L, 925L, 925L), k2oteor = c(0.2, 0.2,
0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,
0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4,
0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.2,
0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.4, 0.4, 0.4,
0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4,
0.4, 0.4, 0.4), p2o5teor = c(0.17, 0.17, 0.17, 0.17, 0.17, 0.17,
0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17,
0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17,
0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17,
0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17,
0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17,
0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17, 0.17), k2omer = c(0.104,
0.104, 0.104, 0.104, 0.104, 0.104, 0.104, 0.104, 0.104, 0.104,
0.102, 0.102, 0.102, 0.102, 0.102, 0.102, 0.102, 0.102, 0.102,
0.102, 0.384, 0.384, 0.384, 0.384, 0.384, 0.384, 0.384, 0.384,
0.384, 0.384, 0.211, 0.211, 0.211, 0.211, 0.211, 0.211, 0.211,
0.211, 0.211, 0.211, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18,
0.18, 0.18, 0.18, 0.266, 0.266, 0.266, 0.266, 0.266, 0.266, 0.266,
0.266, 0.266, 0.266, 0.26, 0.26, 0.26, 0.26, 0.26, 0.26, 0.26,
0.26, 0.26, 0.26), p2o5mer = c(0.167, 0.167, 0.167, 0.167, 0.167,
0.167, 0.167, 0.167, 0.167, 0.167, 0.165, 0.165, 0.165, 0.165,
0.165, 0.165, 0.165, 0.165, 0.165, 0.165, 0.171, 0.171, 0.171,
0.171, 0.171, 0.171, 0.171, 0.171, 0.171, 0.171, 0.16, 0.16,
0.16, 0.16, 0.16, 0.16, 0.16, 0.16, 0.16, 0.16, 0.164, 0.164,
0.164, 0.164, 0.164, 0.164, 0.164, 0.164, 0.164, 0.164, 0.162,
0.162, 0.162, 0.162, 0.162, 0.162, 0.162, 0.162, 0.162, 0.162,
0.165, 0.165, 0.165, 0.165, 0.165, 0.165, 0.165, 0.165, 0.165,
0.165), al2o3 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.017, 0.017,
0.017, 0.017, 0.017, 0.017, 0.017, 0.017, 0.017, 0.017, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0.006, 0.006, 0.006, 0.006, 0.006, 0.006,
0.006, 0.006, 0.006, 0.006, 0.025, 0.025, 0.025, 0.025, 0.025,
0.025, 0.025, 0.025, 0.025, 0.025, 0.019, 0.019, 0.019, 0.019,
0.019, 0.019, 0.019, 0.019, 0.019, 0.019, 0.016, 0.016, 0.016,
0.016, 0.016, 0.016, 0.016, 0.016, 0.016, 0.016), tskut = c(900L,
900L, 900L, 900L, 900L, 950L, 950L, 950L, 950L, 950L, 900L, 900L,
900L, 900L, 900L, 950L, 950L, 950L, 950L, 950L, 900L, 900L, 900L,
900L, 900L, 950L, 950L, 950L, 950L, 950L, 900L, 900L, 900L, 900L,
900L, 950L, 950L, 950L, 950L, 950L, 900L, 900L, 900L, 900L, 900L,
950L, 950L, 950L, 950L, 950L, 900L, 900L, 900L, 900L, 900L, 950L,
950L, 950L, 950L, 950L, 

Re: [R] Rbbg usurped ?

2016-12-28 Thread Sarah Goslee
If you actually visit that link, you will see that the directory structure
isn't laid out in the way that install.packages() currently expects for a
repo, but that you can still download the package yourself, and presumably
install it from local file.


On Wed, Dec 28, 2016 at 4:41 AM Tolga Uzuner  wrote:

> Dear R users,
>
>
>
> I have some old code that was using Rbbg, which no longer appears to be
>
> working.
>
>
>
> I tried to download Rbbg using the line:
>
> install.packages("Rbbg", repos = "http://r.findata.org";)
>
>
>
> in R version 3.3.2 on a Windows 10 machine and got the following error:
>
>
>
>  > install.packages("Rbbg", repos = "http://r.findata.org";)
>
> Installing package into ‘C:/Users/Tolga/Documents/R/win-library/3.3’
>
> (as ‘lib’ is unspecified)
>
> Warning: unable to access index for repository
>
> http://r.findata.org/src/contrib:
>
>cannot open URL 'http://r.findata.org/src/contrib/PACKAGES'
>
> Warning: unable to access index for repository
>
> http://r.findata.org/bin/windows/contrib/3.3:
>
>cannot open URL 'http://r.findata.org/bin/windows/contrib/3.3/PACKAGES'
>
> Warning message:
>
> package ‘Rbbg’ is not available (for R version 3.3.2)
>
>  >
>
>
>
> Is Rbbg no longer supported ? Has it been usurped by something else ?
>
> Does this mean I have to rewrite code or is the new package compatible
>
> with code written for Rbbg ?
>
>
>
> Thanks in advance
>
>
>
> __
>
> 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] Bayesian cox model: spBayesSurv package

2016-12-28 Thread radhika sundar
The example code for the indeptCoxph function  in the spBayesSurv package
has been updated(this is not cross-posted anywhere else). See code below.
The author simulates data to illustrate the Cox model -  I am stuck trying
to understand the role of the functions f0oft, S0oft, fioft and Sioft as
also Finv.

Am I right in thinking that he is only using the above mentioned functions
to simulate his data? If I wanted to run the indeptCoxph function with
different data, do I need to define those functions again?
Roughly, in the author's example, I can understand he fits a Cox model with
2 predictors x1 and x2. He simulates survival time data (but this is where
I am confused).
As for the bayesian model itself, the only prior he uses is for M, the
number of cutpoints in the baseline hazard function. (There is no function
listed as a prior for Survival times in the ideptCoxph call).

Sorry --- this is a novice question relating to understanding both the
statistical set-up and the R-code.
Thanks for any help!
Author's(updated)  code:
###
# A simulated data: Cox PH
###
rm(list=ls())
library(survival)
library(spBayesSurv)
library(coda)
library(MASS)
## True parameters
betaT = c(1,1);
n=500; npred=30; ntot=n+npred;
## Baseline Survival
f0oft = function(t) 0.5*dlnorm(t, -1, 0.5)+0.5*dlnorm(t,1,0.5);
S0oft = function(t) (0.5*plnorm(t, -1, 0.5, lower.tail=FALSE)+
   0.5*plnorm(t, 1, 0.5, lower.tail=FALSE))
## The Survival function:
Sioft = function(t,x)  exp( log(S0oft(t))*exp(sum(x*betaT)) ) ;
fioft = function(t,x) exp(sum(x*betaT))*f0oft(t)/S0oft(t)*Sioft(t,x);
Fioft = function(t,x) 1-Sioft(t,x);
## The inverse for Fioft
Finv = function(u, x) uniroot(function (t) Fioft(t,x)-u, lower=1e-100,
  upper=1e100, extendInt ="yes",
tol=1e-6)$root

## generate x
x1 = rbinom(ntot, 1, 0.5); x2 = rnorm(ntot, 0, 1); X = cbind(x1, x2);
## generate survival times
u = runif(ntot);
tT = rep(0, ntot);
for (i in 1:ntot){
  tT[i] = Finv(u[i], X[i,]);
}

## right censoring
t_obs=tT
Centime = runif(ntot, 2, 6);
delta = (tT<=Centime) +0 ;
length(which(delta==0))/ntot; # censoring rate
rcen = which(delta==0);
t_obs[rcen] = Centime[rcen]; ## observed time
## make a data frame
dtotal = data.frame(t_obs=t_obs, x1=x1, x2=x2, delta=delta,
tT=tT);
## Hold out npred=30 for prediction purpose
predindex = sample(1:ntot, npred);
dpred = dtotal[predindex,];
dtrain = dtotal[-predindex,];

# Prediction settings
xpred = cbind(dpred$x1,dpred$x2);
prediction = list(xpred=xpred);

###
# Independent Cox PH
###
# MCMC parameters
nburn=1000; nsave=1000; nskip=0;
# Note larger nburn, nsave and nskip should be used in practice.
mcmc=list(nburn=nburn, nsave=nsave, nskip=nskip, ndisplay=1000);
prior = list(M=10);
state <- NULL;
# Fit the Cox PH model
res1 = indeptCoxph( y = dtrain$t_obs, delta =dtrain$delta,
x = cbind(dtrain$x1, dtrain$x2),RandomIntervals=FALSE,
prediction=prediction,  prior=prior, mcmc=mcmc,
state=state);
save.beta = res1$beta; row.names(save.beta)=c("x1","x2")
apply(save.beta, 1, mean); # coefficient estimates
apply(save.beta, 1, sd); # standard errors
apply(save.beta, 1, function(x) quantile(x, probs=c(0.025, 0.975))) # 95% CI
## traceplot
par(mfrow = c(2,1))
traceplot(mcmc(save.beta[1,]), main="beta1")
traceplot(mcmc(save.beta[2,]), main="beta2")
res1$ratebeta; # adaptive MH acceptance rate
## LPML
LPML1 = sum(log(res1$cpo)); LPML1;
## MSPE
mean((dpred$tT-apply(res1$Tpred, 1, median))^2);

## plots
par(mfrow = c(2,1))
x1new = c(0, 0);
x2new = c(0, 1)
xpred = cbind(x1new, x2new);
nxpred = nrow(xpred);
tgrid = seq(1e-10, 4, 0.03);
ngrid = length(tgrid);
estimates = GetCurves(res1, xpred, log(tgrid), CI=c(0.05, 0.95));
fhat = estimates$fhat;
Shat = estimates$Shat;
## density in t
plot(tgrid, fioft(tgrid, xpred[1,]), "l", lwd=2,  ylim=c(0,3),
main="density")
for(i in 1:nxpred){
  lines(tgrid, fioft(tgrid, xpred[i,]), lwd=2)
  lines(tgrid, fhat[,i], lty=2, lwd=2, col=4);
}
## survival in t
plot(tgrid, Sioft(tgrid, xpred[1,]), "l", lwd=2, ylim=c(0,1),
main="survival")
for(i in 1:nxpred){
  lines(tgrid, Sioft(tgrid, xpred[i,]), lwd=2)
  lines(tgrid, Shat[,i], lty=2, lwd=2, col=4);
  lines(tgrid, estimates$Shatup[,i], lty=2, lwd=1, col=4);
  lines(tgrid, estimates$Shatlow[,i], lty=2, lwd=1, col=4);
}


On Wed, Dec 28, 2016 at 2:11 AM, David Winsemius 
wrote:

> Cross posting is deprecated on rhelp but if you do so, please at least
> post a link to the stackoverflow address for the duplicate question.
>
> Sent from my iPhone
>
> > On Dec 27, 2016, at 6:52 AM, radhika sundar 
> wrote:
> >
> > I am going through R's function indeptCoxph in the spBayesSurv package
> > which fits a bayesian Cox model. I am confuse

Re: [R] Bayesian cox model: spBayesSurv package

2016-12-28 Thread David Winsemius

> On Dec 28, 2016, at 4:30 AM, radhika sundar  
> wrote:
> 
> The example code for the indeptCoxph function  in the spBayesSurv package has 
> been updated(this is not cross-posted anywhere else). See code below. The 
> author simulates data to illustrate the Cox model -  I am stuck trying to 
> understand the role of the functions f0oft, S0oft, fioft and Sioft as also 
> Finv.

Your preamble very much resembles the 2 questions from yesterday of the 
anonymous questioner: user2450223

http://stackoverflow.com/questions/41344300/bayesian-survival-analysis
http://stackoverflow.com/questions/41342836/stuck-with-package-example-code-in-r-simulating-data-to-fit-a-model

One of those questions was apparently answered by the package's author 
yesterday, although you (at least I think it must have been you) have not 
acknowledged it yet. If you are asking question on Rhelp about little-used 
packages you are advised in the Posting Guide to first contact the package 
author and if unsuccessful, then post to Rhelp (preferably with visible CC: to 
the author as well as to the list.)

Learn the `maintainer` function:

> maintainer( 'spBayesSurv')
[1] "Haiming Zhou "


> 
> Am I right in thinking that he is only using the above mentioned functions to 
> simulate his data? If I wanted to run the indeptCoxph function with different 
> data, do I need to define those functions again?
> Roughly, in the author's example, I can understand he fits a Cox model with 2 
> predictors x1 and x2. He simulates survival time data (but this is where I am 
> confused).
> As for the bayesian model itself, the only prior he uses is for M, the number 
> of cutpoints in the baseline hazard function. (There is no function listed as 
> a prior for Survival times in the ideptCoxph call).

Rhelp is not set up to handle questions that are fundamentally statistical. 
When the issue is the underlying statistical theory for running R code the best 
place start would be the package author, and only when unsuccessful post to 
whatever alternate location he suggests in the packageDescription (although I 
don't see one) or then post to:

http://stats.stackexchange.com/

Given the package's "spatial" capacities, it might also have been appropriate 
on:

https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Neither R-help nor StackOverflow are good fits to this question in my opinion.

-- 
David.

> 
> Sorry --- this is a novice question relating to understanding both the 
> statistical set-up and the R-code.
> Thanks for any help!
> Author's(updated)  code:
> ###
> # A simulated data: Cox PH
> ###
> rm(list=ls())
> library(survival)
> library(spBayesSurv)
> library(coda)
> library(MASS)
> ## True parameters 
> betaT = c(1,1); 
> n=500; npred=30; ntot=n+npred;
> ## Baseline Survival
> f0oft = function(t) 0.5*dlnorm(t, -1, 0.5)+0.5*dlnorm(t,1,0.5);
> S0oft = function(t) (0.5*plnorm(t, -1, 0.5, lower.tail=FALSE)+
>0.5*plnorm(t, 1, 0.5, lower.tail=FALSE))
> ## The Survival function:
> Sioft = function(t,x)  exp( log(S0oft(t))*exp(sum(x*betaT)) ) ;
> fioft = function(t,x) exp(sum(x*betaT))*f0oft(t)/S0oft(t)*Sioft(t,x);
> Fioft = function(t,x) 1-Sioft(t,x);
> ## The inverse for Fioft
> Finv = function(u, x) uniroot(function (t) Fioft(t,x)-u, lower=1e-100, 
>   upper=1e100, extendInt ="yes", 
> tol=1e-6)$root
> 
> ## generate x 
> x1 = rbinom(ntot, 1, 0.5); x2 = rnorm(ntot, 0, 1); X = cbind(x1, x2);
> ## generate survival times
> u = runif(ntot);
> tT = rep(0, ntot);
> for (i in 1:ntot){
>   tT[i] = Finv(u[i], X[i,]);
> }
> 
> ## right censoring
> t_obs=tT 
> Centime = runif(ntot, 2, 6);
> delta = (tT<=Centime) +0 ; 
> length(which(delta==0))/ntot; # censoring rate
> rcen = which(delta==0);
> t_obs[rcen] = Centime[rcen]; ## observed time 
> ## make a data frame
> dtotal = data.frame(t_obs=t_obs, x1=x1, x2=x2, delta=delta, 
> tT=tT);
> ## Hold out npred=30 for prediction purpose
> predindex = sample(1:ntot, npred);
> dpred = dtotal[predindex,];
> dtrain = dtotal[-predindex,];
> 
> # Prediction settings 
> xpred = cbind(dpred$x1,dpred$x2);
> prediction = list(xpred=xpred);
> 
> ###
> # Independent Cox PH
> ###
> # MCMC parameters
> nburn=1000; nsave=1000; nskip=0;
> # Note larger nburn, nsave and nskip should be used in practice.
> mcmc=list(nburn=nburn, nsave=nsave, nskip=nskip, ndisplay=1000);
> prior = list(M=10);
> state <- NULL;
> # Fit the Cox PH model
> res1 = indeptCoxph( y = dtrain$t_obs, delta =dtrain$delta, 
> x = cbind(dtrain$x1, dtrain$x2),RandomIntervals=FALSE, 
> prediction=prediction,  prior=prior, mcmc=mcmc, 
> state=state);
> save.beta = res1$beta; row.names(save.beta)=c("x1","x2")
> apply(save.be

Re: [R] Rbbg usurped ?

2016-12-28 Thread John Laing
I've cleaned up the findata repository, you should now be able to install
Rbbg as expected.

But that said, the package is no longer being actively developed. Recent
efforts have been taking place in the Rblpapi package. The interface is
similar, though not strictly compatible. If you're doing much work with
Bloomberg data I recommend you check it out.

JL

On Dec 28, 2016 5:39 AM, "Sarah Goslee"  wrote:

> If you actually visit that link, you will see that the directory structure
> isn't laid out in the way that install.packages() currently expects for a
> repo, but that you can still download the package yourself, and presumably
> install it from local file.
>
>
> On Wed, Dec 28, 2016 at 4:41 AM Tolga Uzuner  wrote:
>
> > Dear R users,
> >
> >
> >
> > I have some old code that was using Rbbg, which no longer appears to be
> >
> > working.
> >
> >
> >
> > I tried to download Rbbg using the line:
> >
> > install.packages("Rbbg", repos = "http://r.findata.org";)
> >
> >
> >
> > in R version 3.3.2 on a Windows 10 machine and got the following error:
> >
> >
> >
> >  > install.packages("Rbbg", repos = "http://r.findata.org";)
> >
> > Installing package into ‘C:/Users/Tolga/Documents/R/win-library/3.3’
> >
> > (as ‘lib’ is unspecified)
> >
> > Warning: unable to access index for repository
> >
> > http://r.findata.org/src/contrib:
> >
> >cannot open URL 'http://r.findata.org/src/contrib/PACKAGES'
> >
> > Warning: unable to access index for repository
> >
> > http://r.findata.org/bin/windows/contrib/3.3:
> >
> >cannot open URL 'http://r.findata.org/bin/
> windows/contrib/3.3/PACKAGES'
> >
> > Warning message:
> >
> > package ‘Rbbg’ is not available (for R version 3.3.2)
> >
> >  >
> >
> >
> >
> > Is Rbbg no longer supported ? Has it been usurped by something else ?
> >
> > Does this mean I have to rewrite code or is the new package compatible
> >
> > with code written for Rbbg ?
> >
> >
> >
> > Thanks in advance
> >
> >
> >
> > __
> >
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >
> > https://stat.ethz.ch/mailman/listinfo/r-help
> >
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> >
> > and provide commented, minimal, self-contained, reproducible code.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[R] Predictive analysis based on past data

2016-12-28 Thread Winson Lui
HI,

I have a historical dataset which tells who bought our products. This dataset 
contains ID, Age, Gender and Salary.
I have another set of data which contains the four fields above.
How should I use R to calculate the probability of purchase of each customer in 
the second dataset or whether they would buy our products (T/F)?
Should I use glm function? If yes, how should I approach this?
Thanks.

Regards,
Winson Lui
Business Analyst
M: +44 (0) 79 1714 6247
E: winson@bwinparty.com


[[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] recovering PLSDA equations for prediction (outside R)

2016-12-28 Thread Diego Ruiz Moreno
Hi all,
I'm trying to use the result of a PLSDA model outside R, but I'm having a
really hard time finding documentation on how to write the model from the
results in the fit object.
In order to provide a good starting point I believe that this code creates
a good model that is stored in the fit variable. I know that I can use the
predict function to create the predictions but I would like to "write the
predict function outside R".

Can anyone provide me with the equations? Thanks


# load the package
library(caret)
data(iris)
x <- iris[,1:4]
y <- iris[,5]
# fit model
fit <- plsda(x, y, probMethod="Bayes")
# summarize the fit
summary(fit)
# make predictions
predictions <- predict(fit, iris[,1:4])
# summarize accuracy
table(predictions, iris$Species)

[[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] Reshape to wide format

2016-12-28 Thread David L Carlson
Your original data does not contain a field called year. This will not give you 
what you asked for which was a separate row for each month and you have 
specified month as part of the timevar (columns) and the idvar (rows). Perhaps 
you want year and month to specify the rows using idvar=c("year", "month")? 

---
David L. Carlson
Department of Anthropology
Texas A&M University



From: Miluji Sb [mailto:miluj...@gmail.com] 
Sent: Thursday, December 22, 2016 8:19 AM
To: David L Carlson 
Cc: Jim Lemon ; r-help mailing list 
Subject: Re: [R] Reshape to wide format

Apologies for the late reply. Thank you very much!

I get the following warnings. If I modify the code to add both month and year 
as part of the ID, will it still be correct?

df$ID<-paste(df$iso3,df$lon,df$lat,df$year,df$month,sep="")

wide <- reshape(df, v.names="precip", timevar="ID", idvar="month",
                direction="wide",  drop=c("iso3", "lon", "lat", "year"))

Sincerely,

Milu

warnings()
Warning messages:
1: In reshapeWide(data, idvar = idvar, timevar = timevar,  ... :
  some constant variables (year) are really varying
2: In reshapeWide(data, idvar = idvar, timevar = timevar,  ... :
  multiple rows match for ID=AFG6132: first taken
3: In reshapeWide(data, idvar = idvar, timevar = timevar,  ... :
  multiple rows match for ID=AFG6133: first taken
4: In reshapeWide(data, idvar = idvar, timevar = timevar,  ... :
  multiple rows match for ID=AFG6134: first taken

On Tue, Dec 13, 2016 at 6:21 PM, David L Carlson  wrote:
You can also use function reshape() in stats:

temp$ID<-paste(temp$iso3,temp$lon,temp$lat,sep="")
wide <- reshape(temp, v.names="precip", timevar="ID", idvar="month",
     direction="wide",  drop=c("iso3", "lon", "lat", "dm"))
wide

   month precip.AFG6132 precip.AFG6133
1      1      0.9966658    1.133129032
2      2      0.1567117    0.355208276
3      3      0.2424774    0.307277419
4      4      0.000    0.008316000
5      5      0.000    0.0
6      6      0.000    0.0
7      7      0.000    0.0
8      8      0.000    0.000836129
9      9      0.000             NA
10    10      0.000             NA
11    11      0.1215360             NA
12    12      0.3886606             NA

-
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon
Sent: Tuesday, December 13, 2016 2:59 AM
To: Miluji Sb; r-help mailing list
Subject: Re: [R] Reshape to wide format

Hi Milu,
I may have the wrong idea, but is this what you want?

temp$ID<-paste(temp$iso3,temp$lon,temp$lat,sep="")
library(prettyR)
newtemp<-stretch_df(temp,"month","precip")[,c(5,7,8)]
names(newtemp)<-c("month",unique(temp$ID))

Jim


On Tue, Dec 13, 2016 at 4:10 AM, Miluji Sb  wrote:
> Dear all,
>
> I have the following monthly data by coordinates:
>
> I would like to reshape this data to wide format so that each column is a
> coordinate and each row is a month,
>
> coordinate1 coordinate2 coordinate3...
> Month 1
> Month 2
>
> Is the best option to concatenate the iso3, lon, and lat variables to
> create an ID variable? I realize that this question might be very basic but
> I'm slightly baffled. Thank you.
>
> temp <- dput(head(precip_2000,20))
> structure(list(iso3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("AFG",
> "AGO", "ALB", "ARE", "ARG", "ARM", "AUS", "AUT", "AZE", "BDI",
> "BEL", "BEN", "BFA", "BGD", "BGR", "BHS", "BIH", "BLR", "BLZ",
> "BOL", "BRA", "BRN", "BTN", "BWA", "CAF", "CAN", "CHE", "CHL",
> "CHN", "CIV", "CMR", "COD", "COG", "COL", "CRI", "CUB", "CYP",
> "CZE", "DEU", "DJI", "DNK", "DOM", "DZA", "ECU", "EGY", "ERI",
> "ESH", "ESP", "EST", "ETH", "FIN", "FJI", "FLK", "FRA", "GAB",
> "GBR", "GEO", "GHA", "GIN", "GNB", "GNQ", "GRC", "GRL", "GTM",
> "GUF", "GUY", "HND", "HRV", "HTI", "HUN", "IDN", "IND", "IRL",
> "IRN", "IRQ", "ISL", "ISR", "ITA", "JAM", "JOR", "JPN", "KAZ",
> "KEN", "KGZ", "KHM", "KIR", "KOR", "KWT", "LAO", "LBN", "LBR",
> "LBY", "LCA", "LKA", "LSO", "LTU", "LUX", "LVA", "MAR", "MDA",
> "MDG", "MEX", "MKD", "MLI", "MMR", "MNE", "MNG", "MOZ", "MRT",
> "MWI", "MYS", "NAM", "NCL", "NER", "NGA", "NIC", "NLD", "NOR",
> "NPL", "NZL", "OMN", "PAK", "PAN", "PER", "PHL", "PNG", "POL",
> "PRI", "PRK", "PRT", "PRY", "QAT", "ROU", "RUS", "RWA", "SAU",
> "SDN", "SEN", "SJM", "SLB", "SLE", "SLV", "SOM", "SRB", "SUR",
> "SVK", "SVN", "SWE", "SWZ", "SYR", "TCD", "TGO", "THA", "TJK",
> "TKM", "TLS", "TUN", "TUR", "TWN", "TZA", "UGA", "UKR", "URY",
> "USA", "UZB", "VEN", "VNM", "VUT", "YEM", "ZAF", "ZMB", "ZWE"
> ), class = "factor"), lon = c(61L, 61L, 61L, 61L, 61L, 61L, 61L,
> 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L
> ), lat = c(32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L, 32L,
> 32L, 32L, 33L, 33L,

Re: [R] Rbbg usurped ?

2016-12-28 Thread Dirk Eddelbuettel

On 28 December 2016 at 13:46, John Laing wrote:
| I've cleaned up the findata repository, you should now be able to install
| Rbbg as expected.
| 
| But that said, the package is no longer being actively developed. Recent
| efforts have been taking place in the Rblpapi package. The interface is
| similar, though not strictly compatible. If you're doing much work with
| Bloomberg data I recommend you check it out.

Also, Rblpapi is on CRAN and installs like other packages via

install.packages("Rblpapi")

and update.packages() relieving you from the need to go to findata.org.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
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] Predictive analysis based on past data

2016-12-28 Thread Bert Gunter
This list is about R programming, not statistical methodology,
although there is sometimes an overlap. You should do better posting
to a statistics list like stats.stackexchange.com for queries about
statistics. Although it looks like you may need to do some studying in
a basic regression methods text or online tutorial.

Cheers,
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 Wed, Dec 28, 2016 at 2:23 AM, Winson Lui  wrote:
> HI,
>
> I have a historical dataset which tells who bought our products. This dataset 
> contains ID, Age, Gender and Salary.
> I have another set of data which contains the four fields above.
> How should I use R to calculate the probability of purchase of each customer 
> in the second dataset or whether they would buy our products (T/F)?
> Should I use glm function? If yes, how should I approach this?
> Thanks.
>
> Regards,
> Winson Lui
> Business Analyst
> M: +44 (0) 79 1714 6247
> E: winson@bwinparty.com
>
>
> [[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.


[R] Interpolating Splines: Equidistant Points

2016-12-28 Thread Sidoti, Salvatore A.
I am attempting to smooth the jagged paths of animal tracks to determine their 
distances with greater accuracy. The data is in the form of (x,y) 2D 
coordinates. My end goal is to produce a set of interpolating points whereby 
their Cartesian distances are equal to each other. So far, I have been able to 
produce a path with a specified number of interpolating points via spline(). 
However, these points are not equidistant.

An example data set and my code thus far:

df <- structure(list(x = c(329L, 329L, 329L, 329L, 330L, 330L, 330L, 
330L, 330L, 330L, 330L, 330L, 330L, 330L, 330L, 330L, 330L, 330L, 
330L, 330L, 330L, 330L, 331L, 331L, 331L, 332L, 332L, 333L, 333L, 
333L, 333L, 333L, 333L, 333L, 333L, 333L, 333L, 333L, 334L, 334L, 
334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 
334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 
334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 
334L, 334L, 334L, 334L, 334L, 334L, 334L, 333L, 333L, 332L, 332L, 
332L, 332L, 332L, 332L, 333L, 333L, 333L, 332L, 333L, 331L, 331L, 
330L, 330L, 330L, 330L, 330L, 330L, 330L, 330L, 329L, 329L, 329L, 
329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 
329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 328L, 
327L, 327L, 327L, 327L, 327L, 326L, 326L, 325L, 325L, 325L, 325L, 
325L, 323L, 322L, 321L, 320L, 319L, 319L, 319L, 319L, 319L, 319L
), y = c(255L, 256L, 256L, 256L, 257L, 257L, 257L, 257L, 257L, 
257L, 257L, 257L, 257L, 257L, 258L, 259L, 259L, 259L, 261L, 261L, 
262L, 263L, 263L, 264L, 265L, 266L, 266L, 267L, 268L, 269L, 270L, 
272L, 272L, 273L, 274L, 275L, 275L, 275L, 275L, 275L, 275L, 275L, 
275L, 275L, 275L, 275L, 275L, 275L, 275L, 275L, 275L, 275L, 275L, 
276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 
276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 
276L, 276L, 276L, 276L, 277L, 278L, 278L, 279L, 280L, 281L, 283L, 
284L, 285L, 287L, 288L, 290L, 291L, 291L, 294L, 295L, 297L, 298L, 
299L, 300L, 301L, 302L, 302L, 304L, 305L, 306L, 306L, 308L, 308L, 
308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 
308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 309L, 
310L, 311L, 311L, 312L, 313L, 314L, 315L, 318L, 319L, 320L, 322L, 
323L, 324L, 325L, 325L, 325L, 325L, 326L, 326L, 327L)), .Names = c("x", 
"y"), row.names = c(NA, -150L), class = "data.frame")

require(Momocs)

cumdist <- coo_perimcum(df)
sx <- spline(cumdist, df[, 1], method = "natural", n = 10)
sy <- spline(cumdist, df[, 2], method = "natural", n = 10)
splines <- cbind.data.frame(x = sx$y, y = sy$y)

par(pty = "s")
with(df, plot(x, y, main = "Example Locomotor Path - Cubic Spline Smoothing",
  axes = FALSE, frame.plot = TRUE, type = "l", col = "light gray", 
lwd = 3))
with(splines, lines(x, y, type = "b", col = "red", lwd = 3))

Thank you!

Salvatore A. Sidoti
PhD Student
Behavioral Ecology

__
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] Export R output in Excel

2016-12-28 Thread Bryan Mac
Hi,

How do I export results from R to Excel in a format-friendly way? For example, 
when I copy and paste my results into excel, the formatting is messed up.

Thanks.
 
Bryan Mac
bryanmac...@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] Predictive analysis based on past data

2016-12-28 Thread Vikash Kumar
Collaborative filtering will be helpful.

Regards,
Vikash


On Wed, Dec 28, 2016 at 3:53 PM, Winson Lui 
wrote:

> HI,
>
> I have a historical dataset which tells who bought our products. This
> dataset contains ID, Age, Gender and Salary.
> I have another set of data which contains the four fields above.
> How should I use R to calculate the probability of purchase of each
> customer in the second dataset or whether they would buy our products (T/F)?
> Should I use glm function? If yes, how should I approach this?
> Thanks.
>
> Regards,
> Winson Lui
> Business Analyst
> M: +44 (0) 79 1714 6247
> E: winson@bwinparty.com
>
>
> [[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] [FORGED] Export R output in Excel

2016-12-28 Thread Rolf Turner

On 29/12/16 10:45, Bryan Mac wrote:

Hi,

How do I export results from R to Excel in a format-friendly way? For
example, when I copy and paste my results into excel, the formatting
is messed up.



Short answer:  *Don't*.  ("Friends don't let friends use excel for 
statistics.")


Longer answer:  Googling on "export R data to excel" yields lots of 
"useful" hits --- "useful" given the (false) assertion that it is useful 
to export things to excel.


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] Interpolating Splines: Equidistant Points

2016-12-28 Thread Bert Gunter
I think this is really a statistical issue, not a general r
programming issue, which is what r-help is about.

I think a much better target for this post would be the r-sig-geo
list, where you likely would find the expertise you need.
r-sig-ecology might also work, so you should probably check this out
also.

Cheers,
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 Wed, Dec 28, 2016 at 12:11 PM, Sidoti, Salvatore A.
 wrote:
> I am attempting to smooth the jagged paths of animal tracks to determine 
> their distances with greater accuracy. The data is in the form of (x,y) 2D 
> coordinates. My end goal is to produce a set of interpolating points whereby 
> their Cartesian distances are equal to each other. So far, I have been able 
> to produce a path with a specified number of interpolating points via 
> spline(). However, these points are not equidistant.
>
> An example data set and my code thus far:
>
> df <- structure(list(x = c(329L, 329L, 329L, 329L, 330L, 330L, 330L,
> 330L, 330L, 330L, 330L, 330L, 330L, 330L, 330L, 330L, 330L, 330L,
> 330L, 330L, 330L, 330L, 331L, 331L, 331L, 332L, 332L, 333L, 333L,
> 333L, 333L, 333L, 333L, 333L, 333L, 333L, 333L, 333L, 334L, 334L,
> 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L,
> 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L,
> 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L, 334L,
> 334L, 334L, 334L, 334L, 334L, 334L, 334L, 333L, 333L, 332L, 332L,
> 332L, 332L, 332L, 332L, 333L, 333L, 333L, 332L, 333L, 331L, 331L,
> 330L, 330L, 330L, 330L, 330L, 330L, 330L, 330L, 329L, 329L, 329L,
> 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L,
> 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 329L, 328L,
> 327L, 327L, 327L, 327L, 327L, 326L, 326L, 325L, 325L, 325L, 325L,
> 325L, 323L, 322L, 321L, 320L, 319L, 319L, 319L, 319L, 319L, 319L
> ), y = c(255L, 256L, 256L, 256L, 257L, 257L, 257L, 257L, 257L,
> 257L, 257L, 257L, 257L, 257L, 258L, 259L, 259L, 259L, 261L, 261L,
> 262L, 263L, 263L, 264L, 265L, 266L, 266L, 267L, 268L, 269L, 270L,
> 272L, 272L, 273L, 274L, 275L, 275L, 275L, 275L, 275L, 275L, 275L,
> 275L, 275L, 275L, 275L, 275L, 275L, 275L, 275L, 275L, 275L, 275L,
> 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L,
> 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L, 276L,
> 276L, 276L, 276L, 276L, 277L, 278L, 278L, 279L, 280L, 281L, 283L,
> 284L, 285L, 287L, 288L, 290L, 291L, 291L, 294L, 295L, 297L, 298L,
> 299L, 300L, 301L, 302L, 302L, 304L, 305L, 306L, 306L, 308L, 308L,
> 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L,
> 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 308L, 309L,
> 310L, 311L, 311L, 312L, 313L, 314L, 315L, 318L, 319L, 320L, 322L,
> 323L, 324L, 325L, 325L, 325L, 325L, 326L, 326L, 327L)), .Names = c("x",
> "y"), row.names = c(NA, -150L), class = "data.frame")
>
> require(Momocs)
>
> cumdist <- coo_perimcum(df)
> sx <- spline(cumdist, df[, 1], method = "natural", n = 10)
> sy <- spline(cumdist, df[, 2], method = "natural", n = 10)
> splines <- cbind.data.frame(x = sx$y, y = sy$y)
>
> par(pty = "s")
> with(df, plot(x, y, main = "Example Locomotor Path - Cubic Spline Smoothing",
>   axes = FALSE, frame.plot = TRUE, type = "l", col = "light 
> gray", lwd = 3))
> with(splines, lines(x, y, type = "b", col = "red", lwd = 3))
>
> Thank you!
>
> Salvatore A. Sidoti
> PhD Student
> Behavioral Ecology
>
> __
> 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] [FORGED] Export R output in Excel

2016-12-28 Thread Rolf Turner

On 29/12/16 12:48, Bryan Mac wrote:

Hi Rolf,

I wanted to export the output/results of R to an Excel file for
easier comparisons/reporting. When I tried to copy and paste my
output to an excel file the formatting was off. I want to export my
descriptive stats and the linear regression.


This makes little to no sense to me.  Spreadsheets are for use in 
storing data, not for displaying the output of analyses.  (I know that 
Excel users do this sort of thing, but then people do all sorts of 
irrational things.)



I googled “Export R output to excel” but did not find most of the
hints “useful”. if anything, it got me more confused.

Thanks.


(1) The best advice is still "*Don't*."

(2) You do not need Excel to make comparisons and report.  In fact it is 
a handicap.  Re-think your strategy.


(3) If you insist in proceeding in a wrong-headed manner, isn't the item 
about XLConnect (3rd answer, 1st hit) "useful"?


cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] [FORGED] Export R output in Excel

2016-12-28 Thread Bryan Mac
Hi Rolf,

I wanted to export the output/results of R to an Excel file for easier 
comparisons/reporting. When I tried to copy and paste my output to an excel 
file the formatting was off.
I want to export my descriptive stats and the linear regression.

I googled “Export R output to excel” but did not find most of the hints 
“useful”. if anything, it got me more confused. 

Thanks.

Bryan Mac
bryanmac...@gmail.com



> On Dec 28, 2016, at 3:15 PM, Rolf Turner  wrote:
> 
> On 29/12/16 10:45, Bryan Mac wrote:
>> Hi,
>> 
>> How do I export results from R to Excel in a format-friendly way? For
>> example, when I copy and paste my results into excel, the formatting
>> is messed up.
> 
> 
> Short answer:  *Don't*.  ("Friends don't let friends use excel for 
> statistics.")
> 
> Longer answer:  Googling on "export R data to excel" yields lots of "useful" 
> hits --- "useful" given the (false) assertion that it is useful to export 
> things to excel.
> 
> cheers,
> 
> Rolf Turner
> 
> -- 
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276

__
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] Export R output in Excel

2016-12-28 Thread Jim Lemon
Hi Bryan,
When I have to do something like this, I usually go through HTML
output and import it into MS Word. I am not suggesting that this is
the best thing to do, but it might get you out of trouble. I'm not
sure whether importing HTML into Excel will work as well. I assume
that you are running analyses in R and want to export the output that
appears in the console window. If so, try producing HTML output with
the prettyR or R2HTML packages and importing it. There are other ways
to do this, but the learning curve is steep and you might not want to
climb it right now.

Jim


On Thu, Dec 29, 2016 at 8:45 AM, Bryan Mac  wrote:
> Hi,
>
> How do I export results from R to Excel in a format-friendly way? For 
> example, when I copy and paste my results into excel, the formatting is 
> messed up.
>
> Thanks.
>
> Bryan Mac
> bryanmac...@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.

__
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] How to overlay lines and rectangles in lattice plot key

2016-12-28 Thread sbihorel

Hi,

I would like to create a custom key for a lattice xyplot in which line 
elements are displayed on top of rectangle elements. In the example code 
below, the lines and rectangles are shown side by side (the legend 
itself is meaningless, but that is not the point). Is there a way to 
overlay these key elements (but not the text)?


Thanks

xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
  iris,
  type = c("p", "r"),
  jitter.x = TRUE,
  jitter.y = TRUE,
  factor = 5,
  key = list(
column=4,
text=list(lab=letters[1:4]),
lines=list(col=1:4, pch=1:4, type='b'),
rectangles=list(col=1:4, alpha=0.25, border=FALSE)
  )
)

__
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] Export R output in Excel

2016-12-28 Thread Omar André Gonzáles Díaz
use "write.csv("you-df", "name-of-file.csv", row.names = FALSE).

And Google please, as others have suggested.

2016-12-28 21:33 GMT-05:00 Jim Lemon :

> Hi Bryan,
> When I have to do something like this, I usually go through HTML
> output and import it into MS Word. I am not suggesting that this is
> the best thing to do, but it might get you out of trouble. I'm not
> sure whether importing HTML into Excel will work as well. I assume
> that you are running analyses in R and want to export the output that
> appears in the console window. If so, try producing HTML output with
> the prettyR or R2HTML packages and importing it. There are other ways
> to do this, but the learning curve is steep and you might not want to
> climb it right now.
>
> Jim
>
>
> On Thu, Dec 29, 2016 at 8:45 AM, Bryan Mac  wrote:
> > Hi,
> >
> > How do I export results from R to Excel in a format-friendly way? For
> example, when I copy and paste my results into excel, the formatting is
> messed up.
> >
> > Thanks.
> >
> > Bryan Mac
> > bryanmac...@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.
>
> __
> 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] How to overlay lines and rectangles in lattice plot key

2016-12-28 Thread David Winsemius

> On Dec 28, 2016, at 6:50 PM, sbihorel  
> wrote:
> 
> Hi,
> 
> I would like to create a custom key for a lattice xyplot in which line 
> elements are displayed on top of rectangle elements. In the example code 
> below, the lines and rectangles are shown side by side (the legend itself is 
> meaningless, but that is not the point). Is there a way to overlay these key 
> elements (but not the text)?
> 
> Thanks
> 
> xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
>  iris,
>  type = c("p", "r"),
>  jitter.x = TRUE,
>  jitter.y = TRUE,
>  factor = 5,
>  key = list(
>column=4,
>text=list(lab=letters[1:4]),
>lines=list(col=1:4, pch=1:4, type='b'),
>rectangles=list(col=1:4, alpha=0.25, border=FALSE)
>  )
> )

I'm not seeing the result that you describe. Attached is the pdf that comes 
from:

 pdf(); print( xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
 iris,
 type = c("p", "r"),
 jitter.x = TRUE,
 jitter.y = TRUE,
 factor = 5,
 key = list(
   column=4,
   text=list(lab=letters[1:4]),
   lines=list(col=1:4, pch=1:4, type='b'),
   rectangles=list(col=1:4, alpha=0.25, border=FALSE)
 )
) ); dev.off()



Rplots.pdf
Description: Adobe PDF document


-- 
David Winsemius
Alameda, CA, USA

__
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] Need Help, Unable to find the problem in R Script

2016-12-28 Thread David Winsemius

> On Dec 27, 2016, at 7:28 PM, amit rathee  
> wrote:
> 
> R/Sir,    i am trying to find 
> precision and recall value for multi class software clustering problem using 
> package "ClusterCrit"i have attached my source code 
> "Clustering.txt" and input files "ClassCoupling.txt" 
> & "JUnitGoldStandard"in my script for different combination of 
> clustering i am getting same value of precision & recall, which i think 
> should not be?Kindly helpThanks in advanceAMIT RATHEEResearch Scholar


> 

> 

You posted two files with a difficult to parse message. You should ask 
_yourself_ whether a person who saved those two files to his working directory 
could expect that code file to actually process that data file. I seriously 
doubt that effort would be successful.


> __
> 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.

David Winsemius
Alameda, CA, USA

__
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] How to overlay lines and rectangles in lattice plot key

2016-12-28 Thread Richard M. Heiberger
Yes, but it will probably require work.  I think you will need to
write a grob that does what you want
and then use the grob in a legend statement in the xyplot.

Start with the 'legend' argument to xyplot (about line 940 in ?xyplot).
You will probably need to work directly with grid functions and will
find Paul Murrell's book very helpful.
https://www.crcpress.com/R-Graphics/Murrell/p/book/9781584884866

Rich

On Wed, Dec 28, 2016 at 9:50 PM, sbihorel
 wrote:
> Hi,
>
> I would like to create a custom key for a lattice xyplot in which line
> elements are displayed on top of rectangle elements. In the example code
> below, the lines and rectangles are shown side by side (the legend itself is
> meaningless, but that is not the point). Is there a way to overlay these key
> elements (but not the text)?
>
> Thanks
>
> xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
>   iris,
>   type = c("p", "r"),
>   jitter.x = TRUE,
>   jitter.y = TRUE,
>   factor = 5,
>   key = list(
> column=4,
> text=list(lab=letters[1:4]),
> lines=list(col=1:4, pch=1:4, type='b'),
> rectangles=list(col=1:4, alpha=0.25, border=FALSE)
>   )
> )
>
> __
> 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] How to overlay lines and rectangles in lattice plot key

2016-12-28 Thread Duncan Mackay
Hi

Is this something like what you are looking for?
I have put it on the right and heights etc are just a quick guess. (all i
have time for)
It may be a little too complicated for what you want but I thought  of this
first based on your description rather than the plot.

library(grid)
library(lattice)

# legend
XY04.glay <-
grid.layout(nrow = 8,
ncol = 2,
heights = unit(rep(1, 2), rep("cm", 2)),
widths  = unit(c(0.4, 0.8),
   c("in","in")),
just = "centre")

XY04.fmG <- frameGrob(layout = XY04.glay)

k <-0
for (j in seq(1,8,2)){
  k = k+1
  
  XY04.fmG <-
  placeGrob(XY04.fmG, textGrob(lab = letters[1:4][k],
 just = 0,
 gp = gpar(cex = 0.8)), row = j, col = 1)
  XY04.fmG <-
  placeGrob(XY04.fmG, linesGrob(c(0.2,0.8),  c(0.5, 0.5),
  gp = gpar(col = c(1:4)[k])), row = j, col = 2)
  XY04.fmG <-
  placeGrob(XY04.fmG, pointsGrob(c(0.2,0.8),  c(0.5, 0.5),
  pch = j,
  gp = gpar(cex = 0.7, col = c(1:4)[k])), row =
j, col = 2)
}
k = 0
for (j in seq(2,8,2)){
  k = k+1
  XY04.fmG <-
  placeGrob(XY04.fmG, rectGrob(width = 0.6,
   gp = gpar(col=k,
 alpha = 0.25,
 fill = k)), row = j, col = 2)

}

xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
   iris,
   type = c("p", "r"),
   jitter.x = TRUE,
   jitter.y = TRUE,
   factor = 5,
   legend = list(right = list(fun = XY04.fmG))
)


Have a look at https://stat.ethz.ch/pipermail/r-help/2005-April/069459.html
and the following emails on the thread.

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 sbihorel
Sent: Thursday, 29 December 2016 13:51
To: r-help@r-project.org
Subject: [R] How to overlay lines and rectangles in lattice plot key

Hi,

I would like to create a custom key for a lattice xyplot in which line 
elements are displayed on top of rectangle elements. In the example code 
below, the lines and rectangles are shown side by side (the legend 
itself is meaningless, but that is not the point). Is there a way to 
overlay these key elements (but not the text)?

Thanks

xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
   iris,
   type = c("p", "r"),
   jitter.x = TRUE,
   jitter.y = TRUE,
   factor = 5,
   key = list(
 column=4,
 text=list(lab=letters[1:4]),
 lines=list(col=1:4, pch=1:4, type='b'),
 rectangles=list(col=1:4, alpha=0.25, border=FALSE)
   )
)

__
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] How to overlay lines and rectangles in lattice plot key

2016-12-28 Thread Richard M. Heiberger
I think the intended appearance is closer to this

xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
  iris,
  type = c("p", "r"),
  jitter.x = TRUE,
  jitter.y = TRUE,
  factor = 5,
  key = list(between=c(-4.5),
column=4,
text=list(lab=paste0("   ", letters[1:4], "   ")),
lines=list(col=1:4, pch=1:4, type='b'),
rectangles=list(col=1:4, alpha=0.25, border=FALSE)
  )
)

I have the partial overlap of the rectangles and the line-point objects.
They don't align correctly.  I think even more complex grid usage is needed than
Duncan provided.

Rich


On Thu, Dec 29, 2016 at 12:16 AM, Duncan Mackay  wrote:
> Hi
>
> Is this something like what you are looking for?
> I have put it on the right and heights etc are just a quick guess. (all i
> have time for)
> It may be a little too complicated for what you want but I thought  of this
> first based on your description rather than the plot.
>
> library(grid)
> library(lattice)
>
> # legend
> XY04.glay <-
> grid.layout(nrow = 8,
> ncol = 2,
> heights = unit(rep(1, 2), rep("cm", 2)),
> widths  = unit(c(0.4, 0.8),
>c("in","in")),
> just = "centre")
>
> XY04.fmG <- frameGrob(layout = XY04.glay)
>
> k <-0
> for (j in seq(1,8,2)){
>   k = k+1
>
>   XY04.fmG <-
>   placeGrob(XY04.fmG, textGrob(lab = letters[1:4][k],
>  just = 0,
>  gp = gpar(cex = 0.8)), row = j, col = 1)
>   XY04.fmG <-
>   placeGrob(XY04.fmG, linesGrob(c(0.2,0.8),  c(0.5, 0.5),
>   gp = gpar(col = c(1:4)[k])), row = j, col = 2)
>   XY04.fmG <-
>   placeGrob(XY04.fmG, pointsGrob(c(0.2,0.8),  c(0.5, 0.5),
>   pch = j,
>   gp = gpar(cex = 0.7, col = c(1:4)[k])), row =
> j, col = 2)
> }
> k = 0
> for (j in seq(2,8,2)){
>   k = k+1
>   XY04.fmG <-
>   placeGrob(XY04.fmG, rectGrob(width = 0.6,
>gp = gpar(col=k,
>  alpha = 0.25,
>  fill = k)), row = j, col = 2)
>
> }
>
> xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
>iris,
>type = c("p", "r"),
>jitter.x = TRUE,
>jitter.y = TRUE,
>factor = 5,
>legend = list(right = list(fun = XY04.fmG))
> )
>
>
> Have a look at https://stat.ethz.ch/pipermail/r-help/2005-April/069459.html
> and the following emails on the thread.
>
> 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 sbihorel
> Sent: Thursday, 29 December 2016 13:51
> To: r-help@r-project.org
> Subject: [R] How to overlay lines and rectangles in lattice plot key
>
> Hi,
>
> I would like to create a custom key for a lattice xyplot in which line
> elements are displayed on top of rectangle elements. In the example code
> below, the lines and rectangles are shown side by side (the legend
> itself is meaningless, but that is not the point). Is there a way to
> overlay these key elements (but not the text)?
>
> Thanks
>
> xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
>iris,
>type = c("p", "r"),
>jitter.x = TRUE,
>jitter.y = TRUE,
>factor = 5,
>key = list(
>  column=4,
>  text=list(lab=letters[1:4]),
>  lines=list(col=1:4, pch=1:4, type='b'),
>  rectangles=list(col=1:4, alpha=0.25, border=FALSE)
>)
> )
>
> __
> 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.

__
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] Export R output in Excel

2016-12-28 Thread PIKAL Petr
Hi

For rectangular data

write.table(tab, "clipboard", sep = "\t", row.names = F)
followed by Ctrl-V in Excel

or
write.table(tab, "somefile.xls", sep = "\t", row.names = F)

For free format output like summary(somefit) I prefer to copy it to Word and 
use font like  Courier New with monospaced letters

Cheers
Petr


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bryan Mac
> Sent: Wednesday, December 28, 2016 10:45 PM
> To: R-help@r-project.org
> Subject: [R] Export R output in Excel
>
> Hi,
>
> How do I export results from R to Excel in a format-friendly way? For
> example, when I copy and paste my results into excel, the formatting is
> messed up.
>
> Thanks.
>
> Bryan Mac
> bryanmac...@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.


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 contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
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] How to overlay lines and rectangles in lattice plot key

2016-12-28 Thread Duncan Mackay
Hi 

It makes it easier

library(grid)
library(lattice)

# legend
XY04.glay <-
grid.layout(nrow = 4,
ncol = 2,
heights = unit(rep(1, 2), rep("cm", 2)),
widths  = unit(c(0.4, 0.8),
   c("in","in")),
just = "centre")

XY04.fmG <- frameGrob(layout = XY04.glay)

k <-0
for (j in seq_len(4)){

  XY04.fmG <-
  placeGrob(XY04.fmG, textGrob(lab = letters[j],
 just = 0,
 gp = gpar(cex = 0.8)), row = j, col = 1)
  XY04.fmG <-
  placeGrob(XY04.fmG, rectGrob(width = 0.6,
   gp = gpar(col=j,
 alpha = 0.25,
 fill = j)), row = j, col = 2)
  XY04.fmG <-
  placeGrob(XY04.fmG, linesGrob(c(0.2,0.8),  c(0.5, 0.5),
  gp = gpar(col = j)), row = j, col = 2)
  XY04.fmG <-
  placeGrob(XY04.fmG, pointsGrob(x = unit(1, "cm"), y = unit(0.5, "npc"),
  pch = j,
  #width = unit(2, "cm"),
  gp = gpar(cex = 0.7, col = j)), row = j, col =
2)
}

xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
   iris,
   type = c("p", "r"),
   jitter.x = TRUE,
   jitter.y = TRUE,
   factor = 5,
   legend = list(right = list(fun = XY04.fmG))
)

This gives 1 point instead of 2 or 3.
The OP needs to change the format and fix the heights of the rectangles etc.
I also fixed the colour vectors had j instead of k


Duncan

-Original Message-
From: Duncan Mackay [mailto:dulca...@bigpond.com] 
Sent: Thursday, 29 December 2016 16:17
To: R
Subject: RE: [R] How to overlay lines and rectangles in lattice plot key

Hi

Is this something like what you are looking for?
I have put it on the right and heights etc are just a quick guess. (all i
have time for)
It may be a little too complicated for what you want but I thought  of this
first based on your description rather than the plot.

library(grid)
library(lattice)

# legend
XY04.glay <-
grid.layout(nrow = 8,
ncol = 2,
heights = unit(rep(1, 2), rep("cm", 2)),
widths  = unit(c(0.4, 0.8),
   c("in","in")),
just = "centre")

XY04.fmG <- frameGrob(layout = XY04.glay)

k <-0
for (j in seq(1,8,2)){
  k = k+1
  
  XY04.fmG <-
  placeGrob(XY04.fmG, textGrob(lab = letters[1:4][k],
 just = 0,
 gp = gpar(cex = 0.8)), row = j, col = 1)
  XY04.fmG <-
  placeGrob(XY04.fmG, linesGrob(c(0.2,0.8),  c(0.5, 0.5),
  gp = gpar(col = c(1:4)[k])), row = j, col = 2)
  XY04.fmG <-
  placeGrob(XY04.fmG, pointsGrob(c(0.2,0.8),  c(0.5, 0.5),
  pch = j,
  gp = gpar(cex = 0.7, col = c(1:4)[k])), row =
j, col = 2)
}
k = 0
for (j in seq(2,8,2)){
  k = k+1
  XY04.fmG <-
  placeGrob(XY04.fmG, rectGrob(width = 0.6,
   gp = gpar(col=k,
 alpha = 0.25,
 fill = k)), row = j, col = 2)

}

xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
   iris,
   type = c("p", "r"),
   jitter.x = TRUE,
   jitter.y = TRUE,
   factor = 5,
   legend = list(right = list(fun = XY04.fmG))
)


Have a look at https://stat.ethz.ch/pipermail/r-help/2005-April/069459.html
and the following emails on the thread.

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 sbihorel
Sent: Thursday, 29 December 2016 13:51
To: r-help@r-project.org
Subject: [R] How to overlay lines and rectangles in lattice plot key

Hi,

I would like to create a custom key for a lattice xyplot in which line 
elements are displayed on top of rectangle elements. In the example code 
below, the lines and rectangles are shown side by side (the legend 
itself is meaningless, but that is not the point). Is there a way to 
overlay these key elements (but not the text)?

Thanks

xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
   iris,
   type = c("p", "r"),
   jitter.x = TRUE,
   jitter.y = TRUE,
   factor = 5,
   key = list(
 column=4,
 text=list(lab=letters[1:4]),
 lines=list(col=1:4, pch=1:4, type='b'),
 rectangles=list(col=1:4, alpha=0.25, border=FALSE)
   )
)

__
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-h

Re: [R] Rbbg usurped ?

2016-12-28 Thread Tolga Uzuner
Many thanks John, Bush, Dirk.

Kind regards

> On Dec 28, 2016, at 9:57 PM, Dirk Eddelbuettel  wrote:
> 
> 
> On 28 December 2016 at 13:46, John Laing wrote:
> | I've cleaned up the findata repository, you should now be able to install
> | Rbbg as expected.
> | 
> | But that said, the package is no longer being actively developed. Recent
> | efforts have been taking place in the Rblpapi package. The interface is
> | similar, though not strictly compatible. If you're doing much work with
> | Bloomberg data I recommend you check it out.
> 
> Also, Rblpapi is on CRAN and installs like other packages via
> 
>install.packages("Rblpapi")
> 
> and update.packages() relieving you from the need to go to findata.org.
> 
> Dirk
> 
> -- 
> http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
>

__
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] How to overlay lines and rectangles in lattice plot key

2016-12-28 Thread Duncan Mackay
I forgot to change the xyplot for the colours; if you want the same colours
in the key you need to use the par.settings argument or set the settings for
the device.

the xyplot becomes

xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
   iris,
   par.settings = list(superpose.symbol = list(col = 1:4,
   cex = 1,
   pch = 1:4),
   superpose.line = list(col = 1:4)
  ),
   type = c("p", "r"),
   jitter.x = TRUE,
   jitter.y = TRUE,
   factor = 5,
   legend = list(right = list(fun = XY04.fmG))
)
 
Duncan

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan
Mackay
Sent: Thursday, 29 December 2016 18:21
To: R
Subject: Re: [R] How to overlay lines and rectangles in lattice plot key

Hi 

It makes it easier

library(grid)
library(lattice)

# legend
XY04.glay <-
grid.layout(nrow = 4,
ncol = 2,
heights = unit(rep(1, 2), rep("cm", 2)),
widths  = unit(c(0.4, 0.8),
   c("in","in")),
just = "centre")

XY04.fmG <- frameGrob(layout = XY04.glay)

k <-0
for (j in seq_len(4)){

  XY04.fmG <-
  placeGrob(XY04.fmG, textGrob(lab = letters[j],
 just = 0,
 gp = gpar(cex = 0.8)), row = j, col = 1)
  XY04.fmG <-
  placeGrob(XY04.fmG, rectGrob(width = 0.6,
   gp = gpar(col=j,
 alpha = 0.25,
 fill = j)), row = j, col = 2)
  XY04.fmG <-
  placeGrob(XY04.fmG, linesGrob(c(0.2,0.8),  c(0.5, 0.5),
  gp = gpar(col = j)), row = j, col = 2)
  XY04.fmG <-
  placeGrob(XY04.fmG, pointsGrob(x = unit(1, "cm"), y = unit(0.5, "npc"),
  pch = j,
  #width = unit(2, "cm"),
  gp = gpar(cex = 0.7, col = j)), row = j, col =
2)
}

xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
   iris,
   type = c("p", "r"),
   jitter.x = TRUE,
   jitter.y = TRUE,
   factor = 5,
   legend = list(right = list(fun = XY04.fmG))
)

This gives 1 point instead of 2 or 3.
The OP needs to change the format and fix the heights of the rectangles etc.
I also fixed the colour vectors had j instead of k


Duncan

-Original Message-
From: Duncan Mackay [mailto:dulca...@bigpond.com] 
Sent: Thursday, 29 December 2016 16:17
To: R
Subject: RE: [R] How to overlay lines and rectangles in lattice plot key

Hi

Is this something like what you are looking for?
I have put it on the right and heights etc are just a quick guess. (all i
have time for)
It may be a little too complicated for what you want but I thought  of this
first based on your description rather than the plot.

library(grid)
library(lattice)

# legend
XY04.glay <-
grid.layout(nrow = 8,
ncol = 2,
heights = unit(rep(1, 2), rep("cm", 2)),
widths  = unit(c(0.4, 0.8),
   c("in","in")),
just = "centre")

XY04.fmG <- frameGrob(layout = XY04.glay)

k <-0
for (j in seq(1,8,2)){
  k = k+1
  
  XY04.fmG <-
  placeGrob(XY04.fmG, textGrob(lab = letters[1:4][k],
 just = 0,
 gp = gpar(cex = 0.8)), row = j, col = 1)
  XY04.fmG <-
  placeGrob(XY04.fmG, linesGrob(c(0.2,0.8),  c(0.5, 0.5),
  gp = gpar(col = c(1:4)[k])), row = j, col = 2)
  XY04.fmG <-
  placeGrob(XY04.fmG, pointsGrob(c(0.2,0.8),  c(0.5, 0.5),
  pch = j,
  gp = gpar(cex = 0.7, col = c(1:4)[k])), row =
j, col = 2)
}
k = 0
for (j in seq(2,8,2)){
  k = k+1
  XY04.fmG <-
  placeGrob(XY04.fmG, rectGrob(width = 0.6,
   gp = gpar(col=k,
 alpha = 0.25,
 fill = k)), row = j, col = 2)

}

xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width,
   iris,
   type = c("p", "r"),
   jitter.x = TRUE,
   jitter.y = TRUE,
   factor = 5,
   legend = list(right = list(fun = XY04.fmG))
)


Have a look at https://stat.ethz.ch/pipermail/r-help/2005-April/069459.html
and the following emails on the thread.

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 sbihorel
Sent: Thursday, 29 December 2016 13:51
To: r-help@r-project.org
Subject: [R] How to overlay lines and rectangles in lattice plot key

Hi,

I would like to create a custom key for a lattice xyplot in which line 
elements are displayed on top of rectangle elements. In the example code 
below, the lines and rectangles are shown side by side (the legend 
itself is meaningless, but that is no