Re: [R] R Packages Crack the 3,000 Mark!

2009-11-25 Thread Peter Dalgaard

Stephan Kolassa wrote:

Hi Bob,

Muenchen, Robert A (Bob) wrote:


Does anyone have a program that graphs the growth of R packages? I don't
know if that historical data is around.


John Fox had a slide on this in his useR 2008 talk "The Social 
Organization of the R Project" (page 7), with package counts up to March 
2008. As "Source of Data" he gave https://svn.r-project.org/R/branches/. 
I've been digging around in there but really have no idea how he found 
the relevant data there.


I'd be quite interested in this, too, so if you find out anything please 
drop me a line...


I believe he looked inside tests/internet.Rout.save

This has

> nrow(available.packages(contrib.url("http://cran.r-project.org";)))
[1] 2008

and gets updated at each release.

--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Multivariate problems . . . with 200 resposes variables and 1 explanatory variable

2009-11-25 Thread Gavin Simpson
On Wed, 2009-11-25 at 16:55 -0800, ychu066 wrote:
> How should I analysis it in R  all the resposes variables are ordinal
> from 0 to 10. and the explanatory variable is a factor ...

You give very little to go on (please read the posting guide for future
reference), but:

If you want to analyse all the responses at once:

A VGLM might be useful; see the VGAM package on CRAN and the author's
(Thomas Yee) web site for lots of useful information.

A constrained ordination might also be useful. cca() in package vegan,
or capscale() (also in vegan) with a suitable dissimilarity for ordinal
data (see daisy() in package cluster for such dissimilarities).

If you want to model the 200 responses separately (i.e. 200 models) then
polr() in package MASS or lrm() in package rms would be places to start.

HTH

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.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.


[R] How to display an image on RGL plot?

2009-11-25 Thread Vladimir Eremeev

Hi all.
It's been a long time since I wrote to this list. Glad to see the R project
well and working.

I am working  with a 3D plot similar to this: 
http://old.nabble.com/file/p26525177/rgl-device.png rgl-device.png 

The underlying picture is a JPEG image, loaded with the rimage package and
coerced to the matrix. 
Spheres denote control points, collected from this picture and must be
situated over the certain points of the image.
I display the image with rgl.points. 
In case of the standard video camera image (704x576) it has to display over
40 points which is rather slow and memory consuming. 
How can I put an original JPEG on this plot?

Another problem is that the picture is color initially, but was converted to
the grayscale. I'd like to preserve colors.
-- 
View this message in context: 
http://old.nabble.com/How-to-display-an-image-on-RGL-plot--tp26525177p26525177.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] jpeg support in R

2009-11-25 Thread Gavin Simpson
On Wed, 2009-11-25 at 14:26 -0800, kennyPA wrote:
> Hi, I'd like to have jpeg support in R under RedHat Linux, when I ran the
> ./configure in the install process, the config.log gave me the following
> error messages:
> 
> configure:43621: checking if jpeglib version >= 6b
> conftest.c:200:21: error: jpeglib.h: No such file or directory
> 
> I assume I need to install some system jpeg libraries. Could someone tell me
> what I should do to get the configure right and build a R with jpeg
> supported. thanks a lot!

su -c "yum install libjpeg-devel"

in a console will install the relevant development headers for you.

HTH

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.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] Feature request for as.Date() function 20)

2009-11-25 Thread nabble . 30 . miller_2555
An easy way is just to write your own function that will accept "NA",
convert it to NA and then call as.Date.

R is a functional language, so write some functions.  Don't try to
overload existing functions with new options that may break a lot of
existing code.  If you have special requirements, then adapt your code
to them.  You would probably have to wait around for a long time
before an new option got in, so it is easier to create your own.



On Wed, Nov 25, 2009 at 4:40 PM,   wrote:
> On Wed, Nov 25, 2009 at 2:56 PM, jim holtman - 
> nabble.30.miller_2...@spamgourmet.com
> <>
> wrote:
>> Seems to work fine in my testing:
>>
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>> Similarly, the following command produces the same error:
>>>    as.Date("NA")
>>>
>>> However, as.Date(NA) performs as documented.
>>>
>>> Can we enhance the as.Date() function to convert "NA" strings into NA
>>> value prior to type conversion?
>
> I sincerely appreciate the help, but with all due respect, I have read
> the posting guide and did provide the minimal code necessary to
> reproduce the desired feature. To reiterate, I would like to be able
> to feed the character string "NA" to the as.Date() function to yield
> the same result as `as.Date(NA)`. Please advise if testing the
> following does not yield an error:
>> as.Date("NA");
>
> This may or may not aid the read.csv() error message in my particular
> code (for which a workaround has already been identified).
>
> Thank you.
>
>



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

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] arg min ???

2009-11-25 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 25.11.2009 16:50:49:

