[R] [R-pkgs] stringr: version 0.4

2010-08-25 Thread Hadley Wickham
Strings are not glamorous, high-profile components of R, but they do
play a big role in many data cleaning and preparations tasks. R
provides a solid set of string operations, but because they have grown
organically over time, they can be inconsistent and a little hard to
learn. Additionally, they lag behind the string operations in other
programming languages, so that some things that are easy to do in
languages like Ruby or Python are rather hard to do in R. The
`stringr` package aims to remedy these problems by providing a clean,
modern interface to common string operations.

More concretely, `stringr`:

 * Processes factors and characters in the same way.

 * Gives functions consistent names and arguments.

 * Simplifies string operations by eliminating options that you don't need
   95% of the time.

 * Produces outputs than can easily be used as inputs. This includes ensuring
   that missing inputs result in missing outputs, and zero length inputs
   result in zero length outputs.

 * Completes R's string handling functions with useful functions from other
   programming languages.


New in stringr 0.4:

 * all functions now vectorised with respect to string, pattern (and
   where appropriate) replacement parameters
 * fixed() function now tells stringr functions to use fixed matching, rather
   than escaping the regular expression.  Should improve performance for
   large vectors.
 * new ignore.case() modifier tells stringr functions to ignore case of
   pattern.
 * str_replace renamed to str_replace_all and new str_replace function added.
   This makes str_replace consistent with all functions.
 * new str_sub- function (analogous to substring-) for substring replacement
 * str_sub now understands negative positions as a position from the end of
   the string. -1 replaces Inf as indicator for string end.
 * str_pad side argument can be left, right, or both (instead of center)
 * str_trim gains side argument to better match str_pad
 * stringr now has a namespace and imports plyr (rather than requiring it)


-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
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] SEM : Warning : Could not compute QR decomposition of Hessian

2010-08-25 Thread John Fox
Dear Anne,

I started to diagram your model but stopped when I noticed some problems:
(1) Some variables, such as pays_alti, are clearly endogenous, since they
have arrows pointing to them, yet are declared as fixed exogenous variables;
that clearly doesn't make sense. (2) You've placed conflicting constraints
on factor loadings and the variances of latent variables, for example
setting both the path from the factor type_paysage to the indicator
pays_alti and the variance of type_paysage to 1; again, that doesn't make
sense.

Do you have a path diagram for the model that you're trying to fit? It would
in particular be helpful to have a diagram of the structural part of the
model.

Regards,
 John


John Fox
Senator William McMaster 
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of Anne Mimet
 Sent: August-25-10 10:27 AM
 To: r-help@r-project.org
 Subject: [R] SEM : Warning : Could not compute QR decomposition of Hessian
 
 Hi useRs,
 
 I'm trying for the first time to use a sem. The model finally runs,
 but gives a warning saying :
 In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names
 = vars,  :   Could not compute QR decomposition of Hessian.
 Optimization probably did not converge. 
 
 I found in R-help some posts on this warning, but my attemps to modify
 the code didn't change the warning message (i tried to give an error
 of 1 to the latente variables). I can't figure what the problem is.
 Here is the code :
 
 
 tab-read.table(F:/Mes documents/stats/sem/donnees_corr.txt,
 header=T, sep=,na.strings = NA)
 
 tab[,46]-as.factor(tab[,46])
 tab[,24]-as.factor(tab[,24])
 tab[,40]-as.factor(tab[,40])
 
 fct_cor-hetcor(tab, ML=T)
 cor_tab- fct_cor$correlations
 
 moment_tab-read.moments(diag=F, names=c('c1','c2', 'c3','c4','c5',
 'c6','c7', 'c8', 'c9',  'ind_plando', 'long_sup15', 'long_inf15',
 'pente', 'est', 'sud','ouest', 'nord' ,'reg_hydriq', 'prof_sol',
 'pierro', 'efferv', 'struct','drainage','texture', 'route1_pond',
 'route2_pond',
 'pourcactif', 'tx_chomage', 'pourcagric', 'pourc_jeunes', 'pop99',
 'rev_imp_foyer','eq_CONC', 'eq_sante', 'eq_edu', 'sold_nat',
 'sold_mig', 'tps_dom_emp','TXEMPLOI','ORIECO','dist_paris','axe1',
 'axe2', 'axe3', 'dist_protect','urbanisation','pays_incli','pays_alti'))
 # after comes the moment matrix (triangular)
 
 ram_tab-specify.model()
 type_paysage-pays_alti,NA,1
 type_paysage-pays_incli, pays2, NA
 pedo-reg_hydriq, NA, 1
 pedo-prof_sol, ped8, NA
 pedo-pierro, ped9, NA
 pedo-efferv, ped10, NA
 pedo-struct, ped11, NA
 pedo-drainage, ped12, NA
 pedo-texture, ped13, NA
 adj_99-c1, NA,1
 adj_99-c2, adj2,NA
 adj_99-c3, adj3,NA
 adj_99-c4, adj4,NA
 adj_99-c5, adj5,NA
 adj_99-c6, adj6,NA
 adj_99-c7, adj7,NA
 adj_99-c8, adj8,NA
 adj_99-c9, adj9,NA
 etat_hexa-axe1, NA, 1
 etat_hexa-axe2, et2, NA
 etat_hexa-axe3, et3, NA
 socioBV-sold_mig, BV1, NA
 socioBV-sold_nat, BV2, NA
 socioBV-TXEMPLOI, BV3, NA
 socioBV-ORIECO, BV4, NA
 socioBV-tps_dom_emp, NA, 1
 eqBV-eq_CONC, NA, 1
 eqBV-eq_sante, eq2, NA
 eqBV-eq_edu, eq3, NA
 socio_com-pourcactif , NA, 1
 socio_com-tx_chomage, com2, NA
 socio_com-pourcagric, com3, NA
 socio_com-pourc_jeunes, com4, NA
 socio_com-pop99, com5, NA
 socio_com-rev_imp_foyer, com7, NA
 access_hexa-route1_pond, NA, 1
 access_hexa-route2_pond, acc2, NA
 hydro-ind_plando, NA, 1
 hydro-long_sup15, eau2, NA
 hydro-long_inf15, eau3, NA
 topog-pente, NA, 1
 topog-est, top2, NA
 topog-sud, top3, NA
 topog-nord, top4, NA
 topog-ouest, top5, NA
 dist_protect- urbanisation, cor1,NA
 dist_protect- adj_99, cor2, NA
 dist_protect- etat_hexa, cor3, NA
 topog- urbanisation, cor4, NA
 topog- adj_99, cor5, NA
 topog- etat_hexa, cor6, NA
 topog- access_hexa, cor7, NA
 topog-hydro, cor8, NA
 topog-pedo, cor9, NA
 pedo- urbanisation, cor10, NA
 pedo- adj_99, cor11, NA
 pedo- etat_hexa, cor12, NA
 pedo-hydro, cor1, NA
 hydro- urbanisation, cor13, NA
 hydro- adj_99, cor14, NA
 hydro- etat_hexa, cor15, NA
 access_hexa- urbanisation, cor16, NA
 access_hexa- etat_hexa, cor17, NA
 socio_com- etat_hexa, cor18, NA
 socio_com- adj_99, cor19, NA
 socio_com- urbanisation, cor20, NA
 dist_paris- socio_com, cor21, NA
 dist_paris- access_hexa, cor22, NA
 dist_paris- adj_99, cor23, NA
 dist_paris- etat_hexa, cor24, NA
 dist_paris- urbanisation, cor25, NA
 dist_paris- socioBV, cor26, NA
 socioBV- eqBV, cor27, NA
 socioBV- urbanisation, cor28, NA
 socioBV- adj_99, cor29, NA
 socioBV- etat_hexa, cor30, NA
 eqBV- etat_hexa, cor31, NA
 eqBV- adj_99, cor32, NA
 eqBV- urbanisation, cor33, NA
 etat_hexa- urbanisation, cor34, NA
 etat_hexa- adj_99, cor35, NA
 adj_99- urbanisation, cor36, NA
 type_paysage- urbanisation, cor37, NA
 type_paysage- adj_99, cor38, NA
 type_paysage- etat_hexa, cor39, NA
 dist_paris-dist_paris, auto1, NA
 

Re: [R] output values from within a function

2010-08-25 Thread Greg Snow
Put the line:

cat(z1,'\n')

in your function.  You may also want to put the flush.console() command right 
after that.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Maas James Dr (MED)
 Sent: Friday, August 20, 2010 7:41 AM
 To: r-help@r-project.org
 Subject: [R] output values from within a function
 
 Is it possible to get R to output the value of an expression, that is
 being calculated within a function?  I've attached a very simple
 example but for more complicated ones would like to be able to debug by
 seeing what the value of specific expressions are each time it cycles
 through a loop that executes the expression.  I'm relatively new to
 this so there may be much simpler more elegant ways to do it.
 
 For example, is there a command I can put within the function funct01
 that will output the value of z1 to the screen?
 
 Thanks
 
 Jim
 
 ==
 ## Practice file to try out evaluations
 
 y - 5
 
 (x - y^2)
 
 funct01 - function (x,y) {
 
 z1 - x + y
 z2 - x * y
 z3 - x^y
 
 results - data.frame (z1=z1, z2=z2, z3=z3)
 return(results)
 
 }
 
 funct01(7,9)
 
 
 ===
 Dr. Jim Maas
 University of East Anglia
 Norwich, UK
 NR4 7TJ
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 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
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] Removing inter-bar spaces in barchart

2010-08-25 Thread Greg Snow
Using the barplot function in base graphics you just set space=0, but that 
function does not have a box.ratio argument which would imply that you are 
using something else.  If you let us know which function (and which package it 
is in) then it is easier (possible) for us to help you, even better is to give 
the information asked for at the bottom of every post and the posting guide.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Jonathan Greenberg
 Sent: Tuesday, August 24, 2010 8:21 PM
 To: r-help
 Subject: [R] Removing inter-bar spaces in barchart
 
 Rhelpers:
 
 I'm trying to make a barchart of a 2-group dataset
 (barchart(x~y,data=data,groups=z,horizontal=FALSE)).  My problem is
 that I can't, for the life of me, seem to get rid of the inter-bar
 space -- box.ratio set to 1 doesn't do much.  Any ideas?  I'd
 ideally want zero space between the bars.  Thanks!
 
 --j
 
 --
 Jonathan A. Greenberg, PhD
 Assistant Project Scientist
 Center for Spatial Technologies and Remote Sensing (CSTARS)
 Department of Land, Air and Water Resources
 University of California, Davis
 One Shields Avenue
 Davis, CA 95616
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307
 
 __
 R-help@r-project.org mailing list
 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
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] What does this warning message (from optim function) mean?

2010-08-25 Thread Prof Brian Ripley

You mean 'TRUE': 'T' is a variable in R, with initial value TRUE.

On Wed, 25 Aug 2010, Sally Luo wrote:


Hi R users,
I am trying to use the optim function to maximize a likelihood funciton, and
I got the following warning messages.
Could anyone explain to me what messege 31 means exactly?  Is it a cause for
concern?
Since the value of convergence turns out to be zero, it means that the
converging is successful, right?
So can I assume that the parameter estimates generated thereafter are
reliable MLE estimates?
Thanks a lot for your help.

Maomao


p-optim(c(0,0,0), f, method =BFGS, hessian =T, y=y,X=X,W=W)


There were 31 warnings (use warnings() to see them)


warnings()


Warning messages:

1: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

2: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

3: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

4: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

5: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

6: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

7: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

8: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

9: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

10: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

11: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

12: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

13: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

14: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

15: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

16: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

17: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

18: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

19: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

20: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

21: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

22: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

23: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

24: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

25: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

26: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

27: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

28: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

29: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

30: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

31: In if (hessian) { ... :

 the condition has length  1 and only the first element will be used


p$counts


function gradient

148   17


p$convergence


[1] 0

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
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] approxfun-problems (yleft and yright ignored)

