Re: [R] isssues with predict.coxph, offset, type = "expected", and newdata

2016-10-02 Thread David James
Thanks Terry,

Re: the second case (predicting from a null model with a newdata=
argument), I agree that it looks a bit over the top for such a
straight forward computation, so maybe it is more a wish than anything
else.  In this one instance, this computation is embedded in a wider
multi-state simulation in Epi::simLexis() where transition hazards are
modeled  as functions of covariates via Cox proportional hazards, and
a subset of transitions happen not to depend on any covariate, thus
the null model(s).   There are ways to circumvent this special case
within Epi::simLexis(), so even in this one example I wouldn't
consider it high priority at all.  But maybe it would be nice to have.


On Sat, Oct 1, 2016 at 10:44 PM, Therneau, Terry M., Ph.D.
 wrote:
> I'm off on vacation and checking email only intermittently.
> Wrt the offset issue, I expect that you are correct.  This is not a case that 
> I had ever envisioned, and so was not on my "list" when writing the code and 
> certainly has no test case.  That does not mean that it shouldn't work, just 
> that I am not shocked to see it.   I will look into this.
>
> For the second case of a NULL model I am less sympathetic.  This is, in 
> theory, just reading off values from a Nelson hazard estimate at specific 
> time points; using a coxph call to do so is a case of swatting a fly with a 
> hammer.   A bit more background might make me more excited about extending 
> the code to this case.
>
> Terry Therneau

__
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] Font problem.

2016-10-02 Thread Jeff Newmiller
There is R-sig-debian (Ubuntu is a derivative of Debian), but to be honest, 
this seems more like a question for askubuntu.com.
-- 
Sent from my phone. Please excuse my brevity.

On October 2, 2016 1:55:59 PM PDT, Rolf Turner  wrote:
>
>Dunno exactly whom I should ask about this problem, but I thought I'd 
>start with good old r-help.
>
>I have recently acquired a new laptop, and have installed Ubuntu 16.04 
>on it.  Still having some teething problems.
>
>If I do
>
>plot(1:10,ylab=expression(italic(J(r)))
>
>I get the error:
>
>Error in title(...) :
>   X11 font -*-courier-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 5 at size 15 
>could not be loaded
>
>So it would seem that I am missing a font.  Fonts have always been a 
>complete mystery to me.  Can anyone suggest how I might rectify this 
>deficiency in the fonts on my system?  If so, *please* be as explicit
>as 
>you can in your instructions; I am all at sea here.
>
>cheers,
>
>Rolf Turner
>
>P. S.  I have also just noticed that if I do:
>
>plot(1:10,ylab=expression(alpha))
>
>I get an "a" as the y-axis label, rather than the Greek letter alpha.
>
>Likewise if I do plot(1:10,ylab=expression(Sigma)) I get a capital "S" 
>rather than an upper case Greek Sigma symbol.  No error thrown, but.
>
>Any ideas as to how to fix this problem?
>
>For what it's worth, here is my sessionInfo():
>
>R version 3.3.1 (2016-06-21)
>Platform: x86_64-pc-linux-gnu (64-bit)
>Running under: Ubuntu 16.04.1 LTS
>
>locale:
>  [1] LC_CTYPE=en_NZ.UTF-8   LC_NUMERIC=C
>  [3] LC_TIME=en_NZ.UTF-8LC_COLLATE=en_NZ.UTF-8
>  [5] LC_MONETARY=en_NZ.UTF-8LC_MESSAGES=en_NZ.UTF-8
>  [7] LC_PAPER=en_NZ.UTF-8   LC_NAME=C
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
>[11] LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C
>
>attached base packages:
>[1] stats graphics  grDevices utils datasets  methods   base
>
>other attached packages:
>[1] misc_0.0-16
>
>loaded via a namespace (and not attached):
>  [1] deldir_0.1-13   Matrix_1.2-3mgcv_1.8-12
>  [4] abind_1.4-3 spatstat_1.46-1.036 rpart_4.1-10
>  [7] nlme_3.1-128grid_3.3.1  polyclip_1.5-0
>[10] lattice_0.20-33 goftest_1.0-3   tensor_1.5
>
>R. T.

__
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] Font problem.

2016-10-02 Thread Jim Lemon
Hi Rolf,
I would try using dnf (or whatever the Ubuntu equivalent is) to
install the X11 fonts. You may have a GUI method for this in Ubuntu.