> 
> This is nice, but i have to define vector of possible theta, this is not 
what
> i want to do.
> I have vector of unknow parameters theta. I have som estimate of theta, 
but
> i want to do better estimate of them, using some criterion function. 
> I mean it is clasical argmin f(x_1,x_2,...x_n)  to fit vector
> (x_1,x_2...,x_n)` 

I am not sure what you mean by argmin, but maybe you could look at ?optim

Regards
Petr

> 
> 
> David Winsemius wrote:
> > 
> > 
> > On Nov 25, 2009, at 9:15 AM, Peterko wrote:
> > 
> >>
> >> Is there function what aproximate vector of parameters some function 
> >> to
> >> minimum ?
> >>
> >> tet={tet1,tet2}  i have they starting value
> >>
> >> and i want to find the tet what minimalizing some function of tet ?
> > 
> > ?which.min
> > 
> > Perhaps:
> > 
> >   which.min( fn(tet) )
> > 
> >>
> >> thanks
> >> -- 
> >> View this message in context:
> >> http://old.nabble.com/arg-min-tp26513358p26513358.html
> >> Sent from the R help mailing list archive at Nabble.com.
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> > 
> > David Winsemius, MD
> > Heritage Laboratories
> > 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.
> > 
> > 
> 
> -- 
> View this message in context: 
http://old.nabble.com/arg-min-tp26513358p26515110.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Grouped Boxplot

2009-11-25 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 24.11.2009 18:44:43:

> Back in March Soren Vogel asked exactly the same thing:
> 
> Here is the solution that was offered then. (He offered a dataset as 
> requested in the Posting Guide.)  ... with only a minor adjustment:
> 
> g <- rep.int(c("A", "B", "C", "D"), 125)
> t <- rnorm(5000)
> a <- sample(t, 500, replace=TRUE)
> b <- sample(t, 500, replace=TRUE)
> dta <- data.frame(val = sample(t,1000), g = gl(4, 250, labels=c("A", 
> "B", "C", "D")) , G2 = gl(2,1, labels=c("XX", "YY")))
> boxplot( val ~ g + G2, data=dta, at = 0.8*c(1,2,3,4,6,7,8,9), 
> boxwex=0.8)
> 
> This should have shown up with this:
> 
> RSiteSearch("grouped boxplot")

or ggplot2 variant

p <- ggplot(dta, aes(factor(G2), val))
p + geom_boxplot(aes(fill = factor(g)))

Regards
Petr


> 
> -- 
> David
> 
> On Nov 24, 2009, at 10:35 AM, Gary wrote:
> 
> > Thanks Uwe and Petr for your suggestion. Please see Fig. 3 on the 
> > attached
> > file. Thanks!
> >
> > On Tue, Nov 24, 2009 at 6:44 AM, Petr PIKAL  
> > wrote:
> >
> >> Hi
> >>
> >> try ggplot2. It has some functionality to make groups of boxplots.
> >>
> >> Regards
> >> Petr
> >>
> >>
> > Your attachment did not pass the list's filters. Anyway, see ?boxplot.
> >
> > Uwe Ligges
> >
> >
> >
> >>
> >> r-help-boun...@r-project.org napsal dne 24.11.2009 03:33:49:
> >>
> >>> Hi R Users,
> >>>
> >>> I'm interested in plotting a grouped boxplot (please see attached 
> >>> file
> >> for
> >>> sample). Can anyone suggest a function{package} which can help me
> >> achieve
> >>> this.
> >>>
> >>> Thanks,
> >>> Gary
> >>> __
> >>> R-help@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/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.
> 
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] as.data.frame.table() to convert by() output to a data frame

2009-11-25 Thread David Winsemius


On Nov 26, 2009, at 12:17 AM, David Winsemius wrote:



On Nov 25, 2009, at 9:54 PM, Michael Ash wrote:


I remain confused by the difference between

library(MASS)
data(Cars93)

as
.data
.frame
(tapply
(Cars93
$Price,list(Cars93$Origin,Cars93$AirBags,Cars93$Passengers),median))
as
.data
.frame
.table
(tapply
(Cars93
$Price,list(Cars93$Origin,Cars93$AirBags,Cars93$Passengers),median))



The display may not make it clear, but applying str() to both should  
make it clear that the first is similar to what one might get with  
cbind'ing the results of the inner function (which would not work in  
this case on a list object).


I mis-wrote... tapply returned an array, although not one that would  
allow simple cbinding. Ths is the code from as.data.frame.array, x  
being the passed object:

dn <- dimnames(x)
dim(x) <- c(d[1L], prod(d[-1L]))
if (!is.null(dn)) {
if (length(dn[[1L]]))
rownames(x) <- dn[[1L]]
for (i in 2L:length(d)) if (is.null(dn[[i]]))
dn[[i]] <- seq_len(d[i])
colnames(x) <- interaction(expand.grid(dn[-1L]))
}
as.data.frame.matrix(x, row.names, optional, ...)

You get two rows of 18 variables all medians or NA, while the second  
is the unique combinations of the (USA/ 
nonUSA)*(Passengers)*(Airbags)*(Passengers) cross and their  
associated medians which as.data.frame has labeled "Freq" since that  
is the usual element of a contingency table. I think of  
as.data.frame.table as simply another way of accomplishing  
as.data.frame(table()). Is that not how you were intending it?




I clearly want the latter, but that's not clear from the  
documentation.


Sometimes it is helpful to look at the code as well:

> as.data.frame.table
function (x, row.names = NULL, ..., responseName = "Freq",  
stringsAsFactors = TRUE)

{
   x <- as.table(x)
   ex <- quote(data.frame(do.call("expand.grid", c(dimnames(x),
   stringsAsFactors = stringsAsFactors)), Freq = c(x), row.names  
= row.names))

   names(ex)[3L] <- responseName
   eval(ex)
}

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



Best,
Michael


On Wed, Nov 25, 2009 at 5:55 PM, David Winsemius > wrote:


On Nov 25, 2009, at 4:11 PM, Michael Ash wrote:


Dear all,

This seems to be working, but I'd like to make sure that I'm not  
doing

anything wrong.

I am using by() to construct a complicated summary statistic by
several factors in my data (specifically, the 90-50 income ratio by
city and race).

cityrace.by <- by(microdata, list(microdata$city,microdata$race),
function (x) quantile(x$income, probs=0.9) / quantile(x$income,
probs=0.5) )

I would now like to use the data created by by() as a dataset with
city-race as the unit of observation.

However, cityrace.data <- as.data.frame(cityrace.by) does not  
work because

"Error in as.data.frame.default(city.by) :
cannot coerce class "by" into a data.frame"

The following is not a documented use of as.data.frame.table(),  
but it
seems to work.  It gives the columns slightly strange names,  
including

"Freq" for the statistic computed in by by() but otherwise, the
dataframe is indexed by city and race with the 90-50 ratio as the
variable

cityrace.data <- as.data.frame.table(cityrace.by)


If the by-object you get happens to be a 2d array, then why not.  
Tables are

matrices after all.


tt <- table(c(1,1), c(1,1))
tt


  1
1 2

is.matrix(tt)

[1] TRUE


--



David Winsemius, MD
Heritage Laboratories
West Hartford, CT


--
Michael Ash, Associate Professor
of Economics and Public Policy
Department of Economics and CPPA
University of Massachusetts
Amherst, MA 01003
Tel +1-413-545-6329 Fax +1-413-545-2921
Email m...@econs.umass.edu
http://people.umass.edu/maash


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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
Heritage Laboratories
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] as.data.frame.table() to convert by() output to a data frame

2009-11-25 Thread David Winsemius


On Nov 25, 2009, at 9:54 PM, Michael Ash wrote:


I remain confused by the difference between

library(MASS)
data(Cars93)

as
.data
.frame
(tapply
(Cars93
$Price,list(Cars93$Origin,Cars93$AirBags,Cars93$Passengers),median))
as
.data
.frame
.table
(tapply
(Cars93
$Price,list(Cars93$Origin,Cars93$AirBags,Cars93$Passengers),median))



The display may not make it clear, but applying str() to both should  
make it clear that the first is similar to what one might get with  
cbind'ing the results of the inner function (which would not work in  
this case on a list object). You get two rows of 18 variables all  
medians or NA, while the second is the unique combinations of the (USA/ 
nonUSA)*(Passengers)*(Airbags)*(Passengers) cross and their associated  
medians which as.data.frame has labeled "Freq" since that is the usual  
element of a contingency table. I think of as.data.frame.table as  
simply another way of accomplishing as.data.frame(table()). Is that  
not how you were intending it?




I clearly want the latter, but that's not clear from the  
documentation.


Sometimes it is helpful to look at the code as well:

> as.data.frame.table
function (x, row.names = NULL, ..., responseName = "Freq",  
stringsAsFactors = TRUE)

{
x <- as.table(x)
ex <- quote(data.frame(do.call("expand.grid", c(dimnames(x),
stringsAsFactors = stringsAsFactors)), Freq = c(x), row.names  
= row.names))

names(ex)[3L] <- responseName
eval(ex)
}

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



Best,
Michael


On Wed, Nov 25, 2009 at 5:55 PM, David Winsemius > wrote:


On Nov 25, 2009, at 4:11 PM, Michael Ash wrote:


Dear all,

This seems to be working, but I'd like to make sure that I'm not  
doing

anything wrong.

I am using by() to construct a complicated summary statistic by
several factors in my data (specifically, the 90-50 income ratio by
city and race).

cityrace.by <- by(microdata, list(microdata$city,microdata$race),
function (x) quantile(x$income, probs=0.9) / quantile(x$income,
probs=0.5) )

I would now like to use the data created by by() as a dataset with
city-race as the unit of observation.

However, cityrace.data <- as.data.frame(cityrace.by) does not work  
because

"Error in as.data.frame.default(city.by) :
 cannot coerce class "by" into a data.frame"

The following is not a documented use of as.data.frame.table(),  
but it
seems to work.  It gives the columns slightly strange names,  
including

"Freq" for the statistic computed in by by() but otherwise, the
dataframe is indexed by city and race with the 90-50 ratio as the
variable

cityrace.data <- as.data.frame.table(cityrace.by)


If the by-object you get happens to be a 2d array, then why not.  
Tables are

matrices after all.


tt <- table(c(1,1), c(1,1))
tt


   1
 1 2

is.matrix(tt)

[1] TRUE


--



David Winsemius, MD
Heritage Laboratories
West Hartford, CT


--
Michael Ash, Associate Professor
 of Economics and Public Policy
Department of Economics and CPPA
University of Massachusetts
Amherst, MA 01003
Tel +1-413-545-6329 Fax +1-413-545-2921
Email m...@econs.umass.edu
http://people.umass.edu/maash


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Binary operators in packages and documentation?

2009-11-25 Thread Zhou Fang
Hi,

I'm trying to make a package defining a new (S3?) class. Part of this
involves a custom version of a binary operator. e.g. "*.foo", so I can
do obj.foo * bar, or things like that.

Now, I think to makes this work with a NAMESPACE, I can do

S3method("*", foo)

in the NAMESPACE file, right? The question I was wondering was what
the appropriate way to document this operator is. i.e. What should I
put in the \usage section, etc?

'Writing R Extensions' doesn't seem to see much about this, but maybe
I'm missing something obvious.

Thanks,

Zhou Fang

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] as.data.frame.table() to convert by() output to a data frame

2009-11-25 Thread Michael Ash
I remain confused by the difference between

library(MASS)
data(Cars93)

as.data.frame(tapply(Cars93$Price,list(Cars93$Origin,Cars93$AirBags,Cars93$Passengers),median))
as.data.frame.table(tapply(Cars93$Price,list(Cars93$Origin,Cars93$AirBags,Cars93$Passengers),median))


I clearly want the latter, but that's not clear from the documentation.


Best,
Michael


On Wed, Nov 25, 2009 at 5:55 PM, David Winsemius  wrote:
>
> On Nov 25, 2009, at 4:11 PM, Michael Ash wrote:
>
>> Dear all,
>>
>> This seems to be working, but I'd like to make sure that I'm not doing
>> anything wrong.
>>
>> I am using by() to construct a complicated summary statistic by
>> several factors in my data (specifically, the 90-50 income ratio by
>> city and race).
>>
>> cityrace.by <- by(microdata, list(microdata$city,microdata$race),
>> function (x) quantile(x$income, probs=0.9) / quantile(x$income,
>> probs=0.5) )
>>
>> I would now like to use the data created by by() as a dataset with
>> city-race as the unit of observation.
>>
>> However, cityrace.data <- as.data.frame(cityrace.by) does not work because
>> "Error in as.data.frame.default(city.by) :
>>  cannot coerce class "by" into a data.frame"
>>
>> The following is not a documented use of as.data.frame.table(), but it
>> seems to work.  It gives the columns slightly strange names, including
>> "Freq" for the statistic computed in by by() but otherwise, the
>> dataframe is indexed by city and race with the 90-50 ratio as the
>> variable
>>
>> cityrace.data <- as.data.frame.table(cityrace.by)
>
> If the by-object you get happens to be a 2d array, then why not. Tables are
> matrices after all.
>
>> tt <- table(c(1,1), c(1,1))
>> tt
>
>    1
>  1 2
>> is.matrix(tt)
> [1] TRUE
>
>> --
>
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>



-- 
Michael Ash, Associate Professor
  of Economics and Public Policy
Department of Economics and CPPA
University of Massachusetts
Amherst, MA 01003
Tel +1-413-545-6329 Fax +1-413-545-2921
Email m...@econs.umass.edu
http://people.umass.edu/maash

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Multivariate problems . . . with 200 resposes variables and 1 explanatory variable

2009-11-25 Thread Jason Morgan
Please see the posting guide here:

http://www.r-project.org/posting-guide.html

In short, it would be helpful if you provided more information on your
data and what the goal of your analysis is. However, to get you started,
see the polr() function in the MASS package. Depending on your
goal/data, that may help.

~Jason

On 2009.11.25 16:55:13, ychu066 wrote:
> 
> How should I analysis it in R  all the resposes variables are ordinal
> from 0 to 10. and the explanatory variable is a factor ...
> -- 
> View this message in context: 
> http://old.nabble.com/Multivariate-problems-.-.-.-with-200-resposes-variables-and-1-explanatory-variable-tp26522912p26522912.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.

-- 
Jason W. Morgan
Graduate Student
Department of Political Science
*The Ohio State University*
154 North Oval Mall
Columbus, Ohio 43210

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Question in using e1071 svm routine

2009-11-25 Thread David Winsemius


On Nov 25, 2009, at 7:54 PM, akal wrote:



Hi all,

I am encountering the same error "Error in if (any(co)) { : missing  
value

where TRUE/FALSE needed"
when i run:model <- svm(databctrain, classesbctrain)

I am not sure what this error means . is it some problem with the  
dataset ?


How do you propose that we address this question?



Could i get some help ?








Only if you supply sufficient information. Read the Posting Guide  
before reposting, please.


--
David

Thanks,
Akshatha



losemind wrote:


Hi all,

I've got the following error message in using e1071 svm routine...

Could anybody please help me?

Thank you!

-
model <- svm(y=factor(mytraindata[, 1]), x=mytraindata[, -1],
probability=T)
Error in if (any(co)) { : missing value where TRUE/FALSE needed
In addition: Warning message:
In FUN(newX[, i], ...) : NAs introduced by coercion

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




--
View this message in context: 
http://old.nabble.com/Question-in-using-e1071-svm-routine-tp24382208p26522910.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
Heritage Laboratories
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] Question in using e1071 svm routine

2009-11-25 Thread akal

Hi all,

I am encountering the same error "Error in if (any(co)) { : missing value
where TRUE/FALSE needed"
when i run:model <- svm(databctrain, classesbctrain)

I am not sure what this error means . is it some problem with the dataset ? 

Could i get some help ?

Thanks,
Akshatha



losemind wrote:
> 
> Hi all,
> 
> I've got the following error message in using e1071 svm routine...
> 
> Could anybody please help me?
> 
> Thank you!
> 
> -
> model <- svm(y=factor(mytraindata[, 1]), x=mytraindata[, -1],
> probability=T)
> Error in if (any(co)) { : missing value where TRUE/FALSE needed
> In addition: Warning message:
> In FUN(newX[, i], ...) : NAs introduced by coercion
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Question-in-using-e1071-svm-routine-tp24382208p26522910.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] R help with princomp and pam clustering

2009-11-25 Thread Tyler82

Hi all!
I am working with R package cluster and I have a little problem: 
let's say I have two datasets...first one ("A") is divided into 4 clusters
by means of Pam algorythm.
Let's say I want to project the second database ("B") onto the Comp.1 X
Comp.2 graph, and see where its elements are placed.
The two datasets are made of different dim (54x19 and 28x19). I tried to
extract the $loadings of the A clustering but I can't seem to figure out how
to use them with B :(
Using princomp I menaged to extract the $scores and plot the graph. Wouldn't
using princomp on the B dataset generate different PC? 
Thank you all!
Bye!!

Claudio
-- 
View this message in context: 
http://old.nabble.com/R-help-with-princomp-and-pam-clustering-tp26522485p26522485.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] jpeg support in R

2009-11-25 Thread kennyPA

Hi, I'd like to have jpeg support in R under RedHat Linux, when I ran the
./configure in the install process, the config.log gave me the following
error messages:

configure:43621: checking if jpeglib version >= 6b
conftest.c:200:21: error: jpeglib.h: No such file or directory

I assume I need to install some system jpeg libraries. Could someone tell me
what I should do to get the configure right and build a R with jpeg
supported. thanks a lot!
-- 
View this message in context: 
http://old.nabble.com/jpeg-support-in-R-tp26521364p26521364.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] Adding text in the panels for Trellis plot ...

2009-11-25 Thread ychu066

i was trying to do a for loop for plotting the histograms , but it doesnt
work properly 

> library(lattice) 
> columns <- 8:153 
> plots <- vector("list", length(columns)) 
> j <- 0 
> for (i in columns) 
+ {   
+   plots[[ j <- j+1 ]] <- histogram( ~ data[,i] | data[,2],ylab =
"Frequency", 
+   xlab = "Score", xlim = c(1,5), ylim = c(0,100),layout=c(3,1), 
+   main = c(colnames(data)[i],"index",j+1),mycolors =
colors()[c(536,552,652,254,26)], 
+   panel = function(..., col, mycolors) { 
+   panel.histogram(..., col = mycolors[panel.number()])}) 
+ trellis.focus('strip', 1, 1, highlight=FALSE) 
+ ltext(0.60, -0.25, 'PPM', col='blue', pos=3) 
+ trellis.unfocus() 
+ }   
Error in grid.Call.graphics("L_downviewport", name$name, strict) : 
  Viewport 'plot1.strip.1.1.vp' was not found 
> 
> print(plots[[1]]) 


I am not sure what was happeneing. . . can anyone help me ? 

-- 
View this message in context: 
http://old.nabble.com/Adding-text-in-the-panels-for-Trellis-plot-...-tp26522902p26522902.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] Multivariate problems . . . with 200 resposes variables and 1 explanatory variable

2009-11-25 Thread ychu066

How should I analysis it in R  all the resposes variables are ordinal
from 0 to 10. and the explanatory variable is a factor ...
-- 
View this message in context: 
http://old.nabble.com/Multivariate-problems-.-.-.-with-200-resposes-variables-and-1-explanatory-variable-tp26522912p26522912.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] Arrhenius plot with lattice

2009-11-25 Thread milton ruser
Hi Markus,

PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
Your example is not reproducible. Help your helper :-)

bests

miltinho

On Wed, Nov 25, 2009 at 5:54 PM, Markus Häge  wrote:

> hello there,
>
> I like to print a theoretical function into my data. It would work with
> "panel.curve" when it's all "normal". but unfortunately it's an
> arrhenius plot and I need "1000/Temperature"(70-300K) at the x-axis.
> With my data it wasn't a Problem but now I have to add this function to
> the plot and don't know how to turn around the variable in the function
> and adapt the plot to this.
>
> log(n)=log(f(T^.5))-const/T
>
> thanks
>
> Markus
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Concave hull

2009-11-25 Thread David Winsemius


On Nov 25, 2009, at 7:51 PM, David Winsemius wrote:


Drats; Forgot the plot:

xx <- runif(100, -1, 1)
yy <- abs(xx)+rnorm(100,0,.2); plot(xx,yy, xlim=c( min(xx)-sd(xx),  
max(xx)+sd(xx)), ylim =c( min(yy)-sd(yy), max(yy)+sd(yy)))


dens2 <- kde2d(xx, yy, lims=c(min(xx)-sd(xx), max(xx)+sd(xx),  
min(yy)-sd(yy), max(yy)+sd(yy) )  )

contour(dens2, add=TRUE)

#  You can pick a single contour if you like:


contour(dens2, level=0.05, col="red", add=TRUE)
contour(dens2, level=0.10, col="blue", add=TRUE)


And as a further note you can drop the bandwidth and lower the density  
level to get a tighter fit:


xx <- runif(1, -1, 1)
yy <- abs(xx)+rnorm(1   ,0,.2); plot(xx,yy, xlim=c( min(xx)- 
sd(xx), max(xx)+sd(xx)), ylim =c( min(yy)-sd(yy), max(yy)+sd(yy)),  
cex=.2)


dens2 <- kde2d(xx, yy, lims=c(min(xx)-sd(xx), max(xx)+sd(xx), min(yy)- 
sd(yy), max(yy)+sd(yy) ) , h=c(bandwidth.nrd(xx)/4, bandwidth.nrd(xx)/ 
4) )

contour(dens2, add=TRUE)
#  You can pick a single contour if you like:

contour(dens2, level=0.05, col="red", add=TRUE)
contour(dens2, level=0.10, col="blue", add=TRUE)

contour(dens2, level=0.005, col="red", add=TRUE)


(More bat-like.)

--
David.




On Nov 25, 2009, at 7:46 PM, David Winsemius wrote:

This is not a true convave hull, but a 2D density is something  
similar and perhaps more "statistical":


library(MASS)
xx <- runif(100, 0, 1)
xx <- runif(100, -1, 1)
yy <- abs(xx)+rnorm(100,0,.2)
dens2 <- kde2d(xx, yy, lims=c(min(xx)-sd(xx), max(xx)+sd(xx),  
min(yy)-sd(yy), max(yy)+sd(yy) )  )

contour(dens2, add=TRUE)

#  You can pick a single contour if you like:

contour(dens2, level=0.05, col="red", add=TRUE)
contour(dens2, level=0.10, col="blue", add=TRUE)


Happy Valentine's
--
David

On Nov 25, 2009, at 11:37 AM, Corrado wrote:


Dear friends,

Do you know how to calculate the CONCAVE hull of a set of points (2-
dimensional or n-dimensional)? is that possible in R? (With a  
"smoothing"

parameter of course).

Best,
--
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.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
Heritage Laboratories
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
Heritage Laboratories
West Hartford, CT



David Winsemius, MD
Heritage Laboratories
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] Concave hull

2009-11-25 Thread David Winsemius

Drats; Forgot the plot:

 xx <- runif(100, 0, 1)
xx <- runif(100, -1, 1)
yy <- abs(xx)+rnorm(100,0,.2); plot(xx,yy, xlim=c( min(xx)-sd(xx),  
max(xx)+sd(xx)), ylim =c( min(yy)-sd(yy), max(yy)+sd(yy)))


dens2 <- kde2d(xx, yy, lims=c(min(xx)-sd(xx), max(xx)+sd(xx), min(yy)- 
sd(yy), max(yy)+sd(yy) )  )

contour(dens2, add=TRUE)

#  You can pick a single contour if you like:


contour(dens2, level=0.05, col="red", add=TRUE)
contour(dens2, level=0.10, col="blue", add=TRUE)



On Nov 25, 2009, at 7:46 PM, David Winsemius wrote:

This is not a true convave hull, but a 2D density is something  
similar and perhaps more "statistical":


library(MASS)
xx <- runif(100, 0, 1)
xx <- runif(100, -1, 1)
yy <- abs(xx)+rnorm(100,0,.2)
dens2 <- kde2d(xx, yy, lims=c(min(xx)-sd(xx), max(xx)+sd(xx),  
min(yy)-sd(yy), max(yy)+sd(yy) )  )

contour(dens2, add=TRUE)

#  You can pick a single contour if you like:

contour(dens2, level=0.05, col="red", add=TRUE)
contour(dens2, level=0.10, col="blue", add=TRUE)


Happy Valentine's
--
David

On Nov 25, 2009, at 11:37 AM, Corrado wrote:


Dear friends,

Do you know how to calculate the CONCAVE hull of a set of points (2-
dimensional or n-dimensional)? is that possible in R? (With a  
"smoothing"

parameter of course).

Best,
--
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.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
Heritage Laboratories
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
Heritage Laboratories
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] Concave hull

2009-11-25 Thread David Winsemius
This is not a true convave hull, but a 2D density is something similar  
and perhaps more "statistical":


library(MASS)
 xx <- runif(100, 0, 1)
 xx <- runif(100, -1, 1)
 yy <- abs(xx)+rnorm(100,0,.2)
 dens2 <- kde2d(xx, yy, lims=c(min(xx)-sd(xx), max(xx)+sd(xx),  
min(yy)-sd(yy), max(yy)+sd(yy) )  )

 contour(dens2, add=TRUE)

#  You can pick a single contour if you like:

 contour(dens2, level=0.05, col="red", add=TRUE)
 contour(dens2, level=0.10, col="blue", add=TRUE)


Happy Valentine's
--
David

On Nov 25, 2009, at 11:37 AM, Corrado wrote:


Dear friends,

Do you know how to calculate the CONCAVE hull of a set of points (2-
dimensional or n-dimensional)? is that possible in R? (With a  
"smoothing"

parameter of course).

Best,
--
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.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
Heritage Laboratories
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] Concave hull

2009-11-25 Thread Remko Duursma
Oh right I think I did not catch that *because of* the caps. Sorry.

r

-
Remko Duursma
Post-Doctoral Fellow

Centre for Plants and the Environment
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908
www.remkoduursma.com



On Thu, Nov 26, 2009 at 10:51 AM, Barry Rowlingson
 wrote:
> On Wed, Nov 25, 2009 at 11:39 PM, Remko Duursma  
> wrote:
>> See the function 'convhulln' in the 'geometry' package. It uses this
>> algorithm : http://www.qhull.org/
>
>  That looks like a CONVEX hull, the original poster asked about
> CONCAVE hulls (and in all CAPS to emphasise this!).
>
>  I've seen various algorithms for generating 'concave hulls' of point
> sets, the one that tops google searches is not available in source
> code but there is a web applet and set of java class files which
> appear to be based on a patented algorithm.
>
>  There's a lot of discussion on algorithms for this, and some
> implementations by processing the point data with GRASS. There main
> discussion appears to be to first generate the convex hull and then
> replace single edges with two edges based on some minimum or maximum
> distance criteria...
>
>  Couldn't find an implementation in R or Python though...
>
> 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.


Re: [R] Concave hull

2009-11-25 Thread Barry Rowlingson
On Wed, Nov 25, 2009 at 11:39 PM, Remko Duursma  wrote:
> See the function 'convhulln' in the 'geometry' package. It uses this
> algorithm : http://www.qhull.org/

 That looks like a CONVEX hull, the original poster asked about
CONCAVE hulls (and in all CAPS to emphasise this!).

 I've seen various algorithms for generating 'concave hulls' of point
sets, the one that tops google searches is not available in source
code but there is a web applet and set of java class files which
appear to be based on a patented algorithm.

 There's a lot of discussion on algorithms for this, and some
implementations by processing the point data with GRASS. There main
discussion appears to be to first generate the convex hull and then
replace single edges with two edges based on some minimum or maximum
distance criteria...

 Couldn't find an implementation in R or Python though...

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.


Re: [R] R or C++ on FreeNX servers

2009-11-25 Thread Gad Abraham
On Thu, Nov 26, 2009 at 8:00 AM, Murray Jorgensen
 wrote:
> Hi all,
>
> I have just found out that the machine learning group in our Faculty has a
> lot of spare capacity on their FreeNX servers. I do not know a lot about
> these beasts but I understand that they are a free version of something
> produced by a firm called "NoMachine".

FreeNX is just software for connecting to a desktop remotely, like VNC
(only better). So they probably have some sort of cluster. You don't
need NX unless you want to run an R GUI, which is not a good idea for
long running processes and unreliable network connections. Better to
run it from the terminal (check out GNU screen too).

>
> They are designed for executing parallel algorithms and I thought that they
> might be of use in a project of mine comparing different model-fitting
> algorithms from the point of view of sensitivity to starting values.
>
> Anyway before revealing my near-total ignorance to my computer science
> colleagues I thought I would ask if any of my fellow R users have any
> experience with these things and possibly advice to offer. The CS people
>  are probably using the servers in conjunction with Java or C++ and I could
> possibly use the latter of these. I wondered, though, if R could be used
> directly with such hardware and if so, how the parallelizing would be
> handled.

Assuming it's a Unix/Linux cluster on standard hardware (most likely),
you could just run R as normal (single threaded), or do parallel
processing using packages like Rmpi, snow, multicore, etc.. If you use
MPI, you'll probably need a bit of help setting it up properly.

For starters, see
http://cran.r-project.org/web/views/HighPerformanceComputing.html and
the R-sig-hpc mailing list.


-- 
Gad Abraham
PhD Student, Dept. CSSE and NICTA
The University of Melbourne
Parkville 3010, Victoria, Australia
email: gabra...@csse.unimelb.edu.au
web: http://www.csse.unimelb.edu.au/~gabraham

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Concave hull

2009-11-25 Thread Remko Duursma
See the function 'convhulln' in the 'geometry' package. It uses this
algorithm : http://www.qhull.org/



remko

-
Remko Duursma
Post-Doctoral Fellow

Centre for Plants and the Environment
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908
www.remkoduursma.com



On Thu, Nov 26, 2009 at 3:37 AM, Corrado  wrote:
> Dear friends,
>
> Do you know how to calculate the CONCAVE hull of a set of points (2-
> dimensional or n-dimensional)? is that possible in R? (With a "smoothing"
> parameter of course).
>
> Best,
> --
> Corrado Topi
>
> Global Climate Change & Biodiversity Indicators
> Area 18,Department of Biology
> University of York, York, YO10 5YW, UK
> Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.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.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Arrhenius plot with lattice

2009-11-25 Thread Markus Häge
hello there,

I like to print a theoretical function into my data. It would work with
"panel.curve" when it's all "normal". but unfortunately it's an
arrhenius plot and I need "1000/Temperature"(70-300K) at the x-axis.
With my data it wasn't a Problem but now I have to add this function to
the plot and don't know how to turn around the variable in the function
and adapt the plot to this.

log(n)=log(f(T^.5))-const/T

thanks

Markus

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] as.data.frame.table() to convert by() output to a data frame

2009-11-25 Thread David Winsemius


On Nov 25, 2009, at 4:11 PM, Michael Ash wrote:


Dear all,

This seems to be working, but I'd like to make sure that I'm not doing
anything wrong.

I am using by() to construct a complicated summary statistic by
several factors in my data (specifically, the 90-50 income ratio by
city and race).

cityrace.by <- by(microdata, list(microdata$city,microdata$race),
function (x) quantile(x$income, probs=0.9) / quantile(x$income,
probs=0.5) )

I would now like to use the data created by by() as a dataset with
city-race as the unit of observation.

However, cityrace.data <- as.data.frame(cityrace.by) does not work  
because

"Error in as.data.frame.default(city.by) :
 cannot coerce class "by" into a data.frame"

The following is not a documented use of as.data.frame.table(), but it
seems to work.  It gives the columns slightly strange names, including
"Freq" for the statistic computed in by by() but otherwise, the
dataframe is indexed by city and race with the 90-50 ratio as the
variable

cityrace.data <- as.data.frame.table(cityrace.by)


If the by-object you get happens to be a 2d array, then why not.  
Tables are matrices after all.


> tt <- table(c(1,1), c(1,1))
> tt

1
  1 2
> is.matrix(tt)
[1] TRUE


--



David Winsemius, MD
Heritage Laboratories
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] Insert elements into a vector in a defined positions

2009-11-25 Thread Rolf Turner


On 26/11/2009, at 10:46 AM, Manuel Ramon wrote:



Dear R users,
I have a vector of length n and I want to insert some elements (in  
my case
the NA string) into a defined positions. For example, my vector is  
z1 and I
want to add NA's in positions 4, 6 y 7 so after that, my new  
vector, z2,

should have a length of 10+3.

  z1 <- 1:10
  id <- c(4,6,7)

  # And z2 should be:
  z2 <- c(1,2,3,NA,4,5,NA,NA,6,7,8,9,10)

Anyone knows how can I do that?


At first I thought append() might work ... but the "after"
argument to append seems to have to be of length 1.

How about:

z2 <- numeric(length(z1)+length(id))
z2[id] <- NA
z2[!is.na(z2)] <- z1

A bit kludgy, but it appears to work.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Interpretation of plots in linear regression models (verification of Gauss-Markov hypothesis)

2009-11-25 Thread jose romero
Hello R Gurus:

I'm doing a simple linear regression model:

modelo1 <- lm(X9 ~ 1 + X1 + I(log(X2)) + X3 + I(log(X4)) + X5 + I(log(X6)) + X7)

of which i later do a plot:

plot(modelo1)

This shows 4 graphics, about which I ask:

1) In the "Residuals vs. Fitted", what does the red curve represent?
2) What does the "scale-location" graphic show? How is it different from the 
"residuals vs. fitted? (I mean, changing the scale of the Y axis to show 
standarized residuals does not look like a big difference to me) What does the 
red curve represent in that graphic?
3) How do i interpret the whole "residuals vs. leverage" graphic and what is 
that "cook's distance" business about?

I'm basically intereseted in doing a residual analysis (you know, at least 
"visually" confirming the conditions of the gauss markov hypothesis).   I 
understand that the QQplot allows me to visually confirm if the residuals are 
normally distributed, but how do i use the other graphics to verify 
homocedasticity and independance of the residuals from the model variables?

Thanks in advance,

jose loreto romero




[[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 sum only a few elements in a line

2009-11-25 Thread David Winsemius


On Nov 25, 2009, at 3:45 PM, William Dunlap wrote:


-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Marcio Resende
Sent: Wednesday, November 25, 2009 12:27 PM
To: r-help@r-project.org
Subject: [R] How to sum only a few elements in a line


Hello,

I have a matrix with the numbers 0,1 and 9
I would like to write a function that could sum each line
skiping everytime
a number 9 appears
for example
[0 1 0 1 1 9 1]
the sum would be 4.
However I cannot replace 9 by 0 otherwise after the sum is
done I wouldn´t
be able to distiguish which ones were real zeros and which
ones were nines
replaced by zero just to sum.


One of the nice things about the S language is
that arguments functions are not altered by the
function.  When the function appears to alter
an argument it is really altering a copy of it.
Thus you can write a function like
   f <- function(matrix) {
   matrix[matrix==9] <- 0
   rowSums(matrix)
   }
and use it as

myMatrix <- rbind(c(0,1,0,1,1,9,1), c(9,9,9,9,9,17,9))
f(myMatrix)

   [1]  4 17


How about using the element-wise behavior of "*" when working with  
matrices?


> rowSums( myMatrix*(myMatrix != 9) )
[1]  4 17


myMatrix # not altered by running f over it

[,1] [,2] [,3] [,4] [,5] [,6] [,7]
   [1,]0101191
   [2,]99999   179

By the way, it would help if you wrote your example data
as an S expression, e.g., rbind(c(...),c(...)), and not
as an expression in some other language, "[ 1 1 9 ]".

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


Thank you very much

--



David Winsemius, MD
Heritage Laboratories
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] predict(): NoSuchMethodError

2009-11-25 Thread nstender49

I am currently working on a code which clusters attributes from a data set,
then uses a linear regression model to predict NA values in the data set. 
The code works for almost all cases, but then errors out on a case that
seems like it should work the same. 

This is the line of code that is giving me the problem:

NewClusterData[j,att] <- predict(cl,newdata = ClusterData[j,],type="class")

Here is the code for the arguments:

algName <- "LinearRegression"
Formula <- as.formula(paste(as.name(att), " ~ ",  paste(otherAtts, collapse=
"+")))
myAlg <- get(algName)
cl <- myAlg(Formula, data = Data)

And this is the error I'm getting:

Error in .jnew("weka/core/Attribute", attname[i]) :
java.lang.NoSuchMethodError: 

Here is the printout of the a working case:

cl = Linear Regression Model
  petallength =
   1.748  * sepallength +
  -1.4174 * sepalwidth +
  -2.1294
   
ClusterData[j,] = sepallength sepalwidth petallength petalwidth class
5.7   2.6   NA1
1

petallength = 4.148813

And the non-working case:

cl = Linear Regression Model
  petalwidth =
   0.8948 * class +
   0.3031
ClusterData[j,] = sepallength sepalwidth petallength petalwidth class
4.93 1.4NA  
0

Error in .jnew("weka/core/Attribute", attname[i]) : 
  java.lang.NoSuchMethodError: 

Thanks for any help that anyone can provide!
-- 
View this message in context: 
http://old.nabble.com/predict%28%29%3A-NoSuchMethodError-tp26521075p26521075.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] Feature request for as.Date() function 20)

2009-11-25 Thread nabble . 30 . miller_2555
On Wed, Nov 25, 2009 at 2:56 PM, jim holtman - jholt...@gmail.com
<+nabble+miller_2555+9dc9649aca.jholtman#gmail@spamgourmet.com>
wrote:
> Seems to work fine in my testing:
>
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>>
>> Similarly, the following command produces the same error:
>>    as.Date("NA")
>>
>> However, as.Date(NA) performs as documented.
>>
>> Can we enhance the as.Date() function to convert "NA" strings into NA
>> value prior to type conversion?

I sincerely appreciate the help, but with all due respect, I have read
the posting guide and did provide the minimal code necessary to
reproduce the desired feature. To reiterate, I would like to be able
to feed the character string "NA" to the as.Date() function to yield
the same result as `as.Date(NA)`. Please advise if testing the
following does not yield an error:
> as.Date("NA");

This may or may not aid the read.csv() error message in my particular
code (for which a workaround has already been identified).

Thank you.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] as.data.frame.table() to convert by() output to a data frame

2009-11-25 Thread Michael Ash
Dear all,

This seems to be working, but I'd like to make sure that I'm not doing
anything wrong.

I am using by() to construct a complicated summary statistic by
several factors in my data (specifically, the 90-50 income ratio by
city and race).

cityrace.by <- by(microdata, list(microdata$city,microdata$race),
function (x) quantile(x$income, probs=0.9) / quantile(x$income,
probs=0.5) )

I would now like to use the data created by by() as a dataset with
city-race as the unit of observation.

However, cityrace.data <- as.data.frame(cityrace.by) does not work because
"Error in as.data.frame.default(city.by) :
  cannot coerce class "by" into a data.frame"

The following is not a documented use of as.data.frame.table(), but it
seems to work.  It gives the columns slightly strange names, including
"Freq" for the statistic computed in by by() but otherwise, the
dataframe is indexed by city and race with the 90-50 ratio as the
variable

cityrace.data <- as.data.frame.table(cityrace.by)

Any objections?

Best,
Michael



-- 
Michael Ash, Associate Professor
  of Economics and Public Policy
Department of Economics and CPPA
University of Massachusetts
Amherst, MA 01003
Tel +1-413-545-6329 Fax +1-413-545-2921
Email m...@econs.umass.edu
http://people.umass.edu/maash

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Insert elements into a vector in a defined positions

2009-11-25 Thread Manuel Ramon

Dear R users,
I have a vector of length n and I want to insert some elements (in my case
the NA string) into a defined positions. For example, my vector is z1 and I
want to add NA's in positions 4, 6 y 7 so after that, my new vector, z2,
should have a length of 10+3. 

  z1 <- 1:10
  id <- c(4,6,7)

  # And z2 should be: 
  z2 <- c(1,2,3,NA,4,5,NA,NA,6,7,8,9,10)

Anyone knows how can I do that?
Thank you.

-
Manuel Ramón Fernández
Group of Reproductive Biology (GBR)
University of Castilla-La Mancha (Spain)
mra...@jccm.es
-- 
View this message in context: 
http://old.nabble.com/Insert-elements-into-a-vector-in-a-defined-positions-tp26520841p26520841.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] R installation error: perl not found

2009-11-25 Thread Cristian Opazo
Hello:

I'm trying to install R 2.10 on a Linux 64-bit machine running RHE4 using the 
"R-core-2.10.0-2.el4.i386.rpm" install package I downloaded from 
http://cran.opensourceresources.org/. After executing the RPM, the system looks 
for package dependencies and I get the following error message: 

Package not found
The following package could not be found in your system. Installation cannot 
continue until it is installed.
Unlocatable package: perl (File::Copy::Recursive)
Required by ('R-core', '2.10.0', '2.el4')

The strange thing is that I've updated my system to the latest RHE-blessed 
version of perl already:

[r...@bunuel bin]# perl -v
This is perl, v5.8.5 built for x86_64-linux-thread-multi
Copyright 1987-2004, Larry Wall

I tried installing the 32-bit version but ran into the same problem (no perl 
package found).

Please help... and Happy Thanksgiving to everybody!

Thanks,

Cristian

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] R or C++ on FreeNX servers

2009-11-25 Thread Murray Jorgensen

Hi all,

I have just found out that the machine learning group in our Faculty has 
a lot of spare capacity on their FreeNX servers. I do not know a lot 
about these beasts but I understand that they are a free version of 
something produced by a firm called "NoMachine".


They are designed for executing parallel algorithms and I thought that 
they might be of use in a project of mine comparing different 
model-fitting algorithms from the point of view of sensitivity to 
starting values.


Anyway before revealing my near-total ignorance to my computer science 
colleagues I thought I would ask if any of my fellow R users have any 
experience with these things and possibly advice to offer. The CS people 
 are probably using the servers in conjunction with Java or C++ and I 
could possibly use the latter of these. I wondered, though, if R could 
be used directly with such hardware and if so, how the parallelizing 
would be handled.



Regards,   Murray Jorgensen

--
Dr Murray Jorgensen  http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: m...@waikato.ac.nzFax 7 838 4155
Phone  +64 7 838 4773 wkHome +64 7 825 0441   Mobile 021 0200 8350

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Reading from Google Docs

2009-11-25 Thread Farrel Buchinsky
Oh OH! Could you please help with a problem that I never used to get.

library(RGoogleDocs)
ps <-readline(prompt="get the password in ")
sheets.con = getGoogleDocsConnection(getGoogleAuth("fjb...@gmail.com", ps,
service ="wise"))
ts2=getWorksheets("OnCall",sheets.con)

Those opening lines of script used to work flawlesly. Now I get.
Error in getDocs(con) : problems connecting to get the list of documents

Yet I got it to work earlier while I had been toying with RGoogleData
package in another session. Could RGoogleData have opened something for
RGoogleDocs to use?

Farrel Buchinsky
Google Voice Tel: (412) 567-7870

Sent from Pittsburgh, Pennsylvania, United States

On Wed, Nov 25, 2009 at 16:34, Farrel Buchinsky  wrote:

> That was painless. I had already installed Rtools and had already put it on
> my path.
>
> Your line worked very well. [Thanks for telling me. However I did it last
> time was worse than sticking daggers in my eyes. ]
>  install.packages( "RGoogleDocs", repos="http://www.omegahat.org/R";, 
> type="source"
> )
>
> I now have
> Package: RGoogleDocs
> Version: 0.4-0
> Title:
> 
> Maintainer: Duncan Temple Lang 
> Packaged: 2009-10-27 22:10:22 UTC; duncan
> Built: R 2.10.0; ; 2009-11-25 20:59:03 UTC; windows
>
> I am providing the following link to a copy of my RGoogleDocs zipped
> directory. It is for people who run R in windows and do not want to go
> through the pain of setting things up so that they can install source.
> http://dl.dropbox.com/u/23200/RGoogleDocs/RGoogleDocs.zip
>
> I BELIEVE that if one downloads the zip and extracts it to an empty
> directory called RGoogleDocs in one's Library directory then everything will
> work. Please let me know.
>
> Farrel Buchinsky
> Google Voice Tel: (412) 567-7870
>
>
>
> On Wed, Nov 25, 2009 at 15:15, Charlie Sharpsteen wrote:
>
>> On Wed, Nov 25, 2009 at 12:02 PM, Farrel Buchinsky 
>> wrote:
>> > I reinstalled from a binary that Duncan Temple Lang placed in omegahat.
>> I
>> > see that omegahat has a subdirectory for each version of R. There is not
>> a
>> > directory for 2.10. I took the liberty of taking it from the 2.9
>> directory.
>>
>> That explains the warning message.
>>
>> > Who knows what crime I committed. Is that first or third degree murder.
>>
>> Well, it's just a warning-- so it shouldn't be a show-stopper.  And
>> from what I see the warning is only referring to the package help
>> pages, which are available online.  It looks like the functionality of
>> the package should still work just fine if you don't want to bother
>> with a reinstall.
>>
>> > I saw however that there is a far more recent version of RGoogleDocs
>> (Last
>> > Release: 0.4-0 (27 Oct 2009)). But it is in tar.gz. I assume that it is
>> in
>> > source. Once before I spent about 27000 hours getting a source to become
>> a
>> > binary. I don't know how I finally got it right and am reluctant to
>> wander
>> > into that swamp again.
>> > Farrel Buchinsky
>>
>> This shouldn't be extraordinarily difficult-- unfortunately Murphy's
>> Law does come into play sometimes.  But it should just be a matter of:
>>
>>  install.packages( "RGoogleDocs", repos="http://www.omegahat.org/R";,
>> type="source" )
>>
>> And that's it for Linux, Mac OS or other UNIX-based system.  With
>> Windows you will first have to install the toolset available at:
>>
>>  http://www.murdoch-sutherland.com/Rtools/
>>
>> Grab the "Rtools210" installer as you are using R 2.10.x.  Install
>> using the "Package Authoring" option and make sure you check any
>> options that ask about modifying your PATH.
>>
>> Good luck!
>>
>> -Charlie
>>
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R Packages Crack the 3,000 Mark!

2009-11-25 Thread Stephan Kolassa

Hi Bob,

Muenchen, Robert A (Bob) wrote:


Does anyone have a program that graphs the growth of R packages? I don't
know if that historical data is around.


John Fox had a slide on this in his useR 2008 talk "The Social 
Organization of the R Project" (page 7), with package counts up to March 
2008. As "Source of Data" he gave https://svn.r-project.org/R/branches/. 
I've been digging around in there but really have no idea how he found 
the relevant data there.


I'd be quite interested in this, too, so if you find out anything please 
drop me a line...


Best,
Stephan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Feature request for as.Date() function

2009-11-25 Thread smu
hi,

it fails, when the NA is surrounded by double quotes, which is the
default way of quoting of the write.table command.

x <- read.csv(textConnection('date,value
+ + 2009-01-01,10
+ + 2009-02-01,1
+ + "NA", 3'), colClasses=c("Date", 'integer'))
Fehler in fromchar(x) : 
character string is not in a standard unambiguous format

regards,
 stefan


On Wed, Nov 25, 2009 at 02:56:56PM -0500, jim holtman wrote:
> Seems to work fine in my testing:
> 
> > x <- read.csv(textConnection("date,value
> + 2009-01-01,10
> + 2009-02-01,1
> + 'NA', 3"), colClasses=c("Date", 'integer'))
> >
> > str(x)
> 'data.frame':   3 obs. of  2 variables:
>  $ date :Class 'Date'  num [1:3] 14245 14276 NA
>  $ value: int  10 1 3
> > x <- read.csv(textConnection("date,value
> + 2009-01-01,10
> + 2009-02-01,1
> + NA, 3"), colClasses=c("Date", 'integer'))
> >
> > str(x)
> 'data.frame':   3 obs. of  2 variables:
>  $ date :Class 'Date'  num [1:3] 14245 14276 NA
>  $ value: int  10 1 3
> >
> 
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> On Wed, Nov 25, 2009 at 12:38 PM,
>  wrote:
> > Hello -
> >
> > I have a csv file with a few date columns. Some of the records have an
> > "NA" character string instead of the date. When I attempt to use
> > read.csv() and typecast the columns using colClasses, I receive the
> > following error:
> >    Error in charToDate(x) :
> >      character string is not in a standard unambiguous format
> >
> > Similarly, the following command produces the same error:
> >    as.Date("NA")
> >
> > However, as.Date(NA) performs as documented.
> >
> > Can we enhance the as.Date() function to convert "NA" strings into NA
> > value prior to type conversion?
> >
> > Thanks!
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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?
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Reading from Google Docs

2009-11-25 Thread Farrel Buchinsky
That was painless. I had already installed Rtools and had already put it on
my path.

Your line worked very well. [Thanks for telling me. However I did it last
time was worse than sticking daggers in my eyes. ]
 install.packages( "RGoogleDocs", repos="http://www.omegahat.org/R";,
type="source"
)

I now have
Package: RGoogleDocs
Version: 0.4-0
Title:

Maintainer: Duncan Temple Lang 
Packaged: 2009-10-27 22:10:22 UTC; duncan
Built: R 2.10.0; ; 2009-11-25 20:59:03 UTC; windows

I am providing the following link to a copy of my RGoogleDocs zipped
directory. It is for people who run R in windows and do not want to go
through the pain of setting things up so that they can install source.
http://dl.dropbox.com/u/23200/RGoogleDocs/RGoogleDocs.zip

I BELIEVE that if one downloads the zip and extracts it to an empty
directory called RGoogleDocs in one's Library directory then everything will
work. Please let me know.

Farrel Buchinsky
Google Voice Tel: (412) 567-7870



On Wed, Nov 25, 2009 at 15:15, Charlie Sharpsteen wrote:

> On Wed, Nov 25, 2009 at 12:02 PM, Farrel Buchinsky 
> wrote:
> > I reinstalled from a binary that Duncan Temple Lang placed in omegahat. I
> > see that omegahat has a subdirectory for each version of R. There is not
> a
> > directory for 2.10. I took the liberty of taking it from the 2.9
> directory.
>
> That explains the warning message.
>
> > Who knows what crime I committed. Is that first or third degree murder.
>
> Well, it's just a warning-- so it shouldn't be a show-stopper.  And
> from what I see the warning is only referring to the package help
> pages, which are available online.  It looks like the functionality of
> the package should still work just fine if you don't want to bother
> with a reinstall.
>
> > I saw however that there is a far more recent version of RGoogleDocs
> (Last
> > Release: 0.4-0 (27 Oct 2009)). But it is in tar.gz. I assume that it is
> in
> > source. Once before I spent about 27000 hours getting a source to become
> a
> > binary. I don't know how I finally got it right and am reluctant to
> wander
> > into that swamp again.
> > Farrel Buchinsky
>
> This shouldn't be extraordinarily difficult-- unfortunately Murphy's
> Law does come into play sometimes.  But it should just be a matter of:
>
>  install.packages( "RGoogleDocs", repos="http://www.omegahat.org/R";,
> type="source" )
>
> And that's it for Linux, Mac OS or other UNIX-based system.  With
> Windows you will first have to install the toolset available at:
>
>  http://www.murdoch-sutherland.com/Rtools/
>
> Grab the "Rtools210" installer as you are using R 2.10.x.  Install
> using the "Package Authoring" option and make sure you check any
> options that ask about modifying your PATH.
>
> Good luck!
>
> -Charlie
>

[[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] order of panels in xyplots

2009-11-25 Thread Peter Ehlers


Titus Malsburg wrote:

The documentation of xyplot could be improved here.  It says:

  "If 'index.cond' is a list, it has to be as long as the number of conditioning
   variables, and the 'i'-th component has to be a valid indexing vector for the
   integer vector '1:nlevels(g_i)' (which can, among other things, repeat some
   of the levels or drop some altogether)."

It should make explicit that nlevels is the number of levels actually
used in the data and not length(levels(f)).


It does say "... _valid_ indexing vector ..." (my emphasis).
If nlevels(g) = 5, but you're only plotting 3 panels, it seems
to me that c(3,1,5) might be a valid indexing vector.

 -Peter Ehlers


Cheers,

   Titus

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] R or C++ on FreeNX servers

2009-11-25 Thread Tobias Verbeke

Hi Murray,

Murray Jorgensen wrote:


I have just found out that the machine learning group in our Faculty has
a lot of spare capacity on their FreeNX servers. I do not know a lot
about these beasts but I understand that they are a free version of
something produced by a firm called "NoMachine".

They are designed for executing parallel algorithms and I thought that
they might be of use in a project of mine comparing different
model-fitting algorithms from the point of view of sensitivity to
starting values.


As far as I know FreeNX is an implementation of a protocol that
allows to connect to remote X sessions (X being the standard
windowing system for *nix systems) in an optimized way.

There is (in my understanding) no relationship to parallel algorithm
execution. Using a NX client, you can connect to a remote (often
more powerful) machine (potentially making use of multiple cores on
that machine in a parallel way), but the FreeNX part of it is just
about having the remote machine's GUI forwarded such that you can
work "on the server" (in a window on) on your desktop machine.

HTH,
Tobias


Anyway before revealing my near-total ignorance to my computer science
colleagues I thought I would ask if any of my fellow R users have any
experience with these things and possibly advice to offer. The CS people
 are probably using the servers in conjunction with Java or C++ and I
could possibly use the latter of these. I wondered, though, if R could
be used directly with such hardware and if so, how the parallelizing
would be handled.


Regards,   Murray Jorgensen



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lattice: plotting in a loop

2009-11-25 Thread Ryan Archer
Ah, it's a FAQ ... thought I'd looked hard enough.  The ignominy, and for a
first post!  Well, in any case, thanks a lot Baptiste.

2009/11/25 baptiste auguie 

> Hi,
> it's a FAQ, you need to print() the plot,
>
>
> http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
>
> baptiste
>
> 2009/11/25 Ryan Archer :
> > Hi,
> >
> > I'm having trouble seeing graphics output from lattice xyplot() when
> called
> > from inside a for loop:
> >
> > x <- 1:50
> > for ( i in 1:5 ) {
> >  y <- rnorm(x)
> >  xyplot(y~x)  # no graphics when inside for-loop
> > # plot(x,y)# works fine
> > # Sys.sleep(0.5)   # doesn't seem to help
> > }
> >
> > The xyplot() is fine outside the loop.  Results are the same to X11
> device
> > and to file devices.
> >
> > I have noticed that there is a delay proportional to the size of the
> loop,
> > so presumably xyplot() is computing although the results aren't reaching
> the
> > graphics device.
> >
> > Can anyone suggest a cause or remedy?
> >
> > This is my first post to the list, although I've picked up a lot of
> useful
> > information reading here!
> >
> > -Ryan
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to sum only a few elements in a line

2009-11-25 Thread Peter Ehlers


Marcio Resende wrote:

Hello,

I have a matrix with the numbers 0,1 and 9
I would like to write a function that could sum each line skiping everytime
a number 9 appears
for example
[0 1 0 1 1 9 1]
the sum would be 4.
However I cannot replace 9 by 0 otherwise after the sum is done I wouldn´t
be able to distiguish which ones were real zeros and which ones were nines
replaced by zero just to sum.
Thank you very much


In order to distinguish 'real' 0s from those resulting
from elimination of 9s (without going back to the original
matrix), you can do this:

f <- function(x){
  Sum <- sum(x[x != 9])
  has_9 <- 9 %in% x
  c(Sum = Sum, has_9 = has_9)
}

# make a sample matrix
M <- matrix(sample(c(0,1,9), 30, TRUE), 6, 5)

# get sums and whether the row contained one or more 9s
t(apply(M, 1, f))

 -Peter Ehlers

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lattice: plotting in a loop

2009-11-25 Thread baptiste auguie
Hi,
it's a FAQ, you need to print() the plot,

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f

baptiste

2009/11/25 Ryan Archer :
> Hi,
>
> I'm having trouble seeing graphics output from lattice xyplot() when called
> from inside a for loop:
>
> x <- 1:50
> for ( i in 1:5 ) {
>  y <- rnorm(x)
>  xyplot(y~x)          # no graphics when inside for-loop
> # plot(x,y)            # works fine
> # Sys.sleep(0.5)       # doesn't seem to help
> }
>
> The xyplot() is fine outside the loop.  Results are the same to X11 device
> and to file devices.
>
> I have noticed that there is a delay proportional to the size of the loop,
> so presumably xyplot() is computing although the results aren't reaching the
> graphics device.
>
> Can anyone suggest a cause or remedy?
>
> This is my first post to the list, although I've picked up a lot of useful
> information reading here!
>
> -Ryan
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R or C++ on FreeNX servers

2009-11-25 Thread Cedrick W. Johnson
All FreeNX allows you to do is access a regular linux machine using X 
over SSH as opposed to ssh'ing in, redirecting the X-display back to 
your local machine (running a xserver locally)..


You can install R on the machine(s) just as you would normally, and if 
the machines are in some sort of clustered environment,  you could setup 
the packages specifically available on linux for R to do that (snow, 
multicore, etc...)


Check out FreeNX here http://freenx.berlios.de/

hth
-c

Murray Jorgensen wrote:

Hi all,

I have just found out that the machine learning group in our Faculty has
a lot of spare capacity on their FreeNX servers. I do not know a lot
about these beasts but I understand that they are a free version of
something produced by a firm called "NoMachine".

They are designed for executing parallel algorithms and I thought that
they might be of use in a project of mine comparing different
model-fitting algorithms from the point of view of sensitivity to
starting values.

Anyway before revealing my near-total ignorance to my computer science
colleagues I thought I would ask if any of my fellow R users have any
experience with these things and possibly advice to offer. The CS people
 are probably using the servers in conjunction with Java or C++ and I
could possibly use the latter of these. I wondered, though, if R could
be used directly with such hardware and if so, how the parallelizing
would be handled.


Regards,   Murray Jorgensen



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lattice: plotting in a loop

2009-11-25 Thread Ryan Archer
Hi,

I'm having trouble seeing graphics output from lattice xyplot() when called
from inside a for loop:

x <- 1:50
for ( i in 1:5 ) {
  y <- rnorm(x)
  xyplot(y~x)  # no graphics when inside for-loop
# plot(x,y)# works fine
# Sys.sleep(0.5)   # doesn't seem to help
}

The xyplot() is fine outside the loop.  Results are the same to X11 device
and to file devices.

I have noticed that there is a delay proportional to the size of the loop,
so presumably xyplot() is computing although the results aren't reaching the
graphics device.

Can anyone suggest a cause or remedy?

This is my first post to the list, although I've picked up a lot of useful
information reading here!

-Ryan

[[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] R or C++ on FreeNX servers

2009-11-25 Thread Murray Jorgensen

Hi all,

I have just found out that the machine learning group in our Faculty has
a lot of spare capacity on their FreeNX servers. I do not know a lot
about these beasts but I understand that they are a free version of
something produced by a firm called "NoMachine".

They are designed for executing parallel algorithms and I thought that
they might be of use in a project of mine comparing different
model-fitting algorithms from the point of view of sensitivity to
starting values.

Anyway before revealing my near-total ignorance to my computer science
colleagues I thought I would ask if any of my fellow R users have any
experience with these things and possibly advice to offer. The CS people
 are probably using the servers in conjunction with Java or C++ and I
could possibly use the latter of these. I wondered, though, if R could
be used directly with such hardware and if so, how the parallelizing
would be handled.


Regards,   Murray Jorgensen

--
Dr Murray Jorgensen  http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: m...@waikato.ac.nzFax 7 838 4155
Phone  +64 7 838 4773 wkHome +64 7 825 0441   Mobile 021 0200 8350

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 sum only a few elements in a line

2009-11-25 Thread David Winsemius


On Nov 25, 2009, at 3:27 PM, Marcio Resende wrote:



Hello,

I have a matrix with the numbers 0,1 and 9
I would like to write a function that could sum each line skiping  
everytime

a number 9 appears
for example
[0 1 0 1 1 9 1]


sum(x[x != 9])


the sum would be 4.
However I cannot replace 9 by 0 otherwise after the sum is done I  
wouldn´t
be able to distiguish which ones were real zeros and which ones were  
nines

replaced by zero just to sum.
Thank you very much

--


David Winsemius, MD
Heritage Laboratories
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] How to sum only a few elements in a line

2009-11-25 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Marcio Resende
> Sent: Wednesday, November 25, 2009 12:27 PM
> To: r-help@r-project.org
> Subject: [R] How to sum only a few elements in a line
> 
> 
> Hello,
> 
> I have a matrix with the numbers 0,1 and 9
> I would like to write a function that could sum each line 
> skiping everytime
> a number 9 appears
> for example
> [0 1 0 1 1 9 1]
> the sum would be 4.
> However I cannot replace 9 by 0 otherwise after the sum is 
> done I wouldn´t
> be able to distiguish which ones were real zeros and which 
> ones were nines
> replaced by zero just to sum.

One of the nice things about the S language is
that arguments functions are not altered by the
function.  When the function appears to alter
an argument it is really altering a copy of it.
Thus you can write a function like
f <- function(matrix) {
matrix[matrix==9] <- 0
rowSums(matrix)
}
and use it as
> myMatrix <- rbind(c(0,1,0,1,1,9,1), c(9,9,9,9,9,17,9))
> f(myMatrix)
[1]  4 17
> myMatrix # not altered by running f over it
 [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]0101191
[2,]99999   179

By the way, it would help if you wrote your example data
as an S expression, e.g., rbind(c(...),c(...)), and not
as an expression in some other language, "[ 1 1 9 ]".

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> Thank you very much
> 
> -- 
> View this message in context: 
> http://old.nabble.com/How-to-sum-only-a-few-elements-in-a-line
-tp26519740p26519740.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to sum only a few elements in a line

2009-11-25 Thread Peter Alspach
Tena koe Marcio

Try something like (untested)

apply(yourMatrix, 1, function(x) sum(x[x!=9])) 

HTH ...

Peter Alspach

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Marcio Resende
> Sent: Thursday, 26 November 2009 9:27 a.m.
> To: r-help@r-project.org
> Subject: [R] How to sum only a few elements in a line
> 
> 
> Hello,
> 
> I have a matrix with the numbers 0,1 and 9 I would like to 
> write a function that could sum each line skiping everytime a 
> number 9 appears for example [0 1 0 1 1 9 1] the sum would be 4.
> However I cannot replace 9 by 0 otherwise after the sum is 
> done I wouldn´t be able to distiguish which ones were real 
> zeros and which ones were nines replaced by zero just to sum.
> Thank you very much
> 
> --
> View this message in context: 
> http://old.nabble.com/How-to-sum-only-a-few-elements-in-a-line
> -tp26519740p26519740.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Grouped Barplot

2009-11-25 Thread Gary
I'm able to add legend. ~Gary

On Wed, Nov 25, 2009 at 3:15 PM, Gary  wrote:

> Thanks David. I reduced the data set and its copied below (also attached to
> this email as text file). Now N=50, Only 2 years, Only 2 Cities. I tried:
>
> foo<-read.table("SampleData.txt", header=TRUE)
> boxplot(foo$admit ~ foo$city + foo$year, col=2:3)
>
> I need some help with:
> 1) Defining labels for x-axis (just "2000" and "2001").
> 2) Removing gap between cities boxplots (but leaving gap between years).
> 3) Adding "MEAN" to the boxplots.
>
>
> city   year   admit
> Asheville2000   0
>  Asheville2000   0
> Asheville2000   1
> Asheville2000   2
> Asheville2000   2
> Asheville2000   0
> Asheville2000   1
> Asheville2000   0
> Asheville2000   0
> Asheville2000   0
> Asheville2000   2
> Asheville2000   3
> Asheville2000   1
> Asheville2000   2
> Asheville2000   1
> Asheville2000   1
> Asheville2000   0
> Asheville2000   0
> Asheville2000   1
> Asheville2001   1
> Asheville2001   3
> Asheville2001   0
> Asheville2001   0
> Asheville2001   2
> Asheville2001   3
> Asheville2001   3
> Charlotte2000   5
> Charlotte2000   1
> Charlotte2000   0
> Charlotte2000   4
> Charlotte2000   1
> Charlotte2000   3
> Charlotte2000   0
> Charlotte2000   3
> Charlotte2000   3
> Charlotte2000   3
> Charlotte2000   2
> Charlotte2000   1
> Charlotte2000   1
> Charlotte2000   3
> Charlotte2001   1
> Charlotte2001   4
> Charlotte2001   2
> Charlotte2001   4
> Charlotte2001   3
> Charlotte2001   3
> Charlotte2001   1
> Charlotte2001   7
> Charlotte2001   4
> Charlotte2001   1
>
> Sample: http://www.imachordata.com/wp-content/uploads/2009/09/boxplot.png
>
> Thanks!
>
>
> On Wed, Nov 25, 2009 at 2:45 PM, David Winsemius 
> wrote:
>
>>
>> On Nov 25, 2009, at 1:48 PM, Gary wrote:
>>
>>  Hi R Users,
>>>
>>> I tried plotting a similar boxplot as it is on the FOLLOWING LINK:
>>>
>>> http://www.imachordata.com/wp-content/uploads/2009/09/boxplot.png
>>>
>>
>> Looks like a product of a function from ggplot2. In fact trimming that URL
>> brings you to a page with the code that created it!
>>
>>>
>>> Sample data is attached --
>>>
>>
>> No, it's not. Read the Posting Guide for what file types are acceptable to
>> the server. I suspect you will get better success if the extension is
>> ".txt", even if it is comma separated.
>>
>> Or better yet follow the directions there for posting data in a form that
>> can be enclosed in your posting and  copy-pasted into the console session.
>>
>>
>>
>>  there are 9 years and 5 cities. In my case I'm
>>> looking to plot "Year" on x-axis and grouping boxplots by "City". I tried
>>> the following code.
>>>
>>> foo<-read.table("SampleData.csv", sep=",", header=TRUE)
>>> attach(foo)
>>> boxplot(Admit ~ City + Year, range=0.5, col=2:6) # its not solving the
>>> purpose
>>>
>>> I need some help with:
>>> 1) Plotting only 9 labels on x-axis (1996-2004).
>>> 2) For each "Year", I need to plot FIVE boxplots -- one for each "City".
>>> [so
>>> it will look like nine clusters with five boxplots each (with no gap
>>> between
>>> them, but with gaps between year labels].
>>> 3) Adding "MEAN" to the boxplots.
>>> 4) And, legend including "color" + "city name".
>>>
>>> Any help would be greatly appreciated!
>>>
>>>
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> 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.


Re: [R] Reading from Google Docs

2009-11-25 Thread Charlie Sharpsteen
On Wed, Nov 25, 2009 at 12:02 PM, Farrel Buchinsky  wrote:
> I reinstalled from a binary that Duncan Temple Lang placed in omegahat. I
> see that omegahat has a subdirectory for each version of R. There is not a
> directory for 2.10. I took the liberty of taking it from the 2.9 directory.

That explains the warning message.

> Who knows what crime I committed. Is that first or third degree murder.

Well, it's just a warning-- so it shouldn't be a show-stopper.  And
from what I see the warning is only referring to the package help
pages, which are available online.  It looks like the functionality of
the package should still work just fine if you don't want to bother
with a reinstall.

> I saw however that there is a far more recent version of RGoogleDocs (Last
> Release: 0.4-0 (27 Oct 2009)). But it is in tar.gz. I assume that it is in
> source. Once before I spent about 27000 hours getting a source to become a
> binary. I don't know how I finally got it right and am reluctant to wander
> into that swamp again.
> Farrel Buchinsky

This shouldn't be extraordinarily difficult-- unfortunately Murphy's
Law does come into play sometimes.  But it should just be a matter of:

  install.packages( "RGoogleDocs", repos="http://www.omegahat.org/R";,
type="source" )

And that's it for Linux, Mac OS or other UNIX-based system.  With
Windows you will first have to install the toolset available at:

 http://www.murdoch-sutherland.com/Rtools/

Grab the "Rtools210" installer as you are using R 2.10.x.  Install
using the "Package Authoring" option and make sure you check any
options that ask about modifying your PATH.

Good luck!

-Charlie

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Mysterious R script behavior when called from webserver

2009-11-25 Thread Dylan Beaudette
On Wednesday 25 November 2009, Barry Rowlingson wrote:
> On Wed, Nov 25, 2009 at 8:15 PM, Dylan Beaudette
>
>  wrote:
> > Hi,
> >
> > I am trying to transition a system based on dynamic image generation (via
> > R) from our development system to a production environment. Our R script
> > functions as expected when run by a regular user. However the script dies
> > when calling the png() function, when started by the webserver user.
> >
> > Here are some details
> >
> >>sessionInfo()
> >
> > R version 2.9.2 (2009-08-24)
> > i686-pc-linux-gnu
> > locale:
> > C
> > attached base packages:
> > [1] stats     graphics  grDevices utils     datasets  methods   base
> >
> > The script gets to this line:
> >
> > png(file=filename, width=600, height=400)
> >
> > and then dies. It leaves an empty PNG file where it should be, however it
> > never finishes the file. If
> >
> > I replace png() with pdf() an output file is generated and closed by
> > dev.off() as expected.
> >
> > It seems like the environment is setup just as when started by a regular
> > user, specifically the LD_LIBRARY_PATH variable.
> >
> > This behavior suggests that R is encountering an error, and stopping.
> > However there is no reporting of the error. Is there any way to get more
> > verbose error reporting?
>
>  How is R run from your web server? Does it start a new R process or
> is it an apache module thing with a dynamically linked R (if such a
> thing even exists)? Can't figure out how you could get more error
> reporting without knowing that - you need to see where stderr is
> going, possibly to the apache error.log file - have you looked there?
>
>  Have you tried a trivial png generating example, just a three liner:
>
> png(file="/tmp/wherever/foo.png")
> plot(1:10)
> dev.off()
>
>  just in case it's something else previous in your script that's
> breaking things.
>
>  In the old days of R you needed an X11 display connection to do PNG
> graphics, but that was fixed before 2.9, I think. Try it interactively
> but unset the DISPLAY variable first:
>
>  export -n DISPLAY
>  R
>
>   > png(... etc etc)
>
>  Does that work?
>
> Barry

Hi Barry thanks for the tips. I was able to get more error reporting by 
placing the png() function inside of try(). Turns out this was an X11 related 
problem-- probably an unset DISPLAY variable for the www user. 

For the record, R was being run by PHP. I just realized that R was not 
compiled with Cairo support-- fixing this should make the problems go away...

Cheers,
Dylan



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Mysterious R script behavior when called from webserver

2009-11-25 Thread Barry Rowlingson
On Wed, Nov 25, 2009 at 8:15 PM, Dylan Beaudette
 wrote:
> Hi,
>
> I am trying to transition a system based on dynamic image generation (via R)
> from our development system to a production environment. Our R script
> functions as expected when run by a regular user. However the script dies
> when calling the png() function, when started by the webserver user.
>
> Here are some details
>
>>sessionInfo()
> R version 2.9.2 (2009-08-24)
> i686-pc-linux-gnu
> locale:
> C
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> The script gets to this line:
>
> png(file=filename, width=600, height=400)
>
> and then dies. It leaves an empty PNG file where it should be, however it
> never finishes the file. If
>
> I replace png() with pdf() an output file is generated and closed by dev.off()
> as expected.
>
> It seems like the environment is setup just as when started by a regular user,
> specifically the LD_LIBRARY_PATH variable.
>
> This behavior suggests that R is encountering an error, and stopping. However
> there is no reporting of the error. Is there any way to get more verbose
> error reporting?

 How is R run from your web server? Does it start a new R process or
is it an apache module thing with a dynamically linked R (if such a
thing even exists)? Can't figure out how you could get more error
reporting without knowing that - you need to see where stderr is
going, possibly to the apache error.log file - have you looked there?

 Have you tried a trivial png generating example, just a three liner:

png(file="/tmp/wherever/foo.png")
plot(1:10)
dev.off()

 just in case it's something else previous in your script that's
breaking things.

 In the old days of R you needed an X11 display connection to do PNG
graphics, but that was fixed before 2.9, I think. Try it interactively
but unset the DISPLAY variable first:

 export -n DISPLAY
 R
  > png(... etc etc)

 Does that work?

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.


Re: [R] order of panels in xyplots

2009-11-25 Thread Titus Malsburg
The documentation of xyplot could be improved here.  It says:

  "If 'index.cond' is a list, it has to be as long as the number of conditioning
   variables, and the 'i'-th component has to be a valid indexing vector for the
   integer vector '1:nlevels(g_i)' (which can, among other things, repeat some
   of the levels or drop some altogether)."

It should make explicit that nlevels is the number of levels actually
used in the data and not length(levels(f)).

Cheers,

   Titus

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] error with hmm()?

2009-11-25 Thread Alon Ben-Ari
Hello R users,

I am suing library(hmm.discnp)
I have a vector
y
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0
 [741] 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 2 2 1 0 0 0 0 0"

So I did

y=y+1  (Otherwise  R crahsed)

"... 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 1
 [741] 1 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 3 3 2 1 1 ..."

I try to fit a hidden markov model  with two states.
hmm(y,K=2)
and this is what I get

Error in FUN(X[[1L]], ...) : subscript out of bounds?

where is my error?
Thanks,
below is the system I use.

version.string R version 2.8.1 (2008-12-22)
platform   i686-suse-linux-gnu

[[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 sum only a few elements in a line

2009-11-25 Thread Marcio Resende

Hello,

I have a matrix with the numbers 0,1 and 9
I would like to write a function that could sum each line skiping everytime
a number 9 appears
for example
[0 1 0 1 1 9 1]
the sum would be 4.
However I cannot replace 9 by 0 otherwise after the sum is done I wouldn´t
be able to distiguish which ones were real zeros and which ones were nines
replaced by zero just to sum.
Thank you very much

-- 
View this message in context: 
http://old.nabble.com/How-to-sum-only-a-few-elements-in-a-line-tp26519740p26519740.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] Grouped Barplot

2009-11-25 Thread Gary
Thanks David. I reduced the data set and its copied below (also attached to
this email as text file). Now N=50, Only 2 years, Only 2 Cities. I tried:

foo<-read.table("SampleData.txt", header=TRUE)
boxplot(foo$admit ~ foo$city + foo$year, col=2:3)

I need some help with:
1) Defining labels for x-axis (just "2000" and "2001").
2) Removing gap between cities boxplots (but leaving gap between years).
3) Adding "MEAN" to the boxplots.
4) Adding legend including "color" + "city name".

city   year   admit
Asheville2000   0
Asheville2000   0
Asheville2000   1
Asheville2000   2
Asheville2000   2
Asheville2000   0
Asheville2000   1
Asheville2000   0
Asheville2000   0
Asheville2000   0
Asheville2000   2
Asheville2000   3
Asheville2000   1
Asheville2000   2
Asheville2000   1
Asheville2000   1
Asheville2000   0
Asheville2000   0
Asheville2000   1
Asheville2001   1
Asheville2001   3
Asheville2001   0
Asheville2001   0
Asheville2001   2
Asheville2001   3
Asheville2001   3
Charlotte2000   5
Charlotte2000   1
Charlotte2000   0
Charlotte2000   4
Charlotte2000   1
Charlotte2000   3
Charlotte2000   0
Charlotte2000   3
Charlotte2000   3
Charlotte2000   3
Charlotte2000   2
Charlotte2000   1
Charlotte2000   1
Charlotte2000   3
Charlotte2001   1
Charlotte2001   4
Charlotte2001   2
Charlotte2001   4
Charlotte2001   3
Charlotte2001   3
Charlotte2001   1
Charlotte2001   7
Charlotte2001   4
Charlotte2001   1

Sample: http://www.imachordata.com/wp-content/uploads/2009/09/boxplot.png

Thanks!


On Wed, Nov 25, 2009 at 2:45 PM, David Winsemius wrote:

>
> On Nov 25, 2009, at 1:48 PM, Gary wrote:
>
>  Hi R Users,
>>
>> I tried plotting a similar boxplot as it is on the FOLLOWING LINK:
>>
>> http://www.imachordata.com/wp-content/uploads/2009/09/boxplot.png
>>
>
> Looks like a product of a function from ggplot2. In fact trimming that URL
> brings you to a page with the code that created it!
>
>>
>> Sample data is attached --
>>
>
> No, it's not. Read the Posting Guide for what file types are acceptable to
> the server. I suspect you will get better success if the extension is
> ".txt", even if it is comma separated.
>
> Or better yet follow the directions there for posting data in a form that
> can be enclosed in your posting and  copy-pasted into the console session.
>
>
>
>  there are 9 years and 5 cities. In my case I'm
>> looking to plot "Year" on x-axis and grouping boxplots by "City". I tried
>> the following code.
>>
>> foo<-read.table("SampleData.csv", sep=",", header=TRUE)
>> attach(foo)
>> boxplot(Admit ~ City + Year, range=0.5, col=2:6) # its not solving the
>> purpose
>>
>> I need some help with:
>> 1) Plotting only 9 labels on x-axis (1996-2004).
>> 2) For each "Year", I need to plot FIVE boxplots -- one for each "City".
>> [so
>> it will look like nine clusters with five boxplots each (with no gap
>> between
>> them, but with gaps between year labels].
>> 3) Adding "MEAN" to the boxplots.
>> 4) And, legend including "color" + "city name".
>>
>> Any help would be greatly appreciated!
>>
>>
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>
city   year   admit
Asheville2000   0
Asheville2000   0
Asheville2000   1
Asheville2000   2
Asheville2000   2
Asheville2000   0
Asheville2000   1
Asheville2000   0
Asheville2000   0
Asheville2000   0
Asheville2000   2
Asheville2000   3
Asheville2000   1
Asheville2000   2
Asheville2000   1
Asheville  

[R] Mysterious R script behavior when called from webserver

2009-11-25 Thread Dylan Beaudette
Hi,

I am trying to transition a system based on dynamic image generation (via R) 
from our development system to a production environment. Our R script 
functions as expected when run by a regular user. However the script dies 
when calling the png() function, when started by the webserver user.

Here are some details

>sessionInfo()
R version 2.9.2 (2009-08-24)
i686-pc-linux-gnu
locale:
C 
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

The script gets to this line:

png(file=filename, width=600, height=400)

and then dies. It leaves an empty PNG file where it should be, however it 
never finishes the file. If 

I replace png() with pdf() an output file is generated and closed by dev.off() 
as expected.

It seems like the environment is setup just as when started by a regular user, 
specifically the LD_LIBRARY_PATH variable.

This behavior suggests that R is encountering an error, and stopping. However 
there is no reporting of the error. Is there any way to get more verbose 
error reporting?

Cheers,
Dylan




-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Feature request for as.Date() function

2009-11-25 Thread jim holtman
Seems to work fine in my testing:

> x <- read.csv(textConnection("date,value
+ 2009-01-01,10
+ 2009-02-01,1
+ 'NA', 3"), colClasses=c("Date", 'integer'))
>
> str(x)
'data.frame':   3 obs. of  2 variables:
 $ date :Class 'Date'  num [1:3] 14245 14276 NA
 $ value: int  10 1 3
> x <- read.csv(textConnection("date,value
+ 2009-01-01,10
+ 2009-02-01,1
+ NA, 3"), colClasses=c("Date", 'integer'))
>
> str(x)
'data.frame':   3 obs. of  2 variables:
 $ date :Class 'Date'  num [1:3] 14245 14276 NA
 $ value: int  10 1 3
>

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

On Wed, Nov 25, 2009 at 12:38 PM,
 wrote:
> Hello -
>
> I have a csv file with a few date columns. Some of the records have an
> "NA" character string instead of the date. When I attempt to use
> read.csv() and typecast the columns using colClasses, I receive the
> following error:
>    Error in charToDate(x) :
>      character string is not in a standard unambiguous format
>
> Similarly, the following command produces the same error:
>    as.Date("NA")
>
> However, as.Date(NA) performs as documented.
>
> Can we enhance the as.Date() function to convert "NA" strings into NA
> value prior to type conversion?
>
> Thanks!
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] predict: remove columns with new levels automatically

2009-11-25 Thread Andreas Wittmann

Thank you all for the good advice.

Now i did a fast hack, which does want i was looking for, maybe anyone 
else finds this usefull



set.seed(0)
x <- rnorm(9)
y <- x + rnorm(9)

training <- data.frame(x=x, y=y,
  z1=c(rep("A", 3), rep("B", 3), rep("C", 3)),
  z2=c(rep("F", 4), rep("G", 5)))
test <- data.frame(x=t<-rnorm(1), y=t+rnorm(1), z1="D", z2="F")


`predict.drop` <- function(f, dat, newdat)
{
 datlev <- vector("list", ncol(dat))
 newdatlev <- vector("list", ncol(newdat))

 `filllevs` <- function(dat, veclev)
 {
   for (j in 1:ncol(dat))
   {
 if (is.factor(dat[,j]))
   veclev[[j]] <- levels(dat[,j])
 else
   veclev[[j]] <- NULL
   }

   return(veclev)
 }

 datlev <- filllevs(dat, datlev)
 newdatlev <- filllevs(newdat, newdatlev)

 if (ncol(dat) == ncol(newdat))
 {
   drop <- logical(ncol(dat))
   names(drop) <- colnames(dat)

   for (j in 1:ncol(dat))
   {
 if (!is.null(datlev[[j]]))
 {
   if (!(newdatlev[[j]] %in% datlev[[j]]))
 drop[j] <- TRUE
 }
   }
 }
 else
   stop("dat and newdat must have the same column length!")

 m <- lm(formula(f), data=dat[,(1:ncol(dat))[!drop]])
 p <- predict(m, newdat)

 return(list(drop=drop, p=p))
}


predict.drop(x ~ ., training, test)


best regards

Andreas




David Winsemius wrote:


On Nov 25, 2009, at 1:48 AM, Andreas Wittmann wrote:

Sorry for my bad description, i don't want get a constructed 
algorithm without own work. i only hoped to get some advice how to do 
this. i don't want to predict any sort of data, i reference only to 
newdata which variables are the same as in the model data. But if 
factors in the data than i can by possibly that the newdata has a 
level which doesn't exist in the original data.
So i have to compare each factor in the data and in the newdata and 
if the newdata has a levels which is not in the original data and 
drop this variable and do compute the model and prediction again.
I thought this problem is quite common and i can use an algorithm 
somebody has already implemented.


best regards

Andreas

If you use str to look at the lm1 object you will find at the bottom a 
list called "x":


lm1$x will show you the factors that were present in variables at the 
time of the model creation

> lm1$x
$z
[1] "A" "B" "C"

New testing scenario good level and bad level:

test <- data.frame(x=t<-rnorm(2), y=t+rnorm(2), z=c("B", "D") )
 lm1 <- lm(x ~ ., data=training)
 predict(lm1, subset(test, z %in% lm1$x$z) )  # get prediction for 
good level only

1
0.4225204





 Original-Nachricht 

Datum: Wed, 25 Nov 2009 00:48:59 -0500
Von: David Winsemius 
An: Andreas Wittmann 
CC: r-help@r-project.org
Betreff: Re: [R] predict: remove columns with new levels automatically




On Nov 24, 2009, at 2:24 PM, Andreas Wittmann wrote:


Dear R-users,

in the follwing thread

http://tolstoy.newcastle.edu.au/R/help/03b/3322.html

the problem how to remove rows for predict that contain levels which
are not in the model.

now i try to do this the other way round and want to remove columns
(variables) in the model which will be later problematic with new
levels for prediction.

## example:
set.seed(0)
x <- rnorm(9)
y <- x + rnorm(9)

training <- data.frame(x=x, y=y, z=c(rep("A", 3), rep("B", 3),
rep("C", 3)))
test <- data.frame(x=t<-rnorm(1), y=t+rnorm(1), z="D")

lm1 <- lm(x ~ ., data=training)
## prediction does not work because the variable z has the new level
"D"
predict(lm1, test)

## solution: the variable z is removed from the model
## the prediction happens without using the information of variable z
lm2 <- lm(x ~ y, data=training)
predict(lm2, test)

How can i autmatically recognice this and calculate according to this?


Let me get this straight. You want us to predict in advance (or more
accurately design an algorithm that can see into the future and work
around) any sort of newdata you might later construct

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT


--
Preisknaller: GMX DSL Flatrate für nur 16,99 Euro/mtl.!
http://portal.gmx.net/de/go/dsl02


David Winsemius, MD
Heritage Laboratories
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] Grouped Barplot

2009-11-25 Thread David Winsemius


On Nov 25, 2009, at 1:48 PM, Gary wrote:


Hi R Users,

I tried plotting a similar boxplot as it is on the FOLLOWING LINK:

http://www.imachordata.com/wp-content/uploads/2009/09/boxplot.png


Looks like a product of a function from ggplot2. In fact trimming that  
URL brings you to a page with the code that created it!


Sample data is attached --


No, it's not. Read the Posting Guide for what file types are  
acceptable to the server. I suspect you will get better success if the  
extension is ".txt", even if it is comma separated.


Or better yet follow the directions there for posting data in a form  
that can be enclosed in your posting and  copy-pasted into the console  
session.




there are 9 years and 5 cities. In my case I'm
looking to plot "Year" on x-axis and grouping boxplots by "City". I  
tried

the following code.

foo<-read.table("SampleData.csv", sep=",", header=TRUE)
attach(foo)
boxplot(Admit ~ City + Year, range=0.5, col=2:6) # its not solving the
purpose

I need some help with:
1) Plotting only 9 labels on x-axis (1996-2004).
2) For each "Year", I need to plot FIVE boxplots -- one for each  
"City". [so
it will look like nine clusters with five boxplots each (with no gap  
between

them, but with gaps between year labels].
3) Adding "MEAN" to the boxplots.
4) And, legend including "color" + "city name".

Any help would be greatly appreciated!




David Winsemius, MD
Heritage Laboratories
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] Reading from Google Docs

2009-11-25 Thread Charlie Sharpsteen
On Wed, Nov 25, 2009 at 5:39 AM, Farrel Buchinsky  wrote:
> I recently installed R 2.10
>
> Now I get
>
>> library(RGoogleDocs)
> Loading required package: RCurl
> Loading required package: bitops
> Loading required package: XML
>
> Attaching package: 'RGoogleDocs'
>
>
>        The following object(s) are masked from package:methods :
>
>         getAccess
>
> Warning message:
> package 'RGoogleDocs' was built under R version 2.9.1 and help will not work
> correctly
> Please re-install it
>
> But alas reinstalling it does not take away the error message.
> Farrel Buchinsky

How did you try reinstalling it?  It sounds like you are using a
binary distribution that was built under 2.9.1-- you probably have to
build and install from a source distribution of the package.

-Charlie

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 writing for loop

2009-11-25 Thread Steven McKinney
Hi,

The great thing about the S language is that it is 'vectorized',
so you can do a lot of matrix manipulations without loops.

Here's a smaller example of what you describe.
matrix A with 3 columns and 10 rows (instead of 100)
matrix B with 3 columns and 15 rows (instead of 1500)

> set.seed(123)
> mA <- matrix(runif(30), ncol = 3)
> mA
   [,1]   [,2]  [,3]
 [1,] 0.2875775 0.95683335 0.8895393
 [2,] 0.7883051 0.45333416 0.6928034
 [3,] 0.4089769 0.67757064 0.6405068
 [4,] 0.8830174 0.57263340 0.9942698
 [5,] 0.9404673 0.10292468 0.6557058
 [6,] 0.0455565 0.89982497 0.7085305
 [7,] 0.5281055 0.24608773 0.5440660
 [8,] 0.8924190 0.04205953 0.5941420
 [9,] 0.5514350 0.32792072 0.2891597
[10,] 0.4566147 0.95450365 0.1471136

> x <- seq(15)
> mB <- cbind(1, x, x^2)
> mB
 x
 [1,] 1  1   1
 [2,] 1  2   4
 [3,] 1  3   9
 [4,] 1  4  16
 [5,] 1  5  25
 [6,] 1  6  36
 [7,] 1  7  49
 [8,] 1  8  64
 [9,] 1  9  81
[10,] 1 10 100
[11,] 1 11 121
[12,] 1 12 144
[13,] 1 13 169
[14,] 1 14 196
[15,] 1 15 225

> mR <- apply(mB, 1, function(x){mA %*% x})
> mR
  [,1] [,2]  [,3]  [,4]  [,5] [,6] [,7]
 [1,] 2.133950 5.759401 11.163931 18.347540 27.310227 38.05199 50.57284
 [2,] 1.934443 4.466187  8.383538 13.686496 20.375061 28.44923 37.90901
 [3,] 1.727054 4.326145  8.206250 13.367368 19.809500 27.53265 36.53681
 [4,] 2.449921 6.005363 11.549346 19.081867 28.602929 40.11253 53.61067
 [5,] 1.699098 3.769140  7.150594 11.843459 17.847736 25.16342 33.79052
 [6,] 1.653912 4.679328  9.121806 14.981344 22.257943 30.95160 41.06232
 [7,] 1.318259 3.196545  6.162963 10.217513 15.360195 21.59101 28.90995
 [8,] 1.528621 3.353106  6.365876 10.566930 15.956267 22.53389 30.29979
 [9,] 1.168515 2.363915  4.137635  6.489674  9.420032 12.92871 17.01571
[10,] 1.558232 2.954077  4.644149  6.628448  8.906974 11.47973 14.34671
  [,8] [,9] [,10] [,11] [,12] [,13] [,14]
 [1,] 64.87276 80.95176  98.80984 118.44700 139.86324 163.05856 188.03295
 [2,] 48.75440 60.98539  74.60199  89.60419 105.99201 123.76542 142.92445
 [3,] 46.82198 58.38816  71.23536  85.36358 100.77281 117.46305 135.43430
 [4,] 69.09735 86.57257 106.03633 127.48863 150.92947 176.35884 203.77676
 [5,] 43.72904 54.97896  67.54029  81.41304  96.59720 113.09277 130.89975
 [6,] 52.59011 65.53495  79.89685  95.67582 112.87184 131.48493 151.51508
 [7,] 37.31703 46.81224  57.39559  69.06706  81.82667  95.67440 110.61027
 [8,] 39.25398 49.39646  60.72722  73.24626  86.95358 101.84919 117.93309
 [9,] 21.68102 26.92466  32.74662  39.14689  46.12549  53.68240  61.81763
[10,] 17.50792 20.96335  24.71302  28.75691  33.09502  37.72737  42.65394
  [,15]
 [1,] 214.78642
 [2,] 163.46908
 [3,] 154.68657
 [4,] 233.18322
 [5,] 150.01814
 [6,] 172.96229
 [7,] 126.63428
 [8,] 135.20527
 [9,]  70.53119
[10,]  47.87474
> 

so the results matrix mR has one column for each element of x,
and the i-th row element is the solution for
y = a + bx + cx^2
for the i-th row of coefficients in the parameter estimates matrix mA

You can spot check with e.g. 

> mA[1,] %*% mB[15,]
 [,1]
[1,] 214.7864
> mA[1,] %*% mB[5,]
 [,1]
[1,] 27.31023
> mA[1,]
[1] 0.2875775 0.9568333 0.8895393
> mB[5,]
x
 1  5 25 
> 



HTH

Steven McKinney, Ph.D.

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney +at+ bccrc +dot+ ca

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C.
V5Z 1L3
Canada


From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Jessica Schedlbauer [jsche...@fiu.edu]
Sent: November 25, 2009 10:43 AM
To: r-help@r-project.org
Subject: [R] help writing for loop

Hi,

I’d like to ask for some help in writing a loop.  My situation is the following:

I have a matrix (matrix.A) containing 3 columns and 100 rows.  The columns 
represent parameter estimates a, b, and c.  The rows contain different values 
for these parameter estimates.  Each row is unique.

I want to insert these parameter estimates into a model (say, y = a + bx + 
cx^2) and solve for y given a separate matrix (matrix.B) of x values (where x 
has a length of 1500).

I want to solve for y 100 times using each set of the parameter estimates in 
matrix.A once.

At present my code looks like this and it only performs the first iteration.

For (i in 1:length(matrix.A)) { y <- matrix.A$a[[i]] + matrixA$b[[i]] * 
matrix.B$x + matrixA$c[[i]] * matrix.B$x^2)

I have not been able to figure out how to loop through the rows of parameter 
estimates in matrix.A.  I am new to writing loops, so any assistance would be 
much appreciated.

Regards,
Jessica Schedlbauer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, m

Re: [R] Grouped Barplot

2009-11-25 Thread S Devriese
On 11/25/2009 07:48 PM, Gary wrote:
> Hi R Users,
>
> I tried plotting a similar boxplot as it is on the FOLLOWING LINK:
>
> http://www.imachordata.com/wp-content/uploads/2009/09/boxplot.png
>
> Sample data is attached -- there are 9 years and 5 cities. In my case I'm
> looking to plot "Year" on x-axis and grouping boxplots by "City". I tried
> the following code.
>
> foo<-read.table("SampleData.csv", sep=",", header=TRUE)
> attach(foo)
> boxplot(Admit ~ City + Year, range=0.5, col=2:6) # its not solving the
> purpose
>
> I need some help with:
> 1) Plotting only 9 labels on x-axis (1996-2004).
> 2) For each "Year", I need to plot FIVE boxplots -- one for each "City". [so
> it will look like nine clusters with five boxplots each (with no gap between
> them, but with gaps between year labels].
> 3) Adding "MEAN" to the boxplots.
> 4) And, legend including "color" + "city name".
>
> Any help would be greatly appreciated!
>
> ~Gary
>   
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   
Have a look at
https://stat.ethz.ch/pipermail/r-help/2000-November/009191.html. Might
be what you're looking for.

[[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] Feature request for as.Date() function

2009-11-25 Thread nabble . 30 . miller_2555
Hello -

I have a csv file with a few date columns. Some of the records have an
"NA" character string instead of the date. When I attempt to use
read.csv() and typecast the columns using colClasses, I receive the
following error:
Error in charToDate(x) :
  character string is not in a standard unambiguous format

Similarly, the following command produces the same error:
as.Date("NA")

However, as.Date(NA) performs as documented.

Can we enhance the as.Date() function to convert "NA" strings into NA
value prior to type conversion?

Thanks!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] multi variate plot with string data

2009-11-25 Thread frenchcr


Ive got two columns in data_set that are strings

the first column is called "character" and has levels:
good, bad, ugly

the second column is called "abusive" and has levels:
aggressive, moderately aggressive, mildly aggressive


I want to do a stacked boxplot that has this sort of structure: 

%aggressive %aggressive %aggressive
%moderately aggressive %moderately aggressive  %moderately
aggressive
%mildly aggressive %mildly aggressive %mildly
aggressive
%not agressive %not agressive  %not
agressive

   bad  good  
ugly


...with legend at the size showing which colour each of the "abusive" levels
takes.


How is it done?
-- 
View this message in context: 
http://old.nabble.com/multi-variate-plot-with-string-data-tp26517211p26517211.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] Is there a package for generating standardized R script command line options?

2009-11-25 Thread Trevor . L . Davis
> Hi,
>
> In python, there is a package that helps generating command line
> options. I am wondering if there is such a package in R that helps
> generating the command options for a R script?
>
> http://docs.python.org/library/optparse.html
>
> Regards,
> Peng

I recently put a package on CRAN that tries to implement much of the 
functionality and approach of python's "optparse" library:

http://cran.r-project.org/web/packages/optparse/

It contains a package vignette (use vignette("optparse") after installing 
the package) that illustrates an example program using optparse and trying 
it with various options on the command line.

The "getopt" package or manually parsing the command line remain good 
approaches too.


Trevor Davis
Research Assistant
Division of Research & Statistics
Federal Reserve Board of Governors

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] overdispersion and quasibinomial model

2009-11-25 Thread Peter Ehlers



djpren wrote:

Thanks for the reply. Naturally I already searched the site and help for the
answers to these questions. I think I've figured out how to run a
quasi-binomial model, but I cannot figure out how to test for
over-dispersion or how to apply a shapiro-wilk test.

This is not homework, neither do I have an instructor who is proficient in
using R. This program was suggested to me by another researcher after he
witnessed my frustration with the inflexibility of SPSS and other such
programs. I am on a very tight schedule and I don't have time to become a
statistician and computer scientist, which is why I wrote 3 very quick
questions asking for commands that i had already tried to find myself.

Testing for over-dispersion is probably something I can eventually get to
grips with, since I just have get variance for the real and modelled data.
However, I cannot find a command to do shapiro-wilks on the site or on these
forums. Also, why do you say that most people here wouldn't recommend this
procedure?


The customary (well, at least to me) to check for overdispersion
is to look at the ratio of the sum of squared Pearson residuals
over residual degrees of freedom. This is well discussed in
MASS (the book).

Example:

library(MASS)
fm1 <- glm(low ~ age + race, family = binomial, data = birthwt)
phi <- sum(resid(fm, type = "pearson")^2) / df.residual(fm)
phi
#[1] 1.011612

For a binomial glm, this value is expected to be near 1.0
as it is here. So there is no indication of overdispersion
in this example.

I don't know of a specific test for overdispersion. Personally,
I start to worry about the adequacy of the model if the data
set is large and phi is greater than about 1.2. For small data
sets I wouldn't be too concerned if phi is less than 1.5.
But this all depends crucially on what you want to do with
your model results. Adjusting phi to be greater than 1.0 will
provide more conservative estimates of the parameters.
Note that using family="quasibinomial" won't change the
parameter estimates, just their SEs.

fm2 <- glm(low ~ age + race, family = quasibinomial, data = birthwt)

Now you can compare summary(fm1) with summary(fm2).

What Shapiro-Wilk has to do with this is: Nothing!

 -Peter Ehlers



David Winsemius wrote:


On Nov 24, 2009, at 3:41 PM, djpren wrote:


I am looking for the correct commands to do the following things:

1. I have a binomial logistic regression model and i want to test for
overdispersion.

Under the teach a man to fish precept,   ... try:

RSiteSearch("test over dispersion binomial models")

2. If I do indeed have overdispersion i need to then run a quasi- 
binomial

model, but I'm not sure of the command.

?glm
# and follow the appropriate links

3. I can get the residuals of the model, but i need to then apply a  
shapiro

wilk test to test them. Does anyone know the command for this?


RSiteSearch("shapiro-wilks")   # not that people here recommend this  
procedure


The overall flavor of these questions is "homework", so I'm  
speculating that you may want to consult your instructors.


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.






__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Sampling dataframe

2009-11-25 Thread Ronaldo Reis Júnior
Hi,

I have a table like that:

> datatest 
   var1 var2 var3
1 111
2 312
3 813
4 614
51015
6 221
7 422
8 623
9 824
10   1025

I need to create another table based on that with the rules:

take a random sample by var2==1 (2 sample rows for example):

   var1 var2 var3
1 111
4 614

in this random sample a get the 1 and 4 value on the var3, now I need to 
complete the table with var1==2 with the lines that var3 are not select on 
var2==1

The resulting table is:
   var1 var2 var3
1 111
4 614
7 422
8 623
10   1025

the value 1 and 4 on var3 is not present in the var2==2.

I try several options but without success. take a random value is easy, but I 
cant select the others value excluding the random selected values.

Any help?

Thanks
Ronaldo


-- 
17ª lei - Seu orientador quer que você se torne famoso, 
  de modo que ele possa, finalmente, se tornar famoso.

  --Herman, I. P. 2007. Following the law. NATURE, Vol 445, p. 228.
--
> Prof. Ronaldo Reis Júnior
|  .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional
| : :'  : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
| `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
|   `- Fone: (38) 3229-8192 | ronaldo.r...@unimontes.br | chrys...@gmail.com
| http://www.ppgcb.unimontes.br/lecc | ICQ#: 5692561 | LinuxUser#: 205366
--
Favor NÃO ENVIAR arquivos do Word ou Powerpoint
Prefira enviar em PDF, Texto, OpenOffice (ODF), HTML, or RTF.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R: Re: R: Re: chol( neg.def.matrix ) WAS: Re: Choleski and Choleski with pivoting of matrix fails

2009-11-25 Thread Ravi Varadhan
I do not understand what the problem is, as it works just fine for me:

A <- matrix(c(0.5401984,-0.3998675,-1.3785897,-0.3998675,1.0561872,  
0.8158639,-1.3785897, 0.8158639, 1.6073119), 3, 3, byrow=TRUE)

eA <- eigen(A)

chA <-  eA$vec %*% diag(sqrt(eA$val+0i)) %*% t(eA$vec)

all.equal(A, Re(chA %*% t(chA)))

Y <- diag(c(1,2,3))

solve(chA %*% Y)

Ravi.

---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:  
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.html





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of simona.racio...@libero.it
Sent: Wednesday, November 25, 2009 9:59 AM
To: p.dalga...@biostat.ku.dk
Cc: r-help@r-project.org
Subject: [R] R: Re: R: Re: chol( neg.def.matrix ) WAS: Re: Choleski and 
Choleski with pivoting of matrix fails

Dear Peter,
thank you very much for your answer.

My problem is that I need to calculate the following quantity:

solve(chol(A)%*%Y)

Y is a 3*3 diagonal matrix and A is a 3*3 matrix. Unfortunately one 
eigenvalue of A is negative. I can anyway take the square root of A but when I 
multiply it by Y, the imaginary part of the square root of A is dropped, and I 
do not get the right answer.

I tried to exploit the diagonal structure of Y by using 2*2 matrices for A 
and Y. In this way the problem mentioned above disappears (since all 
eigenvalues of A are positive) and when I perform the calculation above I get 
approximately the right answer. The approximation is quite good. However it is 
an approximation.

Any suggestion?
Thank you very much!
Simon




>Messaggio originale
>Da: p.dalga...@biostat.ku.dk
>Data: 23-nov-2009 14.09
>A: "simona.racio...@libero.it"
>Cc: "Charles C. Berry", 
>Ogg: Re: R: Re: [R] chol( neg.def.matrix ) WAS: Re: Choleski and Choleski 
with pivoting of matrix fails
>
>simona.racio...@libero.it wrote:
>> It works! But Once I have the square root of this matrix, how do I convert 
it 
>> to a real (not imaginary) matrix which has the same property? Is that 
>> possible?
>
>No. That is theoretically impossible.
>
>If A = B'B, then x'Ax = ||Bx||^2 >= 0
>
>for any x, which implies in particular that all eigenvalues of A should
>be nonnegative.
>
>> 
>> Best,
>> Simon
>> 
>>> Messaggio originale
>>> Da: p.dalga...@biostat.ku.dk
>>> Data: 21-nov-2009 18.56
>>> A: "Charles C. Berry"
>>> Cc: "simona.racio...@libero.it", > project.org>
>>> Ogg: Re: [R] chol( neg.def.matrix ) WAS: Re: Choleski and Choleski with 
>> pivoting of matrix fails
>>> Charles C. Berry wrote:
 On Sat, 21 Nov 2009, simona.racio...@libero.it wrote:

> Hi Everyone,
>
> I need to take the square root of the following matrix:
>
>[,1]   [,2][,3]
> [1,]  0.5401984 -0.3998675 -1.3785897
> [2,] -0.3998675  1.0561872  0.8158639
> [3,] -1.3785897  0.8158639  1.6073119
>
> I tried Choleski which fails. I then tried Choleski with pivoting, but
> unfortunately the square root I get is not valid. I also tried eigen
> decomposition but i did no get far.
>
> Any clue on how to do it?!

 If you want to take the square root of a negative definite matrix, you 
 could use

 sqrtm( neg.def.mat )

 from the expm package on rforge:

 http://r-forge.r-project.org/projects/expm/
>>> But that matrix is not negative definite! It has 2 positive and one 
>>> negative eigenvalue. It is non-positive definite.
>>>
>>> It is fairly easy in any case to get a matrix square root from the 
eigen 
>>> decomposition:
>>>
 v%*%diag(sqrt(d+0i))%*%t(v)
>>>   [,1]  [,2]  [,3]
>>> [1,]  0.5164499+0.4152591i -0.1247682-0.0562317i -0.7257079+0.3051868i
>>> [2,] -0.1247682-0.0562317i  0.9618445+0.0076145i  0.3469916-0.0413264i
>>> [3,] -0.7257079+0.3051868i  0.3469916-0.0413264i  1.0513849+0.2242912i
 ch <- v%*%diag(sqrt(d+0i))%*%t(v)
 t(ch)%*% ch
>>>   [,1]  [,2]  [,3]
>>> [1,]  0.5401984+0i -0.3998675-0i -1.3785897-0i
>>> [2,] -0.3998675-0i  1.0561872+0i  0.8158639-0i
>>> [3,] -1.3785897-0i  0.8158639-0i  1.6073119-0i
>>>
>>> A triangular square root is, er, more difficult, but hardly impossible.
>>>
>>> -- 
>>>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>>>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>>>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
>>> ~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907
>>>
>> 
>> 
>
>
>-- 
>   O__   Peter Dal

[R] Grouped Barplot

2009-11-25 Thread Gary
Hi R Users,

I tried plotting a similar boxplot as it is on the FOLLOWING LINK:

http://www.imachordata.com/wp-content/uploads/2009/09/boxplot.png

Sample data is attached -- there are 9 years and 5 cities. In my case I'm
looking to plot "Year" on x-axis and grouping boxplots by "City". I tried
the following code.

foo<-read.table("SampleData.csv", sep=",", header=TRUE)
attach(foo)
boxplot(Admit ~ City + Year, range=0.5, col=2:6) # its not solving the
purpose

I need some help with:
1) Plotting only 9 labels on x-axis (1996-2004).
2) For each "Year", I need to plot FIVE boxplots -- one for each "City". [so
it will look like nine clusters with five boxplots each (with no gap between
them, but with gaps between year labels].
3) Adding "MEAN" to the boxplots.
4) And, legend including "color" + "city name".

Any help would be greatly appreciated!

~Gary
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] order of panels in xyplots

2009-11-25 Thread S Devriese
On 11/25/2009 07:33 PM, Titus Malsburg wrote:
> On Wed, Nov 25, 2009 at 7:03 PM, Titus Malsburg  wrote:
>   
>>  I was expecting
>> that this should plot the panels in the order in which the levels
>> occur in the data frame:
>>
>>  xyplot(dur~roi|trial, data, index.cond=unique(as.integer(data$trial)))
>> 
> The answer is apparently:
>
>   xyplot(dur~roi|trial, data, index.cond=rank(unique(data$trial)))
>
> (Strange phenomenon, that I very often find the solution myself
> minutes after posting to the mailing list.)
>
> Best,
>Titus
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   
An alternative could be to reorder the levels of "trial" prior to
calling xyplot or in the xyplot call itself (useful if you want to order
the levels on some other criterion like the mean or median of another
variable). See ?reorder

Just a thought

S

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 writing for loop

2009-11-25 Thread Jessica Schedlbauer
Hi, 

I’d like to ask for some help in writing a loop.  My situation is the following:

I have a matrix (matrix.A) containing 3 columns and 100 rows.  The columns 
represent parameter estimates a, b, and c.  The rows contain different values 
for these parameter estimates.  Each row is unique.

I want to insert these parameter estimates into a model (say, y = a + bx + 
cx^2) and solve for y given a separate matrix (matrix.B) of x values (where x 
has a length of 1500).

I want to solve for y 100 times using each set of the parameter estimates in 
matrix.A once.

At present my code looks like this and it only performs the first iteration.  

For (i in 1:length(matrix.A)) { y <- matrix.A$a[[i]] + matrixA$b[[i]] * 
matrix.B$x + matrixA$c[[i]] * matrix.B$x^2)

I have not been able to figure out how to loop through the rows of parameter 
estimates in matrix.A.  I am new to writing loops, so any assistance would be 
much appreciated.

Regards,
Jessica Schedlbauer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] order of panels in xyplots

2009-11-25 Thread Titus Malsburg
On Wed, Nov 25, 2009 at 7:03 PM, Titus Malsburg  wrote:
>  I was expecting
> that this should plot the panels in the order in which the levels
> occur in the data frame:
>
>  xyplot(dur~roi|trial, data, index.cond=unique(as.integer(data$trial)))

The answer is apparently:

  xyplot(dur~roi|trial, data, index.cond=rank(unique(data$trial)))

(Strange phenomenon, that I very often find the solution myself
minutes after posting to the mailing list.)

Best,
   Titus

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] augPred and nlme

2009-11-25 Thread Sam Albers
Hello there,

Using 'The R Book' (p675-677) I am following instructions on performing a
series of nonlinear regressions fitting the same model to a set of groups. I
have been to able to fit the model to my data using the following call to
nlme:
 >library(nlme)
 >inorg.model<-nlme(inorg.grv ~ a*exp( - ((numDate-b)^2 / 2*c^2)),
fixed=a+b+c~1,
random=a~1|Sectionf,
start=c(a=adi,b=bdi,c=cdi), verbose = TRUE)

Now, again following the R book, I would like to plot these models using
augPred. However I receive the following error:

>plot(augPred(inorg.model))
Error in augPred.lme(inorg.model) :
Data in inorg.model call must evaluate to a data frame

I am not sure even how to diagnose this problem. I basically followed to R
book directions to the letter. I could plot each of these curves from each
out individually but the prospect of R doing it all for me is too tempting.

I am using R 2.8.1-1 and Ubuntu 9.04.

Thanks in advance!

Sam

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


[R] draw circle on PCA plot

2009-11-25 Thread phoebe kong
Hi,

I have a hard time in drawing circle on PCA.
I have 60 samples. The corresponding PC1 scores and PC2 scores were stored
as "mergedata". Here are the summary of PCs scores.

> range(mergedata[,"PC1"])
[1] 0.0085 0.0100
> range(mergedata[,"PC2"])
[1] 0.0032 0.0075
> mean(mergedata[,"PC1"])
[1] 0.009241667
> mean(mergedata[,"PC2"])
[1] 0.005541667
> dim(mergedata)
[1]  60 102
First of all, I need to find the center of the cluster points in PC plot.
Then, I would lilke to draw out from that center concentric circles with
radius 1 SD, 1.5 SD, 2 SD, 2.5 SD and 3 SD.

plot(mergedata[,"PC1"],mergedata[,"PC2"],xlab="PC1",ylab="PC2",xlim=range(mergedata[,"PC1"]),ylim=range(mergedata[,"PC2"]),pch=20,col="blue")
circle with radius 1SD
symbols(mean(mergedata[,"PC1"]),mean(mergedata[,"PC2"]),circle=sd(c(mergedata[,"PC2"],mergedata[,"PC1"])),inches=FALSE,add=TRUE)


However, only points were plotted, but the cicle doesn't appear. Could
anyone tell me what's wrong with my code?

Thanks,
Phoebe

[[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] order of panels in xyplots

2009-11-25 Thread Titus Malsburg
I'd like do a simple xyplot with customized order of panels and try to
understand how to use index.cond for that. Several attempts didn't
deliver the correct results. Now, I noticed the following:

> p <- xyplot(dur~roi|trial, data)
> p$index.cond
[[1]]
 [1]  1  2  3  4  5  6  7  8  9 10

These numbers are "valid indexing vector for the integer vector
'1:nlevels(g_i)'" but

  levels(data$trial)[p$index.cond[[1]]]

does not yield the correct level names of the data points in data.
(Actually the first ten levels are not used in data.)  I was expecting
that this should plot the panels in the order in which the levels
occur in the data frame:

  xyplot(dur~roi|trial, data, index.cond=unique(as.integer(data$trial)))

But this leaves the panels empty.  Could anybody please help me to
understand this?

Thanks!

   Titus

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Structural Equation Models(SEM)

2009-11-25 Thread William Revelle

Ralf,
  If you are representing this as a factor model, you need to have 
the factors lead to the variables:


model.RLIM <- specify.model()
  f1 ->  R  , laddR,  NA
f1 ->  L, laddL,  NA
   f1 ->  I, laddI,  NA
   f1 ->   M,  laddM,  NA
   R <->  R,  dR,NA
   L <->  L,  dL,NA
   I <->  I,  dI,NA
   M <->  M,  dM,NA
   f1 <->  f1,  df1,NA


 sem(mod1,tcv,101)


 Model Chisquare =  5.955411   Df =  3

   F1RF1LF1Ix1ex2ex3ex4e
0.20301850 0.28443881 0.39421470 0.10734247 0.09951485 0.09105800 0.31702970

 Iterations =  24


For a simple way to create the sem commands from an exploratory 
factor analysis, you might want to look at the psych package and the 
vignette: psych_for_sem.


e.g.,

 library(psych)
 f1 <- fa(tcv) #do the exploratory factor analysis


 mod1 <- structure.diagram(f1,errors=TRUE)  #draw the path diagram 
from the model and create the sem commands

 mod1

  Path  Parameter StartValue
1 MR1->RF1R
2 MR1->LF1L
3 MR1->IF1I
4 R<->R x1e
5 L<->L x2e
6 I<->I x3e
7 M<->M x4e
8 MR1<->MR11

 sem(mod1,tcv,101)  #do the sem


 Model Chisquare =  5.955411   Df =  3

   F1RF1LF1Ix1ex2ex3ex4e
0.20301850 0.28443881 0.39421470 0.10734247 0.09951485 0.09105800 0.31702970

 Iterations =  24

Best wishes,

Bill






At 6:23 PM +0200 11/25/09, Ralf Finne wrote:

Hi R-colleagues.

In the sem-package
i have a problem to introduce hidden variables.
As a simple example I take an ordinary factor analysis.
The program:

cmat=c(0.14855886, 0.05774635, 0.08003300, 0.04900990,
  0.05774635, 0.18042029, 0.11213013, 0.03752475,
0.08003300, 0.11213013, 0.24646337, 0.03609901,
  0.04900990, 0.03752475, 0.03609901, 0.31702970)
rn=c("R","L","I","M")
cn=c("R","L","I","M")

tcv=matrix(cmat,nrow=4,ncol=4,dimnames=list(rn,cn))

model.RLIM <- specify.model()
   R  ->  f1, laddR,  NA
   L  ->  f1, laddL,  NA
   I  ->  f1, laddI,  NA
   M  ->  f1, laddM,  NA
   R <->  R,  dR,NA
   L <->  L,  dL,NA
   I <->  I,  dI,NA
   M <->  M,  dM,NA
   f1 <->  f1,  df1,NA

sem.RLIM=sem(model.RLIM,tcv,101)

The output:
Error in dimnames(x) <- dn :
 length of 'dimnames' [2] not equal to array extent
In addition: Warning messages:
1: In sem.default(ram = ram, S = S, N = N, param.names = pars, 
var.names = vars,  :

  singular Hessian: model is probably underidentified.

2: In sem.default(ram = ram, S = S, N = N, param.names = pars, 
var.names = vars,  :

  refitting without aliased parameters.

I use R version 2.10.0 (2009-10-26) under Windows XP
sem_0.9-19  version.

Where did I make a mistake? Have anyone of  you knowledge
of any other package doing similar things like Confirmative Factor Analysis
Ralf Finne
Novia University of Applied Science
Vasa  Finland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
William Revelle http://personality-project.org/revelle.html
Professor   http://personality-project.org/personality.html
Department of Psychology http://www.wcas.northwestern.edu/psych/
Northwestern University http://www.northwestern.edu/
Use R for psychology   http://personality-project.org/r
It is 5 minutes to midnight http://www.thebulletin.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] Importing many files from a single code

2009-11-25 Thread David Winsemius


On Nov 25, 2009, at 9:35 AM, ram basnet wrote:


Dear R users,

Does somebody know the way to import many files by a single command  
in R ? I have 50 files in a directory and now, i am importing the  
files repeatedly (one by one). If there is a way to import all files  
at a time, it makes much more easy and save times too.

Thanks in advance.


Learn to search:

> RSiteSearch("import many files")
A search query has been submitted to http://search.r-project.org
The results page should open in your browser shortly

One link away you find:

https://stat.ethz.ch/pipermail/r-help/attachments/20080903/4172cd28/attachment.pl

--

David Winsemius, MD
Heritage Laboratories
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] Structural Equation Models(SEM)

2009-11-25 Thread Viechtbauer Wolfgang (STAT)
The model you have specified there is not an ordinary factor analysis model. 

This may be closer to what you are thinking of:

model.RLIM <- specify.model()
   f1  ->  R,  laddR,  NA
   f1  ->  L,  laddL,  NA
   f1  ->  I,  laddI,  NA
   f1  ->  M,  laddM,  NA
   R  <->  R,  dR, NA
   L  <->  L,  dL, NA
   I  <->  I,  dI, NA
   M  <->  M,  dM, NA
   f1 <->  f1, NA, 1

sem.RLIM=sem(model.RLIM,tcv,101)

summary(sem.RLIM)

Note that the paths go from the latent factor to the manifest variables, not 
vice-versa.

Best,

--
Wolfgang Viechtbauerhttp://www.wvbauer.com/
Department of Methodology and StatisticsTel: +31 (0)43 388-2277
School for Public Health and Primary Care   Office Location:
Maastricht University, P.O. Box 616 Room B2.01 (second floor)
6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck)

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Ralf Finne [ralf.fi...@novia.fi]
Sent: Wednesday, November 25, 2009 5:23 PM
To: r-help@r-project.org
Subject: [R] Structural Equation Models(SEM)

Hi R-colleagues.

In the sem-package
i have a problem to introduce hidden variables.
As a simple example I take an ordinary factor analysis.
The program:

cmat=c(0.14855886, 0.05774635, 0.08003300, 0.04900990,
  0.05774635, 0.18042029, 0.11213013, 0.03752475,
0.08003300, 0.11213013, 0.24646337, 0.03609901,
  0.04900990, 0.03752475, 0.03609901, 0.31702970)
rn=c("R","L","I","M")
cn=c("R","L","I","M")

tcv=matrix(cmat,nrow=4,ncol=4,dimnames=list(rn,cn))

model.RLIM <- specify.model()
   R  ->  f1, laddR,  NA
   L  ->  f1, laddL,  NA
   I  ->  f1, laddI,  NA
   M  ->  f1, laddM,  NA
   R <->  R,  dR,NA
   L <->  L,  dL,NA
   I <->  I,  dI,NA
   M <->  M,  dM,NA
   f1 <->  f1,  df1,NA

sem.RLIM=sem(model.RLIM,tcv,101)

The output:
Error in dimnames(x) <- dn :
 length of 'dimnames' [2] not equal to array extent
In addition: Warning messages:
1: In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names = 
vars,  :
  singular Hessian: model is probably underidentified.

2: In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names = 
vars,  :
  refitting without aliased parameters.

I use R version 2.10.0 (2009-10-26) under Windows XP
sem_0.9-19  version.

Where did I make a mistake? Have anyone of  you knowledge
of any other package doing similar things like Confirmative Factor Analysis
Ralf Finne
Novia University of Applied Science
Vasa  Finland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] fitting mixture of normals distribution to asset return data

2009-11-25 Thread Christian Hennig

Dear John,

I don't know what the "exp" stuff in your line below is about, but 
mclustBIC in package mclust does fit normal mixtures.

Try for a start
library(mclust)
mmm <- mclustBIC(data,G=2)
mmms <- summary(mmm)
mmms

If you want to learn more, read the documentation.

Christian

On Wed, 25 Nov 2009, John Seppänen wrote:


Hi,

I have a 15 years of monthly return data (180 observations) from instruments
that have non-normal return distributions. Thus, I would like to fit a
mixture of normal distribution to each of the series. So, that I would be
able to simulate from the marginal distributions like this:

asset.1<-exp(c(rnorm(500,-0.07,0.02),rnorm(9500,0.05,0.05)))-1

My problem is that I have tried to use Google and go through some packages
(eg mixtools & mclust) but haven't been able to find a function to fit the
mixture of normals. I would like to have two different states of world and
then get the probabilities and the mean and sigma in those states (as in the
example above).

I am newbie in this subject so if someone could point me a R function for
this, I'd really appreciate it...

br,
John

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



*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Importing many files from a single code

2009-11-25 Thread Erik Iverson
See the example in ?source, which does exactly this... or make a package 
depending on your needs. 

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of ram basnet
> Sent: Wednesday, November 25, 2009 8:35 AM
> To: R help
> Subject: [R] Importing many files from a single code
> 
> Dear R users,
> 
> Does somebody know the way to import many files by a single command in R ?
> I have 50 files in a directory and now, i am importing the files
> repeatedly (one by one). If there is a way to import all files at a time,
> it makes much more easy and save times too.
> Thanks in advance.
> 
> 
> Sincerely,
> Ram Kumar Basent
> Wageningen University,
> the Netherlands
> 
> 
> 
> 
>   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R Packages Crack the 3,000 Mark!

2009-11-25 Thread Muenchen, Robert A (Bob)
I thought that the unique function would eliminate duplicate package names. Is 
there a better way to count the number of packages?

Thanks,
Bob

-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] 
Sent: Wednesday, November 25, 2009 10:40 AM
To: Muenchen, Robert A (Bob)
Cc: r-help@r-project.org
Subject: Re: [R] R Packages Crack the 3,000 Mark!

Note that:

- there are also 199 R packages on google code:
http://code.google.com/hosting/search?q=label:R
- some (many?) of the packages on R-Forge and on google code are also on CRAN

On Wed, Nov 25, 2009 at 9:11 AM, Muenchen, Robert A (Bob)
 wrote:
> Hi Liviu,
>
> Yes, I selected all the repositories on the list, including things like CRAN 
> (extras), the four Bioconductor (BioC) sites, and R-Forge.
>
> Cheers,
> Bob
>
> -Original Message-
> From: Liviu Andronic [mailto:landronim...@gmail.com]
> Sent: Wednesday, November 25, 2009 4:47 AM
> To: Muenchen, Robert A (Bob)
> Cc: r-help@r-project.org
> Subject: Re: [R] R Packages Crack the 3,000 Mark!
>
> Hello
>
>
> On 11/24/09, Muenchen, Robert A (Bob)  wrote:
>>  I don't know if this has been reported before, but according to Henrique
>>  Dallazuanna's program (below) the number of R packages has exceeded the
>>  3,000 mark. The count today is 3,175. I ran this just a couple of months
>>  ago & the number was still in the high 2,000s, so it must be fairly
>>  recent. I think this represents about 50% growth in the last year. Not
>>  bad!
>>
> Performing the same here I get only 2000+ packages.
>> myPackageNames <- available.packages()
> --- Please select a CRAN mirror for use in this session ---
> Loading Tcl/Tk interface ... done
>> length(unique( rownames(myPackageNames) ))
> [1] 2058
>
> And CRAN [1] reports a similar number. Perhaps you have some
> non-standard repositories configured?
> Liviu
>
> [1] http://cran.r-project.org/web/packages/
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] difference of two rows

2009-11-25 Thread jim holtman
Try this:

> x <- read.table(textConnection("ID YEAR
+ 13 2007
+ 15 2003
+ 15 2006
+ 15 2008
+ 21 2006
+ 21 2007"), header=TRUE)
> x$diff <- ave(x$YEAR, x$ID, FUN=function(a) c(diff(a), NA))
>
> x
  ID YEAR diff
1 13 2007   NA
2 15 20033
3 15 20062
4 15 2008   NA
5 21 20061
6 21 2007   NA


On Wed, Nov 25, 2009 at 10:55 AM, clion  wrote:
>
> Dear R user,
> I'd like to calculate the difference of two rows, where "ID" is the same.
> eg.: I've got the following dataframe:
> ID YEAR
> 13 2007
> 15 2003
> 15 2006
> 15 2008
> 21 2006
> 21 2007
>
> and I'd like to get the difference, like this:
> ID YEAR     diff
> 13 2007      NA
> 15 2003       3
> 15 2006       2
> 15 2008      NA
> 21 2006       1
> 21 2007      NA
>
> that should be fairly easy...I hope
> Thanks for any helpful comments
> B.
>
>
>
> --
> View this message in context: 
> http://old.nabble.com/difference-of-two-rows-tp26515212p26515212.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.
>



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

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Unique observations

2009-11-25 Thread David Winsemius


On Nov 25, 2009, at 9:44 AM, John Lipkins wrote:


Hey R list,

A beginners question. How can I do the following:

In my research population it is possible that several items can appear
several times, measured on different moments in time. This is being  
supplied
in a total list with all observations identified by a number (per  
item) and
a moment of observation (date). Now I want to make a unique list of  
this
observation preserving the characteristics of the first observation.  
As

example:

Tree  disease  date
Tree1  leaves  01-01-2009
Tree2  roots  13-09-2009
Tree1  roots  24-10-2009

Now I want to create a list of unique elements (in the example only  
once
Tree1 and Tree2) with the first observed disease and date. For the  
example

the result would look like:

Tree  disease  date
Tree1  roots  24-10-2008
Tree2  roots  13-09-2009

Can someone help me with this question?


I think the function you will need include:

?as.Date  #to get the date field into sortable form
?order#as in treedat2 <- treedat[ order(treedat$dt, treedat$Tree), ]
?duplicated  # as in treedat2[ !duplicated(treedat2(Tree), ]

--

David Winsemius, MD
Heritage Laboratories
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] Unique observations

2009-11-25 Thread jim holtman
shouldn't the first observation for Tree1 be " Tree1  leaves  01-01-2009"?

> x <- read.table(textConnection("Tree  disease  date
+  Tree1  leaves  01-01-2009
+  Tree2  roots  13-09-2009
+  Tree1  roots  24-10-2009"), header=TRUE)
> closeAllConnections()
> # split by "Tree" and take first observation
> do.call('rbind', lapply(split(x, x$Tree), function(.tr) .tr[1,]))
   Tree disease   date
Tree1 Tree1  leaves 01-01-2009
Tree2 Tree2   roots 13-09-2009
>


On Wed, Nov 25, 2009 at 9:44 AM, John Lipkins
 wrote:
> Hey R list,
>
> A beginners question. How can I do the following:
>
> In my research population it is possible that several items can appear
> several times, measured on different moments in time. This is being supplied
> in a total list with all observations identified by a number (per item) and
> a moment of observation (date). Now I want to make a unique list of this
> observation preserving the characteristics of the first observation. As
> example:
>
>  Tree  disease  date
>  Tree1  leaves  01-01-2009
>  Tree2  roots  13-09-2009
>  Tree1  roots  24-10-2009
>
> Now I want to create a list of unique elements (in the example only once
> Tree1 and Tree2) with the first observed disease and date. For the example
> the result would look like:
>
>  Tree  disease  date
>  Tree1  roots  24-10-2008
>  Tree2  roots  13-09-2009
>
> Can someone help me with this question?
>
> Thanks in advance.
> Kind regards,
>
> John
>
>        [[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?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Importing many files from a single code

2009-11-25 Thread jim holtman
Exactly what do you mean by "import"?  What commands are you using?
You can get a list of the files in a directory and then iterate
through reading each one in.  If you use 'lapply', you can
'read.table' in some data frames and then 'rbind' them into a single
data frame.  You need to be more specific on the problem you are
trying to solve.

On Wed, Nov 25, 2009 at 9:35 AM, ram basnet  wrote:
> Dear R users,
>
> Does somebody know the way to import many files by a single command in R ? I 
> have 50 files in a directory and now, i am importing the files repeatedly 
> (one by one). If there is a way to import all files at a time, it makes much 
> more easy and save times too.
> Thanks in advance.
>
>
> Sincerely,
> Ram Kumar Basent
> Wageningen University,
> the Netherlands
>
>
>
>
>        [[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?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Natural colours for topographic data

2009-11-25 Thread Karl Ove Hufthammer
Tysdag 24. november 2009 11.08.08 skreiv du:
>>> > I would be happy with a simple one, that just mapped negative values
>>> > to water colours and positive values to land colours.
>
> Have you tried my colourscheme package? Its not on CRAN but you can
>get it from here:

Thanks for the suggestion. It looks very nice. Perhaps I’ll even write a 
general function for generating topographic colour scales, based on this.
(It might be a while before it’s ready, though.)

-- 
Karl Ove Hufthammer
http://huftis.org/
Jabber: k...@huftis.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] tick marks on fold change versus fold change plot

2009-11-25 Thread jim holtman
It sounds like you want to plot 'log' on both axis:

plot(..., log='xy')

On Wed, Nov 25, 2009 at 12:24 PM, Alla Bulashevska
 wrote:
>
> Dear R users,
> i try to produce the fold change versus fold change plot
> where i have the values for x and y ranging from 0.01 to
> 100. So i start with
> plot(x,y,xlim=c(0.01,100),ylim=c(0.01,100), axes=F).
> Then i would like both axes to have tick marks as
> c(0.01,0.1,1,10,100) but they should appear equidistant.
> How should i manage this?
> Thank you for your help,
> Alla.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] XML package example code?

2009-11-25 Thread Tony B
It's been a long time since i read the tutorials, but 'I think', the
reason you get those notifications is because the html code is
malformed, meaning that some of the opening tags '' don't have
corresponding end tags  etc.

The XML package seems rather good at working with malformed code, and
therefore I usually just force those notifications into an empty
function.


library(RCurl)
library(XML)
html <- getURL("http://www.omegahat.org/RSXML/index.html";)
html.tree <- htmlTreeParse(html, useInternalNodes = TRUE, error =
function(...){})

HTH,
Tony Breyal


On 25 Nov, 16:21, Peng Yu  wrote:
> On Wed, Nov 25, 2009 at 12:19 AM, cls59  wrote:
>
> > Peng Yu wrote:
>
> >> I'm interested in parsing an html page. I should use XML, right? Could
> >> you somebody show me some example code? Is there a tutorial for this
> >> package?
>
> > Did you try looking through the help pages for the XML package or browsing
> > the Omegahat website?
>
> > Look at:
>
> >  library(XML)
> >  ?htmlTreeParse
>
> > And the relevant web page for documentation and examples is:
>
> >  http://www.omegahat.org/RSXML/
>
> http://www.omegahat.org/RSXML/shortIntro.html
>
> I'm trying the example on the above webpage. But I'm not sure why I
> got the following error. Would you help to take a look?
>
> $ Rscript main.R> library(XML)
>
> > download.file('http://www.omegahat.org/RSXML/index.html','index.html')
>
> trying URL 'http://www.omegahat.org/RSXML/index.html'
> Content type 'text/html; charset=ISO-8859-1' length 3021 bytes
> opened URL
> ==
> downloaded 3021 bytes
>
>
>
> > doc = xmlInternalTreeParse("index.html")
>
> Opening and ending tag mismatch: dd line 68 and dl
> Opening and ending tag mismatch: li line 67 and body
> Opening and ending tag mismatch: dt line 66 and html
> Premature end of data in tag dd line 64
> Premature end of data in tag li line 63
> Premature end of data in tag dt line 62
> Premature end of data in tag dl line 61
> Premature end of data in tag body line 5
> Premature end of data in tag html line 1
> Error: 1: Opening and ending tag mismatch: dd line 68 and dl
> 2: Opening and ending tag mismatch: li line 67 and body
> 3: Opening and ending tag mismatch: dt line 66 and html
> 4: Premature end of data in tag dd line 64
> 5: Premature end of data in tag li line 63
> 6: Premature end of data in tag dt line 62
> 7: Premature end of data in tag dl line 61
> 8: Premature end of data in tag body line 5
> 9: Premature end of data in tag html line 1
> Execution halted
>
> __
> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://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] R: Re: R: Re: chol( neg.def.matrix ) WAS: Re: Choleski and Choleski with pivoting of matrix fails

2009-11-25 Thread simona.racio...@libero.it
Dear Peter,
thank you very much for your answer.

My problem is that I need to calculate the following quantity:

solve(chol(A)%*%Y)

Y is a 3*3 diagonal matrix and A is a 3*3 matrix. Unfortunately one 
eigenvalue of A is negative. I can anyway take the square root of A but when I 
multiply it by Y, the imaginary part of the square root of A is dropped, and I 
do not get the right answer.

I tried to exploit the diagonal structure of Y by using 2*2 matrices for A 
and Y. In this way the problem mentioned above disappears (since all 
eigenvalues of A are positive) and when I perform the calculation above I get 
approximately the right answer. The approximation is quite good. However it is 
an approximation.

Any suggestion?
Thank you very much!
Simon




>Messaggio originale
>Da: p.dalga...@biostat.ku.dk
>Data: 23-nov-2009 14.09
>A: "simona.racio...@libero.it"
>Cc: "Charles C. Berry", 
>Ogg: Re: R: Re: [R] chol( neg.def.matrix ) WAS: Re: Choleski and Choleski 
with pivoting of matrix fails
>
>simona.racio...@libero.it wrote:
>> It works! But Once I have the square root of this matrix, how do I convert 
it 
>> to a real (not imaginary) matrix which has the same property? Is that 
>> possible?
>
>No. That is theoretically impossible.
>
>If A = B'B, then x'Ax = ||Bx||^2 >= 0
>
>for any x, which implies in particular that all eigenvalues of A should
>be nonnegative.
>
>> 
>> Best,
>> Simon
>> 
>>> Messaggio originale
>>> Da: p.dalga...@biostat.ku.dk
>>> Data: 21-nov-2009 18.56
>>> A: "Charles C. Berry"
>>> Cc: "simona.racio...@libero.it", > project.org>
>>> Ogg: Re: [R] chol( neg.def.matrix ) WAS: Re: Choleski and Choleski with 
>> pivoting of matrix fails
>>> Charles C. Berry wrote:
 On Sat, 21 Nov 2009, simona.racio...@libero.it wrote:

> Hi Everyone,
>
> I need to take the square root of the following matrix:
>
>[,1]   [,2][,3]
> [1,]  0.5401984 -0.3998675 -1.3785897
> [2,] -0.3998675  1.0561872  0.8158639
> [3,] -1.3785897  0.8158639  1.6073119
>
> I tried Choleski which fails. I then tried Choleski with pivoting, but
> unfortunately the square root I get is not valid. I also tried eigen
> decomposition but i did no get far.
>
> Any clue on how to do it?!

 If you want to take the square root of a negative definite matrix, you 
 could use

 sqrtm( neg.def.mat )

 from the expm package on rforge:

 http://r-forge.r-project.org/projects/expm/
>>> But that matrix is not negative definite! It has 2 positive and one 
>>> negative eigenvalue. It is non-positive definite.
>>>
>>> It is fairly easy in any case to get a matrix square root from the 
eigen 
>>> decomposition:
>>>
 v%*%diag(sqrt(d+0i))%*%t(v)
>>>   [,1]  [,2]  [,3]
>>> [1,]  0.5164499+0.4152591i -0.1247682-0.0562317i -0.7257079+0.3051868i
>>> [2,] -0.1247682-0.0562317i  0.9618445+0.0076145i  0.3469916-0.0413264i
>>> [3,] -0.7257079+0.3051868i  0.3469916-0.0413264i  1.0513849+0.2242912i
 ch <- v%*%diag(sqrt(d+0i))%*%t(v)
 t(ch)%*% ch
>>>   [,1]  [,2]  [,3]
>>> [1,]  0.5401984+0i -0.3998675-0i -1.3785897-0i
>>> [2,] -0.3998675-0i  1.0561872+0i  0.8158639-0i
>>> [3,] -1.3785897-0i  0.8158639-0i  1.6073119-0i
>>>
>>> A triangular square root is, er, more difficult, but hardly impossible.
>>>
>>> -- 
>>>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>>>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>>>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
>>> ~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907
>>>
>> 
>> 
>
>
>-- 
>   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
> (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
>~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] XML package example code?

2009-11-25 Thread Tony B
Not sure if my code was attached in that last post:

library(RCurl)
library(XML)
html <- getURL("http://www.omegahat.org/RSXML/index.html";)
html.tree <- htmlTreeParse(html, useInternalNodes = TRUE, error =
function(...){})


On 25 Nov, 16:21, Peng Yu  wrote:
> On Wed, Nov 25, 2009 at 12:19 AM, cls59  wrote:
>
> > Peng Yu wrote:
>
> >> I'm interested in parsing an html page. I should use XML, right? Could
> >> you somebody show me some example code? Is there a tutorial for this
> >> package?
>
> > Did you try looking through the help pages for the XML package or browsing
> > the Omegahat website?
>
> > Look at:
>
> >  library(XML)
> >  ?htmlTreeParse
>
> > And the relevant web page for documentation and examples is:
>
> >  http://www.omegahat.org/RSXML/
>
> http://www.omegahat.org/RSXML/shortIntro.html
>
> I'm trying the example on the above webpage. But I'm not sure why I
> got the following error. Would you help to take a look?
>
> $ Rscript main.R> library(XML)
>
> > download.file('http://www.omegahat.org/RSXML/index.html','index.html')
>
> trying URL 'http://www.omegahat.org/RSXML/index.html'
> Content type 'text/html; charset=ISO-8859-1' length 3021 bytes
> opened URL
> ==
> downloaded 3021 bytes
>
>
>
> > doc = xmlInternalTreeParse("index.html")
>
> Opening and ending tag mismatch: dd line 68 and dl
> Opening and ending tag mismatch: li line 67 and body
> Opening and ending tag mismatch: dt line 66 and html
> Premature end of data in tag dd line 64
> Premature end of data in tag li line 63
> Premature end of data in tag dt line 62
> Premature end of data in tag dl line 61
> Premature end of data in tag body line 5
> Premature end of data in tag html line 1
> Error: 1: Opening and ending tag mismatch: dd line 68 and dl
> 2: Opening and ending tag mismatch: li line 67 and body
> 3: Opening and ending tag mismatch: dt line 66 and html
> 4: Premature end of data in tag dd line 64
> 5: Premature end of data in tag li line 63
> 6: Premature end of data in tag dt line 62
> 7: Premature end of data in tag dl line 61
> 8: Premature end of data in tag body line 5
> 9: Premature end of data in tag html line 1
> Execution halted
>
> __
> r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://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] Unique observations

2009-11-25 Thread John Lipkins
Hey R list,

A beginners question. How can I do the following:

In my research population it is possible that several items can appear
several times, measured on different moments in time. This is being supplied
in a total list with all observations identified by a number (per item) and
a moment of observation (date). Now I want to make a unique list of this
observation preserving the characteristics of the first observation. As
example:

 Tree  disease  date
 Tree1  leaves  01-01-2009
 Tree2  roots  13-09-2009
 Tree1  roots  24-10-2009

Now I want to create a list of unique elements (in the example only once
Tree1 and Tree2) with the first observed disease and date. For the example
the result would look like:

 Tree  disease  date
 Tree1  roots  24-10-2008
 Tree2  roots  13-09-2009

Can someone help me with this question?

Thanks in advance.
Kind regards,

John

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R 2.9.1: Error building target 'front'

2009-11-25 Thread Loris Bennett
Loris Bennett  writes:

Bad news: I found no solution to this problem.

Good news: The problem does not occur with version 2.10.0.
 
Loris

> Loris Bennett  writes:
>
> I get the same problem using R version 2.9.2.
>
> I would be very grateful if anyone could shed some light on this
> issue.
>
> Regards
>
> Loris
>
>> loris.benn...@fu-berlin.de (Loris Bennett) writes:
>>
>>> Hi,
>>>
>>> I am getting the following error
>>>
>>># (R-2.9.1/src/library/methods): gmake front
>>>
>>>/bin/sh: 0403-057 Syntax error at line 1 : `;' is not expected.
>>>gmake: *** [front] Error 2
>>>
>>> However, I am not sure what script sh is trying to execute at this
>>> point. I am building on AIX 5.3.
>>>
>>
>> Here is some more information on this problem. Running
>>
>> gmake -n front
>>
>> produces
>>
>> for f in ; do \
>>   if test -f ./${f}; then \
>> /usr/local/bin/install -c -m 644 ./${f} \
>>   ../../../library/methods; \
>>   fi; \
>> done
>>
>> This seems to come from the following line in share/make/basepkg.mk
>>
>> @for f in $(FRONTFILES); do \
>>
>> Grepping for FRONTFILES yields
>>
>> library/stats/Makefile.in:FRONTFILES = COPYRIGHTS.modreg SOURCES.ts
>> library/stats/Makefile.win:FRONTFILES = COPYRIGHTS.modreg SOURCES.ts
>> library/stats/Makefile:FRONTFILES = COPYRIGHTS.modreg SOURCES.ts
>>
>> Is something similar missing from the makefiles in src/library/methods?
>>
>> Loris
>>
> -- 
> Dr. Loris Bennett
> Computer Centre
> Freie Universität Berlin
> Berlin, Germany
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Dr. Loris Bennett
Computer Centre
Freie Universität Berlin
Berlin, Germany

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] tick marks on fold change versus fold change plot

