[R] Faster matrix operation?

2010-06-01 Thread Remko Duursma
Dear R-helpers,

I have a three-column matrix with lots of rows:

xyzs - matrix(rnorm(3*10,0,1),ncol=3)

# And I am multiplying it with some vector V, and summing the rows
(columns after t()) in this way:
V - c(2,3,4)
system.time(vx - apply(t(xyzs) * V, 2 ,sum))


Ok, this does not take long (0.9 sec on my machine), but I have to do
this lots of times, with frequently larger matrices.

Is there a way to significantly speed this up, apart from writing it
in Fortran or C and calling it from within R (which is what I am
planning unless there is an alternative)?


thanks,
Remko



-
Remko Duursma
Research Lecturer

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

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

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

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

2010-06-01 Thread Bill.Venables
 xyzs - matrix(rnorm(3*10,0,1),ncol=3)
 
 V - c(2,3,4)
 system.time(vx - apply(t(xyzs) * V, 2 ,sum))
   user  system elapsed 
   1.060.021.08 
 
 system.time(wx - as.vector(xyzs %*% V))
   user  system elapsed 
  0   0   0 
 all.equal(vx, wx)
[1] TRUE
 
? 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Remko Duursma
Sent: Tuesday, 1 June 2010 4:04 PM
To: r-help@r-project.org
Subject: [R] Faster matrix operation?

Dear R-helpers,

I have a three-column matrix with lots of rows:

xyzs - matrix(rnorm(3*10,0,1),ncol=3)

# And I am multiplying it with some vector V, and summing the rows
(columns after t()) in this way:
V - c(2,3,4)
system.time(vx - apply(t(xyzs) * V, 2 ,sum))


Ok, this does not take long (0.9 sec on my machine), but I have to do
this lots of times, with frequently larger matrices.

Is there a way to significantly speed this up, apart from writing it
in Fortran or C and calling it from within R (which is what I am
planning unless there is an alternative)?


thanks,
Remko



-
Remko Duursma
Research Lecturer

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

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
Dear group,

Here is the kind of data.frame I obtain every day with my function :

futures -
structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10, 
CORN Jul/10, CORN Jul/10, CORN Jul/10, LIVE CATTLE Aug/10, 
LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, 
SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10
), CREATED.DATE = structure(c(18403, 18406, 18406, 18406, 18406, 
18407, 18408, 18406, 18407, 18407, 18407, 18407), class = Date), 
QUANTITY = c(1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1), SETTLEMENT =
c(373.2500, 
373.2500, 373.2500, 373.2500, 373.2500, 90.7750, 
90.7750, 14.9200, 14.9200, 14.9200, 14.9200, 14.9200
)), .Names = c(DESCRIPTION, CREATED.DATE, QUANTITY, 
SETTLEMENT), row.names = c(NA, 12L), class = data.frame)

I need then to apply to the df this following code line :

PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise, POSITION=
sum(QUANTITY))[,c(1,3,2)]

It works perfectly in most of case, BUT I have a new problem: it can
sometime occurs that my df futures is empty, with zero rows.


futures -
structure(list(DESCRIPTION = character(0), CREATED.DATE =
structure(numeric(0), class = Date), 
QUANTITY = numeric(0), SETTLEMENT = character(0)), .Names =
c(DESCRIPTION, 
CREATED.DATE, QUANTITY, SETTLEMENT), row.names = integer(0), class =
data.frame)

It is not the usual case, but it can happen. With this df, when I pass the
above mentione line, I get an error :

PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise, POSITION=
sum(QUANTITY))[,c(1,3,2)]
Error in tapply(1:nrow(data), splitv, list) : 
  arguments must have same length


How can I avoid this when my df is empty?

Any help is appreciated

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
Brian,

If I do understand correctly, I must use in my function something else than
ddply() if I want to avoid any error each time my df has zero rows?
Am I correct?

TY




 -Original Message-
 From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
 Sent: Tuesday, June 01, 2010 9:47 AM
 To: arnaud Gaboury
 Subject: Re: [R] data frame manipulation with zero rows
 
 On Tue, 1 Jun 2010, arnaud Gaboury wrote:
 
  Dear group,
 
  Here is the kind of data.frame I obtain every day with my function :
 
  futures -
  structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10,
  CORN Jul/10, CORN Jul/10, CORN Jul/10, LIVE CATTLE Aug/10,
  LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10,
  SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10
  ), CREATED.DATE = structure(c(18403, 18406, 18406, 18406, 18406,
  18407, 18408, 18406, 18407, 18407, 18407, 18407), class = Date),
 QUANTITY = c(1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1), SETTLEMENT =
  c(373.2500,
 373.2500, 373.2500, 373.2500, 373.2500, 90.7750,
 90.7750, 14.9200, 14.9200, 14.9200, 14.9200, 14.9200
 )), .Names = c(DESCRIPTION, CREATED.DATE, QUANTITY,
  SETTLEMENT), row.names = c(NA, 12L), class = data.frame)
 
  I need then to apply to the df this following code line :
 
  PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise,
 POSITION=
  sum(QUANTITY))[,c(1,3,2)]
 
  It works perfectly in most of case, BUT I have a new problem: it can
  sometime occurs that my df futures is empty, with zero rows.
 
 
  futures -
  structure(list(DESCRIPTION = character(0), CREATED.DATE =
  structure(numeric(0), class = Date),
 QUANTITY = numeric(0), SETTLEMENT = character(0)), .Names =
  c(DESCRIPTION,
  CREATED.DATE, QUANTITY, SETTLEMENT), row.names = integer(0),
 class =
  data.frame)
 
  It is not the usual case, but it can happen. With this df, when I
 pass the
  above mentione line, I get an error :
 
  PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise,
 POSITION=
  sum(QUANTITY))[,c(1,3,2)]
  Error in tapply(1:nrow(data), splitv, list) :
   arguments must have same length
 
 
  How can I avoid this when my df is empty?
 
 Ask the author of the (missing) function ddply() to correct the error
 of using 1:nrow(data) by replacing it by seq_len(nrow(data)).
 
 It's helpful to give example code, but much more helpful if you test
 it: yours cannot work without the function ddply() -- this is what
 'self-contained' means in the footer here.
 
 
 
  Any help is appreciated
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 --
 Brian D. Ripley,  rip...@stats.ox.ac.uk
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] MacOS X binary for lme4 not available on CRAN

2010-06-01 Thread Armin Goralczyk
Dear group,

I have noticed that the MacOS X binary for lme4 is not available on
CRAN at the moment. I am aware that it may be possible to install from
source but I am not very familiar with that procedure and would rather
avoid it. But I need the package for a statistics course next week. So
can anybody give an update about the situation with the MacOS X
binaries? Will it be resolved within the next days or should I rather
install from source (in that case: is my assumption correct that it is
possible or will it fail (I read the the check log and it seems that
there is some error ?)

Thank you for any advise or help

-- 
Armin Goralczyk
--
http://www.gwdg.de/~agoralc

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

2010-06-01 Thread Noah Silverman
I'm running a long MCMC chain that is generating samples for 22 variables.

I have each run of the chain as a row in a matrix.

So:  Chain[,1] is the column with all the samples for variable one. 
Chain[,2] is the column with all the samples for variable 2, etc.

I'd like to fit all 22 on a single page to print a nice summary.  It is
OK if the graphs are small, I just need to show the overall shape and
convergence.

Using par(mfrow=(11,2)) gives me the error:  figure margins too large
when I try to draw a plot
I looked at the Lattice package, which seems very promising, but I can't
figure out how to have it plot each column in a separate box.

I need to do this same one page summary about 50 times, so it would be
a nightmare to make over 1,000 plots by hand.

Ideally, I'd create a loop for each of the 50 runs that would generate a
single page containing the 22 plots.

In pseudocode:

for( i in 1:50){
par(mfrow(11,2))
for(j in 1:22){
plot(Chain[,j], type=l)
}
}

BUT, this doesn't work.

Does anyone have any ideas about an easy way to do this?

Thanks!

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


Re: [R] two questions about PLOT

2010-06-01 Thread Jie TANG
thanks for your reply.
 I have tried to use rseek.org.But still some problems.
When I add axis(4) and axis(1,at=1:6,labels=gradeinfo$gradenam),the old
tick or labels still
are there as shown in the figure,how could I delete them( the old tick
information in x-axis and left y axis )
My script is shown as below :

plot(avegrp,type='l',lty=1,col='black',lwd=4,xlab=xxlab,ylab=yylab,labels=TRUE)
axis(2)
axis(1,at=1:6,labels=gradeinfo$gradenam, tick=FALSE)
par(new=T)

plot(sdgrp,type='l',lty=3,col='red1',xlab=xxlab,ylab=yylab,lwd=4,labels=TRUE)
axis(1,at=1:6,labels=gradeinfo$gradenam, tick=FALSE)
#axis(2, col = gold, lty = 2, lwd = 0.5)
axis(4)
legend(topright, legend,   lty=llty, lwd=llwd,col =lgcol)



2010/6/1 Jannis bt_jan...@yahoo.de

 I would wote this question one of the most often asked questions here on
 that list ;-). Try searching the help archiwe (www.rseek.org) and you will
 find solutions. I would guess that you need to use something like:

 axis(4)

 as the sides of the plot are always numbered from bottom,left,top,right

 HTH
 Jannis
 Jie TANG schrieb:

 here ,I want to plot two lines in one figure.But I have two problems
 1) how to move one of the y-axis to be the right ? I tried to the
 commandaxis(2),But I failed.
 2) how to add the axis information correctly.Since I have use the cmommand
 axis(1,at=1:6,labels=gradeinfo$gradenam)
   but it seems that the correct information that I want is superposition
 with the old axis information.What can i do ?
 the script and figure is shown as below .thanks .:)

 outflnm-paste(Outdic,meansd.jpg,sep=/)
 jpeg(file=outflnm, bg=transparent)
 legend-c(average error,stand quare error)
 lgcol-c(black,red1)
 par(las=1)
 yylab-c(forecast error)
 xxlab-c(typhoon class)
 llty-c(1,3)
 llwd-c(4,4)
 #par(bg='yellow')


 plot(avegrp,type='l',lty=1,col='black',lwd=4,xlab=xxlab,ylab=yylab)
 par(new=T)
 plot(sdgrp,type='l',lty=3,col='red1',xlab=xxlab,ylab=yylab,lwd=4)
 #axis(2, col = gold, lty = 2, lwd = 0.5)
 legend(topright, legend,   lty=llty, lwd=llwd,col =lgcol)
 axis(1,at=1:6,labels=gradeinfo$gradenam)
 dev.off()

  

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






-- 
TANG Jie
Email: totang...@gmail.com
Tel: 0086-2154896104
Shanghai Typhoon Institute,China
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] accessing a data frame with row names

2010-06-01 Thread e-letter
On 31/05/2010, Gabor Grothendieck ggrothendi...@gmail.com wrote:
 Use read.csv or read.table(..., sep = ,).  Also note that if you
 delete the first comma of the header (as in the second example below)
 you won't have to specify row.names since it can figure it out from
 the fact that there is one fewer column name than data fields.

 Lines - ,column1,column2
 + row1,0.1,0.2
 + row2,0.3,0.4

 read.csv(textConnection(Lines), row.names = 1)
  column1 column2
 row1 0.1 0.2
 row2 0.3 0.4

Thank you. When I enter the command:

max(dataframe[,2])

The response is:

[1] 0.4

But I want to receive the row name, i.e.:

[1] row2 0.4

Is this possible?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] accessing a data frame with row names

2010-06-01 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 01.06.2010 10:20:35:

 On 31/05/2010, Gabor Grothendieck ggrothendi...@gmail.com wrote:
  Use read.csv or read.table(..., sep = ,).  Also note that if you
  delete the first comma of the header (as in the second example below)
  you won't have to specify row.names since it can figure it out from
  the fact that there is one fewer column name than data fields.
 
  Lines - ,column1,column2
  + row1,0.1,0.2
  + row2,0.3,0.4
 
  read.csv(textConnection(Lines), row.names = 1)
   column1 column2
  row1 0.1 0.2
  row2 0.3 0.4
 
 Thank you. When I enter the command:
 
 max(dataframe[,2])
 
 The response is:
 
 [1] 0.4
 
 But I want to receive the row name, i.e.:
 
 [1] row2 0.4

It seems that you probably shall consult

?which with parameter arr.ind=T

which(dataframe==max(dataframe), arr.ind=T)

Regards
Petr


 
 Is this possible?
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Sweave amp; png

2010-06-01 Thread Gildas Mazo
Thank you





Ben Bolker a écrit :
 Gildas Mazo gildas.mazo at curie.fr writes:

   
 Is there a simple way to save my figures in png instead of pdf with
 Sweave ??
 


 See

 http://sites.google.com/site/thibautjombart/r-packages

 (scroll to the bottom)

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

2010-06-01 Thread arnaud Gaboury
Dear group,

Here is my data frame:


futures -
structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10, 
CORN Jul/10, CORN Jul/10, CORN Jul/10, LIVE CATTLE Aug/10, 
LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, 
SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10
), CREATED.DATE = structure(c(18403, 18406, 18406, 18406, 18406, 
18407, 18408, 18406, 18407, 18407, 18407, 18407), class = Date), 
QUANTITY = c(1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1), SETTLEMENT =
c(373.2500, 
373.2500, 373.2500, 373.2500, 373.2500, 90.7750, 
90.7750, 14.9200, 14.9200, 14.9200, 14.9200, 14.9200
)), .Names = c(DESCRIPTION, CREATED.DATE, QUANTITY, 
SETTLEMENT), row.names = c(NA, 12L), class = data.frame)

Here is the line I pass :

PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise, POSITION=
sum(QUANTITY))[,c(1,3,2)]

And here the result :

PosFut -
structure(list(DESCRIPTION = structure(1:3, .Label = c(CORN Jul/10, 
LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10), class = factor), 
POSITION = c(5, 4, 5), SETTLEMENT = structure(c(2L, 3L, 1L
), .Label = c(14.9200, 373.2500, 90.7750), class = factor)),
.Names = c(DESCRIPTION, 
POSITION, SETTLEMENT), class = data.frame, row.names = c(NA, 
-3L))

I can no more use ddply, as this above command line is in a function, and
this line should be able to work with a data frame with zero rows, and in
this case ddply doesn't work.
Any suggestion how to obtain the same result without ddply?

TY for any help.

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

2010-06-01 Thread Peter Ehlers

On 2010-06-01 0:16, bill.venab...@csiro.au wrote:

xyzs- matrix(rnorm(3*10,0,1),ncol=3)

V- c(2,3,4)
system.time(vx- apply(t(xyzs) * V, 2 ,sum))

user  system elapsed
1.060.021.08


system.time(wx- as.vector(xyzs %*% V))

user  system elapsed
   0   0   0

all.equal(vx, wx)

[1] TRUE


Or, for a very slight further reduction in time in
the case of larger matrices/vectors:

 as.vector(tcrossprod(V, xyzs))

I mention this merely to remind new users of the
excellent speed of [t]crossprod().

 -Peter Ehlers




?

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Remko Duursma
Sent: Tuesday, 1 June 2010 4:04 PM
To: r-help@r-project.org
Subject: [R] Faster matrix operation?

Dear R-helpers,

I have a three-column matrix with lots of rows:

xyzs- matrix(rnorm(3*10,0,1),ncol=3)

# And I am multiplying it with some vector V, and summing the rows
(columns after t()) in this way:
V- c(2,3,4)
system.time(vx- apply(t(xyzs) * V, 2 ,sum))


Ok, this does not take long (0.9 sec on my machine), but I have to do
this lots of times, with frequently larger matrices.

Is there a way to significantly speed this up, apart from writing it
in Fortran or C and calling it from within R (which is what I am
planning unless there is an alternative)?


thanks,
Remko




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

2010-06-01 Thread baptiste auguie
On 1 June 2010 11:34, Peter Ehlers ehl...@ucalgary.ca wrote:
 Or, for a very slight further reduction in time in
 the case of larger matrices/vectors:

  as.vector(tcrossprod(V, xyzs))

 I mention this merely to remind new users of the
 excellent speed of [t]crossprod().

  -Peter Ehlers

Thanks, I've been using t(x)%*%y for several years now, and had never
found out there was a faster and more straight-forward function for
this. Perhaps a link to [t]crossprod could be added on the help page
for ?%*%.

Best,

baptiste

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

2010-06-01 Thread Ivan Calandra

Hi,

Try with:
par(mfrow=c(11,2))

It should work better!
Remember that mfrow is an argument of the function par(), not a function 
itself.


One other tip: think about using pdf, ps, png, or SVG devices, I find it 
easier and nicer.


HTH,
Ivan

Le 6/1/2010 10:02, Noah Silverman a écrit :

I'm running a long MCMC chain that is generating samples for 22 variables.

I have each run of the chain as a row in a matrix.

So:  Chain[,1] is the column with all the samples for variable one.
Chain[,2] is the column with all the samples for variable 2, etc.

I'd like to fit all 22 on a single page to print a nice summary.  It is
OK if the graphs are small, I just need to show the overall shape and
convergence.

Using par(mfrow=(11,2)) gives me the error:  figure margins too large
when I try to draw a plot
I looked at the Lattice package, which seems very promising, but I can't
figure out how to have it plot each column in a separate box.

I need to do this same one page summary about 50 times, so it would be
a nightmare to make over 1,000 plots by hand.

Ideally, I'd create a loop for each of the 50 runs that would generate a
single page containing the 22 plots.

In pseudocode:

for( i in 1:50){
 par(mfrow(11,2))
 for(j in 1:22){
 plot(Chain[,j], type=l)
 }
}

BUT, this doesn't work.

Does anyone have any ideas about an easy way to do this?

Thanks!

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

   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] New behavior of 'write.csv' append argument?

2010-06-01 Thread jim holtman
As noted in the help file under CSV files:

These wrappers are deliberately inflexible: they are designed to
ensure that the correct conventions are used to write a valid file.
Attempts to change append, col.names, sep, dec or qmethod are ignored,
with a warning.



On Mon, May 31, 2010 at 8:33 PM, Steven Worthington
steven.worthing...@gmail.com wrote:

 Dear R users,

 I have recently begun to reuse some functions I made several months ago. The
 scripts write to a .csv file using the 'write.csv' function with the append
 option set to TRUE. This used to work fine, albeit with the warning
 appending column names to file. I upgraded to R version 2.11.0 on OSX
 10.5.8 and 'write.csv' will no longer append any files - I get the warning
 attempt to set 'append' ignored. The exact same object will append when
 using 'write.table' without issue. Here's a minimal example. Has there been
 a change in 'write.csv'?

 # 
 x - rnorm(10, 5)
 y - rnorm(10, 10)
 z - rnorm(10, 15)
 dat - data.frame(x, y, z)
 names(dat) - c(first, second, third)

 write.csv(dat, file=dat.csv, append=TRUE)
 write.table(dat, file=dat2.csv, sep=,, row.names=FALSE, append=TRUE)
 # 

 best,

 Steve
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/New-behavior-of-write-csv-append-argument-tp2237936p2237936.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem that you are trying to solve?

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


Re: [R] two questions about PLOT

2010-06-01 Thread Ivan Calandra
It may not be the nicest solution, but my suggestion should work.
Have you tried plot(type=n,...), plotting the axes with axis(), and 
plotting the data with lines()?
Ivan

Le 6/1/2010 10:10, Jie TANG a écrit :
 thanks for your reply.
   I have tried to use rseek.org.But still some problems.
 When I add axis(4) and axis(1,at=1:6,labels=gradeinfo$gradenam),the old
 tick or labels still
 are there as shown in the figure,how could I delete them( the old tick
 information in x-axis and left y axis )
 My script is shown as below :

 plot(avegrp,type='l',lty=1,col='black',lwd=4,xlab=xxlab,ylab=yylab,labels=TRUE)
 axis(2)
 axis(1,at=1:6,labels=gradeinfo$gradenam, tick=FALSE)
 par(new=T)

 plot(sdgrp,type='l',lty=3,col='red1',xlab=xxlab,ylab=yylab,lwd=4,labels=TRUE)
 axis(1,at=1:6,labels=gradeinfo$gradenam, tick=FALSE)
 #axis(2, col = gold, lty = 2, lwd = 0.5)
 axis(4)
 legend(topright, legend,   lty=llty, lwd=llwd,col =lgcol)



 2010/6/1 Jannisbt_jan...@yahoo.de


 I would wote this question one of the most often asked questions here on
 that list ;-). Try searching the help archiwe (www.rseek.org) and you will
 find solutions. I would guess that you need to use something like:

 axis(4)

 as the sides of the plot are always numbered from bottom,left,top,right

 HTH
 Jannis
 Jie TANG schrieb:

  
 here ,I want to plot two lines in one figure.But I have two problems
 1) how to move one of the y-axis to be the right ? I tried to the
 commandaxis(2),But I failed.
 2) how to add the axis information correctly.Since I have use the cmommand
 axis(1,at=1:6,labels=gradeinfo$gradenam)
but it seems that the correct information that I want is superposition
 with the old axis information.What can i do ?
 the script and figure is shown as below .thanks .:)

 outflnm-paste(Outdic,meansd.jpg,sep=/)
 jpeg(file=outflnm, bg=transparent)
 legend-c(average error,stand quare error)
 lgcol-c(black,red1)
 par(las=1)
 yylab-c(forecast error)
 xxlab-c(typhoon class)
 llty-c(1,3)
 llwd-c(4,4)
 #par(bg='yellow')


 plot(avegrp,type='l',lty=1,col='black',lwd=4,xlab=xxlab,ylab=yylab)
 par(new=T)
 plot(sdgrp,type='l',lty=3,col='red1',xlab=xxlab,ylab=yylab,lwd=4)
 #axis(2, col = gold, lty = 2, lwd = 0.5)
 legend(topright, legend,   lty=llty, lwd=llwd,col =lgcol)
 axis(1,at=1:6,labels=gradeinfo$gradenam)
 dev.off()

   

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


