Re: [R] xtable - how to add a sum of values in a row column?

2009-09-28 Thread Ken-JP
I wonder if the right approach is to convert temp.ts into a matrix, add the column at the end, and then call xtable()... ...anyone have any suggestions? TIA. - Ken Ken-JP wrote: Hi, I saw this example for 2.10 Time series in the xtable gallery documentation. http://cran.r

Re: [R] xtable - how to add a sum of values in a row column?

2009-09-28 Thread Ken-JP
(as.data.frame(temp.table)), 2), digits = 0) On Sun, Sep 27, 2009 at 2:24 PM, Ken-JP kfmf...@gmail.com wrote: Hi, I saw this example for 2.10 Time series in the xtable gallery documentation. http://cran.r-project.org/web/packages/xtable/vignettes/xtableGallery.pdf How would I add a column at the end

[R] xtable - how to add a sum of values in a row column?

2009-09-27 Thread Ken-JP
Hi, I saw this example for 2.10 Time series in the xtable gallery documentation. http://cran.r-project.org/web/packages/xtable/vignettes/xtableGallery.pdf How would I add a column at the end Total which sums the row, with minimal changes to the code below? Thanks in advance. - Ken 2.10

[R] xtable formatting: RED for negative numbers?

2009-07-28 Thread Ken-JP
I've been experimenting recently with the fantastic Sweave/xtable combination for generating latex. In the xtable vignette, I found this great example of printing a ts object by months. Is there a way to modify this code to generate RED numbers inside xtable for negative results in x.ts?

Re: [R] Roxygen to ignore a block of code?

2009-06-21 Thread Ken-JP
For instance, I am trying to run Roxygen on: require( zoo ) # needed for time series setClass( zoo ) # lets S4 know about S3 class so we can use as an argument setClass( myClass, representation( .zoo=zoo ), prototype( 0, as.Date(1970-01-01) )) When I run this code through

[R] Roxygen to ignore a block of code?

2009-06-21 Thread Ken-JP
Any way to tell Roxygen to ignore a block of code? It is generating an unwanted .Rd file. I've been searching for hours for an example, scouring documentation, but no luck... Thanks. - Ken -- View this message in context:

[R] Roxygen vs Sweave for S4 documentation

2009-06-20 Thread Ken-JP
Hi, I have been using R for a while. Recently, I have begun converting my package into S4 classes. I was previously using Rdoc for documentation. Now, I am looking to use the best tool for S4 documentation. It seems that the best choices for me are Roxygen and Sweave (I am fine with tex).

Re: [R] How to get rid of loop? [SOLVED]

2009-04-27 Thread Ken-JP
Thanks, Uwe, Peter, and Ray, for taking the time to look into this. Just to wrap up this thread, and so that others may benefit, I tried writing both a R code version and an inline C version. Tested on a 8GB Ubuntu 64amd box, R 2.81, the speed difference was: 104secs vs 0.534secs, or the C

Re: [R] How to get rid of loop?

2009-04-26 Thread Ken-JP
The code below shows what I'm trying to get rid of. If there is no way to get rid of the loop, I will try to use package( inline ). I'm just curious as to whether there is a vector way of doing this algorithm. #

[R] How to get rid of loop?

2009-04-24 Thread Ken-JP
set.seed(1) x - runif(100) # I want to calculate y such that: # # 1. if x0.75, y - 1 # 2. else if x0.25, y - -1 # 3. else if y_prev==1 x0.5, y - 0 # 4. else if y_prev==-1 x0.5, y - 0 # 5. else y - y_prev # # 1. and 2. are directly doable without looping. # # How do I do 3.-5. without looping?

Re: [R] Out of memory issue

2009-04-24 Thread Ken-JP
Is your CSV file really that big? Have you passed the correct parameters to read.table()? For example, specified the correct sep=, parameter? If you've done everything correctly and are still running out of memory, maybe you need to go to 64-bit. R works great under 64-bit Ubuntu (8GB on my

[R] n-dimensional vector operations

