Re: [R] Assigning variable value as name to cbind column

2010-06-24 Thread Bill.Venables
Why does the naming have to be done inside the cbind()? How about > dataTest <- data.frame(col1 = c(1,2,3)) > new.data <- c(1,2) > name <- "test" > length(new.data) <- nrow(dataTest) > newDataTest <- cbind(dataTest, new.data) > names(newDataTest)[[ncol(newDataTest)]] <- name > newDataTest col1

[R] Assigning variable value as name to cbind column

2010-06-24 Thread Ralf B
Hi all, I have this (non-working) script: dataTest <- data.frame(col1=c(1,2,3)) new.data <- c(1,2) name <- "test" n.row <- dim(dataTest)[1] length(new.data) <- n.row names(new.data) <- name cbind(dataTest, name=new.data) print(dataTest) and would like to bind the new column 'new.data' to 'dataTe

Re: [R] Install package automatically if not there?

2010-06-24 Thread Prof Brian Ripley
On Thu, 24 Jun 2010, Bert Gunter wrote: You mean if a "package" has been installed?! (big difference) ?installed.packages or ?.packages with all.available = TRUE Various people have suggested those. Can I point out that they are very slow with a few thousand packages installed, especially

Re: [R] what "density" is plotting ?

2010-06-24 Thread Jeff Newmiller
?density Or http://en.m.wikipedia.org/wiki/Kernel_density_estimation?wasRedirected=true "Ralf B" wrote: >The density function works empirically based on your data. It makes no >assumption about an underlying distribution. > >Ralf > >On Thu, Jun 24, 2010 at 10:48 PM, Carrie Li wrote: >> Hello,

Re: [R] ask a question about list in R

2010-06-24 Thread Phil Spector
Song - Set the element to NULL: al=list(c(2,3),5,7) al[[2]] = NULL al [[1]] [1] 2 3 [[2]] [1] 7 - Phil Spector Statistical Computing Facility Department of Statistics

[R] ask a question about list in R

2010-06-24 Thread song song
my list al is as below: al=list(c(2,3),5,7) > al [[1]] [1] 2 3 [[2]] [1] 5 [[3]] [1] 7 and I check the second component, its element is 5, then I remove this, now my al is: al[[2]][al[[2]]!=5]->al[[2]] > al [[1]] [1] 2 3 [[2]] numeric(0) [[3]] [1] 7 The Question is, how I can get the new li

Re: [R] ggplot2: deterministic position_jitter & geom_line with position_jitter

