Peter Ehlers | 1 Dec 01:20 2009
Picon

Re: question about availability of splines library for 2.10.0

Have you searched your computer?
Rhome/library/splines

It's one of the packages automatically installed with R.

  -Peter Ehlers

Alan Swanson wrote:
> Dear R gurus,
> I am using the gbm library under R version 2.10.0, which depends on the 
> splines library.  I have searched the various repositories and can't 
> seem to locate any current version of the splines library.  This is 
> strange because I had previously installed splines (built under 2.10.0 
> according to the description) on another machine.  Where can I find this 
> library?
> Thanks in advance,
> Alan
> 
> 
>  > sessionInfo()
> R version 2.10.0 (2009-10-26)
> i386-pc-mingw32
> 
> ______________________________________________
> R-help <at> r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
(Continue reading)

David Winsemius | 1 Dec 01:29 2009
Picon
Picon

Re: question about availability of splines library for 2.10.0


On Nov 30, 2009, at 6:47 PM, Alan Swanson wrote:

> Dear R gurus,
> I am using the gbm library under R version 2.10.0, which depends on  
> the splines library.  I have searched the various repositories and  
> can't seem to locate any current version of the splines library.   
> This is strange because I had previously installed splines (built  
> under 2.10.0 according to the description) on another machine.   
> Where can I find this library?
> Thanks in advance,

They don't appear to show up within my package Installer search, but  
it seems unlikely that would be a persistent problem since it is a  
recommended package and the docs say that the R Core Team is the  
maintainer. Isn't that package part of the default installation? The  
stats package doesn't show up either which suggests that using the  
package manager is not the right way to access the package. I'm  
guessing that you should try:

library(splines)
sessionInfo()

> Alan
>
>
> > sessionInfo()
> R version 2.10.0 (2009-10-26)
> i386-pc-mingw32
>
(Continue reading)

Alan Swanson | 1 Dec 01:36 2009

Re: question about availability of splines library for 2.10.0

Phil and Peter, thanks - figured it was something obvious.  I had 
uninstalled splines to check the behavior of some other code.  I just 
reinstalled R 2.10.0 and it shows up.  Thanks!  Alan
Peter Ehlers wrote:
> Have you searched your computer?
> Rhome/library/splines
> 
> It's one of the packages automatically installed with R.
> 
>  -Peter Ehlers
> 
> 
> Alan Swanson wrote:
>> Dear R gurus,
>> I am using the gbm library under R version 2.10.0, which depends on 
>> the splines library.  I have searched the various repositories and 
>> can't seem to locate any current version of the splines library.  This 
>> is strange because I had previously installed splines (built under 
>> 2.10.0 according to the description) on another machine.  Where can I 
>> find this library?
>> Thanks in advance,
>> Alan
>>
>>
>>  > sessionInfo()
>> R version 2.10.0 (2009-10-26)
>> i386-pc-mingw32
>>
>> ______________________________________________
>> R-help <at> r-project.org mailing list
(Continue reading)

Douglas M. Hultstrand | 1 Dec 01:49 2009

paste name in for loop?

Hello,

I am trying to create subsets of grouped data (by area size), and use 
the area size as part of the output name.  The code below works for area 
(xout) 1 and 50, the other files are given NA for an area.

A simple example:
xout <- c(1,5,10,25,50,100)
for(i in xout) { print(paste("Areal_Ppt_",xout[i],"sqmi.txt", sep="")) }
[1] "Areal_Ppt_1sqmi.txt"
[1] "Areal_Ppt_50sqmi.txt"
[1] "Areal_Ppt_NAsqmi.txt"
[1] "Areal_Ppt_NAsqmi.txt"
[1] "Areal_Ppt_NAsqmi.txt"
[1] "Areal_Ppt_NAsqmi.txt"

The actual code and partial dataset are below.

Thanks for your help,
Doug

