[R] Noobie question on aggregate tapply and by

2010-04-24 Thread steven mosher
I have a 43MB dataframe ( 5 variables) and I'm trying to summarize subsets
of the data.
I've RTFM ( not very clear) and looked at a variety of samples but cant seem
to figure out
how to make these functions work.

A sample of what I want to do would be this:

ids<-seq(1,50)
 years<-c(rep(5,10),rep(6,10),rep(7,10),rep(8,20))
 data<-c(rep(23.2,7),rep(14.2,17),rep(29.2,6),rep(13.4,10),rep(16.3,5), NA,
rep(40,4))
data2<-c(rep(22.2,5),rep(13.2,8),NA, rep(29.8,16),rep(12.4,10),rep(16.3,5),
rep(38,5))
 DF<-data.frame(ids,years,data,data2)

That will give you a dataframe that is a good analog of what I have. i
would like to calculate means
( with NA removed na.rm) for each level of years.

  data  data2
5 xx. yy.
6 xx yz
7 ... ,,,
8 ..  ...

And then things like this:

5-7 :   xx yy
8   :xy zz

[[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 save as PDF when I used par(ask=T)

2010-04-24 Thread David Winsemius
You do not say what OS you are using and the differences in graphics  
operations can be substantial. Had this been on a Mac, the answer  
would be to page backward through the plots with cmd- and  
save them with cmd-s or File/Save As..  I suspect that similar  
facilities exist on Windows. Perhaps you should read:


?Devices

... and section 5.2 of the RW-Faq..

Would be a good idea to read the whole FAQ while you're in the  
neighborhood.


--
David.


On Apr 24, 2010, at 9:47 PM, casperyc wrote:



==
y=c(9,9,17,11,7,8,15,5)

treat=c("A","C","B","C","D","A","B","D")

block=c(1,1,2,2,2,3,3,3)

q1.mod=aov(y~as.factor(treat)+as.factor(block))
q1.mod
summary(q1.mod)

par(ask=T)
plot(TukeyHSD(q1.mod))
===

This way, I can only save the last picture that is displayed.
(when I try to save the first one,
the only button i can press is ''Next'')

How do I save the previous one?

Thanks.

casper
--



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] assign value between different type: Double vs Integer

2010-04-24 Thread jim holtman
If you are looping doing the assignment:

 gdata34[1,m]<-gdata[m,4]

why would yo expect that gdata[1,4]  would have the same value as
gdata[1,4].  Do you have your indices reversed?

You need to provide at least the data in 'gdata' so we have a reproducible
example.

On Sat, Apr 24, 2010 at 9:13 AM, GUO Dong 郭东  wrote:

> Dear list,
>
> just to put it in a simple way:
>
> i read.csv from csv file to create a gdata
>
> then, create array gdata34
>
> however, when making a loop for assigning gdata34[1,m]<-gdata[m,4], this is
> what happen
>
> gdata[1,4] 's real value is 10354, however, the gdata34[1,4] turns to be
> 883
>
> then i checked the type: gdata[1,4] is integer, while gdata34[1,4] is
> double.
>
> Can any one give me some help on it
>
> Many thanks in advance.
>
> Best regards,
> Dong
>
>
>
>[[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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

[[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] barplot - offsetting individual bars

2010-04-24 Thread Jim Lemon

On 04/25/2010 05:04 AM, Kevin Turner wrote:

Hello,

I'm trying currently using barplot to summarize precipitation data.  So far
I've compiled total annual snow and rain accumulation in a table
(attached).  I've been successful at plotting it using the following code:

fig=barplot(t(Annual_Precip_table), horiz=TRUE, space=0, col=c("grey70",
"white"), axes=FALSE)
.
.
The result is a stacked barplot with total annual rain represented by grey
bars and total annual snow represented by white bars.  This is great,
however, I'd like to position the bars so that the rain bars are right
justified on the axis and the snow bars are left justified on the axis.

I looked around for ways to do this, and I'm not sure, but is plotrix
capable of doing it using the barb function?  Does anyone have experience
with this kind of plot?


Hi Kevin,
No, barp can't do this, but you may have to program a custom plot using 
similar code. barp creates an empty plot and then draws rectangles on 
it. It wouldn't be too hard to stack your rectangles from the left or 
right depending upon a test of whether the stack represented rain or 
snow. I haven't encountered this type of plot before, but if it is 
common in some area, it might be worth writing a proper function and 
making it available to others who could use it.


Jim

__
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] categorical variable in scatterplot (car)

2010-04-24 Thread Peter Ehlers

On 2010-04-24 21:30, Anthony Lopez wrote:

Hello R folks,

I am encountering a problem with the following scatterplot function from the
car package:


scatterplot(y~x|z)


where y and x are continuous (interval) random variables and z is a
categorical variable.  When z is a categorical variable coded 1 or 2, I
(appropriately) get a scatterplot of y by x, coded by z.  Similarly, when z
is a categorical variable coded 1, 2, or 3, there is again, no problem.
  However, when z is a categorical variable coded 0 or 1, the scatterplot


scatterplot(y~x|z)


is exactly identical to the one generated by


scatterplot(y~x)


It is not possible that this is due to the fact that there is no difference
between the categories.  It is as if R doesn't "see" that I want it coded by
z.  But this only happens when one of the categories of z is coded "0" (i.e.
zero).  Any ideas why this is so, or how I can fix this without recoding my
variable?


Make z a factor (which it really should be anyway).

 -Peter Ehlers



Thank you!

Anthony

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




--
Peter Ehlers
University of Calgary

__
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] Adding error bars to xyplot()

2010-04-24 Thread Deepayan Sarkar
On Fri, Apr 23, 2010 at 12:56 PM, Jon Zadra  wrote:
> I took a look at xYplot() but it is beyond over-complex, at least for my
> level, and the documentation isn't too clear.
>
> Is there a simple way to make functions like plotCI() and errbar() use the
> lattice reference rather than base graphics?
>
> It seems like creating a plot of two lines across three time points
> separated into two groups should be a very basic, simple thing for a
> statistics program to do.  Is there really no way to simply pass a model to
> a plotting function and get something that includes error bars?  I just
> wonder if I"m missing how to do this "the easy way."

Try ?segplot in package latticeExtra. E.g.,

require(latticeExtra)
segplot(interaction(group, time) ~ (means-SE) + (means+SE), centers = means,
horizontal = FALSE, draw.bands = FALSE)

YMMV.

-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] How to stamp my graphs with date and time

2010-04-24 Thread Deepayan Sarkar
On Sat, Apr 24, 2010 at 3:26 PM, Jun Shen  wrote:
> Hi, David,
>
> Thanks. It is working perfectly now. But I still don't understand the
> argument "page", I couldn't find it in text() or par(). Also in the "page =
> function(n){..}" the argument "n" does not appear anywhere and it seems
> OK to be replaced with any other letter. Can anyone explain it a little bit?

Both documented in ?xyplot

-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] barchart in lattice 0.18-5

2010-04-24 Thread Deepayan Sarkar
On Sat, Apr 24, 2010 at 7:43 PM, Felix Andrews  wrote:
> On 25 April 2010 08:41, Erich Studerus  wrote:
>> Hello
>>
>> After updating to R version 2.11.0, the xlim argument of the lattice
>> barchart function does no longer work as expected. For example, the
>> following code does not produce the same result in lattice lattice_0.18-3
>> and lattice_0.18-5
>>
>> barchart(t(matrix(1:3,1:3)),horizontal=F,box.width=1,xlim=c(0.5,3.5))
>>
>> In lattice_0.18-3, I could use xlim to remove the spaces between the left
>> y-axis and the first bar and between the right y-axis and the last bar. This
>> is no longer possible in lattice_0.18-5. Is this a bug?
>
> Yes, and it is my fault.
>
> I am testing a fix.

Note that the ``correct'' way to do this (that does not depend on the
numeric mapping of the categorical axis) would be

barchart(t(matrix(1:3,1:3)),horizontal=F,box.width=1,
 lattice.options = list(axis.padding = list(factor = 0.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] help please: predict error code

2010-04-24 Thread Peter Ehlers

I'm sure there are people willing to help you, but you
will have to be a little more forthcoming with information.
I don't know how many predict functions there are in the
2000-plus packages on CRAN, but there surely are quite a
few. Perhaps you could let us know what you're using
before you get to your predict call. Reproducible code
would be best.

 -Peter Ehlers

On 2010-04-24 12:45, Brittany Hall wrote:










Hello,

I am trying to calculate predicted values derived from one dataset into a 
hypothetical dataset. I tried this line of code:

graphdata$fmgpredvalues<- predict(Acs250.3.4, graphdata)

and received the following error message:

ERROR: ZXend[1], drop = FALSE] %*%lmeFit$beta

I have made sure all variable names are the same between the two datasets and 
all factors are appropriately labeled.

I appreciate any insight.

Thanks,

Brittany





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


--
Peter Ehlers
University of Calgary

__
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] categorical variable in scatterplot (car)

2010-04-24 Thread Anthony Lopez
Hello R folks,

I am encountering a problem with the following scatterplot function from the
car package:

> scatterplot(y~x|z)

where y and x are continuous (interval) random variables and z is a
categorical variable.  When z is a categorical variable coded 1 or 2, I
(appropriately) get a scatterplot of y by x, coded by z.  Similarly, when z
is a categorical variable coded 1, 2, or 3, there is again, no problem.
 However, when z is a categorical variable coded 0 or 1, the scatterplot

> scatterplot(y~x|z)

is exactly identical to the one generated by

> scatterplot(y~x)

It is not possible that this is due to the fact that there is no difference
between the categories.  It is as if R doesn't "see" that I want it coded by
z.  But this only happens when one of the categories of z is coded "0" (i.e.
zero).  Any ideas why this is so, or how I can fix this without recoding my
variable?

Thank you!

Anthony

[[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] left-to-right series of box and whisker plots from a csv file

2010-04-24 Thread Dennis Murphy
Hi:

Here are a few options. The key step, it seems to me, is to transform the
data so that
you have one 'factor' consisting of the variable names and another column
with
the values; this is what the melt() function in the reshape package does.
This idea
should work irrespectively of the number of variables in the data frame; the
only
condition is that they are all numeric...and of course, comparable.

library(ggplot2) # adds several packages, including reshape
library(lattice)

# Manufacture some fake data with five numeric variables to compare
df <- data.frame(x1 = rnorm(20), x2 = rnorm(20), x3 = rnorm(20),
  x4 = rnorm(20), x5 = rnorm(20))
dfmelt <- melt(df)

# Basically unlists the variables into a vector value and adds an indicator
of
# the variable to which each value belongs...
dim(dfmelt)
# [1] 100   2
names(dfmelt)# variable is the 'factor', value is a numeric vector
# [1] "variable" "value"

# Generate some plots...

# Vertical boxplot in ggplot2
ggplot(dfmelt, aes(x = variable, y = value)) + geom_boxplot()
last_plot() + xlab('These are my variables') + ylab('These are my values')
# Horizontal - just add coord_flip() to previous call:
last_plot() + coord_flip()

# Horizontal violin plot in ggplot2:
p <- ggplot(dfmelt, aes(value))
p + geom_ribbon(aes(ymax = ..density.., ymin = -..density..),
stat = 'density') +  facet_grid(variable ~ .)

# Vertical and horizontal boxplots and violin plots in lattice:
bwplot(value ~ variable, data = dfmelt)
bwplot(value ~ variable, data = dfmelt, panel = panel.violin)

 bwplot(variable ~ value, data = dfmelt)
bwplot(variable ~ value, data = dfmelt, panel = panel.violin)

HTH,
Dennis

On Sat, Apr 24, 2010 at 12:53 PM, Albert Vilella  wrote:

> Hi,
>
> I've got a csv file with scores like this:
>
> 40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,32,38,40,20,40,26,40,30,40,5,5,13,12,40,40,3,33,29,23,2,24,9,15,4,21,16,5,26,8,8,18
>
> 40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,32,40,40,30,40,40,37,34,40,36,13,40,13,40,5,40,8,29,5,15,34,5,22,14,20
>
> 40,40,40,40,40,40,40,40,40,12,40,40,40,20,40,40,17,40,40,40,40,40,11,40,40,29,12,40,1,13,21,10,14,24,9,13,18,28,19,12,15,3,5,3,8,2
> [...]
>
> For a given file, the number of columns can vary from a few dozen to a
> few hundreds, and I would like a script that
> draws a series of box and whiskers or violins left to right for every
> column in a single plot.
>
> How can I do that in a self-contained R script that can be called with
> the input file as argument?
>
> Cheers,
>
> Albert.
>
> __
> 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] barchart in lattice 0.18-5

2010-04-24 Thread Felix Andrews
On 25 April 2010 08:41, Erich Studerus  wrote:
> Hello
>
> After updating to R version 2.11.0, the xlim argument of the lattice
> barchart function does no longer work as expected. For example, the
> following code does not produce the same result in lattice lattice_0.18-3
> and lattice_0.18-5
>
> barchart(t(matrix(1:3,1:3)),horizontal=F,box.width=1,xlim=c(0.5,3.5))
>
> In lattice_0.18-3, I could use xlim to remove the spaces between the left
> y-axis and the first bar and between the right y-axis and the last bar. This
> is no longer possible in lattice_0.18-5. Is this a bug?

Yes, and it is my fault.

I am testing a fix.



-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andr...@anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/

__
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] Intersection for two curves

2010-04-24 Thread hadley wickham
> Many people seem to be reluctant to define functions,
> even thought I think it is a pretty small step from
> writing scripts to writing functions.

I'm not so sure - I find most students struggle to grasp that next
level of abstraction. Generalising from a specific task to a general
function is a big step. Most R users aren't programmers and many have
never had any formal training - I think writing functions well is hard
to pick up on your own.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
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 stamp my graphs with date and time

2010-04-24 Thread David Winsemius


On Apr 24, 2010, at 9:00 PM, David Winsemius wrote:



On Apr 24, 2010, at 6:26 PM, Jun Shen wrote:


Hi, David,

Thanks. It is working perfectly now. But I still don't understand  
the argument "page", I couldn't find it in text() or par().


text and par are base graphics functions. page is an argument to  
lattice functions:


(Page 26 of Sarkar;'s book says):

"Another type of annotation directly supported by lattice functions  
is through the page argument. If specified, it has to be a function,  
and is called after each page is drawn. It can be used, for example  
to mark the page numbers in a multipage display."


The code for Figure 12.1 uses it to locate a legend. (See the  
website.)



Also in the "page = function(n){..}" the argument "n" does not  
appear anywhere and it seems OK to be replaced with any other  
letter. Can anyone explain it a little bit?


That "n" could be replaced, not just with any single letter but with  
any string, as long as it was used properly (or not used at all)  
within the function body. That's just programming. Given what I know  
about R programming (not a huge amount) , I strongly suspect you  
could leave it out all together. Lot's of R functions have no formal  
arguments.


And I would have been ( er, was) wrong. You do need a dummy argument  
in the function even if it's not used.


--
David.





Jun

On Sat, Apr 24, 2010 at 4:14 PM, David Winsemius > wrote:


On Apr 24, 2010, at 4:52 PM, Jun Shen wrote:

Hi,

I also want to show user's name at the lower-left corner. So I  
added one more line to Deepayan's code but it didn't work. I am not  
sure how to use the "page" argument here. Appreciate any comment.


lattice.options(default.args = list(page = function(n) {
 panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.02, adj = 1)
 panel.text(lab = sprintf("%s",  
paste("User:",Sys.getenv("USERNAME"))), x = 0.01, y = 0.02)

}))


Using 0 for the adj argument:


lattice.options(default.args = list(page = function(n) {
  panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.02, adj =  
1)
  panel.text(lab = sprintf("%s",  
paste("User:",Sys.getenv("USERNAME"))),

  x = 0.01, y = 0.02, adj=0)
}))

> xyplot(1~1)  # works

