[R] mgcv stopped working mid-session

2012-02-25 Thread Bryan Althouse
Hello, I am working in R 2.13.2 GUI 1.42 Leopard build 32-bit (5910) on a MacBook Pro. I am working with a data frame of 22 columns and approximately 7,100 rows. I have been using the package scatter3d routinely to work similar data sets. However, when I tried to use scatter3d to work with this

[R] Help needed! Error in setwd(newdir) : cannot change working directory

2012-02-25 Thread ying chen
Hi Guys, I am new to R and just trying to write a small script to automate a couple commands. But I run into the setwd(): cannot change working directory. I googled a little bit and tried all fixes/suggestions with no success. Basically I have a script that works from inside a directory with my

Re: [R] How would you program an Adverse Events statistical table using R code?

2012-02-25 Thread Frank Harrell
As Ista and Rich have implied, graphics are better than tables for AEs. Also, statistical tests are not always of value here. For more, see http://www.ctspedia.org/do/view/CTSpedia/StatGraphHome and p. 47-53 of http://biostat.mc.vanderbilt.edu/wiki/pub/Main/StatGraphCourse/graphscourse.pdf. p.

Re: [R] Dealing with NAs in C

2012-02-25 Thread Rui Barradas
Hello, See section 5.10.3 of the R-exts.pdf. There are macros ISNA(x) and ISNAN(x) (only for 'double') and constants NA_INTEGER, NA_REAL, NA_LOGICAL and NA_STRING. > I am currently converting a lot of R code to C in order to make it more > efficient. A lot of the data involves NAs. As > the dat

Re: [R] Dealing with NAs in C

2012-02-25 Thread chris90nz
Thanks Rui, that was exactly what I was looking for! Have successfully implemented it and got rid of yet another loop! Cheers, Chris -- View this message in context: http://r.789695.n4.nabble.com/Dealing-with-NAs-in-C-tp4421377p4421532.html Sent from the R help mailing list archive at Nabble.co

Re: [R] assign same legend colors than in the grouped data plot

2012-02-25 Thread R. Michael Weylandt
Your code isn't reproducible...(note the "legend " block -- that's not code) and (if I had to guess) it looks like you are using attach(). Don't do that... What do you mean it doesn't work? You say something about plotting lines, but your "working" code (the first block) doesn't do that... If

Re: [R] How to deal with missing values when using Random Forrest

2012-02-25 Thread David Winsemius
On Feb 25, 2012, at 6:24 PM, kevin123 wrote: I am using the package Random Forrest to test and train a model, I aim to predict (LengthOfStay.days),: library(randomForest) model <- randomForest( LengthOfStay.days~.,data = training, + importance=TRUE, + keep.forest=TRUE + ) *This is a small

[R] How to deal with missing values when using Random Forrest

