Re: [R] Exporting to text files

2018-05-19 Thread John
On Fri, 18 May 2018 11:47:25 -0500
Ed Siefker  wrote:

> I have dose response data analyzed with the package 'drc'.
> 'summary(mymodel)' prints my kinetic parameters.  I want
> that text in an ASCII text file.  I want to get exactly what I
> would get if I copied and pasted from the terminal window.
> 
> I've read the documentation on data export to text files here:
> https://cran.r-project.org/doc/manuals/r-release/R-data.html#Export-to-text-files
> 
> write() does not work.
> 
The sink() or capture.output() commands do what you want.  The latter is
less cumbersome if you are working directly with R in a terminal rather
than with a script.  You could also employ the knitr and rmarkdown
packages with RStudio if you plan to include the material in a Word or
Libreoffice document.

JWDougherty

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


Re: [R] How to predict time series high-frequency data?

2018-05-19 Thread Jeff Newmiller
Your description does not indicate that you know what theory you want to apply 
to this data, and this mailing list is the wrong place to discuss which theory 
you want to apply.

However, this sounds perfectly suitable to many time series or data frame based 
analytical methods. You may need to refer to a textbook to gain the appropriate 
background. Then look at the Time Series View on CRAN, and perhaps start with 
the zoo package. Once you have a better understanding of what you want to 
accomplish, post again with a more specific question about using R to do the 
work, preferably with a small reproducible example (input data and some attempt 
to work with it and desired outcome).

On May 19, 2018 10:49:51 AM PDT, Rama shankar  wrote:
>Hi All,
>I am having very high-frequency data, captured  between 3 to 7 seconds
>by
>sensor for tank. Number of rows of data point are 7 million and its
>multivariate  problem.
>
>Due to high frequency data, time series is unable to capture frequency
>&
>Cycle of data.
>
>Please help me, how to approach and which kinds of algorithm required
>to
>solve this problem using R.
>
>Thanks,
>Rama Shankar
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

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


[R] How to predict time series high-frequency data?

2018-05-19 Thread Rama shankar
Hi All,
I am having very high-frequency data, captured  between 3 to 7 seconds by
sensor for tank. Number of rows of data point are 7 million and its
multivariate  problem.

Due to high frequency data, time series is unable to capture frequency &
Cycle of data.

Please help me, how to approach and which kinds of algorithm required to
solve this problem using R.

Thanks,
Rama Shankar

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Lower bound and upper bound in maximum likelihood

2018-05-19 Thread Siow Yun Tan
Dear all,

I need to simulate data which fit to a double poisson time series model
with certain parameters. Then, check whether the estimated parameter close
to the true parameter by using maximum likelihood estimation.

Simulation:
set.seed(10)
library("rmutil")
a0 = 1.5; a1 = 0.4; b1 = 0.3; g1= 0.7  ; n=100
#a0, a1 and b1 are parameter where n is size.
nu = h = rep(0, n)
h[1] = a0/(1-a1-b1)
nu[1] = rdoublepois(1,h[1],g1)
for (i in 2:n) {
  h[i] = a0 + a1 * nu[i-1] + b1 * h[i-1]
  nu[i] = rdoublepois(1,h[i],g1)
}

Maximum likelihood by double poisson density function from rmutil:

  logl3 <- function(par) {
  h.new <- vector()
  a0 <- par[1]
  a1 <- par[2]
  b1 <- par[3]
  g1 <- par[4]

  for (i in 2:n) {
h.new[i] = a0 + a1 * nu[i-1] + b1 * h.new[i-1]
  }

 -sum(ddoublepois(nu, m=h.new[2:n], s=g1,log=TRUE))
}
nlminb(start = c(0.01,0.01,0.01,0.01), lower = 1e-3, upper = Inf,
logl3)$par

But there is error.

 >Error in if (any(m <= 0)) stop("m must be positive") :
 >missing value where TRUE/FALSE needed

So I further check the maximum likelihood stop at which iteration:

logl <- function(par,debug=FALSE) {
  h.new <- vector()
  a0 <- par[1]
  a1 <- par[2]
  b1 <- par[3]
  g1 <- par[4]
  h.new[1] <- a0/(1-a1-b1)

  for (i in 2:n) {
h.new[i] <- a0 + a1 * nu[i-1] + b1 * h.new[i-1]
  }
  if(debug) cat(a0,a1,b1,g1,"")
  r <- -sum(ddoublepois(nu, m=h.new[1:n], s=g1,log=TRUE))
  if(debug) cat(r,"\n")
  return(r)
}
nlminb(start = c(0.1,0.1,0.1,0.1), lower = -Inf,
   upper = Inf, logl,debug=TRUE)

