[R] lattice: adding information on number of observations

2009-12-01 Thread RINNER Heinrich
Dear R-users, I am using R version 2.9.1 and lattice 0.17-26 under windows. In a lattice boxplot, I would like to add information on how many observations each singel boxplot is based upon. For example (the basic plot): # Begin R-code library(lattice) dat <- data.frame(panvar = rep(c("A","B","A"

Re: [R] How do I run to or more R consoles on Mac OS X?

2009-12-01 Thread chronos.phenomena
Thanks Don Sent from my iPhone On 2 Dec 2009, at 06:16, "Don MacQueen [via R]" wrote: > If myscript.r has as its first line: > >#! /usr/bin/Rscript > > and you make it executable > chmod +x myscript.r > > Then you can run it by giving the command > >./myscript.r > > > -Don > > At

Re: [R] Multiple grouping on the X axis.

2009-12-01 Thread Jim Lemon
On 12/02/2009 05:07 AM, Munin wrote: I am trying to plot data with multiple logical and physical groups using R. Below is a sample of the kind of data I am working with and the desired output. We have a jmp script that can do the same thing, but at ~$200 a year the licensing is counterprodu

Re: [R] A ggplot question

2009-12-01 Thread Megh
Thanks Ista for your mail. Here I wanted to have control on color-pallet. It is because, here my entire plot window is subdivided in 3 sub-plots horizontally, on basis if a factor-variable which contains three factors, using facet_grid(). Each sub-plot contains scatter-plot. I want to color the p

Re: [R] explanation for left-side behaviour

2009-12-01 Thread Don MacQueen
Read the help page for substr(). It says that the first argument should be a character vector. The only one that works is the one where you gave it a character vector. You said only third one "works". But you didn't explain what you mean by "works". It's always a good idea on r-help to show both

Re: [R] Translation from R codes to SAS.

2009-12-01 Thread xlr82sas
ychu066 wrote: > > my teachers doesnt understand R and I don't know how to use SAS. > Anyone interested in translating my codes to test whether your SAS codes > are as good as R??? > I can test it on SAS codes once you have translated it > > > > regards:working: > It is quite easy

Re: [R] How do I run to or more R consoles on Mac OS X?

2009-12-01 Thread Don MacQueen
If myscript.r has as its first line: #! /usr/bin/Rscript and you make it executable chmod +x myscript.r Then you can run it by giving the command ./myscript.r -Don At 3:03 PM -0800 11/30/09, chronos.phenomena wrote: Thanks... that worked is there a way to run r script? for example

Re: [R] sort a data frame by a vector

2009-12-01 Thread Don MacQueen
This looks like a job for match(). vec = c("C", "A", "B") dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3)) dataDF[match(dataDF$A1,vec),] A1 A2 3 C 3 2 A 2 1 B 1 -Don At 10:36 PM -0500 12/1/09, Hao Cen wrote: Hi, I have a a vector and a data frame with two columns

Re: [R] How to export a function from a package and access it only by specifying the namespace?

2009-12-01 Thread Sharpie
Peng Yu wrote: > > Then I try the package 'try.package' in an R session. I'm wondering > why neither 'my_test_f' and 'try.package::my_test_f' work. > The error message you got below clearly explains this-- you did not export my_test_f in your NAMESPACE file. To access unexported functions, y

Re: [R] A ggplot question

2009-12-01 Thread Ista Zahn
There was a recent discussion of the ggplot2 mailing list about a similar issue. The first question is how will people know what the colors mean if you remove the legend? -Ish On Tue, Dec 1, 2009 at 11:41 PM, Megh wrote: > > Let consider following plot : > > p <- ggplot(mtcars, aes(mpg, wt)) >  

[R] How to export a function from a package and access it only by specifying the namespace?