-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php


[[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] data frame manipulation with zero rows

2010-06-01 Thread Peter Ehlers

On 2010-06-01 1:53, arnaud Gaboury wrote:

Brian,

If I do understand correctly, I must use in my function something else than
ddply() if I want to avoid any error each time my df has zero rows?
Am I correct?



You could define a function to handle the zero-rows case:

f - function(x){
 if(nrow(x)  1) out - x[, c(1,3,2)]  # or whatever
 else
   out - ddply(x, c(DESCRIPTION,SETTLEMENT), summarise,
POSITION=sum(QUANTITY))[,c(1,3,2)]
 out
}
f(futures)

 -Peter Ehlers





-Original Message-
From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
Sent: Tuesday, June 01, 2010 9:47 AM
To: arnaud Gaboury
Subject: Re: [R] data frame manipulation with zero rows

On Tue, 1 Jun 2010, arnaud Gaboury wrote:


Dear group,

Here is the kind of data.frame I obtain every day with my function :

futures-
structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10,
CORN Jul/10, CORN Jul/10, CORN Jul/10, LIVE CATTLE Aug/10,
LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10,
SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10
), CREATED.DATE = structure(c(18403, 18406, 18406, 18406, 18406,
18407, 18408, 18406, 18407, 18407, 18407, 18407), class = Date),
QUANTITY = c(1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1), SETTLEMENT =
c(373.2500,
373.2500, 373.2500, 373.2500, 373.2500, 90.7750,
90.7750, 14.9200, 14.9200, 14.9200, 14.9200, 14.9200
)), .Names = c(DESCRIPTION, CREATED.DATE, QUANTITY,
SETTLEMENT), row.names = c(NA, 12L), class = data.frame)

I need then to apply to the df this following code line :


PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise,

POSITION=

sum(QUANTITY))[,c(1,3,2)]

It works perfectly in most of case, BUT I have a new problem: it can
sometime occurs that my df futures is empty, with zero rows.


futures-
structure(list(DESCRIPTION = character(0), CREATED.DATE =
structure(numeric(0), class = Date),
QUANTITY = numeric(0), SETTLEMENT = character(0)), .Names =
c(DESCRIPTION,
CREATED.DATE, QUANTITY, SETTLEMENT), row.names = integer(0),

class =

data.frame)

It is not the usual case, but it can happen. With this df, when I

pass the

above mentione line, I get an error :


PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise,

POSITION=

sum(QUANTITY))[,c(1,3,2)]
Error in tapply(1:nrow(data), splitv, list) :
  arguments must have same length


How can I avoid this when my df is empty?


Ask the author of the (missing) function ddply() to correct the error
of using 1:nrow(data) by replacing it by seq_len(nrow(data)).

It's helpful to give example code, but much more helpful if you test
it: yours cannot work without the function ddply() -- this is what
'self-contained' means in the footer here.




Any help is appreciated

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

guide.html

and provide commented, minimal, self-contained, reproducible code.



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595




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

2010-06-01 Thread arnaud Gaboury
Patrick,

When apply to this following df :

futures -
structure(list(DESCRIPTION = character(0), CREATED.DATE =
structure(numeric(0), class = Date), 
QUANTITY = numeric(0), SETTLEMENT = character(0)), .Names =
c(DESCRIPTION, 
CREATED.DATE, QUANTITY, SETTLEMENT), row.names = integer(0), class =
data.frame)


 PosFut - aggregate(futures$QUANTITY, list(DESCRIPTION =
futures$DESCRIPTION,SETTLEMENT=futures$SETTLEMENT),sum)[,c(1,3,2)]
Error in aggregate.data.frame(as.data.frame(x), ...) : 
  no rows to aggregate



 -Original Message-
 From: Patrick Hausmann [mailto:patrick.hausm...@uni-bremen.de]
 Sent: Tuesday, June 01, 2010 11:38 AM
 To: arnaud Gaboury
 Subject: Re: [R] data frame manipulation ddply
 
 Hi Arnaud,
 
 maybe aggregate can help:
 
 PosFut - aggregate(futures$QUANTITY, list(DESCRIPTION =
 futures$DESCRIPTION,
   SETTLEMENT  = futures$SETTLEMENT),
 sum)[, c(1,3,2)]
 
 HTH,
 Patrick
 
 Am 01.06.2010 11:02, schrieb arnaud Gaboury:
  Dear group,
 
  Here is my data frame:
 
 
  futures-
  structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10,
  CORN Jul/10, CORN Jul/10, CORN Jul/10, LIVE CATTLE Aug/10,
  LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10,
  SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10
  ), CREATED.DATE = structure(c(18403, 18406, 18406, 18406, 18406,
  18407, 18408, 18406, 18407, 18407, 18407, 18407), class = Date),
   QUANTITY = c(1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1), SETTLEMENT =
  c(373.2500,
   373.2500, 373.2500, 373.2500, 373.2500, 90.7750,
   90.7750, 14.9200, 14.9200, 14.9200, 14.9200, 14.9200
   )), .Names = c(DESCRIPTION, CREATED.DATE, QUANTITY,
  SETTLEMENT), row.names = c(NA, 12L), class = data.frame)
 
  Here is the line I pass :
 
  PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise,
 POSITION=
  sum(QUANTITY))[,c(1,3,2)]
 
  And here the result :
 
  PosFut-
  structure(list(DESCRIPTION = structure(1:3, .Label = c(CORN Jul/10,
  LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10), class = factor),
   POSITION = c(5, 4, 5), SETTLEMENT = structure(c(2L, 3L, 1L
   ), .Label = c(14.9200, 373.2500, 90.7750), class =
 factor)),
  .Names = c(DESCRIPTION,
  POSITION, SETTLEMENT), class = data.frame, row.names = c(NA,
  -3L))
 
  I can no more use ddply, as this above command line is in a function,
 and
  this line should be able to work with a data frame with zero rows,
 and in
  this case ddply doesn't work.
  Any suggestion how to obtain the same result without ddply?
 
  TY for any help.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] New behavior of 'write.csv' append argument?

2010-06-01 Thread Ivan Calandra

Is there a reason why append=TRUE should not be used?

I actually use it a lot; that way I have less csv files created. I can 
output everything to a single file. Since some statistical tests returns 
lists with different number of elements, it is not always possible to 
export the output all at once (or at least I don't know how).

All the packages that I know of that export to xls do not append either.

So from R2.11 is there no way to append to xls/csv anymore?

Ivan

Le 6/1/2010 11:56, jim holtman a écrit :

As noted in the help file under CSV files:

These wrappers are deliberately inflexible: they are designed to
ensure that the correct conventions are used to write a valid file.
Attempts to change append, col.names, sep, dec or qmethod are ignored,
with a warning.



On Mon, May 31, 2010 at 8:33 PM, Steven Worthington
steven.worthing...@gmail.com  wrote:
   

Dear R users,

I have recently begun to reuse some functions I made several months ago. The
scripts write to a .csv file using the 'write.csv' function with the append
option set to TRUE. This used to work fine, albeit with the warning
appending column names to file. I upgraded to R version 2.11.0 on OSX
10.5.8 and 'write.csv' will no longer append any files - I get the warning
attempt to set 'append' ignored. The exact same object will append when
using 'write.table' without issue. Here's a minimal example. Has there been
a change in 'write.csv'?

# 
x- rnorm(10, 5)
y- rnorm(10, 10)
z- rnorm(10, 15)
dat- data.frame(x, y, z)
names(dat)- c(first, second, third)

write.csv(dat, file=dat.csv, append=TRUE)
write.table(dat, file=dat2.csv, sep=,, row.names=FALSE, append=TRUE)
# 

best,

Steve
--
View this message in context: 
http://r.789695.n4.nabble.com/New-behavior-of-write-csv-append-argument-tp2237936p2237936.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.

 



   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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

2010-06-01 Thread baptiste auguie
Hi,

You could use melt from the reshape package to create a long format
data.frame. This is more easy to plot with lattice or ggplot2, and you
can then use facetting to arrange several plots on the same page. The
dummy example below produces 10 pages of output with 10 graphs per
page.

library(ggplot2)

dl - replicate(10, as.data.frame(matrix(rnorm(1e3), ncol=10)), simplify=FALSE)
names(dl) - paste(column, seq_along(dl), sep=)

# dummy list of data.frames
str(dl)

# a function to plot one data.frame
plotone - function(d, ...)
  qplot(seq_along(value), value, data=melt(d)) +
  facet_wrap(~variable, scales=free)

# call the function for each data.frame
pl - llply(dl, plotone)

# print to a file
pdf(test.pdf)
l_ply(pl, print)
dev.off()


HTH,

baptiste

On 1 June 2010 10:02, Noah Silverman n...@smartmediacorp.com wrote:
 I'm running a long MCMC chain that is generating samples for 22 variables.

 I have each run of the chain as a row in a matrix.

 So:  Chain[,1] is the column with all the samples for variable one.
 Chain[,2] is the column with all the samples for variable 2, etc.

 I'd like to fit all 22 on a single page to print a nice summary.  It is
 OK if the graphs are small, I just need to show the overall shape and
 convergence.

 Using par(mfrow=(11,2)) gives me the error:  figure margins too large
 when I try to draw a plot
 I looked at the Lattice package, which seems very promising, but I can't
 figure out how to have it plot each column in a separate box.

 I need to do this same one page summary about 50 times, so it would be
 a nightmare to make over 1,000 plots by hand.

 Ideally, I'd create a loop for each of the 50 runs that would generate a
 single page containing the 22 plots.

 In pseudocode:

 for( i in 1:50){
    par(mfrow(11,2))
    for(j in 1:22){
        plot(Chain[,j], type=l)
    }
 }

 BUT, this doesn't work.

 Does anyone have any ideas about an easy way to do this?

 Thanks!

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] data frame manipulation with zero rows

2010-06-01 Thread Prof Brian Ripley

On Tue, 1 Jun 2010, Peter Ehlers wrote:


On 2010-06-01 1:53, arnaud Gaboury wrote:

Brian,

If I do understand correctly, I must use in my function something else than
ddply() if I want to avoid any error each time my df has zero rows?
Am I correct?



You could define a function to handle the zero-rows case:

f - function(x){
if(nrow(x)  1) out - x[, c(1,3,2)]  # or whatever
else
  out - ddply(x, c(DESCRIPTION,SETTLEMENT), summarise,
   POSITION=sum(QUANTITY))[,c(1,3,2)]
out
}
f(futures)


Or simply fix ddply.  We don't know what that is or what it should do 
for the case of zero rows: it may or may not be the one in package 
plyr.




-Peter Ehlers





-Original Message-
From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
Sent: Tuesday, June 01, 2010 9:47 AM
To: arnaud Gaboury
Subject: Re: [R] data frame manipulation with zero rows

On Tue, 1 Jun 2010, arnaud Gaboury wrote:


Dear group,

Here is the kind of data.frame I obtain every day with my function :

futures-
structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10,
CORN Jul/10, CORN Jul/10, CORN Jul/10, LIVE CATTLE Aug/10,
LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10,
SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10
), CREATED.DATE = structure(c(18403, 18406, 18406, 18406, 18406,
18407, 18408, 18406, 18407, 18407, 18407, 18407), class = Date),
QUANTITY = c(1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1), SETTLEMENT =
c(373.2500,
373.2500, 373.2500, 373.2500, 373.2500, 90.7750,
90.7750, 14.9200, 14.9200, 14.9200, 14.9200, 14.9200
)), .Names = c(DESCRIPTION, CREATED.DATE, QUANTITY,
SETTLEMENT), row.names = c(NA, 12L), class = data.frame)

I need then to apply to the df this following code line :


PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise,

POSITION=

sum(QUANTITY))[,c(1,3,2)]

It works perfectly in most of case, BUT I have a new problem: it can
sometime occurs that my df futures is empty, with zero rows.


futures-
structure(list(DESCRIPTION = character(0), CREATED.DATE =
structure(numeric(0), class = Date),
QUANTITY = numeric(0), SETTLEMENT = character(0)), .Names =
c(DESCRIPTION,
CREATED.DATE, QUANTITY, SETTLEMENT), row.names = integer(0),

class =

data.frame)

It is not the usual case, but it can happen. With this df, when I

pass the

above mentione line, I get an error :


PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise,

POSITION=

sum(QUANTITY))[,c(1,3,2)]
Error in tapply(1:nrow(data), splitv, list) :
  arguments must have same length


How can I avoid this when my df is empty?


Ask the author of the (missing) function ddply() to correct the error
of using 1:nrow(data) by replacing it by seq_len(nrow(data)).

It's helpful to give example code, but much more helpful if you test
it: yours cannot work without the function ddply() -- this is what
'self-contained' means in the footer here.


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] New behavior of 'write.csv' append argument?

2010-06-01 Thread Peter Ehlers

On 2010-05-31 18:33, Steven Worthington wrote:


Dear R users,

I have recently begun to reuse some functions I made several months ago. The
scripts write to a .csv file using the 'write.csv' function with the append
option set to TRUE. This used to work fine, albeit with the warning
appending column names to file. I upgraded to R version 2.11.0 on OSX
10.5.8 and 'write.csv' will no longer append any files - I get the warning
attempt to set 'append' ignored. The exact same object will append when
using 'write.table' without issue. Here's a minimal example. Has there been
a change in 'write.csv'?

# 
x- rnorm(10, 5)
y- rnorm(10, 10)
z- rnorm(10, 15)
dat- data.frame(x, y, z)
names(dat)- c(first, second, third)

write.csv(dat, file=dat.csv, append=TRUE)
write.table(dat, file=dat2.csv, sep=,, row.names=FALSE, append=TRUE)
# 



It's always a good idea to check the NEWS file. Here is a quote:

  write.csv[2] no longer allow 'append' to be changed: as ever,
   direct calls to write.table() give more flexibility as well as
   more room for error.

So use write.table.

  -Peter Ehlers

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


Re: [R] MacOS X binary for lme4 not available on CRAN

2010-06-01 Thread Prof Brian Ripley
First, this is not the list to discuss MacOS X binaries: that is 
R-sig-mac.


Second, only one person really knows about the situation with package 
binaries, the person who produces them (equally true for Windows and 
for Mac OS X).  And that person does not read R-help, having asked for 
such issues to be discussed on R-sig-mac.


I very much doubt that this will be solved this week: the failure of 
lme4 in its checks on Mac OS X has been going on for years.


On Tue, 1 Jun 2010, Armin Goralczyk wrote:


Dear group,

I have noticed that the MacOS X binary for lme4 is not available on
CRAN at the moment. I am aware that it may be possible to install from
source but I am not very familiar with that procedure and would rather
avoid it. But I need the package for a statistics course next week. So
can anybody give an update about the situation with the MacOS X
binaries? Will it be resolved within the next days or should I rather
install from source (in that case: is my assumption correct that it is
possible or will it fail (I read the the check log and it seems that
there is some error ?)


Installation will work but package checking will fail, at least on an 
i386 Mac.



Thank you for any advise or help

--
Armin Goralczyk
--
http://www.gwdg.de/~agoralc

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Printing page nmbers in multi-page pdf

2010-06-01 Thread David Winsemius


On May 31, 2010, at 11:40 PM, Nevil Amos wrote:


Is it possible to print page numbers in pdf() with multiple pages?


?mtext



thanks

Nevil Amos

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] n-dimensional vector plot

2010-06-01 Thread David Winsemius


On Jun 1, 2010, at 12:51 AM, suman dhara wrote:


Sir,
I have n p-dimensional regressor vectors corresponding to n  
responses. I
want to plot n regressor vectors in R. Is it possible to plot them  
in R?

If yes, please send me the code.


?matplot



Thanks,
Suman Dhara


David Winsemius, MD
West Hartford, CT

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


[R] Help barplots

2010-06-01 Thread khush ........
Dear All,

I am newbie to R, and I wanted to plot a barplots with R and in such a way
that It will also show me position which I can plot on the bar line.

Here is my code that I am using to plot,

 chromosome - c(40.2, 35.6, 36.1, 29.6, 31, 29.6, 31, 29.4, 28.2, 23, 23,
28.2)
barplot (chromosome, col=purple, xlab=Oryza sativa Chromosomes, border
= NA, space = 5, ylim = c(0,45))

I wanted to mark the position say on chromosome 1 (40.2) I need to mark 10.2
and on other also.
I also want to set the scale of y axis from 0,5,10,15,20,25,30,35,40,45 i.e
gap of 5 instead of 10.

please help me to solve my querygurus.


Thank you
Jeet

[[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] Odp: Help barplots

2010-06-01 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 01.06.2010 13:01:38:

 Dear All,
 
 I am newbie to R, and I wanted to plot a barplots with R and in such a 
way
 that It will also show me position which I can plot on the bar line.
 
 Here is my code that I am using to plot,
 
  chromosome - c(40.2, 35.6, 36.1, 29.6, 31, 29.6, 31, 29.4, 28.2, 23, 
23,
 28.2)
 barplot (chromosome, col=purple, xlab=Oryza sativa Chromosomes, 
border
 = NA, space = 5, ylim = c(0,45))
 
 I wanted to mark the position say on chromosome 1 (40.2) I need to mark 
10.2
 and on other also.

I do not understand what you want? What is 10.2

maybe names.arg is what you want.

barplot (chromosome, col=purple, xlab=Oryza sativa Chromosomes, border
= NA, space = 5, ylim = c(0,45), names.arg=chromosome, axes=F)

 I also want to set the scale of y axis from 0,5,10,15,20,25,30,35,40,45 
i.e
 gap of 5 instead of 10.

use axes=F and

axis(2, at=seq(0,45,5))

Regards
Petr

 
 please help me to solve my querygurus.
 
 
 Thank you
 Jeet
 
[[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] two questions about PLOT

2010-06-01 Thread Jim Lemon

On 06/01/2010 12:44 AM, Jie TANG wrote:

here ,I want to plot two lines in one figure.But I have two problems
1) how to move one of the y-axis to be the right ? I tried to the
commandaxis(2),But I failed.
2) how to add the axis information correctly.Since I have use the cmommand
axis(1,at=1:6,labels=gradeinfo$gradenam)
but it seems that the correct information that I want is superposition
with the old axis information.What can i do ?
the script and figure is shown as below .thanks .:)

outflnm-paste(Outdic,meansd.jpg,sep=/)
jpeg(file=outflnm, bg=transparent)
legend-c(average error,stand quare error)
lgcol-c(black,red1)
par(las=1)
yylab-c(forecast error)
xxlab-c(typhoon class)
llty-c(1,3)
llwd-c(4,4)
#par(bg='yellow')


plot(avegrp,type='l',lty=1,col='black',lwd=4,xlab=xxlab,ylab=yylab)
par(new=T)
plot(sdgrp,type='l',lty=3,col='red1',xlab=xxlab,ylab=yylab,lwd=4)
#axis(2, col = gold, lty = 2, lwd = 0.5)
legend(topright, legend,   lty=llty, lwd=llwd,col =lgcol)
axis(1,at=1:6,labels=gradeinfo$gradenam)
dev.off()


Hi Jie,
First problem:

# put this just after the jpeg device is opened
# to leave extra space on the right
par(mar=c(5,4,4,4)
# then just before dev.off
axis(4,...)

Second problem:

# don't display the default x axis
plot(avegrp,type='l',lty=1,col='black',lwd=4,
 xlab=xxlab,ylab=yylab,xaxt=n)
# then display your custom axis

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] Fancy Page layout

2010-06-01 Thread Jim Lemon

On 06/01/2010 04:16 AM, Noah Silverman wrote:

Hi,

Working on a report that is going to have a large number of graphs and
summaries.  We have 80 groups with 20 variables each.

Ideally, I'd like to produce ONE page for each group.  It would have two
columns of 10 graphs and then the 5 number summary of the variables at
the bottom.
So, perhaps the top 2/3 of the page has the graphs and the bottom third
has 20 rows of data summary(maybe a table of sorts.)
This COULD be done in Latex, but would have to be hand coded for each of
the 80 groups which would be painfully slow.

I can easily do the graphs with par(mfrow=c(5,2))  band then draw the
graphs in a loop.

But I am stuck from here:

1) How do I control the size of the plot window.  (Ideally, it should
print to fill an 8.5 x 11 piece of paper)
2) Is there a way to easily insert a 5 number summary (summary
command) into the lower half of the page.

Does anybody have any ideas??


Hi Noah,
One easy way is to leave some space at the bottom, either by using:

par(mfrow=c(6,2))

or the more flexible layout function, and then use text or a fancier 
function (textbox, boxed.labels, addtable2plot, etc.) to add your text 
after:


par(xpd=NA)

allows you to display the text anywhere you please. If you use a bitmap 
graphics device, make it big:


png(numberoneofeighty.png,850,1100)

so that it won't look lumpy on the printed page.

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] Help barplots

2010-06-01 Thread Martyn Byng
Hi,

If you want to draw lines on your barchart then

aa = barplot(chromosome, col=purple, xlab=Oryza sativa Chromosomes,
border
= NA, space = 5, ylim = c(0,45))

returns the midpoints of each bar in the vector aa and then you can use
the lines() function to do the drawing.

Martyn

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of khush 
Sent: 01 June 2010 12:02
To: r-help@r-project.org
Subject: [R] Help barplots

Dear All,

I am newbie to R, and I wanted to plot a barplots with R and in such a
way
that It will also show me position which I can plot on the bar line.

Here is my code that I am using to plot,

 chromosome - c(40.2, 35.6, 36.1, 29.6, 31, 29.6, 31, 29.4, 28.2, 23,
23,
28.2)
barplot (chromosome, col=purple, xlab=Oryza sativa Chromosomes,
border
= NA, space = 5, ylim = c(0,45))