Seems to work.  Panel.text did not help me, but it pointed to the  
base graphics functions  which I interpreted to be text() and in  
the Details section it does.


--
David


Jun

On Fri, Apr 23, 2010 at 10:32 AM, Deepayan Sarkar > wrote:
On Wed, Apr 21, 2010 at 4:02 PM, David Winsemius > wrote:

>
> On Apr 21, 2010, at 6:58 PM, David Winsemius wrote:
>
>> Sarkar offers a worked example of taking user input regarding  
location for

>> locating a grid viewport outside the plot area.
>>
>> http://lmdvr.r-forge.r-project.org/figures/figures.html
>>
>> See Figure 12.1
>>
>> state <- data.frame(state.x77, state.region)
>> trellis.vpname("xlab", prefix = "plot1")
>> trellis.vpname("strip", column = 2, row = 2, prefix = "plot2")
>>
>>
>> data(Chem97, package = "mlmRev")
>> qqmath(~ gcsescore | factor(score), Chem97, groups = gender,
>>  f.value = function(n) ppoints(100),
>>  aspect = "xy",
>>  page = function(n) {
>>  cat("Click on plot to place legend", fill = TRUE)
>>  ll <- grid.locator(unit = "npc")
>>  if (!is.null(ll))
>>  draw.key(simpleKey(levels(factor(Chem97$gender))),
>>   vp = viewport(x = ll$x, y = ll$y),
>>   draw = TRUE)
>>  })
>>
>
> Furthermore when I try:
>
> mtext(date(), side=3, line=4, adj=0)
>
>  I get a datetime stamp even though I am mixing graphic  
paradigms. This
> would seem to be one of those instances where you needn't worry  
about

> getting the internal coordinates to match up.

Appearances can be deceiving. Try to create a PDF file with this, and
you will get

> pdf()
> xyplot(1 ~ 1)
> mtext(date(), side=1, line=4, adj=0)
Error in mtext(date(), side = 1, line = 4, adj = 0) :
plot.new has not been called yet
> dev.off()

Try to copy the screen device to PDF, and you will get

> dev.copy(pdf, file = "/tmp/foo.pdf")
Error in dev.copy(pdf, file = "/tmp/foo.pdf") : invalid graphics  
state


For a footnote in lattice plots, page is the appropriate argument to
use. Adapting an example from the book (section 9.3), the following
will add a timestamp to all subsequent lattice plots:

lattice.options(default.args = list(page = function(n) {
 panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.05, adj = 1)
}))

xyplot(1 ~ 1)


-Deepayan


David Winsemius, MD
West Hartford, CT




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.


David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list

[R] How to save as PDF when I used par(ask=T)

2010-04-24 Thread casperyc

==
y=c(9,9,17,11,7,8,15,5)

treat=c("A","C","B","C","D","A","B","D")

block=c(1,1,2,2,2,3,3,3)

q1.mod=aov(y~as.factor(treat)+as.factor(block))
q1.mod
summary(q1.mod)

par(ask=T)
plot(TukeyHSD(q1.mod))
===

This way, I can only save the last picture that is displayed.
(when I try to save the first one,
the only button i can press is ''Next'')

How do I save the previous one?

Thanks.

casper
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-save-as-PDF-when-I-used-par-ask-T-tp2063966p2063966.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 stamp my graphs with date and time

2010-04-24 Thread David Winsemius


On Apr 24, 2010, at 6:26 PM, Jun Shen wrote:


Hi, David,

Thanks. It is working perfectly now. But I still don't understand  
the argument "page", I couldn't find it in text() or par().


text and par are base graphics functions. page is an argument to  
lattice functions:


 (Page 26 of Sarkar;'s book says):

"Another type of annotation directly supported by lattice functions is  
through the page argument. If specified, it has to be a function, and  
is called after each page is drawn. It can be used, for example to  
mark the page numbers in a multipage display."


The code for Figure 12.1 uses it to locate a legend. (See the website.)


Also in the "page = function(n){..}" the argument "n" does not  
appear anywhere and it seems OK to be replaced with any other  
letter. Can anyone explain it a little bit?


That "n" could be replaced, not just with any single letter but with  
any string, as long as it was used properly (or not used at all)  
within the function body. That's just programming. Given what I know  
about R programming (not a huge amount) , I strongly suspect you could  
leave it out all together. Lot's of R functions have no formal  
arguments.





Jun

On Sat, Apr 24, 2010 at 4:14 PM, David Winsemius > wrote:


On Apr 24, 2010, at 4:52 PM, Jun Shen wrote:

Hi,

I also want to show user's name at the lower-left corner. So I added  
one more line to Deepayan's code but it didn't work. I am not sure  
how to use the "page" argument here. Appreciate any comment.


lattice.options(default.args = list(page = function(n) {
  panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.02, adj = 1)
  panel.text(lab = sprintf("%s",  
paste("User:",Sys.getenv("USERNAME"))), x = 0.01, y = 0.02)

}))


Using 0 for the adj argument:


lattice.options(default.args = list(page = function(n) {
   panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.02, adj =  
1)
   panel.text(lab = sprintf("%s",  
paste("User:",Sys.getenv("USERNAME"))),

   x = 0.01, y = 0.02, adj=0)
 }))

> xyplot(1~1)  # works

Seems to work.  Panel.text did not help me, but it pointed to the  
base graphics functions  which I interpreted to be text() and in the  
Details section it does.


--
David


Jun

On Fri, Apr 23, 2010 at 10:32 AM, Deepayan Sarkar > wrote:
On Wed, Apr 21, 2010 at 4:02 PM, David Winsemius > wrote:

>
> On Apr 21, 2010, at 6:58 PM, David Winsemius wrote:
>
>> Sarkar offers a worked example of taking user input regarding  
location for

>> locating a grid viewport outside the plot area.
>>
>> http://lmdvr.r-forge.r-project.org/figures/figures.html
>>
>> See Figure 12.1
>>
>> state <- data.frame(state.x77, state.region)
>> trellis.vpname("xlab", prefix = "plot1")
>> trellis.vpname("strip", column = 2, row = 2, prefix = "plot2")
>>
>>
>> data(Chem97, package = "mlmRev")
>> qqmath(~ gcsescore | factor(score), Chem97, groups = gender,
>>  f.value = function(n) ppoints(100),
>>  aspect = "xy",
>>  page = function(n) {
>>  cat("Click on plot to place legend", fill = TRUE)
>>  ll <- grid.locator(unit = "npc")
>>  if (!is.null(ll))
>>  draw.key(simpleKey(levels(factor(Chem97$gender))),
>>   vp = viewport(x = ll$x, y = ll$y),
>>   draw = TRUE)
>>  })
>>
>
> Furthermore when I try:
>
> mtext(date(), side=3, line=4, adj=0)
>
>  I get a datetime stamp even though I am mixing graphic  
paradigms. This
> would seem to be one of those instances where you needn't worry  
about

> getting the internal coordinates to match up.

Appearances can be deceiving. Try to create a PDF file with this, and
you will get

> pdf()
> xyplot(1 ~ 1)
> mtext(date(), side=1, line=4, adj=0)
Error in mtext(date(), side = 1, line = 4, adj = 0) :
 plot.new has not been called yet
> dev.off()

Try to copy the screen device to PDF, and you will get

> dev.copy(pdf, file = "/tmp/foo.pdf")
Error in dev.copy(pdf, file = "/tmp/foo.pdf") : invalid graphics state

For a footnote in lattice plots, page is the appropriate argument to
use. Adapting an example from the book (section 9.3), the following
will add a timestamp to all subsequent lattice plots:

lattice.options(default.args = list(page = function(n) {
  panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.05, adj = 1)
}))

xyplot(1 ~ 1)


-Deepayan


David Winsemius, MD
West Hartford, CT




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] Intersection for two curves

2010-04-24 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Ehlers
> Sent: Saturday, April 24, 2010 3:51 PM
> To: hadley wickham
> Cc: r-help@r-project.org
> Subject: Re: [R] Intersection for two curves
> 
> On 2010-04-24 13:50, hadley wickham wrote:
> > On Sat, Apr 24, 2010 at 12:54 PM, Peter 
> Ehlers  wrote:
> >> Well, this has seriously gotten off the original topic.
> >>
> >> While Hadley makes some sense, it is nevertheless
> >> sometimes the case (surely so for David, I would surmise)
> >> that one is putting together a response to an R-help
> >> query when a new query prompts one to temporarily abandon
> >> the first and formulate a response to the second. One
> >> may well prefer not to have one's workspace cleared even
> >> though this would not lose more than the temporarily
> >> suspended work. So, is ther *ever* a good reason to
> >> *not* put rm(list=ls()) behind a comment char? I doubt it.
> >
> > Is there ever a good idea to use rm(list = ls()) ?  Why not close R
> > and restart it so you can guarantee you have a clean 
> environment which
> > with to test your code.
> 
> I agree completely. It's precisely what I do. The only
> drawback might be restarting a number of packages but even
> that hasn't been a problem. I don't think I've used rm(list=ls())
> in any session other than one I don't mind losing.

My guess about why lots of people start their
scripts with a call like rm(list=ls(all=TRUE))
is that they don't want to define functions to
use.  Hence their workspace gets filled with
temporary variables and they want to get rid of
them before the next test run of the script file.

E.g., one appeared today that looked like
   # [do not execute] # RM(list=ls(all=TRUE))
   myData <- read.table(...)
   for(i in 1:ncol(myData)) {
   tmp1 <- ...
   ...
   tmp20 <- ...
   print(tmp20)
   result <- cbind(result, c(tmp1, ..., tmp20))
   }
I suspect the rm() is there to get rid of the 20 temporary
variables left over from the last try.  If this were written
as a function definition followed by a call, so all temporary
variables disappeared when the call was done, there might
be less temptation to put the rm() call in the script:
f <- function(data) {
   for(i in 1:nrow(data)) {
  tmp1 <- ...
  ...
  tmp20 <- ...
  print(tmp20)
  returnValue <- ...
   }
   returnValue
   }
   result <- f(myData)
Defining functions makes it easier for others to work
on a problem, since they make it clear what the inputs
and outputs are and it is easy to compare the outputs of
two functions calls with all.equal(f1(data), f2(data)).

Many people seem to be reluctant to define functions,
even thought I think it is a pretty small step from
writing scripts to writing functions.  If you don't
write functions you are doomed to an R-life of copying
and pasting or having to remember stupid details of
the language instead of being able to solve a problem
once and reusing the solution (like doing math by
using only Peano's axioms instead of using theorems
proved from them).

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> 
>   -Peter
> 
> >
> > This is probably one of the biggest disadvantages of using the
> > existing R guis - you normally only have one running, and it's a
> > hassle to close it down and restart it.
> >
> > Hadley
> >
> 
> -- 
> Peter Ehlers
> University of Calgary
> 
> __
> 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] Intersection for two curves

2010-04-24 Thread Peter Ehlers

On 2010-04-24 13:50, hadley wickham wrote:

On Sat, Apr 24, 2010 at 12:54 PM, Peter Ehlers  wrote:

Well, this has seriously gotten off the original topic.

While Hadley makes some sense, it is nevertheless
sometimes the case (surely so for David, I would surmise)
that one is putting together a response to an R-help
query when a new query prompts one to temporarily abandon
the first and formulate a response to the second. One
may well prefer not to have one's workspace cleared even
though this would not lose more than the temporarily
suspended work. So, is ther *ever* a good reason to
*not* put rm(list=ls()) behind a comment char? I doubt it.


Is there ever a good idea to use rm(list = ls()) ?  Why not close R
and restart it so you can guarantee you have a clean environment which
with to test your code.


I agree completely. It's precisely what I do. The only
drawback might be restarting a number of packages but even
that hasn't been a problem. I don't think I've used rm(list=ls())
in any session other than one I don't mind losing.

 -Peter



This is probably one of the biggest disadvantages of using the
existing R guis - you normally only have one running, and it's a
hassle to close it down and restart it.

Hadley



--
Peter Ehlers
University of Calgary

__
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] barchart in lattice 0.18-5

2010-04-24 Thread Erich Studerus

Hello

After updating to R version 2.11.0, the xlim argument of the lattice 
barchart function does no longer work as expected. For example, the 
following code does not produce the same result in lattice lattice_0.18-3 
and lattice_0.18-5


barchart(t(matrix(1:3,1:3)),horizontal=F,box.width=1,xlim=c(0.5,3.5))

In lattice_0.18-3, I could use xlim to remove the spaces between the left 
y-axis and the first bar and between the right y-axis and the last bar. This 
is no longer possible in lattice_0.18-5. Is this a bug?

Regards,
Erich

__
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 stamp my graphs with date and time

2010-04-24 Thread Jun Shen
Hi, David,

Thanks. It is working perfectly now. But I still don't understand the
argument "page", I couldn't find it in text() or par(). Also in the "page =
function(n){..}" the argument "n" does not appear anywhere and it seems
OK to be replaced with any other letter. Can anyone explain it a little bit?


Jun

On Sat, Apr 24, 2010 at 4:14 PM, David Winsemius wrote:

>
> On Apr 24, 2010, at 4:52 PM, Jun Shen wrote:
>
>  Hi,
>>
>> I also want to show user's name at the lower-left corner. So I added one
>> more line to Deepayan's code but it didn't work. I am not sure how to use
>> the "page" argument here. Appreciate any comment.
>>
>> lattice.options(default.args = list(page = function(n) {
>>   panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.02, adj = 1)
>>   panel.text(lab = sprintf("%s", paste("User:",Sys.getenv("USERNAME"))), x
>> = 0.01, y = 0.02)
>> }))
>>
>>
> Using 0 for the adj argument:
>
>
> lattice.options(default.args = list(page = function(n) {
>panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.02, adj = 1)
>panel.text(lab = sprintf("%s", paste("User:",Sys.getenv("USERNAME"))),
>x = 0.01, y = 0.02, adj=0)
>  }))
>
> > xyplot(1~1)  # works
>
> Seems to work.  Panel.text did not help me, but it pointed to the base
> graphics functions  which I interpreted to be text() and in the Details
> section it does.
>
> --
> David
>
>
>  Jun
>>
>> On Fri, Apr 23, 2010 at 10:32 AM, Deepayan Sarkar <
>> deepayan.sar...@gmail.com> wrote:
>> On Wed, Apr 21, 2010 at 4:02 PM, David Winsemius 
>> wrote:
>> >
>> > On Apr 21, 2010, at 6:58 PM, David Winsemius wrote:
>> >
>> >> Sarkar offers a worked example of taking user input regarding location
>> for
>> >> locating a grid viewport outside the plot area.
>> >>
>> >> http://lmdvr.r-forge.r-project.org/figures/figures.html
>> >>
>> >> See Figure 12.1
>> >>
>> >> state <- data.frame(state.x77, state.region)
>> >> trellis.vpname("xlab", prefix = "plot1")
>> >> trellis.vpname("strip", column = 2, row = 2, prefix = "plot2")
>> >>
>> >>
>> >> data(Chem97, package = "mlmRev")
>> >> qqmath(~ gcsescore | factor(score), Chem97, groups = gender,
>> >>  f.value = function(n) ppoints(100),
>> >>  aspect = "xy",
>> >>  page = function(n) {
>> >>  cat("Click on plot to place legend", fill = TRUE)
>> >>  ll <- grid.locator(unit = "npc")
>> >>  if (!is.null(ll))
>> >>  draw.key(simpleKey(levels(factor(Chem97$gender))),
>> >>   vp = viewport(x = ll$x, y = ll$y),
>> >>   draw = TRUE)
>> >>  })
>> >>
>> >
>> > Furthermore when I try:
>> >
>> > mtext(date(), side=3, line=4, adj=0)
>> >
>> >  I get a datetime stamp even though I am mixing graphic paradigms.
>> This
>> > would seem to be one of those instances where you needn't worry about
>> > getting the internal coordinates to match up.
>>
>> Appearances can be deceiving. Try to create a PDF file with this, and
>> you will get
>>
>> > pdf()
>> > xyplot(1 ~ 1)
>> > mtext(date(), side=1, line=4, adj=0)
>> Error in mtext(date(), side = 1, line = 4, adj = 0) :
>>  plot.new has not been called yet
>> > dev.off()
>>
>> Try to copy the screen device to PDF, and you will get
>>
>> > dev.copy(pdf, file = "/tmp/foo.pdf")
>> Error in dev.copy(pdf, file = "/tmp/foo.pdf") : invalid graphics state
>>
>> For a footnote in lattice plots, page is the appropriate argument to
>> use. Adapting an example from the book (section 9.3), the following
>> will add a timestamp to all subsequent lattice plots:
>>
>> lattice.options(default.args = list(page = function(n) {
>>   panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.05, adj = 1)
>> }))
>>
>> xyplot(1 ~ 1)
>>
>>
>> -Deepayan
>>
>>
> David Winsemius, MD
> West Hartford, CT
>
>

