[R] Question about foreach (with doSNOW), is that a bug?

2011-02-24 Thread Julian TszKin Chan
Hi all, Within a foreach loop with doSNOW, we cant call functions which come from the non-default package. We need to load(require/library) the package once more within the foreach loop. Anyone knows why would happen like this? Is it caused by the snow package and something happened when "snow" pa

[R] Interactive/Dynamic plots with R

2011-02-24 Thread Abhishek Pratap
Hi Guys In order to look at a dense plot I would like to have the capability to plot dynamic/interactive. Before I try rgobi which I heard can help me; I would like to take your opinion. Thanks! -Abhi __ R-help@r-project.org mailing list https://stat.e

[R] Creating objects (data.frames) with names stored in character vector

2011-02-24 Thread Kent Alleman
Hello, I'm fairly new to R. I'm a chemist, not a programmer so please bear with me. I have a large data.frame that I want to break down (subset) into smaller data.frames for analysis. I would like to give the data.frames descriptive names which I have stored in a character vector. My origina

[R] Calculate probabilty

2011-02-24 Thread Fabrice Tourre
Hi List, I have a question to calculate probability using R. There are 491 boxes and 142 balles. If the ball randomly put into the box. How to calculate the probability of six or more there are in one box? I have try : dbinom(6,142,1/491) 1-pbinom(6,142,1/491) But I think I have some unclear

[R] Markov chain transition model, data replication project

2011-02-24 Thread Eric R. Schmidt
Hello all, I am currently attempting to replicate data from a political science article that utilized a Markov chain transition model to predict voter turnout intention at time *t*; the data was separated into two different models based on whether prior intent was to vote or not to vote. The deta

Re: [R] Group rows by common ID and plot?

2011-02-24 Thread DB1984
In terms of a reproducible example: ProbeSet.ID.F ProbeSet.ID Feature.ID Gene.Symbol X0030V120810.4 X0143V120110.4 X0258V111710.4 X0283V111710.4 X0430V120710.4 X0472V111610.4 X0520V111610.4 X0546V113010.4 X0578V111810.4 X0624V111810.4 7896741_479302 7896741 479302 OR4F17

[R] accuracy of measurements

2011-02-24 Thread Denis Kazakiewicz
Dear R people Could you please help with following Trying to compare accuracy of tumor size evaluation by different methods. So data looks like id true metod1 method2 ... 1 22 2.5 2 1.5 2 2 3 22 2 etc. Could you please give a hint how to deal with that. Seems like

[R] BFGS versus L-BFGS-B

2011-02-24 Thread Brian Tsai
Hi all, I'm trying to figure out the effective differences between BFGS and L-BFGS-B are, besides the obvious that L-BFGS-B should be using a lot less memory, and the user can provide box constraints. 1) Why would you ever want to use BFGS, if L-BFGS-B does the same thing but use less memory? 2)

[R] Variable names AS variable names?

2011-02-24 Thread Noah Silverman
How can I dynamically use a variable as the name for another variable? I realize this sounds cryptic, so an example is best: #Start with an array of "codes" codes <- c("a1", "b24", "q99") #Each code has a corresponding matrix (could be vector) a1 <- matrix(rnorm(100), nrow=10) b24 <- matrix(rnor

Re: [R] problem in for loop

2011-02-24 Thread Jeff Newmiller
Notice that >mone-3 [1] -8.881784e-16 on my machine so, no, mone is actually less than 3, which truncates to 2. This is an overcomplicated version of R FAQ 7.31, which is mentioned in the posting guide referenced at the end of every R-help message. --

Re: [R] Plotting two time series with different frequencies

2011-02-24 Thread Gabor Grothendieck
On Thu, Feb 24, 2011 at 3:13 PM, Gabriel Bergin wrote: > Hi, > > I have two time series; one of annual data and one of monthly data. How do I > plot these on the same plot? I checked out ts.plot(), but it only allows for > different starting times, not different frequencies. > Try this assuming s

Re: [R] combining two columns into one column despite NAs

2011-02-24 Thread Andrew Anglemyer
Thanks for all the solutions! On Thu, Feb 24, 2011 at 5:37 PM, Sarah Goslee wrote: > What about: > > ifelse(is.na(x), y, x) > > as long as x and y are always the same where one is not NA. > > Sarah > > On Thu, Feb 24, 2011 at 7:53 PM, Andrew Anglemyer > wrote: > > Thanks! Unfortunately, in my

Re: [R] combining two columns into one column despite NAs

2011-02-24 Thread Sarah Goslee
What about: ifelse(is.na(x), y, x) as long as x and y are always the same where one is not NA. Sarah On Thu, Feb 24, 2011 at 7:53 PM, Andrew Anglemyer wrote: > Thanks!  Unfortunately, in my effort to simply the question, I didn't really > adequately describe the problem.  This solution is perf