2009-04-20 Thread Ken-JP
Let's start with a concrete case of n=3 dimensions. Along dimension x, I have a matrix of 5 vectors (each with ten rows) Along dimension y, I have a matrix of 3 vectors (each with ten rows) Along dimension z, I have a matrix of 2 vectors (each with ten rows) I am trying to write a:

Re: [R] n-dimensional vector operations

2009-04-20 Thread Ken-JP
Peter, Thank you for your array() hint for multi-dimensional matrices. Actually, my final answer should be of dimension 5,3,2 because my funcp(a,b,c) will be reduced to one number when I set a to a column of x, b to a column of y, and c to a column of z. I did make some useful observations,

Re: [R] Tinn-R (Version 2.2.0.2) dose not support R 2.9.0 very well

2009-04-18 Thread Ken-JP
Hi, I used Tinn-R for a long time, but had real headaches on Vista (commands not being sent, etc...) that were not resolved since R 2.8 or so. Since then, I have switched to Eclipse/StatET. The setup requires more effort, but it is much easier to manage your own packages. With the Eclipse IDE

[R] Need Help with R.oo and multiple inheritance

2009-04-18 Thread Ken-JP
This is what I'm trying to do: HasPersistence - an Interface class which implements things like WriteToDisk(), ReadFromDisk() B isA A C isA A, but also implements HasPersistence My solution in R.oo is to have a root class called A which implements IsPersistent() by returning FALSE, but is

[R] rnorm() converted to daily

2009-04-17 Thread Ken-JP
yearly 8% drift, 25% sd why are x and y so different (x and z look ok)? Does this have something to do with biases due to the relationship between population and sample-estimates as a function of n samples and sd? Or am I doing something wrong?

Re: [R] rnorm() converted to daily

2009-04-17 Thread Ken-JP
Hi Karl, Your comment is very interesting. Do you mean I should favor: rnorm(n, 0, 1) * b + a over rnorm(n, a, b) ? What is the proper/safe way to use rnorm()? FWIW, set.seed( 1 ); yy - mean( rnorm( 10 ) *

Re: [R] parse_Rd() Version 2 on Japanese Vista 32 (encoding problems)

2009-04-07 Thread Ken-JP
Hi Duncan, I tried \encoding{latin1} and it gave me the same result as \encoding{UTF-8} In other words, no errors, but I plenty of warnings from Warning in grep(^[[:blank:]]*\n?$, x, perl = TRUE) : perl = TRUE is only fully implemented in UTF-8 locales

[R] Need Help with StatET Error/Bug? on Ubuntu 8.10 amd64

2009-04-06 Thread Ken-JP
Hi, I posted this message on the StatET-user board last week, but it looks like a ghost-town... I have a bad feeling that there is some code in the plug-in which doesn't work well with my environment, but if I am lucky, maybe other users have worked around this problem somehow - I am hoping

Re: [R] Eclipse and StatET Howto (also added Subversion, Rtools)

2009-04-06 Thread Ken-JP
UPDATE on StatET and Ubuntu 8.10 amd64: StatET also works perfectly on Ubuntu 8.10 amd64, but the installation procedure takes a lot more effort than on XP Pro 32-bit or Vista 32-bit (at least from my experience). But I am very happy to have more RAM and having StatET working definitely helps

Re: [R] Need Help with StatET Error/Bug? on Ubuntu 8.10 amd64

2009-04-06 Thread Ken-JP
working on a 64-bit Windoze system, do please let us know. Thank you. - Ken John Fox-6 wrote: Dear Ken-JP, I'm not sure that this is relevant, but I posted a question recently to the StatET list about using StatET with 64 bit Vista (I don't yet have the machine), and was told that it would

[R] R package: Where to put code to Run Once Only?

2009-04-06 Thread Ken-JP
Is there a specific place where we can place code to run once only in a package? I have code that switches based on Sys.info()[[nodename]] - but since this just about never changes, I would like to run it only once when someone runs: require( mypackage ) or library( vte ) I'm tempted to have

