Re: [R] getting the results of tapply into a single matrix

2013-11-14 Thread arun
Hi, Try: example <- read.table(text="ID Sex Location CL 1   F    lake1   40 1   F    lake1    1   F    lake1 43 2   M    lake1    30 3   M    lake2    22 4   F    lake2 25 4   F    lake2 27",sep="",header=TRUE,stringsAsFactors=FALSE,fill=TRUE) aggregate(CL~.,example,mean,na.rm=TRUE)

[R] Error in MuMIn "models are not all fitted to the same data"

2013-11-14 Thread Lilly Dethier
I'm pretty new to GLMMs and model averaging, but think I'm getting some understanding of it all through lots of reading. However, I keep receiving an error message when trying to average models that I don't understand and can't find any resources about. I'm doing science education research trying t

Re: [R] Find the cutoff correlation value for Pearson correlation test

2013-11-14 Thread Jim Lemon
On 11/15/2013 12:53 PM, jpm miao wrote: Hi, I find a few Pearson correlation test functions like fBasics::correlationTest or stats::cor.test which give the p-value of the test result. Is there a function that calculate the cutoff correlation value for a specific p-value , e.g., p = 0.0

[R] Find the cutoff correlation value for Pearson correlation test

2013-11-14 Thread jpm miao
Hi, I find a few Pearson correlation test functions like fBasics::correlationTest or stats::cor.test which give the p-value of the test result. Is there a function that calculate the cutoff correlation value for a specific p-value , e.g., p = 0.05? I have a plot for the cross correlations

[R] Inconsistent results between caret+kernlab versions

2013-11-14 Thread Andrew Digby
I'm using caret to assess classifier performance (and it's great!). However, I've found that my results differ between R2.* and R3.* - reported accuracies are reduced dramatically. I suspect that a code change to kernlab ksvm may be responsible (see version 5.16-24 here: http://cran.r-project.

Re: [R] optimization: multiple assignment problem

2013-11-14 Thread Hans W.Borchers
Jean-Francois Chevalier bisnode.com> writes: > You have already given the answer yourself. You have binary variables x(j, i), you need to set up the inequalities, and then apply one of the mixed-integer linear programming solvers in R, for instance 'lpSolve', 'Rglpk', 'Rsymphony'. Setting up th

Re: [R] Double Pareto Log Normal Distribution DPLN

2013-11-14 Thread b. alzahrani
Thanks Dave for your help on this. Waiting other suggestions from the list on this. Regards Bander > On 14 Nov 2013, at 09:29 pm, "David R Forrest" wrote: > > Hi Bander, > > I'm pushing this discussion back to the list, because I'm not sure of the > shape/rate parameters for rpareto and rexp

[R] Warning message during starts up

2013-11-14 Thread Dereje Fentie
During startup R gives a Warning message: "Setting LC_CTYPE=en_US gnumeric & failed" What is the error and how can I fix it? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help P

Re: [R] Windows 7/Rstudio/Rattle - rattle() Causes R Session to abort

2013-11-14 Thread Duncan Murdoch
On 13-11-14 4:41 PM, Lopez, Dan wrote: It's happening in the 64bit installation of R I have too (w/o Rstudio). This is R version 2.15.1 That's kind of an old R version (from June 2012); there were two more releases in the 2.15.x series. The current release is 3.0.2. Can you upgrade? Dunc

Re: [R] Windows 7/Rstudio/Rattle - rattle() Causes R Session to abort

2013-11-14 Thread Lopez, Dan
It's happening in the 64bit installation of R I have too (w/o Rstudio). This is R version 2.15.1 Dan -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Thursday, November 14, 2013 1:38 PM To: Lopez, Dan; R help (r-help@r-project.org) Subject: Re: [R] Window

Re: [R] Windows 7/Rstudio/Rattle - rattle() Causes R Session to abort