Re: [R] combining two columns into one column despite NAs

2011-02-24 Thread Phil Spector
Andrew - I believe character.data$z = ifelse(is.na(character.data$x), character.data$y,character.data$x) should do what you want. - Phil Spector Statistical Computing Facility

Re: [R] combining two columns into one column despite NAs

2011-02-24 Thread Andrew Anglemyer
Thanks! Unfortunately, in my effort to simply the question, I didn't really adequately describe the problem. This solution is perfect in the numeric case I presented, but what about in the case of character classes! Let me try again: I have >character.data id xy 1

Re: [R] combining two columns into one column despite NAs

2011-02-24 Thread Ista Zahn
I think the easiest way is probably data$z <- rowMeans(data[, c("x", "y")], na.rm=TRUE) Best, Ista On Fri, Feb 25, 2011 at 12:12 AM, Andrew Anglemyer wrote: > I am trying to combine two columns in a data frame into one column.  Some > values in either column are missing, but not in the same row

[R] combining two columns into one column despite NAs

2011-02-24 Thread Andrew Anglemyer
I am trying to combine two columns in a data frame into one column. Some values in either column are missing, but not in the same row for the two different columns. Additionally, when both columns in a row contain data, the data are identical. I want a new column with the identical data or the d

Re: [R] How to calculate the perimeter and common border of polygons?

2011-02-24 Thread MacQueen, Don
I would suggest asking this question on r-sig-geo. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 2/18/11 10:44 AM, "Leonardo Monasterio" wrote: >Dear R-users, > >Is there any way of calculating the perimeter of a pol

Re: [R] Plotting a functional time series

2011-02-24 Thread Eduardo de Oliveira Horta
Thanks a lot! Regards, Eduardo On Thu, Feb 24, 2011 at 6:47 PM, David Winsemius wrote: > > On Feb 24, 2011, at 3:06 PM, Eduardo de Oliveira Horta wrote: > >> It seems the code I've sent had typos... >> >> Here's a corrected version: >> >> # >> x <- sapply(1:10, f

Re: [R] Plotting a functional time series

2011-02-24 Thread David Winsemius
On Feb 24, 2011, at 3:06 PM, Eduardo de Oliveira Horta wrote: It seems the code I've sent had typos... Here's a corrected version: # x <- sapply(1:10, function(i)rnorm(1000)) f <- sapply(1:10, function(i)density(x[,i], from=-5,to=5)$y) grid <- density(x[,1], fr

Re: [R] Fitting distributions with fitdistr