2010-08-25 Thread Greg Snow
The plots did not come through, see the posting guide for which attachments are 
allowed.  It will be easier for us to help if you can send reproducible code 
(we can copy and paste to run, then examine, edit, etc.).  Try finding a subset 
of your data for which the problem still occurs, then send the data if 
possible, or similar simulated data if you cannot send original data.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Samuel Wuest
 Sent: Wednesday, August 25, 2010 8:20 AM
 To: r-help@r-project.org
 Subject: [R] approxfun-problems (yleft and yright ignored)
 
 Dear all,
 
 I have run into a problem when running some code implemented in the
 Bioconductor panp-package (applied to my own expression data), whereby
 gene
 expression values of known true negative probesets (x) are interpolated
 onto
 present/absent p-values (y) between 0 and 1 using the *approxfun -
 function*{stats}; when I have used R version 2.8, everything had
 worked fine,
 however, after updating to R 2.11.1., I got unexpected output
 (explained
 below).
 
 Please correct me here, but as far as I understand, the yleft and
 yright
 arguments set the extreme values of the interpolated y-values in case
 the
 input x-values (on whose approxfun is applied) fall outside range(x).
 So if
 I run approxfun with yleft=1 and yright=0 with y-values between 0 and
 1,
 then I should never get any values higher than 1. However, this is not
 the
 case, as this code-example illustrates:
 
  ### define the x-values used to construct the approxfun, basically
 these
 are 2000 expression values ranging from ~ 3 to 7:
  xNeg - NegExprs[, 1]
  xNeg - sort(xNeg, decreasing = TRUE)
 
  ### generate 2000 y-values between 0 and 1:
  yNeg - seq(0, 1, 1/(length(xNeg) - 1))
  ### define yleft and yright as well as the rule to clarify what
 should
 happen if input x-values lie outside range(x):
  interp - approxfun(xNeg, yNeg, yleft = 1, yright = 0, rule=2)
 Warning message:
 In approxfun(xNeg, yNeg, yleft = 1, yright = 0, rule = 2) :
   collapsing to unique 'x' values
  ### apply the approxfun to expression data that range from ~2.9 to
 13.9
 and can therefore lie outside range(xNeg):
   PV - sapply(AllExprs[, 1], interp)
  range(PV)
 [1]0.000 6208.932
  summary(PV)
  Min.   1st Qu.Median  Mean   3rd Qu.  Max.
 0.000e+00 0.000e+00 2.774e-03 1.299e+00 3.164e-01 6.209e+03
 
 So the resulting output PV object contains data ranging from 0 to 6208,
 the
 latter of which lies outside yleft and is not anywhere close to extreme
 y-values that were used to set up the interp-function. This seems wrong
 to
 me, and from what I understand, yleft and yright are simply ignored?
 
 I have attached a few histograms that visualize the data distributions
 of
 the objects I xNeg, yNeg, AllExprs[,1] (== input x-values) and PV (the
 output), so that it is easier to make sense of the data structures...
 
 Does anyone have an explanation for this or can tell me how to fix the
 problem?
 
 Thanks a million for any help, best, Sam
 
  sessionInfo()
 R version 2.11.1 (2010-05-31)
 x86_64-apple-darwin9.8.0
 
 locale:
 [1] en_IE.UTF-8/en_IE.UTF-8/C/C/en_IE.UTF-8/en_IE.UTF-8
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 
 other attached packages:
 [1] panp_1.18.0   affy_1.26.1   Biobase_2.8.0
 
 loaded via a namespace (and not attached):
 [1] affyio_1.16.0 preprocessCore_1.10.0
 
 
 --
 -
 Samuel Wuest
 Smurfit Institute of Genetics
 Trinity College Dublin
 Dublin 2, Ireland
 Phone: +353-1-896 2444
 Web: http://www.tcd.ie/Genetics/wellmer-2/index.html
 Email: wue...@tcd.ie
 --

__
R-help@r-project.org mailing list
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] lattice help required

2010-08-25 Thread Kay Cichini

.. thanks again, richard.
and you swiftly saw the next problem comming up - when using par.settings =
list(layout.widths = list(axis.panel = c(1, 0))) getting rid of the double
tick labeling would be natural -
but i'll leave it at that for today.

many thanks,
kay