2013-11-14 Thread Duncan Murdoch
On 13-11-14 3:50 PM, Lopez, Dan wrote:> Windows 7, R 2.15.1 64bit, RStudio 0.97.312, Rattle 2.6.26 > > Hi, > Please help. > > I removed rattle then reinstalled then loaded then attempted to open rattle with rattle(). But each time I do that My R session in R studio aborts and restarts. > > rem

Re: [R] Double Pareto Log Normal Distribution DPLN

2013-11-14 Thread David R Forrest
Hi Bander, I'm pushing this discussion back to the list, because I'm not sure of the shape/rate parameters for rpareto and rexp and how they'd be applied across this mix of typo'd papers. # Reed Equation 6 http://www.math.uvic.ca/faculty/reed/dPlN.3.pdf exponentiated per end of sec 3: rdpln<-f

[R] Windows 7/Rstudio/Rattle - rattle() Causes R Session to abort

2013-11-14 Thread Lopez, Dan
Windows 7, R 2.15.1 64bit, RStudio 0.97.312, Rattle 2.6.26 Hi, Please help. I removed rattle then reinstalled then loaded then attempted to open rattle with rattle(). But each time I do that My R session in R studio aborts and restarts. remove.packages("rattle") install.packages("rattle") libr

Re: [R] Fitting arbitrary curve to 1D data with error bars