Re: [R] R package: Where to put code to Run Once Only?

2009-04-06 Thread Ken-JP
Thanks to pointers from Uwe, I first tried zzz.R and .First.lib(), which does what I needed (initialize once). Then under Martin's suggestion, I converted the package to use NAMESPACE and .onLoad(). Using NAMESPACE, I was able to hide my globals behind a . (eg .myGlobal - 72) and use

[R] parse_Rd() Version 2 on Japanese Vista 32 (encoding problems)

2009-04-06 Thread Ken-JP
Hi, I need some help with 2.9.0 parse_Rd() Version 2 changes. I read the .pdf file and some posts on r-help, but after playing with this for several hours, I can't seem to get around this UTF-8 problem. - I'm trying to get rid of some warnings during R CMD Check for R 2.9.0Alpha on Japanese

Re: [R] R package: Where to put code to Run Once Only?

2009-04-06 Thread Ken-JP
Rolf Turner-3 wrote: On 7/04/2009, at 3:34 PM, Ken-JP wrote: snip Using NAMESPACE, I was able to hide my globals behind a . (eg .myGlobal - 72) and use exportPattern(^[^\\.]*) to prevent users from seeing my globals, yet I was able to access their values inside my package

Re: [R] Eclipse and StatET Howto (also added Subversion, Rtools)

2009-04-05 Thread Ken-JP
Peter Dalgaard wrote: Hum.. Fedora 9 doesn't have it either. It does have /usr/share/X11/rgb.txt though, so please check whether it has moved. I'm curious as to why (only) R/tcltk would be confused by this sort of thing. If you check here:

[R] (SOLVED) Re: [tcl] unknown color name red errors

2009-04-04 Thread Ken-JP
On the boards for Ubuntu 8.10 64-bit, there were comments along the lines that: /etc/X11/rgb.txt was missing. However, even after I replace this file, and logged back out in, this problem went away. It's shocking that a file as old/basic as /etc/X11/rgb.txt can be removed - I'm sure a lot

Re: [R] Eclipse and StatET Howto (also added Subversion, Rtools)

2009-04-04 Thread Ken-JP
An update: after several days of struggling, I got StatET to work on Ubuntu 8.10 amd64, R 2.8.1. Here are some tips: 1. You may run into an X11 issue with tktcl in R as someone decided to omit /etc/X11/rgb.txt If you get weird issues with your R installation with window colors like red or

Re: [R] Eclipse and StatET Howto (also added Subversion, Rtools)

2009-04-04 Thread Ken-JP
Yes, I have x11-common installed, and dpkg -S /etc/X11/rgb.txt shows not found for me. This is on Ubuntu 8.10 amd64. http://ubuntuforums.org/archive/index.php/t-59024.html Thanks for the detailed explanation on how R decides on where to install packages! I think I ran into problems when I

[R] [tcl] unknown color name red errors

2009-04-02 Thread Ken-JP
I am running on 64-bit Ubuntu, R version 2.8.1 If I do anything Tcl/Tk related like: library( Rcmdr ) or available.packages() I get the error: Error in structure(.External(dotTclObjv, objv, PACKAGE=tcltk), class = tclObj) : [tcl] unknown color name red

[R] Excellent Talk on Statistics (Good examples of stat. visualization)

2009-03-30 Thread Ken-JP
with very good examples of statistical visualization. Talks Hans Rosling: Debunking third-world myths with the best stats you've ever seen http://www.ted.com/index.php/talks/hans_rosling_shows_the_best_stats_you_ve_ever_seen.html -- View this message in context:

[R] Eclipse and StatET Howto (also added Subversion, Rtools)

2009-03-28 Thread Ken-JP
I recently got a RFC on Eclipse and StatET setup from a R-help user, so here it is. Note: there may be slight errors of omission in my directions as I am making these notes after I had a successful install. If you have questions post here. Setup tested with Eclipse 3.4.0 on XP 32-bit and

Re: [R] Error Running TinnR with R

