Re: [R] No P.values in polr summary

2013-10-18 Thread Prof Brian Ripley
On 18/10/2013 15:01, Vincent Guyader wrote: Hi everyone, If I compute a "Ordered Logistic or Probit Regression" with the polr function from MASS package. the summary give me : coefficients, Standard error and Tvalue.. but not directly the p.value. I can compute "manualy" the Pvalue, but Is th

Re: [R] read table and import of a text file

2013-10-18 Thread arun
Hi, The code is based on what you pasted on the page. In the original post, you used sep="", while the pasted data shows "," as delimiter. dat1 <- subset(head(read.table(text="#Hogd/met, Temp, 005[M], Value #Hogd/met, Difftemp, 051[M], Value BA0+ 1 MTEMP005 1 [deg.C] 2 MDTMP051 1 [deg.C] EOH 8912

Re: [R] find jumps in vector of repeats

2013-10-18 Thread arun
In addition to Bill's method, you may also use: vec1 <- rep(c(1,2,3,4,5), c(10,30,24,65,3))  c(0,which(diff(vec2)!=0)) #or  indx <- cumsum(rle(vec2)$lengths)  c(0,indx[-length(indx)]) #Bill's method was found to be the fastest vec3 <- rep(vec1,1e4) system.time( res <- c(0,which(diff(vec3)!=0))

Re: [R] How would i set every column in a data frame to a scale of 1-100

2013-10-18 Thread arun
Hi, Try dat <- read.table(text=" a   b c 0   89   4 1   93   3 0   88   5",sep="",header=TRUE) datNew <- within(dat,{a<-a*(100/1);c <- c*(100/5)}) #or vec1 <- c(1,100,5) as.data.frame(t(t(dat*(100))/vec1)) #or sweep(dat*100,2,vec1,`/`) A.K. Hi, i am trying to get all the colums of my

Re: [R] find jumps in vector of repeats

2013-10-18 Thread Berend Hasselman
On 19-10-2013, at 02:17, "Benton, Paul" wrote: > Hello all, > > I'm not really sure how to search for this in google/Rseek so there is > probably a command to do it. I also know I could write an apply loop to find > it but thought I would ask all you lovely R gurus. > > I have a very long v

Re: [R] Loop for taking sum of rows based on proximity to other non-NA rows

2013-10-18 Thread arun
Hi, Found a bug in the function when tested.  So, try this (added one more line): #Modified function fun1 <- function(dat,n) {  rl <- rle(is.na(dat[,"Count"])) indx <- which(is.na(dat[,"Count"]))[rep(rl$lengths[rl$values],rl$lengths[rl$values])==n]  lst1 <- lapply(split(indx,((seq_along(indx)-

Re: [R] Need to merge multiple data frames with time stamp

2013-10-18 Thread Kevin Schiesser
Merge has an option 'all', when set to 'TRUE' merge will return a data.frame of every row in both data.frames. You can also specify all.x, and all.y. I do not suggest taking this path. Rather, standardize time columns for all 15 data.frames with as.POSIXct()/as.POSIXlt() depending on the input tim

Re: [R] saveXML() prefix argument

2013-10-18 Thread Earl Brown
Thanks Duncan. However, now I can't get the Spanish and Portuguese accented vowels to come out correctly and still keep the indents in the saved document, even when I set encoding = "UTF-8": library("XML") concepts <- c("español", "português") info <- c("info about español", "info about portuguê

Re: [R] find jumps in vector of repeats

2013-10-18 Thread Bert Gunter
Hint: ?diff -- Bert On Fri, Oct 18, 2013 at 5:17 PM, Benton, Paul wrote: > Hello all, > > I'm not really sure how to search for this in google/Rseek so there is > probably a command to do it. I also know I could write an apply loop to find > it but thought I would ask all you lovely R gurus. >

Re: [R] find jumps in vector of repeats

2013-10-18 Thread William Dunlap
> I have a very long vector (length=1855190) it looks something like this > > ......etc so it would be something equivalent of doing: > rep(c(1,2,3,4,5), c(10,30,24,65,3)) > > How can I find the index of where the step/jump is? For example using the > above I would > get an index

Re: [R] saveXML() prefix argument

2013-10-18 Thread Duncan Temple Lang
Hi Earl Unfortunately, the code works for me, i.e. indents _and_ displays the accented vowels correctly. Can you send me the output of the function call libxmlVersion() and also sessionInfo(), please? D. On 10/18/13 10:27 AM, Earl Brown wrote: > Thanks Duncan. However, now I can't get the

[R] find jumps in vector of repeats

2013-10-18 Thread Benton, Paul
Hello all, I'm not really sure how to search for this in google/Rseek so there is probably a command to do it. I also know I could write an apply loop to find it but thought I would ask all you lovely R gurus. I have a very long vector (length=1855190) it looks something like this ...

Re: [R] Official way to set/retrieve options in packages?

2013-10-18 Thread Duncan Murdoch
On 13-10-18 6:46 PM, Jonathan Greenberg wrote: Wanted to re-start this thread a bit, since I'm still not exactly sure the best approach to my problem -- basically, the parameters I'm try to make persistent are installation locations of a particular command line program that is not installed along

Re: [R] Official way to set/retrieve options in packages?

2013-10-18 Thread Bert Gunter
1. I do not recall saying any such thing. 2. HOWEVER, no matter. There is no choice. Follow Brian's advice. -- Bert On Fri, Oct 18, 2013 at 3:46 PM, Jonathan Greenberg wrote: > Wanted to re-start this thread a bit, since I'm still not exactly sure > the best approach to my problem -- basically,

Re: [R] Official way to set/retrieve options in packages?

2013-10-18 Thread Jonathan Greenberg
Wanted to re-start this thread a bit, since I'm still not exactly sure the best approach to my problem -- basically, the parameters I'm try to make persistent are installation locations of a particular command line program that is not installed along with an R package I'm working on (GDAL, for thos

Re: [R] Loop for taking sum of rows based on proximity to other non-NA rows

2013-10-18 Thread arun
Hi, May be this helps: dat1 <- structure(list(Position = c(15L, 22L, 38L, 49L, 55L, 61L, 62L, 14L, 29L, 63L, 46L, 22L, 18L, 24L, 22L, 49L, 42L, 38L, 29L, 22L, 29L, 23L, 42L), Count = c(15L, NA, NA, 5L, NA, 17L, 18L, NA, NA, NA, 8L, NA, 20L, NA, NA, 16L, 19L, NA, NA, NA, 13L, NA, 33L )), .Names

Re: [R] speeding up a loop

2013-10-18 Thread Ye Lin
when the system locks up it is consuming CPU to ~50%-60%, physical memory is about ~33%. I did tried on a subset of the data, e.g i in 1:100 and it works although takes about 5-10 min. Thanks for your help! On Fri, Oct 18, 2013 at 12:49 PM, jim holtman wrote: > When the system locks up, what

Re: [R] speeding up a loop

2013-10-18 Thread jim holtman
When the system locks up, what do you see in the Task Manager? Is it consuming CPU and memory? On the example data you sent, you won't get a match on the time since there is not match for the first entry in df1 in the 'b' dataframe. This leads to an error that you are not checking for. Have yo

Re: [R] dmvnorm returns NaN

2013-10-18 Thread David Winsemius
On Oct 18, 2013, at 10:31 AM, David Winsemius wrote: > > On Oct 18, 2013, at 1:12 AM, peter dalgaard wrote: > >> >> On Oct 18, 2013, at 08:37 , David Winsemius wrote: >> >>> >>> On Oct 17, 2013, at 9:11 PM, Steven LeBlanc wrote: >>> Greets, I'm using nlminb() to estimate the

Re: [R] Recovering object names when using the ... argument in a fn XXXX

2013-10-18 Thread William Dunlap
> However, I do not understand the >substitute(...()) > idiom. Would you care to explain it? (No is an acceptable answer!). I don't completely understand it either, I treat it as an idiom. I saw it on this list once. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original

Re: [R] hurdle model error why does need integer values for the dependent variable?

2013-10-18 Thread Achim Zeileis
On Fri, 18 Oct 2013, Lauria, Valentina wrote: Dear list, I am using the hurdle model for modelling the habitat of rare fish species. However I do get an error message when I try to model my data: test_new1<-hurdle(GALUMEL~ depth + sal + slope + vrm + lat:long + offset(log(haul_numb)), dist

Re: [R] dmvnorm returns NaN

2013-10-18 Thread David Winsemius
On Oct 18, 2013, at 8:26 AM, Steven LeBlanc wrote: > On Oct 17, 2013, at 11:37 PM, David Winsemius wrote: > >> >> On Oct 17, 2013, at 9:11 PM, Steven LeBlanc wrote: >> >>> Greets, >>> >>> I'm using nlminb() to estimate the parameters of a multivariate normal >>> random sample with missing v

Re: [R] Recovering object names when using the ... argument in a fn XXXX

2013-10-18 Thread Bert Gunter
Yes, similar, but better, as match.call() will get unwanted named arguments, too. However, I do not understand the substitute(...()) idiom. Would you care to explain it? (No is an acceptable answer!). I would have expressed it as: as.list(substitute(list(...)))[-1] to convert the parse tree

Re: [R] Recovering object names when using the ... argument in a fn XXXX

2013-10-18 Thread Dan Abner
Many thanks Bert! You are a big help!! On Fri, Oct 18, 2013 at 1:25 PM, Bert Gunter wrote: > That's because I screwed up! I gave you the wrong function, "f" instead of > "g" . > > Here's g: > > g <- function(...){ > sapply(as.list(match.call())[-1],deparse) > } > > and the example should now

Re: [R] dmvnorm returns NaN

2013-10-18 Thread David Winsemius
On Oct 18, 2013, at 1:12 AM, peter dalgaard wrote: > > On Oct 18, 2013, at 08:37 , David Winsemius wrote: > >> >> On Oct 17, 2013, at 9:11 PM, Steven LeBlanc wrote: >> >>> Greets, >>> >>> I'm using nlminb() to estimate the parameters of a multivariate normal >>> random sample with missing v

Re: [R] Recovering object names when using the ... argument in a fn XXXX

2013-10-18 Thread William Dunlap
> I am using the ... argument to parmeterize a user define fn to accept > multiple input objects. I subsquently save all these data as a list. > Question: what is the best way to recover or extract the original object > names that were fed to the fn? The following function, ellipsisInfo, returns c

Re: [R] Recovering object names when using the ... argument in a fn XXXX

2013-10-18 Thread Bert Gunter
That's because I screwed up! I gave you the wrong function, "f" instead of "g" . Here's g: g <- function(...){ sapply(as.list(match.call())[-1],deparse) } and the example should now work. Sheepishly, -Bert On Fri, Oct 18, 2013 at 10:21 AM, Dan Abner wrote: > Hi Bert, > > Thank you for the

Re: [R] Recovering object names when using the ... argument in a fn XXXX

2013-10-18 Thread Dan Abner
Hi Bert, Thank you for the code. However, I don't see what I am doing different, but my output is different. I would much rather have output similar to yours where only the input objects are returned (instead of the fn name, the encapsulating parentheses, etc.): > d1<-data.frame(x1=runif(100),x

Re: [R] Multimodal multidimensional optimization

2013-10-18 Thread Bert Gunter
1. This is not an R question. Post on a statistics or optimization list. 2. However, I would note that if what you mean by "multimodal"solution is that there is more than one value that gives the "same" optimal value (within numerical error?) then, probably no: An optimization function by definiti

Re: [R] Recovering object names when using the ... argument in a fn XXXX

2013-10-18 Thread Bert Gunter
1. Always cc to the list unless it is truly a private offlist reply. This is to get help from a wider audience, as may well be required here. Translation: Take my "solution" with a grain of salt. It is fragile at best. 2. I think ?match.call and ?deparse are what you're looking for: f <- function

Re: [R] speeding up a loop

2013-10-18 Thread Ye Lin
Thanks for your advice Jim! I tried Rprof but since the code just freezes the system, I am not able to get results so far as I had to close R after waiting for a long time. I am confused that the same code would work differently on the same system. I tried out foreach package as well but didnt no

[R] No P.values in polr summary

2013-10-18 Thread Vincent Guyader
Hi everyone, If I compute a "Ordered Logistic or Probit Regression" with the polr function from MASS package. the summary give me : coefficients, Standard error and Tvalue.. but not directly the p.value. I can compute "manualy" the Pvalue, but Is there a way to directly obtain the pa.value, and

[R] hurdle model error why does need integer values for the dependent variable?

2013-10-18 Thread Lauria, Valentina
Dear list, I am using the hurdle model for modelling the habitat of rare fish species. However I do get an error message when I try to model my data: > test_new1<-hurdle(GALUMEL~ depth + sal + slope + vrm + lat:long + > offset(log(haul_numb)), dist = "negbin", data = datafit_elasmo) Error in h

[R] Multimodal multidimensional optimization

2013-10-18 Thread Jonathan Thayn
Hello all I've been performing a series of multidimensional optimizations (3 variables) using the optima() function. Recently, I noticed that the solution is rarely unimodal. Is there a package or function that handles multimodal multidimensional optimizations? I really appreciate any suggestio

[R] Logistic regression over LOOCV

2013-10-18 Thread Nicolás Sánchez
Hello all. I have this code: myLOOCV <- function(myformula, data) { Y <- all.vars(myformula)[1] Scores<- numeric(length(data[,1])) for (i in 1:length(data[,1])) { train <- data[-i,] test <- data[i,] myModel <- lrm(myformula, train) Scores[i] <- predict(

Re: [R] Lists with numbers lists and strings

2013-10-18 Thread arun
Hi, Not sure this is what you wanted. lstNew <- list(Spans, lapply(lapply(Spans,`[`,1),as.character) ) str(lstNew) #List of 2  $ :List of 3   ..$ : num [1:2] 8.37e+08 8.42e+08   ..$ : num [1:2] 8.32e+08 8.37e+08   ..$ : num [1:2] 9.30e+08 9.35e+08  $ :List of 3   ..$ : chr "8.37e+08"   ..$ : chr "8

Re: [R] crr question‏ in library(cmprsk)

2013-10-18 Thread Elan InP
On 10/18/2013 9:10 AM, Berend Hasselman wrote: > On 18-10-2013, at 14:06, Elan InP wrote: > >> Hi all >> >> I do not understand why I am getting the following error message. I am >> showing all my code this time. Can >> anybody help me with this? Thanks in advance. >> >> >> install.packages("cmpr

Re: [R] Recovering object names when using the ... argument in a fn XXXX

2013-10-18 Thread Bert Gunter
I'm not exactly sure what you mean by "names." Does the following meet your needs? f <- function(...)names(list(...)) > f(a=2,b=3) [1] "a" "b" > f(a=2,3) [1] "a" "" If not, a reproducible example of what you want might be helpful. Cheers, Bert On Fri, Oct 18, 2013 at 9:05 AM, Dan Abner wro

[R] Recovering object names when using the ... argument in a fn XXXX

2013-10-18 Thread Dan Abner
Hi all, I am using the ... argument to parmeterize a user define fn to accept multiple input objects. I subsquently save all these data as a list. Question: what is the best way to recover or extract the original object names that were fed to the fn? Thanks, Dan [[alternative HTML versi

Re: [R] dmvnorm returns NaN

2013-10-18 Thread Steven LeBlanc
On Oct 18, 2013, at 1:12 AM, peter dalgaard wrote: > > On Oct 18, 2013, at 08:37 , David Winsemius wrote: > >> >> On Oct 17, 2013, at 9:11 PM, Steven LeBlanc wrote: >> >>> Greets, >>> >>> I'm using nlminb() to estimate the parameters of a multivariate normal >>> random sample with missing

[R] Lists with numbers lists and strings

2013-10-18 Thread Alaios
Dear all, I have a list that is created like that Spans<-list( c(837e6,842e6),       c(832e6,837e6),       c(930.1e6,935.1e6)       ) I would like to include a second list that will contain the string that would correspond to the numbers at the left side. I would like thus insi

Re: [R] dmvnorm returns NaN

2013-10-18 Thread Steven LeBlanc
On Oct 17, 2013, at 11:37 PM, David Winsemius wrote: > > On Oct 17, 2013, at 9:11 PM, Steven LeBlanc wrote: > >> Greets, >> >> I'm using nlminb() to estimate the parameters of a multivariate normal >> random sample with missing values and ran into an unexpected result from my >> call to dmvn

Re: [R] read table and import of a text file

2013-10-18 Thread arun
Hi, Assuming that you provided the sample data from the file. temp <- readLines(textConnection("#Hogd/met, Temp, 005[M], Value #Hogd/met, Difftemp, 051[M], Value BA0+ 1 MTEMP005 1 [deg.C] 2 MDTMP051 1 [deg.C] EOH 891231, 2400, -1.5, -0.21, 900101, 0100, -1.4, -0.25, 900101, 0200, -1.6, -0.28, 9001

Re: [R] Need to merge multiple data frames with time stamp

2013-10-18 Thread jim holtman
You at least need to provide a subset of what the data looks likes. Since you are merging on 'time', if there are not the same times in each set, then you will have missing values. For example, in the merges that you are doing, have you looked at the size of the resulting object compared to the tw

Re: [R] speeding up a loop

2013-10-18 Thread jim holtman
You might want to use the profiler (Rprof) on a subset of your code to see where time is being spent. Find a subet that runs for a minute, or so, and enable profiling for the test. Take a look and see which functions are taking the time. This will be a start. You can also watch the task monitor

[R] Need to merge multiple data frames with time stamp

2013-10-18 Thread Sandeep.Sampara
Hi, I'm trying to combine 15 different data frames but all have time field as common. But the thing is time intervals are different (like min's and sec's). So I have to check the common time from all the 15 data frames and merge it to a single data frame and then export it to excel or csv. I

Re: [R] Subseting a data.frame

2013-10-18 Thread Katherine Gobin
Dear sir, Thanks a lot for your guidance. I have been benefited immensely by this discussion. Thanks again. Regards Katherine On Friday, 18 October 2013 2:50 AM, Bert Gunter wrote: Thanks, Bill. But ?ave specifically says: ave(x, ..., FUN = mean) Arguments: x A numeric. So that it sh

Re: [R] plot - how to vary the distances of the x axis?

2013-10-18 Thread Hermann Norpois
Thanks. This was helpful. Hermann 2013/10/17 Bretschneider (R) > > On 17 Oct 2013, at 13:44 , Hermann Norpois wrote: > > Hello, > > > my dots of 0 and 2 are quite close to the marging. So I would like to move > the 0 and the 2 both towards the 1. I wish to be my dots more centered. > And: I don

[R] Data frame to PostgreSQL without primary key

2013-10-18 Thread Bill Q
Hi, I just got started with R. I am trying to load some data into PostgreSQL using RPostgreSQL. Everything went quite smoothly except for that the table created by using dbWriteTable does not have a primary key. The ideal solution is to ask PostgreSQL to do a auto-increment with the rows I am goin

Re: [R] speeding up a loop

2013-10-18 Thread Ye Lin
Thanks for your help David! I was running the same code the other day and it worked fine although it took a while as well. You are right that dff shud be df1 and maybe it's a portion of my data so it have an error of length =0. About CPU usage, I got it by clicking ctrl+alt+delete and it showed C

Re: [R] crr question‏ in library(cmprsk)

2013-10-18 Thread Berend Hasselman
On 18-10-2013, at 14:06, Elan InP wrote: > Hi all > > I do not understand why I am getting the following error message. I am > showing all my code this time. Can > anybody help me with this? Thanks in advance. > > > install.packages("cmprsk") > library(cmprsk) > > > ndim = 5 > > # two cov

Re: [R] Subseting a data.frame

2013-10-18 Thread S Ellison
> -Original Message- > > mydat >   basel_asset_class defa_frequency > 1                 2          0.150 > 2                 8          0.070 > 3                 8          0.030 > 4                 8          0.001 > > > I need to get the subset of this data.frame where no of records f

Re: [R] Subseting a data.frame

2013-10-18 Thread S Ellison
> -Original Message- > ... the kindest guide I can give is to > read an Introduction to R (ships with R) or a R web tutorial of your choice No quibble with the advice, but it prompted me to look again at the R Intro. Interestingly, the Intro doesn't mention subset() at all; the subsetting

Re: [R] plotting a marginal distribution on the plane behind a persp() plot

2013-10-18 Thread Colin Rowat
Dear Duncan, Thank you for your quick reply. I've got the basic version of what I'm looking for now (see below). My next step will be your rgl::persp3d suggestion for the hidden lines control. Best, Colin library(MASS) X <- mvrnorm(1000,mu=c(0,0),Sigma=matrix(c(1,0,0,1),2)) X.kde <- kde

Re: [R] Lattice xyplot: Fill Legend Points

2013-10-18 Thread Rich Shepard
On Fri, 18 Oct 2013, S Ellison wrote: Using trellis.par.set seems more successful than specifying par.settings in the call, however much I'd prefer to avoid relying on globals. Example: ss<-trellis.par.get("superpose.symbol") ss$pch=rep(19,7) ss$col=rainbow(7) trellis.par.set(superpose.symbol=s

Re: [R] Lattice xyplot: Fill Legend Points

2013-10-18 Thread S Ellison
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Rich Shepard > Subject: [R] Lattice xyplot: Fill Legend Points > >When I specify pch = 19 for a scatter plot the points are filled > circles. > Deapite reading ?points and

Re: [R] crr question‏ in library(cmprsk)

2013-10-18 Thread Elan InP
Hi all I do not understand why I am getting the following error message. I am showing all my code this time. Can anybody help me with this? Thanks in advance. install.packages("cmprsk") library(cmprsk) ndim = 5 # two covariates standard normal variates z1 = rnorm(ndim) z2 = rnorm(ndim) bet

Re: [R] crr question‏ in library(cmprsk)

2013-10-18 Thread Andrews, Chris
I don't get an error message. However, I had to make up fstatus and all the rest because your example is not reproducible. Please provide the list with more information and you'll likely get a more helpful answer from someone. -Original Message- From: Elan InP [mailto:elodie.gill...@gm

Re: [R] representing points in 3D space with trajectories over time

2013-10-18 Thread Umut Toprak
Thank you Greg I will likely go with a list of data frames as each data frame will represent independent entities and as the syntax will probably be better that way. I did find it puzzling that multidimensional data frame or the ability to hold a vector in a cell of a data frame was not added in

Re: [R] (no subject)

2013-10-18 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Manuel Figueroa > Sent: Friday, October 18, 2013 6:24 AM > To: r-help@r-project.org > Subject: [R] (no subject) > > I have a simple table, 2 columns and 1994 rows. First row,

Re: [R] dmvnorm returns NaN

2013-10-18 Thread peter dalgaard
On Oct 18, 2013, at 08:37 , David Winsemius wrote: > > On Oct 17, 2013, at 9:11 PM, Steven LeBlanc wrote: > >> Greets, >> >> I'm using nlminb() to estimate the parameters of a multivariate normal >> random sample with missing values and ran into an unexpected result from my >> call to dmvnor