Jim


On Mon, Oct 3, 2016 at 7:55 AM, Rolf Turner  wrote:
>
> Dunno exactly whom I should ask about this problem, but I thought I'd start
> with good old r-help.
>
> I have recently acquired a new laptop, and have installed Ubuntu 16.04 on
> it.  Still having some teething problems.
>
> If I do
>
> plot(1:10,ylab=expression(italic(J(r)))
>
> I get the error:
>
> Error in title(...) :
>   X11 font -*-courier-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 5 at size 15 could
> not be loaded
>
> So it would seem that I am missing a font.  Fonts have always been a
> complete mystery to me.  Can anyone suggest how I might rectify this
> deficiency in the fonts on my system?  If so, *please* be as explicit as you
> can in your instructions; I am all at sea here.
>
> cheers,
>
> Rolf Turner
>
> P. S.  I have also just noticed that if I do:
>
> plot(1:10,ylab=expression(alpha))
>
> I get an "a" as the y-axis label, rather than the Greek letter alpha.
>
> Likewise if I do plot(1:10,ylab=expression(Sigma)) I get a capital "S"
> rather than an upper case Greek Sigma symbol.  No error thrown, but.
>
> Any ideas as to how to fix this problem?
>
> For what it's worth, here is my sessionInfo():
>
> R version 3.3.1 (2016-06-21)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 16.04.1 LTS
>
> locale:
>  [1] LC_CTYPE=en_NZ.UTF-8   LC_NUMERIC=C
>  [3] LC_TIME=en_NZ.UTF-8LC_COLLATE=en_NZ.UTF-8
>  [5] LC_MONETARY=en_NZ.UTF-8LC_MESSAGES=en_NZ.UTF-8
>  [7] LC_PAPER=en_NZ.UTF-8   LC_NAME=C
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> other attached packages:
> [1] misc_0.0-16
>
> loaded via a namespace (and not attached):
>  [1] deldir_0.1-13   Matrix_1.2-3mgcv_1.8-12
>  [4] abind_1.4-3 spatstat_1.46-1.036 rpart_4.1-10
>  [7] nlme_3.1-128grid_3.3.1  polyclip_1.5-0
> [10] lattice_0.20-33 goftest_1.0-3   tensor_1.5
>
> R. T.
>
> --
> 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.

__
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] Histogram using Sturges' Bining Errors

2016-10-02 Thread Jim Lemon
Hi Elysa,
This is pretty much a guess. If you understand the first error, i.e.
that there are nine rows in your input data frame (?) that contain NA,
NaN, or Inf values, have you tried manually removing those rows and
feeding the remainder to your code?

Jim


On Sun, Oct 2, 2016 at 7:19 PM, Elysa Mitova  wrote:
> Histogram using Sturges' bining
>
> Hello,
>
> I am trying to create a histogram using Sturges' bining rule, yet I keep
> getting 2 errors, which probably have to do with the variable I am using.
>
> Here is my process and the errors, what would you suggest?
>
> k <- ggplot (world, aes (x=polstab))
>
> wid <- ceiling ((max(world$polstab)- min (world$polstab))/
> nclass.Sturges(world$polstab))
>
> k + geom_histogram(col = "black", fill = "white", binwidth = wid)
>
> Now, I get two error messages:
>
> 1: Removed 9 rows containing non-finite values (stat_bin).
> 2: Computation failed in `stat_bin()`:
> missing value where TRUE/FALSE needed
>
> The first one I understand, the second one is more problematic. What could
> I do to remove this error?
>
>
>
> Thank you in advance!
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] BCa confidence bands around fitted curves MARS regression

2016-10-02 Thread varin sacha via R-help
Hi,
So, I can draw/plot the usual 95% least squares confidence bands around the 3 
fitted curves for MARS regression, but I don't know how to get the 95% BCa 
bootstrapped confidence bands. 

Any help would be highly appreciated.


Reproducible example :


##