2010-06-24 Thread meow9th
I'm having the same problem as Stephan (see below), but what I'm trying to jitter is not a numeric vector, but a factor. How do I proceed? (Naively jittering a factor makes it numeric, no longer factor, so I don't get the custom ordering which conveniently comes with using a factor. I'm not sure h

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-24 Thread David Winsemius
On Jun 24, 2010, at 6:58 PM, Atte Tenkanen wrote: Is there anything for me? There is a lot of data, n=2418, but there are also a lot of ties. My sample n≈250-300 I do not understand why there should be so many ties. You have not described the measurement process or units. ( ... although

Re: [R] Simple qqplot question

2010-06-24 Thread Ralf B
Short rep: I have two distributions, data and data2; each build from about 3 million data points; they appear similar when looking at densities and histograms. I plotted qqplots for further eye-balling: qqplot(data, data2, xlab = "1", ylab = "2") and get an almost perfect diagonal line which mean

Re: [R] what "density" is plotting ?

2010-06-24 Thread Ralf B
The density function works empirically based on your data. It makes no assumption about an underlying distribution. Ralf On Thu, Jun 24, 2010 at 10:48 PM, Carrie Li wrote: > Hello, Ralf, > > Sorry I was being clear. > I mean probability density function > like normal f(x)=(1/2*pi*sd )*exp() 

[R] Label Values in levelplot

2010-06-24 Thread Ben Wilkinson
I am trying to add labels equal to the value in a levelplot. I believe that panel may be the way to go but cannot understand the examples. In the following example: X,Y,Z A,M,100 A,M,200 B,N,150 B,N,225 I would like to label each of the rectangles 100,200,150 and 225 and colour according to the

Re: [R] Handouts / Reports or just simply printing text to PDF?

2010-06-24 Thread Erik Iverson
Ralf B wrote: I assume R won't easily generate nice reports (unless one starts using Sweave and LaTeX) but perhaps somebody here knows a package that can create report like output for special cases? How can I simply plot output into PDF? See ?pdf if you just want to save plots into a PDF file.

Re: [R] what "density" is plotting ?

2010-06-24 Thread Carrie Li
Hello, Ralf, Sorry I was being clear. I mean probability density function like normal f(x)=(1/2*pi*sd )*exp() something like that . Sorry about the confusion Carrie On Thu, Jun 24, 2010 at 10:43 PM, Ralf B wrote: > Hi Carrie, > > the output is defined by you; density() only creates the fu

Re: [R] what "density" is plotting ?

2010-06-24 Thread Ralf B
Hi Carrie, the output is defined by you; density() only creates the function which you need to plot using the plot() function. When you call plot(density(x)) you get the output on the screen. You need to use pdf() if you want to create a pdf file, png() for creating a png file or postscript if you

[R] what "density" is plotting ?

2010-06-24 Thread Carrie Li
Hi everyone, I am confused regarding the function "density". suppose that there is a sample x of 100 data points, and plot(density(x)) gives it's pdf ? or it's more like histogram only ? thanks for any answering Carrie [[alternative HTML version deleted]] __

[R] Handouts / Reports or just simply printing text to PDF?

2010-06-24 Thread Ralf B
I assume R won't easily generate nice reports (unless one starts using Sweave and LaTeX) but perhaps somebody here knows a package that can create report like output for special cases? How can I simply plot output into PDF? Perhaps you know a package I should check out? What do you guys do to creat

Re: [R] dimnames(x) <- dn error

2010-06-24 Thread Joshua Wiley
Hello Ayesha, What would you like the rownames to be? Your problem is that dim(distF)[1] will return the length of the 1st dimension; this is a single number. This code shows what happens and gives you some alternatives. temp.data <- matrix(1:9, ncol=3) temp.data dim(temp.data)[1] ## Possible

[R] dimnames(x) <- dn error

2010-06-24 Thread Ayesha Khan
Hi , I want to assign names to the rows in my matrix so that when I use the 'agnes' function from R cluster package , the dendogram that is produced represents the rows of the matrix. This way I would know what elements in the matrix are clustered together. But when I do the following, rownames(di

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-24 Thread Atte Tenkanen
Is there anything for me? There is a lot of data, n=2418, but there are also a lot of ties. My sample n≈250-300 i would like to test, whether the mean of the sample differ significantly from the population mean. The histogram of the population looks like in attached histogram, what test should

Re: [R] Popularity of R, SAS, SPSS, Stata...

2010-06-24 Thread Jeremy Miles
I think you need speech marks though: http://www.google.com/insights/search/#q=%22r%20code%20for%22%2C%22sas%20code%20for%22%2C%22spss%20code%20for%22&cmpt=q (There's not a lot of people looking for SPSS code ...) Jeremy On 24 June 2010 16:56, Joris Meys wrote: > Nice idea, but quite sensitive

Re: [R] Simple qqplot question

2010-06-24 Thread Ralf B
Unfortunately not. I want a qqplot from two variables. Ralf On Thu, Jun 24, 2010 at 7:23 PM, Joris Meys wrote: > Also take a look at qq.plot in the package "car". Gives you exactly > what you want. > Cheers > Joris > > On Fri, Jun 25, 2010 at 12:55 AM, Ralf B wrote: >> More details... >> >> I

Re: [R] write a loop for tallies

2010-06-24 Thread Joris Meys
It would help if you placed r <- 0; s <- 0 etc. outside the loop. Same goes for cat(...). And get rid of the sum(r), sum(s) and so on, that's doing nothing (r,s,... are single numbers) This said : See Peter Langfelder's response. Cheers Joris > # see ?table for a better approach > r<-0 > s<-0 >

Re: [R] Popularity of R, SAS, SPSS, Stata...

2010-06-24 Thread Joris Meys
dangit, tab in the way... On Fri, Jun 25, 2010 at 1:56 AM, Joris Meys wrote: > Nice idea, but quite sensitive to search terms, if you compare your > result on "... code" with "... code for": > http://www.google.com/insights/search/#q=r%20code%20for%2Csas%20code%20for%2Cspss%20code%20for&cmpt=q T

Re: [R] Popularity of R, SAS, SPSS, Stata...

2010-06-24 Thread Joris Meys
Nice idea, but quite sensitive to search terms, if you compare your result on "... code" with "... code for": http://www.google.com/insights/search/#q=r%20code%20for%2Csas%20code%20for%2Cspss%20code%20for&cmpt=q On Thu, Jun 24, 2010 at 10:48 PM, Dario Solari wrote: > First: excuse for my english

Re: [R] Install package automatically if not there?

2010-06-24 Thread Joris Meys
If you want to make changes more permanent, you should take a look at the "Rprofile.site" file. This one gets loaded in R at the startup of the console. You can set the CRAN there if you want too. Cheers Joris On Fri, Jun 25, 2010 at 1:32 AM, Joshua Wiley wrote: > Hello Ralf, > > Glad it works f

Re: [R] Install package automatically if not there?

2010-06-24 Thread Joshua Wiley
Hello Ralf, Glad it works for you. As far as avoiding any prompting if packages are out-of-date; I am not sure. It honestly seems like a risky idea to me to have old packages being overwritten without a user knowing. However, I added a few lines of code here to set the CRAN mirror, and revert it

Re: [R] Install package automatically if not there?

2010-06-24 Thread Joris Meys
I've never seen R been Perl'd this nice before. On Thu, Jun 24, 2010 at 10:32 PM, Albert-Jan Roskam wrote: > require(pkg) || install.packages(pkg) > > Cheers!! > > Albert-Jan > > > > ~~ > > All right, but apart from the sanitatio

Re: [R] Simple qqplot question

2010-06-24 Thread Joris Meys
Also take a look at qq.plot in the package "car". Gives you exactly what you want. Cheers Joris On Fri, Jun 25, 2010 at 12:55 AM, Ralf B wrote: > More details... > > I have two distributions which are very similar. I have plotted > density plots already from the two distributions. In addition, >

[R] BBH2 and FrF2 packages

2010-06-24 Thread Andrea Bernasconi DG
Hi R HELP, I consider the 2^3 factorial experiment described at page 177 of the book Statistics for Experimenters: Design, Innovation, and Discovery by George E. P. Box, J. Stuart Hunter, William G. Hunter (BHH2). This example use the following data in file BHH2-Data/tab0502.dat at ftp://ftp.wile

Re: [R] help, bifurcation diagram efficiency

2010-06-24 Thread Joris Meys
Basically, don't write loops. Think vectors, matrices,... The R Inferno of Patrick Burns contains a lot of valuable information on optimizing code : http://lib.stat.cmu.edu/S/Spoetry/Tutor/R_inferno.pdf Cheers Joris On Thu, Jun 24, 2010 at 7:51 PM, Tyler Massaro wrote: > Hello all - > > This c

Re: [R] write a loop for tallies

2010-06-24 Thread Erik Iverson
On average, any data manipulation that can be described in a sentence or two of English can be programmed in one line in R. If you find yourself writing a long 'for' loop to do something that sounds simple, take a step back and research if an existing combination of functions can easily handle y

Re: [R] Simple qqplot question

2010-06-24 Thread Bert Gunter
?qqplot ## note the "Value" section ?abline z <- qqplot(datax,datay) abline(reg=lm(z$y ~ z$x)) As the help for abline says, you can fit any line you like, perhaps a simple resistant one would be better as in ?line, in which case use abline(reg= line(z$x, z$y)) ## note x's and y's are reversed

Re: [R] Simple qqplot question

2010-06-24 Thread Ralf B
More details... I have two distributions which are very similar. I have plotted density plots already from the two distributions. In addition, I created a qqplot that show an almost straight line. What I want is a line that represents the ideal case in which the two distributions match perfectly.

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-24 Thread David Winsemius
On Jun 24, 2010, at 6:42 PM, Joris Meys wrote: On Fri, Jun 25, 2010 at 12:17 AM, David Winsemius wrote: On Jun 24, 2010, at 6:09 PM, Joris Meys wrote: I do agree that one should not trust solely on sources like wikipedia and graphpad, although they contain a lot of valuable information.

Re: [R] Sending a null byte to a socket

2010-06-24 Thread Dan Tenenbaum
OK, I figured this out: > s <- "CONNECT\n\n" > con <- socketConnection(port=61613, blocking=F) > writeChar(s, con, nchar(s)) > r = readLines(con) > r [1] "CONNECTED" "session:ID:yourhost.yourdomain.com-49763-1276709732624-4:28" "" [4] "" > close(con) Thanks Dan On Wed, Jun 16, 2010 at 12:52

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-24 Thread Joris Meys
On Fri, Jun 25, 2010 at 12:17 AM, David Winsemius wrote: > > On Jun 24, 2010, at 6:09 PM, Joris Meys wrote: > >> I do agree that one should not trust solely on sources like wikipedia >> and graphpad, although they contain a lot of valuable information. >> >> This said, it is not too difficult to i

Re: [R] write a loop for tallies

2010-06-24 Thread Peter Langfelder
On Thu, Jun 24, 2010 at 3:16 PM, john polo wrote: > Dear R users, > > I have a list of numbers such as > >> n > [1] 3000 4000 5000 3000 5000 6000 4000 5000 7000 5000 6000 7000 > > and i'd like to set up a loop that will keep track of the number of > occurences of each of the values that occur in t

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-24 Thread David Winsemius
On Jun 24, 2010, at 6:09 PM, Joris Meys wrote: I do agree that one should not trust solely on sources like wikipedia and graphpad, although they contain a lot of valuable information. This said, it is not too difficult to illustrate why, in the case of the one-sample signed rank test, That i

[R] write a loop for tallies

2010-06-24 Thread john polo
Dear R users, I have a list of numbers such as > n [1] 3000 4000 5000 3000 5000 6000 4000 5000 7000 5000 6000 7000 and i'd like to set up a loop that will keep track of the number of occurences of each of the values that occur in the list, e.g. 3000: 2 4000: 2 5000: 4 I came up with the fol

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-24 Thread Joris Meys
I do agree that one should not trust solely on sources like wikipedia and graphpad, although they contain a lot of valuable information. This said, it is not too difficult to illustrate why, in the case of the one-sample signed rank test, the differences should be not to far away from symmetrical.

Re: [R] Simple qqplot question

2010-06-24 Thread Greg Snow
The line for the perfect match would be abline(0,1) if you want to allow affine transformations, then it gets a bit harder. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-pr

Re: [R] Simple qqplot question

2010-06-24 Thread stephen sefick
You are going to have to define the question a little better. Also, please provide a reproducible example. On Thu, Jun 24, 2010 at 4:44 PM, Ralf B wrote: > I am a beginner in R, so please don't step on me if this is too > simple. I have two data sets datax and datay for which I created a > qqplo

[R] Simple qqplot question

2010-06-24 Thread Ralf B
I am a beginner in R, so please don't step on me if this is too simple. I have two data sets datax and datay for which I created a qqplot qqplot(datax,datay) but now I want a line that indicates the perfect match so that I can see how much the plot diverts from the ideal. This ideal however is no

Re: [R] [OT] Combinatorials wtih constraints

2010-06-24 Thread Ted Harding
That's neat, Greg! (As code, anyway). There was I, thinking about how best to build it up by construction, then your "slash-and-burn" technique does it in one line. But was this the right problem, or the alternative that Bert Gunter suggested? Ted. On 24-Jun-10 21:06:06, Greg Snow wrote: > Well h

Re: [R] Displaying additional values on the Y-axis ggplot2

2010-06-24 Thread Brian Diggs
On 6/24/2010 11:16 AM, Christopher David Desjardins wrote: Hi, I am running the following code: mfg0 <- ggplot(aes(x=Grade,y=Math,colour=RiskStatic45678),data=math.f) mfg1 <- mfg0 + geom_smooth(method="lm", formula=y ~ ns(x,2),size=1) + geom_smooth(aes(y=nalt.math,color="NALT"),size=1,data=nalt)

Re: [R] Best way to compute a sum

2010-06-24 Thread Duncan Murdoch
On 24/06/2010 4:57 PM, Peter Langfelder wrote: On Thu, Jun 24, 2010 at 1:50 PM, Duncan Murdoch wrote: On 24/06/2010 4:39 PM, Peter Langfelder wrote: AFAIK the optimal way of summing a large number of positive numbers is to always add the two smallest numbers Isn't that what I

Re: [R] Install package automatically if not there?

2010-06-24 Thread Joshua Wiley
On Thu, Jun 24, 2010 at 1:51 PM, Joshua Wiley wrote: > Hello Ralf, > > This is a little function that you may find helpful.  If the package > is already installed, it just loads it, otherwise it updates the > existing packages and then installs the required package.  As in > require(), 'x' does no

Re: [R] Best way to compute a sum

2010-06-24 Thread Gabor Grothendieck
On Thu, Jun 24, 2010 at 4:08 PM, Lasse Kliemann wrote: > What is the best way in R to compute a sum while avoiding > cancellation effects? > See ?sum.exact in the caTools package. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listin

Re: [R] [OT] Combinatorials wtih constraints

2010-06-24 Thread Greg Snow
Well here is one way (but this finds too many, then reduces, so if the final result is near the memory limit, this would go over first): unique(t(combn( rep(LETTERS[1:5], each=2), 3))) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8

Re: [R] Popularity of R, SAS, SPSS, Stata...

2010-06-24 Thread Dario Solari
First: excuse for my english My opinion: a useful font for measuring "popoularity" can be Google Insights for Search - http://www.google.com/insights/search/# Every person using a software like R, SAS, SPSS needs first to learn it. So probably he make a web-search for a manual, a tutorial, a guid

Re: [R] Best way to compute a sum

2010-06-24 Thread Peter Langfelder
On Thu, Jun 24, 2010 at 1:50 PM, Duncan Murdoch wrote: > On 24/06/2010 4:39 PM, Peter Langfelder wrote: > >> AFAIK the optimal way of summing a large number of positive numbers is >> to always add the two smallest numbers > > Isn't that what I said? I understood that you suggested to linearly sum

Re: [R] [OT] Combinatorials wtih constraints

2010-06-24 Thread Ted Harding
On 24-Jun-10 19:47:38, Doran, Harold wrote: > This is not an R question, but a question on some combinatorial > mathematics. Apologies for the OT if it is wildy inappropriate. > The traditional C(n.k) method tells me how many combinations k > I can make with n objects. However, suppose I want the n

Re: [R] Install package automatically if not there?

2010-06-24 Thread Joshua Wiley
Hello Ralf, This is a little function that you may find helpful. If the package is already installed, it just loads it, otherwise it updates the existing packages and then installs the required package. As in require(), 'x' does not need to be quoted. load.fun <- function(x) { x <- as.charact

Re: [R] Install package automatically if not there?

2010-06-24 Thread David Winsemius
Nice. Very nice. -- David. On Jun 24, 2010, at 4:32 PM, Albert-Jan Roskam wrote: require(pkg) || install.packages(pkg) Cheers!! Albert-Jan ~~ All right, but apart from the sanitation, the medicine, education, wine,

Re: [R] Best way to compute a sum

2010-06-24 Thread Duncan Murdoch
On 24/06/2010 4:39 PM, Peter Langfelder wrote: On Thu, Jun 24, 2010 at 1:26 PM, Duncan Murdoch wrote: On 24/06/2010 4:08 PM, Lasse Kliemann wrote: What is the best way in R to compute a sum while avoiding cancellation effects? Use sum(). If it's not good enough, then do

Re: [R] Best way to compute a sum

2010-06-24 Thread David Winsemius
On Jun 24, 2010, at 4:08 PM, Lasse Kliemann wrote: a <- 0 ; for(i in (1:2)) a <- a + 1/i b <- 0 ; for(i in (2:1)) b <- b + 1/i c <- sum(1/(1:2)) d <- sum(1/(2:1)) order(c(a,b,c,d)) [1] 1 2 4 3 b [1] TRUE c==d [1] FALSE I'd expected b being the largest, si

Re: [R] Best way to compute a sum

2010-06-24 Thread Peter Langfelder
On Thu, Jun 24, 2010 at 1:26 PM, Duncan Murdoch wrote: > On 24/06/2010 4:08 PM, Lasse Kliemann wrote: >> What is the best way in R to compute a sum while avoiding cancellation >> effects? >> > > Use sum().  If it's not good enough, then do it in C, accumulating in > extended precision (which is w

Re: [R] Correctly plotting bar and scatter chart on 2-y axis plot with par(new=T)

2010-06-24 Thread Greg Snow
Is this what you want: y1 <- c(-30353.382, -21693.519, -7049.923, -72968.722, -10267.584, -269432.795, -19847.670, -686283.171, -376231.754, -597800.080, -274637.587, -112663.167, -39550.445, -133916.431) xlabs <- c(1, 7, 13, 2, 8, 14, 3, 9, 4, 10, 5, 11, 6, 12) y2 <- c(50, 25,

Re: [R] Install package automatically if not there?

2010-06-24 Thread Albert-Jan Roskam
require(pkg) || install.packages(pkg) Cheers!! Albert-Jan ~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the R

Re: [R] Best way to compute a sum

2010-06-24 Thread Duncan Murdoch
On 24/06/2010 4:08 PM, Lasse Kliemann wrote: > a <- 0 ; for(i in (1:2)) a <- a + 1/i > b <- 0 ; for(i in (2:1)) b <- b + 1/i > c <- sum(1/(1:2)) > d <- sum(1/(2:1)) > order(c(a,b,c,d)) [1] 1 2 4 3 > b c==d [1] FALSE I'd expected b being the largest

Re: [R] Correctly plotting bar and scatter chart on 2-y axis plot with par(new=T)

2010-06-24 Thread dan.weavesham
Hello, Thanks for the advice so far -- still struggling with it, I must admit. Here is some sample data, which I hope helps: # y axis #1 -- data for the bar chart -30353.382 -21693.519 -7049.923 -72968.722 -10267.584 -269432.795 -19847.670 -686283.171 -376231.754 -597800.080 -274637.587 -

[R] [OT] Combinatorials wtih constraints

2010-06-24 Thread Doran, Harold
This is not an R question, but a question on some combinatorial mathematics. Apologies for the OT if it is wildy inappropriate. The traditional C(n.k) method tells me how many combinations k I can make with n objects. However, suppose I want the number of combinations where an object cannot be u

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-24 Thread Atte Tenkanen
> On Jun 23, 2010, at 9:58 PM, Atte Tenkanen wrote: > > > Thanks. What I have had to ask is that > > > > how do you test that the data is symmetric enough? > > If it is not, is it ok to use some data transformation? > > > > when it is said: > > > > "The Wilcoxon signed rank test does not assume th

[R] Best way to compute a sum

2010-06-24 Thread Lasse Kliemann
> a <- 0 ; for(i in (1:2)) a <- a + 1/i > b <- 0 ; for(i in (2:1)) b <- b + 1/i > c <- sum(1/(1:2)) > d <- sum(1/(2:1)) > order(c(a,b,c,d)) [1] 1 2 4 3 > b c==d [1] FALSE I'd expected b being the largest, since we sum up the smallest numbers first.

Re: [R] Install package automatically if not there?

2010-06-24 Thread Ista Zahn
Hi Ralf, Ralf B writes: > Hi fans, > > is it possible for a script to check if a library has been installed? > I want to automatically install it if it is missing to avoid scripts > to crash when running on a new machine... You could do something like if ("somepackage" %in% row.names(installed.p

Re: [R] Install package automatically if not there?

2010-06-24 Thread Bert Gunter
You mean if a "package" has been installed?! (big difference) ?installed.packages or ?.packages with all.available = TRUE ?install.packages Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On

Re: [R] Install package automatically if not there?

2010-06-24 Thread Law, Jason
Something like: if (!require(pkg)){ install.packages(pkg) } Jason -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ralf B Sent: Thursday, June 24, 2010 12:26 PM To: r-help@r-project.org Subject: [R] Install package automa

Re: [R] Install package automatically if not there?

2010-06-24 Thread David Winsemius
On Jun 24, 2010, at 3:25 PM, Ralf B wrote: Hi fans, is it possible for a script to check if a library has been installed? I want to automatically install it if it is missing to avoid scripts to crash when running on a new machine... Puzzled. When you went to the help page for install.package

[R] Install package automatically if not there?

2010-06-24 Thread Ralf B
Hi fans, is it possible for a script to check if a library has been installed? I want to automatically install it if it is missing to avoid scripts to crash when running on a new machine... Ralf __ R-help@r-project.org mailing list https://stat.ethz.ch

Re: [R] Sweave with external R code

2010-06-24 Thread Duncan Murdoch
On 24/06/2010 3:00 PM, Gaston Fiore wrote: Hello, I'm new to R and Sweave and I was wondering whether you can just include all your R code in external files and then call them from within the code chunks. I've read the Sweave User Manual but I couldn't find any specific information about this

Re: [R] Question on WLS (gls vs lm)

2010-06-24 Thread Gabor Grothendieck
On Thu, Jun 24, 2010 at 9:20 AM, Viechtbauer Wolfgang (STAT) wrote: > The weights in 'aa' are the inverse standard deviations. But you want to use > the inverse variances as the weights: > > aa <- (attributes(summary(f1)$modelStruct$varStruct)$weights)^2 > > And then the results are essentially i

[R] Sweave with external R code

2010-06-24 Thread Gaston Fiore
Hello, I'm new to R and Sweave and I was wondering whether you can just include all your R code in external files and then call them from within the code chunks. I've read the Sweave User Manual but I couldn't find any specific information about this. Is this not customarily done? Thanks, -Ga

[R] help, bifurcation diagram efficiency

2010-06-24 Thread Tyler Massaro
Hello all - This code will run, but it bogs down my computer when I run it for finer and finer time increments and more generations. I was wondering if there is a better way to write my loops so that this wouldn't happen. Thanks! -Tyler # # Bifurcation diagram # Using Braaksm

Re: [R] Euclidean Distance Matrix Analysis (EDMA) in R?

2010-06-24 Thread Kjetil Halvorsen
¿Is'nt this just another name for multidimensional scaling? Kjetil On Thu, Jun 24, 2010 at 9:15 AM, Tal Galili wrote: > Isn't this what > ?dist > Does ? > > Tal > > Contact > Details:--- > Contact me: tal.gal...@gmail.com |  972

Re: [R] How to say "if error"

2010-06-24 Thread Paul Chatfield
Thanks again Joris - you've been very helpful J From: Joris FA Meys [via R] [mailto:ml-node+2267176-1824205151-120...@n4.nabble.com] Sent: 24 June 2010 16:40 To: Paul Chatfield Subject: Re: How to say "if error" You could do that using the options, eg : set.seed(1) x <- rnorm(1:10) y

Re: [R] Adjusted means and generalized chain block designs

2010-06-24 Thread Giles Crane
To whom it may concern: I compared several R package results, and manual checked two generalized chain block design experiments. The correct adjusted treatment means can be computed by using the effects library as follows: library(effects) aov1 = aov(y~blocks+rows+trt) means.aov = a

Re: [R] xyplot: adding pooled regression lines to a paneled type="r" plot

2010-06-24 Thread Michael Friendly
Dennis Murphy wrote: Hi: Does this work for you? xyplot(distance ~ age | Sex, data = Orthodont, groups = Subject, main = 'Individual linear regressions ~ age', type = c('g', 'r'), panel = function(x, y, ...) { panel.xyplot(x, y, ..., col = gray(0.5))

Re: [R] probabilities from survfit.coxph

2010-06-24 Thread Therneau, Terry M., Ph.D.
> In the example below (or for a censored data) using survfit.coxph, can > anyone point me to a link or a pdf as to how the probabilities appearing in > bold under "summary(pred$surv)" are calculated? These are predicted probabilities that a subject who is age 60 will still be alive. How this is

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-24 Thread Frank E Harrell Jr
On 06/24/2010 12:40 PM, David Winsemius wrote: On Jun 23, 2010, at 9:58 PM, Atte Tenkanen wrote: Thanks. What I have had to ask is that how do you test that the data is symmetric enough? If it is not, is it ok to use some data transformation? when it is said: "The Wilcoxon signed rank test

[R] Displaying additional values on the Y-axis ggplot2

2010-06-24 Thread Christopher David Desjardins
Hi, I am running the following code: mfg0 <- ggplot(aes(x=Grade,y=Math,colour=RiskStatic45678),data=math.f) mfg1 <- mfg0 + geom_smooth(method="lm", formula=y ~ ns(x,2),size=1) + geom_smooth(aes(y=nalt.math,color="NALT"),size=1,data=nalt) + scale_colour_brewer("Risk Status", pal="Set1") + coor

Re: [R] help in SVM

2010-06-24 Thread Steve Lianoglou
Hi, On Thu, Jun 24, 2010 at 1:22 PM, Changbin Du wrote: > HI, GUYS, > > I used the following codes to run SVM and get prediction on new data set hh. > >  dim(all_h) > [1] 2034   24 >  dim(hh)    # it contains all the variables besides the variables in all_h > data set. > [1] 640 415 If I underst

Re: [R] Sending a null byte to a socket

2010-06-24 Thread Dan Tenenbaum
Sorry to spam the list again, but I was wondering if anyone has a solution to this. It seems that writing nulls to sockets is a pretty common use case, so I would hope there is a way to do this. Thanks. On Wed, Jun 16, 2010 at 12:52 PM, Dan Tenenbaum < dtenenb...@systemsbiology.org> wrote: > Hell

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-24 Thread David Winsemius
On Jun 23, 2010, at 9:58 PM, Atte Tenkanen wrote: Thanks. What I have had to ask is that how do you test that the data is symmetric enough? If it is not, is it ok to use some data transformation? when it is said: "The Wilcoxon signed rank test does not assume that the data are sampled from

Re: [R] read.csv does not find my file (windows xp)

2010-06-24 Thread Ralf B
jep! I forgot to use sep="" for paste and introducted a space in front of the filename... damn, 1 hour of my life! Ralf 2010/6/24 Uwe Ligges : > > > On 24.06.2010 19:02, Ralf B wrote: >> >> I try to load a file >> >> myData<- read.csv(file="C:\\myfolder\\mysubfolder\\mydata.csv", >> head=TRUE, se

Re: [R] how can I evaluate a formula passed as a string?

2010-06-24 Thread Mike Williamson
Thank you, Peter! I sure love this help group!! :) "Telescopes and bathyscaphes and sonar probes of Scottish lakes, Tacoma Narrows bridge collapse explained with abstract phase-space maps, Some x-ray slides, a music score, Minard's Napoleanic war: The most exciting frontier is charting

Re: [R] how can I evaluate a formula passed as a string?

2010-06-24 Thread Peter Langfelder
On Thu, Jun 24, 2010 at 10:16 AM, Mike Williamson wrote: > Hey everyone, > >    I've been using 'R' long enough that I should have some idea of what the > heck either   expression()  or eval()  are really ever useful for.  I come > across another instance where I WISH they would be useful, but I c

Re: [R] read.csv does not find my file (windows xp)

2010-06-24 Thread Uwe Ligges
On 24.06.2010 19:02, Ralf B wrote: I try to load a file myData<- read.csv(file="C:\\myfolder\\mysubfolder\\mydata.csv", head=TRUE, sep=";") and get this error: Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'C:\m

[R] help in SVM

2010-06-24 Thread Changbin Du
HI, GUYS, I used the following codes to run SVM and get prediction on new data set hh. dim(all_h) [1] 2034 24 dim(hh)# it contains all the variables besides the variables in all_h data set. [1] 640 415 require(e1071) svm.tune<-tune(svm, as.factor(out) ~ ., data=all_h, ranges=list(gamma

[R] how can I evaluate a formula passed as a string?

2010-06-24 Thread Mike Williamson
Hey everyone, I've been using 'R' long enough that I should have some idea of what the heck either expression() or eval() are really ever useful for. I come across another instance where I WISH they would be useful, but I cannot get them to work. Here is the crux of what I would like

[R] read.csv does not find my file (windows xp)

2010-06-24 Thread Ralf B
I try to load a file myData <- read.csv(file="C:\\myfolder\\mysubfolder\\mydata.csv", head=TRUE, sep=";") and get this error: Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'C:\myfolder\mysubfolder\mydata.csv: No such

Re: [R] Wilcoxon signed rank test and its requirements

2010-06-24 Thread S Ellison
There is a potentially useful remark from Peter Dalfgaard at http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg86359.html : Summarising: "[The Wilcoxon paired rank sign test assumes symmetry] ...of differences, and under the null hypothesis. This is usually rather uncontroversial. " My r

Re: [R] How to say "if error"

2010-06-24 Thread Duncan Murdoch
On 24/06/2010 11:12 AM, Paul Chatfield wrote: On a similar issue, how can you detect a warning in a loop - e.g. the following gives a warning, so I'd like to set up code to recognise that and then carry on in a loop x<-rnorm(2);y<-c(1,0) ff<-glm(y/23~x, family=binomial) so this would be incorpo

Re: [R] Correctly plotting bar and scatter chart on 2-y axis plot with par(new=T)

2010-06-24 Thread Greg Snow
Using par(new=T) is dangerous and tricky for those people who understand what it does and how to use it. Trying to use it without fully understanding it will be much worse. I would use the updateusr function from the TeachingDemos package instead. The first example on the help page may give y

Re: [R] Plotrix Trick

2010-06-24 Thread Hrishi Mittal
Lorenzo, I think your question was already answered by Jan van der Laan - http://r.789695.n4.nabble.com/Plotrix-Trick-tp2265893p2266722.html -- View this message in context: http://r.789695.n4.nabble.com/Plotrix-Trick-tp2267177p2267225.html Sent from the R help mailing list archive at Nabble.c

Re: [R] Plotrix Trick

2010-06-24 Thread David Winsemius
On Jun 24, 2010, at 11:38 AM, Lorenzo Isella wrote: Dear Hrishi, I am almost there, thanks. The only small problem left is to convince also the colorbar to plot the values I want. Consider the small snippet at the end of the email: colors and numbers inside the cells are OK, but the legend show

Re: [R] Comparing distributions

2010-06-24 Thread Greg Snow
If you want a more objective eye-ball test, look at: Buja, A., Cook, D. Hofmann, H., Lawrence, M. Lee, E.-K., Swayne, D.F and Wickham, H. (2009) Statistical Inference for exploratory data analysis and model diagnostics Phil. Trans. R. Soc. A 2009 367, 4361-4383 doi: 10.1098/rsta.

Re: [R] PD: ?to calculate sth for groups defined between points in one variable (string), / value separating/ spliting variable into groups by i.e. between start, NA, NA, stop1, start2, NA, stop2

2010-06-24 Thread Joris Meys
Same trick : c0<-rbind( 1, 2 , 3, 4, 5, 6, 7, 8, 9,10,11, 12,13,14,15,16,17 ) c0 c1<-rbind(10, 20 ,30,40, 50,10,60,20,30,40,50, 30,10, 0,NA,20,10.3444) c1 c2<-rbind(NA,"A",NA,NA,"B",NA,NA,NA,NA,NA,NA,"C",NA,NA,NA,NA,"D") c2 C.df<-data.frame(c0,c1,c2) C.df pos <- which(!i

[R] Plotrix Trick

2010-06-24 Thread Lorenzo Isella
Dear Hrishi, I am almost there, thanks. The only small problem left is to convince also the colorbar to plot the values I want. Consider the small snippet at the end of the email: colors and numbers inside the cells are OK, but the legend shows the extremes of the log transformed data instead of th

Re: [R] How to say "if error"

2010-06-24 Thread Joris Meys
You could do that using the options, eg : set.seed(1) x <- rnorm(1:10) y <- letters[1:10] z <- rnorm(1:10) warn <-getOption("warn") options(warn=2) for (i in list(x,y,z)){ cc <- try(mean(i), silent=T) if(is(cc,"try-error")) {next} print(cc) } options(warn=warn) see ?options under "warn" C

Re: [R] How to say "if error"

2010-06-24 Thread Paul Chatfield
On a similar issue, how can you detect a warning in a loop - e.g. the following gives a warning, so I'd like to set up code to recognise that and then carry on in a loop x<-rnorm(2);y<-c(1,0) ff<-glm(y/23~x, family=binomial) so this would be incorporated into a loop that might be x<-rnorm(10);y

  1   2   >