[[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] Formatting numerical output

2010-04-24 Thread MARCEL CURLIN
Hello,
I am new to R and am having difficulty formatting numerical output from a 
regression analysis. My code iteratively performs linear regression on a 
dataset while excluding certain data ranges. 

My code:
rm(list = ls(all = TRUE))
sink("outfile")
dat <- read.table("testdat", sep="\t", header=TRUE)
int = 0.2

for (x in c(0:20)) { 
subdat <- subset(dat, time <= int * x | time > (int*x) + int)   
#excludes range of time data between int * x and (int*x) + int
lm.subdat <- lm(length~time, subdat)
#regression
rs.subdat <- summary(lm.subdat)$r.squared   
#getting R-squared information
txt1 <- ("Excluded range: Time")
#creating components of output message
txt2 <- ("R^2 =")   
#creating components of output message
lowend <- (int*x)
highend <- (int*x + int)
output <- c(txt1, lowend, highend, txt2, rs.subdat)
print.noquote(output, sep="\t")
}
sink()

Currently my output looks like:
[1] Excluded range: Time 00.2 
[4] R^2 =0.111526872884505   
[1] Excluded range: Time 0.2  0.4 
[4] R^2 =0.0706332920267015  
[1] Excluded range: Time 0.4  0.6 
[4] R^2 =0.0691466100802879

I would like the output format to look like:
Excluded range: Time 1.0 - 1.2R^2 = 0.45  
Excluded range: Time 1.2 - 1.4R^2 = 0.5
etc.

I would like to 
1. get time and R^2 data on the same line
2. control (reduce) the number of digits reported for R^2
3. reduce the large number of empty spaces between "R^2' and value.

I searched a lot but could not find much on this. Any help on these specifics 
or general comments on formatting numerical output greatly appreciated. 

thanks,

Marcel

__
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] basic table statistics

2010-04-24 Thread David Winsemius


On Apr 23, 2010, at 3:48 PM, Maxim wrote:


I have a very simple question, but I'm obviously not able to solve the
problem on my own.

I have a data.frame like

sample(c("A","B","C"),size=20,replace = T)->type

rnorm(20)->value

data.frame(ty=type,val=value)->test

There must be some built in functions, that will do some descriptive
statistics with tabular output, in the end I like to have something  
like


number of samples mean sd .

A 5
B 9
C 6

So I need a function that counts the number of  occurrences of  
factors in

type and then does something like the *summary* function, but factor
specific.

I tried:
vector()->Median
vector()->SD
vector()->Mean

as.data.frame(table(type))->int
for (count in c(1:(nrow(int
{
subset(test, ty==as.character(int$type[count])) -> subtest
median(subtest$val)->Median[count]
sd(subtest$val)->SD[count]
mean(subtest$val)->Mean[count]
}


cbind(int,Median,SD,Mean)


> require(Design)  # loads Hmisc which has ne of many version of  
describe()

> describe(test)
test

 2  Variables  20  Observations
-
ty
  n missing  unique
 20   0   3

A (4, 20%), B (5, 25%), C (11, 55%)
-
val
n   missingunique  Mean   .05   .10   .25
   20 020   0.07383 -0.865776 -0.815317 -0.707465
  .50   .75   .90   .95
 0.005735  0.634226  1.270066  1.771820

lowest : -1.7965 -0.8168 -0.8152 -0.8040 -0.7170
highest:  0.6790  1.0680  1.2149  1.7665  1.8729
-


> require(doBy)
> summaryBy(value~ty, test, FUN=list(length, mean, min, max, sd,  
median))

  ty value.length  value.mean  value.min value.max  value.sd
1  A4 -0.03442822 -0.8151531  1.766502 1.2258221
2  B5  0.34541927 -0.8167919  1.214906 0.7647165
3  C   11 -0.01025352 -1.7964684  1.872865 1.0109676
  value.median
1  -0.54453098
2   0.57020532
3  -0.06826249


The by() function which is an application of tapply can also be used.

>



This works, but: isn't this much too complicated, I bet there is such
functionality embedded in the base packages, but I cannot find it.


Maxim



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] did you find a solution to this?

2010-04-24 Thread stivc
I wrote a followup to your old message which had no replies-- my situation is 
near identical, and, I wonder if you found a solution.  (Running "make check" 
on R, failure of stats test.)

Thanks,

Stephen Carrier

__
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: testing 'stats' failed" - R 2.9.2 on Linux

2010-04-24 Thread sal

Identical Problem on Identical Platform.  Only difference is R-2.11.0.  The
trailing content of stats-Ex.Rout.fail is:

-
> trees <- window(treering, start=0)
> (fit <- StructTS(trees, type = "level"))

Call:
StructTS(x = trees, type = "level")

Variances:
levelepsilon  
0.0003700  0.0719877  
> plot(trees)
> lines(fitted(fit), col = "green")
> tsdiag(fit)
> 
> (fit <- StructTS(log10(UKgas), type = "BSM"))
Error in optim(init[mask], getLike, method = "L-BFGS-B", lower = rep(0,  : 
  non-finite value supplied by optim
Calls: StructTS -> optim
Execution halted
-

Judging by the lack of response to the previous query, and similarity of
platforms, I am guessing the answer has to do with some particularity of
slackware-13.0.  Such as a particular library version.  But which one?  As
they say 'bump'.  Thanks.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Error-testing-stats-failed-R-2-9-2-on-Linux-tp899492p2063727.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 please: predict error code

2010-04-24 Thread Brittany Hall









Hello,
 
I am trying to calculate predicted values derived from one dataset into a 
hypothetical dataset. I tried this line of code:
 
graphdata$fmgpredvalues <- predict(Acs250.3.4, graphdata)
 
and received the following error message:
 
ERROR: ZXend[1], drop = FALSE] %*%lmeFit$beta
 
I have made sure all variable names are the same between the two datasets and 
all factors are appropriately labeled.
 
I appreciate any insight.
 
Thanks,
 
Brittany
 



  
[[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 stamp my graphs with date and time

2010-04-24 Thread David Winsemius


On Apr 24, 2010, at 4:52 PM, Jun Shen wrote:


Hi,

I also want to show user's name at the lower-left corner. So I added  
one more line to Deepayan's code but it didn't work. I am not sure  
how to use the "page" argument here. Appreciate any comment.


lattice.options(default.args = list(page = function(n) {
   panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.02, adj =  
1)
   panel.text(lab = sprintf("%s",  
paste("User:",Sys.getenv("USERNAME"))), x = 0.01, y = 0.02)

}))



Using 0 for the adj argument:

lattice.options(default.args = list(page = function(n) {
panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.02, adj =  
1)
panel.text(lab = sprintf("%s",  
paste("User:",Sys.getenv("USERNAME"))),

x = 0.01, y = 0.02, adj=0)
 }))

> xyplot(1~1)  # works

Seems to work.  Panel.text did not help me, but it pointed to the base  
graphics functions  which I interpreted to be text() and in the  
Details section it does.


--
David


Jun

On Fri, Apr 23, 2010 at 10:32 AM, Deepayan Sarkar > wrote:
On Wed, Apr 21, 2010 at 4:02 PM, David Winsemius > wrote:

>
> On Apr 21, 2010, at 6:58 PM, David Winsemius wrote:
>
>> Sarkar offers a worked example of taking user input regarding  
location for

>> locating a grid viewport outside the plot area.
>>
>> http://lmdvr.r-forge.r-project.org/figures/figures.html
>>
>> See Figure 12.1
>>
>> state <- data.frame(state.x77, state.region)
>> trellis.vpname("xlab", prefix = "plot1")
>> trellis.vpname("strip", column = 2, row = 2, prefix = "plot2")
>>
>>
>> data(Chem97, package = "mlmRev")
>> qqmath(~ gcsescore | factor(score), Chem97, groups = gender,
>>  f.value = function(n) ppoints(100),
>>  aspect = "xy",
>>  page = function(n) {
>>  cat("Click on plot to place legend", fill = TRUE)
>>  ll <- grid.locator(unit = "npc")
>>  if (!is.null(ll))
>>  draw.key(simpleKey(levels(factor(Chem97$gender))),
>>   vp = viewport(x = ll$x, y = ll$y),
>>   draw = TRUE)
>>  })
>>
>
> Furthermore when I try:
>
> mtext(date(), side=3, line=4, adj=0)
>
>  I get a datetime stamp even though I am mixing graphic  
paradigms. This
> would seem to be one of those instances where you needn't worry  
about

> getting the internal coordinates to match up.

Appearances can be deceiving. Try to create a PDF file with this, and
you will get

> pdf()
> xyplot(1 ~ 1)
> mtext(date(), side=1, line=4, adj=0)
Error in mtext(date(), side = 1, line = 4, adj = 0) :
 plot.new has not been called yet
> dev.off()

Try to copy the screen device to PDF, and you will get

> dev.copy(pdf, file = "/tmp/foo.pdf")
Error in dev.copy(pdf, file = "/tmp/foo.pdf") : invalid graphics state

For a footnote in lattice plots, page is the appropriate argument to
use. Adapting an example from the book (section 9.3), the following
will add a timestamp to all subsequent lattice plots:

lattice.options(default.args = list(page = function(n) {
   panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.05, adj =  
1)

}))

xyplot(1 ~ 1)


-Deepayan



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] basic table statistics

2010-04-24 Thread Walmes Zeviani

You can use fBasics package

sample(c("A","B","C"),size=20,replace = T) -> type
rnorm(20) -> value
data.frame(ty=type,val=value) -> test

require(fBasics)

nam <- rownames(basicStats(test$val))
result <- do.call("cbind", with(test, tapply(val, ty, basicStats)))
rownames(result) <- nam
result

Bests.

-
..ooo0
...
..()... 0ooo...  Walmes Zeviani
...\..(.(.)... Master in Statistics and Agricultural
Experimentation
\_). )../   walmeszevi...@hotmail.com, Lavras - MG, Brasil

(_/
-- 
View this message in context: 
http://r.789695.n4.nabble.com/basic-table-statistics-tp2062829p2063832.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 stamp my graphs with date and time

2010-04-24 Thread Jun Shen
Hi,

I also want to show user's name at the lower-left corner. So I added one
more line to Deepayan's code but it didn't work. I am not sure how to use
the "page" argument here. Appreciate any comment.

lattice.options(default.args = list(page = function(n) {
   panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.02, adj = 1)
   panel.text(lab = sprintf("%s", paste("User:",Sys.getenv("USERNAME"))), x
= 0.01, y = 0.02)
}))


Jun

On Fri, Apr 23, 2010 at 10:32 AM, Deepayan Sarkar  wrote:

> On Wed, Apr 21, 2010 at 4:02 PM, David Winsemius 
> wrote:
> >
> > On Apr 21, 2010, at 6:58 PM, David Winsemius wrote:
> >
> >> Sarkar offers a worked example of taking user input regarding location
> for
> >> locating a grid viewport outside the plot area.
> >>
> >> http://lmdvr.r-forge.r-project.org/figures/figures.html
> >>
> >> See Figure 12.1
> >>
> >> state <- data.frame(state.x77, state.region)
> >> trellis.vpname("xlab", prefix = "plot1")
> >> trellis.vpname("strip", column = 2, row = 2, prefix = "plot2")
> >>
> >>
> >> data(Chem97, package = "mlmRev")
> >> qqmath(~ gcsescore | factor(score), Chem97, groups = gender,
> >>  f.value = function(n) ppoints(100),
> >>  aspect = "xy",
> >>  page = function(n) {
> >>  cat("Click on plot to place legend", fill = TRUE)
> >>  ll <- grid.locator(unit = "npc")
> >>  if (!is.null(ll))
> >>  draw.key(simpleKey(levels(factor(Chem97$gender))),
> >>   vp = viewport(x = ll$x, y = ll$y),
> >>   draw = TRUE)
> >>  })
> >>
> >
> > Furthermore when I try:
> >
> > mtext(date(), side=3, line=4, adj=0)
> >
> >  I get a datetime stamp even though I am mixing graphic paradigms.
> This
> > would seem to be one of those instances where you needn't worry about
> > getting the internal coordinates to match up.
>
> Appearances can be deceiving. Try to create a PDF file with this, and
> you will get
>
> > pdf()
> > xyplot(1 ~ 1)
> > mtext(date(), side=1, line=4, adj=0)
> Error in mtext(date(), side = 1, line = 4, adj = 0) :
>  plot.new has not been called yet
> > dev.off()
>
> Try to copy the screen device to PDF, and you will get
>
> > dev.copy(pdf, file = "/tmp/foo.pdf")
> Error in dev.copy(pdf, file = "/tmp/foo.pdf") : invalid graphics state
>
> For a footnote in lattice plots, page is the appropriate argument to
> use. Adapting an example from the book (section 9.3), the following
> will add a timestamp to all subsequent lattice plots:
>
> lattice.options(default.args = list(page = function(n) {
>panel.text(lab = sprintf("%s", date()), x = 0.99, y = 0.05, adj = 1)
> }))
>
> xyplot(1 ~ 1)
>
>
> -Deepayan
>

[[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] left-to-right series of box and whisker plots from a csv file

2010-04-24 Thread David Winsemius


On Apr 24, 2010, at 3:53 PM, Albert Vilella wrote:


Hi,

I've got a csv file with scores like this:
40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,32,38,40,20,40,26,40,30,40,5,5,13,12,40,40,3,33,29,23,2,24,9,15,4,21,16,5,26,8,8,18
40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,32,40,40,30,40,40,37,34,40,36,13,40,13,40,5,40,8,29,5,15,34,5,22,14,20
40,40,40,40,40,40,40,40,40,12,40,40,40,20,40,40,17,40,40,40,40,40,11,40,40,29,12,40,1,13,21,10,14,24,9,13,18,28,19,12,15,3,5,3,8,2
[...]

For a given file, the number of columns can vary from a few dozen to a
few hundreds, and I would like a script that
draws a series of box and whiskers or violins left to right for every
column in a single plot.

How can I do that in a self-contained R script that can be called with
the input file as argument?

Cheers,

Albert.

__
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] 2 simple question

2010-04-24 Thread tamas barjak
Hi

I do not speak in English very well, I'm sorry.

I try good:

layout(matrix(1:4,ncol=2, byrow=T)) = par(mfrow=c(2, 2))

plot(1,1) <--- anddoes plot in the upper left corner
plot(2, 2) <--- upper right corner

BUT, I like plot( n, m) for example lower right corner, or lower left
corner, or again upper right corner etc...

But I received an answer already:

?split.screen
?screen   #same help page

>From this is it any better?

Tamas

[[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] Intersection for two curves

2010-04-24 Thread Carl Witthoft
 Well it sounds like you won't lose any work, but you will lose 
some time. But why not open another session of R for R-help questions? 
Then you're never in any danger. I often have four or five instances of 
R running for different projects.


Hadley


Well for one thing you turkey,  OS X will not under normal circumstances 
open two instances of a given app. Don't be Windows-centric.


And as Gabor said, why post bad code in the first place?  rm(list=ls()) 
is practically a cliche precisely because it's nuclear and should never 
be used anywhere.


Typical code listed in package help files may end with unlink([stuff]), 
which makes far better sense than, e.g.  unlink(*.*)  .


Carl

__
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] import file formatted RFC-822

2010-04-24 Thread Sebastian Kruk
I used it but for example:

> robots2[74]
[1] "\"Teoma\" or \"Ask Jeeves\" or \"Jeeves\""

It wasn't sorted.

Sebastian.

2010/4/14 Barry Rowlingson :
> On Wed, Apr 14, 2010 at 6:20 PM, Sebastian Kruk  
> wrote:
>> I have a problem, In a few cases "robot-exclusion-useragent" have 2 or
>> more values, is there a manner to fix it? For example, robot askjeeves
>> has three names.
>
>  use 'all=TRUE'?
>
> test data:
>
> foo: 1
> bar: 2
>
> foo: 1
> foo: 2
> bar: 4
> baz: 7
>
>> read.dcf("simple.txt",all=TRUE)
>   foo bar  baz
> 1    1   2 
> 2 1, 2   4    7
>
>  note that $foo is a *list* in order to handle multiple values in its 
> elements:
>
>  > m=read.dcf("simple.txt",all=TRUE)
>  > m$foo
> [[1]]
> [1] "1"
>
> [[2]]
> [1] "1" "2"
>
>  whereas $bar is a simple vector:
>
>  > m$bar
> [1] "2" "4"
>
>  as is $baz (with NA where no baz record exists)
>
>  > m$baz
> [1] NA  "7"
>
> sorted?
>
> Barry
>

__
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] left-to-right series of box and whisker plots from a csv file