Dataset = 
data.frame(PIBparHab=c(43931,67524,48348,44827,52409,15245,24453,57636,28992,17102,51495,47243,40908,22494,12784,48391,44221,32514,35132,46679,106022,9817,99635,38678,49128,12876,20732,17151,19670,41053,22488,57134,83295,10660),
  
QUALITESANSREDONDANCE=c(1082.5,1066.6,1079.3,1079.9,1074.9,1008.6,1007.5,.3,1108.2,1109.7,1059.6,1165.1,1026.7,1035.1,997.8,1044.8,1073.6,1085.7,1083.8,1021.6,1036.2,1075.3,1069.3,1101.4,1086.9,1072.1,1166.7,983.9,1004.5,1082.5,1123.5,1094.9,1105.1,1010.8),
  
competitivite=c(89,83,78,73,90,71,77,85,61,67,98,82,70,43,57,78,72,79,61,71,86,63,90,75,87,64,60,56,66,80,53,91,97,62),
  
innovation=c(56,52,53,54,57,43,54,60,47,55,58,62,52,35,47,59,56,56,45,52,58,33,57,57,61,40,45,41,50,61,50,65,68,34))
 
install.packages("earth") 
library(earth) 
newdata=na.omit(Dataset) 
model=earth(PIBparHab ~ QUALITESANSREDONDANCE + competitivite + 
innovation,data=newdata, penalty=-1) 
summary(model) 
plot(model) 
plotmo(model) 
model2 <- earth(PIBparHab ~ QUALITESANSREDONDANCE + competitivite + 
innovation,data=newdata, penalty=-1, varmod.method="lm",nfold=10,ncross=3) 
plotmo(model2, pt.col=1, level=.95)


boot.MARS=function(formula,data,indices) {
d=data[indices,]
fit=earth(formula,data=d)
return(coef(fit))
}

library(boot)
results=boot(data=newdata, statistic=boot.MARS, R=1000,formula=PIBparHab ~ 
QUALITESANSREDONDANCE + competitivite + innovation)

boot.ci(results, type= "bca", index=2)


##


De : Bert Gunter 

Cc : R-help Mailing List 
Envoyé le : Dimanche 25 septembre 2016 22h39
Objet : Re: [R] BCa confidence bands around fitted curves MARS regression


Presumably the "earth" package lacks this functionality ...?

So, obvious query: did you try using the boot package? If not, why
not? If so, show us the code that failed.

Or am I missing the point?

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 Sun, Sep 25, 2016 at 12:19 PM, varin sacha via R-help
 wrote:
> Dear R-experts,
>
> I have fitted a MARS regression and am trying now to plot/draw the BCa 
> confidence bands around the 3 fitted curves (QUALITESANSREDONDANC, 
> competitivite and innovation).
>
>
> Here is the reproducible example.
>
>
> 
>
> Dataset = 
> data.frame(PIBparHab=c(43931,67524,48348,44827,52409,15245,24453,57636,28992,17102,51495,47243,40908,22494,12784,48391,44221,32514,35132,46679,106022,9817,99635,38678,49128,12876,20732,17151,19670,41053,22488,57134,83295,10660),
>
> QUALITESANSREDONDANCE=c(1082.5,1066.6,1079.3,1079.9,1074.9,1008.6,1007.5,.3,1108.2,1109.7,1059.6,1165.1,1026.7,1035.1,997.8,1044.8,1073.6,1085.7,1083.8,1021.6,1036.2,1075.3,1069.3,1101.4,1086.9,1072.1,1166.7,983.9,1004.5,1082.5,1123.5,1094.9,1105.1,1010.8),
>
> competitivite=c(89,83,78,73,90,71,77,85,61,67,98,82,70,43,57,78,72,79,61,71,86,63,90,75,87,64,60,56,66,80,53,91,97,62),
>
> innovation=c(56,52,53,54,57,43,54,60,47,55,58,62,52,35,47,59,56,56,45,52,58,33,57,57,61,40,45,41,50,61,50,65,68,34))
>
> install.packages("earth")
>
> library(earth)
>
> newdata=na.omit(Dataset)
>
> model=earth(PIBparHab ~ QUALITESANSREDONDANCE + competitivite + 
> innovation,data=newdata, penalty=-1)
>
> summary(model)
>
> plot(model)
>
> plotmo(model)
>
>
> 
>
> Best Regards,
> S
>
> __
> 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] Font problem.

2016-10-02 Thread Rolf Turner


Dunno exactly whom I should ask about this problem, but I thought I'd 
start with good old r-help.


I have recently acquired a new laptop, and have installed Ubuntu 16.04 
on it.  Still having some teething problems.


