[R] Month Difference

2012-09-07 Thread Rantony
Hi, i need a small help. a- as.Date(2012-01-01) b- as.Date(2012-12-01) My requirement what is, i need to get the month difference of these two dates. Can any one help me please ! - Antony -- View this message in context:

Re: [R] Why the error is coming, can anyone help?

2012-09-07 Thread Sri krishna Devarayalu Balanagu
Thank you for the answer. It's working. But the error occurring here also df - paste(i)[, c(Reference_ID, Arm_ID)] How to get rid of that. -Original Message- From: William Dunlap [mailto:wdun...@tibco.com] Sent: Thursday, September 06, 2012 10:15 PM To: Sri krishna Devarayalu Balanagu;

[R] Quiry regardig the interpretation of graph

2012-09-07 Thread shabbir r khan srk
Dear Sir, I am shabbir Raza Khan doing research on arthropod diversity and environment. I have done some analysis on DCA using software PCORD 0.5 but I am unable to do the interpretation of the graph.Can you please help me for the interpretation of graph. Please reply my mail so that I can send

Re: [R] Why the error is coming, can anyone help?

2012-09-07 Thread Jim Holtman
'paste' does not return a matrix, so trying to extract with the '[' is incorrect. what did you expect from that expression? Sent from my iPad On Sep 7, 2012, at 2:41, Sri krishna Devarayalu Balanagu balanagudevaray...@gvkbio.com wrote: Thank you for the answer. It's working. But the

Re: [R] Query on how to do maximum likelihood fitting of a functional (MLFR)