2013-11-14 Thread Erkcan Özcan
Thanks, this was a useful pointer. Since the function I am trying to fit is exponential, I decided to use nls. And I was able to reproduce exactly the results and the plot in the URL I had posted. For future reference, here is the R code I wrote: require("gplots") xx <- 1:10 yy <- c(1.56,1.20,

Re: [R] polygon circling a graph

2013-11-14 Thread Carl Witthoft
Please post the packages from which 'barabasi' and 'layout.fruch' originate (not to mention whatever the plot() method is for whatever class your 'g' is). Further, without seeing what your data look like we have no way of knowing whether you've fed the appropriate elements of "L" to chull. e

Re: [R] polygon circling a graph

2013-11-14 Thread William Dunlap
layout.fruchterman.reingold(g) returns a random result, so you want to call it once and use the one return value. Also, I think you need to avoid the rescaling that plot.igraph does. It looks like you need to explicitly specify xlim and ylim if you do that, but I may not have looked long enough a

Re: [R] Column Name Matching in xts Objects

2013-11-14 Thread Joshua Ulrich
On Thu, Nov 14, 2013 at 12:06 PM, Pooya Lalehzari wrote: > Hello, > I noticed an unexpected behavior when using the xts object and I was > wondering if anyone knows why that happens. I have a code to create a new > column and copy one of the columns to the new column (please see below): > > libr

Re: [R] optimization: multiple assignment problem

2013-11-14 Thread Simon Zehnder
It would be more clear if you tell, what you want to do instead of what you do not want to do. If you start with a usual cost matrix (whatever cost function you have) and you have to assign N to N this reduces to the well-known Munkre’s algorithm (see for example: http://gallery.rcpp.org/artic

[R] polygon circling a graph

2013-11-14 Thread email
Hi: I want to create a polygon encircling a graph. For this i use convex hull to get the coordinate points for polygon. g <- barabasi.game(10) L<-layout.fruchterman.reingold(g) temp1 <- chull(L) temp1 <- c(temp1, temp1[1]) plot(g, layout=layout.fruchterman.reingold) But when i plot the polygon

[R] optimization: multiple assignment problem

2013-11-14 Thread Jean-Francois Chevalier
Hello, I'm trying to solve a multiple assignment problem. I found a package Adagio and its function mknapsack which maximize vstar = p(1)*(x(1,1) + ... + x(m,1)) + ... ... + p(n)*(x(1,n) + ... + x(m,n)) subject to w(1)*x(i,1) + ... + w(n)*x(i,n) <= k(i) for i=1,...,m x(1,j) + ... + x(m,j) <= 1

[R] Column Name Matching in xts Objects

2013-11-14 Thread Pooya Lalehzari
Hello, I noticed an unexpected behavior when using the xts object and I was wondering if anyone knows why that happens. I have a code to create a new column and copy one of the columns to the new column (please see below): library(xts) df = data.frame(stringsAsFactors=FALSE) df[1:3,"date"] = c("

Re: [R] Transform aggregated data to individual data

2013-11-14 Thread arun
HI, A more general form would be:  D[rep(1:nrow(D),D[,3]),-3] A.K. On Thursday, November 14, 2013 12:27 PM, arun wrote: Hi, Try:  D1 <- D[rep(row.names(D),D[,3]),-3] ##assuming rownames(D) are from 1:nrow(D)  row.names(D1) <- 1:nrow(D1) A.K. On Thursday, November 14, 2013 5:32 AM, peron

Re: [R] From list to dataframe

2013-11-14 Thread Hermann Norpois
do.call (rbind, testlist) and Reduce (rbind, testlist) are perfect. Thanks hermann 2013/11/14 arun > > > Hi Hermann, > > You may try: > do.call(rbind,testlist) > #or > Reduce(rbind,testlist) > #or > library(plyr) > ldply(testlist) > A.K. > > > > > On Thursday, November 14, 2013 8:27 AM, Herman

[R] 2SLS for panel data, re

2013-11-14 Thread Chanita Holmes
Hi, I am trying to estimate a 2sls using panel data (random effect model). I tried the same estimation in STATA using the ivtreg2 command. However STATA and R are giving me two different results. I figure there is something with my R code: iv=plm(formula=wecon~fdistockgdp +trade + polrightsrevers

Re: [R] Substring and extract a certain number of characters

2013-11-14 Thread arun
Also, library(stringr) str_sub(s2,-5,-1) str_extract(s1,"[[:alpha:]]+") A.K. On Thursday, November 14, 2013 10:50 AM, arun wrote: Try: s1 <- "hello.world" s2 <- c("GLEm0045", "GLEn0042", "GLEz0048")  substr(s1,1,5) #or gsub("\\..*","",s1) n <- 5 substr(s2,nchar(s2)-n +1,nchar(s2)) A.K.

Re: [R] Substring and extract a certain number of characters

2013-11-14 Thread arun
Try: s1 <- "hello.world" s2 <- c("GLEm0045", "GLEn0042", "GLEz0048")  substr(s1,1,5) #or gsub("\\..*","",s1) n <- 5 substr(s2,nchar(s2)-n +1,nchar(s2)) A.K. If I have a column that has "hello.world"  how   could I extract hello?  In addition in a column how can I extract the last 5 characte

Re: [R] Replace NA's with value in the next row

2013-11-14 Thread arun
Hi, I think you used a column that doesn't exist in the dataset. Targetstation <- read.table(text="V1 V2 V3 V4 V5 V6 V7  0 0 0 1.2 0 0 0.259 0 0 12.8 0 23.7 0 8.495  6 0 81.7 0.2 0 20 19.937  0 1.5 60.9 0 0 15.5 13.900  1 13 56.8 17.5 32.8 6.4 27.654   4 3 66.4 2 0.3 NA 17.145",sep="",header=T

Re: [R] Transform aggregated data to individual data

2013-11-14 Thread arun
Hi, Try:  D1 <- D[rep(row.names(D),D[,3]),-3] ##assuming rownames(D) are from 1:nrow(D)  row.names(D1) <- 1:nrow(D1) A.K. On Thursday, November 14, 2013 5:32 AM, peron wrote: Hello I have data in following form : 100 ind describe by two variables x and y. D<-data .frame( x=rnorm(3), y=r

Re: [R] From list to dataframe

2013-11-14 Thread arun
Hi Hermann, You may try: do.call(rbind,testlist) #or Reduce(rbind,testlist) #or library(plyr)  ldply(testlist) A.K. On Thursday, November 14, 2013 8:27 AM, Hermann Norpois wrote: Hello, having a list like testlist I would like to transform it in dataframe. How does it work? Thanks Herman

Re: [R] lapply?

2013-11-14 Thread Toth, Denes
Hi, the output of lapply() is a list; see ?lapply and ?sapply. # if you know the length of your list in advance, # this definition is better: uu <- vector("list", 2) # list elements uu[[1]] <- c(1,2,3) uu[[2]] <- c(3,4,5) # some options to achieve what you want: matrix(unlist(uu), 2, 3, T) do

Re: [R] volume of ellipsoid

2013-11-14 Thread yuanzhi
Carl Witthoft wrote > Well, given that an upvoted question on math.stackexchange got no answers, > I'd say you're asking a very difficult question. Perhaps this paper > http://www.geometrictools.com/Documentation/IntersectionOfEllipsoids.pdf > > will be of some help. It's possible that you c

Re: [R] volume of ellipsoid

2013-11-14 Thread yuanzhi
Hi, Carl Witthoft yes, it looks like a mathematical question. I will try based on your suggestion to calculate the volume of the intersection. But I still want to know whether there are some functions in R which can calculate the volume of an ellipsoid(area for p=2, hypervolume for p>3) containing

Re: [R] Survival analysis with truncated data

2013-11-14 Thread Nicolas Palix
Hi, Thanks for your response. On Thu, Nov 14, 2013 at 4:44 PM, Terry Therneau wrote: > I think that your data is censored, not truncated. > For a fault introduced 1/2005 and erased 2/2006, duration = 13 months > For a fault introduced 4/2010 and still in existence at the last > observation 1

Re: [R] making a barplot with table of experimental conditions underneath (preferably ggplot2)

2013-11-14 Thread John Kane
Hi Nina, I think the following code does what you want (thanks to Jim Lemon for showing me what you wanted in terms of x-axis tick labels) However I think that barcharts are generally evil so I changed your geom_bar to geom_point. Feel free to change it back if your discipline requires it bu

Re: [R] MM estimator

2013-11-14 Thread Simon Zehnder
Thanks Martin, for making this clear to me, I thought of Pearson’s Method-of-Moments. On 14 Nov 2013, at 16:08, Martin Maechler wrote: >> "SZ" == Simon Zehnder >>on Thu, 14 Nov 2013 08:52:16 +0100 writes: > >SZ> Check the gmm package with a weighting matrix equal to >SZ> th

Re: [R] lapply?

2013-11-14 Thread Brian Smith
Thanks all! So many ways On Thu, Nov 14, 2013 at 10:35 AM, Rui Barradas wrote: > Hello, > > You are applying rbind to each element of the list, not rbinding it with > the others. Try instead > > do.call(rbind, uu) > > Hope this helps, > > Rui Barradas > > Em 14-11-2013 15:20, Brian Smith es

Re: [R] Generating bootstrap samples from a panel data frame

2013-11-14 Thread Dereje Fentie
With a sample data frame: d = data.frame(id = rep(c(1,2,3,4),5), x = round(rexp(20), digits=2), y = round(runif(20), digits=2)) I would like to generate 100 bootstrap data with replacement and save each bootstrap data as b1, b2, ..., b100. I attempted the sample function but could not make it work

Re: [R] Survival analysis with truncated data

2013-11-14 Thread Terry Therneau
I think that your data is censored, not truncated. For a fault introduced 1/2005 and erased 2/2006, duration = 13 months For a fault introduced 4/2010 and still in existence at the last observation 12/2010, duration> 8 months. For a fault introduced before 2004, erased 3/2005, in a machine

Re: [R] lapply?

2013-11-14 Thread Rui Barradas
Hello, You are applying rbind to each element of the list, not rbinding it with the others. Try instead do.call(rbind, uu) Hope this helps, Rui Barradas Em 14-11-2013 15:20, Brian Smith escreveu: Hi, I was trying to use lapply to create a matrix from a list: uu <- list() uu[[1]] <- c(1,2

Re: [R] lapply?

2013-11-14 Thread Berend Hasselman
On 14-11-2013, at 16:20, Brian Smith wrote: > Hi, > > I was trying to use lapply to create a matrix from a list: > > uu <- list() > uu[[1]] <- c(1,2,3) > uu[[2]] <- c(3,4,5) > > The output I desire is a matrix with 2 rows and 3 columns, so I try: > > xx <- lapply(uu,rbind) > > Obviously, I'

Re: [R] issues with calling predict.coxph.penal (survival) inside a function

2013-11-14 Thread Terry Therneau
Thanks for the reproducable example. I can confirm that it fails on my machine using survival 2-37.5, the next soon-to-be-released version, The issue is with NextMethod, and my assumption that the called routine inherited everything from the parent, including the environment chain. A simple t

[R] lapply?

2013-11-14 Thread Brian Smith
Hi, I was trying to use lapply to create a matrix from a list: uu <- list() uu[[1]] <- c(1,2,3) uu[[2]] <- c(3,4,5) The output I desire is a matrix with 2 rows and 3 columns, so I try: xx <- lapply(uu,rbind) Obviously, I'm not doing something right, but what!? [[alternative HTML versi

Re: [R] MM estimator

2013-11-14 Thread Martin Maechler
> "SZ" == Simon Zehnder > on Thu, 14 Nov 2013 08:52:16 +0100 writes: SZ> Check the gmm package with a weighting matrix equal to SZ> the identity. Best SZ> Simon No."MM" is ambigous: The gmm package is about "Generalized Method of Moments" but Izhak is reall

Re: [R] R Beginner - Need Perhaps 5 - 10 Minutes of R User Time to Learn Few Basics

2013-11-14 Thread John Kane
This is not an R question per se. It really seems like an RStudio question. They have their own help forum and it is probably best to ask there. My first thought was that you had just closed the output window in RStudio but in my version, 0.97.449 under Ubuntu 13.10 the window automatically

Re: [R] Replace NA's with value in the next row

2013-11-14 Thread Bert Gunter
On Thu, Nov 14, 2013 at 1:13 AM, Frans Marcelissen wrote: > R purists forbid the use of the for loop, That is utter nonsense. Please do not make such statements when you have no idea what you're talking about. It just promulgates confusion. -- Bert > simple solution: > > for (i in 1:(length(V6)

Re: [R] xts objects comparison

2013-11-14 Thread Joshua Ulrich
On Thu, Nov 14, 2013 at 2:26 AM, Tstudent wrote: > I have the following two xts object: > > https://dl.dropboxusercontent.com/u/102669/series1.rdata > > https://dl.dropboxusercontent.com/u/102669/series2.rdata > > With str i see that they are both xts objects > > I can't understand why it's imposs

Re: [R] How to sum a function over a specific range in R?

2013-11-14 Thread Adams, Jean
You should cc r-help on all correspondence, so others can follow the thread. Here is a very simple example of a home-made smooth function. Perhaps you can modify it to suit your needs. Jean # simple smooth function, using a weighted mean smoothfunction <- function(allxs, allys, centerindex, ha

Re: [R] From list to dataframe

2013-11-14 Thread andrija djurovic
Hi. Here is one way: l <- list(structure(list(BP_A = c(27001689L, 27001689L, 27001689L, 27001689L, 27001689L, 27001689L), SNP_A = c("rs4822747", "rs4822747", "rs4822747", "rs4822747", "rs4822747", "rs4822747"), BP_B = c(27002392L, 27004298L, 27004902L, 27004964L, 27005122L, 27005158L), SNP_B = c("r

[R] beta package for 3D PDF output

2013-11-14 Thread Michail Vidiassov
Dear All, recent desktop versions of Adobe Acrobat and Adobe Reader have built-in support for 3D models in PDF. You can take a look at http://www.pdf3d.com/gallery.php for a gallery of professional results achieved with a commercial tool. For an overview of what 3D PDF can be used for I (natural

[R] From list to dataframe

2013-11-14 Thread Hermann Norpois
Hello, having a list like testlist I would like to transform it in dataframe. How does it work? Thanks Hermann > testlist [[1]] BP_A SNP_A BP_B SNP_B R2 2 27001689 rs4822747 27002392 rs4820690 0.695642 3 27001689 rs4822747 27004298 rs5761627 0.695642 4 27001689 rs4822747

[R] xts objects comparison

2013-11-14 Thread Tstudent
I have the following two xts object: https://dl.dropboxusercontent.com/u/102669/series1.rdata https://dl.dropboxusercontent.com/u/102669/series2.rdata With str i see that they are both xts objects I can't understand why it's impossible to compare each element. For example: series1 > series2 Wh

[R] Fw: Lower 'Pi' 3.1415926... and Exact 'Pi' and Squaring of Circle

2013-11-14 Thread sarvajannnadha reddy
__ 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/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Re: [R] Replace NA's with value in the next row

2013-11-14 Thread Frans Marcelissen
R purists forbid the use of the for loop, but I am afraid this is the most simple solution: for (i in 1:(length(V6)-1)) if(is.na(V6[i])) V6[i]<-V6[i+1] 2013/11/14 Jim Lemon > On 11/14/2013 04:02 PM, dila radi wrote: > >> Hi all, >> >> I have a data set which treat missing value as NA and now

Re: [R] volume of ellipsoid

2013-11-14 Thread Carl Witthoft
Well, given that an upvoted question on math.stackexchange got no answers, I'd say you're asking a very difficult question. Perhaps this paper http://www.geometrictools.com/Documentation/IntersectionOfEllipsoids.pdf will be of some help. It's possible that you could do: 1) find the ellipse o

Re: [R] Printing from windows device; was: (sin asunto)

2013-11-14 Thread Uwe Ligges
On 13.11.2013 22:45, Elisa Frutos Bernal wrote: Hi! I need to print a graph that I have in a window. Previously I used: try(win.print(), silent = TRUE) if (geterrmessage() != "Error in win.print() : unable to start device devWindows\n") { plotFunctiond(screen = FALSE)

Re: [R] Transform aggregated data to individual data

2013-11-14 Thread Jim Lemon
On 11/14/2013 09:28 PM, peron wrote: Hello I have data in following form : 100 ind describe by two variables x and y. D<-data .frame( x=rnorm(3), y=rnorm(3), size=c(50,10,40)) I want data for individual, i.e, 100 observations for my 100 ind. Hi Olivier, From the above, it seems you hav

[R] Transform aggregated data to individual data

2013-11-14 Thread peron
Hello I have data in following form : 100 ind describe by two variables x and y. D<-data .frame( x=rnorm(3), y=rnorm(3), size=c(50,10,40)) I want data for individual, i.e, 100 observations for my 100 ind. Thank for your help Olivier Peron [[alternative HTML version de

Re: [R] Fitting arbitrary curve to 1D data with error bars

2013-11-14 Thread Suzen, Mehmet
Maybe you are after "weights" option given by 'lm' or 'glm' See: http://stackoverflow.com/questions/6375650/function-for-weighted-least-squares-estimates On 14 November 2013 10:01, Erkcan Özcan wrote: > Thanks, but if you have another closer look to my post, you will see that my > question has

Re: [R] Fitting arbitrary curve to 1D data with error bars

2013-11-14 Thread Erkcan Özcan
Thanks, but if you have another closer look to my post, you will see that my question has nothing to do with drawing error bars on a plot. What I want is to do a curve fit to a data with error bars. Best, e. On 14 Nov 2013, at 04:21, Suzen, Mehmet wrote: > If you are after adding error bars in

Re: [R] Replace NA's with value in the next row

2013-11-14 Thread Jim Lemon
On 11/14/2013 04:02 PM, dila radi wrote: Hi all, I have a data set which treat missing value as NA and now I need to replace all these NA's by using number in the same row but different column. Here is the part of my data: V1 V2 V3 V4 V5 V6 V7 0 0 0 1.2 0 0 0.259 0 0 12.8 0 23.7 0 8.495 6