From | Sent On | Attachments |
---|---|---|

pa...@gribblelab.org | May 5, 2010 3:17 am |

Subject: | Re: [R] R-help Digest, Vol 87, Issue 5 | |
---|---|---|

From: | pa...@gribblelab.org (pa...@gribblelab.org) | |

Date: | May 5, 2010 3:17:24 am | |

List: | org.r-project.r-help | |

Note: | This is a very long message, its output has been truncated. |

Unsubscribe

-----Original Message----- From: r-he...@r-project.org Date: Wed, 05 May 2010 12:00:09 To: <r-h...@r-project.org> Subject: R-help Digest, Vol 87, Issue 5

Send R-help mailing list submissions to r-h...@r-project.org

To subscribe or unsubscribe via the World Wide Web, visit https://stat.ethz.ch/mailman/listinfo/r-help or, via email, send a message with subject or body 'help' to r-he...@r-project.org

You can reach the person managing the list at r-he...@r-project.org

When replying, please edit your Subject line so it is more specific than "Re: Contents of R-help digest..."

Today's Topics:

1. aregImpute (Hmisc package) : error in matxv(X, xcof)... (Marc Carpentier) 2. Agreement (HB8) 3. Re: How to rbind listed data frames? (it-r...@ml.epigenomics.com) 4. All possible paths between two nodes in a flowgraph using igraphs? (jcano) 5. superscript (Kay Cichini) 6. All possible paths between two nodes in a flowgraph using igraphs? (jcano) 7. Re: superscript (Jorge Ivan Velez) 8. Re: superscript (Duncan Murdoch) 9. Re: aregImpute (Hmisc package) : error in matxv(X, xcof)... (Uwe Ligges) 10. Re: superscript (Kay Cichini) 11. Re: superscript (Kay Cichini) 12. Re: All possible paths between two nodes in a flowgraph using igraphs? (Nikhil Kaza) 13. How to replace all <NA> values in a data.frame with another ( not 0) value (Nevil Amos) 14. Agreement (HB8) 15. Show number at each bar in barchart? (someone) 16. Re: How to replace all <NA> values in a data.frame with another ( not 0) value (Lanna Jin) 17. Re: aregImpute (Hmisc package) : error in matxv(X, xcof)... (Frank E Harrell Jr) 18. Re: Need help on having multiple distributions in one graph (Frank E Harrell Jr) 19. Re: How to replace all <NA> values in a data.frame with another ( not 0) value (Lanna Jin) 20. Re: Problem with vignette compilation during R CMD check (pomc...@free.fr) 21. Re: How to replace all <NA> values in a data.frame with another ( not 0) value (Muhammad Rahiz) 22. Re: How to replace all <NA> values in a data.frame with another ( not 0) value (John Kane) 23. Re: How to replace all <NA> values in a data.frame with another ( not 0) value (Muhammad Rahiz) 24. Re: How to replace all <NA> values in a data.frame with another ( not 0) value (Bart Joosen) 25. Re: Show number at each bar in barchart? (John Kane) 26. Re: error in La.svd Lapack routine 'dgesdd' (Douglas Bates) 27. make a column from the row names (Mohan L) 28. Re: Plotting legend outside of multiple panels (Patrick Lenon) 29. Using R with screenreading software (Rainer Scheuchenpflug) 30. Re: Show number at each bar in barchart? (Jorge Ivan Velez) 31. Re: make a column from the row names (John Kane) 32. R for web browser (Lanna Jin) 33. Re: Using R with screenreading software (Duncan Murdoch) 34. Odp: How to replace all <NA> values in a data.frame with another ( not 0) value (Petr PIKAL) 35. Idiomatic looping over list name, value pairs in R (Luis N) 36. Re: Show number at each bar in barchart? (David Winsemius) 37. Memory issues using R withing Eclipse-StatET (Harsh) 38. Kernel density estimate plot for 3-dimensional data (Pascal Martin) 39. Re: Idiomatic looping over list name, value pairs in R (Christos Argyropoulos) 40. Re: Idiomatic looping over list name, value pairs in R (Duncan Murdoch) 41. fit printed output onto a single page (Abiel X Reinhart) 42. Lazy evaluation in function call (Thorn) 43. Re: Kernel density estimate plot for 3-dimensional data (Duncan Murdoch) 44. strange behavior of RODBC and/or ssconvert (stef...@gmail.com) 45. Re: Idiomatic looping over list name, value pairs in R (Luis N) 46. Re: 3D version of triax.plot (package plotrix) (Gabriele Esposito) 47. Re: Kernel density estimate plot for 3-dimensional data (Pascal Martin) 48. Re: Kernel density estimate plot for 3-dimensional data (Duncan Murdoch) 49. Avoiding for-loop for splitting vector into subvectors based on positions (Joris Meys) 50. Re: Avoiding for-loop for splitting vector into subvectors based on positions (jim holtman) 51. Re: R for web browser (Tal Galili) 52. Re: / Operator not meaningful for factors (John Kane) 53. Re: ISO Eric Kort (rtiff) (cg...@witthoft.com) 54. read.table: skipping trailing delimiters (Marshall Feldman) 55. Re: strange behavior of RODBC and/or ssconvert (Gabor Grothendieck) 56. Flushing print buffer (Marshall Feldman) 57. Re: read.table: skipping trailing delimiters (Marc Schwartz) 58. Re: read.table: skipping trailing delimiters (Gabor Grothendieck) 59. Re: Flushing print buffer (jim holtman) 60. Re: Flushing print buffer (jim holtman) 61. Package Rsafd (Bo Li) 62. legend with lines and points (threshold) 63. Re: Package Rsafd (David Winsemius) 64. Re: Package Rsafd (David Winsemius) 65. Re: R for web browser (j verzani) 66. help overlay scatterplot to effects plot (Anderson, Chris) 67. How to make predictions with the predict() method on an arimax object using arimax() from TSA library (a a) 68. Re : aregImpute (Hmisc package) : error in matxv(X, xcof)... (Marc Carpentier) 69. unsubcribe (Galois Theory) 70. Re: Re : aregImpute (Hmisc package) : error in matxv(X, xcof)... (David Winsemius) 71. Re: unsubcribe (Cedrick W. Johnson) 72. randomforests - how to classify (pdb) 73. installing a package in linux (Fahim Md) 74. Re: randomforests - how to classify (Changbin Du) 75. R formula language---a min and max function? (ivo welch) 76. Re: R formula language---a min and max function? (David Winsemius) 77. Re: R formula language---a min and max function? (ivo welch) 78. Re: R formula language---a min and max function? (Gabor Grothendieck) 79. Re: R formula language---a min and max function? (David Winsemius) 80. rgl: plane3d or abline() analog (Michael Friendly) 81. Re: rgl: plane3d or abline() analog (David Winsemius) 82. Re: generating correlated random variables from different distributions (Greg Snow) 83. Re: Agreement (Tobias Verbeke) 84. Error when invoking x11() (Alex Chelminsky) 85. Re: Avoiding for-loop for splitting vector into subvectors based on positions (Joris Meys) 86. Two Questions on R (call by reference and pre-compilation) (Ruihong Huang) 87. timing a function (pdb) 88. Re: timing a function (moha...@inserm.fr) 89. Re: R formula language---a min and max function? (ivo welch) 90. Re: timing a function (Joris Meys) 91. Re: R formula language---a min and max function? (David Winsemius) 92. Re: Lazy evaluation in function call (Joris Meys) 93. Re: Show number at each bar in barchart? (Carl Witthoft) 94. Re: Two Questions on R (call by reference and pre-compilation) (Steve Lianoglou) 95. Re: Lazy evaluation in function call (Bert Gunter) 96. Openings in the Consulting Department of XLSolutions Corp (su...@xlsolutions-corp.com) 97. Re: R formula language---a min and max function? (Gabor Grothendieck) 98. Re: R formula language---a min and max function? (Gabor Grothendieck) 99. readLines with space-delimiter? (Seth) 100. Re: rgl: plane3d or abline() analog (Duncan Murdoch) 101. Re: Two Questions on R (call by reference and pre-compilation) (Duncan Murdoch) 102. Re: installing a package in linux (Tengfei Yin) 103. Symbolic eigenvalues and eigenvectors (John Mesheimer) 104. Visualizing binary response data? (Kim Jung Hwa) 105. Re: Symbolic eigenvalues and eigenvectors (Steve Lianoglou) 106. Re: Symbolic eigenvalues and eigenvectors (John Mesheimer) 107. Re: rgl: plane3d or abline() analog (Michael Friendly) 108. Re: Symbolic eigenvalues and eigenvectors (Gabor Grothendieck) 109. Re: Visualizing binary response data? (Thomas Stewart) 110. Re: Visualizing binary response data? (Frank E Harrell Jr) 111. Re: readLines with space-delimiter? (jim holtman) 112. Re: Cross-checking a custom function for separability indices (Nikos Alexandris) 113. Re: Symbolic eigenvalues and eigenvectors (Steve Lianoglou) 114. Re: Delete rows with duplicate field... (kMan) 115. converting an objects list (Anthony Fristachi) 116. masking of objects between mtrace() and getYahooData() (zerdna) 117. Re: How to make predictions with the predict() method on an arimax object using arimax() from TSA library (Dennis Murphy) 118. question about 'write.table' (karena) 119. Re : Re : aregImpute (Hmisc package) : error in matxv(X, xcof)... (Marc Carpentier) 120. Re: Estimating theta for negative binomial model (Tim Clark) 121. Re: Errors when trying to open odfWeave documents (Paul) 122. Creating Crosstabs using a sparse table (merrittr) 123. Re: How to replace all <NA> values in a data.frame with another ( not 0) value (Nevil Amos) 124. Help with dummy.coef (James M. Curran) 125. Re: readLines with space-delimiter? (Seth) 126. better way to trick data frame structure? (Seth) 127. Odp: better way to trick data frame structure? (Petr PIKAL) 128. Re: Odp: better way to trick data frame structure? (Seth) 129. Converting dollar value (factors) to numeric (Wang, Kevin (SYD)) 130. Re: Lazy evaluation in function call (Thorn) 131. Re: Two Questions on R (call by reference and pre-compilation) (Ruihong Huang) 132. Re: installing a package in linux (Ruihong Huang) 133. Re: Converting dollar value (factors) to numeric (Ruihong Huang) 134. Re: Converting dollar value (factors) to numeric (Fredrik Karlsson) 135. A question regarding the loess function (Scott MacDonald) 136. Re: Converting dollar value (factors) to numeric (Phil Spector) 137. help with restart (Wincent) 138. Re: Two Questions on R (call by reference and pre-compilation) (Seth) 139. Re: converting an objects list (Jim Lemon) 140. Re: fit printed output onto a single page (Jim Lemon) 141. concatenate values of two columns (n.vi...@libero.it) 142. Memory issue (Alex van der Spek) 143. puzzles with assign() (David.Epstein)

----------------------------------------------------------------------

Message: 1 Date: Tue, 4 May 2010 03:23:52 -0700 (PDT) From: Marc Carpentier <marc...@ymail.com> To: r-h...@r-project.org Subject: [R] aregImpute (Hmisc package) : error in matxv(X, xcof)... Message-ID: <5545...@web28212.mail.ukl.yahoo.com> Content-Type: text/plain

Dear r-help list,
I'm trying to use multiple imputation for my MSc thesis.
Having good exemples using the Hmisc package, I tried the aregImpute function.

But with my own dataset, I have the following error :

Erreur dans matxv(X, xcof) : columns in a (51) must be <= length of b (50)
De plus : Warning message:
In f$xcoef[, 1] * f$xcenter :
la taille d'un objet plus long n'est pas multiple de la taille d'un objet plus

court
= longer object length is not a multiple of shorter object length

I first tried to "I()" all the continuous variables but the same error occurs

with different numbers :
Erreur dans matxv(X, xcof) : columns in a (37) must be <= length of b (36)...

I'm a student and I'm not familiar with possible constraints in a dataset to be

effectively imputed. I just found this previous message, where the author's

autoreply suggests that particular distributions might be an explanation of

algorithms failure :
http://www.mail-archive.com/r-help@r-proje...@

Does anyone know if these messages reflect a specific problem in my dataset ?

And if the number mentioned might give me a hint on which column to look at (and

maybe transform or ignore for the imputation) ?
Thanks for any advice you might have.

Marc

[[alternative HTML version deleted]]

------------------------------

Message: 2 Date: Tue, 4 May 2010 13:06:57 +0200 From: HB8 <hb8...@gmail.com> To: r-h...@r-project.org Subject: [R] Agreement Message-ID: <n2v9...@mail.gmail.com> Content-Type: text/plain

Hi, Has Lawrence Lin's code been ported to R? http://tigger.uic.edu/~hedayat/sascode.html<http://tigger.uic.edu/%7Ehedayat/sascode.html> Regards, Gregoire Thomas

[[alternative HTML version deleted]]

------------------------------

Message: 3 Date: Tue, 04 May 2010 13:11:05 +0200 From: it-r...@ml.epigenomics.com To: Phil Wieland <phw...@gmx.de> Subject: Re: [R] How to rbind listed data frames? Message-ID: <4BE0...@epigenomics.com> Content-Type: text/plain; charset=ISO-8859-1

assuming all data frames have the same format do.call("rbind", dataList)

will concatenate all data frames contained in your list object.

Phil Wieland wrote, On 05/04/10 09:51:

I made a list (dataList) of data frames. The list looks like this (the first two elements):

[[1]] est cond targets 1 400 exo_depth_65 Hautklinik 2 300 exo_depth_65 Ostturm_UKM 3 200 exo_depth_65 Kreuzung_Roxeler/Albert_Schweizer ...

[[2]] est cond targets 1 400 control Hautklinik 2 220 control Ostturm_UKM 3 300 control Kreuzung_Roxeler/Albert_Schweizer ...

Now I would like to merge the data frames with rbind. It works fine this way:

rbind(dataList[[1]], dataList[[2]], ...)

but I would like to use lapply or a for loop to get rid of specifying the subscripts. The output of lapply(dataList, rbind) is always

[,1] [,2] [1,] List,3 List,3

Thanks for help...

______________________________________________ R-h...@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.

-- Matthias Burger Project Manager/ Biostatistician Epigenomics AG Kleine Praesidentenstr. 1 10178 Berlin, Germany phone:+49-30-24345-0 fax:+49-30-24345-555 http://www.epigenomics.com matt...@epigenomics.com

-- Epigenomics AG Berlin Amtsgericht Charlottenburg HRB 75861 Vorstand: Geert Nygaard (CEO/Vorsitzender) Oliver Schacht PhD (CFO) Aufsichtsrat: Prof. Dr. Dr. hc. Rolf Krebs (Chairman/Vorsitzender)

------------------------------

Message: 4 Date: Tue, 4 May 2010 04:21:00 -0700 (PDT) From: jcano <javi...@urjc.es> To: r-h...@r-project.org Subject: [R] All possible paths between two nodes in a flowgraph using igraphs? Message-ID: <1272...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

Hi all