If I do

plot(1:10,ylab=expression(italic(J(r)))

I get the error:

Error in title(...) :
  X11 font -*-courier-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 5 at size 15 
could not be loaded


So it would seem that I am missing a font.  Fonts have always been a 
complete mystery to me.  Can anyone suggest how I might rectify this 
deficiency in the fonts on my system?  If so, *please* be as explicit as 
you can in your instructions; I am all at sea here.


cheers,

Rolf Turner

P. S.  I have also just noticed that if I do:

plot(1:10,ylab=expression(alpha))

I get an "a" as the y-axis label, rather than the Greek letter alpha.

Likewise if I do plot(1:10,ylab=expression(Sigma)) I get a capital "S" 
rather than an upper case Greek Sigma symbol.  No error thrown, but.


Any ideas as to how to fix this problem?

For what it's worth, here is my sessionInfo():

R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS

locale:
 [1] LC_CTYPE=en_NZ.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_NZ.UTF-8LC_COLLATE=en_NZ.UTF-8
 [5] LC_MONETARY=en_NZ.UTF-8LC_MESSAGES=en_NZ.UTF-8
 [7] LC_PAPER=en_NZ.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] misc_0.0-16

loaded via a namespace (and not attached):
 [1] deldir_0.1-13   Matrix_1.2-3mgcv_1.8-12
 [4] abind_1.4-3 spatstat_1.46-1.036 rpart_4.1-10
 [7] nlme_3.1-128grid_3.3.1  polyclip_1.5-0
[10] lattice_0.20-33 goftest_1.0-3   tensor_1.5

R. T.

--
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] Extract an invertible submatrix

2016-10-02 Thread Richard M. Heiberger
Use qr

tmp <- cbind(matrix(rnorm(30), 5, 6), 0)[, c(1,2,3,4,7,5,6)]
tmp
tmp.qr <- qr(tmp)
tmp.qr
tmp.qr$pivot
tmp.subset <- tmp[, tmp.qr$pivot[1:tmp.qr$rank]]
solve(tmp.subset)


On Sun, Oct 2, 2016 at 2:19 PM, Bertrand Marc  wrote:
> Dear R helpers,
>
> I am looking for an efficient way to extract (any) one of the biggest 
> invertible submatrix.
>
> I have a rectangular matrix A (p x n), with rank k <= min(p, n). I would like 
> to get a submatrix (k x k) invertible, or even better, the list of rows and 
> columns of A which
> would form the submatrix (A[rows, columns] would be invertible, with 
> length(rows)=length(columns)=k).
>
> This is the general problem, but in my particular R code, the rank of A would 
> be p (p not sure it is
> easier.
> For now, my (very bad) solution would be to try every submatrix until I find 
> one invertible.
>
> Do you think of any solution which would be more efficient ?
>
> Best regards,
> Bertrand
>
> __
> 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] Can I get odd ratios from lm() model or only glm()?

2016-10-02 Thread David Winsemius

> On Oct 2, 2016, at 9:24 AM, mviljamaa  wrote:
> 
> I'm doing logistic regression and I need to infer the coefficients as odds 
> ratios.
> 
> I first did my model using lm(), but now that I need odd ratios, then should 
> I have used glm() like displayed here:
> 
> http://r.789695.n4.nabble.com/Odds-ratio-from-Logistic-model-in-R-td2630277.html

Yes.


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


[R] Extract an invertible submatrix

2016-10-02 Thread Bertrand Marc
Dear R helpers,

I am looking for an efficient way to extract (any) one of the biggest 
invertible submatrix.

I have a rectangular matrix A (p x n), with rank k <= min(p, n). I would like 
to get a submatrix (k x k) invertible, or even better, the list of rows and 
columns of A which
would form the submatrix (A[rows, columns] would be invertible, with 
length(rows)=length(columns)=k).