I wanted to mark the position say on chromosome 1 (40.2) I need to mark
10.2
and on other also.
I also want to set the scale of y axis from 0,5,10,15,20,25,30,35,40,45
i.e
gap of 5 instead of 10.

please help me to solve my querygurus.


Thank you
Jeet

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


This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}

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

2010-06-01 Thread Jim Lemon

On 06/01/2010 09:01 PM, khush  wrote:

Dear All,

I am newbie to R, and I wanted to plot a barplots with R and in such a way
that It will also show me position which I can plot on the bar line.

Here is my code that I am using to plot,


chromosome- c(40.2, 35.6, 36.1, 29.6, 31, 29.6, 31, 29.4, 28.2, 23, 23,

28.2)

barplot (chromosome, col=purple, xlab=Oryza sativa Chromosomes, border

= NA, space = 5, ylim = c(0,45))

I wanted to mark the position say on chromosome 1 (40.2) I need to mark 10.2
and on other also.
I also want to set the scale of y axis from 0,5,10,15,20,25,30,35,40,45 i.e
gap of 5 instead of 10.

please help me to solve my querygurus.


Hi Jeet,
I think you want the x positions of the bars. Get them like this:

xpos-barplot (chromosome, col=purple,
 xlab=Oryza sativa Chromosomes,
 border = NA, space = 5, ylim = c(0,45))

Then you can place the extra labels using the values in xpos.
For the custom y axis, add the argument yaxt=n to your plot command 
and then add the axis later. I suspect you will have to use something 
like the staxlab function in the plotrix package to get all those labels 
to display.


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] Help barplots

2010-06-01 Thread Peter Ehlers

On 2010-06-01 5:01, khush  wrote:

Dear All,

I am newbie to R, and I wanted to plot a barplots with R and in such a way
that It will also show me position which I can plot on the bar line.

Here is my code that I am using to plot,


chromosome- c(40.2, 35.6, 36.1, 29.6, 31, 29.6, 31, 29.4, 28.2, 23, 23,

28.2)

barplot (chromosome, col=purple, xlab=Oryza sativa Chromosomes, border

= NA, space = 5, ylim = c(0,45))

I wanted to mark the position say on chromosome 1 (40.2) I need to mark 10.2
and on other also.
I also want to set the scale of y axis from 0,5,10,15,20,25,30,35,40,45 i.e
gap of 5 instead of 10.

please help me to solve my querygurus.



If I understand correctly, maybe you want something like this:

# save the x-locations of the bars in a vector bp;
# use that to put marks on the bars with points();
# omit the default y-axis with yaxt = n or, as Petr
# showed, with axes = FALSE;

 bp - barplot(chromosome, border = NA, space = 5,
   ylim = c(0, 45), yaxt = n)
 points(bp[1], 10.2, pch = 4, cex = 2)

# add the y-axis:
 axis(2, at = seq(0, 45, 5), las = 1)

#(you might want to add: box(bty = l)

Instead of points(), you could use segments() to place
horizontal marks.

  -Peter Ehlers



Thank you
Jeet



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 on the iPhone/iPad? Not so much....a GPL violation

2010-06-01 Thread Marc Schwartz
Hi all,

Thanks to an offlist e-mail from Thomas (Lumley), I have spent the past few 
days getting a bit more edumacated on additional restrictions on the 
opportunity for R to appear on the iPhone/iPad. These in fact go well beyond 
the GPL issue that I raised in my initial post, which in and of itself, is not 
trivial by any means. I now know, or at least think I know, more about these 
issues than I probably wanted, but I also want to present a better picture of 
the situation.

Note that I am not a lawyer and am not intending to represent my findings from 
a legal perspective. I am reporting them here using a common sense approach 
from my own reading of the relevant Apple iPhone SDK language, as well as being 
based upon specific examples and discussions that I located on the web.

So, in summary, here are the key issues. I will follow each with some 
additional details below, but note that all such restrictions would need to be 
removed or otherwise overcome, before R could in fact appear on these two 
platforms, at least through Apple approved means in the App Store.


1. Distribution of GPL covered applications is not permissible via the App 
Store due to the Apple Terms of Service language, which infringes upon rights 
granted under the GPL.

'Nuff said.




2. The use of FORTRAN is precluded (explicitly from SDK version 4.x forward)

Version 3.x of the iPhone SDK has the following language:

3.3.1   Applications may only use Documented APIs in the manner prescribed by 
Apple and must not use or call any private APIs.


Apple of course does not offer a FORTRAN compiler, as those who build R from 
source on OSX, as I do, are keenly aware. Thanks to Simon, we have one to use 
for OSX, but one is not officially available for the iPhone/iPad in the SDK. 

Note that there is an important distinction here. The ability to build R versus 
the ability to have the resultant application pass Apple's review to be able to 
appear in the App Store.

The above language has also been interpreted to apply to Java/Flash, precluding 
those environments from appearing on the iPhone/iPad.

However, the beta release of the 4.x version of the iPhone SDK has the 
following language in the same section:

3.3.1 — Applications may only use Documented APIs in the manner prescribed by 
Apple and must not use or call any private APIs. Applications must be 
originally written in Objective-C, C, C++, or JavaScript as executed by the 
iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may 
compile and directly link against the Documented APIs (e.g., Applications that 
link to Documented APIs through an intermediary translation or compatibility 
layer or tool are prohibited).


Thus, in fact, one can only use Objective-C, C, C++ or JavaScript to develop 
applications for the iPhone/iPad. No FORTRAN, upon which of course, R is 
dependent. The above language has also been interpreted to further reinforce 
restrictions specifically on Java/Flash.

 


3. The implementation of programming language interpreters, of which R is one, 
is precluded.

The following language appears in version 3.x of the iPhone SDK:

3.3.2   An Application may not itself install or launch other executable code 
by any means, including without limitation through the use of a plug-in 
architecture, calling other frameworks, other APIs or otherwise. No interpreted 
code may be downloaded or used in an Application except for code that is 
interpreted and run by Apple's Documented APIs and built-in interpreter(s).


The above language has been (pardon the pun) interpreted to restrict the 
implementation of programming language interpreters on these devices. Some 
sites I found have narrowly focused on the No interpreted code may be 
downloaded part of the language as an out of sorts. However, upon review, 
they seem to ignore the or used wording, which would seem to be independent 
of the action of downloading. If the language was and used, then one could 
envision the use of locally stored or entered code, but this is not the case. 
In either case, of course, R would not be one of Apple's built-in 
interpreters.

I found two interesting examples of how Apple has either approved or rejected 
applications that can be considered interpreters. It is not clear where Apple 
drew the line between these two, such that it might enable one to better 
differentiate the reasoning and therefore design an app that would pass muster 
with them. Thus, one complication may be Apple's lack of internal consistency 
in making decisions on allowing or disallowing apps in the App Store. 

The first is an application which was intended to be a BASIC interpreter on the 
iPhone and which was apparently rejected by Apple under the name BasicMatrix:

 http://smartcalc.coollittlethings.com/?p=3

After the author substantially restricted the functionality of the application 
to being an enhanced calculator under the name SmartCalc, Apple approved 
the application.


Re: [R] Plot multiple columns

2010-06-01 Thread Ben Bolker
Noah Silverman noah at smartmediacorp.com writes:

 
 I'm running a long MCMC chain that is generating samples for 22 variables.
 
 I have each run of the chain as a row in a matrix.

 So:  Chain[,1] is the column with all the samples for variable one. 
 Chain[,2] is the column with all the samples for variable 2, etc. 

  The previous 2 paragraphs seemed contradictory until I realized
that in the first paragraph you are using run to mean what I would
usually call a sample ...

 I'd like to fit all 22 on a single page to print a nice summary.  It is
 OK if the graphs are small, I just need to show the overall shape and
 convergence.

  How about for example

 x - matrix(runif(22000),ncol=22)
 library(coda)
 m - as.mcmc(x)
 xyplot(m)
 xyplot(m,layout=c(4,6))

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Mid-P value for a chi-squared test

2010-06-01 Thread Wilson, Andrew
Can anyone tell me how to calculate a mid-p value for a chi-squared test
in R?

Many thanks,

Andrew Wilson

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] storing output data from a loop that has varying row numbers

2010-06-01 Thread RCulloch

Hi All, 

I am trying to run a loop that will have varying numbers of rows with each
output.

Previously I have had the same number of rows so I would use (and I
appreciate that this will no doubt achieve some gasps as being thoroughly
inefficient!):

xdfrow-(0)
xdfrow1-(1:32)
xdfrow2-(33:64)
xdfrow3-(65:96)
xdfrow4-(97:128)
xdfrow5-(129:160)
xdfrow6-(161:192)
xdfrow7-(193:224)

and so on

xdf - matrix(999, nrow=1024, ncol=7)
xdf - as.data.frame(xdf)
NAM - c(NAME,ID2,DAY,BEH, B_FALSE, B_TRUE,TOTAL)
colnames(xdf)-NAM

I then use this matrix and then run the loop and assign the data to each of
the xdfrows just doing +1 on each loop. (If that makes sense? Not really
important, just trying to show that I do try and solve some of my own
problems, albeit perhaps not in the best manner!)

_

However, the data I'm working with now has a very varied number of rows
(0:2500) over a large data set and I can't work out how is best to do this.

So my loop would be:

for (i in 1:33){
SEL_DAY-seal_dist[seal_dist[,10]==i,]
print(paste(DAY, i, of 33)) 
for (s in 1:11){
SEL_HR-SEL_DAY[SEL_DAY[,5]==s,]
print(paste(HR, s, of 11))  
indx - subset(SEL_HR, SEL_HR$DIST == 0)
SEL_HR$TO_ID - indx$ID[match(SEL_HR$TO, indx$TO)]}
}

where i is day and s is the hr within the day, the loop works fine because
it prints as i expect it too. I have not given any info on the data because
I assume this is more of a method question and will be very straight forward
to most people on here!? But I am happy to post data if it is needed.

I assume I need to set up a matrix before the loop,

e.g. DIST_LOOP-matrix(NA,1000,ncol=11)

and then I should be able to put something before the first } that allows me
to add to the matrix, but everything I have tried doesn't work

e.g. DIST_LOOP[[i]]-SEL_HR 

Any help would be much appreciated,

Best wishes,

Ross





-- 
View this message in context: 
http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238396.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] storing output data from a loop that has varying row numbers

2010-06-01 Thread Ivan Calandra

Hi,

I might be a bit tired so that I don't understand everything but I'm a 
bit confused.


How would you like your DIST_LOOP matrix to look like?
What do you intend to use xdfrow1...xdfrow7? As I said, I might not be 
at the best of my shape!
A sample dataset would really help to see what you have and what you 
want to do (maybe using dput).


But maybe just:
DIST_LOOP[i, ]-SEL_HR
would be enough, if you want to fill rows, as I understood.

HTH,
Ivan



Le 6/1/2010 13:51, RCulloch a écrit :

Hi All,

I am trying to run a loop that will have varying numbers of rows with each
output.

Previously I have had the same number of rows so I would use (and I
appreciate that this will no doubt achieve some gasps as being thoroughly
inefficient!):

xdfrow-(0)
xdfrow1-(1:32)
xdfrow2-(33:64)
xdfrow3-(65:96)
xdfrow4-(97:128)
xdfrow5-(129:160)
xdfrow6-(161:192)
xdfrow7-(193:224)

and so on

xdf- matrix(999, nrow=1024, ncol=7)
xdf- as.data.frame(xdf)
NAM- c(NAME,ID2,DAY,BEH, B_FALSE, B_TRUE,TOTAL)
colnames(xdf)-NAM

I then use this matrix and then run the loop and assign the data to each of
the xdfrows just doing +1 on each loop. (If that makes sense? Not really
important, just trying to show that I do try and solve some of my own
problems, albeit perhaps not in the best manner!)

_

However, the data I'm working with now has a very varied number of rows
(0:2500) over a large data set and I can't work out how is best to do this.

So my loop would be:

for (i in 1:33){
SEL_DAY-seal_dist[seal_dist[,10]==i,]
print(paste(DAY, i, of 33)) 
for (s in 1:11){
SEL_HR-SEL_DAY[SEL_DAY[,5]==s,]
print(paste(HR, s, of 11))  
indx- subset(SEL_HR, SEL_HR$DIST == 0)
SEL_HR$TO_ID- indx$ID[match(SEL_HR$TO, indx$TO)]}
}

where i is day and s is the hr within the day, the loop works fine because
it prints as i expect it too. I have not given any info on the data because
I assume this is more of a method question and will be very straight forward
to most people on here!? But I am happy to post data if it is needed.

I assume I need to set up a matrix before the loop,

e.g. DIST_LOOP-matrix(NA,1000,ncol=11)

and then I should be able to put something before the first } that allows me
to add to the matrix, but everything I have tried doesn't work

e.g. DIST_LOOP[[i]]-SEL_HR

Any help would be much appreciated,

Best wishes,

Ross





   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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

2010-06-01 Thread JLucke
The closest explanation of the term loess I can find is in  Local 
regression models by Cleveland, W. S.; Grosse, E.  Shyu, W. M. (Chapter 
8 of  Statistical models in S (1992) by Chambers, J. M.  Hastie, T. J.)

... local regression models is called loess, which is short for local 
regression, and was chosen as the name since a loess is a deposit of fine 
clay or silt ..., and is a surface of sorts. (p. 314).





Tal Galili tal.gal...@gmail.com 
Sent by: r-help-boun...@r-project.org
05/31/2010 12:39 PM

To
Peter Neuhaus pneuh...@pneuhaus.de
cc
r-help@r-project.org
Subject
Re: [R] What does LOESS stand for?






Hi Peter,

If this article is correct:
http://www.r-bloggers.com/abbreviations-of-r-commands-explained-250-r-abbreviations/

Loess stands for:
[LO]cally [E]stimated [S]catterplot [S]moothing


Best,
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 Mon, May 31, 2010 at 12:33 PM, Peter Neuhaus 
pneuh...@pneuhaus.dewrote:

 Dear R-community,

 maybe someone can help me with this:

 I've been using the loess() smoother for quite a while now, and for
 the matter of documentation I'd like to resolve the acronym LOESS.
 Unfortunately there's no explanation in the help file, and I didn't
 get anything convincing from google either.

 I know that the predecessor LOWESS stands for Locally Weighted
 Scatterplot Smoothing. But what does LOESS stand for, specifically?
 Locally Weighted Exponential Scatterplot Smoothing? As far as
 I understand LOESS is still a local polynomial regression, so that
 would probably make no sense.

 Any help appreciated!

 Thanks in advance,

 Peter


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


[[alternative HTML version deleted]]

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


[R] R-help spam detection; please help the moderators

2010-06-01 Thread Martin Maechler
Dear readers of R-help

as most of you will *not* be aware, R-help has continued to work the
way it does, only thanks to a dozen of volunteers,
see https://stat.ethz.ch/mailman/listinfo/r-help .

The volunteers manually moderate e-mails that look like spam (and
sometimes are and sometimes are not).
While much more than 90% of the spam is filtered out long before
a human sees it, with the increasing sophistication of spammers,
manual intervention has deemed to be necessary and served the
community very well.

OTOH, in recent weeks, the amount of work for the volunteers has
increased, mainly because an increasingly number of non-spam postings are
erronously tagged as possibly spam.
We have discussed about this and done some analysis and found
that most of these message that produce a considerable amount of
extra work share two properties :
 1) they are posted via Nabble  {which *always* attaches a small
 pro-Nabble spam at the end of the message}
 2) the e-mail address of the sender is from a freemail
provider, quite often 'at gmail dot com', and often the part
*before* the '@' (at-sign) ends with digits.

We hereby ask those among you who use a freemail account to
please no longer post via nabble.

Thank you for your support of R-help, *the* community mailing
list of the R project since even before that project existed
formally, namely since 1997-04-01,
today 13 years and two months.

Martin Maechler, ETH Zurich
(and R-help creator and principal manager)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Issue with assigning text to matrix

2010-06-01 Thread Jessica Queree
My issue relates to adding text to a matrix and finding that the text is
converted to a number.



This is the section of code I'm having trouble with:



# First, I load in a list of names from a .csv file to 'names'

names - read.csv(file(Names.csv))



# Then I define a matrix which will be populated with various test
statistics, with several rows for each entry in names



testOutput -matrix(nrow = 200, ncol = 5)

for (i in 1:nrow(names)){



testOutput[i,1] - names[i,1]

testOutput[i,2] - names[i,2]



# test statistics code here



}





If I look at names[,1], I get the following:



names[,1]

 [1] EQ_Level_UK   EQ_Level_EUR  EQ_Level_US   EQ_Level_Far East

 [5] IR_PC 1_UKIR_PC 2_UKIR_PC 3_UKSwap_PC 1_UK

 [9] Swap_PC 2_UK  Swap_PC 3_UK  FX_Level_EUR  FX_Level_US

[13] FX_Level_Far East Infl_PC 1_UK  Infl_PC 2_UK  Infl_PC 3_UK

[17] Prop_Level_UK CreditAAA_PC 1_UK CreditAAA_PC 2_UK CreditAAA_PC 3_UK

[21] CreditAA_PC 1_UK  CreditAA_PC 2_UK  CreditAA_PC 3_UK  CreditA_PC 1_UK

[25] CreditA_PC 2_UK   CreditA_PC 3_UK   CreditBBB_PC 1_UK CreditBBB_PC 2_UK

[29] CreditBBB_PC 3_UK

29 Levels: CreditA_PC 1_UK CreditA_PC 2_UK CreditA_PC 3_UK ... Swap_PC 3_UK



But if I look at testOutput[,1], I get:



testOutput[,1]

  [1] 15 13 16 14 23 24 25 27 28 29 17 19 18 20
21

 [16] 22 26 7  8  9  4  5  6  1  2  3  10 11 12
17

 [31] NA   NA   19 18 NA   NA   NA   20 NA   NA   21 NA   NA   22
NA

 [46] NA   26 NA   NA   7  NA   NA   8  NA   NA   9  NA   NA   4
NA

 [61] NA   5  NA   NA   6  NA   NA   1  NA   NA   2  NA   NA   3
NA

 [76] NA   10 NA   NA   11 NA   NA   12 NA   NA   NA   NA   NA   NA
NA

 [91] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA

[106] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA

[121] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA

[136] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA

[151] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA

[166] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA

[181] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA

[196] NA   NA   NA   NA   NA



That is, the names are now converted to numbers. I think this might have
something to do with the way I've defined the testOutput matrix, but haven't
been able to find any information about how to fix it. Can anyone help?



Many thanks.

[[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] storing output data from a loop that has varying row numbers

2010-06-01 Thread RCulloch

Hi Ivan, 

Thanks for your help, your initial suggestion did not work, but that is no
doubt down to my lack of making sense! 

Here is a short example of my dataset. Basically the loop is set up to match
the ID with the TO column based on DIST = 0. So A1 = 2, A1.1 =1, A2 = 4,
A2.1 = 3. That is fine for HR 9, but for HR 10 the numbers no longer match
those IDs so I need to loop the data and store each loop - if that makes
sense. 


  FROM TO DIST  ID HR DD MM YY ANIMAL DAY
1 1  1  2.63981'A1'  9 30  9  7  1   1
2 1  2  0.0'A1'  9 30  9  7  1   1
3 1  3  6.95836'A1'  9 30  9  7  1   1
4 1  4  8.63809'A1'  9 30  9  7  1   1
5 1  1  0.0  'A1.1'  9 30  9  7  7   1
6 1  2  2.63981  'A1.1'  9 30  9  7  7   1
7 1  3  8.03071  'A1.1'  9 30  9  7  7   1
8 1  4  8.90896  'A1.1'  9 30  9  7  7   1
9 1  1  8.90896'A2'  9 30  9  7  1   1
101  2  8.63809'A2'  9 30  9  7  1   1
111  3  2.85602'A2'  9 30  9  7  1   1
121  4  0.0'A2'  9 30  9  7  1   1
131  1  8.03071  'A2.1'  9 30  9  7  7   1
141  2  6.95836  'A2.1'  9 30  9  7  7   1
151  3  0.0  'A2.1'  9 30  9  7  7   1
161  4  2.85602   A2.1'  9 30  9  7  7   1
171  1  3.53695'A1' 10 30  9  7  1   1
181  2  4.32457'A1' 10 30  9  7  1   1
191  3  0.0'A1' 10 30  9  7  1   1
201  4  8.85851'A1' 10 30  9  7  1   1
211  5 12.09194'A1' 10 30  9  7  1   1
221  1  7.44743  'A1.1' 10 30  9  7  7   1
231  2  0.0  'A1.1' 10 30  9  7  7   1
241  3  4.32457  'A1.1' 10 30  9  7  7   1
251  4 13.16728  'A1.1' 10 30  9  7  7   1
261  5 16.34761  'A1.1' 10 30  9  7  7   1
271  1  6.13176'A2' 10 30  9  7  1   1
281  2 13.16728'A2' 10 30  9  7  1   1
291  3  8.85851'A2' 10 30  9  7  1   1
301  4  0.0'A2' 10 30  9  7  1   1
311  5  3.40726'A2' 10 30  9  7  1   1
321  1  9.03345  'A2.1' 10 30  9  7  7   1
331  2 16.34761  'A2.1' 10 30  9  7  7   1
341  3 12.09194  'A2.1' 10 30  9  7  7   1
351  4  3.40726  'A2.1' 10 30  9  7  7   1
361  5  0.0  'A2.1' 10 30  9  7  7   1
371  1  0.0 'MALE1' 10 30  9  7 12   1
381  2  7.44743 'MALE1' 10 30  9  7 12   1
391  3  3.53695 'MALE1' 10 30  9  7 12   1
401  4  6.13176 'MALE1' 10 30  9  7 12   1
411  5  9.03345 'MALE1' 10 30  9  7 12   1


So the loop is:

DIST_LOOP-matrix(NA,NA,ncol=11)

for (i in 1:33){
SEL_DAY-seal_dist[seal_dist[,10]==i,]
SEL_DAY[i]=dist[i]
print(paste(DAY, i, of 33)) 
for (s in 1:11){
SEL_HR-SEL_DAY[SEL_DAY[,5]==s,]
print(paste(HR, s, of 11))  
indx - subset(SEL_HR, SEL_HR$DIST == 0)
SEL_HR$TO_ID - indx$ID[match(SEL_HR$TO, indx$TO)]
DIST_LOOP[i,]-SEL_HR
}
}   

But storing the data in the DIST_LOOP matrix doesn't work, I am just told in
another post that a list might be better than a matrix? 

I hope this makes more sense!? 

Many thanks,

Ross
-- 
View this message in context: 
http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238483.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] discriminant analysis