2012-02-25 Thread kevin123
I am using the package Random Forrest to test and train a model, I aim to predict (LengthOfStay.days),: > library(randomForest) > model <- randomForest( LengthOfStay.days~.,data = training, + importance=TRUE, + keep.forest=TRUE + ) *This is a small portion of the data frame: * *data(traini

[R] rugarch for GJR

2012-02-25 Thread nserdar
hi >From *uguarchfit()* output; *$sigma* values are same as above formulation: sigma(t-1)^2= omega1+ alpha1*return(t-1)^2 + gamma1* I(t-1)*return(t-1)^2 + beta1*sigma(t-1) Can I use output of $sigma ^2 instead of above formulation ? spec<-ugarchspec(variance.model = list(model = "gjrGARCH"

[R] Dealing with NAs in C

2012-02-25 Thread chris90nz
Hi. I am currently converting a lot of R code to C in order to make it more efficient. A lot of the data involves NAs. As the data is mainly integers > 0, I am just setting all NAs to 0 then sending it to the C code then resetting them to NAs again after the C program is done, to be compatible with

Re: [R] Telling plot() the max y value to expect when plotting one distribution and then using lines() to add more distributions

2012-02-25 Thread R. Michael Weylandt
I had never actually played with matplot before -- thanks for the great tip. Michael On Sat, Feb 25, 2012 at 7:39 PM, Peter Ehlers wrote: > See inline below. > > On 2012-02-25 12:40, R. Michael Weylandt wrote: >> >> I might (re-)format your code as follows -- others will make some >> different d

Re: [R] Telling plot() the max y value to expect when plotting one distribution and then using lines() to add more distributions

2012-02-25 Thread Peter Ehlers
See inline below. On 2012-02-25 12:40, R. Michael Weylandt wrote: I might (re-)format your code as follows -- others will make some different design decisions. This isn't the most efficient (more vectorization could be squeezed in there and it's arguably better to use apply statements but I'd ar

Re: [R] Help needed please

2012-02-25 Thread R. Michael Weylandt
Look at ?optim and example(optim) Michael On Sat, Feb 25, 2012 at 11:47 AM, Jaymin Shah wrote: > I was wondering how to make a function which minimises  a vector (a,b,c,d). > > I have an equation ( for simplicity) say its 5 -(3a+4b+6c+8d) and i want to > make this equation as small as possible.

Re: [R] Help needed please

2012-02-25 Thread Jaymin Shah
I was wondering how to make a function which minimises a vector (a,b,c,d). I have an equation ( for simplicity) say its 5 -(3a+4b+6c+8d) and i want to make this equation as small as possible. Thus need to find the values for a b c and d for which this happens. I know there is a function in r

Re: [R] Problem Removing Border Lines in Maps Package

2012-02-25 Thread jour4life
I'm sorry to ask this silly question so long after you posted this response. But I have also been trying to do this. What is the option to draw the outlines the same color as the fill? I'm also using the "spdep" and "maptools" libraries. I have shapefiles for Mexico (counties and read in the spatia

[R] embed a bitmap by link reference into a SVG image

2012-02-25 Thread Olivier Delrieu
I would like, in R, to embed a bitmap image /by link reference/ into a SVG plot image. Images may be included in an SVG by http://www.w3.org/TR/SVG/struct.html#ImageElementHrefAttribute link reference , or even http://en.wikipedia.org/wiki/Data_Uri data , for example: My objective is to redu

Re: [R] Finding name of variable supplied as function argument

2012-02-25 Thread Stephen Eglen
> I could of course do this the tedious way by simply entering > the name-strings "G1", "G2" as arguments as well as the variable > names G1, G2, in a call like > > meds3x3(G1,G2,"G1","G2") > > But I'd like to simply be able to pick up, within the function, > the names of the variables that were

Re: [R] Finding name of variable supplied as function argument

2012-02-25 Thread Ted Harding
[See in-line below] On 25-Feb-2012 ilai wrote: > On Sat, Feb 25, 2012 at 12:53 PM, Ted Harding > wrote: > >> I have defined >> a function med3x3() such that, given vectors X,Y, >> med3x3(X,Y) returns a 3x3 table > ... >> But I'd like to simply be able to pick up, within the function, >> the name

Re: [R] Finding name of variable supplied as function argument

2012-02-25 Thread ilai
On Sat, Feb 25, 2012 at 12:53 PM, Ted Harding wrote: > I have defined > a function med3x3() such that, given vectors X,Y, > med3x3(X,Y) returns a 3x3 table ... > But I'd like to simply be able to pick up, within the function, > the names of the variables that were used as arguments in the > func

Re: [R] Telling plot() the max y value to expect when plotting one distribution and then using lines() to add more distributions

2012-02-25 Thread R. Michael Weylandt
I might (re-)format your code as follows -- others will make some different design decisions. This isn't the most efficient (more vectorization could be squeezed in there and it's arguably better to use apply statements but I'd argue you'd loose clarity here) but I think it shows some useful R idio

[R] Finding name of variable supplied as function argument

2012-02-25 Thread Ted Harding
Greetings All. I want to do the following simple thing. I have defined a function med3x3() such that, given vectors X,Y, med3x3(X,Y) returns a 3x3 table where: Row 1: X > median(X) Row 2: X = median(X) Row 3: X < median(X) Col 1: Y < median(Y) Col 2: Y = median(Y) Col 3: Y > median(Y) (with inters

Re: [R] which is the fastest way to make data.frame out of a three-dimensional array?

2012-02-25 Thread Hans Ekbrand
First, thank you both Bert and Petr for your excellent answers. Berts solution seems somewhat faster, and Petrs is - in my opion at least - slightly more elegant. > foo <- rnorm(36 * 150 * 170) > dim(foo) <- c(36, 150, 170) > n <- dim(foo) > > system.time(my.df <- data.frame(dat = as.vector(foo

Re: [R] xpose4

2012-02-25 Thread Jeff Newmiller
Perhaps contact the maintainer maintainer("xpose4") --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live:

Re: [R] which is the fastest way to make data.frame out of a three-dimensional array?

2012-02-25 Thread Bert Gunter
Petr: Your expand.grid solution is clearly much better than my nonsense. It is just as fast (or faster) and is the far more sensible thing to do. For an array, ar, with dim(ar) = c(100,100,1000) , modifying your call slightly to: data.frame(c(ar),do.call(expand.grid,lapply(dim(ar),seq_len))) I

Re: [R] NaN's in class 'performance; [package "ROCR"]

2012-02-25 Thread Uwe Ligges
On 24.02.2012 17:41, Chet Seligman wrote: The first item in @ y.values is a NaN Slot "y.values": [[1]] [1] NaN 1.000 How do replace it with 1.00 or otherwise get rid of it? I wonder if you really want to do that,m but if so, you can replace it by: object@y.values[[1]][1] <

Re: [R] shell command with Robocopy error

2012-02-25 Thread Uwe Ligges
This is not an R question at all, but a robocopy question that you should ask its support. Anyway, a Google serach for robocopy exit codes returns: http://support.microsoft.com/kb/954404 Uwe Ligges On 24.02.2012 20:06, Aldo wrote: Also it copies the files, but I am using this as part of a l

Re: [R] which is the fastest way to make data.frame out of a three-dimensional array?

2012-02-25 Thread Petr Savicky
On Sat, Feb 25, 2012 at 04:54:30PM +0100, Hans Ekbrand wrote: > foo <- rnorm(30*34*12) > dim(foo) <- c(30, 34, 12) > > I want to make a data.frame out of this three-dimensional array. Each > dimension will be a variabel (column) in the data.frame. Hi. Try this n1 <- dim(foo)[1] n2 <- dim(f

Re: [R] which is the fastest way to make data.frame out of a three-dimensional array?

2012-02-25 Thread Petr Savicky
On Sat, Feb 25, 2012 at 08:07:01AM -0800, Bert Gunter wrote: > Cheat! Arrays are stored in column major order, so you can translate > the indexing directly by: > > Assume dim(yourarray) = c(n1,n2,n3) > > *** warning: UNTESTED ** > > yourframe <- data.frame( dat = as.vector(yourarray) > , dim1

Re: [R] Calling R code through VC.net

2012-02-25 Thread Uwe Ligges
On 25.02.2012 10:21, Xiongqing Zhang wrote: Hi, I try to use the visual studio 2008(VC.net) to call R code, This is not the Visual Studio support desk. Most of us do not even know how to call R code from Visual Studio. but there is en error: Exception from HRESULT: 0x80040013 Which is

Re: [R] remove multiple objects starting with same name

2012-02-25 Thread Uwe Ligges
On 25.02.2012 08:00, R. Michael Weylandt wrote: rm(list = ls(pattern = "object")) Or rm(list = ls(pattern = "^object")) since we know the names start woth "object". Uwe Michael On Fri, Feb 24, 2012 at 4:40 PM, katarv wrote: Hi, I'm trying to figure out syntax R function rm() needs

Re: [R] which is the fastest way to make data.frame out of a three-dimensional array?

2012-02-25 Thread Bert Gunter
Cheat! Arrays are stored in column major order, so you can translate the indexing directly by: Assume dim(yourarray) = c(n1,n2,n3) *** warning: UNTESTED ** yourframe <- data.frame( dat = as.vector(yourarray) , dim1 = rep(seq_len(n1), n2*n3 ,dim2 = rep( rep(seq_len(n2), e=n1), n3) , dim3 = rep(

[R] which is the fastest way to make data.frame out of a three-dimensional array?

2012-02-25 Thread Hans Ekbrand
foo <- rnorm(30*34*12) dim(foo) <- c(30, 34, 12) I want to make a data.frame out of this three-dimensional array. Each dimension will be a variabel (column) in the data.frame. I know how this can be done in a very slow way using for loops, like this: x <- rep(seq(from = 1, to = 30), 34) y <- as

[R] xpose4

2012-02-25 Thread xiaocong zuo
Hi, Dear all, When I run xpose4() in R and select "2: Basic goodness of fit plots", I get an error like this " Selection: 2Error in print(basic.gof(.cur.db)) : error in evaluating the argument 'x' in selecting a method for function 'print': Error in xvardef(v, object) : object '.cur.db' not fou

Re: [R] How to compare two curve model

2012-02-25 Thread Bert Gunter
You need to combine all the data into one set and add another variable, call it "dataset," with values 1 and 2. Then you can fit a model to this **one combined" dataset that has an additive term for "dataset," and, if you care to, test it for significance. However, as usual, that probably will not

Re: [R] lattice/seqplot group colors

2012-02-25 Thread Dieter Menne
Found it. Use level instead of groups. # seqplot bar coloring library(latticeExtra) d = data.frame(acid=letters[1:10],lwr=rnorm(10), essential=rep(c(TRUE,FALSE),each=5)) d$upr = d$lwr+1 # Works as expected barchart(acid~lwr,data=d, groups=essential, par.settings=

[R] lattice/seqplot group colors

2012-02-25 Thread Dieter Menne
I am trying to get segplot honor the groups parameter like barchart does. The below give an incorrect display for segplot. Any help? Dieter # seqplot bar coloring library(latticeExtra) d = data.frame(acid=letters[1:10],lwr=rnorm(10), essential=rep(c(TRUE,FALSE),each=5)) d$upr = d$

Re: [R] How would you program an Adverse Events statistical table using R code?

2012-02-25 Thread Ista Zahn
Hi Robert, I think you might find it helpful to start with http://biostat.mc.vanderbilt.edu/wiki/pub/Main/StatReport/summary.pdf Best, Ista On Friday, February 24, 2012 07:13:10 PM Robert Wilkins wrote: > A graph != A table. > I'm talking about a page full of summary statistics and advanced > s

Re: [R] Optim() package restriction

2012-02-25 Thread ilai
On Fri, Feb 24, 2012 at 4:03 PM, nserdar wrote: > I did it like above  but got an error message. > >> estimate<- optim(init.par,Linn,gr=NULL,method= "L-BFGS-B", >> hessian=FALSE,control = >> list(trace=1),lower=c(0,-Inf,Inf,Inf),upper=c(1,Inf,Inf,Inf)) Your lower bound for parameters 3,4 needs to

[R] dbWriteTable() command (package RPostgreSQL) does not accept append=TRUE statement

2012-02-25 Thread Cornelius Senf
Hey everyone! I try to convert severall raster files into a dataframe and then store them in a postegresql database using the RPostgreSQL package (see code example below). The for loop below should ideally attach each rasters dataframe to the existing table "modis" created with the first raste

Re: [R] RJava help

2012-02-25 Thread jesslim
i saw an example in http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg76159.html but an error occur Error in .jcall(“my_convolve”, “[D”, “convolve”, x, y) : RcallMethod: cannot determine object class because the directory of classpath? -- View this message in context: http://r.789695.n4.n

[R] How to compare two curve model

2012-02-25 Thread 孟欣
Hi all: I have two curve models: model1<-nls(result ~ exp(b0 + b1*(time)), start = list(b0 = 0, b1 = 5),trace=TRUE,data=data1) model2<-nls(result ~ exp(b0 + b1*(time)), start = list(b0 = 0, b1 = 5),trace=TRUE,data=data2) I wanna compare the two models to find out whether the difference betwe

Re: [R] RJava help

2012-02-25 Thread jesslim
u get the solution? if yes, please share it. i face same problem too -- View this message in context: http://r.789695.n4.nabble.com/RJava-help-tp2995886p4419945.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org maili

[R] how use rjava

2012-02-25 Thread jesslim
i set an example in http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg76159.html but an error occur Error in .jcall(“my_convolve”, “[D”, “convolve”, x, y) : RcallMethod: cannot determine object class because the directory of classpath? how solve it? -- View this message in context: http:

[R] Calling R code through VC.net

2012-02-25 Thread Xiongqing Zhang
Hi, I try to use the visual studio 2008(VC.net) to call R code, but there is en error:  Exception from HRESULT: 0x80040013 How can I fix the problem? Thanks.   My PC systern is XP, R version is "R-2.14.1" and "R_Scilab_DCOM3.0-1B5.exe".   best regards, Xiongqing [[alternative HTML versio

Re: [R] How would you program an Adverse Events statistical table using R code?

2012-02-25 Thread Richard M. Heiberger
Robert, Plase look at the ae.dotplot function in the HH package. AE (Adverse Events) dotplot of incidence and relative risk ## install.packages("HH") ## if necessary library(HH) ?ae.dotplot In addition to command line access to the function, we have direct access using RExcel from an Excel work

Re: [R] install rJava in Ubuntu 11.10

2012-02-25 Thread John Kane
John Kane Kingston ON Canada > -Original Message- > From: e...@debian.org > Sent: Sat, 25 Feb 2012 06:44:33 -0600 > To: jrkrid...@inbox.com > Subject: Re: [R] install rJava in Ubuntu 11.10 > > > On 24 February 2012 at 10:32, John Kane wrote: > | I am trying to install rJava on a WUBI

Re: [R] install rJava in Ubuntu 11.10

2012-02-25 Thread Dirk Eddelbuettel
On 24 February 2012 at 10:32, John Kane wrote: | I am trying to install rJava on a WUBI Ubuntu 11.10 installation of R with no luck. I was originally trying to install the iplots package and encountered this rJava problem. Just install the existing binary package, eg via sudo apt-get

Re: [R] B-spline/smooth.basis derivative matrices

2012-02-25 Thread vito.muggeo
dear s, If you are willing to use B-splines placing p knots, say, (rather than smoothing splines placing n knots), you could have a look to the functions splineDesign() or spline.des() (argument derivs) in the package "splines". vito On Fri, 24 Feb 2012 12:28:58 -0800 (PST), Vassily Shvets