Is there any systematic way to compute all possible paths, first-order loops and j-th order loops between two given nodes in a flowgraph (directed graph with cycles) - preferably using the igraph library in R? I have checked the igraph documentation but I can't figure out any direct and systematic way to do so. Any ideas? I use the following definitions from Butler, R. and A. Huzurbazar (1997). Stochastic Network Models for Survival Analysis. Journal of the American Statistical Association 92 (437), 246-257. - A path from node i to j is any possible sequence of nodes from i to j which does not pass through any intermediate node more than once. - A first-order loop is any closed path in the flowgraph that returns to the initial node of the loop without passing through any intermediate node more than once. - A jth-order loop consists of j nontouching first-order loops.

For example, in the flowgraph below http://n4.nabble.com/file/n2125321/flowgraph_subsume.jpg there are 18 paths between nodes 1 and a: - 1a; - 12a, 124a, 1243a, 1245a, 12436a, 124365a, 12456a, 124563a; - 13a, 134a, 136a, 1342a, 1345a, 13456a, 1365a, 13654a, 136542a. 3 first-order loops: - 12431, 1245631, 45634; and no loops of order two or more.

Thanks in advance

jcano

--
View this message in context:

http://r.789695.n4.nabble.com/All-possible-paths-between-two-nodes-in-a-flowgraph-using-igraphs-tp2125321p2125321.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 5 Date: Tue, 4 May 2010 04:33:10 -0700 (PDT) From: Kay Cichini <Kay....@uibk.ac.at> To: r-h...@r-project.org Subject: [R] superscript Message-ID: <1272...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

hello,

i need to add legend text: "4th-root transformation", with the "th" superscripted - tried much - but nothing worked..

thanks for any hints, kay

-----

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

------------------------

--
View this message in context:

http://r.789695.n4.nabble.com/superscript-tp2125341p2125341.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 6 Date: Tue, 4 May 2010 04:34:53 -0700 (PDT) From: jcano <javi...@urjc.es> To: r-h...@r-project.org Subject: [R] All possible paths between two nodes in a flowgraph using igraphs? Message-ID: <1272...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

Hi all

Is there any systematic way to compute all possible paths, first-order loops and j-th order loops between two given nodes in a flowgraph (directed graph with cycles) - preferably using the igraph library in R? I have checked the igraph documentation but I can't figure out any direct and systematic way to do so. Any ideas? I use the following definitions from Butler, R. and A. Huzurbazar (1997). Stochastic Network Models for Survival Analysis. Journal of the American Statistical Association 92 (437), 246-257. - A path from node i to j is any possible sequence of nodes from i to j which does not pass through any intermediate node more than once. - A first-order loop is any closed path in the flowgraph that returns to the initial node of the loop without passing through any intermediate node more than once. - A jth-order loop consists of j nontouching first-order loops.

For example, in the flowgraph below there are 18 paths between nodes 1 and a: - 1a; - 12a, 124a, 1243a, 1245a, 12436a, 124365a, 12456a, 124563a; - 13a, 134a, 136a, 1342a, 1345a, 13456a, 1365a, 13654a, 136542a. 6 first-order loops: - 12431, 13421, 1245631, 1365421, 45634, 43654; and no loops of order two or more.

Thanks in advance

jcano http://n4.nabble.com/file/n2125347/flowgraph_subsume.jpg

--
View this message in context:

http://r.789695.n4.nabble.com/All-possible-paths-between-two-nodes-in-a-flowgraph-using-igraphs-tp2125347p2125347.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 7 Date: Tue, 4 May 2010 07:37:48 -0400 From: Jorge Ivan Velez <jorg...@gmail.com> To: Kay Cichini <Kay....@uibk.ac.at> Cc: r-h...@r-project.org Subject: Re: [R] superscript Message-ID: <t2q3...@mail.gmail.com> Content-Type: text/plain

Hi Kay,

Try

plot(1:10) legend('topleft', expression(4^th*"-root transformation"))

HTH, Jorge

On Tue, May 4, 2010 at 7:33 AM, Kay Cichini <> wrote:

hello,

i need to add legend text: "4th-root transformation", with the "th" superscripted - tried much - but nothing worked..

thanks for any hints, kay

-----

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

------------------------

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

______________________________________________ R-h...@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]]

------------------------------

Message: 8 Date: Tue, 04 May 2010 07:44:14 -0400 From: Duncan Murdoch <murd...@gmail.com> To: Kay Cichini <Kay....@uibk.ac.at> Cc: r-h...@r-project.org Subject: Re: [R] superscript Message-ID: <4BE0...@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Kay Cichini wrote:

hello,

i need to add legend text: "4th-root transformation", with the "th" superscripted - tried much - but nothing worked..

This puts it in the title for the plot:

plot(1, main=expression(paste("4"^"th"," root transformation")))

This puts it in a legend:

legend("topleft", pch=1, expression(paste("4"^"th"," root transformation")))

Duncan Murdoch

------------------------------

Message: 9 Date: Tue, 04 May 2010 13:52:31 +0200 From: Uwe Ligges <lig...@statistik.tu-dortmund.de> To: Marc Carpentier <marc...@ymail.com> Cc: r-h...@r-project.org Subject: Re: [R] aregImpute (Hmisc package) : error in matxv(X, xcof)... Message-ID: <4BE0...@statistik.tu-dortmund.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Having reproducible examples including data and the actual call that lead to the error would be really helpful to be able to help.

Uwe Ligges

On 04.05.2010 12:23, Marc Carpentier wrote:

Dear r-help list,
I'm trying to use multiple imputation for my MSc thesis.
Having good exemples using the Hmisc package, I tried the aregImpute function.

But with my own dataset, I have the following error :

Erreur dans matxv(X, xcof) : columns in a (51) must be<= length of b (50)
De plus : Warning message:
In f$xcoef[, 1] * f$xcenter :
la taille d'un objet plus long n'est pas multiple de la taille d'un objet

plus court
= longer object length is not a multiple of shorter object length

I first tried to "I()" all the continuous variables but the same error occurs

with different numbers :
Erreur dans matxv(X, xcof) : columns in a (37) must be<= length of b (36)...

I'm a student and I'm not familiar with possible constraints in a dataset to be

effectively imputed. I just found this previous message, where the author's

autoreply suggests that particular distributions might be an explanation of

algorithms failure :
http://www.mail-archive.com/r-help@r-proje...@

Does anyone know if these messages reflect a specific problem in my dataset ?

And if the number mentioned might give me a hint on which column to look at (and

maybe transform or ignore for the imputation) ?
Thanks for any advice you might have.

Marc

[[alternative HTML version deleted]]

______________________________________________ R-h...@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.

------------------------------

Message: 10 Date: Tue, 4 May 2010 05:05:08 -0700 (PDT) From: Kay Cichini <Kay....@uibk.ac.at> To: r-h...@r-project.org Subject: Re: [R] superscript Message-ID: <1272...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

thanks a lot!

-----

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

------------------------

--
View this message in context:

http://r.789695.n4.nabble.com/superscript-tp2125341p2125384.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 11 Date: Tue, 4 May 2010 05:05:44 -0700 (PDT) From: Kay Cichini <Kay....@uibk.ac.at> To: r-h...@r-project.org Subject: Re: [R] superscript Message-ID: <1272...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

thanks a lot!

-----

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

------------------------

--
View this message in context:

http://r.789695.n4.nabble.com/superscript-tp2125341p2125386.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 12 Date: Tue, 4 May 2010 08:17:13 -0400 From: Nikhil Kaza <nikh...@gmail.com> To: jcano <javi...@urjc.es> Cc: r-h...@r-project.org Subject: Re: [R] All possible paths between two nodes in a flowgraph using igraphs? Message-ID: <AB13...@gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

Finding all paths between two nodes in a general graph is very hard. If your graph is sparse you may be able to construct the list of paths provided of course you take care not to get stuck in a cycle. But for most practical purposes you may just need edge disjoint path or vertex disjoint paths.

I am not sure about cycles. But I suppose you can just use the minimum spanning tree and iteratively add the remaining edges to get the cycles.

Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina

nikh...@gmail.com

On May 4, 2010, at 7:34 AM, jcano wrote:

Hi all

Is there any systematic way to compute all possible paths, first- order loops and j-th order loops between two given nodes in a flowgraph (directed graph with cycles) - preferably using the igraph library in R? I have checked the igraph documentation but I can't figure out any direct and systematic way to do so. Any ideas? I use the following definitions from Butler, R. and A. Huzurbazar (1997). Stochastic Network Models for Survival Analysis. Journal of the American Statistical Association 92 (437), 246-257. - A path from node i to j is any possible sequence of nodes from i to j which does not pass through any intermediate node more than once. - A first-order loop is any closed path in the flowgraph that returns to the initial node of the loop without passing through any intermediate node more than once. - A jth-order loop consists of j nontouching first-order loops.

For example, in the flowgraph below there are 18 paths between nodes 1 and a: - 1a; - 12a, 124a, 1243a, 1245a, 12436a, 124365a, 12456a, 124563a; - 13a, 134a, 136a, 1342a, 1345a, 13456a, 1365a, 13654a, 136542a. 6 first-order loops: - 12431, 13421, 1245631, 1365421, 45634, 43654; and no loops of order two or more.

Thanks in advance

jcano http://n4.nabble.com/file/n2125347/flowgraph_subsume.jpg

--
View this message in context:

http://r.789695.n4.nabble.com/All-possible-paths-between-two-nodes-in-a-flowgraph-using-igraphs-tp2125347p2125347.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 13 Date: Tue, 04 May 2010 22:54:14 +1000 From: Nevil Amos <nevi...@gmail.com> To: r-h...@stat.math.ethz.ch Subject: [R] How to replace all <NA> values in a data.frame with another ( not 0) value Message-ID: <4BE0...@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I need to replace <NA> occurrences in multiple columns in a data.frame with "000/000"

how do I achieve this?

Thanks

Nevil Amos

------------------------------

Message: 14 Date: Tue, 4 May 2010 12:59:48 +0200 From: HB8 <hb8...@gmail.com> To: r-h...@R-project.org Subject: [R] Agreement Message-ID: <j2j9...@mail.gmail.com> Content-Type: text/plain

Hi, Has Lawrence Lin's code been ported to R? http://tigger.uic.edu/~hedayat/sascode.html Regards, Gregoire Thomas

[[alternative HTML version deleted]]

------------------------------

Message: 15 Date: Tue, 4 May 2010 05:41:02 -0700 (PDT) From: someone <vonh...@t-online.de> To: r-h...@r-project.org Subject: [R] Show number at each bar in barchart? Message-ID: <1272...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

when i plot a barchart with 5 bars there is one bar pretty long and the others get smaller like (20, 80, 20, 5, 2) is there a way of displaying the number accoirding to each bar next to it? like in a bwplot the panel option N?

--
View this message in context:

http://r.789695.n4.nabble.com/Show-number-at-each-bar-in-barchart-tp2125438p2125438.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 16 Date: Tue, 4 May 2010 06:02:29 -0700 (PDT) From: Lanna Jin <lann...@gmail.com> To: r-h...@r-project.org Subject: Re: [R] How to replace all <NA> values in a data.frame with another ( not 0) value Message-ID: <1272...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

Try: "x[which(is.na(x)),] <- 000/000", where is x is your data frame

----- Lanna Jin

lann...@gmail.com 510-898-8525

--
View this message in context:

http://r.789695.n4.nabble.com/How-to-replace-all-NA-values-in-a-data-frame-with-another-not-0-value-tp2125458p2125464.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 17 Date: Tue, 4 May 2010 08:05:24 -0500 From: Frank E Harrell Jr <f.ha...@Vanderbilt.Edu> To: <r-h...@r-project.org> Subject: Re: [R] aregImpute (Hmisc package) : error in matxv(X, xcof)... Message-ID: <4BE0...@vanderbilt.edu> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed

On 05/04/2010 06:52 AM, Uwe Ligges wrote:

Having reproducible examples including data and the actual call that lead to the error would be really helpful to be able to help.

Uwe Ligges

In addition to that, this kind of message usually means that you have a singularity somewhere, e.g., you are using too many knots for spline terms or have a tiny cell in a categorical variable.

Frank

On 04.05.2010 12:23, Marc Carpentier wrote:

Dear r-help list, I'm trying to use multiple imputation for my MSc thesis. Having good exemples using the Hmisc package, I tried the aregImpute function. But with my own dataset, I have the following error :

Erreur dans matxv(X, xcof) : columns in a (51) must be<= length of b (50) De plus : Warning message: In f$xcoef[, 1] * f$xcenter : la taille d'un objet plus long n'est pas multiple de la taille d'un objet plus court = longer object length is not a multiple of shorter object length

I first tried to "I()" all the continuous variables but the same error occurs with different numbers : Erreur dans matxv(X, xcof) : columns in a (37) must be<= length of b (36)...

I'm a student and I'm not familiar with possible constraints in a dataset to be effectively imputed. I just found this previous message, where the author's autoreply suggests that particular distributions might be an explanation of algorithms failure : http://www.mail-archive.com/r-help@r-proje...@

Does anyone know if these messages reflect a specific problem in my dataset ? And if the number mentioned might give me a hint on which column to look at (and maybe transform or ignore for the imputation) ? Thanks for any advice you might have.

Marc

[[alternative HTML version deleted]]

-- Frank E Harrell Jr Professor and Chairman School of Medicine Department of Biostatistics Vanderbilt University

------------------------------

Message: 18 Date: Tue, 4 May 2010 08:06:09 -0500 From: Frank E Harrell Jr <f.ha...@Vanderbilt.Edu> To: <r-h...@r-project.org> Subject: Re: [R] Need help on having multiple distributions in one graph Message-ID: <4BE0...@vanderbilt.edu> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed

On 05/03/2010 11:14 PM, Jorge Ivan Velez wrote:

Hi Joseph,

How about this?

matplot(cbind(m0, m1, m3, m4), type = 'l', lty = 1) legend('topright', paste('m', c(0, 1, 3, 4), sep = ""), lty = 1, col = 1:4)

See ?matplot and ?legend for details.

HTH, Jorge

Also see the labcurve function in the Hmisc package, which will draw curves and label them where they are most separated.

Frank

On Mon, May 3, 2010 at 6:42 PM,<> wrote:

R-listers:

I have searched the help files and everything I have related to R graphics. I cannot find how to graph y against several distributions on a single graph. Here is code for creating 4 Poisson distributions with different mean values, although I would prefer having it in a loop: The top of the y axis for the first distribution, with count of 0, is .6, which is the highest point for any of the distributions.

obs<- 1:20 y<- obs-1 m0<- (exp(-.5) * .5^y)/factorial(y) m1<- (exp(-1) * 1^y)/factorial(y) m3<- (exp(-3) * 3^y)/factorial(y) m4<- (exp(-5) * 5^y)/factorial(y)

How do I plot the graph of each distribution on y, all on a single graph? I have spent so many hours on this, which is really quite simple in applications such as Stata. Thanks very much for the assistance:

-- Frank E Harrell Jr Professor and Chairman School of Medicine Department of Biostatistics Vanderbilt University

------------------------------

Message: 19 Date: Tue, 4 May 2010 06:06:25 -0700 (PDT) From: Lanna Jin <lann...@gmail.com> To: r-h...@r-project.org Subject: Re: [R] How to replace all <NA> values in a data.frame with another ( not 0) value Message-ID: <1272...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