2010-06-01 Thread suman dhara
Sir,
Can you suggest  some function for discriminant analysis for Binary response
having continuous as well as categorical regressors.



Thanks,
Suman Dhara

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

2010-06-01 Thread mhalsham

Can any one help it will be very kind, loop statements
I have this table and some more records, I want to reshape it

V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
TP53 Dis1 Dis2 Dis3 Dis4 Dis5 Dis6
DCI New1 New2 New3 New4
FDI Hi2 H3 H4
GHD I1 I3 I4 I5 I6 I7 I8

I want my new table or matrix to be some thing like this

V1 V2 V3
Tp53 Dis1 Dis2
Tp53 Dis1 Dis3
Tp53 Dis1 Dis4
Tp53 Dis1 Dis5
Tp53 Dis1 Dis6
Tp53 Dis2 Dis3
Tp53 Dis2 Dis4
Tp53 Dis2 Dis5
Tp53 Dis2 Dis6
Tp53 Dis3 Dis4
Tp53 Dis3 Dis5
Tp53 Dis3 Dis6
Tp53 Dis4 Dis5
Tp53 Dis4 Dis6
Tp53 Dis5 Dis6
DCI New1 New2
DCI New1 New3
DCI New1 New4
DCI New2 New3
DCI New2 New4
DCI New3 New4
   

And so on for the rest of the table. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/loop-tp2238209p2238209.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] Issue with assigning text to matrix

2010-06-01 Thread Sarah Goslee
On Tue, Jun 1, 2010 at 5:04 AM, Jessica Queree
j.j.que...@googlemail.com wrote:
 My issue relates to adding text to a matrix and finding that the text is
 converted to a number.


A matrix can only hold one type of data. Since you started with character,
that's what you get.

A dataframe can hold different types of data, both character and numeric.
If you convert your matrix to a dataframe with dataf.frame() it can hold
your output in the manner you expect.

testOutput - data.frame(matrix(nrow = 200, ncol = 5))

Sarah

 This is the section of code I'm having trouble with:



 # First, I load in a list of names from a .csv file to 'names'

 names - read.csv(file(Names.csv))



 # Then I define a matrix which will be populated with various test
 statistics, with several rows for each entry in names



 testOutput -matrix(nrow = 200, ncol = 5)

 for (i in 1:nrow(names)){



            testOutput[i,1] - names[i,1]

            testOutput[i,2] - names[i,2]



            # test statistics code here



 }


 That is, the names are now converted to numbers. I think this might have
 something to do with the way I've defined the testOutput matrix, but haven't
 been able to find any information about how to fix it. Can anyone help?



 Many thanks.




-- 
Sarah Goslee
http://www.functionaldiversity.org

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


[R] save image to folder

2010-06-01 Thread thoeb

Hello,

is there an equivalent to write.csv for saving images to a folder? E.g. if I
have a histogram or piechart I would need to write a command that saves the
resulting image as png or jpg into a certain folder (working directory).

Thanks
-- 
View this message in context: 
http://r.789695.n4.nabble.com/save-image-to-folder-tp2238249p2238249.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] strsplit

2010-06-01 Thread Joël Baumann

Hello!

I have the following problem:

I have a file in R that has in the first row three informations in one 
row that I would like to in three different rows.


The first row looks like this:

GenusA_SpeciesC_Tree
GenusA_SpeciesF_Tree
GenusB_SpeciesA_Shrub
...

I tried with strsplit and and substring but I don't get any solution. I 
know I can do this in Excel, but in R would be much nicer!


Thanks for helping me.

Joël Baumann

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


[R] [R-pkgs] Yet Another Package for Time Data

2010-06-01 Thread Charlotte Maia
Hi fellow R developers/users,

I've recently revised a package called rtv, and now consider it
reasonably stable.

Description: A package for conveniently representing, manipulating and
visualising time data. Here, time is regarded as a random variable,
and objects are used to represent realisations of that random
variable. This is particularly useful for change points, irregular
timeseries and failure events. There's a strong emphasis on continuous
representations of time, with user-specified origins and units.

http://cran.r-project.org/web/packages/rtv/index.html

The package contains classes notably similar to the POSIXt classes.
However, the classes are based on a somewhat different philosophy.
The major advantage of the package, is that crtv objects (similar to
POSIXct objects) allow user-specified origins and units.
It also allows time events to be represented as fractional months or
fractional years.

More info in the package vignette.

Bug reports and feature requests welcome.


kind regards
-- 
Charlotte Maia
http://sites.google.com/site/maiagx

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] storing output data from a loop that has varying row numbers

2010-06-01 Thread Joris Meys
There's something very unlogic in your code. You have the whole time the
same datafra

On Tue, Jun 1, 2010 at 1:51 PM, RCulloch ross.cull...@dur.ac.uk wrote:


 Hi All,

 I am trying to run a loop that will have varying numbers of rows with each
 output.

 Previously I have had the same number of rows so I would use (and I
 appreciate that this will no doubt achieve some gasps as being thoroughly
 inefficient!):

 xdfrow-(0)
 xdfrow1-(1:32)
 xdfrow2-(33:64)
 xdfrow3-(65:96)
 xdfrow4-(97:128)
 xdfrow5-(129:160)
 xdfrow6-(161:192)
 xdfrow7-(193:224)

 and so on

 xdf - matrix(999, nrow=1024, ncol=7)
 xdf - as.data.frame(xdf)
 NAM - c(NAME,ID2,DAY,BEH, B_FALSE, B_TRUE,TOTAL)
 colnames(xdf)-NAM

 I then use this matrix and then run the loop and assign the data to each of
 the xdfrows just doing +1 on each loop. (If that makes sense? Not really
 important, just trying to show that I do try and solve some of my own
 problems, albeit perhaps not in the best manner!)

 _

 However, the data I'm working with now has a very varied number of rows
 (0:2500) over a large data set and I can't work out how is best to do this.

 So my loop would be:

 for (i in 1:33){
SEL_DAY-seal_dist[seal_dist[,10]==i,]
print(paste(DAY, i, of 33))
for (s in 1:11){
SEL_HR-SEL_DAY[SEL_DAY[,5]==s,]
print(paste(HR, s, of 11))
indx - subset(SEL_HR, SEL_HR$DIST == 0)
SEL_HR$TO_ID - indx$ID[match(SEL_HR$TO, indx$TO)]}
 }

 where i is day and s is the hr within the day, the loop works fine because
 it prints as i expect it too. I have not given any info on the data because
 I assume this is more of a method question and will be very straight
 forward
 to most people on here!? But I am happy to post data if it is needed.

 I assume I need to set up a matrix before the loop,

 e.g. DIST_LOOP-matrix(NA,1000,ncol=11)

 and then I should be able to put something before the first } that allows
 me
 to add to the matrix, but everything I have tried doesn't work

 e.g. DIST_LOOP[[i]]-SEL_HR

 Any help would be much appreciated,

 Best wishes,

 Ross





 --
 View this message in context:
 http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238396.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.




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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] save image to folder

2010-06-01 Thread Sarah Goslee
You might consider starting your search with
?png

Sarah

On Tue, Jun 1, 2010 at 5:34 AM, thoeb t.hoebin...@gmail.com wrote:

 Hello,

 is there an equivalent to write.csv for saving images to a folder? E.g. if I
 have a histogram or piechart I would need to write a command that saves the
 resulting image as png or jpg into a certain folder (working directory).


-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] strsplit

2010-06-01 Thread Sarah Goslee
How about this:

testdata - data.frame(sp = c(GenusA_SpeciesC_Tree,
GenusA_SpeciesF_Tree, GenusB_SpeciesA_Shrub),
stringsAsFactors=FALSE)

# for one
unlist(strsplit(testdata[1,1], split=_))

# for all of them
do.call(rbind, sapply(testdata[,1], strsplit, split=_))


Sarah

On Tue, Jun 1, 2010 at 5:45 AM, Joël Baumann joelbaum...@gmx.net wrote:
 Hello!

 I have the following problem:

 I have a file in R that has in the first row three informations in one row
 that I would like to in three different rows.

 The first row looks like this:

 GenusA_SpeciesC_Tree
 GenusA_SpeciesF_Tree
 GenusB_SpeciesA_Shrub
 ...

 I tried with strsplit and and substring but I don't get any solution. I know
 I can do this in Excel, but in R would be much nicer!



-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] strsplit

2010-06-01 Thread Ivan Calandra

Hi,

I don't know if it would help you since your goal is not really clear to 
me, but here are some thoughts:


 x - c(GenusA_SpeciesC_Tree, GenusA_SpeciesF_Tree, 
GenusB_SpeciesA_Shrub)

 test - strsplit(x, _)
 test