Richard M. Heiberger wrote:
 
 The multiple y axes are protecting you in this situation.
 
 
 z - cbind(rnorm(100,c(1,10),1), rnorm(100,c(20,30),1))
 dotplot(z[,1]+z[,2] ~ facs$Treatment|facs$Sites,
 outer=TRUE,
 scales = list(
   y = list(
 relation=free)),
 ylab=c(y1, y2),
 xlab=c(Site 1, Site 2),
 strip=FALSE,
 main=problem)
 
 dotplot(z[,1]+z[,2] ~ facs$Treatment|facs$Sites,
 outer=TRUE,
 scales = list(
   y = list(
 relation=free,
 limits=list(c(-5,13),c(-5,13),c(18,32),c(18,32,
 ylab=c(y1, y2),
 xlab=c(Site 1, Site 2),
 strip=FALSE, main=protected)
 
 For more control (such as suppressing the y-tick labels in the right-hand
 column,
 I recommend Deepayan Sarkar's book.
 
 Rich
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 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.
 
 


-

Kay Cichini
Postgraduate student
Institute of Botany
Univ. of Innsbruck


-- 
View this message in context: 
http://r.789695.n4.nabble.com/lattice-help-required-tp2338382p2338707.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
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] GLM outputs in condensed versus expanded table

2010-08-25 Thread Peter Dalgaard
On 08/25/2010 05:17 PM, francogrex wrote:
 
 Hi I'm having different outputs from GLM when using a condensed table
 V1V2  V3  Present Absent
 0 0   0   3   12
 0 0   1   0   0
 0 1   0   0   0
 0 1   1   1   0
 1 0   0   7   20
 1 0   1   0   0
 1 1   0   3   0
 1 1   1   6   0
 
 
 resp=cbind(Present, Absent)
 glm(resp~V1+V2+V3+I(V1*V2*V3),family=binomial)
 Deviance Residuals: 
 [1]  0  0  0  0  0  0  0  0
  etc and also coefficients...
 
 And when using the same but expanded table
 
   V1  V2  V3  condition (1 present 0 abscent)
 Id1   1   0   0   1
 id2   1   1   1   1
 ... etc
 glm(condition~V1+V2+V3+I(V1*V2*V3),family=binomial)
 Deviance Residuals: 
 Min  1Q  Median  3Q Max  
   -0.7747317  -0.7747317  -0.6680472   0.0001315   1.7941226 
 and also coefficients are different from above.
 
 What could I be doing wrong?
 
 

Not necessarily anything. Anything technical, that is.

You have 3 uninformative combinations where the total is zero. The model
has 5 parameters. This is quite likely to generate a perfect fit to the
aggregated data. With the groups having zeros in the absent category,
the fit probably diverged so some coefficients are numerically large.

Refitting with individual data will likely give slightly different
coefficients, since it sort of depends on how far you came on the way to
infinity.

With the aggregated data, a perfect fit gives residuals of zero, but
with individual data, the 0's and 1's give negative and positive
residuals. Try

z - rep(0:1,5)
zz - cbind(5,5)

summary(glm(z~1, binomial))
summary(glm(zz~1, binomial))

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list
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] several odfWeave questions

2010-08-25 Thread Max Kuhn
Ben,

  1a. am I right in believing that odfWeave does not respect the
 'keep.source' option?  Am I missing something obvious?

I believe it does, since this gets passed directly to Sweave.

  1b. is there a way to set global options analogous to \SweaveOpts{}
 directives in Sweave? (I looked at odfWeaveControl, it doesn't seem to
 do it.)

Yes. There are examples of this in the 'examples' package directory.

  2. I tried to write a Makefile directive to process files from the
 command line:

 %.odt: %_in.odt
        $(RSCRIPT) -e library(odfWeave);
 odfWeave(\$*_in.odt\,\$*.odt\);

  This works, *but* the resulting output file gives a warning (The file
 'odftest2.odt' is corrupt and therefore cannot be opened.
 OpenOffice.org can try to repair the file ...).  Based on looking at
 the contents, it seems that a spurious/unnecessary 'Rplots.pdf' file is 
 getting
 created and zipped in with the rest of the archive; when I unzip, delete
 the Rplots.pdf file and re-zip, the ODT file opens without a warning.
 Obviously I could post-process but it would be nicer to find a
 workaround within R ...

Get the latest version form R-Forge. I haven't gotten this fix onto
CRAN yet (I've been on a caret streak lately).

  3. I find the requirement that all file paths be specified as absolute
 rather than relative paths somewhat annoying -- I understand the reason,
 but it goes against one practice that I try to encourage for
 reproducibility, which is *not* to use absolute file paths -- when
 moving a same set of data and analysis files across computers, it's hard
 to enforce them all ending up in the same absolute location, which then
 means that the recipient has to edit the ODT file.  It would be nice if
 there were hooks for read.table() and load() as there are for plotting
 and package/namespace loading -- then one could just copy them into the
 working directory on the fly.
   has anyone experienced this/thought of any workarounds?
  (I guess one solution is to zip any necessary source files into the archive 
 beforehand,
 as illustrated in the vignette.)

You can set the working directory with the (wait for it...) 'workDir'
argument. Using 'workDir = getwd()' will pack and unpack the files in
the current location and you wouldn't need to worry about setting the
path. I use the temp directory because I started over-wrting files.

Max

__
R-help@r-project.org mailing list
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] package MuMI

2010-08-25 Thread Ben Bolker
Marino Taussig De Bodonia, Agnese agnese.marino09 at imperial.ac.uk writes:

 I am using the package MuMI to run all the possible combinations
  of variables in my full model, and select
 my best models. When I enter my variables in the original model I 
 write them like this
 
 lm(y~ a +b +c +a:b)
 
 However,  MuMI will also use the variable b:a, which I do not want 
 in my model.
 
 How do I stop that from happening?


  (1) I think you mean MuMIn.
  (2) Please send a reproducible example! (Hint: see the posting
guide that is referred to at the bottom of all R-help messages ...)
  (3) [now proceeding to try to guess what you mean ...]

a:b and b:a have identical meanings in the R formula syntax.

  I tried to do something like what I thought you might have meant
and got what seemed to be reasonable answers.

 library(MuMIn)
 dat - data.frame(y=runif(100),a=factor(sample(1:5,replace=TRUE,size=100)),
+b= factor(sample(1:5,replace=TRUE,size=100)), c=runif(100))
 m1 - lm(y~a+b+c+a:b,data=dat)
 dredge(m1)
Global model: lm(formula = y ~ a + b + c + a:b, data = dat)
---
Model selection table 
   (Int)  a b c   a:b k  R.sqAdj.R.sq  RSS   AIC   AICc  delta   weight
4  0.6385 -0.1643  3 0.03019  0.020290 7.386 29.23 29.48  0. 0.420 
1  0.5530  2 0.0  0.00 7.616 30.29 30.42  0.9392 0.262 
7  0.6283   + -0.1461  7 0.09397  0.045770 6.900 30.42 31.64  2.1650 0.142 
3  0.5533   +  6 0.07067  0.031540 7.077 30.96 31.87  2.3890 0.127 
6  0.6134 +   -0.2199  7 0.06700  0.017370 7.105 33.36 34.57  5.0980 0.033 
2  0.5202 +6 0.01989 -0.021380 7.464 36.28 37.19  7.7100 0.009 
8  0.6232 + + -0.1941 11 0.12050  0.032540 6.698 35.45 38.45  8.9760 0.005 
5  0.5352 + + 10 0.08490  0.004455 6.969 37.42 39.89 10.4100 0.002 
10 0.7433 + + -0.2504 +   27 0.27800  0.034140 5.498 47.71 68.71 39.2400 0.000 
9  0.6193 + + +   26 0.23150 -0.014420 5.853 51.96 71.19 41.7200 0.000

__
R-help@r-project.org mailing list
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] Change value of a slot of an S4 object within a method.

2010-08-25 Thread Steve Lianoglou
Howdy,

On Wed, Aug 25, 2010 at 1:21 PM, Joris Meys jorism...@gmail.com wrote:
 Hi Steve,

 thanks for the tip.  I'll definitely take a closer look at your
 solution for implementation for future use.  But right now I don't
 have the time to start rewriting my class definitions.

 Luckily, I found where exactly things were going wrong. After reading
 into the documentation about the evaluation in R, I figured out I have
 to specify the environment where substitute should look explicitly as
 parent.frame(1). I still don't understand completely why exactly, but
 it does the job.

 Thus :
 eval(eval(substitute(expression(obj...@extra[[name]] - value

 should become :

 eval(
   eval(
      substitute(
         expression(obj...@extra[[name]] - value)
      ,env=parent.frame(1) )
   )
 )

My eyes start to gloss over on their first encounter of `substitute`
... add enough `eval`s and (even) an `expression` (!) to that, and
you'll probably see me running for the hills ... but hey, if it makes
sense to you, more power to you ;-)

Glad you found a fix that works,

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
R-help@r-project.org mailing list
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] Draw a perpendicular line?

2010-08-25 Thread Dennis Murphy
Hi:

The function below plots the line segment between two points A and B as well
as the normal from C to AB, with a dot as the intersection point (D), which
is returned with the function call. The aspect ratio is kept at one so that
the orthogonality between the two lines is not distorted by the axis
scaling.

The input is a 3 x 2 matrix with point A in the first row, B in the second
and C in the third.

normalLine - function(pts) {
 # A function that takes points A, B, C (rows of matrix pts)
 # as input
 # find slope of line between A and B
 # find equation of normal that passes through C
 # find the intersection point D between AB and its normal
 # through C

if(nrow(pts) != 3 || ncol(pts) != 2) stop('input matrix must be 3 x 2')

A - pts[1, , drop = TRUE]
B - pts[2, , drop = TRUE]
C - pts[3, , drop = TRUE]

slopeAB - (B[2] - A[2])/(B[1] - A[1])
slopeNorm - -1/slopeAB
a - A[2] - slopeAB * A[1]
b - C[2] - slopeNorm * C[1]

xintersect - (b - a)/(slopeAB - slopeNorm)
yintersect - b + slopeNorm * xintersect

mxlim - max(pts)
mnlim - min(pts)

plot(pts[, 1], pts[, 2], pch = c('A', 'B', 'C'), xlab = , ylab = ,
 xlim = c(mnlim, mxlim), ylim = c(mnlim, mxlim))
segments(A[1], A[2], B[1], B[2])
segments(xintersect, yintersect, C[1], C[2])

points(xintersect, yintersect, pch = 16, cex = 1.2)

c(xintersect, yintersect)

  }

## Test:
pts - matrix(c(1, 2, 5, 9, 3, 4), ncol = 2, byrow = TRUE)
normalLine(pts)

HTH,
Dennis

On Wed, Aug 25, 2010 at 8:54 AM, William Revelle li...@revelle.net wrote:

 At 3:04 PM -0700 8/23/10, CZ wrote:

 Hi,

 I am trying to draw a perpendicular line from a point to two points.
 Mathematically I know how to do it, but to program it, I encounter some
 problem and hope can get help.  Thanks.

 I have points, A, B and C.  I calculate the slope and intercept for line
 drawn between A and B.
 I am trying to check whether I can draw a perpendicular line from C to
 line
 AB and get the x,y value for the point D at the intersection.

 Assume I get the slope of the perpendicular line, I will have my point (D)
 using variable x and y which is potentially on line AB.   My idea was
 using
 |AC|*|AC| = |AD|*|AD|+ |CD|*|CD|.  I don't know what function I may need
 to
 call to calculate the values for point D (uniroot?).



 This is easier than you think.
 Think of the x,y coordinates of each point :
 Then, the slope is slope = rise/run =  (By- Ay)/(Bx- Ax)
 The Dx coordinate = Cx and the Dy = (Dx - Ax) * slope
 Then, to draw the line segment from C to D
 lines(C,D)

 In R:

 A - c(2,4)
 B - c(4,1)
 C - c(8,10)
 slope -( C[2]- A[2])/(C[1]-A[1])  #rise/run
 D - c(B[1],(B[1]-A[1])*slope + A[2])  # find D

 my.data - rbind(A,B,C,D)
 colnames(my.data) - c(X,Y)
 my.data#show it
 plot(my.data,type=n)   #graph it without the points
 text(my.data,rownames(my.data))  #put the points in
 segments(A[1],A[2],C[1],C[2])   #draw the line segments
 segments(B[1],B[2],D[1],D[2])

 Bill




 Thank you.



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Draw-a-perpendicular-line-tp2335882p2335882.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 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
 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
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] What does this warning message (from optim function) mean?

2010-08-25 Thread Ravi Varadhan
Hi,

You did not give us any information about your likelihood function, f, nor
did you provide a reproducible example.  So, I cannot tell for sure whether
the parameter estimates are reliable.

Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Sally Luo
Sent: Wednesday, August 25, 2010 11:26 AM
To: r-help@r-project.org
Subject: [R] What does this warning message (from optim function) mean?

Hi R users,
I am trying to use the optim function to maximize a likelihood funciton, and
I got the following warning messages.
Could anyone explain to me what messege 31 means exactly?  Is it a cause for
concern?
Since the value of convergence turns out to be zero, it means that the
converging is successful, right?
So can I assume that the parameter estimates generated thereafter are
reliable MLE estimates?
Thanks a lot for your help.

Maomao

 p-optim(c(0,0,0), f, method =BFGS, hessian =T, y=y,X=X,W=W)

There were 31 warnings (use warnings() to see them)

 warnings()

Warning messages:

1: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

2: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

3: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

4: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

5: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

6: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

7: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

8: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

9: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

10: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

11: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

12: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

13: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

14: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

15: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

16: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

17: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

18: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

19: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

20: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

21: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

22: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

23: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

24: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

25: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

26: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

27: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

28: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

29: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

30: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced

31: In if (hessian) { ... :

  the condition has length  1 and only the first element will be used

 p$counts

function gradient

 148   17

 p$convergence

[1] 0

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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
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] Checking a point behind two polygons

2010-08-25 Thread CZ

Hi,

I am working on a problem of checking whether a point is behind two convex
hulls.  By 'behind', I mean a point which is outside of two convex hulls
can't reach either of these two hulls without reaching the other.  

My idea is to find the segments between the point and the vertices of a hull
first. And then check whether there is any intersection between the segments
and the edges of the other hull.  If for all the edges to be checked, there
is no intersection point found outside of the edges -- the point is said to
be behind that hull. 

Basically, I am doing line-line intersection. I know if I use the line-line
intersection checking, I will have to deal with lots of edges and segments. 
Besides, the line-line intersection checking may not be working...I wonder
someone knows a simply way and more accurate way to check it,
e.g.line-polygon intersection.   Thank you.  
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Checking-a-point-behind-two-polygons-tp2338823p2338823.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
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] What does this warning message (from optim function) mean?

2010-08-25 Thread Cheng Peng

the deteminant is a nonpositive value. log(det(...)) produce NaNs...
-- 
View this message in context: 
http://r.789695.n4.nabble.com/What-does-this-warning-message-from-optim-function-mean-tp2338689p2338719.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
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 do R calculates the number of intervals between tick-marks

2010-08-25 Thread Antonio Olinto

Hi,

With axTicks I did what I wanted. Thank you all for the attention.

Below is the code I did to have a plot with three y axes.

Suggestions to improve the routine are welcome.

All the best,

Antonio Olinto

Data in a spreadsheet

YEARL   NFB NFT
200526,352158   150025,014
200632,514789   210035,024
200727,458126   180030,254
200828,568971   150043,254
200932,564789   300060,32

# comma is a decimal symbol

dat.lnbnt - read.delim(clipboard,dec=,,header=T)

attach(dat.lnbnt)
summary(dat.lnbnt)
  YEARL  NFBNFT
 Min.   :2005   Min.   :26.35   Min.   :1500   Min.   :25.01
 1st Qu.:2006   1st Qu.:27.46   1st Qu.:1500   1st Qu.:30.25
 Median :2007   Median :28.57   Median :1800   Median :35.02
 Mean   :2007   Mean   :29.49   Mean   :1980   Mean   :38.77
 3rd Qu.:2008   3rd Qu.:32.51   3rd Qu.:2100   3rd Qu.:43.25
 Max.   :2009   Max.   :32.56   Max.   :3000   Max.   :60.32

y1min - 26
y1max - 33
y1range - y1max-y1min
y2min - 1500
y2max - 3000
y2range - y2max-y2min
y3min - 25
y3max - 61
y3range - y3max-y3min

par(mar=c(6, 6, 2,12))
plot(L, ylim=c(y1min,y1max), ylab=landings (×1000 t),  
type=l,col=red,las=0, cex.axis=1.2,cex.lab=1.4,xaxt=n,xlab=)

points(y1range*((NFB-y2min)/y2range)+y1min,type=l,col=blue)
points(y1range*((NFT-y3min)/y3range)+y1min,type=l,col=darkgreen)

yticks - axTicks(2)
interval - yticks[2]-yticks[1]
divisions - length(yticks)-1

axis(1,at=axTicks(1),labels=as.character(YEAR),las=2,cex.axis=1.2)
axis(4,at=seq(y1min,y1max,interval),labels=as.integer(seq(y2min,y2max,y2range/divisions)),las=0,cex.axis=1.2)
axis(4,at=seq(y1min,y1max,interval),labels=as.integer(seq(y3min,y3max,y3range/divisions)),cex.axis=1.2,  
las=0,line=5)

mtext(nº of fishing boats,4,3,cex=1.4)
mtext(nº of fishing trips (×1000),4,8, cex=1.4)
legend(4,33,c(L,Nº FB,Nº  
FT),bty=n,lty=c(1,1,1),col=c(red,blue,darkgreen),cex=1.4)



Citando David Winsemius dwinsem...@comcast.net:



On Aug 24, 2010, at 7:05 PM, Antonio Olinto wrote:


Hello,

I want to know how do R calculates the number of intervals between  
tick-marks in the y axis in a plot.


?axTicks # and then look at the other citations and the code as needed




I'm making a three y-axes plot and this information would help me a lot.

Thanks in advance.

Antonio Olinto


--

David Winsemius, MD
West Hartford, CT







Webmail - iBCMG Internet
http://www.ibcmg.com.br

__
R-help@r-project.org mailing list
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] Removing inter-bar spaces in barchart

2010-08-25 Thread Dennis Murphy
Hi:

On Wed, Aug 25, 2010 at 11:28 AM, Greg Snow greg.s...@imail.org wrote:

 Using the barplot function in base graphics you just set space=0, but that
 function does not have a box.ratio argument which would imply that you are
 using something else.  If you let us know which function (and which package
 it is in) then it is easier (possible) for us to help you, even better is to
 give the information asked for at the bottom of every post and the posting
 guide.


It looks like he's using barchart() in lattice, which does have a box.ratio
argument.

 --
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 greg.s...@imail.org
 801.408.8111


  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
  project.org] On Behalf Of Jonathan Greenberg
  Sent: Tuesday, August 24, 2010 8:21 PM
  To: r-help
  Subject: [R] Removing inter-bar spaces in barchart
 
  Rhelpers:
 
  I'm trying to make a barchart of a 2-group dataset
  (barchart(x~y,data=data,groups=z,horizontal=FALSE)).  My problem is
  that I can't, for the life of me, seem to get rid of the inter-bar
  space -- box.ratio set to 1 doesn't do much.  Any ideas?  I'd
  ideally want zero space between the bars.  Thanks!


I'm more interested in why you'd 'ideally want zero space between
the bars'. By default, bar chart functions in R have spaces between
bars because the bars represent different categories of a
discrete/factor variable and the space is a visual device meant to
connote to the viewer that the categories are not to be interpreted
as an underlying continuum. In contrast, there are no spaces in
between bars of a histogram precisely because the x-scale is meant
to be continuous. Since you're using barchart(), why do you want to
remove the space between bars?

Cheers,
Dennis


  --j
 
  --
  Jonathan A. Greenberg, PhD
  Assistant Project Scientist
  Center for Spatial Technologies and Remote Sensing (CSTARS)
  Department of Land, Air and Water Resources
  University of California, Davis
  One Shields Avenue
  Davis, CA 95616
  Phone: 415-763-5476
  AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307
 
  __
  R-help@r-project.org mailing list
  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
 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
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] Draw a perpendicular line?

2010-08-25 Thread CZ

Thank you all for your suggestions and especially the codes.

Now I am able to solve it by finding the intercepts and slopes for both
lines first, and then I can find the coordinates of x and y at the
intersection.  At first I forgot how to use C to get the intercept of line
CD...  

Thanks again. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Draw-a-perpendicular-line-tp2335882p2338864.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
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] accessing the attr(*,label.table) after importing from spss

2010-08-25 Thread moleps
Dear all,
I just received a file from a colleague in spss. The read.spss could not finish 
the file due to an error (Unrecognized record type 7, subtype 18 encountered in 
system file) so instead I converted the file using stat-transfer. Looking at my 
data I see that most labels are in the attributes and I´d love to access them 
and assign the pertinent variables to factors without doing the whole 
factor(levels,labels) thing manually. Is there any remedy to this ??