This is the general problem, but in my particular R code, the rank of A would 
be p (p

Re: [R] remove a "corrupted file" after using download.file() with R on Windows 7

2016-10-02 Thread Fabien Tarrade

Hi Henrik,


1. It could be that a virus checker locks the file.
This is some internal document so I don't think so and this was monitor 
by our IT security team.

2. There are Windows software tools that identify which process locks
a particular file, e.g. LockHunter (http://lockhunter.com/).  Those
should help you figure out what's going on.

ok, thanks.

3. R.utils::downloadFile() tries it's best to download files
atomically, i.e. it either gives you a fully downloaded file or not
all.  In your case, you might still end up with a temporary corrupt
file, but at least it will have a filename that is different than the
one you ask for.
My issue is that if I run over 300'000 documents and I will get the same 
amount of corrupted files.

I will try some solution with R or try with python

Thanks
Cheers
Fabien



Hi there,

Sometime download.file() failed to download the file and I would like to
remove the correspond file.
The issue is that I am not able to do it and Windows complain that the file
is use by another application.
I try to closeAllConnections(), or unlink() before removing the file but
without sucess.

Any idea how I should proceed &

Please find the code below

  # consider warning as an error
   options(warn=2)

   # try to download the file
   tryCatch({
 download.file(url,path_file,mode="wb",quiet=quiet)
 return(0)
   },error = function(e){
 if(verbose){
   print(e)
   print(e$message)
 }
 # close file when it failed
 if (file.exists(path_file)){
   closeAllConnections()
   #unlink(path_file, recursive=TRUE)
   #file.create(path_file,overwrite=TRUE,showWarning=TRUE)
   #system(paste0('open "', path_file, '"'))
   file.remove(path_file,overwrite=TRUE,showWarning=TRUE)
 }
 return(1)
 }
)

Thanks a lot
Cheers
Fabien

--
Dr Fabien Tarrade

Quantitative Analyst/Developer - Data Scientist

Senior data analyst specialised in the modelling, processing and statistical
treatment of data.
PhD in Physics, 10 years of experience as researcher at the forefront of
international scientific research.
Fascinated by finance and data modelling.

Geneva, Switzerland

Email : cont...@fabien-tarrade.eu 
Phone : www.fabien-tarrade.eu 
Phone : +33 (0)6 14 78 70 90

LinkedIn  Twitter
 Google
 Facebook
 Google 
Xing 

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


--
Dr Fabien Tarrade

Quantitative Analyst/Developer - Data Scientist

Senior data analyst specialised in the modelling, processing and 
statistical treatment of data.
PhD in Physics, 10 years of experience as researcher at the forefront of 
international scientific research.

Fascinated by finance and data modelling.

Geneva, Switzerland

Email : cont...@fabien-tarrade.eu 
Phone : www.fabien-tarrade.eu 
Phone : +33 (0)6 14 78 70 90

LinkedIn  Twitter 
 Google 
 Facebook 
 Google 
 Xing 


__
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] remove a "corrupted file" after using download.file() with R on Windows 7

2016-10-02 Thread Fabien Tarrade

Hi Robert,

sorry for the delays
Sometime download.file() failed to download the file and I would like 
to remove the correspond file.

No answers, but a couple of additional questions:
1)  Does the issue persist if you close R or does the file remain 
locked against deletion?

no, if I close R then I can remove the file
2) If so, is there a related process in the task list if you use 
CTRL-ALT-DEL?

nothing special a part from R studio
3) Does   print(e$message) yield any useful information when it 
hangs?
I have an url to access the pages of .tiff documents. The issue that I 
don't know how many pages have each documents. So I try to copy and 
incrememt the index for the number of pges until it failed. I know it is 
not an idea solution but this is I have now until we get this info into 
a DB.

Would debugging in R Studio shed additional light?

I will give a try.

Thanks
Cheers
Fabien

--
Dr Fabien Tarrade

Quantitative Analyst/Developer - Data Scientist

Senior data analyst specialised in the modelling, processing and 
statistical treatment of data.
PhD in Physics, 10 years of experience as researcher at the forefront of 
international scientific research.

Fascinated by finance and data modelling.

Geneva, Switzerland

Email : cont...@fabien-tarrade.eu 
Phone : www.fabien-tarrade.eu 
Phone : +33 (0)6 14 78 70 90

LinkedIn  Twitter 
 Google 
 Facebook 
 Google 
 Xing 


__
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] Histogram using Sturges' Bining Errors

2016-10-02 Thread Elysa Mitova
Histogram using Sturges' bining

Hello,

I am trying to create a histogram using Sturges' bining rule, yet I keep
getting 2 errors, which probably have to do with the variable I am using.

Here is my process and the errors, what would you suggest?

k <- ggplot (world, aes (x=polstab))