2010-04-24 Thread Albert Vilella
Hi,

I've got a csv file with scores like this:
40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,32,38,40,20,40,26,40,30,40,5,5,13,12,40,40,3,33,29,23,2,24,9,15,4,21,16,5,26,8,8,18
40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,32,40,40,30,40,40,37,34,40,36,13,40,13,40,5,40,8,29,5,15,34,5,22,14,20
40,40,40,40,40,40,40,40,40,12,40,40,40,20,40,40,17,40,40,40,40,40,11,40,40,29,12,40,1,13,21,10,14,24,9,13,18,28,19,12,15,3,5,3,8,2
[...]

For a given file, the number of columns can vary from a few dozen to a
few hundreds, and I would like a script that
draws a series of box and whiskers or violins left to right for every
column in a single plot.

How can I do that in a self-contained R script that can be called with
the input file as argument?

Cheers,

Albert.

__
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] Intersection for two curves

2010-04-24 Thread hadley wickham
On Sat, Apr 24, 2010 at 12:54 PM, Peter Ehlers  wrote:
> Well, this has seriously gotten off the original topic.
>
> While Hadley makes some sense, it is nevertheless
> sometimes the case (surely so for David, I would surmise)
> that one is putting together a response to an R-help
> query when a new query prompts one to temporarily abandon
> the first and formulate a response to the second. One
> may well prefer not to have one's workspace cleared even
> though this would not lose more than the temporarily
> suspended work. So, is ther *ever* a good reason to
> *not* put rm(list=ls()) behind a comment char? I doubt it.

Is there ever a good idea to use rm(list = ls()) ?  Why not close R
and restart it so you can guarantee you have a clean environment which
with to test your code.

This is probably one of the biggest disadvantages of using the
existing R guis - you normally only have one running, and it's a
hassle to close it down and restart it.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
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 lmport this dataframe into R

2010-04-24 Thread Gabor Grothendieck
Define a function dejunkify which removes commas and parens and
converts cols 2 onwards to numeric.  Assuming that the lines near the
end of the file all start with B use "B" as the comment character and
read in the file and then dejunkify it.  Then read in the lines again
and extract out the lines that begin with B.  Using strapply in gsubfn
split it into the required 4 fields and dejunkify it.  If the actual
data does not follow these rules you may need to modify this somewhat.

library(gsubfn)

dejunkify <- function(x) {
for(i in 2:ncol(x)) x[[i]] <- as.numeric(gsub("[,()]", "", x[[i]]))
x
}

DF <- read.table("myfile", skip = 1, comment = "B",
na.strings = "n", as.is = TRUE)
DF <- dejunkify(DF[-c(4,8,12))

Other <- grep("^B", readLines("myfile"), value = TRUE)
Other <- as.data.frame(strapply(Other, "(^.*) (\\S+) (\\S+) (\\S+)",
c, simplify = rbind))
Other <- dejunkify(Other)



On Sat, Apr 24, 2010 at 1:40 PM, Felipe Carrillo
 wrote:
> Hi:
> I need help with a dataframe(see pic attached). is a mix of dates and text.
> I want to create a table either using latex function from hmisc or xtable. I
> already know how to do this but the problem is getting the dataframe into R.
> I don't have a reproducible example but I am hoping that the pic attachment
> will make it to you. If someone is interested in helping with this task I 
> could
> send the excel file offlist. Thanks
>
>
> Date First Second Third
> 2/26/2010 0 ( - ) 0 ( - ) 7,002 (33 - 39)
> 2/27/2010 n (0 - 0) n (0 - 0) n (0 - 0)
> 2/28/2010 357 (123 - 123) 0 ( - ) 130,342 (29 - 57)
> 3/1/2010 144 (95 - 152) 99 (65 - 71) 22,741 (31 - 56)
> 3/2/2010 73 (126 - 152) 0 ( - ) 8,365 (31 - 53)
> 3/3/2010 43 (108 - 108) 86 (66 - 76) 5,962 (33 - 60)
> 3/4/2010 n (0 - 0) n (0 - 0) n (0 - 0)
> 3/5/2010 270 (101 - 140) 0 ( - ) 22,461 (30 - 61)
> 3/6/2010 121 (111 - 112) 40 (66 - 66) 12,485 (31 - 55)
> 3/7/2010 0 ( - ) 0 ( - ) 7,352 (31 - 56)
> 3/8/2010 34 (111 - 111) 33 (74 - 74) 2,908 (32 - 48)
> 3/9/2010 102 (111 - 140) 0 ( - ) 3,265 (27 - 48)
> 3/10/2010 0 ( - ) 35 (66 - 66) 1,993 (30 - 55)
> 3/11/2010 35 (125 - 125) 35 (70 - 70) 1,445 (33 - 62)
> Biweekly Lower 90% Confidence Interval -537 -549 35,097
> Biweekly Total 1,425 402 296,085
> Biweekly Upper 90% Confidence Interval 3,388 1,353 557,074
> Brood-year  Lower 90% Confidence Interval 2,578,499 74,306 2,249,920
> Brood Year Total 4,455,877 314,206 7,347,719
> Brood-year Upper 90% Confidence Interval 6,333,255 541,552 12,058,021
>
> Felipe D. Carrillo
> Supervisory Fishery Biologist
> Department of the Interior
> US Fish & Wildlife Service
> California, 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-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] method dispatching vs inheritance/polymorphism

2010-04-24 Thread Albert-Jan Roskam
Hi,

I'm having trouble seeing the added value over functions defined by setGeneric 
vis-a-vis
methods defined by inheritance and polymorphism. setGeneric offers a 'clean' 
call to a generic function, ie. no need to call new(), so less typing to do for 
the user. But such explicit calls can also be avoided by functions like f <- 
function(x, y) new(Class = SomeClass, x=x, y=y). Then again, R relies heavily 
on method dispatching, so it must have clear advantages. 

*confused* Can anybody enlighten me? Thanks in advance!

Cheers!!

Albert-Jan



~~

All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a fresh water system, and public health, what have 
the Romans ever done for us?

~~


  
[[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] how to import a dataframe with mixed text and numbers

2010-04-24 Thread Felipe Carrillo
Hi:
I need help with a dataframe. is a mix of dates and text.
I want to create a table either using latex function from hmisc or xtable. I
already know how to do this but the problem is getting the dataframe into R.
I don't have a reproducible example . If someone is interested in 
helping with this task I could
send the excel file offlist. Thanks


Date  First   
Second   Third 
2/26/2010 0 ( − ) --0 ( − ) 
--7,002 (33 − 39) 
2/27/2010 n (0 − 0) --n (0 − 
0)--- n (0 − 0) 
2/28/2010--- 357 (123 − 123)-0 ( − )--- 
130,342 (29 − 57) 
3/1/2010 144 (95 − 152)-99 (65 − 71) 
22,741 (31 − 56) 
3/2/2010 ---73 (126 − 152)--- 0 ( − ) 
8,365 (31 − 53) 
3/3/2010 ---43 (108 − 108)--- 86 (66 − 76) 
5,962 (33 − 60) 
3/4/2010--- n (0 − 0) ---n (0 − 
0) n (0 − 0) 
3/5/2010 --270 (101 − 140)-- 0 ( − ) 
-22,461 (30 − 61) 
3/6/2010 --121 (111 − 112)--- 40 (66 − 66)- 
12,485 (31 − 55) 
3/7/2010 ---0 ( − ) ---0 ( − ) 
---7,352 (31 − 56) 
3/8/2010 34 (111 − 111)-- 33 (74 − 
74) 2,908 (32 − 48) 
Biweekly Lower 90% Confidence Interval    -537- -549 
-35,097 
Biweekly Total -1,425 402 
-296,085 
Biweekly Upper 90% Confidence Interval --3,388 --1,353 
-557,074 
Brood-year  Lower 90% Confidence Interval ---2,578,499 
---74,306 2,249,920 
Brood Year Total --4,455,877 314,206 
---7,347,719 
Brood-year Upper 90% Confidence Interval ---6,333,255 
--541,552 12,058,021 

 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, 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] barplot - offsetting individual bars

2010-04-24 Thread Kevin Turner
Hello,

I'm trying currently using barplot to summarize precipitation data.  So far
I've compiled total annual snow and rain accumulation in a table
(attached).  I've been successful at plotting it using the following code:

fig=barplot(t(Annual_Precip_table), horiz=TRUE, space=0, col=c("grey70",
"white"), axes=FALSE)
.
.
The result is a stacked barplot with total annual rain represented by grey
bars and total annual snow represented by white bars.  This is great,
however, I'd like to position the bars so that the rain bars are right
justified on the axis and the snow bars are left justified on the axis.

I looked around for ways to do this, and I'm not sure, but is plotrix
capable of doing it using the barb function?  Does anyone have experience
with this kind of plot?

Thanks.

-- 
Kevin Turner
Department of Geography
and Environmental Studies
Wilfrid Laurier University
Waterloo, Ontario
__
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] formatted output facilities ... was ..Oddity with internet access and R 11.0 - solved

2010-04-24 Thread chrishold
David Winsemius sent the following  at 24/04/2010 18:24:
>> Now that I'm here, courtesy of my time slip, what I'd really love to see
>> in R 10.0.0, or even 2.12.0, is the choice to have output either in the
>> current plain text or to some simple formatting primitives that would
>> have default tabs & tables for matrices etc. and allow embedded
>> graphics.  I'd love to be able to opt to save that as HTML, XML, TeX,
>> RTF, ODF wihthout the complexities of Sweave, ODFWeave, R2HTML etc.
>>
>> I know the complexities of Sweave etc. are child's play to numerically
>> and computer gifted people such as yourself Professor, and the R core
>> team, but for those of us who proselytise for R to mere psychologists,
>> doctors, psychotherapists etc., that complexity is hard and the hassles
>> of reformatting text to nice tables etc. discourages people from coming
>> across from SPSS I know.
> 
> -- 
>> require(xtable)
> Loading required package: xtable
>> ?xtable
> 
> -- 
> David (a mere doctor).

Not "mere" to me David.

Yes, I know xtable and use it a bit, well, quite a lot when I was
writing R things for cgi use on the web.  I'm sure it's evolved (quick
check suggests it has and great to see that aov, lm etc. are all
covered).  However, it really does underline my point: you have to know
it exists, you have to load it, then what you get on screen is either
TeX or HTML formatted things and it doesn't embed graphics.  As I
generally (boo hiss) have to get things to end up in Word documents it
means I have to save to HTML and import from there.

I did also work a bit with ODFweave and really liked it but kept hitting
problems and found the extra layer between me and debugging my very bad
R coding meant that I didn't really make the leap from using ESS & R and
raw output.  Not helped by work restrictions ensuring I couldn't really
make the leap from Word to Open Office but the main problems were more
of a feeling of more layers between me and R.  I've got used to ESS and
love it but that leaves me stuck with these output reformatting challenges.

Xtable is wonderful and surely provides a lot of the functions that I'd
love to see embedded into the R core.  If we get into my R tardis, and
go to R 10.0.0, or could it only be R 2.13.0 say, those things would
support an option to stream R output into lightly formatted form AND
render and save that.  I'm looking for table handling such as xtable
provides, tabs and embedding of graphics though if that last didn't come
for years, I'd still be happy to have the text formatting and I'd love
to be able to chose saving to at least a couple of ODF, RTF, HTML, Tex.

As well as the code in xtable, I'm sure other resources are in ODFweave,
Sweave that would help this.  I know it's a significant programming
challenge to do that, particularly in a program that so brilliantly
embraces so many different platforms.

One of my guesses is that just allowing addition of tabs into the
routine R output and encouraging us all to start using them, would be a
huge step forward.

Thanks,

Chris

P.S. I'm cc'g to r-core as this is really a plea to the core team.
Sorry if that's a breach of R etiquette.

-- 
Chris Evans  Skype: chris-psyctc
Consultant Psychiatrist in Psychotherapy, Notts. PDD network;
Trust Research Governance Lead and Clinical Director, Psychological
  Therapies Directorate in Local Services, Nottinghamshire NHS Trust;
Professor, Psychotherapy, Nottingham University
*If I am writing from one of those roles, it will be clear. Otherwise*
*my views are my own and not representative of those institutions*
If you have difficulty Emailing me on this address or getting a reply,
send again but cc to:   chris dot evans at nottshc dot nhs dot uk
and to: c dot evans at nottingham dot ac dot uk

__
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] Intersection for two curves

2010-04-24 Thread Peter Ehlers

Well, this has seriously gotten off the original topic.

While Hadley makes some sense, it is nevertheless
sometimes the case (surely so for David, I would surmise)
that one is putting together a response to an R-help
query when a new query prompts one to temporarily abandon
the first and formulate a response to the second. One
may well prefer not to have one's workspace cleared even
though this would not lose more than the temporarily
suspended work. So, is ther *ever* a good reason to
*not* put rm(list=ls()) behind a comment char? I doubt it.

Just my 2c.

 -Peter Ehlers

On 2010-04-24 11:14, David Winsemius wrote:


On Apr 24, 2010, at 10:09 AM, hadley wickham wrote:


Perhaps, true in some respects. I am still chiseling out work using
primitive editing tools. But it still takes several minutes to load the
objects I am working on into memory and then several minutes each to
build
new models. The models still reside in memory, since I do not know any
method for automatically saving the output that would not further
increase
the time expended. Typically I am working on .Rdta files that are
400MB on
disk and then are around 4GB in RAM. I need to make a tradeoff
between the
time I would lose in saving after every  models or tabulation,
versus the
security of having everything saved. If you want to recommend methods
that
would speed those processes, I'm surely all ears.


Well it sounds like you won't lose any work, but you will lose some
time. But why not open another session of R for R-help questions?
Then you're never in any danger. I often have four or five instances
of R running for different projects.


Not a bad idea but one that I thought was unfeasible with my use of an
R-GUI. I had considering keeping a session open on my laptop.



Hadley

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/


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.




--
Peter Ehlers
University of Calgary

__
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 lmport this dataframe into R

2010-04-24 Thread Felipe Carrillo
Hi:
I need help with a dataframe(see pic attached). is a mix of dates and text.
I want to create a table either using latex function from hmisc or xtable. I
already know how to do this but the problem is getting the dataframe into R.
I don't have a reproducible example but I am hoping that the pic attachment
will make it to you. If someone is interested in helping with this task I could
send the excel file offlist. Thanks