regards,

M


 str(dat)
'data.frame':   860 obs. of  19 variables:
 $ Ag: int  15 15 15 15 15 15 15 15 15 15 ...
 $ G: int  2 2 2 1 1 1 1 1 1 2 ...
 $ GCQ: int  15 15 15 15 15 15 15 15 15 15 ...
 $ Amn: int  2 2 2 2 2 2 1 1 1 1 ...
 $ HI  : int  1 1 1 1 1 1 2 2 2 2 ...
 $ Hos: int  2 2 2 2 2 2 2 2 2 2 ...
 $ Risk   : int  2 2 2 2 2 2 2 2 2 2 ...
 $ CTO : int  2 2 2 2 2 1 1 1 1 1 ...
 $ pat  : int  NA NA NA NA NA 2 2 2 2 2 ...
 $ Day: int  7 7 7 5 4 6 5 7 7 5 ...
 $ Ho  : int  NA NA NA NA NA NA NA NA NA NA ...
 $ coh  : int  1 1 1 1 1 1 1 1 1 1 ...
 $ Comp : int  1 1 1 1 1 1 1 1 1 1 ...
 $ Ethan: int  2 2 2 2 2 2 2 2 2 2 ...
 $ Pro   : num  NA NA NA NA NA NA NA NA NA NA ...
 $ Ye  : int  1 1 1 3 3 3 1 1 1 3 ...
 $ Ageg: int  1 1 1 1 1 1 1 1 1 1 ...
 $ BAC: int  0 0 0 0 0 0 0 0 0 0 ...
 - attr(*, val.labels)= chr   VL_Gender  VL_Amnesia ...
 - attr(*, var.labels)= chr  Age (years) Gender GCQSSA Amnesty ...
 - attr(*, label.table)=List of 19
  ..$ : NULL
  ..$ : Named num  1 2
  .. ..- attr(*, names)= chr  Male Female
  ..$ : NULL
  ..$ : Named num  1 2
  .. ..- attr(*, names)= chr  Yes No
  ..$ : NULL
  ..$ : Named num  1 2
  .. ..- attr(*, names)= chr  Yes No
  ..$ : Named num  1 2
  .. ..- attr(*, names)= chr  Yes No
  ..$ : Named num  1 2
  .. ..- attr(*, names)= chr  Yes No
  ..$ : Named num  1 2
  .. ..- attr(*, names)= chr  Yes No
  ..$ : Named num  1 2 3 4 5 6 7
  .. ..- attr(*, names)= chr  Monday Tuesday Wednesday Thursday ...
  ..$ : Named num  1 2
  .. ..- attr(*, names)= chr  Yes No
  ..$ : Named num  1 2
  .. ..- attr(*, names)= chr  Yes No
  ..$ : Named num  1 2 3 4 5 6 7
  .. ..- attr(*, names)= chr  Yes Overtriage  Undertriage with 
admission Overtriage with pos ...
  ..$ : Named num  1 2
  .. ..- attr(*, names)= chr  Yes No
  ..$ : NULL
  ..$ : NULL
  ..$ : Named num  1 2 3 4
  .. ..- attr(*, names)= chr  15 - 24 25-39 40-59 60-
  ..$ : Named num  1 2 3
  .. ..- attr(*, names)= chr  0.10-0.99 1.00-1.99 2.00-
  ..$ : Named num  0 1 2 3 4
  .. ..- attr(*, names)= chr  sorry undeweight 0.10-0.99 1.00-1.99 ...
__
R-help@r-project.org mailing list
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] Removing inter-bar spaces in barchart

2010-08-25 Thread David Winsemius


On Aug 24, 2010, at 10:20 PM, Jonathan Greenberg wrote:


Rhelpers:

I'm trying to make a barchart of a 2-group dataset
(barchart(x~y,data=data,groups=z,horizontal=FALSE)).  My problem is
that I can't, for the life of me, seem to get rid of the inter-bar
space -- box.ratio set to 1 doesn't do much.  Any ideas?  I'd
ideally want zero space between the bars.  Thanks!


You didn't provide any data (nor did you illustrate with one of the  
available datasets that are used in examples.)


Compare these two outputs:

barchart(yield ~ year, data = barley,
 groups = variety,   ylab = Barley Yield (bushels/acre),
)

barchart(yield ~ variety, data = barley,
 groups = year,   ylab = Barley Yield (bushels/acre),
)

... and notice that the variables in the group have no separation of  
their bars whereas the rhs variables do. This is the opposite of what  
I expected, so perhaps you think as I did and reversing the roles  
ofy and z  might help?


--

David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
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] package MuMIn

2010-08-25 Thread Ben Bolker
  [cc'ing back to r-help: this is good etiquette so that the responses
will be seen by others/
archived for future reference.]

On 10-08-25 04:35 PM, Marino Taussig De Bodonia, Agnese wrote:
 Yes, I meant MuMIn

 the global formula I introduced was:

 rc4.mod-lm(central$hunting~ central$year + central$gender  +
central$hunter + central$k.score + central$seen.in.wild +
central$captivity + central$had.damage +
central$importance.of.being.informed + central$RC1+ central$RC2 +
central$year:central$hunter + central$year:central$had.damage +
central$year:central$seen.in.wild +central$year:central$RC1 +
central$year:central$RC2)

  In general it would be much clearer and more generalizable if you
instead used:

rc4.mod-lm(hunting~ year + gender  + hunter + k.score + seen.in.wild +
captivity +
   had.damage + importance.of.being.informed + RC1+ RC2 + year:hunter +
year:had.damage +
   year:seen.in.wild +year:RC1 + year:RC2, data=central)

or even

rc4.mod - lm(hunting ~ gender + k.score + captivity +
importance.of.being.informed+
 year*(RC1 + RC2 + hunter + had.damage + seen.in.wild), data=central)

  I don't know why those spurious interactions are showing up. It
*might* be a bug in MuMIn.

  So far, I can't reproduce this behavior with my simple example:

=
library(MuMIn)
dat - data.frame(y=runif(100),a=factor(sample(1:5,replace=TRUE,size=100)),
  b= factor(sample(1:5,replace=TRUE,size=100)),
c=runif(100))

m1 - lm(y~a+b+c+a:b,data=dat)
gm - function(x) {
  model.avg(get.models(dredge(x),subset=deltaInf))$relative.importance
}

gm(m1)

m1 - lm(y~dat$a+dat$b+dat$c+dat$a:dat$b,data=dat)
gm(m1)
==

  You have to keep working to simplify your example until you can get to
a pair
of examples, one simpler and one more complicated, that 'bracket' the
problem --
the simpler example doesn't show the problem, and the more complicated
(closer
to your original example) does.

  Alternatively, you may simplify the problem out of existence and
decide that you don't need to spend any more
time figuring out what it was ...

  Two more quick notes to consider:

  * why are you not considering models with delta4 ... ?
  * it is quite tricky to compare relative importance of 'main effect'
parameters in models with and without interactions.



 There are 15 explanatory variables in this model.

 my code was:

 rc4.mod.Mu - dredge(rc4.mod, rank = AICc)
 rc4.mod.Mu
 rc4.mod.Mu.avg-model.avg(get.models(rc4.mod.Mu, subset = delta  4))

 the output for the command rc4.mod.Mu.avg$relative.importance was:

 central$hunter1
 central$seen.in.wild1
 central$year0.986960449
 central$had.damage0.89670109
 central$RC20.83866013
 central$k.score0.656654734
 central$had.damage:central$year0.517130185
 central$year:central$hunter0.305988097
 central$hunter:central$year0.212045101
 central$year:central$seen.in.wild0.190520501
 central$seen.in.captivity0.148263242
 central$gender0.119314202
 central$RC10.098234445
 central$importance.of.being.informed0.091842088
 central$year:central$RC20.069501158
 central$seen.in.wild:central$year0.065788243
 central$RC2:central$year0.024221603

 There are 17 variables above:  central$year:central$RC2  and
central$RC2:central$year are both present, as are
central$hunter:central$year  and  central$year:central$hunter .

 Can you tell me why, if they are the same thing, they are present twice
and have different values?

 Thanks a lot,

 Agnese
 
 From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On
Behalf Of Ben Bolker [bbol...@gmail.com]
 Sent: 25 August 2010 20:36
 To: r-h...@stat.math.ethz.ch
 Subject: Re: [R] package MuMI

 Marino Taussig De Bodonia, Agnese agnese.marino09 at imperial.ac.uk
writes:

 I am using the package MuMI to run all the possible combinations
  of variables in my full model, and select
 my best models. When I enter my variables in the original model I
 write them like this

 lm(y~ a +b +c +a:b)

 However,  MuMI will also use the variable b:a, which I do not want
 in my model.

 How do I stop that from happening?


   (1) I think you mean MuMIn.
   (2) Please send a reproducible example! (Hint: see the posting
 guide that is referred to at the bottom of all R-help messages ...)
   (3) [now proceeding to try to guess what you mean ...]

 a:b and b:a have identical meanings in the R formula syntax.

   I tried to do something like what I thought you might have meant
 and got what seemed to be reasonable answers.

 library(MuMIn)
 dat -
data.frame(y=runif(100),a=factor(sample(1:5,replace=TRUE,size=100)),
 +b= factor(sample(1:5,replace=TRUE,size=100)), c=runif(100))
 m1 - lm(y~a+b+c+a:b,data=dat)
 dredge(m1)
 Global model: lm(formula = y ~ a + b + c + a:b, data = dat)
 ---
 Model selection table
(Int)  a b c   a:b k  R.sqAdj.R.sq  RSS   AIC   AICc 
delta   weight
 4  0.6385 -0.1643  3 0.03019  

Re: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
Hi Adrian,

Your code for the secant method is correct.

I just tweaked it a bit w/o the calendar time feature (assuming that the
cash flows will be available on an annual basis) as follows:

ANXIRR - function (cashFlow, guess, tol=1.e-04){

npv - function (cashFlow, irr) {
n - length(cashFlow)
sum(cashFlow / (1 + irr)^{0: (n-1)})
}

irrprev - c(0)
  irr - guess
pvPrev - sum(cashFlow)
pv - npv(cashFlow, irr)
eps - abs(pv-pvPrev)

while (eps = tol) {
tmp - irrprev 
 irrprev - irr
irr - irr - ((irr - tmp) * pv / (pv - pvPrev))
pvPrev - pv
pv - npv(cashFlow, irr)
 eps - abs(pv - pvPrev)
}
list(irr = irr, npv = pv)
}

# example from Wikipedia enntry
cashflow - c(-4000, 1200, 1410, 1875, 1050)

ANXIRR(cashflow, guess=0.05)  

 ANXIRR(cashflow, guess=0.05)
$irr
[1] 0.1429934

$npv
[1] 1.705303e-12


Hope this helps,
Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Adrian Ng
Sent: Wednesday, August 25, 2010 8:39 AM
To: r-help@r-project.org
Subject: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

Hi,

I am new to R, and as a first exercise, I decided to try to implement an
XIRR function using the secant method.  I did a quick search and saw another
posting that used the Bisection method but wanted to see if it was possible
using the secant method.

I would input a Cash Flow and Date vector as well as an initial guess.  I
hardcoded today's initial date so I could do checks in Excel.  This code
seems to only converge when my initial guess is very close to the correct
IRR.

Maybe I have some basic errors in my coding/logic? Any help would be greatly
appreciated.

The Wikipedia article to secant method and IRR:
http://en.wikipedia.org/wiki/Internal_rate_of_return#Numerical_solution

Thanks!



ANXIRR - function (cashFlow, cfDate, guess){
cfDate-as.Date(cfDate,format=%m/%d/%Y)
irrprev - c(0); irr- guess


pvPrev- sum(cashFlow)
pv-
sum(cashFlow/((1+irr)^(as.numeric(difftime(cfDate,2010-08-24,units=days)
)/360)))
print(pv)
print(Hi)


while (abs(pv) = 0.001) {
t-irrprev; irrprev- irr;
irr-irr-((irr-t)*pv/(pv-pvPrev));
pvPrev-pv;
 
pv-sum(cashFlow/((1+irr)^(as.numeric(difftime(cfDate,2010-08-24,units=da
ys))/365)))
print(irr);print(pv)
}
}