[[1]]
[1] GenusA   SpeciesC Tree
[[2]]
[1] GenusA   SpeciesF Tree
[[3]]
[1] GenusB   SpeciesA Shrub
 lapply(test, [, 1)
[[1]]
[1] GenusA
[[2]]
[1] GenusA
[[3]]
[1] GenusB
 df - data.frame(Genus=unlist(lapply(test,[,1)), 
Species=unlist(lapply(test,[,2)), Veget=unlist(lapply(test,[,3)))

 df
   Genus  Species Veget
1 GenusA SpeciesC  Tree
2 GenusA SpeciesF  Tree
3 GenusB SpeciesA Shrub

There are probably better and nicer ways to do each step.

HTH,
Ivan


Le 6/1/2010 11:45, Joël Baumann a écrit :

Hello!

I have the following problem:

I have a file in R that has in the first row three informations in one 
row that I would like to in three different rows.


The first row looks like this:

GenusA_SpeciesC_Tree
GenusA_SpeciesF_Tree
GenusB_SpeciesA_Shrub
...

I tried with strsplit and and substring but I don't get any solution. 
I know I can do this in Excel, but in R would be much nicer!


Thanks for helping me.

Joël Baumann

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

and provide commented, minimal, self-contained, reproducible code.



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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

2010-06-01 Thread Rafael Björk
This might not be the most elegant way of doing it, but it should probably
work, given that data is always separated by a _.

string.1-strsplit(c(GenusA_SpeciesC_Tree,GenusA_SpeciesF_Tree,
GenusB_SpeciesA_Shrub),_)

matrix(unlist(string.1),ncol=3,byrow=TRUE)

2010/6/1 Joël Baumann joelbaum...@gmx.net

 Hello!

 I have the following problem:

 I have a file in R that has in the first row three informations in one row
 that I would like to in three different rows.

 The first row looks like this:

 GenusA_SpeciesC_Tree
 GenusA_SpeciesF_Tree
 GenusB_SpeciesA_Shrub
 ...

 I tried with strsplit and and substring but I don't get any solution. I
 know I can do this in Excel, but in R would be much nicer!

 Thanks for helping me.

 Joël Baumann

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] using R and for simulating a wireless network

2010-06-01 Thread amir
Hi,

I want to simulate a simple wireless network in R.
There is a source and destination and source sends some data packets to
the destination and some routing table and so on.
Does anyone have any idea and knowledge about this or are there any
packages for this.
The thing that I am going to do is wiring a simple simulator using R
that a node sends some packet and using some table to reach the
destination (Like Ns-2 but with less details)

Best Regards,
Amir

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] any doc to understand arima state space model?

2010-06-01 Thread shakira M
I am trying to understand R arima function. Any pointers would be
appreciated.

Thank you,
Shakira.

[[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] storing output data from a loop that has varying row numbers

2010-06-01 Thread Joris Meys
could you just give us the output of dput() for the data you copied in the
mail?

eg dput(seal_dist[,1:100])

and an example of how you want your output. I guess I get what you want to
do, but it's not what your code is doing. And it will be difficult to put
that in a matrix, as you have different labels and different numbers of
TO-levels for different days and HR values.

Cheers

On Tue, Jun 1, 2010 at 3:32 PM, RCulloch ross.cull...@dur.ac.uk wrote:


 Hi Ivan,

 Thanks for your help, your initial suggestion did not work, but that is no
 doubt down to my lack of making sense!

 Here is a short example of my dataset. Basically the loop is set up to
 match
 the ID with the TO column based on DIST = 0. So A1 = 2, A1.1 =1, A2 = 4,
 A2.1 = 3. That is fine for HR 9, but for HR 10 the numbers no longer match
 those IDs so I need to loop the data and store each loop - if that makes
 sense.


  FROM TO DIST  ID HR DD MM YY ANIMAL DAY
 1 1  1  2.63981'A1'  9 30  9  7  1   1
 2 1  2  0.0'A1'  9 30  9  7  1   1
 3 1  3  6.95836'A1'  9 30  9  7  1   1
 4 1  4  8.63809'A1'  9 30  9  7  1   1
 5 1  1  0.0  'A1.1'  9 30  9  7  7   1
 6 1  2  2.63981  'A1.1'  9 30  9  7  7   1
 7 1  3  8.03071  'A1.1'  9 30  9  7  7   1
 8 1  4  8.90896  'A1.1'  9 30  9  7  7   1
 9 1  1  8.90896'A2'  9 30  9  7  1   1
 101  2  8.63809'A2'  9 30  9  7  1   1
 111  3  2.85602'A2'  9 30  9  7  1   1
 121  4  0.0'A2'  9 30  9  7  1   1
 131  1  8.03071  'A2.1'  9 30  9  7  7   1
 141  2  6.95836  'A2.1'  9 30  9  7  7   1
 151  3  0.0  'A2.1'  9 30  9  7  7   1
 161  4  2.85602   A2.1'  9 30  9  7  7   1
 171  1  3.53695'A1' 10 30  9  7  1   1
 181  2  4.32457'A1' 10 30  9  7  1   1
 191  3  0.0'A1' 10 30  9  7  1   1
 201  4  8.85851'A1' 10 30  9  7  1   1
 211  5 12.09194'A1' 10 30  9  7  1   1
 221  1  7.44743  'A1.1' 10 30  9  7  7   1
 231  2  0.0  'A1.1' 10 30  9  7  7   1
 241  3  4.32457  'A1.1' 10 30  9  7  7   1
 251  4 13.16728  'A1.1' 10 30  9  7  7   1
 261  5 16.34761  'A1.1' 10 30  9  7  7   1
 271  1  6.13176'A2' 10 30  9  7  1   1
 281  2 13.16728'A2' 10 30  9  7  1   1
 291  3  8.85851'A2' 10 30  9  7  1   1
 301  4  0.0'A2' 10 30  9  7  1   1
 311  5  3.40726'A2' 10 30  9  7  1   1
 321  1  9.03345  'A2.1' 10 30  9  7  7   1
 331  2 16.34761  'A2.1' 10 30  9  7  7   1
 341  3 12.09194  'A2.1' 10 30  9  7  7   1
 351  4  3.40726  'A2.1' 10 30  9  7  7   1
 361  5  0.0  'A2.1' 10 30  9  7  7   1
 371  1  0.0 'MALE1' 10 30  9  7 12   1
 381  2  7.44743 'MALE1' 10 30  9  7 12   1
 391  3  3.53695 'MALE1' 10 30  9  7 12   1
 401  4  6.13176 'MALE1' 10 30  9  7 12   1
 411  5  9.03345 'MALE1' 10 30  9  7 12   1


 So the loop is:

 DIST_LOOP-matrix(NA,NA,ncol=11)

 for (i in 1:33){
SEL_DAY-seal_dist[seal_dist[,10]==i,]
 SEL_DAY[i]=dist[i]
 print(paste(DAY, i, of 33))
for (s in 1:11){
SEL_HR-SEL_DAY[SEL_DAY[,5]==s,]
print(paste(HR, s, of 11))
indx - subset(SEL_HR, SEL_HR$DIST == 0)
SEL_HR$TO_ID - indx$ID[match(SEL_HR$TO, indx$TO)]
 DIST_LOOP[i,]-SEL_HR
}
}

 But storing the data in the DIST_LOOP matrix doesn't work, I am just told
 in
 another post that a list might be better than a matrix?

 I hope this makes more sense!?

 Many thanks,

 Ross
 --
 View this message in context:
 http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238483.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.




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

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

2010-06-01 Thread Ista Zahn
Another option is to use the colsplit() function (in the reshape package):

testdata - data.frame(sp = c(GenusA_SpeciesC_Tree,
GenusA_SpeciesF_Tree, GenusB_SpeciesA_Shrub),
stringsAsFactors=FALSE)

library(reshape)
testdata - cbind(testdata, colsplit(testdata$sp, split=_, names=c(Genus, 
Species, Type)))

-Ista

On Tuesday 01 June 2010 10:10:22 am Ivan Calandra wrote:
 Hi,
 
 I don't know if it would help you since your goal is not really clear to
 
 me, but here are some thoughts:
   x - c(GenusA_SpeciesC_Tree, GenusA_SpeciesF_Tree,
 
 GenusB_SpeciesA_Shrub)
 
   test - strsplit(x, _)
   test
 
 [[1]]
 [1] GenusA   SpeciesC Tree
 [[2]]
 [1] GenusA   SpeciesF Tree
 [[3]]
 [1] GenusB   SpeciesA Shrub
 
   lapply(test, [, 1)
 
 [[1]]
 [1] GenusA
 [[2]]
 [1] GenusA
 [[3]]
 [1] GenusB
 
   df - data.frame(Genus=unlist(lapply(test,[,1)),
 
 Species=unlist(lapply(test,[,2)), Veget=unlist(lapply(test,[,3)))
 
   df
 
 Genus  Species Veget
 1 GenusA SpeciesC  Tree
 2 GenusA SpeciesF  Tree
 3 GenusB SpeciesA Shrub
 
 There are probably better and nicer ways to do each step.
 
 HTH,
 Ivan
 
 Le 6/1/2010 11:45, Joël Baumann a écrit :
  Hello!
  
  I have the following problem:
  
  I have a file in R that has in the first row three informations in one
  row that I would like to in three different rows.
  
  The first row looks like this:
  
  GenusA_SpeciesC_Tree
  GenusA_SpeciesF_Tree
  GenusB_SpeciesA_Shrub
  ...
  
  I tried with strsplit and and substring but I don't get any solution.
  I know I can do this in Excel, but in R would be much nicer!
  
  Thanks for helping me.
  
  Joël Baumann
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] storing output data from a loop that has varying row numbers

2010-06-01 Thread Ivan Calandra

Hi Ross,

I'm still really confused about your question.

Let me ask you some specific questions (maybe someone more experienced 
would understand at once, but I'm no expert; I hope I can still help 
you! In any case, I would like to understand for myself ;) )


- is seal_dist the name of your data.frame?
- what do you want to do with
SEL_DAY[i]=dist[i]
? What is dist? If I understand well, you want to replace the values 
in FROM (then TO, then DIST...) with the values from the same column 
number in dist?
- Since I still haven't understood your goal completely, I still don't 
understand why you add the column TO_ID to SEL_HR.


- In any case, a matrix cannot work because you want to store data of 
different classes in DIST_LOOP (ID is character and the others are 
numeric). You can either use a data.frame (if you really want to have 
the table-like structure, which is a list) or a list.


- Moreover, the output from dput(your data) would really help to see 
what you have!


HTH,
Ivan


Le 6/1/2010 15:32, RCulloch a écrit :

Hi Ivan,

Thanks for your help, your initial suggestion did not work, but that is no
doubt down to my lack of making sense!

Here is a short example of my dataset. Basically the loop is set up to match
the ID with the TO column based on DIST = 0. So A1 = 2, A1.1 =1, A2 = 4,
A2.1 = 3. That is fine for HR 9, but for HR 10 the numbers no longer match
those IDs so I need to loop the data and store each loop - if that makes
sense.


   FROM TO DIST  ID HR DD MM YY ANIMAL DAY
1 1  1  2.63981'A1'  9 30  9  7  1   1
2 1  2  0.0'A1'  9 30  9  7  1   1
3 1  3  6.95836'A1'  9 30  9  7  1   1
4 1  4  8.63809'A1'  9 30  9  7  1   1
5 1  1  0.0  'A1.1'  9 30  9  7  7   1
6 1  2  2.63981  'A1.1'  9 30  9  7  7   1
7 1  3  8.03071  'A1.1'  9 30  9  7  7   1
8 1  4  8.90896  'A1.1'  9 30  9  7  7   1
9 1  1  8.90896'A2'  9 30  9  7  1   1
101  2  8.63809'A2'  9 30  9  7  1   1
111  3  2.85602'A2'  9 30  9  7  1   1
121  4  0.0'A2'  9 30  9  7  1   1
131  1  8.03071  'A2.1'  9 30  9  7  7   1
141  2  6.95836  'A2.1'  9 30  9  7  7   1
151  3  0.0  'A2.1'  9 30  9  7  7   1
161  4  2.85602   A2.1'  9 30  9  7  7   1
171  1  3.53695'A1' 10 30  9  7  1   1
181  2  4.32457'A1' 10 30  9  7  1   1
191  3  0.0'A1' 10 30  9  7  1   1
201  4  8.85851'A1' 10 30  9  7  1   1
211  5 12.09194'A1' 10 30  9  7  1   1
221  1  7.44743  'A1.1' 10 30  9  7  7   1
231  2  0.0  'A1.1' 10 30  9  7  7   1
241  3  4.32457  'A1.1' 10 30  9  7  7   1
251  4 13.16728  'A1.1' 10 30  9  7  7   1
261  5 16.34761  'A1.1' 10 30  9  7  7   1
271  1  6.13176'A2' 10 30  9  7  1   1
281  2 13.16728'A2' 10 30  9  7  1   1
291  3  8.85851'A2' 10 30  9  7  1   1
301  4  0.0'A2' 10 30  9  7  1   1
311  5  3.40726'A2' 10 30  9  7  1   1
321  1  9.03345  'A2.1' 10 30  9  7  7   1
331  2 16.34761  'A2.1' 10 30  9  7  7   1
341  3 12.09194  'A2.1' 10 30  9  7  7   1
351  4  3.40726  'A2.1' 10 30  9  7  7   1
361  5  0.0  'A2.1' 10 30  9  7  7   1
371  1  0.0 'MALE1' 10 30  9  7 12   1
381  2  7.44743 'MALE1' 10 30  9  7 12   1
391  3  3.53695 'MALE1' 10 30  9  7 12   1
401  4  6.13176 'MALE1' 10 30  9  7 12   1
411  5  9.03345 'MALE1' 10 30  9  7 12   1


So the loop is:

DIST_LOOP-matrix(NA,NA,ncol=11)

for (i in 1:33){
SEL_DAY-seal_dist[seal_dist[,10]==i,]
SEL_DAY[i]=dist[i]
print(paste(DAY, i, of 33)) 
for (s in 1:11){
SEL_HR-SEL_DAY[SEL_DAY[,5]==s,]
print(paste(HR, s, of 11))  
indx- subset(SEL_HR, SEL_HR$DIST == 0)
SEL_HR$TO_ID- indx$ID[match(SEL_HR$TO, indx$TO)]
DIST_LOOP[i,]-SEL_HR
}
}   

But storing the data in the DIST_LOOP matrix doesn't work, I am just told in
another post that a list might be better than a matrix?

I hope this makes more sense!?

Many thanks,

Ross
   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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

2010-06-01 Thread Stella Pachidi
Dear R experts,

I would really appreciate if you had an idea on how to use more
efficiently the aggregate method:

More specifically, I would like to calculate the mean of certain
values on a data frame,  grouped by various attributes, and then
create a new column in the data frame that will have the corresponding
mean for every row. I attach part of my code:

matchMean - function(ind,dataTable,aggrTable)
{
index - which((aggrTable[,1]==dataTable[[Attr1]][ind]) 
(aggrTable[,2]==dataTable[[Attr2]][ind]))
as.numeric(aggrTable[index,3])
}

avgDur - aggregate(ap.dat[[Dur]], by = list(ap.dat[[Attr1]],
ap.dat[[Attr2]]), FUN=mean)
meanDur - sapply((1:length(ap.dat[,1])), FUN=matchMean, ap.dat, avgDur)
ap.dat - cbind (ap.dat, meanDur)

As I deal with very large dataset, it takes long time to run my
matching function, so if you had an idea on how to automate more this
matching process I would be really grateful.

Thank you very much in advance!

Kind regards,
Stella



--
Stella Pachidi
Master in Business Informatics student
Utrecht University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] storing output data from a loop that has varying row numbers

2010-06-01 Thread Joris Meys
Is this what you're looking for?

seal_list - split(seal_dist,sel)

out - lapply(seal_list,function(x){
  indx - subset(x, x$DIST == 0)
  x$TO_ID - indx$ID[match(x$TO, indx$TO)]
  return(x)
})

output - unsplit(out,sel)

Cheers
Joris

On Tue, Jun 1, 2010 at 3:32 PM, RCulloch ross.cull...@dur.ac.uk wrote:


 Hi Ivan,

 Thanks for your help, your initial suggestion did not work, but that is no
 doubt down to my lack of making sense!

 Here is a short example of my dataset. Basically the loop is set up to
 match
 the ID with the TO column based on DIST = 0. So A1 = 2, A1.1 =1, A2 = 4,
 A2.1 = 3. That is fine for HR 9, but for HR 10 the numbers no longer match
 those IDs so I need to loop the data and store each loop - if that makes
 sense.


  FROM TO DIST  ID HR DD MM YY ANIMAL DAY
 1 1  1  2.63981'A1'  9 30  9  7  1   1
 2 1  2  0.0'A1'  9 30  9  7  1   1
 3 1  3  6.95836'A1'  9 30  9  7  1   1
 4 1  4  8.63809'A1'  9 30  9  7  1   1
 5 1  1  0.0  'A1.1'  9 30  9  7  7   1
 6 1  2  2.63981  'A1.1'  9 30  9  7  7   1
 7 1  3  8.03071  'A1.1'  9 30  9  7  7   1
 8 1  4  8.90896  'A1.1'  9 30  9  7  7   1
 9 1  1  8.90896'A2'  9 30  9  7  1   1
 101  2  8.63809'A2'  9 30  9  7  1   1
 111  3  2.85602'A2'  9 30  9  7  1   1
 121  4  0.0'A2'  9 30  9  7  1   1
 131  1  8.03071  'A2.1'  9 30  9  7  7   1
 141  2  6.95836  'A2.1'  9 30  9  7  7   1
 151  3  0.0  'A2.1'  9 30  9  7  7   1
 161  4  2.85602   A2.1'  9 30  9  7  7   1
 171  1  3.53695'A1' 10 30  9  7  1   1
 181  2  4.32457'A1' 10 30  9  7  1   1
 191  3  0.0'A1' 10 30  9  7  1   1
 201  4  8.85851'A1' 10 30  9  7  1   1
 211  5 12.09194'A1' 10 30  9  7  1   1
 221  1  7.44743  'A1.1' 10 30  9  7  7   1
 231  2  0.0  'A1.1' 10 30  9  7  7   1
 241  3  4.32457  'A1.1' 10 30  9  7  7   1
 251  4 13.16728  'A1.1' 10 30  9  7  7   1
 261  5 16.34761  'A1.1' 10 30  9  7  7   1
 271  1  6.13176'A2' 10 30  9  7  1   1
 281  2 13.16728'A2' 10 30  9  7  1   1
 291  3  8.85851'A2' 10 30  9  7  1   1
 301  4  0.0'A2' 10 30  9  7  1   1
 311  5  3.40726'A2' 10 30  9  7  1   1
 321  1  9.03345  'A2.1' 10 30  9  7  7   1
 331  2 16.34761  'A2.1' 10 30  9  7  7   1
 341  3 12.09194  'A2.1' 10 30  9  7  7   1
 351  4  3.40726  'A2.1' 10 30  9  7  7   1
 361  5  0.0  'A2.1' 10 30  9  7  7   1
 371  1  0.0 'MALE1' 10 30  9  7 12   1
 381  2  7.44743 'MALE1' 10 30  9  7 12   1
 391  3  3.53695 'MALE1' 10 30  9  7 12   1
 401  4  6.13176 'MALE1' 10 30  9  7 12   1
 411  5  9.03345 'MALE1' 10 30  9  7 12   1


 So the loop is:

 DIST_LOOP-matrix(NA,NA,ncol=11)

 for (i in 1:33){
SEL_DAY-seal_dist[seal_dist[,10]==i,]
 SEL_DAY[i]=dist[i]
 print(paste(DAY, i, of 33))
for (s in 1:11){
SEL_HR-SEL_DAY[SEL_DAY[,5]==s,]
print(paste(HR, s, of 11))
indx - subset(SEL_HR, SEL_HR$DIST == 0)
SEL_HR$TO_ID - indx$ID[match(SEL_HR$TO, indx$TO)]
 DIST_LOOP[i,]-SEL_HR
}
}

 But storing the data in the DIST_LOOP matrix doesn't work, I am just told
 in
 another post that a list might be better than a matrix?

 I hope this makes more sense!?

 Many thanks,

 Ross
 --
 View this message in context:
 http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238483.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.




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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] storing output data from a loop that has varying row numbers

2010-06-01 Thread Joris Meys
Sorry, forgot to add the sel. This is the first line, then just run the
rest.

sel - as.factor(paste(seal_dist[,10],-,seal_dist[,5],sep=))

cheers
Joris

On Tue, Jun 1, 2010 at 4:56 PM, Joris Meys jorism...@gmail.com wrote:

 Is this what you're looking for?

 seal_list - split(seal_dist,sel)

 out - lapply(seal_list,function(x){
   indx - subset(x, x$DIST == 0)
   x$TO_ID - indx$ID[match(x$TO, indx$TO)]
   return(x)
 })

 output - unsplit(out,sel)

 Cheers
 Joris

 On Tue, Jun 1, 2010 at 3:32 PM, RCulloch ross.cull...@dur.ac.uk wrote:


 Hi Ivan,

 Thanks for your help, your initial suggestion did not work, but that is no
 doubt down to my lack of making sense!

 Here is a short example of my dataset. Basically the loop is set up to
 match
 the ID with the TO column based on DIST = 0. So A1 = 2, A1.1 =1, A2 = 4,
 A2.1 = 3. That is fine for HR 9, but for HR 10 the numbers no longer match
 those IDs so I need to loop the data and store each loop - if that makes
 sense.


  FROM TO DIST  ID HR DD MM YY ANIMAL DAY
 1 1  1  2.63981'A1'  9 30  9  7  1   1
 2 1  2  0.0'A1'  9 30  9  7  1   1
 3 1  3  6.95836'A1'  9 30  9  7  1   1
 4 1  4  8.63809'A1'  9 30  9  7  1   1
 5 1  1  0.0  'A1.1'  9 30  9  7  7   1
 6 1  2  2.63981  'A1.1'  9 30  9  7  7   1
 7 1  3  8.03071  'A1.1'  9 30  9  7  7   1
 8 1  4  8.90896  'A1.1'  9 30  9  7  7   1
 9 1  1  8.90896'A2'  9 30  9  7  1   1
 101  2  8.63809'A2'  9 30  9  7  1   1
 111  3  2.85602'A2'  9 30  9  7  1   1
 121  4  0.0'A2'  9 30  9  7  1   1
 131  1  8.03071  'A2.1'  9 30  9  7  7   1
 141  2  6.95836  'A2.1'  9 30  9  7  7   1
 151  3  0.0  'A2.1'  9 30  9  7  7   1
 161  4  2.85602   A2.1'  9 30  9  7  7   1
 171  1  3.53695'A1' 10 30  9  7  1   1
 181  2  4.32457'A1' 10 30  9  7  1   1
 191  3  0.0'A1' 10 30  9  7  1   1
 201  4  8.85851'A1' 10 30  9  7  1   1
 211  5 12.09194'A1' 10 30  9  7  1   1
 221  1  7.44743  'A1.1' 10 30  9  7  7   1
 231  2  0.0  'A1.1' 10 30  9  7  7   1
 241  3  4.32457  'A1.1' 10 30  9  7  7   1
 251  4 13.16728  'A1.1' 10 30  9  7  7   1
 261  5 16.34761  'A1.1' 10 30  9  7  7   1
 271  1  6.13176'A2' 10 30  9  7  1   1
 281  2 13.16728'A2' 10 30  9  7  1   1
 291  3  8.85851'A2' 10 30  9  7  1   1
 301  4  0.0'A2' 10 30  9  7  1   1
 311  5  3.40726'A2' 10 30  9  7  1   1
 321  1  9.03345  'A2.1' 10 30  9  7  7   1
 331  2 16.34761  'A2.1' 10 30  9  7  7   1
 341  3 12.09194  'A2.1' 10 30  9  7  7   1
 351  4  3.40726  'A2.1' 10 30  9  7  7   1
 361  5  0.0  'A2.1' 10 30  9  7  7   1
 371  1  0.0 'MALE1' 10 30  9  7 12   1
 381  2  7.44743 'MALE1' 10 30  9  7 12   1
 391  3  3.53695 'MALE1' 10 30  9  7 12   1
 401  4  6.13176 'MALE1' 10 30  9  7 12   1
 411  5  9.03345 'MALE1' 10 30  9  7 12   1


 So the loop is:

 DIST_LOOP-matrix(NA,NA,ncol=11)

 for (i in 1:33){
SEL_DAY-seal_dist[seal_dist[,10]==i,]
 SEL_DAY[i]=dist[i]
 print(paste(DAY, i, of 33))
for (s in 1:11){
SEL_HR-SEL_DAY[SEL_DAY[,5]==s,]
print(paste(HR, s, of 11))
indx - subset(SEL_HR, SEL_HR$DIST == 0)
SEL_HR$TO_ID - indx$ID[match(SEL_HR$TO, indx$TO)]
 DIST_LOOP[i,]-SEL_HR
}
}

 But storing the data in the DIST_LOOP matrix doesn't work, I am just told
 in
 another post that a list might be better than a matrix?

 I hope this makes more sense!?

 Many thanks,

 Ross
 --
 View this message in context:
 http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238483.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.




 --
 Joris Meys
 Statistical Consultant

 Ghent University
 Faculty of Bioscience Engineering
 Department of Applied mathematics, biometrics and process control

 Coupure Links 653
 B-9000 Gent

 tel : +32 9 264 59 87
 joris.m...@ugent.be
 ---
 Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php


Re: [R] Help on aggregate method

2010-06-01 Thread Erik Iverson
It's easiest for us to help if you give us a reproducible example.  We 
don't have your datasets (ap.dat), so we can't run your code below. 
It's easy to create sample data with the random number generators in R, 
or use ?dput to give us a sample of your actual data.frame.


I would guess your problem is solved by ?ave though.

Stella Pachidi wrote:

Dear R experts,

I would really appreciate if you had an idea on how to use more
efficiently the aggregate method:

More specifically, I would like to calculate the mean of certain
values on a data frame,  grouped by various attributes, and then
create a new column in the data frame that will have the corresponding
mean for every row. I attach part of my code:

matchMean - function(ind,dataTable,aggrTable)
{
index - which((aggrTable[,1]==dataTable[[Attr1]][ind]) 
(aggrTable[,2]==dataTable[[Attr2]][ind]))
as.numeric(aggrTable[index,3])
}

avgDur - aggregate(ap.dat[[Dur]], by = list(ap.dat[[Attr1]],
ap.dat[[Attr2]]), FUN=mean)
meanDur - sapply((1:length(ap.dat[,1])), FUN=matchMean, ap.dat, avgDur)
ap.dat - cbind (ap.dat, meanDur)

As I deal with very large dataset, it takes long time to run my
matching function, so if you had an idea on how to automate more this
matching process I would be really grateful.

Thank you very much in advance!

Kind regards,
Stella



--
Stella Pachidi
Master in Business Informatics student
Utrecht University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
It is indeed ddply() from package plyr.





 -Original Message-
 From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
 Sent: Tuesday, June 01, 2010 12:24 PM
 To: Peter Ehlers
 Cc: arnaud Gaboury; r-help@r-project.org
 Subject: Re: [R] data frame manipulation with zero rows
 
 On Tue, 1 Jun 2010, Peter Ehlers wrote:
 
  On 2010-06-01 1:53, arnaud Gaboury wrote:
  Brian,
 
  If I do understand correctly, I must use in my function something
 else than
  ddply() if I want to avoid any error each time my df has zero rows?
  Am I correct?
 
 
  You could define a function to handle the zero-rows case:
 
  f - function(x){
  if(nrow(x)  1) out - x[, c(1,3,2)]  # or whatever
  else
out - ddply(x, c(DESCRIPTION,SETTLEMENT), summarise,
 POSITION=sum(QUANTITY))[,c(1,3,2)]
  out
  }
  f(futures)
 
 Or simply fix ddply.  We don't know what that is or what it should do
 for the case of zero rows: it may or may not be the one in package
 plyr.
 
 
  -Peter Ehlers
 
 
 
  -Original Message-
  From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
  Sent: Tuesday, June 01, 2010 9:47 AM
  To: arnaud Gaboury
  Subject: Re: [R] data frame manipulation with zero rows
 
  On Tue, 1 Jun 2010, arnaud Gaboury wrote:
 
  Dear group,
 
  Here is the kind of data.frame I obtain every day with my function
 :
 
  futures-
  structure(list(DESCRIPTION = c(CORN Jul/10, CORN Jul/10,
  CORN Jul/10, CORN Jul/10, CORN Jul/10, LIVE CATTLE Aug/10,
  LIVE CATTLE Aug/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10,
  SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10, SUGAR NO.11 Jul/10
  ), CREATED.DATE = structure(c(18403, 18406, 18406, 18406, 18406,
  18407, 18408, 18406, 18407, 18407, 18407, 18407), class = Date),
  QUANTITY = c(1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1), SETTLEMENT =
  c(373.2500,
  373.2500, 373.2500, 373.2500, 373.2500, 90.7750,
  90.7750, 14.9200, 14.9200, 14.9200, 14.9200,
 14.9200
  )), .Names = c(DESCRIPTION, CREATED.DATE, QUANTITY,
  SETTLEMENT), row.names = c(NA, 12L), class = data.frame)
 
  I need then to apply to the df this following code line :
 
  PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise,
  POSITION=
  sum(QUANTITY))[,c(1,3,2)]
 
  It works perfectly in most of case, BUT I have a new problem: it
 can
  sometime occurs that my df futures is empty, with zero rows.
 
 
  futures-
  structure(list(DESCRIPTION = character(0), CREATED.DATE =
  structure(numeric(0), class = Date),
  QUANTITY = numeric(0), SETTLEMENT = character(0)), .Names =
  c(DESCRIPTION,
  CREATED.DATE, QUANTITY, SETTLEMENT), row.names = integer(0),
  class =
  data.frame)
 
  It is not the usual case, but it can happen. With this df, when I
  pass the
  above mentione line, I get an error :
 
  PosFut=ddply(futures, c(DESCRIPTION,SETTLEMENT), summarise,
  POSITION=
  sum(QUANTITY))[,c(1,3,2)]
  Error in tapply(1:nrow(data), splitv, list) :
arguments must have same length
 
 
  How can I avoid this when my df is empty?
 
  Ask the author of the (missing) function ddply() to correct the
 error
  of using 1:nrow(data) by replacing it by seq_len(nrow(data)).
 
  It's helpful to give example code, but much more helpful if you
 test
  it: yours cannot work without the function ddply() -- this is what
  'self-contained' means in the footer here.
 
 --
 Brian D. Ripley,  rip...@stats.ox.ac.uk
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595

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

2010-06-01 Thread Mauricio Zambrano
Dear R-users,

I'm developing a package that heavily depends on another package
released under the GPL-2 license.

In addition, some few functions depends on other packages released
under the following licences (as described in the corresponding pages
of http://cran.r-project.org/web/packages/):

GPL
GPL =2.

I want to release my package under a GPL = 2 license, and after
reading the section 1.1.1 of the R-exts manual and looking at the
compatibility matrix found on http://gplv3.fsf.org/dd3-faq,  I'm still
in doubt if I can do that.

I would appreciate if you could tell me if can I release my package
under a GPL = 2 license considering the aforementioned licenses ?


Finally, a general question:

When a package is released under GPL =2, does it mean that the terms
of the GPL-3 license apply or not ?


Thanks in advance for any help.

Mauricio

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] BreastCancer Dataset for Classification in kknn

2010-06-01 Thread Nitin
Dear All,

I'm getting a error while trying to apply the BreastCancer dataset
(package=mlbench) to kknn (package=kknn) that I don't understand as I'm new
to R.
The codes are as follow:

rm = (list = ls())
library(mlbench)
data(BreastCancer)
library(kknn)

BCancer = na.omit(BreastCancer)
d  = dim(BCancer)[1]
i1 = seq(1, d, 2)
i2 = seq(2, d, 2)

t1 = BCancer[i1, ]
t2 = BCancer[i2, ]
y2  = BCancer[i2, 11]

x = 10
k = array(1:x, dim = c(x,1))
ker = array(c( rectangular, triangular, epanechnikov, biweight,
triweight, cos, inv, gaussian), dim = c(8,1))

f = function(x, ker){

BreastCancer.kknn  -  kknn(Class~., train = t1, test = t2, k = x,
kernel = ker, distance = 1)
fit = fitted(BreastCancer.kknn)

z - (fit==y2)
z.e - (100 - (length(y2)-length(z[!z]))/length(y2)*100 )
}

err.k = function(ker){
error.BreastCancer = apply(k,1,function(y) f(y, ker))
}

err.ker = apply(ker, 1, err.k)
colnames(err.ker) = c(rectangular, triangular, epanechnikov,
biweight,
triweight, cos, inv, gaussian)
print(err.ker)

It throws a error: Error in as.matrix(learn[, ind == i]) :
  (subscript) logical subscript too long
In addition: Warning messages:
1: In model.matrix.default(mt, mf) : variable 'Id' converted to a factor
2: In model.matrix.default(mt, test) : variable 'Id' converted to a factor

I tried the codes with other datasets in mlbench package and most of them
working. That is the mistake here for this particular dataset and how can I
solve it?

Thanks
Nitin

[[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] Issue with assigning text to matrix

2010-06-01 Thread Peter Ehlers

Jessica,

Two further comments:
1. When you read your data, your character vectors are
   stored as factors; is that what you want?
2. You may be better off using a list.

  -Peter Ehlers

On 2010-06-01 7:47, Sarah Goslee wrote:

On Tue, Jun 1, 2010 at 5:04 AM, Jessica Queree
j.j.que...@googlemail.com  wrote:

My issue relates to adding text to a matrix and finding that the text is
converted to a number.



A matrix can only hold one type of data. Since you started with character,
that's what you get.

A dataframe can hold different types of data, both character and numeric.
If you convert your matrix to a dataframe with dataf.frame() it can hold
your output in the manner you expect.

testOutput- data.frame(matrix(nrow = 200, ncol = 5))

Sarah


This is the section of code I'm having trouble with:



# First, I load in a list of names from a .csv file to 'names'

names- read.csv(file(Names.csv))



# Then I define a matrix which will be populated with various test
statistics, with several rows for each entry in names



testOutput-matrix(nrow = 200, ncol = 5)

for (i in 1:nrow(names)){



testOutput[i,1]- names[i,1]

testOutput[i,2]- names[i,2]



# test statistics code here



}


That is, the names are now converted to numbers. I think this might have
something to do with the way I've defined the testOutput matrix, but haven't
been able to find any information about how to fix it. Can anyone help?



Many thanks.





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


Re: [R] storing output data from a loop that has varying row numbers

2010-06-01 Thread RCulloch

Hi Joris,

Thanks for your help!

The data as requested:

structure(list(FROM = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 
TO = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 
2L, 3L, 4L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 
3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), DIST = c(2.63981, 
0, 6.95836, 8.63809, 0, 2.63981, 8.03071, 8.90896, 8.90896, 
8.63809, 2.85602, 0, 8.03071, 6.95836, 0, 2.85602, 3.53695, 
4.32457, 0, 8.85851, 12.09194, 7.44743, 0, 4.32457, 13.16728, 
16.34761, 6.13176, 13.16728, 8.85851, 0, 3.40726, 9.03345, 
16.34761, 12.09194, 3.40726, 0, 0, 7.44743, 3.53695, 6.13176, 
9.03345), ID = structure(c(12L, 12L, 12L, 12L, 11L, 11L, 
11L, 11L, 14L, 14L, 14L, 14L, 13L, 13L, 13L, 143L, 12L, 12L, 
12L, 12L, 12L, 11L, 11L, 11L, 11L, 11L, 14L, 14L, 14L, 14L, 
14L, 13L, 13L, 13L, 13L, 13L, 94L, 94L, 94L, 94L, 94L), .Label =
c('11.1', 
'15.1', '15.5', '18.1', '24.2', '26.1', '26.2', 
'28.3', '4.2', '7.1', 'A1.1', 'A1', 'A2.1', 'A2', 
'B1', 'C1', 'D1.1', 'D1', 'D2.1', 'D2', 'D3.1', 
'D3', 'D4.1', 'D4', 'D5.1', 'D5', 'D6.1', 'D6', 
'E1.1', 'E1', 'E2.1', 'E2', 'E4', 'E5', 'F1.1', 
'F1', 'F10.1', 'F10', 'F11', 'F2', 'F3', 'F4.1', 
'F4', 'F5.1', 'F5', 'F7', 'F8.1', 'F8', 'G2.1', 
'G2', 'G3.1', 'G3', 'G4.1', 'G4', 'G5.1', 'G5', 
'H1.1', 'H1', 'H2', 'H3.1', 'H3', 'H8', 'I1.1', 
'I1', 'I2', 'I4.1', 'I4', 'J1.1', 'J1', 'J2.1', 
'J2', 'J3', 'J6', 'J7', 'JUV', 'K1.1', 'K1', 
'K2', 'K3', 'K4.1', 'K4', 'L1.1', 'L1', 'L2.1', 
'L2', 'L4', 'M1', 'M2.1', 'M2', 'M3.1', 'M3', 
'M4.1', 'M4', 'MALE1', 'N1.1', 'N1', 'N2', 'N3', 
'N4.1', 'N4', 'O1', 'O2', 'O3.1', 'O3', 'O4.1', 
'O4', 'O5', 'P1.1', 'P1', 'Q1', 'Q2', 'Q3', 
'R1.1', 'R1', 'R2', 'R3.1', 'R3', 'R4.1', 'R4', 
'R5.1', 'R5', 'S1.1', 'S1', 'S2.1', 'S2', 'S3.1', 
'S3', 'S4.1', 'S4', 'T1', 'U1.1', 'U1', 'U2', 
'U3', 'UKFEM', 'UKMAL', 'UKPUP', 'V1.1', 'V1', 
'W1.1', 'W1', 'WR', A2.1'), class = factor), HR = c(9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
10L), DD = c(30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L), MM = c(9L, 9L, 9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L), YY = c(7L, 7L, 7L, 7L, 7L, 
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
7L, 7L, 7L, 7L, 7L, 7L), ANIMAL = c(1L, 1L, 1L, 1L, 7L, 7L, 
7L, 7L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L, 1L, 1L, 1L, 1L, 1L, 
7L, 7L, 7L, 7L, 7L, 1L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L, 7L, 
12L, 12L, 12L, 12L, 12L), DAY = c(1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L)), .Names = c(FROM, TO, DIST, ID, 
HR, DD, MM, YY, ANIMAL, DAY), row.names = c(NA, 41L
), class = data.frame)



The output should be as the original file is, but it should have an
additional column for 'TO_ID' 

I hope that makes sense? 

Cheers,

Ross 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238576.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] storing output data from a loop that has varying row numbers

2010-06-01 Thread RCulloch

Hi Ivan,

Thanks again for your help! I'll just go through your questions...

I'm still really confused about your question.
-Sorry!!!


Let me ask you some specific questions (maybe someone more experienced
would understand at once, but I'm no expert; I hope I can still help
you! In any case, I would like to understand for myself ;) )

- is seal_dist the name of your data.frame?
yes 
so..
head(seal_dist)

  FROM TODIST ID HR DD MM YY ANIMAL DAY
11  1 2.63981   'A1'  9 30  9  7  1   1
21  2 0.0   'A1'  9 30  9  7  1   1
31  3 6.95836   'A1'  9 30  9  7  1   1
41  4 8.63809   'A1'  9 30  9  7  1   1
51  1 0.0 'A1.1'  9 30  9  7  7   1
61  2 2.63981 'A1.1'  9 30  9  7  7   1


- what do you want to do with
SEL_DAY[i]=dist[i]

That was a (desperate) attempt to do 'something', but didn't work - so
shouldn't have been in the script I posted, sorry!

? What is dist? 
It is a measure of distance from one point (ID) to another i.e. the distance
between A1 and A1.1

If I understand well, you want to replace the values
in FROM (then TO, then DIST...) with the values from the same column
number in dist?

The problem is that Arc doesn't output the data as I'd like, so I want to
create a new column to add to the data. What Arc has done is taken a
distance between each ID for each hour, but because the number of IDs in
each hour don't match it means that the TO number is not unique to the ID
throughout the entire dataset, only on that given hour. So when distance = 0
in the TO column then that TO number -s equal to the ID i.e. the distance to
A1 to A1 is 0, so I then want to use that information to create a new column
that will tell me the actual ID. If that is any clearer?


- Since I still haven't understood your goal completely, I still don't
understand why you add the column TO_ID to SEL_HR.
see above


- In any case, a matrix cannot work because you want to store data of
different classes in DIST_LOOP (ID is character and the others are
numeric). You can either use a data.frame (if you really want to have
the table-like structure, which is a list) or a list.
I see, can you advise on how to set up a list to write to?

- Moreover, the output from dput(your data) would really help to see
what you have! 
I have not long posted it, I hope it helps!!

Thanks again for your help Ivan, much appreciated,

Ross

-- 
View this message in context: 
http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238630.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] How to make R automatic?