Date First     Second Third 
2/26/2010 0 ( − ) 0 ( − ) 7,002 (33 − 39) 
2/27/2010 n (0 − 0) n (0 − 0) n (0 − 0) 
2/28/2010 357 (123 − 123) 0 ( − ) 130,342 (29 − 57) 
3/1/2010 144 (95 − 152) 99 (65 − 71) 22,741 (31 − 56) 
3/2/2010 73 (126 − 152) 0 ( − ) 8,365 (31 − 53) 
3/3/2010 43 (108 − 108) 86 (66 − 76) 5,962 (33 − 60) 
3/4/2010 n (0 − 0) n (0 − 0) n (0 − 0) 
3/5/2010 270 (101 − 140) 0 ( − ) 22,461 (30 − 61) 
3/6/2010 121 (111 − 112) 40 (66 − 66) 12,485 (31 − 55) 
3/7/2010 0 ( − ) 0 ( − ) 7,352 (31 − 56) 
3/8/2010 34 (111 − 111) 33 (74 − 74) 2,908 (32 − 48) 
3/9/2010 102 (111 − 140) 0 ( − ) 3,265 (27 − 48) 
3/10/2010 0 ( − ) 35 (66 − 66) 1,993 (30 − 55) 
3/11/2010 35 (125 − 125) 35 (70 − 70) 1,445 (33 − 62) 
Biweekly Lower 90% Confidence Interval -537 -549 35,097 
Biweekly Total 1,425 402 296,085 
Biweekly Upper 90% Confidence Interval 3,388 1,353 557,074 
Brood-year  Lower 90% Confidence Interval 2,578,499 74,306 2,249,920 
Brood Year Total 4,455,877 314,206 7,347,719 
Brood-year Upper 90% Confidence Interval 6,333,255 541,552 12,058,021 
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, 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] formatted output facilities ... was ..Oddity with internet access and R 11.0 - solved

2010-04-24 Thread David Winsemius


On Apr 24, 2010, at 8:06 AM, chrish...@psyctc.org wrote:


Ah, Dr. Who's got nothing on me!

Beg pardon, I'm recuperating from an operation and clearly more than
usually disoriented.  I meant 2.10.1 and 2.11.0 of course.

Now that I'm here, courtesy of my time slip, what I'd really love to  
see
in R 10.0.0, or even 2.12.0, is the choice to have output either in  
the

current plain text or to some simple formatting primitives that would
have default tabs & tables for matrices etc. and allow embedded
graphics.  I'd love to be able to opt to save that as HTML, XML, TeX,
RTF, ODF wihthout the complexities of Sweave, ODFWeave, R2HTML etc.

I know the complexities of Sweave etc. are child's play to numerically
and computer gifted people such as yourself Professor, and the R core
team, but for those of us who proselytise for R to mere psychologists,
doctors, psychotherapists etc., that complexity is hard and the  
hassles
of reformatting text to nice tables etc. discourages people from  
coming

across from SPSS I know.


--
> require(xtable)
Loading required package: xtable
> ?xtable

--
David (a mere doctor).


OK, back into my tardis and thanks for the correction!!

Chris

Prof Brian Ripley sent the following  at 24/04/2010 11:57:

Could you please explain how you manage to travel to the future to  
get
access to R 11.0[.0] and 10.1.0.  I'm sure the other R developers  
would

also love to know what new features we are going to implement in the
next several decades.

On Fri, 23 Apr 2010, Chris Evans wrote:

Just in case anyone else hits this.  I just installed R 11.0  
alongside R
10.1.0 (off my D: drive in D:\R\... but I think that's irrelevent)  
and
all went well, I selected my nearest CRAN mirror (Bristol is the  
one I
like) and getting the selection list seemed to take ages though it  
did

come eventually.  However, I then got an error message saying that R
couldn't make contact on port 80.  I rechecked with R 10.1.0:  
fine.  I
reinstalled R 11.0.0 and selected "internet2" instead of  
"standard" for

internet, no change.

I thought "Can't be the firewall as it wouldn't get the list of  
mirrors"

but I went into Sophos firewall and manually added R 11.0.0 and
everything is now fine.

Very odd and I'd be interested to hear if some clever person can  
explain
why R 11.0.0 was making (very slow) access to the internet to get  
the

list of mirrors but then failing (I have the 10.1.0 location in the
windows path but not, yet, the 11.0.0 one, could it be that?)

However, ultimately this seems to me to be a problem with Sophos's
firewall not R and I'm just reporting it here in case anyone else  
sees

the same and finds this helpful.

Thanks to the R team, yet again, for an amazing product!

Chris


--
Chris Evans  Skype: chris-psyctc
Consultant Psychiatrist in Psychotherapy, Notts. PDD network;
Trust Research Governance Lead and Clinical Director, Psychological
Therapies Directorate in Local Services, Nottinghamshire NHS Trust;
Professor, Psychotherapy, Nottingham University
*If I am writing from one of those roles, it will be clear.  
Otherwise*
*my views are my own and not representative of those  
institutions*
If you have difficulty Emailing me on this address or getting a  
reply,
send again but cc to:   chris dot evans at nottshc dot nhs dot  
uk

and to: c dot evans at nottingham dot ac dot uk

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








--
Chris Evans  Skype: chris-psyctc
Consultant Psychiatrist in Psychotherapy, Notts. PDD network;
Trust Research Governance Lead and Clinical Director, Psychological
 Therapies Directorate in Local Services, Nottinghamshire NHS Trust;
Professor, Psychotherapy, Nottingham University
*If I am writing from one of those roles, it will be clear. Otherwise*
*my views are my own and not representative of those institutions*
If you have difficulty Emailing me on this address or getting a reply,
send again but cc to:   chris dot evans at nottshc dot nhs dot uk
and to: c dot evans at nottingham dot ac dot uk

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


[R] Assumptions on Non-Standard F ratios

2010-04-24 Thread Sam Albers
Hello there,

I am trying to run an ANOVA model using a non-Standard F ratio. Imagine that
the treatments (treatments 1 & 2) are applied to the row not to individual
samples. Thus the row is the experimental unit. Therefore my error term in
my ANOVA table should be the error associated with with row.

The question is how do I check the assumptions of an ANOVA model when I have
a non-standard F ratio?

For this type of model I would normally use plot(model) to examine the
residuals. However this doesn't seem to work and I expect that R is looking
for residuals that don't exist. Is there some option I can change on the
plot command?

Sorry if this is simple but searching for this answer was a little difficult
as plot() has many uses. Below is an example. I am using R 2.10.1 and Ubuntu
9.04.

Thanks in advance!

Sam

x <-  runif(48, 2, 70)
data <- data.frame(x)
data$treat1 <- factor(c("ONE", "TWO", "THREE"))
data$treat2 <- factor(c("PRUNED", "UNPRUNED"))
data$row <- factor(1:12)

model <- with(data, aov(x ~ treat1 + treat2 + treat1*treat2 + Error(row)))

plot(model)
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf

-- 
*
Sam Albers
Geography Program
University of Northern British Columbia
 University Way
Prince George, British Columbia
Canada, V2N 4Z9
phone: 250 960-6777
*

[[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] Intersection for two curves

2010-04-24 Thread David Winsemius


On Apr 24, 2010, at 10:09 AM, hadley wickham wrote:


Perhaps, true in some respects. I am still chiseling out work using
primitive editing tools. But it still takes several minutes to load  
the
objects I am working on into memory and then several minutes each  
to build
new models. The models still reside in memory, since I do not know  
any
method for automatically saving the output that would not further  
increase
the time expended. Typically I am working on .Rdta files that are  
400MB on
disk and then are around 4GB in RAM. I need to make a tradeoff  
between the
time I would lose in saving after every  models or tabulation,  
versus the
security of having everything saved. If you want to recommend  
methods that

would speed those processes, I'm surely all ears.


Well it sounds like you won't lose any work, but you will lose some
time.  But why not open another session of R for R-help questions?
Then you're never in any danger.  I often have four or five instances
of R running for different projects.


Not a bad idea but one that I thought was unfeasible with my use of an  
R-GUI. I had considering keeping a session open on my laptop.




Hadley

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/


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] 2 simple question

2010-04-24 Thread Nikhil Kaza

If I understand it correctly

par(mfrow=c(2,2))
plot(x,y)
plot(y,z)
.

should work.


On Apr 24, 2010, at 8:11 AM, Jim Lemon wrote:


On 04/24/2010 02:52 AM, tamas barjak wrote:

Hi All!

I have 2 plain questions:

1.)
I know that very primitive question, but that to grant it, that the  
drawing

on the screen divided up onto which part draw

for example:


layout(matrix(1:4,ncol=2, byrow=T))

plot(x, y, ...)<--- 1. screen

plot(y, z, ...)<--- 2. screen

etc...

2.)

How I can fix it and to insert the random numbers in order for him to
generate them later

for example:

a<-runif(100)

and to insert these here--->  rnorm(100, 0, 1)


Hi Tamas,
I may not understand what you are asking, but take a look at the  
example for the "panes" function in the plotrix package.

Jim

__
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] assign value between different type: Double vs Integer

2010-04-24 Thread GUO Dong 郭东
Dear list,

just to put it in a simple way: 

i read.csv from csv file to create a gdata

then, create array gdata34

however, when making a loop for assigning gdata34[1,m]<-gdata[m,4], this is 
what happen

gdata[1,4] 's real value is 10354, however, the gdata34[1,4] turns to be 883

then i checked the type: gdata[1,4] is integer, while gdata34[1,4] is double.

Can any one give me some help on it

Many thanks in advance.

Best regards,
Dong



[[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] Oddity with internet access and R 11.0 with Sophos firewall and Windoze XP - solved (and version numbers corrected!)

2010-04-24 Thread chrishold
Ah, Dr. Who's got nothing on me!

Beg pardon, I'm recuperating from an operation and clearly more than
usually disoriented.  I meant 2.10.1 and 2.11.0 of course.

Now that I'm here, courtesy of my time slip, what I'd really love to see
in R 10.0.0, or even 2.12.0, is the choice to have output either in the
current plain text or to some simple formatting primitives that would
have default tabs & tables for matrices etc. and allow embedded
graphics.  I'd love to be able to opt to save that as HTML, XML, TeX,
RTF, ODF wihthout the complexities of Sweave, ODFWeave, R2HTML etc.

I know the complexities of Sweave etc. are child's play to numerically
and computer gifted people such as yourself Professor, and the R core
team, but for those of us who proselytise for R to mere psychologists,
doctors, psychotherapists etc., that complexity is hard and the hassles
of reformatting text to nice tables etc. discourages people from coming
across from SPSS I know.

OK, back into my tardis and thanks for the correction!!

Chris

Prof Brian Ripley sent the following  at 24/04/2010 11:57:

> Could you please explain how you manage to travel to the future to get
> access to R 11.0[.0] and 10.1.0.  I'm sure the other R developers would
> also love to know what new features we are going to implement in the
> next several decades.
> 
> On Fri, 23 Apr 2010, Chris Evans wrote:
> 
>> Just in case anyone else hits this.  I just installed R 11.0 alongside R
>> 10.1.0 (off my D: drive in D:\R\... but I think that's irrelevent) and
>> all went well, I selected my nearest CRAN mirror (Bristol is the one I
>> like) and getting the selection list seemed to take ages though it did
>> come eventually.  However, I then got an error message saying that R
>> couldn't make contact on port 80.  I rechecked with R 10.1.0: fine.  I
>> reinstalled R 11.0.0 and selected "internet2" instead of "standard" for
>> internet, no change.
>>
>> I thought "Can't be the firewall as it wouldn't get the list of mirrors"
>> but I went into Sophos firewall and manually added R 11.0.0 and
>> everything is now fine.
>>
>> Very odd and I'd be interested to hear if some clever person can explain
>> why R 11.0.0 was making (very slow) access to the internet to get the
>> list of mirrors but then failing (I have the 10.1.0 location in the
>> windows path but not, yet, the 11.0.0 one, could it be that?)
>>
>> However, ultimately this seems to me to be a problem with Sophos's
>> firewall not R and I'm just reporting it here in case anyone else sees
>> the same and finds this helpful.
>>
>> Thanks to the R team, yet again, for an amazing product!
>>
>> Chris
>>
>>
>> -- 
>> Chris Evans  Skype: chris-psyctc
>> Consultant Psychiatrist in Psychotherapy, Notts. PDD network;
>> Trust Research Governance Lead and Clinical Director, Psychological
>>  Therapies Directorate in Local Services, Nottinghamshire NHS Trust;
>> Professor, Psychotherapy, Nottingham University
>> *If I am writing from one of those roles, it will be clear. Otherwise*
>> *my views are my own and not representative of those institutions*
>> If you have difficulty Emailing me on this address or getting a reply,
>> send again but cc to:   chris dot evans at nottshc dot nhs dot uk
>> and to: c dot evans at nottingham dot ac dot uk
>>
>> __
>> 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.
>>
> 




-- 
Chris Evans  Skype: chris-psyctc
Consultant Psychiatrist in Psychotherapy, Notts. PDD network;
Trust Research Governance Lead and Clinical Director, Psychological
  Therapies Directorate in Local Services, Nottinghamshire NHS Trust;
Professor, Psychotherapy, Nottingham University
*If I am writing from one of those roles, it will be clear. Otherwise*
*my views are my own and not representative of those institutions*
If you have difficulty Emailing me on this address or getting a reply,
send again but cc to:   chris dot evans at nottshc dot nhs dot uk
and to: c dot evans at nottingham dot ac dot uk

__
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() and highlighted values

2010-04-24 Thread Sebastian Bergmann
Am 24.04.2010 16:01, schrieb Marc Schwartz:
> If you really want the values on top of the bars, use text() instead
> of mtext(). You will also need to increase the max value of the y axis 
> to make room for the labels using the ylim argument in barplot():
> costs <- c(1, 5, 10, 20, 50, 150)
> 
> mp <- barplot(costs, ylab = "Relative cost of a bugfix", 
>   names.arg = c("Requirements", "Design", "Code", "Developer 
> Tests", 
> "Acceptance Tests", "Operations"),
>   cex.names=0.6, ylim = c(0, max(costs) * 1.2))
> 
> text(mp, costs, labels = costs, pos = 3)

 This is exactly what I needed, thank you so much!

-- 
Sebastian BergmannCo-Founder and Principal Consultant
http://sebastian-bergmann.de/   http://thePHP.cc/

__
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] 'geepack' and 'gee' package outputs

2010-04-24 Thread cmc

Hi, having used both the gee pacakge and the geepack package, i am unsure of
how to interpret the results.

Here are the results from the geeglm function from the geepack package

> gee2<-geeglm(data$erythema~data$product, data = data, id=subject,
> family=binomial, corstr="independence")
Warning message:
In model.response(mf, "numeric") :
  using type="numeric" with a factor response will be ignored
> summary(gee2)

Call:
geeglm(formula = data$erythema ~ data$product, family = binomial, 
data = data, id = subject, corstr = "independence")

 Coefficients:
Estimate   Std.err Wald Pr(>|W|)
(Intercept) 3.14e+16  5.05e+14 3864   <2e-16 ***
data$product2   3.69e+16  8.12e+14 2062   <2e-16 ***
data$product3  -2.67e+16  4.67e+14 3267   <2e-16 ***
data$product4  -2.59e+16  5.04e+14 2642   <2e-16 ***
data$product5  -1.41e+16  5.30e+14  710   <2e-16 ***
data$product6  -2.59e+16  4.96e+14 2722   <2e-16 ***
data$product7   1.55e+17  2.07e+15 5646   <2e-16 ***
data$product8   2.90e+16  7.87e+14 1362   <2e-16 ***
data$product9  -2.43e+16  4.79e+14 2584   <2e-16 ***
data$product10 -2.04e+16  5.05e+14 1632   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Estimated Scale Parameters:
Estimate  Std.err
(Intercept) 5.51e+15 5.58e+38

Correlation: Structure = independenceNumber of clusters:   33   Maximum
cluster size: 40 
>


And here are the results for the gee function from the gee package

> gee(data$erythema~data$product, data = data, id=subject, family=binomial,
> corstr="independence")
Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27
running glm to get initial regression estimate
   (Intercept)  data$product2  data$product3  data$product4  data$product5 
data$product6 
-1.181  0.488 -1.863 -1.863 -0.800  
  
-1.701 
 data$product7  data$product8  data$product9 data$product10 
 1.456  0.782 -1.863 -1.121 
Error in gee(data$erythema ~ data$product, data = data, id = subject,  : 
  Cgee: error: logistic model for probability has fitted value very close to
1.
estimates diverging; iteration terminated.
> 


I know from doing multinomial logit regression that product 7 greatly
increases levels of erythema, and products 2 and 8 have a slight increase in
erythema. However, i am unsure how to read the above results and be able to
present them to other people.

Any help much appreciated. 


-- 
View this message in context: 
http://r.789695.n4.nabble.com/geepack-and-gee-package-outputs-tp2063454p2063454.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] bigmemory package woes

2010-04-24 Thread zerdna

Jay, thanks a bunch. New package seems to work just fine and great
improvement in docs by the way:). I tried the same example, new version
deals with it smoothly. In terms of usefulness of my sample code -- sure i
am writing same stuff to disk many times with only one handle -- it was some
toy code to demonstrate type of issues with saving data repeatedly i
encountered in the real code. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/bigmemory-package-woes-tp2062996p2063419.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] assign value between different type: Double vs Integer

