[R] need help with distribution graphics

2013-12-27 Thread capricy gao
I need to graph categorical data like a or b in the the following figure. Could anybody let me know what command line I should go with? Thanks a lot! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch

[R] R strange behaviour when working with fifos

2013-12-27 Thread Julio Sergio Santana
I'm trying to establish a connection to a pair of fifos in R, one represents the input stream of a process and the other one the output of the same process. The problem is that R behaves very different when running the commands directly in the interpreter than when running via a script file. He

Re: [R] gc() vs memory.profile()

2013-12-27 Thread Ross Boylan
On Fri, 2013-12-27 at 16:47 -0600, Hadley Wickham wrote: > For your original case, you may find it more useful to do memory + > line profiling (e.g. as visualised by > https://github.com/hadley/lineprof) to figure out what's going on. > > Hadley I've been trying memory and line profiling, but mem

Re: [R] gc() vs memory.profile()

2013-12-27 Thread Hadley Wickham
Hi Ross, It's not obvious how useful memory.profile() is here. I created the following little experiment to help me understand what memory.profile() is showing (and to make it easier to see the changes), but it's left me more confused than enlightened: m_delta <- function(expr) { # Evaluate in

[R] Matchit

2013-12-27 Thread Thyago Moraes
Dear Friends, I'm using Matchit package for a Cohor Study. After match the number provided by the summary output apparently don't correspond to the true value: Here the values provided by summary:>summary (test) Summary of Balance for Matched Data Age: Means treated 44.89; Means control 45.47 How

Re: [R] Subject: Counts of duplicate rows as a new column without grouping of duplicates raws.

2013-12-27 Thread Thomas Jagger
Suppose that you have a dataframe myData, with columns A,B,C and you want a new column D to have the counts for each item in column A, then try: myData$D<-table(myData$A)[as.character(myData$A)] The table creates the counts as a named vector by converting the column to a factor, the names are th

[R] gc() vs memory.profile()

2013-12-27 Thread Ross Boylan
I am trying to understand why a function causes my memory use to explode. While doing that I noticed that my memory use as reported by gc() is growing, but the results of memory.profile() are almost unchanged (the count for raw grew by 3). How can the two functions produce different results, and

[R] Trying to optimize a graph

2013-12-27 Thread alejandro.th.na
Hi, I don’t really have a problem, but I’m trying to improve my R abilities and I think I might use some help. I’ve done this graph: a<-.05; b<- 1; kr1<-70;kr2<-60;kr3<-50 K1<- kr1/a; K2<- kr2/a; K3<- kr3/a curve(kr1*x*(b-a*x/kr1),col="blue",from=-50,to=1500,xlab="Nombre d'individus",ylab="Cr

Re: [R] Averaging specified array indices

2013-12-27 Thread Bert Gunter
I just wanted to note that Arun's first approach, which uses matrix indexing -- often a very useful way to do these things, btw -- can be simplified a bit. m <- do.call(rbind,xyz_indices) ## 4x3 matrix ## avoids repeated evaluation. lapply is not needed as it's a list already sapply(seq(dim(edm)[

Re: [R] Problem of scope

2013-12-27 Thread Sébastien Bihorel
Thank you Uwe. I always forget about how environments are embedded within each other. On Fri, Dec 27, 2013 at 9:33 AM, Sébastien Bihorel wrote: > Hi, > > I have a problem of variable scope illustrated by the following example > (this examples greatly simplifies the actual code I am working on

Re: [R] Changing names into number

2013-12-27 Thread arun
Hi, Not able to reproduce the problem when "A" is a matrix A <- as.matrix( read.table(text="nazwa1 nazwa3  0,2531 nazwa7 nazwa5  0,562 nazwa2 nazwa6  0,65959",header=FALSE,sep=""))  cbind(A[,1],A[,3]) # [,1] [,2] #[1,] "nazwa1" "0,2531" #[2,] "nazwa7" "0,562"  #[3,] "nazwa2" "0,6595

Re: [R] Problem of scope

2013-12-27 Thread Adams, Jean
You didn't save the output from the call to funb() within funa(). Try this. funa <- function(x) { # here is some code that defines the variables aa, bb, cc aa <- 11 bb <- 21 cc <- 31 myabc <- c(aa, bb, cc) # fun b uses some input variable of funa to modify aa, bb, and cc myabc <- funb(x) cat(sp

Re: [R] Averaging specified array indices

2013-12-27 Thread Adams, Jean
This does the trick. apply(sapply(xyz_indices, function(xyz) edm[xyz[1], xyz[2], xyz[3], ]), 1, mean) Jean On Fri, Dec 27, 2013 at 7:28 AM, Morway, Eric wrote: > In the larger problem I'm attempting to solve, I read a 2Gb file > into a 4D array, where the first 3 dimensions are related to spa

Re: [R] Problem of scope

2013-12-27 Thread Uwe Ligges
On 27.12.2013 15:33, Sébastien Bihorel wrote: Hi, I have a problem of variable scope illustrated by the following example (this examples greatly simplifies the actual code I am working on but I unfortunately cannot share it). I have two functions, funa and funb: funb is called within funa. The

Re: [R] Averaging specified array indices

2013-12-27 Thread arun
HI, You could try: res1 <- sapply(seq(dim(edm)[4]),function(i) mean(edm[do.call(rbind,lapply(xyz_indices,function(x) c(x,i)))],na.rm=TRUE)) #or indx <- cbind(matrix(rep(unlist(xyz_indices),50),ncol=3,byrow=TRUE),rep(1:50,each=4)) res2 <-tapply(edm[indx],((seq(200)-1)%/%4)+1,mean)  dimnames(re

[R] Problem of scope

2013-12-27 Thread Sébastien Bihorel
Hi, I have a problem of variable scope illustrated by the following example (this examples greatly simplifies the actual code I am working on but I unfortunately cannot share it). I have two functions, funa and funb: funb is called within funa. The goal of funb is to modify variables created withi

[R] Averaging specified array indices

2013-12-27 Thread Morway, Eric
In the larger problem I'm attempting to solve, I read a 2Gb file into a 4D array, where the first 3 dimensions are related to space (x, y, z), and the 4th dimension is time. My goal is to find the average of specific x, y, z-indices for each time step. A small, reproducible example starts like th

Re: [R] Results from Vegan metaMDS varry depending on set.seed

2013-12-27 Thread Jari Oksanen
Dear Vinny Moriarty, Vinny Moriarty gmail.com> writes: > > I've got an ecological data set that I've worked up to the point of having > a relative abundance matrix I created with the decostand() command in Vegan. > > Here is the distance matrix data: <-- clip: 8 x 4 data matrix giving distance