Please consider the environment before printing this e-mail.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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
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] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
Another approach is to use `uniroot' to find the zero of the NPV function:

npv - function (cashFlow, irr) {
n - length(cashFlow)
sum(cashFlow / (1 + irr)^{0: (n-1)})
}

uniroot(f=npv, interval=c(0,1), cashFlow=cashFlow)

However, there may be situations where there are no real zeros or there are
multiple zeros of the NPV function.

Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Adrian Ng
Sent: Wednesday, August 25, 2010 8:39 AM
To: r-help@r-project.org
Subject: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

Hi,

I am new to R, and as a first exercise, I decided to try to implement an
XIRR function using the secant method.  I did a quick search and saw another
posting that used the Bisection method but wanted to see if it was possible
using the secant method.

I would input a Cash Flow and Date vector as well as an initial guess.  I
hardcoded today's initial date so I could do checks in Excel.  This code
seems to only converge when my initial guess is very close to the correct
IRR.

Maybe I have some basic errors in my coding/logic? Any help would be greatly
appreciated.

The Wikipedia article to secant method and IRR:
http://en.wikipedia.org/wiki/Internal_rate_of_return#Numerical_solution

Thanks!



ANXIRR - function (cashFlow, cfDate, guess){
cfDate-as.Date(cfDate,format=%m/%d/%Y)
irrprev - c(0); irr- guess


pvPrev- sum(cashFlow)
pv-
sum(cashFlow/((1+irr)^(as.numeric(difftime(cfDate,2010-08-24,units=days)
)/360)))
print(pv)
print(Hi)


while (abs(pv) = 0.001) {
t-irrprev; irrprev- irr;
irr-irr-((irr-t)*pv/(pv-pvPrev));
pvPrev-pv;
 
pv-sum(cashFlow/((1+irr)^(as.numeric(difftime(cfDate,2010-08-24,units=da
ys))/365)))
print(irr);print(pv)
}
}





Please consider the environment before printing this e-mail.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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
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] OT: R for iPhone/iPad OS?

2010-08-25 Thread Carl Witthoft
No, seriously:  I've had more than one person at work wonder what math 
toolset could be loaded onto iOS.   So, before Matlab, FreeMat, 
Mathematia, SciLab, Octave, or numpy (:-) ) produces a version for iPad, 
any chance someone is working on R for iPad?


__
R-help@r-project.org mailing list
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] OT: R for iPhone/iPad OS?

2010-08-25 Thread Greg Snow
I believe that the iPad conditions for producing apps are incompatible with the 
GPL (gnuGo was removed from the apps store recently for this reason), so don't 
hold your breath.

There may be some possibility for an app on the iPad that would access R on a 
server somewhere else, but that is beyond my abilities/interest.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Carl Witthoft
 Sent: Wednesday, August 25, 2010 3:24 PM
 To: r-help@r-project.org
 Subject: [R] OT: R for iPhone/iPad OS?
 
 No, seriously:  I've had more than one person at work wonder what math
 toolset could be loaded onto iOS.   So, before Matlab, FreeMat,
 Mathematia, SciLab, Octave, or numpy (:-) ) produces a version for
 iPad,
 any chance someone is working on R for iPad?
 
 __
 R-help@r-project.org mailing list
 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
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] OT: R for iPhone/iPad OS?

2010-08-25 Thread Erik Iverson

Instructions for installing R on jailbroken devices:

http://rwiki.sciviews.org/doku.php?id=getting-started:installation:iphone


Carl Witthoft wrote:
No, seriously:  I've had more than one person at work wonder what math 
toolset could be loaded onto iOS.   So, before Matlab, FreeMat, 
Mathematia, SciLab, Octave, or numpy (:-) ) produces a version for iPad, 
any chance someone is working on R for iPad?


__
R-help@r-project.org mailing list
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
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] OT: R for iPhone/iPad OS?

2010-08-25 Thread Steve Lianoglou
Hi,

On Wed, Aug 25, 2010 at 5:37 PM, Greg Snow greg.s...@imail.org wrote:
 I believe that the iPad conditions for producing apps are incompatible with 
 the GPL (gnuGo was removed from the apps store recently for this reason), so 
 don't hold your breath.

 There may be some possibility for an app on the iPad that would access R on a 
 server somewhere else, but that is beyond my abilities/interest.

This has come up a few times before on R-sig-mac.

Here's one:
http://thread.gmane.org/gmane.comp.lang.r.mac/4912

You can search that list for others discussions that have popped up to
get a feel of what was discussed about this already. If you have more
to add to the conversation, I reckon you'd get the most traction if
you post directly to that mailing list ...

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
R-help@r-project.org mailing list
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] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
Yes, the secant method (like Newton Raphson) is not guaranteed to converge,
unlike the bisection method, but it has a superlinear convergence (not that
this matters much!).  Brent's method, which is used in `uniroot', is a
reliable and fast method, which is why I suggested it in my previous email.

Having said that, I am not sure about the convergence problem that you are
having without seeing the actual example.

Ravi.

-Original Message-
From: Adrian Ng [mailto:a...@hamiltonlane.com] 
Sent: Wednesday, August 25, 2010 5:28 PM
To: Ravi Varadhan; r-help@r-project.org
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
XIRR/IRR)

Hi Ravi,

Thanks for the responses.  I was actually trying to calculate IRR based on
unevenly spaced cash flows, and that's why I decided to use the secant
method.  I'm not sure if my answer isn't converging because I have some
careless mistake in the code, or if it's simply because unlike the bisection
method, the secant method doesn't 'sandwich' the desired root.



-Original Message-
From: Ravi Varadhan [mailto:rvarad...@jhmi.edu] 
Sent: Wednesday, August 25, 2010 5:24 PM
To: Adrian Ng; r-help@r-project.org
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
XIRR/IRR)

Another approach is to use `uniroot' to find the zero of the NPV function:

npv - function (cashFlow, irr) {
n - length(cashFlow)
sum(cashFlow / (1 + irr)^{0: (n-1)})
}

uniroot(f=npv, interval=c(0,1), cashFlow=cashFlow)

However, there may be situations where there are no real zeros or there are
multiple zeros of the NPV function.

Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Adrian Ng
Sent: Wednesday, August 25, 2010 8:39 AM
To: r-help@r-project.org
Subject: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

Hi,

I am new to R, and as a first exercise, I decided to try to implement an
XIRR function using the secant method.  I did a quick search and saw another
posting that used the Bisection method but wanted to see if it was possible
using the secant method.

I would input a Cash Flow and Date vector as well as an initial guess.  I
hardcoded today's initial date so I could do checks in Excel.  This code
seems to only converge when my initial guess is very close to the correct
IRR.

Maybe I have some basic errors in my coding/logic? Any help would be greatly
appreciated.

The Wikipedia article to secant method and IRR:
http://en.wikipedia.org/wiki/Internal_rate_of_return#Numerical_solution

Thanks!



ANXIRR - function (cashFlow, cfDate, guess){
cfDate-as.Date(cfDate,format=%m/%d/%Y)
irrprev - c(0); irr- guess


pvPrev- sum(cashFlow)
pv-
sum(cashFlow/((1+irr)^(as.numeric(difftime(cfDate,2010-08-24,units=days)
)/360)))
print(pv)
print(Hi)


while (abs(pv) = 0.001) {
t-irrprev; irrprev- irr;
irr-irr-((irr-t)*pv/(pv-pvPrev));
pvPrev-pv;
 
pv-sum(cashFlow/((1+irr)^(as.numeric(difftime(cfDate,2010-08-24,units=da
ys))/365)))
print(irr);print(pv)
}
}





Please consider the environment before printing this e-mail.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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
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] OT: R for iPhone/iPad OS?

2010-08-25 Thread Marc Schwartz
On Aug 25, 2010, at 4:23 PM, Carl Witthoft wrote:

 No, seriously:  I've had more than one person at work wonder what math 
 toolset could be loaded onto iOS.   So, before Matlab, FreeMat, Mathematia, 
 SciLab, Octave, or numpy (:-) ) produces a version for iPad, any chance 
 someone is working on R for iPad?


See this coverage of recent discussions at R-Bloggers:

  
http://www.r-bloggers.com/could-we-run-a-statistical-analysis-on-iphoneipad-using-r/

Unless you are willing to jailbreak the devices, the basic answer is not as a 
traditional stand alone application. 

However, using a client/server model based GUI application (think 
Wolfram|Alpha) or via a web browser connecting to a remote R server, yes you 
can. 

HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
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] Looking for an image (R 64-bit on Linux 64-bit) on Amazon EC2

2010-08-25 Thread noclue_

I have found an existing image on Amazon EC2 including R. But unfortunately,
it is 32-bit 
R on 32-bit Linux.

Does anybody know if there exists an mage (R 64-bit on Linux 64-bit) on 
Amazon EC2?

Or how can I install 64-bit R on my own Linux instance there?

Thanks.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Looking-for-an-image-R-64-bit-on-Linux-64-bit-on-Amazon-EC2-tp2338938p2338938.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
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] OT: R for iPhone/iPad OS?

2010-08-25 Thread Brian Diggs

On 8/25/2010 2:23 PM, Carl Witthoft wrote:

No, seriously:  I've had more than one person at work wonder what math
toolset could be loaded onto iOS. So, before Matlab, FreeMat,
Mathematia, SciLab, Octave, or numpy (:-) ) produces a version for iPad,
any chance someone is working on R for iPad?


This has come up before and one conclusion was that there may be issues 
regarding GPL software and the App Store's restrictions, or at least 
design issues that would make this somewhere between difficult and 
impossible.  For a much more thorough discussion see the threads:


https://stat.ethz.ch/pipermail/r-help/2010-May/240669.html
https://stat.ethz.ch/pipermail/r-help/2010-June/240901.html

--
Brian Diggs
Senior Research Associate, Department of Surgery
Oregon Health  Science University

__
R-help@r-project.org mailing list
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] Looking for an image (R 64-bit on Linux 64-bit) on Amazon EC2

2010-08-25 Thread stephen sefick
You have a 64 bit Linux?  If so...

Dowload the sources

make sure you have all of the dependencies

unpack tarball

cd to de-compressed directory

issue

./configure

make

sudo make install

or maybe use your distros packages managment tool.

Am I missing something?

On Wed, Aug 25, 2010 at 4:39 PM, noclue_ tim@netzero.net wrote:

 I have found an existing image on Amazon EC2 including R. But unfortunately,
 it is 32-bit
 R on 32-bit Linux.

 Does anybody know if there exists an mage (R 64-bit on Linux 64-bit) on
 Amazon EC2?

 Or how can I install 64-bit R on my own Linux instance there?

 Thanks.
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Looking-for-an-image-R-64-bit-on-Linux-64-bit-on-Amazon-EC2-tp2338938p2338938.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 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.




-- 
Stephen Sefick

| Auburn University                                   |
| Department of Biological Sciences           |
| 331 Funchess Hall                                  |
| Auburn, Alabama                                   |
| 36849                                                    |
|___|
| sas0...@auburn.edu                             |
| http://www.auburn.edu/~sas0025             |
|___|

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

                                -K. Mullis

A big computer, a complex algorithm and a long time does not equal science.

                              -Robert Gentleman

__
R-help@r-project.org mailing list
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] OT: R for iPhone/iPad OS?

2010-08-25 Thread Carl Witthoft

Hey,
Many thanks to all who responded!  I'll pass along the links to my pals.

Personally I can't imagine doing R on a virtual keyboard in the first 
place, but to each his own.



Carl

__
R-help@r-project.org mailing list
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 plot y-axis on the right of x-axis

2010-08-25 Thread elaine kuo
Thank you.
The answers provides the right direction and a code was written accordingly.

One more request, if the label of axis X wants to be drawn from 5 to 1 (left
to right)
rather than 1 to 5, is it fine to change axis (4, at = NULL) ?
If so, which value should be input ?

Thanks again.

Elaine

code
plot(1:5,axes=FALSE)
axis(1)
axis(4)
box()




On Wed, Aug 25, 2010 at 5:39 PM, Jim Lemon j...@bitwrit.com.au wrote:

 On 08/25/2010 09:12 AM, elaine kuo wrote:

 Dear List,

 I have a richness data distributing across 20 N to 20 S latitude. (120
 E-140
 E longitude).


 I would like to draw the richness in the north hemisphere and a regression
 line in the plot
 (x-axis: latitude, y-axis: richness in the north hemisphere).
 The above demand is done using plot.

 Then, south hemisphere richness and regression are required to be
 generated
 using
 the same y-axis above but an x-axis on the left side of the y-axis.
 (The higher latitude in the south hemisphere, the left it would move)

 Please kindly share how to design the south plot and regression line for
 richness.
 Also, please advise if any more info is in need.

  Hi Elaine,
 Changing the position of the axes is easily done by changing the side and
 pos arguments of the axis function. If you want to move the y-axis to
 the right (or as you state it, the x axis to the left):

 # y axis on the left
 plot(1:5,axes=FALSE)
 axis(1)
 axis(2)
 # add a y axis one third of the way to the right
 xylim-par(usr)
 axis(2,pos=xylim[1]+diff(xylim[1:2])/3)
 # add another y axis two thirds of the way
 axis(4,pos=xylim[2]-diff(xylim[1:2])/3)
 # add one more on the right
 axis(4)

 You can move the x axis up and down using the same tricks.

 Jim


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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 plot y-axis on the right of x-axis

2010-08-25 Thread elaine kuo
Yes, I appreciated your answers which well hit my questions. (esp the
perfect model parts).

About the plot part, one more question.
Is it possible to make the two plots (northern and southern richness)
sharing the same Y axis (latitude = 0, the equator) ?
In other words, southern richness would be on the left side of the Y axis,
while northern one on the right side.

Elaine


Two plot panels on the same device like:

layout(1:2)
plot(1:100)
plot(1:100)
layout(1)

=  Yes that's what I want

The second panel for southern species richness, do you mean you want the
plot to go like this:

plot(1:100, xlim = c(100,1))

=  Yes, too.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
The secant method converges just fine.  Your problem might have occurred due
to improper conversion of dates to elapsed time.  You want to calculate IRR
using year as the time unit, not days.  

Here is the secant function (modified to account for irregular times) and
the results for your example:

ANXIRR - function (cashFlow, dates, guess, tol=1.e-04){

npv - function (cashFlow, times, irr) {
n - length(cashFlow)
sum(cashFlow / (1 + irr)^times)
}

if (guess == 0)stop(Initial guess must be strictly greater than 0)  

times - as.numeric(difftime(dates, dates[1], units=days) /
365.24)

irrprev - c(0)
  irr - guess
pvPrev - sum(cashFlow)
pv - npv(cashFlow, times, irr)
eps - abs(pv-pvPrev)

while (eps = tol) {
tmp - irrprev 
 irrprev - irr
irr - irr - ((irr - tmp) * pv / (pv - pvPrev))
pvPrev - pv
pv - npv(cashFlow, times, irr)
 eps - abs(pv - pvPrev)
}
list(irr = irr, npv = pv)
}

CF - c(-1000,500,500,500,500,500)

dates -
c(1/1/2001,2/1/2002,3/1/2003,4/1/2004,5/1/2005,6/1/2006) 

ANXIRR(CF, dates, guess=0.1)

 ANXIRR(CF, dates, guess=0.1)
$irr
[1] 0.4106115

$npv
[1] 2.984279e-13


Ravi.

-Original Message-
From: Adrian Ng [mailto:a...@hamiltonlane.com] 
Sent: Wednesday, August 25, 2010 6:23 PM
To: Ravi Varadhan
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
XIRR/IRR)

The forum is kind of slow so I'm just re-sending you the message here:

Hi Ravi, 

I'm just trying a fairly simple example: 
CFs: -1000,500,500,500,500,500 
dates-c(1/1/2001,2/1/2002,3/1/2003,4/1/2004,5/1/2005,6/1/2006) 

Thanks a lot for your help. 
Adrian

-Original Message-
From: Ravi Varadhan [mailto:rvarad...@jhmi.edu] 
Sent: Wednesday, August 25, 2010 5:44 PM
To: Adrian Ng; r-help@r-project.org
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
XIRR/IRR)

Yes, the secant method (like Newton Raphson) is not guaranteed to converge,
unlike the bisection method, but it has a superlinear convergence (not that
this matters much!).  Brent's method, which is used in `uniroot', is a
reliable and fast method, which is why I suggested it in my previous email.