2010-04-24 Thread Sarah Goslee
Ah, you didn't provide a complete description of
your problem. gdata is a factor. You need to
read about converting factors to numeric, or
perhaps reconsider your method of creating or
importing gdata.

as.numeric(somefactor) does not extract the
printed value, it extracts the *order of the factor*.

> somefactor <- as.factor(c(1,2,6,4))
> somefactor
[1] 1 2 6 4
Levels: 1 2 4 6
> as.numeric(somefactor)
[1] 1 2 4 3
> as.numeric(as.character(somefactor))
[1] 1 2 6 4
>
>
> somefactor <- as.factor(c("a", "b", "d", "c"))
> somefactor
[1] a b d c
Levels: a b c d
> as.numeric(somefactor)
[1] 1 2 4 3


Please read the posting guide, and follow the
instructions therein for providing a clear and
complete question. Plus, I think this is a FAQ.

Sarah

On Sat, Apr 24, 2010 at 10:50 AM, Dong GUO  wrote:
> Thanks, Sarah.
> the loop is all right. this is what I just experimented.
> and when trying to do as.numeric (ggg), and I got the 883 coming out, which
> basically is the point here. somehow in the process, it transformed the
> 10354 to 883 as a different a type from Double to Numeric...
> Dont know how this can happen..
>



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


[R] Fwd: assign value between different type: Double vs Integer

2010-04-24 Thread Dong GUO
-- Forwarded message --
From: Dong GUO 
Date: Sat, Apr 24, 2010 at 4:50 PM
Subject: Re: [R] assign value between different type: Double vs Integer
To: Sarah Goslee 


Thanks, Sarah.
the loop is all right. this is what I just experimented.
and when trying to do as.numeric (ggg), and I got the 883 coming out, which
basically is the point here. somehow in the process, it transformed the
10354 to 883 as a different a type from Double to Numeric...
Dont know how this can happen..


> gdata[1,5]
[1] 10354
57290 Levels: -1234 -294 -5 -534 ... 0 1 10 100 1000 1 10 ... 
> typeof(gdata[1,5])
[1] "integer"
> ggg<-gdata[1,5]
> ggg
[1] 10354
57290 Levels: -1234 -294 -5 -534 ... 0 1 10 100 1000 1 10 ... 
> integer(ggg)
 [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[36] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[71] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[106] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[141] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[176] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[211] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[246] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[281] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[316] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[351] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[386] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[421] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[456] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[491] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[526] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[561] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[596] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[631] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[666] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[701] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[736] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[771] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[806] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[841] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[876] 0 0 0 0 0 0 0 0
> ggg[1]
[1] 10354
57290 Levels: -1234 -294 -5 -534 ... 0 1 10 100 1000 1 10 ... 

> as.double(ggg)
[1] 883
> as.numeric(ggg)
[1] 883
> as.integer(ggg)
[1] 883
> typeof(ggg)
[1] "integer"
> ggg
[1] 10354
57290 Levels: -1234 -294 -5 -534 ... 0 1 10 100 1000 1 10 ... 
> as.numeric(ggg)
[1] 883
> ggg[0]
factor(0)
57290 Levels: -1234 -294 -5 -534 ... 0 1 10 100 1000 1 10 ... 
> factor(ggg)
[1] 10354
Levels: 10354
> aaa<-factor(ggg)
> aaa
[1] 10354
Levels: 10354
> typeof(aaa)
[1] "integer"
> aaa<-as.numeric(factor(ggg))
> aaa
[1] 1
> aaa
[1] 1

>

On Sat, Apr 24, 2010 at 4:45 PM, Sarah Goslee 
wrote:
> On Sat, Apr 24, 2010 at 9:31 AM, Dong GUO  wrote:
>> Dear list,
>>
>> just to put it in a simple way:
>>
>> i read.csv from csv file to create a gdata
>>
>> then, create array gdata34
>>
>> however, when making a loop for assigning gdata34[1,m]<-gdata[m,4],
>> this is what happen
>
> So you assigned (m == 4)
>
> gdata34[1, 4] <- gdata[4, 4]
>
>
>> gdata[1,4] 's real value is 10354, however, the gdata34[1,4] turns to be
883
>
> But now you expect
>  gdata[1,4] == gdata34[1,4]
>
> If your loop description is correct,
> gdata34[1,4] <- gdata[4, 4]
> and
> gdata34[1,1] <- gdata[1,4]
>
> Something is wrong either in your description or
> your check. I don't think it has anything to do with
> storage mode.
>
> Sarah
>
>> then i checked the type: gdata[1,4] is integer, while gdata34[1,4] is
double.
>>
>> Can any one give me some help on it
>>
>> Many thanks in advance.
>>
>> Best regards,
>> Dong
>>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>

[[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] assign value between different type: Double vs Integer

2010-04-24 Thread Sarah Goslee
On Sat, Apr 24, 2010 at 9:31 AM, Dong GUO  wrote:
> Dear list,
>
> just to put it in a simple way:
>
> i read.csv from csv file to create a gdata
>
> then, create array gdata34
>
> however, when making a loop for assigning gdata34[1,m]<-gdata[m,4],
> this is what happen

So you assigned (m == 4)

gdata34[1, 4] <- gdata[4, 4]


> gdata[1,4] 's real value is 10354, however, the gdata34[1,4] turns to be 883

But now you expect
 gdata[1,4] == gdata34[1,4]

If your loop description is correct,
gdata34[1,4] <- gdata[4, 4]
and
gdata34[1,1] <- gdata[1,4]

Something is wrong either in your description or
your check. I don't think it has anything to do with
storage mode.

Sarah

> then i checked the type: gdata[1,4] is integer, while gdata34[1,4] is double.
>
> Can any one give me some help on it
>
> Many thanks in advance.
>
> Best regards,
> Dong
>
-- 
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] DICE Coefficient of similarity measure

2010-04-24 Thread Shubha Vishwanath Karanth
Just wrote a small piece of code to do so. Thanks.


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Shubha Vishwanath Karanth
Sent: Saturday, April 24, 2010 6:28 PM
To: r-help@r-project.org; r-h...@stat.math.ethz.ch
Cc: gabor.csa...@unil.ch
Subject: [R] DICE Coefficient of similarity measure

Hi,

 

I wanted the DICE coefficient (similarity measure for binary variables)
to be calculated in R and found that the "igraph" package has the option
of "similarity.dice" to do this. But, for this command, the input object
should be an igraph object. But, I have a dataframe of columns
containing 1's and 0's. Can I convert this dataframe into an igraph
object, so that the DICE coefficient can be reproduced? Or does any
other packages gives the DICE coefficient?

 

Thanks,

Shubha

 

This e-mail may contain confidential and/or privileged
i...{{dropped:13}}

__
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.
This e-mail may contain confidential and/or privileged i...{{dropped:10}}

__
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] table command

2010-04-24 Thread Marc Schwartz
On Apr 24, 2010, at 8:59 AM, Shubha Vishwanath Karanth wrote:

> Hi,
> 
> 
> 
> Let s be a dataframe. 
> 
> 
> 
>> s
> 
>   A B C
> 
>   0 0 1
> 
>   1 0 1
> 
>   1 0 1
> 
>   0 0 1
> 
>   1 0 1
> 
>   0 1 1
> 
>   0 1 1
> 
>   0 1 1
> 
>   0 0 1
> 
> 
> 
>> tab1=table(s[,c(1,2)])
> 
>> tab1
> 
>   B
> 
> A   0 1
> 
>  0 3 3
> 
>  1 3 0
> 
> 
> 
>> tab2=table(s[,c(1,3)])
> 
>> tab2
> 
>   C
> 
> A   1
> 
>  0 6
> 
>  1 3
> 
> 
> 
> 
> 
> The problem is I need to access frequency corresponding to (0,0).
> tab1[1] will give me the correct value while tab2[1] will not give the
> frequency which I expected. So, is there a possibility in the table
> command to have the order of tab1 and tab2 being equal? (here 2*2). May
> be by filling in the appropriate value as 0 or NA?
> 
> 
> 
> Thanks,
> 
> Shubha


In this case, 'C' has no 0's, so that value is not considered in the tabulation 
in the second table. 

If you coerce each column to a factor with common levels, then you can obtain 
consistent formats for the output of table. Even though there are no 0's in 
'C', that 'C' as a factor now has levels of 0 and 1, they will both be included 
in the table() output.


s.new <- data.frame(lapply(s, factor, levels = 0:1))

> str(s.new)
'data.frame':   9 obs. of  3 variables:
 $ A: Factor w/ 2 levels "0","1": 1 2 2 1 2 1 1 1 1
 $ B: Factor w/ 2 levels "0","1": 1 1 1 1 1 2 2 2 1
 $ C: Factor w/ 2 levels "0","1": 2 2 2 2 2 2 2 2 2

> s.new
  A B C
1 0 0 1
2 1 0 1
3 1 0 1
4 0 0 1
5 1 0 1
6 0 1 1
7 0 1 1
8 0 1 1
9 0 0 1


> table(s.new[, c(1, 2)])
   B
A   0 1
  0 3 3
  1 3 0

> table(s.new[, c(1, 3)])
   C
A   0 1
  0 0 6
  1 0 3


See ?factor, ?lapply and ?data.frame

HTH,

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] Intersection for two curves

2010-04-24 Thread hadley wickham
> Perhaps, true in some respects. I am still chiseling out work using
> primitive editing tools. But it still takes several minutes to load the
> objects I am working on into memory and then several minutes each to build
> new models. The models still reside in memory, since I do not know any
> method for automatically saving the output that would not further increase
> the time expended. Typically I am working on .Rdta files that are 400MB on
> disk and then are around 4GB in RAM. I need to make a tradeoff between the
> time I would lose in saving after every  models or tabulation, versus the
> security of having everything saved. If you want to recommend methods that
> would speed those processes, I'm surely all ears.

Well it sounds like you won't lose any work, but you will lose some
time.  But why not open another session of R for R-help questions?
Then you're never in any danger.  I often have four or five instances
of R running for different projects.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
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] Intersection for two curves

2010-04-24 Thread hadley wickham
>> If clearing out your workspace destroys *any* work, then something is
>> seriously wrong with your workflow.
>>
>
> Yes, of course.  Lets all post viruses to run on each others'
> machines.  That will teach those users who don't run antivirus and
> backup software between each posting to r-help.  Also if they are
> running large data sets whose processing takes time to recreate they
> should be checkpointing everything at all points during the
> development.  And what about those misguided Bayesians who are running
> those long MCMC simulations.  Let them just rerun them from the start.
>  Its really all their fault anyways.  They should have known better.
> :)

If you are running random R code from the internet in the same R
session that you are performing important work, then you deserve
everything you get!

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
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] doBy and Hmisc on R version 2.11.0

2010-04-24 Thread Uwe Ligges
The reason why Hmisc is not available from CRAN can be seen on the 
package check summaries. Particularly for Hmisc:


http://cran.r-project.org/web/checks/check_results_Hmisc.html

which fails everywehre now. The maintainer has been notified by 
automated messages.


We do not ship binaries of packages that do not pass the checks under a 
new R release.



Best wishes,
Uwe Ligges





On 23.04.2010 21:44, David Winsemius wrote:


On Apr 23, 2010, at 3:26 PM, Juliet Hannah wrote:


I should have mentioned that I also tried:


install.packages("Hmisc")

Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
package ‘Hmisc’ is not available


If you have the necessary tools and install.packages("Hmisc",
type="source") also produces an error (as it apparently did in the most
recent CRAN package check), then you need to contact the package
maintainer who is listed as Charles Dupont, but generally Frank Harrell
is watching this mailing list, so he may already know about the problem.



__
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() and highlighted values

2010-04-24 Thread Marc Schwartz
On Apr 24, 2010, at 5:44 AM, Sebastian Bergmann wrote:

> Hello!
> 
> I started using R today to produce a bar chart that I can use in LaTeX.
> 
> Here is what I have got so far:
> 
>   pdf("bugfix_costs.pdf")
>   costs <- c(1, 5, 10, 20, 50, 150)
>   barplot(costs,
>   ylab="Relative cost of a bugfix",
>   names.arg=c("Requirements", "Design", "Code",
>   "Developer Tests", "Acceptance Tests", "Operations"),
>   cex.names=0.6
>  )
>   dev.off()
>   q()
> 
> What I am missing from the produced chart is "highlighted values" as in
> http://www.slideshare.net/spriebsch/die-5-goldenen-oopregeln-fr-php, for
> instance. Basically what I need is to put text above each of the bars.
> Is that possible?
> 
> Thanks!


You will find that most folks here will suggest that you not put the values on 
top of the bars, as they alter the visual perception of the graphic. A better 
approach is to put them below each bar on the x axis. Others will suggest that 
you use a ?dotchart instead of a barplot.

A key feature to note is that barplot() returns the x axis values of the bar 
midpoints, which enables the alignment of annotations:

costs <- c(1, 5, 10, 20, 50, 150)

mp <- barplot(costs, ylab = "Relative cost of a bugfix", 
  names.arg = c("Requirements", "Design", "Code", "Developer 
Tests", 
"Acceptance Tests", "Operations"),
  cex.names = 0.6)

mtext(1, at = mp, text = costs, cex = 0.6, line = 2)


See ?mtext for more information


If you really want the values on top of the bars, use text() instead of 
mtext(). You will also need to increase the max value of the y axis to make 
room for the labels using the ylim argument in barplot():


costs <- c(1, 5, 10, 20, 50, 150)

mp <- barplot(costs, ylab = "Relative cost of a bugfix", 
  names.arg = c("Requirements", "Design", "Code", "Developer 
Tests", 
"Acceptance Tests", "Operations"),
  cex.names=0.6, ylim = c(0, max(costs) * 1.2))

text(mp, costs, labels = costs, pos = 3)


See ?text for more information.

HTH,

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.


[R] table command

2010-04-24 Thread Shubha Vishwanath Karanth
Hi,

 

Let s be a dataframe. 

 

> s

   A B C

   0 0 1

   1 0 1

   1 0 1

   0 0 1

   1 0 1

   0 1 1

   0 1 1

   0 1 1

   0 0 1

 

> tab1=table(s[,c(1,2)])

> tab1

   B