2011-02-24 Thread Peter Ehlers
On 2011-02-24 08:18, Andrea Storto wrote: Dear all, I am having troubles in using fitdistr() from MASS package to fit self-defined distributions. I try to use it in this simple example where I want to fit some data to a Gaussian+Flat distribution: gaussflat<-function(x,sd,k){ res<-x

Re: [R] Plotting a functional time series

2011-02-24 Thread David Winsemius
I'm not a Windows user, but if win.graph is like other output device calls, it would need a dev.off() to close it. When I do it with pdf() and close with dev.off() I get ten pages, each with a density that is consistent with what should be seen with rnorm() as input. -- David. On Feb 21,

Re: [R] The L Word

2011-02-24 Thread Claudia Beleites
On 02/24/2011 05:14 PM, Hadley Wickham wrote: Note however that I've never seen evidence for a *practical* difference in simple cases, and also of such cases as part of a larger computation. But I'm happy to see one if anyone has an interesting example. E.g., I would typically never use 0L:100L

Re: [R] Random Forest & Cross Validation

2011-02-24 Thread Liaw, Andy
Exactly as Max said. See the rfcv() function in the latest version of randomForest, as well as the reference in the help page for that function. OOB estimate is as accurate as CV estimate _if_ you run straight RF. Most other methods do not have this "feature". However, if you start adding ste

Re: [R] reshaping list into a contingency table

2011-02-24 Thread Henrique Dallazuanna
Try this: reshape(x, direction = 'long', varying = list(c(2, 4), c(3, 5)), idvar = 'gene') On Thu, Feb 24, 2011 at 3:19 PM, fbarreto wrote: > > Hi all, > > I have been struggling with this problem for a few days. > > I have a data table like this: > > gene rpkm1 diff1

[R] Plotting two time series with different frequencies

2011-02-24 Thread Gabriel Bergin
Hi, I have two time series; one of annual data and one of monthly data. How do I plot these on the same plot? I checked out ts.plot(), but it only allows for different starting times, not different frequencies. Sincerely, Gabriel Bergin gabr...@bergin.se [[alternative HTML version delete

Re: [R] Plotting a functional time series

2011-02-24 Thread Eduardo de Oliveira Horta
It seems the code I've sent had typos... Here's a corrected version: # x <- sapply(1:10, function(i)rnorm(1000)) f <- sapply(1:10, function(i)density(x[,i], from=-5,to=5)$y) grid <- density(x[,1], from=-5,to=5)$x win.graph() persp(grid, 1:10, f,theta=-50, phi=30, d

[R] parallel bootstrap linear model on multicore mac (re-post)

2011-02-24 Thread Anthony Dick
Hello all, I am re-posting my previous question with a simpler, more transparent, commented code. I have been ramming my head against this problem, and I wondered if anyone could lend a hand. I want to make parallel a bootstrap of a linear mixed model on my 8-core mac. Below is the process t

Re: [R] create dummy variables by for loop

2011-02-24 Thread Changbin Du
Thanks, Dimitri! It is really cool! On Thu, Feb 24, 2011 at 11:43 AM, Dimitri Liakhovitski < dimitri.liakhovit...@gmail.com> wrote: > If your ack$ID variable is numeric, you could first turn it into a factor: > > myfactor = as.factor(ack$ID) > > And then use model.matrix to create dummy variables

Re: [R] Help..Neural Network

2011-02-24 Thread Raji
Hi R-help, I am using nnet package in R for neural networks for performing classification and regression.Is there any command or set of commands in R which would help to figure out the variable importance of the inputs in the generated neural network. Thanks in advance. Regards, Raji -- View

[R] reshaping list into a contingency table

2011-02-24 Thread fbarreto
Hi all, I have been struggling with this problem for a few days. I have a data table like this: gene rpkm1 diff1 rpkm2 diff2 gene1 23 50 13 120 gene2 111 220 827 1200 gene3 7

Re: [R] Interpreting the example given by Prof Frank Harrell in {Design} validate.cph

2011-02-24 Thread vikkiyft
Dear Prof Frank, I tried to simulate an example data set as close as possible to my own real data with the codes below. There are only two covariates, tumor(3 levels) and ecog(3 levels). "rx" is treatment (4 levels). Validation with the stratified model (by rx) had a negative R2.. and the R2 unde

Re: [R] weighted Voronoi diagrams

2011-02-24 Thread rex.dwyer
One way to do Dirichlet triangulations is to map point (x,y) to point (x,y,x^2+y^2) (I think, it's been a while) and then find the convex hull of these points in 3 dimensions. You can do the Voronoi diagram of circles by mapping (x,y,r) to (x,y,x^2+y^2-r^2) I would try assigning an r to each

Re: [R] create dummy variables by for loop

2011-02-24 Thread Dimitri Liakhovitski
If your ack$ID variable is numeric, you could first turn it into a factor: myfactor = as.factor(ack$ID) And then use model.matrix to create dummy variables: mydummies = model.matrix(~myfactor)[, -1] You'll get as many dummy variables as values you have in ack$ID - minus 1 (for the reference lev

Re: [R] create dummy variables by for loop

2011-02-24 Thread Changbin Du
Thanks, David! On Thu, Feb 24, 2011 at 11:30 AM, David Winsemius wrote: > > On Feb 24, 2011, at 1:23 PM, Changbin Du wrote: > > HI, Dear R community, >> >> I try to create 100 dummy variables like the following: >> >> ack$id_1 <- (ack$ID==1)*1 >> ack$id_2 <- (ack$ID==2)*1 >> .. >> . >> ack$id_100

Re: [R] create dummy variables by for loop

2011-02-24 Thread David Winsemius
On Feb 24, 2011, at 1:23 PM, Changbin Du wrote: HI, Dear R community, I try to create 100 dummy variables like the following: ack$id_1 <- (ack$ID==1)*1 ack$id_2 <- (ack$ID==2)*1 .. . ack$id_100 <- (ack$ID==100)*1 I used the following codes: for(i in 1:100){ ack$id_[i] <- (ack$

Re: [R] create dummy variables by for loop

2011-02-24 Thread Changbin Du
Thanks to all, appreciated! On Thu, Feb 24, 2011 at 11:18 AM, Jonathan P Daily wrote: > See inline below. > -- > Jonathan P. Daily > Technician - USGS Leetown Science Center > 11649 Leetown Road > Kearneysville WV, 25430 > (304) 724-4480 > "Is the room still a

Re: [R] create dummy variables by for loop

2011-02-24 Thread Jonathan P Daily
See inline below. -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 "Is the room still a room when its empty? Does the room, the thing itself have purpose? Or do we, what's the word... imbue i

Re: [R] set argument of a function by string variable

2011-02-24 Thread David Winsemius
On Feb 24, 2011, at 1:03 PM, Duke wrote: Hi folks, I am wondering if the following is possible: I want to control the arguments sent to a function by string variables. For example, instead of > heatmap.2( A, col=greenred(75) ) I would want to have something like: > heatmap.2 ( paste(A, "c

[R] create dummy variables by for loop

2011-02-24 Thread Changbin Du
HI, Dear R community, I try to create 100 dummy variables like the following: ack$id_1 <- (ack$ID==1)*1 ack$id_2 <- (ack$ID==2)*1 .. . ack$id_100 <- (ack$ID==100)*1 I used the following codes: for(i in 1:100){ ack$id_[i] <- (ack$ID==i)*1 } But only one colum

Re: [R] The L Word

2011-02-24 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Martin Maechler > Sent: Thursday, February 24, 2011 7:45 AM > To: Claudia Beleites > Cc: r-help@r-project.org > Subject: Re: [R] The L Word > > > "CB" == Claudia Beleites >

Re: [R] set argument of a function by string variable

2011-02-24 Thread Peter Langfelder
On Thu, Feb 24, 2011 at 10:03 AM, Duke wrote: > Hi folks, > > I am wondering if the following is possible: I want to control the arguments > sent to a function by string variables. For example, instead of >> heatmap.2( A, col=greenred(75) ) > I would want to have something like: >> heatmap.2 ( pas

Re: [R] Boxplot not doing what I think it should

2011-02-24 Thread Greg Snow
Look at ?quantile, especially the detail section on "type" and the second reference (and the see also section). There are many different definitions of quantiles/quartiles and different functions use different versions. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Heal

[R] set argument of a function by string variable

2011-02-24 Thread Duke
Hi folks, I am wondering if the following is possible: I want to control the arguments sent to a function by string variables. For example, instead of > heatmap.2( A, col=greenred(75) ) I would want to have something like: > heatmap.2 ( paste(A, "col=greenred(75)", sep=",") ) Is this possible

Re: [R] The L Word

2011-02-24 Thread Martin Maechler
> "MM" == Martin Maechler > on Thu, 24 Feb 2011 18:34:36 +0100 writes: > "HW" == Hadley Wickham > on Thu, 24 Feb 2011 10:14:35 -0600 writes: >>> Note however that I've never seen evidence for a *practical* >>> difference in simple cases, and also of such cases as

[R] extract printed value from a function

2011-02-24 Thread Duarte Viana
Let me first thank you all for the replies. Actually I also tried the print() function, and indeed it did not work. The function capture.output() Peter said did the job. Thank you for sending the proposition for the new code to the maintainer. Duarte On Thu, Feb 24, 2011 at 4:51 PM, Martin Ma

Re: [R] problem in for loop

2011-02-24 Thread Sarah Goslee
You've fallen afoul of rounding error, FAQ 7.31 I believe, > rnorm(3, 0, 1) [1] -2.0903756 -0.9314351 0.1477768 but > rnorm(mone, 0, 1) [1] -0.8695359 -0.5429294 because mone is not actually three, but on my linux system a bit less. > mone == 3 [1] FALSE > mone < 3 [1] TRUE You could try >

Re: [R] problem in for loop

2011-02-24 Thread Ivan Calandra
Hi, It's FAQ 7.31 Try this: mone <- round(m-mzero) HTH, Ivan Le 2/24/2011 18:31, li li a écrit : Hi all. I was having some trouble with a for loop and I found the problem is the following. Does anyone have some idea why I got the following R result? Since mone is equal to 3, why mu1 on

Re: [R] Objects must be passed as an argument or generated in the function, right?

2011-02-24 Thread Duncan Murdoch
On 24/02/2011 9:59 AM, Jk Zheng wrote: Hi, I'm new to R, and found this code confusing. It is from the bioconductor package "RpsiXML". entryCount<- length(nodes) The "nodes" object is either the argument nor generated in the function. How can R find the "nodes" object? What am I missing h

Re: [R] The L Word

2011-02-24 Thread Martin Maechler
> "HW" == Hadley Wickham > on Thu, 24 Feb 2011 10:14:35 -0600 writes: >> Note however that I've never seen evidence for a *practical* >> difference in simple cases, and also of such cases as part of a >> larger computation. >> But I'm happy to see one if anyone has an

[R] problem in for loop

2011-02-24 Thread li li
Hi all. I was having some trouble with a for loop and I found the problem is the following. Does anyone have some idea why I got the following R result? Since mone is equal to 3, why mu1 only have 2 components? library(MASS) > p0 <- seq(0.1, 0.9,by=0.1) > m <- 10 > > > p0 <- p0[7] > > ## da

Re: [R] debugging

2011-02-24 Thread jim holtman
options(error=utils::recover) On Thu, Feb 24, 2011 at 12:06 PM, Yan Jiao wrote: > Dear R user > > > > How to make the program stop at the spot where the error occurs?  I mean > inside the iterations,. > > > > Many thanks > > > > yan > > > **

Re: [R] debugging

2011-02-24 Thread Rainer M Krug
On Thu, Feb 24, 2011 at 6:06 PM, Yan Jiao wrote: > Dear R user > > > > How to make the program stop at the spot where the error occurs?  I mean > inside the iterations,. > Check ?browser ?debug Rainer > > > Many thanks > > > > yan > > > **

[R] debugging

2011-02-24 Thread Yan Jiao
Dear R user How to make the program stop at the spot where the error occurs? I mean inside the iterations,. Many thanks yan ** This email and any files transmitted with it are confide...{{dropped:10}} __

[R] Boxplot not doing what I think it should

2011-02-24 Thread Lewis Berman
My box plot below is drawing its upper whisker all the way to the last point, instead of showing the point as an outlier. Am I misunderstanding, or is it a bug? Help(boxplot) states for the parameter “range” that “this determines how far the plot whiskers extend out from the box. If range is po

Re: [R] Running code sequentially from separate scripts (but not functions)

2011-02-24 Thread rex.dwyer
You don't need to write functions to "source" files: source("code1.R") source("code2.R") source("code3.R") When you source a file with a bunch of function definitions, the definitions are just assignment statements: f <- function (x)... g <- function (x,y,z) ... Did you think you would break y

[R] Objects must be passed as an argument or generated in the function, right?

2011-02-24 Thread Jk Zheng
Hi, I'm new to R, and found this code confusing. It is from the bioconductor package "RpsiXML". entryCount <- length(nodes) The "nodes" object is either the argument nor generated in the function. How can R find the "nodes" object? What am I missing here? Thanks Zheng Jk parseXmlEntryNod

Re: [R] Gaps in plotting temporal data.

2011-02-24 Thread rex.dwyer
If you're in a hurry, it's way easier than that: t <- c(1,2,3,7,8,9,11,12,13) x <- rnorm(length(t)) new.t <- min(t):max(t) new.x <- NULL new.x[t-min(t)+1] <- x plot(new.t, new.x, type='l') This is wastes max(t)-min(t)-length(t)+1 vector entries, but presumably you won't be wasting a lot of rea

[R] Fitting distributions with fitdistr

2011-02-24 Thread Andrea Storto
Dear all, I am having troubles in using fitdistr() from MASS package to fit self-defined distributions. I try to use it in this simple example where I want to fit some data to a Gaussian+Flat distribution: gaussflat<-function(x,sd,k){ res<-x res[ abs(x) <= k ] <- dnorm(x[ abs(x) <= k

[R] var:covariance matrix from glm using logit function

2011-02-24 Thread Christopher Dennis
I want to predict a set of proportions from a linear regression using glm. The model includes a logit link. However I want to extract the variance:covariance matrix among the predicted proportions rather than on the logit scale. Is there a way to do this using Vcov or a similar package in R?

[R] weighted Voronoi diagrams

2011-02-24 Thread Tuomas Aakala
Dear R-users, Does anyone know how to do weighted Voronoi diagrams (Dirichlet tesselation) in R? To be more specific, I have a set of coordinates for tree locations on a plot, and I'm looking for a way to do the tesselation so that the polygon size for each tree depends on the size of the sub

[R] MCMCpack combining chains

2011-02-24 Thread Alan Kelly
Deal all, as MCMClogit does not allow for the specification of several chains, I have run my model 3 times with different random number seeds and differently dispersed multivariate normal priors. For example: res1 = MCMClogit(y~x,b0=0,B0=0.001,data=mydat, burnin=500, mcmc=5500, seed=1234, thin=5

Re: [R] The L Word

2011-02-24 Thread Hadley Wickham
> Note however that I've never seen evidence for a *practical* > difference in simple cases, and also of such cases as part of a > larger computation. > But I'm happy to see one if anyone has an interesting example. > > E.g., I would typically never use  0L:100L  instead of 0:100 > in an R script b

Re: [R] Running code sequentially from separate scripts (but not functions)

2011-02-24 Thread Dimitri Liakhovitski
Thanks a lot, everyone! Honestly - I just did not know one could source everything and not just functions. What you wrote is simple, but pretty eye-opening for me (and extremely helpful)! Dimitri On Thu, Feb 24, 2011 at 10:51 AM, wrote: > You don't need to write functions to "source" files: > >

Re: [R] extract printed value from a function

2011-02-24 Thread Martin Maechler
> "PE" == Peter Ehlers > on Thu, 24 Feb 2011 07:07:29 -0800 writes: PE> On 2011-02-24 06:32, David Winsemius wrote: >> >> On Feb 24, 2011, at 7:22 AM, Peter Ehlers wrote: >> >>> On 2011-02-24 03:26, Duarte Viana wrote: Hello all, This

Re: [R] The L Word

2011-02-24 Thread Martin Maechler
> "CB" == Claudia Beleites > on Thu, 24 Feb 2011 12:31:55 +0100 writes: CB> On 02/24/2011 11:20 AM, Prof Brian Ripley wrote: >> On Thu, 24 Feb 2011, Tal Galili wrote: >> >>> Thank you all for the answers. >>> >>> So if I may extend on the question - >>> W

Re: [R] Running code sequentially from separate scripts (but not functions)

2011-02-24 Thread Jonathan P Daily
If you are just wanting to run them once, you can just do: source("code1.r") source("code2.r") source("code3.r") or place the file names in a vector, say 'filenames' and: sapply(filenames, source) If you want to use them multiple times, try: run1 <- parse("code1.r") run2 <- parse("code2.r") ru

Re: [R] Running code sequentially from separate scripts (but not functions)

2011-02-24 Thread Jeff Newmiller
You say you are aware that you can source them from a common script, yet you don't seem satisfied with that. Perhaps you could be more specific about why that solution is not satisfactory? One thing you said could indicate a misunderstanding... you do not have to wrap the code in functions bef

Re: [R] extract printed value from a function

2011-02-24 Thread David Winsemius
On Feb 24, 2011, at 10:07 AM, Peter Ehlers wrote: On 2011-02-24 06:32, David Winsemius wrote: On Feb 24, 2011, at 7:22 AM, Peter Ehlers wrote: On 2011-02-24 03:26, Duarte Viana wrote: Hello all, This shouldn't be difficult, but I am not able to extract a printed value from a function and

[R] Running code sequentially from separate scripts (but not functions)

2011-02-24 Thread Dimitri Liakhovitski
Hello! I am wondering if it's possible to run - in sequence - code that is stored in several R scripts. For example: Script in the file "code1.r" contains the code: a = 3; b = 5; c = a + b Script in the file "code2.r" contains the code: d = 10; e = d - c Script in the file "code3.r" contains th

Re: [R] extract printed value from a function

2011-02-24 Thread Keith Jewell
I don't think that third suggestion actually works: > x <- print( twotPermutation(c(2,3,4),c(3,6,5),plotit=F) ) [1] 0.289 NULL > x NULL twotPermutation returns the value of invisible() which is NULL: x <- print(invisible()) x This conflicts with the documented behaviour of twotPermutation which

Re: [R] extract printed value from a function

2011-02-24 Thread Peter Ehlers
On 2011-02-24 06:32, David Winsemius wrote: On Feb 24, 2011, at 7:22 AM, Peter Ehlers wrote: On 2011-02-24 03:26, Duarte Viana wrote: Hello all, This shouldn't be difficult, but I am not able to extract a printed value from a function and assign it to an object. In my case, library(DAAG)

Re: [R] boa library and plots

2011-02-24 Thread David Winsemius
On Feb 24, 2011, at 7:21 AM, emj83 wrote: Hi, I would like to save the plots produced by boa into postscript files in R. I am struggling- can anyone advise? ?postscript I see that Nabble omits the standard capitalized suggestion: PLEASE do read the posting guide http://www.R-project.

[R] J48 - contrasts can be applied only to factors with 2 or more levels

2011-02-24 Thread Patrick Skorupka
Hi everybody, I recently sent out a first message using this tool and was astonished about the quick and helpful replys. So, thank you in advance for your help, I really appreciate that! As already recently mentioned I am new to using R as I have to implement some decision trees with R respect

Re: [R] extract printed value from a function

2011-02-24 Thread David Winsemius
On Feb 24, 2011, at 7:22 AM, Peter Ehlers wrote: On 2011-02-24 03:26, Duarte Viana wrote: Hello all, This shouldn't be difficult, but I am not able to extract a printed value from a function and assign it to an object. In my case, library(DAAG) twotPermutation(c(2,3,4),c(3,6,5),plotit=F)

Re: [R] conditional seq

2011-02-24 Thread mathijsdevaan
Problem solved: DF = data.frame(read.table(textConnection("A B C D E 1 1 a 1999 1 0 2 1 b 1999 0 1 3 1 c 1999 0 1 4 1 d 1999 1 0 5 2 c 2001 1 0 6 2 d 2001 0 1 7 3 a 2004 0 1 8 3 b 2004 0 1 9 3 d 2004 0 1 10 4 b 2001 1 0 11 4 c 2001 1

[R] rpanel rp.tkrplot: x&y when using layout

2011-02-24 Thread Philip Wilson
Hi all, I wish to use rp.tkrplot from the rpanel package with subplots produced by layout or split.screen. My problem is that I want to use a click function, but I can't work out how to convert the x and y values it produces into the values on the plots as unlike for a single plot they don't

[R] clog-log based heckit?

2011-02-24 Thread Daniel McDowell
Dear R Help, I'm using the sampleSelection library to run a heckman model. The default is to use a probit model for the selection equation. I would like to know if it is possible to use a clog-log for the selection equation either with the sampleSelection library or in a different way. Is this pos

[R] changeLOS package use

2011-02-24 Thread kende jan
Hello, I am training to use the changeLOS package. Using data provided in this package (los.data), I want to generate a new plot with overlaying 2 curves of transition probability P01 and P03 and also statistically compare the two curves like the Kaplan-Meier Method.Can someone help me ?

[R] boa library and plots

2011-02-24 Thread emj83
Hi, I would like to save the plots produced by boa into postscript files in R. I am struggling- can anyone advise? Thanks Emma -- View this message in context: http://r.789695.n4.nabble.com/boa-library-and-plots-tp3322508p3322508.html Sent from the R help mailing list archive at Nabble.com.

[R] nlme correlation structure

2011-02-24 Thread Liliana Forzani
Dear all: i have the following problem I use gls, I have 10 repeated meassures. The 10 by 10 matrix has different variances in the diagonal (i know how to handle that) The correlation matrix is blocked: the first 3 repeated meassures have the same correlation, the next 4 have the same correlat

Re: [R] Invalid input error in tm package

2011-02-24 Thread Kutsal Yesilkagit
Dear Shreyasee, I had exactly the same error message. I converted the pdf-files into plain textfiles and reran the command without any problems. I'm no expert but the problem must be with the readability of the filetype. Kind regards Kutsal -- View this message in context: http://r.789695.n4.

Re: [R] Gaps in plotting temporal data.

2011-02-24 Thread Duncan Murdoch
On 24/02/2011 7:38 AM, Christos Delivorias wrote: I'm trying to plot some temporal data that have some gaps in them. You can see the plot here: http://www.tiikoni.com/tis/view/?id=da222e2. The problem is that during the time gaps in the TS the line plot is interpolated over the gap and I don't w

[R] Gaps in plotting temporal data.

2011-02-24 Thread Christos Delivorias
I'm trying to plot some temporal data that have some gaps in them. You can see the plot here: http://www.tiikoni.com/tis/view/?id=da222e2. The problem is that during the time gaps in the TS the line plot is interpolated over the gap and I don't want it to. I've tried interleaving the gaps with an

Re: [R] extract printed value from a function

2011-02-24 Thread Peter Ehlers
On 2011-02-24 03:26, Duarte Viana wrote: Hello all, This shouldn't be difficult, but I am not able to extract a printed value from a function and assign it to an object. In my case, library(DAAG) twotPermutation(c(2,3,4),c(3,6,5),plotit=F) [1] 0.298 I would like to assign this result to an

Re: [R] repeated execution of svm(e1071) gives different results, if weights are use and if probability = TRUE is set

2011-02-24 Thread Juergen Rose
Am Mittwoch, den 23.02.2011, 18:12 +0100 schrieb Juergen Rose: > class.weights=Wts, I have just seen, that me last code was not complete. I try it once more: > library(e1071)> data(Glass, package = "mlbench") > index <- 1:nrow(Glass) > testindex <- sample(index, trunc(length(index)/5)) > testset

Re: [R] Removing -Inf values from all the colums in a dataframe

2011-02-24 Thread Peter Ehlers
On 2011-02-23 19:27, Ramya wrote: Hi there, b is my dataframe. I have a dataframe. I am trying to get rid of the -INF values but didnt have much luck b[which(is.finite(b))] I can get rid of it for a single column b[,1][which(is.finite(b[,2]))] but not for all dataframe I used it inside of a

Re: [R] The L Word

2011-02-24 Thread Bryan Hanson
This came up at least once before, with regard to where it is documented: http://r.789695.n4.nabble.com/Where-are-usages-like-quot-2L-quot-documented-tt831061.html I haven't looked around much to see if the documentation has changed, but in a quick look at ?integer I don't see the concept me

Re: [R] The L Word

2011-02-24 Thread Claudia Beleites
On 02/24/2011 11:20 AM, Prof Brian Ripley wrote: On Thu, 24 Feb 2011, Tal Galili wrote: Thank you all for the answers. So if I may extend on the question - When is it important to use 'Literal integer'? Under what situations could not using it cause problems? Is it a matter of efficiency or pr

[R] extract printed value from a function

2011-02-24 Thread Duarte Viana
Hello all, This shouldn't be difficult, but I am not able to extract a printed value from a function and assign it to an object. In my case, > library(DAAG) > twotPermutation(c(2,3,4),c(3,6,5),plotit=F) [1] 0.298 I would like to assign this result to an object. Thanks, Duarte ___

Re: [R] how to plot equalprobable error ellipse?

2011-02-24 Thread Peter Ehlers
On 2011-02-23 19:06, Jie TANG wrote: hi,R users, Now I have some scatter figures, is there some method can plot equalprobable error ellipse ? It's not clear to me what you mean by 'error ellipse' but perhaps dataEllipse() in the car package is useful. Peter Ehlers ___

Re: [R] if statements on vectors

2011-02-24 Thread kamel gaanoun
Or simply do : position <- as.numeric(trend1 == trend2 ) position 2011/2/24 Dimitris Rizopoulos > there are also vectorized logical operators; have a look at the help page > ?'&', and try this: > > > trend1 <- c(1,1,1,1,1,1,-1,-1,-1,-1,-1,-1) > trend2 <- c(1,1,1,1,1,1,1,1,1,1,1,-1) > > position

Re: [R] if statements on vectors

2011-02-24 Thread Kushan Thakkar
Thanks all. This works.. On Thu, Feb 24, 2011 at 3:43 AM, Jim Lemon wrote: > On 02/24/2011 08:37 PM, Dimitris Rizopoulos wrote: > >> there are also vectorized logical operators; have a look at the help >> page ?'&', and try this: >> >> trend1 <- c(1,1,1,1,1,1,-1,-1,-1,-1,-1,-1) >> trend2 <- c(1,

Re: [R] The L Word

2011-02-24 Thread Prof Brian Ripley
On Thu, 24 Feb 2011, Tal Galili wrote: Thank you all for the answers. So if I may extend on the question - When is it important to use 'Literal integer'? Under what situations could not using it cause problems? Is it a matter of efficiency or precision or both? Efficiency: it avoids unnecessa

Re: [R] if statements on vectors

2011-02-24 Thread Jim Lemon
On 02/24/2011 08:43 PM, Jim Lemon wrote: Oops, forgot about the zero! trunc((trend1 * trend2 + 1)/2) Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posti

Re: [R] if statements on vectors

2011-02-24 Thread Jim Lemon
On 02/24/2011 08:37 PM, Dimitris Rizopoulos wrote: there are also vectorized logical operators; have a look at the help page ?'&', and try this: trend1 <- c(1,1,1,1,1,1,-1,-1,-1,-1,-1,-1) trend2 <- c(1,1,1,1,1,1,1,1,1,1,1,-1) position <- as.numeric((trend1 == 1 & trend2 == 1) | (trend1 == -1 &

Re: [R] if statements on vectors

2011-02-24 Thread Ivan Calandra
Hi, I think you want ifelse(). Assuming that length(trend2)=12 and not 14 as in the data you provided, that should work: position <- ifelse((trend1==1 & trend2==1)|(trend1==-1 & trend2==-1),1,0) #btw, note the single "&" and single "|", not double HTH, Ivan Le 2/24/2011 09:41, Kushan Thak

Re: [R] if statements on vectors

2011-02-24 Thread Dimitris Rizopoulos
there are also vectorized logical operators; have a look at the help page ?'&', and try this: trend1 <- c(1,1,1,1,1,1,-1,-1,-1,-1,-1,-1) trend2 <- c(1,1,1,1,1,1,1,1,1,1,1,-1) position <- as.numeric((trend1 == 1 & trend2 == 1) | (trend1 == -1 & trend2 == -1)) position I hope it helps. Best,

Re: [R] The L Word

2011-02-24 Thread Tal Galili
Thank you all for the answers. So if I may extend on the question - When is it important to use 'Literal integer'? Under what situations could not using it cause problems? Is it a matter of efficiency or precision or both? Thanks, Tal Contact Details:--

[R] if statements on vectors

2011-02-24 Thread Kushan Thakkar
I have two vectors: both have possible values of 1,-1, or 0 trend1 <- c(1,1,1,1,1,1,-1,-1,-1,-1,-1,-1) trend2 <- c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,) i want to create a third vector that is conditional upon these two vectors: if (trend2 == 1 && trend1 == 1) {position <- 1} elseif (trend2 == -1 && tre

  1   2   >