Having said that, I am not sure about the convergence problem that you are
having without seeing the actual example.

Ravi.

-Original Message-
From: Adrian Ng [mailto:a...@hamiltonlane.com] 
Sent: Wednesday, August 25, 2010 5:28 PM
To: Ravi Varadhan; r-help@r-project.org
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
XIRR/IRR)

Hi Ravi,

Thanks for the responses.  I was actually trying to calculate IRR based on
unevenly spaced cash flows, and that's why I decided to use the secant
method.  I'm not sure if my answer isn't converging because I have some
careless mistake in the code, or if it's simply because unlike the bisection
method, the secant method doesn't 'sandwich' the desired root.



-Original Message-
From: Ravi Varadhan [mailto:rvarad...@jhmi.edu] 
Sent: Wednesday, August 25, 2010 5:24 PM
To: Adrian Ng; r-help@r-project.org
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
XIRR/IRR)

Another approach is to use `uniroot' to find the zero of the NPV function:

npv - function (cashFlow, irr) {
n - length(cashFlow)
sum(cashFlow / (1 + irr)^{0: (n-1)})
}

uniroot(f=npv, interval=c(0,1), cashFlow=cashFlow)

However, there may be situations where there are no real zeros or there are
multiple zeros of the NPV function.

Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Adrian Ng
Sent: Wednesday, August 25, 2010 8:39 AM
To: r-help@r-project.org
Subject: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

Hi,

I am new to R, and as a first exercise, I decided to try to implement an
XIRR function using the secant method.  I did a quick search and saw another
posting that used the Bisection method but wanted to see if it was possible
using the secant method.

I would input a Cash Flow and Date vector as well as an initial guess.  I
hardcoded today's initial date so I could do checks in Excel.  This code
seems to only converge when my initial guess is very close to the correct
IRR.

Maybe I have some basic errors in my coding/logic? Any help would be greatly
appreciated.

The Wikipedia article to secant method and IRR:
http://en.wikipedia.org/wiki/Internal_rate_of_return#Numerical_solution

Thanks!



ANXIRR - function (cashFlow, cfDate, guess){
cfDate-as.Date(cfDate,format=%m/%d/%Y)
irrprev - c(0); irr- guess


pvPrev- sum(cashFlow)
pv-
sum(cashFlow/((1+irr)^(as.numeric(difftime(cfDate,2010-08-24,units=days)
)/360)))
print(pv)
print(Hi)


while (abs(pv) = 0.001) {
t-irrprev; irrprev- irr;
irr-irr-((irr-t)*pv/(pv-pvPrev));
pvPrev-pv;
 

Re: [R] lattice help required

2010-08-25 Thread Felix Andrews
Deepayan Sarkar has a function combineLimits() in the development
version of the latticeExtra package (i.e. the version on
r-forge.r-project.org) which will set common scales in each row or
column of your layout. It can also remove the internal axes.

# Felix


On 26 August 2010 04:43, Kay Cichini kay.cich...@uibk.ac.at wrote:

 .. thanks again, richard.
 and you swiftly saw the next problem comming up - when using par.settings =
 list(layout.widths = list(axis.panel = c(1, 0))) getting rid of the double
 tick labeling would be natural -
 but i'll leave it at that for today.

 many thanks,
 kay


 Richard M. Heiberger wrote:

 The multiple y axes are protecting you in this situation.


 z - cbind(rnorm(100,c(1,10),1), rnorm(100,c(20,30),1))
 dotplot(z[,1]+z[,2] ~ facs$Treatment|facs$Sites,
         outer=TRUE,
         scales = list(
           y = list(
             relation=free)),
         ylab=c(y1, y2),
         xlab=c(Site 1, Site 2),
         strip=FALSE,
         main=problem)

 dotplot(z[,1]+z[,2] ~ facs$Treatment|facs$Sites,
         outer=TRUE,
         scales = list(
           y = list(
             relation=free,
             limits=list(c(-5,13),c(-5,13),c(18,32),c(18,32,
         ylab=c(y1, y2),
         xlab=c(Site 1, Site 2),
         strip=FALSE, main=protected)

 For more control (such as suppressing the y-tick labels in the right-hand
 column,
 I recommend Deepayan Sarkar's book.

 Rich

       [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 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.




 -
 
 Kay Cichini
 Postgraduate student
 Institute of Botany
 Univ. of Innsbruck
 

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/lattice-help-required-tp2338382p2338707.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 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.




-- 
Felix Andrews / 安福立
http://www.neurofractal.org/felix/

__
R-help@r-project.org mailing list
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] Adding column to dataframe

2010-08-25 Thread nzcoops

To update on this. I ran the same command on a grid of computers with 32gb
ram, and it completed in 15 seconds, compared to the ~20 minutes on my
desktop.

Simply a ram issue as suspected by a few on the list here.

Thanks
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Adding-column-to-dataframe-tp2330556p2339076.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
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] Rotate x-axis label on log scale

2010-08-25 Thread Tim Elwell-Sutton
Hi Jim
Thanks so much for this. The updated staxlab function works perfectly!
Tim 

-Original Message-
From: Jim Lemon [mailto:j...@bitwrit.com.au] 
Sent: Wednesday, August 25, 2010 6:36 PM
To: tesutton
Cc: r-help@r-project.org
Subject: Re: [R] Rotate x-axis label on log scale

On 08/25/2010 01:37 PM, Tim Elwell-Sutton wrote:
 Hi Jim
 Thanks for this. The staxlab function seems very useful. Unfortunately,
the
 rotation option doesn't seem to work for me when the y-axis is on a log
 scale. It will stagger the labels but not rotate them. There's no error
 message. On a linear axis the rotation works nicely. Any ideas?
 The example below works if you omit log='y' or srt=45

Hi Tim,
Thanks for letting me know about this problem. I never did get around to 
making staxlab work with log axes, but I think this new version:

staxlab-function(side=1,at,labels,nlines=2,top.line=0.5,
  line.spacing=0.8,srt=NA,ticklen=0.03,...) {

  if(missing(labels)) labels-at
  nlabels-length(labels)
  if(missing(at)) at-1:nlabels
  if(is.na(srt)) {
   linepos-rep(top.line,nlines)
   for(i in 2:nlines) linepos[i]-linepos[i-1]+line.spacing
   linepos-rep(linepos,ceiling(nlabels/nlines))[1:nlabels]
   axis(side=side,at=at,labels=rep(,nlabels))
   mtext(text=labels,side=side,line=linepos,at=at,...)
  }
  else {
   xylim-par(usr)
   if(side == 1) {
xpos-at
if(par(ylog)) ypos-10^(xylim[3]-ticklen*(xylim[4]-xylim[3]))
else ypos-xylim[3]-ticklen*(xylim[4]-xylim[3])
   }
   else {
ypos-at
if(par(xlog)) xpos-10^(xylim[1]-ticklen*(xylim[2]-xylim[1]))
else xpos-xylim[1]-ticklen*(xylim[2]-xylim[1])
   }
   par(xpd=TRUE)
   text(xpos,ypos,labels,srt=srt,adj=1,...)
   par(xpd=FALSE)
  }
}

will do what you want.

Jim

__
R-help@r-project.org mailing list
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 obtain the graph of fitted values against one variable after estimation?

2010-08-25 Thread Le Wang
Hi there,

I have a question regarding the plot command after estimation.

Specifically, I estimate a model, say regressing y on x and z. And
after estimation, I would like to plot the fitted values against x,
but I don't need that for z. The following command always gives two
graphs, for both variables x and z.

plot.np-plot(model, plot.errors.method = asymptotic)

My question is, what option should I specify in order to get the graph
for x only?

I know this is probably a very simple question, but I searched around
for a while without any luck. Thank you for your time.

Best,
Le

__
R-help@r-project.org mailing list
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] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
You should use cfDate[1] as the time origin.  You cannot use 08-24-2010 as the 
time origin, since that will yield negative times.  

Here is the correct solution.  

ANXIRR - function (cashFlow, dates, guess, tol=1.e-04){

npv - function (cashFlow, times, irr) {
n - length(cashFlow)
sum(cashFlow / (1 + irr)^times)
}

if (guess == 0) stop(Initial guess must be strictly greater than 0) 

cfDate - as.Date(cfDate,format=%m/%d/%Y)
times - as.numeric(difftime(cfDate, cfDate[1], units=days) /
365.24)

irrprev - c(0)
irr - guess
pvPrev - sum(cashFlow)
pv - npv(cashFlow, times, irr)
eps - abs(pv-pvPrev)

while (eps = tol) {
tmp - irrprev 
irrprev - irr
irr - irr - ((irr - tmp) * pv / (pv - pvPrev))
pvPrev - pv
pv - npv(cashFlow, times, irr)
eps - abs(pv - pvPrev)
}
list(irr = irr, npv = pv)
}
CF - c(-1000,500,500,500,500,500)

dates - c(1/1/2001,2/1/2002,3/1/2003,4/1/2004,5/1/2005,6/1/2006) 

ANXIRR(CF, dates, guess=0.1)

 ANXIRR(CF, dates, guess=0.1)
$irr
[1] 0.3740656

$npv
[1] 2.102695e-09


Hope this helps,
Ravi.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Adrian Ng a...@hamiltonlane.com
Date: Wednesday, August 25, 2010 8:33 pm
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)
To: Ravi Varadhan rvarad...@jhmi.edu
Cc: r-help@r-project.org r-help@r-project.org


 Hi Ravi,
  
  Using days and dividing it by 365 effectively converts the number to 
 years anyway and allows for the irregular times to be specific to the 
 days.
  
  Also, when I replace dates[1] in your line:
   times - as.numeric(difftime(dates, dates[1], units=days) /
  365.24) with 2010-08-24 I think I am getting some irregular 
 results.  
  
  Effectively, what I was trying to do was match what Excel produced 
 with its XIRR function.  With the example I gave excel returned an IRR 
 of ~0.37 (or 37%)
  
  I am still in the process of debugging it...
  
  
  
   
  
  -Original Message-
  From: Ravi Varadhan [ 
  Sent: Wednesday, August 25, 2010 7:24 PM
  To: Adrian Ng
  Cc: r-help@r-project.org
  Subject: RE: [R] Secant Method Convergence (Method to replicate Excel 
 XIRR/IRR)
  
  The secant method converges just fine.  Your problem might have 
 occurred due
  to improper conversion of dates to elapsed time.  You want to 
 calculate IRR
  using year as the time unit, not days.  
  
  Here is the secant function (modified to account for irregular times) 
 and
  the results for your example:
  
  ANXIRR - function (cashFlow, dates, guess, tol=1.e-04){
  
  npv - function (cashFlow, times, irr) {
   n - length(cashFlow)
   sum(cashFlow / (1 + irr)^times)
   }
  
  if (guess == 0)stop(Initial guess must be strictly greater than 0)  
 
  
   times - as.numeric(difftime(dates, dates[1], units=days) /
  365.24)
  
  irrprev - c(0)
irr - guess
  pvPrev - sum(cashFlow)
  pv - npv(cashFlow, times, irr)
   eps - abs(pv-pvPrev)
  
  while (eps = tol) {
  tmp - irrprev 
   irrprev - irr
  irr - irr - ((irr - tmp) * pv / (pv - pvPrev))
  pvPrev - pv
  pv - npv(cashFlow, times, irr)
   eps - abs(pv - pvPrev)
  }
   list(irr = irr, npv = pv)
  }
  
  CF - c(-1000,500,500,500,500,500)
  
  dates -
  c(1/1/2001,2/1/2002,3/1/2003,4/1/2004,5/1/2005,6/1/2006) 
 
  
  ANXIRR(CF, dates, guess=0.1)
  
   ANXIRR(CF, dates, guess=0.1)
  $irr
  [1] 0.4106115
  
  $npv
  [1] 2.984279e-13
  
  
  Ravi.
  
  -Original Message-
  From: Adrian Ng [ 
  Sent: Wednesday, August 25, 2010 6:23 PM
  To: Ravi Varadhan
  Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
  XIRR/IRR)
  
  The forum is kind of slow so I'm just re-sending you the message here:
  
  Hi Ravi, 
  
  I'm just trying a fairly simple example: 
  CFs: -1000,500,500,500,500,500 
  
 dates-c(1/1/2001,2/1/2002,3/1/2003,4/1/2004,5/1/2005,6/1/2006) 
 
  
  Thanks a lot for your help. 
  Adrian
  
  -Original Message-
  From: Ravi Varadhan [ 
  Sent: Wednesday, August 25, 2010 5:44 PM
  To: Adrian Ng; r-help@r-project.org
  Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
  XIRR/IRR)
  
  Yes, the secant method (like Newton Raphson) is not guaranteed to converge,
  unlike the bisection method, but it has a superlinear convergence 
 (not that
  this matters much!).  Brent's method, which is used in `uniroot', is 
 a
  reliable and fast method, which is why I suggested it in my previous 
 email.
  
  Having said that, I am not sure about the convergence problem that 
 you are
  having without seeing the actual example.
  
  Ravi.
  
  -Original Message-
  From: Adrian Ng [ 
  Sent: Wednesday, August 25, 2010 5:28 PM
  To: Ravi Varadhan; r-help@r-project.org
  

Re: [R] How to obtain the graph of fitted values against one variable after estimation?

2010-08-25 Thread David Winsemius


On Aug 25, 2010, at 10:46 PM, Le Wang wrote:


Hi there,

I have a question regarding the plot command after estimation.

Specifically, I estimate a model, say regressing y on x and z. And
after estimation, I would like to plot the fitted values against x,
but I don't need that for z. The following command always gives two
graphs, for both variables x and z.

plot.np-plot(model, plot.errors.method = asymptotic)

My question is, what option should I specify in order to get the graph
for x only?


Pick a constant value for z and vary x in a dataframe that you  
offer to the newdata argument of predict.


?predict

Then plot those values versus x.



I know this is probably a very simple question, but I searched around
for a while without any luck. Thank you for your time.


--

David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
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] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Ravi Varadhan
I have written a general root-finder using the secant method.  