A   0 1

  0 3 3

  1 3 0

 

> tab2=table(s[,c(1,3)])

> tab2

   C

A   1

  0 6

  1 3

 

 

The problem is I need to access frequency corresponding to (0,0).
tab1[1] will give me the correct value while tab2[1] will not give the
frequency which I expected. So, is there a possibility in the table
command to have the order of tab1 and tab2 being equal? (here 2*2). May
be by filling in the appropriate value as 0 or NA?

 

Thanks,

Shubha

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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 Correlation coefficient (spearman, Kenall)

2010-04-24 Thread Ista Zahn
Bootstrap? You could start here:
http://www.statmethods.net/advstats/bootstrapping.html

-Ista

On Sat, Apr 24, 2010 at 6:07 AM, pauls182  wrote:
>
>
> Hi,
>
> I'm currently trying to find/define a relationship between one dependent and
> several independant variables.
> The problem is that i cannot use the normal multiple regression/correlation
> in Spss because the data is not normal distributed.
>
> i calculated the spearman roh and Kendalls tau Correlation and also some
> partial correlations in R.
> Now i wanna find out the the multiple correlation coeffcient for Kendalls
> Tau and spearmans roh and check if it is signifikant.
>
> unfortunately i cannot find a way to do that in R.
>
> any sugestions?
>
> thank you in advance
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Multiple-Correlation-coefficient-spearman-Kenall-tp2063314p2063314.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.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.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] Intersection for two curves

2010-04-24 Thread David Winsemius


On Apr 24, 2010, at 9:05 AM, hadley wickham wrote:


rm(list=ls())


PLEASE, DON'T DO THAT. Or rather you can do it in your  
workspace but
don't post it. It's not fair to a person who may not read your code  
line by
line before pasting it into their workspace and having it wiped  
out. Do you
expect us to completely clear out our workspaces just so we can  
answer your
questions? At the very least comment it out so it doesn't blow away  
half a

days work for someone who is trying to be helpful.


If clearing out your workspace destroys *any* work, then something is
seriously wrong with your workflow.


Perhaps, true in some respects. I am still chiseling out work using  
primitive editing tools. But it still takes several minutes to load  
the objects I am working on into memory and then several minutes each  
to build new models. The models still reside in memory, since I do not  
know any method for automatically saving the output that would not  
further increase the time expended. Typically I am working on .Rdta  
files that are 400MB on disk and then are around 4GB in RAM. I need to  
make a tradeoff between the time I would lose in saving after every  
 models or tabulation, versus the security of having everything  
saved. If you want to recommend methods that would speed those  
processes, I'm surely all ears.




Hadley

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/


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] Intersection for two curves

2010-04-24 Thread Gabor Grothendieck
On Sat, Apr 24, 2010 at 9:05 AM, hadley wickham  wrote:
>>> rm(list=ls())
>>
>> PLEASE, DON'T DO THAT. Or rather you can do it in your workspace but
>> don't post it. It's not fair to a person who may not read your code line by
>> line before pasting it into their workspace and having it wiped out. Do you
>> expect us to completely clear out our workspaces just so we can answer your
>> questions? At the very least comment it out so it doesn't blow away half a
>> days work for someone who is trying to be helpful.
>
> If clearing out your workspace destroys *any* work, then something is
> seriously wrong with your workflow.
>

Yes, of course.  Lets all post viruses to run on each others'
machines.  That will teach those users who don't run antivirus and
backup software between each posting to r-help.  Also if they are
running large data sets whose processing takes time to recreate they
should be checkpointing everything at all points during the
development.  And what about those misguided Bayesians who are running
those long MCMC simulations.  Let them just rerun them from the start.
 Its really all their fault anyways.  They should have known better.
:)

__
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] assign value between different type: Double vs Integer

2010-04-24 Thread Dong GUO
Dear list,

just to put it in a simple way:

i read.csv from csv file to create a gdata

then, create array gdata34

however, when making a loop for assigning gdata34[1,m]<-gdata[m,4],
this is what happen

gdata[1,4] 's real value is 10354, however, the gdata34[1,4] turns to be 883

then i checked the type: gdata[1,4] is integer, while gdata34[1,4] is double.

Can any one give me some help on it

Many thanks in advance.

Best regards,
Dong

__
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] Intersection for two curves

2010-04-24 Thread hadley wickham
>> rm(list=ls())
>
> PLEASE, DON'T DO THAT. Or rather you can do it in your workspace but
> don't post it. It's not fair to a person who may not read your code line by
> line before pasting it into their workspace and having it wiped out. Do you
> expect us to completely clear out our workspaces just so we can answer your
> questions? At the very least comment it out so it doesn't blow away half a
> days work for someone who is trying to be helpful.

If clearing out your workspace destroys *any* work, then something is
seriously wrong with your workflow.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
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] DICE Coefficient of similarity measure

2010-04-24 Thread Shubha Vishwanath Karanth
Hi,

 

I wanted the DICE coefficient (similarity measure for binary variables)
to be calculated in R and found that the "igraph" package has the option
of "similarity.dice" to do this. But, for this command, the input object
should be an igraph object. But, I have a dataframe of columns
containing 1's and 0's. Can I convert this dataframe into an igraph
object, so that the DICE coefficient can be reproduced? Or does any
other packages gives the DICE coefficient?

 

Thanks,

Shubha

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
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] Intersection for two curves

2010-04-24 Thread David Winsemius


On Apr 24, 2010, at 8:10 AM, Muhammad Rahiz wrote:


Thanks again David,

I've made the changes. The optimize() function works alright but it  
does not give me the intersection. I suspect it must have to do with  
the user-defined function which I am totally clueless and am  
inexperienced with. Mind showing the way.


Thanks again and thanks for your patience...

*   s1 cm
10 0.57223196
2   10 0.33110049
3   20 0.11163181
4   30 0.10242237
5   40 0.09254315
6   50 0.02739370
7   60 0.02567137
8   70 0.02492397
9   80 0.03206637
10  90 0.02487381
11 100 0.01747584
12 110 0.15977533
13 120 0.13317708

x<- read.table("test.data.txt",header=TRUE)
ds <- x[,2] ; cr <- x[,3]
plot(ds,cr)

fc <- function(x,a,b){a*exp(-b*x)}

# Needed to split that line

  fm <- nls(cr ~ fc(ds,a,b),start=c(a=1,b=0))
co <- coef(fm)
curve(fc(x,a=co[1],b=co[2]),add=TRUE,col="red",lwd=1.5)

n <- 1/2.71

int <- function(x) {coef(fm)[1] + x*coef(fm)[2]}
 in1 <- optimize(f=function(x) abs(int(x)-n),c(0,120))


# There is still no function in that call to optimize. Need fc(x,  
a=a,b=b)

# This was pointed out in my last reply:

in1 <- optimize(f=function(x) {abs( fc(x, a=co[1], b=co[2]) -n)}, c(0,  
120) )




abline(v=in1$minimum,col="red",lty=2)
abline(h=n,col="red",lty=2)

Muhammad

--
David.


David Winsemius wrote:

On Apr 23, 2010, at 8:06 PM, Muhammad Rahiz wrote:



Thanks David & Peter,

The locator() works but not practical as I have to repeat the   
process many times.


Does the code works on linear regression only?



Should work for any process that can produce a function.


When i tried to find the intersection at a non-linear curve, i  
get  the following error

Error in optimize(f = function(x) abs(xyf(ds) - n), c(0, 13)) :
invalid function value in 'optimize'



Why did you did not change the name of the function?
And the code below would not have produced that error, so why did  
you  post it?




I'd like to know what the error means and how I can correct it.

I have my sample data and code as follows;


*   s1 cm
10 0.57223196
2   10 0.33110049
3   20 0.11163181
4   30 0.10242237
5   40 0.09254315
6   50 0.02739370
7   60 0.02567137
8   70 0.02492397
9   80 0.03206637
10  90 0.02487381
11 100 0.01747584
12 110 0.15977533
13 120 0.13317708

rm(list=ls())



PLEASE, DON'T DO THAT. Or rather you can do it in your  
workspace  but don't post it. It's not fair to a person who may not  
read your  code line by line before pasting it into their workspace  
and having it  wiped out. Do you expect us to completely clear out  
our workspaces  just so we can answer your questions? At the very  
least comment it out  so it doesn't blow away half a days work for  
someone who is trying to  be helpful.




x<- read.table("test.data.txt",header=TRUE)

ds <- x[,2] # distance
cr <- x[,3] # correlation values
plot(ds,cr)
n <- 1/2.71
abline(h=n)

fc <- function(x,a,b){a*exp(-b*x)}# where a & b are constants
fm <- nls(cr ~ fc(ds,a,b),start=c(a=1,b=0))
co <- coef(fm)





curve(fc(x,a=co[1],b=co[2]),add=TRUE,col="red",lwd=1.5)

int <- function(x) coef(fm)[1] + x*coef(fm)[2]
in1 <- optimize(f=function(x) c(0,120), abs(int(ds)-n))



Huh? I don't really see anything in there that would be a function.  
I  think you would need to specify "fc" and coefficient values for  
"a"  and "b".




abline(v=in1$minimize)   # 



I think you would use in1$minimum once you get this far.



thanks,
Muhammad




On 04/23/2010 07:32 PM, Peter Ehlers wrote:


On 2010-04-23 11:46, David Winsemius wrote:



On Apr 23, 2010, at 1:06 PM, Muhammad Rahiz wrote:



Does anyone know of a method that I can get the intersection   
where the

red and blue curves meet i.e. the value on the x-axis?

x<- 1:10
y<- 10:1
plot(x,y)
abline(lm(y~x),col="blue")
abline(h=2.5,col="red")



Two ways :

>  xy<- lm(y~x)
>  xyf<- function(x) coef(xy)[1] +x*coef(xy)[2]

# absolute difference
>  optimise(f=function(x) abs(xyf(x)-2.5), c(1,10) )
$minimum
[1] 8.49998

$objective
(Intercept)
1.932015e-05

#N minimize squared difference
>  optimise(f=function(x) (xyf(x)-2.5)^2, c(1,10) )
$minimum
[1] 8.5

$objective
(Intercept)
3.155444e-30




Another (crude) way is to use locator(). I usually maximize
the plot window for this.





David Winsemius, MD
West Hartford, CT




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] basic table statistics

2010-04-24 Thread Jim Lemon

On 04/24/2010 05:48 AM, Maxim wrote:

Hi,


I have a very simple question, but I'm obviously not able to solve the
problem on my own.


I have a data.frame like


sample(c("A","B","C"),size=20,replace = T)->type

rnorm(20)->value

data.frame(ty=type,val=value)->test


There must be some built in functions, that will do some descriptive
statistics with tabular output, in the end I like to have something like


  number of samples mean sd .

A 5

B 9

C 6



So I need a function that counts the number of  occurrences of factors in
type and then does something like the *summary* function, but factor
specific.


I tried:


vector()->Median

vector()->SD

vector()->Mean


as.data.frame(table(type))->int


for (count in c(1:(nrow(int

  {

subset(test, ty==as.character(int$type[count])) ->  subtest

median(subtest$val)->Median[count]

sd(subtest$val)->SD[count]

mean(subtest$val)->Mean[count]

}


cbind(int,Median,SD,Mean)


This works, but: isn't this much too complicated, I bet there is such
functionality embedded in the base packages, but I cannot find it.



Hi Maxim,
Look at:

describe (psych)
describe (Hmisc)
describe (prettyR)

and you will probably find something useful.

Jim

__
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] Intersection for two curves

2010-04-24 Thread Muhammad Rahiz

Thanks again David,

I've made the changes. The optimize() function works alright but it does 
not give me the intersection. I suspect it must have to do with the 
user-defined function which I am totally clueless and am inexperienced 
with. Mind showing the way.


Thanks again and thanks for your patience...

*   s1 cm
10 0.57223196
2   10 0.33110049
3   20 0.11163181
4   30 0.10242237
5   40 0.09254315
6   50 0.02739370
7   60 0.02567137
8   70 0.02492397
9   80 0.03206637
10  90 0.02487381
11 100 0.01747584
12 110 0.15977533
13 120 0.13317708

x<- read.table("test.data.txt",header=TRUE)
ds <- x[,2] ; cr <- x[,3]
plot(ds,cr)

fc <- function(x,a,b){a*exp(-b*x)}   
fm <- nls(cr ~ fc(ds,a,b),start=c(a=1,b=0))

co <- coef(fm)
curve(fc(x,a=co[1],b=co[2]),add=TRUE,col="red",lwd=1.5)

n <- 1/2.71

int <- function(x) {coef(fm)[1] + x*coef(fm)[2]}
in1 <- optimize(f=function(x) abs(int(x)-n),c(0,120))

abline(v=in1$minimum,col="red",lty=2)
abline(h=n,col="red",lty=2)

Muhammad



David Winsemius wrote:

On Apr 23, 2010, at 8:06 PM, Muhammad Rahiz wrote:

  

Thanks David & Peter,

The locator() works but not practical as I have to repeat the  
process many times.


Does the code works on linear regression only?



Should work for any process that can produce a function.

  
When i tried to find the intersection at a non-linear curve, i get  
the following error

Error in optimize(f = function(x) abs(xyf(ds) - n), c(0, 13)) :
 invalid function value in 'optimize'



Why did you did not change the name of the function?
And the code below would not have produced that error, so why did you  
post it?


  

I'd like to know what the error means and how I can correct it.

I have my sample data and code as follows;


*   s1 cm
10 0.57223196
2   10 0.33110049
3   20 0.11163181
4   30 0.10242237
5   40 0.09254315
6   50 0.02739370
7   60 0.02567137
8   70 0.02492397
9   80 0.03206637
10  90 0.02487381
11 100 0.01747584
12 110 0.15977533
13 120 0.13317708

rm(list=ls())



PLEASE, DON'T DO THAT. Or rather you can do it in your workspace  
but don't post it. It's not fair to a person who may not read your  
code line by line before pasting it into their workspace and having it  
wiped out. Do you expect us to completely clear out our workspaces  
just so we can answer your questions? At the very least comment it out  
so it doesn't blow away half a days work for someone who is trying to  
be helpful.


  

x<- read.table("test.data.txt",header=TRUE)

ds <- x[,2] # distance
cr <- x[,3] # correlation values
plot(ds,cr)
n <- 1/2.71
abline(h=n)

fc <- function(x,a,b){a*exp(-b*x)}# where a & b are constants
fm <- nls(cr ~ fc(ds,a,b),start=c(a=1,b=0))
co <- coef(fm)



  

curve(fc(x,a=co[1],b=co[2]),add=TRUE,col="red",lwd=1.5)

int <- function(x) coef(fm)[1] + x*coef(fm)[2]
in1 <- optimize(f=function(x) c(0,120), abs(int(ds)-n))



Huh? I don't really see anything in there that would be a function. I  
think you would need to specify "fc" and coefficient values for "a"  
and "b".


  

abline(v=in1$minimize)   # 



I think you would use in1$minimum once you get this far.

  

thanks,
Muhammad




On 04/23/2010 07:32 PM, Peter Ehlers wrote:


On 2010-04-23 11:46, David Winsemius wrote:

  

On Apr 23, 2010, at 1:06 PM, Muhammad Rahiz wrote:



Does anyone know of a method that I can get the intersection  
where the

red and blue curves meet i.e. the value on the x-axis?

x<- 1:10
y<- 10:1
plot(x,y)
abline(lm(y~x),col="blue")
abline(h=2.5,col="red")

  

Two ways :

 >  xy<- lm(y~x)
 >  xyf<- function(x) coef(xy)[1] +x*coef(xy)[2]

# absolute difference
 >  optimise(f=function(x) abs(xyf(x)-2.5), c(1,10) )
$minimum
[1] 8.49998

$objective
(Intercept)
1.932015e-05

#N minimize squared difference
 >  optimise(f=function(x) (xyf(x)-2.5)^2, c(1,10) )
$minimum
[1] 8.5

$objective
(Intercept)
3.155444e-30




Another (crude) way is to use locator(). I usually maximize
the plot window for this.


  


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] 2 simple question

2010-04-24 Thread Jim Lemon

On 04/24/2010 02:52 AM, tamas barjak wrote:

Hi All!

I have 2 plain questions:

1.)
I know that very primitive question, but that to grant it, that the drawing
on the screen divided up onto which part draw

for example:


layout(matrix(1:4,ncol=2, byrow=T))

plot(x, y, ...)<--- 1. screen

plot(y, z, ...)<--- 2. screen

etc...

2.)

