Re: [R] sorting/grouping/classification problem?

2013-01-24 Thread Bart Joosen
Nice suggestion for the extra "Time" column. But I think I didn't ask clear enough my problem. My main problem is to find a way to "classify" the rrt's, so that we don't have to check each dataframe by our selfs. So I need a function that fills in the extra "Time" column by taking a look at the

Re: [R] ifelse to speed up loop?

2013-01-24 Thread arun
Hi, If variable `V1` is factor and it follows the same pattern as in your example: test<- structure(list(V1 = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L), .Label = c("a", "b"), class = "factor")), .Names = "V1", class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6", "7

Re: [R] importing data

2013-01-24 Thread Ray Cheung
Dear Michael, Thanks for your codes. However, lapply does not work in my case since I've some files missing in the data (say, the file data101.dat). Do you have any suggestions on this?? Thank you very much. Best Wishes, Ray On Wed, Jan 23, 2013 at 8:15 PM, R. Michael Weylandt < michael.weyla...

Re: [R] How to extract elements from vector in reverse order?

2013-01-24 Thread arun
Hi,  x<-1:80 y<- x[-(1:77)] y #[1] 78 79 80 #or ?tail() #already suggested If you want only the last element,, library(pastecs) last(x) #[1] 80 A.K. - Original Message - From: hp wan To: r-help@r-project.org Cc: Sent: Thursday, January 24, 2013 7:23 PM Subject: [R] How to extrac

Re: [R] How to extract elements from vector in reverse order?

2013-01-24 Thread hp wan
Thanks so much. It greatly enrich my mind. 2013/1/25 arun > > > Hi, > x<-1:80 > y<- x[-(1:77)] > y > > #[1] 78 79 80 > #or > > ?tail() #already suggested > > If you want only the last element,, > library(pastecs) > last(x) > #[1] 80 > A.K. > > > > > - Original Message - > From: hp wan

Re: [R] Saving or copying graphics from Quartz returns empty file

2013-01-24 Thread Jeff Newmiller
This issue is very platform-specific. you should post on R-sig-mac. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go...

Re: [R] How to extract elements from vector in reverse order?

