Re: [R] permutation of vectors (1 or 0)

2012-12-20 Thread Martin Maechler
> Jeffrey Dick > on Thu, 20 Dec 2012 21:40:15 +0800 writes: > you might also try (names modified a bit since R already has a NULL object) >> Zeros <- rep(0,10) >> Ones <- rep(1,10) >> expand.grid(Map(c, Zeros, Ones)) Wow -- really neat! Thank you, Jeff

Re: [R] Optmatch Package Question

2012-12-20 Thread Peter Meissner
Hey, it seems like it is indeed: library(sos) findFn(pscore.dist) Best, Peter source: http://stackoverflow.com/a/10553795/1144966 Am 21.12.2012 00:08, schrieb MA: Hello , My optmatch package is loaded on R and otherwise running fine. I get an error after lcds successfully completes a logi

Re: [R] Optmatch Package Question

2012-12-20 Thread bh1
Hello , My optmatch package is loaded on R and otherwise running fine. I get an error after lcds successfully completes a logistic regression and I then try to obtain a propensity score: pdist <- pscore.dist(lcds) Error: could not find function "pscore.dist" Does anyone know if pscore.di

[R] Memory filling up while looping

2012-12-20 Thread Peter Meissner
Hey, I have an double loop like this: chunk <- list(1:10, 11:20, 21:30) for(k in 1:length(chunk)){ print(chunk[k]) DummyCatcher <- NULL for(i in chunk[k]){ print("i load something") dummy <- 1 print("i do something")

Re: [R] lattice::xyplot & file output

2012-12-20 Thread Pascal Oettli
Hello, A reproducible example would be nice. Anyway, with "lattice::xyplot", you can store, then print the figure, in order to write it into a file: > xyObj <- xyplot(...) > postscript(...) > print(xyObj) > dev.off() Regards, Pascal Le 21/12/2012 02:29, Sam Steingold a écrit : Hi, When I w

Re: [R] Plot multiple Graphics via Layers

2012-12-20 Thread Jim Lemon
On 12/21/2012 04:13 AM, Anne-Marie Brigitte Gallrein wrote: Hello, I want to plot 13 barplots in a 4x4 matrix-window (1st layer). So that's no Problem, it worked out. The problem is now, that I want to add two additional layers to this graphic. They contain similar barplots, just with another

Re: [R] how to make a table of summary statistics

2012-12-20 Thread Jim Lemon
On 12/20/2012 10:45 PM, Francesco Sarracino wrote: Dear R-listers, I am a newbie with R and I am struggling with something I consider very basic. I wish to produce a table (to import in a latex file) of summary statistics, but for as much as I've been looking around and trying various alternativ

Re: [R] Optmatch Package Question

2012-12-20 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of MA > Sent: Thursday, December 20, 2012 3:09 PM > To: r-help@r-project.org > Subject: [R] Optmatch Package Question > > Hello , > > My optmatch package is loaded on R and otherwi

[R] variable names in numeric list and Bayesian inference

2012-12-20 Thread Irucka Embry
Hi everyone, I have received assistance from my previous post (comparison of large data set), but I still need some assistance. This is the revised code (along with some new code that I am requesting assistance with correcting): files <- paste0("MaxFloodDepth_", 1:54, ".txt") fileobs <- "MaxFlood

[R] Optmatch Package Question

2012-12-20 Thread MA
Hello , My optmatch package is loaded on R and otherwise running fine. I get an error after lcds successfully completes a logistic regression and I then try to obtain a propensity score: pdist <- pscore.dist(lcds) Error: could not find function "pscore.dist" Does anyone know if pscore.dist

Re: [R] Filling Lists or Arrays of variable dimensions

2012-12-20 Thread David Winsemius
On Dec 20, 2012, at 10:01 AM, Jessica Streicher wrote: > Really must have been unclear at some point, sorry. Hasn't it become abundantly clear that this would have progress farther had you post a complete example? -- David. > > William, thats interesting, but not really helping the main prob

Re: [R] axes labeling

2012-12-20 Thread William Dunlap
By "too much control" do you mean that axis requires too many inputs? You can use axTicks to get the positions of the tick marks that would have been drawn and create labels based on those positions. E.g., > myAxis <- function (side) { at <- axTicks(side = side) lab <- ifelse(abs(at)>=1e

[R] sitools: bug: f2si(0)=>""

2012-12-20 Thread Sam Steingold
Jonas, I think f2si(0) should be "0", not "" as it is now. Thanks. -- Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000 http://www.childpsy.net/ http://ffii.org http://mideasttruth.com http://thereligionofpeace.com http://iris.org.il http://truepeace.org Type louder,

Re: [R] axes labeling

2012-12-20 Thread Sam Steingold
> * David L Carlson [2012-12-20 13:58:00 -0600]: > > It is possible, but only by using axis() since you can specify axis breaks > in a plot command, but not the labels. You can ignore most of the axis() > options so the commands are pretty simple: > > plot(x=c(1, 100), y=c(1, 100), xlab="x

Re: [R] lattice::xyplot & file output

2012-12-20 Thread Rolf Turner
See FAQ 7.22 and fortune("line 800"). cheers, Rolf Turner On 21/12/12 06:29, Sam Steingold wrote: Hi, When I was using the regular plot() function, I added this: --8<---cut here---start->8--- if (!is.null(file)) { do.call(tools::file_ex

Re: [R] axes labeling

2012-12-20 Thread David L Carlson
It is possible, but only by using axis() since you can specify axis breaks in a plot command, but not the labels. You can ignore most of the axis() options so the commands are pretty simple: plot(x=c(1, 100), y=c(1, 100), xlab="x", ylab="y", xaxt="n", yaxt="n", las=2) pos <- c(0, 200

[R] axes labeling

2012-12-20 Thread Sam Steingold
Is it possible to control formatting of the numbers which go along the axes in plots? e.g. plot(x=1:100,y=1:100) will label the X axis as "0d+00", "2e+05" &c. I want that to read 0, 200k, 400k &c. I know of the function axis(), but it offers far too much control for this simple task. thanks

Re: [R] How to count the nos. in a range?

2012-12-20 Thread arun
Hi, Try this: range1<-cut(x,breaks=c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1),labels=paste("(",c("0-0.1","0.1-0.2","0.2-0.3","0.3-0.4","0.4-0.5","0.5-0.6","0.6-0.7","0.7-0.8","0.8-0.9","0.9-1"),")",sep="")) table(range1) #range1  # (0-0.1) (0.1-0.2) (0.2-0.3) (0.3-0.4) (0.4-0.5) (0.5-0.6) (0.6-0.7)

[R] comparison of large data set

2012-12-20 Thread Irucka Embry
Hi, how are you? I have the following truncated R code: fileobs <- "MaxFloodDepth_Observed.txt" file1 <- "MaxFloodDepth_1.txt" file2 <- "MaxFloodDepth_2.txt" ... file54 <- "MaxFloodDepth_54.txt" observeddepth = as.matrix(read.ascii.grid(fileobs)$data) observeddepth[observeddepth!=0]<-1 model

Re: [R] Filling Lists or Arrays of variable dimensions

2012-12-20 Thread William Dunlap
Also note that a column of a data.frame can be a list of complicated things. E.g., > d <- expand.grid(am=c(0, 1), gear=c(3,4,5)) > d$results <- I(lapply(seq_len(nrow(d)), function(i)try(lm(mpg~wt, > subset=gear==d$gear[i] & am==d$am[i], data=mtcars > d[ d$am==1 & d$gear==5, "results"

Re: [R] an entry level (stupid) question

2012-12-20 Thread Rui Barradas
Hello, Inline. Em 20-12-2012 15:47, Yanyuan Zhu escreveu: Hello all, i'm a newbie to R and now I get stuck by the question, would anybody help me please? Suppose, I got the following test <- data.frame(test1=c(c(0.00, 0.005, 0.01, 0.015, 0.02))) test test1 1 0.000 2 0.005 3 0.010 4 0.015

Re: [R] Filling Lists or Arrays of variable dimensions

2012-12-20 Thread William Dunlap
If you really want to use the nested lists and use things like lst[[ c("high", "north", "unmarried") ]] <- value when lst[["high"]] or lst[["high"]][["north"]] does not exist, then I think you will have to make a class that does this. Another advantage of writing a class is that it could be rew

Re: [R] Filling Lists or Arrays of variable dimensions

2012-12-20 Thread Chris Campbell
Jessica This is super ugly but assigns as you requested in the original post: height<-c("high","low") width<-c("slim","wide") doSomething <- function() { cat("done...\n\n") return(list(a = list(1), b = list(2), c = list(3))) } tempList <- list() for(h in height){

Re: [R] Filling Lists or Arrays of variable dimensions

2012-12-20 Thread Jessica Streicher
Really must have been unclear at some point, sorry. William, thats interesting, but not really helping the main problem, which is: how to do > l[[ as.character(grid[1, ]) ]] <- 1 without having initialized the list in the loop before. Well, or how to initialize it without having to do the lo

Re: [R] Filling Lists or Arrays of variable dimensions

2012-12-20 Thread William Dunlap
Arranging data as a list of lists of lists of lists [...] of scalar values generally will lead to slow and hard-to-read R code, mainly because R is designed to work on long vectors of simple data. If you were to start over, consider constructing a data.frame with one column for each attribute.

[R] lattice::xyplot & file output

2012-12-20 Thread Sam Steingold
Hi, When I was using the regular plot() function, I added this: --8<---cut here---start->8--- if (!is.null(file)) { do.call(tools::file_ext(file),list(file = file)) on.exit(dev.off()) cat("writing",file,"\n") } --8<---cut here

[R] Plot multiple Graphics via Layers

2012-12-20 Thread Anne-Marie Brigitte Gallrein
Hello, I want to plot 13 barplots in a 4x4 matrix-window (1st layer). So that's no Problem, it worked out. The problem is now, that I want to add two additional layers to this graphic. They contain similar barplots, just with another color for the second bar of each barplot (2nd layer) and a

Re: [R] an entry level (stupid) question

2012-12-20 Thread arun
Hi,  test$test2<-ifelse(test$test1!=0,39,1/test$test1) A.K. - Original Message - From: Yanyuan Zhu To: r-help@r-project.org Cc: Sent: Thursday, December 20, 2012 10:45 AM Subject: [R] an entry level (stupid) question Hello all, i'm a newbie to R and now I get stuck by the question, w

Re: [R] an entry level (stupid) question

2012-12-20 Thread Chris Campbell
Hi Yanyuan Check out: ?"==" ?"[" ?"<-" You should be able to assign the column quickly with no more than two lines of code using square brackets and assign. Or to literally use if, look at: ?"ifelse" Happy Christmas Chris Chris Campbell Tel. +44 (0) 1249 705

Re: [R] an entry level (stupid) question

2012-12-20 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Yanyuan Zhu > Sent: Thursday, December 20, 2012 7:48 AM > To: r-help@r-project.org > Subject: [R] an entry level (stupid) question > > Hello all, i'm a newbie to R and now I get

Re: [R] R-help Digest, Vol 118, Issue 20

2012-12-20 Thread Terry Therneau
I don't know of one. If building your own you could use rpart with the "maxdepth=1" as the tool to find the best split at each node. Terry Therneau On 12/20/2012 05:00 AM, r-help-requ...@r-project.org wrote: Hi, I've searched R-help and haven't found an answer. I have a set of data from whi

[R] an entry level (stupid) question

2012-12-20 Thread Yanyuan Zhu
Hello all, i'm a newbie to R and now I get stuck by the question, would anybody help me please? Suppose, I got the following > test <- data.frame(test1=c(c(0.00, 0.005, 0.01, 0.015, 0.02))) > test test1 1 0.000 2 0.005 3 0.010 4 0.015 5 0.020 Now I want another column inside test, named test2

Re: [R] How to count the nos. in a range?

2012-12-20 Thread Steve Friedman
Have considered "cut" and "table" ? On Dec 20, 2012 12:08 PM, "Katherine Gobin" wrote: > Dear R forum > > > I have a following vector of random no.s > > x = runif(100, 0.01, 0.99) > > > [1] 0.47212037 0.77867992 0.33947474 0.93369035 > [5] 0.03720073 0.79307831 0.81801835 0.92710688 > ...

[R] scale Problem in Survreg function

2012-12-20 Thread Lumar
Dear R-Community, I'm writting my diploma-thesis this days. Therefore I have to estimate a few coefficients with a Survreg function (library=Survival). My Problem is that the estimated coefficients doesn't make sense. *My Questions:* - What role plays the scale-Value for the coefficient-estimati

[R] How to count the nos. in a range?

2012-12-20 Thread Katherine Gobin
Dear R forum I have a following vector of random no.s x = runif(100, 0.01, 0.99)  [1] 0.47212037 0.77867992 0.33947474 0.93369035   [5] 0.03720073 0.79307831 0.81801835 0.92710688 . I need to count the random no. falling in the range (0 - 0.10)

[R] an entry level (stupid) question

2012-12-20 Thread Yanyuan Zhu
Hello all, i'm a newbie to R and now I get stuck by the question, would anybody help me please? Suppose, I got the following > test <- data.frame(test1=c(c(0.00, 0.005, 0.01, 0.015, 0.02))) > test test1 1 0.000 2 0.005 3 0.010 4 0.015 5 0.020 Now I want another column inside test, named test2

Re: [R] Problem loading .r file

2012-12-20 Thread Ben Bolker
Christofer Bogaso gmail.com> writes: > [snip] > I was trying to load a .r file using source() and load() functions. > Although I could be able to load the codes (mainly few user defined > functions) written in that .r. file correctly, however getting > following error: > > > source("D:/Book

Re: [R] Problem loading .r file

2012-12-20 Thread Jeff Newmiller
I think your immediate problem is that you are asking this particular question in the wrong forum. It appears that you are following instructions (in a book? a class?) and you need to direct your questions to the author of those instructions. You may find it helpful to know: a) The load functi

Re: [R] Filling Lists or Arrays of variable dimensions

2012-12-20 Thread Jessica Streicher
Aggregate is highly confusing (and i would have appreciated if you used my example instead, i don't get it to do anything sensible on my stuff). And this seems not what i asked for anyway. This may be a named list but not named and structured as i want it at all. happy Christmas too On 20.12.2

Re: [R] Problem with simulation

2012-12-20 Thread Berend Hasselman
On 20-12-2012, at 15:49, Rajibul Mian wrote: > Dear: > > I am having problem with simulation. Sometimes for 100 iteration, my > program works but sometimes give error message regarding some "built-in > function" which I never used > in my code. I have no idea about the problem. Any suggestion, c

[R] Nested ANOVA

2012-12-20 Thread Annette van Baalen
Hi all, I'm trying to perform a nested ANOVA, in which "Rewetted" is the main factor and "Position" is a fixed factor nested in "Location". I'm interested in the effect of "Rewetting" and "Position" on the dependent variable (in this case called N), and also in the interaction between these factor

Re: [R] permutation of vectors (1 or 0)

2012-12-20 Thread arun
HI, library(gtools) If you need ?combinations() combinations(2,10,0:1,repeats.allowed=TRUE) #  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]  #[1,]    0    0    0    0    0    0    0    0    0 0  #[2,]    0    0    0    0    0    0    0    0    0 1  #[3,]    0    0    0    0    0 

Re: [R] "For" loop and "if" question

2012-12-20 Thread arun
HI, You could replace the times=. in res1 with: res1<-na.omit(cbind(ID=rep(dat2[,2][grep("ID",dat2$variable)],times=length(grep("p",names(dat1,dat2[grep("p",dat2$variable),],dat2[grep("lat",dat2$variable),],dat2[grep("long",dat2$variable),])) A.K. - Original Message - From: arun

[R] Problem with simulation

2012-12-20 Thread Rajibul Mian
Dear: I am having problem with simulation. Sometimes for 100 iteration, my program works but sometimes give error message regarding some "built-in function" which I never used in my code. I have no idea about the problem. Any suggestion, comments or idea regarding this would be highly appreciable.

Re: [R] Filling Lists or Arrays of variable dimensions

2012-12-20 Thread Chris Campbell
Dear Jessica Aggregate is a function that allows you to perform loops across multiple variables. tempData <- data.frame(height = rnorm(20, 100, 10), width = rnorm(20, 50, 5), par1 = rnorm(20)) tempData$htfac <- cut(tempData$height, c(0, 100, 200)) tempData$wdfac <- cut(te

Re: [R] permutation of vectors (1 or 0)

2012-12-20 Thread Olga Lyashevska
On 12/20/2012 02:13 PM, arun wrote: > library(gtools) > permutations(2,10,0:1,repeats.allowed=TRUE) This does what I need, but if I increase a number of permutations (59 instead of 10), then I get an error. Error: cannot allocate vector of size 1.5 Gb Is there a smart way of increasing the maxim

Re: [R] permutation of vectors (1 or 0)

2012-12-20 Thread Jeffrey Dick
you might also try (names modified a bit since R already has a NULL object) > Zeros <- rep(0,10) > Ones <- rep(1,10) > expand.grid(Map(c, Zeros, Ones)) On Thu, Dec 20, 2012 at 9:24 PM, Olga Lyashevska wrote: > On 12/20/2012 02:13 PM, arun wrote: >> library(gtools) >> permutations(2,10,0:1,repea

Re: [R] permutation of vectors (1 or 0)

2012-12-20 Thread Olga Lyashevska
On 12/20/2012 02:13 PM, arun wrote: > library(gtools) > permutations(2,10,0:1,repeats.allowed=TRUE) Thanks, this is exactly what I need. Regards, Olga __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

[R] permutation of vectors (1 or 0)

2012-12-20 Thread olga30dec
Dear all, I have 2 vectors of 10 elements, each of them contains either 0 or 1, like following: > Null<-rep(0,10) > Null [1] 0 0 0 0 0 0 0 0 0 0 > One<-rep(1,10) > One [1] 1 1 1 1 1 1 1 1 1 1 How can I obtain a matrix rows of which can take all possible combinations? e.g. 0 0 0 0 0 0 0 0 0 0

[R] Filling Lists or Arrays of variable dimensions

2012-12-20 Thread Jessica Streicher
Following problem: Say you have a bunch of parameters and want to produce results for all combinations of those: height<-c("high","low") width<-c("slim","wide") then what i used to do was something like this: l<-list() for(h in height){ l[[h]]<-list() for(w in width){

Re: [R] triax.plot: control legend position and size of point labels

2012-12-20 Thread Massimo Bressan
thanks jim, I had to move the legend to a different place (as the default) because for some reasons it appeared to me "sliced" on the left side (but I'm not sure if that was due to my own configuration, anyway...); I think that the possibility to control the size of the point labels would be a

Re: [R] how to make a table of summary statistics

2012-12-20 Thread Duncan Murdoch
On 12-12-20 6:45 AM, Francesco Sarracino wrote: Dear R-listers, I am a newbie with R and I am struggling with something I consider very basic. I wish to produce a table (to import in a latex file) of summary statistics, but for as much as I've been looking around and trying various alternatives

[R] how to make a table of summary statistics

2012-12-20 Thread Francesco Sarracino
Dear R-listers, I am a newbie with R and I am struggling with something I consider very basic. I wish to produce a table (to import in a latex file) of summary statistics, but for as much as I've been looking around and trying various alternatives (plyr, reporttools, pastecs and Hmisc) I haven't f

Re: [R] triax.plot: control legend position and size of point labels

2012-12-20 Thread Jim Lemon
On 12/19/2012 11:18 PM, maxbre wrote: Given this example library(plotrix) a<-c(34,10,70) b<-c(33,10,20) c<-c(33,80,10) test<-data.frame(A=a,B=b,C=c) triax.plot(test, main ="title", at=seq(0.25,0.75,by=0.25), tick.labels=list(l=seq(0.25,0.75,by=0.25),

Re: [R] [mgcv][gam] Problem defining axis labels for non-smooth terms (via termplot)

2012-12-20 Thread Simon Wood
plot(fit,all.terms=TRUE,select=3,xlabs="???") On 20/12/12 02:06, Andrew Crane-Droesch wrote: Dear List, plot.gam appears to be having trouble communicating its xlab and ylab information to termplot. A simple example: library(mgcv) x = 1:1000 y = runif(1000)*x^.5 z = rnorm(1000)*y other = sin(