###############
### Real Code ###
###############
data2 <- read.table("GROUP.txt", header=T, sep=",")
xout <- c(1,5,10,25,50,100)
for(i in xout) {
    name <- paste("Areal_Ppt_",xout[i],"sqmi.txt", sep="")
    b.1 <- subset(data2, area == i)
    write.table(b.1, file=name,quote=FALSE,row.names=FALSE, sep=",")
(Continue reading)

Duncan Murdoch | 1 Dec 01:53 2009
Picon

Re: paste name in for loop?

On 30/11/2009 7:49 PM, Douglas M. Hultstrand wrote:
> Hello,
> 
> I am trying to create subsets of grouped data (by area size), and use 
> the area size as part of the output name.  The code below works for area 
> (xout) 1 and 50, the other files are given NA for an area.
> 
> A simple example:
> xout <- c(1,5,10,25,50,100)
> for(i in xout) { print(paste("Areal_Ppt_",xout[i],"sqmi.txt", sep="")) }

Your loop loops over the values in xout, so no need for xout[i].  You 
should be using

for(i in seq_along(xout))

if you want the indices, or just use i instead of xout[i] in the paste.

Duncan Murdoch

> [1] "Areal_Ppt_1sqmi.txt"
> [1] "Areal_Ppt_50sqmi.txt"
> [1] "Areal_Ppt_NAsqmi.txt"
> [1] "Areal_Ppt_NAsqmi.txt"
> [1] "Areal_Ppt_NAsqmi.txt"
> [1] "Areal_Ppt_NAsqmi.txt"
> 
> The actual code and partial dataset are below.
> 
> Thanks for your help,
(Continue reading)

Jorge Ivan Velez | 1 Dec 01:55 2009
Picon

Re: paste name in for loop?

Hi Douglas,

You were almost there. Just remember that your iterator is i and not xout.

R> xout <- c(1,5,10,25,50,100)
R> for(i in xout) print(paste("Areal_Ppt_", i,"sqmi.txt", sep=""))
[1] "Areal_Ppt_1sqmi.txt"
[1] "Areal_Ppt_5sqmi.txt"
[1] "Areal_Ppt_10sqmi.txt"
[1] "Areal_Ppt_25sqmi.txt"
[1] "Areal_Ppt_50sqmi.txt"
[1] "Areal_Ppt_100sqmi.txt"

Best regards,
Jorge

On Mon, Nov 30, 2009 at 7:49 PM, Douglas M. Hultstrand <> wrote:

> Hello,
>
> I am trying to create subsets of grouped data (by area size), and use the
> area size as part of the output name.  The code below works for area (xout)
> 1 and 50, the other files are given NA for an area.
>
> A simple example:
> xout <- c(1,5,10,25,50,100)
> for(i in xout) { print(paste("Areal_Ppt_",xout[i],"sqmi.txt", sep="")) }
> [1] "Areal_Ppt_1sqmi.txt"
> [1] "Areal_Ppt_50sqmi.txt"
> [1] "Areal_Ppt_NAsqmi.txt"
(Continue reading)

jim holtman | 1 Dec 01:54 2009
Picon

Re: paste name in for loop?

Here is what you want:

xout <- c(1,5,10,25,50,100)
for(i in xout) { print(paste("Areal_Ppt_",i,"sqmi.txt", sep="")) }

Notice that 'i' will be assigned each value in xout; you do not have
to index into the vector.  Notice that you second value is 50 which is
xout[5].

On Mon, Nov 30, 2009 at 7:49 PM, Douglas M. Hultstrand
<dmhultst <at> metstat.com> wrote:
> Hello,
>
> I am trying to create subsets of grouped data (by area size), and use the
> area size as part of the output name.  The code below works for area (xout)
> 1 and 50, the other files are given NA for an area.
>
> A simple example:
> xout <- c(1,5,10,25,50,100)
> for(i in xout) { print(paste("Areal_Ppt_",xout[i],"sqmi.txt", sep="")) }
> [1] "Areal_Ppt_1sqmi.txt"
> [1] "Areal_Ppt_50sqmi.txt"
> [1] "Areal_Ppt_NAsqmi.txt"
> [1] "Areal_Ppt_NAsqmi.txt"
> [1] "Areal_Ppt_NAsqmi.txt"
> [1] "Areal_Ppt_NAsqmi.txt"
>
> The actual code and partial dataset are below.
>
> Thanks for your help,
(Continue reading)

Rolf Turner | 1 Dec 02:10 2009
Picon
Picon

Remark on tapply().


Consider the following:

 > set.seed(42)
 > ff <- factor(sample(c(1,3,5),42,TRUE),levels=1:5)
 > x <- runif(42)
 > tapply(x,ff,sum)
        1        2        3        4        5
3.675436       NA 7.519675       NA 9.094210

I got bitten by those NAs in the result of tapply().  Effectively
one is summing over the empty set, and consequently (according to what
I learned as a child) I thought that the result would be 0.

And that's what one gets if one does the sum ``by hand'':

 > sum(x[ff==1])
[1] 3.675436
 > sum(x[ff==2])
[1] 0
  > sum(x[ff==4])
[1] 0

On reflection I realized that since tapply() needs to work with  
arbitrary
functions, and since there is no way to determine what an arbitrary  
function
will do to the empty set, this is the Way It's Got to Be.

But it's a trap for young players, and so I thought I'd post my  
(Continue reading)

Ravi Varadhan | 1 Dec 03:42 2009

Re: optim or nlminb for minimization, which to believe?


Hi Harold,

Hans is right.  You can see this if you use BB::spg

require(BB)

opt2 <- spg(startVal, fn)  # this is fine

opt3 <- spg(startVal, fn,gradient)  # this is not fine!

> opt3 <- spg(startVal, fn, gradient) 
Gradient check details:  max. relative difference in gradients=  0.001697913 

  analytic gradient: 0.1724284 -0.3382045 0.1724284 -0.3382045 -0.4902559 

  numerical gradient: 0.2826690 -0.2569404 0.2826690 -0.2569404 -0.4223231
Error in spg(startVal, fn, gradient) : 
  Analytic gradient does not seem correct! See comparison above. Fix it, remove it, or increase checkGrad.tol.
>

Ravi.

____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University
(Continue reading)

Brock Tibert | 1 Dec 03:56 2009
Picon

Overlapping Plot Labels and Color Palette

Hi all,

I am new to R, but with the help I have received thus,I have already been able to work through a bunch of
questions on my own in just a few days.  I imagine my questions are relatively simple, but here she goes.  

1) I am using a package where one of the objects generated represents X/Y coordinates for each observation. 
I have been able to plot my row names onto the graph using text() (with the help of this list), but because it
is entirely possible for some rows to have the same X/Y coordinates, I need to separate the data labels so
that I can clearly see each.

I tried text(jitter(coordinates), labels = abbreviate(rownames(dataset), minlength=3)), but it
appears that jitter effect is the same for each x/y pair and not unique to each row.

2) I want to vary the color palette.  In the package help, it discusses the ability to change it, but never
mentions anything about what my options are, other than showing "rainbow" in the documentation.  I tried
to use one from RColorBrewer, but the package does not appear recognize it.  How can I find out what palettes
exist and, if possible, how can I create my own?  The palette I wanted was diverging Greys from RColorBrewer

I have made the assumption that the package I am using doesn't matter, but I am using the kohonen package in
case that matters.

Any help you can provide will be greatly appreciated!

- Brock


Gmane