[R] C dll compilation + S Poetry example

2009-01-05 Thread Pedro Mardones
Dear all; Working with the following code extracted from the document S Poetry by Patrick Burns (from CRAN), I haven't been able to load the resulting dll into R. The code is basically the calculation of the quadratic form x'Qx: static double quad_form(double *Q, double *x, long n) { lon

Re: [R] RODBC connection die - using more than 1 Rgui/Rcmdr

2009-01-05 Thread jaey.ahn
Yes, I am aware of that. RODBC connection is automatically shutting down without any warnings or error message. (That's why I jotted down Oracle error message when trying to reconnect). I don't think it's a matter of Oracle since I've tested many query works simultaneously with multiple windows

Re: [R] How to capture multiple graph pages to .png ?

2009-01-05 Thread Mike Williamson
Deepayan, Oopps! You are correct. I read that entire entry (quite long) several times and somehow missed it. I guess I have the bad habit of going straight to the examples to better understand how the code works, and there are no examples that wrap print calls around the plots. Regardle

Re: [R] adding a curve with xaxs="i"

2009-01-05 Thread David Winsemius
See if this gets you closer to what you want. x1 <- c(1,2,3,4,5) x2 <- c(2,4,6,8,10) mod <- lm (x2~x1) hm <- function (x) (mod$coe[1]+x*mod$coe[2]) plot.new() # ... box() curve (hm,lty=1,xaxs="i", xlim=c(0,1), yaxs="i", xlab="", xaxt="n" ) Seemed as though the , add=TRUE, parameter was

[R] Package pdf problems

2009-01-05 Thread stephen sefick
I am checking a package with R CMD check and everything is fine until the pdf portion of the checking process and the errors documented at the end of this message happen. I have looked at the pdf that is created and the typesetting is not perfect, but it is acceptable (readable). I am no good at

Re: [R] Encoding Vector of Strings into Numerical Matrix

2009-01-05 Thread jim holtman
try this: > tags <- c("aaa", "ttt", "ccc", "gcc", "atn") > key <- c(a=0, c=1, g=2, t=3, n=0) > x <- t(sapply(strsplit(tags, ''), function(z) key[z])) > x a a a [1,] 0 0 0 [2,] 3 3 3 [3,] 1 1 1 [4,] 2 1 1 [5,] 0 3 0 On Mon, Jan 5, 2009 at 8:26 PM, Gundala Viswanath wrote: > Dear all, > > Gi

Re: [R] prblem with NA

2009-01-05 Thread Erik Iverson
Hello - kayj wrote: Hi all I have a data set with the total number of columns =ncol, and the total number of rows=nrow. I am trying to loop over the values and id the value is less than or equal to 100 to be changed to 1. if the value is greater than 100 , to be changed to 0. if NA , let X[i,j

Re: [R] prblem with NA

2009-01-05 Thread jim holtman
Try vectorizing instead of a loop: > da <- matrix(nrow=10,ncol=10) > n <- sample(1:100, 40) > da[n[1:20]] <- 99 > da[n[21:40]] <- 199 > X <- ifelse(is.na(da), NA, ifelse(da <= 100, 1, 0)) > > > X [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] NA NA NA NA NA1 NA NA

[R] Encoding Vector of Strings into Numerical Matrix

2009-01-05 Thread Gundala Viswanath
Dear all, Given such vector of array. tags <- c("aaa", "ttt", "ccc", "gcc", "atn") How can I obtain a matrix corresponding to it [,1] [,2] [,3] [1,]000 [2,]333 [3,]111 [4,]211 [5,]03 0 In principle: 1. Number of Column in matrix

Re: [R] How to capture multiple graph pages to .png ?

2009-01-05 Thread Deepayan Sarkar
On Mon, Jan 5, 2009 at 4:57 PM, Mike Williamson wrote: > Greg, others, > >Thanks for the info! I suspect you are right, Greg. > >The main issue, as Sundar Dorai-Raj (who posts here at times) told me in > person and you say indirectly below, is that the "levelplot" function > returns an ob

Re: [R] RODBC connection die - using more than 1 Rgui/Rcmdr

2009-01-05 Thread Duncan Murdoch
On 05/01/2009 6:42 PM, jaey.ahn wrote: Hi, I encounter a problem when using more than 1 Rgui/Rcmdr with RODBC connection. As I use more than 1 RODBC connection with multiple Rgui/Rcmdr windows, my network connection (including internet) is shutting down. Thus the only solution to fix (so far) i

Re: [R] How to capture multiple graph pages to .png ?

2009-01-05 Thread Mike Williamson
Greg, others, Thanks for the info! I suspect you are right, Greg. The main issue, as Sundar Dorai-Raj (who posts here at times) told me in person and you say indirectly below, is that the "levelplot" function returns an object and not a graph. I didn't really know what that *meant*, eve

[R] RODBC connection die - using more than 1 Rgui/Rcmdr

2009-01-05 Thread jaey.ahn
Hi, I encounter a problem when using more than 1 Rgui/Rcmdr with RODBC connection. As I use more than 1 RODBC connection with multiple Rgui/Rcmdr windows, my network connection (including internet) is shutting down. Thus the only solution to fix (so far) is to reboot the computer. I suppose ROD

[R] prblem with NA

2009-01-05 Thread kayj
Hi all I have a data set with the total number of columns =ncol, and the total number of rows=nrow. I am trying to loop over the values and id the value is less than or equal to 100 to be changed to 1. if the value is greater than 100 , to be changed to 0. if NA , let X[i,j]=NA. I ran into a pro

Re: [R] Error : unused arguments in pairs()

2009-01-05 Thread herwig
Dear Prof. Ripley, thanks for your reply. Unfortunately I still was not able to solve the problem. I tried it with the Iris data and you can find the code below: > panel.cor <- function(x, y, digits=2, prefix="", cex.cor) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)

[R] adding a curve with xaxs="i"

2009-01-05 Thread Valentina Kraus
I want the curve to touch the y axis like the curve touches the upper boundary. How can I eliminate the margin between axis and curve on the left side? x1 <- c(1,2,3,4,5) x2 <- c(2,4,6,8,10) mod <- lm (x2~x1) hm <- function (x) (mod$coe[1]+x*mod$coe[2]) plot.new() # ... box() curve (hm,lty=1,add=

Re: [R] the first and last observation for each subject

2009-01-05 Thread Kingsford Jones
whoops -- I left the group size unchanged so k became greather than the length of the group vector. When I increase the size to 1e7, sapply is faster until it gets to k = 1e6. warning: this takes awhile (particularly on my machine which seems to be using just 1 of it's 2 cpus) > for(k in 10^(1

Re: [R] R badly lags matlab on performance?

2009-01-05 Thread luke
On Sun, 4 Jan 2009, Stavros Macrakis wrote: On Sun, Jan 4, 2009 at 4:50 PM, wrote: On Sun, 4 Jan 2009, Stavros Macrakis wrote: On Sat, Jan 3, 2009 at 7:02 PM, wrote: R's interpreter is fairly slow due in large part to the allocation of argument lists and the cost of lookups of variables,

Re: [R] How to capture multiple graph pages to .png ?

2009-01-05 Thread Greg Snow
I suspect that the graph not printing when the if statement follows the command (even commented out), may be faq 7.22, you are making the R parser guess at what you want and sometimes it guesses correctly, and sometimes not. If you wrap your call to levelplot in a print function call, then R do

Re: [R] the first and last observation for each subject

2009-01-05 Thread Kingsford Jones
Here's some more timing's of Bill's function. Although in this example sapply has a clear performance advantage for smaller numbers of groups (k) , gm is substantially faster for k >> 1000: gm <- function(x, group){ # medians by group: o<-order(group, x) group <- group[o] x <- x[o] c

[R] read.mtp "file read error"

2009-01-05 Thread thomas . ruscitti
Hi, I tried for the first time the function read.mtp, and get a "file read error." Searching the archive didn't bring anything up on this. > read.mtp("junk.mtp") Error in read.mtp("junk.mtp") : file read error The file is a portable Minitab v15 file, numeric only. Of course there are workarou

Re: [R] Sweave data-figure coupling

2009-01-05 Thread Philipp Pagel
On Mon, Jan 05, 2009 at 01:52:00PM -0600, Sebastian P. Luque wrote: > <>= > layout(matrix(1:2, ncol=2)); par(mar=c(5, 4, 2, 1), cex=0.75) > matplot(thetas, cbind(prior, lik, post), type="l", lty=c(2, 1, 1), > xlab="theta", ylab="probability density") > lik <- dbinom(60, 100, thetas) > lik.p

Re: [R] help me

2009-01-05 Thread stephen sefick
Is this homework? Anyway, the attachment has been stripped off. Here is how to plot the function. fun <- function(x, y){ a <- 4 b <- x^2 d <- y^2 z <- a-b-d return(z) } a <- fun(seq(-1000,1000,1), seq(-1000,1000,1)) plot(a) #integration s

Re: [R] Sweave data-figure coupling

2009-01-05 Thread Sebastian P. Luque
On Mon, 05 Jan 2009 15:14:37 -0500, Duncan Murdoch wrote: [...] > You missed an @ after this chunk. If this is true in the original, > I'm surprised Sweave didn't report an error, but it probably ate up > the second chunk as part of the first. AFAIK there's no need to separate every chunk by "

Re: [R] Sweave data-figure coupling

2009-01-05 Thread Duncan Murdoch
On 1/5/2009 2:52 PM, Sebastian P. Luque wrote: Hi, With the following Sweave minimal file: ------ \documentclass{article} \usepackage{Sweave} \begin{document} <>= thetas <- seq(0, 1, by=0.001) prior <- rep(1, length(thetas

[R] help me

2009-01-05 Thread jolka sukyte
Hello, I am a student and I working with R. I want to ask you how to solve this integral which is shown in image attach with this letter. And how to draw this function z = 4 – x2 – y2 , width intervals x = ±1, y = ±1. Thank You. Yours sincerely, Jolanta

[R] Sweave data-figure coupling

2009-01-05 Thread Sebastian P. Luque
Hi, With the following Sweave minimal file: ------ \documentclass{article} \usepackage{Sweave} \begin{document} <>= thetas <- seq(0, 1, by=0.001) prior <- rep(1, length(thetas)) / length(thetas) lik <- dbinom(1, 1, thetas) l

Re: [R] transform R to C

2009-01-05 Thread Charles C. Berry
On Mon, 5 Jan 2009, Andreas Wittmann wrote: Dear R users, i would like to transform the following function from R-code to C-code and call it from R in order to speed up the computation because in my other functions this function is called many times. `dgcpois` <- function(z, lambda1, lamb

Re: [R] how specify lme() with multiple within-subject factors?

2009-01-05 Thread Douglas Bates
On Sun, Jan 4, 2009 at 5:28 PM, Bert Gunter wrote: > Folks: > >> Lme() is only able to work with nested random effects, not with crossed >> random effects. > > Not quite true. Crossed models **can** be done, albeit clumsily, via > pdMatrix objects: the Bates/Pinheiro book even contains an example

Re: [R] the first and last observation for each subject

2009-01-05 Thread William Dunlap
Arg, the 'sapply(...)' in the function was in the initial comment, gm <- function(x, group){ # medians by group: sapply(split(x,group),median) but someone's mailer put a newline before the sapply gm <- function(x, group){ # medians by group: sapply(split(x,group),median) so it got execute

Re: [R] error message of RODBC...

2009-01-05 Thread Prof Brian Ripley
No, error message from your ODBC driver ... Your table names are not valid SQL names. The details depend on the exact driver, but you could try omitting the final dollar. This may not work, in which case you may need to use an sqlQuery call. On Mon, 5 Jan 2009, giovanni parrinello wrote:

Re: [R] the first and last observation for each subject

2009-01-05 Thread hadley wickham
> Another application of that technique can be used to quickly compute > medians by groups: > > gm <- function(x, group){ # medians by group: > sapply(split(x,group),median) > o<-order(group, x) > group <- group[o] > x <- x[o] > changes <- group[-1] != group[-length(group)] > first <- whi

Re: [R] the first and last observation for each subject

2009-01-05 Thread William Dunlap
> -Original Message- > From: hadley wickham [mailto:h.wick...@gmail.com] > Sent: Sunday, January 04, 2009 8:56 PM > To: William Dunlap > Cc: gallon...@gmail.com; R help > Subject: Re: [R] the first and last observation for each subject > > >> library(plyr) > >> > >> # ddply is for splitt

Re: [R] How can pairs of values be stored in a 2D matrix ?

2009-01-05 Thread Stavros Macrakis
On Mon, Jan 5, 2009 at 6:30 AM, wrote: > My question is motivated by dealing with pairs of values, like (3,12.5), > (16,2.98), and so on > that are mapped to a cartesian plain (Time, Frequence) > I miss C multidimensional arrays. I am trying to simulate the 3rd dimension > by declaring a matri

Re: [R] strwidth to lines

2009-01-05 Thread Thomas Kaliwe
Why do you take 2.54? I think you forgot a bracket... #par(mar = c(max(strwidth(names(x)) * 2.54, 4,4,2)) # #should be par(mar = c(max(strwidth(names(x))) * 2.54, 4,4,5)) #and 5 would be a better value. But this is merely trial and error?! Regards Thomas Kaliwe Henrique Dallazuanna schrieb:

Re: [R] strwidth to lines

2009-01-05 Thread Henrique Dallazuanna
Try this: par(mar = c(max(strwidth(names(x)) * 2.54, 4,4,2)) barplot(x, las = 3) On Mon, Jan 5, 2009 at 2:15 PM, Thomas Kaliwe wrote: > Dear members, > > Is there a way to turn a strwidth of a string into a number of lines that > ist needed to display the string when using par(mar = c(?,4,4,2)

[R] strwidth to lines

2009-01-05 Thread Thomas Kaliwe
Dear members, Is there a way to turn a strwidth of a string into a number of lines that ist needed to display the string when using par(mar = c(?,4,4,2)) x = 1:5 names(x) = c("Z","Zz","ZZZl","T","Zzhtsddfg" ) par(mfrow = c(1,2)) par(mar = c(8,4,4,2)) barplot(x, las = 3

[R] How can pairs of values be stored in a 2D matrix ?

2009-01-05 Thread mauede
My question is motivated by dealing with pairs of values, like (3,12.5), (16,2.98), and so on that are mapped to a cartesian plain (Time, Frequence) I miss C multidimensional arrays. I am trying to simulate the 3rd dimension by declaring a matrix of lists. R seems to accept the definition of su

[R] exportPattern wiht perl expressions

2009-01-05 Thread Biczok Rudolf
Hi com, I'm writing an R extension which uses a NAMESPACE file. Well I want to export all objects which don't have an "prefix" as part of name. Something like: exportPattern("^(?!prefix).+?", perl = TRUE) but it does not work Is there any way to do this? Cheers Biczok

[R] error message of RODBC...

2009-01-05 Thread giovanni parrinello
channel <- odbcConnectExcel("nuova tabella terapia occupazionale mod.xls") > ## list the spreadsheets > sqlTables(channel) TABLE_CAT TABLE_SCHEM TABLE_NAME 1 c:\\TABELLE DEFINITIVE\\nuova tabella terapia occupazionale mod

Re: [R] R/octave/matlab etc.

2009-01-05 Thread luke
It is the_vectorized_ performance differences that may be in part explained by compiler settings. The interpreter overhead (not just loops) is not. luke On Mon, 5 Jan 2009, Denney, William S. wrote: Hello, I don't think that the large disparity in loop performance between Matlab, R, and Octa

Re: [R] Ratetable creation

2009-01-05 Thread Terry Therneau
> Can anyone can help me in creation ratetable object assuming, that I have > mortality rates organized in standard way by year, gender and age (0-99). Look at technical report #63, "Expected Survival Based on Hazard Rates", Department of Health Science Research, Mayo Clinic. You can find it on

Re: [R] R/octave/matlab etc.

2009-01-05 Thread Denney, William S.
Hello, I don't think that the large disparity in loop performance between Matlab, R, and Octave is explained by compilation time performance settings. For Octave, it is well known that loops perform poorly relative to Matlab (though many other operations perform better). The reason is that Matla

Re: [R] R Stacked Histogram

2009-01-05 Thread hadley wickham
On Sun, Jan 4, 2009 at 6:51 PM, Jason Rupert wrote: > Understood. Will head the warning about odd way to display data. > > Any recommendations about where I look to find full details about "qplot". > > I tried ?qplot, but it did not return full details. > > That description was missing a few item

[R] transform R to C

2009-01-05 Thread Andreas Wittmann
Dear R users, i would like to transform the following function from R-code to C-code and call it from R in order to speed up the computation because in my other functions this function is called many times. `dgcpois` <- function(z, lambda1, lambda2) { `f1` <- function(alpha, lambda1, lambda2

Re: [R] Spatial Statistics e-book.

2009-01-05 Thread Stefan Evert
Well, I suppose he might get away with it as long as said *Brian Ripley* doesn't read this list ... ;-) Sorry, couldn't resist, Stefan On 28 Dec 2008, at 21:07, stephen sefick wrote: Is that an appropriate request? On Sun, Dec 28, 2008 at 2:14 PM, Marcus Vinicius wrote: Dear R user´s,

Re: [R] if statement

2009-01-05 Thread Wacek Kusnierczyk
Duncan Murdoch wrote: > Shruthi Jayaram wrote: >> Hi, >> >> How do I check for two conditions in an if loop? I want to check if a >> value >> lies between 2 other values. >> > "if" isn't normally a loop, but what you want is the vectorized > version, the ifelse() function. >> For example, >> A <

[R] Odp: if statement

2009-01-05 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 05.01.2009 12:41:49: > > Hi, > > How do I check for two conditions in an if loop? I want to check if a value > lies between 2 other values. > > For example, > > A <- ts(rnorm(120), freq=12, start=c(1992,8)) > X <- 0.5 > Y <- 0.8 > > I would like

Re: [R] if statement

2009-01-05 Thread Carlos J. Gil Bellosta
Hello, If you do C <- A C[A > X & A < Y] <- 0 you get what it seems you want. Best regards, Carlos J. Gil Bellosta http://www.datanalytics.com On Mon, 2009-01-05 at 03:41 -0800, Shruthi Jayaram wrote: > A <- ts(rnorm(120), freq=12, start=c(1992,8)) > X <- 0.5 > Y <- 0.8 _

Re: [R] if statement

2009-01-05 Thread Duncan Murdoch
Shruthi Jayaram wrote: Hi, How do I check for two conditions in an if loop? I want to check if a value lies between 2 other values. "if" isn't normally a loop, but what you want is the vectorized version, the ifelse() function. For example, A <- ts(rnorm(120), freq=12, start=c(1992,8)) X

[R] if statement

2009-01-05 Thread Shruthi Jayaram
Hi, How do I check for two conditions in an if loop? I want to check if a value lies between 2 other values. For example, A <- ts(rnorm(120), freq=12, start=c(1992,8)) X <- 0.5 Y <- 0.8 I would like to create a new vector C for which C[i] is 0 if A[i] lies in between X and Y. Would be grate

Re: [R] eval using a environment X but resultsin .GlobalEnv

2009-01-05 Thread Duncan Murdoch
Saptarshi Guha wrote: Hello, Suppose I have an expression, E, which accesses some variables present in an environment V. I do this via eval(E,envir=V) however all assignments end up in V. I would like the results of assignments in E to end up in the .GlobalEnv ? Or at least the calling environmen

Re: [R] Process File Line By Line Without Slurping into Object

2009-01-05 Thread Duncan Murdoch
Gundala Viswanath wrote: Dear all, In general practice one would slurp the whole file using this method before processing the data: dat <- read.table(filename) or variations of it. Is there a way we can access the file line by line without slurping/storing them into object? I am thinking som

Re: [R] Introduction to R (in french)

2009-01-05 Thread Julien Barnier
Dear R users, > I recently put a new version of my french introduction to R online. It > is more specifically targeted at social sciences students and > researchers, but could be interesting for beginners who are not > really familiar with statistics and coding. > > The document is available (in f

Re: [R] Error : unused arguments in pairs()

2009-01-05 Thread Prof Brian Ripley
Your panel function should have a ... argument: see the help page for pairs(). Since your example is not 'self-contained' I cannot test this out On Sun, 4 Jan 2009, herwig wrote: Hi there, I am just starting in R and this might be a very basic question. I applied one on the examples o

[R] [R-pkgs] Rattle 2.4.0 (Data Mining GUI using R)

2009-01-05 Thread Graham Williams
Version 2.4.0 of Rattle has been released to CRAN. The rattle package (http://rattle.togaware.com) is a multi platform (GNU/Linux, Mac/OSX, MS/Windows) GTK based GUI for data mining (for exploring data and building descriptive and predictive models). It has undergone a lot of development over the