2013-01-24 Thread David Winsemius
On Jan 24, 2013, at 4:23 PM, hp wan wrote: > Hi all mailing listers, > > I wanna get the last several elments of vector. > e.g. x <- c(1,2,3,.,78, 79, 80) > > How can I implement to assign last three elements to y, y <- c(78, 79, 80) > ? ?tail > In Matlab, It can easily achieve by y=x(e

Re: [R] Saving or copying graphics from Quartz returns empty file

2013-01-24 Thread David Winsemius
On Jan 24, 2013, at 4:26 PM, heatherchapman wrote: > Hi, > I need some help figuring out how to save or copy graphs I've created in the > Quartz screen. I'm using a Mac, Mountain Lion OS, and have version 2.15.2. > > When I save a graphic, the process either crashes R, or if it saves the > file,

Re: [R] Recommendation for website to format R code

2013-01-24 Thread C W
I ran across this page for C, Java, etc. No R. http://pastebin.com/ It looks similar and more than what I was looking for, just saying. Mike On Wed, Jan 23, 2013 at 9:34 PM, Mark Lamias wrote: > Are you only interested in formatting code from copy and pasting to/from > email? If you are int

Re: [R] How to extract elements from vector in reverse order?

2013-01-24 Thread hp wan
That is to say, there is no variable in R corresponding to "end" iterm in Matlab which means the sum of all elments. Maybe we can reshape the vector and then get the first several elements. It is easy to achieve no matter which means used. Thank Daniel J. Nordlund Huaping Wan 2013/1/25 Nordlu

Re: [R] ifelse to speed up loop?

2013-01-24 Thread William Dunlap
rle() or c(TRUE, cumsum( v[-length(v)] != v[-1] )) will work on any type for which != is defined. The ones involving diff() require numeric inputs. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-p

[R] Saving or copying graphics from Quartz returns empty file

2013-01-24 Thread heatherchapman
Hi, I need some help figuring out how to save or copy graphs I've created in the Quartz screen. I'm using a Mac, Mountain Lion OS, and have version 2.15.2. When I save a graphic, the process either crashes R, or if it saves the file, when I open it, it is a blank file or I get an error message tha

Re: [R] How to extract elements from vector in reverse order?

2013-01-24 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of hp wan > Sent: Thursday, January 24, 2013 4:23 PM > To: r-help@r-project.org > Subject: [R] How to extract elements from vector in reverse order? > > Hi all mailing listers, >

[R] How to extract elements from vector in reverse order?

2013-01-24 Thread hp wan
Hi all mailing listers, I wanna get the last several elments of vector. e.g. x <- c(1,2,3,.,78, 79, 80) How can I implement to assign last three elements to y, y <- c(78, 79, 80) ? In Matlab, It can easily achieve by y=x(end-2:end) Thanks Huaping Wan [[alternative HTML version

Re: [R] ifelse to speed up loop?

2013-01-24 Thread Jeff
Thank you for the tips. I should mention that the V1 is numeric in this case but I am trying to automate the overall procedure so it may not be numeric always. Would that matter with these functions? Sent from my iPhone On Jan 24, 2013, at 6:34 PM, arun wrote: > Hi, > You could do this: > tes

Re: [R] ifelse to speed up loop?

2013-01-24 Thread arun
Hi, I guess you meant: c(TRUE, cumsum( v[-length(v)] != v[-1] ))  [1] 1 0 0 1 1 1 2 2 2 3 3 3 this:  cumsum(c(TRUE, v[-length(v)] != v[-1] )) # [1] 1 1 1 2 2 2 3 3 3 4 4 4 A.K. - Original Message - From: William Dunlap To: arun ; Jeffrey Fuerte Cc: R help Sent: Thursday, January 24,

Re: [R] Help regarding kmeans output. need to save the clusters into different directories/folders.

2013-01-24 Thread Lakshminarayana Motamarri
Hi Don, Thanks for the advise. I followed this video: http://www.youtube.com/watch?v=uw4NtcTD4iM and achieved my goal: i.e. by using 'matrix' function and 'c' function as shown below: > tail_clusters <- matrix(c(input_tail[,1],input_tail[,2],clustering_tail$cluster),ncol=3) and separating them

Re: [R] ifelse to speed up loop?

2013-01-24 Thread William Dunlap
Yes. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: arun [mailto:smartpink...@yahoo.com] > Sent: Thursday, January 24, 2013 3:53 PM > To: William Dunlap > Cc: R help > Subject: Re: [R] ifelse to speed up loop? > > Hi, > > I guess you meant: > c(TRUE

Re: [R] ifelse to speed up loop?

2013-01-24 Thread William Dunlap
I like v <- test[,1] c(TRUE, cumsum( v[-length(v)] != v[-1] )) (R's arithmetic on logicals treats TRUE as 1 and FALSE as 0.) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >

Re: [R] ifelse to speed up loop?

2013-01-24 Thread arun
HI, This might be better. test$group<-cumsum(abs(c(1,diff(test[,1] A.K. - Original Message - From: Jeffrey Fuerte To: r-help@r-project.org Cc: Sent: Thursday, January 24, 2013 4:20 PM Subject: [R] ifelse to speed up loop? Hello, I'm not sure how to explain what I'm looking for

Re: [R] ifelse to speed up loop?

2013-01-24 Thread Bert Gunter
I should add that if your V1 column is numeric, fiddling around with ?diff or equivalent will also identify the groupings for you and may be faster than rle(). -- Bert On Thu, Jan 24, 2013 at 3:32 PM, Bert Gunter wrote: > Your query is a little unclear to me, but I suspect > ?rle > is what you w

Re: [R] ifelse to speed up loop?

2013-01-24 Thread arun
Hi, You could do this: test<-read.table(text="   V1 1  1 2  1 3  1 4  2 5  2 6  2 7  1 8  1 9  1 10  2 11  2 12  2 ",sep="",header=T)  test$Group<-cumsum(abs(c(0,diff(test[,1]+1 test #   V1 Group #1   1 1 #2   1 1 #3   1 1 #4   2 2 #5   2 2 #6   2 2 #7   1 3 #   1  

Re: [R] ifelse to speed up loop?

2013-01-24 Thread Bert Gunter
Your query is a little unclear to me, but I suspect ?rle is what you want. -- Bert On Thu, Jan 24, 2013 at 1:20 PM, Jeffrey Fuerte wrote: > Hello, > > I'm not sure how to explain what I'm looking for but essentially I have a > test dataset that looks like this: > > test: >V1 > 1 1 > 2 1

[R] spatial analysis

2013-01-24 Thread Rosario Garcia Gil
Hello I am using library(spatstat). I managed to test of the random distribution of a collection of sampled trees in the forest. But what I want now is to test if their diameter is randomly distributed across the forest, for example the bigger trees are not clustered together. So far I have no

[R] ifelse to speed up loop?

2013-01-24 Thread Jeffrey Fuerte
Hello, I'm not sure how to explain what I'm looking for but essentially I have a test dataset that looks like this: test: V1 1 1 2 1 3 1 4 2 5 2 6 2 7 1 8 1 9 1 10 2 11 2 12 2 And what I want to be able to do is create another column that captures a "grouping" variable t

Re: [R] How to drop unused factors in faceted R ggplot boxplot?

2013-01-24 Thread arun
HI, You can get the plot in the same window, but the width seems to be a problem. stest<- read.table(text="     site year conc     south 2001 5.3     south 2001 4.67     south 2001 4.98     south 2002 5.76     south 2002 5.93     north 2001 4.64     north 2001 6.32     north 2003 11.5     north 200

Re: [R] How to drop unused factors in faceted R ggplot boxplot?

2013-01-24 Thread Gorczynski, George
Hi and thanks. This unfortunately doesn't work because: "ggplot2 does not currently support free scales with a non-cartesian coord or coord_flip." -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: January-24-13 1:49 PM To: Gorczynski, George Cc: R help Subject: Re: [R]

Re: [R] Please help R error message "masked from 'package:utils':combn"

2013-01-24 Thread MacQueen, Don
After you get that message, use conflicts() (and read the help page for the conflicts function) -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 1/23/13 10:04 PM, "Fumie Sugahara" wrote: >Hi > >The message occurred

Re: [R] Help regarding kmeans output. need to save the clusters into different directories/folders.

2013-01-24 Thread MacQueen, Don
You find the element of clustering_tail that indicates which which point is in which cluster (the help page for kmeans tells you). Then you use that element to subset your input data (1.tsv). Then you save each subset to a separate folder. By "save to a folder" I would assume you mean write a tsv

Re: [R] Question on matrix calculation

2013-01-24 Thread David L Carlson
Or just use aggregate() # Redefine match_df to match your data.frame > match_df <- data.frame(Seq = 1:5, criteria = letters[c(3, 5, 3, 3, 4)]) > aggregate(mat, list(match_df$criteria), sum) Group.1 V1 V2 V3 1 a 7 17 27 2 c 2 7 12 3 d 6 16 26 # If you really want a matrix: >

Re: [R] problems with coercing a factor to be numeric

2013-01-24 Thread Francesco Sarracino
Dear Ellison, thanks a lot for your reply. Your explanation makes things much clearer. Sincerely, f. On 24 January 2013 05:58, S Ellison wrote: > > > On 23 Jan 2013, at 21:36, "Francesco Sarracino" > wrote: > > > what I meant refers to the fact that I've read on "an R and > > S-plus co

Re: [R] sorting/grouping/classification problem?

2013-01-24 Thread Bart Joosen
dat3 is the dataframe where there are some rrt values merged, which is actually the problem: how on Earth discide which rows van be merged Thanks for your input! Bart -Original Message- From: arun Sent: 24 Jan 2013 20:18:28 GMT To: Bart Joosen Cc: R help Subject: Re: [R] sorting/gr

Re: [R] sorting/grouping/classification problem?

2013-01-24 Thread arun
HI, If I understand your question, "dat3" is not you wanted. Is  it something like this you wanted? library(reshape2)  dcast(dat,rrt~Mnd,value.var="Result") #   rrt   0   3    6    9 #1 0.35  NA  NA 0.05   NA #2 0.36  NA  NA   NA 0.06 #3 0.44  NA  NA 0.40   NA #4 0.45 0.1 0.2   NA 0.60 #5 0.46  N

Re: [R] Question on matrix calculation

2013-01-24 Thread arun
Hi, You could also use: mat <- matrix(1:15, 5) set.seed(5) match_df <- data.frame(Seq = 1:5, criteria = sample(letters[1:5], 5, replace = T),stringsAsFactors=F) library(plyr) res<-daply(as.data.frame(mat),.(match_df$criteria),colSums) res #match_df$criteria V1 V2 V3   #   

[R] sorting/grouping/classification problem?

2013-01-24 Thread Bart Joosen
Hi, I'm a database admin for a database which manage chromatographic results of products during stability studies. I use R for the reporting of the results in MS Word through R2wd. But now I think I need your help: suppose we have the following data frame: ID rrt Mnd Result 1 0.45 0

Re: [R] Recommendation for website to format R code

2013-01-24 Thread C W
thanks, Brian. I remember sending code to the R list, it was about the lattice package some time around June 2012. And someone else reformatted, and it my surprise it was eye-opening. Anyways, I will dig around on this list. Thanks, Mike On Thu, Jan 24, 2013 at 2:42 PM, Brian Diggs wrote: > O

Re: [R] Question on matrix calculation

2013-01-24 Thread Rui Barradas
Hello, Something like this? do.call(rbind, lapply(split(as.data.frame(mat), match_df$criteria), colSums)) Hope this helps, Rui Barradas Em 24-01-2013 19:39, Christofer Bogaso escreveu: Hello again, Ley say I have 1 matrix and 1 data frame: mat <- matrix(1:15, 5) match_df <- data.frame(

Re: [R] Recommendation for website to format R code

2013-01-24 Thread Brian Diggs
On 1/23/2013 6:40 PM, C W wrote: Hey Mark, I am aware of this package. The situation is, 1. I am emailing my code from my machine to a public machine. Installation is a hassle. 2. Copy pasting for a website. For your second use case, there is the Pretty R syntax highlighter at http://www.insi

[R] Question on matrix calculation

2013-01-24 Thread Christofer Bogaso
Hello again, Ley say I have 1 matrix and 1 data frame: > mat <- matrix(1:15, 5) > match_df <- data.frame(Seq = 1:5, criteria = sample(letters[1:5], 5, replace > = T)) > mat [,1] [,2] [,3] [1,]16 11 [2,]27 12 [3,]38 13 [4,]49 14 [5,]5 10 15 > m

Re: [R] Custom axis with months name

2013-01-24 Thread Rui Barradas
Hello, To get the months names you can try format(data[,1], "%B") As for the axis, see the help page ?axis. Argument 'labels'. Hope this helps, Rui Barradas Em 24-01-2013 17:34, Grigory Fateyev escreveu: Hello! I have data.frame with column class POSIXct: data[, 1] <- as.POSIXct(data[, 1

Re: [R] Difference between R and SAS in Corcordance index in ordinal logistic regression

2013-01-24 Thread Frank Harrell
Please define 'mean probabilities'. To compute the C-index or Dxy you need anything that is monotonically related to the prediction of interest, including the linear combination of covariates ignoring all intercepts. In other words you don't need to go to the trouble of computing probabiliti

Re: [R] Pasting a list of parameters into a function

2013-01-24 Thread Berend Hasselman
On 24-01-2013, at 18:56, hp wan wrote: > Hi mailing listers, > > Sorry, I made a little mistake in the previous mail. B^{1} should be B^{-1}. > > Is there certain function in R deal with how to compute generalized > eigenvalues, that is the problem: A*x* = ëB*x *? When I use > eigen(B^{-1}*A),

Re: [R] functions as arguments to ther functions with inlinedocs

2013-01-24 Thread Rui Barradas
Hello, Sorry, it's RIGHT parenthesis. Rui Barradas Em 24-01-2013 18:54, Rui Barradas escreveu: Hello, Your function declaration has a syntax error, one left parenthesis too much. Corrected it would be dummyfunction <- function(filters = function(x) {b = 0; x > b} ){ # rest of code here

Re: [R] From table to data.frame

2013-01-24 Thread arun
Hi, In the ?cut(), you can specify `labels`. #or, you can try: test.df<-read.table(text="     Var1 Freq 1    (0,0.05]  68 2  (0.05,0.1]  87 3  (0.1,0.15]  85 4  (0.15,0.2]  72 5  (0.2,0.25]  65 6  (0.25,0.3]  73 7  (0.3,0.35]  74 ",sep="",header=T,stringsAsFactors=F) test.df[,1]<-as.numeric(gsub("

Re: [R] From table to data.frame

2013-01-24 Thread arun
Hi, set.seed(25)  Z<-rnorm(50,0.5,1) res<- as.data.frame(table(cut(Z,seq(0,1,by=0.05),labels=seq(0.05,1,by=0.05))) )  head(res)  # Var1 Freq #1 0.05    1 #2  0.1    1 #3 0.15    0 #4  0.2    0 #5 0.25    0 #6  0.3    1 A.K. - Original Message - From: Wim Kreinen To: r-help@r-project.

Re: [R] How to drop unused factors in faceted R ggplot boxplot?

2013-01-24 Thread Niec
Thank you, Jeff. I think I should have been more clear. I don't want to modify my data. I need to create a series of box plots for different sites (north and south in my example but there are many more) but I don't want empty rows in my plot - for years when data was not collected. I tried to make

Re: [R] mlogit Package

2013-01-24 Thread ya
Hi Ehsan, What do you mean by percent correctly predicted? Could you provide more info about your model? It might be helpful to get a clue. ya From: ehsan rahimi Date: 2013-01-24 12:52 To: r-help Subject: [R] mlogit Package I have problem as follows: I use "mlogit package" to develop a multi

Re: [R] functions as arguments to ther functions with inlinedocs

2013-01-24 Thread Rui Barradas
Hello, Your function declaration has a syntax error, one left parenthesis too much. Corrected it would be dummyfunction <- function(filters = function(x) {b = 0; x > b} ){ # rest of code here filters # this returns a function, don't need return() } x <- -5:5 f <- dummyfunction() # this

[R] predicted HR in coxph with psline

2013-01-24 Thread Carrie Li
Hi all, I have some questions about the predicted HR in coxph function including psline covariate. If just fitting covariate as linear form, by default, the reference value for each of predictions type (linear predictor, risk and terms) is the mean covariate within strata. If the psline is speci

Re: [R] functions as arguments to ther functions with inlinedocs

2013-01-24 Thread Duncan Murdoch
On 24/01/2013 1:32 PM, Jannis wrote: Dear R community, I have a problem when I use functions as default values for argumnents in other functions. When I use curly brackets { here, I can not create a package with inlinedocs. It will give me the error when using package.skeleton() in my package st

Re: [R] how should I make the optional arguments in r?

2013-01-24 Thread Rui Barradas
Hello, The question is a bit confusing, but for what I could understand, try changing to rr <- getrange(dataw, mydatao, method = method) Hope this helps, Rui Barradas Em 24-01-2013 18:26, Tammy Ma escreveu: HI, I guess I did sth wrong with the optional argument in the program. but I do

Re: [R] From table to data.frame

2013-01-24 Thread Rui Barradas
Hello, try the following. test.df$Var1 <- seq(0,1, by=0.05)[-1] test.df Hope this helps, Rui Barradas Em 24-01-2013 17:39, Wim Kreinen escreveu: Hello, I have a dataframe (test.df) with intervals that were generated by table (see below). I would prefer a dataframe labeled like this: tes

Re: [R] Pasting a list of parameters into a function

2013-01-24 Thread Jeff Newmiller
The eigenvalue problem is not unique to R. This is an R mailing list. What is your question about R? --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live G

[R] functions as arguments to ther functions with inlinedocs

2013-01-24 Thread Jannis
Dear R community, I have a problem when I use functions as default values for argumnents in other functions. When I use curly brackets { here, I can not create a package with inlinedocs. It will give me the error when using package.skeleton() in my package structure: Error in parse(text = ut

Re: [R] Pairwise Comparrisons

2013-01-24 Thread David Winsemius
On Jan 24, 2013, at 10:16 AM, Bert Gunter wrote: > You need to get familiar with BioConductoR and post on that list. > Almost certainly you are trying to reinvent the wheel, and may even be > constructing it square. > > Cheers, > Bert > > On Thu, Jan 24, 2013 at 8:25 AM, Benjamin Ward (ENV) wr

[R] how should I make the optional arguments in r?

2013-01-24 Thread Tammy Ma
HI, I guess I did sth wrong with the optional argument in the program. but I don't know how should I make it. in my main program: source("getelasticity_overPB.r") crossprice<-getelasticity(mydata,mydatao,"nest")$cross_p is same with crossprice<-getelasticity(mydata,mydatao)$cross_p I don't k

Re: [R] Pairwise Comparrisons

2013-01-24 Thread Bert Gunter
You need to get familiar with BioConductoR and post on that list. Almost certainly you are trying to reinvent the wheel, and may even be constructing it square. Cheers, Bert On Thu, Jan 24, 2013 at 8:25 AM, Benjamin Ward (ENV) wrote: > Dear all, > > I'm trying to write a function, that will take

Re: [R] dummy encoding in metafor

2013-01-24 Thread Michael Dewey
At 22:06 23/01/2013, Alma Wilflinger wrote: Hi Michael, The supervisor for my Master's Thesis told me that my means are the effect size and cause of this I have to take figure 1 for all standard deviations. So I hope that was the right information. Alma There is a fairly comprehensive list

[R] Empirical copula density

2013-01-24 Thread eliza botto
Dear useRs, Sorry for such a stupid question. But i cant live without asking it. Actually, I was going through "copula" package in R. I needed to know that if there is a way in R to calculate the emipirical copula density between two random variables and plot it like the way we do in "levelpl

[R] Custom axis with months name

2013-01-24 Thread Grigory Fateyev
Hello! I have data.frame with column class POSIXct: data[, 1] <- as.POSIXct(data[, 1], format = "%d.%m.%Y %H:%M") I need to write custom axis for plot where can be ex.: January (mean of january's temperature). List of month I get as table(months(data[, 1])). What is next step? Thanks. -- Всег

[R] Pairwise Comparrisons

2013-01-24 Thread Benjamin Ward (ENV)
Dear all, I'm trying to write a function, that will take as an argument, some aligned genome sequences, and using a sliding window, do pairwise comparisons of sequence similarity. Coding the sliding window I think I can manage but what I'm trying to get to grips with is getting it so as every p

Re: [R] how to combine unequal rows and columns in R

2013-01-24 Thread arun
HI, If you use ?join(), it will preserve the order of the first dataframe. library(plyr) df3<-rbind.fill(crosspries[[1]],crosspries[[2]]) template2<-read.table(text=outer(unique(df3[,1]),unique(df3[,2]),FUN=paste),sep="",stringsAsFactors=F) names(template2)<-names(df3[1:2]) res1<-join(template2,df

Re: [R] Pasting a list of parameters into a function

2013-01-24 Thread hp wan
Hi mailing listers, Sorry, I made a little mistake in the previous mail. B^{1} should be B^{-1}. Is there certain function in R deal with how to compute generalized eigenvalues, that is the problem: A*x* = ëB*x *? When I use eigen(B^{-1}*A), error happened. It displays there are many Inf element

Re: [R] Pasting a list of parameters into a function

2013-01-24 Thread hp wan
Hi mailing listers, Is there certain function in R deal with how to compute generalized eigenvalues, that is the problem: A*x* = ëB*x *? When I use eigen(B^{1}*A), error happened. It displays there are many Inf elements in B^{1}. Thanks Huaping Wan [[alternative HTML version deleted]]

Re: [R] How to construct a valid seed for l'Ecuyer's method with given .Random.seed?

2013-01-24 Thread Marius Hofert
Thanks a lot, Duncan, that solved it! Cheers, Marius Duncan Murdoch writes: > On 13-01-24 2:09 AM, Marius Hofert wrote: >> Dear Daniel, >> >> That's exactly what I also suspected (last post). The question now seems how >> to >> correctly convert .Random.seed from signed to unsigned so that i

Re: [R] Pasting a list of parameters into a function

2013-01-24 Thread S Ellison
> I'm trying to iterate model fits while holding one variable > (l,a,b or s) constant. In order to do this, each time I need > to re-run the mle2 fit with one variable held constant, Have you read the help page closely enough, I wonder? If I look at the mle2 help page, I see an argument called

[R] Creating a "scene" with plot3d or point3d

2013-01-24 Thread cgenolin
Hi the list, As far as I understand, a possibility to create a "scene" is to provide a list of triangles to the function makeTriangles. Is there also a way to turn the data that are used by "plot3d" into a scene? I would like to write: --- 8< - M <- matrix(runif(12),4) plot3d(M) ### Some

Re: [R] Pasting a list of parameters into a function

2013-01-24 Thread bsm2
I'm still having trouble, I think that I may have poorly explained the problem I'm running into. The code I'm working with looks like this: mle.nb<-function(l,a,b,s){ t1pred=(data$T*l)/(1+a*data$T)^b -sum(dnbinom(x=data$T.1, mu=t1pred, size=s,log=TRUE)) } fit.mle.nb=mle2(mle.nb, start=lis

Re: [R] how to combine unequal rows and columns in R

2013-01-24 Thread arun
Hi, Another way might be: df1 <- merge(crosspries[[1]], crosspries[[2]], all=TRUE) template1<-read.table(text=outer(unique(df1[,1]),unique(df1[,2]),FUN=paste),sep="",stringsAsFactors=F)   res<-merge(df1,template1,by.x=c("Product","Year_Month"),by.y=c("V1","V2"),all=TRUE) res1<-do.call(rbind,split(

[R] scaling of nonbinROC penalties - accurate classification with random data?

2013-01-24 Thread Jonathan Williams
Dear R Helpers I am having difficulty understanding how to use the penalty matrix for the nomROC function in package 'nonbinROC'. The documentation says that the values of the penalty matrix code the penalty function L[i,j] in which 0 <= L[i,j] <= 1 for j > i, but gives no other constraints. It

[R] How to get read.table() or scan() to report line on which error occurs

2013-01-24 Thread David Clunie
Hi Please excuse this naive question, but I have search the FAQs and lists and web for an answer but not found one. I have a text file of several hundred thousand rows and somewhere in the middle there is a malformed row. Doing: mydata<-read.table("mydata.dat", header=FALSE, sep=" ", col

Re: [R] long format with reshape

2013-01-24 Thread arun
HI, You could use: library(reshape)  res<-melt(dat,id.var=c("region","state")) names(res)[3:4]<-c("species","presence") res<-res[rev(order(res$region,res$state)),]  row.names(res)<- 1:nrow(res)  res   #  region state  species presence #1   sydney   nsw species3    1 #2   sydney   nsw species2 

Re: [R] Difference between R and SAS in Corcordance index in ordinal logistic regression

2013-01-24 Thread Olivier Collignon
Dear Dr Harrell, Thank you very much for your answer. Actually I also tried to found the C index by hand on these data using the mean probabilities and I found 0.968, as you just showed. I understand now why I had a slight difference with the outpout of lrm. I am thus convinced that this result

Re: [R] Create a Data Frame from an XML

2013-01-24 Thread Adam Gabbert
Hi Ben, Thanks for info. That is definitely a viable solution for the example I provided. It is more common that I have larger files with more edits to make. The main reason I went with a data frame methodology is becuase of the file types I have. Essentially, I have an XML 50+ "rows" by 10 "co

Re: [R] Create a Data Frame from an XML

2013-01-24 Thread Franzini, Gabriele [Nervianoms]
Hello Adam, I had a similar problem with a big dataframe, and building an xmlTree in the clean way was extremely slow; so i resorted to manual method. Not tested, but if your dataframe is my_df, then something like the following should do: buildEntry <- function(x) { cat(paste('\n', sep=""))

Re: [R] how to combine unequal rows and columns in R

2013-01-24 Thread Adams, Jean
Tammy, # use the function dput() to provide code for us to easily recreate your example data crosspries <- list(structure(list(Product = c("A", "B", "C"), Year_Month = c(201208L, 201208L, 201208L), prod1 = c(1L, 2L, 1L)), .Names = c("Product", "Year_Month", "prod1"), class = "data.frame", row.nam

[R] Appending BSON arrays in MongoDB with package 'rmongodb'

2013-01-24 Thread Janko Thyson
Dear list, I simply can't figure out how to append an BSON array in MongoDB (with package 'rmongodb') using either the '$push' or '$addToSet' operator. It's sort of the last missing puzzle piece regarding CRUD operations, so any hint will be greatly appreciated! Below you'll find a link to an

Re: [R] Difference between R and SAS in Corcordance index in ordinal logistic regression

2013-01-24 Thread Frank Harrell
lrm does some binning to make the calculations faster. The exact calculation is obtained by running f <- lrm(...) rcorr.cens(predict(f), DA), which results in: C IndexDxy S.D. nmissing 0.96814404 0.93628809 0.0380833632.

Re: [R] nesting in CoxPH with survival package

2013-01-24 Thread Terry Therneau
In a Cox model, the baseline hazard takes the place of an intercept. Try the following: dummy <- rnorm(nrow(goodexp)) testfit <- lm(dummy ~ ExpTemp + Stability + Period, data=goodexp, x=T) Now look at testfit$x, which is the design matrix for the linear model with an intercept. Examinat

[R] Royston Parmar adjusted survival curves using flexsurv

2013-01-24 Thread Maziar Mohaddes
Dear R I am trying to understand and use the flexible parametric survival model suggested by Royston and Parmar. However I am stuck trying to plot the adjusted survival curves for different covariates in the following code: library(flexsurv) library(graphics) spl <- flexsurvspline(Surv(futime, fu

Re: [R] Pasting a list of parameters into a function

2013-01-24 Thread S Ellison
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of bsm2 > Sent: 23 January 2013 20:00 > To: r-help@r-project.org > Subject: [R] Pasting a list of parameters into a function > > I need to repeat a function many times, with diff

[R] scaling of nonbinROC penalties - accurate classification with random data?

2013-01-24 Thread Jonathan Williams
[[alternative HTML version deleted]] __ 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

[R] Wrong csv data?

2013-01-24 Thread Grigory Fateyev
Hello! I have csv file (attached) with any data, where first column is time. When I read into data.frame become temperature values. What it can be? data <- read.csv("rp5_vladimir2010.csv", colClasses = "character", sep = ";") names(data) data$Time data[,1] -- Всего наилучшего! greg [at] dobroe

[R] cptable too long for source -- gRain problem

2013-01-24 Thread Anna Eklöf
I have a code using the gRain package and there cptable is used to get the conditional probability tables. My problem is that when I want to use this table I get an error message that the file is too long to keep source. I have tried to change the option keep.source but without luck. Anyone expe

[R] mlogit Package

2013-01-24 Thread ehsan rahimi
I have problem as follows: I use "mlogit package" to develop a multinomial logit model but I can not find Percent Correctly predicted. would you help me?  Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://s

[R] Error with Expected Shortfall function, ES.

2013-01-24 Thread kevj1980
ES function gives the below error. > ES(sim, p=.95, method=c("modified"),portfolio_method=c("component"), > weights=w1) /Error in checkData(R, method = "xts", ...) : The data cannot be converted into a time series. If you are trying to pass in names from a data object with one column, you should

[R] How to add a function to another written code?

2013-01-24 Thread Jonsson
I have two directories https://echange-fichiers.inra.fr/get?k=AcHKdNI4No44GEsj7PK with 12 (global maps)binary files in each.I used the code given below to calculate the spatial correlation between these files and it worked well(the output is a global correlation map). I wonder if there is a simple

Re: [R] How to construct a valid seed for l'Ecuyer's method with given .Random.seed?

2013-01-24 Thread Duncan Murdoch
On 13-01-24 2:09 AM, Marius Hofert wrote: Dear Daniel, That's exactly what I also suspected (last post). The question now seems how to correctly convert .Random.seed from signed to unsigned so that it is accepted by the rlecuyer package. The rlecuyer package assumes that seed values are positi

[R] how to combine unequal rows and columns in R

2013-01-24 Thread Tammy Ma
HI, I have the following list: crosspries $crosspries[[1]] Product Year_Month prod1 A 2012081 B 2012082 C 2012081 $crosspries[[2]] Product Year_Monthprod1

Re: [R] long format with reshape

2013-01-24 Thread Gerrit Eichner
Hi, Daisy, try dat2 <- reshape( dat, varying = c( "species1", "species2", "species3"), v.name = "presence", timevar = "species", times = c( "species1", "species2", "species3"), direction="long") dat2[ rev( order( dat2$region)), ] Hth -- Ger

[R] long format with reshape

2013-01-24 Thread Daisy Englert Duursma
Hello, I tried using reshape to rearrange my data to long format but I could not get the output the table they way I wanted it. Anyway I came up with a hack that does works, but I still would like to know if I can do it with reshape. Here is my code and a dummy set of data. It returns the data in