Whoops, my bad. Maybe try using "gsub"

----- Lanna Jin

lann...@gmail.com 510-898-8525

--
View this message in context:

http://r.789695.n4.nabble.com/How-to-replace-all-NA-values-in-a-data-frame-with-another-not-0-value-tp2125458p2125471.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 20 Date: Tue, 4 May 2010 15:17:40 +0200 (CEST) From: pomc...@free.fr To: r-h...@r-project.org Subject: Re: [R] Problem with vignette compilation during R CMD check Message-ID: <3265...@zimbra20-e3.priv.proxad.net>

Content-Type: text/plain; charset=utf-8

Thanks Uwe

------------------------------

Message: 21 Date: Tue, 04 May 2010 14:20:03 +0100 From: Muhammad Rahiz <muha...@ouce.ox.ac.uk> To: "nevi...@sci.monash.edu.au" <nevi...@sci.monash.edu.au> Cc: "r-h...@stat.math.ethz.ch" <r-h...@stat.math.ethz.ch> Subject: Re: [R] How to replace all <NA> values in a data.frame with another ( not 0) value Message-ID: <4BE0...@ouce.ox.ac.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi Nevil,

You can try a method like this

x <- c(rnorm(5),rep(NA,3),rnorm(5)) # sample data dat <- data.frame(x,x) # make sample dataframe dat2 <- as.matrix(dat) # conver to matrix y <- which(is.na(dat)==TRUE) # get index of NA values dat2[y] <- "000/000" # replace all na values with "000/000"

Muhammad

Nevil Amos wrote:

I need to replace <NA> occurrences in multiple columns in a data.frame with "000/000"

how do I achieve this?

Thanks

Nevil Amos

------------------------------

Message: 22 Date: Tue, 4 May 2010 06:21:53 -0700 (PDT) From: John Kane <jrkr...@yahoo.ca> To: r-h...@stat.math.ethz.ch, nevi...@sci.monash.edu.au Subject: Re: [R] How to replace all <NA> values in a data.frame with another ( not 0) value Message-ID: <2714...@web38405.mail.mud.yahoo.com> Content-Type: text/plain; charset=iso-8859-1

?replace

Something like this should work

replace(df1, is.na(df1), "000/000")

--- On Tue, 5/4/10, Nevil Amos <nevi...@gmail.com> wrote:

From: Nevil Amos <nevi...@gmail.com>
Subject: [R] How to replace all <NA> values in a data.frame with another ( not

0) value
To: r-h...@stat.math.ethz.ch
Received: Tuesday, May 4, 2010, 8:54 AM
I need to replace <NA>
occurrences in multiple columns? in a data.frame with
"000/000"

how do I achieve this?

Thanks

Nevil Amos

------------------------------

Message: 23 Date: Tue, 04 May 2010 14:25:15 +0100 From: Muhammad Rahiz <muha...@ouce.ox.ac.uk> To: Lanna Jin <lann...@gmail.com> Cc: "r-h...@r-project.org" <r-h...@r-project.org> Subject: Re: [R] How to replace all <NA> values in a data.frame with another ( not 0) value Message-ID: <4BE0...@ouce.ox.ac.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

000/000 returns NaN, which is no different than NA unless you want it as string i.e. "000/000"

Muhammad

Lanna Jin wrote:

Try: "x[which(is.na(x)),] <- 000/000", where is x is your data frame

----- Lanna Jin

lann...@gmail.com 510-898-8525

------------------------------

Message: 24 Date: Tue, 4 May 2010 06:25:38 -0700 (PDT) From: Bart Joosen <bart...@hotmail.com> To: r-h...@r-project.org Subject: Re: [R] How to replace all <NA> values in a data.frame with another ( not 0) value Message-ID: <1272...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

try x[is.na(x)] <- "000/000"

Bart

--
View this message in context:

http://r.789695.n4.nabble.com/How-to-replace-all-NA-values-in-a-data-frame-with-another-not-0-value-tp2125458p2125509.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 25 Date: Tue, 4 May 2010 06:29:49 -0700 (PDT) From: John Kane <jrkr...@yahoo.ca> To: r-h...@r-project.org, someone <vonh...@t-online.de> Subject: Re: [R] Show number at each bar in barchart? Message-ID: <7959...@web38403.mail.mud.yahoo.com> Content-Type: text/plain; charset=us-ascii

Try this. My appologies for not giving the attribution but I forget who wrote

it.

my.values=100000:100005 x <- barplot(my.values, ylim=c(0,110000))

text(x, my.values, my.values, pos=3)

text(x, my.values, "wibble", pos=3)

--- On Tue, 5/4/10, someone <vonh...@t-online.de> wrote:

From: someone <vonh...@t-online.de> Subject: [R] Show number at each bar in barchart? To: r-h...@r-project.org Received: Tuesday, May 4, 2010, 8:41 AM

when i plot a barchart with 5 bars there is one bar pretty long and the others get smaller like (20, 80, 20, 5, 2) is there a way of displaying the number accoirding to each bar next to it? like in a bwplot the panel option N?

--
View this message in context:

http://r.789695.n4.nabble.com/Show-number-at-each-bar-in-barchart-tp2125438p2125438.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 26 Date: Tue, 4 May 2010 08:32:03 -0500 From: Douglas Bates <bat...@stat.wisc.edu> To: steven mosher <mosh...@gmail.com> Cc: r-help <r-h...@r-project.org> Subject: Re: [R] error in La.svd Lapack routine 'dgesdd' Message-ID: <x2q4...@mail.gmail.com> Content-Type: text/plain; charset=windows-1252

Google the name dgesdd to get the documentation where you will find that the error code indicates that the SVD algorithm failed to converge. Evaluation of the singular values and vectors is done via an iterative optimization and on some occasions will fail to converge. Frequently this is related to the scaling of the matrix. If some rows or columns are a very large magnitude relative to others the convergence of the optimization can be impeded.

Providing a reproducible example of such an error condition will help in diagnosing what is happening.

If you wonder why the error message is so enigmatic, it is because the underlying code is Fortran and does not provide much flexibility for informative error trapping.

On Tue, May 4, 2010 at 1:24 AM, steven mosher <mosh...@gmail.com> wrote:

Error in La.svd(x, nu, nv) : error code 1 from Lapack routine ?dgesdd?

what resources are there to track down errors like this

? ? ? ?[[alternative HTML version deleted]]

------------------------------

Message: 27 Date: Tue, 4 May 2010 18:36:46 +0530 From: Mohan L <l.mo...@gmail.com> To: r-h...@r-project.org Subject: [R] make a column from the row names Message-ID: <n2ha...@mail.gmail.com> Content-Type: text/plain

Dear All,

avglog

01/11/09 02/11/09 03/11/09 04/11/09 9.750000 4.500000 4.500000 8.666667

avglog1 <- data.frame(avglog) avglog1

avglog 01/11/09 9.750000 02/11/09 4.500000 03/11/09 4.500000 04/11/09 8.666667

The first column isnt a column, It's the row names. I makeing a column from the row names by using the following

value1$Day <- rownames(value1) value1

avglog Day 01/11/09 9.750000 01/11/09 02/11/09 4.500000 02/11/09 03/11/09 4.500000 03/11/09 04/11/09 8.666667 04/11/09

But I want like this :

Day avglog Index 1 1 9.750000 9.750000*100 2 2 4.500000 4.500000*100 3 3 4.500000 4.500000*100 4 4 8.666667 8.666667*100

How to achieve it? Any help will be appreciated.

Thanks & Rg Mohan L

[[alternative HTML version deleted]]

------------------------------

Message: 28 Date: Tue, 04 May 2010 08:22:04 -0500 From: Patrick Lenon <len...@fstrf-wi.org> To: r-h...@r-project.org, jrp....@gmail.com Subject: Re: [R] Plotting legend outside of multiple panels Message-ID: <4BE0...@fstrf-wi.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Another solution I've used is to set up an additional layout space and put the legend in there with no graph. You print a blank dummy graph and then add the legend to the "blank" layout panel like so:

if (floatLegend) { # We want to float the legend independently # so we have to add it here as the only visible component of a # dummy graph.

legText <- yourLegendNames

# create a blank graph -- automatically scales -1 to +1 on both axes op <- par(mar=plotMargins) tsFake <- barplot(0,0, axes=FALSE) legend(x=1, y=0, legend=legText, # set fill, angle, density to match your real graph scheme xjust=1, yjust=0.5) par(op) }

Hope that helps.

-- Patrick Lenon Database Engineer Frontier Science and Technology Foundation

(608)441-2947

------------------------------

Message: 29 Date: Tue, 4 May 2010 15:41:41 +0200 From: "Rainer Scheuchenpflug" <sche...@psychologie.uni-wuerzburg.de> To: <r-h...@r-project.org> Subject: [R] Using R with screenreading software Message-ID: <002e01caeb8f$8736b2c0$95a41840$@uni-wuerzburg.de> Content-Type: text/plain; charset="iso-8859-1"

Dear R-Experts,

a student of mine tries to use the Windows-Rconsole with screen reading software (she is blind), and cannot access the command line (Menus are ok). The company which produces her screen reader tells her that this is due to the cursor used in Rconsole, which is static, not blinking. They maintain that if the cursor could be changed to a blinking one, she should be able to access the command line and outputs.

For my last exam she used R in a Dosbox as workaround, but encountered other problems, esp. with scrolling. So: Is it possible to change the cursor type/behavior in R-Console? She uses R 2.8.1, Windows 2000, and screenreader Virgo 4.6 from Baum Retec, if that is any help.

Your assistance with this problem and any other tips for teaching R to blind users will be much appreciated, Rainer Scheuchenpflug

Dr. Rainer Scheuchenpflug Lehrstuhl f?r Psychologie III R?ntgenring 11 97070 W?rzburg Tel: 0931-31-82185 Fax: 0931-31-82616 Mail: sche...@psychologie.uni-wuerzburg.de Web: http://www.izvw.de

------------------------------

Message: 30 Date: Tue, 4 May 2010 09:40:46 -0400 From: Jorge Ivan Velez <jorg...@gmail.com> To: someone <vonh...@t-online.de> Cc: r-h...@r-project.org Subject: Re: [R] Show number at each bar in barchart? Message-ID: <k2g3...@mail.gmail.com> Content-Type: text/plain

Hi someone,

Try this:

x <- c(20, 80, 20, 5, 2) b <- barplot(x, ylim = c(0, 85), las = 1) text(b, x+2, pch = x)

HTH, Jorge

On Tue, May 4, 2010 at 8:41 AM, someone <> wrote:

when i plot a barchart with 5 bars there is one bar pretty long and the others get smaller like (20, 80, 20, 5, 2) is there a way of displaying the number accoirding to each bar next to it? like in a bwplot the panel option N?

-- View this message in context: http://r.789695.n4.nabble.com/Show-number-at-each-bar-in-barchart-tp2125438p2125438.html Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

------------------------------

Message: 31 Date: Tue, 4 May 2010 06:44:44 -0700 (PDT) From: John Kane <jrkr...@yahoo.ca> To: r-h...@r-project.org, Mohan L <l.mo...@gmail.com> Subject: Re: [R] make a column from the row names Message-ID: <9086...@web38405.mail.mud.yahoo.com> Content-Type: text/plain; charset=iso-8859-1

Have a look at ?substring

--- On Tue, 5/4/10, Mohan L <l.mo...@gmail.com> wrote:

From: Mohan L <l.mo...@gmail.com> Subject: [R] make a column from the row names To: r-h...@r-project.org Received: Tuesday, May 4, 2010, 9:06 AM Dear All,

avglog

01/11/09 02/11/09 03/11/09 04/11/09 9.750000 4.500000 4.500000 8.666667

avglog1 <- data.frame(avglog) avglog1

? ? ? ? ???avglog 01/11/09 9.750000 02/11/09 4.500000 03/11/09 4.500000 04/11/09 8.666667

The first column isnt a column, It's the row names. I makeing a column from the row names by using the following

value1$Day <- rownames(value1) value1

? ? ? ? ? ? avglog? ? ? Day 01/11/09 9.750000 01/11/09 02/11/09 4.500000 02/11/09 03/11/09 4.500000 03/11/09 04/11/09 8.666667 04/11/09

But I want like this :

? ? Day? ? avglog? ? ? ???Index 1? ? 1? ? 9.750000? ? 9.750000*100 2? ? 2? ? 4.500000? ? 4.500000*100 3? ? 3? ? 4.500000? ? 4.500000*100 4? ? 4? ? 8.666667? ? 8.666667*100

How to achieve it? Any help will be appreciated.

Thanks & Rg Mohan L

??? [[alternative HTML version deleted]]

------------------------------

Message: 32 Date: Tue, 4 May 2010 06:51:58 -0700 (PDT) From: Lanna Jin <lann...@gmail.com> To: r-h...@r-project.org Subject: [R] R for web browser Message-ID: <1272...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

Hi Everyone,

Does anyone know of any projects for running an interactive R session within a web browser? I'm looking for something similar to the one on the Ruby website (http://tryruby.org), except for R.

Thanks for your responses in advance!

Lanna

----- Lanna Jin

lann...@gmail.com 510-898-8525

--
View this message in context:

http://r.789695.n4.nabble.com/R-for-web-browser-tp2125571p2125571.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 33 Date: Tue, 04 May 2010 09:52:26 -0400 From: Duncan Murdoch <murd...@gmail.com> To: Rainer Scheuchenpflug <sche...@psychologie.uni-wuerzburg.de> Cc: r-h...@r-project.org Subject: Re: [R] Using R with screenreading software Message-ID: <4BE0...@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 04/05/2010 9:41 AM, Rainer Scheuchenpflug wrote:

Dear R-Experts,

a student of mine tries to use the Windows-Rconsole with screen reading software (she is blind), and cannot access the command line (Menus are ok). The company which produces her screen reader tells her that this is due to the cursor used in Rconsole, which is static, not blinking. They maintain that if the cursor could be changed to a blinking one, she should be able to access the command line and outputs.

For my last exam she used R in a Dosbox as workaround, but encountered other problems, esp. with scrolling. So: Is it possible to change the cursor type/behavior in R-Console? She uses R 2.8.1, Windows 2000, and screenreader Virgo 4.6 from Baum Retec, if that is any help.

Your assistance with this problem and any other tips for teaching R to blind users will be much appreciated, Rainer Scheuchenpflug

We are aware of problems when using the Windows Rgui with screen reading software, but nobody in R Core has expertise in this area. If you know of any programmers who do and who could contribute code to the project, I think we'd appreciate it.

In the meantime, using Rterm in a command window is one solution. There are also other front ends available that may work: running R from within Emacs, or using the JGR front end (see the article on p. 9 of http://stat-computing.org/newsletter/issues/scgn-16-2.pdf).

Duncan Murdoch

------------------------------

Message: 34 Date: Tue, 4 May 2010 16:06:38 +0200 From: Petr PIKAL <petr...@precheza.cz> To: nevi...@sci.monash.edu.au Cc: r-he...@r-project.org, r-h...@stat.math.ethz.ch Subject: [R] Odp: How to replace all <NA> values in a data.frame with another ( not 0) value Message-ID: <OFBC...@precheza.cz>

Content-Type: text/plain; charset="US-ASCII"

Hi

r-he...@r-project.org napsal dne 04.05.2010 14:54:14:

I need to replace <NA> occurrences in multiple columns in a data.frame with "000/000"

Be careful if you replace NA in numeric columns.

str(test)

'data.frame': 10 obs. of 3 variables: $ mp: num 20.9 19.9 20.1 20.2 18.9 ... $ so: num 18.8 18.6 18.2 17.9 18.1 ... $ le: num 48 49.1 48.8 42.6 46.1 ...

test[2,2] <- NA test[is.na(test)] <- "000/000" str(test)

'data.frame': 10 obs. of 3 variables: $ mp: num 20.9 19.9 20.1 20.2 18.9 ... $ so: chr "18.75" "000/000" "18.25" "17.89" ... $ le: num 48 49.1 48.8 42.6 46.1 ...

numeric column is now character and you can not use it for further analysis without some fiddling around.

Regards Petr

how do I achieve this?

Thanks

Nevil Amos

------------------------------

Message: 35 Date: Tue, 4 May 2010 23:24:11 +0900 From: Luis N <glob...@gmail.com> To: r-h...@r-project.org Subject: [R] Idiomatic looping over list name, value pairs in R Message-ID: <p2wc...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1

Considering the python code:

for k, v in d.items(): do_something(k); do_something_else(v)

I have the following for R:

for (i in c(1:length(d))) { do_something(names(d[i])); do_something_else(d[[i]]) }

This does not seem seems idiomatic. What is the best way of doing the same with R?

Thanks.

Luis

------------------------------

Message: 36 Date: Tue, 4 May 2010 10:31:46 -0400 From: David Winsemius <dwin...@comcast.net> To: Jorge Ivan Velez <jorg...@gmail.com> Cc: r-h...@r-project.org, someone <vonh...@t-online.de> Subject: Re: [R] Show number at each bar in barchart? Message-ID: <982F...@comcast.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On May 4, 2010, at 9:40 AM, Jorge Ivan Velez wrote:

Hi someone,

Try this:

x <- c(20, 80, 20, 5, 2) b <- barplot(x, ylim = c(0, 85), las = 1) text(b, x+2, pch = x)

I suspect he wanted the "counts" in the label:

x <- c(20, 80, 20, 5, 2) b <- barplot(x, ylim = c(0, 85), las = 1) text(b, x+2, labels=x, pch = x)

... although perhaps his specification by analogy to bwplot with panel option "N" was more meaningful to you that it was to me. I have no idea what that was supposed to suggest.

-- David.

HTH, Jorge

On Tue, May 4, 2010 at 8:41 AM, someone <> wrote:

[[alternative HTML version deleted]]

David Winsemius, MD West Hartford, CT

------------------------------

Message: 37 Date: Tue, 4 May 2010 20:02:28 +0530 From: Harsh <sing...@gmail.com> To: r-h...@r-project.org Subject: [R] Memory issues using R withing Eclipse-StatET Message-ID: <n2re...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1

Hi useRs, I use R within Eclipse via StatET, and it seems to me that some memory intensive tasks fail due to this environment.

For example: I was trying to find the distance matrix of a matrix with (10000 rows and 500 columns), and it failed in StatET, whereas it worked in vanilla R.

I'm using R 2.10.1 on WinXP.

Thanks for any help in this matter. Regards, Harsh

------------------------------

Message: 38 Date: Tue, 4 May 2010 14:33:29 +0000 (GMT) From: Pascal Martin <pasc...@yahoo.de> To: r-h...@r-project.org Subject: [R] Kernel density estimate plot for 3-dimensional data Message-ID: <9569...@web25501.mail.ukl.yahoo.com> Content-Type: text/plain

Hi!

I have a problem with Kernel density estimate plot for 3-dimensional data in

ks-package.
Here the example:

# load ks, spatstat # three-dimensional kernel density of B B <- pp3(runif(300), runif(300), runif(300), box3(c(0,1))) x <- unclass(B$data)$df H <- Hpi(x) fhat <- kde(x, H=H) plot(fhat) plot(fhat, axes=FALSE, box=FALSE, drawpoints=TRUE); axes3d(c('x','y','z'))

If I try to insert my own coordinates instead of the artificial 3D-pattern, it

does not work.
It would be great, if anybody could help me!

Thanks

Pascal

[[alternative HTML version deleted]]

------------------------------

Message: 39 Date: Tue, 4 May 2010 17:34:53 +0300 From: Christos Argyropoulos <argc...@hotmail.com> To: <glob...@gmail.com>, <r-h...@r-project.org> Subject: Re: [R] Idiomatic looping over list name, value pairs in R Message-ID: <BLU1...@phx.gbl> Content-Type: text/plain

Can you give an example of what the python code is supposed to do?

Some of us are not familiar with python, and the R code is not particularly

informative. You seem to encode information on both the values and the names of

the elements of the vector "d". If this is the case, why don't you create a data

frame (or a matrix) and call apply on the columns?

Christos

Date: Tue, 4 May 2010 23:24:11 +0900 From: glob...@gmail.com To: r-h...@r-project.org Subject: [R] Idiomatic looping over list name, value pairs in R

Considering the python code:

for k, v in d.items(): do_something(k); do_something_else(v)

I have the following for R:

for (i in c(1:length(d))) { do_something(names(d[i])); do_something_else(d[[i]]) }

This does not seem seems idiomatic. What is the best way of doing the same with R?

Thanks.

Luis

_________________________________________________________________ Hotmail: Powerful Free email with security by Microsoft.

[[alternative HTML version deleted]]

------------------------------

Message: 40 Date: Tue, 04 May 2010 10:38:40 -0400 From: Duncan Murdoch <murd...@gmail.com> To: Luis N <glob...@gmail.com> Cc: r-h...@r-project.org Subject: Re: [R] Idiomatic looping over list name, value pairs in R Message-ID: <4BE0...@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 04/05/2010 10:24 AM, Luis N wrote:

Considering the python code:

for k, v in d.items(): do_something(k); do_something_else(v)

I have the following for R:

for (i in c(1:length(d))) { do_something(names(d[i])); do_something_else(d[[i]]) }

This does not seem seems idiomatic. What is the best way of doing the same with R?

You could do it as

for (name in names(d)) { do_something(name) do_something(d[[name]]) }

or

sapply(names(d), function(name) { do_something(name) do_something_else(d[[name]]) })

or

do_both <- function(name) { do_something(name) do_something_else(d[[name]]) } sapply(names(d), do_both)

My choice would be the first version, but yours might differ.

Duncan Murdoch

------------------------------

Message: 41 Date: Tue, 4 May 2010 10:12:29 -0400 From: Abiel X Reinhart <abie...@jpmchase.com> To: "r-h...@r-project.org" <r-h...@r-project.org> Subject: [R] fit printed output onto a single page Message-ID: <DF11...@EMARC105VS01.exchad.jpmchase.net>

Content-Type: text/plain; charset="us-ascii"

Is there a way to force a certain block of captured output to fit onto a single

printed page, where one can specify the properties of the page (dimensions,

margins, etc)? For example, I might want to generate 10 different cuts of a data

table and then capture all the output into a PDF, ensuring that each run of the

data table fits onto a single page (i.e. the font-size of the output may have to

be dynamically adjusted).

Thanks,

Abiel This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates.

This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.

Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to European legal entities.

------------------------------

Message: 42 Date: Tue, 4 May 2010 14:26:43 +0000 (UTC) From: Thorn <thor...@rdls.nestle.com> To: r-h...@stat.math.ethz.ch Subject: [R] Lazy evaluation in function call Message-ID: <loom...@post.gmane.org> Content-Type: text/plain; charset=us-ascii

Hi everybody,

how is it possible to refer to an argument passed to a function in the function call? What I like to do, is something like

f <- function(x,y) x+y f(2, x) # should give 4

The problem is of course that x is only known inside the function. Of course I could specify something like

f(z<-2,z)

but I'm just curious whether it is possible to use a fancy combination of eval, substitute or quote ;)

BR, thorn

------------------------------

Message: 43 Date: Tue, 04 May 2010 10:46:03 -0400 From: Duncan Murdoch <murd...@gmail.com> To: Pascal Martin <pasc...@yahoo.de> Cc: r-h...@r-project.org Subject: Re: [R] Kernel density estimate plot for 3-dimensional data Message-ID: <4BE0...@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 04/05/2010 10:33 AM, Pascal Martin wrote:

Hi!

I have a problem with Kernel density estimate plot for 3-dimensional data in

ks-package.
Here the example:

# load ks, spatstat # three-dimensional kernel density of B B <- pp3(runif(300), runif(300), runif(300), box3(c(0,1))) x <- unclass(B$data)$df H <- Hpi(x) fhat <- kde(x, H=H) plot(fhat) plot(fhat, axes=FALSE, box=FALSE, drawpoints=TRUE); axes3d(c('x','y','z'))

If I try to insert my own coordinates instead of the artificial 3D-pattern, it

does not work.
It would be great, if anybody could help me!

You need to be more explicit about what "does not work" means. The example above works (though I don't like the axes in the first plot; I prefer what you get with plot(fhat, box=FALSE)). What problem are you having?

Duncan Murdoch

------------------------------

Message: 44 Date: Tue, 4 May 2010 16:49:29 +0200 From: "stef...@gmail.com" <stef...@gmail.com> To: r-h...@r-project.org Subject: [R] strange behavior of RODBC and/or ssconvert Message-ID: <q2sa...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1

Dear All,

I have the following problem when reading files (a lot of them) in the spreadsheetML format into R. The spreadsheetML format is an xml format to allow easy import of multisheet data in Excel. As far as I can see, a direct import into R (using the XML package) is not feasible. I use the software ssconvert (included in Gnumeric) and call it from R. It converts the spreadsheetML into xls format. When I now import the newly created xls-file using RODBC package, the last row in each sheet is missing. However, when I open the xls-file the last row is present (hence, ssconvert doesn't delete it). When I now save the xls-file, and import it again using the RODB package, the data is now complete.

Any idea what to do about that? My main problem is to get the spreadsheetML into R so I tried other file formats to which ssconvert can convert to, but only excel supports multisheets.

Best, Stefan

Example code: system(paste('ssconvert "excelcohortdata_men_reference scenario.xml" "excelcohortdata_men_reference scenario22.xls"')) channel1<-odbcConnectExcel("excelcohortdata_men_reference scenario10.xls") odbcGetInfo(channel1) sqlTables(channel1) sqlQuery(channel1, "select * from \"age 9in 2010$\"" ) sqlFetch(chanel1, "age 9in 2010""

------------------------------

Message: 45 Date: Tue, 4 May 2010 23:58:44 +0900 From: Luis N <glob...@gmail.com> To: r-h...@r-project.org Subject: Re: [R] Idiomatic looping over list name, value pairs in R Message-ID: <o2vc...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1

Thank you. Your response was enlightening.

On Tue, May 4, 2010 at 11:38 PM, Duncan Murdoch <murd...@gmail.com> wrote:

On 04/05/2010 10:24 AM, Luis N wrote:

Considering the python code:

for k, v in d.items(): do_something(k); do_something_else(v)

I have the following for R:

for (i in c(1:length(d))) { do_something(names(d[i])); do_something_else(d[[i]]) }

This does not seem seems idiomatic. What is the best way of doing the same with R?

You could do it as

for (name in names(d)) { ?do_something(name) ?do_something(d[[name]]) }

or

sapply(names(d), function(name) { ?do_something(name) ?do_something_else(d[[name]]) })

or

do_both <- function(name) { ?do_something(name) ?do_something_else(d[[name]]) } sapply(names(d), do_both)

My choice would be the first version, but yours might differ.

Duncan Murdoch

------------------------------

Message: 46 Date: Tue, 4 May 2010 17:01:14 +0200 From: Gabriele Esposito <gabr...@gmail.com> To: Jim Lemon <ji...@bitwrit.com.au> Cc: r-h...@r-project.org Subject: Re: [R] 3D version of triax.plot (package plotrix) Message-ID: <o2u3...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1

Hi Jim,

thanks! With just the rgl package I cannot do that. For the moment, I merged two values into one and use triax.plot in the package plotrix, but that's not fully satisfactory. If you find something, let me know, thank you a lot!

Gabriele

On Mon, May 3, 2010 at 2:29 PM, Jim Lemon <ji...@bitwrit.com.au> wrote:

On 05/03/2010 09:43 PM, Gabriele Esposito wrote:

Good afternoon,

I am looking for a way to do a scatterplot of 4 values summing to 1 inside a 3D symplex, i.e. an equilateral pyramid. With the function triax.plot I can do that with 3 values summing to 1, but I can't find an equivalent with an extra dimension.

Hi Gabriele,

I don't have time at the moment to do anything but point you to the rgl package. Might be able to look at it more closely tomorrow.

Jim

------------------------------

Message: 47 Date: Tue, 4 May 2010 15:04:41 +0000 (GMT) From: Pascal Martin <pasc...@yahoo.de> To: r-h...@r-project.org Subject: Re: [R] Kernel density estimate plot for 3-dimensional data Message-ID: <9966...@web25502.mail.ukl.yahoo.com> Content-Type: text/plain

________________________________

An: Duncan Murdoch <murd...@gmail.com> Gesendet: Dienstag, den 4. Mai 2010, 17:03:46 Uhr Betreff: AW: [R] Kernel density estimate plot for 3-dimensional data

#B <- pp3(runif(300), runif(300), runif(300), box3(c(0,1))) creates a 3d pattern with random points. But I want it to create a Kernel density estimate plot with my coordinates. I show it in an example:

x<- scan()

1: 1 2 3 4 5 6 7 8 9 10 11: Read 10 items

y<- scan()

1: 10 9 8 7 6 5 4 3 2 1 11: Read 10 items

z<- scan()

1: 6 5 7 4 8 3 9 2 10 1 11: Read 10 items

B<- pp3(x,y,z, c(0,10), c(0,10), c(0,10))

x <- unclass(B$data)$df H <- Hpi(x)

From this point, it shows an error in chol.default(S12) and accordingly the rest does not go on.

fhat <- kde(x, H=H)

plot(fhat) plot(fhat, axes=FALSE, box=FALSE, drawpoints=TRUE); axes3d(c('x','y','z'))

________________________________ Von: Duncan Murdoch <murd...@gmail.com>

CC: r-h...@r-project.org Gesendet: Dienstag, den 4. Mai 2010, 16:46:03 Uhr Betreff: Re: [R] Kernel density estimate plot for 3-dimensional data

On 04/05/2010 10:33 AM, Pascal Martin wrote:

Hi!

I have a problem with Kernel density estimate plot for 3-dimensional data in

ks-package.
Here the example:

# load ks, spatstat # three-dimensional kernel density of B B <- pp3(runif(300), runif(300), runif(300), box3(c(0,1))) x <- unclass(B$data)$df H <- Hpi(x) fhat <- kde(x, H=H) plot(fhat) plot(fhat, axes=FALSE, box=FALSE, drawpoints=TRUE); axes3d(c('x','y','z'))

If I try to insert my own coordinates instead of the artificial 3D-pattern, it

does not work.

[[elided Yahoo spam]]

You need to be more explicit about what "does not work" means. The example above works (though I don't like the axes in the first plot; I prefer what you get with plot(fhat, box=FALSE)). What problem are you having?

Duncan Murdoch

[[alternative HTML version deleted]]

------------------------------

Message: 48 Date: Tue, 04 May 2010 11:17:39 -0400 From: Duncan Murdoch <murd...@gmail.com> To: Pascal Martin <pasc...@yahoo.de> Cc: R-Help <r-h...@r-project.org> Subject: Re: [R] Kernel density estimate plot for 3-dimensional data Message-ID: <4BE0...@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed

On 04/05/2010 11:03 AM, Pascal Martin wrote:

#B <- pp3(runif(300), runif(300), runif(300), box3(c(0,1))) creates a 3d pattern with random points. But I want it to create a Kernel density estimate plot with my coordinates. I show it in an example:

x<- scan()

1: 1 2 3 4 5 6 7 8 9 10 11: Read 10 items

y<- scan()

1: 10 9 8 7 6 5 4 3 2 1 11: Read 10 items

z<- scan()

1: 6 5 7 4 8 3 9 2 10 1 11: Read 10 items

B<- pp3(x,y,z, c(0,10), c(0,10), c(0,10))

x <- unclass(B$data)$df H <- Hpi(x)

From this point, it shows an error in chol.default(S12) and accordingly the rest does not go on.

Those points all lie in a plane (y = 11-x); I imagine that causes the density estimate to overflow. I get the same problem with your data, but not with non-planar data.

Duncan Murdoch

fhat <- kde(x, H=H)

plot(fhat) plot(fhat, axes=FALSE, box=FALSE, drawpoints=TRUE); axes3d(c('x','y','z'))

________________________________ Von: Duncan Murdoch <murd...@gmail.com> An: Pascal Martin <pasc...@yahoo.de> CC: r-h...@r-project.org Gesendet: Dienstag, den 4. Mai 2010, 16:46:03 Uhr Betreff: Re: [R] Kernel density estimate plot for 3-dimensional data

On 04/05/2010 10:33 AM, Pascal Martin wrote:

Hi!

ks-package.
Here the example:

If I try to insert my own coordinates instead of the artificial 3D-pattern, it

does not work.
It would be great, if anybody could help me!

You need to be more explicit about what "does not work" means. The example above works (though I don't like the axes in the first plot; I prefer what you get with plot(fhat, box=FALSE)). What problem are you having?

Duncan Murdoch

------------------------------

Message: 49 Date: Tue, 4 May 2010 17:29:06 +0200 From: Joris Meys <jori...@gmail.com> To: R mailing list <r-h...@r-project.org> Subject: [R] Avoiding for-loop for splitting vector into subvectors based on positions Message-ID: <j2mb...@mail.gmail.com> Content-Type: text/plain

Dear all,

I'm trying to optimize code and want to avoid for-loops as much as possible. I'm applying a calculation on subvectors from a big one, and I get the subvectors by using a vector of starting positions:

x <- 1:10 pos <- c(1,4,7) n <- length(x)

I try to do something like this : pos2 <- c(pos, n+1)

out <- c() for(i in 1:n){ tmp <- x[pos2[i]:pos2[i+1]] out <- c(out, length(tmp)) }

Never mind the length function, I apply a far more complicated one. It's about the use of the indices in the for-loop. I didn't see any way of doing that with an apply, unless there is a very convenient way of splitting my vector in a list of the subvectors or so.

Anybody an idea? Cheers

-- Joris Meys Statistical Consultant

Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control

Coupure Links 653 B-9000 Gent

tel : +32 9 264 59 87 Jori...@Ugent.be

------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[alternative HTML version deleted]]

------------------------------

Message: 50 Date: Tue, 4 May 2010 11:50:42 -0400 From: jim holtman <jhol...@gmail.com> To: Joris Meys <jori...@gmail.com> Cc: R mailing list <r-h...@r-project.org> Subject: Re: [R] Avoiding for-loop for splitting vector into subvectors based on positions Message-ID: <h2u6...@mail.gmail.com> Content-Type: text/plain

Try this:

x <- 1:10 pos <- c(1,4,7) pat <- rep(seq_along(pos), times=diff(c(pos, length(x) + 1))) split(x, pat)

$`1` [1] 1 2 3 $`2` [1] 4 5 6 $`3` [1] 7 8 9 10

On Tue, May 4, 2010 at 11:29 AM, Joris Meys <jori...@gmail.com> wrote:

Dear all,

I'm trying to optimize code and want to avoid for-loops as much as possible. I'm applying a calculation on subvectors from a big one, and I get the subvectors by using a vector of starting positions:

x <- 1:10 pos <- c(1,4,7) n <- length(x)

I try to do something like this : pos2 <- c(pos, n+1)

out <- c() for(i in 1:n){ tmp <- x[pos2[i]:pos2[i+1]] out <- c(out, length(tmp)) }

Never mind the length function, I apply a far more complicated one. It's about the use of the indices in the for-loop. I didn't see any way of doing that with an apply, unless there is a very convenient way of splitting my vector in a list of the subvectors or so.

Anybody an idea? Cheers

-- Joris Meys Statistical Consultant

Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control

Coupure Links 653 B-9000 Gent

tel : +32 9 264 59 87 Jori...@Ugent.be

------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[alternative HTML version deleted]]

______________________________________________ R-h...@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<http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.

-- Jim Holtman Cincinnati, OH +1 513 646 9390

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

------------------------------

Message: 51 Date: Tue, 4 May 2010 18:57:05 +0300 From: Tal Galili <tal....@gmail.com> To: Lanna Jin <lann...@gmail.com> Cc: r-h...@r-project.org Subject: Re: [R] R for web browser Message-ID: <i2o4...@mail.gmail.com> Content-Type: text/plain

I wrote about R-Node last month, it offers what you are talking about:

http://www.r-statistics.com/2010/04/r-node-a-web-front-end-to-r-with-protovis/

----------------Contact Details:------------------------------------------------------- Contact me: Tal....@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English)

----------------------------------------------------------------------------------------------

On Tue, May 4, 2010 at 4:51 PM, Lanna Jin <lann...@gmail.com> wrote:

Hi Everyone,

Does anyone know of any projects for running an interactive R session within a web browser? I'm looking for something similar to the one on the Ruby website (http://tryruby.org), except for R.

Thanks for your responses in advance!

Lanna

----- Lanna Jin

lann...@gmail.com 510-898-8525

-- View this message in context: http://r.789695.n4.nabble.com/R-for-web-browser-tp2125571p2125571.html Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

------------------------------

Message: 52 Date: Tue, 4 May 2010 09:05:48 -0700 (PDT) From: John Kane <jrkr...@yahoo.ca> To: Petr PIKAL <petr...@precheza.cz> Cc: r-h...@r-project.org Subject: Re: [R] / Operator not meaningful for factors Message-ID: <7223...@web38404.mail.mud.yahoo.com> Content-Type: text/plain; charset=iso-8859-1

--- On Tue, 5/4/10, Petr PIKAL <petr...@precheza.cz> wrote:

From: Petr PIKAL <petr...@precheza.cz> Subject: Re: [R] / Operator not meaningful for factors To: "John Kane" <jrkr...@yahoo.ca> Cc: r-h...@r-project.org, "vincent.deluard" <vinc...@trimtabs.com> Received: Tuesday, May 4, 2010, 3:38 AM Hi

r-he...@r-project.org napsal dne 04.05.2010 00:50:00:

? I think that you are correct.? R has the annoying habit of converting character data to factors when you don't want it to

while it is importing

data.? This is because the in the option

"stringsAsFactors" is set to TRUE for

some weird historical reasons.

It is a matter of opinion. I consider it quite useful feature. If I see by

str(some.data) or summary(data0 that numeric columns are factors I know something is wrong with input.

I'm not denying that it can be useful but IIRC from a discussion a couple of

years ago, it was a fairly arbitary decision.

On the other hand it can be very annoying when one has some kinds of data.

and when I want to use ggplot, xyplot or just plot my data with different colours/sizes/pchs/.... it is quite easy to use as.numeric(my.factor) to get numeric representation of levels.

Finally you can easily change labels, concatenate levels and so on.

Just my 2 cents.

Regards Petr

Try the command str(insert name of data) and see what

happens.? It should show

you which columns of data are being treated as factors.

You can convert the back to character or to

numeric.? See the FAQ Part 7 "How

do I convert factors to numeric? " or you can use the String as options command in the read.table to FALSE

Something like this should work, I think, but it's not tested read.table("C:/rdata/trees.csv", stringsAsFactors=FALSE)

--- On Mon, 5/3/10, vincent.deluard <vinc...@trimtabs.com>

wrote:

From: vincent.deluard <vinc...@trimtabs.com> Subject: Re: [R] / Operator not meaningful for factors To: r-h...@r-project.org Received: Monday, May 3, 2010, 6:22 PM

Hi there,

This will sound very stupid because I just started using R but I see you had similar problems.

I just loaded a very large dataset (2950*6602) from csv into R. The format is ticker=row, date=column. Every time I want to compute basic operations, R returns "In Ops.factor: not meaningful for factors"

I believe it is because R does not read the data as numbers but I am not sure. Can anybody help?

Thanks!

-- View this message in context:

http://r.789695.n4.nabble.com/Operator-not-

meaningful-for-factors-tp791563p2124697.html

Sent from the R help mailing list archive at Nabble.com.

______________________________________________ R-h...@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.

------------------------------

Message: 53 Date: Tue, 4 May 2010 16:11:31 +0000 (GMT) From: cg...@witthoft.com To: rip...@stats.ox.ac.uk Cc: r-h...@r-project.org, ca...@witthoft.com Subject: Re: [R] ISO Eric Kort (rtiff) Message-ID: <1684018604.50808.1272989491608.JavaMail.mail@webmail01> Content-Type: text/plain; charset=UTF-8

Thanks, Brian. I can see where to mod readTiff to return the original data

ranges; and where to mod writeTiff so it writes files with something better than

the current 0:255 resolution range.

I have found an additional problem with readTiff, so is there someone I can

write to about it?
What I found was, for some tiff images created within my company, readTiff does

not convert the source data correctly. The files contain greyscale data, 16

bits per pixel (i.e. 0 to 4095). Whether it's a mistake in the way the tags

were originally written to the file, or a mistake in the way that readTiff

interprets the libtiff outputs, I don't know, but readTiff only reads the upper

byte of each pixel. This produces data with a range of 0 to 15 (prior to being

autoscaled into pixmap's [0,1] space ). I can dig up the values returned by

tools like tiffdump, so if someone out there in R-help land can point me to the

pertinent values, I'll do all I can to help solve this problem.

Thanks again

Carl

May 4, 2010 01:46:05 AM, rip...@stats.ox.ac.uk wrote:

===========================================

On Mon, 3 May 2010, Carl Witthoft wrote:

I wanted to ask Eric a question or two about the rtiff package, but his listed email address bounces w/ 550 error. Does anyone know how to reach him, or whether he's actively maintaining rtiff?

He is not. The latest version of rtiff was done by the CRAN team to fix a number of errors and keep it building on the CRAN platfoms -- you will see it was packaged by me.

If anyone's interested, my primary desire is for rtiff (or other tool) to provide me with the raw range of pixel values in a tiff file. rtiff dumps straight into a pixmap object, so the data are autoscaled into [0,1] .

It is very simple package, easy for you to modify -- this could be done in readTiff in a couple of minutes.

An alternative is BioC package EBImage (provided your ImageMagick installation supports TIFF).

-- 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, UK Fax: +44 1865 272595

------------------------------

Message: 54 Date: Tue, 04 May 2010 12:11:38 -0400 From: Marshall Feldman <mar...@uri.edu> To: r-h...@r-project.org Subject: [R] read.table: skipping trailing delimiters Message-ID: <4BE0...@uri.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi,

I am trying to read a tab-delimited file that has trailing tab delimiters. It's a simple file with two legitimate fields. I'm using the first as row.names, and the second should be the only column in the resulting data frame.

Initially, R was filling the last column with NA's, but I was able to stop that by setting colClasses=c("character","character",NULL). Still, the data frame is coming in with an extra column, only now its values are set to "".

Is there any way to skip the trailing delimited field entirely? I've searched for an answer without luck.

Thanks. Marsh Feldman

------------------------------

Message: 55 Date: Tue, 4 May 2010 12:20:46 -0400 From: Gabor Grothendieck <ggro...@gmail.com> To: "stef...@gmail.com" <stef...@gmail.com> Cc: r-h...@r-project.org Subject: Re: [R] strange behavior of RODBC and/or ssconvert Message-ID: <n2z9...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1

The original seems not to have gotten through. Here it is again.

On Tue, May 4, 2010 at 11:14 AM, Gabor Grothendieck <ggro...@gmail.com> wrote:

Try a few of the solutions here: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows and see if they all give you the same result.

------------------------------

Message: 56 Date: Tue, 04 May 2010 12:23:45 -0400 From: Marshall Feldman <mar...@uri.edu> To: r-h...@r-project.org Subject: [R] Flushing print buffer Message-ID: <4BE0...@uri.edu> Content-Type: text/plain

Hello,

I have a function with these lines:

test <- function(object,...){ cat("object: has ",nrow(object),"labels\n") cat("Head:\n") head(object,...) cat("\nTail:\n") tail(object,...) }

If I feed it a data frame object, it only prints out the tail part. If I comment out the last two lines of the function, it does print the head part. Obviously there's a buffer not being flushed between the head and the tail calls, but I don't know how to flush it. Can someone help me?

Thanks.

Marsh Feldman

[[alternative HTML version deleted]]

------------------------------

Message: 57 Date: Tue, 04 May 2010 11:27:30 -0500 From: Marc Schwartz <marc...@me.com> To: Marshall Feldman <mar...@uri.edu> Cc: r-h...@r-project.org Subject: Re: [R] read.table: skipping trailing delimiters Message-ID: <2E00...@me.com> Content-Type: text/plain; charset=us-ascii

On May 4, 2010, at 11:11 AM, Marshall Feldman wrote:

Hi,

I am trying to read a tab-delimited file that has trailing tab delimiters. It's

a simple file with two legitimate fields. I'm using the first as row.names, and

the second should be the only column in the resulting data frame.

Initially, R was filling the last column with NA's, but I was able to stop that

by setting colClasses=c("character","character",NULL). Still, the data frame is

coming in with an extra column, only now its values are set to "".

Is there any way to skip the trailing delimited field entirely? I've searched

for an answer without luck.

Thanks. Marsh Feldman

The easiest way to remove a single final column is to post-process the data

frame that you imported. So if your imported data frame is called 'DF':

DF.New <- DF[, -ncol(DF)]

See ?ncol and ?Extract

You could also do more complex sub-setting using the ?subset function or

consider pre-processing the file to be imported with command line tools such as

cut or awk.

For example, using the 'iris' data set:

str(iris)

'data.frame': 150 obs. of 5 variables:
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
$ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
$ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
$ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
$ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1

1 ...

str(iris[, -ncol(iris)])

'data.frame': 150 obs. of 4 variables: $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ... $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ... $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ... $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...

HTH,

Marc Schwartz

------------------------------

Message: 58 Date: Tue, 4 May 2010 12:34:15 -0400 From: Gabor Grothendieck <ggro...@gmail.com> To: Marshall Feldman <mar...@uri.edu> Cc: r-h...@r-project.org Subject: Re: [R] read.table: skipping trailing delimiters Message-ID: <n2i9...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1

Re-read the colClasses section of ?read.table. Use "NULL", not NULL.

On Tue, May 4, 2010 at 12:11 PM, Marshall Feldman <mar...@uri.edu> wrote:

Hi,

I am trying to read a tab-delimited file that has trailing tab delimiters. It's a simple file with two legitimate fields. I'm using the first as row.names, and the second should be the only column in the resulting data frame.

Initially, R was filling the last column with NA's, but I was able to stop that by setting colClasses=c("character","character",NULL). Still, the data frame is coming in with an extra column, only now its values are set to "".

Is there any way to skip the trailing delimited field entirely? I've searched for an answer without luck.

? ?Thanks. ? ?Marsh Feldman

------------------------------

Message: 59 Date: Tue, 4 May 2010 12:43:55 -0400 From: jim holtman <jhol...@gmail.com> To: Marshall Feldman <mar...@uri.edu> Cc: r-h...@r-project.org Subject: Re: [R] Flushing print buffer Message-ID: <h2n6...@mail.gmail.com> Content-Type: text/plain

explicitly print your data:

print(head(object,...)) On Tue, May 4, 2010 at 12:23 PM, Marshall Feldman <mar...@uri.edu> wrote:

Hello,

I have a function with these lines:

test <- function(object,...){ cat("object: has ",nrow(object),"labels\n") cat("Head:\n") head(object,...) cat("\nTail:\n") tail(object,...) }

If I feed it a data frame object, it only prints out the tail part. If I comment out the last two lines of the function, it does print the head part. Obviously there's a buffer not being flushed between the head and the tail calls, but I don't know how to flush it. Can someone help me?

Thanks.

Marsh Feldman

[[alternative HTML version deleted]]

______________________________________________ R-h...@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<http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.

-- Jim Holtman Cincinnati, OH +1 513 646 9390

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

------------------------------

Message: 60 Date: Tue, 4 May 2010 12:47:40 -0400 From: jim holtman <jhol...@gmail.com> To: Marshall Feldman <mar...@uri.edu> Cc: r-h...@r-project.org Subject: Re: [R] Flushing print buffer Message-ID: <n2q6...@mail.gmail.com> Content-Type: text/plain

I should have also had you read FAQ 7.16

On Tue, May 4, 2010 at 12:43 PM, jim holtman <jhol...@gmail.com> wrote:

explicitly print your data:

print(head(object,...)) On Tue, May 4, 2010 at 12:23 PM, Marshall Feldman <mar...@uri.edu> wrote:

Hello,

I have a function with these lines:

test <- function(object,...){ cat("object: has ",nrow(object),"labels\n") cat("Head:\n") head(object,...) cat("\nTail:\n") tail(object,...) }

If I feed it a data frame object, it only prints out the tail part. If I comment out the last two lines of the function, it does print the head part. Obviously there's a buffer not being flushed between the head and the tail calls, but I don't know how to flush it. Can someone help me?

Thanks.

Marsh Feldman

[[alternative HTML version deleted]]

______________________________________________ R-h...@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<http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.

-- Jim Holtman Cincinnati, OH +1 513 646 9390

What is the problem that you are trying to solve?

-- Jim Holtman Cincinnati, OH +1 513 646 9390

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

------------------------------

Message: 61 Date: Tue, 4 May 2010 16:58:59 +0000 From: Bo Li <libo...@hotmail.com> To: <r-h...@r-project.org> Subject: [R] Package Rsafd Message-ID: <SNT1...@phx.gbl> Content-Type: text/plain

Dear R community,

I am looking for the package "Rsafd". It is not listed on the CRAN directory. I

am wondering anyone has idea with this package. Thans a lot!

Bo

_________________________________________________________________ The New Busy is not the old busy. Search, chat and e-mail from your inbox.

N:WL:en-US:WM_HMP:042010_3 [[alternative HTML version deleted]]

------------------------------

Message: 62 Date: Tue, 4 May 2010 10:11:57 -0700 (PDT) From: threshold <r.ko...@gmail.com> To: r-h...@r-project.org Subject: [R] legend with lines and points Message-ID: <1272...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

Hi, say there are x and y given as:

level x y 3 0.112 0.012 2 0.432 0.111 1 0.415 0.053 3 0.38 0.005 2 0.607 0.01 1 NA NA 3 0.572 0.01 2 0.697 0.039 1 0.377 0.006 3 NA NA 2 0.571 0.003 1 0.646 0.014 3 0.063 0.024 2 0.115 0.017 1 0.035 0.042 3 0.426 0

I did the following plot:

plot(y ~ x, pch=c(1,2,3), col=c('red', 'green', 'blue')); abline(lm(y ~ x), col='red'); lines(lowess.na(y,x), col='blue') abline(lm(y~x),col='red') legend('topright',c('Top','Middle','Bottom'), col=c('red', 'green', 'blue'),pch=c(1,2,3)) legend('right',c('linear','LOWESS'), col=c('red','blue'),lty=c(1,2))

where: lowess.na <- function(x, y) { #do lowess with missing data x1 <- subset(x,(!is.na(x)) &(!is.na(y))) y1 <- subset(y, (!is.na(x)) &(!is.na(y))) lowess.na <- lowess(x1~y1) }

I want ONE legend to involve points (empirical) and lines from linear and lowess fit together. I guess it is simple but.....

best, robert

--
View this message in context:

http://r.789695.n4.nabble.com/legend-with-lines-and-points-tp2125971p2125971.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 63 Date: Tue, 4 May 2010 13:12:50 -0400 From: David Winsemius <dwin...@comcast.net> To: Bo Li <libo...@hotmail.com> Cc: r-h...@r-project.org Subject: Re: [R] Package Rsafd Message-ID: <2781...@comcast.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

Try R-Forge

On May 4, 2010, at 12:58 PM, Bo Li wrote:

Dear R community,

I am looking for the package "Rsafd". It is not listed on the CRAN directory. I am wondering anyone has idea with this package. Thans a lot!

David Winsemius, MD West Hartford, CT

------------------------------

Message: 64 Date: Tue, 4 May 2010 13:28:31 -0400 From: David Winsemius <dwin...@comcast.net> To: David Winsemius <dwin...@comcast.net> Cc: r-h...@r-project.org Subject: Re: [R] Package Rsafd Message-ID: <061C...@comcast.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On May 4, 2010, at 1:12 PM, David Winsemius wrote:

Try R-Forge

I made that suggestion based on finding links to R-Forge searching for "rsafd" with RSeek but that was misleading. Try instead:

http://orfe.princeton.edu/~rcarmona/SVbook/svbook.html

On May 4, 2010, at 12:58 PM, Bo Li wrote:

Dear R community,

I am looking for the package "Rsafd". It is not listed on the CRAN directory. I am wondering anyone has idea with this package. Thans a lot!

David Winsemius, MD West Hartford, CT

David Winsemius, MD West Hartford, CT

------------------------------

Message: 65 Date: Tue, 4 May 2010 18:00:52 +0000 (UTC) From: j verzani <jver...@gmail.com> To: r-h...@stat.math.ethz.ch Subject: Re: [R] R for web browser Message-ID: <loom...@post.gmane.org> Content-Type: text/plain; charset=us-ascii

Lanna Jin <lannajin <at> gmail.com> writes:

Hi Everyone,

Does anyone know of any projects for running an interactive R session within a web browser? I'm looking for something similar to the one on the Ruby website (http://tryruby.org), except for R.

Thanks for your responses in advance!

You can run R code through the sage software. (Sage is a CAS and also an interface to numerous open-source software packages.) The main interface for sage is through a notebook within a web browser. A freely accessible notebook server can be found at www.sagenb.org. Recent work involves integrating R's plotting features within the notebook.

Lanna

----- Lanna Jin

lannajin <at> gmail.com 510-898-8525

------------------------------

Message: 66 Date: Tue, 4 May 2010 10:05:48 -0700 From: "Anderson, Chris" <chri...@paradigmcorp.com> To: "'r-h...@R-project.org'" <r-h...@r-project.org> Subject: [R] help overlay scatterplot to effects plot Message-ID: <FA84...@conmail02.paradigmhealth.com>

Content-Type: text/plain

I have a process where I am creating a effects plot similar to the cowles effect

example. I would like to add the point estimates to the effects plot, can

someone show me the correct syntax. I have included the "R" effects example, so

you can show me the correct syntax. Thanks

mod.cowles <- glm(volunteer ~ sex + neuroticism*extraversion,

data=Cowles, family=binomial)

eff.cowles <- allEffects(mod.cowles, xlevels=list(neuroticism=0:24,

extraversion=seq(0, 24, 6)), given.values=c(sexmale=0.5))

eff.cowles

plot(eff.cowles, 'neuroticism:extraversion', ylab="Prob(Volunteer)", ticks=list(at=c(.1,.25,.5,.75,.9)))

Chris Anderson Data Analyst Medical Affairs wk: 925-677-4870 cell: 707-315-8486 Fax:925-677-4670

</pre><br>This electronic message transmission, including any attachments,

contains <br>information which may be confidential, privileged and/or otherwise

exempt <br>from disclosure under applicable law. The information is intended to

be for the <br>use of the individual(s) or entity named above. If you are not

the intended <br>recipient or the employee or agent responsible for delivering

the message <br>to the intended recipient, you are hereby notified that any

disclosure, copying, <br>distribution or use of the contents of this information

is strictly prohibited. If <br>you have received this electronic transmission

in error, please notify the sender <br>immediately by telephone (800-676-6777)

or by a "reply to sender only" <br>message and destroy all electronic and hard

copies of the communication, <br>including attachments. Thank you.<br><br>For

more information on Paradigm Management Services, LLC, please visit

<br>http://www.paradigmcorp.com <br>

[[alternative HTML version deleted]]

------------------------------

Message: 67 Date: Tue, 4 May 2010 16:18:51 +0000 From: a a <aahm...@hotmail.com> To: <r-h...@r-project.org> Subject: [R] How to make predictions with the predict() method on an arimax object using arimax() from TSA library Message-ID: <SNT1...@phx.gbl> Content-Type: text/plain

Hi R Users,

I'm fairly new to R (about 3 months use thus far.)

I wanting to use the arimax function from the TSA library to incorporate some

exogenous inputs into the basic underllying arima model.Then with that newly

model of type arimax, I would like to make a prediction.

To avoid being bogged down with issues specific to my own work, I would like to

refer to readers to the example given in the TSA documentation which would also

then clarify my own issues:

library(TSA)

data(airmiles)

air.ml=arimax(log(airmiles),order=c(0,1,1),seasonal=list(order=c(0,1,1),

period=12),xtransf=data.frame(I911=1*(seq(airmiles)==69),

I911=1*(seq(airmiles)==69)),

transfer=list(c(0,0),c(1,0)),xreg=data.frame(Dec96=1*(seq(airmiles)==12),

Jan97=1*(seq(airmiles)==13),Dec02=1*(seq(airmiles)==84)),method='ML')

Ok,so I've run the above code and an object called air.ml has now been created

of class type arimax.According to the documentation this is the same type as

arima.So now I make a prediction,say 15 time steps ahead:

forecast=predict(air.m1, n.ahead=15)

The following error is produced:

Error in predict.Arima(air.m1, n.ahead = 15) : 'xreg' and 'newxreg' have different numbers of columns

--------------------------------------------------------------------------------------------------------------------

Question is how to to get a prediction correctly using predict.(I've seen DSE

package but that seems overkill to make just a simple prediction)??

Thank you in advance for any repsonses.

A.A

Part time student at BBK college,UofL.

_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your

inbox.

N:WL:en-US:WM_HMP:042010_2 [[alternative HTML version deleted]]

------------------------------

Message: 68 Date: Tue, 4 May 2010 18:13:08 +0000 (GMT) From: Marc Carpentier <marc...@ymail.com> To: Uwe Ligges <lig...@statistik.tu-dortmund.de> Cc: r-h...@r-project.org Subject: [R] Re : aregImpute (Hmisc package) : error in matxv(X, xcof)... Message-ID: <6065...@web28210.mail.ukl.yahoo.com> Content-Type: text/plain; charset="iso-8859-1"

Ok. I was afraid to refer to a known and obvious error.
Here is a testing dataset (pb1.csv) and commented code (pb1.R) with the

problems.
Thanks for any help.

Marc

________________________________ De : Uwe Ligges <lig...@statistik.tu-dortmund.de> ? : Marc Carpentier <marc...@ymail.com> Cc : r-h...@r-project.org Envoy? le : Mar 4 mai 2010, 13 h 52 min 31 s Objet : Re: [R] aregImpute (Hmisc package) : error in matxv(X, xcof)...

Having reproducible examples including data and the actual call that lead to the error would be really helpful to be able to help.

Uwe Ligges

On 04.05.2010 12:23, Marc Carpentier wrote:

But with my own dataset, I have the following error :

Erreur dans matxv(X, xcof) : columns in a (51) must be<= length of b (50)
De plus : Warning message:
In f$xcoef[, 1] * f$xcenter :
la taille d'un objet plus long n'est pas multiple de la taille d'un objet

plus court
= longer object length is not a multiple of shorter object length

I first tried to "I()" all the continuous variables but the same error occurs

with different numbers :
Erreur dans matxv(X, xcof) : columns in a (37) must be<= length of b (36)...

effectively imputed. I just found this previous message, where the author's

autoreply suggests that particular distributions might be an explanation of

algorithms failure :
http://www.mail-archive.com/r-help@r-proje...@

And if the number mentioned might give me a hint on which column to look at (and

maybe transform or ignore for the imputation) ?
Thanks for any advice you might have.

Marc

[[alternative HTML version deleted]]

------------------------------

Message: 69 Date: Tue, 4 May 2010 14:25:59 -0400 From: Galois Theory <tgal...@gmail.com> To: R-h...@r-project.org Subject: [R] unsubcribe Message-ID: <AANL...@mail.gmail.com> Content-Type: text/plain

[[alternative HTML version deleted]]

------------------------------

Message: 70 Date: Tue, 4 May 2010 14:28:53 -0400 From: David Winsemius <dwin...@comcast.net> To: Marc Carpentier <marc...@ymail.com> Cc: r-h...@r-project.org, Uwe Ligges <lig...@statistik.tu-dortmund.de> Subject: Re: [R] Re : aregImpute (Hmisc package) : error in matxv(X, xcof)... Message-ID: <4AEB...@comcast.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes

On May 4, 2010, at 2:13 PM, Marc Carpentier wrote:

Ok. I was afraid to refer to a known and obvious error. Here is a testing dataset (pb1.csv) and commented code (pb1.R) with the problems. Thanks for any help.

Nothing attached. In all likelihood had you given these file names with extensions of .txt, they would have made it through the server filter

Marc

________________________________ De : Uwe Ligges <lig...@statistik.tu-dortmund.de> ? : Marc Carpentier <marc...@ymail.com> Cc : r-h...@r-project.org Envoy? le : Mar 4 mai 2010, 13 h 52 min 31 s Objet : Re: [R] aregImpute (Hmisc package) : error in matxv(X, xcof)...

Uwe Ligges

On 04.05.2010 12:23, Marc Carpentier wrote:

Marc

David Winsemius, MD West Hartford, CT

------------------------------

Message: 71 Date: Tue, 04 May 2010 14:48:17 -0400 From: "Cedrick W. Johnson" <cedr...@cedrickjohnson.com> To: Galois Theory <tgal...@gmail.com> Cc: R-h...@r-project.org Subject: Re: [R] unsubcribe Message-ID: <4BE0...@cedrickjohnson.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

https://stat.ethz.ch/mailman/listinfo/r-help

On 5/4/2010 2:25 PM, Galois Theory wrote:

[[alternative HTML version deleted]]

------------------------------

Message: 72 Date: Tue, 4 May 2010 12:07:43 -0700 (PDT) From: pdb <phi...@philbrierley.com> To: r-h...@r-project.org Subject: [R] randomforests - how to classify Message-ID: <1273...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

Hi,

I'm experimenting with random forests and want to perform a binary classification task. I've tried some of the sample codes in the help files and things run, but I get a message to the effect 'you don't have very many unique values in the target - are you sure you want to do regression?' (sorry, don't know exact message but r is busy now so can't check).

In reading the help files I see 2 examples, one for classification and one for regression. To the uninformed - these don't seem much different to each other. How does rf know to do regression or classification?

## Classification: ##data(iris) set.seed(71) iris.rf <- randomForest(Species ~ ., data=iris, importance=TRUE, proximity=TRUE)

## Regression: ## data(airquality) set.seed(131) ozone.rf <- randomForest(Ozone ~ ., data=airquality, mtry=3, importance=TRUE, na.action=na.omit)

My target variable only has 2 values - why does it want to do regression? I've entered code just like that in the classification example above. Also when it asks me 'are you sure you want to do regression' - how do I say 'NO, do classification please'?

--
View this message in context:

http://r.789695.n4.nabble.com/randomforests-how-to-classify-tp2126166p2126166.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 73 Date: Tue, 4 May 2010 15:25:34 -0400 From: Fahim Md <fahi...@gmail.com> To: r-h...@r-project.org Subject: [R] installing a package in linux Message-ID: <r2l9...@mail.gmail.com> Content-Type: text/plain

I recently started using ubuntu 9.10 and I am using gedit editor and R plugin for writing R code. To install any package I need to do: $ install.packages() //window pop-up for mirror selection //then another window pop up for package selection. After this as long as I am not exiting, the function of the newly installed packages are available.

After I exit (i use to put 'no' in 'save workspace' option) from R, if I want to again work in R, I have to repeat the process of package install. This reintallation problem was not there in windows(I was using Tinn-R as editor, I just need to put require('package-name') to use its function).

Is there anyway so that reinstallation of the package is avoided??? thanks --Fahim

[[alternative HTML version deleted]]

------------------------------

Message: 74 Date: Tue, 4 May 2010 12:27:46 -0700 From: Changbin Du <chan...@gmail.com> To: pdb <phi...@philbrierley.com> Cc: r-h...@r-project.org Subject: Re: [R] randomforests - how to classify Message-ID: <q2g8...@mail.gmail.com> Content-Type: text/plain

use (as.factor(target) ~., data =your data, ...)

On Tue, May 4, 2010 at 12:07 PM, pdb <phi...@philbrierley.com> wrote:

Hi,

I'm experimenting with random forests and want to perform a binary classification task. I've tried some of the sample codes in the help files and things run, but I get a message to the effect 'you don't have very many unique values in the target - are you sure you want to do regression?' (sorry, don't know exact message but r is busy now so can't check).

In reading the help files I see 2 examples, one for classification and one for regression. To the uninformed - these don't seem much different to each other. How does rf know to do regression or classification?

## Classification: ##data(iris) set.seed(71) iris.rf <- randomForest(Species ~ ., data=iris, importance=TRUE, proximity=TRUE)

## Regression: ## data(airquality) set.seed(131) ozone.rf <- randomForest(Ozone ~ ., data=airquality, mtry=3, importance=TRUE, na.action=na.omit)

My target variable only has 2 values - why does it want to do regression? I've entered code just like that in the classification example above. Also when it asks me 'are you sure you want to do regression' - how do I say 'NO, do classification please'?

-- View this message in context: http://r.789695.n4.nabble.com/randomforests-how-to-classify-tp2126166p2126166.html Sent from the R help mailing list archive at Nabble.com.

-- Sincerely, Changbin

--

[[alternative HTML version deleted]]

------------------------------

Message: 75 Date: Tue, 4 May 2010 15:33:06 -0400 From: ivo welch <ivo...@gmail.com> To: r-help <r-h...@stat.math.ethz.ch> Subject: [R] R formula language---a min and max function? Message-ID: <n2l5...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1

Dear R experts---I would like to estimate a non-linear least squares expression that looks something like

y ~ a+b*min(c,x)

where a, b, and c are the three parameters. how do I define a min function in the formula language of R? advice appreciated.

sincerely,

/iaw

------------------------------

Message: 76 Date: Tue, 4 May 2010 15:40:46 -0400 From: David Winsemius <dwin...@comcast.net> To: ivo welch <ivo...@gmail.com> Cc: r-help <r-h...@stat.math.ethz.ch> Subject: Re: [R] R formula language---a min and max function? Message-ID: <FDB0...@comcast.net> Content-Type: text/plain; charset=US-ASCII; format=flowed

On May 4, 2010, at 3:33 PM, ivo welch wrote:

Dear R experts---I would like to estimate a non-linear least squares expression that looks something like

y ~ a+b*min(c,x)

where a, b, and c are the three parameters. how do I define a min function in the formula language of R? advice appreciated.

?pmin

sincerely,

/iaw

David Winsemius, MD West Hartford, CT

------------------------------

Message: 77 Date: Tue, 4 May 2010 15:52:09 -0400 From: ivo welch <ivo....@gmail.com> To: David Winsemius <dwin...@comcast.net> Cc: r-help <r-h...@stat.math.ethz.ch> Subject: Re: [R] R formula language---a min and max function? Message-ID: <z2t5...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1

thank you, david. indeed. works great (almost). an example for anyone else googling this in the future:

x=1:20 y= 2+3*ifelse(x>10, 10, x)+rnorm(20,0,0.01) r1= nls( y~ a+b*pmin(c,x), start=list(a=2, b=3, c=10), trace=TRUE )

0.002142 : 2 3 10 0.002115 : 2.004 3.000 10.000 0.002114 : 2.006 2.999 10.001 0.002084 : 2.005 2.999 10.000 ... 0.002079 : 2.005 2.999 10.000 Error in nls(y ~ a + b * pmin(c, x), start = list(a = 2, b = 3, c = 10), : step factor 0.000488281 reduced below 'minFactor' of 0.000976562

strange error, but unrelated to my question. will figure this one out next.

regards,

/iaw

On Tue, May 4, 2010 at 3:40 PM, David Winsemius <dwin...@comcast.net> wrote:

On May 4, 2010, at 3:33 PM, ivo welch wrote:

Dear R experts---I would like to estimate a non-linear least squares expression that looks something like

?y ~ a+b*min(c,x)

where a, b, and c are the three parameters. ?how do I define a min function in the formula language of R? ?advice appreciated.

?pmin

sincerely,

/iaw

David Winsemius, MD West Hartford, CT

------------------------------

Message: 78 Date: Tue, 4 May 2010 15:57:05 -0400 From: Gabor Grothendieck <ggro...@gmail.com> To: ivo welch <ivo....@gmail.com> Cc: r-help <r-h...@stat.math.ethz.ch> Subject: Re: [R] R formula language---a min and max function? Message-ID: <u2g9...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1

You need to use set.seed first so that your example is reproducible. Using set.seed(1) there is no error:

set.seed(1) x=1:20 y= 2+3*ifelse(x>10, 10, x)+rnorm(20,0,0.01) r1= nls( y~ a+b*pmin(c,x), start=list(a=2, b=3, c=10), trace=TRUE )

0.001657260 : 2 3 10 0.00153709 : 1.998312 3.000547 9.999568 0.001509616 : 1.996222 3.001117 9.998197 0.001509616 : 1.996222 3.001117 9.998197

r1

Nonlinear regression model model: y ~ a + b * pmin(c, x) data: parent.frame() a b c 1.996 3.001 9.998 residual sum-of-squares: 0.001510

Number of iterations to convergence: 3 Achieved convergence tolerance: 3.195e-09

On Tue, May 4, 2010 at 3:52 PM, ivo welch <ivo....@gmail.com> wrote:

thank you, david. ?indeed. ?works great (almost). ?an example for anyone else googling this in the future:

x=1:20 y= 2+3*ifelse(x>10, 10, x)+rnorm(20,0,0.01) r1= nls( y~ a+b*pmin(c,x), start=list(a=2, b=3, c=10), trace=TRUE )

0.002142 : ? 2 ?3 10 0.002115 : ? 2.004 ?3.000 10.000 0.002114 : ? 2.006 ?2.999 10.001 0.002084 : ? 2.005 ?2.999 10.000 ... 0.002079 : ? 2.005 ?2.999 10.000 Error in nls(y ~ a + b * pmin(c, x), start = list(a = 2, b = 3, c = 10), ?: ?step factor 0.000488281 reduced below 'minFactor' of 0.000976562

strange error, but unrelated to my question. ?will figure this one out next.

regards,

/iaw

On Tue, May 4, 2010 at 3:40 PM, David Winsemius <dwin...@comcast.net> wrote:

On May 4, 2010, at 3:33 PM, ivo welch wrote:

?y ~ a+b*min(c,x)

where a, b, and c are the three parameters. ?how do I define a min function in the formula language of R? ?advice appreciated.

?pmin

sincerely,

/iaw

David Winsemius, MD West Hartford, CT

------------------------------

Message: 79 Date: Tue, 4 May 2010 15:59:58 -0400 From: David Winsemius <dwin...@comcast.net> To: ivo welch <ivo....@gmail.com> Cc: r-help <r-h...@stat.math.ethz.ch> Subject: Re: [R] R formula language---a min and max function? Message-ID: <44C0...@comcast.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On May 4, 2010, at 3:52 PM, ivo welch wrote:

thank you, david. indeed. works great (almost). an example for anyone else googling this in the future:

x=1:20 y= 2+3*ifelse(x>10, 10, x)+rnorm(20,0,0.01) r1= nls( y~ a+b*pmin(c,x), start=list(a=2, b=3, c=10), trace=TRUE )

0.002142 : 2 3 10 0.002115 : 2.004 3.000 10.000 0.002114 : 2.006 2.999 10.001 0.002084 : 2.005 2.999 10.000 ... 0.002079 : 2.005 2.999 10.000 Error in nls(y ~ a + b * pmin(c, x), start = list(a = 2, b = 3, c = 10), : step factor 0.000488281 reduced below 'minFactor' of 0.000976562

strange error, but unrelated to my question. will figure this one out next.

I get no error. May be difficult to sort out unless you can reproduce after setting a random seed.

0.001560045 : 2 3 10 0.001161253 : 2.003824 2.998973 10.000388 0.001161253 : 2.003824 2.998973 10.000388

-- David.

regards,

/iaw

On Tue, May 4, 2010 at 3:40 PM, David Winsemius <dwin...@comcast.net

wrote:

On May 4, 2010, at 3:33 PM, ivo welch wrote:

y ~ a+b*min(c,x)

where a, b, and c are the three parameters. how do I define a min function in the formula language of R? advice appreciated.

?pmin

sincerely,

/iaw

David Winsemius, MD West Hartford, CT

David Winsemius, MD West Hartford, CT

------------------------------

Message: 80 Date: Tue, 04 May 2010 16:09:23 -0400 From: Michael Friendly <frie...@yorku.ca> To: R-Help <r-h...@stat.math.ethz.ch> Subject: [R] rgl: plane3d or abline() analog Message-ID: <4BE0...@yorku.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

For use with rgl, I'm looking for a function to draw a plane in an rgl scene that would function sort of like abline(a, b) does in base graphics, where abline(0, 1) draws a line of unit slope through the origin. Analogously, I'd like to have a plane3d function, so that plane3d(0, 1, 1) draws a plane through the origin with unit slopes in x & y and plane3d(3, 0, 0) draws a horizontal plane at z=3.

I see that scatterplot3d in the scatterplot3d package returns a plane3d() *function* for a given plot. I could probably try to adapt this, but before I do, I wonder if something like this for rgl exists that I haven't found.

-Michael

-- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Street http://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA

------------------------------

Message: 81 Date: Tue, 4 May 2010 16:19:34 -0400 From: David Winsemius <dwin...@comcast.net> To: Michael Friendly <frie...@yorku.ca> Cc: R-Help <r-h...@stat.math.ethz.ch> Subject: Re: [R] rgl: plane3d or abline() analog Message-ID: <B2DB...@comcast.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

On May 4, 2010, at 4:09 PM, Michael Friendly wrote:

For use with rgl, I'm looking for a function to draw a plane in an rgl scene that would function sort of like abline(a, b) does in base graphics, where abline(0, 1) draws a line of unit slope through the origin. Analogously, I'd like to have a plane3d function, so that plane3d(0, 1, 1) draws a plane through the origin with unit slopes in x & y and plane3d(3, 0, 0) draws a horizontal plane at z=3.

I see that scatterplot3d in the scatterplot3d package returns a plane3d() *function* for a given plot. I could probably try to adapt this, but before I do, I wonder if something like this for rgl exists that I haven't found.

?quads3d

-Michael

David Winsemius, MD West Hartford, CT

------------------------------

Message: 82 Date: Tue, 4 May 2010 14:20:59 -0600 From: Greg Snow <Greg...@imail.org> To: Richard and Barbara Males <rbma...@gmail.com> Cc: "r-h...@r-project.org" <r-h...@r-project.org> Subject: Re: [R] generating correlated random variables from different distributions Message-ID: <B37C...@LP-EXMBVS10.CO.IHC.COM> Content-Type: text/plain; charset="iso-8859-1"

Transforming variables will generally change the correlation, so your method

will give you correlated variables, but not exactly at the correlations you

specify (though with some trial and error you may be able to get close). If you

are happy with those results, then your problem is solved, if you need more

control over the relationship then something like the Gibbs sample may be what

you need.

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

-----Original Message----- From: Richard and Barbara Males [mailto:rbma...@gmail.com] Sent: Sunday, May 02, 2010 1:37 PM To: Greg Snow Cc: r-h...@r-project.org Subject: Re: [R] generating correlated random variables from different distributions

Thank you for your reply. The application is a Monte Carlo simulation in environmental planning. Different possible remediation measures have different costs, and produce different results. For example, a $20,000 plan may add 10 acres of wetlands and 12 acres of bird habitat. The desire is to describe the uncertainty in the cost and the outputs (acres of wetlands, acres of bird habitat) by distributions. The cost may be described by a normal distribution, mean $20k, $5k SD, and the 12 acres of birds may be described by a uniform distribution (10 to 14). [These are just examples, not representative of a real problem]. We may know (or think) that wetlands and bird habitat are positively correlated (0.6), and that there is a stronger correlation of both with cost (0.85). So the effort is to generate, through MCS, values at each iteration of cost, acres of wetland, and acres of bird habitat, such that the resultant values give the same correlation, and the values of cost, bird habitat and wetland habitat return the input distributions. The overall desire is compare different remediation measures, taking into account uncertainty in costs and results.

One possible approach (although I have not tried it yet, but will do so in the near future) is to generate, for each iteration, three independent (0,1) random variables, correlate them via the Cholesky approach, and use them as input to the inverse normal, inverse uniform, etc. to get the three variables for each iteration. The primary distributions of interest are normal, uniform, triangular, gamma, and arbitrary cdf, so this approach seems plausible in that inverse distributions are readily available.

Thanks in advance.

Dick Males Cincinnati, OH, USA

On Thu, Apr 29, 2010 at 12:31 PM, Greg Snow <Greg...@imail.org> wrote:

The method you are using (multiply by cholesky) works for normal

distributions, but not necessarily for others (if you want different means/sd, then add/multiply after transforming).

For other distributions this process can sometimes give the

correlation you want, but may change the variable(s) to no longer have the desired distribution.

The short answer to your question is "It Depends", the full long

answer could fill a full semester course. ?If you tell us more of your goal we may be able to give a more useful answer. ?The copula package is one possibility. ?If you know the conditional distribution of each variable given the others then you can use gibbs sampling.

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

-----Original Message----- From: r-he...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Richard and Barbara Males Sent: Thursday, April 29, 2010 9:18 AM To: r-h...@r-project.org Subject: [R] generating correlated random variables from different distributions

I need to generate a set of correlated random variables for a Monte Carlo simulation. ? The solutions I have found (http://www.stat.uiuc.edu/stat428/cndata.html, http://www.sitmo.com/doc/Generating_Correlated_Random_Numbers), using Cholesky Decomposition, seem to work only if the variables come from the same distribution with the same parameters. ?My situation is that each variable may be described by a different distribution (or different parameters of the same distribution). ?This approach does not seem to work, see code and results below. ?Am I missing something here? ?My math/statistics is not very good, will I need to generate correlated uniform random variables on (0,1) and then use the inverse distributions to get the desired results I am looking for? ?That is acceptable, but I would prefer to just generate the individual distributions and then correlate them. ?Any advice much appreciated. Thanks in advance

R. Males Cincinnati, Ohio, USA

Sample Code: # Testing Correlated Random Variables

# reference http://www.sitmo.com/doc/Generating_Correlated_Random_Numbers # reference http://www.stat.uiuc.edu/stat428/cndata.html # create the correlation matrix corMat=matrix(c(1,0.6,0.3,0.6,1,0.5,0.3,0.5,1),3,3) cholMat=chol(corMat) # create the matrix of random variables set.seed(1000) nValues=10000

# generate some random values

matNormalAllSame=cbind(rnorm(nValues),rnorm(nValues),rnorm(nValues))

matNormalDifferent=cbind(rnorm(nValues,1,1.5),rnorm(nValues,2,0.5),rnor

m(nValues,6,1.8))

matUniformAllSame=cbind(runif(nValues),runif(nValues),runif(nValues))

matUniformDifferent=cbind(runif(nValues,1,1.5),runif(nValues,2,3.5),run

if(nValues,6,10.8))

# bind to a matrix print("correlation Matrix") print(corMat) print("Cholesky Decomposition") print (cholMat)

# test same normal

resultMatNormalAllSame=matNormalAllSame%*%cholMat print("correlation matNormalAllSame") print(cor(resultMatNormalAllSame))

# test different normal

resultMatNormalDifferent=matNormalDifferent%*%cholMat print("correlation matNormalDifferent") print(cor(resultMatNormalDifferent))

# test same uniform resultMatUniformAllSame=matUniformAllSame%*%cholMat print("correlation matUniformAllSame") print(cor(resultMatUniformAllSame))

# test different uniform resultMatUniformDifferent=matUniformDifferent%*%cholMat print("correlation matUniformDifferent") print(cor(resultMatUniformDifferent))

and results

[1] "correlation Matrix" ? ? ?[,1] [,2] [,3] [1,] ?1.0 ?0.6 ?0.3 [2,] ?0.6 ?1.0 ?0.5 [3,] ?0.3 ?0.5 ?1.0 [1] "Cholesky Decomposition" ? ? ?[,1] [,2] ? ? ?[,3] [1,] ? ?1 ?0.6 0.3000000 [2,] ? ?0 ?0.8 0.4000000 [3,] ? ?0 ?0.0 0.8660254 [1] "correlation matNormalAllSame" <== ok ? ? ? ? ? [,1] ? ? ?[,2] ? ? ?[,3] [1,] 1.0000000 0.6036468 0.3013823 [2,] 0.6036468 1.0000000 0.5005440 [3,] 0.3013823 0.5005440 1.0000000 [1] "correlation matNormalDifferent" <== no good ? ? ? ? ? [,1] ? ? ?[,2] ? ? ?[,3] [1,] 1.0000000 0.9141472 0.2676162 [2,] 0.9141472 1.0000000 0.2959178 [3,] 0.2676162 0.2959178 1.0000000 [1] "correlation matUniformAllSame" <== ok ? ? ? ? ? [,1] ? ? ?[,2] ? ? ?[,3] [1,] 1.0000000 0.5971519 0.2959195 [2,] 0.5971519 1.0000000 0.5011267 [3,] 0.2959195 0.5011267 1.0000000 [1] "correlation matUniformDifferent" <== no good ? ? ? ? ? [,1] ? ? ?[,2] ? ? ?[,3] [1,] 1.0000000 0.2312000 0.0351460 [2,] 0.2312000 1.0000000 0.1526293 [3,] 0.0351460 0.1526293 1.0000000

______________________________________________ R-h...@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.

------------------------------

Message: 83 Date: Tue, 04 May 2010 22:23:35 +0200 From: Tobias Verbeke <tobi...@openanalytics.eu> To: HB8 <hb8...@gmail.com> Cc: r-h...@r-project.org Subject: Re: [R] Agreement Message-ID: <4BE0...@openanalytics.eu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi Gr?goire,

HB8 wrote:

Has Lawrence Lin's code been ported to R? http://tigger.uic.edu/~hedayat/sascode.html<http://tigger.uic.edu/%7Ehedayat/sascode.html>

One of Lin's methods (CCC) is available in function epi.ccc of the epiR package.

Best, Tobias

------------------------------

Message: 84 Date: Tue, 4 May 2010 16:37:00 -0400 From: Alex Chelminsky <ache...@csc.com> To: r-h...@r-project.org Subject: [R] Error when invoking x11() Message-ID: <OFC9...@csc.com> Content-Type: text/plain; charset=US-ASCII

I'm running an instance of R under Solaris 10.(sun4u sparc). When I invoke the x11() interface, I get the following error:

x11()

Error in x11() : X11 module cannot be loaded In addition: Warning message: In x11() : unable to load shared library '/usr/local/lib/R/modules//R_X11.so': ld.so.1: R: fatal: libpangocairo-1.0.so.0: open failed: No such file or directory)

The module is not present in my environment. Is there anything I need to install for this to work?

Thanks

Alexander Chelminsky Principal CSC

GBS | p: +1 781 290 1620 | f: +1 781 890 1208 | m: +1 617 650 5453 | ache...@csc.com | www.csc.com

This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose.

------------------------------

Message: 85 Date: Tue, 4 May 2010 23:02:00 +0200 From: Joris Meys <jori...@gmail.com> To: jim holtman <jhol...@gmail.com> Cc: R mailing list <r-h...@r-project.org> Subject: Re: [R] Avoiding for-loop for splitting vector into subvectors based on positions Message-ID: <p2ob...@mail.gmail.com> Content-Type: text/plain

Thanks, works nicely. I have to do some clocking to see how much the improvement is, but I surely learnt again.

Attentive readers might have noticed my initial code contains an error. tmp <- x[pos2[i]:pos2[i+1]] should be: tmp <- x[pos2[i]:(pos2[i+1]-1)] off course...

On Tue, May 4, 2010 at 5:50 PM, jim holtman <jhol...@gmail.com> wrote:

Try this:

x <- 1:10 pos <- c(1,4,7) pat <- rep(seq_along(pos), times=diff(c(pos, length(x) + 1))) split(x, pat)

$`1` [1] 1 2 3 $`2` [1] 4 5 6 $`3` [1] 7 8 9 10

On Tue, May 4, 2010 at 11:29 AM, Joris Meys <jori...@gmail.com> wrote:

Dear all,

I'm trying to optimize code and want to avoid for-loops as much as possible. I'm applying a calculation on subvectors from a big one, and I get the subvectors by using a vector of starting positions:

x <- 1:10 pos <- c(1,4,7) n <- length(x)

I try to do something like this : pos2 <- c(pos, n+1)

out <- c() for(i in 1:n){ tmp <- x[pos2[i]:pos2[i+1]] out <- c(out, length(tmp)) }

Never mind the length function, I apply a far more complicated one. It's about the use of the indices in the for-loop. I didn't see any way of doing that with an apply, unless there is a very convenient way of splitting my vector in a list of the subvectors or so.

Anybody an idea? Cheers

-- Joris Meys Statistical Consultant

Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control

Coupure Links 653 B-9000 Gent

tel : +32 9 264 59 87 Jori...@Ugent.be

------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[alternative HTML version deleted]]

-- Jim Holtman Cincinnati, OH +1 513 646 9390

What is the problem that you are trying to solve?

-- Joris Meys Statistical Consultant

Coupure Links 653 B-9000 Gent

tel : +32 9 264 59 87 Jori...@Ugent.be

------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[alternative HTML version deleted]]

------------------------------

Message: 86 Date: Tue, 04 May 2010 23:05:17 +0200 From: Ruihong Huang <ruih...@wiwi.hu-berlin.de> To: r-h...@r-project.org Subject: [R] Two Questions on R (call by reference and pre-compilation) Message-ID: <4BE0...@wiwi.hu-berlin.de> Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"

Hi All,

I have two questions on R. Could you please explain them to me? Thank you!

1) When call a function, R typically copys the values to formal arguments (call by value). This is very cost, if I would like to pass a huge data set to a function. Is there any situations that R doesn't copy the data, besides pass data in an environment object.

2) Does R pre-compile the object function to binary when running "optim"? I experienced the R "optim" is much slower than the MATLAB "fmincon" function. I don't know MATLAB has done any pre-compilation on the script for object function or not. But perhaps, we can increase R performance by some sort of pre-compilation during running time.

Thanks in advance.

Best Regards, Ruihong

------------------------------

Message: 87 Date: Tue, 4 May 2010 14:07:55 -0700 (PDT) From: pdb <phi...@philbrierley.com> To: r-h...@r-project.org Subject: [R] timing a function Message-ID: <1273...@n4.nabble.com> Content-Type: text/plain; charset=us-ascii

Hi, I want to time how long a function takes to execute. Any clues on what to search for to achieve this?

Thanks in advance.

--
View this message in context:

http://r.789695.n4.nabble.com/timing-a-function-tp2126319p2126319.html
Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 88 Date: Tue, 04 May 2010 23:17:45 +0200 From: moha...@inserm.fr To: pdb <phi...@philbrierley.com> Cc: r-h...@r-project.org Subject: Re: [R] timing a function Message-ID: <2010...@imp.inserm.fr> Content-Type: text/plain; charset=UTF-8; DelSp="Yes"; format="flowed"

Hi,

? proc.time() for more help

regards Ml

pdb <phi...@philbrierley.com> a ?crit?:

Hi, I want to time how long a function takes to execute. Any clues on what to search for to achieve this?

Thanks in advance.

-- View this message in context: http://r.789695.n4.nabble.com/timing-a-function-tp2126319p2126319.html Sent from the R help mailing list archive at Nabble.com.

------------------------------

Message: 89 Date: Tue, 4 May 2010 17:25:19 -0400 From: ivo welch <ivo....@gmail.com> To: David Winsemius <dwin...@comcast.net> Cc: r-help <r-h...@stat.math.ethz.ch> Subject: Re: [R] R formula language---a min and max function? Message-ID: <x2j5...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1

thank you, david and gabor. very much appreciated. I should have thought of setting the seed. this was only an example, of course. alas, such intermittent errors could still be of concern to me, because I need to simulate this nls() to find out its properties under the NULL, so I can't easily tolerate errors. fortunately, I had the window still open, so getting my y's out was easy, and the rounded figures produce the same nls error.

cbind(x,round(y,3))

x y [1,] 1 5.017 [2,] 2 7.993 [3,] 3 11.014 [4,] 4 13.998 [5,] 5 17.003 [6,] 6 19.977 [7,] 7 23.011 [8,] 8 25.991 [9,] 9 29.003 [10,] 10 32.014 [11,] 11 31.995 [12,] 12 32.004 [13,] 13 32.012 [14,] 14 31.994 [15,] 15 31.998 [16,] 16 32.000 [17,] 17 32.009 [18,] 18 31.995 [19,] 19 32.000 [20,] 20 31.982

r1= nls( y~ a+b*pmin(c,x), start=list(a=2, b=3, c=10), trace=TRUE )

0.002138 : 2 3 10 0.002117 : 2.004 3.000 9.999 0.002113 : 2.006 2.999 10.001 0.002082 : 2.005 2.999 10.000 0.002077 : 2.005 2.999 10.000 0.002077 : 2.005 2.999 10.000 Error in nls(y ~ a + b * pmin(c, x), start = list(a = 2, b = 3, c = 10), : step factor 0.000488281 reduced below 'minFactor' of 0.000976562

I really don't care about this example, of course---only about learning how to avoid nls() from dying on me. so, any advice would be appreciated.

regards,

/iaw

On Tue, May 4, 2010 at 3:59 PM, David Winsemius <dwin...@comcast.net> wrote:

On May 4, 2010, at 3:52 PM, ivo welch wrote:

thank you, david. ?indeed. ?works great (almost). ?an example for anyone else googling this in the future:

0.002142 : ? 2 ?3 10 0.002115 : ? 2.004 ?3.000 10.000 0.002114 : ? 2.006 ?2.999 10.001 0.002084 : ? 2.005 ?2.999 10.000 ... 0.002079 : ? 2.005 ?2.999 10.000 Error in nls(y ~ a + b * pmin(c, x), start = list(a = 2, b = 3, c = 10), ?: ?step factor 0.000488281 reduced below 'minFactor' of 0.000976562

strange error, but unrelated to my question. ?will figure this one out next.

I get no error. May be difficult to sort out unless you can reproduce after setting a random seed.

0.001560045 : ? 2 ?3 10 0.001161253 : ? 2.003824 ?2.998973 10.000388 0.001161253 : ? 2.003824 ?2.998973 10.000388

-- David.

regards,

/iaw

On Tue, May 4, 2010 at 3:40 PM, David Winsemius <dwin...@comcast.net> wrote:

On May 4, 2010, at 3:33 PM, ivo welch wrote:

?y ~ a+b*min(c,x)

where a, b, and c are the three paramete