Re: [R] Memory Utilization on R

2012-03-22 Thread R. Michael Weylandt
Well... what makes you think you are hitting memory constraints then?
If you have significantly less than 3GB of data, it shouldn't surprise
you if R never needs more than 3GB of memory.

You could just be running your scripts inefficiently...it's an extreme
example, but all the memory and gigaflopping in the world can't speed
this up (by much):

for(i in seq_len(1e6)) Sys.sleep(10)

Perhaps you should look into profiling tools or parallel
computation...if you can post a representative example of your
scripts, we might be able to give performance pointers.

Michael

On Fri, Mar 23, 2012 at 1:33 AM, Kurinji Pandiyan
 wrote:
> Yes, I am.
>
> Thank you,
> Kurinji
>
> On Mar 22, 2012, at 10:27 PM, "R. Michael Weylandt" 
>  wrote:
>
>> Use 64bit R?
>>
>> Michael
>>
>> On Thu, Mar 22, 2012 at 5:22 PM, Kurinji Pandiyan
>>  wrote:
>>> Hello,
>>>
>>> I have a 32 GB RAM Mac Pro with a 2*2.4 GHz quad core processor and 2TB
>>> storage. Despite this having so much memory, I am not able to get R to
>>> utilize much more than 3 GBs. Some of my scripts take hours to run but I
>>> would think they would be much faster if more memory is utilized. How do I
>>> optimize the memory usage on R by my Mac Pro?
>>>
>>> Thank you!
>>> Kurinji
>>>
>>>        [[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-contained, reproducible code.

__
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-contained, reproducible code.


Re: [R] Quicker way to apply values to a function

2012-03-22 Thread R. Michael Weylandt
I'd imagine one could solve this problem analytically
(divergence/convergence *almost certainly* [hint cough!]closed
form value seems hard) but perhaps you want to loop over a matrix
instead:

v <- matrix(NA, ncol = length(mymu), nrow = length(mysigma))
rownames(v) <- mysigma
colnames(v) <- mymu

then in the loop:

v[i,j] <- myint(...)

Michael

On Thu, Mar 22, 2012 at 7:17 PM, casperyc  wrote:
> Hi all,
> myint=function(mu,sigma){
>        integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value
> }
>
> mymu=seq(-3,3,length(1000))
> mysigma=seq(0,1,length(500))[-1]
>
> k=1
> v=c()
> for (j in 1:length(mymu)) {
>        for (i in 1:length(mysigma)) {
>                v[k]=myint(mymu[j],mysigma[i])
>                k=k+1
>        }
> }
>
>
> Basically, I want to investigate for what values of mu and sigma, the
> integral is divergent.
>
> Is there another way to do this other than loops?
>
> For now, the 'output' vector v is not so informative. Is there a way to
> 'show' me for what combinations of mu and sigma, the resulting values 'v'
> are from?
>
> Thanks.
>
>
>
> -
> ###
> PhD candidate in Statistics
> School of Mathematics, Statistics and Actuarial Science, University of Kent
> ###
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Quicker-way-to-apply-values-to-a-function-tp4497293p4497293.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


Re: [R] barplot on map

2012-03-22 Thread Peter Ehlers

Check out the subplot() function in the TeachingDemos package.

Peter Ehlers

On 2012-03-22 12:28, Martin Renner wrote:

I used the function stars() to make barplot-like plots on a map. Now editor 
wants us to use more traditional vertical barplots. Does anybody already have 
some code that would allow to make a small barplot at xy location within a 
larger plot?

Best,
Martin

Martin Renner
Post-doctoral Fellowphone: 907-226 4672
University of Washington
School of Aquatic and Fishery Sciences  Seattle, USA



__
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-contained, reproducible code.


Re: [R] Memory Utilization on R

2012-03-22 Thread R. Michael Weylandt
Use 64bit R?

Michael

On Thu, Mar 22, 2012 at 5:22 PM, Kurinji Pandiyan
 wrote:
> Hello,
>
> I have a 32 GB RAM Mac Pro with a 2*2.4 GHz quad core processor and 2TB
> storage. Despite this having so much memory, I am not able to get R to
> utilize much more than 3 GBs. Some of my scripts take hours to run but I
> would think they would be much faster if more memory is utilized. How do I
> optimize the memory usage on R by my Mac Pro?
>
> Thank you!
> Kurinji
>
>        [[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-contained, reproducible code.

__
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-contained, reproducible code.


Re: [R] question

2012-03-22 Thread R. Michael Weylandt
By googling.

On Thu, Mar 22, 2012 at 11:37 PM, Anjana Thampi
 wrote:
> How do you run a regression in R?
>
>        [[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-contained, reproducible code.

__
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-contained, reproducible code.


[R] Fixing error variance in a path analysis to model measurement error in scales using sem package

2012-03-22 Thread Kino Aguilar
Hi!

I want to construct a path analysis model that can account for measurement
error in totally aggregated parcels, which refer to parcels where all of
the items in a scale are summed or averaged. If I am not mistaken, Bollen
(1989) advocates the following formula for computing the error variance of
each parcel:

(1−α(parcel))×variance(parcel),

such that α refers to Cronbach's alpha, which is a measure of reliability.

What follows is the following path analysis model in theory (i.e., in
practice the formulas are replaced with actual numbers):

path.inf.final <- specifyModel()
pRU -> sRU, test1
pRU -> rRU, test2
sRU -> rRU, test3
sRU -> power_alt, gam1
pRU -> power_alt, gam2
rRU -> power_alt, gam3
sRU -> ms_alt, gam7
pRU -> ms_alt, gam8
rRU -> ms_alt, gam9
sRU <-> sRU,  NA, (1 - alpha(sRU))*(variance(sRU))
pRU <-> pRU, NA, (1 - alpha(pRU))*(variance(pRU))
rRU <-> rRU, NA, (1 - alpha(rRU))*(variance(rRU))
power_alt -> em, iota1
power_alt <-> power_alt, NA, (1 - alpha(power_alt))*(variance(power_alt))
ms_alt -> em, zeta1
ms_alt <-> ms_alt, NA, (1 - alpha(ms_alt))*(variance(ms_alt))
em -> relM1, eta1
em <-> em, NA, (1 - alpha(em))*(variance(em))
relM1 <-> relM1, lam1

After testing this model, the model fits were unnaceptable and package sem
could not compute modification instances. In contrast, when I do not fix
error variances, after a few modifications to the model, I am able to reach
a theoretical cogent model that has acceptable model fits.

I have several questions on this regard:

   1. Am I understanding Bollen (1989) correctly and using the formula
   correctly in my path analysis model?
   2. I also heard that rather than Bollen's formula, I could use alpha or
   alpha squared. Is this correct? If so, would it follow that I just input it
   into the model in much the same manner like I used Bollen's formula. I also
   tried this approach and reached unsatisfactory results.
   3. The dependent variable in the path analysis model is binary and I
   could argue that there is no measurement error associated with it. How
   could I fix the error variance for this variable, i.e., relM1, such that
   the aforementioned is accounted for.

Any help would be much appreciated.

References:

   - Bollen, K. A. (1989). Structural equations with latent variables. New
   York: Wiley.

Thank you!,
~Kino

[[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-contained, reproducible code.


[R] barplot on map

2012-03-22 Thread Martin Renner
I used the function stars() to make barplot-like plots on a map. Now editor 
wants us to use more traditional vertical barplots. Does anybody already have 
some code that would allow to make a small barplot at xy location within a 
larger plot? 

Best,
Martin

Martin Renner
Post-doctoral Fellowphone: 907-226 4672
University of Washington
School of Aquatic and Fishery Sciences  Seattle, USA

__
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-contained, reproducible code.


[R] question

2012-03-22 Thread Anjana Thampi
How do you run a regression in R?

[[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-contained, reproducible code.


Re: [R] R (Bold font) and Latex

2012-03-22 Thread Manish Gupta
Great it works! 

But in my case i have to use text bf in loop (R). Since x is variable (row
from file) which keeps on changing. How can i implement the above logic in
loop. 

Regards

--
View this message in context: 
http://r.789695.n4.nabble.com/R-Bold-font-and-Latex-tp4487535p4497610.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] deSolve

2012-03-22 Thread Ben Bolker
Berend Hasselman  xs4all.nl> writes:

> 
> 
> On 22-03-2012, at 18:37, mhimanshu wrote:

> > How to find best parameter values for deSolve function??
> > 
> 
> I assume you mean the deSolve package which has many options.
> 
> I would suggest predicting which way the wind will blow the 
> day after tomorrow.
> 
> Berend

  I think this is a less-well-worded repeat of this question:

http://article.gmane.org/gmane.comp.lang.r.general/258611

which is not unreasonable, but no-one's gotten around to answering it 
yet.
  (Terse answer: construct a function that takes the parameters of
the ODE, and the initial conditions if you don't know them but 
estimate them at the same time, solves the ODE numerically, and
computes a goodness-of-fit score (actually a badness of fit score,
such as the sum of squares or negative log-likelihood), and use
it as the objective function in optim().)

  Ben

__
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-contained, reproducible code.


Re: [R] How to export hexbin tables?

2012-03-22 Thread fco.pch
After go dinner...an non elegant "patch solution"... is working:

/str(hbin)
density <- table(hbin@count)
cell <- table(hbin@cell)
xcm <- table(hbin@xcm)
ycm <- table(hbin@ycm)

write.table(density, file="temp.density", sep="\t")/
... and the same for xcm, ycm, cell
the disadvantage is to work with 4 ASCII tables, which I need to "paste"

PS: Michael... your solution seems to be less antediluvian ;) 


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-export-hexbin-tables-tp4496035p4497039.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


[R] Memory Utilization on R

2012-03-22 Thread Kurinji Pandiyan
Hello,

I have a 32 GB RAM Mac Pro with a 2*2.4 GHz quad core processor and 2TB
storage. Despite this having so much memory, I am not able to get R to
utilize much more than 3 GBs. Some of my scripts take hours to run but I
would think they would be much faster if more memory is utilized. How do I
optimize the memory usage on R by my Mac Pro?

Thank you!
Kurinji

[[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-contained, reproducible code.


[R] Quicker way to apply values to a function

2012-03-22 Thread casperyc
Hi all,
myint=function(mu,sigma){
integrate(function(x) dnorm(x,mu,sigma)/(1+exp(-x)),-Inf,Inf)$value
}

mymu=seq(-3,3,length(1000))
mysigma=seq(0,1,length(500))[-1]

k=1
v=c()
for (j in 1:length(mymu)) {
for (i in 1:length(mysigma)) {
v[k]=myint(mymu[j],mysigma[i])
k=k+1
}
}


Basically, I want to investigate for what values of mu and sigma, the
integral is divergent.

Is there another way to do this other than loops?

For now, the 'output' vector v is not so informative. Is there a way to
'show' me for what combinations of mu and sigma, the resulting values 'v'
are from?

Thanks.



-
###
PhD candidate in Statistics
School of Mathematics, Statistics and Actuarial Science, University of Kent
###

--
View this message in context: 
http://r.789695.n4.nabble.com/Quicker-way-to-apply-values-to-a-function-tp4497293p4497293.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] Using "Compare" While Excluding Certain Columns

2012-03-22 Thread David Winsemius


On Mar 22, 2012, at 1:29 PM, Edgar Alminar wrote:


Hello All,
Is it possible to use compare (or something like it) and exclude  
certain columns in the csv's being compared? I have tried a bunch of  
different things and done some research, but couldn't find anything  
or get it to work.


You will need to do a better job of explaining what "get it to work"  
means. Exclusion of columns is trivial, but the verb _compare_ is  
exceptionally vague and admitting of many possible interpretations.



Any help would be greatly appreciated.


That's what we should be saying.




Thanks!

Edgar Alminar
Clinical Operations
Alzheimer's Disease Cooperative Study
University of California, San Diego


--

David Winsemius, MD
West Hartford, CT

__
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-contained, reproducible code.


Re: [R] Randomly select elements based on criteria

2012-03-22 Thread Peter Ehlers

Here's another way:
With d1 as your data frame,

 library(plyr)
 d2 <- ddply(d1, .(fam), function(x) x[sample(nrow(x), 1), ])
 d2[sample(nrow(d2), 2), ]

If you have to take account of the 'only one family' case, you
can wrap this in a function with an appropriate check:

  fish <- function(d){
if(length(unique(d[,'fam'])) < 2) stop('only one family')
d2 <- ddply(d,.(fam),function(x)x[sample(nrow(x), 1), ])
d2[sample(nrow(d2), 2), ]
  }

Peter Ehlers

On 2012-03-22 16:03, Jorge I Velez wrote:

You could avoid the loop to run for ever by introducing a stop() check.
Here is an example using Dr. Savicky's code:

# function to sample B pairs of
# fishes from different families
# -- d has columns fam, born, spawn
foo<- function(d, B){

 # internal function
 foo<- function(d){
 if(length(unique(d[, 'fam']))<  2) stop('only one family!')
 while (1) {
 ran<- sample(NROW(d), size = 2)
 if (d[ran[1], 1] != d[ran[2], 1]) break
   }
   d[ran, ]
   }

   # sampling B pairs of fishes
   lapply(1:B, function(i) foo(d))
   }

# example:  2 pairs of fishes from different families
foo(fish, 2)

#  data with only one family
ff<- fish[1,]
foo(ff, 2)  # Error in foo(d) : only one family!

HTH,
Jorge.-


On Thu, Mar 22, 2012 at 5:27 PM, Petr Savicky<>  wrote:


On Thu, Mar 22, 2012 at 11:42:53AM -0700, aly wrote:

Hi,

I want to randomly pick 2 fish born the same day but I need those
individuals to be from different families. My table includes 1787 fish
distributed in 948 families. An example of a subset of fish born in one
specific day would look like:


fish


fam   born  spawn
2546  43
2546  56
2646  50
4346  43
131   46  43
133   46  64
136   46  43
136   46  42
136   46  50
136   46  85
137   46  64
142   46  85
144   46  56
144   46  64
144   46  78
144   46  85
145   46  64
146   46  64
147   46  64
148   46  78
149   46  43
149   46  98
149   46  85
150   46  64
150   46  78
150   46  85
151   46  43
152   46  78
153   46  43
156   46  43
157   46  91
158   46  42

Where "fam" is the family that fish belongs to, "born" is the day it was
born (in this case day 46), and "spawn" is the day it was spawned. I

want to

know if there is a correlation in the day of spawn between fish born the
same day but that are unrelated (not from the same family).
I want to randomly select two rows but they have to be from different

fam.

The fist part (random selection), I got it by doing:


ran<- sample(nrow (fish), size=2); ran


[1]  9 12


newfish<- fish [ran,];  newfish


 fam born spawn
103 136   4650
106 142   4685

In this example I got two individuals from different families (good) but

I

will repeat the process many times and there's a chance that I get two

fish

from the same family (bad):


ran<-sample (nrow(fish), size=2);ran


[1] 26 25


newfish<-fish [ran,]; newfish


 fam born spawn
127 150   4685
126 150   4678

I need a conditional but I have no clue on how to include it in the code.


Hi.

Try the following.

  while (1) {
ran<- sample(nrow(fish), size=2)
if (fish[ran[1], 1] != fish[ran[2], 1]) break
  }
  fish[ran, ]

This will generate only pairs from different families. However,
note that the loop will run forever, if the data contain only
fish from one family.

Hope this helps.

Petr Savicky.

__
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-contained, reproducible code.



[[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-contained, reproducible code.


__
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-contained, reproducible code.


[R] Computing High Order Derivatives (Numerically)

2012-03-22 Thread Gildas Mazo
Dear R users,

Let f be a function over d variables x1,..,xd. I want to compute the k^th-order 
derivative with respect to x1,..,xk (k<=d). I have a by hand solution (see 
below) using an iterating code using D. However, I expect d to be high and f to 
be complicated. Then I want a vector x to be the input, instead of x1,..,xd. 
How to avoid the x1 <- x[1]; x2 <- x[2], etc steps in the code below? Moreover, 
D uses symbolic differentation and then eval evaluates the output to get a 
numerical result. But is there a way to compute the desired derivatives 
numerically directly (without using symbolic calculus at all)? Finally, what is 
the most efficient and fast way to get a numerical result for such derivatives?

Thank you very much in advance,
Gildas

### Code ###
### dif takes a function f, an order k, and a vector x as input. f must be a 
function of x1,..,xd with d >= k. The correspondance is done between xi and 
x[i]. The expression for f must be at the last row of the body function.
dif <- function(f,k,x){
  o <- list()
  n <- length(body(f))
  o[[1]] <- body(f)[[n]]
  for (i in 1:k){
xi <- paste("x",i,sep="")
o[[i+1]] <- D(o[[i]],name=xi)
  }
  x1 <- x[1]
  x2 <- x[2]
  x3 <- x[3]
  eval(o[[k+1]])
}

### Examples ###
## function to differentiate
f <- function(x){
  x1 <- x[1]
  x2 <- x[2]
  x3 <- x[3]
  0.5*x1*x2*x3^2
}
## derivative w.r.t. x1, x2 and x3 at the point (1,2,3).
dif(f,3,c(1,2,3))

### My Questions ###
## how to avoid to write by hand xi <- x[i] ??
## is there a way in R to compute such derivatives without using symbolic 
calculation but numerical compuation instead.

__
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-contained, reproducible code.


Re: [R] Randomly select elements based on criteria

2012-03-22 Thread Jorge I Velez
You could avoid the loop to run for ever by introducing a stop() check.
Here is an example using Dr. Savicky's code:

# function to sample B pairs of
# fishes from different families
# -- d has columns fam, born, spawn
foo <- function(d, B){

# internal function
foo <- function(d){
if(length(unique(d[, 'fam'])) < 2) stop('only one family!')
while (1) {
ran <- sample(NROW(d), size = 2)
if (d[ran[1], 1] != d[ran[2], 1]) break
  }
  d[ran, ]
  }

  # sampling B pairs of fishes
  lapply(1:B, function(i) foo(d))
  }

# example:  2 pairs of fishes from different families
foo(fish, 2)

#  data with only one family
ff <- fish[1,]
foo(ff, 2)  # Error in foo(d) : only one family!

HTH,
Jorge.-


On Thu, Mar 22, 2012 at 5:27 PM, Petr Savicky <> wrote:

> On Thu, Mar 22, 2012 at 11:42:53AM -0700, aly wrote:
> > Hi,
> >
> > I want to randomly pick 2 fish born the same day but I need those
> > individuals to be from different families. My table includes 1787 fish
> > distributed in 948 families. An example of a subset of fish born in one
> > specific day would look like:
> >
> > >fish
> >
> > fam   born  spawn
> > 2546  43
> > 2546  56
> > 2646  50
> > 4346  43
> > 131   46  43
> > 133   46  64
> > 136   46  43
> > 136   46  42
> > 136   46  50
> > 136   46  85
> > 137   46  64
> > 142   46  85
> > 144   46  56
> > 144   46  64
> > 144   46  78
> > 144   46  85
> > 145   46  64
> > 146   46  64
> > 147   46  64
> > 148   46  78
> > 149   46  43
> > 149   46  98
> > 149   46  85
> > 150   46  64
> > 150   46  78
> > 150   46  85
> > 151   46  43
> > 152   46  78
> > 153   46  43
> > 156   46  43
> > 157   46  91
> > 158   46  42
> >
> > Where "fam" is the family that fish belongs to, "born" is the day it was
> > born (in this case day 46), and "spawn" is the day it was spawned. I
> want to
> > know if there is a correlation in the day of spawn between fish born the
> > same day but that are unrelated (not from the same family).
> > I want to randomly select two rows but they have to be from different
> fam.
> > The fist part (random selection), I got it by doing:
> >
> > > ran <- sample(nrow (fish), size=2); ran
> >
> > [1]  9 12
> >
> > > newfish <- fish [ran,];  newfish
> >
> > fam born spawn
> > 103 136   4650
> > 106 142   4685
> >
> > In this example I got two individuals from different families (good) but
> I
> > will repeat the process many times and there's a chance that I get two
> fish
> > from the same family (bad):
> >
> > > ran<-sample (nrow(fish), size=2);ran
> >
> > [1] 26 25
> >
> > > newfish <-fish [ran,]; newfish
> >
> > fam born spawn
> > 127 150   4685
> > 126 150   4678
> >
> > I need a conditional but I have no clue on how to include it in the code.
>
> Hi.
>
> Try the following.
>
>  while (1) {
>ran <- sample(nrow(fish), size=2)
>if (fish[ran[1], 1] != fish[ran[2], 1]) break
>  }
>  fish[ran, ]
>
> This will generate only pairs from different families. However,
> note that the loop will run forever, if the data contain only
> fish from one family.
>
> Hope this helps.
>
> Petr Savicky.
>
> __
> 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-contained, reproducible code.
>

[[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-contained, reproducible code.


Re: [R] Plotting patient drug timelines using ggplot2 (or some other means) -- Help!!!

2012-03-22 Thread Paul Miller
Hi Michael,

This may be an ugly way of doing things but the "title = unique(paste( ..." bit 
in the code below automates the code for pattern, patient, and line.

So now all I'd need is the looping part.

If good ways of automating the code for pattern, patient, and line or of doing 
the looping are apparent, please let me know. 

Thanks,

Paul
 

ggplot(TestData, aes(value, drug)) + geom_line(size = 6) + xlab("") + ylab("") 
+ theme_bw() +
 opts(title = unique(paste(TestData$pattern, "\n (profile_key = 
", TestData$profile_key, ", line = ", TestData$line, ") \n" ) ) ) +
 opts(axis.text.x = theme_blank() )

__
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-contained, reproducible code.


Re: [R] Rcmd build -binary -- problem

2012-03-22 Thread Prof Brian Ripley

On 22/03/2012 17:33, Stephen Eick wrote:

Hi.  I need a bit of help.  I'm running Windows 7 and "out of the box"
versions of Rtools and R (version 2.14.2) and am trying to compile a
package that worked before. When I run the command:


Rcmd build -binary mypackage
Warning: unknown option '-binary'


i get a warning and it creates the tar.gz file but not the zip file like
before.  Something has changed with the more recent versions of R.  Any
suggestions on how to make the .zip file?


Nothing has changed.  It is --binary (two hyphens) as it always was (and 
you explicitly asked not to send HTML, as you always were).




[[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-contained, reproducible code.



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
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-contained, reproducible code.


Re: [R] Plotting patient drug timelines using ggplot2 (or some other means) -- Help!!!

2012-03-22 Thread Paul Miller
Hi Michael,

Want to reverse the ordering of drugs on the y-axis. So tried scale_y_reverse() 
instead of scale_x_reverse(). Sure enough, the command exits. Unfortunately, it 
is "unsuitable for factors". I tried converting "drug" to character but this 
didn't work. Suspect scale_x_reverse() only works for something numeric which I 
don't think is helpful in my case. So changing "drug" to an ordered factor may 
make sense. I found some stuff online suggesting this approach.

The suggestion for setting the size of the image device directly was very 
helpful. 

My code now looks like:

connection <- textConnection("
1/1/Drug A/ Begin (A), Begin (B), End (B), End (A)/0./21.000
1/1/Drug B/ Begin (A), Begin (B), End (B), End (A)/0.7143/18.000
1/2/Drug A/ Begin (A, B, C), End (A, B), End (C)/0./20.000
1/2/Drug B/ Begin (A, B, C), End (A, B), End (C)/0./20.000
1/2/Drug C/ Begin (A, B, C), End (A, B), End (C)/0./36.000
2/1/Drug A/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End 
(D)/0./7.429
2/1/Drug B/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
0./7.429
2/1/Drug C/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
14.5714/21.857
2/1/Drug D/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
25.4286/231.286
2/2/Drug A/ Begin (A, B), End (A, B)/0./35.286
2/2/Drug B/ Begin (A, B), End (A, B)/0./35.286
")

TestData <- data.frame(scan(connection, list(profile_key=0, line=0, drug="", 
pattern="", start_drug=0, stop_drug=0), sep="/"))
TestData <- TestData[TestData$profile_key == 2 & TestData$line == 1,]
TestData

require(reshape)
TestData <- melt(TestData, measure.vars = c("start_drug", "stop_drug"))
TestData

TestData$drug <- factor(TestData$drug, levels = c("Drug D", "Drug C", "Drug B", 
"Drug A"))

png(filename="plot21.png", width=600, height=300)

ggplot(TestData, aes(value, drug)) + geom_line(size = 6) + xlab("") + ylab("") 
+ theme_bw() +
 opts(title = "Pattern = Begin (A), Begin (B), End (B), End (A) 
\n (profile_key = 2, line = 1)") +
 opts(axis.text.x = theme_blank() )

dev.off()

This produces a perfectly sized image. I imported the image created into Word 
and it looks like I would get 3 images per page.

As far as the text at the top of the graphs goes, I have 4 patient x line 
combinations in my data (at least before I filter to get a single patient by 
line combination). So the text at the top of each graph (without any filtering) 
would be as follows:

Pattern = Begin (A), Begin (B), End (B), End (A)
(profile_key = 1, line = 1)

Pattern = Begin (A, B, C), End (A, B), End (C)
(profile_key = 1, line = 2)

Pattern = Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)
(profile_key = 2, line = 1)

Pattern = Begin (A, B), End (A, B)
(profile_key = 2, line = 2)

As far as I know, there's nothing like this online. I hope this makes it clear 
though. 

The last part would be looping. I think I could figure out how to do this using 
a for loop or some other means if I can get one of the graphs set up correctly. 
The graphs themselves might be called something like plot11, plot12, plot21, 
and plot22.

Thanks,

Paul













--- On Thu, 3/22/12, R. Michael Weylandt  wrote:

> From: R. Michael Weylandt 
> Subject: Re: [R] Plotting patient drug timelines using ggplot2 (or some other 
> means) -- Help!!!
> To: "Paul Miller" 
> Cc: r-help@r-project.org
> Received: Thursday, March 22, 2012, 4:11 PM
> On Thu, Mar 22, 2012 at 4:47 PM, Paul
> Miller 
> wrote:
> > Hi Michael,
> >
> > Made some progress but not there yet.
> >
> > Got point #1 by creating an ordered factor. There
> doesn't appear to be a command called Scale_x_flip().
> >
> 
> Sorry, my mistake: I meant scale_x_reverse() ...
> 
> > Still not sure how to decrease vertical space between
> the line segments for each drug. Thought this would be
> necessary in order to get a fair number of graphs onto a
> page in Word or in a pdf (say 4-5). I had imagined creating
> graphs that would be wider than they are tall in order to
> accomplish this.
> 
> You can set the size of the image device directly, e.g.,
> png(,
> width = 400, height = 200) and then make your plots one per
> image,
> closing the device with dev.off() when you're done. I think
> getting
> multiple plots per page (without facetting) won't be super
> easy and
> requires a few tricks with grid tools; someone might know
> better.
> 
> I know pdf() supports multiple pages if you plot multiple
> graphs and
> don't close the device between, but I'm not sure that's
> doable with
> the other ones.
> 
> >
> > Removed numbering from the x-axis using
> "opts(axis.text.x = theme_blank()". This is slightly
> different from the "opts(axis.ticks.x = theme_blank())" that
> you suggested. Having axis.ticks.x made it a lot easier to
> figure out I needed axis.text.x though.
> >
> > Got the text for pattern at the top (point #4).
> >
> > Still struggling with the te

Re: [R] deSolve

2012-03-22 Thread Berend Hasselman

On 22-03-2012, at 18:37, mhimanshu wrote:

> Hello all,
> 
> How to find best parameter values for deSolve function??
> 

I assume you mean the deSolve package which has many options.

I would suggest predicting which way the wind will blow the day after tomorrow.

Berend

__
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-contained, reproducible code.


Re: [R] Randomly select elements based on criteria

2012-03-22 Thread Petr Savicky
On Thu, Mar 22, 2012 at 11:42:53AM -0700, aly wrote:
> Hi,
> 
> I want to randomly pick 2 fish born the same day but I need those
> individuals to be from different families. My table includes 1787 fish
> distributed in 948 families. An example of a subset of fish born in one
> specific day would look like:
> 
> >fish
> 
> fam   born  spawn
> 2546  43
> 2546  56
> 2646  50
> 4346  43
> 131   46  43
> 133   46  64
> 136   46  43
> 136   46  42
> 136   46  50
> 136   46  85
> 137   46  64
> 142   46  85
> 144   46  56
> 144   46  64
> 144   46  78
> 144   46  85
> 145   46  64
> 146   46  64
> 147   46  64
> 148   46  78
> 149   46  43
> 149   46  98
> 149   46  85
> 150   46  64
> 150   46  78
> 150   46  85
> 151   46  43
> 152   46  78
> 153   46  43
> 156   46  43
> 157   46  91
> 158   46  42
> 
> Where "fam" is the family that fish belongs to, "born" is the day it was
> born (in this case day 46), and "spawn" is the day it was spawned. I want to
> know if there is a correlation in the day of spawn between fish born the
> same day but that are unrelated (not from the same family). 
> I want to randomly select two rows but they have to be from different fam.
> The fist part (random selection), I got it by doing:
> 
> > ran <- sample(nrow (fish), size=2); ran
> 
> [1]  9 12
> 
> > newfish <- fish [ran,];  newfish
> 
> fam born spawn
> 103 136   4650 
> 106 142   4685 
> 
> In this example I got two individuals from different families (good) but I
> will repeat the process many times and there's a chance that I get two fish
> from the same family (bad):
> 
> > ran<-sample (nrow(fish), size=2);ran
> 
> [1] 26 25
> 
> > newfish <-fish [ran,]; newfish
> 
> fam born spawn
> 127 150   4685
> 126 150   4678
> 
> I need a conditional but I have no clue on how to include it in the code.

Hi.

Try the following.

  while (1) {
ran <- sample(nrow(fish), size=2)
if (fish[ran[1], 1] != fish[ran[2], 1]) break
  }
  fish[ran, ]

This will generate only pairs from different families. However,
note that the loop will run forever, if the data contain only
fish from one family.

Hope this helps.

Petr Savicky.

__
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-contained, reproducible code.


Re: [R] How to export hexbin tables?

2012-03-22 Thread R. Michael Weylandt
Grumble grumblestop triple postinggrumble grumble..damn
nabblegrumble grumble

It's inelegant, but if your Python-skills are up for it, you could do
something like this:

sapply(c("cell","count","xcm","ycm"), function(x) slot(HEXBINOBJECTNAME, x))

You'll have to reconstruct things on the python end though.

Hope this helps,
Michael

On Thu, Mar 22, 2012 at 2:34 PM, fco.pch  wrote:
> Hi Michael!
> thanks for your answer, but
>
> In fact I need to export the hexbin table (the set of hexagons' coordinates,
> "weights", etc) into an ASCII file. Not the workspace... but only the
> "table".
>
> I gonna handle it with python (this is the  ASCII reason), and compare with
> some theorical predictions.
>
> So... Some idea How can I export only the "hexbin table"?
> Thanks! :D
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/How-to-export-hexbin-tables-tp4496035p4496466.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


Re: [R] trouble for parsing HTML files

2012-03-22 Thread R. Michael Weylandt
Please give sessionInfo() so we can know your version of XML.

Michael

On Thu, Mar 22, 2012 at 2:04 PM, Julien Velcin
 wrote:
> I use mac OS 10.5.8 with this version of R:
>
> R version 2.14.1 (2011-12-22)
> Platform: i386-apple-darwin9.8.0/i386 (32-bit)
>
> I've tried the command "RSiteSearch", but with no result.
>
> BTW, I recall that the code I've posted works for some websites.
>
> Julien
>
>
>
>
> 2012/3/22, Milan Bouchet-Valat :
>> Le jeudi 22 mars 2012 à 17:20 +0100, Julien Velcin a écrit :
>>> Hi all,
>>>
>>> Using the XML package, I'm not able to parse some html webpages. Here
>>> is my code and the error message:
>>>
>>> library("XML")
>>> url <- "http://www.huffingtonpost.com/social/GraniteSkyline?action=fans";
>>> doc <- htmlParse(url)
>>>
>>> Error: Namespace prefix ꛀ of attribute (null) is not defined
>>>
>>> I've searched a lot on the Internet, but it's really difficult to find
>>> something useful for R.
>> What versions of R and XML are you using? The code you provided works
>> fine here (R 2.14.1 x86_64 and XML 3.9-4 on Fedora 16). sessionInfo()
>> will help us.
>>
>> BTW, see ?RSiteSearch to search for R content on the Web.
>>
>>
>> Cheers
>>
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


Re: [R] Plotting patient drug timelines using ggplot2 (or some other means) -- Help!!!

2012-03-22 Thread R. Michael Weylandt
On Thu, Mar 22, 2012 at 4:47 PM, Paul Miller  wrote:
> Hi Michael,
>
> Made some progress but not there yet.
>
> Got point #1 by creating an ordered factor. There doesn't appear to be a 
> command called Scale_x_flip().
>

Sorry, my mistake: I meant scale_x_reverse() ...

> Still not sure how to decrease vertical space between the line segments for 
> each drug. Thought this would be necessary in order to get a fair number of 
> graphs onto a page in Word or in a pdf (say 4-5). I had imagined creating 
> graphs that would be wider than they are tall in order to accomplish this.

You can set the size of the image device directly, e.g., png(,
width = 400, height = 200) and then make your plots one per image,
closing the device with dev.off() when you're done. I think getting
multiple plots per page (without facetting) won't be super easy and
requires a few tricks with grid tools; someone might know better.

I know pdf() supports multiple pages if you plot multiple graphs and
don't close the device between, but I'm not sure that's doable with
the other ones.

>
> Removed numbering from the x-axis using "opts(axis.text.x = theme_blank()". 
> This is slightly different from the "opts(axis.ticks.x = theme_blank())" that 
> you suggested. Having axis.ticks.x made it a lot easier to figure out I 
> needed axis.text.x though.
>
> Got the text for pattern at the top (point #4).
>
> Still struggling with the text for patient and line (point #5). Managed to at 
> least add some text manually to show what the text would look like for one of 
> the graphs.

I'm not sure what you are looking for here -- is there an image online
you can point me too?

>
> Not sure how to get a separate graph for each patient x line combination. 
> Discovered facets earlier today. Think this will just give me one giant graph 
> though that contains graph for each patient x line combination.
> This isn't so bad but it's not clear how one could print it and have the 
> graphs break properly across pages.
>

As described above, you probably want to make multiple files by
looping over your data and selecting subsets. I know Bert pointed you
to xyplot in lattice graphics -- if you get that working, I believe it
has some natural support for multi-page graphics but I don't know the
package so well.

> If you can provide any additional help, that's great. If not that's OK too. 
> As I said earlier, there's a big time crunch around this. If I can't figure 
> it out today, then we'll just move forward without it. Then I can figure out 
> how to do it later for my own edification and at my own leisure. Chances are 
> that will be a lot more fun than trying to learn under intense time pressure.
>
> Thanks,
>
> Paul
>
>
> connection <- textConnection("
> 1/1/Drug A/ Begin (A), Begin (B), End (B), End (A)/0./21.000
> 1/1/Drug B/ Begin (A), Begin (B), End (B), End (A)/0.7143/18.000
> 1/2/Drug A/ Begin (A, B, C), End (A, B), End (C)/0./20.000
> 1/2/Drug B/ Begin (A, B, C), End (A, B), End (C)/0./20.000
> 1/2/Drug C/ Begin (A, B, C), End (A, B), End (C)/0./36.000
> 2/1/Drug A/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End 
> (D)/0./7.429
> 2/1/Drug B/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
> 0./7.429
> 2/1/Drug C/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
> 14.5714/21.857
> 2/1/Drug D/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
> 25.4286/231.286
> 2/2/Drug A/ Begin (A, B), End (A, B)/0./35.286
> 2/2/Drug B/ Begin (A, B), End (A, B)/0./35.286
> ")
>
> TestData <- data.frame(scan(connection, list(profile_key=0, line=0, drug="", 
> pattern="", start_drug=0, stop_drug=0), sep="/"))
> TestData <- TestData[TestData$profile_key == 2 & TestData$line == 1,]
> TestData
>
> require(reshape)
> TestData <- melt(TestData, measure.vars = c("start_drug", "stop_drug"))
> TestData
>
> TestData$drug <- factor(TestData$drug, levels = c("Drug D", "Drug C", "Drug 
> B", "Drug A"))
>
> ggplot(TestData, aes(value, drug)) + geom_line(size = 6) + xlab("") + 
> ylab("") + theme_bw() +
>                 opts(title = "Pattern = Begin (A), Begin (B), End (B), End 
> (A) \n (profile_key = 2, line = 1)") +
>                     opts(axis.text.x = theme_blank() )
>
>
>
> --- On Thu, 3/22/12, R. Michael Weylandt  wrote:
>
>> From: R. Michael Weylandt 
>> Subject: Re: [R] Plotting patient drug timelines using ggplot2 (or some 
>> other means) -- Help!!!
>> To: "Paul Miller" 
>> Cc: r-help@r-project.org
>> Received: Thursday, March 22, 2012, 12:55 PM
>> Inline:
>>
>> On Thu, Mar 22, 2012 at 1:41 PM, Paul Miller 
>> wrote:
>> > Hello All,
>> >
>> > Want very much to learn how to plot patient drug
>> timelines. Trouble is I need to figure out how to do this
>> today. So not much time for me to struggle with it. Hoping
>> someone can just help me out a bit.
>> >
>> > Below are some sample data and code that produces what
>> I think is the beginning of a very nice graph

Re: [R] How do you distinguish between characters on a pco plot?

2012-03-22 Thread Sarah Goslee
Hi,

You can use eg pch and col in the plot command (see ?par for information).

The help for pco even gives an example of doing so.

Sarah

On Thu, Mar 22, 2012 at 1:15 PM, leannehaggerty
 wrote:
> I have a presence/absence matrix for which I create a distance matrix and
> then perform pco analysis on.
>
> /library(ecodist)
> table <- read.table("matrix.pa")
> dist <- dist(table, method = "euclidean", diag = FALSE, upper = FALSE)
> dist.pco <- pco(dist)/
>
> When I plot the pco analysis of the distance matrix I want to be able to
> distinguish between certain characters, for example if the distance matrix
> looks like:
>
> http://r.789695.n4.nabble.com/file/n4496217/Screen_shot_2012-03-22_at_17.14.17.png
>
> 1, 2, 3 and 4 are the characters to be plotted. I'd like 1 and 2 to appear
> as the same shape/ colour on the plot, different from 3 and 4. Is it
> possible to do this?
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

__
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-contained, reproducible code.


Re: [R] how to avoid grid overlapping in a boxplot

2012-03-22 Thread Rui Barradas
Hello,


Michael Weylandt wrote
> 
> It's a bit of a hack, but you could just redraw the boxplot on top of
> the grid lines:
> 
> x <- rnorm(50)
> boxplot(x)
> grid()
> boxplot(x, add = TRUE)
> 
> Michael
> 
> 
> On Thu, Mar 22, 2012 at 12:08 PM, maxbre  wrote:
>> Given the following chart: i.e. a boxplot with a grid
>>
>> boxplot(x~y)
>> grid(nx=NA,ny=NULL)
>>
>> my question: how to avoid the overlapping of boxes (and whiskers) by grid
>> lines?
>>
>> thank you for any help pointing me in the right direction
>>
>> max
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/how-to-avoid-grid-overlapping-in-a-boxplot-tp4495955p4495955.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@ 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-contained, reproducible code.
> 
> __
> R-help@ 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-contained, reproducible code.
> 


Doesn't remove the grid lines, you need the parameter 'col':

x <- rnorm(50)
boxplot(x)
grid()
boxplot(x, add = TRUE, col="white") 

or, start an empty plot, draw the grid then the boxplot:


plot(1, type="n", xlim=c(0.5, 1.5), ylim=range(x), xlab="", ylab="",
axes=FALSE)
grid() 
boxplot(x, add=TRUE, col="white")

If you have two groups, the xlim would be c(0.5, 2.5), etc...

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-avoid-grid-overlapping-in-a-boxplot-tp4495955p4496688.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


[R] Order of terms in formula changes aov() results

2012-03-22 Thread Stuart Luppescu
Hello, This one is very perplexing. I have teacher observation data,
with factors teacher ID, observer ID, component, grade and subject. When
I do this,

aov(data=ratings.prin.22, rating ~ obsid.f + tid.f + subject.f + grade.f + 
comp.f)

I get this:

Terms:
  obsid.f tid.f   grade.fcomp.f Residuals
Sum of Squares  306.23399 221.38173   1.7  14.52831 279.05780
Deg. of Freedom7487 2 9  1406

This looks right. There are about 82 observers so 74 degrees of freedom
for obsid.f is OK. But if I do this (just reordering the terms in the
formula):

aov(data=ratings.prin.22, rating ~ comp.f + grade.f + subject.f + tid.f + 
obsid.f)

I get this:

Terms:
  comp.f  grade.f subject.ftid.f  obsid.f Residuals
Sum of Squares   15.0923  23.39685.9982 499.3568   0.  279.0578
Deg. of Freedom94 4  1523  1406

Now obsid.f only has 3 degrees of freedom and the sum of squares is
0.00. Could this be due to the unbalanced design?

If someone can explain this to me I would be very grateful.

-- 
Stuart Luppescu -=- slu .at. ccsr.uchicago.edu
University of Chicago -=- CCSR 
才文と智奈美の父 -=-Kernel 3.2.1-gentoo-r2
Tony Plate: There looks to be a typo in the R-exts 
 manual: [...] Peter Dalgaard: 'svn blame' tells me
 that this was Brian's addition in rev.35362 [...] 
 Brian D. Ripley: I prefer 'svn praise' myself.
 Peter Dalgaard: Or 'svn annotate'. I think it
 depends on what I'm looking for, plus the risk
 that the author (perpetrator, contributor) might
 be me...-- Tony Plate, Peter Dalgaard and
 Brian D. Ripley (about a typo in the

__
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-contained, reproducible code.


Re: [R] plotting moving range control chart

2012-03-22 Thread iTrubin
My favorite Control chart is based on MASF - Multivariate Adaptive
Statistical Filtering and it is called IT-Control Charts (good to use
against  date-time stamped data like System performance metrics.  And that
is actually based on moving range that MASF calls as a  reference set.  

I have recently started using R to build IT-Control Chart and I am
publishing my progress in my blog - System Management by Exception(
http://itrubin.blogspot.com http://itrubin.blogspot.com ) . See the last
posting related to your question:  
http://itrubin.blogspot.com/2012/03/r-script-to-plot-it-control-chart.html
R-script to plot IT-Control Chart against MySQL 

--
View this message in context: 
http://r.789695.n4.nabble.com/plotting-moving-range-control-chart-tp848263p4496577.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] read.zoo - combining two columns with date and time respectively into one index column?

2012-03-22 Thread knavero
Ah yes, sorry about that Gabor. Found a pretty good example in ?read.zoo
where it has index = 1:3 and takes in times objects. I must have overlooked
it out of impatience. Thanks for the quick and simple feedback however.

--
View this message in context: 
http://r.789695.n4.nabble.com/read-zoo-combining-two-columns-with-date-and-time-respectively-into-one-index-column-tp4495326p4496743.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] Multivariate control charts in R ?

2012-03-22 Thread iTrubin
My favorite Control chart is based on MASF - Multivariate Adaptive
Statistical Filtering and it is called IT-Control Charts (good to use
against  date-time stamped data like System performance metrics. 

I have recently started using R to build IT-Control Chart and I am
publishing my progress in my blog - System Management by Exception( 
http://itrubin.blogspot.com http://itrubin.blogspot.com ) . See the last
posting related to your question:  
http://itrubin.blogspot.com/2012/03/r-script-to-plot-it-control-chart.html
R-script to plot IT-Control Chart against MySQL 

--
View this message in context: 
http://r.789695.n4.nabble.com/Multivariate-control-charts-in-R-tp2336576p4496572.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] glm.fit: fitted probabilities numerically 0 or 1 occurred?

2012-03-22 Thread ufuk beyaztas
Dear ted, thanks for your help. Now, everything is more clear. I read
something about "linear separation" you mentioned, and my data set is very
suitable for this problem.  But, there is a confusing question for me;

I can not controll the process adequately because of usage of bootstrap. So,
this warnings will arise. 
After the analyse, If  I interpret the result with these warnings, does this
right? At least i may control the warnings "glm.fit: algorithm did not
converge" with gm.control, but "fitted probabilities numerically 0 or 1
occurred" will certainly arise. Does the interpretation of results with this
warning right?

Many thanks.

-
Best regards

Ufuk
--
View this message in context: 
http://r.789695.n4.nabble.com/glm-fit-fitted-probabilities-numerically-0-or-1-occurred-tp4490722p4496710.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] How to export hexbin tables?

2012-03-22 Thread fco.pch
Hi Michael! 
thanks for your answer, but 

In fact I need to export the hexbin table (the set of hexagons' coordinates,
"weights", etc) into an ASCII file. Not the workspace... but only the
"table". 

I gonna handle it with python (this is the  ASCII reason), and compare with
some theorical predictions. 

So... Some idea How can I export only the "hexbin table"?
Thanks! :D

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-export-hexbin-tables-tp4496035p4496466.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] How to export hexbin tables?

2012-03-22 Thread fco.pch
Hi Michael! 
thanks for your answer, but 

In fact I need to export the hexbin table (the set of hexagons' coordinates,
"weights", etc) into an ASCII file. Not the workspace... but only the
"table". 

I gonna handle it with python (this is the  ASCII reason), and compare with
some theorical predictions. 

So... Some idea How can I export only the "hexbin table"? 
Thanks! :D

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-export-hexbin-tables-tp4496035p4496543.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] How to export hexbin tables?

2012-03-22 Thread fco.pch
Hi Michael!
thanks for your answer, but

In fact I need to export the hexbin table (the set of hexagons' coordinates,
"weights, etc) into an ASCII file. Not the workspace... but only the
"table".

I gonna hadle it with python (this is the  ASCII reason), and comparing with
some theorical predictions.

So... How can I export a "hexbin table"?

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-export-hexbin-tables-tp4496035p4496440.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] How to export hexbin tables?

2012-03-22 Thread fco.pch
Hi David! 

I tried with dump(), but it can't handle S4 objects (as hexbin is): 

> dump("hbin", file="123.R") 
Warning message: 
In dump("hbin", file = "123.R") : 
  deparse of an S4 object will not be source()able

Thanks 4 the help... please give me another idea! :)

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-export-hexbin-tables-tp4496035p4496541.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


[R] deSolve

2012-03-22 Thread mhimanshu
Hello all,

How to find best parameter values for deSolve function??


Thanks in Advance,


--
View this message in context: 
http://r.789695.n4.nabble.com/deSolve-tp4496292p4496292.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] How to export hexbin tables?

2012-03-22 Thread fco.pch
Hi David!

I tried with dump(), but it can't handle S4 objects (as hexbin is):
/
> dump("hbin", file="123.R")
Warning message:
In dump("hbin", file = "123.R") :
  deparse of an S4 object will not be source()able/

Thanks 4 the help... please give me another idea! :)

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-export-hexbin-tables-tp4496035p4496460.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


[R] Rcmd build -binary -- problem

2012-03-22 Thread Stephen Eick
Hi.  I need a bit of help.  I'm running Windows 7 and "out of the box"
versions of Rtools and R (version 2.14.2) and am trying to compile a
package that worked before. When I run the command:

> Rcmd build -binary mypackage
> Warning: unknown option '-binary'

i get a warning and it creates the tar.gz file but not the zip file like
before.  Something has changed with the more recent versions of R.  Any
suggestions on how to make the .zip file?

[[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-contained, reproducible code.


[R] Using "Compare" While Excluding Certain Columns

2012-03-22 Thread Edgar Alminar
Hello All,
Is it possible to use compare (or something like it) and exclude certain 
columns in the csv's being compared? I have tried a bunch of different things 
and done some research, but couldn't find anything or get it to work. 
Any help would be greatly appreciated.

Thanks!

Edgar Alminar
Clinical Operations
Alzheimer's Disease Cooperative Study
University of California, San Diego
9500 Gilman Drive, MC-0949
La Jolla, CA 92093-0949
Tel: (858) 622-8798
Fax: (858) 622-5876
Email: eaalmi...@ucsd.edu

Confidentiality Notice- This e-mail message from the Alz...{{dropped:11}}

__
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-contained, reproducible code.


[R] How do you distinguish between characters on a pco plot?

2012-03-22 Thread leannehaggerty
I have a presence/absence matrix for which I create a distance matrix and
then perform pco analysis on. 

/library(ecodist)
table <- read.table("matrix.pa")
dist <- dist(table, method = "euclidean", diag = FALSE, upper = FALSE)
dist.pco <- pco(dist)/

When I plot the pco analysis of the distance matrix I want to be able to
distinguish between certain characters, for example if the distance matrix
looks like:

http://r.789695.n4.nabble.com/file/n4496217/Screen_shot_2012-03-22_at_17.14.17.png
 

1, 2, 3 and 4 are the characters to be plotted. I'd like 1 and 2 to appear
as the same shape/ colour on the plot, different from 3 and 4. Is it
possible to do this?

--
View this message in context: 
http://r.789695.n4.nabble.com/How-do-you-distinguish-between-characters-on-a-pco-plot-tp4496217p4496217.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] trouble for parsing HTML files

2012-03-22 Thread Julien Velcin
I use mac OS 10.5.8 with this version of R:

R version 2.14.1 (2011-12-22)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

I've tried the command "RSiteSearch", but with no result.

BTW, I recall that the code I've posted works for some websites.

Julien




2012/3/22, Milan Bouchet-Valat :
> Le jeudi 22 mars 2012 à 17:20 +0100, Julien Velcin a écrit :
>> Hi all,
>>
>> Using the XML package, I'm not able to parse some html webpages. Here
>> is my code and the error message:
>>
>> library("XML")
>> url <- "http://www.huffingtonpost.com/social/GraniteSkyline?action=fans";
>> doc <- htmlParse(url)
>>
>> Error: Namespace prefix ꛀ of attribute (null) is not defined
>>
>> I've searched a lot on the Internet, but it's really difficult to find
>> something useful for R.
> What versions of R and XML are you using? The code you provided works
> fine here (R 2.14.1 x86_64 and XML 3.9-4 on Fedora 16). sessionInfo()
> will help us.
>
> BTW, see ?RSiteSearch to search for R content on the Web.
>
>
> Cheers
>

__
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-contained, reproducible code.


[R] Randomly select elements based on criteria

2012-03-22 Thread aly
Hi,

I want to randomly pick 2 fish born the same day but I need those
individuals to be from different families. My table includes 1787 fish
distributed in 948 families. An example of a subset of fish born in one
specific day would look like:

>fish

fam   born  spawn
25  46  43
25  46  56
26  46  50
43  46  43
131 46  43
133 46  64
136 46  43
136 46  42
136 46  50
136 46  85
137 46  64
142 46  85
144 46  56
144 46  64
144 46  78
144 46  85
145 46  64
146 46  64
147 46  64
148 46  78
149 46  43
149 46  98
149 46  85
150 46  64
150 46  78
150 46  85
151 46  43
152 46  78
153 46  43
156 46  43
157 46  91
158 46  42

Where "fam" is the family that fish belongs to, "born" is the day it was
born (in this case day 46), and "spawn" is the day it was spawned. I want to
know if there is a correlation in the day of spawn between fish born the
same day but that are unrelated (not from the same family). 
I want to randomly select two rows but they have to be from different fam.
The fist part (random selection), I got it by doing:

> ran <- sample(nrow (fish), size=2); ran

[1]  9 12

> newfish <- fish [ran,];  newfish

fam born spawn
103 136   4650 
106 142   4685 

In this example I got two individuals from different families (good) but I
will repeat the process many times and there's a chance that I get two fish
from the same family (bad):

> ran<-sample (nrow(fish), size=2);ran

[1] 26 25

> newfish <-fish [ran,]; newfish

fam born spawn
127 150   4685
126 150   4678

I need a conditional but I have no clue on how to include it in the code.
Thanks in advance for any suggestions,

Aly

--
View this message in context: 
http://r.789695.n4.nabble.com/Randomly-select-elements-based-on-criteria-tp4496483p4496483.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] how to hide code of any function

2012-03-22 Thread Greg Snow
See the 'petals' function in the TeachingDemos package for one example
of hiding source from casual inspection (intermediate level R users
will still easily be able to figure out what the key code is, but will
not be able to claim that they stumbled across it on accident).

This post gives another possibility:
https://stat.ethz.ch/pipermail/r-devel/2011-October/062236.html



On Thu, Mar 15, 2012 at 6:53 AM, mrzung  wrote:
> hi
>
> I'm making some program and it need to be hidden.
>
> it's not commercial purpose but it is educational,
>
> so i do want to hide the code of function.
>
> for example,
>
> if i made following function:
>
> a<-function(x){
> y<-x^2
> print(y)
> }
>
> i do not want someone to type "a" and take the code of the function.
>
> is there anyone who can help me?
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/how-to-hide-code-of-any-function-tp4474822p4474822.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> 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-contained, reproducible code.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

__
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-contained, reproducible code.


Re: [R] Plotting patient drug timelines using ggplot2 (or some other means) -- Help!!!

2012-03-22 Thread Paul Miller
Hi Michael,

Made some progress but not there yet. 

Got point #1 by creating an ordered factor. There doesn't appear to be a 
command called Scale_x_flip(). 

Still not sure how to decrease vertical space between the line segments for 
each drug. Thought this would be necessary in order to get a fair number of 
graphs onto a page in Word or in a pdf (say 4-5). I had imagined creating 
graphs that would be wider than they are tall in order to accomplish this.

Removed numbering from the x-axis using "opts(axis.text.x = theme_blank()". 
This is slightly different from the "opts(axis.ticks.x = theme_blank())" that 
you suggested. Having axis.ticks.x made it a lot easier to figure out I needed 
axis.text.x though.

Got the text for pattern at the top (point #4).

Still struggling with the text for patient and line (point #5). Managed to at 
least add some text manually to show what the text would look like for one of 
the graphs.

Not sure how to get a separate graph for each patient x line combination. 
Discovered facets earlier today. Think this will just give me one giant graph 
though that contains graph for each patient x line combination. 
This isn't so bad but it's not clear how one could print it and have the graphs 
break properly across pages.

If you can provide any additional help, that's great. If not that's OK too. As 
I said earlier, there's a big time crunch around this. If I can't figure it out 
today, then we'll just move forward without it. Then I can figure out how to do 
it later for my own edification and at my own leisure. Chances are that will be 
a lot more fun than trying to learn under intense time pressure.

Thanks,

Paul


connection <- textConnection("
1/1/Drug A/ Begin (A), Begin (B), End (B), End (A)/0./21.000
1/1/Drug B/ Begin (A), Begin (B), End (B), End (A)/0.7143/18.000
1/2/Drug A/ Begin (A, B, C), End (A, B), End (C)/0./20.000
1/2/Drug B/ Begin (A, B, C), End (A, B), End (C)/0./20.000
1/2/Drug C/ Begin (A, B, C), End (A, B), End (C)/0./36.000
2/1/Drug A/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End 
(D)/0./7.429
2/1/Drug B/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
0./7.429
2/1/Drug C/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
14.5714/21.857
2/1/Drug D/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
25.4286/231.286
2/2/Drug A/ Begin (A, B), End (A, B)/0./35.286
2/2/Drug B/ Begin (A, B), End (A, B)/0./35.286
")

TestData <- data.frame(scan(connection, list(profile_key=0, line=0, drug="", 
pattern="", start_drug=0, stop_drug=0), sep="/"))
TestData <- TestData[TestData$profile_key == 2 & TestData$line == 1,]
TestData

require(reshape)
TestData <- melt(TestData, measure.vars = c("start_drug", "stop_drug"))
TestData

TestData$drug <- factor(TestData$drug, levels = c("Drug D", "Drug C", "Drug B", 
"Drug A"))

ggplot(TestData, aes(value, drug)) + geom_line(size = 6) + xlab("") + ylab("") 
+ theme_bw() +
 opts(title = "Pattern = Begin (A), Begin (B), End (B), End (A) 
\n (profile_key = 2, line = 1)") +
 opts(axis.text.x = theme_blank() )



--- On Thu, 3/22/12, R. Michael Weylandt  wrote:

> From: R. Michael Weylandt 
> Subject: Re: [R] Plotting patient drug timelines using ggplot2 (or some other 
> means) -- Help!!!
> To: "Paul Miller" 
> Cc: r-help@r-project.org
> Received: Thursday, March 22, 2012, 12:55 PM
> Inline:
> 
> On Thu, Mar 22, 2012 at 1:41 PM, Paul Miller 
> wrote:
> > Hello All,
> >
> > Want very much to learn how to plot patient drug
> timelines. Trouble is I need to figure out how to do this
> today. So not much time for me to struggle with it. Hoping
> someone can just help me out a bit.
> >
> > Below are some sample data and code that produces what
> I think is the beginning of a very nice graph.
> >
> > Need to alter the code to:
> >
> > 1. Get the lines for the drugs to appear on the y-axis
> in the order that they appear in the data.
> 
> Scale_x_flip()
> 
> >
> > 2. Decrease the vertical space between the line
> segments for each drug so they are fairly close to one
> another.
> 
> Why? This will happen automatically if needed
> 
> >
> > 3. Remove the numbering from the x-axis.
> 
> opts(axis.ticks.x = theme_blank())
> 
> >
> > 4. Put the text for pattern above the graph (e.g.,
> "Begin (A), Begin (B), End (B), End (A)"), either centered
> or left aligned.
> 
> 
> opts(title = "Begin (A), Begin (B), End (B), End (A)")
> 
> >
> > 5. Put the patient and line information below the text
> for pattern (e.g., "profile_key = 1, line = 1")
> 
> example(geom_text)
> or
> https://learnr.wordpress.com/2010/01/03/directlabels-adding-direct-labels-to-ggplot2-and-lattice-plots/
> 
> >
> > 6. Output a separate graph for each patient and line of
> treatent.
> >
> > Ultimately, I want to combine all the graphs into a
> single Word document. Or perhaps better yet, to create a pdf
> using LaTeX.
> 
> Google Sweave or (pos

Re: [R] getting multiple plots on a single plot

2012-03-22 Thread Vihan Pandey
On 22 March 2012 21:06, David Winsemius  wrote:
>
> On Mar 22, 2012, at 3:18 PM, Vihan Pandey wrote:
>
>> Hi all,
>>
>> I have the following R script :
>>
>>
>> #!/usr/bin/Rscript
>>
>> out_file = "hybrid.pdf"
>> pdf(out_file, height=8.5, width=11)
>
>
> At this point (assuming that you want three separate plots on the same page
> which is unclear but you do use different titles and ylabs, so I think this
> is implied) you would either be using layout()
>
> ?layout
>
>  or par() with arguments mfrow, mfcol, or mfg.
>
> ?par

Thanks David, I'm a newbie at R and am not familiar with par() and
layout(), I will check them out!

Cheers!

- vihan

>
>>
>> myvalues_1M <- read.csv("hybrid_sims_1M.csv",head=TRUE,sep=",")
>> plot(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,xlab="Number
>> of Simulations per Thread",ylab="Time per 1 million Simulations(in
>> milliseconds)",col="red",main="For 1 million simulations")
>> lines(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,col="red")
>
>
> If on the other hand you want one plot frame with overlaid point/lines/etc,
> then you should be determining your x and y limits before any plots and
> putting in the same limits for each plot Adding all your labels on the first
> plot and using:
>
> par(new=TRUE) # which seems completely backward to me.
>
> # I say again ...
> ? par
>
>
>>
>> myvalues_5M <- read.csv("hybrid_sims_5M.csv",head=TRUE,sep=",")
>> plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab="Number
>> of Simulations per Thread",ylab="Time per 1 million Simulations(in
>> milliseconds)",col="blue",main="For 5 million simulations")
>> lines(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,col="blue")
>>
>> myvalues_10M <- read.csv("hybrid_sims_10M.csv",head=TRUE,sep=",")
>>
>> plot(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,xlab="Number
>> of Simulations per Thread",ylab="Time per 1 million Simulations(in
>> milliseconds)",col="green",main="For 10 million simulations")
>>
>> lines(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,col="green")
>>
>> dev.off()
>>
>> print(paste("Plot was saved in:", getwd()))
>>
>>
>>
>> This generates a 3 page pdf file with a plot on each page. They look like
>> this :
>>
>> http://s17.postimage.org/ud9ej1cnj/alpha1.png
>> http://s13.postimage.org/7q3snqsrr/alpha2.png
>> http://s14.postimage.org/sf374f12p/alpha3.png
>>
>> I want to plot all the 3 in one graph, in one page with the respective
>> colours - red, blue, and green. Any ideas on how?
>>
>> Thanks,
>>
>> - vihan
>>
>> __
>> 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-contained, reproducible code.
>
>
> David Winsemius, MD
> West Hartford, CT
>

__
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-contained, reproducible code.


Re: [R] trouble for parsing HTML files

2012-03-22 Thread Julien Velcin

Sorry for the multiple messages.
--

I use mac OS 10.5.8 with this version of R:

R version 2.14.1 (2011-12-22)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

I've tried the command "RSiteSearch", but with no result.

BTW, I recall that the code I've posted works for some websites.

Julien

__
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-contained, reproducible code.


Re: [R] getting multiple plots on a single plot

2012-03-22 Thread Vihan Pandey
On 22 March 2012 20:54, Chris Snook  wrote:
> vihan,
>
> you jsut need to add the following statement in the subsequent plot
> commands:
>
> add = TRUE
>
> so that your second and later plot commands look similar to:
>
> plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab="Number
> of Simulations per Thread",ylab="Time per 1 million Simulations(in
> milliseconds)",col="blue",main="For 5 million simulations", add = TRUE)

Thanks, but that still does keeps it on different pages and generates warnings :

Warning messages:
1: In plot.window(...) : "add" is not a graphical parameter
2: In plot.xy(xy, type, ...) : "add" is not a graphical parameter
3: In axis(side = side, at = at, labels = labels, ...) :
  "add" is not a graphical parameter
4: In axis(side = side, at = at, labels = labels, ...) :
  "add" is not a graphical parameter
5: In box(...) : "add" is not a graphical parameter
6: In title(...) : "add" is not a graphical parameter

Cheers!

- vihan

>
> HTH
>
> Chris
> On 03/22/2012 03:18 PM, Vihan Pandey wrote:
>> Hi all,
>>
>> I have the following R script :
>>
>>
>> #!/usr/bin/Rscript
>>
>> out_file = "hybrid.pdf"
>> pdf(out_file, height=8.5, width=11)
>>
>> myvalues_1M <- read.csv("hybrid_sims_1M.csv",head=TRUE,sep=",")
>> plot(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,xlab="Number
>> of Simulations per Thread",ylab="Time per 1 million Simulations(in
>> milliseconds)",col="red",main="For 1 million simulations")
>> lines(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,col="red")
>>
>> myvalues_5M <- read.csv("hybrid_sims_5M.csv",head=TRUE,sep=",")
>> plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab="Number
>> of Simulations per Thread",ylab="Time per 1 million Simulations(in
>> milliseconds)",col="blue",main="For 5 million simulations")
>> lines(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,col="blue")
>>
>> myvalues_10M <- read.csv("hybrid_sims_10M.csv",head=TRUE,sep=",")
>> plot(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,xlab="Number
>> of Simulations per Thread",ylab="Time per 1 million Simulations(in
>> milliseconds)",col="green",main="For 10 million simulations")
>> lines(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,col="green")
>>
>> dev.off()
>>
>> print(paste("Plot was saved in:", getwd()))
>>
>>
>>
>> This generates a 3 page pdf file with a plot on each page. They look like 
>> this :
>>
>> http://s17.postimage.org/ud9ej1cnj/alpha1.png
>> http://s13.postimage.org/7q3snqsrr/alpha2.png
>> http://s14.postimage.org/sf374f12p/alpha3.png
>>
>> I want to plot all the 3 in one graph, in one page with the respective
>> colours - red, blue, and green. Any ideas on how?
>>
>> Thanks,
>>
>> - vihan
>>
>> __
>> 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-contained, reproducible code.
>>
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


Re: [R] getting multiple plots on a single plot

2012-03-22 Thread Vihan Pandey
On 22 March 2012 20:23, R. Michael Weylandt  wrote:
> Don't use plot three times -- it opens a new page when pdf() is your
> current device. Do the first with plot -- then use lines() online from
> there to the end.

Thanks a million that did the job! :-)

Cheers!

- vihan

>
> Michael
>
> On Thu, Mar 22, 2012 at 3:18 PM, Vihan Pandey  wrote:
>> Hi all,
>>
>> I have the following R script :
>>
>>
>> #!/usr/bin/Rscript
>>
>> out_file = "hybrid.pdf"
>> pdf(out_file, height=8.5, width=11)
>>
>> myvalues_1M <- read.csv("hybrid_sims_1M.csv",head=TRUE,sep=",")
>> plot(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,xlab="Number
>> of Simulations per Thread",ylab="Time per 1 million Simulations(in
>> milliseconds)",col="red",main="For 1 million simulations")
>> lines(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,col="red")
>>
>> myvalues_5M <- read.csv("hybrid_sims_5M.csv",head=TRUE,sep=",")
>> plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab="Number
>> of Simulations per Thread",ylab="Time per 1 million Simulations(in
>> milliseconds)",col="blue",main="For 5 million simulations")
>> lines(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,col="blue")
>>
>> myvalues_10M <- read.csv("hybrid_sims_10M.csv",head=TRUE,sep=",")
>> plot(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,xlab="Number
>> of Simulations per Thread",ylab="Time per 1 million Simulations(in
>> milliseconds)",col="green",main="For 10 million simulations")
>> lines(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,col="green")
>>
>> dev.off()
>>
>> print(paste("Plot was saved in:", getwd()))
>>
>>
>>
>> This generates a 3 page pdf file with a plot on each page. They look like 
>> this :
>>
>> http://s17.postimage.org/ud9ej1cnj/alpha1.png
>> http://s13.postimage.org/7q3snqsrr/alpha2.png
>> http://s14.postimage.org/sf374f12p/alpha3.png
>>
>> I want to plot all the 3 in one graph, in one page with the respective
>> colours - red, blue, and green. Any ideas on how?
>>
>> Thanks,
>>
>> - vihan
>>
>> __
>> 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-contained, reproducible code.

__
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-contained, reproducible code.


Re: [R] getting multiple plots on a single plot

2012-03-22 Thread David Winsemius


On Mar 22, 2012, at 3:18 PM, Vihan Pandey wrote:


Hi all,

I have the following R script :


#!/usr/bin/Rscript

out_file = "hybrid.pdf"
pdf(out_file, height=8.5, width=11)


At this point (assuming that you want three separate plots on the same  
page which is unclear but you do use different titles and ylabs, so I  
think this is implied) you would either be using layout()


?layout

 or par() with arguments mfrow, mfcol, or mfg.

?par


myvalues_1M <- read.csv("hybrid_sims_1M.csv",head=TRUE,sep=",")
plot(myvalues_1M$num_sims_per_thread,myvalues_1M 
$time_per_sim,xlab="Number

of Simulations per Thread",ylab="Time per 1 million Simulations(in
milliseconds)",col="red",main="For 1 million simulations")
lines(myvalues_1M$num_sims_per_thread,myvalues_1M 
$time_per_sim,col="red")


If on the other hand you want one plot frame with overlaid point/lines/ 
etc, then you should be determining your x and y limits before any  
plots and putting in the same limits for each plot Adding all your  
labels on the first plot and using:


par(new=TRUE) # which seems completely backward to me.

# I say again ...
? par




myvalues_5M <- read.csv("hybrid_sims_5M.csv",head=TRUE,sep=",")
plot(myvalues_5M$num_sims_per_thread,myvalues_5M 
$time_per_sim,xlab="Number

of Simulations per Thread",ylab="Time per 1 million Simulations(in
milliseconds)",col="blue",main="For 5 million simulations")
lines(myvalues_5M$num_sims_per_thread,myvalues_5M 
$time_per_sim,col="blue")


myvalues_10M <- read.csv("hybrid_sims_10M.csv",head=TRUE,sep=",")
plot(myvalues_10M$num_sims_per_thread,myvalues_10M 
$time_per_sim,xlab="Number

of Simulations per Thread",ylab="Time per 1 million Simulations(in
milliseconds)",col="green",main="For 10 million simulations")
lines(myvalues_10M$num_sims_per_thread,myvalues_10M 
$time_per_sim,col="green")


dev.off()

print(paste("Plot was saved in:", getwd()))



This generates a 3 page pdf file with a plot on each page. They look  
like this :


http://s17.postimage.org/ud9ej1cnj/alpha1.png
http://s13.postimage.org/7q3snqsrr/alpha2.png
http://s14.postimage.org/sf374f12p/alpha3.png

I want to plot all the 3 in one graph, in one page with the respective
colours - red, blue, and green. Any ideas on how?

Thanks,

- vihan

__
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-contained, reproducible code.


David Winsemius, MD
West Hartford, CT

__
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-contained, reproducible code.


Re: [R] getting multiple plots on a single plot

2012-03-22 Thread Chris Snook
vihan,

you jsut need to add the following statement in the subsequent plot
commands:

add = TRUE

so that your second and later plot commands look similar to:

plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab="Number
of Simulations per Thread",ylab="Time per 1 million Simulations(in
milliseconds)",col="blue",main="For 5 million simulations", add = TRUE)

HTH

Chris
On 03/22/2012 03:18 PM, Vihan Pandey wrote:
> Hi all,
>
> I have the following R script :
>
>
> #!/usr/bin/Rscript
>
> out_file = "hybrid.pdf"
> pdf(out_file, height=8.5, width=11)
>
> myvalues_1M <- read.csv("hybrid_sims_1M.csv",head=TRUE,sep=",")
> plot(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,xlab="Number
> of Simulations per Thread",ylab="Time per 1 million Simulations(in
> milliseconds)",col="red",main="For 1 million simulations")
> lines(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,col="red")
>
> myvalues_5M <- read.csv("hybrid_sims_5M.csv",head=TRUE,sep=",")
> plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab="Number
> of Simulations per Thread",ylab="Time per 1 million Simulations(in
> milliseconds)",col="blue",main="For 5 million simulations")
> lines(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,col="blue")
>
> myvalues_10M <- read.csv("hybrid_sims_10M.csv",head=TRUE,sep=",")
> plot(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,xlab="Number
> of Simulations per Thread",ylab="Time per 1 million Simulations(in
> milliseconds)",col="green",main="For 10 million simulations")
> lines(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,col="green")
>
> dev.off()
>
> print(paste("Plot was saved in:", getwd()))
>
>
>
> This generates a 3 page pdf file with a plot on each page. They look like 
> this :
>
> http://s17.postimage.org/ud9ej1cnj/alpha1.png
> http://s13.postimage.org/7q3snqsrr/alpha2.png
> http://s14.postimage.org/sf374f12p/alpha3.png
>
> I want to plot all the 3 in one graph, in one page with the respective
> colours - red, blue, and green. Any ideas on how?
>
> Thanks,
>
> - vihan
>
> __
> 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-contained, reproducible code.
>

__
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-contained, reproducible code.


[R] substituting XML tags with custom values

2012-03-22 Thread filip
Hello,

I have an xml document with a following element:

 


ACAGTTGACACCCTT


I would like to parse a new sequence of characters inside the "taxon"
tags. I started looking into XML package documentation, but cannot find
a simple solution yet. My code:

# load packages
require("XML")

# create a new sequence
newSeq <- "TGTCAATGGAACCTG"

# read the xml
xml <- xmlParse("epoch_mcmc.xml")

# save as character:
charXML <- saveXML(xml)

-- 
while(!suceed) { try(); }

__
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-contained, reproducible code.


Re: [R] getting multiple plots on a single plot

2012-03-22 Thread R. Michael Weylandt
Don't use plot three times -- it opens a new page when pdf() is your
current device. Do the first with plot -- then use lines() online from
there to the end.

Michael

On Thu, Mar 22, 2012 at 3:18 PM, Vihan Pandey  wrote:
> Hi all,
>
> I have the following R script :
>
>
> #!/usr/bin/Rscript
>
> out_file = "hybrid.pdf"
> pdf(out_file, height=8.5, width=11)
>
> myvalues_1M <- read.csv("hybrid_sims_1M.csv",head=TRUE,sep=",")
> plot(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,xlab="Number
> of Simulations per Thread",ylab="Time per 1 million Simulations(in
> milliseconds)",col="red",main="For 1 million simulations")
> lines(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,col="red")
>
> myvalues_5M <- read.csv("hybrid_sims_5M.csv",head=TRUE,sep=",")
> plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab="Number
> of Simulations per Thread",ylab="Time per 1 million Simulations(in
> milliseconds)",col="blue",main="For 5 million simulations")
> lines(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,col="blue")
>
> myvalues_10M <- read.csv("hybrid_sims_10M.csv",head=TRUE,sep=",")
> plot(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,xlab="Number
> of Simulations per Thread",ylab="Time per 1 million Simulations(in
> milliseconds)",col="green",main="For 10 million simulations")
> lines(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,col="green")
>
> dev.off()
>
> print(paste("Plot was saved in:", getwd()))
>
>
>
> This generates a 3 page pdf file with a plot on each page. They look like 
> this :
>
> http://s17.postimage.org/ud9ej1cnj/alpha1.png
> http://s13.postimage.org/7q3snqsrr/alpha2.png
> http://s14.postimage.org/sf374f12p/alpha3.png
>
> I want to plot all the 3 in one graph, in one page with the respective
> colours - red, blue, and green. Any ideas on how?
>
> Thanks,
>
> - vihan
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


[R] getting multiple plots on a single plot

2012-03-22 Thread Vihan Pandey
Hi all,

I have the following R script :


#!/usr/bin/Rscript

out_file = "hybrid.pdf"
pdf(out_file, height=8.5, width=11)

myvalues_1M <- read.csv("hybrid_sims_1M.csv",head=TRUE,sep=",")
plot(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,xlab="Number
of Simulations per Thread",ylab="Time per 1 million Simulations(in
milliseconds)",col="red",main="For 1 million simulations")
lines(myvalues_1M$num_sims_per_thread,myvalues_1M$time_per_sim,col="red")

myvalues_5M <- read.csv("hybrid_sims_5M.csv",head=TRUE,sep=",")
plot(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,xlab="Number
of Simulations per Thread",ylab="Time per 1 million Simulations(in
milliseconds)",col="blue",main="For 5 million simulations")
lines(myvalues_5M$num_sims_per_thread,myvalues_5M$time_per_sim,col="blue")

myvalues_10M <- read.csv("hybrid_sims_10M.csv",head=TRUE,sep=",")
plot(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,xlab="Number
of Simulations per Thread",ylab="Time per 1 million Simulations(in
milliseconds)",col="green",main="For 10 million simulations")
lines(myvalues_10M$num_sims_per_thread,myvalues_10M$time_per_sim,col="green")

dev.off()

print(paste("Plot was saved in:", getwd()))



This generates a 3 page pdf file with a plot on each page. They look like this :

http://s17.postimage.org/ud9ej1cnj/alpha1.png
http://s13.postimage.org/7q3snqsrr/alpha2.png
http://s14.postimage.org/sf374f12p/alpha3.png

I want to plot all the 3 in one graph, in one page with the respective
colours - red, blue, and green. Any ideas on how?

Thanks,

- vihan

__
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-contained, reproducible code.


Re: [R] gamlss results for EXP and LNO seem to have reversed AIC scores

2012-03-22 Thread rigbyr
Global Deviance = -2*fitted log likelihood,
AIC = Global deviance +2*number of parameters
Choocing distribution with the lowest AIC selects the exponential

--
View this message in context: 
http://r.789695.n4.nabble.com/gamlss-results-for-EXP-and-LNO-seem-to-have-reversed-AIC-scores-tp4409754p4496500.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] Plotting patient drug timelines using ggplot2 (or some other means) -- Help!!!

2012-03-22 Thread Paul Miller
Hi Bert,

Seems I've not provided enough detail. Sometimes it's hard to know how much to 
put in.

If you run all the code I sent, I think my data do make it into the "long" 
format. 

Let me begin by trying to explain my data as they appear prior to the melt() 
function. The data for patient 2 (profile_key = patient) and line 1 of 
treatment look like:

 profile_key line   drug
   pattern start_drug stop_drug
6   21 Drug A  Begin (A, B), End (A, B), Begin (C), End (C), Begin 
(D), End (D) 0. 7.429
7   21 Drug B  Begin (A, B), End (A, B), Begin (C), End (C), Begin 
(D), End (D) 0. 7.429
8   21 Drug C  Begin (A, B), End (A, B), Begin (C), End (C), Begin 
(D), End (D)14.571421.857
9   21 Drug D  Begin (A, B), End (A, B), Begin (C), End (C), Begin 
(D), End (D)25.4286   231.286

Here we have a cancer patient who took 4 drugs within a line of treatment. 
Their treatment involved the following sequence:

Start Drug A and Drug B
Stop Drug A and Drug B
Start Drug C
Stop Drug C
Start Drug D
Stop Drug D

This is reflected in their value for pattern:

Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)

The patient has separate rows for each drug (A-D) and also start_drug and 
stop_drug variables that indicate when the drugs started and stopped relative 
to one another. The start_drug and stop_drug variables are measurements in 
weeks. I don't actually want the time scale to appear on the x-axis though. I 
could go into why but think that might introduce too much detail rather than 
too little.

If you look at the code from "reshape()" on down, I think you'll see that the 
data do get transposed into long form. 

The ggplot code also produces the beginning of a very nice graph. I should say 
that so far I really like ggplot2. I think it makes very pretty graphs.

I just want to know how to alter the code to produce the changes I described 
earlier.

Do you know how to make those changes? Or can anyone else show me how to make 
them?

Thanks,

Paul 


--- On Thu, 3/22/12, Bert Gunter  wrote:

> From: Bert Gunter 
> Subject: Re: [R] Plotting patient drug timelines using ggplot2 (or some other 
> means) -- Help!!!
> To: "Paul Miller" 
> Cc: r-help@r-project.org
> Received: Thursday, March 22, 2012, 12:50 PM
> Your data are still uninterpretable
> to me.
> 
> A general approach to this sort of thing is to get your data
> in "long"
> format, like this
> 
> patientID   time   value
>   A
> 
> On Thu, Mar 22, 2012 at 10:41 AM, Paul Miller 
> wrote:
> > Hello All,
> >
> > Want very much to learn how to plot patient drug
> timelines. Trouble is I need to figure out how to do this
> today. So not much time for me to struggle with it. Hoping
> someone can just help me out a bit.
> >
> > Below are some sample data and code that produces what
> I think is the beginning of a very nice graph.
> >
> > Need to alter the code to:
> >
> > 1. Get the lines for the drugs to appear on the y-axis
> in the order that they appear in the data.
> >
> > 2. Decrease the vertical space between the line
> segments for each drug so they are fairly close to one
> another.
> >
> > 3. Remove the numbering from the x-axis.
> >
> > 4. Put the text for pattern above the graph (e.g.,
> "Begin (A), Begin (B), End (B), End (A)"), either centered
> or left aligned.
> >
> > 5. Put the patient and line information below the text
> for pattern (e.g., "profile_key = 1, line = 1")
> >
> > 6. Output a separate graph for each patient and line of
> treatent.
> >
> > Ultimately, I want to combine all the graphs into a
> single Word document. Or perhaps better yet, to create a pdf
> using LaTeX.
> >
> > I'm going to continue to try and fugure this out as
> best I can. Any help with it will be greatly appreciated
> though.
> >
> > Thanks,
> >
> > Paul
> >
> >
> > connection <- textConnection("
> > 1/1/Drug A/ Begin (A), Begin (B), End (B), End
> (A)/0./21.000
> > 1/1/Drug B/ Begin (A), Begin (B), End (B), End
> (A)/0.7143/18.000
> > 1/2/Drug A/ Begin (A, B, C), End (A, B), End
> (C)/0./20.000
> > 1/2/Drug B/ Begin (A, B, C), End (A, B), End
> (C)/0./20.000
> > 1/2/Drug C/ Begin (A, B, C), End (A, B), End
> (C)/0./36.000
> > 2/1/Drug A/ Begin (A, B), End (A, B), Begin (C), End
> (C), Begin (D), End (D)/0./7.429
> > 2/1/Drug B/ Begin (A, B), End (A, B), Begin (C), End
> (C), Begin (D), End (D)/ 0./7.429
> > 2/1/Drug C/ Begin (A, B), End (A, B), Begin (C), End
> (C), Begin (D), End (D)/ 14.5714/21.857
> > 2/1/Drug D/ Begin (A, B), End (A, B), Begin (C), End
> (C), Begin (D), End (D)/ 25.4286/231.286
> > 2/2/Drug A/ Begin (A, B), End (A, B)/0./35.286
> > 2/2/Drug B/ Begin (A, B), End (A, B)/0./35.286
> > ")
> >
> > TestData <- data.frame(scan(connection,
> list(profile_key=0, line=0, drug="", pattern="",
> start_drug=0, stop_drug=0), sep="/"))
> > TestData <- TestData[TestData$profile_key =

Re: [R] How to export hexbin tables?

2012-03-22 Thread David Winsemius


On Mar 22, 2012, at 12:31 PM, fco.pch wrote:


Hi all!
I'm trying to save an output of the HEXBIN process... is so much data
(105k), and I need to export to an ASCII file.


?dump


I tried to use:
write.table() > Error in as.data.frame.default(x[[i]], optional  
= TRUE)

:
 cannot coerce class 'structure("hexbin", package = "hexbin")' into a
data.frame

cat() ---> Error in cat(list(...), file, sep, fill, labels, append) :
 argument 1 (type 'S4') cannot be handled by 'cat'

write()

...but they didn't work  :/
Please, somebody can help me?

THANKS! Fco




David Winsemius, MD
West Hartford, CT

__
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-contained, reproducible code.


Re: [R] Create weird type of sequences

2012-03-22 Thread Alaios
Thanks a lot.. that is the way to it .




 From: Richard M. Heiberger 

Cc: R help  
Sent: Thursday, March 22, 2012 7:09 PM
Subject: Re: [R] Create weird type of sequences


rep(1:4, c(1,2,4,8))

rep has additional arguments that might be helpful to you.
?rep




Dear all,
>I would like to create the following sequence of numbers
>1 2 2 3 3 3 3 4 4 4 4 4 4 4 4 and so on (actually I double the number of same 
>elements)
>
>the reason is that I want then to feed the sequence above to 
>tapply(myVector, weirSeq, FUN = mean)
>
>and then average over those...
>
>Could you please provide some guidance how I can create such a sequence in R?
>
>Regards
>Alex
>
>       [[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-contained, reproducible code.
>
>
[[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-contained, reproducible code.


Re: [R] Plotting patient drug timelines using ggplot2 (or some other means) -- Help!!!

2012-03-22 Thread Bert Gunter
The message apparently sent itself  before I was ready . :-(

Here's the full version. I hope I have interpreted your intent
correctly. Ignore if I have not.


 A general approach to this sort of thing is to get your data in "long"
 format, like this

 patientID   time   value
  A  1  .029
  A  2 .053
.
.
.
  B   11.25
.
.
.

The ID's do not need to appear in order or together. The times need
not be in order.

Once the data are in this form, xyplot() in lattice can do it via:

xyplot( value ~ time , group = patientID, type = "c("l","p"), auto.key=TRUE )

?xyplot for additional info.


-- Bert









>
> On Thu, Mar 22, 2012 at 10:41 AM, Paul Miller  wrote:
>> Hello All,
>>
>> Want very much to learn how to plot patient drug timelines. Trouble is I 
>> need to figure out how to do this today. So not much time for me to struggle 
>> with it. Hoping someone can just help me out a bit.
>>
>> Below are some sample data and code that produces what I think is the 
>> beginning of a very nice graph.
>>
>> Need to alter the code to:
>>
>> 1. Get the lines for the drugs to appear on the y-axis in the order that 
>> they appear in the data.
>>
>> 2. Decrease the vertical space between the line segments for each drug so 
>> they are fairly close to one another.
>>
>> 3. Remove the numbering from the x-axis.
>>
>> 4. Put the text for pattern above the graph (e.g., "Begin (A), Begin (B), 
>> End (B), End (A)"), either centered or left aligned.
>>
>> 5. Put the patient and line information below the text for pattern (e.g., 
>> "profile_key = 1, line = 1")
>>
>> 6. Output a separate graph for each patient and line of treatent.
>>
>> Ultimately, I want to combine all the graphs into a single Word document. Or 
>> perhaps better yet, to create a pdf using LaTeX.
>>
>> I'm going to continue to try and fugure this out as best I can. Any help 
>> with it will be greatly appreciated though.
>>
>> Thanks,
>>
>> Paul
>>
>>
>> connection <- textConnection("
>> 1/1/Drug A/ Begin (A), Begin (B), End (B), End (A)/0./21.000
>> 1/1/Drug B/ Begin (A), Begin (B), End (B), End (A)/0.7143/18.000
>> 1/2/Drug A/ Begin (A, B, C), End (A, B), End (C)/0./20.000
>> 1/2/Drug B/ Begin (A, B, C), End (A, B), End (C)/0./20.000
>> 1/2/Drug C/ Begin (A, B, C), End (A, B), End (C)/0./36.000
>> 2/1/Drug A/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End 
>> (D)/0./7.429
>> 2/1/Drug B/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End 
>> (D)/ 0./7.429
>> 2/1/Drug C/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End 
>> (D)/ 14.5714/21.857
>> 2/1/Drug D/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End 
>> (D)/ 25.4286/231.286
>> 2/2/Drug A/ Begin (A, B), End (A, B)/0./35.286
>> 2/2/Drug B/ Begin (A, B), End (A, B)/0./35.286
>> ")
>>
>> TestData <- data.frame(scan(connection, list(profile_key=0, line=0, drug="", 
>> pattern="", start_drug=0, stop_drug=0), sep="/"))
>> TestData <- TestData[TestData$profile_key == 2 & TestData$line == 1,]
>> TestData
>>
>> require(reshape)
>> TestData <- melt(TestData, measure.vars = c("start_drug", "stop_drug"))
>> TestData
>>
>> ggplot(TestData, aes(value, drug)) + geom_line(size = 6) + xlab("") + 
>> ylab("") + theme_bw()
>> ggsave(file = "plot21.pdf")
>>
>> __
>> 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-contained, reproducible code.
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> Internal Contact Info:
> Phone: 467-7374
> Website:
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
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-contained, reproducible code.


Re: [R] Plotting patient drug timelines using ggplot2 (or some other means) -- Help!!!

2012-03-22 Thread R. Michael Weylandt
Inline:

On Thu, Mar 22, 2012 at 1:41 PM, Paul Miller  wrote:
> Hello All,
>
> Want very much to learn how to plot patient drug timelines. Trouble is I need 
> to figure out how to do this today. So not much time for me to struggle with 
> it. Hoping someone can just help me out a bit.
>
> Below are some sample data and code that produces what I think is the 
> beginning of a very nice graph.
>
> Need to alter the code to:
>
> 1. Get the lines for the drugs to appear on the y-axis in the order that they 
> appear in the data.

Scale_x_flip()

>
> 2. Decrease the vertical space between the line segments for each drug so 
> they are fairly close to one another.

Why? This will happen automatically if needed

>
> 3. Remove the numbering from the x-axis.

opts(axis.ticks.x = theme_blank())

>
> 4. Put the text for pattern above the graph (e.g., "Begin (A), Begin (B), End 
> (B), End (A)"), either centered or left aligned.


opts(title = "Begin (A), Begin (B), End (B), End (A)")

>
> 5. Put the patient and line information below the text for pattern (e.g., 
> "profile_key = 1, line = 1")

example(geom_text)
or
https://learnr.wordpress.com/2010/01/03/directlabels-adding-direct-labels-to-ggplot2-and-lattice-plots/

>
> 6. Output a separate graph for each patient and line of treatent.
>
> Ultimately, I want to combine all the graphs into a single Word document. Or 
> perhaps better yet, to create a pdf using LaTeX.

Google Sweave or (possibly easier) knitr

>
> I'm going to continue to try and fugure this out as best I can. Any help with 
> it will be greatly appreciated though.
>
> Thanks,
>
> Paul
>
>
> connection <- textConnection("
> 1/1/Drug A/ Begin (A), Begin (B), End (B), End (A)/0./21.000
> 1/1/Drug B/ Begin (A), Begin (B), End (B), End (A)/0.7143/18.000
> 1/2/Drug A/ Begin (A, B, C), End (A, B), End (C)/0./20.000
> 1/2/Drug B/ Begin (A, B, C), End (A, B), End (C)/0./20.000
> 1/2/Drug C/ Begin (A, B, C), End (A, B), End (C)/0./36.000
> 2/1/Drug A/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End 
> (D)/0./7.429
> 2/1/Drug B/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
> 0./7.429
> 2/1/Drug C/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
> 14.5714/21.857
> 2/1/Drug D/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
> 25.4286/231.286
> 2/2/Drug A/ Begin (A, B), End (A, B)/0./35.286
> 2/2/Drug B/ Begin (A, B), End (A, B)/0./35.286
> ")
>
> TestData <- data.frame(scan(connection, list(profile_key=0, line=0, drug="", 
> pattern="", start_drug=0, stop_drug=0), sep="/"))
> TestData <- TestData[TestData$profile_key == 2 & TestData$line == 1,]
> TestData
>
> require(reshape)
> TestData <- melt(TestData, measure.vars = c("start_drug", "stop_drug"))
> TestData
>
> ggplot(TestData, aes(value, drug)) + geom_line(size = 6) + xlab("") + 
> ylab("") + theme_bw()

It would be easier if you could use dput() but this was helpfully reproducible.

Hope this gets you started,

Michael

> ggsave(file = "plot21.pdf")
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


Re: [R] Plotting patient drug timelines using ggplot2 (or some other means) -- Help!!!

2012-03-22 Thread Bert Gunter
Your data are still uninterpretable to me.

A general approach to this sort of thing is to get your data in "long"
format, like this

patientID   time   value
  A

On Thu, Mar 22, 2012 at 10:41 AM, Paul Miller  wrote:
> Hello All,
>
> Want very much to learn how to plot patient drug timelines. Trouble is I need 
> to figure out how to do this today. So not much time for me to struggle with 
> it. Hoping someone can just help me out a bit.
>
> Below are some sample data and code that produces what I think is the 
> beginning of a very nice graph.
>
> Need to alter the code to:
>
> 1. Get the lines for the drugs to appear on the y-axis in the order that they 
> appear in the data.
>
> 2. Decrease the vertical space between the line segments for each drug so 
> they are fairly close to one another.
>
> 3. Remove the numbering from the x-axis.
>
> 4. Put the text for pattern above the graph (e.g., "Begin (A), Begin (B), End 
> (B), End (A)"), either centered or left aligned.
>
> 5. Put the patient and line information below the text for pattern (e.g., 
> "profile_key = 1, line = 1")
>
> 6. Output a separate graph for each patient and line of treatent.
>
> Ultimately, I want to combine all the graphs into a single Word document. Or 
> perhaps better yet, to create a pdf using LaTeX.
>
> I'm going to continue to try and fugure this out as best I can. Any help with 
> it will be greatly appreciated though.
>
> Thanks,
>
> Paul
>
>
> connection <- textConnection("
> 1/1/Drug A/ Begin (A), Begin (B), End (B), End (A)/0./21.000
> 1/1/Drug B/ Begin (A), Begin (B), End (B), End (A)/0.7143/18.000
> 1/2/Drug A/ Begin (A, B, C), End (A, B), End (C)/0./20.000
> 1/2/Drug B/ Begin (A, B, C), End (A, B), End (C)/0./20.000
> 1/2/Drug C/ Begin (A, B, C), End (A, B), End (C)/0./36.000
> 2/1/Drug A/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End 
> (D)/0./7.429
> 2/1/Drug B/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
> 0./7.429
> 2/1/Drug C/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
> 14.5714/21.857
> 2/1/Drug D/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
> 25.4286/231.286
> 2/2/Drug A/ Begin (A, B), End (A, B)/0./35.286
> 2/2/Drug B/ Begin (A, B), End (A, B)/0./35.286
> ")
>
> TestData <- data.frame(scan(connection, list(profile_key=0, line=0, drug="", 
> pattern="", start_drug=0, stop_drug=0), sep="/"))
> TestData <- TestData[TestData$profile_key == 2 & TestData$line == 1,]
> TestData
>
> require(reshape)
> TestData <- melt(TestData, measure.vars = c("start_drug", "stop_drug"))
> TestData
>
> ggplot(TestData, aes(value, drug)) + geom_line(size = 6) + xlab("") + 
> ylab("") + theme_bw()
> ggsave(file = "plot21.pdf")
>
> __
> 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-contained, reproducible code.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
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-contained, reproducible code.


Re: [R] writing data to file

2012-03-22 Thread Peter Ehlers

On 2012-03-22 08:35, mail me wrote:

Hi:

I created a data frame

df<- data.frame( person = c('John','Bob','Mary'), team =
c('a','b','c'), stringsAsFactors = F);

and obtained the expected  output

  df
   person   team
1   John  a
2Bob  b
3   Mary  c

now I want to save the whole content of df preserving its row and
column order to a file in disk with the following command:

write(df, file = "testfile",  append=FALSE, sep=" ");

and I get the error message

Error in cat(list(...), file, sep, fill, labels, append) :   argument
1 (type 'list') cannot be handled by 'cat'

Can you help to solve the problem? Thanks in advance.

deb


You're using the wrong function; use write.table() instead.
You may want to set either or both of the arguments 'quote'
and 'row.names' to FALSE.

Peter Ehlers

__
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-contained, reproducible code.


Re: [R] trouble for parsing HTML files

2012-03-22 Thread Milan Bouchet-Valat
Le jeudi 22 mars 2012 à 17:20 +0100, Julien Velcin a écrit :
> Hi all,
> 
> Using the XML package, I'm not able to parse some html webpages. Here  
> is my code and the error message:
> 
> library("XML")
> url <- "http://www.huffingtonpost.com/social/GraniteSkyline?action=fans";
> doc <- htmlParse(url)
> 
> Error: Namespace prefix ꛀ of attribute (null) is not defined
> 
> I've searched a lot on the Internet, but it's really difficult to find  
> something useful for R.
What versions of R and XML are you using? The code you provided works
fine here (R 2.14.1 x86_64 and XML 3.9-4 on Fedora 16). sessionInfo()
will help us.

BTW, see ?RSiteSearch to search for R content on the Web.


Cheers

__
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-contained, reproducible code.


[R] Plotting patient drug timelines using ggplot2 (or some other means) -- Help!!!

2012-03-22 Thread Paul Miller
Hello All,

Want very much to learn how to plot patient drug timelines. Trouble is I need 
to figure out how to do this today. So not much time for me to struggle with 
it. Hoping someone can just help me out a bit.

Below are some sample data and code that produces what I think is the beginning 
of a very nice graph. 

Need to alter the code to:

1. Get the lines for the drugs to appear on the y-axis in the order that they 
appear in the data.

2. Decrease the vertical space between the line segments for each drug so they 
are fairly close to one another.

3. Remove the numbering from the x-axis.

4. Put the text for pattern above the graph (e.g., "Begin (A), Begin (B), End 
(B), End (A)"), either centered or left aligned.

5. Put the patient and line information below the text for pattern (e.g., 
"profile_key = 1, line = 1")

6. Output a separate graph for each patient and line of treatent.

Ultimately, I want to combine all the graphs into a single Word document. Or 
perhaps better yet, to create a pdf using LaTeX.

I'm going to continue to try and fugure this out as best I can. Any help with 
it will be greatly appreciated though.

Thanks,

Paul


connection <- textConnection("
1/1/Drug A/ Begin (A), Begin (B), End (B), End (A)/0./21.000
1/1/Drug B/ Begin (A), Begin (B), End (B), End (A)/0.7143/18.000
1/2/Drug A/ Begin (A, B, C), End (A, B), End (C)/0./20.000
1/2/Drug B/ Begin (A, B, C), End (A, B), End (C)/0./20.000
1/2/Drug C/ Begin (A, B, C), End (A, B), End (C)/0./36.000
2/1/Drug A/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End 
(D)/0./7.429
2/1/Drug B/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
0./7.429
2/1/Drug C/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
14.5714/21.857
2/1/Drug D/ Begin (A, B), End (A, B), Begin (C), End (C), Begin (D), End (D)/ 
25.4286/231.286
2/2/Drug A/ Begin (A, B), End (A, B)/0./35.286
2/2/Drug B/ Begin (A, B), End (A, B)/0./35.286
")

TestData <- data.frame(scan(connection, list(profile_key=0, line=0, drug="", 
pattern="", start_drug=0, stop_drug=0), sep="/"))
TestData <- TestData[TestData$profile_key == 2 & TestData$line == 1,]
TestData

require(reshape)
TestData <- melt(TestData, measure.vars = c("start_drug", "stop_drug"))
TestData

ggplot(TestData, aes(value, drug)) + geom_line(size = 6) + xlab("") + ylab("") 
+ theme_bw() 
ggsave(file = "plot21.pdf")

__
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-contained, reproducible code.


Re: [R] How to get the input of a function right?

2012-03-22 Thread David Winsemius


On Mar 22, 2012, at 12:14 PM, Sarah Goslee wrote:


On Thu, Mar 22, 2012 at 11:55 AM, R. Michael Weylandt
 wrote:
This is quite difficult without being able to see the function  
f .


Michael


I thought we had a fortune about telepathy, but I can't find it in the
fortunes package.


Using the partial matching features of the fortune() function and the  
search strategy " mind" for "mind-reading" and "mind reading" and to  
avoid "remind", I find these candidates:


> fortune(" mind")

There are actual error messages, and until you show them, we can not  
help as the mind reading machine is currently off for repairs.

   -- Dirk Eddelbuettel (after reports about errors with R CMD check)
  R-help (July 2010)
#-
You are going to need a few more sessions for this therapy to be  
useful, we cannot read your computer's mind, just interpret what you  
tell us. I don't want to jump ahead, but can you tell us the childhood  
of your crashes, etc.
   -- Romain Francois (in a 'psychotherapy' session trying to  
understand the sources of a useR's problems)

  R-help (November 2009)





Sarah
--
Sarah Goslee
http://www.functionaldiversity.org

__
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-contained, reproducible code.


David Winsemius, MD
West Hartford, CT

__
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-contained, reproducible code.


Re: [R] Automaticall adjust axis scales

2012-03-22 Thread R. Michael Weylandt
Simply calculate it before it's not hard:

ylim = range(sapply(datalist, function(x) range(x$dataset$Utilization)))

should work, but it's untested.  Then pass that to plot().

If your data set is large enough that you want to do a single loop,
simply create a list of the density objects and get the bounds
appropriately after that.

Michael

On Thu, Mar 22, 2012 at 1:10 PM, Alaios  wrote:
> Hmm.. this how my code looks like inside my function
>
> plot(density(100*datalist[[1]]$dataset$Utilization), xlab="Overall 
> utilization [ % ]", main="", ...)
>     colorList=colors()[seq(10,100,10)]
>     colorList[1]="black"
>     if (length(datalist) > 1) {
>         for (i in 2:length(datalist)) {
>             lines(density(100*datalist[[i]]$dataset$Utilization), lty=i, col= 
> colorList[i])
>         }
>     }
>
> given on input a datalist the code above just by reading element by element 
> of the list adds the corresponding line(..)
>
> I fail to see how I can calculate the min and max and then call the first 
> plot with the right lim.
>
> Could you please help me?
> Regards
> Alex
>
>
>
> 
>  From: Jim Lemon 
>
> Cc: R help 
> Sent: Thursday, March 22, 2012 8:13 AM
> Subject: Re: [R] Automaticall adjust axis scales
>
> On 03/22/2012 05:42 AM, Alaios wrote:
>> Would it be possible to change the axis at the end?
>> My data sets seem to be quite large so I was thinking for the plot and
>> the consequent lines to keep always
>> the current minimum and maximum like
>> plot(x)
>> minimum=min(x)
>> lines(x1)
>> minimum=c(minimum,x1)
>> lines(x2)
>> minimum=c(minimum,x2)
>> then if there is a good way for altering axis lines I could put the
>> limits I want to.
>
> Hi Alex,
> One way or another you are going to have to set the limits in your first call 
> to "plot". You could do the plot first and collect the limits along the way, 
> then do it again, but I can't see that this has any advantage over 
> calculating the limits for the entire set of data that is to be plotted at 
> the beginning and then doing the plots. If you want to get the limits for 
> each data set separately, maybe:
>
> range1<-range(x1)
> range2<-range(x2)
> range3<-range(x3)
> ylim<-range(c(range1,range2,range3))
>
> However, I suspect that this is of more use in helping you understand what is 
> happening than actually getting it done.
>
> Jim
>        [[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-contained, reproducible code.
>

__
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-contained, reproducible code.


Re: [R] Automaticall adjust axis scales

2012-03-22 Thread Alaios
Hmm.. this how my code looks like inside my function

plot(density(100*datalist[[1]]$dataset$Utilization), xlab="Overall utilization 
[ % ]", main="", ...)
    colorList=colors()[seq(10,100,10)]
    colorList[1]="black"
    if (length(datalist) > 1) {
        for (i in 2:length(datalist)) {
            lines(density(100*datalist[[i]]$dataset$Utilization), lty=i, col= 
colorList[i])
        }
    }

given on input a datalist the code above just by reading element by element of 
the list adds the corresponding line(..)

I fail to see how I can calculate the min and max and then call the first plot 
with the right lim.

Could you please help me?
Regards
Alex




 From: Jim Lemon 

Cc: R help  
Sent: Thursday, March 22, 2012 8:13 AM
Subject: Re: [R] Automaticall adjust axis scales

On 03/22/2012 05:42 AM, Alaios wrote:
> Would it be possible to change the axis at the end?
> My data sets seem to be quite large so I was thinking for the plot and
> the consequent lines to keep always
> the current minimum and maximum like
> plot(x)
> minimum=min(x)
> lines(x1)
> minimum=c(minimum,x1)
> lines(x2)
> minimum=c(minimum,x2)
> then if there is a good way for altering axis lines I could put the
> limits I want to.

Hi Alex,
One way or another you are going to have to set the limits in your first call 
to "plot". You could do the plot first and collect the limits along the way, 
then do it again, but I can't see that this has any advantage over calculating 
the limits for the entire set of data that is to be plotted at the beginning 
and then doing the plots. If you want to get the limits for each data set 
separately, maybe:

range1<-range(x1)
range2<-range(x2)
range3<-range(x3)
ylim<-range(c(range1,range2,range3))

However, I suspect that this is of more use in helping you understand what is 
happening than actually getting it done.

Jim
[[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-contained, reproducible code.


Re: [R] Create weird type of sequences

2012-03-22 Thread Uwe Ligges



On 22.03.2012 18:03, Alaios wrote:

Dear all,
I would like to create the following sequence of numbers
1 2 2 3 3 3 3 4 4 4 4 4 4 4 4 and so on (actually I double the number of same 
elements)

the reason is that I want then to feed the sequence above to
tapply(myVector, weirSeq, FUN = mean)

and then average over those...

Could you please provide some guidance how I can create such a sequence in R?



We do not answer homework questions.

Uwe Ligges



Regards
Alex

[[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-contained, reproducible code.


__
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-contained, reproducible code.


Re: [R] Create weird type of sequences

2012-03-22 Thread Richard M. Heiberger
rep(1:4, c(1,2,4,8))


rep has additional arguments that might be helpful to you.

?rep

On Thu, Mar 22, 2012 at 1:03 PM, Alaios  wrote:

> Dear all,
> I would like to create the following sequence of numbers
> 1 2 2 3 3 3 3 4 4 4 4 4 4 4 4 and so on (actually I double the number of
> same elements)
>
> the reason is that I want then to feed the sequence above to
> tapply(myVector, weirSeq, FUN = mean)
>
> and then average over those...
>
> Could you please provide some guidance how I can create such a sequence in
> R?
>
> Regards
> Alex
>
>[[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-contained, reproducible code.
>
>

[[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-contained, reproducible code.


Re: [R] Replace sub string

2012-03-22 Thread Ajay Askoolum
Thanks.

1. For consistency: I am using / everywhere else in my script.

2. For ease of use: I am passing the string to a client application (using 
rcom) where it is easeir to handle / than \\.





See ?gsub
But why would you do that? Both / and \\ are valid in a path, aren't they?

Ivan
[[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-contained, reproducible code.


[R] Create weird type of sequences

2012-03-22 Thread Alaios
Dear all,
I would like to create the following sequence of numbers
1 2 2 3 3 3 3 4 4 4 4 4 4 4 4 and so on (actually I double the number of same 
elements)

the reason is that I want then to feed the sequence above to 
tapply(myVector, weirSeq, FUN = mean) 

and then average over those...

Could you please provide some guidance how I can create such a sequence in R?

Regards
Alex

[[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-contained, reproducible code.


Re: [R] how to avoid grid overlapping in a boxplot

2012-03-22 Thread R. Michael Weylandt
It's a bit of a hack, but you could just redraw the boxplot on top of
the grid lines:

x <- rnorm(50)
boxplot(x)
grid()
boxplot(x, add = TRUE)

Michael


On Thu, Mar 22, 2012 at 12:08 PM, maxbre  wrote:
> Given the following chart: i.e. a boxplot with a grid
>
> boxplot(x~y)
> grid(nx=NA,ny=NULL)
>
> my question: how to avoid the overlapping of boxes (and whiskers) by grid
> lines?
>
> thank you for any help pointing me in the right direction
>
> max
>
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/how-to-avoid-grid-overlapping-in-a-boxplot-tp4495955p4495955.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


Re: [R] how to avoid grid overlapping in a boxplot

2012-03-22 Thread Sarah Goslee
On Thu, Mar 22, 2012 at 12:08 PM, maxbre  wrote:
> Given the following chart: i.e. a boxplot with a grid
>
> boxplot(x~y)
> grid(nx=NA,ny=NULL)
>
> my question: how to avoid the overlapping of boxes (and whiskers) by grid
> lines?

Don't draw a grid?

Put the lines somewhere else?

> thank you for any help pointing me in the right direction

Or you could provide the requested reproducible example, and someone
might be able to offer better suggestions.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.org

__
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-contained, reproducible code.


Re: [R] How to export hexbin tables?

2012-03-22 Thread R. Michael Weylandt
What do you need to use it again for? If you just want to get it back
for a different R session (which I think is the only thing that makes
sense) you might only need to save() the object and then you can
load() it later. [Or perhaps better, saveRDS() and readRDS()]

Michael

On Thu, Mar 22, 2012 at 12:31 PM, fco.pch  wrote:
> Hi all!
> I'm trying to save an output of the HEXBIN process... is so much data
> (105k), and I need to export to an ASCII file.
> I tried to use:
>  write.table() > Error in as.data.frame.default(x[[i]], optional = TRUE)
> :
>  cannot coerce class 'structure("hexbin", package = "hexbin")' into a
> data.frame
>
>  cat() ---> Error in cat(list(...), file, sep, fill, labels, append) :
>  argument 1 (type 'S4') cannot be handled by 'cat'
>
>  write()
>
> ...but they didn't work  :/
> Please, somebody can help me?
>
> THANKS! Fco
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/How-to-export-hexbin-tables-tp4496035p4496035.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


[R] how to avoid grid overlapping in a boxplot

2012-03-22 Thread maxbre
Given the following chart: i.e. a boxplot with a grid

boxplot(x~y)
grid(nx=NA,ny=NULL)

my question: how to avoid the overlapping of boxes (and whiskers) by grid
lines?

thank you for any help pointing me in the right direction

max




--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-avoid-grid-overlapping-in-a-boxplot-tp4495955p4495955.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


[R] How to export hexbin tables?

2012-03-22 Thread fco.pch
Hi all! 
I'm trying to save an output of the HEXBIN process... is so much data
(105k), and I need to export to an ASCII file. 
I tried to use: 
 write.table() > Error in as.data.frame.default(x[[i]], optional = TRUE)
: 
  cannot coerce class 'structure("hexbin", package = "hexbin")' into a
data.frame 

 cat() ---> Error in cat(list(...), file, sep, fill, labels, append) : 
  argument 1 (type 'S4') cannot be handled by 'cat' 

 write() 
  
...but they didn't work  :/ 
Please, somebody can help me? 

THANKS! Fco

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-export-hexbin-tables-tp4496035p4496035.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] how to adjust gui window size

2012-03-22 Thread j verzani
mrzung  gmail.com> writes:

> 
> hi, i'm trying to make gui function by "aDialog" FUN.
> What i want to do is adjusting the window size.
> 
> my function is ,
> 
> aa<- aDialog(items=list(
> ps=numericItem(),
> number=numericItem(),
> term=numericItem()
> ),
> OK_handler=function(.) { # . is reference to dlg object
> values <- .$to_R()
> do.call("KOD",values)
> }
> )
> 
> how can i adjust the size of the window?


You are much better off pointing out this uses the traitr package, 
as otherwise one wouldn't know where to begin. In this case, 
there isn't a straightforward way, but this hack will let you do it:

 size(aa$widget_list$toplevel) <- c(600, 600)

I haven't worked on that package for awhile, as it didn't get many users.

__
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-contained, reproducible code.


Re: [R] writing data to file

2012-03-22 Thread Gaurav Sood
look up dump

On Thu, Mar 22, 2012 at 11:35 AM, mail me  wrote:
> Hi:
>
> I created a data frame
>
> df <- data.frame( person = c('John','Bob','Mary'), team =
> c('a','b','c'), stringsAsFactors = F);
>
> and obtained the expected  output
>
>  df
>  person   team
> 1   John      a
> 2    Bob      b
> 3   Mary      c
>
> now I want to save the whole content of df preserving its row and
> column order to a file in disk with the following command:
>
> write(df, file = "testfile",  append=FALSE, sep=" ");
>
> and I get the error message
>
> Error in cat(list(...), file, sep, fill, labels, append) :   argument
> 1 (type 'list') cannot be handled by 'cat'
>
> Can you help to solve the problem? Thanks in advance.
>
> deb
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


[R] trouble for parsing HTML files

2012-03-22 Thread Julien Velcin

Hi all,

Using the XML package, I'm not able to parse some html webpages. Here  
is my code and the error message:


library("XML")
url <- "http://www.huffingtonpost.com/social/GraniteSkyline?action=fans";
doc <- htmlParse(url)

Error: Namespace prefix ꛀ of attribute (null) is not defined

I've searched a lot on the Internet, but it's really difficult to find  
something useful for R.


Thanks for your help!

Julien
__
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-contained, reproducible code.


Re: [R] How to get the input of a function right?

2012-03-22 Thread Sarah Goslee
On Thu, Mar 22, 2012 at 11:55 AM, R. Michael Weylandt
 wrote:
> This is quite difficult without being able to see the function f .
>
> Michael

I thought we had a fortune about telepathy, but I can't find it in the
fortunes package.

Sarah
-- 
Sarah Goslee
http://www.functionaldiversity.org

__
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-contained, reproducible code.


Re: [R] Suggestions for RAM for new box

2012-03-22 Thread Marc Schwartz
On Mar 22, 2012, at 10:26 AM, Neotropical bat risk assessments wrote:

> Hi all,
> 
> My main Dell melted down a month ago and I need to buy a new workstation.
> It will be Win7 64 bit and fast graphics card with large RAM.
> 
> For GIS (ArcGis) I am opting for 6 GB RAM.
> Is there any advantage for R to boost this to 8 GB or will 6 GB be sufficient 
> for R applications?
> There have been a lot of discussion about "Big Memory" issues with R.


I might note that these days, 6Gb is not "large RAM". I have 8Gb in my now 3 
year old dual core MacBook Pro laptop running OSX Lion (64 bit).

The keys to consider are that even with a 64 bit build of R, you are still 
going to be limited to creating/accessing objects where the indexing of those 
objects will be limited to a 32 bit signed integer (2^31 - 1). So things like 
vectors/matrices/arrays will be limited to that size in terms of number of 
elements.

In addition, based upon comments in the R Admin Manual 
(http://cran.r-project.org/doc/manuals/R-admin.html#Choosing-between-32_002d-and-64_002dbit-builds),
 64 bit builds of R will have a memory block allocation limit of about 8Gb. In 
other words, a single R object can be no larger than about 8Gb.

Within those limits of course, if you run out of physical RAM, you end up 
swapping to disk, which slows things down notably. So with 6Gb of RAM, after 
the OS and other applications consume some portion of that, you have what is 
left over for R, which may or may not be enough for your specific needs.

The "Big Memory" issues (see 
http://cran.r-project.org/web/views/HighPerformanceComputing.html) typically 
address situations where the above constraints come into play.

RAM is sufficiently cheap these days, that going to 8Gb or even 16gb should not 
be prohibitively expensive and if you need to deal with "large" objects in R, 
that is something to consider.

Hard to provide specific guidance without having a sense of the size of the 
datasets that you will be working with, along with the nature of the operations 
on those datasets, which might require the copying of those datasets in RAM 
during analyses. That being said, get as much RAM as your budget will allow for.

Regards,

Marc Schwartz

__
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-contained, reproducible code.


Re: [R] How to get the input of a function right?

2012-03-22 Thread R. Michael Weylandt
This is quite difficult without being able to see the function f .

Michael

On Thu, Mar 22, 2012 at 11:43 AM, stella  wrote:
> Hi,
>
> I wrote a function with three inputs fun(x,y,z).
>
> x is a matrix of three vectors combined with cbind. e.g.
>
> x1<-(1,2,3,4)
> x2<-(2,3,4,5)
> x3<-(3,4,5,6)
>
> x<-cbind(x1,x2,x3)
>
> y is a vector e.g
> y<-c(7,8,9)
>
> z is a real number e.g.
> z<-2.5
>
> If a give the function an input like this, I get 'NA' in return. If I give
> the function a vector e.g c(1,2,3) instead of 'x' the function works just
> fine.
> Does anyone has an idea why the function would not except 'x' as an input?
>
> Thank you very much!
> Stella
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/How-to-get-the-input-of-a-function-right-tp4495879p4495879.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


[R] how to adjust gui window size

2012-03-22 Thread mrzung
hi, i'm trying to make gui function by "aDialog" FUN.
What i want to do is adjusting the window size.

my function is ,

aa<- aDialog(items=list(
ps=numericItem(),
number=numericItem(),
term=numericItem()
),
OK_handler=function(.) { # . is reference to dlg object
values <- .$to_R()
do.call("KOD",values)
}
)

how can i adjust the size of the window?

Thanks~

--
View this message in context: 
http://r.789695.n4.nabble.com/how-to-adjust-gui-window-size-tp4495883p4495883.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] How to get the input of a function right?

2012-03-22 Thread Petr Savicky
On Thu, Mar 22, 2012 at 08:43:00AM -0700, stella wrote:
> Hi,
> 
> I wrote a function with three inputs fun(x,y,z).
> 
> x is a matrix of three vectors combined with cbind. e.g.
> 
> x1<-(1,2,3,4)
> x2<-(2,3,4,5)
> x3<-(3,4,5,6)
> 
> x<-cbind(x1,x2,x3)
> 
> y is a vector e.g 
> y<-c(7,8,9)
> 
> z is a real number e.g.
> z<-2.5
> 
> If a give the function an input like this, I get 'NA' in return. If I give
> the function a vector e.g c(1,2,3) instead of 'x' the function works just
> fine. 
> Does anyone has an idea why the function would not except 'x' as an input?

Hi.

Can you send also the function? Without it, it is hard
to guess the source of the error.

Petr Savicky.

__
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-contained, reproducible code.


Re: [R] Recommendations regarding textbooks

2012-03-22 Thread Liviu Andronic
On Thu, Mar 22, 2012 at 1:17 PM, richard willey
 wrote:
> I was hoping to get some advice regarding teaching R in an academic 
> environment.
>

> thinks regarding “An R Companion to Applied Regression”.
>
CAR features an excellent introduction to R programming.

Liviu

__
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-contained, reproducible code.


[R] How to get the input of a function right?

2012-03-22 Thread stella
Hi,

I wrote a function with three inputs fun(x,y,z).

x is a matrix of three vectors combined with cbind. e.g.

x1<-(1,2,3,4)
x2<-(2,3,4,5)
x3<-(3,4,5,6)

x<-cbind(x1,x2,x3)

y is a vector e.g 
y<-c(7,8,9)

z is a real number e.g.
z<-2.5

If a give the function an input like this, I get 'NA' in return. If I give
the function a vector e.g c(1,2,3) instead of 'x' the function works just
fine. 
Does anyone has an idea why the function would not except 'x' as an input?

Thank you very much!
Stella

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-get-the-input-of-a-function-right-tp4495879p4495879.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


[R] writing data to file

2012-03-22 Thread mail me
Hi:

I created a data frame

df <- data.frame( person = c('John','Bob','Mary'), team =
c('a','b','c'), stringsAsFactors = F);

and obtained the expected  output

 df
  person   team
1   John  a
2Bob  b
3   Mary  c

now I want to save the whole content of df preserving its row and
column order to a file in disk with the following command:

write(df, file = "testfile",  append=FALSE, sep=" ");

and I get the error message

Error in cat(list(...), file, sep, fill, labels, append) :   argument
1 (type 'list') cannot be handled by 'cat'

Can you help to solve the problem? Thanks in advance.

deb

__
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-contained, reproducible code.


Re: [R] Error : package is not installed for 'arch=x64'

2012-03-22 Thread Uwe Ligges



On 22.03.2012 16:46, Li, Yan wrote:

Hi Uwe,

Thanks very much for your reply!

It is in Windows OS and I read the manual, installed the latest version of 
RTools. I also have MinGW64 compiler installed. I still kept getting this 
errors.



Then, please make your package available and tell us what you did, hoiw 
your PATH looks like, and what is in the directories your PATH points to.


You can also try the winbuilder service.

Best,
Uwe Ligges



Regards,
Yan

-Original Message-
From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de]
Sent: Sunday, March 18, 2012 1:29 PM
To: Li, Yan
Cc: r-help@r-project.org
Subject: Re: [R] Error : package is not installed for 'arch=x64'



On 13.03.2012 18:18, Li, Yan wrote:

HI All,

I got the error : package  is not installed for 'arch=x64' when building my own 
package for 64bit R. How can I configure the arch ? The 'R CMD config' does not 
work. Thank you very much!


Which OS?

If Linux: run R with the desired architecture and install.package().

If Windows: See the R Installation and Administration manual that explains the 
steps to set the environment up correctly. And if you start with it, use R>= 
2.14.2 so that you install the new toolchain to be compatible for future releases.

Uwe Ligges






The detailed error is :

** testing if installed package can be loaded Error : package 'xxx' is
not installed for 'arch=x64'
Error: loading failed
Execution halted
ERROR: loading failed

Best,
Yan

[[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-contained, reproducible code.


__
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-contained, reproducible code.


Re: [R] Error : package is not installed for 'arch=x64'

2012-03-22 Thread Li, Yan
Hi Uwe,

Thanks very much for your reply! 

It is in Windows OS and I read the manual, installed the latest version of 
RTools. I also have MinGW64 compiler installed. I still kept getting this 
errors. 

Regards,
Yan

-Original Message-
From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
Sent: Sunday, March 18, 2012 1:29 PM
To: Li, Yan
Cc: r-help@r-project.org
Subject: Re: [R] Error : package is not installed for 'arch=x64'



On 13.03.2012 18:18, Li, Yan wrote:
> HI All,
>
> I got the error : package  is not installed for 'arch=x64' when building my 
> own package for 64bit R. How can I configure the arch ? The 'R CMD config' 
> does not work. Thank you very much!

Which OS?

If Linux: run R with the desired architecture and install.package().

If Windows: See the R Installation and Administration manual that explains the 
steps to set the environment up correctly. And if you start with it, use R >= 
2.14.2 so that you install the new toolchain to be compatible for future 
releases.

Uwe Ligges




>
> The detailed error is :
>
> ** testing if installed package can be loaded Error : package 'xxx' is 
> not installed for 'arch=x64'
> Error: loading failed
> Execution halted
> ERROR: loading failed
>
> Best,
> Yan
>
>   [[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-contained, reproducible code.

__
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-contained, reproducible code.


[R] Suggestions for RAM for new box

2012-03-22 Thread Neotropical bat risk assessments

Hi all,

My main Dell melted down a month ago and I need to buy a new workstation.
It will be Win7 64 bit and fast graphics card with large RAM.

For GIS (ArcGis) I am opting for 6 GB RAM.
Is there any advantage for R to boost this to 8 GB or will 6 GB be 
sufficient for R applications?

There have been a lot of discussion about "Big Memory" issues with R.

__
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-contained, reproducible code.


Re: [R] Recommendations regarding textbooks

2012-03-22 Thread Peter Ehlers

On 2012-03-22 05:17, richard willey wrote:

Hello

I was hoping to get some advice regarding teaching R in an academic environment.

What are the best choices with respect to textbooks?

When this question was asked a few years back, people were primarily
recommending “Modern Applied Statistics with S” and “Introductory
Statistics with R” as two good choices.  I’ve also heard some good
thinks regarding “An R Companion to Applied Regression”.

Has anything else really good come along in recent years?

Alternatively, are there any really good companion textbooks / lab
manuals to accompany standard texts?


 "... teaching R in an academic environment" is a bit too general.
If you're primarily concerned with using R in teaching statistics, then
the course level would be important. For into, Dalgaard's is nice. The
MASS book is something of a bible for more advanced courses.

On the other hand, if you're talking about R programming, then I can
recommend "A First Course in Statistical Programming with R"
by John Braun and Duncan Murdoch as a very nice introduction.

Peter Ehlers

__
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-contained, reproducible code.


[R] deSolve & optim, nlm function?

2012-03-22 Thread mhimanshu
Hi everyone.

Can anyone please tell me how do i used optim or nlm function after solving
a ode bx desolve package?

I have a set of two differential equation, first i solved them with deSolve
package and now i want to optimize my two parameter values for the same twoo
differential equation?

please let me know if anyone has any idea about it..!!

Thanks in advance...

--
View this message in context: 
http://r.789695.n4.nabble.com/deSolve-optim-nlm-function-tp4495446p4495446.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


Re: [R] How to change colnames in xtable?

2012-03-22 Thread Rainer Schuermann
You can change the column names of a data frame with

> colnames( df ) <- c( "my", "data", "frame" )

and from here, xtable() is your friend (or at least mine...).

Rgds,
Rainer


On Thursday 22 March 2012 01:13:18 Manish Gupta wrote:
> Hi,
> 
> Can we change column names in latex table?
> 
> Regards
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/How-to-change-colnames-in-xtable-tp4494833p44
> 94833.html Sent from the R help mailing list archive at Nabble.com.
> 
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


Re: [R] Multiple data frames in single csv output

2012-03-22 Thread R. Michael Weylandt
To elaborate (because I've made this mistake before): one can use
append = TRUE for write.table() but not write.csv(). You'll need to
set the other arguments in write.table() to match the csv standard
you're using.

Michael

On Thu, Mar 22, 2012 at 10:36 AM, David Winsemius
 wrote:
>
> On Mar 22, 2012, at 6:37 AM, Andreas Emanuelsson wrote:
>
>> Hi everybody, I have a model that outputs 1) primary analysis results, 2)
>> secondary analysis results and 3) model choice parameters. I would like to
>> output them all together as one "spread sheet" to minimize my "copy paste
>> time" since I need to run the model with at least 20-30 sets of parameters.
>> They are all in different data.frames with different dimensions.
>>
>> However, I have tried  to construct one final output data frame the
>> different classes cant vary within each row (it seems) and I can't merge,
>> r-c-bind or fill the old data frames into a bigger new. Just using a matrix
>> seems to work but stills it feels like an crude way and I lose the headers
>> and some of the formatting option (replace dot with comma).
>>
>> Does anyone know a if there is a better package for "layouting" csv
>> structure? (I don't want one spread sheet per table)
>>
>> Are there any other neat way to join data.frames but ignoring all the
>> indexing? (maybe turning them into text and printing them as a csv file)?
>
>
> Can't you just write them to the same file with append=TRUE?
>
> --
>
> David Winsemius, MD
> West Hartford, CT
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


Re: [R] Multiple data frames in single csv output

2012-03-22 Thread David Winsemius


On Mar 22, 2012, at 6:37 AM, Andreas Emanuelsson wrote:

Hi everybody, I have a model that outputs 1) primary analysis  
results, 2) secondary analysis results and 3) model choice  
parameters. I would like to output them all together as one "spread  
sheet" to minimize my "copy paste time" since I need to run the  
model with at least 20-30 sets of parameters. They are all in  
different data.frames with different dimensions.


However, I have tried  to construct one final output data frame the  
different classes cant vary within each row (it seems) and I can't  
merge, r-c-bind or fill the old data frames into a bigger new. Just  
using a matrix seems to work but stills it feels like an crude way  
and I lose the headers and some of the formatting option (replace  
dot with comma).


Does anyone know a if there is a better package for "layouting" csv  
structure? (I don't want one spread sheet per table)


Are there any other neat way to join data.frames but ignoring all  
the indexing? (maybe turning them into text and printing them as a  
csv file)?


Can't you just write them to the same file with append=TRUE?

--

David Winsemius, MD
West Hartford, CT

__
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-contained, reproducible code.


[R] earth and linearly dependent regressors

2012-03-22 Thread Johann Hibschman
I'm trying to understand how the earth package treats linearly
dependent regressors. I was surprised when switching between two
linearly-dependent terms gave different results. Here's an example:

> library(earth)
> cars2 <- transform(cars, speed2=100-speed)
> earth(dist ~ speed, data=cars2)
Selected 3 of 7 terms, and 1 of 1 predictors
Importance: speed
Number of terms at each degree of interaction: 1 2 (additive model)
GCV 255.4974RSS 10347.64GRSq 0.622945RSq 0.6819924
> earth(dist ~ speed2, data=cars2)
Selected 3 of 7 terms, and 1 of 1 predictors
Importance: speed2
Number of terms at each degree of interaction: 1 2 (additive model)
GCV 246.9339RSS 1.82GRSq 0.6355828RSq 0.692651

Naively, I expected these two fits to be identical, since for each
step of the forward pass, the hinge functions considered for speed2
are the same as for speed, just exchanged and with a different
constant. Then, for the backward pass, each component should add the
same amount to the GCV.

Can anyone shed any light on what's going on here?

Thanks,
Johann

__
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-contained, reproducible code.


Re: [R] read.zoo - combining two columns with date and time respectively into one index column?

2012-03-22 Thread David Winsemius


On Mar 22, 2012, at 8:24 AM, knavero wrote:

I have three columns in my raw data: date, time, and dry bulb  
temperature:


http://r.789695.n4.nabble.com/file/n4495326/weathDataSDCoron.txt
weathDataSDCoron.txt

The date format is %Y%m%d and the time format is %H:%M. Any ideas on  
how to
read it in such that it looks at the first two columns and then  
merges it

into one column combining both the date and time?


I'm reasonably optimistic that read.zoo will do that. It's capable of  
two column datetime reads. My memory is that you just give the column  
numbers to the index.column argument. You will also need to give a  
format argument since your formats to not look to be bog standard.




--
View this message in context: 
http://r.789695.n4.nabble.com/read-zoo-combining-two-columns-with-date-and-time-respectively-into-one-index-column-tp4495326p4495326.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


David Winsemius, MD
West Hartford, CT

__
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-contained, reproducible code.


Re: [R] read.zoo - combining two columns with date and time respectively into one index column?

2012-03-22 Thread Gabor Grothendieck
On Thu, Mar 22, 2012 at 8:24 AM, knavero  wrote:
> I have three columns in my raw data: date, time, and dry bulb temperature:
>
> http://r.789695.n4.nabble.com/file/n4495326/weathDataSDCoron.txt
> weathDataSDCoron.txt
>
> The date format is %Y%m%d and the time format is %H:%M. Any ideas on how to
> read it in such that it looks at the first two columns and then merges it
> into one column combining both the date and time?

index= in read.zoo can be a vector.

library(zoo)
library(chron)

URL <- "http://r.789695.n4.nabble.com/file/n4495326/weathDataSDCoron.txt";

toChron <- function(d, t) as.chron(paste(d, t), format = "%Y%m%d %H:%M")
tail1 <- function(x) tail(x, 1)  # for duplicate times take last

z <- read.zoo(URL, index = 1:2, FUN = toChron,
header = TRUE, sep = "\t", aggregate = tail1)

See ?read.zoo and the zoo-read vignette for many examples.


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
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-contained, reproducible code.


Re: [R] Bubble chart

2012-03-22 Thread David Winsemius


On Mar 22, 2012, at 12:22 AM, ens wrote:

I have a matrix of p-values for for each explanatory variable. Each  
row is an
area of the response variable and each column is an explanatory  
variable.


e.g.
  PSA   pval_DOY pval_PDSIconcurrent  
pval_PDSIantecedent_annual_average

pval_TMAXanomaly pval_FM100anomaly
1 NC06 0.96747495   0.6092668  
0.53353019

0.93011150.99801334
2 NC04 0.04699659   0.2759152  
0.07024752

0.60468280.03224094
3 NC01 0.71437394   0.9979173  
0.85296024

0.99775580.99833623
4 NC08 0.67315904   0.9970511  
0.51756714

0.78099940.99626038
5 NC07 0.55221280   0.5784208  
0.43975219

0.36694910.34898877
6 NC05 0.52089881   0.7191645  
0.91972153

0.44874600.94922430

I want to create a visual display such that instead of #s for the p- 
values,

I have a circle sized to represent the size of the p-value.


Wouldn't that convey exactly the wrong information? Unless that is p- 
value has some sort of non-statistical meaning?


--
David.


symbolys() is what I've found to do this, but it isn't clear to me  
how to

format the input for the function.

Any suggestions? or help? Even a link if someone else has asked the  
question

and it's been answered would be helpful.

--
View this message in context: 
http://r.789695.n4.nabble.com/Bubble-chart-tp4494539p4494539.html
Sent from the R help mailing list archive at Nabble.com.

__
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-contained, reproducible code.


David Winsemius, MD
West Hartford, CT

__
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-contained, reproducible code.


Re: [R] Recommendations regarding textbooks

2012-03-22 Thread R. Michael Weylandt
What level are you looking to teach?

MASS is fantastic but very terse; it presumes a good foundation in
statistics and deals mainly with the computational aspects. My guess
would be that this book would only really be suitable for a class with
a good pre-existing background knowledge who are willing to work-hard
and learn R quite rapidly. Once one's up to speed, however, it's a
pretty indispensable resource.

I don't know the other two books personally, but their authors are
quite well known in the R community and, like you, I've heard good
things about both [books]. Prof. Dalgaard is in R-Core and Prof. Fox
is an active package maintainer so they might jump in any minute to
clarify the level of their books.

Just browsing the ToC on Amazon, the subject matters also seem to be
somewhat different so it might also be worthwhile deciding which bits
of statistics your course aims to teach. If you can narrow down the
scope of the course you can probably get a better recommendation.

Hope this helps,
Michael

On Thu, Mar 22, 2012 at 8:17 AM, richard willey
 wrote:
> Hello
>
> I was hoping to get some advice regarding teaching R in an academic 
> environment.
>
> What are the best choices with respect to textbooks?
>
> When this question was asked a few years back, people were primarily
> recommending “Modern Applied Statistics with S” and “Introductory
> Statistics with R” as two good choices.  I’ve also heard some good
> thinks regarding “An R Companion to Applied Regression”.
>
> Has anything else really good come along in recent years?
>
> Alternatively, are there any really good companion textbooks / lab
> manuals to accompany standard texts?
>
> Thanks in advance,
>
> Richard
>
>
>
> --
> I think back to the halcyon dates of my youth, when indeterminate
> Hessians had something to do with the Revolutionary War, where
> conjugate priors were monks who had broken their vows, and the
> expression (X'X)^-1(X'Y) was greek
>
> Those were simpler times
>
> __
> 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-contained, reproducible code.

__
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-contained, reproducible code.


  1   2   >