2009-12-01 Thread Peng Yu
I have the following test package. $ ls DESCRIPTION man NAMESPACE R $ cat DESCRIPTION Package: try.package Type: Package Title: What the package does (short line) Version: 1.0 Date: 2009-10-26 Author: Who wrote it Maintainer: Who to complain to Description: More about what it does (maybe more

[R] A ggplot question

2009-12-01 Thread Megh
Let consider following plot : p <- ggplot(mtcars, aes(mpg, wt)) p + geom_point(colour="grey50", size = 4) + geom_point(aes(colour = cyl)) Now I want R to hide the color-pallet on "cyl", placed in the right edge completely. Can anyone please guide me how to do that? Thanks, -- View this me

[R] Re How to remove R banner?

2009-12-01 Thread Charlotte Maia
Hi, Annoying I love it (except possibly when re-directing standard out to a file). I think it's one of the command line options (in which case, it will be clearly documented). No idea how it works on the GUI systems (maybe an option somewhere...). In saying that, I have to assume that if peo

Re: [R] How to remove R banner?

2009-12-01 Thread Sharpie
Peng Yu wrote: > > I always see a banner like the following, which is annoying. I'm > wondering how to disable it. > > R version 2.7.1 (2008-06-23) > Copyright (C) 2008 The R Foundation for Statistical Computing > ISBN 3-900051-07-0 > > R is free software and comes with ABSOLUTELY NO WARRANTY.

Re: [R] How to remove R banner?

2009-12-01 Thread Ben Bolker
Peng Yu gmail.com> writes: > I always see a banner like the following, which is annoying. I'm > wondering how to disable it. R --quiet (it took about 8 seconds to find this with R --help) __ R-help@r-project.org mailing list https://stat.ethz.ch/mail

Re: [R] sort a data frame by a vector

2009-12-01 Thread David Winsemius
On Dec 1, 2009, at 10:59 PM, jim holtman wrote: The factor statement should have been: (missed the 'vec' on the first reading) dataDF$A1 <- factor(dataDF$A1, levels=vec) It's not necessary to alter the data.frame. You can use the results of the construction above as the row index and st

Re: [R] Replying to Posts Within Same Thread

2009-12-01 Thread David Winsemius
On Dec 1, 2009, at 10:42 PM, Charlotte Maia wrote: On 12/2/09, John Sorkin wrote: I don't know what you are doing wrong because I don't know exactly what you are doing. I do know that I don't have your problem when I simply reply to a message without touching the subject line. John Coul

Re: [R] sort a data frame by a vector

2009-12-01 Thread jim holtman
The factor statement should have been: (missed the 'vec' on the first reading) dataDF$A1 <- factor(dataDF$A1, levels=vec) On Tue, Dec 1, 2009 at 10:57 PM, jim holtman wrote: > Is this what you want: > >> dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3)) >> dataDF >  A1 A2 > 1  B  1 > 2

[R] How to remove R banner?

2009-12-01 Thread Peng Yu
I always see a banner like the following, which is annoying. I'm wondering how to disable it. R version 2.7.1 (2008-06-23) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it

Re: [R] sort a data frame by a vector

2009-12-01 Thread milton ruser
not ellegant.. but... vecDF = data.frame(A1=c("C", "A", "B")) vecDF$A1.order=1:dim(vecDF) vecDF dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3)) dataDF2<-merge(vecDF, dataDF, by=intersect(colnames(vecDF),colnames(dataDF))) dataDF2 dataDF2.ord<-dataDF2[order(dataDF2$A1.order),] dataDF2.ord

Re: [R] sort a data frame by a vector

2009-12-01 Thread jim holtman
Is this what you want: > dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3)) > dataDF A1 A2 1 B 1 2 A 2 3 C 3 > dataDF[order(dataDF$A1),] A1 A2 2 A 2 1 B 1 3 C 3 > If you want the sequence "CAB" then you will have to change the factors in column 1: > dataDF$A1 <- factor(dat

Re: [R] Normal tests disagree?

2009-12-01 Thread Ben Bolker
milton ruser gmail.com> writes: > > Hi there, > > Could you provide a minimum reproducible code, please. > Bests > > milton > > On Tue, Dec 1, 2009 at 6:11 PM, charter.net> wrote: > > > If I have data that I feed into shapio.test and jarque.bera.test yet they > > seem to disagree. What do I

Re: [R] Replying to Posts Within Same Thread

2009-12-01 Thread Charlotte Maia
On 12/2/09, John Sorkin wrote: > I don't know what you are doing wrong because I don't know exactly what you > are doing. I do know that I don't have your problem when I simply reply to a > message without touching the subject line. > John Could you clarify the notion of "simply reply". There i

[R] sort a data frame by a vector

2009-12-01 Thread Hao Cen
Hi, I have a a vector and a data frame with two columns vec = c("C", "A", "B") dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3)) I would like to sort the data frame by column A1 such that the order of elements in A1 is as the same as in vec. After the ordering, the data frame

Re: [R] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Rolf Turner
On 2/12/2009, at 3:48 PM, Peng Yu wrote: On Tue, Dec 1, 2009 at 8:24 PM, Rolf Turner wrote: On 2/12/2009, at 3:09 PM, Peng Yu wrote: Here is my sessionInfo(). [Snotty comment deleted.] sessionInfo() R version 2.7.1 (2008-06-23) If you're going to us

Re: [R] Replying to Posts Within Same Thread