How I can fix it and to insert the random numbers in order for him to
generate them later

for example:

a<-runif(100)

and to insert these here--->  rnorm(100, 0, 1)


Hi Tamas,
I may not understand what you are asking, but take a look at the example 
for the "panes" function in the plotrix package.

Jim

__
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] 3D Plot

2010-04-24 Thread Jim Lemon

On 04/23/2010 10:51 PM, Ariane C. Böhm wrote:

Hi guys of the R-Help-Team!First of all - you do a great job!I've found a lot of your mails in the internet. So I thought it would be a
good idea to ask you a question about R.R is new to me, so sorry,
if the question is too simple :)I have a matrix.I can make a
2D Heatmap of this matrix.My question:Can I also make a 3D
Heatmap of this matrix - so the third parameter should the value in the
matrix.My first thought was :> mat<- read.table(file
="AvgMatrix.mat")> x<-as.matrix(mat)> hv
<- heatmap.2 (x, col=topo.colors, Colv = NA, Rowv = NA,
main="AvgMatrix", xlab="Columns", ylab="Rows",
key=TRUE, trace ="none")But that is just a 2D heatmap.Thanks for your helpAriane


Hi Ariane,
The color2D.matplot function can almost do this, as there is an option 
to display the numeric values within the cells. Now with the small 
kludge of adding an extra argument:


x3=NULL

and changing the following lines:

   if(show.values)
text(sort(rep((1:xdim[2])-0.5,xdim[1])),
 rep(seq(xdim[1]-0.5,0,by=-1),xdim[2]),
 round(x,show.values),col=vcol,cex=vcex)
  }

to this:

   if(show.values)
if(is.null(x3)) xval<-x
else xval<-x3
text(sort(rep((1:xdim[2])-0.5,xdim[1])),
 rep(seq(xdim[1]-0.5,0,by=-1),xdim[2]),
 round(xval,show.values),col=vcol,cex=vcex)
  }

You may have a solution to your plotting problem.

Of course this will do nothing at all for your problem of sending HTML 
formatted messages.


Jim

__
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] bigmemory package woes

2010-04-24 Thread Jay Emerson
Zerdna,

Please note that the CRAN version 3.12 is about
to be replaced by a new cluster of packages now on R-Forge; we consider the
new bigmemory >= 4.0 to be "stable" and recommend you start using it
immediately.  Please see http://www.bigmemory.org.

In your case, two comments:

(1) Your for() loop will generate three identical copies of filebackings on
disk,
yes.  Note that when the loop exists, the R object xx will reference only
the
3rd of these, so xx[1,1] <- 1 will modify only the third filebacking, not
the
first two.  You'll need to use the separate descriptor files (probably
created
automatically for you, but we recommend naming them specifically using
descriptorfile=) to attach.big.matrix() whatever of these you really want to
be using.

(2) In the problem with "hanging" I believe you have exhausted the shared
resources on your system.  This problem will no longer arise in the >= 4.0
problems, as we're handling mutexes separately rather than automatically.
These shared resource limits are mysterious, depending on the OS as well
as the hardware and other jobs or tasks in existence at any given point in
time.
But again, it shouldn't be a problem with the new version.

The CRAN update should take place early next week, along with some revised
documentation.

Regards,

Jay

---


Message: 125
Date: Fri, 23 Apr 2010 13:51:32 -0800 (PST)
From: zerdna 
To: r-help@r-project.org
Subject: [R] bigmemory package woes
Message-ID: <1272059492009-2062996.p...@n4.nabble.com>
Content-Type: text/plain; charset=us-ascii


I have pretty big data sizes, like matrices of .5 to 1.5GB so once i need to
juggle several of them i am in need of disk cache. I am trying to use
bigmemory package but getting problems that are hard to understand. I am
getting seg faults and machine just hanging. I work by the way on Red Hat
Linux, 64 bit R version 10.

Simplest problem is just saving matrices. When i do something like

r<-matrix(rnorm(100), nr=10); librarybigmemory)
for(i in 1:3) xx<-as.big.matrix(r, backingfile=paste("r",i, sep="",
collapse=""), backingpath=MyDirName)

it works just fine -- saves small matrices  as three different matrices on
disc. However, when i try it with real size, like

with r<-matrix(normal(5000), nr=1000)

I am either getting seg fault on saving the third big matrix, or hang
forever.

Am i doing something obviously wrong, or is it an unstable package at the
moment? Could anyone recommend something similar that is reliable in this
case?


-- 
John W. Emerson (Jay)
Associate Professor of Statistics
Department of Statistics
Yale University
http://www.stat.yale.edu/~jay

[[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] multiple paired t-tests without loops

2010-04-24 Thread Matthew Finkbeiner
I am new to R and I suspect my problem is easily solved, but I haven't 
been able to figure it out without using loops.  I am trying to 
implement Blair & Karniski's (1993) permutation test.  I've included a 
sample data frame below.  This data frame represents the conditional 
means (C1, C2) for 3 subjects in 2 consecutive samples of a continuous 
data set (e.g. ERP waveform).  Each sample includes all possible 
permuations of the subject means (2^N), which is 8 in this case.


The problem: I need to run a paired t-test on each SampleXPermutation 
set and save the maximum t-value obtained for each sample.  The real 
data set has 16 subjects (2^16 permutations) and 500 samples, which 
leads to more than 32 million t-tests.  I have a loop version of the 
program working, but it would take a few weeks to complete the job and I 
was hoping that someone could tell me how to do it faster?


thank you kindly,

Matthew Finkbeiner



"Sample"  "C1"  "C2"  "PermN"
1   5   8   perm1
1   4   3   perm1
1   6   4   perm1
2   2   6   perm1
2   3   1   perm1
2   7   4   perm1
1   8   5   perm2
1   3   4   perm2
1   6   4   perm2
2   6   2   perm2
2   1   3   perm2
2   7   4   perm2
1   5   8   perm3
1   3   4   perm3
1   6   4   perm3
2   2   6   perm3
2   1   3   perm3
2   7   4   perm3
1   8   5   perm4
1   4   3   perm4
1   4   6   perm4
2   6   2   perm4
2   3   1   perm4
2   4   7   perm4
1   5   8   perm5
1   4   3   perm5
1   4   6   perm5
2   2   6   perm5
2   3   1   perm5
2   4   7   perm5
1   8   5   perm6
1   3   4   perm6
1   4   6   perm6
2   6   2   perm6
2   1   3   perm6
2   4   7   perm6
1   5   8   perm7
1   3   4   perm7
1   4   6   perm7
2   2   6   perm7
2   1   3   perm7
2   4   7   perm7
1   8   5   perm8
1   4   3   perm8
1   6   4   perm8
2   6   2   perm8
2   3   1   perm8
2   7   4   perm8






--
Dr. Matthew Finkbeiner
Senior Lecturer & ARC Australian Research Fellow
Macquarie Centre for Cognitive Science (MACCS)
Macquarie University, Sydney, NSW 2109

Phone: +61 2 9850-6718
Fax:   +61 2 9850-6059
Homepage: http://www.maccs.mq.edu.au/~mfinkbei
Lab Homepage: http://www.maccs.mq.edu.au/laboratories/action/

__
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] Unable to make bitmapdll files on windows 7 64 bit machine

2010-04-24 Thread arnholtat
Thanks for all of the replies.  For me at least, it turns out I had to manually 
set permissions in the bitmap folder, 
and the three folders (jpeg-8a, libpng, and libtiff).  Works fine now.

Alan-

- Original Message -
From: Duncan Murdoch 
Date: Friday, April 23, 2010 4:48 am
Subject: Re: [R] Unable to make bitmapdll files on windows 7 64 bit machine
To: arnhol...@appstate.edu
Cc: r-help@r-project.org

> On 22/04/2010 2:03 PM, arnhol...@appstate.edu wrote:
> > I am trying to build a windows 32 bit version of R 2.11.0 from 
> source on a machine running
> >  windows 7 - 64 bit while running as the machine's administrator.
> > I am able to run "make all recommended"...However, once I attempt 
> to build the bitmap files I get the following:
> >
> > C:\Rsource\R-2.11.0\src\gnuwin32>make bitmapdll
> > make -C bitmap
> > make[1]: Entering directory `/cygdrive/c/Rsource/R-
> 2.11.0/src/gnuwin32/bitmap'> make CC='gcc -std=gnu99' AR='ar' \
> >   CFLAGS="-O3 -I../../../extra/zlib -DPNG_NO_MMX_CODE" \
> >   RANLIB=ranlib ZLIBLIB=../../../extra/zlib -C libpng \
> >   -f scripts/makefile.mingw prefix=foo libpng.a
> > gcc -std=gnu99 -c -O3 -I../../../extra/zlib -DPNG_NO_MMX_CODE -o 
> png.o png.c
> > Assembler messages:
> > Fatal error: can't create png.o: Permission denied
> > make[3]: *** [png.o] Error 1
> > make[2]: *** [buildpng] Error 2
> > make[1]: *** [all] Error 2
> > make[1]: Leaving directory `/cygdrive/c/Rsource/R-
> 2.11.0/src/gnuwin32/bitmap'> make: *** [bitmapdll] Error 2
> >
> > Any suggestions/hints on what I am messing up are most 
> appreciated.  
> >   
> 
> You  need to check the permissions on the files installed by the 
> Rtools 
> installer.  From the look of it, you are missing some permissions 
> on the 
> src/gnuwin32/bitmap/libpng directory, or one of its parents.  In 
> Unix 
> terms, you need read-write-execute permission on all of those 
> directories, and I think the Rtools installer is not currently 
> giving 
> you that.  You can run "ls -l" to see what permissions you've got; 
> ls is 
> in the Rtools.  I forget how you change permissions in Windows 7 
> without 
> chmod, but I think it's a matter of working with the Properties you 
> see 
> when you right click the file.  (Or you can install Cygwin, and 
> then 
> you'll get chmod.)
> 
> Duncan Murdoch
> > Thanks in advance.
> >
> > Alan-
> >
> > Alan T. Arnholt
> > Professor and Assistant Chair
> > Department of Mathematical Sciences
> > Appalachian State University
> > T:(828)262-2863
> > F:(828)265-8617
> > http://www1.appstate.edu/~arnholta/
> >
> >   
> > --
> --
> >
> > __
> > 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.
> >   
> 
> 

Alan T. Arnholt
Professor and Assistant Chair
Department of Mathematical Sciences
Appalachian State University
T:(828)262-2863
F:(828)265-8617
http://www1.appstate.edu/~arnholta/

__
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] Multiple Correlation coefficient (spearman, Kenall)

2010-04-24 Thread pauls182


Hi,

I'm currently trying to find/define a relationship between one dependent and
several independant variables.
The problem is that i cannot use the normal multiple regression/correlation
in Spss because the data is not normal distributed.

i calculated the spearman roh and Kendalls tau Correlation and also some
partial correlations in R.
Now i wanna find out the the multiple correlation coeffcient for Kendalls
Tau and spearmans roh and check if it is signifikant.

unfortunately i cannot find a way to do that in R.

any sugestions?

thank you in advance 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Multiple-Correlation-coefficient-spearman-Kenall-tp2063314p2063314.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] barplot() and highlighted values

2010-04-24 Thread Sebastian Bergmann
 Hello!

 I started using R today to produce a bar chart that I can use in LaTeX.

 Here is what I have got so far:

   pdf("bugfix_costs.pdf")
   costs <- c(1, 5, 10, 20, 50, 150)
   barplot(costs,
   ylab="Relative cost of a bugfix",
   names.arg=c("Requirements", "Design", "Code",
   "Developer Tests", "Acceptance Tests", "Operations"),
   cex.names=0.6
  )
   dev.off()
   q()

 What I am missing from the produced chart is "highlighted values" as in
 http://www.slideshare.net/spriebsch/die-5-goldenen-oopregeln-fr-php, for
 instance. Basically what I need is to put text above each of the bars.
 Is that possible?

 Thanks!

-- 
Sebastian BergmannCo-Founder and Principal Consultant
http://sebastian-bergmann.de/   http://thePHP.cc/

__
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] multiple paired t-tests without loops

2010-04-24 Thread Matthew Finkbeiner
I am new to R and I suspect my problem is easily solved, but I haven't 
been able to figure it out without using loops.  I am trying to 
implement Blair & Karniski's (1993) permutation test.  I've included a 
sample data frame below.  This data frame represents the conditional 
means (C1, C2) for 3 subjects in 2 consecutive samples of a continuous 
data set (e.g. ERP waveform).  Each sample includes all possible 
permuations of the subject means (2^N), which is 8 in this case.


The problem: I need to run a paired t-test on each SampleXPermutation 
set and save the maximum t-value obtained for each sample.  The real 
data set has 16 subjects (216 permutations) and 500 samples, which leads 
to more than 32 million t-tests.  I have a loop version of the program 
working, but it would take a few weeks to complete the job and I was 
hoping that someone could tell me how to do it faster?


thank you kindly,

Matthew Finkbeiner



"Sample""C1""C2""PermN"
158perm1
143perm1
164perm1
226perm1
231perm1
274perm1
185perm2
134perm2
164perm2
262perm2
213perm2
274perm2
158perm3
134perm3
164perm3
226perm3
213perm3
274perm3
185perm4
143perm4
146perm4
262perm4
231perm4
247perm4
158perm5
143perm5
146perm5
226perm5
231perm5
247perm5
185perm6
134perm6
146perm6
262perm6
213perm6
247perm6
158perm7
134perm7
146perm7
226perm7
213perm7
247perm7
185perm8
143perm8
164perm8
262perm8
231perm8
274perm8






--
Dr. Matthew Finkbeiner
Senior Lecturer & ARC Australian Research Fellow
Macquarie Centre for Cognitive Science (MACCS)
Macquarie University, Sydney, NSW 2109

Phone: +61 2 9850-6718
Fax:   +61 2 9850-6059
Homepage: http://www.maccs.mq.edu.au/~mfinkbei
Lab Homepage: http://www.maccs.mq.edu.au/laboratories/action/

__
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] Linux System Function

2010-04-24 Thread Ryan Garner

Clever solution. I use paste alot and didn't think to use it for this
problem. Thanks!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Linux-System-Function-tp2063058p2063113.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] Combinations with restrictions

2010-04-24 Thread Cláudio Sá
Thank you for the quick answer, but i was asking if some method could do
combinations where numbers of the same vector wont combine.
A little bit like 'expand.grid', but with the possibility to choose the
length for output combinations.

Cláudio

2010/4/23 Jorge Ivan Velez 

> Hi Cláudio,
>
> Try this:
>
> require(gtools)
> combinations(10, 2)
> combinations(10, 2, repeats = TRUE)
>
> HTH,
> Jorge
>
>
> 2010/4/23 Cláudio Sá <>
>
>> Hi!
>>
>>  Is there any easy/fast way to combine vectors with restrictions?
>>
>> Example:
>>
>> a=c(1,2,3), b=c(4,5,6), c=c(7,8,9)
>>
>> I want all combinations of this 3 vectors with length=2.
>>
>> Like this:
>> 1,4
>> 1,5
>> 1,6
>> 1,7
>> 1,8
>> 1,9
>> 2,4
>> 2,5
>> 2,6
>> 2,7
>> ... and so on.
>>
>> Thanks in advance.
>>
>>[[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.