2010-06-01 Thread zhangted001

Hello, I have a question about how R can run automatically.  Here is the
story:

A file called data.csv will be generated every couple of minutes in a
folder (overwrite itself). What I want R to do is:

1) scan the folder to find the file.
2) if the file is a newly generated file, process the file
3) output some file identifier on the screen, such as the time when the file
was generated.
4) pause for 20 seconds (doesnt need to be precise) and repeat 1)

Idealy, I would like R to do this everyday from 9:00am to 6:00pm.

What I got so far is: I can use list.files() and file.info to get 1) and 2). 
For 4), I can write some trivial loop to kill some time, but I would like to
be more accurate tham that, considering different PC running the loop.  I
have no idea about 3).

Any suggestion/better solution?

Thank you very much!!

Best regards,
Ted







-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-make-R-automatic-tp2238541p2238541.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 the design matrix to correctly configure contrasts

2010-06-01 Thread Karl Brand

Esteemed R-forum subscribers,

I'm having a tough time configuring contrasts for my 3-way ANOVA. In short:

I don't know how to configure (all) my contrasts correctly in order to 
specify (all) my comparisons of interest.


I succeeded getting my contrasts of interest set up for a simpler 2-way 
ANOVA based on the fairly intuitive logic of the design col.names.


But i'm not able to extend this logic to a more complex three way ANOVA. 
Obviously there *is* a logic to the 0's and 1's of R's design 
'treatment contrast' matrix- i see that the 1's correspond to each of 
the factors that an observation is associated with. But exactly how this 
information can be used to ascribe contrasts of interest remains beyond 
my understanding, especially where interaction is concerned. Googling 
for days didn't yield the help i was looking for.


Can some one point me to a detailed explanation (suitable for R 
dilettantes) how to specify any contrast of interest given a design matrix?


For anyone really needing some diversion, i'd *really* appreciate a 
personal explanation using my design as an example. Warning- its not 
small...


#load limma package to analyse affy gene expression data
library(limma)

targets - read.delim(targets.txt)

#factors  levels
Time - factor(targets$Time, levels = c(t1, t2, t3, t4,
t5, t6, t7, t8,
t9, t10, t11, t12,
t13, t14, t15, t16))
Tissue - factor(targets$Tissue, levels = c(R, C))
Pperiod - factor(targets$Pperiod, levels = c(E, L, S))

#model excluding the 3-way interaction (written for convenience to
# build on previous 2-way ANOVA
design - model.matrix(~Time + Tissue + Pperiod + Time:Tissue + 
Time:Pperiod + Tissue:Pperiod)


fit - lmFit(rma.pp, design)

#how does this design look:

 colnames(design)
 [1] (Intercept)  Timet2
 [3] Timet3   Timet4
 [5] Timet5   Timet6
 [7] Timet7   Timet8
 [9] Timet9   Timet10
[11] Timet11  Timet12
[13] Timet13  Timet14
[15] Timet15  Timet16
[17] TissueC  PperiodL
[19] PperiodS Timet2:TissueC
[21] Timet3:TissueC   Timet4:TissueC
[23] Timet5:TissueC   Timet6:TissueC
[25] Timet7:TissueC   Timet8:TissueC
[27] Timet9:TissueC   Timet10:TissueC
[29] Timet11:TissueC  Timet12:TissueC
[31] Timet13:TissueC  Timet14:TissueC
[33] Timet15:TissueC  Timet16:TissueC
[35] Timet2:PperiodL  Timet3:PperiodL
[37] Timet4:PperiodL  Timet5:PperiodL
[39] Timet6:PperiodL  Timet7:PperiodL
[41] Timet8:PperiodL  Timet9:PperiodL
[43] Timet10:PperiodL Timet11:PperiodL
[45] Timet12:PperiodL Timet13:PperiodL
[47] Timet14:PperiodL Timet15:PperiodL
[49] Timet16:PperiodL Timet2:PperiodS
[51] Timet3:PperiodS  Timet4:PperiodS
[53] Timet5:PperiodS  Timet6:PperiodS
[55] Timet7:PperiodS  Timet8:PperiodS
[57] Timet9:PperiodS  Timet10:PperiodS
[59] Timet11:PperiodS Timet12:PperiodS
[61] Timet13:PperiodS Timet14:PperiodS
[63] Timet15:PperiodS Timet16:PperiodS
[65] TissueC:PperiodL TissueC:PperiodS

#the contrasts that i believe i *can* work out correctly:

cont.matrix - cbind(

t1.S.RvsAll.S.R.Times =
  c( 0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
 0,  0),

t1.E.RvsAll.E.R.Times =
  c( 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0),

t1.L.RvsAll.L.R.Times =
  c( 0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
 1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0)
  )

fit2 - contrasts.fit(fit, cont.matrix)
fit3 - eBayes(fit2)

#sensical out put follows suggesting i'm on the right track

BUT! Most basically, the contrasts i can NOT work out are:

t1.S.CvsAll.Times  t1.L.CvsAll.Times

ie., similar to t1.S.RvsAll.Times  t1.S.RvsAll.Times above but for the 
C tissue, not the S.





--
Karl Brand k.br...@erasmusmc.nl
Department of Genetics
Erasmus MC
Dr Molewaterplein 50
3015 GE Rotterdam
P +31 (0)10 704 3409 | F +31 (0)10 704 4743 | M +31 (0)642 777 268

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

2010-06-01 Thread Joris Meys
Take a look at
?split (and unsplit)

eg:
Dur - rnorm(100)
Attr1=rep(c(A,B),each=50)
Attr2=rep(c(A,B),times=50)

ap.dat -data.frame(Attr1,Attr2,Dur)

split.fact - paste(ap.dat$Attr1,ap.dat$Attr2)
ap.list -split(ap.dat,split.fact)
ap.mean -lapply(ap.list,function(x){
x$meanDur=rep(mean(x$Dur),dim(x)[1])
return(x)
  })

ap.dat.fast - unsplit(ap.mean,split.fact)

system.time on 1000 replicates gives :
 system.time(replicate(1000,{
+ split.fact - paste(ap.dat$Attr1,ap.dat$Attr2)
+ ap.list -split(ap.dat,split.fact)
+ ap.mean -lapply(ap.list,functi  [TRUNCATED]
   user  system elapsed
   4.880.004.88
 source(.trPaths[5], echo=TRUE, max.deparse.length=150)

 system.time(replicate(1000,{
+ avgDur - aggregate(ap.dat[[Dur]], by = list(ap.dat[[Attr1]],
+ ap.dat[[Attr2]]), FUN=mean)
+ meanDur - sapp  [TRUNCATED]
   user  system elapsed
  58.000.11   58.13


It should be a tenfold faster.

Cheers
Joris


On Tue, Jun 1, 2010 at 4:48 PM, Stella Pachidi stella.pach...@gmail.comwrote:

 Dear R experts,

 I would really appreciate if you had an idea on how to use more
 efficiently the aggregate method:

 More specifically, I would like to calculate the mean of certain
 values on a data frame,  grouped by various attributes, and then
 create a new column in the data frame that will have the corresponding
 mean for every row. I attach part of my code:

 matchMean - function(ind,dataTable,aggrTable)
 {
index - which((aggrTable[,1]==dataTable[[Attr1]][ind]) 
 (aggrTable[,2]==dataTable[[Attr2]][ind]))
as.numeric(aggrTable[index,3])
 }

 avgDur - aggregate(ap.dat[[Dur]], by = list(ap.dat[[Attr1]],
 ap.dat[[Attr2]]), FUN=mean)
 meanDur - sapply((1:length(ap.dat[,1])), FUN=matchMean, ap.dat, avgDur)
 ap.dat - cbind (ap.dat, meanDur)

 As I deal with very large dataset, it takes long time to run my
 matching function, so if you had an idea on how to automate more this
 matching process I would be really grateful.

 Thank you very much in advance!

 Kind regards,
 Stella



 --
 Stella Pachidi
 Master in Business Informatics student
 Utrecht University

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




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[alternative HTML version deleted]]

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


Re: [R] How to make R automatic?

2010-06-01 Thread Charles C. Berry



?Sys.sleep

On Tue, 1 Jun 2010, zhangted001 wrote:



Hello, I have a question about how R can run automatically.  Here is the
story:

A file called data.csv will be generated every couple of minutes in a
folder (overwrite itself). What I want R to do is:

1) scan the folder to find the file.
2) if the file is a newly generated file, process the file
3) output some file identifier on the screen, such as the time when the file
was generated.
4) pause for 20 seconds (doesnt need to be precise) and repeat 1)

Idealy, I would like R to do this everyday from 9:00am to 6:00pm.

What I got so far is: I can use list.files() and file.info to get 1) and 2).
For 4), I can write some trivial loop to kill some time, but I would like to
be more accurate tham that, considering different PC running the loop.  I
have no idea about 3).

Any suggestion/better solution?

Thank you very much!!

Best regards,
Ted







--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-make-R-automatic-tp2238541p2238541.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.



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

2010-06-01 Thread Peter Ehlers


On 2010-06-01 8:07, zhangted001 wrote:


Hello, I have a question about how R can run automatically.  Here is the
story:

A file called data.csv will be generated every couple of minutes in a
folder (overwrite itself). What I want R to do is:

1) scan the folder to find the file.
2) if the file is a newly generated file, process the file
3) output some file identifier on the screen, such as the time when the file
was generated.
4) pause for 20 seconds (doesnt need to be precise) and repeat 1)

Idealy, I would like R to do this everyday from 9:00am to 6:00pm.

What I got so far is: I can use list.files() and file.info to get 1) and 2).
For 4), I can write some trivial loop to kill some time, but I would like to
be more accurate tham that, considering different PC running the loop.  I
have no idea about 3).


For (3), assign the value of file.info:

 fi - file.info(data.csv)
 print(fi[, mtime])

For (4) see help(Sys.sleep)

  -Peter Ehlers



Any suggestion/better solution?

Thank you very much!!

Best regards,
Ted


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] storing output data from a loop that has varying row numbers

2010-06-01 Thread Joris Meys
OK, then I was right. It's exactly what my code does.
Enjoy.
Cheers

On Tue, Jun 1, 2010 at 4:25 PM, RCulloch ross.cull...@dur.ac.uk wrote:


 Hi Joris,

 Thanks for your help!

 The data as requested:

 structure(list(FROM = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L),
TO = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L,
2L, 3L, 4L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L,
3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), DIST = c(2.63981,
0, 6.95836, 8.63809, 0, 2.63981, 8.03071, 8.90896, 8.90896,
8.63809, 2.85602, 0, 8.03071, 6.95836, 0, 2.85602, 3.53695,
4.32457, 0, 8.85851, 12.09194, 7.44743, 0, 4.32457, 13.16728,
16.34761, 6.13176, 13.16728, 8.85851, 0, 3.40726, 9.03345,
16.34761, 12.09194, 3.40726, 0, 0, 7.44743, 3.53695, 6.13176,
9.03345), ID = structure(c(12L, 12L, 12L, 12L, 11L, 11L,
11L, 11L, 14L, 14L, 14L, 14L, 13L, 13L, 13L, 143L, 12L, 12L,
12L, 12L, 12L, 11L, 11L, 11L, 11L, 11L, 14L, 14L, 14L, 14L,
14L, 13L, 13L, 13L, 13L, 13L, 94L, 94L, 94L, 94L, 94L), .Label =
 c('11.1',
'15.1', '15.5', '18.1', '24.2', '26.1', '26.2',
'28.3', '4.2', '7.1', 'A1.1', 'A1', 'A2.1', 'A2',
'B1', 'C1', 'D1.1', 'D1', 'D2.1', 'D2', 'D3.1',
'D3', 'D4.1', 'D4', 'D5.1', 'D5', 'D6.1', 'D6',
'E1.1', 'E1', 'E2.1', 'E2', 'E4', 'E5', 'F1.1',
'F1', 'F10.1', 'F10', 'F11', 'F2', 'F3', 'F4.1',
'F4', 'F5.1', 'F5', 'F7', 'F8.1', 'F8', 'G2.1',
'G2', 'G3.1', 'G3', 'G4.1', 'G4', 'G5.1', 'G5',
'H1.1', 'H1', 'H2', 'H3.1', 'H3', 'H8', 'I1.1',
'I1', 'I2', 'I4.1', 'I4', 'J1.1', 'J1', 'J2.1',
'J2', 'J3', 'J6', 'J7', 'JUV', 'K1.1', 'K1',
'K2', 'K3', 'K4.1', 'K4', 'L1.1', 'L1', 'L2.1',
'L2', 'L4', 'M1', 'M2.1', 'M2', 'M3.1', 'M3',
'M4.1', 'M4', 'MALE1', 'N1.1', 'N1', 'N2', 'N3',
'N4.1', 'N4', 'O1', 'O2', 'O3.1', 'O3', 'O4.1',
'O4', 'O5', 'P1.1', 'P1', 'Q1', 'Q2', 'Q3',
'R1.1', 'R1', 'R2', 'R3.1', 'R3', 'R4.1', 'R4',
'R5.1', 'R5', 'S1.1', 'S1', 'S2.1', 'S2', 'S3.1',
'S3', 'S4.1', 'S4', 'T1', 'U1.1', 'U1', 'U2',
'U3', 'UKFEM', 'UKMAL', 'UKPUP', 'V1.1', 'V1',
'W1.1', 'W1', 'WR', A2.1'), class = factor), HR = c(9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L), DD = c(30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L), MM = c(9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L), YY = c(7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L), ANIMAL = c(1L, 1L, 1L, 1L, 7L, 7L,
7L, 7L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L, 1L, 1L, 1L, 1L, 1L,
7L, 7L, 7L, 7L, 7L, 1L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L, 7L,
12L, 12L, 12L, 12L, 12L), DAY = c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L)), .Names = c(FROM, TO, DIST, ID,
 HR, DD, MM, YY, ANIMAL, DAY), row.names = c(NA, 41L
 ), class = data.frame)



 The output should be as the original file is, but it should have an
 additional column for 'TO_ID'

 I hope that makes sense?

 Cheers,

 Ross

 --
 View this message in context:
 http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238576.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.




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[alternative HTML version deleted]]

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


Re: [R] How to make R automatic?

2010-06-01 Thread Nikhil Kaza

?difftime
?file.info
file.info(filename)$mtime
Sys.sleep(20)


Nikhil Kaza
Asst. Professor,
City and Regional Planning
University of North Carolina

nikhil.l...@gmail.com



On Jun 1, 2010, at 10:07 AM, zhangted001 wrote:



Hello, I have a question about how R can run automatically.  Here is  
the

story:

A file called data.csv will be generated every couple of minutes  
in a

folder (overwrite itself). What I want R to do is:

1) scan the folder to find the file.
2) if the file is a newly generated file, process the file
3) output some file identifier on the screen, such as the time when  
the file

was generated.
4) pause for 20 seconds (doesnt need to be precise) and repeat 1)

Idealy, I would like R to do this everyday from 9:00am to 6:00pm.

What I got so far is: I can use list.files() and file.info to get 1)  
and 2).
For 4), I can write some trivial loop to kill some time, but I would  
like to
be more accurate tham that, considering different PC running the  
loop.  I