The results:
>0.1 0.1 0.1 0.1 1517.164
>0.1 0.1 0.1 0.1 1517.164
>0.1 0.1 0.1 0.1 1517.164
>0.1 0.1 0.1 0.1 1517.164
>0.1 0.1 0.1 0.1 1517.164
>0.218201 0.6245722 0.1792584 -0.739387

>Error in ddoublepois(nu, m = h.new[1:n], s = g1, log = TRUE) :
>s must be positive

I am guessing that there is problem at the part of initial value, lower
bound and upper bound of my optimization function.
Please give me some guides.
Thanks in advance.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Split a data.frame

2018-05-19 Thread K. Elo
Hi!

How about this:

--- snip --

for (i in 1:(length(split_str)-1)) {
assign(paste("DF",i,sep=""),DF[
c((which(DF$name==split_str[i])+1):(which(DF$name==split_str[i+1])-1)), 
])
}

--- snip ---

'assign' creates for each subset a new data.frame DFn, where n ist a
count (1,2,...).

But note: if your DF has duplicates in 'name' (e.g. two rows with 'a'
in 'DF$name'), my solution will use the first occurrence only (and this
for both start and for end).

HTH,
Kimmo

2018-05-19 kello 16:37 +0530, Christofer Bogaso wrote:
> Hi,
> 
> I am struggling to split a data.frame as will below scheme :
> 
> DF = data.frame(name = c('a', 'v', 'c'), val = 0); DF
> 
> split_str = c('a', 'c')
> 
> Now, for each element in split_str, R should find which row of DF
> contains
> that element, and return DF with all rows starting from next row of
> the
> corresponding element and ending with the preceding value of the next
> element.
> 
> So in my case, I should see 2 data.frames
> 
> 1st data-frame with name = 'v' (i.e. 2nd row of DF)
> 
> 2nd data.frame with number_of_rows as 0 (as there is no row left
> after 'c')
> 
> Similarly if split_str = c('v'') then, my 2 data.frames will be
> 
> 1st data.frame with name = 'a'
> 2nd data.frame with name = 'c'
> 
> Any idea how to efficiently implement above scheme would be highly
> appreciated. I tried with split() function, however, it is not giving
> the
> right answer.
> 
> Thanks,
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-gui
> de.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Split a data.frame

2018-05-19 Thread jim holtman
Forgot to take care of the boundary conditions:

# revised data.frame to take care of boundary conditions
DF = data.frame(name = c('b', 'a','v','z', 'c','d'), val = 0); DF
##   name val
## 1b   0
## 2a   0
## 3v   0
## 4z   0
## 5c   0
## 6d   0
split_str = c('a', 'c')

# If we assume that the values in split_str are ordered in
# the same order as in the dataframe, then this might work.
offsets <- match(split_str, DF$name)

# now find the values inbetween the offsets
ret_indx <- NULL
for (i in seq_len(length(offsets) - 1)){
  if (offsets[i + 1] - offsets[i] > 1){  # something inbetween
ret_indx <- c(ret_indx, (offsets[i] + 1):(offsets[i+1] - 1))
  }
}
DF[ret_indx, ]
##   name val
## 3v   0
## 4z   0



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Sat, May 19, 2018 at 4:07 AM, Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:

> Hi,
>
> I am struggling to split a data.frame as will below scheme :
>
> DF = data.frame(name = c('a', 'v', 'c'), val = 0); DF
>
> split_str = c('a', 'c')
>
> Now, for each element in split_str, R should find which row of DF contains
> that element, and return DF with all rows starting from next row of the
> corresponding element and ending with the preceding value of the next
> element.
>
> So in my case, I should see 2 data.frames
>
> 1st data-frame with name = 'v' (i.e. 2nd row of DF)
>
> 2nd data.frame with number_of_rows as 0 (as there is no row left after 'c')
>
> Similarly if split_str = c('v'') then, my 2 data.frames will be
>
> 1st data.frame with name = 'a'
> 2nd data.frame with name = 'c'
>
> Any idea how to efficiently implement above scheme would be highly
> appreciated. I tried with split() function, however, it is not giving the
> right answer.
>
> Thanks,
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Split a data.frame

2018-05-19 Thread Bert Gunter
...
yes, but note that:

which(data[[col]] %in% s

can be replaced directly by match:

match(data[[col]], s)

Corner cases (nothing matches, etc.) would also have to be checked and
probably should sort the matched row numbers for safety.

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sat, May 19, 2018 at 7:58 AM, Rui Barradas  wrote:

> Hello,
>
> Maybe something like the following.
>
> splitDF <- function(data, col, s){
> n <- nrow(data)
> inx <- which(data[[col]] %in% s)
> lapply(seq_along(inx), function(i){
> k <- if(inx[i] < n) (inx[i] + 1):(inx[i + 1])
> data[k, ]
> })
> }
>
> splitDF(DF, "name", split_str)
>
>
> Hope this helps,
>
> Rui Barradas
>
>
> On 5/19/2018 12:07 PM, Christofer Bogaso wrote:
>
>> Hi,
>>
>> I am struggling to split a data.frame as will below scheme :
>>
>> DF = data.frame(name = c('a', 'v', 'c'), val = 0); DF
>>
>> split_str = c('a', 'c')
>>
>> Now, for each element in split_str, R should find which row of DF contains
>> that element, and return DF with all rows starting from next row of the
>> corresponding element and ending with the preceding value of the next
>> element.
>>
>> So in my case, I should see 2 data.frames
>>
>> 1st data-frame with name = 'v' (i.e. 2nd row of DF)
>>
>> 2nd data.frame with number_of_rows as 0 (as there is no row left after
>> 'c')
>>
>> Similarly if split_str = c('v'') then, my 2 data.frames will be
>>
>> 1st data.frame with name = 'a'
>> 2nd data.frame with name = 'c'
>>
>> Any idea how to efficiently implement above scheme would be highly
>> appreciated. I tried with split() function, however, it is not giving the
>> right answer.
>>
>> Thanks,
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Split a data.frame

2018-05-19 Thread jim holtman
DF = data.frame(name = c('a', 'v', 'c'), val = 0); DF
##   name val
## 1a   0
## 2v   0
## 3c   0
split_str = c('a', 'c')
# If we assume that the values in split_str are ordered in the same order
as in the dataframe, then this might work.

offsets <- match(split_str, DF$name)
# Since you only want the rows in between

DF[diff(offsets), ]
##   name val
## 2v   0


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Sat, May 19, 2018 at 7:58 AM, Rui Barradas  wrote:

> Hello,
>
> Maybe something like the following.
>
> splitDF <- function(data, col, s){
> n <- nrow(data)
> inx <- which(data[[col]] %in% s)
> lapply(seq_along(inx), function(i){
> k <- if(inx[i] < n) (inx[i] + 1):(inx[i + 1])
> data[k, ]
> })
> }
>
> splitDF(DF, "name", split_str)
>
>
> Hope this helps,
>
> Rui Barradas
>
>
> On 5/19/2018 12:07 PM, Christofer Bogaso wrote:
>
>> Hi,
>>
>> I am struggling to split a data.frame as will below scheme :
>>
>> DF = data.frame(name = c('a', 'v', 'c'), val = 0); DF
>>
>> split_str = c('a', 'c')
>>
>> Now, for each element in split_str, R should find which row of DF contains
>> that element, and return DF with all rows starting from next row of the
>> corresponding element and ending with the preceding value of the next
>> element.
>>
>> So in my case, I should see 2 data.frames
>>
>> 1st data-frame with name = 'v' (i.e. 2nd row of DF)
>>
>> 2nd data.frame with number_of_rows as 0 (as there is no row left after
>> 'c')
>>
>> Similarly if split_str = c('v'') then, my 2 data.frames will be
>>
>> 1st data.frame with name = 'a'
>> 2nd data.frame with name = 'c'
>>
>> Any idea how to efficiently implement above scheme would be highly
>> appreciated. I tried with split() function, however, it is not giving the
>> right answer.
>>
>> Thanks,
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Split a data.frame

2018-05-19 Thread Rui Barradas

Hello,

Maybe something like the following.

splitDF <- function(data, col, s){
n <- nrow(data)
inx <- which(data[[col]] %in% s)
lapply(seq_along(inx), function(i){
k <- if(inx[i] < n) (inx[i] + 1):(inx[i + 1])
data[k, ]
})
}

splitDF(DF, "name", split_str)


Hope this helps,

Rui Barradas

On 5/19/2018 12:07 PM, Christofer Bogaso wrote:

Hi,

I am struggling to split a data.frame as will below scheme :

DF = data.frame(name = c('a', 'v', 'c'), val = 0); DF

split_str = c('a', 'c')

Now, for each element in split_str, R should find which row of DF contains
that element, and return DF with all rows starting from next row of the
corresponding element and ending with the preceding value of the next
element.

So in my case, I should see 2 data.frames

1st data-frame with name = 'v' (i.e. 2nd row of DF)

2nd data.frame with number_of_rows as 0 (as there is no row left after 'c')

Similarly if split_str = c('v'') then, my 2 data.frames will be

1st data.frame with name = 'a'
2nd data.frame with name = 'c'

Any idea how to efficiently implement above scheme would be highly
appreciated. I tried with split() function, however, it is not giving the
right answer.

Thanks,

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Split a data.frame

2018-05-19 Thread Christofer Bogaso
Hi,

I am struggling to split a data.frame as will below scheme :

DF = data.frame(name = c('a', 'v', 'c'), val = 0); DF

split_str = c('a', 'c')

Now, for each element in split_str, R should find which row of DF contains
that element, and return DF with all rows starting from next row of the
corresponding element and ending with the preceding value of the next
element.

So in my case, I should see 2 data.frames

1st data-frame with name = 'v' (i.e. 2nd row of DF)

2nd data.frame with number_of_rows as 0 (as there is no row left after 'c')

Similarly if split_str = c('v'') then, my 2 data.frames will be

1st data.frame with name = 'a'
2nd data.frame with name = 'c'

Any idea how to efficiently implement above scheme would be highly
appreciated. I tried with split() function, however, it is not giving the
right answer.

Thanks,

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


Re: [R] How to average values from grid cells with coordinates

2018-05-19 Thread Jim Lemon
Hi lily,
You could also create "blackcells" as a dataframe (which is itself a
type of list). I used a list as I thought it would be a more general
solution if there were different numbers of values for different grid
cells. The use of 1 for the comparison was due to the grid increments
being 1. If you had larger or smaller grid increments, you would use
the grid increment size for the comparison. That guarantees that only
the four nearest "black" cells will be identified as within the "red"
cell.

Jim

On Sat, May 19, 2018 at 4:07 AM, lily li  wrote:
> Hi Jim,
>
> Thanks. Yes, the two assumptions are correct, and they reflect the datasets.
> I have an uncertainty about the code below. Why do you use
> abs(blackcells[[i]]$lat - redcell$lat) <1 rather than a different number
> than 1? Second, why to construct blackcells as a list, rather than a
> dataframe. Because in a dataframe, each row can represent one grid cell,
> while the three columns can represent the lati, lon, and pop. Thanks again
> for your help.
>
> for(i in 1:121) {
> if(abs(blackcells[[i]]$lat-redcell$lat) < 1 &&
> abs(blackcells[[i]]$lon-redcell$lon) < 1) {
> close4[closen]<-i
> closen<-closen+1
> }
> }
>
> On Wed, May 16, 2018 at 2:45 AM, Jim Lemon  wrote:
>>
>> Hi lily,
>> There are one or two assumptions to be made here. First is that the
>> latitude and longitude values of the "black" cells are equally spaced
>> as in your illustration. Second, that all latitude and longitude
>> values for the "red" cells fall at the corners of four "black" cells.
>>
>> You can get the four "black" cells by finding the lat/lon values that
>> are closest to the "red" lat/lon values. Here's a basic example:
>>
>> lat<-rep(28:38,11)
>> lon<-rep(98:108,each=11)
>> pop<-sample(80:200,121)
>> blackcells<-list()
>> for(i in 1:121) blackcells[[i]]<-list(lat=lat[i],lon=lon[i],pop=pop[i])
>> redcell<-list(lat=33.5,lon=100.5,pop=NA)
>> close4<-rep(NA,4)
>> closen<-1
>> for(i in 1:121) {
>>  if(abs(blackcells[[i]]$lat-redcell$lat) < 1 &&
>>   abs(blackcells[[i]]$lon-redcell$lon) < 1) {
>>   close4[closen]<-i
>>   closen<-closen+1
>>  }
>> }
>> cat(close4,"\n")
>> redcell$pop<-(blackcells[[close4[1]]]$pop +
>>  blackcells[[close4[2]]]$pop + blackcells[[close4[3]]]$pop +
>>  blackcells[[close4[4]]]$pop)/4
>> print(blackcells[[close4[1]]])
>> print(blackcells[[close4[2]]])
>> print(blackcells[[close4[3]]])
>> print(blackcells[[close4[4]]])
>> print(redcell)
>>
>> As you can see, this has picked out the four "black" cells closest to
>> the "red" cell's coordinates and calculated the mean.
>>
>> Jim
>>
>> On Wed, May 16, 2018 at 2:23 PM, lily li  wrote:
>> > Hi R users,
>> >
>> > I have a question about data processing. I have such a dataset, while
>> > each
>> > black grid cell has a few attributes and the corresponding attribute
>> > values. The latitude and longitude of the center of each grid cell are
>> > given also.
>> >
>> > Then I want to average the attribute values from four adjacent grid
>> > cells
>> > to get the average value for the center of each red grid cell. Thus,
>> > there
>> > are the same number of attributes, but different values. The red grid
>> > cells
>> > do not overlap. I was thinking to write such a script that can ID each
>> > black grid cell, for example, 1, 2, 3, 4, ..., then the corresponding
>> > four
>> > grid cells will be used to average for the red grid cell. But I just
>> > have
>> > the latitude and longitude, attribute values for the black cells, and
>> > also
>> > latitude and longitude for the red cells, how to write such a script in
>> > R.
>> > Could anyone give me suggestion about the work flow? Thanks very much.
>> >
>> > I attached the picture of the grid cells here.
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.