wid <- ceiling ((max(world$polstab)- min (world$polstab))/
nclass.Sturges(world$polstab))

k + geom_histogram(col = "black", fill = "white", binwidth = wid)

Now, I get two error messages:

1: Removed 9 rows containing non-finite values (stat_bin).
2: Computation failed in `stat_bin()`:
missing value where TRUE/FALSE needed

The first one I understand, the second one is more problematic. What could
I do to remove this error?



Thank you in advance!

[[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] Can I get odd ratios from lm() model or only glm()?

2016-10-02 Thread mviljamaa
I'm doing logistic regression and I need to infer the coefficients as 
odds ratios.


I first did my model using lm(), but now that I need odd ratios, then 
should I have used glm() like displayed here:


http://r.789695.n4.nabble.com/Odds-ratio-from-Logistic-model-in-R-td2630277.html

__
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] Bootstrapping in R

2016-10-02 Thread ruipbarradas

Right.
To see it in action just compare the results of the two calls to boot.

library(boot)

set.seed(1007)

x <- rnorm(100)
y <- x + rnorm(100)
dat <- data.frame(x, y)

#Wrong
stat1 <- function(DF, f){
model <- lm(DF$y ~ DF$x, data = DF[f,])  #Doesn't bootstrap DF
coef(model)
}

#Correct
stat2 <- function(DF, f){
model <- lm(y ~ x, data = DF[f,])
coef(model)
}

boot(dat, stat1, R = 100)
boot(dat, stat2, R = 100)


Rui Barradas


Citando peter dalgaard :


On 01 Oct 2016, at 16:11 , Daniel Nordlund  wrote:

You haven't told us anything about the structure of your data, or  
the definition of the DataSummary function.


Yes. Just let me add that a common error with boot() is not to pay  
attention to the required form of the statistic= function argument.  
It should depend on the data and a set of indices and (for  
nonparametic bootstrap) it is the indices that are random.


Typical mistakes are to completely ignore the index argument, or to  
write clumsy code that ignores the data specification, as in

coef(lm(df$y~df$x, data=d[f])).


--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


__
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] Convert a list with NULL to a dataframe with NA

2016-10-02 Thread Bob Rudis
It's fairly straightforward with help from the purrr package:

library(purrr)

map_df(OB1, function(x) {
  if (length(x) == 0) {
data.frame(id=NA_character_, nam=NA_character_, stringsAsFactors=FALSE)
  } else {
data.frame(id=x[1], nam=names(x), stringsAsFactors=FALSE)
  }
}, .id="V1")



On Sun, Oct 2, 2016 at 6:40 AM, Mohammad Tanvir Ahamed via R-help <
r-help@r-project.org> wrote:

> Hi,
>
> I have a list like below.
>
> OB1 <- structure(list(aa0 = NULL,
> aa1 = structure("23403", .Names = "BB10"),
> aa2 = structure("54904", .Names = "BB20"),
> aa3 = structure("22897", .Names = "BB30"),
> aa4 = structure("3751", .Names = "BB40"),
> aa5 = NULL,
> aa6 = structure("3679", .Names = "BB50"),
> aa7 = structure("440193", .Names = "BB60"),
> aa8 = structure("23144", .Names = "BB70"),
> aa9 = structure("84667", .Names = "BB80"),
> aa10 = structure("130540", .Names = "BB90")),
> .Names = c("aa0", "aa1", "aa2", "aa3",
> "aa4", "aa5", "aa6", "aa7",
> "aa8", "aa9", "aa10"))
>
> I am expecting an output like below
> OB2 <- structure(list(V1 = structure(c(3L, 5L, 8L, 1L, 4L, 2L, 10L,
> 7L, 9L, 11L, 6L), .Label = c("aa3", "aa5", "aa0",
> "aa4", "aa1", "aa10", "aa7", "aa2",
> "aa8", "aa6", "aa9"), class = "factor"),
> id = structure(c(NA, 4L, 8L, 2L, 6L, NA, 5L, 7L, 3L, 9L,
> 1L), .Label = c("130540", "22897", "23144", "23403", "3679",
> "3751", "440193", "54904", "84667"), class = "factor"), nam =
> structure(c(NA,
> 4L, 8L, 3L, 7L, NA, 6L, 2L, 9L, 5L, 1L), .Label = c("BB90",
> "BB60", "BB30", "BB10", "BB80", "BB50", "BB40",
> "BB20", "BB70"), class = "factor")), .Names = c("V1",
> "id", "nam"), row.names = c(NA, -11L), class = "data.frame")
>
> Problems :
> 1. Get OB1 to OB2
> 2. Get OB2 to OB1
>
> I  will be great-full if anyone can share idea how to solve the problem .
> Thanks in advance !!
>
>
>
>
> Tanvir Ahamed
> Göteborg, Sweden  |  mashra...@yahoo.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.

