Re: [R] Rounding to the nearest 5

2009-09-15 Thread Bill.Venables
x5 <- 5*round(x/5) From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Chris Li [chri...@austwaterenv.com.au] Sent: 16 September 2009 09:15 To: r-help@r-project.org Subject: [R] Rounding to the nearest 5 Hi all, I want to roun

[R] VAR analysis

2009-09-15 Thread MD. ABDULLAH AL MAMUN Mamun
[[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 provide commented, minimal, self-con

[R] How to calculate min of a dataset that contains empty column

2009-09-15 Thread Chris Li
Hi all, I have got a dataset like the following: a b c 1 5 2 3 7 I am taking the minimum of each column and use it as the minimum of the y-axis of my graphs. My scripts (simplified version) are like the following: f<-array f[1]=a f[2]=b f[3]=c for i in 1:3 name=f[i] ymin<-min(datas

Re: [R] cluster-lite

2009-09-15 Thread Henrik Bengtsson
The R.batch package does most of this. It's been several years, but I used it run batch jobs on multiple (30-40) machines with different OS:es but sharing the same file system. No communication needed between hosts. It worked like a charm and I could process 3-4 CPU years in a few weeks for some

[R] best method to format output of frequency table

2009-09-15 Thread esawdust
I have some security alert log data that I'm parsing and doing some stats on. One of the fields is the "Classtype" which is the enumerated value of the type of alert found. classtypes = factor( alerts$Classtype ) fclass_types = table( classtypes ) fclass_types gives me a frequency table of the

[R] Rounding to the nearest 5

2009-09-15 Thread Chris Li
Hi all, I want to round my values to the nearest 5. For example, if I have a value of 11, I want R to round it to 10. I have been searching for this command on the web and in the help file, but I couldn't find anything useful. Any help would be greatly appreciated. Many thanks, Chris -- View

Re: [R] Questions on pareto

2009-09-15 Thread TsubasaZero
Hi, Thanks a lot. I think this is what I want. actuar package get more distributions. Zero~ David Winsemius wrote: > > > On Sep 15, 2009, at 1:09 PM, TsubasaZero wrote: > >> >> Hi all, >> >> I had generated 1000 random variates (u,v), and I would like to find >> the >> corresponding (x,y

Re: [R] list of symbols to substitution

2009-09-15 Thread Schalk Heunis
Instead of eval(expr), use lapply(expr,eval) HTH Schalk Heunis On Wed, Sep 16, 2009 at 5:50 AM, Michael Spiegel < michael.m.spie...@gmail.com> wrote: > Hi, > > I'm trying to use a list of symbols as one of the values to be > substituted in a substitute expression, but I can't figure out how to

Re: [R] comma as decimal separator in xtable

2009-09-15 Thread Schalk Heunis
This might be of help, first applies the formatting:print(xtable(prettyNum(d, decimal.mark=","))) Schalk Heunis On Tue, Sep 15, 2009 at 5:06 PM, Jakson A. Aquino wrote: > Hello, > > How can I make xtable print a comma as decimal separator? Setting > the option OutDec isn't enough for xtable:

[R] list of symbols to substitution

2009-09-15 Thread Michael Spiegel
Hi, I'm trying to use a list of symbols as one of the values to be substituted in a substitute expression, but I can't figure out how to write the correct expression for my problem. Let me illustrate a simple example of what I'm trying to do. The following code snippet will evaluate to '5': sym

Re: [R] Teasing out logrank differences *between* groups using survdiff or something else?

2009-09-15 Thread Bryan Hanson
Thomas, thanks for your comments. We weren't entirely sure we we even framing the question right, your comments are encouraging. Here are our results: Call: coxph(formula = Surv(lifespan, status) ~ group, data = four) n= 573 coef exp(coef) se(coef) z Pr(>|z|) groupT1

Re: [R] Teasing out logrank differences *between* groups using survdiff or something else?

2009-09-15 Thread Thomas Lumley
I think you do in fact want to just run the analysis for the four groups you are interested in. The logrank chisquared test would then be of the hypothesis that these four groups have the same survival and censoring distributions, with the greatest power for detecting proportional-hazards diff

Re: [R] Teasing out logrank differences *between* groups using survdiff or something else?

2009-09-15 Thread David Winsemius
On Sep 15, 2009, at 9:58 PM, Bryan Hanson wrote: R Folk: Please forgive what I'm sure is a fairly naïve question; I hope it's clear. A colleague and I have been doing a really simple one-off survival analysis, but this is an area with which we are not very familiar, we just happen to hav

[R] plot sin wave and fft

2009-09-15 Thread Randall A. Blake
I am reading John R. Pierce's An Introduction to Information Theory and read that any wave can be decomposed into simple sin waves by means of a Fourier analysis. I would like to play with the idea a little and want to plot a couple simple sin waves in R; add them together as if they were bei

Re: [R] wilcox.test p-value = 0

2009-09-15 Thread Thomas Lumley
On Tue, 15 Sep 2009, Keo Ormsby wrote: Hi Murat, I am not an expert in either statistics nor R, but I can imagine that since the default is exact=TRUE, It numerically computes the probability, and it may indeed be 0. if you use wilcox.test(x, y, exact=FALSE) it will give you a normal aproxima

Re: [R] cluster-lite

2009-09-15 Thread Cedrick Johnson
perhaps a long shot but maybe the package 'nws' could handle some of it. I've recently begun looking into something similar lately as well. -c ivo welch wrote: I am about to write a "cluster-lite" R solution for myself. I wanted to know whether it already exists. If not, I will probably writ

[R] Teasing out logrank differences *between* groups using survdiff or something else?

2009-09-15 Thread Bryan Hanson
R Folk: Please forgive what I'm sure is a fairly naïve question; I hope it's clear. A colleague and I have been doing a really simple one-off survival analysis, but this is an area with which we are not very familiar, we just happen to have gathered some data that needs this type of analysis. We'

Re: [R] How to quickly find the position of the first non-zero element of a vector

2009-09-15 Thread jim holtman
Fast fingers. Had to change the test: > vlarge <- c(numeric(20),1:20) > system.time( + for (i in 1:3) { +which.min(!(vlarge != 0))}) # test changed user system elapsed 0.350.000.42 > > #Method 2: > system.time( + for (i in 1:3) { + for (i in 1:40) { + if (vlarge[

Re: [R] How to quickly find the position of the first non-zero element of a vector

2009-09-15 Thread jim holtman
try .which.mine Here is what is does on my system: > vlarge <- c(numeric(20),1:20) > system.time( + for (i in 1:3) { +which.min(vlarge != 0)}) user system elapsed 0.300.000.35 > > #Method 2: > system.time( + for (i in 1:3) { + for (i in 1:40) { + if (vlarge[i] != 0

Re: [R] how to load only lines that start with a particular symbol

2009-09-15 Thread Gabor Grothendieck
In the Windows cmd shell ^ means escape the next character so try this (assuming the data you posted is in genetest.dat in the current directory): > readLines(pipe("findstr/b ^> genetest.dat")) [1] ">gene A;." ">gene B;" and on UNIX replace "..." with the corresponding grep command making

Re: [R] Rounding to the nearest 5

2009-09-15 Thread jim holtman
you can also use: round(x / 5) * 5 > for (i in 1:20) cat(round(i / 5) * 5, ' ') 0 0 5 5 5 5 5 10 10 10 10 10 15 15 15 15 15 20 20 20 > On Tue, Sep 15, 2009 at 8:08 PM, J Chen wrote: > > hope this will help > > for (i in 1:10) { >    if (i%%5>2) { >    print((i%/%5+1)*5) >  

Re: [R] Regular expression problem

2009-09-15 Thread jim holtman
CHeck out this site: http://www.quanetic.com/Regex you can google 'regular expression tester' and find it. R uses the standard (whatever that is) expressions so check out tutorials you might find via google. On Tue, Sep 15, 2009 at 8:16 PM, wrote: > Thanks Jim and Rolf, > > grep("n.*mytype",m

Re: [R] Regular expression problem

2009-09-15 Thread Sebastien . Bihorel
Thanks Jim and Rolf, grep("n.*mytype",mystr) will do. I thought that * only applies on group of characters defined in a [] sequence. Would you be aware of any documentation/tutorial that would give slightly more detail and examples that the ?regexp? Also, would you be aware of any (online) tool t

Re: [R] Rounding to the nearest 5

2009-09-15 Thread J Chen
hope this will help for (i in 1:10) { if (i%%5>2) { print((i%/%5+1)*5) } else { print((i%/%5)*5) } } Jimmy Chris Li wrote: > > Hi all, > > I want to round my values to the nearest 5. > > For example, if I have a value of 11, I want R to round it to 10. > > I have be

[R] cluster-lite

2009-09-15 Thread ivo welch
I am about to write a "cluster-lite" R solution for myself. I wanted to know whether it already exists. If not, I will probably write up how I do this, and I will make the code available. Background: we have various linux and OSX systems, which are networked, but not set up as a cluster. I have

[R] How to quickly find the position of the first non-zero element of a vector

2009-09-15 Thread Bryan Keller
Anyone familiar with a quicker method to find the position of the first non-zero element of a vector? #The first way: print(min(which(vector != 0))) #The second way: for(i in 1:length(vector)) { if (vector[i] != 0) { print(i) break }

Re: [R] wilcox.test p-value = 0

2009-09-15 Thread Keo Ormsby
Hi Murat, I am not an expert in either statistics nor R, but I can imagine that since the default is exact=TRUE, It numerically computes the probability, and it may indeed be 0. if you use wilcox.test(x, y, exact=FALSE) it will give you a normal aproximation, which will most likely be differen

Re: [R] Regular expression problem

2009-09-15 Thread Rolf Turner
On 16/09/2009, at 9:58 AM, jim holtman wrote: try: grep("n.*mytype",mystr) [1] 1 with the [.] it is a class with a period. '.*' match zero, or more, characters. Perhaps the OP wants grep("n[.].*mytype",mystr) to insist that ``mystr'' contain the string ``n.'' (literal ``.'')

Re: [R] R console line-wrapping

2009-09-15 Thread David Winsemius
On Sep 15, 2009, at 5:47 PM, Nick Matzke wrote: Hi all, a quick question I couldn't find the answer to in the usual places: Is there a way to turn off line-wrapping in the R console? Or set the line width-before-wrapping manually? Currently it looks like the console linewraps after abo

Re: [R] Regular expression problem

2009-09-15 Thread jim holtman
try: > grep("n.*mytype",mystr) [1] 1 with the [.] it is a class with a period. '.*' match zero, or more, characters. On Tue, Sep 15, 2009 at 5:52 PM, Sebastien Bihorel wrote: > Dear R-users, > > I am trying to use the grep function to test whether a particular string is > of the form "n.../my

Re: [R] R console line-wrapping

2009-09-15 Thread Erik Iverson
See ?options, particularly the "width" setting. > options(width=200) Might do what you want, by default it is 80... Best, Erik Iverson -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Nick Matzke Sent: Tuesday, September 15, 2

[R] R console line-wrapping

2009-09-15 Thread Nick Matzke
Hi all, a quick question I couldn't find the answer to in the usual places: Is there a way to turn off line-wrapping in the R console? Or set the line width-before-wrapping manually? Currently it looks like the console linewraps after about 70 characters, this occurs even if I increase the w

[R] Regular expression problem

2009-09-15 Thread Sebastien Bihorel
Dear R-users, I am trying to use the grep function to test whether a particular string is of the form "n.../mydir/myfile.mytype.myext". Anything between n and mytype could vary, and anything after mytype could vary. I tried to proceed by steps to build my regular expression... but I do not rea

Re: [R] how to load only lines that start with a particular symbol

2009-09-15 Thread Doran, Harold
Along those lines, python is so easy to use for stuff like this. Sample code would be # Read in a file with the data filename = raw_input("Please enter the name of the original file: ") new_file = raw_input("Enter the name of the file to output: ") # create a new file defined by the user f = ope

Re: [R] how to load only lines that start with a particular symbol

2009-09-15 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of J Chen > Sent: Tuesday, September 15, 2009 2:00 PM > To: r-help@r-project.org > Subject: [R] how to load only lines that start with a > particular symbol > > > Dear all, > > I

Re: [R] why is nrow() so slow?

2009-09-15 Thread hadley wickham
> PS: Any speed suggestions are appreciated.  This is "experimenting time" for > me. You might want to check out the plyr package - it incorporates everything I know about making these sorts of operations fast. The next version will do even better. Hadley -- http://had.co.nz/

Re: [R] why is nrow() so slow?

2009-09-15 Thread jim holtman
'by' works with data.frames. Look at what happens if you don't send in a dataframe to 'by': > by.default function (data, INDICES, FUN, ..., simplify = TRUE) { dd <- as.data.frame(data) if (length(dim(data))) by(dd, INDICES, FUN, ..., simplify = simplify) else { if (!is

Re: [R] why is nrow() so slow?

2009-09-15 Thread ivo welch
interestingly, in my case, the opposite seems to be the case. data frames seem faster than matrices when it comes to "by" computation (which is where most of my calculations are in): ### here is my data frame and some information about it > dim(rets.subset) [1] 132508 3 > names(rets.subset)

Re: [R] How to remove 'NA's?

2009-09-15 Thread Erik Iverson
Well, how about the nomatch argument to the match function, see ?match . The nomatch argument is NA by default. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Tuesday, September 15, 2009 4:05 PM To: r-h...@stat.math.

Re: [R] How to remove 'NA's?

2009-09-15 Thread jim holtman
couple of different ways depending on what you want to do with the data: > match(c(3,4), c(3,2,1)) [1] 1 NA > match(c(3,4), c(3,2,1), nomatch=0) [1] 1 0 > x <- match(c(3,4), c(3,2,1)) > x[!is.na(x)] [1] 1 > On Tue, Sep 15, 2009 at 5:05 PM, Peng Yu wrote: > Hi, > >> match(c(3,4), c(3,2,1)) > [1

[R] How to remove 'NA's?

2009-09-15 Thread Peng Yu
Hi, > match(c(3,4), c(3,2,1)) [1] 1 NA The above result has 'NA' in. Is there a way to make 'match' does not produce any 'NA's? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

Re: [R] how to load only lines that start with a particular symbol

2009-09-15 Thread jim holtman
read in the data with 'readLines' and then use 'grep' > x [1] ">gene A;." "A" "T" "CCCTT" ">gene B;" "C" "G" > x <- x[grep("^>", x)] > x [1] ">gene A;." ">gene B;" > On Tue, Sep 15, 2009 at 4:59 PM, J Chen wrote: > > Dear all, > >

[R] wilcox.test p-value = 0

2009-09-15 Thread Murat Tasan
hi, folks, how have you gone about reporting a p-value from a test when the returned value from a test (in this case a rank-sum test) is numerically equal to 0 according to the machine? the next lowest value greater than zero that is distinct from zero on the machine is likely algorithm-dependent

[R] how to load only lines that start with a particular symbol

2009-09-15 Thread J Chen
Dear all, I have DNA sequence data which are fasta-formatted as >gene A;. A T CCCTT >gene B; C G I want to load only the lines that start with ">" where the annotation information for the gene is contained. In principle, I can remove the sequences bef

Re: [R] why is nrow() so slow?

2009-09-15 Thread Duncan Murdoch
On 9/15/2009 4:24 PM, ivo welch wrote: hi david---no, this time I actually know what I was asking ( ;-) ). I do need speed computed on many data sets, each of which is created by a "by" statement. so, no iterative programming on my side. thanks, hadley for the pointer to .row_names_info() in

Re: [R] why is nrow() so slow?

2009-09-15 Thread ivo welch
hi david---no, this time I actually know what I was asking ( ;-) ). I do need speed computed on many data sets, each of which is created by a "by" statement. so, no iterative programming on my side. thanks, hadley for the pointer to .row_names_info() in lieu of dim() or nrows(). I don't seem t

Re: [R] Viewing Function Code

2009-09-15 Thread Tobias Verbeke
Michael Pearmain wrote: I'd like to see the function code behind the barplots2() function in the gplots package, however i come across a bit of a stumbling block of a hidden function, can anyone help? library(gplots) methods(barplot2) [1] barplot2.default* Non-visible functions are asteri

Re: [R] Viewing Function Code

2009-09-15 Thread Erik Iverson
See the reference to ?getAnywhere in the following post: http://www.nabble.com/The-code-behind-the-function-td25370743.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Pearmain Sent: Tuesday, September 15, 2009 3:14 PM

[R] Viewing Function Code

2009-09-15 Thread Michael Pearmain
Hi All, I'd like to see the function code behind the barplots2() function in the gplots package, however i come across a bit of a stumbling block of a hidden function, can anyone help? > library(gplots) > methods(barplot2) [1] barplot2.default* Non-visible functions are asterisked > barplot2 f

Re: [R] Questions on pareto

2009-09-15 Thread David Winsemius
On Sep 15, 2009, at 1:09 PM, TsubasaZero wrote: Hi all, I had generated 1000 random variates (u,v), and I would like to find the corresponding (x,y) for a bivariate pareto distribution. Which x=inverse pareto of u and y=inverse pareto of v. What is the code I should use to find (x,y).

Re: [R] R Memory Usage Concerns

2009-09-15 Thread Carlos J. Gil Bellosta
Hello, I do not know whether my package "colbycol" may help you. It can help you read files that would not have fitted into memory otherwise. Internally, as the name indicates, data is read into R in a column by column fashion. IO times increase but you need just a fraction of "intermediate memo

Re: [R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread William Dunlap
Should the help file for identical() say that it mainly useful for testing code (as part of a QA program) and it is not recommended for general use? Currently help(identical) gives, IMO, inappropriate advice: A call to identical is the way to test exact equality in if and while statements,

Re: [R] Putting together a constantly evolving package

2009-09-15 Thread Romain Francois
Hi, Maybe you can put the sqlite database somewhere else in the package, for example: inst/sqlite/data.sqlite and access it like this : db <- system.file( "sqlite", "data.sqlite", package = "YourPackage" ) Romain On 09/15/2009 09:07 PM, Steve Lianoglou wrote: Hi all, I'm putting togethe

Re: [R] Putting together a constantly evolving package

2009-09-15 Thread Erik Iverson
Steve, I can't speak to your exact question, but perhaps suggest a simple alternative. What I do is simply make changes to the .R file containing my code, and use the "source" function to read in the new definitions of my functions while I'm tweaking them. Then, at the end of the day, I do my

Re: [R] Performance degradation on multi-processor system

2009-09-15 Thread mlopez
Has there been any progress in enabling R to take advantage of multiple processors? Rajiv Garg wrote: > > Hi, > > We are seeing performance degradation when running the same R script in > multiple instances of R on a multi-processor system. We are a bit > surprised by this because we figured

[R] Questions on pareto

2009-09-15 Thread TsubasaZero
Hi all, I had generated 1000 random variates (u,v), and I would like to find the corresponding (x,y) for a bivariate pareto distribution. Which x=inverse pareto of u and y=inverse pareto of v. What is the code I should use to find (x,y). Thanks a lot~~~ Zero~~ -- View this message in context:

[R] Putting together a constantly evolving package

2009-09-15 Thread Steve Lianoglou
Hi all, I'm putting together some common code + data into a custom package, everything is working out fine, but the ``R CMD INSTALL MyPackage`` call seems to take a particularly long time in the "**data" step: $ R CMD INSTALL MyPackage/ * installing to library ‘/Library/Frameworks/R.framewo

Re: [R] Reading a data frame from R to excel

2009-09-15 Thread Marc Schwartz
On Sep 15, 2009, at 4:58 AM, filip rendel wrote: Hello! I've generated multiple data frames that I wish to export to excel using the function write.table. When I do so all the data is merged into a single column in excel. I Would like the columns of my data frame in separate columns in ex

Re: [R] How to know the current line number in browser()?

2009-09-15 Thread Duncan Murdoch
On 9/15/2009 10:43 AM, Peng Yu wrote: Hi, I tried the command 'where' in browser(). But it does not give me the current line number (or the content of the current line). Is there a command for this? That is not supported in released versions of R, but it's in R-devel (which will become R 2.10

Re: [R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread Gavin Simpson
On Tue, 2009-09-15 at 18:04 +0100, Corrado wrote: > On Tuesday 15 September 2009 17:28:02 Gavin Simpson wrote: > > [note you don't give us your x so I'm making this up - This is what > > Duncan was going on about in an earlier thread, give us something we can > > just paste into R and it works] >

Re: [R] quoting a table name due to a special character in sqlQuery (RODBC)

2009-09-15 Thread Stefan Uhmann
It works, great! Thank you, Phil. /Stefan Phil Spector schrieb, Am 15.09.2009 18:28: Stefan - Have you tried surrounding the problem names with backticks (`) instead of quotes (' or ")? - Phil Spector Statis

Re: [R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread Seeliger . Curt
Corrado writes: > I do not understand what more information! Take any vector of length 1, for > example x<-1. Plus all the command that where in my previous email > > What is the logic behind > > identical(length(x),1) > > being false? identical() returns FALSE because they are not iden

Re: [R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread David Winsemius
On Sep 15, 2009, at 1:04 PM, Corrado wrote: On Tuesday 15 September 2009 17:28:02 Gavin Simpson wrote: [note you don't give us your x so I'm making this up - This is what Duncan was going on about in an earlier thread, give us something we can just paste into R and it works] Dear Gavin,

Re: [R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread Thomas Lumley
On Tue, 15 Sep 2009, Corrado wrote: On Tuesday 15 September 2009 17:28:02 Gavin Simpson wrote: [note you don't give us your x so I'm making this up - This is what Duncan was going on about in an earlier thread, give us something we can just paste into R and it works] Dear Gavin, I do not und

Re: [R] Factor Analysis function source code required

2009-09-15 Thread Thomas Lumley
On Tue, 15 Sep 2009, Moumita Das wrote: Hi All, There were lot of diffrences in the R and SPSS results for Exploratory Factor Analysis.why is it so ?I used standard factor analysis functions like:-- factanal(m, factors=3, rotation="varimax") princomp(m, cor = FALSE, scores = TRUE, subset = rep(

Re: [R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread Corrado
On Tuesday 15 September 2009 17:28:02 Gavin Simpson wrote: > [note you don't give us your x so I'm making this up - This is what > Duncan was going on about in an earlier thread, give us something we can > just paste into R and it works] Dear Gavin, I do not understand what more information! Take

Re: [R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread Gavin Simpson
On Tue, 2009-09-15 at 17:28 +0100, Gavin Simpson wrote: > On Tue, 2009-09-15 at 17:16 +0100, Corrado wrote: > > Dear R, > > Are you really looking for all.equal()? > > > isTRUE(all.equal(length(x), 1)) > [1] TRUE Please ignore that bit of rubbish above, clearly that is not what is required or w

Re: [R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread Gavin Simpson
On Tue, 2009-09-15 at 12:22 -0400, Steve Lianoglou wrote: > Hi, > I guess the lesson learned is that: > > identical() != == Indeed, and ?identical explains some of the motivation behind the function identical and the examples of said help page include the problem the OP faced... now where was t

Re: [R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread Gavin Simpson
On Tue, 2009-09-15 at 17:16 +0100, Corrado wrote: > Dear R, > > the condition: > > identical(length(x),1) returns FALSE > > but > > print(length(x)) > > returns 1 and: > > is.vector(x) is TRUE. > is.integer(length(x)) is TRUE > length(x) ==1 is TRUE > > I am puzzled. The key is noticing t

[R] Function returns different results on the vector as a whole vs. on the values of the vector

2009-09-15 Thread Corrado
Dear R friends, I have developed the function here below attached. Strangely, when I apply it to a vector it behaves very differently than when I apply it separately to each value of the vector itself. Is there any reason why? Here is the function: # TODO: Add comment # # Author: ct529, 3 Se

Re: [R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread Steve Lianoglou
Hi, On Sep 15, 2009, at 12:16 PM, Corrado wrote: Dear R, the condition: identical(length(x),1) returns FALSE but print(length(x)) returns 1 and: is.vector(x) is TRUE. is.integer(length(x)) is TRUE length(x) ==1 is TRUE I am puzzled. But is.integer(1) is FALSE and identical(length(x)

Re: [R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread Uwe Ligges
Corrado wrote: Dear R, the condition: identical(length(x),1) returns FALSE but print(length(x)) returns 1 and: is.vector(x) is TRUE. is.integer(length(x)) is TRUE length(x) ==1 is TRUE I am puzzled. Regards > is.integer(length(x)) [1] TRUE > is.integer(1) [1] FALSE Hence: > iden

[R] identical(length(x), 1) returns FALSE, but print(length(x)) is 1, length(x)==1 is TRUE, and is.integer(lenght(x)) is TRUE????

2009-09-15 Thread Corrado
Dear R, the condition: identical(length(x),1) returns FALSE but print(length(x)) returns 1 and: is.vector(x) is TRUE. is.integer(length(x)) is TRUE length(x) ==1 is TRUE I am puzzled. Regards -- Corrado Topi Global Climate Change & Biodiversity Indicators Area 18,Department of Biology U

Re: [R] why is nrow() so slow?

2009-09-15 Thread hadley wickham
On Tue, Sep 15, 2009 at 9:48 AM, ivo welch wrote: > dear R wizards:  here is the strange question for the day.  It seems to me > that nrow() is very slow.  Let me explain what I mean: > > ds= data.frame( NA, x=rnorm(1) )   ##  a sample data set > >> system.time( { for (i in 1:1) NA } )   #

Re: [R] Mantel test

2009-09-15 Thread Gavin Simpson
On Mon, 2009-09-14 at 23:46 -0700, swertie wrote: > oh yes of course. It is quite simple. I have two presence/absence matrices > (one for plants, one for butterflies) and I would like to test if the > butterfly community similarities is correlated with the plant community > similarities. The think

Re: [R] why is nrow() so slow?

2009-09-15 Thread David Winsemius
On Sep 15, 2009, at 10:48 AM, ivo welch wrote: dear R wizards: here is the strange question for the day. It seems to me that nrow() is very slow. Let me explain what I mean: ds= data.frame( NA, x=rnorm(1) ) ## a sample data set system.time( { for (i in 1:1) NA } ) ## doing

[R] coefficients of aov results has less number of elements?

2009-09-15 Thread Peng Yu
Hi, I run the following commands. 'A' has 3 levels and 'B' has 4 levels. Should there be totally 3+4 = 7 coefficients (A1, A2, A3, B1, B2, B3, B4)? > a=3 > b=4 > n=1000 > A = rep(sapply(1:a,function(x){rep(x,n)}),b) > B = as.vector(sapply(sapply(1:b, function(x){rep(x,n)}), > function(x){rep(x,a

[R] INSTALL html help (and vignettes) only?

2009-09-15 Thread Jonathan Baron
For maintaining my R search page at http://finzi.psych.upenn.edu (also used for RSiteSearch(), I have been extracting only the html help pages and the vignettes from most packages. (Many will not compile on Linux. And, more generally, this saves wear and tear on the computer and me.) I wrote a v

[R] two party questions: terminal stats and second dataset

2009-09-15 Thread AnnieE
Hi there, Question 1: Anybody out there know if there is a way to retrieve a list/table of ctree terminal node stats? If I could get a list containing each terminal node, and distributional stats for the training observations allocated to it (e.g., mean, standard deviation, range), I would be a

Re: [R] Reading a data frame from R to excel

2009-09-15 Thread Jorge Ivan Velez
Hi Filip, Try also: write.table(object, "yourpath_with_xls_extension",sep="\t", quote = FALSE) HTH, Jorge On Tue, Sep 15, 2009 at 5:58 AM, filip rendel <> wrote: > > Hello! I've generated multiple data frames that I wish to export to excel > using the function write.table. When I do so all the

[R] comma as decimal separator in xtable

2009-09-15 Thread Jakson A. Aquino
Hello, How can I make xtable print a comma as decimal separator? Setting the option OutDec isn't enough for xtable: library(xtable) options(OutDec = ",") x <- c(1.1, 1.2, 1.3) y <- c(2.3, 2.2, 2.1) d <- data.frame(x, y) d print(xtable(d)) Thanks! Jakson Aquino __

[R] Compare a group of line slopes

2009-09-15 Thread Jun Shen
Hi, all, I am thinking to compare a group of slopes from regression lines to see if they are different overall, and then make specific comparisons between groups. How can I achieve that in R? I searched the archives and there are only discussions about comparing two lines a time. Thanks. A samp

Re: [R] Subsetting matrix with values from vector

2009-09-15 Thread Jorge Ivan Velez
Hi jorgusch, First, do not call your data, "data" :-) require(fortunes) fortune('dog') Here are two suggestions to do what you asked for: # your data id <- 1:5 idnew <- 3:10 # to get the indexes id %in% idnew # to get the id's matching the new vector id[ id %in% idnew ] # another way inters

Re: [R] Reading a data frame from R to excel

2009-09-15 Thread Felipe Carrillo
I use sep="\t" for Excel files and sep="," for csv files. # Save to Excel write.table(objectname, file = "C:/Documents andSettings/Desktop/myfile.xls",sep="\t") Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish & Wildlife Service California, USA --- On

Re: [R] R Journal

2009-09-15 Thread David Winsemius
On Sep 15, 2009, at 10:36 AM, Robert Baer wrote: Is there a good search tool, either in R itself or in a public place, to search for R Journal (R News) articles on a given package or topic? I found the Table of Contents and the BibTex file, but I was looking for something a little more fl

Re: [R] Subsetting matrix with values from vector

2009-09-15 Thread Dimitris Rizopoulos
have a look at ?"%in%" Best, Dimitris jorgusch wrote: Hello, I have a large matrix (data), in which there is a column offerid. The values are numbers (lets say 1:5) There is another vector (idnew), which contains some of the offerids and many more (3:10). I want a subset of the matrix wiith

Re: [R] How can I use R:sort function in C code?

2009-09-15 Thread cls59
Guozhu.Wen wrote: > > Hi, I wrote a C extension for R. Within the C code I wanted to invoke the > R's sort function, with the argument "index.return = TRUE". I found it is > a > difficult problem, how can I do that? I have implemented the decreasing > sorting by the code "PROTECT(R_fcall = lang

[R] Factor Analysis function source code required

2009-09-15 Thread Moumita Das
Hi All, There were lot of diffrences in the R and SPSS results for Exploratory Factor Analysis.why is it so ?I used standard factor analysis functions like:-- factanal(m, factors=3, rotation="varimax") princomp(m, cor = FALSE, scores = TRUE, subset = rep(TRUE, nrow(as.matrix(m print(summary(pr

[R] legend disappeared after pdf() export to file

2009-09-15 Thread Thierry Janssens
Dear R-help, I am trying to print a graph with an additional legend to a pdf() or jpeg() file. Unfortunately the legend has completely disappeared in the file (pdf of jpeg) compared to what is in the graphics device of the Rgui. I positioned the legend after retrieving the x,y coordinates by th

[R] quoting a table name due to a special character in sqlQuery (RODBC)

2009-09-15 Thread Stefan Uhmann
Dear List, I have a problem with RODBC on a Paradox-DB, sqlQuery, and special characters in table names. Unfortunately, some of the latter include the underscore <_>. And I am not able to change them. That's not a problem, when I quote the table name: > sqlQuery(channel2, 'SELECT * FROM "anme

Re: [R] Reading a data frame from R to excel

2009-09-15 Thread Nandi
There is a package called 'xlsReadWrite', which has functions like read.xls & write.xls that might be helpful for you. You can also use write.table to produce .csv files, but you'll have to use it in the following manner: write.table(DataFrame, 'ExcelFile.csv', sep=",", col.names=T, row.names=F)

[R] why is nrow() so slow?

2009-09-15 Thread ivo welch
dear R wizards: here is the strange question for the day. It seems to me that nrow() is very slow. Let me explain what I mean: ds= data.frame( NA, x=rnorm(1) ) ## a sample data set > system.time( { for (i in 1:1) NA } ) ## doing nothing takes virtually no time user system elap

[R] Reg: R-systems in java

2009-09-15 Thread Sujin Chandra
Dear All, As I am doing a project in java and in that we need to integrate R software for displaying statistical graph using the different set of data. I don't have any idea on how to integrate R software in our java project. Kindly give basic idea about the R software and how to integrate in java

[R] Error...

2009-09-15 Thread Inez Campbell
Hi, I am trying to find in FAQ, in the manual, everywhere, the reason and most importantly, how to solve: Error: protect(): protection stack overflow It appeared after requesting a plot. Thanks, -- Inez __ R-help@r-project.org mailing list https://s

[R] R-squared in proportional hazards regression

2009-09-15 Thread Jenkins, Helen
Hi I'm trying to interpret the output from the coxph command. One of the outputs is: Rsquare= 0.01 (max possible= 0.069 ) Given that the methods for calculating R squared and its validity with proportional hazards regression are debated in the literature - can anyone tell me exactly how this

[R] Subsetting matrix with values from vector

2009-09-15 Thread jorgusch
Hello, I have a large matrix (data), in which there is a column offerid. The values are numbers (lets say 1:5) There is another vector (idnew), which contains some of the offerids and many more (3:10). I want a subset of the matrix wiith only those rows, which match the criteria of the vector.

Re: [R] Mantel test

2009-09-15 Thread swertie
oh yes of course. It is quite simple. I have two presence/absence matrices (one for plants, one for butterflies) and I would like to test if the butterfly community similarities is correlated with the plant community similarities. The think is also that I don't really see the purpose of doing a PC

Re: [R] Boost in R

2009-09-15 Thread Steve Lianoglou
Hi, On Sep 15, 2009, at 8:07 AM, MERAL YAY wrote: Hello, does any one know how to interpret this output in R? Classification with logitboost fit <- logitboost(xlearn, ylearn, xtest, presel=50, mfinal=20) summarize(fit, ytest) Minimal mcr: 0 achieved after 6 boosting step(s) Fixed mcr:

[R] How to know the current line number in browser()?

2009-09-15 Thread Peng Yu
Hi, I tried the command 'where' in browser(). But it does not give me the current line number (or the content of the current line). Is there a command for this? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-

[R] R Journal

2009-09-15 Thread Robert Baer
Is there a good search tool, either in R itself or in a public place, to search for R Journal (R News) articles on a given package or topic? I found the Table of Contents and the BibTex file, but I was looking for something a little more flexible. These lists are getting impressively long afte

  1   2   >