have no idea about 3).

Any suggestion/better solution?

Thank you very much!!

Best regards,
Ted







--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-make-R-automatic-tp2238541p2238541.html
Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] Help on aggregate method

2010-06-01 Thread Stella Pachidi
Dear Erik and R experts,

Thank you for the fast response!

I include an example with the ChickWeight dataset:

ap.dat - ChickWeight

matchMeanEx - function(ind,dataTable,aggrTable)
{
   index - which((aggrTable[,1]==dataTable[[Diet]][ind]) 
(aggrTable[,2]==dataTable[[Chick]][ind]))
   as.numeric(aggrTable[index,3])
}

avgW - aggregate(ap.dat[[weight]], by = list(ap.dat[[Diet]],
ap.dat[[Chick]]), FUN=mean)
meanW - sapply((1:length(ap.dat[,1])), FUN=matchMeanEx, ap.dat, avgW)
ap.dat - cbind (ap.dat, meanW)


Best regards,
Stella


On Tue, Jun 1, 2010 at 4:58 PM, Erik Iverson er...@ccbr.umn.edu wrote:

 It's easiest for us to help if you give us a reproducible example.  We
 don't have your datasets (ap.dat), so we can't run your code below. It's
 easy to create sample data with the random number generators in R, or use
 ?dput to give us a sample of your actual data.frame.

 I would guess your problem is solved by ?ave though.

 Stella Pachidi wrote:

 Dear R experts,

 I would really appreciate if you had an idea on how to use more
 efficiently the aggregate method:

 More specifically, I would like to calculate the mean of certain
 values on a data frame,  grouped by various attributes, and then
 create a new column in the data frame that will have the corresponding
 mean for every row. I attach part of my code:

 matchMean - function(ind,dataTable,aggrTable)
 {
index - which((aggrTable[,1]==dataTable[[Attr1]][ind]) 
 (aggrTable[,2]==dataTable[[Attr2]][ind]))
as.numeric(aggrTable[index,3])
 }

 avgDur - aggregate(ap.dat[[Dur]], by = list(ap.dat[[Attr1]],
 ap.dat[[Attr2]]), FUN=mean)
 meanDur - sapply((1:length(ap.dat[,1])), FUN=matchMean, ap.dat, avgDur)
 ap.dat - cbind (ap.dat, meanDur)

 As I deal with very large dataset, it takes long time to run my
 matching function, so if you had an idea on how to automate more this
 matching process I would be really grateful.

 Thank you very much in advance!

 Kind regards,
 Stella



 --
 Stella Pachidi
 Master in Business Informatics student
 Utrecht University

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




-- 
Stella Pachidi
Master in Business Informatics student
Utrecht University
email: s.pach...@students.uu.nl
tel: +31644478898

[[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] storing output data from a loop that has varying row numbers

2010-06-01 Thread Ivan Calandra

Hi Ross,

I think Joris answered your question, but to keep with your own code:

To set up a list, you can use:
DIST_LOOP - list()
Or, if you know the length:
DIST_LOOP - vector(mode=list, length=11)
You would then fill up with (in your for loop):
DIST_LOOP[[i]] - SEL_HR ##Actually, what you had at the beginning, but 
DIST_LOOP is now a list so it should work.


Regarding what you're trying to do, wouldn't aggregate() work? Or with 
unique()? I still haven't completely understood what you looking for, so 
I might be completely wrong!


But as I said, I guess (and hope for you) Joris fixed the problem already

Ivan

Le 6/1/2010 16:56, RCulloch a écrit :

Hi Ivan,

Thanks again for your help! I'll just go through your questions...

I'm still really confused about your question.
-Sorry!!!


Let me ask you some specific questions (maybe someone more experienced
would understand at once, but I'm no expert; I hope I can still help
you! In any case, I would like to understand for myself ;) )

- is seal_dist the name of your data.frame?
yes
so..
head(seal_dist)

   FROM TODIST ID HR DD MM YY ANIMAL DAY
11  1 2.63981   'A1'  9 30  9  7  1   1
21  2 0.0   'A1'  9 30  9  7  1   1
31  3 6.95836   'A1'  9 30  9  7  1   1
41  4 8.63809   'A1'  9 30  9  7  1   1
51  1 0.0 'A1.1'  9 30  9  7  7   1
61  2 2.63981 'A1.1'  9 30  9  7  7   1


- what do you want to do with
SEL_DAY[i]=dist[i]

That was a (desperate) attempt to do 'something', but didn't work - so
shouldn't have been in the script I posted, sorry!

? What is dist?
It is a measure of distance from one point (ID) to another i.e. the distance
between A1 and A1.1

If I understand well, you want to replace the values
in FROM (then TO, then DIST...) with the values from the same column
number in dist?

The problem is that Arc doesn't output the data as I'd like, so I want to
create a new column to add to the data. What Arc has done is taken a
distance between each ID for each hour, but because the number of IDs in
each hour don't match it means that the TO number is not unique to the ID
throughout the entire dataset, only on that given hour. So when distance = 0
in the TO column then that TO number -s equal to the ID i.e. the distance to
A1 to A1 is 0, so I then want to use that information to create a new column
that will tell me the actual ID. If that is any clearer?


- Since I still haven't understood your goal completely, I still don't
understand why you add the column TO_ID to SEL_HR.
see above


- In any case, a matrix cannot work because you want to store data of
different classes in DIST_LOOP (ID is character and the others are
numeric). You can either use a data.frame (if you really want to have
the table-like structure, which is a list) or a list.
I see, can you advise on how to set up a list to write to?

- Moreover, the output from dput(your data) would really help to see
what you have!
I have not long posted it, I hope it helps!!

Thanks again for your help Ivan, much appreciated,

Ross

   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


Re: [R] Question about the license of an R package

2010-06-01 Thread Duncan Murdoch

Mauricio Zambrano wrote:

Dear R-users,

I'm developing a package that heavily depends on another package
released under the GPL-2 license.
  


Are you including code from that package in yours, or just making use of 
it?  The former requires that you follow all the GPL rules about your 
own.  If you just use their package, then license your package any way 
you like.

In addition, some few functions depends on other packages released
under the following licences (as described in the corresponding pages
of http://cran.r-project.org/web/packages/):

GPL
GPL =2.

I want to release my package under a GPL = 2 license, and after
reading the section 1.1.1 of the R-exts manual and looking at the
compatibility matrix found on http://gplv3.fsf.org/dd3-faq,  I'm still
in doubt if I can do that.

I would appreciate if you could tell me if can I release my package
under a GPL = 2 license considering the aforementioned licenses ?


Finally, a general question:

When a package is released under GPL =2, does it mean that the terms
of the GPL-3 license apply or not ?
  


I believe that's an offer to license under whatever version of the GPL 
(from 2 up) that the person using your code chooses.  If GPL-3 offers 
something that GPL-2 doesn't (e.g. compatibility with other GPL-3 code), 
they can use that.  If GPL-3 places restrictions they don't like (e.g. 
incompatibility with GPL-2 code), they can use GPL-2.


Duncan Murdoch

Thanks in advance for any help.

Mauricio

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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-help spam detection; please help the moderators

2010-06-01 Thread Joris Meys
Hi all,

I also couldn't help but notice that some of my messages are bounced for
following reason:

   The message headers matched a filter rule

I included the header of one of the messages below, but neither of these
messages is sent trough Nabble, nor does any mail address has digits in it.
I also never had that before. Did you change some of the rules somehow?

Cheers
Joris

---

MIME-Version: 1.0
Received: by 10.140.173.9 with HTTP; Fri, 28 May 2010 05:32:32 -0700 (PDT)
In-Reply-To: aanlktim9etuy2efynloh2lyn7m133ytjencdjpkgp...@mail.gmail.com
References: aanlktikgc7v2zbsyrwcwbueezm8d24qj0vqeb2z1n...@mail.gmail.com
aanlktim9etuy2efynloh2lyn7m133ytjencdjpkgp...@mail.gmail.com
Date: Fri, 28 May 2010 14:32:32 +0200
Delivered-To: jorism...@gmail.com
Message-ID: aanlktimg4idyivhe1ek9mk6_rybjcnuu4msvwrvts...@mail.gmail.com
Subject: Re: [R] How to get values out of a string using regular expressions?
From: Joris Meys jorism...@gmail.com
To: Gabor Grothendieck ggrothendi...@gmail.com
Cc: R mailing list r-help@r-project.org
Content-Type: multipart/alternative; boundary=000e0cd2295481515c0487a6b3be

--000e0cd2295481515c0487a6b3be
Content-Type: text/plain; charset=ISO-8859-1



On Tue, Jun 1, 2010 at 3:25 PM, Martin Maechler
maech...@stat.math.ethz.chwrote:

 Dear readers of R-help

 as most of you will *not* be aware, R-help has continued to work the
 way it does, only thanks to a dozen of volunteers,
 see https://stat.ethz.ch/mailman/listinfo/r-help .

 The volunteers manually moderate e-mails that look like spam (and
 sometimes are and sometimes are not).
 While much more than 90% of the spam is filtered out long before
 a human sees it, with the increasing sophistication of spammers,
 manual intervention has deemed to be necessary and served the
 community very well.

 OTOH, in recent weeks, the amount of work for the volunteers has
 increased, mainly because an increasingly number of non-spam postings are
 erronously tagged as possibly spam.
 We have discussed about this and done some analysis and found
 that most of these message that produce a considerable amount of
 extra work share two properties :
  1) they are posted via Nabble  {which *always* attaches a small
 pro-Nabble spam at the end of the message}
  2) the e-mail address of the sender is from a freemail
provider, quite often 'at gmail dot com', and often the part
*before* the '@' (at-sign) ends with digits.

 We hereby ask those among you who use a freemail account to
 please no longer post via nabble.

 Thank you for your support of R-help, *the* community mailing
 list of the R project since even before that project existed
 formally, namely since 1997-04-01,
 today 13 years and two months.

 Martin Maechler, ETH Zurich
 (and R-help creator and principal manager)

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




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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] as.date

2010-06-01 Thread arnaud Gaboury
Dear group,

Here is my df (obtained with a read.csv2()):


df -
structure(list(DESCRIPTION = c(COTTON NO.2 Jul/10, COTTON NO.2 Jul/10, 
PALLADIUM Jun/10, PALLADIUM Jun/10, SUGAR NO.11 Jul/10, 
SUGAR NO.11 Jul/10), CREATED.DATE = c(13/05/2010, 13/05/2010, 
14/05/2010, 14/05/2010, 10/05/2010, 10/05/2010), QUANITY = c(1, 
1, -1, -1, 1, 1), CLOSING.PRICE = c(81.2000, 81.2000, 503.6000, 
503.6000, 13.8900, 13.8900)), .Names = c(DESCRIPTION, 
CREATED.DATE, QUANITY, CLOSING.PRICE), row.names = c(NA, 
6L), class = data.frame)

 str(df)
'data.frame':   6 obs. of  4 variables:
 $ DESCRIPTION  : chr  COTTON NO.2 Jul/10 COTTON NO.2 Jul/10 PALLADIUM
Jun/10 PALLADIUM Jun/10 ...
 $ CREATED.DATE : chr  13/05/2010 13/05/2010 14/05/2010 14/05/2010
...
 $ QUANITY  : num  1 1 -1 -1 1 1
 $ CLOSING.PRICE: chr  81.2000 81.2000 503.6000 503.6000 ...

I want to change the class of df$CREATED.DATE from Chr to Date:


pose$CREATED.DATE=as.Date(pose$CREATED.DATE,%d/%m/%y)

Here is what I get :

df -
structure(list(DESCRIPTION = c(COTTON NO.2 Jul/10, COTTON NO.2 Jul/10, 
PALLADIUM Jun/10, PALLADIUM Jun/10, SUGAR NO.11 Jul/10, 
SUGAR NO.11 Jul/10), CREATED.DATE = structure(c(18395, 18395, 
18396, 18396, 18392, 18392), class = Date), QUANITY = c(1, 
1, -1, -1, 1, 1), CLOSING.PRICE = c(81.2000, 81.2000, 503.6000, 
503.6000, 13.8900, 13.8900)), .Names = c(DESCRIPTION, 
CREATED.DATE, QUANITY, CLOSING.PRICE), row.names = c(NA, 
6L), class = data.frame)

Where does the problem comes from?? Maybe from my sytem date ??

TY for any help

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] using the design matrix to correctly configure contrasts

2010-06-01 Thread RICHARD M. HEIBERGER
Please look at the maiz example, the last example in ?MMC in the HH package.
Follow the example all the way to the end.  It illustrates a problem and
then the resolution
of the problem.

install.packages(HH)  ## if you don't have it yet.
library(HH)
?MMC


Rich

[[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] as.date

2010-06-01 Thread Erik Iverson



Where does the problem comes from?? Maybe from my sytem date ??


Simply from not reading the options carefully enough, from ?strptime,

 ‘%y’ Year without century (00-99). If you use this on input, which
  century you get is system-specific.  So don't!  Most often
  values 00 to 68 are prefixed by 20 and 69 to 99 by 19 - that
  is the behaviour specified by the 2001 POSIX standard, but it
  does also say ‘it is expected that in a future version of
  IEEE Std 1003.1-2001 the default century inferred from a
  2-digit year will change’.

 ‘%Y’ Year with century.


You want %Y, not %y.

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


Re: [R] as.date

2010-06-01 Thread Joshua Wiley
Hello,

The lowercase 'y' is year without century.  This should work for you:

as.Date(x=df$CREATED.DATE, format=%d/%m/%Y)

HTH,

Josh


On Tue, Jun 1, 2010 at 8:57 AM, arnaud Gaboury arnaud.gabo...@gmail.com wrote:
 Dear group,

 Here is my df (obtained with a read.csv2()):


 df -
 structure(list(DESCRIPTION = c(COTTON NO.2 Jul/10, COTTON NO.2 Jul/10,
 PALLADIUM Jun/10, PALLADIUM Jun/10, SUGAR NO.11 Jul/10,
 SUGAR NO.11 Jul/10), CREATED.DATE = c(13/05/2010, 13/05/2010,
 14/05/2010, 14/05/2010, 10/05/2010, 10/05/2010), QUANITY = c(1,
 1, -1, -1, 1, 1), CLOSING.PRICE = c(81.2000, 81.2000, 503.6000,
 503.6000, 13.8900, 13.8900)), .Names = c(DESCRIPTION,
 CREATED.DATE, QUANITY, CLOSING.PRICE), row.names = c(NA,
 6L), class = data.frame)

 str(df)
 'data.frame':   6 obs. of  4 variables:
  $ DESCRIPTION  : chr  COTTON NO.2 Jul/10 COTTON NO.2 Jul/10 PALLADIUM
 Jun/10 PALLADIUM Jun/10 ...
  $ CREATED.DATE : chr  13/05/2010 13/05/2010 14/05/2010 14/05/2010
 ...
  $ QUANITY      : num  1 1 -1 -1 1 1
  $ CLOSING.PRICE: chr  81.2000 81.2000 503.6000 503.6000 ...

 I want to change the class of df$CREATED.DATE from Chr to Date:


pose$CREATED.DATE=as.Date(pose$CREATED.DATE,%d/%m/%y)

 Here is what I get :

 df -
 structure(list(DESCRIPTION = c(COTTON NO.2 Jul/10, COTTON NO.2 Jul/10,
 PALLADIUM Jun/10, PALLADIUM Jun/10, SUGAR NO.11 Jul/10,
 SUGAR NO.11 Jul/10), CREATED.DATE = structure(c(18395, 18395,
 18396, 18396, 18392, 18392), class = Date), QUANITY = c(1,
 1, -1, -1, 1, 1), CLOSING.PRICE = c(81.2000, 81.2000, 503.6000,
 503.6000, 13.8900, 13.8900)), .Names = c(DESCRIPTION,
 CREATED.DATE, QUANITY, CLOSING.PRICE), row.names = c(NA,
 6L), class = data.frame)

 Where does the problem comes from?? Maybe from my sytem date ??

 TY for any help

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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
Senior in Psychology
University of California, Riverside
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] as.date

2010-06-01 Thread Joris Meys
Change this line to :

pose$CREATED.DATE=as.Date(pose$CREATED.DATE,%d/%m/%Y) # mind the capital
Y
pose
  DESCRIPTION CREATED.DATE QUANITY CLOSING.PRICE
1 COTTON NO.2 Jul/10   2010-05-13   1   81.2000
2 COTTON NO.2 Jul/10   2010-05-13   1   81.2000
3   PALLADIUM Jun/10   2010-05-14  -1  503.6000
4   PALLADIUM Jun/10   2010-05-14  -1  503.6000
5 SUGAR NO.11 Jul/10   2010-05-10   1   13.8900
6 SUGAR NO.11 Jul/10   2010-05-10   1   13.8900

Cheers
Joris

On Tue, Jun 1, 2010 at 5:57 PM, arnaud Gaboury arnaud.gabo...@gmail.comwrote:

 Dear group,

 Here is my df (obtained with a read.csv2()):


 df -
 structure(list(DESCRIPTION = c(COTTON NO.2 Jul/10, COTTON NO.2 Jul/10,
 PALLADIUM Jun/10, PALLADIUM Jun/10, SUGAR NO.11 Jul/10,
 SUGAR NO.11 Jul/10), CREATED.DATE = c(13/05/2010, 13/05/2010,
 14/05/2010, 14/05/2010, 10/05/2010, 10/05/2010), QUANITY = c(1,
 1, -1, -1, 1, 1), CLOSING.PRICE = c(81.2000, 81.2000, 503.6000,
 503.6000, 13.8900, 13.8900)), .Names = c(DESCRIPTION,
 CREATED.DATE, QUANITY, CLOSING.PRICE), row.names = c(NA,
 6L), class = data.frame)

  str(df)
 'data.frame':   6 obs. of  4 variables:
  $ DESCRIPTION  : chr  COTTON NO.2 Jul/10 COTTON NO.2 Jul/10 PALLADIUM
 Jun/10 PALLADIUM Jun/10 ...
  $ CREATED.DATE : chr  13/05/2010 13/05/2010 14/05/2010 14/05/2010
 ...
  $ QUANITY  : num  1 1 -1 -1 1 1
  $ CLOSING.PRICE: chr  81.2000 81.2000 503.6000 503.6000 ...

 I want to change the class of df$CREATED.DATE from Chr to Date:


 pose$CREATED.DATE=as.Date(pose$CREATED.DATE,%d/%m/%y)

 Here is what I get :

 df -
 structure(list(DESCRIPTION = c(COTTON NO.2 Jul/10, COTTON NO.2 Jul/10,
 PALLADIUM Jun/10, PALLADIUM Jun/10, SUGAR NO.11 Jul/10,
 SUGAR NO.11 Jul/10), CREATED.DATE = structure(c(18395, 18395,
 18396, 18396, 18392, 18392), class = Date), QUANITY = c(1,
 1, -1, -1, 1, 1), CLOSING.PRICE = c(81.2000, 81.2000, 503.6000,
 503.6000, 13.8900, 13.8900)), .Names = c(DESCRIPTION,
 CREATED.DATE, QUANITY, CLOSING.PRICE), row.names = c(NA,
 6L), class = data.frame)

 Where does the problem comes from?? Maybe from my sytem date ??

 TY for any help

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




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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] Issue with assigning text to matrix

2010-06-01 Thread Joris Meys
Hi Jessica,

this tells me that your text is saved as a factor.
Try :
names - read.csv(file=Names.csv,stringsAsFactors=F)


Cheers
Joris

On Tue, Jun 1, 2010 at 11:04 AM, Jessica Queree
j.j.que...@googlemail.comwrote:

 My issue relates to adding text to a matrix and finding that the text is
 converted to a number.



 This is the section of code I'm having trouble with:



 # First, I load in a list of names from a .csv file to 'names'

 names - read.csv(file(Names.csv))



 # Then I define a matrix which will be populated with various test
 statistics, with several rows for each entry in names



 testOutput -matrix(nrow = 200, ncol = 5)

 for (i in 1:nrow(names)){



testOutput[i,1] - names[i,1]

testOutput[i,2] - names[i,2]



# test statistics code here



 }





 If I look at names[,1], I get the following:



 names[,1]

  [1] EQ_Level_UK   EQ_Level_EUR  EQ_Level_US   EQ_Level_Far
 East

  [5] IR_PC 1_UKIR_PC 2_UKIR_PC 3_UKSwap_PC 1_UK

  [9] Swap_PC 2_UK  Swap_PC 3_UK  FX_Level_EUR  FX_Level_US

 [13] FX_Level_Far East Infl_PC 1_UK  Infl_PC 2_UK  Infl_PC 3_UK

 [17] Prop_Level_UK CreditAAA_PC 1_UK CreditAAA_PC 2_UK CreditAAA_PC
 3_UK

 [21] CreditAA_PC 1_UK  CreditAA_PC 2_UK  CreditAA_PC 3_UK  CreditA_PC 1_UK

 [25] CreditA_PC 2_UK   CreditA_PC 3_UK   CreditBBB_PC 1_UK CreditBBB_PC
 2_UK

 [29] CreditBBB_PC 3_UK

 29 Levels: CreditA_PC 1_UK CreditA_PC 2_UK CreditA_PC 3_UK ... Swap_PC 3_UK



 But if I look at testOutput[,1], I get:



 testOutput[,1]

  [1] 15 13 16 14 23 24 25 27 28 29 17 19 18 20
 21

  [16] 22 26 7  8  9  4  5  6  1  2  3  10 11 12
 17

  [31] NA   NA   19 18 NA   NA   NA   20 NA   NA   21 NA   NA   22
 NA

  [46] NA   26 NA   NA   7  NA   NA   8  NA   NA   9  NA   NA   4
 NA

  [61] NA   5  NA   NA   6  NA   NA   1  NA   NA   2  NA   NA   3
 NA

  [76] NA   10 NA   NA   11 NA   NA   12 NA   NA   NA   NA   NA   NA
 NA

  [91] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
 NA

 [106] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
 NA

 [121] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
 NA

 [136] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
 NA

 [151] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
 NA

 [166] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
 NA

 [181] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
 NA

 [196] NA   NA   NA   NA   NA



 That is, the names are now converted to numbers. I think this might have
 something to do with the way I've defined the testOutput matrix, but
 haven't
 been able to find any information about how to fix it. Can anyone help?



 Many thanks.

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




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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] as.date