secant - function(par, fn, tol=1.e-07, itmax = 100, trace=TRUE, ...) {
# par = a starting vector with 2 starting values
# fn = a function whose first argument is the variable of interest
# 
if (length(par) != 2) stop(You must specify a starting parameter vector of 
length 2) 
p.2 - par[1]
p.1 - par[2]
f - rep(NA, length(par))
f[1] - fn(p.1, ...)
f[2] - fn(p.2, ...)
iter - 1
pchg - abs(p.2 - p.1)
fval - f[2]
if (trace) cat(par: , par, fval: , f, \n)
while (pchg = tol  abs(fval)  tol  iter = itmax) {
p.new - p.2 - (p.2 - p.1) * f[2] / (f[2] - f[1])
pchg - abs(p.new - p.2)
fval - fn(p.new, ...)
p.1 - p.2
p.2 - p.new
f[1] - f[2]
f[2] - fval
iter - iter + 1
if (trace) cat(par: , p.new, fval: , fval, \n)
}
list(par = p.new, value = fval, iter=iter)
}

Now we can use this function to find the zero of your NPV function as follows:

npv - function (irr, cashFlow, times) sum(cashFlow / (1 + irr)^times)

CF - c(-1000,500,500,500,500,500)

dates - c(1/1/2001,2/1/2002,3/1/2003,4/1/2004,5/1/2005,6/1/2006) 
cfDate - as.Date(cfDate,format=%m/%d/%Y)
times - as.numeric(difftime(cfDate, cfDate[1], units=days))/365.24

secant(par=c(0,0.1), fn=npv, cashFlow=CF, times=times)

 secant(par=c(0,0.1), fn=npv, cashFlow=CF, times=times)
par:  0 0.1 fval:  854.2388 1500 
par:  0.232284 fval:  334.7318 
par:  0.2990093 fval:  156.9595 
par:  0.3579227 fval:  30.59229 
par:  0.3721850 fval:  3.483669 
par:  0.3740179 fval:  0.08815743 
par:  0.3740655 fval:  0.0002613245 
par:  0.3740656 fval:  1.966778e-08 
$par
[1] 0.3740656

$value
[1] 1.966778e-08

$iter
[1] 8


Hope this helps,
Ravi.



Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Ravi Varadhan rvarad...@jhmi.edu
Date: Wednesday, August 25, 2010 10:51 pm
Subject: Re: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)
To: Adrian Ng a...@hamiltonlane.com
Cc: r-help@r-project.org r-help@r-project.org


 You should use cfDate[1] as the time origin.  You cannot use 
 08-24-2010 as the time origin, since that will yield negative times.  
 
  
  Here is the correct solution.  
  
  ANXIRR - function (cashFlow, dates, guess, tol=1.e-04){
  
  npv - function (cashFlow, times, irr) {
  n - length(cashFlow)
  sum(cashFlow / (1 + irr)^times)
  }
  
  if (guess == 0) stop(Initial guess must be strictly greater than 0) 
 
  
  cfDate - as.Date(cfDate,format=%m/%d/%Y)
  times - as.numeric(difftime(cfDate, cfDate[1], units=days) /
  365.24)
  
  irrprev - c(0)
  irr - guess
  pvPrev - sum(cashFlow)
  pv - npv(cashFlow, times, irr)
  eps - abs(pv-pvPrev)
  
  while (eps = tol) {
  tmp - irrprev 
  irrprev - irr
  irr - irr - ((irr - tmp) * pv / (pv - pvPrev))
  pvPrev - pv
  pv - npv(cashFlow, times, irr)
  eps - abs(pv - pvPrev)
  }
  list(irr = irr, npv = pv)
  }
  CF - c(-1000,500,500,500,500,500)
  
  dates - 
 c(1/1/2001,2/1/2002,3/1/2003,4/1/2004,5/1/2005,6/1/2006) 
  
  ANXIRR(CF, dates, guess=0.1)
  
   ANXIRR(CF, dates, guess=0.1)
  $irr
  [1] 0.3740656
  
  $npv
  [1] 2.102695e-09
  
  
  Hope this helps,
  Ravi.
  
  
  
  Ravi Varadhan, Ph.D.
  Assistant Professor,
  Division of Geriatric Medicine and Gerontology
  School of Medicine
  Johns Hopkins University
  
  Ph. (410) 502-2619
  email: rvarad...@jhmi.edu
  
  
  - Original Message -
  From: Adrian Ng a...@hamiltonlane.com
  Date: Wednesday, August 25, 2010 8:33 pm
  Subject: RE: [R] Secant Method Convergence (Method to replicate Excel 
 XIRR/IRR)
  To: Ravi Varadhan rvarad...@jhmi.edu
  Cc: r-help@r-project.org r-help@r-project.org
  
  
   Hi Ravi,

Using days and dividing it by 365 effectively converts the number 
 to 
   years anyway and allows for the irregular times to be specific to 
 the 
   days.

Also, when I replace dates[1] in your line:
 times - as.numeric(difftime(dates, dates[1], units=days) /
365.24) with 2010-08-24 I think I am getting some irregular 
   results.  

Effectively, what I was trying to do was match what Excel produced 
 
   with its XIRR function.  With the example I gave excel returned an 
 IRR 
   of ~0.37 (or 37%)

I am still in the process of debugging it...



 

-Original Message-
From: Ravi Varadhan [ 
Sent: Wednesday, August 25, 2010 7:24 PM
To: Adrian Ng
Cc: r-help@r-project.org
Subject: RE: [R] Secant Method Convergence (Method to replicate 
 Excel 
   XIRR/IRR)

The secant method converges just fine.  Your problem might have 
   occurred due
to improper conversion of dates to elapsed time.  You want to 
   calculate IRR
using year 

[R] list of closures

2010-08-25 Thread Stephen T.

Hi, I wanted to create a list of closures. When I use Map(), mapply(), 
lapply(), etc., to create this list, it appears that the wrong arguments are 
being passed to the main function. For example:
Main function:
 adder - function(x) function(y) x + y
Creating list of closures with Map():
 plus - Map(adder,c(one=1,two=2)) plus$one(1)[1] 3 plus$two(1)[1] 3
Examining what value was bound to x:
 Map(function(fn) get(x,environment(fn)),plus)$one[1] 2$two[1] 2

This is what I had expected:
 plus - list(one=adder(1),two=adder(2)) plus$one(1)[1] 2 plus$two(1)[1] 3
 Map(function(fn) get(x,environment(fn)),plus)$one[1] 1$two[1] 2

Anyone know what's going on? Thanks much!
Stephen


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] list of closures

2010-08-25 Thread Gabor Grothendieck
On Thu, Aug 26, 2010 at 12:04 AM, Stephen T. obsessiv...@hotmail.com wrote:

 Hi, I wanted to create a list of closures. When I use Map(), mapply(), 
 lapply(), etc., to create this list, it appears that the wrong arguments are 
 being passed to the main function. For example:
 Main function:
 adder - function(x) function(y) x + y
 Creating list of closures with Map():
 plus - Map(adder,c(one=1,two=2)) plus$one(1)[1] 3 plus$two(1)[1] 3
 Examining what value was bound to x:
 Map(function(fn) get(x,environment(fn)),plus)$one[1] 2$two[1] 2

 This is what I had expected:
 plus - list(one=adder(1),two=adder(2)) plus$one(1)[1] 2 plus$two(1)[1] 3
 Map(function(fn) get(x,environment(fn)),plus)$one[1] 1$two[1] 2

 Anyone know what's going on? Thanks much!