2009-12-01 Thread John Sorkin
I don't know what you are doing wrong because I don't know exactly what you are doing. I do know that I don't have your problem when I simply reply to a message without touching the subject line. John -Original Message- From: Charlotte Maia To: Sent: 12/1/2009 9:48:06 PM Subject: [R]

Re: [R] Is R-2.10.0 released already

2009-12-01 Thread Wincent
Hi, R-2.10.0 was released and R-2.10.1 is to be released soon. I don't think there is any problem with cran. Best 2009/12/2 Hiroto Miyoshi : > > Dear R users, and Dr. Delagard > > I got an R-announce message which tells that > R-2.10.0 will be released on December 4, 2009. > > Houever, it seems t

Re: [R] Is R-2.10.0 released already

2009-12-01 Thread Charlie Sharpsteen
On Tue, Dec 1, 2009 at 6:19 PM, Hiroto Miyoshi wrote: > > Dear R users, and Dr. Delagard > > I got an R-announce message which tells that > R-2.10.0 will be released on December 4, 2009. According to the message I received it was the first patch release, 2.10.1, that was announced not 2.10.0. -C

[R] Replying to Posts Within Same Thread

2009-12-01 Thread Charlotte Maia
Hi, When I reply to a post, it generally appears as a separate thread, rather than branching off the original post. Anyone know what I'm doing wrong? Noting I am currently receiving a couple of the lists in digest form. kind regards -- Charlotte Maia http://sites.google.com/site/maiagx/home

Re: [R] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Peng Yu
On Tue, Dec 1, 2009 at 8:24 PM, Rolf Turner wrote: > > On 2/12/2009, at 3:09 PM, Peng Yu wrote: > >         > >> Here is my sessionInfo(). > >        [Snotty comment deleted.] > >>> sessionInfo() >> >> R version 2.7.1 (2008-06-23) > >         > >        If you're going to use a version which is th

[R] Is R-2.10.0 released already

2009-12-01 Thread Hiroto Miyoshi
Dear R users, and Dr. Delagard I got an R-announce message which tells that R-2.10.0 will be released on December 4, 2009. Houever, it seems the R of that version was already released. At leased I made sure that the R of that version was in Cran and Univ. of Tsukuba, and also Univ. of Toronto.

Re: [R] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Rolf Turner
On 2/12/2009, at 3:09 PM, Peng Yu wrote: Here is my sessionInfo(). [Snotty comment deleted.] sessionInfo() R version 2.7.1 (2008-06-23) If you're going to use a version which is that antiquated then you can expect a great many things not to wor

Re: [R] Container/Collection Object to keep data structures and object

2009-12-01 Thread Rolf Turner
On 2/12/2009, at 3:08 PM, Sharpie wrote: Amir Liu wrote: In l[3] <- matrix(1:4, 2, 2) : number of items to replace is not a multiple of replacement length When inserting single entries into a list list, you should use the '[[ ]]' notation. Use '[ ]' when you want to extract multipl

Re: [R] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Peng Yu
On Tue, Dec 1, 2009 at 8:04 PM, Jorge Ivan Velez wrote: > > I guess it depends on which version of R you are using. My sessionInfo() > follows. What's yours? > R> sessionInfo() > R version 2.10.0 Patched (2009-10-26 r50212) > i386-pc-mingw32 > locale: > [1] LC_COLLATE=English_United States.1252  L

Re: [R] Container/Collection Object to keep data structures and object

2009-12-01 Thread Sharpie
Amir Liu wrote: > > In l[3] <- matrix(1:4, 2, 2) : >   number of items to replace is not a multiple of replacement length > When inserting single entries into a list list, you should use the '[[ ]]' notation. Use '[ ]' when you want to extract multiple entries or copy multiple entries from on

Re: [R] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Jorge Ivan Velez
I guess it depends on which version of R you are using. My sessionInfo() follows. What's yours? R> sessionInfo() R version 2.10.0 Patched (2009-10-26 r50212) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United State

Re: [R] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Peng Yu
On Tue, Dec 1, 2009 at 7:46 PM, Jorge Ivan Velez wrote: > Try this: > R> apropos('any') > R> ?anyDuplicated > HTH, > Jorge > > On Tue, Dec 1, 2009 at 8:32 PM, Peng Yu wrote: >> >> On Tue, Dec 1, 2009 at 1:40 AM, Karl Ove Hufthammer >> wrote: >> > On Tue, 1 Dec 2009 14:48:04 +1100 Remko Duursma

Re: [R] Container/Collection Object to keep data structures and object