2009-11-25 Thread Alla Bulashevska

Dear R users,
i try to produce the fold change versus fold change plot
where i have the values for x and y ranging from 0.01 to
100. So i start with
plot(x,y,xlim=c(0.01,100),ylim=c(0.01,100), axes=F).
Then i would like both axes to have tick marks as 
c(0.01,0.1,1,10,100) but they should appear equidistant.
How should i manage this?
Thank you for your help,
Alla.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] XML package example code?

2009-11-25 Thread Duncan Temple Lang


Peng Yu wrote:
> On Wed, Nov 25, 2009 at 12:19 AM, cls59  wrote:
>>
>> Peng Yu wrote:
>>> I'm interested in parsing an html page. I should use XML, right? Could
>>> you somebody show me some example code? Is there a tutorial for this
>>> package?
>>>
>> Did you try looking through the help pages for the XML package or browsing
>> the Omegahat website?
>>
>> Look at:
>>
>>  library(XML)
>>  ?htmlTreeParse
>>
>> And the relevant web page for documentation and examples is:
>>
>>  http://www.omegahat.org/RSXML/
> 
> 
> http://www.omegahat.org/RSXML/shortIntro.html
> 
> I'm trying the example on the above webpage. But I'm not sure why I
> got the following error. Would you help to take a look?
> 
> 
> $ Rscript main.R
>> library(XML)
>>
>> download.file('http://www.omegahat.org/RSXML/index.html','index.html')
> trying URL 'http://www.omegahat.org/RSXML/index.html'
> Content type 'text/html; charset=ISO-8859-1' length 3021 bytes
> opened URL
> ==
> downloaded 3021 bytes
> 
>> doc = xmlInternalTreeParse("index.html")