2009-03-27 Thread Ken-JP
I had all these headaches with Tinn-R on Vista - tried reading all the message boards, reconfiguring .Rprofile, etc... ...no luck. I finally gave up and started using Eclipse with StatET. Now, it's actually easier to run RCMDs to check and release a package, and with SVN integration in

[R] Converting a Matrix to a Vector

2009-03-25 Thread Ken-JP
Say I have: set.seed( 1 ) m - matrix( runif(5^2), nrow=5, dimnames = list( c(A,B,C,D,E), c(O,P,Q,R,S) ) ) m O P Q R S A 0.2655087 0.89838968 0.2059746 0.4976992 0.9347052 B 0.3721239 0.94467527 0.1765568 0.7176185 0.2121425 C 0.5728534 0.66079779

[R] Doing %o% that operates on columns instead of atomics

2009-03-25 Thread Ken-JP
Okay, this one is hard to put into words: x - 1:9; names(x) - x y - x %o% x y 1 2 3 4 5 6 7 8 9 1 1 2 3 4 5 6 7 8 9 2 2 4 6 8 10 12 14 16 18 3 3 6 9 12 15 18 21 24 27 4 4 8 12 16 20 24 28 32 36 5 5 10 15 20 25 30 35 40 45 6 6 12 18 24 30 36 42 48 54 7 7 14 21 28 35 42

Re: [R] Doing %o% that operates on columns instead of atomics

2009-03-25 Thread Ken-JP
CORRECTION: my.foo - function( a, b ) { c - a - b; } #really more complex, but just to illustrate -- View this message in context: http://www.nabble.com/Doing--o--that-operates-on-columns-instead-of-atomics-tp22701363p22701400.html Sent from the R help mailing list archive at Nabble.com.

[R] performance: zoo's rollapply() vs inline

2009-03-23 Thread Ken-JP
zoo's rollapply() function appears to be extremely useful for plugging in a function on-the-fly to run over a window. With inline, there is a lot more coding and room for error, and the code is less portable because the user has to have R compiling set up or it won't work. However, rollapply()

Re: [R] 'require' equivalent for local functions

2009-03-22 Thread Ken-JP
I agree with Duncan. I used to do exactly what you did - source()ing data files inside a wrapper not unlike C #define wrappers, but it became a headache with more files and the files began looking more cluttered. It has taken me several days to learn about how create a package properly, along

[R] How to avoid switching on input type?

2009-03-21 Thread Ken-JP
Hi, I need some help improving this ugly code I wrote. I would like to shift forward a zoo object, matrix, ts, or list by shift items (default 1) and fill the holes with 0's. The code below works, but it looks ugly. I could write a function lag.zerofill() which calls the two functions below

[R] Problem with zoo and rbind() converting matrix to vector

2009-03-21 Thread Ken-JP
require( zoo ) inp - c( 5, 9, 4, 2, 1 ); m - zoo( cbind( inp ), as.Date(2003-02-01) + (0:(length(inp)-1))); dim( m ) # [1] 5 1 dim( m[1,,drop=FALSE] ) # [1] 1 1 - ok dim( lag( m, -1 )) # [1] 4 1 - ok dim( rbind( m[1,,drop=FALSE], lag(m,-1) )) # NULL - converted from zoo matrix to zoo

Re: [R] Problem with zoo and rbind() converting matrix to vector

2009-03-21 Thread Ken-JP
Thank you for your reply, but I am still confused. Let me clarify... ...my problem isn't with zoo-ness per se. With zoo objects, there appears to be zoo-matrices and zoo-vectors. My problem is this - I start with a zoo-matrix: x - m[1,,drop=FALSE] x inp 2003-02-01 5 is.matrix(

Re: [R] Problem with zoo and rbind() converting matrix to vector

2009-03-21 Thread Ken-JP
Hi Achim, That was a very quick reply/fix that got posted in between my reading and my response. I have downloaded your fix from: svn checkout svn://r-forge.r-project.org/svnroot/zoo for the HEAD revision and confirmed that it works as expected - I tested using the code I posted in the first