Re: [R] Reordering levels of a factor within a lattice dotplot

2012-06-23 Thread Deepayan Sarkar
On Fri, Jun 22, 2012 at 5:50 PM, maxbre mbres...@arpa.veneto.it wrote:
 Given my reproducible example

 myexample-structure(list(site = structure(c(4L, 2L, 2L, 4L, 2L, 4L, 4L,
 3L, 1L, 3L, 1L, 1L, 3L, 4L, 5L, 2L), .Label = c(A, B, C,
 D, E), class = factor), obs = c(0.302, 0.956, 0.72, 1.21,
 0.887, 0.728, 1.294, 20.493, 0.902, 0.031, 0.468, 2.318, 4.795,
 89.581, 4.59, 3618.353), sample = structure(c(6L, 6L, 2L, 8L,
 7L, 7L, 9L, 4L, 4L, 1L, 1L, 3L, 3L, 10L, 11L, 5L), .Label = c(18/08/2009,
 20/04/2009, 03/12/2008, 17/03/2009, 05/01/2012, 21/04/2009,
 17/07/2009, 17/04/2009, 21/07/2009, 29/01/2009, 16/07/2008
 ), class = factor, scores = structure(c(2, 3, 2, 3, 4, 4, 2,
 5, 2, 4, 2), .Dim = 11L, .Dimnames = list(c(18/08/2009, 21/04/2009,
 20/04/2009, 17/07/2009, 17/04/2009, 21/07/2009, 03/12/2008,
 16/07/2008, 17/03/2009, 29/01/2009, 05/01/2012), .Names =
 c(site,
 obs, sample), row.names = c(NA, -16L), class = data.frame)


 I want to dotplot with lattice the observations (obs) against sampling dates
 (sample) for each site but I need to reorder the factor levels of sampling
 dates based on the value of observations  within each site (rather than
 keeping the original arbitrary data)

 These are my two best (?) attempts both of them not properly working for
 different reasons

 #start

 library(lattice); library(latticeExtra)

 #first attempt
 myexample$sample-
  with(myexample, reorder(sample,obs))


 dotplot(sample ~ obs | site, data=myexample,
        scales=list(x=list(log=TRUE), y=list(relation=free)),
        xscale.components = xscale.components.logpower,
        strip=FALSE, strip.left=TRUE, layout=c(1,5),

        index.cond= function(x,y){median(x)},

        panel = function(x,y,...) {
          panel.dotplot(x,y,...)
          panel.abline(v = median(x), col.line=red, lty=dotted)
        }
        )


 #second attempt
 myexample$sample-
  with(myexample, reorder(reorder(sample,obs), as.numeric(site)))


 dotplot(sample ~ obs | site, data=myexample,
        scales=list(x=list(log=TRUE), y=list(relation=free)),
        xscale.components = xscale.components.logpower,
        strip=FALSE, strip.left=TRUE, layout=c(1,5),

        index.cond= function(x,y){median(x)},

        panel = function(x,y,...) {
          panel.dotplot(x,y,...)
          panel.abline(v = median(x), col.line=red, lty=dotted)
        }
        )

 #end

 There is to note the presence of some ties (i.e. same sampling dates,
 particularly noticeable for site A and B).
 The number of factor levels related to sampling dates (11) is different than
 total number of observations (17): is this responsible for the lack of
 reordering for factor sample in the dotplot?
 How to fix this ? How to get a neat y axis without that “holes” in between
 of the sampling dates within each site?

 Should I try to make somehow as much factor levels as the observations so
 that to avoid this sort of problem? Is there any alternative solution?

Yes, you need to avoid duplicates. Here is one way to do that:

myexample$sampleLabel - as.character(myexample$sample)
myexample$sampleId - gl(length(myexample$sample), 1)

myexample$sample2 -
with(myexample, reorder(reorder(sampleId, obs),
as.numeric(site)))

## correct plot, but useless y-axis labels

dotplot(sample2 ~ reorder(site, obs) | site, data = myexample,
scales=list(x=list(log=TRUE), y=list(relation=free)),
xscale.components = xscale.components.logpower,
strip=FALSE, strip.left=TRUE, layout=c(1,5))

## match reordered levels with original order, and set axis labels

nl - as.numeric(levels(myexample$sample2))

dotplot(sample2 ~ obs | reorder(site, obs), data = myexample,
scales=list(x=list(log=TRUE), y=list(relation=free)),
ylim = myexample$sampleLabel[nl],
xscale.components = xscale.components.logpower,
strip=FALSE, strip.left=TRUE, layout=c(1,5))

-Deepayan

__
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] Reordering levels of a factor within a lattice dotplot

2012-06-23 Thread maxbre
thanks a lot deepayan,
I will study carefully your code!
thanks
max

--
View this message in context: 
http://r.789695.n4.nabble.com/Reordering-levels-of-a-factor-within-a-lattice-dotplot-tp4634201p4634277.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] matching a string with multiple conditions using grep

2012-06-23 Thread Zhipeng Wang
Suppose I have a vector  [A_cont_1, A_cont_12, B_treat_8,
AB_cont_22, cont_21_Aa], I hope I can extract the strings which include
3 short strings, say A, cont and 2,  that is to say, A_cont_12,
AB_cont_22 and  cont_21_Aa will be extract, using a relatively short
code (using grep?).
Would you please to give some idea? Thank you !

[[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] incomplete gamma function with negative arguments

2012-06-23 Thread Ximing Wu

Dear list,

Is there an incomplete gamma function in R that can take negative 
arguments? If not, pointers to its implementation will be greatly 
appreciated.


I know the 'Igamma' function in 'zipfR' package. However, Igamma(a,x) 
only takes positive x. (When x is negative, this function should return 
a value that is complex. Matlab function 'gammainc' can handle negative 
arguments. But it is an internal Matlab function, so I don't get to see 
how it is done.)



Thanks! X.W.

__
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] Uniroot error message with in intergration

2012-06-23 Thread jeka12386
Many thanks Ellison

I have modified it as you suggested but I have this error message Error
in f(lower, ...) : unused argument(s) (N = 54)
 I am not sure which arguments I have missed? 
*y - function(t,n){ 
diff - 0.5 
df1 - 2*n-2 
ncp1 - sqrt((diff^2*n)/2) 
p - 1- pt(t,df=df1) 
test - qt((1-p),df=df1,ncp=ncp1)*(1/sqrt(2)) 
return(test) 
} 

integ - function(n){ 
1-integrate(y,lower=0,upper=2.7,n)$value -0.8
} 
  
uniroot(integ,lower=0,upper=1000,N=n) 

traceback()*

--
View this message in context: 
http://r.789695.n4.nabble.com/Uniroot-error-message-with-in-intergration-tp4634247p4634278.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] matching a string with multiple conditions using grep

2012-06-23 Thread Rui Barradas

Hello,

Try the following.


wanted - c(A_cont_12, AB_cont_22, cont_21_Aa)

x - c(A_cont_1, A_cont_12, B_treat_8, AB_cont_22, cont_21_Aa)

pattern - c(A, cont, 2)

ix - Reduce(``, lapply(pattern, grepl, x))  # This does the trick
identical(wanted, x[ix])


See ?Reduce.

Hope this helps,

Rui Barradas

Em 23-06-2012 11:19, Zhipeng Wang escreveu:

Suppose I have a vector  [A_cont_1, A_cont_12, B_treat_8,
AB_cont_22, cont_21_Aa], I hope I can extract the strings which include
3 short strings, say A, cont and 2,  that is to say, A_cont_12,
AB_cont_22 and  cont_21_Aa will be extract, using a relatively short
code (using grep?).
Would you please to give some idea? Thank you !

[[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] Event Studies in R

2012-06-23 Thread ivan
Dear all

I tried finding a package for event studies but unfortunately without
success. Does anyone know which package suits best for such an analysis?

Thank you in advance.

Regards

[[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] Can't save a plot

2012-06-23 Thread Tomek.Tarczynski
Hi,
I can't save a plot in R. Even the most simple examples taken from the
internet doesn't work:

jpeg('rplot.jpg')
plot(1:10)
dev.off()

The message that I receive is:
 jpeg('rplot.jpg')
 plot(1:10)
 dev.off()
null device 
  1 

I've also tried using png, pdf, and so on...

I've windows 7 64b.
Ive tried R 2.15.0 x86 and x64, same result in both.

Can anyone tell me what is wrong?

--
View this message in context: 
http://r.789695.n4.nabble.com/Can-t-save-a-plot-tp4634281.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] Can't save a plot

2012-06-23 Thread R. Michael Weylandt
Are you sure it's not working? That's exactly what the console is
supposed to display (the message means you've switched from the jpeg
_to_ the null device) -- check again to make sure the file wasn't
created -- I think you'll be pleasantly surprised.

If you're not sure where to check, look in the directory returned by
getwd(); you can do this from within R by using list.files()

Best,
Michael

On Sat, Jun 23, 2012 at 5:47 AM, Tomek.Tarczynski
tomek.tarczyn...@gmail.com wrote:
 Hi,
 I can't save a plot in R. Even the most simple examples taken from the
 internet doesn't work:

 jpeg('rplot.jpg')
 plot(1:10)
 dev.off()

 The message that I receive is:
  jpeg('rplot.jpg')
 plot(1:10)
 dev.off()
 null device
          1 

 I've also tried using png, pdf, and so on...

 I've windows 7 64b.
 Ive tried R 2.15.0 x86 and x64, same result in both.

 Can anyone tell me what is wrong?

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Can-t-save-a-plot-tp4634281.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] Boxplot with Log10 and base-exponent axis

2012-06-23 Thread Luigi
Thank you!
This works good. I understand that the value are now in Log10 scale,
although I did not understand what is happening  at line 4 of your script. 
I would like to ask how can I change the y limits since they now depend on
par(user). What if I'd like y limits extending from 1000 to 1 000 000?
I've tried to modify ylim (line 3) and ceiling (line 4) but I obtained
errors.
Best wishes,
Luigi


### UPDATED EXAMPLE 
# generationg random numbers
x-runif(100, min=0, max=10)


#plotting 
boxplot(x, log = y, yaxt=n)
 ylim - par(usr)[3:4]
  
log10AtY - seq(ceiling(ylim[1]), floor(ylim[2]))

axis(side=2, at=10^log10AtY, lab=as.expression(lapply(log10AtY,
function(y)bquote(10^.(y)


#


-- Your Response

The key is to supply an expression, not text, to the labels argument to
axis.
See help(plotmath) for details.  Here is an example:
1  x - list(One=10^(sin(1:10)+5), Two=10^(cos(1:30)*2))
2  boxplot(x, log=y, yaxt=n)
3  ylim - par(usr)[3:4]
4  log10AtY - seq(ceiling(ylim[1]), floor(ylim[2]))
5  axis(side=2, at=10^log10AtY, lab=as.expression(lapply(log10AtY,
function(y)bquote(10^.(y)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf
 Of Luigi
 Sent: Friday, June 22, 2012 7:54 AM
 To: r-help@r-project.org
 Subject: [R] Boxplot with Log10 and base-exponent axis
 
 Dear all,
 
 I would like to (i) produce boxplot graphs with axis in logarithm in base
10
 and (ii) showing the values on the axis in 10^exponent format rather than
 10E+exponent.
 
 
 
 To illustrate with an example, I have some widely spread data that I chart
 plot using  boxplot() [figure on the left]; the log=y option of
boxplot()
 I obtained the natural logarithm conversion of the data and the unfriendly
 notation baseE+exponent [figure on the centre]; if I log10 the data I
obtain
 the desired plot, but the axis are showing only the exponent. [figure on
the
 right].
 
 
 
 Can anybody help?
 
 
 
 Best regards
 
 Luigi Marongiu, MSc
 
 
 
 ### EXAMPLE 
 
 # generationg random numbers
 
 x-runif(100, min=0, max=10)
 
 
 
 # create plot
 
 par(mfrow = c(1,3))
 
 
 
 #plotting in the left side
 
 boxplot(x, xlab=Linear values)
 
 
 
 #plotting in the centre
 
 boxplot(x, log = y, xlab=y axis logged)
 
 
 
 # creating log10 values and plotting on the right side
 
 Log.base10.x-log10(x)
 
 boxplot(Log.base10.x, xlab=LOG10 of data)
 
 
 
 
 
 
   [[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] Event Studies in R

2012-06-23 Thread Jim Porzak
Ivan,
You need to be more specific if you want an answer. What kind of
events? With or without attributes?
Species extinction? Formula 1 races? Web clicks?

Jim Porzak
Minted.com
San Francisco, CA
www.linkedin.com/in/jimporzak
use R! Group SF: www.meetup.com/R-Users/


On Sat, Jun 23, 2012 at 5:36 AM, ivan i.pet...@gmail.com wrote:

 Dear all

 I tried finding a package for event studies but unfortunately without
 success. Does anyone know which package suits best for such an analysis?

 Thank you in advance.

 Regards

        [[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] Problem with converting character vector to time

2012-06-23 Thread emorway
It's not entirely clear where your trying to go with your problem, but one
'solution' depending on your destination could be:

time_obj-format(as.POSIXct(test,format=%H:%M:%S),format=%H:%M:%S)
 time_obj
[1] 00:49:19
 class(time_obj)
[1] character

 But this is a fairly unsatisfactory solution since it simply undoes the
application of as.POSIXct
 
Perhaps you can share more of your problem so folks responding know where
you're trying to get to.

--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-converting-character-vector-to-time-tp4634283p4634293.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] Event Studies in R

2012-06-23 Thread Paul Smith
I suspect Ivan is looking for packages to do discrete-event simulation
like simulation of queues.

Paul


On Sat, Jun 23, 2012 at 5:15 PM, Jim Porzak jpor...@gmail.com wrote:
 Ivan,
 You need to be more specific if you want an answer. What kind of
 events? With or without attributes?
 Species extinction? Formula 1 races? Web clicks?

 Jim Porzak
 Minted.com
 San Francisco, CA
 www.linkedin.com/in/jimporzak
 use R! Group SF: www.meetup.com/R-Users/


 On Sat, Jun 23, 2012 at 5:36 AM, ivan i.pet...@gmail.com wrote:

 Dear all

 I tried finding a package for event studies but unfortunately without
 success. Does anyone know which package suits best for such an analysis?

 Thank you in advance.

 Regards

        [[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-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] Boxplot with Log10 and base-exponent axis

2012-06-23 Thread William Dunlap
To change the y-limits you need to add ylim=c(min,max)
to the call to boxplot.  The limits there should be
in the units of the y variable (not its log10).  par(usr)[3:4]
report the y-limits on the log10 scale (they will be expanded
a bit from your desired limits so the plot does not extend
all the way to edge).

 boxplot(abs(tan(1:100)), log=y, ylim=c(.001, 1000))
 par(usr)[3:4]
[1] -3.24  3.24
 10 ^ par(usr)[3:4]
[1] 5.754399e-04 1.737801e+03

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 -Original Message-
 From: Luigi [mailto:marongiu.lu...@gmail.com]
 Sent: Saturday, June 23, 2012 8:49 AM
 To: William Dunlap
 Cc: 'Martin Maechler'; r-help@r-project.org
 Subject: RE: [R] Boxplot with Log10 and base-exponent axis
 
 Thank you!
 This works good. I understand that the value are now in Log10 scale,
 although I did not understand what is happening  at line 4 of your script.
 I would like to ask how can I change the y limits since they now depend on
 par(user). What if I'd like y limits extending from 1000 to 1 000 000?
 I've tried to modify ylim (line 3) and ceiling (line 4) but I obtained
 errors.
 Best wishes,
 Luigi
 
 
 ### UPDATED EXAMPLE 
 # generationg random numbers
   x-runif(100, min=0, max=10)
 
 
 #plotting
   boxplot(x, log = y, yaxt=n)
ylim - par(usr)[3:4]
 
   log10AtY - seq(ceiling(ylim[1]), floor(ylim[2]))
 
   axis(side=2, at=10^log10AtY, lab=as.expression(lapply(log10AtY,
 function(y)bquote(10^.(y)
 
 
 #
 
 
 -- Your Response
 
 The key is to supply an expression, not text, to the labels argument to
 axis.
 See help(plotmath) for details.  Here is an example:
 1  x - list(One=10^(sin(1:10)+5), Two=10^(cos(1:30)*2))
 2  boxplot(x, log=y, yaxt=n)
 3  ylim - par(usr)[3:4]
 4  log10AtY - seq(ceiling(ylim[1]), floor(ylim[2]))
 5  axis(side=2, at=10^log10AtY, lab=as.expression(lapply(log10AtY,
 function(y)bquote(10^.(y)
 
 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf
  Of Luigi
  Sent: Friday, June 22, 2012 7:54 AM
  To: r-help@r-project.org
  Subject: [R] Boxplot with Log10 and base-exponent axis
 
  Dear all,
 
  I would like to (i) produce boxplot graphs with axis in logarithm in base
 10
  and (ii) showing the values on the axis in 10^exponent format rather than
  10E+exponent.
 
 
 
  To illustrate with an example, I have some widely spread data that I chart
  plot using  boxplot() [figure on the left]; the log=y option of
 boxplot()
  I obtained the natural logarithm conversion of the data and the unfriendly
  notation baseE+exponent [figure on the centre]; if I log10 the data I
 obtain
  the desired plot, but the axis are showing only the exponent. [figure on
 the
  right].
 
 
 
  Can anybody help?
 
 
 
  Best regards
 
  Luigi Marongiu, MSc
 
 
 
  ### EXAMPLE 
 
  # generationg random numbers
 
  x-runif(100, min=0, max=10)
 
 
 
  # create plot
 
  par(mfrow = c(1,3))
 
 
 
  #plotting in the left side
 
  boxplot(x, xlab=Linear values)
 
 
 
  #plotting in the centre
 
  boxplot(x, log = y, xlab=y axis logged)
 
 
 
  # creating log10 values and plotting on the right side
 
  Log.base10.x-log10(x)
 
  boxplot(Log.base10.x, xlab=LOG10 of data)
 
 
 
 
 
 
  [[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] Event Studies in R

2012-06-23 Thread Patrick Burns

Bill Alpert and I thought about creating a
package from when we worked together on an
event study.  But our experience was that
most of the work was in aligning the data
and virtually none of what we did was
generalizable.

Maybe someone has found a way to make a
useful package, but I'm doubtful.

Pat


On 23/06/2012 13:36, ivan wrote:

Dear all

I tried finding a package for event studies but unfortunately without
success. Does anyone know which package suits best for such an analysis?

Thank you in advance.

Regards

[[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.



--
Patrick Burns
pbu...@pburns.seanet.com
twitter: @portfolioprobe
http://www.portfolioprobe.com/blog
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')

__
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] Can't save a plot

2012-06-23 Thread Tomek.Tarczynski
I'm a bit ashamed, because it actually works, but I'd some problems with the
privilages because it is not working when I set wd to c:\, when I changed I
used default wd everything is working.
Thanks for pointing out my ingorance!

Best,
Tomek

--
View this message in context: 
http://r.789695.n4.nabble.com/Can-t-save-a-plot-tp4634281p4634289.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] sparse distance object?

2012-06-23 Thread Broeckling,Corey
R community,

I am trying to cluster large omics datasets (10,000-20,000 variables).  
Obviously, with datasets of this size, PC memory is an issue.  I am using a 
custom distance metric, and am able to generate a dissimilarity matrix in 
sparse format.  To cluster, for example, using heirarchical clustering (hclust, 
or fastcluster::hclust), I need to submit the dataset as a distance object.  I 
can use as.dist() to acheive this, but in doing so the sparse matrix format is 
expanded to its full form, which quickly consumes all the memory on most 
desktop PCs.

My question is then:
1. Is there a clustering tool that can take as input a sparse dissimilarity 
matrix directly without expanding it?
2. alternatively, is there a sparse distance object format that I can't seem to 
find (an alternative to as.dist(), for example)?

Any advice is appreciated.
Corey

[[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 at.level() with a MCMCglmm zero-inflated poisson model

2012-06-23 Thread Alex Ruder
I have a question for users of MCMCglmm that have experience implementing
the zero-inflated poisson model.

I find that the documentation, and previous questions, do not offer a lot
of clear guidance on specifying and interpreting the zipoisson model.  In
particular, I see a lot of zero-inflated poisson examples that use the
at.level(trait, x):variableName syntax.

Specifically, the MCMCglmm course notes, available on the package's CRAN
page, uses the following example on page 102:

 m5d.1 - MCMCglmm(art ~ trait - 1 + at.level(trait, 1):fem +
 at.level(trait, 1):mar + at.level(trait, 1):kid5 + at.level(trait, 1):phd
+ at.level(trait, 1):ment, rcov = ~idh(trait):units,
 data = bioChemists, prior = prior.m5d.1, family = zipoisson,
 verbose = FALSE)

I have been unable to find an answer to the following questions and would
appreciate any guidance:

1) Does at.level(trait, 1) index the poisson latent variable, or is that
at.level(trait,2)?  More generally, how does one find out what levels, and
what values, are indexed with trait?

2) Why is the example specified only using the trait 1? That is, why not
estimate the model in the following fashion:

 m5d.1 - MCMCglmm(art ~ trait  + trait:fem +  trait:mar + trait:kid5 +
trait:phd + trait:ment, rcov = ~idh(trait):units,
 data = bioChemists, prior = prior.m5d.1, family = zipoisson,
 verbose = FALSE)

3) How do we properly interpret the results from the two models, say using
summary(m5d.1) ?

I would appreciate any pointers to relevant documentation/examples.

[[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] matching a string with multiple conditions using grep

2012-06-23 Thread Zhipeng Wang
Dear Barradas, and Dear A.K.

Thank you so much for the solutions. I got them.
I think I will study more about regular expression and apply family.

Best Regards,

Wang

2012/6/24 arun smartpink...@yahoo.com

 Hi,

 Try this:
 vec1-c(A_cont_1, A_cont_12, B_treat_8, AB_cont_22, cont_21_Aa)
 vec2-grep((A){0,1}.*cont.*2,vec1)

 vec1[vec2]
 [1] A_cont_12  AB_cont_22 cont_21_Aa


 A.K.




 - Original Message -
 From: Zhipeng Wang wa...@kuhp.kyoto-u.ac.jp
 To: r-help@r-project.org
 Cc:
 Sent: Saturday, June 23, 2012 6:19 AM
 Subject: [R] matching a string with multiple conditions using grep

 Suppose I have a vector  [A_cont_1, A_cont_12, B_treat_8,
 AB_cont_22, cont_21_Aa], I hope I can extract the strings which include
 3 short strings, say A, cont and 2,  that is to say, A_cont_12,
 AB_cont_22 and  cont_21_Aa will be extract, using a relatively short
 code (using grep?).
 Would you please to give some idea? Thank you !

 [[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.


[R] Obtaining saving cluster membership via hclust

2012-06-23 Thread Bob Green

Hello,

I want to examine the characteristics of 49 persons in terms of their 
symptoms and motivations, in a cluster analysis . The data is in a 
binary format.


I was hoping to save and then examine the cluster membership. I would 
appreciate advice on whether this is possible within hclust and if 
so, how do I do this? The syntax I have employed so far, follows.


FS4 - read.csv(E://Arsont2.csv,header=T)
dmat - dist(FS4,  method=binary)
dmat
ctest - hclust (dist(FS4,  method=binary), ave)
plot(ctest)


Bob Green

__
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] Error using PostScriptTrace()

2012-06-23 Thread M. Ndiaye
I couldn't run PostScriptTrace() from the package grImport without an
error. At first the postscript program couldn't be found. however the
problem persisted after the full path the postscript program was indicated.
I read earlier post on the subject in vain. See the codes and output below.
The file Senegal_location_map.ps was originally a svg file from:
 http://en.wikipedia.org/wiki/File:Senegal_location_map.svg
It was saved as ps file from Inkscape.
Thank you for any assistance
Modou
 library(grImport)
Loading required package: grid
Loading required package: XML
 Sys.setenv(R_GSCMD=C:/Program Files/gs/gs9.05/bin/gswin64c.exe)
 PostScriptTrace(Senegal_location_map.ps, charpath=F)
Error in PostScriptTrace(Senegal_location_map.ps, charpath = F) :
  status 127 in running command 'C:/Program Files/gs/gs9.05/bin/gswin64c.exe
  -q -dBATCH -dNOPAUSE -sDEVICE=pswrite -sOutputFile=
  C:\Users\heman\AppData\Local\Temp\Rtmp2duW3P\filefd01d981ff7
  -sstdout=Senegal_location_map2.ps.xml captureSenegal_location_map.ps'
 traceback()
2: stop(gettextf(status %d in running command '%s', ret, cmd),
   domain = NA)
1: PostScriptTrace(Senegal_location_map.ps, charpath = F)
 sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-mingw32/x64 (64-bit)

[[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.