2012-09-07 Thread Jose Iparraguirre
Turgut, I'm afraid you'll have to write it by yourself. Dhanoa and Sanderson (Can J Zool, 66:821-823, 2010) mention the FREML Excel add-in written by Ripley and Thompson (available on the Royal Society of Chemistry's website at the moment of writing that paper) and that the simulation and

[R] regions in Gabriel graph

2012-09-07 Thread Ondřej Mikula
Dear list, following the vignette of the package 'spacemmakeR' I have built a gabriel graph of ten randomly placed points: library(spdep) set.seed(3) xyir-matrix(runif(20),10,2) nbgab-graph2nb(gabrielneigh(xyir), sym=TRUE) plot(nbgab,xyir,points=FALSE)

Re: [R] text command - how to get a white background to cover grid lines

2012-09-07 Thread Jim Lemon
On 09/07/2012 07:30 AM, Levi Waldron wrote: For posterity, I found the TeachingDemos::shadowtext option most agreeable for this problem: * legend puts a large box around the text which did not seem possible to shrink, and does not accept vector x, y arguments * plotrix::boxed.labels

Re: [R] Month Difference

2012-09-07 Thread Berend Hasselman
On 07-09-2012, at 10:26, Rantony wrote: Hi, i need a small help. a- as.Date(2012-01-01) b- as.Date(2012-12-01) My requirement what is, i need to get the month difference of these two dates. One way is: library(zoo)

Re: [R] use of ddply() within function

2012-09-07 Thread Franckx Laurent
Problem solved, thanks. I've used this instead: COSTaux_AVCAR - ddply(CARaux,c(SC,YEAR),.fun = function(xx){sum(xx[ ,costcarin])}) -Original Message- From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] Sent: donderdag 6 september 2012 14:56 To: Franckx Laurent;

Re: [R] Month Difference

2012-09-07 Thread Marc Girondot
Le 07/09/12 10:26, Rantony a écrit : Hi, i need a small help. a- as.Date(2012-01-01) b- as.Date(2012-12-01) My requirement what is, i need to get the month difference of these two dates. Can any one help me please ! Here is a solution from here:

Re: [R] Month Difference

2012-09-07 Thread Akkara, Antony (GE Energy, Non-GE)
Yes. Its working fine. We need to convert to as.Date thatz all. Thank you Petr. -Original Message- From: PIKAL Petr [mailto:petr.pi...@precheza.cz] Sent: Friday, September 07, 2012 3:42 PM To: Akkara, Antony (GE Energy, Non-GE); r-help@r-project.org Subject: RE: [R] Month Difference One

Re: [R] Month Difference

2012-09-07 Thread PIKAL Petr
One possibility as.numeric(format(b, %m))-as.numeric(format(a, %m)) Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Rantony Sent: Friday, September 07, 2012 10:26 AM To: r-help@r-project.org Subject: [R] Month

[R] error: in catg (xi, name=nam, label=lab): LO2 has 2 category levels

2012-09-07 Thread Tvandenberg
Dear R-users, During a fit procedure in a Logistic prediction model I encounter the following problem: error: in catg (xi, name=nam, label=lab: X has 2 category levels The following code is used: fit -lrm(MRI_Diag_RC ~ factor(O4_1r) + N6_1r + leeftijd + LO1 + LO2 + LO3+ LO4+ LO5+ LO6+ LO7+

Re: [R] Why the error is coming, can anyone help?

2012-09-07 Thread Jeff Newmiller
Learn to use the str() function so you can answer these questions yourself. If you type str(paste(i)) you can learn about the structure of the return value from the paste function, which is not a matrix or a data frame, so two-dimensional subscripting is not going to work on it. You may also

Re: [R] Help! Weird behavioral difference between R interactive and command-line?

2012-09-07 Thread R. Michael Weylandt
On Thu, Sep 6, 2012 at 7:22 PM, Michael comtech@gmail.com wrote: Help! Weird behavioral difference between R interactive and command-line? Hi all, This weird problem has been bugging me for a while. If I run the R program in an interactive session, it worked; But if I run the R

Re: [R] creating a symmetric matrix

2012-09-07 Thread David L Carlson
You asked for existing functions, but I was more intrigued by trying to create one: symmat - function(n) { x - matrix(1:n, nrow=n, ncol=n) abs(x-col(x))+1 } symmat(4) [,1] [,2] [,3] [,4] [1,]1234 [2,]2123 [3,]3212 [4,]43

[R] Error when using s.multinom() of the ade4 package - %PCA and MCOA

2012-09-07 Thread Fridolin
Hello, I am working with s.multinom() from the ade4package. I tried to plot the results of my %PCA (via the function dudi.pca()) followed by a MCOA (mcoa()). But when I give my variables to s.multinom() I get the following Error message: Error in FUN(1:14[[1L]], ...) : number 1 profile without

Re: [R] error: in catg (xi, name=nam, label=lab): LO2 has 2 category levels

2012-09-07 Thread PIKAL Petr
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Tvandenberg Sent: Friday, September 07, 2012 1:05 PM To: r-help@r-project.org Subject: [R] error: in catg (xi, name=nam, label=lab): LO2 has 2 category levels Dear

Re: [R] error: in catg (xi, name=nam, label=lab): LO2 has 2 category levels

2012-09-07 Thread Frank Harrell
You appeaer to be using the rms package. Please follow the posting guide. The error message looks to be self-explanatory (empty cell); you just have to find which predictor it applies to. As an aside, rms does not like you to use factor() in a model, and there's probably a more concise way to

[R] metafor package: study level variation

2012-09-07 Thread Jarrett Byrnes
Hello. A quick question about incorporating variation due to study in the metafor package. I'm working with a particular data set for meta-analysis where some studies have multiple measurements. Others do not. So, let's say the effect I'm looking at is response to two different kinds of

Re: [R] error: in catg (xi, name=nam, label=lab): LO2 has 2 category levels

2012-09-07 Thread PIKAL Petr
Hi It is good to cc to list. Somebody could have better insight. Dear Petr, Thank you for responding. It seems right what you say. The funny thing however is that the 'LO2' variable in SPSS has 2 answer categories. If I look at the same variable in R, again I see 2 different values.

Re: [R] error: in catg (xi, name=nam, label=lab): LO2 has 2 category levels

2012-09-07 Thread Berg, Tobias van den
Dear all, Probably I made a beginners mistake. While importing a spss file I didn't specify that missings should be NA (use.missings = TRUE). Thanks to Petr Pikal and Bert Gunter I now know how to check how many values are known within a variable. Although I can fit my logistic model on this

[R] Predictions of every individual tree in Cforest

2012-09-07 Thread Boris Waelchli
Hello everyone I am a frequent user of Random Forests and have currently switch to apply cforest from the party package as it seems more appropriate to my current analysis. The problem I have is that I would like to see the individual predictions each tree in the cforest does for each

[R] Is something wrong wiht draw.circle()?

2012-09-07 Thread Chris82
Hey R users, I am a little bit confused. require(plotrix) plot(0,xlim=c(-10,10),ylim=c(-10,10),type=n,xlab=,ylab=) draw.circle(0,0,5) lines(c(0,0),c(0,5)) lines(c(0,5),c(0,0)) This is not really a circle with a radius of 5. best regards -- View this message in context:

Re: [R] [Rscript] difficulty passing named arguments from commandline

2012-09-07 Thread William Dunlap
The trailling arguments to Rscript, generally read by commandArgs(TRUE), come into R as a vector of character strings. Your script can interpret those character strings in many ways. The OP's script processed them all with eval(parse(text=arg[i])) so all the arguments had to be valid R

[R] Problem with duplicates in row.names

2012-09-07 Thread STADLER Frederic
Hello, I am drawing a heatmap with hundreds of genes. Everything work fine, except when I want to had the name of the genes as the row.names with row.names (a)-a$Name And there's this things that duplicate are not allowed... How can I do to allow duplicates ??? I don't have the choice I can't

Re: [R] error: in catg (xi, name=nam, label=lab): LO2 has 2 category levels

2012-09-07 Thread David Winsemius
On Sep 7, 2012, at 8:03 AM, Berg, Tobias van den wrote: Dear all, Probably I made a beginners mistake. While importing a spss file I didn't specify that missings should be NA (use.missings = TRUE). Thanks to Petr Pikal and Bert Gunter I now know how to check how many values are known

Re: [R] creating a symmetric matrix

2012-09-07 Thread Bert Gunter
??? A previous answer pointed out ?toeplitz entering toeplitz gives { if (!is.vector(x)) stop('x' is not a vector) n - length(x) A - matrix(0, n, n) matrix(x[abs(col(A) - row(A)) + 1], n, n) } Why reinvent? -- Bert On Fri, Sep 7, 2012 at 8:19 AM, David L Carlson

Re: [R] Package installation errors

2012-09-07 Thread Uwe Ligges
On 06.09.2012 20:58, Santosh wrote: Dear Rxperts.. I am trying to install a few packages in R (version 2.14.2) on a *64-bit Window 7* workstation. Some of the errors are posted below.. Both 32-bit and 64-bit versions of R were installed. I did not get errors while installing packages through

Re: [R] Is something wrong wiht draw.circle()?

2012-09-07 Thread Peter Langfelder
On Fri, Sep 7, 2012 at 9:04 AM, Chris82 rubenba...@gmx.de wrote: Hey R users, I am a little bit confused. require(plotrix) plot(0,xlim=c(-10,10),ylim=c(-10,10),type=n,xlab=,ylab=) draw.circle(0,0,5) lines(c(0,0),c(0,5)) lines(c(0,5),c(0,0)) The culprit are unequal margins. Issue

Re: [R] Is something wrong wiht draw.circle()?

2012-09-07 Thread William Dunlap
Add asp=1 to your call to plot() to force equal scales on both axes. 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 Behalf Of Peter Langfelder Sent: Friday, September 07, 2012

[R] splitting character vectors into multiple vectors using strsplit

2012-09-07 Thread David Romano
Hi folks, Suppose I create the character vector charvec by charvec-c(a1.b1,a2.b2) charvec [1] a1.b1 a2.b2 and then I use strsplit on charvec as follows: splitlist-strsplit(charvec,split=.,fixed=TRUE) splitlist [[1]] [1] a1 b1 [[2]] [1] a2 b2 I was wondering whether there is already a

Re: [R] splitting character vectors into multiple vectors using strsplit

2012-09-07 Thread Duncan Murdoch
On 07/09/2012 2:12 PM, David Romano wrote: Hi folks, Suppose I create the character vector charvec by charvec-c(a1.b1,a2.b2) charvec [1] a1.b1 a2.b2 and then I use strsplit on charvec as follows: splitlist-strsplit(charvec,split=.,fixed=TRUE) splitlist [[1]] [1] a1 b1 [[2]] [1] a2 b2

[R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread wwreith
I am just starting to experiment with writing a function and have run into what seems like a limitation or more likely a lack of understanding on my part. Very Simple Example: I want to define a function that does 1+1=2. z-1 ADD-function(x) { x-x+1 } ADD(z) z output for z is 1 not the

Re: [R] splitting character vectors into multiple vectors using strsplit

2012-09-07 Thread Richard M. Heiberger
If you know that there are exactly the same number of items in each string, then something simpler can be constructed. matrix(unlist(splitlist), length(splitlist[[1]]), length(splitlist)) [,1] [,2] [1,] a1 a2 [2,] b1 b2 The rows above are what you are looking for. If you intend to treat

[R] Contrasts for 2x4 interaction in mixed effects model

2012-09-07 Thread Stephen Politzer-Ahles
Hello everyone, I am running a mixed effects model where I have two fixed factors, one with 2 levels and one with 4, and their interaction. Let's say these are my factors and their levels: FirstFactor: 1, 2 SecondFactor: A, B, C, D For the interaction, I am interested in the four two-way

Re: [R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread Berend Hasselman
On 07-09-2012, at 20:00, wwreith wrote: I am just starting to experiment with writing a function and have run into what seems like a limitation or more likely a lack of understanding on my part. Very Simple Example: I want to define a function that does 1+1=2. z-1 ADD-function(x) {

Re: [R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread William Dunlap
Berend, The OP's ADD() is returning the new value of x, as do all of your alternatives. His problem is that he is not assigning the output of ADD to a variable, as in z - ADD(z) Ordinary functions do not alter their arguments. There is no need for the 'x -' in the definiton of ADD. It may

Re: [R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread Berend Hasselman
On 07-09-2012, at 21:32, William Dunlap wrote: Berend, The OP's ADD() is returning the new value of x, as do all of your alternatives. His problem is that he is not assigning the output of ADD to a variable, as in z - ADD(z) Ordinary functions do not alter their arguments. There is

Re: [R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread William Dunlap
The functions f1 - function(x) x - x + 1 and f2 - function(x) x + 1 both return the same value. You can see this by doing z1 - f1(10) ; print(z1) z2 - f2(10) ; print(z2) or just print(f1(10)) print(f2(10)) f1(x) does not automatically print its output when run directly from the

Re: [R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread Berend Hasselman
On 07-09-2012, at 21:54, William Dunlap wrote: The functions f1 - function(x) x - x + 1 and f2 - function(x) x + 1 both return the same value. You can see this by doing z1 - f1(10) ; print(z1) z2 - f2(10) ; print(z2) or just print(f1(10)) print(f2(10)) f1(x) does not

Re: [R] splitting character vectors into multiple vectors using strsplit

2012-09-07 Thread arun
Hi, You can also try this: unlist(lapply(splitlist,head,1)) #[1] a1 a2  unlist(lapply(splitlist,tail,1)) #[1] b1 b2 A.K. From: David Romano roma...@grinnell.edu To: r-help@r-project.org Sent: Friday, September 7, 2012 2:12 PM Subject: [R] splitting

Re: [R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread Bert Gunter
WHEW! Have you read An Introduction to R? If not, stop and do so. If you have, stop and do so again. Or look for other web tutorials (you may get some suggestions here) or books (CRAN is a good place to look for this). The problem is that you are so far from understanding how a function works,

Re: [R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread Rui Barradas
Hello, Start by (re-)reading An Introduction to R, file R-intro.pdf in your doc directory. Chapter 10. You're just computing, not returning the result of that computation. Nor anything else, ADD() does not return a value. (See the example in R-intro, section 10.1) And you need to assign the

[R] Closing WinBugs 14 window

2012-09-07 Thread Apt Alx
Hi all I am using WinBugs 14, and packages arm, rbugs to call WinBugs from R. I have to do the analysis for a series for data sets. I have a for loop which calls function bugs and then saves the result in Res[[i]]. Everything works just fine in the R script. However the for loop is for i in

Re: [R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread David Winsemius
On Sep 7, 2012, at 11:00 AM, wwreith wrote: I am just starting to experiment with writing a function and have run into what seems like a limitation or more likely a lack of understanding on my part. Very Simple Example: I want to define a function that does 1+1=2. z-1 ADD-function(x)

Re: [R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread David Winsemius
On Sep 7, 2012, at 1:34 PM, David Winsemius wrote: On Sep 7, 2012, at 11:00 AM, wwreith wrote: I am just starting to experiment with writing a function and have run into what seems like a limitation or more likely a lack of understanding on my part. Very Simple Example: I want to

Re: [R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread Ista Zahn
On Fri, Sep 7, 2012 at 3:16 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, Start by (re-)reading An Introduction to R, file R-intro.pdf in your doc directory. Chapter 10. You're just computing, not returning the result of that computation. Nor anything else, ADD() does not return a

Re: [R] Contrasts for 2x4 interaction in mixed effects model

2012-09-07 Thread Richard M. Heiberger
Stephen, You are looking for the nesting of the FirstFactor within the SecondFactor. Here is an example for your two-way design. The model.matrix shows the dummy variables. The last four columns show the two-level comparisons of Fir within each level of Sec Rich tmp - data.frame(y=rnorm(16),

Re: [R] Trying to learn how to write a function... can't define a variable??

2012-09-07 Thread William Dunlap
ADD - function(x) x - x+1 This would not solve the user's problem. x - something assigns something to a variable called (literally) 'x' in the first ancestral environment of ADD that already contains a variable called 'x' or in the global environment if 'x' were not found. E.g.,

Re: [R] splitting character vectors into multiple vectors using strsplit

2012-09-07 Thread arun
Hi, You can also try this:  sapply(lapply(splitlist,rle),`[[`,2)[1,] #[1] a1 a2  sapply(lapply(splitlist,rle),`[[`,2)[2,] #[1] b1 b2 A.K. - Original Message - From: David Romano roma...@grinnell.edu To: r-help@r-project.org Cc: Sent: Friday, September 7, 2012 2:12 PM Subject: [R]

[R] Producing a table with mean values

2012-09-07 Thread Tinus Sonnekus
Hi All, I have a data set wit three size classes (pico, nano and micro) and 12 different sites (Seamounts). I want to produce a table with the mean and standard deviation values for each site. Seamount PicoNano MicroTotal_Ch 1 Off_Mount 1 0.0691 0.24200 0.00100 0.31210 2

Re: [R] Producing a table with mean values

2012-09-07 Thread David Winsemius
On Sep 7, 2012, at 1:49 PM, Tinus Sonnekus wrote: Hi All, I have a data set wit three size classes (pico, nano and micro) and 12 different sites (Seamounts). I want to produce a table with the mean and standard deviation values for each site. Seamount PicoNano Micro

Re: [R] Producing a table with mean values

2012-09-07 Thread Rui Barradas
Hello, Try the following. agg1 - aggregate(cbind(Pico, Nano, Micro) ~ Seamount, data = SChla, mean) agg2 - aggregate(cbind(Pico, Nano, Micro) ~ Seamount, data = SChla, sd) names(agg1)[-1] - paste(u, names(agg1)[-1], sep = .) names(agg2)[-1] - paste(sd, names(agg2)[-1], sep = .) merge(agg1,

Re: [R] Producing a table with mean values

2012-09-07 Thread Duncan Murdoch
On 12-09-07 4:49 PM, Tinus Sonnekus wrote: Hi All, I have a data set wit three size classes (pico, nano and micro) and 12 different sites (Seamounts). I want to produce a table with the mean and standard deviation values for each site. Seamount PicoNano MicroTotal_Ch 1

Re: [R] Problem with duplicates in row.names

2012-09-07 Thread Jeff Newmiller
You cannot have duplicate row names. You have to do something to address that, such as remove duplicates or aggregate your data. --- Jeff NewmillerThe . . Go Live...

Re: [R] Producing a table with mean values

2012-09-07 Thread arun
Hi, Try this: dat1-read.table(text=  Seamount    Pico    Nano  Micro    Total_Ch   1 0.0691 0.24200 0.00100  0.31210   1 0.0938 0.00521 0.02060  0.11961   1 0.1130 0.2 0.06620  0.37920   1 0.0864 0.15900 0.22300  0.46840   1 0.0262 0.04570 0.00261  0.07451   2 0.0314 0.17400 0.12800  0.33340

[R] reshape and geeglm problem

2012-09-07 Thread Lilia Verchinina
Dear R users, could you please help me figure out why I am getting an error? Initially my data looks like this: attributes(compl)$names [1] UserID compl_bin Sex.x PHQ_base PHQ_Surv1 PHQ_Surv2 PHQ_Surv3 [8] PHQ_Surv4 EFENeuro

Re: [R] Problem with duplicates in row.names

2012-09-07 Thread J Toll
On Fri, Sep 7, 2012 at 11:04 AM, STADLER Frederic frederic.stad...@unifr.ch wrote: Hello, I am drawing a heatmap with hundreds of genes. Everything work fine, except when I want to had the name of the genes as the row.names with row.names (a)-a$Name And there's this things that duplicate are

[R] Can I make spss.get reencode from Windows-1252?

2012-09-07 Thread Dan Delaney
Hi all. I have an SPSS file that I'm loading into R with the Hmisc spss.get function. The trouble is that the SPSS file uses the Windows-1252 character set (which I think is the default for SPSS on Windows) instead of plain-ol' Latin-1, and since spss.get doesn't allow me to pass the reencode

[R] How to Rename Column Labels?

2012-09-07 Thread Youn Se Hwan
Hi, How do I rename the column labels in the table? For Instance, if I have a table like this, and I want to have the column labels changed from A1 A2 A3 A4 A5 to Mike Kate Michelle Paul Young A1 A2 A3A4A5 1 3344 55 6677 2 3 4 5 6 7 7 8 9 and my text