R uses lazy evaluation of function arguments.  Try forcing x:

 adder - function(x) { force(x); function(y) x + y }
 plus - Map(adder,c(one=1,two=2))
 plus$one(1)
[1] 2
 plus$two(1)
[1] 3

__
R-help@r-project.org mailing list
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] list of closures

2010-08-25 Thread Philippe Grosjean
Unless for learning R, you should really consider R.oo or proto packages 
that may be more convenient for you (but you don't provide enough 
context to tell).

Best,

Philippe

On 26/08/10 06:28, Gabor Grothendieck wrote:

On Thu, Aug 26, 2010 at 12:04 AM, Stephen T.obsessiv...@hotmail.com  wrote:


Hi, I wanted to create a list of closures. When I use Map(), mapply(), 
lapply(), etc., to create this list, it appears that the wrong arguments are 
being passed to the main function. For example:
Main function:

adder- function(x) function(y) x + y

Creating list of closures with Map():

plus- Map(adder,c(one=1,two=2))  plus$one(1)[1] 3  plus$two(1)[1] 3

Examining what value was bound to x:

Map(function(fn) get(x,environment(fn)),plus)$one[1] 2$two[1] 2


This is what I had expected:

plus- list(one=adder(1),two=adder(2))  plus$one(1)[1] 2  plus$two(1)[1] 3
Map(function(fn) get(x,environment(fn)),plus)$one[1] 1$two[1] 2


Anyone know what's going on? Thanks much!


R uses lazy evaluation of function arguments.  Try forcing x:


adder- function(x) { force(x); function(y) x + y }
plus- Map(adder,c(one=1,two=2))
plus$one(1)

[1] 2

plus$two(1)

[1] 3

__
R-help@r-project.org mailing list
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
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] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

2010-08-25 Thread Adrian Ng
Hi Ravi,

Using days and dividing it by 365 effectively converts the number to years 
anyway and allows for the irregular times to be specific to the days.

Also, when I replace dates[1] in your line:
 times - as.numeric(difftime(dates, dates[1], units=days) /
365.24) with 2010-08-24 I think I am getting some irregular results.  

Effectively, what I was trying to do was match what Excel produced with its 
XIRR function.  With the example I gave excel returned an IRR of ~0.37 (or 37%)

I am still in the process of debugging it...



 

-Original Message-
From: Ravi Varadhan [mailto:rvarad...@jhmi.edu] 
Sent: Wednesday, August 25, 2010 7:24 PM
To: Adrian Ng
Cc: r-help@r-project.org
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

The secant method converges just fine.  Your problem might have occurred due
to improper conversion of dates to elapsed time.  You want to calculate IRR
using year as the time unit, not days.  

Here is the secant function (modified to account for irregular times) and
the results for your example:

ANXIRR - function (cashFlow, dates, guess, tol=1.e-04){

npv - function (cashFlow, times, irr) {
n - length(cashFlow)
sum(cashFlow / (1 + irr)^times)
}

if (guess == 0)stop(Initial guess must be strictly greater than 0)  

times - as.numeric(difftime(dates, dates[1], units=days) /
365.24)

irrprev - c(0)
  irr - guess
pvPrev - sum(cashFlow)
pv - npv(cashFlow, times, irr)
eps - abs(pv-pvPrev)

while (eps = tol) {
tmp - irrprev 
 irrprev - irr
irr - irr - ((irr - tmp) * pv / (pv - pvPrev))
pvPrev - pv
pv - npv(cashFlow, times, irr)
 eps - abs(pv - pvPrev)
}
list(irr = irr, npv = pv)
}

CF - c(-1000,500,500,500,500,500)

dates -
c(1/1/2001,2/1/2002,3/1/2003,4/1/2004,5/1/2005,6/1/2006) 

ANXIRR(CF, dates, guess=0.1)

 ANXIRR(CF, dates, guess=0.1)
$irr
[1] 0.4106115

$npv
[1] 2.984279e-13


Ravi.

-Original Message-
From: Adrian Ng [mailto:a...@hamiltonlane.com] 
Sent: Wednesday, August 25, 2010 6:23 PM
To: Ravi Varadhan
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
XIRR/IRR)

The forum is kind of slow so I'm just re-sending you the message here:

Hi Ravi, 

I'm just trying a fairly simple example: 
CFs: -1000,500,500,500,500,500 
dates-c(1/1/2001,2/1/2002,3/1/2003,4/1/2004,5/1/2005,6/1/2006) 

Thanks a lot for your help. 
Adrian

-Original Message-
From: Ravi Varadhan [mailto:rvarad...@jhmi.edu] 
Sent: Wednesday, August 25, 2010 5:44 PM
To: Adrian Ng; r-help@r-project.org
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
XIRR/IRR)

Yes, the secant method (like Newton Raphson) is not guaranteed to converge,
unlike the bisection method, but it has a superlinear convergence (not that
this matters much!).  Brent's method, which is used in `uniroot', is a
reliable and fast method, which is why I suggested it in my previous email.

Having said that, I am not sure about the convergence problem that you are
having without seeing the actual example.

Ravi.

-Original Message-
From: Adrian Ng [mailto:a...@hamiltonlane.com] 
Sent: Wednesday, August 25, 2010 5:28 PM
To: Ravi Varadhan; r-help@r-project.org
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
XIRR/IRR)

Hi Ravi,

Thanks for the responses.  I was actually trying to calculate IRR based on
unevenly spaced cash flows, and that's why I decided to use the secant
method.  I'm not sure if my answer isn't converging because I have some
careless mistake in the code, or if it's simply because unlike the bisection
method, the secant method doesn't 'sandwich' the desired root.



-Original Message-
From: Ravi Varadhan [mailto:rvarad...@jhmi.edu] 
Sent: Wednesday, August 25, 2010 5:24 PM
To: Adrian Ng; r-help@r-project.org
Subject: RE: [R] Secant Method Convergence (Method to replicate Excel
XIRR/IRR)

Another approach is to use `uniroot' to find the zero of the NPV function:

npv - function (cashFlow, irr) {
n - length(cashFlow)
sum(cashFlow / (1 + irr)^{0: (n-1)})
}

uniroot(f=npv, interval=c(0,1), cashFlow=cashFlow)

However, there may be situations where there are no real zeros or there are
multiple zeros of the NPV function.

Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Adrian Ng
Sent: Wednesday, August 25, 2010 8:39 AM
To: r-help@r-project.org
Subject: [R] Secant Method Convergence (Method to replicate Excel XIRR/IRR)

Hi,

I am new to R, and as a first exercise, I decided to try to implement an
XIRR function using the secant method.  I did a quick search and saw another
posting that used the Bisection method but wanted to see if it was possible
using the secant method.

I would input a Cash Flow and Date vector as well as an initial guess.  I
hardcoded today's initial date so I could 

Re: [R] creation package

2010-08-25 Thread anderson nuel
Dear r-help,

I took your advice into consideration and i tried to solve my errors. But ,
when I use the command R CMD check namepackage, I find an error in this file
C:/Rpack/namepackage.Rcheck/00check.txt :


* using log directory 'C:/Rpack/namepackge.Rcheck'
* using R version 2.10.1 (2009-12-14)
* using session charset: ISO8859-1
* checking for file 'namepackge/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'namepackge' version '1.0'
* checking package name space information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for executable files ... OK
* checking whether package 'namepackge' can be installed ... OK
* checking package directory ... OK
* checking for portable file names ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the name space can be loaded with stated dependencies ...
OK
* checking for unstated dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking data for non-ASCII characters ... OK
* checking examples ... ERROR
Running examples in 'namepackge-Ex.R' failed.
The error most likely occurred in:

 ### * RT

 flush(stderr()); flush(stdout())

 ### Name: RT
 ### Title: modeling
 ### Aliases: RT
 ### Keywords: programming models

 ### ** Examples

   data(d)
   data - d
 RT(t(d), c(2,2,2), c(1,2,3),c(V1,V2,V3))
Error in text.default(x, y, labels = labels, col = label.color, family =
label.family,  :
  family 'serif' not included in PostScript device
Calls: RT- plot - plot.igraph - text - text.default
Execution halted
Best Regards,






2010/8/19, Michael Dewey i...@aghmed.fsnet.co.uk:

 At 13:57 19/08/2010, anderson nuel wrote:

 Dear r-help,

 I don't use namespace.


 Well, as I said in my original reply, it would be a good idea to do so.


 How can I make asia available?


 Without knowing where asia is that is quite a tough call. How do you access
 it when you test your code before you try to package it?


 I think my problem in creating the package in this: I have a singleglobal
 function (RT) in my package, but inside RT I need to call several other
 function( comb l,earn_comb, nchoo). When I used package.sekeleton, Iput in
 lists all the functions(comb l,earn_comb, nchoo,RT),but in the 'man' I
 left
 only namepackage-package.Rd and RT.Rd. When I did do this, is it true??


 Best Regards


 2010/8/18, Michael Dewey mailto:i...@aghmed.fsnet.co.uk
 i...@aghmed.fsnet.co.uk:

 At 10:27 18/08/2010, anderson nuel wrote:
 Dear r-help,

 No, I find errors in the file C:/Rp/namepackage.Rcheck/00check.txt :

 * using log directory 'C:/Rpackage/namepackage.Rcheck'
 * using R version 2.10.1 (2009-12-14)
 * using session charset: ISO8859-1
 * checking for file 'namepackage/DESCRIPTION' ... OK
 * checking extension type ... Package
 * this is package 'namepackage' version '1.0'
 * checking package dependencies ... OK
 * checking if this is a source package ... OK
 * checking for executable files ... OK
 * checking whether package 'namepackage' can be installed ... OK
 * checking package directory ... OK
 * checking for portable file names ... OK
 * checking DESCRIPTION meta-information ... OK
 * checking top-level files ... OK
 * checking index information ... OK
 * checking package subdirectories ... OK
 * checking R files for non-ASCII characters ... OK
 * checking R files for syntax errors ... OK
 * checking whether the package can be loaded ... OK
 * checking whether the package can be loaded with stated dependencies ...
 OK
 * checking for unstated dependencies in R code ... OK
 * checking S3 generic/method consistency ... OK
 * checking replacement functions ... OK
 * checking foreign function calls ... OK
 * checking R code for possible problems ... NOTE
 comb: no visible global function definition for 'copy_bloc'
 comb: no visible global function definition for 'copy_interl'
 * checking Rd files ... OK
 * checking Rd metadata ... OK
 * checking Rd cross-references ... OK
 * checking for missing documentation entries ... WARNING
 Undocumented code objects:
  comb learn_comb nchoo
 All user-level objects in a package should have documentation entries.
 See the chapter 'Writing R documentation files' in manual 'Writing R
 Extensions'.
 * checking for 

Re: [R] Looking for an image (R 64-bit on Linux 64-bit) on Amazon EC2

2010-08-25 Thread noclue_


 You have a 64 bit Linux?  If so... 

Dowload the sources 

Do you mean download Linux kernel source code and then compile it on Amazon
EC2?


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Looking-for-an-image-R-64-bit-on-Linux-64-bit-on-Amazon-EC2-tp2338938p2339072.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
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] Specify non-default libiconv, readline, libpng, tiff etc during R compilation

2010-08-25 Thread Derrick LIN
Hi guys,

I am trying to compile 64-bit R 2.11.1 on Solaris 10. I mainly follow the
guide in here

https://www.initworks.com/wiki/pages/viewpage.action?pageId=6521038

The guide suggests that install the customised libiconv, readline under the
designated R installation folder and become the private libraries that are
exclusive to that R only.

This seems to be a great solution, as I need to compile several versions of
R in the same environment, libiconv, readline, libpng etc would be different
version too. This concept will allow me to do so without contaminating the
global default libraries.

But I found that, R ./configure does not locate the customised, provate
libiconv, readline etc in the designated location. It still looks from the
default one like /usr/lib, /usr/local/lib etc (typically, is older version).

I am wondering if any R user has done the similar work and can share some
experience.

Regards,
Derrick

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


<    1   2