You are trying to parse an HTML document as if it were XML.
But HTML is often not well-formed.  So use htmlParse()
for a more forgiving parser.

Or use the RTidyHTML package (www.omegahat.org/RTidyHTML)
to make the HTML well-formed before passing it to xmlTreeParse()
(aka xmlInternalTreeParse()). That package is an interface to
libtidy.

 D.


> Opening and ending tag mismatch: dd line 68 and dl
> Opening and ending tag mismatch: li line 67 and body
> Opening and ending tag mismatch: dt line 66 and html
> Premature end of data in tag dd line 64
> Premature end of data in tag li line 63
> Premature end of data in tag dt line 62
> Premature end of data in tag dl line 61
> Premature end of data in tag body line 5
> Premature end of data in tag html line 1
> Error: 1: Opening and ending tag mismatch: dd line 68 and dl
> 2: Opening and ending tag mismatch: li line 67 and body
> 3: Opening and ending tag mismatch: dt line 66 and html
> 4: Premature end of data in tag dd line 64
> 5: Premature end of data in tag li line 63
> 6: Premature end of data in tag dt line 62
> 7: Premature end of data in tag dl line 61
> 8: Premature end of data in tag body line 5
> 9: Premature end of data in tag html line 1
> Execution halted
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] difference of two rows

2009-11-25 Thread R Help
You want to use tapply

?tapply

This is a simple example

dat = data.frame(a=sample(1:10,100,T),b=rnorm(100,0,1))
tapply(dat$b,dat$a,mean)

Hope that helps,
Sam

On Wed, Nov 25, 2009 at 11:55 AM, clion  wrote:
>
> Dear R user,
> I'd like to calculate the difference of two rows, where "ID" is the same.
> eg.: I've got the following dataframe:
> ID YEAR
> 13 2007
> 15 2003
> 15 2006
> 15 2008
> 21 2006
> 21 2007
>
> and I'd like to get the difference, like this:
> ID YEAR     diff
> 13 2007      NA
> 15 2003       3
> 15 2006       2
> 15 2008      NA
> 21 2006       1
> 21 2007      NA
>
> that should be fairly easy...I hope
> Thanks for any helpful comments
> B.
>
>
>
> --
> View this message in context: 
> http://old.nabble.com/difference-of-two-rows-tp26515212p26515212.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   >