Re: [R] How to print colorful R output??

2010-12-11 Thread Liviu Andronic
Hello

On Fri, Dec 10, 2010 at 10:53 PM, casperyc  wrote:
> I wonder if there is a way to print the R output with COLOR?
> Not the color plots, but the outputs in the console.
>
I once asked for this on the list [1], and the are two points:
- although technically feasible, say using ncurses, there are
currently no facilities for automated formatting of input/output
- go for editors that do this automatically, say Emacs or JGR

Regards
Liviu

[1] http://www.mail-archive.com/r-help@r-project.org/msg86512.html

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 with RSQLite adding a new column

2010-12-11 Thread Michael Bedward
Hi Michael,

Sorry if I'm being slow, but I've read your post three times and still
can't quite work out what you're trying to do (the changing variables
names are a bit confusing).

I use RSQLite a lot and might be able to help if you could explain
your inputs and desired output in simple terms.

(another) Michael


On 11 December 2010 05:18, Michael D  wrote:
> I'm new to using sql so I'm having difficulties (and worries) in adding a
> new column of data to a table I have. Its a very large file (around 5 Gb)
> which is why I'm having to use SQL
>
> I have a table with variables ID, IDrec and IDdes and the variables IDrec
> and IDdes give a mapping of some other values but the other values are
> associated with the ID variable (think of IDrec and IDdes being character
> strings and ID being numeric)
>
> (Imagine the transposed)
> Table1:
> ID: 1,2,3,4,...
> IDrec: A,B,C,D...
> IDdes: B,C,A,E...
>
> So I've created a table with the final form I need it to be in
>
> dbGetQuery(db, "CREATE TABLE Map
>                (ID int, IDrec int, IDrec1 int,
>                IDdes int, IDdes1 int)")
>
> And the finished table would look something like:
> Map:
> ID: 1, 2, 3, 4,...
> IDrec: 1, 2, 3, 4,...
> IDrec1: A, B, C, D,...
> IDdes: 2, 3, 1, 5,
> IDdes1: B, C, A, E,...
>
> So I copy in the first set of values easily:
> dbGetQuery(db, "INSERT INTO Map(ID, IDrec, IDrec1, IDdes1)
>                SELECT ID, ID, IDrec, IDdes FROM Ntemp")
>
> Giving me a table that looks like:
> Map:
> ID: 1, 2, 3, 4,...
> IDrec: 1, 2, 3, 4,...
> IDrec1: A, B, C, D,...
> IDdes: NA,NA,NA,NA,...
> IDdes1: B, C, A, E,...
>
> Then I create a new table with just the IDdes values I need:
> dbGetQuery(db, "Create table temp2 as
>                SELECT temp.ID
>                FROM Ntemp, temp
>                WHERE Ntemp.IDdes1 = temp.IDrec1")
>
> Giving me temp2 (not sure what the variable name is)
> V1: 2, 3, 1, 5,...
>
> But when I try to copy in the new data:
> dbGetQuery(db, "INSERT INTO Map(IDdes)
>                SELECT * FROM temp2")
>
> My map table isn't updated:
> Map:
> ID: 1, 2, 3, 4,...
> IDrec: 1, 2, 3, 4,...
> IDrec1: A, B, C, D,...
> IDdes: NA,NA,NA,NA,...
> IDdes1: B, C, A, E,...
>
> Is there something I'm missing? Or am I just going about inserting the IDdes
> variables the wrong way?
>
> Thanks for the help.
> Michael
>
>        [[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] 45 Degree labels on barplot? Help understanding code previously posted.

2010-12-11 Thread Jim Lemon

On 12/11/2010 02:25 AM, Simon Kiss wrote:

Dear colleagues,
i found a line or two of code in the help archives from Uwe Ligges about 
creating slanted x-labels for a barplot and it works well for my purposes (code 
below). However, I was hoping someone could explain to me precisely what the 
code is doing.
I'm aware it's invoking the text command, and I know the first ttwo arguments to text are x and y co-ordinates.  I'm 
also aware that par("usr")[3] is grabbing the third element of the vector of plotting co-ordinates.  But I 
tried replacing par("usr")[3] with just "0" and that didn't work; all the labels got bunched up on 
the left.  Is it necessary to create a new object via "barplot" and then quote that in the x,y coordinates of 
text?
Like I said, the code works great, but I'm trying to actually understand the 
rationale behind the elements so I can apply it in future.


Hi Simon,
The staxlab function will add an axis to an existing plot with either 
staggered or rotated labels. It is somewhat similar to Uwe's function. 
Looking at both the code and the examples on the help page might give 
you some idea why the function was written. It is principally to allow 
the user to add more labels than would be displayed on the default axes, 
and to decide whether staggering or rotating those labels will produce a 
better looking plot. The problem most often mentioned in adding custom 
labels to a plot produced by barplot is that the bars are centered on 
non-integer values, and so the user must get the return value of barplot 
and use that for the axis label positions.


Jim

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


Re: [R] Adding numbers in Outputs

2010-12-11 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 10.12.2010 15:00:12:

> Dear Mr Holtman Sir,
> 
> Thanks a lot for your great solution. This certainly is helping me 
achieve 
> what I need to get. However, I shall be hugely thankful to you if you 
can 
> guide me in one respect.
> 
> Sir, you have used following commands to assign values to x and y.  
> 
> > x <- list(40, c(80,160), c(160,80,400))
> > y <- list(10, c(10,30), c(5,18,20))
> > z <- c(1,2,3)
> 
> But Sir, the problem is these values are basically outputs of some other 

> process which I am running and chances are these will vary. Sir, it will 
be a 
> great help if you can guide me to convert the output (which I am 
getting)
> 
> X
> [[1]]
> [1] 40
> 
> [[2]]
> [1] 80160
> 
> [[3]]
> [1] 160   80  400
> 

I believe this object is probably list too so Jim's answer shall work on 
it. See what str(X) gives you as an output. 

Regards
Petr


> to what you have suggested 
> 
> x <- list(40, c(80,160), c(160,80,400))
> 
> So, in that case once I get output in my format, I will convert that 
output as
> provided by you.
> 
> I apologize for taking the liberty of writing to you, but I shall be 
really 
> grateful to you, as I have just started getting the feel of 'R' and I 
know I 
> need to take lots of efforts to begin with.
> 
> Thanks and eagerly waiting for your guidance.
> 
> Amelia Vettori
> 
> --- On Fri, 10/12/10, jim holtman  wrote:
> 
> From: jim holtman 
> Subject: Re: [R] Adding numbers in Outputs
> To: "Amelia Vettori" 
> Cc: r-help@r-project.org
> Received: Friday, 10 December, 2010, 1:43 PM
> 
> try this:
> 
> > x <- list(40, c(80,160), c(160,80,400))
> > y <- list(10, c(10,30), c(5,18,20))
> > z <- c(1,2,3)
> > mapply(function(a1,a2,a3){
> + a3 * sum(a1 * a2)
> + }
> + , x
> + , y
> + , z
> + )
> [1]   400 11200 30720
> 
> 
> On Fri, Dec 10, 2010 at 5:41 AM, Amelia Vettori
>  wrote:
> > two OutputsHello!
> >
> > I am Amelia from Auckland and work for a bank. I am new to R and I 
have 
> started my venture with R just a couple of weeks back and this is my 
first 
> mail to R-forum. I need following assistance
> >
> > Suppose my R code generates following outputs as
> >
> >
> >> X
> > [[1]]
> > [1] 40
> >
> > [[2]]
> > [1] 80160
> >
> > [[3]]
> > [1] 160   80  400
> >
> >
> >> Y
> >
> > [[1]]
> >
> > [1] 10
> >
> >
> >
> > [[2]]
> >
> > [1] 1030
> >
> >
> >
> > [[3]]
> >
> > [1] 5  18  20
> >
> > and suppose
> >
> > Z = c(1, 2, 3)
> >
> > I need to perform the calculation where I will be multiplying 
corresponding 
> terms of X and Y individually and multiplying their sum by Z and store 
these 
> results in a dataframe.
> >
> > I.e. I need to calculate
> >
> > (40*10) * 1 # (first element of X + 
First 
> element of Y) * Z[1] = 400
> >
> > ((80*10)+(160*30)) * 2 # 2 row of X and 2nd row of Y = 
11200
> >
> > ((160*5)+(80*18)+(400*20)) * 3 # 3rd row of X and 3 row of Y and 
Z[3] =  30720
> >
> >
> >
> > So the final output should be
> >
> > 400
> > 11200
> > 30720
> >
> >
> > One way of doing it is write R code for individual rows and
> >  arrive at the result e.g.
> >
> > ([[X]][1]*[[Y]][1])*1 will result in 400. However, I was just trying 
to know
> some smart way of doing it as there could be number of rows and writing 
code 
> for each row will be a cumbersome job. So is there any better way to do 
it?
> >
> > Please guide me.
> >
> > I thank you in advance.
> >
> > Thanking
> >  all
> >
> > Amelia
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >[[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
> Data Munger Guru
> 
> What is the problem that you are trying to solve?
> 
> 
> 
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] overlap different line in a xyplot (lattice)

2010-12-11 Thread Francesco Nutini

mmmh, yes this method works...
but I have to overlap this two graphs:



> xyplot(  a ~  b |  sites, data=dataset,  col="red")



> xyplot(  c ~  b |  sites, data=dataset,  col="blue")


a, b and c are columns in the same dataset. "Sites" is also a column in the 
dataset, but it's a factorial variables.
How can I use your method?
sorry for my ignorance! 

Francesco Nutini

> Date: Fri, 10 Dec 2010 10:13:00 -0800
> From: ehl...@ucalgary.ca
> To: nutini.france...@gmail.com
> CC: r-help@r-project.org
> Subject: Re: [R] [r] overlap different line in a xyplot (lattice)
> 
> On 2010-12-10 07:04, Francesco Nutini wrote:
> >
> > dear [R] users,
> > is there a way to plot different data (but with the same x-variables) in 
> > the same xyplot window?
> > There are already a similar question, but the answer is not enought 
> > explanatory...
> 
> Something like this?
> 
>   x <- rep(1:10, 2)
>   y1 <- rnorm(10); y2 <- rnorm(10) + 2
>   y <- c(y1, y2)
>   g <- gl(2, 10)
>   xyplot( y ~ x, groups = g, type = 'b')
> 
> Peter Ehlers
> 
> >
> >
> > Thanks a lot,
> > Francesco
> >
> 
  
[[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] melt causes errors when characters and values are used

2010-12-11 Thread Dennis Murphy
Hi:


On Fri, Dec 10, 2010 at 6:47 AM, Daniel Brewer wrote:

> Hello,
>
> I am finding that the melt function from the reshape library causes
> errors when applied to a data.frame that contains numeric and character
> columns.  For example,
>

In this case, thankfully so - it's warning that you're trying to mix numeric
and factor variables.

>
> melt(id.vars="ID",data.frame(ID=1:3,date=c("a","b","c"),value=c(1,4,5)))
>  ID variable value
> 1  1 date a
> 2  2 date b
> 3  3 date c
> 4  1value  
> 5  2value  
> 6  3value  
> Warning message:
> In `[<-.factor`(`*tmp*`, ri, value = c(1, 4, 5)) :
>  invalid factor level, NAs generated
>
> It would be useful in this situation that the numerical column got
> converted to a character column in this situation.  Any ways round this?
>

For this question, convert value to character before melting it.

>
> In actual fact I have got a situation where it is more like this
>
> ID  Date_1  Value_1 Date_2  Value_2 ...
>
> and I would like to convert it to a data.frame of ID, Date & Value but I
> thought the above would be an appropriate middle step.
>

This is a more effective way, taken from a post on the ggplot2 list,
courtesy of Kohske Takahashi:

# Toy data:
df <- data.frame(id = as.character(101:110),
  date1 = seq(from = as.Date('2006-01-10'),
to = as.Date('2006-01-19'), by = 'day'),
   value1 = rpois(10, 5),
  date2 = seq(from = as.Date('2006-02-10'),
to = as.Date('2006-02-19'), by = 'day'),
   value2 = rpois(10, 10),
   stringsAsFactors = FALSE)

dfm <- data.frame(
melt(df, id = 'id', measure = c(grep('^date', names(df,
myval = melt(df, id = 'id',
 measure = c(grep('^val', names(df$value
 )
names(dfm)[3] <- 'date'

The first melt() call creates the three variables that are normally returned
from melt(): id, variable and value. The second, internal melt() call
creates a stacked column for the values without creating a new 'variable'.
One can repeat the game with multiple sets of variables.

Of course, there is an alternative way to reshape such data with the
reshape() function...


HTH,
Dennis


Thanks
>
> Dan
> --
> **
> Daniel Brewer, Ph.D.
>
> Institute of Cancer Research
> Molecular Carcinogenesis
> Email: daniel.bre...@icr.ac.uk
> **
>
> The Institute of Cancer Research: Royal Cancer Hospital, a charitable
> Company Limited by Guarantee, Registered in England under Company No. 534147
> with its Registered Office at 123 Old Brompton Road, London SW7 3RP.
>
> This e-mail message is confidential and for use by the...{{dropped:13}}

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


Re: [R] (no subject)

2010-12-11 Thread Dennis Murphy
Hi:

Here's a plyr solution:

library(plyr)
dg <- data.frame(x1 = rep(1:2, c(10, 15)), x2 = 1:25)
f <- function(x) head(rev(sort(x)), 5)
> ddply(dg, 'x1', summarise, x2 = f(x2))
   x1 x2
1   1 10
2   1  9
3   1  8
4   1  7
5   1  6
6   2 25
7   2 24
8   2 23
9   2 22
10  2 21

HTH,
Dennis


On Fri, Dec 10, 2010 at 6:18 AM, andrija djurovic wrote:

> Hi R-help,
>
>
>
> I am trying to find a way to select five highest values in data frame
> according some variable. I will demonstrate:
>
> c
>
>   X1 X2
>
> 1   1  1
>
> 2   1  2
>
> 3   1  3
>
> 4   1  4
>
> 5   1  5
>
> 6   1  6
>
> 7   1  7
>
> 8   1  8
>
> 9   1  9
>
> 10  1 10
>
> 11  2 11
>
> 12  2 12
>
> 13  2 13
>
> 14  2 14
>
> 15  2 15
>
> 16  2 16
>
> 17  2 17
>
> 18  2 18
>
> 19  2 19
>
> 20  2 20
>
> 21  2 21
>
> 22  2 22
>
> 23  2 23
>
> 24  2 24
>
> 25  2 25
>
>
>
> So I would like to select a rows with higest values of X2 inside X1.
> Expected result should be:
>
> X1 X2
>
>   1  10
>
>   1  9
>
>   1  8
>
>   1  7
>
>   1  6
>
>   2  25
>
>   2  24
>
>   2  23
>
>   2  22
>
>   2  21
>
>
>
> I first oreded the data frame using
>
> c=c[with(c,order(X1,-X2)),]
>
> but I need a help to select highes five. It is easy to select when I have
> just 2 unique values of X1 but what is if I have 500 unique values in X1?
>
>
>
> Thanks
>
> Andrija
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] New R Install Worked to End Trouble Loading doBy and coin Packages

2010-12-11 Thread Adam Carr
Hello Peter:

The new R install seems to have worked. Both doBy and coin appear to load and 
run fine. Thanks for taking the time to help me.

Adam





From: Peter Ehlers 

Cc: "r-help@r-project.org" 
Sent: Fri, December 10, 2010 7:13:17 AM
Subject: Re: [R] New Installs, Same Trouble Loading doBy and coin Packages

On 2010-12-10 03:43, Adam Carr wrote:
> I tried Tal's suggestion of deleting the doBy and coin packages and then
> reinstalling them from a different mirror. The first install was from the
> Harvard mirror and the second was from the Case Western Univ. mirror. The new
> packages generate the same errors when I call them using the library() 
command.
>
> Also, I tried to load these packages using R and its script editor thinking 
>that
> the problem may have something to do with Tinn-R, but the same errors are
> generated on the R terminal when I use the library() function.
>
> Any help would be appreciated.
>
> Again, the errors for these two packages:
>
> Error in length(label) : could not find function ".extendsForS3"
> Error: package/namespace load failed for 'doBy'
>
>
>> library(coin)
> Loading required package: mvtnorm
> Loading required package: modeltools
> Loading required package: stats4  #This is odd. I cannot find any reference 
for
> this package. AC
> Error in length(sig) : could not find function ".extendsForS3"
> Error: package 'stats4' could not be loaded
>

I would remove and re-install R. 'stats4' is a base package
and if that can't be loaded, your installation may be broken.
Try
  require(stats4)
or
  help(package=stats4)

Peter Ehlers

>
>
>
>
> - Forwarded Message 

> To: Tal Galili
> Cc: r-help@r-project.org
> Sent: Thu, December 9, 2010 1:12:21 PM
> Subject: Re: [R] Trouble Loading doBy and coin Packages
>
> Hi Tal:
>
> No I have not tried this. I will do it this evening and we'll see what 
happens.
> Thanks for the suggestion.
>
> Adam
>
>
>
>
> 
> From: Tal Galili
>
> Cc: r-help@r-project.org
> Sent: Thu, December 9, 2010 12:29:20 PM
> Subject: Re: [R] Trouble Loading doBy and coin Packages
>
>
> I Adam,
> Have you tried deleting the package files and then reinstalling them from a
> different CRAN mirror?
>
>
> Tal
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
>--
>-
>
>
>
>
>
>
>
>
>
> Good Evening R-Help Community:
>>
>> I have attached a file that contains the output from sessionInfo() and a
> summary
>> of my Win XP system. I am running R 2.12.0 and using Tinn-R 2.3.6.2 as my
>> interface. When I attempt to call either the doBy or coin packages R 
generates
>> an error that I do not understand and have so far not been able to resolve by
>> searching R resources.
>>
>> I exchanged a couple of emails with Soren Hojsgaard who does not think the 
>doBy
>> error is directly related to the package itself, and he suggested that I post
>> this problem for input from others.
>>
>> When the doBy package is loaded, the following error appears in the Tinn-R 
>log:
>>
>> Error in length(label) : could not find function ".extendsForS3"
>> Error: package/namespace load failed for 'doBy'
>>
>> When the coin package is called, this error appears in the Tinn-R log:
>>
>> Error in length(sig) : could not find function ".extendsForS3"
>> Error: package 'stats4' could not be loaded
>>
>> No functions in either package work, and when I attempt to call them the same
>> errors are generated in the log.
>>
>> Any help or direction would be appreciated.
>>
>> Thanks very much,
>>
>> Adam
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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]]
>
>
>


  
[[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] Projecting data on a world map using long/lat

2010-12-11 Thread Patrick Hausmann

Hi Mathijs,

this should work:

library(maptools)
library(ggplot2)
gpclibPermit()
theme_set(theme_bw())

#setwd("C:\\foo") point to your local dir
# Data: http://thematicmapping.org/downloads/world_borders.php
world.shp <- readShapeSpatial("TM_WORLD_BORDERS-0.3.shp")

# check for region-id - Use "FIPS"
head(world@data)

## see licence, not GPL
world.shp.p <- fortify.SpatialPolygonsDataFrame(world.shp, region="FIPS")

world <- merge(world.shp.p, world.shp, by.x="id", by.y="FIPS")

head(world)
dim(world)

# only the worldmap
p <- ggplot(data=world, aes(x=long, y=lat, group=group)) + 
geom_polygon(fill="#63D1F4")

p <- p + geom_path(color="white") + coord_equal()
ggsave(p, width=11.69, height=8.27, file="world_map.jpg")

## Add some locations
cities <- read.table(textConnection("
longlat  city  pop
-58.381944 -34.599722 'Buenos Aires' 11548541
14.25 40.83 Neapel 962940"), header = TRUE)

p1 <- p + geom_point(data = cities, aes(group = NULL), shape=5,
 color='black')
ggsave(p1, width=11.69, height=8.27, file="world_map_2.jpg")

Regards,
Patrick


Am 10.12.2010 17:53, schrieb mathijsdevaan:


Thanks for the suggestions, but I am not there yet (I'm a real novice). In
the code provided by Patrick (see below), I changed the shape input (from
sids to world) which I downloaded here:
http://thematicmapping.org/downloads/world_borders.php. As a result I also
need to change the "CNTY_ID" and "id" in the code, but I have no idea what
to put there. Could you please help me? Thanks!

Mathijs

library(maptools)
library(ggplot2)
gpclibPermit()

myshp<- readShapeSpatial(system.file("shapes/sids.shp",
package="maptools"))

## see licence, not GPL
myshp.points<- fortify.SpatialPolygonsDataFrame(myshp,
region="CNTY_ID")

shpm<- merge(myshp.points, myshp, by.x="id", by.y="CNTY_ID")

head(shpm)

p<- ggplot(shpm, aes(long, lat, group=group, fill=NWBIR74))
p<- p + geom_polygon() + geom_path(color="white") + coord_equal()

## Add some locations
cities<- read.table(textConnection("
longlat  city  val
-78.644722 35.818889  Raleigh   323
-80.84 35.226944  Charlotte  510
-82.555833 35.58  Asheville400"), header = TRUE)

p<- p + geom_point(aes( fill=NULL, group = NULL, size=val),
  data = cities, color= 'black')
p


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RES: Barplot with "Independent" Lines Y axis

2010-12-11 Thread Rodrigo Aluizio
Well, at least I could help (even if unintentionally), as a
compensation for all the help I got from the list.

Cheers.

Em sexta-feira, 10 de dezembro de 2010, Jim Lemon escreveu:
> On 12/10/2010 08:48 PM, Rodrigo Aluizio wrote:
>
> OK that's it. Working nicely. I sent the final graph with the note of the
> twoord.plot help attached to it. And some "personal" comments
>
>
> Hi Rodrigo,
> Although I came rather late to this, I might as well show how I did it:
>
> # first I corrected the commas as Peter pointed out
> library(plotrix)
> par(las=3)
> twoord.plot(ly=pluv_sal$Rain,lx=pluv_sal$Salt,mar=c(6,4,4,2),
>  xlab="",ylab="Rainfall (mm)",rylab="Salinity",type=c("bar","b"),
>  main="Rainfall and salinity",lcol=NA,rcol=2,
>  xticklab=pluv_sal$Point,xaxt="n")
> par(las=0)
> mtext("Month",side=1,at=7,line=3)
>
> You did find a bug in the twoord.plot function, and the next version of 
> plotrix will contain one more bug fix, with thanks to you.
>
> Jim
>
>

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


[R] Can't install Sweave

2010-12-11 Thread Rainer Schuermann
Hi there!

I tried to work with Sweave, assuming that it is part of the standard 
installation - which it was not for my system. Trying to install, it gives me 
this error message:

> install.packages("Sweave")
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘Sweave’ is not available

My system data are:

> sessionInfo() 
>   
R version 2.12.0 (2010-10-15)   
  
Platform: x86_64-pc-linux-gnu (64-bit)  
  

  
locale: 
  
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8  
  
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8 
  
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C   
  
 [9] LC_ADDRESS=C   LC_TELEPHONE=C  
  
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C 
  

  
attached base packages: 
  
[1] stats graphics  grDevices utils datasets  grid  methods 
  
[8] base
  

  
other attached packages:
  
[1] reshape_0.8.3 plyr_1.2.1proto_0.3-8 
  

  
loaded via a namespace (and not attached):  
  
[1] ggplot2_0.8.8

Any idea what I need to do?

Thanks a lot,
Rainer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] overlap different line in a xyplot (lattice)

2010-12-11 Thread Peter Ehlers

On 2010-12-11 03:12, Francesco Nutini wrote:

mmmh, yes this method works...
but I have to overlap this two graphs:


 xyplot(a ~b |sites, data=dataset, col="red")



 xyplot(c ~b |sites, data=dataset, col="blue")



a, b and c are columns in the same dataset. "Sites" is also a column in
the dataset, but it's a factorial variables.
How can I use your method?


The idea is the same: you need to get your data
into "long" format with a grouping variable and
then use the 'groups' argument to xyplot.
Here's fake data frame (you should have provided one):

 DF <- data.frame(y1 = rnorm(30),
  y2 = rnorm(30) + 2,
  x  = rep(1:10, 3),
   sites = gl(3, 10, lab=LETTERS[1:3]))

## Use the reshape2 package to melt the data:
## (or use reshape() in base R)
 require(reshape2)
 DF1 <- melt(DF, measure.vars = c('y1', 'y2'),
 variable.name = 'grp', value.name = 'y')

## and plot:
 require(lattice)
 p <- xyplot( y ~ x | sites, data = DF1, groups = grp,
 col = c("red", "blue"), type = "b")
 print(p)

Peter Ehlers


sorry for my ignorance!

Francesco Nutini

 > Date: Fri, 10 Dec 2010 10:13:00 -0800
 > From: ehl...@ucalgary.ca
 > To: nutini.france...@gmail.com
 > CC: r-help@r-project.org
 > Subject: Re: [R] [r] overlap different line in a xyplot (lattice)
 >
 > On 2010-12-10 07:04, Francesco Nutini wrote:
 > >
 > > dear [R] users,
 > > is there a way to plot different data (but with the same
x-variables) in the same xyplot window?
 > > There are already a similar question, but the answer is not enought
explanatory...
 >
 > Something like this?
 >
 > x <- rep(1:10, 2)
 > y1 <- rnorm(10); y2 <- rnorm(10) + 2
 > y <- c(y1, y2)
 > g <- gl(2, 10)
 > xyplot( y ~ x, groups = g, type = 'b')
 >
 > Peter Ehlers
 >
 > >
 > >
 > > Thanks a lot,
 > > Francesco
 > >
 >


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


Re: [R] Can't install Sweave

2010-12-11 Thread huang min
Sweave is not a package. It is a function which comes with the base R.

Huang

On Sat, Dec 11, 2010 at 9:07 PM, Rainer Schuermann <
rainer.schuerm...@gmx.net> wrote:

> Hi there!
>
> I tried to work with Sweave, assuming that it is part of the standard
> installation - which it was not for my system. Trying to install, it gives
> me this error message:
>
> > install.packages("Sweave")
> Warning message:
> In getDependencies(pkgs, dependencies, available, lib) :
>  package ‘Sweave’ is not available
>
> My system data are:
>
> > sessionInfo()
> R version 2.12.0 (2010-10-15)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  grid  methods
> [8] base
>
> other attached packages:
> [1] reshape_0.8.3 plyr_1.2.1proto_0.3-8
>
> loaded via a namespace (and not attached):
> [1] ggplot2_0.8.8
>
> Any idea what I need to do?
>
> Thanks a lot,
> Rainer
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Can't install Sweave

2010-12-11 Thread Gavin Simpson
On Sat, 2010-12-11 at 14:07 +0100, Rainer Schuermann wrote:
> Hi there!
> 
> I tried to work with Sweave, assuming that it is part of the standard
> installation - which it was not for my system. Trying to install, it
> gives me this error message:

Why do you think it wasn't installed? There is no package "Sweave".

Sweave() is a function in package "utils", which you session info
indicates you have and is loaded.

Care to tell us what you want to do with Sweave and why you think it
isn't working?

HTH

G


> > install.packages("Sweave")
> Warning message:
> In getDependencies(pkgs, dependencies, available, lib) :
>   package ‘Sweave’ is not available
> 
> My system data are:
> 
> > sessionInfo()   
> > 
> R version 2.12.0 (2010-10-15) 
> 
> Platform: x86_64-pc-linux-gnu (64-bit)
> 
>   
> 
> locale:   
> 
>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C  
> 
>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
> 
>  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8   
> 
>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C 
> 
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> 
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   
> 
>   
> 
> attached base packages:   
> 
> [1] stats graphics  grDevices utils datasets  grid  methods   
> 
> [8] base  
> 
>   
> 
> other attached packages:  
> 
> [1] reshape_0.8.3 plyr_1.2.1proto_0.3-8   
> 
>   
> 
> loaded via a namespace (and not attached):
> 
> [1] ggplot2_0.8.8
> 
> Any idea what I need to do?
> 
> Thanks a lot,
> Rainer
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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. 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] Rapache on windows

2010-12-11 Thread Santosh Srinivas
Hello all,

I searched on the www but could not find installation instructution for
rapache on windows. The page says that the release runs on UNIX/Linux and
Mac OS X operating systems.
Has anyone been able to configure it on windows? Any idea how to go about
it?

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.


Re: [R] Can't install Sweave

2010-12-11 Thread Rainer Schuermann
> Why do you think it wasn't installed? There is no package "Sweave".
> 
> Sweave() is a function in package "utils", which you session info
> indicates you have and is loaded.
> 
> Care to tell us what you want to do with Sweave and why you think it
> isn't working?

Oops - this is embarrassing!

I promise I have done a lot of research before I posted the question but I got 
the info wrong and didn't realize that it's a function, rather than a package...

Sweave.sty is not in my latex folder, will take care of that right now (I 
thought an "installation" would be the right way to get that done!) and keep 
quiet if thinks work nicely after that.

Thanks for pointing me in the right direction (also to Hung Min)
Rainer




On Saturday 11 December 2010 14:24:24 you wrote:
> On Sat, 2010-12-11 at 14:07 +0100, Rainer Schuermann wrote:
> > Hi there!
> > 
> > I tried to work with Sweave, assuming that it is part of the standard
> > installation - which it was not for my system. Trying to install, it
> > gives me this error message:
> 
> Why do you think it wasn't installed? There is no package "Sweave".
> 
> Sweave() is a function in package "utils", which you session info
> indicates you have and is loaded.
> 
> Care to tell us what you want to do with Sweave and why you think it
> isn't working?
> 
> HTH
> 
> G
> 
> 
> > > install.packages("Sweave")
> > Warning message:
> > In getDependencies(pkgs, dependencies, available, lib) :
> >   package ‘Sweave’ is not available
> > 
> > My system data are:
> > 
> > > sessionInfo() 
> > >   
> > R version 2.12.0 (2010-10-15)   
> >   
> > Platform: x86_64-pc-linux-gnu (64-bit)  
> >   
> > 
> >   
> > locale: 
> >   
> >  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
> >   
> >  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8  
> >   
> >  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8 
> >   
> >  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C   
> >   
> >  [9] LC_ADDRESS=C   LC_TELEPHONE=C  
> >   
> > [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C 
> >   
> > 
> >   
> > attached base packages: 
> >   
> > [1] stats graphics  grDevices utils datasets  grid  methods 
> >   
> > [8] base
> >   
> > 
> >   
> > other attached packages:
> >   
> > [1] reshape_0.8.3 plyr_1.2.1proto_0.3-8 
> >   
> > 
> >   
> > loaded via a namespace (and not attached):  
> >   
> > [1] ggplot2_0.8.8
> > 
> > Any idea what I need to do?
> > 
> > Thanks a lot,
> > Rainer
> > 
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] Can't install Sweave

2010-12-11 Thread Duncan Murdoch

On 11/12/2010 8:41 AM, Rainer Schuermann wrote:

Why do you think it wasn't installed? There is no package "Sweave".

Sweave() is a function in package "utils", which you session info
indicates you have and is loaded.

Care to tell us what you want to do with Sweave and why you think it
isn't working?


Oops - this is embarrassing!

I promise I have done a lot of research before I posted the question but I got 
the info wrong and didn't realize that it's a function, rather than a package...

Sweave.sty is not in my latex folder, will take care of that right now (I thought an 
"installation" would be the right way to get that done!) and keep quiet if 
thinks work nicely after that.


You shouldn't do that.  It will work until Sweave.sty is updated, then 
cause you hard-to-debug problems.


Use R utilities (e.g. tools::texi2dvi, or ones from a contributed 
package) to run latex, and they will point to the current Sweave.sty. 
If you put a copy of Sweave.sty into your latex installation, in a few 
months you'll have an obsolete version, and things will just not work.


Duncan Murdoch



Thanks for pointing me in the right direction (also to Hung Min)
Rainer




On Saturday 11 December 2010 14:24:24 you wrote:

On Sat, 2010-12-11 at 14:07 +0100, Rainer Schuermann wrote:

Hi there!

I tried to work with Sweave, assuming that it is part of the standard
installation - which it was not for my system. Trying to install, it
gives me this error message:


Why do you think it wasn't installed? There is no package "Sweave".

Sweave() is a function in package "utils", which you session info
indicates you have and is loaded.

Care to tell us what you want to do with Sweave and why you think it
isn't working?

HTH

G



install.packages("Sweave")

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

My system data are:


sessionInfo()

R version 2.12.0 (2010-10-15)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
  [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  grid  methods
[8] base

other attached packages:
[1] reshape_0.8.3 plyr_1.2.1proto_0.3-8

loaded via a namespace (and not attached):
[1] ggplot2_0.8.8

Any idea what I need to do?

Thanks a lot,
Rainer

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





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


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


[R] Statistics::R

2010-12-11 Thread Yifang Liu
Dear,ALL

I am using CRAN module Statistics::R to run R scripts in Perl, The problem
is how to pass the array variable to R?
Following is my Perl script:

#!/usr/bin/perl

use strict;
use warnings;
use Statistics::R;

open DATA,"<","data.txt" or die "$!";
my @data = ;
my $R = Statistics::R -> new();
$R -> startR;
$R -> send(qq'x <- ...') #how to pass @data to the R variable x?

Any suggestion will be appreciate~

[[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] simple payoff function

2010-12-11 Thread Santosh Srinivas
Just wondering if there is a better way to do this?

x <-  seq(4,20,1)

y <- sapply(x, function(x) (max(x-10,0)))

Is there a easier way to get to y? i.e. max(x-10,0)

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

2010-12-11 Thread Romain Francois

Le 11/12/10 16:09, Santosh Srinivas a écrit :


Just wondering if there is a better way to do this?

x<-  seq(4,20,1)

y<- sapply(x, function(x) (max(x-10,0)))

Is there a easier way to get to y? i.e. max(x-10,0)


Hello,

You are probably looking for pmax, that is described in the same help 
page as max.


> pmax(x-10, 0)
 [1]  0  0  0  0  0  0  0  1  2  3  4  5  6  7  8  9 10
> ?pmax

Romain

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/fT2rZM : highlight 0.2-5
|- http://bit.ly/gpCSpH : Evolution of Rcpp code size
`- http://bit.ly/hovakS : RcppGSL initial release

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

2010-12-11 Thread andrija djurovic
Hi R users.

I have a problem with function strata in sampling packages.

> st0 = strata(dom, stratanames="stratas", size=sample.size,
method="systematic",pik, FALSE)
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?

In previous version of R 2.9.1 and previous version of package sampling this
code worked well and now I don't know what is a problem?
Any ideas how to solve this problem will be very useful?


Thanks in advance

Andrija

[[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] toJSON question

2010-12-11 Thread Santosh Srinivas
Hello,

I am trying to use RJSONIO

I have:
x <- c(0,4,8,9)
y <- c(3,8,5,13)
z <- cbind(x,y)

Any idea how to convert z into the JSON format below?

I want to get the following JSON output to put into a php file.
 [[0, 3], [4, 8], [8, 5], [9, 13]]

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.


Re: [R] Can't install Sweave

2010-12-11 Thread Rainer Schuermann
On Saturday 11 December 2010 14:54:39 Duncan Murdoch wrote:
> If you put a copy of Sweave.sty into your latex installation, in a few 
> months you'll have an obsolete version, and things will just not work.

A link from ly latex installation to the original file in my R installation 
would do fine? It works, but is there a downside I wouldn't know?

Background is that I want to use kile for editing my .Rnw file (which will be 
more text than calculation), with the convenience of having the .Rnw and the 
.tex file (and the .bib file) all in one window, with an integrated Konsole 
window at the bottom.

Thanks,
Rainer

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

2010-12-11 Thread Duncan Temple Lang


On 12/11/10 8:00 AM, Santosh Srinivas wrote:
> Hello,
> 
> I am trying to use RJSONIO
> 
> I have:
> x <- c(0,4,8,9)
> y <- c(3,8,5,13)
> z <- cbind(x,y)
> 
> Any idea how to convert z into the JSON format below?
> 
> I want to get the following JSON output to put into a php file.
>  [[0, 3], [4, 8], [8, 5], [9, 13]]

The toJSON() function is the basic mechanism.
In this case, z has names on the columns.
Remove these
  colnames(z) = NULL

Then toJSON(z) gives you want you want.

If you want to remove the new line (\n) characters,
use gsub().

  gsub("\\\n", "", toJSON(z))


  D.


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

2010-12-11 Thread Dieter Menne


Santosh Srinivas wrote:
> 
> I am trying to use RJSONIO
> 
> I have:
> x <- c(0,4,8,9)
> y <- c(3,8,5,13)
> z <- cbind(x,y)
> 
> Any idea how to convert z into the JSON format below?
> 
> I want to get the following JSON output to put into a php file.
>  [[0, 3], [4, 8], [8, 5], [9, 13]]
> 

I have not tried RJSONIO, but with package rjson you could use:

> toJSON(as.data.frame(z))
[1] "{\"x\":[0,4,8,9],\"y\":[3,8,5,13]}"
> toJSON(as.data.frame(t(z)))
[1] "{\"V1\":[0,3],\"V2\":[4,8],\"V3\":[8,5],\"V4\":[9,13]}"

Dieter


-- 
View this message in context: 
http://r.789695.n4.nabble.com/toJSON-question-tp3083427p3083445.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] Could concurrent R sessions mix up variables?

2010-12-11 Thread Tal Galili
Hello Anthony,
Since you are working on Windows, also consider using the "doSMP" with the
"foreach" package.
Although it is not fully GPL as many of us would have preferred (e.g: doSMP
is not on CRAN), it is still freely available (with source code and all) to
download (even without the need for "REvolution R").
See my post here:
http://www.r-statistics.com/2010/04/parallel-multicore-processing-with-r-on-windows/
On how to use them for parallel multicore processing.

My previous attempts at using the "snowfall" package with multicore has
failed.  But it could be that I have missed something, or that the package
was updated in meantime - so I would suggest trying both.
The multicore package is not available for windows.

Cheers,
Tal




Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Fri, Dec 10, 2010 at 8:58 PM, Phil Spector wrote:

> Anthony -
>   I would advise you to use the multicore or snowfall packages
> to utilize multiple CPUs.  As an example using multicore:
>
>  library(multicore)
>> sim = function(mu)max(replicate(10,max(rnorm(100,mu
>> library(multicore)
>> unlist(mclapply(c(1,5,10,20),sim))
>>
> [1]  6.569332 10.268091 15.335847 25.291502
>
> Using snowfall:
>
>  library(snowfall)
>> sim = function(mu)max(replicate(10,max(rnorm(100,mu
>> sfInit(cpus=4,type='SOCK',parallel=TRUE)
>> sfSapply(c(1,5,10,20),sim)
>>
> [1]  6.200161 10.307807 15.271581 25.055950
>
> Hope this helps.
>
>- Phil Spector
> Statistical Computing Facility
> Department of Statistics
> UC Berkeley
> spec...@stat.berkeley.edu
>
>
>
>
>
>
>
> On Fri, 10 Dec 2010, Anthony Damico wrote:
>
>  Hi, I'm working in R 2.11.1 x64 on Windows x86_64-pc-mingw32.
>>
>> I'm experiencing a strange problem in R that I'm not even sure how to
>> begin to fix.
>>
>> I've got a huge (forty-pages printed) simulation written in R that I'd
>> like to run multiple times.  When I open up R and run it on its own,
>> it works fine.  At the beginning of the program, there's a variable X
>> that I set to 1, 5, 10, 20, depending on how sensitive I want the
>> simulation to be to a certain parameter.  When I just run one instance
>> of R, the X variable stays the same throughout the program.
>>
>> I have a quad-core machine, so I'd like to take advantage of all four
>> processors.
>>
>> If I open up four sessions and set X to 1, 5, 10, and 20 in those
>> different sessions, then run all four simulations all the way through
>> (about eighteen hours of processing time) at the same time, the
>> variable X ends up being 20 at the end of all four sessions.  It's as
>> if R mixed up the variable setting between the four concurrent
>> sessions.  I can't figure out why else my variable X would ever get
>> changed to 20 in the three simulations that I set it to 1, 5, and 10,
>> respeectively (it doesn't get updated anywhere during the simulation).
>>
>> When I have all four of these simulations running concurrently, I am
>> absolutely maxing out my computer.  All four processors are at 100%,
>> and my Windows Task Manager says I'm using almost 100% of my 16 GB of
>> RAM.  Is it possible that intense resource use would cause a variable
>> conflict like this?  I have no idea where to start troubleshooting
>> this error, so any advice would be appreciated.
>>
>> Thanks!
>>
>> Anthony Damico
>> Kaiser Family Foundation
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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.
>

[[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] Can't install Sweave

2010-12-11 Thread Yihui Xie
Is it a good idea to put Sweave.sty and other style files into CTAN as
a LaTeX package? (instead of pointing the users to file.path(R.home(),
'share', 'texmf') each time they run into troubles)

Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Sat, Dec 11, 2010 at 7:54 AM, Duncan Murdoch
 wrote:
> On 11/12/2010 8:41 AM, Rainer Schuermann wrote:
>>>
>>> Why do you think it wasn't installed? There is no package "Sweave".
>>>
>>> Sweave() is a function in package "utils", which you session info
>>> indicates you have and is loaded.
>>>
>>> Care to tell us what you want to do with Sweave and why you think it
>>> isn't working?
>>
>> Oops - this is embarrassing!
>>
>> I promise I have done a lot of research before I posted the question but I
>> got the info wrong and didn't realize that it's a function, rather than a
>> package...
>>
>> Sweave.sty is not in my latex folder, will take care of that right now (I
>> thought an "installation" would be the right way to get that done!) and keep
>> quiet if thinks work nicely after that.
>
> You shouldn't do that.  It will work until Sweave.sty is updated, then cause
> you hard-to-debug problems.
>
> Use R utilities (e.g. tools::texi2dvi, or ones from a contributed package)
> to run latex, and they will point to the current Sweave.sty. If you put a
> copy of Sweave.sty into your latex installation, in a few months you'll have
> an obsolete version, and things will just not work.
>
> Duncan Murdoch
>
>>
>> Thanks for pointing me in the right direction (also to Hung Min)
>> Rainer
>>
>>
>>
>>
>> On Saturday 11 December 2010 14:24:24 you wrote:
>>>
>>> On Sat, 2010-12-11 at 14:07 +0100, Rainer Schuermann wrote:

 Hi there!

 I tried to work with Sweave, assuming that it is part of the standard
 installation - which it was not for my system. Trying to install, it
 gives me this error message:
>>>
>>> Why do you think it wasn't installed? There is no package "Sweave".
>>>
>>> Sweave() is a function in package "utils", which you session info
>>> indicates you have and is loaded.
>>>
>>> Care to tell us what you want to do with Sweave and why you think it
>>> isn't working?
>>>
>>> HTH
>>>
>>> G
>>>
>>>
> install.packages("Sweave")

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

 My system data are:

> sessionInfo()

 R version 2.12.0 (2010-10-15)
 Platform: x86_64-pc-linux-gnu (64-bit)

 locale:
  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C
 [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

 attached base packages:
 [1] stats     graphics  grDevices utils     datasets  grid      methods
 [8] base

 other attached packages:
 [1] reshape_0.8.3 plyr_1.2.1    proto_0.3-8

 loaded via a namespace (and not attached):
 [1] ggplot2_0.8.8

 Any idea what I need to do?

 Thanks a lot,
 Rainer

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

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


Re: [R] Can't install Sweave

2010-12-11 Thread Duncan Murdoch

On 11/12/2010 11:18 AM, Rainer Schuermann wrote:

On Saturday 11 December 2010 14:54:39 Duncan Murdoch wrote:

If you put a copy of Sweave.sty into your latex installation, in a few
months you'll have an obsolete version, and things will just not work.


A link from ly latex installation to the original file in my R installation 
would do fine? It works, but is there a downside I wouldn't know?


The link may break when you re-install R, but the link is probably safer 
than making a copy.



Background is that I want to use kile for editing my .Rnw file (which will be 
more text than calculation), with the convenience of having the .Rnw and the 
.tex file (and the .bib file) all in one window, with an integrated Konsole 
window at the bottom.


I don't know that editor, but I would suggest that most of the time you 
don't really want to look at the .tex file.  Changes there get wiped out 
the next time you run Sweave.


What I do is to write a simple command for my editor that does the three 
steps Sweave, latex/pdflatex, preview all in one command.  I wrote a 
little R package that helps with this; it's called patchDVI, available 
on R-forge.  Using that package the command is


echo patchDVI::SweaveMiktex('%2', preview='yap -1 -s"%1%2" \x25s') | 
Rterm --slave


or

echo patchDVI::SweavePDF('%2', stylepath=FALSE, 
preview="f:/SumatraPDF/SumatraPDF \x25s") | Rterm --slave



The previewer gets links back to the .Rnw file.

This still requires looking at the .tex file to understand LaTeX errors; 
one day I'll patch those too, but haven't got around to it yet.


Duncan Murdoch




Thanks,
Rainer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] quantile linear ridge regression using qrnn

2010-12-11 Thread Daniel Gordon
We would like to use the qrnn package for building a quantile  linear ridge
regression.
To this end we need to use the function qrnn.rbf.
The meaning of the second argument x.basis, isn't clear to me.
What should I give it as an argument? Does the contents of this matrix have
any meaning or only it's dimensions?

Thanks,
Daniel

[[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] remove quotes from the paste output

2010-12-11 Thread vaibhav dua
Hi,

I'm generating the name of the variable with paste function and then using that 
variable name further to get the specific position value from the data.frame, 
here is the snippet from my code:

modelResults <- extractModelParameters("C:/PilotStudy/Mplus_Input/Test", 
recursive=TRUE)

#extractModelParameters reads all the output files from the Test folder and 
create the following variables in R for each file read:
#C..PilotStudy.Mplus_Input.Test.rep1.out.unstandardized.est
#C..PilotStudy.Mplus_Input.Test.rep2.out.unstandardized.est
#C..PilotStudy.Mplus_Input.Test.rep3.out.unstandardized.est

modelResultsTemp <- as.data.frame(modelResults)

MeansTempC1 = rep(NA ,9)
counter = 1

for (f in 1:3)
{
i=31

for (g in 1:3)
{
OutputFileName <- 
paste("modelResultsTemp$C..PilotStudy.Mplus_Input.Test.rep",f,".out.unstandardized.est[",i,"]",sep="")

MeansTempC1[counter] = OutputFileName
i=i+1
counter = counter+1
}
}

Its not giving me any error but I'm not getting the desired output in 
MeansTempC1 because OutputFileName is a string and thats why its not returning 
the OutputFileName[31] etc. Does anybody know how to eliminate the double 
quotes 
so that I can use the variable name (generated with the paste function) further 
in the code

Regards
Bob



  
[[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] break

2010-12-11 Thread Serdar Akin
Hi

I'm trying to utilize the break command for breaking the loop when the
p-value is less than 10 per cent using the urca package. But it does not
break the loop, anyone that can help me?

library(urca)
set.seed(1)
a1 <- runif(100)
lag.max <- function(object, n = 12){
matris <- matrix(NA, nrow = n)
for(i in 1:n) {
   matris[i] <- ur.df(object, lags = i,
  type = "trend")@testreg$coefficients[i+3,4]
   if (i <  0.1) {break(i)}
   }
   list(matris = round(matris, 3))
   }
a2 <- lag.max(a1)

/With regards
Serdar

[[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] help requested

2010-12-11 Thread profaar


hi
  thanks for your reply. there are around 2 nodes in my dataset. will it 
work for conversion from edge list format to node list format? I am using R 
under Windows XP.

With Warm Wishes and Regards
  
A. Abdul Rasheed, M.C.A., M.E., Ph.D.,
Assistant Professor,
Department of Computer Applications,
Valliammai Engineering College,
SRM Nagar, Kattankulathur - 603 203.
Kancheepuram District. Tamil Nadu. INDIA.
Contact: 91 - 44 - 27454784 Ext: 451 (O) / 996 23 000 55





Date: Fri, 10 Dec 2010 10:33:30 -0800
From: ml-node+3082496-762697967-204...@n4.nabble.com
To: prof...@live.com
Subject: Re: help requested



On Fri, Dec 10, 2010 at 07:20:55AM -0800, profaar wrote:

> 

> HI friends,

>   I have very lengthy graph data in edge list format. I want to convert it

> into node list format. 

> 

> example:

> EDGE LIST FORMAT

> 1 2 

> 1 3 

> 1 4 

> 1 5

> 2 3 

> 2 4

> 3 2 

> 4 1

> 4 3

> 4  5

> 5 2

> 5 4

> 

> ITS NODE LIST FORMAT SHOULD BE LIKE:

> 1 2 3  4 5

> 2 3 4

> 3 2

> 4 1 3

> 5 2 4

> 

>   Kindly suggest me which package in R provides the support to do my task.

How long the list of egdes is? For not too large lists, consider also


  library(graph)

  G <- new("graphNEL", edgemode="directed")

  G <- addNode(as.character(1:5), G)

  edges <- read.table(file=stdin(), colClasses="character")

1 2

1 3

1 4

1 5

2 3

2 4

3 2

4 1

4 3

4 5

5 2

5 4


  G <- addEdge(from=edges[, 1], to=edges[, 2], G)

  edgeL(G)


  $`1`

  $`1`$edges

  [1] 2 3 4 5

  

  

  $`2`

  $`2`$edges

  [1] 3 4

  

  

  $`3`

  $`3`$edges

  [1] 2

  

  

  $`4`

  $`4`$edges

  [1] 1 3 5

  

  

  $`5`

  $`5`$edges

  [1] 2 4


Very large lists can be handled by unix/linux sort command (if not sorted

already) and by extracting the end-nodes of the edges starting in each node.

In a sorted file, they form blocks of consecutive lines, so a simple text

processing with perl is sufficient.


Petr Savicky.


__

[hidden email] mailing list

https://stat.ethz.ch/mailman/listinfo/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 message @ 
http://r.789695.n4.nabble.com/help-requested-tp3082147p3082496.html


To unsubscribe from help requested, click here.
  
-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-requested-tp3082147p3083278.html
Sent from the R help mailing list archive at Nabble.com.

[[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] Specifying Prior Weights in a GLM

2010-12-11 Thread Enrique Garcia

Hello R folks,

I have three questions. I am trying to run a logistic regression (binomial
family) where the response variable is a proportion.  According to R
Documentation in "a binomial GLM prior weights are used to give the number
of trials when the response is the proportion of successes."  However when I
run my code I get the following error message:

Error in model.frame.default(formula = PER_ELA ~ A_EX + COMM + ENG + S_R + 
: 
  variable lengths differ (found for '(weights)')

I'm not sure what I am doing wrong.  My response variable is Y/M, which is
the proportion of 1's (successes) among M binary responses.  My prior weight
is a variable indicating the number of trials for each observation.  


This is an abbreviated version of the code that I ran: 

glm1<-glm(PER_ELA~A_EX  PER_LEA,
family=binomial(link="logit"),data=data2,weights="REG")


Question 1 and 2:
Does the number of trials for each observation in my dataset have to be the
same? What am I doing wrong here?


Question 3:
Is it OK for me to use percentages as predictor variables in a logistic
regression? 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Specifying-Prior-Weights-in-a-GLM-tp3083480p3083480.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] using Statistics::R

2010-12-11 Thread Yi-Fang Liu
Hi,ALL

I want to use R in Perl, the Statistics::R module is great but I meet the 
problem: I don`g know how to pass one array from Perl to R, can anyone show me?
Any suggestion will be appreciate~

Thank you!


  
[[alternative HTML version deleted]]

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


Re: [R] break

2010-12-11 Thread Jim Holtman

It is 'break', not 'break(I)'

Sent from my iPhone

What is the problem you are trying to solve?

On Dec 11, 2010, at 12:17, Serdar Akin  wrote:


Hi

I'm trying to utilize the break command for breaking the loop when the
p-value is less than 10 per cent using the urca package. But it does  
not

break the loop, anyone that can help me?

library(urca)
set.seed(1)
a1 <- runif(100)
lag.max <- function(object, n = 12){
   matris <- matrix(NA, nrow = n)
   for(i in 1:n) {
  matris[i] <- ur.df(object, lags = i,
 type = "trend")@testreg$coefficients[i+3,4]
  if (i <  0.1) {break(i)}
  }
  list(matris = round(matris, 3))
  }
a2 <- lag.max(a1)

/With regards
Serdar

   [[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] break

2010-12-11 Thread Jorge Ivan Velez
If I understand correctly, the following should do it:

lag.max2 <- function(object, n = 12){
matris <- matrix(NA, nrow = n)
for(i in 1:n){
matris[i] <- ur.df(object, lags = i, type =
"trend")@testreg$coefficients[i+3,4]
   if(matris[i]<0.1) break
}
# output
 c('lag' = i, 'p' = matris[i])
   }
a2 <- lag.max2(a1)
a2
#   lag  p
# 1. 0.09613726

HTH,
Jorge


On Sat, Dec 11, 2010 at 3:17 PM, Serdar Akin <> wrote:

> Hi
>
> I'm trying to utilize the break command for breaking the loop when the
> p-value is less than 10 per cent using the urca package. But it does not
> break the loop, anyone that can help me?
>
> library(urca)
> set.seed(1)
> a1 <- runif(100)
> lag.max <- function(object, n = 12){
>matris <- matrix(NA, nrow = n)
>for(i in 1:n) {
>   matris[i] <- ur.df(object, lags = i,
>  type = "trend")@testreg$coefficients[i+3,4]
>   if (i <  0.1) {break(i)}
>   }
>   list(matris = round(matris, 3))
>   }
> a2 <- lag.max(a1)
>
> /With regards
> Serdar
>
>[[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] break

2010-12-11 Thread Ted Harding
And not only that! According to the code, the only place that i is
set is in the loop for(i in 1:n){...}, and the test for 'break' is
  if (i <  0.1) {break(i)}
Therefore the condition will never be satisfied.

Possibly Serdar meant

  if(matris[i] < 0.1) {break}

or something similar.
Ted.

On 11-Dec-10 21:24:47, Jim Holtman wrote:
> It is 'break', not 'break(I)'
> 
> Sent from my iPhone
> 
> What is the problem you are trying to solve?
> 
> On Dec 11, 2010, at 12:17, Serdar Akin  wrote:
> 
>> Hi
>>
>> I'm trying to utilize the break command for breaking the loop when the
>> p-value is less than 10 per cent using the urca package. But it does  
>> not
>> break the loop, anyone that can help me?
>>
>> library(urca)
>> set.seed(1)
>> a1 <- runif(100)
>> lag.max <- function(object, n = 12){
>>matris <- matrix(NA, nrow = n)
>>for(i in 1:n) {
>>   matris[i] <- ur.df(object, lags = i,
>>  type = "trend")@testreg$coefficients[i+3,4]
>>   if (i <  0.1) {break(i)}
>>   }
>>   list(matris = round(matris, 3))
>>   }
>> a2 <- lag.max(a1)
>>
>> /With regards
>> Serdar
>>
>>[[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.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 11-Dec-10   Time: 21:45:35
-- XFMail --

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

2010-12-11 Thread Craig O'Connell
Dear R-users,

   I am currently modifying a previously developed predator prey model and
was curious if there was a way to add in a disturbance to the model (let's
say at time t=100).  The disturbance can be the introduction of 40 prey
(N=40) and 10 predators (Pred = 10).  I would like to see my model go from a
state of equilibrium (up to t = 99), show this disturbance (at t = 100) and
then slowly work its way back to equilibrium.  Does anybody know if this
could be done?


LVmod0D <- function(Time, State, Pars) {

with(as.list(c(State, Pars)), {

IngestPred <- rI * N * Pred

GrowthN <- rG * N * (1 - N/K)

MortPred <- rM * Pred



dN <- GrowthN - IngestPred

dPred <- IngestPred * AE - MortPred



return(list(c(dN, dPred)))

})

}



pars <- c(rI = 0.1, rG = 0.9, rM = 0.8, AE = 0.9, K = 20)

yini <- c(N = 20, Pred = 20)

times <- seq(0, 200, by = 1)

y(time=100)<-c(N=10, Pred=5)

print(system.time)

zout <- as.data.frame(lsoda(yini, y(time=100), times, LVmod0D, pars))

plot(zout[,1],zout[,2], type="l",col="black", ylim=range(0,25),
xlab="time",ylab="population")

points(zout[,1],zout[,3],type="l",col="red")

title(main="prey (black) predator (red)")



Thanks much for your help!

[[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] remove quotes from the paste output

2010-12-11 Thread Joshua Wiley
Hi Bob,

You can use the get() function to loopup a variable name.

> long.variable.name <- 5
> "long.variable.name"
[1] "long.variable.name"
> get("long.variable.name")
[1] 5

However, I think this is all overkill.  Assuming
extractModelParameters() came from the MplusAutomation package, and
that the documentation is correct, then it returns a list, ordered in
some predictable way.  Take advantage of this.  I suspect you can get
all your code down to something like:

lapply(modelResults, `[`, 31)

I do not have any Mplus outfiles to toy around with so that code
probably will not be it exactly, but the point is, I think you are
going to a lot of trouble to create these variable names, and there is
probably a much easier way.  If you can upload an Mplus file online
and email the link, I can probably give you more specific advice.

Cheers,

Josh


On Sat, Dec 11, 2010 at 12:43 PM, vaibhav dua  wrote:
> Hi,
>
> I'm generating the name of the variable with paste function and then using 
> that
> variable name further to get the specific position value from the data.frame,
> here is the snippet from my code:
>
> modelResults <- extractModelParameters("C:/PilotStudy/Mplus_Input/Test",
> recursive=TRUE)
>
> #extractModelParameters reads all the output files from the Test folder and
> create the following variables in R for each file read:
> #C..PilotStudy.Mplus_Input.Test.rep1.out.unstandardized.est
> #C..PilotStudy.Mplus_Input.Test.rep2.out.unstandardized.est
> #C..PilotStudy.Mplus_Input.Test.rep3.out.unstandardized.est
>
> modelResultsTemp <- as.data.frame(modelResults)
>
> MeansTempC1 = rep(NA ,9)
> counter = 1
>
> for (f in 1:3)
> {
> i=31
>
> for (g in 1:3)
> {
> OutputFileName <-
> paste("modelResultsTemp$C..PilotStudy.Mplus_Input.Test.rep",f,".out.unstandardized.est[",i,"]",sep="")
>
> MeansTempC1[counter] = OutputFileName
> i=i+1
> counter = counter+1
> }
> }
>
> Its not giving me any error but I'm not getting the desired output in
> MeansTempC1 because OutputFileName is a string and thats why its not returning
> the OutputFileName[31] etc. Does anybody know how to eliminate the double 
> quotes
> so that I can use the variable name (generated with the paste function) 
> further
> in the code
>
> Regards
> Bob
>
>
>
>
>        [[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.

-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] help requested

2010-12-11 Thread jim holtman
try this:

> x
   X1 X2
1   1  3
2   1  4
3   1  5
4   2  3
5   2  4
6   3  2
7   4  1
8   4  3
9   4  5
10  5  2
11  5  4
> sapply(split(x, x$X1), function(.grp){
+ paste(.grp[[1]][1], paste(.grp[[2]], collapse = ','))
+ })
1 2 3 4 5
"1 3,4,5"   "2 3,4" "3 2" "4 1,3,5"   "5 2,4"
>


On Fri, Dec 10, 2010 at 11:20 AM, Jinyan Huang  wrote:
> awk '{arr[$1]=arr[$1] " " $2}END{for( i in arr){print i,arr[i]}}'
> edgelist.txt | sort -k1
>
>
>
> On Fri, Dec 10, 2010 at 4:20 PM, profaar  wrote:
>> 1 2
>> 1 3
>> 1 4
>> 1 5
>> 2 3
>> 2 4
>> 3 2
>> 4 1
>> 4 3
>> 4  5
>> 5 2
>> 5 4
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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
Data Munger Guru

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] Why do we have to turn factors into characters for various functions?

2010-12-11 Thread Tal Galili
Hello dear R-help mailing list,

My question is *not* about how factors are implemented in R (which is, if I
understand correctly, that factors keeps numbers and assign levels to them).
My question *is* about why so many functions that work on factors don't
treat them as characters by default?

Here are two simple examples:
Example one turning the characters inside a factor into numeric:

x <- factor(4:6)
as.numeric(x) # output: 1 2 3
as.numeric(as.character(x)) # output: 4 5 6  # isn't this what we wanted?


Example two, using strsplit on a factor:

x <- factor(paste(letters[4:6], 4:6, sep="A"))
strsplit(x, "A") # will result in an error:  # Error in strsplit(x, "A") :
non-character argument
strsplit(as.character(x), "A") # will work and split


So what is the reason this is the case?
Is it that implementing a switch of factors to characters as the default in
some of the basic function will cause old code to break?
Is it a better design in some other way?

I am curious to know the reason for this.

Thank you for your reading,
Tal

Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[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] Why do we have to turn factors into characters for various functions?

2010-12-11 Thread Joshua Wiley
Hi Tal,

I always think of factors as a way of imposing (however arbitrarily)
order on some variable.  To that extent, the key aspect is first,
second, third, etc., represented numerically in factors as 1, 2, 3,
etc. .  The labels are for convenience and interpretation.  Consider:

x <- factor(c(5, 4, 6))
y <- factor(c(6, 5, 7))
as.numeric(x)
as.numeric(y)

Is there numeric or character value of 5 more important?  Or is its
relative position?

If you have character data that you might want to split and
manipulate, store it as a string variable (you can set an option so
stringsAsFactors = FALSE by default in read.table()).  If your factor
labels are numeric, that suggests it might have been better stored as
numeric in the first place.  Generally, when I find myself converting
factors to numeric or character class data, it means I've been using
factor() to recode data (which is not its intended purpose).

My 2 cents.

Cheers,

Josh

On Sat, Dec 11, 2010 at 2:48 PM, Tal Galili  wrote:
> Hello dear R-help mailing list,
>
> My question is *not* about how factors are implemented in R (which is, if I
> understand correctly, that factors keeps numbers and assign levels to them).
> My question *is* about why so many functions that work on factors don't
> treat them as characters by default?
>
> Here are two simple examples:
> Example one turning the characters inside a factor into numeric:
>
> x <- factor(4:6)
> as.numeric(x) # output: 1 2 3
> as.numeric(as.character(x)) # output: 4 5 6  # isn't this what we wanted?
>
>
> Example two, using strsplit on a factor:
>
> x <- factor(paste(letters[4:6], 4:6, sep="A"))
> strsplit(x, "A") # will result in an error:  # Error in strsplit(x, "A") :
> non-character argument
> strsplit(as.character(x), "A") # will work and split
>
>
> So what is the reason this is the case?
> Is it that implementing a switch of factors to characters as the default in
> some of the basic function will cause old code to break?
> Is it a better design in some other way?
>
> I am curious to know the reason for this.
>
> Thank you for your reading,
> Tal
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
> --
>
>        [[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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] (S|odf)weave : how to intersperse (\LaTeX{}|odf) comments in source code ? Delayed R evaluation ?

2010-12-11 Thread Emmanuel Charpentier
Dear list,

Inspired by the original Knuth tools, and for paedaogical reasons, I wish 
to produce a document presenting some source code with interspersed 
comments in the source (see Knuth's books rendering TeX and metafont 
sources to see what I mean).

I seemed to remember that a code chunk could be defined piecewise, like in

Comments...

<>=
SomeCode
@

Some other comments...

<>=
MoreCode
@

And finally,

<>=
<>
<>
EndOfTheCode
@

That works ... as long as SomeCode, MoreCode and EndOfTheCode are self-
standing pieces of R code, but *not* code fragments. You can *not* 
intersperse comments in, say, a function body, or  local() environment 
this way : when Sweaving, *R* complains of an incomplete source (makes 
noise about an unexpected end of input at the end of Chunk1, IIRC, and 
never sees Chunk2).

I hoped that Sweave's "alternative" syntax could offer a way out : no 
such luck.

There seems to be no way to delay R evaluation of a R chunk passed by 
Sweave ; at least, the "eval=FALSE" option of chunk declaration is not 
sufficient for that.

Am I missing something in the Sweave nd odfWeve documentations (that I 
read till I grew green and moldy) ? Or does this require a fundamental 
change in the relevant Sweave drivers ?

Can you suggest alternative ways of doing what I mean to do ? The only 
workaround I found is to paste a second copy of my code in a \verbatim 
environment (or, in the case of odfWeave, in the "text" part), and spice 
it with \end{verbatim} comments.. \begin{verbatim} chunks. This way, I 
lose any guarantee of consistency between commented text and effective 
code.

Any other idea ?

Emmanuel Charpentier

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] overlap different line in a xyplot (lattice)

2010-12-11 Thread Felix Andrews
On 12 December 2010 00:08, Peter Ehlers  wrote:
> On 2010-12-11 03:12, Francesco Nutini wrote:
>>
>> mmmh, yes this method works...
>> but I have to overlap this two graphs:
>>
>>>  xyplot(a ~b |sites, data=dataset, col="red")
>>
>>>  xyplot(c ~b |sites, data=dataset, col="blue")
>>
>>
>> a, b and c are columns in the same dataset. "Sites" is also a column in
>> the dataset, but it's a factorial variables.
>> How can I use your method?
>
> The idea is the same: you need to get your data
> into "long" format with a grouping variable and
> then use the 'groups' argument to xyplot.
> Here's fake data frame (you should have provided one):
>
>  DF <- data.frame(y1 = rnorm(30),
>                  y2 = rnorm(30) + 2,
>                  x  = rep(1:10, 3),
>               sites = gl(3, 10, lab=LETTERS[1:3]))
>
> ## Use the reshape2 package to melt the data:
> ## (or use reshape() in base R)
>  require(reshape2)
>  DF1 <- melt(DF, measure.vars = c('y1', 'y2'),
>             variable.name = 'grp', value.name = 'y')
>
> ## and plot:
>  require(lattice)
>  p <- xyplot( y ~ x | sites, data = DF1, groups = grp,
>             col = c("red", "blue"), type = "b")
>  print(p)
>
> Peter Ehlers


By the way, in this particular case there is a shortcut which does the
reshaping internally:

xyplot(y1 + y2 ~ x | sites, DF, type = "b")



>
>> sorry for my ignorance!
>>
>> Francesco Nutini
>>
>>  > Date: Fri, 10 Dec 2010 10:13:00 -0800
>>  > From: ehl...@ucalgary.ca
>>  > To: nutini.france...@gmail.com
>>  > CC: r-help@r-project.org
>>  > Subject: Re: [R] [r] overlap different line in a xyplot (lattice)
>>  >
>>  > On 2010-12-10 07:04, Francesco Nutini wrote:
>>  > >
>>  > > dear [R] users,
>>  > > is there a way to plot different data (but with the same
>> x-variables) in the same xyplot window?
>>  > > There are already a similar question, but the answer is not enought
>> explanatory...
>>  >
>>  > Something like this?
>>  >
>>  > x <- rep(1:10, 2)
>>  > y1 <- rnorm(10); y2 <- rnorm(10) + 2
>>  > y <- c(y1, y2)
>>  > g <- gl(2, 10)
>>  > xyplot( y ~ x, groups = g, type = 'b')
>>  >
>>  > Peter Ehlers
>>  >
>>  > >
>>  > >
>>  > > Thanks a lot,
>>  > > Francesco
>>  > >
>>  >
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Felix Andrews / 安福立
http://www.neurofractal.org/felix/

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


Re: [R] overlap different line in a xyplot (lattice)

2010-12-11 Thread Peter Ehlers

On 2010-12-11 16:47, Felix Andrews wrote:

On 12 December 2010 00:08, Peter Ehlers  wrote:


[...snip...]


The idea is the same: you need to get your data
into "long" format with a grouping variable and
then use the 'groups' argument to xyplot.
Here's fake data frame (you should have provided one):

  DF<- data.frame(y1 = rnorm(30),
  y2 = rnorm(30) + 2,
  x  = rep(1:10, 3),
   sites = gl(3, 10, lab=LETTERS[1:3]))

## Use the reshape2 package to melt the data:
## (or use reshape() in base R)
  require(reshape2)
  DF1<- melt(DF, measure.vars = c('y1', 'y2'),
 variable.name = 'grp', value.name = 'y')

## and plot:
  require(lattice)
  p<- xyplot( y ~ x | sites, data = DF1, groups = grp,
 col = c("red", "blue"), type = "b")
  print(p)

Peter Ehlers



By the way, in this particular case there is a shortcut which does the
reshaping internally:

xyplot(y1 + y2 ~ x | sites, DF, type = "b")


Right; thanks for the reminder, Felix. I keep forgetting
about that mainly because I almost always need 'long' data.

Peter Ehlers

[...snip...]

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

2010-12-11 Thread Ben Bolker
Craig O'Connell  gmail.com> writes:

>I am currently modifying a previously developed predator prey model and
> was curious if there was a way to add in a disturbance to the model (let's
> say at time t=100).  The disturbance can be the introduction of 40 prey
> (N=40) and 10 predators (Pred = 10).  I would like to see my model go from a
> state of equilibrium (up to t = 99), show this disturbance (at t = 100) and
> then slowly work its way back to equilibrium.  Does anybody know if this
> could be done?

library(deSolve)
?events

lsoda(...,
  events=list(data=data.frame(var=c("N","Pred"),time=rep(100,2),
  value=c(40,10),method=rep("add",2

or something like that ...

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] randomForest: help with combine() function

2010-12-11 Thread Liaw, Andy
combine() is meant to be used on randomForest objects that were built
from identical training data.

Andy

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Dennis Duro
> Sent: Friday, December 10, 2010 11:59 PM
> To: r-help@r-project.org
> Subject: [R] randomForest: help with combine() function
> 
> I've built two RF objects (RF1 and RF2) and have tried to combine
> them, but I get the following error:
> 
> Error in rf$votes + ifelse(is.na(rflist[[i]]$votes), 0, 
> rflist[[i]]$votes) :
>   non-conformable arrays
> In addition: Warning message:
> In rf$oob.times + rflist[[i]]$oob.times :
>   longer object length is not a multiple of shorter object length
> 
> 
> Both RF models use the same variables, although the NAs in both models
> likely differ (using na.roughfix in both models). I assume this is
> part of the reason that my arrays are "non-conformable". If so, does
> anyone have any suggestions on how to combine in such a situation? How
> similar do RFs have to be in order to combine?
> 
> Cheers
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
Notice:  This e-mail message, together with any attachme...{{dropped:11}}

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


Re: [R] remove quotes from the paste output

2010-12-11 Thread Mark Difford

Bob,

>> Does anybody know how to eliminate the double quotes so that I can use
>> the 
>> variable name (generated with the paste function) further in the code...

?noquote should do it.

##
> "varName"
[1] "varName"
> noquote("varName")
[1] varName

Regards, Mark.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/remove-quotes-from-the-paste-output-tp3083692p3084037.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] Specifying Prior Weights in a GLM

2010-12-11 Thread Dennis Murphy
Hi:

Here's a simple example of its use using the data from Montgomery, Myers and
Vining (2002), problem 4.7:

ex4.7 <- structure(list(pressure = c(2500L, 2700L, 2900L, 3100L, 3300L,
3500L, 3700L, 3900L, 4100L, 4300L), nfast = c(50L, 70L, 100L,
60L, 40L, 85L, 90L, 50L, 80L, 65L), nfailures = c(10L, 17L, 30L,
21L, 18L, 43L, 54L, 33L, 60L, 51L)), .Names = c("pressure", "nfast",
"nfailures"), row.names = c("1", "2", "3", "4", "5", "6", "7",
"8", "9", "10"), class = "data.frame")

# nfast is the sample size per covariate class, nfailures and pressure
# the response and covariate, respectively.

# Notice that the weights variable is the denominator of the response
m <- glm(nfailures/nfast ~ pressure, data = ex4.7, weights = nfast)

ex4.7a <- cbind(ex4.7, pred = predict(m, type = 'response'))

# Check that the observed proportions and the predicted probabilities are
reasonably in sync

library(ggplot2)
ggplot(ex4.7a, aes(x = pressure, y = nfailures/nfast)) +
geom_point(size = 2.5) + geom_line(aes(y = pred), size = 1, color =
'red')

# or in base graphics,
plot(nfailures/nfast ~ pressure, data = ex4.7a, pch = 16)
with(ex4.7a, lines(pressure, pred, col = 'red', lwd = 1.2))

HTH,
Dennis

On Sat, Dec 11, 2010 at 8:59 AM, Enrique Garcia  wrote:

>
> Hello R folks,
>
> I have three questions. I am trying to run a logistic regression (binomial
> family) where the response variable is a proportion.  According to R
> Documentation in "a binomial GLM prior weights are used to give the number
> of trials when the response is the proportion of successes."  However when
> I
> run my code I get the following error message:
>
> Error in model.frame.default(formula = PER_ELA ~ A_EX + COMM + ENG + S_R +
> :
>  variable lengths differ (found for '(weights)')
>
> I'm not sure what I am doing wrong.  My response variable is Y/M, which is
> the proportion of 1's (successes) among M binary responses.  My prior
> weight
> is a variable indicating the number of trials for each observation.
>
>
> This is an abbreviated version of the code that I ran:
>
> glm1<-glm(PER_ELA~A_EX  PER_LEA,
> family=binomial(link="logit"),data=data2,weights="REG")
>
>
> Question 1 and 2:
> Does the number of trials for each observation in my dataset have to be the
> same? What am I doing wrong here?
>
>
> Question 3:
> Is it OK for me to use percentages as predictor variables in a logistic
> regression?
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Specifying-Prior-Weights-in-a-GLM-tp3083480p3083480.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.
>

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