2009-12-01 Thread Amir Liu
Here is an example of how I attempt to add elements to a given list denoted as l: > l <- list() > l list() > l[1] <- 5 > l [[1]] [1] 5 > l[2] <- "cd" > l [[1]] [1] 5 [[2]] [1] "cd" > l[3] <- matrix(1:4,2,2) Warning message: In l[3] <- matrix(1:4, 2, 2) :   number of items to replace is not

Re: [R] ''system(cmd) : make not found'' error during package install

2009-12-01 Thread Duncan Murdoch
Matthew Anaka wrote: Hello, I've been using various packages in R for a few years now to analyse genomics data but I've just come up with some errors for which I canÂ’t seem to find a solution. HereÂ’s the situation: source("http://harlequin.jax.org/rmodel/packages/downloadRmodel.R";)

[R] Passing additional argument to be numerically integrated function

2009-12-01 Thread Amir Liu
Hi, I try to use the numerical integration functionality of R to integrate a univariate (1D) function. Below I am integrating function const1 which works nicely as expected. But for some reasons I need to pass to my function that I want to integrate an additional parameter. If it were object-

Re: [R] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Jorge Ivan Velez
Try this: R> apropos('any') R> ?anyDuplicated HTH, Jorge On Tue, Dec 1, 2009 at 8:32 PM, Peng Yu wrote: > On Tue, Dec 1, 2009 at 1:40 AM, Karl Ove Hufthammer > wrote: > > On Tue, 1 Dec 2009 14:48:04 +1100 Remko Duursma > > wrote: > >> any(duplicated(c(1,2,2))) > > > > or > > anyDuplicated(c

Re: [R] Normal tests disagree?

2009-12-01 Thread milton ruser
Hi there, Could you provide a minimum reproducible code, please. Bests milton On Tue, Dec 1, 2009 at 6:11 PM, wrote: > If I have data that I feed into shapio.test and jarque.bera.test yet they > seem to disagree. What do I use for a decision? > > For my data set I have p.value of 0.05496421 re

Re: [R] draw a box at 10% lower and upper in scatter plot

2009-12-01 Thread Peter Alspach
Tena koe Roslina Check: ?rect ?quantile Perhaps those two functions will give you what you want. HTH Peter Alspach > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Roslina Zakaria > Sent: Wednesday, 2 December 2009 12

Re: [R] Is there a function to test if all the elements in a vector are unique

2009-12-01 Thread Peng Yu
On Tue, Dec 1, 2009 at 1:40 AM, Karl Ove Hufthammer wrote: > On Tue, 1 Dec 2009 14:48:04 +1100 Remko Duursma > wrote: >> any(duplicated(c(1,2,2))) > > or > anyDuplicated(c(1,2,2)) > which is slightly more efficient. I don't find anyDuplicated(). Which package is it from? ___

[R] ''system(cmd) : make not found'' error during package install

2009-12-01 Thread Matthew Anaka
Hello, I've been using various packages in R for a few years now to analyse genomics data but I've just come up with some errors for which I can’t seem to find a solution. Here’s the situation: > source("http://harlequin.jax.org/rmodel/packages/downloadRmodel.R";) > getRmodelHuman() also

Re: [R] Reformat x axis

2009-12-01 Thread Peter Alspach
Tena koe M Haywood I haven't a clue about SAS FORMAT, but R does have the ability to specify the axis ticks, labels and titles in pretty much any way you might require. See ?axis and also ?text HTH Peter Alspach > -Original Message- > From: r-help-boun...@r-project.org > [mailto

Re: [R] Container/Collection Object to keep data structures and object

2009-12-01 Thread Sharpie
Amir Liu wrote: > > I want to have a collection object that can store objects. In R I only saw > lists. But these only seem to be able to handle basic objects like numbers > and strings. Whenever I tried to add more complicated objects or just very > simple data structures like matrices I would

Re: [R] Partial correlations and p-values

2009-12-01 Thread dadrivr
I am trying to calculate a partial correlation and p-values. Unfortunately, the results in R are different than what SPSS gives. Here is an example in R (calculating the partial correlation of x and y, controlling for z1 and z2): x <- c(1,20,14,30,9,4,8) y <- c(5,6,7,9,NA,10,6) z1 <- c(13,8,16,

[R] Container/Collection Object to keep data structures and object

2009-12-01 Thread Amir Liu
I want to have a collection object that can store objects. In R I only saw lists. But these only seem to be able to handle basic objects like numbers and strings. Whenever I tried to add more complicated objects or just very simple data structures like matrices I would get an error like: "n

Re: [R] Distance between sets of points in transformed environmental space

2009-12-01 Thread Charlotte Maia
Hi Corrado, I was thinking about this some more. Maybe you could use a linear discriminate, i.e. a (hyper)plane that partitions your points into two sets, such that the misclassification rate is minimised. Closeness could be regarded as the number of misclassified points. Two sets would be dista

[R] Reformat x axis

2009-12-01 Thread d haywood
Hi I am trying to do a simple XY plot with a dataset that has dates stored as integers . I would like to have the X values displayed as dates. I realize I could do this by converting the x values to dates first, However, does R have the ability like SAS FORMAT, for example, of reformatting the

[R] Error when running Conditional Logit Model

2009-12-01 Thread Hien Nguyen
Dear R-helpers, I am very new to R and trying to run the conditional logit model using "clogit " command. I have more than 4000 observations in my dataset and try to predict the dependent variable from 14 independent variables. My command is as follows clmtest1 <- clogit(Pin~Income+Bus+Pop+U

Re: [R] Aligning Diagonally Oriented Labels Under Bar Chart

2009-12-01 Thread Peter Alspach
Tena koe Jason Is this an example of what you want? temp <- barplot(3:17) text(temp, rep(-0.5, length(3:17)), LETTERS[3:17], srt=45, adj=1) HTH Peter Alspach > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Jason Rupe

[R] draw a box at 10% lower and upper in scatter plot

2009-12-01 Thread Roslina Zakaria
Hi,   I would like to draw a box at each corner of lower 10% and upper 10% in the scatter plot on(0,1)*(0,1)  to indicate the lower and upper tail.  I hope somebody can help me.   Here is my code: ## scatter plot plot(hume_uni[,2],beec_uni[,2], pch=19, xlab="Hume_uni", ylab="Beec_uni", col= "bl

[R] Normal tests disagree?

2009-12-01 Thread rkevinburton
If I have data that I feed into shapio.test and jarque.bera.test yet they seem to disagree. What do I use for a decision? For my data set I have p.value of 0.05496421 returned from the shapiro.test and 0.882027 returned from the jarque.bera.test. I have included the data set below. Thank you.

[R] Aligning Diagonally Oriented Labels Under Bar Chart

2009-12-01 Thread Jason Rupert
I searched the forms (i.e., R Search) and come up with the following suggested link:  http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f I tried to implement what I believe was being implied by that URL and came up with the below: barplot(WorldPhones[1,],   

[R] Normal tests disagree?

2009-12-01 Thread rkevinburton
If I have data that I feed into shapio.test and jarque.bera.test yet they seem to disagree. What do I use for a decision? For my data set I have p.value of 0.05496421 returned from the shapiro.test and 0.882027 returned from the jarque.bera.test. I have included the data set below. Thank you.

[R] coding negative effects in categorical dummy variables

2009-12-01 Thread andre74
Hello, I have a problem with categorical variables and dummy encoding. I've a factor and for each pair (i,j) with i != j, I'd like to fit res ~ a*x[i] - b*x[j]. A brief example with 3 variables: a - b = 2 b - c = -1 c - a = 0 Thus I fitted the following model: fit <- lm(result ~ X + Y) whe

Re: [R] write.csv fails with $ operator invalid for atomic

2009-12-01 Thread ggraves
It was in some documentation along with using data.frame and other entries that didn't work. Can't explain why I didn't try it "as is". Gregory A. Graves Lead Scientist REstoration COoordination and VERification (RECOVER) Restoration Sciences Department South Florida Water Management District

Re: [R] write.csv fails with $ operator invalid for atomic

2009-12-01 Thread John Kane
Where does the table come from? write.csv(t, file = "t.csv") looks like it would work --- On Tue, 12/1/09, ggraves wrote: > From: ggraves > Subject: [R] write.csv fails with $ operator invalid for atomic > To: r-help@r-project.org > Received: Tuesday, December 1, 2009, 1:36 PM > > I want

Re: [R] How to compute contrast where there are interaction terms in the linear model?

2009-12-01 Thread Charles C. Berry
On Tue, 1 Dec 2009, Peng Yu wrote: Could somebody recommend some textbook how to compute contrast when there are interactions terms? "Applied Linear Regression Models" (book) mentioned contrast, but I cannot extend it to the case where there are interaction terms. Textbook? Schmextbook! You

[R] Canberra distance

2009-12-01 Thread Hongbo Zhu
Hi, I am using R 2.9.0. It seems the documentation for the calculation of Canberra distance using stats::dist is ambiguous. Does anyone have the original definition given in the Lance & Williams paper from Aust. Comput. J. 1, 15-20, 1967? When there are zeros at certain position in both vectors,

[R] How to compute contrast where there are interaction terms in the linear model?

2009-12-01 Thread Peng Yu
Could somebody recommend some textbook how to compute contrast when there are interactions terms? "Applied Linear Regression Models" (book) mentioned contrast, but I cannot extend it to the case where there are interaction terms. __ R-help@r-project.org

Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius
On Dec 1, 2009, at 3:28 PM, Gabor Grothendieck wrote: > Try this: > > > library(gsubfn) > > strapply(testvec, "[-+.0-9]+", as.numeric, simplify = ~ > colMeans(cbind(...))) > [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 Very, nice. Also tried on some other valid ("200,2") and invalid )

Re: [R] ggplot legend for multiple time series

2009-12-01 Thread hadley wickham
Because of the combinatorial nature of ggplot2, it is simply not possible to provide an example that illustrates every single combination of options. There are already over 600 example graphics in the package - if you can't find one that exactly meets your need, you need to buy the book and learn

Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Gabor Grothendieck
Try this: > library(gsubfn) > strapply(testvec, "[-+.0-9]+", as.numeric, simplify = ~ colMeans(cbind(...))) [1] -5.8500 -2.9800 -2.8160 -2.7120 -2.6325 -2.5680 On Tue, Dec 1, 2009 at 3:14 PM, David Winsemius wrote: > I'm sitting here chuckling. Your solution is just so "pure". > > I would offer

Re: [R] median for time data

2009-12-01 Thread uvilla
Thanks you both Jannis now it is working!!. I just have one mor request, please! How I'm suppose to make a boxplot with anfang, when working with times, it just have on the y axis some decimal number which make no sense. i need the time to appear in the y axis in order to see the median in the bo

Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius
I'm sitting here chuckling. Your solution is just so "pure". I would offer an enhancement. When I tested with my cuts that had "-" before the digits, you solution dropped them, so my suggestion for the pattern would be: "[-[:digit:].]+" I will admit that I thought it might fail with posit

Re: [R] ggplot legend for multiple time series

2009-12-01 Thread Edwin Sun
Hello - Thank you so much for the help. It works perfectly. I guess that as many have pointed out, ggplot is a great package but there is a lack of documentation and examples. Edwin Sun baptiste auguie-5 wrote: > > Hi, > > I don't understand why you used scale_manual_colour if you want only

Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Henrique Dallazuanna
Perhaps this shoul work too: sapply(strsplit(gsub("^\\W|\\W$", "", testvec), ","), function(x)sum(as.numeric(x))/2) On Tue, Dec 1, 2009 at 5:41 PM, David Winsemius wrote: > Starting with the head of a 499 element matrix whose column names are now > the labels trom a cut() operation, I needed to

Re: [R] An R vs. SAS Discrepancy: How do I determine which is correct?

2009-12-01 Thread Kevin E. Thorpe
Thanks to an insightful comment from Jeremy Miles, who politely pointed out my thick-headed moment, I know what happened. The sex variable was coded as 1/2 in the SAS data, but was a factor in the R data and so became a properly coded dummy variable. Sorry for the obvious question and answer. K

Re: [R] ggplot legend for multiple time series

2009-12-01 Thread baptiste auguie
Hi, I don't understand why you used scale_manual_colour if you want only black lines. To have different line types in the legend you can map the linetype to the data, huron <- data.frame(year=1875:1972, level=LakeHuron) ggplot(huron, aes(year)) + geom_line(aes(y=level+5, linetype="above")) +

Re: [R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread Gabor Grothendieck
You also might want to look at demo("gsubfn-cut") On Tue, Dec 1, 2009 at 2:41 PM, David Winsemius wrote: > Starting with the head of a 499 element matrix whose column names are now > the labels trom a cut() operation, I needed to get to a vector of midpoints > to serve as the basis for plotting

[R] An R vs. SAS Discrepancy: How do I determine which is correct?

2009-12-01 Thread Kevin E. Thorpe
I was messing around with some data in R and SAS (the reason is unimportant) fitting a multiple linear regression and got a curious discrepancy. The data set is too big to post, but if someone wants it, I can send it. So, here are the (partial) results: From R: Coefficients: Estima

Re: [R] Remark on tapply().

2009-12-01 Thread Rolf Turner
On 1/12/2009, at 8:32 PM, Karl Ove Hufthammer wrote: Exercise to the reader: Note that sapply(split(x, ff, drop=TRUE), sum) gives you the values of (just) the non-empty levels. Now, why does sapply(split(x, ff), sum, drop=TRUE) give the wrong value (1) for these levels, while sa

[R] Cut intervals (character) to numeric midpoint; regex problem

2009-12-01 Thread David Winsemius
Starting with the head of a 499 element matrix whose column names are now the labels trom a cut() operation, I needed to get to a vector of midpoints to serve as the basis for plotting a calibration curve ( exp(linear predictor) vs. : > dput(head(dimnames(mtcal)[2][[1]])) # was starting po

Re: [R] LMER: How to specify Random Effects

2009-12-01 Thread Ubuntu Diego
Thanks for your feedback. Actually Plant is nested since High and Low are qualitative relative values (High in Michigan is not the same as High in Sienna). S Ellison wrote: The Plant classification is not nested; it's an effect across all countires and states and probably a fixed effct (assum

[R] ggplot legend for multiple time series

2009-12-01 Thread Edwin Sun
Hello All, I am trying to create a legend for a black-white graph. The package I use is ggplot2. It can add colors to the legend key but not line types. Can you please help? # example from Wickman (2009, ggplot2 – elegant graphics for data analysis, page 109) library(ggplot2) huron <- data.fram

[R] ggplot legend for multiple time series

2009-12-01 Thread Changyou Sun
Hello All, I am trying to create a legend for a black-white graph. The package I use is ggplot2. It can add colors to the legend key but not line types. Can you please help? # example from Wickman (2009, ggplot2 - elegant graphics for data analysis, page 109) library(ggplot2) huron <-

[R] Multiple grouping on the X axis.

2009-12-01 Thread Munin
I am trying to plot data with multiple logical and physical groups using R. Below is a sample of the kind of data I am working with and the desired output. We have a jmp script that can do the same thing, but at ~$200 a year the licensing is counterproductive. Thanks for any help. Data inpu

Re: [R] median for time data

2009-12-01 Thread Jannis v. Buttlar
uvilla schrieb: When I use strptime() I just get NA NA NA I`m new at using R, must finisth this work thoug I guess Im doing totally wrong, actually everytime i try to use "POSIXct" it doesn`t work If you have a look at help(strptime) you find that you have to specify the format in which yo

[R] write.csv fails with $ operator invalid for atomic

2009-12-01 Thread ggraves
I want to export a csv file so I can do other things with it. I issue this command to break down years as to whether it was windy or not: t<-tapply(TURB,list(year,windy),mean,na.rm=T) which results in: > t no yes 1990 21.516514 39.86400 1991 13.580435 28.87500 1992 12.17142

Re: [R] Learning R

2009-12-01 Thread Dr. Thomas W. MacFarland
Hi Julia: I am sure that you will find many useful resources as you attempt to learn R. If time permits, please look at the Tegrity-based video that I’ve prepared for my students: http://tegrity1.acast.nova.edu/tegrityUtils/GetCourseListing.aspx?Session_In fo=7KmTs8Wkvvr0/Q0TsCfcur4RNGDvBGYk0jY+

Re: [R] Problem in reading data

2009-12-01 Thread Gabor Grothendieck
Specify that your input is of class yearmon (as opposed to Date class) and also correct the format specification as per the percent codes in ?strptime library(zoo) z <- read.zoo("clipboard", FUN = as.yearmon, format = "%b-%y") On Tue, Dec 1, 2009 at 12:55 PM, Megh wrote: > > In my Excel file,

[R] Testing the significance of gradients in trends

2009-12-01 Thread Steve Murray
Dear all, I want to determine if the slopes of the trends I have in my plot are significantly different from each other (I have 2 time-series trends). What statistical test is most suitable for this purpose and is it available in the R base package? Many thanks, Steve

Re: [R] median for time data

2009-12-01 Thread Gabor Grothendieck
# input library(chron) tt <- times(c("8:50:10", "9:40:20", "10:55:45")) tt2 <- times(c("01:00:00", "02:00:00", "03:00:00")) tt tt2 # calc median and differences (although it will give results as fractions of a day if there are negative results) median(tt) tt - tt2 tt2 - tt On Tue, Dec 1, 2009 a

Re: [R] median for time data

2009-12-01 Thread uvilla
Thanks a lot for your answer Jannis. Actually, I should have specified what I`m trying to do. I have a datafame which 3 colums, one is the "person ID", second is "Anfag" and third is "Ende". The two time colums are in this way: "8:50:10", so I have to calculate the medan of the Anfag colum and to

[R] Problem in reading data

2009-12-01 Thread Megh
In my Excel file, I have data in following format : Feb-07 38.49 Mar-07 39.95 Apr-07 37.47 May-07 35.77 Jun-07 32.96 Jul-07 33.27 I tried to copy this data as a time series using following code : library(zoo) dat <- read.zoo(file="clipboard", format="%m-%y") However getting following err

Re: [R] eigenvalues of complex matrices

2009-12-01 Thread Ravi Varadhan
Hi, You haven't given us much information. You might actually have the same eigenvalues, but don't recognize that due to possibly different orderings. Complex numbers do not possess ordering. Therefore, there is no natural way to report complex eigenvalues. In R, the complex eigenvalues are o

Re: [R] Starting estimates for nls Exponential Fit

2009-12-01 Thread Katharine Mullen
If you could reformulate your model as alpha * (y0 + E^t) then you could use nls with alg="plinear" (alpha then would be eliminated from the nonlinear param and treated as conditionally linear) and this would help with convergence. Else you can try package DEoptim to get the starting values; the a

Re: [R] "subset" or "condition" as argument to a function

2009-12-01 Thread baptiste auguie
Hi, an alternative to parse() is to use quote and bquote, set.seed(123) d = data.frame(a=letters[1:5], b=1:10, c=sample(0:1, 10, repl=TRUE)) cond1 <- quote(a=="b") cond2 <- quote(b < 6) cond3 <- bquote(.(cond1) & .(cond2)) subset(d, eval(cond1)) subset(d, eval(cond2)) subset(d, eval(cond3)) HT

Re: [R] Error message when logical indexing vecor is all FALSE

2009-12-01 Thread jim holtman
?try On Tue, Dec 1, 2009 at 12:22 PM, Jannis wrote: > Dears, > > > is there any way to "switch off" or work around the error message that > pops up when I do something like: > > > A<-B['logical vector'] > > > and when 'logical vector' only consists of FALSE values? My problem is > that this messa

[R] Error message when logical indexing vecor is all FALSE

2009-12-01 Thread Jannis
Dears, is there any way to "switch off" or work around the error message that pops up when I do something like: A<-B['logical vector'] and when 'logical vector' only consists of FALSE values? My problem is that this message always kicks me out of my loops and always testing via an if clause

[R] time series - month value

2009-12-01 Thread Alfredo Alessandrini
Hi, I've this time series: > ts_evi Time Series: Start = c(2000, 4) End = c(2002, 7) Frequency = 23 [1] 0.1948306 0.1930461 0.1905792 0.1848909 0.1893624 0.1811400 0.1678140 [8] 0.1750714 0.3100132 0.3495946 0.4103353 0.4973740 0.4937490 0.4031435 [15] 0.3503787 0.2755022 0.2304617 0.2284854 0.

[R] problem with RWeka Weka_control RandomForest

2009-12-01 Thread Itziar Frades Alzueta
Dear All, I am finding trouble trying to build a Wrapper using random forest to evaluate the subsets: I do: nombi <- make_Weka_filter("weka/filters/supervised/attribute/AttributeSelection") datbin<- nombi(gene ~., data=X1X2X4X5W, control =Weka_control( S=list("weka.attributeSelection.

Re: [R] median for time data

2009-12-01 Thread Jannis
Hi, try to convert this to the R time format "POSIXct" or "POSIXlt" via strptime(). Then you can simply substract them. I am not sure whether a median can be calculated though (should be possible as POSIXct stores the value as seconds since 1970) Best Jannis uvilla schrieb: Hi everybo

Re: [R] problem with RWeka Weka_control RandomForest

2009-12-01 Thread Achim Zeileis
On Tue, 1 Dec 2009, Itziar Frades Alzueta wrote: Dear All, I am finding trouble trying to guild a Wrapper using random forest to evaluate the subsets: I do: nombi <- make_Weka_filter("weka/filters/supervised/attribute/AttributeSelection") datbin<- nombi(gene ~., data=X1X2X4X5W, control =

Re: [R] "subset" or "condition" as argument to a function

2009-12-01 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh > Sent: Tuesday, December 01, 2009 7:39 AM > To: r-help@r-project.org > Subject: Re: [R] "subset" or "condition" as argument to a function > > Dear R gurus.. > I had trie

[R] problem with RWeka Weka_control RandomForest

2009-12-01 Thread Itziar Frades Alzueta
Dear All, I am finding trouble trying to guild a Wrapper using random forest to evaluate the subsets: I do: nombi <- make_Weka_filter("weka/filters/supervised/attribute/AttributeSelection") datbin<- nombi(gene ~., data=X1X2X4X5W, control =Weka_control( S=list("weka.attributeSelection.Geneti

Re: [R] Package is loaded but functions are not exported

2009-12-01 Thread Saptarshi Guha
I have no idea why I used the \\, the perils of copy and pasting from some other package or source . So, heres the thing, did R regex interpreter change? How come my export stopped working? Thank you Regards Saptarshi On Tue, Dec 1, 2009 at 11:28 AM, Romain Francois wrote: > You probably just wa

  1   2   >