[[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] Convert a list with NULL to a dataframe with NA

2016-10-02 Thread Mohammad Tanvir Ahamed via R-help
Hi, 

I have a list like below. 

OB1 <- structure(list(aa0 = NULL, 
aa1 = structure("23403", .Names = "BB10"), 
aa2 = structure("54904", .Names = "BB20"), 
aa3 = structure("22897", .Names = "BB30"), 
aa4 = structure("3751", .Names = "BB40"), 
aa5 = NULL, 
aa6 = structure("3679", .Names = "BB50"), 
aa7 = structure("440193", .Names = "BB60"), 
aa8 = structure("23144", .Names = "BB70"), 
aa9 = structure("84667", .Names = "BB80"), 
aa10 = structure("130540", .Names = "BB90")), 
.Names = c("aa0", "aa1", "aa2", "aa3", 
"aa4", "aa5", "aa6", "aa7", 
"aa8", "aa9", "aa10"))

I am expecting an output like below
OB2 <- structure(list(V1 = structure(c(3L, 5L, 8L, 1L, 4L, 2L, 10L, 
7L, 9L, 11L, 6L), .Label = c("aa3", "aa5", "aa0", 
"aa4", "aa1", "aa10", "aa7", "aa2", 
"aa8", "aa6", "aa9"), class = "factor"), 
id = structure(c(NA, 4L, 8L, 2L, 6L, NA, 5L, 7L, 3L, 9L, 
1L), .Label = c("130540", "22897", "23144", "23403", "3679", 
"3751", "440193", "54904", "84667"), class = "factor"), nam = structure(c(NA, 
4L, 8L, 3L, 7L, NA, 6L, 2L, 9L, 5L, 1L), .Label = c("BB90", 
"BB60", "BB30", "BB10", "BB80", "BB50", "BB40", 
"BB20", "BB70"), class = "factor")), .Names = c("V1", 
"id", "nam"), row.names = c(NA, -11L), class = "data.frame")

Problems :
1. Get OB1 to OB2
2. Get OB2 to OB1

I  will be great-full if anyone can share idea how to solve the problem .
Thanks in advance !!



 
Tanvir Ahamed 
Göteborg, Sweden  |  mashra...@yahoo.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] Bootstrapping in R

2016-10-02 Thread peter dalgaard

> On 01 Oct 2016, at 16:11 , Daniel Nordlund  wrote:
> 
> You haven't told us anything about the structure of your data, or the 
> definition of the DataSummary function.

Yes. Just let me add that a common error with boot() is not to pay attention to 
the required form of the statistic= function argument. It should depend on the 
data and a set of indices and (for nonparametic bootstrap) it is the indices 
that are random. 

Typical mistakes are to completely ignore the index argument, or to write 
clumsy code that ignores the data specification, as in 
coef(lm(df$y~df$x, data=d[f])).


-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [R] installation error

2016-10-02 Thread David Winsemius

> On Oct 1, 2016, at 10:58 AM,   
> wrote:
> 
> Hello,
> 
> I’m suman kumar. I am trying to use “syuzhet” packages and already installed 
> it but when using it then facing some error.
> I have run these codes but in second line, it is showing errors.
> 
> library(syuzhet)
> textdata= get_text_as_string("G:/SEM-3/DSE-PROJECT/AGASHIYEmain.txt")
> s_v = get_sentences(textdata)
> s_v
> 
> 
> errors:-
> Error: .onLoad failed in loadNamespace() for 'rJava', details:
>  call: fun(libname, pkgname)
>  error: JAVA_HOME cannot be determined from the Registry
> 
> 
> please help me to remove this error. Thanks in advance.

You have not provided enough information. How did you install Java? Or did you?
> 
> Thanks
> Suman kumar 
> 
> Sent from Mail for Windows 10
> 
> 
>   [[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.

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.