2010-06-01 Thread arnaud Gaboury
TY for the tip. The lower case is in fact the culprit.





 -Original Message-
 From: Erik Iverson [mailto:er...@ccbr.umn.edu]
 Sent: Tuesday, June 01, 2010 6:05 PM
 To: arnaud Gaboury
 Cc: r-help@r-project.org
 Subject: Re: [R] as.date
 
 
  Where does the problem comes from?? Maybe from my sytem date ??
 
 Simply from not reading the options carefully enough, from ?strptime,
 
   '%y' Year without century (00-99). If you use this on input,
 which
century you get is system-specific.  So don't!  Most often
values 00 to 68 are prefixed by 20 and 69 to 99 by 19 - that
is the behaviour specified by the 2001 POSIX standard, but
 it
does also say 'it is expected that in a future version of
IEEE Std 1003.1-2001 the default century inferred from a
2-digit year will change'.
 
   '%Y' Year with century.
 
 
 You want %Y, not %y.

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

2010-06-01 Thread Erik Iverson



Stella Pachidi wrote:

Dear Erik and R experts,

Thank you for the fast response!

I include an example with the ChickWeight dataset:

ap.dat - ChickWeight

matchMeanEx - function(ind,dataTable,aggrTable)
{
   index - which((aggrTable[,1]==dataTable[[Diet]][ind])  
(aggrTable[,2]==dataTable[[Chick]][ind]))

   as.numeric(aggrTable[index,3])
}

avgW - aggregate(ap.dat[[weight]], by = list(ap.dat[[Diet]], 
ap.dat[[Chick]]), FUN=mean)

meanW - sapply((1:length(ap.dat[,1])), FUN=matchMeanEx, ap.dat, avgW)
ap.dat - cbind (ap.dat, meanW)




How about simply using ave.

ap.dat$meanW - ave(ap.dat$weight, list(ap.dat$Diet, ap.dat$Chick))

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] any doc to understand arima state space model?

2010-06-01 Thread Joris Meys
Type in Google

Arima R

Read the first hit, the third, the fifth, and any other that says tutorial

Cheers
Joris

On Tue, Jun 1, 2010 at 4:14 PM, shakira M m.shak...@gmail.com wrote:

 I am trying to understand R arima function. Any pointers would be
 appreciated.

 Thank you,
 Shakira.

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




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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 on aggregate method

2010-06-01 Thread Stella Pachidi
Dear Erik,

Thank you very much. Indeed ave did the same job amazingly fast! I did not
know the function before.

Many thanks to all R experts who answer to this mailing list, it's amazing
how much help you offer to the newbies :)

Kind regards,
Stella

On Tue, Jun 1, 2010 at 6:11 PM, Erik Iverson er...@ccbr.umn.edu wrote:



 Stella Pachidi wrote:

 Dear Erik and R experts,

 Thank you for the fast response!

 I include an example with the ChickWeight dataset:

 ap.dat - ChickWeight

 matchMeanEx - function(ind,dataTable,aggrTable)
 {
   index - which((aggrTable[,1]==dataTable[[Diet]][ind]) 
 (aggrTable[,2]==dataTable[[Chick]][ind]))
   as.numeric(aggrTable[index,3])
 }

 avgW - aggregate(ap.dat[[weight]], by = list(ap.dat[[Diet]],
 ap.dat[[Chick]]), FUN=mean)
 meanW - sapply((1:length(ap.dat[,1])), FUN=matchMeanEx, ap.dat, avgW)
 ap.dat - cbind (ap.dat, meanW)



 How about simply using ave.

 ap.dat$meanW - ave(ap.dat$weight, list(ap.dat$Diet, ap.dat$Chick))




-- 
Stella Pachidi
Master in Business Informatics student
Utrecht University
email: s.pach...@students.uu.nl
tel: +31644478898

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

2010-06-01 Thread khush ........
Dear All,

Thank you  very much for your kind help and support I got it.

Jeet

On Tue, Jun 1, 2010 at 5:32 PM, Jim Lemon j...@bitwrit.com.au wrote:

 On 06/01/2010 09:01 PM, khush  wrote:

 Dear All,

 I am newbie to R, and I wanted to plot a barplots with R and in such a way
 that It will also show me position which I can plot on the bar line.

 Here is my code that I am using to plot,

  chromosome- c(40.2, 35.6, 36.1, 29.6, 31, 29.6, 31, 29.4, 28.2, 23, 23,

 28.2)

 barplot (chromosome, col=purple, xlab=Oryza sativa Chromosomes,
 border

 = NA, space = 5, ylim = c(0,45))

 I wanted to mark the position say on chromosome 1 (40.2) I need to mark
 10.2
 and on other also.
 I also want to set the scale of y axis from 0,5,10,15,20,25,30,35,40,45
 i.e
 gap of 5 instead of 10.

 please help me to solve my querygurus.

  Hi Jeet,
 I think you want the x positions of the bars. Get them like this:

 xpos-barplot (chromosome, col=purple,

  xlab=Oryza sativa Chromosomes,
  border = NA, space = 5, ylim = c(0,45))

 Then you can place the extra labels using the values in xpos.
 For the custom y axis, add the argument yaxt=n to your plot command and
 then add the axis later. I suspect you will have to use something like the
 staxlab function in the plotrix package to get all those labels to display.

 Jim


[[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] discriminant analysis

2010-06-01 Thread Uwe Ligges

Which kind of discriminant analysis?
If you mean LDA, use lda() in package MASS and read the correpsonding 
book Modern Applied Statistics with S by Venables and Ripley published 
by Springer.


Uwe Ligges


On 01.06.2010 09:24, suman dhara wrote:

Sir,
Can you suggest  some function for discriminant analysis for Binary response
having continuous as well as categorical regressors.



Thanks,
Suman Dhara

[[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] Ignoring initial rows in a text file import

2010-06-01 Thread Uwe Ligges



On 01.06.2010 02:19, David Winsemius wrote:


On May 31, 2010, at 8:14 PM, jim holtman wrote:


try this:

input - readLines(yourfile.txt)
# determine start
start - grep(\tBegin Main\t, input)[1] # first line if many


Puzzled. I thought backslashes in grepping patterns needed to be
doubled? I guess not.




Well, yes, for a backslash, but here a tab is specified, but no 
backslash at all.


Additionally, see ?regex:
The current implementation interprets \a as BEL, \e as ESC, \f as FF, 
\n as LF, \r as CR and \t as TAB.


Uwe Ligges

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

2010-06-01 Thread Noah Silverman
Hi,

I used the term run, as each iteration of the Gibbs sampler produces
22 variables (coefficients for Beta in a regression model)


The example wont work


On 6/1/10 5:54 AM, Ben Bolker wrote:
 Noah Silverman noah at smartmediacorp.com writes:

   
 I'm running a long MCMC chain that is generating samples for 22 variables.

 I have each run of the chain as a row in a matrix.
 
   
 So:  Chain[,1] is the column with all the samples for variable one. 
 Chain[,2] is the column with all the samples for variable 2, etc. 
 
   The previous 2 paragraphs seemed contradictory until I realized
 that in the first paragraph you are using run to mean what I would
 usually call a sample ...

   
 I'd like to fit all 22 on a single page to print a nice summary.  It is
 OK if the graphs are small, I just need to show the overall shape and
 convergence.
 
   How about for example

   
 x - matrix(runif(22000),ncol=22)
 library(coda)
 m - as.mcmc(x)
 xyplot(m)
 xyplot(m,layout=c(4,6))
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Set resolution of embedded plots in pdf() or CairoPDF()

2010-06-01 Thread Uwe Ligges
Both pdf() and CairoPDF() produce vector graphics, hence there is no 
things such as resolution required here.


Uwe Ligges


On 27.05.2010 11:09, Will Eagle wrote:

Dear all,

how can I set the resolution of embedded plots in PDF using pdf() or
CairoPDF() to a value of e.g. 600 dpi to meet journal requirements?

Thanks in advance,

Will

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] library installation problem, invalid regular expression in help indices

2010-06-01 Thread Uwe Ligges
I guess something strange is loaded or changed in your personal startup 
scripts (i.e. through your Renviron or Rprofile settings.


Uwe Ligges




On 27.05.2010 15:34, Rainer Machne wrote:

Hi,

I have a strange package installation problem after update to R 2.11.0
on Fedora Core 12.

A colleague of mine with the very same Fedora and R versions doesn't
have this problem, while logging on to his computer but installing from
my settings and into my local library path also shows the problem, so it
seems to be related to some of my environment settings.

Installation of several packages fails during installation of help
indices. The error is:

Error: invalid regular expression '^[[:blank:]]*

The packages for which installation failes, with the respective help
files after which the error occurs:

robustbase: NOxEmissions
tuneR: lilyinput
kernlab: kha
rrcov: CovSest
seewave: wasp


Any ideas?

btw, i just copied my colleague's installation folders to mine, and it
seems to work; for me the problem is solved for now. But it would still
be good to know what the problem is.


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.


Re: [R] BreastCancer Dataset for Classification in kknn

2010-06-01 Thread Joris Meys
Hi Nitin,

It can be solved by splitting your data a bit different. You need more
training data than you have evaluation data, eg :
i1 = 1:400
i2=401:d

Then it works on my computer. No clue as to where the error originates from
though.

Cheers
Joris

On Tue, Jun 1, 2010 at 4:27 PM, Nitin niti...@gmail.com wrote:

 Dear All,

 I'm getting a error while trying to apply the BreastCancer dataset
 (package=mlbench) to kknn (package=kknn) that I don't understand as I'm new
 to R.
 The codes are as follow:

 rm = (list = ls())
 library(mlbench)
 data(BreastCancer)
 library(kknn)

 BCancer = na.omit(BreastCancer)
 d  = dim(BCancer)[1]
 i1 = seq(1, d, 2)
 i2 = seq(2, d, 2)

 t1 = BCancer[i1, ]
 t2 = BCancer[i2, ]
 y2  = BCancer[i2, 11]

 x = 10
 k = array(1:x, dim = c(x,1))
 ker = array(c( rectangular, triangular, epanechnikov, biweight,
triweight, cos, inv, gaussian), dim = c(8,1))

 f = function(x, ker){

BreastCancer.kknn  -  kknn(Class~., train = t1, test = t2, k = x,
kernel = ker, distance = 1)
fit = fitted(BreastCancer.kknn)

z - (fit==y2)
z.e - (100 - (length(y2)-length(z[!z]))/length(y2)*100 )
 }

 err.k = function(ker){
error.BreastCancer = apply(k,1,function(y) f(y, ker))
 }

 err.ker = apply(ker, 1, err.k)
 colnames(err.ker) = c(rectangular, triangular, epanechnikov,
 biweight,
triweight, cos, inv, gaussian)
 print(err.ker)

 It throws a error: Error in as.matrix(learn[, ind == i]) :
  (subscript) logical subscript too long
 In addition: Warning messages:
 1: In model.matrix.default(mt, mf) : variable 'Id' converted to a factor
 2: In model.matrix.default(mt, test) : variable 'Id' converted to a factor

 I tried the codes with other datasets in mlbench package and most of them
 working. That is the mistake here for this particular dataset and how can I
 solve it?

 Thanks
 Nitin

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




-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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] Fancy Page layout

2010-06-01 Thread Noah Silverman
Thanks Jim,

That helps.

Ben Bolker had a nice suggestion on how to get the lattice package to
easily plot all 22 variables in one window.

Ultimately, I'd like to generate a PDF that will print on a standard
(8.5 x 11) page.

A few things I'm still stuck are:
1) How to use the lattice command AND leave room at the bottom for a
text block
2) How to tell lattice the size of the window
3) How to integrate all this together - draw a big window, plot
trellis in the top half and then text box in the bottom.

Any thoughts?

-N


On 6/1/10 4:53 AM, Jim Lemon wrote:
 On 06/01/2010 04:16 AM, Noah Silverman wrote:
 Hi,

 Working on a report that is going to have a large number of graphs and
 summaries.  We have 80 groups with 20 variables each.

 Ideally, I'd like to produce ONE page for each group.  It would have two
 columns of 10 graphs and then the 5 number summary of the variables at
 the bottom.
 So, perhaps the top 2/3 of the page has the graphs and the bottom third
 has 20 rows of data summary(maybe a table of sorts.)
 This COULD be done in Latex, but would have to be hand coded for each of
 the 80 groups which would be painfully slow.

 I can easily do the graphs with par(mfrow=c(5,2))  band then draw the
 graphs in a loop.

 But I am stuck from here:

 1) How do I control the size of the plot window.  (Ideally, it should
 print to fill an 8.5 x 11 piece of paper)
 2) Is there a way to easily insert a 5 number summary (summary
 command) into the lower half of the page.

 Does anybody have any ideas??

 Hi Noah,
 One easy way is to leave some space at the bottom, either by using:

 par(mfrow=c(6,2))

 or the more flexible layout function, and then use text or a
 fancier function (textbox, boxed.labels, addtable2plot, etc.) to add
 your text after:

 par(xpd=NA)

 allows you to display the text anywhere you please. If you use a
 bitmap graphics device, make it big:

 png(numberoneofeighty.png,850,1100)

 so that it won't look lumpy on the printed page.

 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] Question about the license of an R package

2010-06-01 Thread Mauricio Zambrano
2010/6/1 Duncan Murdoch murdoch.dun...@gmail.com:
 Mauricio Zambrano wrote:

 Dear R-users,

 I'm developing a package that heavily depends on another package
 released under the GPL-2 license.


 Are you including code from that package in yours, or just making use of it?
  The former requires that you follow all the GPL rules about your own.  If
 you just use their package, then license your package any way you like.

Thank you very much for the information!.

I'm just using the packages, without including a single line of code.


 In addition, some few functions depends on other packages released
 under the following licences (as described in the corresponding pages
 of http://cran.r-project.org/web/packages/):

 GPL
 GPL =2.

 I want to release my package under a GPL = 2 license, and after
 reading the section 1.1.1 of the R-exts manual and looking at the
 compatibility matrix found on http://gplv3.fsf.org/dd3-faq,  I'm still
 in doubt if I can do that.

 I would appreciate if you could tell me if can I release my package
 under a GPL = 2 license considering the aforementioned licenses ?


 Finally, a general question:

 When a package is released under GPL =2, does it mean that the terms
 of the GPL-3 license apply or not ?


 I believe that's an offer to license under whatever version of the GPL (from
 2 up) that the person using your code chooses.  If GPL-3 offers something
 that GPL-2 doesn't (e.g. compatibility with other GPL-3 code), they can use
 that.  If GPL-3 places restrictions they don't like (e.g. incompatibility
 with GPL-2 code), they can use GPL-2.

 Duncan Murdoch

Thanks Duncan.

Knds,

Mauricio Zambrano B.

-- 
==
Dept. of Civil and Env. Engineering
University of Trento, Italy


 Thanks in advance for any help.

 Mauricio

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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-help spam detection; please help the moderators

2010-06-01 Thread Ted Harding
Hi Joris,
The matched a filter rule is the principal reason for holding
messages for moderation. Please don't become anxious about the
situation -- one of the reasons we have become concerned about
the situation is that people whose messages get held up do tend
to become worried about it. This is unnecessary -- they, and you,
are not really doing anything wrong!

As I understand it, the filter rules are set by the ethz.ch admins,
and even Martin does not seem to know, in detail, what they are.
Also, it is likely that the filters learn, and they may well
be learning from a lot of other emails received at eth.ch which
have nothing to do with R-help but which are true spam -- then the
headers of such messages could be folded into Bayes spam scores
which can trigger matched a filter rule.

As far as R-help is concerned, the situation seems to be that
gmail.com and nabble.com are important triggers (though there
are plenty of others). Lots of email addresses which do not have
the username ending in digits are trapped in this way.

In round figures, proportions I have logged myself amongst the
messages held because they matched a filter rule are:

non-gmail, non-nabble: 30%
non-gmail, nabble: 25%
gmail, non-nabble: 32%
gmail, nabble: 13%

gmail : 45%
nabble: 52%

The true nature of this situation is still unclear!

Ted.


On 01-Jun-10 16:00:40, Joris Meys wrote:
 Hi all,
 
 I also couldn't help but notice that some of my messages are bounced
 for following reason:
 
The message headers matched a filter rule
 
 I included the header of one of the messages below, but neither of
 these messages is sent trough Nabble, nor does any mail address has
 digits in it.
 I also never had that before. Did you change some of the rules somehow?
 
 Cheers
 Joris
 
 ---
 
 MIME-Version: 1.0
 Received: by 10.140.173.9 with HTTP; Fri, 28 May 2010 05:32:32 -0700
 (PDT)
 In-Reply-To:
 aanlktim9etuy2efynloh2lyn7m133ytjencdjpkgp...@mail.gmail.com
 References:
 aanlktikgc7v2zbsyrwcwbueezm8d24qj0vqeb2z1n...@mail.gmail.com
   aanlktim9etuy2efynloh2lyn7m133ytjencdjpkgp...@mail.gmail.com
 Date: Fri, 28 May 2010 14:32:32 +0200
 Delivered-To: jorism...@gmail.com
 Message-ID:
 aanlktimg4idyivhe1ek9mk6_rybjcnuu4msvwrvts...@mail.gmail.com
 Subject: Re: [R] How to get values out of a string using regular
 expressions?
 From: Joris Meys jorism...@gmail.com
 To: Gabor Grothendieck ggrothendi...@gmail.com
 Cc: R mailing list r-help@r-project.org
 Content-Type: multipart/alternative;
 boundary=000e0cd2295481515c0487a6b3be
 
 --000e0cd2295481515c0487a6b3be
 Content-Type: text/plain; charset=ISO-8859-1
 
 
 
 On Tue, Jun 1, 2010 at 3:25 PM, Martin Maechler
 maech...@stat.math.ethz.chwrote:
 
 Dear readers of R-help

 as most of you will *not* be aware, R-help has continued to work the
 way it does, only thanks to a dozen of volunteers,
 see https://stat.ethz.ch/mailman/listinfo/r-help .

 The volunteers manually moderate e-mails that look like spam (and
 sometimes are and sometimes are not).
 While much more than 90% of the spam is filtered out long before
 a human sees it, with the increasing sophistication of spammers,
 manual intervention has deemed to be necessary and served the
 community very well.

 OTOH, in recent weeks, the amount of work for the volunteers has
 increased, mainly because an increasingly number of non-spam postings
 are
 erronously tagged as possibly spam.
 We have discussed about this and done some analysis and found
 that most of these message that produce a considerable amount of
 extra work share two properties :
  1) they are posted via Nabble  {which *always* attaches a small
 pro-Nabble spam at the end of the
 message}
  2) the e-mail address of the sender is from a freemail
provider, quite often 'at gmail dot com', and often the part
*before* the '@' (at-sign) ends with digits.

 We hereby ask those among you who use a freemail account to
 please no longer post via nabble.

 Thank you for your support of R-help, *the* community mailing
 list of the R project since even before that project existed
 formally, namely since 1997-04-01,
 today 13 years and two months.

 Martin Maechler, ETH Zurich
 (and R-help creator and principal manager)

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

 
 
 
 -- 
 Joris Meys
 Statistical Consultant
 
 Ghent University
 Faculty of Bioscience Engineering
 Department of Applied mathematics, biometrics and process control
 
 Coupure Links 653
 B-9000 Gent
 
 tel : +32 9 264 59 87
 joris.m...@ugent.be
 ---
 Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
 
   [[alternative HTML version deleted]]
 
 

[R] Problem using apply

2010-06-01 Thread Joachim de Lezardiere
Hello ,

 

I can not get apply function to do what I want when doing stuff on rows.
Let's say I want to divide the rows of matrix by their mean, the below show
you get the same result weather you use 1 or 2, i.e. same result for columns
than for means..:( 

 

Thanks a lot for the help,

 

 

 

m = matrix( c(1,4,7,4,5,8,7,8,9), nrow = 3 )

 

divideByMean  = function( v ){

return( v/mean(v))

}

 

rowMean = c( mean( m[1,]),mean( m[2,]),mean( m[3,]) )

rowMean

 

colMean = c( mean( m[,1]),mean( m[,2]),mean( m[,3]) )

colMean

 

m

print(ByRow)

apply( m, 1, divideByMean)

 

print(ByCol)

apply( m, 2, divideByMean)

 

 

 


[[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] Problem using apply

2010-06-01 Thread Henrique Dallazuanna
The mean by col and by row are the same:

colMeans(m) == rowMeans(m)

So:

m / rowMeans(m) # You don't need apply here
m / colMeans(m)

On Tue, Jun 1, 2010 at 2:26 PM, Joachim de Lezardiere 
joachim.lez...@gmail.com wrote:

 Hello ,



 I can not get apply function to do what I want when doing stuff on rows.
 Let's say I want to divide the rows of matrix by their mean, the below show
 you get the same result weather you use 1 or 2, i.e. same result for
 columns
 than for means..:(



 Thanks a lot for the help,







 m = matrix( c(1,4,7,4,5,8,7,8,9), nrow = 3 )



 divideByMean  = function( v ){

 return( v/mean(v))

 }



 rowMean = c( mean( m[1,]),mean( m[2,]),mean( m[3,]) )

 rowMean



 colMean = c( mean( m[,1]),mean( m[,2]),mean( m[,3]) )

 colMean



 m

 print(ByRow)

 apply( m, 1, divideByMean)



 print(ByCol)

 apply( m, 2, divideByMean)








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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


  1   2   >