Re: [R] R on Linux - a primer

2010-03-18 Thread Mike Miller
Thanks for sharing the interesting information about cran2deb.  I was 
unaware of that project (but I did know that Dirk E. had been doing Octave 
and R binaries for Debian for years).  Dirk Eddelbuettel (you spelled his 
name correctly) and Charles Blundell gave a talk at UseR! 2009...


http://dirk.eddelbuettel.com/papers/useR2009cran2deb.pdf

...where they seem to claim that they chose to develop for Debian partly 
because of its similarity to Ubuntu:


Common platform -- as Debian forms the base for Ubuntu and several other 
derivative or single-focus distributions


Audience -- given the reach of Debian and Ubuntu, large number of users 
can be reached with little effort


But that was in July.  This what he was saying in November:

http://www.mail-archive.com/r-sig-deb...@r-project.org/msg00892.html

And this is what he was saying a month ago:

https://stat.ethz.ch/pipermail/r-sig-debian/2010-February/001042.html

I guess we just don't know if cran2deb works on Unbuntu and we don't know 
if Charles and Dirk will be providing binaries for Ubuntu.  Apparently, 
they want to reach the Ubuntu user base, but it is a lot of work for them 
and they aren't getting the resources they need to pull it off.


Mike


On Tue, 16 Mar 2010, Emmanuel Charpentier wrote:


Le dimanche 14 mars 2010 à 18:04 -0400, Axel Urbiz a écrit :

Hi,

I'm looking to move from Windows into a 64-bit Linux environment. Which is
the best Linux Flavor to use within R? To install R on this environment, do
I need to do any compiling?


I'd like to add two cents of folly to the (wise) advice you've received
already.

Indeed , Ubuntu is one very good distribution whose management system
has made the care and feeding of a Linux system a *lot* easier for the
not-so-system-oriented people like yours truly. Whereas my first
contacts with a Unix-like system were about 30 years ago (Oh my, how
time flies, and how far away are Xenix and our 68000 systems ...), I'm
*still* not fond of system maintenance for it's own sake. Ubuntu added
an (almost) fool-proof maintenance system to an excellent distribution
called Debian, thus lowering the Linux entry bar to as low as it can be
humanely made. Some pretended that Ubuntu was a code word for I'm too
stupid to configure Debian ; quite untrue ! It only means I'm too
busy|lazy to configure Debian, which is a Good Thing (TM).

But Debian has its strong points,  and one of them is *extremely* strong
for an R user : Dirk Eddelbuettel (whose name I'm almost surely
misspelling (sorry, Dirk !)) has created a marvelous system called
cran2deb which routinely creates binary Debian packages from (almost)
the 2000+ R packages available nowadays.

That might look small change : the basic tools used for
developing/compiling most R packages are small beer (at least by today's
standards).But some of them might depend on fiendishly
difficult-to-maintain foreign libraries. Dirk's cran2deb takes care of
that and creates any information that Debian's dpkg maintenance system
needs to automate *your* R maintenance chores by integrating them in
Debian's maintenance scheme, which is as automatic as you can get
without becoming an incomprehensible beast.

In fact, cran2deb is so good that Im seriously tempted to go back to
Debian (after almost 8 years of Debian use, Ubuntu's ease-of-use, easy
access to no-so-exotic hardware drivers (and the then-incessant
politically correct yack-yacking on some Debian mailing lists...) made
me switch to an early Ubuntu distribution). I did not yet switch back
(mostly for not-so-superficial hardware support reasons), but I
maintain a backup Debian installation for the hell of it and to test
waters. So far, they have been a lot less rough than they used to be,
but there are still occasional rows (e. g. a recent gotcha with
openoffice.org, which would have render myself unable to work with those
d*mn Word files for about a month, or forced me to do a maual repair
(which I hate...)).

So consider Debian as a (desirable) alternative to Ubuntu.

HTH,

Emmanuel Charpentier, DDS, MSc
affiliation withdrawn,
notwithstanding Frank Harrell's
whims...__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Adding text outside (lattice barchart) plotting region.

2010-03-18 Thread Deepayan Sarkar
On Thu, Mar 18, 2010 at 5:26 AM, Peng Cai pengcaimaill...@gmail.com wrote:
 Thanks Richard and Jim for your reply!

 @All:

 Is there a way to do this without altering default x-labels (because in my
 case there could be up to 30-40 x-labels and I may have to repeat the script
 multiple times with different x-lables).

 OR, not sure but can it be done by extending plotting region parameters for
 lattice plots (though I'm aware of how to change these).

The most general solution I can think of is to use the legend
functionality (whereby new grid objects can be used as legends). A
simple example is

dotplot(yield ~ year, data = barley,
legend = list(bottom =
  list(fun = textGrob,
   args = list(x = c(0.5, 1, 2), y = 0.5,
label = c(Month:, March, April),
   just = center, default.units
= native,
   vp = viewport(xscale = c(0.4,
2.6), yscale = c(0, 1))

More complex layouts will typically need frameGrob (see
lattice::draw.colorkey for an example). Note that the legend doesn't
know what the panel limits are, so you will need to tell it
explicitly.

-Deepayan


 Thanks,
 Peng Cai

 On Wed, Mar 17, 2010 at 7:27 PM, Jim Lemon j...@bitwrit.com.au wrote:

  On 03/18/2010 09:50 AM, Peng Cai wrote:

 Hi All,

 I need some help with adding text at the bottom of the graph (outside of
 default outline of graph).

 Say, I need to write Month:   01     04 below each of the two years in
 the
 following R code, something like this:

           ___
           |                         |
           |         Plot          |
           |___  __|
            1931          1932
 Month:   01              04

 # R code
 require(lattice)
 barchart(yield ~ year, data = barley,
   stack=TRUE,
   col=black,
   ylim=c(0,85)
 )


 Hi Peng,
 Try using mtext:

 mtext(Month:  01   04,side=1,line=2,at=0,adj=0)

 You may have to adjust the last three arguments to get it in the correct
 position.

 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.


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

2010-03-18 Thread ManInMoon

Thanks - that works
-- 
View this message in context: 
http://n4.nabble.com/Date-conversion-issue-tp1596548p1597627.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] Using indexing to manipulate data

2010-03-18 Thread Jim Lemon

On 03/18/2010 04:05 PM, duncandonutz wrote:


I know one of R's advantages is it's ability to index, eliminating the need
for control loops to select relevant data, so I thought this problem would
be easy.  I can't crack it.  I have looked through past postings, but
nothing seems to match this problem

I have a data set with one column of actors and one column of acts.  I need
a list that will give me a pair of actors in each row, provided they both
participated in the act.

Example:

The Data looks like this:
Jim A
BobA
BobC
Larry  D
Alice  C
Tom   F
Tom   D
Tom   A
Alice  B
NancyB

I would like this:
Jim  Bob
Jim  Tom
Bob Alice
Larry   Tom
AliceNancy

The order doesn't matter (Jim-Bob vs. Bob-Jim), but each pairing should be
counted only once.


Hi duncandonutz,
Try this:

actnames-read.table(junkfunc/names.dat,stringsAsFactors=FALSE)
actorpairs-NULL
for(act in unique(actnames$V2)) {
 actors-actnames$V1[actnames$V2 == act]
 nactors-length(actors)
 if(nactors  1) {
  indices-combn(nactors,2)
  for(i in 1:dim(indices)[2])
   actorpairs-
rbind(actorpairs,c(actors[indices[1,i]],actors[indices[2,i]]))
 }
}
actorpairs

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] Using indexing to manipulate data

2010-03-18 Thread Dimitris Rizopoulos

One approach is the following:

Dat - read.table(textConnection(
Jim A
BobA
BobC
Larry  D
Alice  C
Tom   F
Tom   D
Tom   A
Alice  B
NancyB))
closeAllConnections()
names(Dat) - c(name, act)


out - tapply(as.character(Dat$name), Dat$act, function (x) {
if (length(x)  2) c(x, ) else t(combn(x, 2))
})
unique(do.call(rbind, out))


I hope it helps.

Best,
Dimitris


On 3/18/2010 6:05 AM, duncandonutz wrote:


I know one of R's advantages is it's ability to index, eliminating the need
for control loops to select relevant data, so I thought this problem would
be easy.  I can't crack it.  I have looked through past postings, but
nothing seems to match this problem

I have a data set with one column of actors and one column of acts.  I need
a list that will give me a pair of actors in each row, provided they both
participated in the act.

Example:

The Data looks like this:
Jim A
BobA
BobC
Larry  D
Alice  C
Tom   F
Tom   D
Tom   A
Alice  B
NancyB

I would like this:
Jim  Bob
Jim  Tom
Bob Alice
Larry   Tom
AliceNancy

The order doesn't matter (Jim-Bob vs. Bob-Jim), but each pairing should be
counted only once.
Thanks!



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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

2010-03-18 Thread Gabor Grothendieck
Here are two solutions.  The first uses merge and the second uses
sqldf.  They both do a self join picking off the unique pairs.  The
sqldf solution also sorts the result:

# input
DF - structure(list(Actor = c(Jim, Bob, Bob, Larry, Alice,
Tom, Tom, Tom, Alice, Nancy), Act = c(A, A, C,
D, C, F, D, A, B, B)), .Names = c(Actor, Act
), class = data.frame, row.names = c(NA, -10L))

subset(unique(merge(DF, DF, by = 2)), Actor.x  Actor.y)

library(sqldf) # see http://sqldf.googlecode.com
sqldf(select A.Actor, A.Act, B.Act
from DF A join DF B
where A.Act = B.Act and A.Actor  B.Actor
order by A.Act, A.Actor)



On Thu, Mar 18, 2010 at 1:05 AM, duncandonutz dwads...@unm.edu wrote:

 I know one of R's advantages is it's ability to index, eliminating the need
 for control loops to select relevant data, so I thought this problem would
 be easy.  I can't crack it.  I have looked through past postings, but
 nothing seems to match this problem

 I have a data set with one column of actors and one column of acts.  I need
 a list that will give me a pair of actors in each row, provided they both
 participated in the act.

 Example:

 The Data looks like this:
 Jim         A
 Bob        A
 Bob        C
 Larry      D
 Alice      C
 Tom       F
 Tom       D
 Tom       A
 Alice      B
 Nancy    B

 I would like this:
 Jim      Bob
 Jim      Tom
 Bob     Alice
 Larry   Tom
 Alice    Nancy

 The order doesn't matter (Jim-Bob vs. Bob-Jim), but each pairing should be
 counted only once.
 Thanks!

 --
 View this message in context: 
 http://n4.nabble.com/Using-indexing-to-manipulate-data-tp1597547p1597547.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] Care to share an R presentation?

2010-03-18 Thread ONKELINX, Thierry
Have a look at this presentation of Matthew Keller:
http://www.matthewckeller.com/Lecture1.ppt

Best regards,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie  Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics  Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey
  

 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] Namens Paul Johnson
 Verzonden: donderdag 18 maart 2010 5:54
 Aan: R-help
 Onderwerp: [R] Care to share an R presentation?
 
 The R movement is picking up steam in the center of America.  
 People that ignored my R-enthusiasm 10 years ago are now 
 calling me up asking for presentations.  I need to make a 2  
 hour presentation to a collection of faculty and grad
 students who might like to use R. I don't want to make it 
 seem too complicated (as I often do), but I don't want to 
 mislead them to think it will be easy.
 
 I expect other r-help readers have been in this same 
 situation.  I have a recollection (5, 6 years ago) that one 
 of the R leaders had a slideshow for this exact purpose.  But 
 I can't find it now. There is a R-help similar request and 
 both John Fox and  Deepayan Sarkar offered links to their 
 materials.  However, the links aren't valid anymore.
 
 If I don't find a pre-existing example to work from, I'll 
 slap together a Beamer/Sweave presentation and post it where 
 future speech givers can get it.
 
 --
 Paul E. Johnson
 Professor, Political Science
 1541 Lilac Lane, Room 504
 University of Kansas
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

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

2010-03-18 Thread S Ellison

new_ns$chr - factor(new_ns$chr, levels=paste(1:22))


 Soyeon Kim yunni0...@gmail.com 18/03/2010 00:57 
Dear All,

My data looks like this
 new_ns
   chr nc_two nc_not_two
11488 58
22325114
33233 79
44200153
55239 53
66196313
77229 45
88231137
99164111
10  10156 45
11  11181 92
12  12179 52
13  13 72 30
14  14 73 62
15  15185 25
16  16 93 42
17  17 84 50
18  18 33 17
19  19 31 40
20  20 49  8
21  21 12 16
22  22 26 37

 new_ns$chr
 [1] 1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21 22
Levels: 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 3 4 5 6 7 8 9

but when I run this : plot(new_ns$chr,new_ns$nc_two)

the order of new_ns$chr is 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22
3 4 5 6 7 8 9
how can fix this order to 1  2  3  4  5  6  7  8  9  10 11 12 13 14 15
16 17 18 19 20 21 22 in the plot ?
I attached the plot.

Thank you ahead.

***
This email and any attachments are confidential. Any use...{{dropped:8}}

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

2010-03-18 Thread Duncan Murdoch

Worik R wrote:

Related:  I found the problem eventually.  It was a parameter that was too
large and the function called stop.

Looking at the documentation I see I can supply my own error handler.  Cool.

Are there already written error handlers that dump a stack trace?
  


See http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/, 
particularly the section on post-mortem debugging.  One of the choices 
described there is to set options(error=recover).


Duncan Murdoch

cheers
Worik

On Thu, Mar 18, 2010 at 2:58 PM, Worik R wor...@gmail.com wrote:

  

I have a large programme that after running half an hour or so fails with
an error

Error in x[value] - NA : only 0's may be mixed with negative subscripts

How can I find out where that error occurs?

If I have to do a binary search using error messages it will take a long
time!  Is there some way I can generate a stack trace?

cheers
Worik




[[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] question about multinom function (nnet)

2010-03-18 Thread Sergii Ivakhno

 

Hello Again,

Doesn't anyone know where the problem might be? I could not get any more
information from the help page.

Many thanks

Best

Sergii


[R] question about multinom function (nnet)


*   This message: [ Message body
http://tolstoy.newcastle.edu.au/R/e9/help/10/03/9009.html#start  ] [
More options
http://tolstoy.newcastle.edu.au/R/e9/help/10/03/9009.html#options2  ] 
*   Related messages: [ Next message
http://tolstoy.newcastle.edu.au/R/e9/help/10/03/9010.html  ] [
Previous message
http://tolstoy.newcastle.edu.au/R/e9/help/10/03/9008.html  ] 

From: Sergii Ivakhno Sergii.Ivakhno_at_cancer.org.uk
mailto:Sergii.Ivakhno_at_cancer.org.uk?Subject=Re:%20[R]%20question%20a
bout%20multinom%20function%20%28nnet%29  
Date: Wed, 17 Mar 2010 14:59:10 +


Hello Again,


Dear All. 

I have the following table that I want to analyze using multinom
function 

  freq segments sample 

4271 Seg1 tumour 

4311 Seg2 tumour 

3515 Seg1 normal 

3561 Seg2 normal   

I want to compare model with both factors to the one where only sample
is present. 

model1=multinom(freq~segments+sample,data=table) 

model2=multinom(freq~ sample,data=table)   

anova(model2,model1) 

Likelihood ratio tests of Multinomial Models   

Response: freq 

  Model Resid. df Resid. Dev Test Df LR stat. Pr(Chi) 

1 sample 6 5.5452609828 

2 segments + sample 3 0.0001600513 1 vs 2 3 5.545101 0.1359658   

What I do not understand is where df of 6 and 3 come from? Shouldn't
they be 2 and 1? 

Many thanks for your help in advance 

Sincerely 

Sergii  




Sergii Ivakhno 

PhD student 

Computational Biology Group 
Cancer Research UK Cambridge Research Institute Li Ka Shing Centre 
Robinson Way 
Cambridge CB2 0RE 
England 

+44 (0)1223 404293 (O) 
+44 (0)1223 404128 (F) 


http://www.compbio.group.cam.ac.uk http://www.compbio.group.cam.ac.uk/
http://www.compbio.group.cam.ac.uk/
http://www.compbio.group.cam.ac.uk/  / 

This communication is from Cancer Research UK. Our website is at
www.cancerresearchuk.org. We are a charity registered under number
1089464 and a company limited by guarantee registered in England  Wales
under number 4325234. Our registered address is 61 Lincoln's Inn Fields,
London WC2A 3PX. Our central telephone number is 020 7242 0200. 

This communication and any attachments contain information which is
confidential and may also be privileged. It is for the exclusive use of
the intended recipient(s). If you are not the intended recipient(s)
please note that any form of disclosure, distribution, copying or use of
this communication or the information in it or in any attachments is
strictly prohibited and may be unlawful. If you have received this
communication in error, please notify the sender and delete the email
and destroy any copies of it. 

E-mail communications cannot be guaranteed to be secure or error free,
as information could be intercepted, corrupted, amended, lost,
destroyed, arrive late or incomplete, or contain viruses. We do not
accept liability for any such matters or their consequences. Anyone who
communicates with us by e-mail is taken to accept the risks in doing so.


[[alternative HTML version deleted]] 


  
--
Sergii Ivakhno

PhD student

Computational Biology Group
Cancer Research UK Cambridge Research Institute
Li Ka Shing Centre
Robinson Way
Cambridge CB2 0RE
England

+44 (0)1223 404293 (O)
+44 (0)1223 404128 (F)

http://www.compbio.group.cam.ac.uk http://www.compbio.group.cam.ac.uk/
/


This communication is from Cancer Research UK. Our website is at 
www.cancerresearchuk.org. We are a charity registered under number 1089464 and 
a company limited by guarantee registered in England  Wales under number 
4325234. Our registered address is 61 Lincoln's Inn Fields, London WC2A 3PX. 
Our central telephone number is 020 7242 0200.

This communication and any attachments contain information which is 
confidential and may also be privileged.   It is for the exclusive use of the 
intended recipient(s).  If you are not the intended recipient(s) please note 
that any form of disclosure, distribution, copying or use of this communication 
or the information in it or in any attachments is strictly prohibited and may 
be unlawful.  If you have received this communication in error, please notify 
the sender and delete the email and destroy any copies of it.

E-mail communications cannot be guaranteed to be secure or error free, as 
information could be intercepted, corrupted, amended, lost, destroyed, arrive 
late or incomplete, or contain viruses.  We do not accept liability for any 
such matters or their consequences.  Anyone who communicates with us by e-mail 
is taken to accept the risks in doing so.
[[alternative HTML version deleted]]

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

Re: [R] replace NA value with 0

2010-03-18 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 17.03.2010 18:01:50:

 
 Building on the question how to replace NA with 0.
 
 My data set below has date, station 1, flags for station 1, station 2, 
flags
 for station 2, etc...
 
 I would like to make the values in the station columns equal to 1 and 
the NA
 in the station columns equal to 0 and then sum each row for the number 
of 1
 present in the row.
 
 head(data.matrix, n=10)
  date 05AE005 flg_05AE005 05AF010 flg_05AF010 05BM014 
flg_05BM014
 1  1900-01-01  NANA  NANA  NA NA
 2  1900-01-02  NANA  NANA  .23 NA
 3  1900-01-03  NANA  NANA  .45 NA
 4  1900-01-04  NANA  NANA  NA NA
 5  1900-01-05  NANA  NANA  NA NA
 6  1900-01-06  NANA  NANA  NA NA
 7  1900-01-07  0.75  NA  .09NA  NA NA
 8  1900-01-08  0.87  NA  .23NA  NA NA
 9  1900-01-09  0.26  NA  .78NA  NA NA
 10 1900-01-10  0.23  NA  NANA  NA NA
 
 # figure out which columns the data are in
 colpos - seq(2, by = 2, length.out = n)

What relation is colpos to data.matrix?

 
 # make value 1 and NA 0
 colpos[!is.na(colpos)] - 1.0
 colpos[is.na(colpos)] - 0.0
 
 # sum number of values on a given day
 rowsum(colpos, )

Do you want by chance to get how many nonnumeric values are in each row of 
your data frame in station columns?

If yes, try

colpos - seq(2, 7, by = 2)
rowSums(!is.na(data.matrix)[,colpos])

Regards
Petr


 
 
 The above script is what i have tried - and does not work. The values 
are
 not being replaced with 1s and the NAs with 0s and the rows are not 
being
 summed.
 
 any help would be greatly appreciated.
 
 E
 
 -- 
 View this message in context: 
http://n4.nabble.com/replace-NA-value-with-0-
 tp834446p1596779.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.


[R] recommendations on use of - operator

2010-03-18 Thread Dan Kelley
I have never used   -  but I noticed at 

http://github.com/jiho/r-utils/blob/master/beamer_colors.R

that some people do.  In fact, the above-named code has a sort of elegance 
about it (except for the use of = for assignment...).  To my eye,  -   calls 
to mind a type of assignment that is meant to stand out.  For example, perhaps 
it would make sense to use  -  to assign to things that are not expected to 
vary through the rest of the code block.

Q1: is there a convention, informal or otherwise, on when to use the   -   
operator?

Q2: if there is no convention, but if people think a convention might help, 
what would that convention be?

Dan Kelley, PhD
Professor and Graduate Coordinator
Dept. Oceanography, Dalhousie University, Halifax NS B3H 4J1
kelley@gmail.com (1-minute path on US server) or dan.kel...@dal.ca (2-hour 
path on Cdn server)
Phone 902 494 1694;  Fax  902 494 3877








[[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] language!!!

2010-03-18 Thread Katharina Gerstendorf

Hi,

 

there´s something that really bothers me about R and after hours and hours of 
internet research, I´m still stuck with the same problem: I installed R and it 
is in Spanish, as the system on my work. I would really like it in English and 
there seems to be no way to change that!?! I´m doing an abroad internship, so 
my Spanish is far from perfect and my tutorial is in English.

 

Is there any way that I´m not aware of to change the language environment of R?

 

Thanks a lot!

Katharina
  
_
[[elided Hotmail spam]]

[[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] Converting factors to numeric in a dataframe

2010-03-18 Thread Michael Glanville
Hi petr,

Thanks for the reply.

My original data is in comma separated variable (csv) format with variable
names in column 1 and numeric data in the remaining columns. The read.csv
command reads this data set into object name pcrdata as a dataframe where
the variable names and numeric data are conserved (as required). However,
when I transpose the table it becomes a matrix and all the data become
character. Using the as.data.frame command coerces the matrix to a
dataframe but, at the same time, changes all the data to factor. As far as
I can see, for my analysis I need to coerce the data in the matrix, formed
by transposition of the raw data, to factor in row 1 and numeric for the
remaining rows before then converting the matrix to a dataframe, using the
as.data.frame command. Is this the information you required and, if so, is
what I am asking at all possible?

Best wishes,

Mike

On 17 March 2010 15:13, Petr PIKAL petr.pi...@precheza.cz wrote:

 Hi

 r-help-boun...@r-project.org napsal dne 17.03.2010 15:23:34:

  I am currently trying to write a program that minimises the amount of
 work
  required for “auditable” qPCR data. At the moment I am using an Excel
 (.csv)
  spreadsheet as source data that has been transposed to the column format
  required for R to read. Unfortunately, this means I have* *to manually
  confirm the whole data set prior to doing any analysis, which is taking
 a
  considerable amount of time! My idea now is to read the raw data in
 directly
  and get R to do the transformation prior to analysis. The problem I now
 have
  is that, upon transposition, the data are converted to “character” in a
  matrix, rather than “factor” and “numeric” in a dataframe. I have
 succeeded
  in changing the matrix to a dataframe (via as.data.frame(object)), but
 this
  then converts all the data to “factor” which I can’t use for my analysis
  since, other than the column headings, I need the data to be numeric. I
 have
  tried coercing the data to numeric using the as() and as.numeric()
 commands,
  but this has no effect on the data format. I have no experience in
  programming and so am at a loss as to what to do: am I making a basic
 error
  in my programming or missing something essential (or both!)?
 
 
 
  I am using R version 2.9.0 at the moment, but this will change as soon
 as I
  have sorted this issue out. Below is the code I have put together, as
 you
  can see it is VERY brief but essential to allow my analysis to proceed:
 
 
 
  pcrdata-read.csv(File_path,header=FALSE)
 

 This is supposed to be data frame already. As you did not show us any of
 possible clues of data type like

 str(pcrdata)

 it is difficult to say.

 However from your description your original data are in columns which have
 numeric and character data together which is not possible. I believe that
 there are options for reading such data.

 
  pcrdata-as.data.frame(t(pcrdata))

 OK. Here you say you get data in columns but they are all character.

 
  pcrdata[2:51]-as.numeric(as.character(pcrdata))
 

 Here it depends whether they are all numeric or if some of them shall be
 character (factor). Functions like those above can not be used directly on
 data frames. You need to use apply.

 apply(pcrdata, 1, as.character)

 Exact sequence of required functions is impossible to guess without
 knowing structure of your objects.

 You shall also consult R intro and R data manuals.

 Regards
 Petr


 
 
  Any help would be gratefully appreciated,
 
 
 
  Mike Glanville
 
 [[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.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

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


Re: [R] Converting factors to numeric in a dataframe

2010-03-18 Thread Petr PIKAL
Hi Michael


r-help-boun...@r-project.org napsal dne 18.03.2010 12:02:19:

 Hi petr,
 
 Thanks for the reply.
 
 My original data is in comma separated variable (csv) format with 
variable
 names in column 1 and numeric data in the remaining columns. The 
read.csv
 command reads this data set into object name pcrdata as a dataframe 
where
 the variable names and numeric data are conserved (as required). 
However,

So why not transpose only numeric part, then set it to data frame and add 
column names from first column.

Something like (untested)

pcrdata-read.csv(File_path,header=FALSE)

numdata-t(pcrdata[,-1])
numdata-data.frame(numdata)
names(numdata) - pcrdata[,1]

Regards
Petr



 when I transpose the table it becomes a matrix and all the data become
 character. Using the as.data.frame command coerces the matrix to a
 dataframe but, at the same time, changes all the data to factor. As 
far as
 I can see, for my analysis I need to coerce the data in the matrix, 
formed
 by transposition of the raw data, to factor in row 1 and numeric for 
the
 remaining rows before then converting the matrix to a dataframe, using 
the
 as.data.frame command. Is this the information you required and, if 
so, is
 what I am asking at all possible?
 
 Best wishes,
 
 Mike
 
 On 17 March 2010 15:13, Petr PIKAL petr.pi...@precheza.cz wrote:
 
  Hi
 
  r-help-boun...@r-project.org napsal dne 17.03.2010 15:23:34:
 
   I am currently trying to write a program that minimises the amount 
of
  work
   required for “auditable” qPCR data. At the moment I am using an 
Excel
  (.csv)
   spreadsheet as source data that has been transposed to the column 
format
   required for R to read. Unfortunately, this means I have* *to 
manually
   confirm the whole data set prior to doing any analysis, which is 
taking
  a
   considerable amount of time! My idea now is to read the raw data in
  directly
   and get R to do the transformation prior to analysis. The problem I 
now
  have
   is that, upon transposition, the data are converted to “character” 
in a
   matrix, rather than “factor” and “numeric” in a dataframe. I have
  succeeded
   in changing the matrix to a dataframe (via as.data.frame(object)), 
but
  this
   then converts all the data to “factor” which I can’t use for my 
analysis
   since, other than the column headings, I need the data to be 
numeric. I
  have
   tried coercing the data to numeric using the as() and as.numeric()
  commands,
   but this has no effect on the data format. I have no experience in
   programming and so am at a loss as to what to do: am I making a 
basic
  error
   in my programming or missing something essential (or both!)?
  
  
  
   I am using R version 2.9.0 at the moment, but this will change as 
soon
  as I
   have sorted this issue out. Below is the code I have put together, 
as
  you
   can see it is VERY brief but essential to allow my analysis to 
proceed:
  
  
  
   pcrdata-read.csv(File_path,header=FALSE)
  
 
  This is supposed to be data frame already. As you did not show us any 
of
  possible clues of data type like
 
  str(pcrdata)
 
  it is difficult to say.
 
  However from your description your original data are in columns which 
have
  numeric and character data together which is not possible. I believe 
that
  there are options for reading such data.
 
  
   pcrdata-as.data.frame(t(pcrdata))
 
  OK. Here you say you get data in columns but they are all character.
 
  
   pcrdata[2:51]-as.numeric(as.character(pcrdata))
  
 
  Here it depends whether they are all numeric or if some of them shall 
be
  character (factor). Functions like those above can not be used 
directly on
  data frames. You need to use apply.
 
  apply(pcrdata, 1, as.character)
 
  Exact sequence of required functions is impossible to guess without
  knowing structure of your objects.
 
  You shall also consult R intro and R data manuals.
 
  Regards
  Petr
 
 
  
  
   Any help would be gratefully appreciated,
  
  
  
   Mike Glanville
  
  [[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.htmlhttp://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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 nlme and coxme (both!): Looking for workaround

2010-03-18 Thread Dieter Menne
I am trying to use nlme and coxme in one Sweave document. I have read the
thread in r-devel on the subject, 

http://markmail.org/thread/snchg6ynofrzbf2v

and nlme::fixef works, but I did not understand what workaround to use when
I am calling a function in a package that I do not want to change.

Dieter



library(nlme)
library(coxme) # hides fixef, among others

deplynestedforeingpackagefunction = function(x){
  # I do not want to change this function in another package
  fixef(x)
}

fit - coxme(Surv(time, status) ~ age + (1|ph.ecog), lung) 
fixef(fit)

fm1 - lme(distance ~ age, data = Orthodont)
nlme::fixef(fm1) # can use nlme::
# 
deplynestedforeingpackagefunction(fm1) #error



R version 2.10.1 (2009-12-14) 
i386-pc-mingw32 

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C   
[5] LC_TIME=German_Germany.1252

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

other attached packages:
[1] coxme_2.0   bdsmatrix_1.0   survival_2.35-8 nlme_3.1-96

loaded via a namespace (and not attached):
[1] grid_2.10.1lattice_0.18-3 tools_2.10.1  


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

2010-03-18 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 18.03.2010 11:16:26:

 
 Hi,
 
 
 
 there´s something that really bothers me about R and after hours and 
hours of 
 internet research, I´m still stuck with the same problem: I installed R 
and it
 is in Spanish, as the system on my work. I would really like it in 
English and
 there seems to be no way to change that!?! I´m doing an abroad 
internship, so 
 my Spanish is far from perfect and my tutorial is in English.
 
 
 
 Is there any way that I´m not aware of to change the language 
environment of R?

Maybe

?Sys.getlocale

Sys.setlocale(LC_ALL, Czech) # for Czech locale

Regards
Petr


 
 
 
 Thanks a lot!
 
 Katharina
 
 _
 [[elided Hotmail spam]]
 
[[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] language!!!

2010-03-18 Thread Berwin A Turlach
G'day Katharina,

On Thu, 18 Mar 2010 11:16:26 +0100
Katharina Gerstendorf katharin...@hotmail.com wrote:

 there_s something that really bothers me about R and after hours and
 hours of internet research, I_m still stuck with the same problem: 

And during these hours of research you did not come across the R
Windows FAQ available on CRAN and all mirrors?  E.g.:

http://cran.ms.unimelb.edu.au/bin/windows/base/rw-FAQ.html

particularly question 3.2 of that FAQ:


http://cran.ms.unimelb.edu.au/bin/windows/base/rw-FAQ.html#I-want-R-in-English_0021

 Thanks a lot!

You are welcome.

Cheers,

Berwin

== Full address 
Berwin A Turlach  Tel.: +61 (8) 6488 3338 (secr)
School of Maths and Stats (M019)+61 (8) 6488 3383 (self)
The University of Western Australia   FAX : +61 (8) 6488 1028
35 Stirling Highway   
Crawley WA 6009e-mail: ber...@maths.uwa.edu.au
Australiahttp://www.maths.uwa.edu.au/~berwin

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

2010-03-18 Thread Prof Brian Ripley

You haven't told us your OS, so it is probably Windows ...

This is an FAQ, specifically
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#I-want-R-in-English_0021

Since you seem to be unfamiliar with FAQs, there is a lot more useful 
information there, and the posting guide asked you to search them 
before posting.  (And certainly before 'hours and hours of internet 
research'.)


If you are not on Windows, see the 'R Installation and Administration 
Manual' section 7.2, or if you use the R.app GUI on Mac OS X see the 
relevant FAQ section 9. But in general R will use the same language as 
your OS, and if you don't want Spanish, simply change the language of 
the OS.


On Thu, 18 Mar 2010, Katharina Gerstendorf wrote:



Hi,



there?s something that really bothers me about R and after hours and 
hours of internet research, I?m still stuck with the same problem: I 
installed R and it is in Spanish, as the system on my work. I would 
really like it in English and there seems to be no way to change 
that!?! I?m doing an abroad internship, so my Spanish is far from 
perfect and my tutorial is in English.




Is there any way that I?m not aware of to change the language 
environment of R?




Thanks a lot!

Katharina


--
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] language!!!

2010-03-18 Thread Duncan Murdoch

On 18/03/2010 6:16 AM, Katharina Gerstendorf wrote:

Hi,

 


there´s something that really bothers me about R and after hours and hours of 
internet research, I´m still stuck with the same problem: I installed R and it 
is in Spanish, as the system on my work. I would really like it in English and 
there seems to be no way to change that!?! I´m doing an abroad internship, so 
my Spanish is far from perfect and my tutorial is in English.

 


Is there any way that I´m not aware of to change the language environment of R?


Yes, set the environment variable LANGUAGE to what you want.  This is 
described in detail in the R Installation and Administration manual. 
You can do this on the R command line, e.g. I normally get R in English, 
but can switch to Spanish by starting it as


Rgui LANGUAGE=es

The two letter language abbreviations are listed in 
http://en.wikipedia.org/wiki/ISO_639-1 and a document it links to.


Duncan Murdoch


 


Thanks a lot!

Katharina
 		 	   		  
_

[[elided Hotmail spam]]

[[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] recommendations on use of - operator

2010-03-18 Thread Duncan Murdoch

On 18/03/2010 7:08 AM, Dan Kelley wrote:
I have never used   -  but I noticed at 


http://github.com/jiho/r-utils/blob/master/beamer_colors.R

that some people do.  In fact, the above-named code has a sort of elegance about it (except for 
the use of = for assignment...).  To my eye,  -   calls to mind a type of 
assignment that is meant to stand out.  For example, perhaps it would make sense to use  -  
to assign to things that are not expected to vary through the rest of the code block.

Q1: is there a convention, informal or otherwise, on when to use the   -   
operator?


My recommendation would be never.  It's rarely used and unnecessary, 
so you'll just confuse people.  It also looks identical to the - 
operator in C for pointing to a member of a structure, another cause for 
confusion for some people.


Duncan Murdoch



Q2: if there is no convention, but if people think a convention might help, 
what would that convention be?

Dan Kelley, PhD
Professor and Graduate Coordinator
Dept. Oceanography, Dalhousie University, Halifax NS B3H 4J1
kelley@gmail.com (1-minute path on US server) or dan.kel...@dal.ca (2-hour 
path on Cdn server)
Phone 902 494 1694;  Fax  902 494 3877








[[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] Care to share an R presentation?

2010-03-18 Thread John Fox
Dear Paul,

There are links to materials from two R courses that I taught fairly recent
on my home page at http://socserv.mcmaster.ca/jfox/, and I always keep
links to course materials there.

Regards,
 John


John Fox
Senator William McMaster 
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of Paul Johnson
 Sent: March-18-10 12:54 AM
 To: R-help
 Subject: [R] Care to share an R presentation?
 
 The R movement is picking up steam in the center of America.  People
 that ignored my R-enthusiasm 10 years ago are now calling me up asking
 for presentations.  I need to make a 2  hour presentation to a
 collection of faculty and grad students who might like to use R. I
 don't want to make it seem too complicated (as I often do), but I
 don't want to mislead them to think it will be easy.
 
 I expect other r-help readers have been in this same situation.  I
 have a recollection (5, 6 years ago) that one of the R leaders had a
 slideshow for this exact purpose.  But I can't find it now. There is a
 R-help similar request and both John Fox and  Deepayan Sarkar offered
 links to their materials.  However, the links aren't valid anymore.
 
 If I don't find a pre-existing example to work from, I'll slap
 together a Beamer/Sweave presentation and post it where future speech
 givers can get it.
 
 --
 Paul E. Johnson
 Professor, Political Science
 1541 Lilac Lane, Room 504
 University of Kansas
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] recommendations on use of - operator

2010-03-18 Thread Prof Brian Ripley
- is usually only used when you suddenly remember you wanted to keep 
result of a computation, especially in the days before command-line 
editors were universal.


fn(a,b) ... oh I'd better keep that ... - z

On Thu, 18 Mar 2010, Dan Kelley wrote:


I have never used   -  but I noticed at

http://github.com/jiho/r-utils/blob/master/beamer_colors.R

that some people do.


In fact, the above-named code has a sort of elegance about it 
(except 
for the use of = for assignment...).  To my eye,  -   calls to mind a type of assignment that is meant to stand out.  For example, perhaps it would make sense to use  -  to assign to things that are not expected to vary through the rest of the code block.


Q1: is there a convention, informal or otherwise, on when to use the   -   
operator?

Q2: if there is no convention, but if people think a convention might help, 
what would that convention be?

Dan Kelley, PhD
Professor and Graduate Coordinator
Dept. Oceanography, Dalhousie University, Halifax NS B3H 4J1
kelley@gmail.com (1-minute path on US server) or dan.kel...@dal.ca (2-hour 
path on Cdn server)
Phone 902 494 1694;  Fax  902 494 3877








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



--
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] Converting factors to numeric in a dataframe

2010-03-18 Thread Petr PIKAL
Hi

as you did not provide data it is hard to say what is wrong.

You can see that it is working on dates similar what you described.

 test - data.frame(x=letters[1:10], y=rnorm(10), z=runif(10))
 test
   x   y  z
1  a  0.09980806 0.32211567
2  b  0.70559139 0.32204076
3  c -1.50514354 0.28267338


testnum-data.frame(t(test[,-1]))
names(testnum)-test[,1]
testnum
   a b  c d e   f g
y 0.09980806 0.7055914 -1.5051435 0.4421971 0.1041789 -1.54683799 
0.3405809
z 0.32211567 0.3220408  0.2826734 0.8819248 0.5189688  0.05171076 
0.4583101
  h  i j
y 2.3137394 -0.4953507 0.7668954
z 0.7515886  0.5876854 0.4192073


Regards
Petr



Michael Glanville michael.glanvill...@googlemail.com napsal dne 
18.03.2010 12:37:21:

 Thanks Petr, your suggestion has worked to a certain extent. The only 
issue is
 that the sample names don't appear in the final dataframe. However, I 
will 
 persevere and see what I can do.
  
 Many thanks for you invaluable help,
  
 Mike

 On 18 March 2010 11:23, Petr PIKAL petr.pi...@precheza.cz wrote:
 Hi Michael
 
 
 r-help-boun...@r-project.org napsal dne 18.03.2010 12:02:19:
 
  Hi petr,
 
  Thanks for the reply.
 
  My original data is in comma separated variable (csv) format with
 variable
  names in column 1 and numeric data in the remaining columns. The
 read.csv
  command reads this data set into object name pcrdata as a dataframe
 where
  the variable names and numeric data are conserved (as required).
 However,

 So why not transpose only numeric part, then set it to data frame and 
add
 column names from first column.
 
 Something like (untested)
 
 pcrdata-read.csv(File_path,header=FALSE)

 numdata-t(pcrdata[,-1])
 numdata-data.frame(numdata)
 names(numdata) - pcrdata[,1]
 
 Regards
 Petr


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

2010-03-18 Thread Rob Forler
ya it looks like you can't use predict to take in data.

In general you could do the following:


fit a model to n-(prediction sample set length). Then use the predict
function to do a 1 step forward forecast. Test to see how close it is to the
actual 1 value ahead.

Then train your model on n-(prediction sample set length-1). predict 1 step
ahead and compare to the next value. rinse and repeat.

-Rob

On Thu, Mar 18, 2010 at 2:59 AM, RAGHAVENDRA PRASAD 
raghav.npra...@gmail.com wrote:

 Hi,

 Thanks a lot.It was very useful to me.If i m correct we cant do real time
 Stock forecasting using R with ARIMA+GARCH model using garchFit or any other
 available packages which are avaibale in R as Predict function wont take any
 test data.

 Eg: predict(garch11sp500t, 10)

 We just need to give how for how many periods we need the forecast
 results.Is there any work around any packages avaiable where we can use test
 data for prediction like we have in Neural Nets package.


 Regards,
 Raghav


 On Wed, Mar 17, 2010 at 8:40 PM, Rob Forler rfor...@uchicago.edu wrote:

 Hi,

 I can help, but what you are saying doesn't make sense. firstly what is
 fitted.ga?

 You can use predict from the garchFit that will give the predictions for
 fitted.gar for example.

 For example,

 library(fGarch)
 library(tseries)
 library(moments)

 data = get.hist.quote(instrument=^GSPC, 1990-01-01, 2010-02-01,
 quote = c(AdjClose),provider=c(yahoo))

 ret = diff(log(data))

 garch11sp500t = garchFit(~arma(1,1) +garch(1,1), data=ret,
 cond.dist=std)

  predtsp500 = predict(garch11sp500t, 10)
  predtsp500
meanForecast  meanError standardDeviation
 1  0.0013071158 0.010497830.01049783
 2  0.0011799772 0.010515550.01050872
 3  0.0010749574 0.010531070.01051959
 4  0.0009882084 0.010545090.01053042
 5  0.0009165514 0.010558070.01054123
 6  0.0008573608 0.010570340.01055201
 7  0.0008084679 0.010582110.01056276
 8  0.0007680811 0.010593540.01057349
 9  0.0007347205 0.010604720.01058418
 10 0.0007071638 0.010615720.01059485

 you will see that both the mean and the standard deviation is forecasted.
 This gives you both the stock forecast and the stocks' volatility
 forecast.

 now comparing the models you have a lot of different options. And it cares
 what you are looking to use the predictions for.

 In the above example imagine you were using the model to trade. You would
 want to pick the model that gives you the best pnl.

 Secondly you want to look at the acf and the pacf of the standarized
 residuals to makes sure that there are not any significant lags. Also you
 may want to look at the distribution of the residuals! are they really
 t-distributed? you can use a qq type test to determine this. if not you may
 have a model misspecification. you may need to use a skewed distribution or
 you may need to use something like aparch (in garchFit) which fits an
 asymmetric model/

 you also want to look at summary(garch11sp500t)
 look at :
 Error Analysis:
  Estimate  Std. Error  t value Pr(|t|)
 mu  1.003e-04   3.718e-052.697  0.00701 **
 ar1 8.260e-01   5.913e-02   13.971   2e-16 ***
 ma1-8.621e-01   5.267e-02  -16.368   2e-16 ***
 omega   4.090e-07   1.365e-072.998  0.00272 **
 alpha1  5.743e-02   6.607e-038.693   2e-16 ***
 beta1   9.409e-01   6.484e-03  145.123   2e-16 ***
 shape   6.990e+00   6.820e-01   10.249   2e-16 ***
 ---
 you can see here that all the coefficients are very significant.

 also,
   AIC   BIC   SIC  HQIC
 -6.539617 -6.530588 -6.539621 -6.536455

 are computed from the summary. Google these. Picking a model with a lower
 aic or bic can be another way to choose the model.

 If you need more help let me nkow,
 Rob

 On Wed, Mar 17, 2010 at 1:11 AM, RAGHAVENDRA PRASAD 
 raghav.npra...@gmail.com wrote:

 Hi,

 Although my doubt is pretty,as i m not from stats background i am not
 sure
 how to proceed on this.

 Currently i am doing a forecasting.I used ARIMA to forecast and time
 series
 was volatile i used garchFit for residuals.
 How to use the output of Garch to correct the forecasted values from
 ARIMA.

 Here is my code:

 ###delta is the data

 fit-arima(delta,order=c(2,,0,1))

 fit.res - resid(fit)
 ##Check for Residuals
 acf((fit.res-mean(fit.res))/sd(fit.res))
 acf(((fit.res-mean(fit.res))/sd(fit.res))^2)
 fit.fore = predict(fit, n.ahead=test)

 ##Use ARIMA GARCH To fit residuals from ARIMA Model
 1.
 fitted.gar-garchFit(formula
 =~arma(2,1)+garch(1,1),data=*fit.res*,cond.dist
 = std,trace=FALSE)
 sresi=fitted@residuals/fitted@sigma.t   ###Standardised
 Residuals
 acf(sresi)
 acf(sresi^2)
 fore.res-predict(fitted.ga, n.ahead=test)

 OR
 2.
 fitted.gar-garchFit(formula
 =~arma(2,1)+garch(1,1),data=*delta*,cond.dist =
 std,trace=FALSE)
 sresi=fitted@residuals/fitted@sigma.t   ###Standardised
 Residuals
 acf(sresi)
 acf(sresi^2)
 fore.res-predict(fitted.ga, n.ahead=test)

 

[R] unbind matrix?

2010-03-18 Thread ManInMoon

I have a function that take a variable number of arguments, each of which
must be a vector.

Is there a way to unbind a matrix that would pass the columns as vectors?

Myfunc-function(...) {
 [My code]
}

Myfunc(z[,1],z[,2])   works

but Myfunc(z[,1:2]) is passing a submatrix

Is there something like Myfunc(unbind(z[,1:2])) ??


-- 
View this message in context: 
http://n4.nabble.com/unbind-matrix-tp1597887p1597887.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] package debug not available in Ubuntu

2010-03-18 Thread zerdna

Hi, i have 8.10 Ubuntu, R version 2.7.1  on 64 bit pc. I install packages
fine, but when i try to do install.packages(debug) i get error message 

package 'debug' is not available

Does this package exist for Ubuntu?
-- 
View this message in context: 
http://n4.nabble.com/package-debug-not-available-in-Ubuntu-tp1597844p1597844.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] how to take multiple subsets from a matrix

2010-03-18 Thread dc896148

Thank!  This worked great!
-- 
View this message in context: 
http://n4.nabble.com/how-to-take-multiple-subsets-from-a-matrix-tp1597411p1597899.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] Regress a matrix on another matrix column by column

2010-03-18 Thread Frederick Ho
Hi everyone,

I have a response matrix (y) and two predictor matrices (x.a, x.b), how
should i proceed if i want to regress y on x.a and x.b column by column?

To be specific, what i want to do is:

y[,1]~x.a[,1]+x.b[,1]
y[,2]~x.a[,2]+x.b[,2]
.
.
.

I have tried lm(y~x1+x2) but it does not work as R treat that as:

y[,1]~x.a[,1]+x.a[,2]+...+x.b[,1]+x.b[,2]+...
.
.
.

Thanks.

Regards,
Fred

[[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] IRT simulation repeated

2010-03-18 Thread Helena
Hello R:
  i work on an IRT simulation research. I've written a code to generate a 
single dataset.As i will repeat simulating the data 100 times under every 
condition, how can i write the R code to make it run the single simulation 
code 100 times and save the generate results each time? 
   Thanks so much~

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

2010-03-18 Thread Ben Bolker
zerdna azege at yahoo.com writes:

 
 
 Hi, i have 8.10 Ubuntu, R version 2.7.1  on 64 bit pc. I install packages
 fine, but when i try to do install.packages(debug) i get error message 
 
 package 'debug' is not available
 
 Does this package exist for Ubuntu?

   Your problem is probably R 2.7.1 (several years old) rather than
Ubuntu.  I have no problem installing it (Ubuntu 8.10, R 2.10.1).

  Ben Bolker

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

2010-03-18 Thread David Winsemius



?c


On Mar 18, 2010, at 8:39 AM, ManInMoon wrote:



I have a function that take a variable number of arguments, each of  
which

must be a vector.

Is there a way to unbind a matrix that would pass the columns as  
vectors?


Myfunc-function(...) {
[My code]
}

Myfunc(z[,1],z[,2])   works

but Myfunc(z[,1:2]) is passing a submatrix

Is there something like Myfunc(unbind(z[,1:2])) ??


--
View this message in context: 
http://n4.nabble.com/unbind-matrix-tp1597887p1597887.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
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] Regress a matrix on another matrix column by column

2010-03-18 Thread Dimitris Rizopoulos

try this:

y - matrix(rnorm(100*100), 100, 100)
x.a - matrix(rnorm(100*100), 100, 100)
x.b - matrix(rnorm(100*100), 100, 100)

M - ncol(y)
models - vector(list, M)
for (m in 1:M) {
Dat - data.frame(y = y[, m], x.a = x.a[, m], x.b = x.b[, m])
models[[m]] - lm(y ~ ., data = Dat)
}

Moreover and depending on what exactly you want to extract from these 
models, it may be even faster if you use lm.fit() instead of lm().



I hope it helps.

Best,
Dimitris


On 3/18/2010 12:35 PM, Frederick Ho wrote:

Hi everyone,

I have a response matrix (y) and two predictor matrices (x.a, x.b), how
should i proceed if i want to regress y on x.a and x.b column by column?

To be specific, what i want to do is:

y[,1]~x.a[,1]+x.b[,1]
y[,2]~x.a[,2]+x.b[,2]
.
.
.

I have tried lm(y~x1+x2) but it does not work as R treat that as:

y[,1]~x.a[,1]+x.a[,2]+...+x.b[,1]+x.b[,2]+...
.
.
.

Thanks.

Regards,
Fred

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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


Re: [R] Help with calculating entropy of data

2010-03-18 Thread mnstn

Thanks Marsh,
I'll look in to those references.
MS
-- 
View this message in context: 
http://n4.nabble.com/Help-with-calculating-entropy-of-data-tp1593954p1597963.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] PCA - blank loadings

2010-03-18 Thread Uwe Ligges



On 17.03.2010 00:16, Xanthe Walker wrote:

Hi,

I have successfully completed a PCA and printed the loadings, however,
numerous values are blank. I know that this means the values are just very
small but not equal to zero.

Is there a way to print out the loadings, including the very small values, I
need them for graphing purposes.



See ?loadings and find that

 print(loadings(pca_object), cutoff=0)

shoudl print everything.

Although, if you want to use the loadings for generating graphics, you 
should work with the output directly, since thge information in the 
loadings object is much more precise than its pinted representation. Too 
see a bit more, type, e.g.:


l - loadings(pca_object)
l[]


Uwe Ligges




Thanks,
Xan

[[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] Regress a matrix on another matrix column by column

2010-03-18 Thread Henrique Dallazuanna
Try this:

mapply(function(y, x, z)lm(y ~ x + z), as.data.frame(y),
as.data.frame(x.a), as.data.frame(x.b), SIMPLIFY = FALSE)

On Thu, Mar 18, 2010 at 8:35 AM, Frederick Ho cres...@gmail.com wrote:
 Hi everyone,

 I have a response matrix (y) and two predictor matrices (x.a, x.b), how
 should i proceed if i want to regress y on x.a and x.b column by column?

 To be specific, what i want to do is:

 y[,1]~x.a[,1]+x.b[,1]
 y[,2]~x.a[,2]+x.b[,2]
 .
 .
 .

 I have tried lm(y~x1+x2) but it does not work as R treat that as:

 y[,1]~x.a[,1]+x.a[,2]+...+x.b[,1]+x.b[,2]+...
 .
 .
 .

 Thanks.

 Regards,
 Fred

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

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

2010-03-18 Thread ManInMoon

I am trying to un-c...
-- 
View this message in context: 
http://n4.nabble.com/unbind-matrix-tp1597887p1597987.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] cumsum for matrix

2010-03-18 Thread ManInMoon

IIs there an equivalent of cumsum for a matrix? i.e cumsum is applied to each
column ?


-- 
View this message in context: 
http://n4.nabble.com/cumsum-for-matrix-tp1597985p1597985.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] unbind matrix?

2010-03-18 Thread David Winsemius

Did you try it?


On Mar 18, 2010, at 10:03 AM, ManInMoon wrote:



I am trying to un-c...
--
View this message in context: 
http://n4.nabble.com/unbind-matrix-tp1597887p1597987.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
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] Using nlme and coxme (both!): Looking for workaround

2010-03-18 Thread Douglas Bates
On Thu, Mar 18, 2010 at 6:26 AM, Dieter Menne
dieter.me...@menne-biomed.de wrote:
 I am trying to use nlme and coxme in one Sweave document. I have read the
 thread in r-devel on the subject,

 http://markmail.org/thread/snchg6ynofrzbf2v

 and nlme::fixef works, but I did not understand what workaround to use when
 I am calling a function in a package that I do not want to change.

We discussed a fix for that which is to add a line to the NAMESPACE
file for any packages that want to define methods for the fixef or
ranef generic.  The line is simply

importFrom(nlme, fixef, ranef)

I thought Terry was going to add that in the coxme sources.



 library(nlme)
 library(coxme) # hides fixef, among others

 deplynestedforeingpackagefunction = function(x){
  # I do not want to change this function in another package
  fixef(x)
 }

 fit - coxme(Surv(time, status) ~ age + (1|ph.ecog), lung)
 fixef(fit)

 fm1 - lme(distance ~ age, data = Orthodont)
 nlme::fixef(fm1) # can use nlme::
 #
 deplynestedforeingpackagefunction(fm1) #error



 R version 2.10.1 (2009-12-14)
 i386-pc-mingw32

 locale:
 [1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
 [5] LC_TIME=German_Germany.1252

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

 other attached packages:
 [1] coxme_2.0       bdsmatrix_1.0   survival_2.35-8 nlme_3.1-96

 loaded via a namespace (and not attached):
 [1] grid_2.10.1    lattice_0.18-3 tools_2.10.1


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

2010-03-18 Thread Jorge Ivan Velez
Hi ManInMoon,

Perhaps the following  apply(yourmatrix, 2, cumsum, na.rm = TRUE) ?   See
?cumsum and ?apply for more information.

HTH,
Jorge


On Thu, Mar 18, 2010 at 10:01 AM, ManInMoon  wrote:


 IIs there an equivalent of cumsum for a matrix? i.e cumsum is applied to
 each
 column ?


 --
 View this message in context:
 http://n4.nabble.com/cumsum-for-matrix-tp1597985p1597985.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] How good is R at making publication quality tables?

2010-03-18 Thread Paul Miller
Hello Everyone,
 
At last count, I had 14 responses to my question. Thanks very much to everyone 
who replied, for helping me to understand that R is in fact capable of making 
publication quality tables and is very flexible in rendering these outputs. I'm 
still working my way through some of the basics of the program, but when it 
comes time to learn how to make tables I'll certainly know where to look for 
the necessary resources and information.
 
Thanks again,
 
Paul
 
 
 


  __
Make your browsing faster, safer, and easier with the new Internet 
Explorer[[elided Yahoo spam]]
com/ca/internetexplorer/
[[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] unbind matrix?

2010-03-18 Thread David Winsemius


I think I may have figured out what you _might_ have meant. An example  
would have speeded this process up considerably. Try:


apply(mtx, 2, function)  # perhaps within the MyFunc ... that you also  
did not provide.


--
David.

On Mar 18, 2010, at 10:03 AM, ManInMoon wrote:



I am trying to un-c...


--

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] two scales for one plot

2010-03-18 Thread Bunny, lautloscrew.com
Dear all, 

i am looking for a possibility to use two lines in the same plot with different 
scales. i.e the standard y-axis should represent the line created by vector x 
and the vertical line vice versa should be used as a second y-axis for the plot 
of vector y.  I´ve seen that often, particularly in the visualization of 
timelines (because the x-axis remains the same) and wonder if there´s a 
possibility to do so in R, too. If I am on the wrong list, please let me know. 
Thx in advance for any help.

best regards

bunny
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Pedigree / Identifying Immediate Family of Index Animal

2010-03-18 Thread Ben Bimber
I have a data frame containing the Id, Mother, Father and Sex from about
10,000 animals in our colony.  I am interested in graphing simple family
trees for a given subject or small number of subjects.  The basic idea is:
start with data frame from entire colony and list of index animals.  I need
to identify all immediate relatives of these index animals and plot the
pedigree for them.  We're not trying to do any sort of real analysis, just
present a visualization of the family structure.  I have used the kinship
and pedigree packages to plot the pedigree.  My question relates to
efficiently identifying the animals to include in the pedigree:

Starting with the data frame of ~10,000 records, I want to use a set of
index animals to extract the immediate relatives and plot only a small
number in the pedigree.  'Immediate relatives' is somewhat of an ambiguous
term - I am currently defining it as 3 generations forward and 3 backward.
Currently, I have a somewhat ugly approach where I recursively calculate
each generation forward or backward and build a new dataframe.  Is there a
better approach or package that does this?  I realize my code should be
written better to get rid of the loops, so if anyone has suggestions there I
would appreciate this as well.  Thanks in advance.

Code to calculate generations forward and backward:

#queryIds holds the unique Ids for parents of the index animals
queryIds = unique(c(ped$Sire, ped$Dam));
for(i in 1:gens){
if (length(queryIds) == 0){break};

#allPed is the dataframe with Id,Dam,Sire and Sex for animals in our
colony
newRows - subset(allPed, Id %in% queryIds);
queryIds = c(newRows$Sire, newRows$Dam);
ped - unique(rbind(newRows,ped));
}


#build forwards
#when calculating children, queryIds holds the Ids of the previous
generation
queryIds = unique(ped$Id);
for(i in 1:gens){
if (length(queryIds)==0){break};

#allPed is the dataframe with Id,Dam,Sire and Sex for animals in our
colony
newRows - subset(allPed, Sire %in% queryIds | Dam %in% queryIds);
queryIds = newRows$Id;
ped - unique(rbind(newRows,ped));
}

[[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] two scales for one plot

2010-03-18 Thread David Winsemius
In some sense you _are_ in the wrong list because there is a strong  
opposition to that presentation strategy, but there are plenty of  
worked examples in the archives and I believe that some plotting  
functions in plotrix will also do this, twoord.plot perhaps?



On Mar 18, 2010, at 10:40 AM, Bunny, lautloscrew.com wrote:


Dear all,

i am looking for a possibility to use two lines in the same plot  
with different scales. i.e the standard y-axis should represent the  
line created by vector x and the vertical line vice versa should be  
used as a second y-axis for the plot of vector y.  I´ve seen that  
often, particularly in the visualization of timelines (because the x- 
axis remains the same) and wonder if there´s a possibility to do so  
in R, too. If I am on the wrong list, please let me know. Thx in  
advance for any help.


best regards

bunny

--

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] offlist Re: Dataframe manipulation

2010-03-18 Thread Hosack, Michael
David,

A quick correction. I have been posting for less than one month (my first 
posting was Mar 5, verify if so inclined). Thank you for making me aware of 
dput and dump capabilities, I will use them in future posts. Secondly, I would 
assume that all of us are either directly or indirectly seeking assistance with 
'work' related R issues, either for a government agency, in school as 
preparation for future paid work, or in academics where one receives a salary 
for doing research, among other things. So, I don't see the relevance of your 
second point.  I doubt anyone here is learning R for the fun of it. I would 
rather be fishing, lol. I think my attached dataframe clearly shows what I want 
to do, and all I really want is some specific guidance (i.e. given relevant 
functions, etc.). I would LOVE to code this on my own. Thank you for your help 
thus far.

Mike


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Thursday, March 18, 2010 10:31 AM
To: Hosack, Michael
Subject: offlist Re: [R] Dataframe manipulation

Here's why I am not taking this one one. You've been posting similar  
problems for the last 6 months and you still have not learned how to  
use dput or dump to create cut and pastable R object descriptions...  
plus this looks like its a job and you are asking us to do your  
work... but that's only of secondary importance. It's the first  
concern that is primary. You are asking us to figure out what your  
data really looks like and repeat lots of steps that are already done.

-- 
David.

On Mar 18, 2010, at 9:48 AM, Hosack, Michael wrote:

 Hello R users,

 I spent most of my workday yesterday trying unsuccessfully to
 write code that will perform a series of calculations on my
 dataframe (partial copy is attached). What I need to do is
 multiply the 24 hr time in the 'DEPART' column by the time
 (in the 'TRAVEL' column (travel time in minutes), and store this
 result in the 'ARRIVE' column for the following 'SITE1' number.
 Then I need to add the 'WAIT' time (minutes) for that site's row
 to its 'ARRIVE' time to calculate the next 'DEPART' time and
 then proceed down the dataframe independently for each unique 'MM'
 by 'DD' combination. What I want to do I hope will be obvious after  
 you
 view the dataframe. Basically, for each unique 'MM' (month) by  
 'DD'(day) grouping
 I have four sites that are surveyed sequentially, and the starting
 site for a survey day was chosen randomly. The route is circular,
 proceeding from site 101 to 104. I really hope someone can help
 me with this, because I am so close to finishing it.

 BTW, the code that adds minutes to 24 hr time to create 24 hr time  
 is as follows:

 addTime2-function(timeTxt,mins){
 orig.date-as.POSIXct(paste(2001-01-01,timeTxt))
 new.Date-orig.date+mins*60
 new.Date-strsplit(as.character(new.Date), )
 new.Time-(sapply(new.Date,[,2))
 return(new.Time)
 }
 SCHEDULE2$DEPART-addTime2(SCHEDULE2$ARRIVE,SCHEDULE2$WAIT)
 (code courtesy of Gustaf)

 Thank you,

 Mike
 Dataframe.pdf__
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Dimnames of array inside loop

2010-03-18 Thread Márcio Resende

I read the post
http://n4.nabble.com/Error-setting-rowname-if-rowname-currently-NULL-td794579.html#a794579
where it says that the problem is that 
dimnames(acuracia) is Null -equivalent to rownames(fred) is NULL (in the
post)
Then I tried to define all the dimnames first as random names to be then
replaced in the loop
but it did not work either?

Does anyone have a clue?
Thanks a lot

-- 
View this message in context: 
http://n4.nabble.com/Dimnames-of-array-inside-loop-tp1594215p1598069.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] two scales for one plot

2010-03-18 Thread Christian Ruckert

Maybe this is what you are searching for:

2-Y-axes on same plot
https://stat.ethz.ch/pipermail/r-help/2008-December/182374.html

Best regards,
Christian

Bunny, lautloscrew.com wrotes:
Dear all, 


i am looking for a possibility to use two lines in the same plot with different 
scales. i.e the standard y-axis should represent the line created by vector x 
and the vertical line vice versa should be used as a second y-axis for the plot 
of vector y.  I´ve seen that often, particularly in the visualization of 
timelines (because the x-axis remains the same) and wonder if there´s a 
possibility to do so in R, too. If I am on the wrong list, please let me know. 
Thx in advance for any help.

best regards

bunny
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] R takes long time to open

2010-03-18 Thread Dimitri Liakhovitski
Hello.
Until today I've been using R2.9 and since today R2.10 (on a PC).
In both of them it takes about 20 sec for the prompt to appear IN R
console after I start R. And every time it says: Previous saved work
space restored - even if I have not saved any workspace or, in case
of R2.10 - even though I have not used it once.
In the older versions - R would start within 2-3 sec.
Is there any way to change some setting to make R open faster?

Thank you!

-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.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] two scales for one plot

2010-03-18 Thread Bunny, lautloscrew.com
thx everybody. The twoord.plot from the plotrix packages just helped ! 
Sometimes you just don´t find what you´re looking for - even if it is that 
simple... 

On 18.03.2010, at 15:59, Christian Ruckert wrote:

 Maybe this is what you are searching for:
 
 2-Y-axes on same plot
 https://stat.ethz.ch/pipermail/r-help/2008-December/182374.html
 
 Best regards,
 Christian
 
 Bunny, lautloscrew.com wrotes:
 Dear all, i am looking for a possibility to use two lines in the same plot 
 with different scales. i.e the standard y-axis should represent the line 
 created by vector x and the vertical line vice versa should be used as a 
 second y-axis for the plot of vector y.  I´ve seen that often, particularly 
 in the visualization of timelines (because the x-axis remains the same) and 
 wonder if there´s a possibility to do so in R, too. If I am on the wrong 
 list, please let me know. Thx in advance for any help.
 best regards
 bunny
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 takes long time to open

2010-03-18 Thread Dimitri Liakhovitski
Someone gave me a tip - it turns out I accidentally saved a workspace
in the directory R opens in and forgot about it.
I deleted it and my problem was solved.
Dimitri

On Thu, Mar 18, 2010 at 11:08 AM, Dimitri Liakhovitski ld7...@gmail.com wrote:
 Hello.
 Until today I've been using R2.9 and since today R2.10 (on a PC).
 In both of them it takes about 20 sec for the prompt to appear IN R
 console after I start R. And every time it says: Previous saved work
 space restored - even if I have not saved any workspace or, in case
 of R2.10 - even though I have not used it once.
 In the older versions - R would start within 2-3 sec.
 Is there any way to change some setting to make R open faster?

 Thank you!

 --
 Dimitri Liakhovitski
 Ninah.com
 dimitri.liakhovit...@ninah.com




-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.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] Reshape dataframe according to ordered variables

2010-03-18 Thread Duarte Viana
Dear all,

I am still a R apprentice... Apologies for the basic question.
I am trying to reshape a dataframe based on the order of two variables
(a character variable and a numerical variable). To simplify it,
consider the following dataframe

 df-data.frame(id=c(b,b,a,a,a),ord=c(2,1,1,3,2))

  id ord
1  b   2
2  b   1
3  a   1
4  a   3
5  a   2

I want to reshape it such that it results in this dataframe (id
alphabetically ordered and ranked according to the ord order)

df1-data.frame(id=c(a,a,a,b,b),ord=c(1,2,3,1,2))

  id ord
1  a   1
2  a   2
3  a   3
4  b   1
5  b   2

Thanks in advance,

Duarte Viana

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

2010-03-18 Thread Alla Bulashevska
Dear R users,
I'm running R version 2.10.1.
I tried installing the Cairo package and I got the
following message:


* installing *source* package ‘Cairo’ ...
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89...
none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e...
/bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for pkg-config... /usr/bin/pkg-config
checking whether pkg-config knows about cairo... no
configure: CAIRO_LIBS is unset, attempting to guess it.
configure: CAIRO_CFLAGS=
checking if R was compiled with the RConn patch... no
checking cairo.h usability... no
checking cairo.h presence... no
checking for cairo.h... no
configure: error: Cannot find cairo.h! Please install cairo
(http://www.cairogra
phics.org/) and/or set
CAIRO_CFLAGS/LIBS correspondingly.
ERROR: configuration failed for package ‘Cairo’

Any help would be greatly appreciated.
Alla

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


Re: [R] R takes long time to open

2010-03-18 Thread jim holtman
I have--no-save  --no-restoreon my startup of R  since I only
save/load explicitly what I want.

On Thu, Mar 18, 2010 at 11:24 AM, Dimitri Liakhovitski ld7...@gmail.comwrote:

 Someone gave me a tip - it turns out I accidentally saved a workspace
 in the directory R opens in and forgot about it.
 I deleted it and my problem was solved.
 Dimitri

 On Thu, Mar 18, 2010 at 11:08 AM, Dimitri Liakhovitski ld7...@gmail.com
 wrote:
  Hello.
  Until today I've been using R2.9 and since today R2.10 (on a PC).
  In both of them it takes about 20 sec for the prompt to appear IN R
  console after I start R. And every time it says: Previous saved work
  space restored - even if I have not saved any workspace or, in case
  of R2.10 - even though I have not used it once.
  In the older versions - R would start within 2-3 sec.
  Is there any way to change some setting to make R open faster?
 
  Thank you!
 
  --
  Dimitri Liakhovitski
  Ninah.com
  dimitri.liakhovit...@ninah.com
 



 --
 Dimitri Liakhovitski
 Ninah.com
 dimitri.liakhovit...@ninah.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.htmlhttp://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?

[[alternative HTML version deleted]]

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


[R] how to return date part of POSIXct

2010-03-18 Thread ManInMoon

How do I get a number representing a date from a POSIXct i.e. removing the
time elements?
-- 
View this message in context: 
http://n4.nabble.com/how-to-return-date-part-of-POSIXct-tp1598109p1598109.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] Reshape dataframe according to ordered variables

2010-03-18 Thread jim holtman
try this:

 df
  id ord
1  b   2
2  b   1
3  a   1
4  a   3
5  a   2
 df[order(df$id, df$ord),]
  id ord
3  a   1
5  a   2
4  a   3
2  b   1
1  b   2



On Thu, Mar 18, 2010 at 11:27 AM, Duarte Viana viana.s...@gmail.com wrote:

 Dear all,

 I am still a R apprentice... Apologies for the basic question.
 I am trying to reshape a dataframe based on the order of two variables
 (a character variable and a numerical variable). To simplify it,
 consider the following dataframe

  df-data.frame(id=c(b,b,a,a,a),ord=c(2,1,1,3,2))

  id ord
 1  b   2
 2  b   1
 3  a   1
 4  a   3
 5  a   2

 I want to reshape it such that it results in this dataframe (id
 alphabetically ordered and ranked according to the ord order)

 df1-data.frame(id=c(a,a,a,b,b),ord=c(1,2,3,1,2))

  id ord
 1  a   1
 2  a   2
 3  a   3
 4  b   1
 5  b   2

 Thanks in advance,

 Duarte Viana

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://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?

[[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] unbind matrix?

2010-03-18 Thread ManInMoon

Sorry David,

Here's cut down version of my function - real version does some fancy plot
formatting.

I have found a way round my problem because cbind will bind vectors and
matrices into a single matrix, which I can work with. It is not the answer I
was looking for - but it does the job.

Many thanks...


Myfunc-function(...) {
 parms-cbind(...)
 for (i in 1:ncol(parms)) {
   plot(parms[,i])
 }
}
-- 
View this message in context: 
http://n4.nabble.com/unbind-matrix-tp1597887p1598089.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] how to return date part of POSIXct

2010-03-18 Thread jim holtman
Does one of these work for you:

 x - as.POSIXct('2010-03-18 12:15')
 x
[1] 2010-03-18 12:15:00 EDT
 unclass(x)
[1] 1268928900
attr(,tzone)
[1] 
 as.vector(x)
[1] 1268928900



On Thu, Mar 18, 2010 at 11:18 AM, ManInMoon xmoon2...@googlemail.comwrote:


 How do I get a number representing a date from a POSIXct i.e. removing the
 time elements?
 --
 View this message in context:
 http://n4.nabble.com/how-to-return-date-part-of-POSIXct-tp1598109p1598109.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.htmlhttp://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?

[[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] Reshape dataframe according to ordered variables

2010-03-18 Thread MORNEAU François
Hello Duarte,
It seems that order is what you are looking for :
df - df[order(df$id, df$ord), ] 
Regards,
François

-Message d'origine-
De : r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] De la 
part de Duarte Viana
Envoyé : jeudi 18 mars 2010 16:27
À : r-help
Objet : [R] Reshape dataframe according to ordered variables

Dear all,

I am still a R apprentice... Apologies for the basic question.
I am trying to reshape a dataframe based on the order of two variables
(a character variable and a numerical variable). To simplify it,
consider the following dataframe

 df-data.frame(id=c(b,b,a,a,a),ord=c(2,1,1,3,2))

  id ord
1  b   2
2  b   1
3  a   1
4  a   3
5  a   2

I want to reshape it such that it results in this dataframe (id
alphabetically ordered and ranked according to the ord order)

df1-data.frame(id=c(a,a,a,b,b),ord=c(1,2,3,1,2))

  id ord
1  a   1
2  a   2
3  a   3
4  b   1
5  b   2

Thanks in advance,

Duarte Viana

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

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


Re: [R] how to return date part of POSIXct

2010-03-18 Thread David Winsemius


On Mar 18, 2010, at 11:37 AM, jim holtman wrote:


Does one of these work for you:


x - as.POSIXct('2010-03-18 12:15')
x

[1] 2010-03-18 12:15:00 EDT

unclass(x)

[1] 1268928900
attr(,tzone)
[1] 

as.vector(x)

[1] 1268928900


I was guessing he wanted:

 x - as.POSIXct('2010-03-18 12:15')
 as.Date(x)
[1] 2010-03-18

Or perhaps:
 unclass(as.Date(x))
[1] 14686

Hard to know since he persists in not following the Posting Guide's  
request to provide examples and specifics for the desired result.


--
David.






On Thu, Mar 18, 2010 at 11:18 AM, ManInMoon  
xmoon2...@googlemail.comwrote:




How do I get a number representing a date from a POSIXct i.e.  
removing the

time elements?
--
View this message in context:
http://n4.nabble.com/how-to-return-date-part-of-POSIXct-tp1598109p1598109.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.htmlhttp://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?

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


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] unbind matrix?

2010-03-18 Thread Bert Gunter
Convert your matrix to a data frame and use do.call().
?do.call

do.call(Myfunc, data.frame(yourMatrix))

You need to do the data frame conversion because do.call wants the arguments
as a list and a data frame **is** a list (the columns are the list members)
with a dim attribute (+ others).


Bert Gunter
Genentech Nonclinical Biostatistics
 
 -Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of ManInMoon
Sent: Thursday, March 18, 2010 5:39 AM
To: r-help@r-project.org
Subject: [R] unbind matrix?


I have a function that take a variable number of arguments, each of which
must be a vector.

Is there a way to unbind a matrix that would pass the columns as vectors?

Myfunc-function(...) {
 [My code]
}

Myfunc(z[,1],z[,2])   works

but Myfunc(z[,1:2]) is passing a submatrix

Is there something like Myfunc(unbind(z[,1:2])) ??


-- 
View this message in context:
http://n4.nabble.com/unbind-matrix-tp1597887p1597887.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] IRT simulation repeated

2010-03-18 Thread jim holtman
result - lapply(1:100, yourFunction)

On Thu, Mar 18, 2010 at 9:05 AM, Helena helenaguchen...@hotmail.com wrote:

 Hello R:
  i work on an IRT simulation research. I've written a code to generate a
 single dataset.As i will repeat simulating the data 100 times under every
 condition, how can i write the R code to make it run the single simulation
 code 100 times and save the generate results each time?
   Thanks so much~

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://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?

[[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-pkgs] package JM -- version 0.6-0

2010-03-18 Thread Dimitris Rizopoulos

Dear R-users,

I'd like to announce the release of the new version of package JM (soon 
available from CRAN) for the joint modelling of longitudinal and 
time-to-event data using shared parameter models. These models are 
applicable in mainly two settings. First, when focus is in the 
time-to-event outcome and we wish to account for the effect of a 
time-dependent covariate measured with error. Second, when focus is in 
the longitudinal outcome and we wish to correct for nonrandom dropout.


New features include:

* function survfitJM() has been added that calculates predictions of 
subject-specific survival probabilities given a history of longitudinal 
responses.


  * function dynC() has been added that calculates a dynamic 
concordance index for joint models. The function also returns 
time-dependent areas under the ROC curve.


  * method = ch-GH has been replaced by method = spline-PH-GH that 
fits a relative risk model with a B-spline-approximated baseline risk 
function. Similarly to method = ch-GH, the plan is that the same 
relative risk model with a B-spline-approximated baseline risk will also 
replace method = ch-Laplace.


  * method = spline-PH-GH allows for stratification, i.e., different 
spline coefficients are estimated for the different levels of a 
stratification factor. By default the knots positions are the same 
across strata -- this can be changed by either directly specifying the 
knots or by setting the control argument 'equal.strata.knots' to FALSE.


  * the new function wald.strata() can be used to test for equality of 
the spline coefficients among strata.


  * jointModel() has now the extra argument 'lag' that allows for 
lagged effects in the time-dependent covariate represented by the linear 
mixed model.


  * method = ph-GH that fits a relative risk with an unspecified 
baseline risk function has been renamed to method = Cox-PH-GH.


  * a bug was corrected in joint models with piecewise constant 
baseline risk function. In particular, the 'xi' parameters were reported 
as double their actual value.



As always, any kind of feedback (e.g., questions, suggestions, 
bug-reports, etc.) is more than welcome.


Best,
Dimitris

--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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


[R] R output to Rich Text Format

2010-03-18 Thread Alex Bryant
Hi,  Does anyone know of an existing package that will output to rtf?  
Something along the lines of pdf(ds,'file.pdf') or write.csv(ds,'file.csv').

Thanks,

//
// Alex Bryant
// Software Developer
// Integrated Clinical Systems, Inc.
// 908-996-7208



Confidentiality Note: This e-mail, and any attachment to...{{dropped:13}}

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


[R] Regression of a time series on its Quarters

2010-03-18 Thread Len Vir
# Dear List,

# I want to characterize a time series according to its Quarter components.

# My data (a.ts:
http://docs.google.com/View?id=dfvvwzr2_478cr9k4cdb)  look like:

# Qtr1  Qtr2  Qtr3  Qtr4
#   1948 -0.0714961837  0.0101747827  0.0654816569 -0.0227830729
#   1949 -0.1175517556  0.1151378692  0.1015777858 -0.1971535900
#   1950  0.0716002123  0.2551020416  0.0977574743 -0.0739337411
#    ...


#  The time series is 216 long

#  The easiest way I could figure out, is to create
#  Quarter dummies:

Q1 - rep(c(1,0,0,0),54)
Q2 - rep(c(0,1,0,0),54)
Q3 - rep(c(0,0,1,0),54)
Q4 - rep(c(0,0,0,1),54)

qtr - cbind(Q1,Q2,Q3,Q4)

# and then regress my data on the dummies.

summary(lm(a.ts ~ qtr - 1))

# The regression on 'Quarters' works fine.
# It does exactly what I want it to do.

# But!  Surely there must be a more elegant way
#   to accomplish the same thing ?!

# I have looked at the following packages (amongst others):
# tseries, timeSeries, TSA, AER, fSeries, vars, FinTS, xts, fArma,
# fRegression, tsfa, uroot, urca, ...

# without finding anything more convenient (simpler, nicer!).

# Any suggestion?

# Thank you.

# Len Vir

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] multiple print commands in win.metafile()

2010-03-18 Thread Kim Jung Hwa
Hi All,

I need a file which I can import to MS Word, I'm trying win.metafile(), but
it does not seem to support multiple print commands at once (please see
below). Is there an alternative to get plots file which can be used in
powerpoint/word?

# R code:
# this does not work; but same thing works with pdf()
library(lattice)
win.metafile(test.wmf)
p1 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
   type = a,
   auto.key =
   list(space = right, points = FALSE, lines = TRUE))

p2 - xyplot(sunspot.year ~ 1700:1988, xlab = , type = l,
   scales = list(x = list(alternating = 2)),
   main = Yearly Sunspots)

print(p1, split=c(1,1,2,1), more=TRUE)
print(p2, split=c(2,1,2,1))
dev.off()

Can anyone help please, thanks,
Kim

[[alternative HTML version deleted]]

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


[R] How to match two matrices with different dates

2010-03-18 Thread Loïc Marechal
Dear R users,

I am experiencing a problem, I am trying to merge two matrices composed like
this:

Matrix1 :

Col1 datetime  // Col2 Data1

Matrix2:

Col1 datetime // Col2 Data2

The datetime are matching most of the time, but on both matrices, there are
some values missing, and this generates a gap, so the two matrices don't
match.
Do you know which function I could use/create in order to make one matrix
out of this, like:

Matrix:

Col1 = datetime // Col2 = Data1 // Col3 = Data2

Thank you very much for your help,

Loïc.

[[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] multiple print commands in win.metafile()

2010-03-18 Thread jim holtman
?win.metafile


For win.metafile only one plot is allowed per file, and Windows seems to
disallow reusing the file. So the *only* way to allow multiple plots is to
use a parametrized filename as in the example.
win.metafile(Rplot%02d.wmf, pointsize = 10)
Notice the %02d in the file name.

On Thu, Mar 18, 2010 at 12:36 PM, Kim Jung Hwa kimhwamaill...@gmail.comwrote:

 Hi All,

 I need a file which I can import to MS Word, I'm trying win.metafile(), but
 it does not seem to support multiple print commands at once (please see
 below). Is there an alternative to get plots file which can be used in
 powerpoint/word?

 # R code:
 # this does not work; but same thing works with pdf()
 library(lattice)
 win.metafile(test.wmf)
 p1 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
   type = a,
   auto.key =
   list(space = right, points = FALSE, lines = TRUE))

 p2 - xyplot(sunspot.year ~ 1700:1988, xlab = , type = l,
   scales = list(x = list(alternating = 2)),
   main = Yearly Sunspots)

 print(p1, split=c(1,1,2,1), more=TRUE)
 print(p2, split=c(2,1,2,1))
 dev.off()

 Can anyone help please, thanks,
 Kim

[[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.htmlhttp://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?

[[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] Unable to install Cairo package

2010-03-18 Thread Sharpie


Alla Bulashevska wrote:
 
 Dear R users,
 I'm running R version 2.10.1.
 I tried installing the Cairo package and I got the
 following message:
 
 
 * installing *source* package ‘Cairo’ ...
 
 {snip}
 
 checking cairo.h usability... no
 checking cairo.h presence... no
 checking for cairo.h... no
 configure: error: Cannot find cairo.h! Please install cairo
 (http://www.cairogra
 phics.org/) and/or set
 CAIRO_CFLAGS/LIBS correspondingly.
 ERROR: configuration failed for package ‘Cairo’
 
 Any help would be greatly appreciated.
 Alla
 

The Cairo package for R provides an interface to the Cairo graphics library-
therefore that library must be installed for the package to work.  Configure
scripts are notorious for having cryptic error messages, but this one is
actually very explicit about stating what the problem is.

You need to:

  1. Install Cairo and try installing the package again.

Or, if you have Cairo installed in a non-standard location that the
configure script can't find:

  2. Set -L/path/to/libcairo in the CAIRO_CFLAGS option and try installing
again.

In cases when package installation is failing, it is also very important to
tell us what operating system you are using as these issues are often
platform-dependent.

Hope this helps!

-Charlie

-
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: 
http://n4.nabble.com/Unable-to-install-Cairo-package-tp1598140p1598264.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] How to match two matrices with different dates

2010-03-18 Thread jim holtman
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

example data would be useful.

Try 'merge' and the post processing of the data, but with no data, no idea
of what that might entail.

On Thu, Mar 18, 2010 at 12:40 PM, Loïc Marechal lym.marec...@gmail.comwrote:

 Dear R users,

 I am experiencing a problem, I am trying to merge two matrices composed
 like
 this:

 Matrix1 :

 Col1 datetime  // Col2 Data1

 Matrix2:

 Col1 datetime // Col2 Data2

 The datetime are matching most of the time, but on both matrices, there are
 some values missing, and this generates a gap, so the two matrices don't
 match.
 Do you know which function I could use/create in order to make one matrix
 out of this, like:

 Matrix:

 Col1 = datetime // Col2 = Data1 // Col3 = Data2

 Thank you very much for your help,

 Loďc.

[[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.htmlhttp://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?

[[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] Constrained non linear regression using ML

2010-03-18 Thread Corrado

Dear Gabor, Arne, Ravi, R users,

I am firstly trying the maximum likelihood approach, then will try the 
Bayesian approach.


The likelihood function, and the log likelihood function, will depend on 
the pdf of the error e in the formula:


y=f(theta*x)+e

Now let's say that e is  Gaussian distributed, then I can use LS which 
is the same as ML in this case, and the residuals would be distributed 
Gaussian. Is that right?


If e is distributed differently (for example: beta, in the continuous 
case,  or binomial, in the discrete case), then I am better off by using 
Maximum Likelihood. How would the residual be distributed? Should they 
not be distributed the same as e?


Best,

Gabor Grothendieck wrote:

For specific questions on the betareg package contact the maintainer.
If the likelihood based approaches are giving too much difficulty try
moving to a Bayesian framework (WinBUGS/R2WinBUGS, JAGS/r2jags, etc.)

On Wed, Mar 17, 2010 at 10:03 AM, Corrado ct...@york.ac.uk wrote:
  

Dear Arne, Gabor,

I solved the problem with betareg (downloaded the package). I run it on my
data, and unfortunately the  constraint is definitively active, if I remove
the active variables, I then remove the most significant variables!

Of course the error is important, not the distribution of the variable.

In this case, one of the assumptions is that the error may be distributed ~
beta. I think that betareg makes this assumption, am I right?

I am finding it difficult to solve two problems:

1) write the maximum likelihood function (what do you suggest?)
2) deal with the fact that a few factors actually have values of y (the
response) at the extremes: that is 0 and 1. But that mean that the link
function returns Infinite values in that case 
3) the error is dependent on E(y).

PS: Additional silly question: what is the discrete equivalent of beta?
binomial?

Arne Henningsen wrote:


On 17 March 2010 14:22, Gabor Grothendieck ggrothendi...@gmail.com
wrote:

  

Contact the maintainer regarding problems with the package.  Not sure
if this is acceptable but if you get it to run you could consider just
dropping the variables from your model that correspond to active
constraints.

Also try the maxLik package.  You will have to define the likelihood
yourself but it does support constraints.



Yes. And specifying the likelihood function is probably (depending on
your distributional assumptions) not too complicated.

BTW: Even if your y follows a beta distribution, it does not mean that
your error term also follows a beta distribution. And it the
distribution of the error term which is crucial for specifying the
likelihood function.

/Arne

  

--

Corrado Topi
PhD Researcher
Global Climate Change and Biodiversity
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk






--
Corrado Topi
PhD Researcher
Global Climate Change and Biodiversity
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


[R] Help with multiple output

2010-03-18 Thread Meng Wu

I am trying pairwise t-test with thousands of genes in different sample group

so I am trying some code like:

for (i in 1:length(GENE)){
 array[i]-pairwise.t.test(AGE6TTEST[[GENE[i]]],Lable,p.adj=fdr)
}

I want to put the output in an array list, then I can check them, but seems
I have the problem since there are multiple lines in the output of
pairwise.t.test. I usually only got the first line in the array[i] and also
warning messages.

I tried 
a1-pairwise.t.test(AGE6TTEST[[GENe[1]]],Lable,p.adj=fdr)

It worked

My questions, when I do these huge pairwise comparison, how can I output the
results ?

Thanks,

Meng


-- 
View this message in context: 
http://n4.nabble.com/Help-with-multiple-output-tp1598181p1598181.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] how to return date part of POSIXct

2010-03-18 Thread ManInMoon

You are right David - I found the as.Date by myself eventually(must be
getting better at this!)

But unclass is new to me - thanks very much
-- 
View this message in context: 
http://n4.nabble.com/how-to-return-date-part-of-POSIXct-tp1598109p1598250.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] [R-pkgs] spikeslab 1.0.0 now available on CRAN

2010-03-18 Thread Udaya B. Kogalur
Please find release 1.0.0 of the new CRAN package spikeslab now
available for download.  Thank you.

-

RELEASE 1.0.0 is the first and initial release of this package.

Fits a rescaled spike and slab model using a continuous bimodal
prior. Can be used for prediction and variable selection in low and
high-dimensional linear regression models.

Key features include:

o Option for ultra-fast handling of high-dimensional data.

o Variable selection using the generalized elastic net (gnet).

o Grouping of variables with unique regularization (no limit on the number).

o Predict wrapper for predicting on test data.

o Sparse PC approach for multiclass analysis of gene expression data.

o Depends on the randomForest and lars R-packages.


-

kogalursh...@gmail.com

Udaya B. Kogalur, Ph.D.
Adjunct Staff, Dept of Quantitative Health Sciences, Cleveland Clinic Foundation
President, Kogalur Shear Corporation
5425 Nestleway Drive, Suite L1
Clemmons, NC 27012

___
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] Using indexing to manipulate data

2010-03-18 Thread William Dunlap

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon
 Sent: Thursday, March 18, 2010 1:33 AM
 To: duncandonutz
 Cc: r-help@r-project.org
 Subject: Re: [R] Using indexing to manipulate data
 
 On 03/18/2010 04:05 PM, duncandonutz wrote:
 
  I know one of R's advantages is it's ability to index, 
 eliminating the need
  for control loops to select relevant data, so I thought 
 this problem would
  be easy.  I can't crack it.  I have looked through past 
 postings, but
  nothing seems to match this problem
 
  I have a data set with one column of actors and one column 
 of acts.  I need
  a list that will give me a pair of actors in each row, 
 provided they both
  participated in the act.
 
  Example:
 
  The Data looks like this:
  Jim A
  BobA
  BobC
  Larry  D
  Alice  C
  Tom   F
  Tom   D
  Tom   A
  Alice  B
  NancyB
 
  I would like this:
  Jim  Bob
  Jim  Tom
  Bob Alice
  Larry   Tom
  AliceNancy
 
  The order doesn't matter (Jim-Bob vs. Bob-Jim), but each 
 pairing should be
  counted only once.

You can use merge() to get all possible within-
group pairings and then eliminate the self-pairings
and the same-but-for-order pairings with the following
code:

   data - read.table(header=FALSE, textConnection(
  + Jim A
  + BobA
  + BobC
  + Larry  D
  + Alice  C
  + Tom   F
  + Tom   D
  + Tom   A
  + Alice  B
  + NancyB
  + )) # column names are now V1 and V2
   # add seqence numbers for elimination step
   data$seq - seq_len(nrow(data))
   tmp - merge(data,data,by=V2)
   result - tmp[tmp$seq.x  tmp$seq.y,] # omit unwanted pairings
   result
 V2  V1.x seq.x  V1.y seq.y
  2   A   Jim 1   Bob 2
  3   A   Jim 1   Tom 8
  6   A   Bob 2   Tom 8
  11  B Alice 9 Nancy10
  15  C   Bob 3 Alice 5
  20  D Larry 4   Tom 7
  
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 
 Hi duncandonutz,
 Try this:
 
 actnames-read.table(junkfunc/names.dat,stringsAsFactors=FALSE)
 actorpairs-NULL
 for(act in unique(actnames$V2)) {
   actors-actnames$V1[actnames$V2 == act]
   nactors-length(actors)
   if(nactors  1) {
indices-combn(nactors,2)
for(i in 1:dim(indices)[2])
 actorpairs-
  rbind(actorpairs,c(actors[indices[1,i]],actors[indices[2,i]]))
   }
 }
 actorpairs
 
 Jim
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

2010-03-18 Thread Loïc Marechal
Hello jim, thank you for your quick answer!

Here is an example:

  *TIME1**DATA1*  *TIME2  DATA2*
2   14:38:00  1.07212 14:38:00  1.51339
3   *14:40:00  1.07195 14:39:00  1.51330*
4   14:41:00  1.07218 14:40:00  1.51335
5   14:42:00  1.07246 14:41:00  1.51326
6   14:43:00  1.07229 14:42:00  1.51310
7   14:45:00  1.07226 14:45:00  1.51310
8   *14:46:00  1.07205 14:48:00  1.51357*
9   14:47:00  1.07078 14:49:00  1.51375
10  14:48:00  1.07155 14:50:00  1.51359
11  14:49:00  1.07184 14:51:00  1.51406
12  14:50:00  1.07114 14:52:00  1.51458

And I would like to get from this only one matrix, with the matching time
and the corresponding data.
Of course, some rows from one or another matrix will have to be removed.

Thank you very much again for your help!

Loïc.


2010/3/18 jim holtman jholt...@gmail.com

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

 example data would be useful.

 Try 'merge' and the post processing of the data, but with no data, no idea
 of what that might entail.

 On Thu, Mar 18, 2010 at 12:40 PM, Loïc Marechal 
 lym.marec...@gmail.comwrote:

 Dear R users,

 I am experiencing a problem, I am trying to merge two matrices composed
 like
 this:

 Matrix1 :

 Col1 datetime  // Col2 Data1

 Matrix2:

 Col1 datetime // Col2 Data2

 The datetime are matching most of the time, but on both matrices, there
 are
 some values missing, and this generates a gap, so the two matrices don't
 match.
 Do you know which function I could use/create in order to make one matrix
 out of this, like:

 Matrix:

 Col1 = datetime // Col2 = Data1 // Col3 = Data2

 Thank you very much for your help,

 Loďc.

[[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.htmlhttp://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?


[[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] Regression of a time series on its Quarters

2010-03-18 Thread Gabor Grothendieck
Try this:

lm(a.ts ~ factor(cycle(a.ts)) - 1)


On Thu, Mar 18, 2010 at 12:30 PM, Len Vir len...@gmail.com wrote:
 # Dear List,

 # I want to characterize a time series according to its Quarter components.

 # My data (a.ts:
 http://docs.google.com/View?id=dfvvwzr2_478cr9k4cdb)  look like:

 # Qtr1  Qtr2  Qtr3  Qtr4
 #   1948 -0.0714961837  0.0101747827  0.0654816569 -0.0227830729
 #   1949 -0.1175517556  0.1151378692  0.1015777858 -0.1971535900
 #   1950  0.0716002123  0.2551020416  0.0977574743 -0.0739337411
 #    ...


 #  The time series is 216 long

 #  The easiest way I could figure out, is to create
 #  Quarter dummies:

 Q1 - rep(c(1,0,0,0),54)
 Q2 - rep(c(0,1,0,0),54)
 Q3 - rep(c(0,0,1,0),54)
 Q4 - rep(c(0,0,0,1),54)

 qtr - cbind(Q1,Q2,Q3,Q4)

 # and then regress my data on the dummies.

 summary(lm(a.ts ~ qtr - 1))

 # The regression on 'Quarters' works fine.
 # It does exactly what I want it to do.

 # But!  Surely there must be a more elegant way
 #   to accomplish the same thing ?!

 # I have looked at the following packages (amongst others):
 # tseries, timeSeries, TSA, AER, fSeries, vars, FinTS, xts, fArma,
 # fRegression, tsfa, uroot, urca, ...

 # without finding anything more convenient (simpler, nicer!).

 # Any suggestion?

 # Thank you.

 # Len Vir

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Regression of a time series on its Quarters

2010-03-18 Thread Achim Zeileis

On Thu, 18 Mar 2010, Gabor Grothendieck wrote:


Try this:

lm(a.ts ~ factor(cycle(a.ts)) - 1)


An equivalent but somewhat more convenient interface is available in 
dynlm where you can say dynlm(a.ts ~ season(a.ts)) or

dynlm(a.ts ~ season(a.ts) - 1):

R dynlm(a.ts ~ season(a.ts))

Time series regression with ts data:
Start = 1947(2), End = 2000(4)

Call:
dynlm(formula = a.ts ~ season(a.ts))

Coefficients:
   (Intercept)  season(a.ts)Q2  season(a.ts)Q3  season(a.ts)Q4
   0.03069 0.01310-0.19455 0.09481


Best,
Z



On Thu, Mar 18, 2010 at 12:30 PM, Len Vir len...@gmail.com wrote:

# Dear List,

# I want to characterize a time series according to its Quarter components.

# My data (a.ts:
http://docs.google.com/View?id=dfvvwzr2_478cr9k4cdb)  look like:

# Qtr1  Qtr2  Qtr3  Qtr4
#   1948 -0.0714961837  0.0101747827  0.0654816569 -0.0227830729
#   1949 -0.1175517556  0.1151378692  0.1015777858 -0.1971535900
#   1950  0.0716002123  0.2551020416  0.0977574743 -0.0739337411
#    ...


#  The time series is 216 long

#  The easiest way I could figure out, is to create
#  Quarter dummies:

Q1 - rep(c(1,0,0,0),54)
Q2 - rep(c(0,1,0,0),54)
Q3 - rep(c(0,0,1,0),54)
Q4 - rep(c(0,0,0,1),54)

qtr - cbind(Q1,Q2,Q3,Q4)

# and then regress my data on the dummies.

summary(lm(a.ts ~ qtr - 1))

# The regression on 'Quarters' works fine.
# It does exactly what I want it to do.

# But!  Surely there must be a more elegant way
#   to accomplish the same thing ?!

# I have looked at the following packages (amongst others):
# tseries, timeSeries, TSA, AER, fSeries, vars, FinTS, xts, fArma,
# fRegression, tsfa, uroot, urca, ...

# without finding anything more convenient (simpler, nicer!).

# Any suggestion?

# Thank you.

# Len Vir

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



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


[R] list names

2010-03-18 Thread Robert M. Flight
So I have a list variable, and each item has a name. Is it possible to
return just the names in the list and not the contents of each one?

Example:

Currently, if I have a list variable matrices, and it contains 3
matrices, M1, M2, and M3, if I type:

matrices, R returns $M1 - listing of numbers in matrix; $M2 -
listing of numbers in matrix, and $M3 - listing of numbers in the
matrix.

Is there a way to have it return only the names $M1, $M2, $M3?

I know this seems trivial and I'm sure it has been asked before, but I
can't find it.

Thanks in advance.

-Robert

Robert M. Flight, Ph.D.
Bioinformatics and Biomedical Computing Laboratory
University of Louisville
Louisville, KY

PH 502-852-0467
EM robert.fli...@louisville.edu
EM rfligh...@gmail.com

Williams and Holland's Law:
   If enough data is collected, anything may be proven by
statistical methods.

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

2010-03-18 Thread Sharpie


Robert M. Flight wrote:
 
 So I have a list variable, and each item has a name. Is it possible to
 return just the names in the list and not the contents of each one?
 
 Example:
 
 Currently, if I have a list variable matrices, and it contains 3
 matrices, M1, M2, and M3, if I type:
 
 matrices, R returns $M1 - listing of numbers in matrix; $M2 -
 listing of numbers in matrix, and $M3 - listing of numbers in the
 matrix.
 
 Is there a way to have it return only the names $M1, $M2, $M3?
 
 I know this seems trivial and I'm sure it has been asked before, but I
 can't find it.
 
 Thanks in advance.
 
 -Robert
 

  ?names

The help.search() function can be useful for finding functions when you know
what you want to get done, but not which function does it.  For example:

  help.search( names )

Would list several functions and their descriptions would help you find the
one you wanted.

-Charlie

-
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: 
http://n4.nabble.com/list-names-tp1598316p1598330.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] list names

2010-03-18 Thread David Winsemius


On Mar 18, 2010, at 1:12 PM, Robert M. Flight wrote:


So I have a list variable, and each item has a name. Is it possible to
return just the names in the list and not the contents of each one?


?names



Example:

Currently, if I have a list variable matrices, and it contains 3
matrices, M1, M2, and M3, if I type:

matrices, R returns $M1 - listing of numbers in matrix; $M2 -
listing of numbers in matrix, and $M3 - listing of numbers in the
matrix.

Is there a way to have it return only the names $M1, $M2, $M3?

I know this seems trivial and I'm sure it has been asked before, but I
can't find it.

Thanks in advance.

-Robert

Robert M. Flight, Ph.D.
Bioinformatics and Biomedical Computing Laboratory
University of Louisville
Louisville, KY

PH 502-852-0467
EM robert.fli...@louisville.edu
EM rfligh...@gmail.com

Williams and Holland's Law:
  If enough data is collected, anything may be proven by
statistical methods.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Pedigree / Identifying Immediate Family of Index Animal

2010-03-18 Thread Charles C. Berry

On Thu, 18 Mar 2010, Ben Bimber wrote:


I have a data frame containing the Id, Mother, Father and Sex from about
10,000 animals in our colony.  I am interested in graphing simple family
trees for a given subject or small number of subjects.  The basic idea is:
start with data frame from entire colony and list of index animals.  I need
to identify all immediate relatives of these index animals and plot the
pedigree for them.  We're not trying to do any sort of real analysis, just
present a visualization of the family structure.  I have used the kinship
and pedigree packages to plot the pedigree.  My question relates to
efficiently identifying the animals to include in the pedigree:

Starting with the data frame of ~10,000 records, I want to use a set of
index animals to extract the immediate relatives and plot only a small
number in the pedigree.  'Immediate relatives' is somewhat of an ambiguous
term - I am currently defining it as 3 generations forward and 3 backward.
Currently, I have a somewhat ugly approach where I recursively calculate
each generation forward or backward and build a new dataframe.  Is there a
better approach or package that does this?  I realize my code should be
written better to get rid of the loops, so if anyone has suggestions there I
would appreciate this as well.  Thanks in advance.



Using an indicator matrix for parent/child relations, you can identify 
future/past generations using matrix multiplication(s).


Since you have 1 animals, the matrix indicating parents/children will 
be 1 x 1, but will have 2 non-zero elements.


To me, this sounds like a good candidate for a sparse matrix 
representation. Packages 'Matrix' and 'SparseM' provide these.


HTH,

Chuck




Code to calculate generations forward and backward:

#queryIds holds the unique Ids for parents of the index animals
queryIds = unique(c(ped$Sire, ped$Dam));
for(i in 1:gens){
   if (length(queryIds) == 0){break};

   #allPed is the dataframe with Id,Dam,Sire and Sex for animals in our
colony
   newRows - subset(allPed, Id %in% queryIds);
   queryIds = c(newRows$Sire, newRows$Dam);
   ped - unique(rbind(newRows,ped));
}


#build forwards
#when calculating children, queryIds holds the Ids of the previous
generation
queryIds = unique(ped$Id);
for(i in 1:gens){
   if (length(queryIds)==0){break};

   #allPed is the dataframe with Id,Dam,Sire and Sex for animals in our
colony
   newRows - subset(allPed, Sire %in% queryIds | Dam %in% queryIds);
   queryIds = newRows$Id;
   ped - unique(rbind(newRows,ped));
}

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



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.


[R] Using a function to consolidate variables

2010-03-18 Thread David Young
Dear List,

I'm getting the error: object of type 'closure' is not subsettable
And am not sure how to get around the problem.  I've included two
short code sets below.  One that shows what I want to do and works,
but without using the function much, and another that tries to use the
function but causes the error.

# THIS WORKS AND SHOWS WHAT I'D LIKE TO DO
a - c(1,2,3)
b - c(5,6,0)
c - data.frame(a,b)

# TAKES THE MAX OF TWO VARS AND SAVES IT TO A NEW VARIABLE AND DELETES OLD 
VARIABLES
consolidate.fun - function( data, var1, var2, saved.max ) {
max - apply( data[,c(var1, var2)], 1, max)

# THIS WORKS BUT I HAVE TO CALL THE DATA FRAME BY NAME RATHER THEN USING THE 
FUNCTION DATA NAME
c[,var.max] - max  
c$a - NULL
c$b - NULL
}
consolidate.fun( data=c , var1=a, var2=b, saved.max=var.max )
c

# THIS SHOWS THE MORE COMPLETE USE OF THE FUNCTION'S INTENT, BUT
#  CAUSES THE ERROR IN R.
a - c(1,2,3)
b - c(5,6,0)
c - data.frame(a,b)

# TAKES THE MAX OF TWO VARS AND SAVES IT TO A NEW VARIABLE AND DELETES OLD 
VARIABLES
consolidate.fun - function( data, var1, var2, saved.max ) {
max - apply( data[,c(var1, var2)], 1, max)

# SOURCE OF ERROR.  I'VE TRIED CALLING THE DATA FRAME IN DIFFERENT
#  WAYS, BUT NONE SEEM TO WORK FOR ME.
data[, saved.max ] - max  
data[, var1 ] - NULL
data[, var2 ] - NULL
}
consolidate.fun( data=c , var1=a, var2=b, saved.max=var.max )
c

Any helpful comments would be appreciated.


  mailto:dyo...@telefonica.net

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] multiple print commands in win.metafile()

2010-03-18 Thread Kim Jung Hwa
Hi Jim, thank you for your reply.

Apart from win.metafile(), is there some other function available which can
handle multiple prints or par(mfrow=c(2,2)) command and eventually can be
used in powerpoint/word. thanks,

Kim

On Thu, Mar 18, 2010 at 12:42 PM, jim holtman jholt...@gmail.com wrote:

 ?win.metafile


 For win.metafile only one plot is allowed per file, and Windows seems to
 disallow reusing the file. So the *only* way to allow multiple plots is to
 use a parametrized filename as in the example.
 win.metafile(Rplot%02d.wmf, pointsize = 10)
 Notice the %02d in the file name.

   On Thu, Mar 18, 2010 at 12:36 PM, Kim Jung Hwa kimhwamaill...@gmail.com
  wrote:

  Hi All,

 I need a file which I can import to MS Word, I'm trying win.metafile(),
 but
 it does not seem to support multiple print commands at once (please see
 below). Is there an alternative to get plots file which can be used in
 powerpoint/word?

 # R code:
 # this does not work; but same thing works with pdf()
 library(lattice)
 win.metafile(test.wmf)
 p1 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
   type = a,
   auto.key =
   list(space = right, points = FALSE, lines = TRUE))

 p2 - xyplot(sunspot.year ~ 1700:1988, xlab = , type = l,
   scales = list(x = list(alternating = 2)),
   main = Yearly Sunspots)

 print(p1, split=c(1,1,2,1), more=TRUE)
 print(p2, split=c(2,1,2,1))
 dev.off()

 Can anyone help please, thanks,
 Kim

[[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.htmlhttp://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?


[[alternative HTML version deleted]]

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


Re: [R] R output to Rich Text Format

2010-03-18 Thread lith
 Hi,  Does anyone know of an existing package that will output to rtf?  
 Something along the lines of pdf(ds,'file.pdf') or write.csv(ds,'file.csv').

You could use odfWeave and then use OpenOffice to generate an RTF
file.

Regards,
Tom

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

2010-03-18 Thread Orvalho Augusto
Thank you!

I did not know about this resource.

Caveman


On Thu, Mar 18, 2010 at 6:26 AM, David Winsemius dwinsem...@comcast.net wrote:

 On Mar 18, 2010, at 12:03 AM, Orvalho Augusto wrote:

 Dears!

 I have a system that generates links on a https webserver.

 I have to be logged on with a username and password; Then follow at
 least fife links to get into the link where I can download the file.

 The question is: How can I accomplish that with R?

 RSiteSearch(password https rcurl)

 Leading to:
 http://finzi.psych.upenn.edu/Rhelp10/2009-August/208582.html


 Caveman

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] merge.zoo produces non unique chron time series

2010-03-18 Thread Jan Schwanbeck

Dear all,

merge.zoo produces duplicated time indexes in the example stated below. 
Can anybody explain, what I am doing wrong?


Many thanks!

Jan

(R 2.10.0, WindowsXP)

require(chron)
require(zoo)

# create time series (zoo.ts) with no data from 31Aug2009 14:50 to 
3Sep2009 7:25

t.st - chron(31/08/2009,09:20:00,format=c(d/m/Y,h:m:s))
t.nd - chron(31/08/2009,14:50:00,format=c(d/m/Y,h:m:s))
t.indexA-seq(t.st,t.nd,by=1/(24*12))

t.st - chron(03/09/2009,07:25:00,format=c(d/m/Y,h:m:s))
t.nd - chron(03/09/2009,23:55:00,format=c(d/m/Y,h:m:s))
t.indexB-seq(t.st,t.nd,by=1/(24*12))

t.index-c(t.indexA,t.indexB)

zoo.ts - zoo(0,t.index)

# create reference time series (zoo.ts.pot) without missing time steps
t.st - head(time(zoo.ts),1)
t.nd - tail(time(zoo.ts),1)
t.index-seq(t.st,t.nd,by=1/(24*12))
zoo.ts.pot - zoo(NA,t.index)

# merge erroneous time series with reference time series
zoo.ts.cor - merge.zoo(zoo.ts.pot,zoo.ts)


 Do not run: Results:
  zoo.ts.pot zoo.ts
(31/08/09 09:20:00) NA  0
(31/08/09 09:25:00) NA  0
(31/08/09 09:30:00) NA  0
...
(31/08/09 14:50:00) NA  0
(31/08/09 14:55:00) NA NA
(31/08/09 15:00:00) NA NA
(31/08/09 15:05:00) NA NA
...
(03/09/09 07:15:00) NA NA
(03/09/09 07:20:00) NA NA
(03/09/09 07:25:00) NA  0
(03/09/09 07:30:00) NA  0
(03/09/09 07:35:00) NA  0
(03/09/09 07:40:00) NA  0
(03/09/09 07:45:00) NA  0
(03/09/09 07:50:00) NA  0
(03/09/09 07:55:00) NA  0
(03/09/09 08:00:00) NA  0
# everything o.k. up to here
(03/09/09 08:00:00) NA NA
# from here: every tenth time stamp is duplicated. Why?
...
(03/09/09 08:45:00) NA  0
(03/09/09 08:45:00) NA NA
..
(03/09/09 09:30:00) NA  0
(03/09/09 09:30:00) NA NA
...

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

2010-03-18 Thread Peng Cai
Hi All,

I'm trying to get following but not successfully:

# this works okay
ylab=expression(PM2.5 Concentration (*mu*g/m^3*))

# But I need 2.5 as a subscript to PM and below this an additional line
saying some text, like.
ylab=expression(PM[2.5] Concentration (*mu*g/m^3*)\n(random text in
brackets))

Square brackets doesn't seem to work because I'm using them in  and \n
operator is not working too. Any help would be highly appreciated, thanks,
Peng Cai

[[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] strptime(): on Linux system it seems to call system time?

2010-03-18 Thread Alexander Peterhansl
Dear List,

 

For what I understand, strptime() simply converts from one class
representation to another; i.e., from character to POSIXct/POSIXlt.

 

One strange feature of this command running on Linux is that there are
repeated calls to system time (as was revealed in a trace of system
calls), which considerably affect performance.  These system calls end
up taking almost 75% of the execution time, and are completely
unnecessary.

 

Code:

ptm - proc.time()

for (i in 1:10) strptime(2010-03-10 17:00:00, %F %H:%M:%S)

(proc.time() -ptm)

 

Output on Windows Box (32-bit R 2.9.1 running on Intel X5472 @ 3.0 GHz):

   user  system elapsed 

   1.310.021.30

 

Output on Linux Box (64-bit R 2.10.1 running on Intel Xeon E5520 @
2.27GHz):

   user  system elapsed 

   3.338.94112.273

 

Any help would be appreciated.  Also, if I should turn to a different
mailing list for this, please let me know.

 

Regards,

Alex  


[[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] greek symbols on ylab=

2010-03-18 Thread Henrique Dallazuanna
Try this:

par(mar = c(5.1, 6, 4, 2))
plot(1, ylab = '')
mtext(expression(PM[2.5] ~ Concentration ~(mu*g/m^3)), side = 2, line = 4)
mtext((random text in brackets), side = 2, line = 3, cex = 0.8)

On Thu, Mar 18, 2010 at 3:02 PM, Peng Cai pengcaimaill...@gmail.com wrote:
 Hi All,

 I'm trying to get following but not successfully:

 # this works okay
 ylab=expression(PM2.5 Concentration (*mu*g/m^3*))

 # But I need 2.5 as a subscript to PM and below this an additional line
 saying some text, like.
 ylab=expression(PM[2.5] Concentration (*mu*g/m^3*)\n(random text in
 brackets))

 Square brackets doesn't seem to work because I'm using them in  and \n
 operator is not working too. Any help would be highly appreciated, thanks,
 Peng Cai

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] multiple print commands in win.metafile()

2010-03-18 Thread jim holtman
It depends on what you want them for.  With win.metafile, what is the
problem with multiple files?  You can still include them in
powerpoint/word.  If you want it in one file, then use PDF and you can
cut/paste the graph from the pages that you want.  I typically create a PDF
file if I have a number of graphs and then use the 'snapshot' under Adobe
Reader to capture the output for my document.  It usually has enough
resolution.

On Thu, Mar 18, 2010 at 1:41 PM, Kim Jung Hwa kimhwamaill...@gmail.comwrote:

 Hi Jim, thank you for your reply.

 Apart from win.metafile(), is there some other function available which can
 handle multiple prints or par(mfrow=c(2,2)) command and eventually can be
 used in powerpoint/word. thanks,

 Kim

   On Thu, Mar 18, 2010 at 12:42 PM, jim holtman jholt...@gmail.comwrote:

 ?win.metafile


 For win.metafile only one plot is allowed per file, and Windows seems to
 disallow reusing the file. So the *only* way to allow multiple plots is
 to use a parametrized filename as in the example.
 win.metafile(Rplot%02d.wmf, pointsize = 10)
 Notice the %02d in the file name.

   On Thu, Mar 18, 2010 at 12:36 PM, Kim Jung Hwa 
 kimhwamaill...@gmail.com wrote:

  Hi All,

 I need a file which I can import to MS Word, I'm trying win.metafile(),
 but
 it does not seem to support multiple print commands at once (please see
 below). Is there an alternative to get plots file which can be used in
 powerpoint/word?

 # R code:
 # this does not work; but same thing works with pdf()
 library(lattice)
 win.metafile(test.wmf)
 p1 - xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
   type = a,
   auto.key =
   list(space = right, points = FALSE, lines = TRUE))

 p2 - xyplot(sunspot.year ~ 1700:1988, xlab = , type = l,
   scales = list(x = list(alternating = 2)),
   main = Yearly Sunspots)

 print(p1, split=c(1,1,2,1), more=TRUE)
 print(p2, split=c(2,1,2,1))
 dev.off()

 Can anyone help please, thanks,
 Kim

[[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.htmlhttp://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?





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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


[R] probable timezone confusion with as.yearmon

2010-03-18 Thread Peter Keller
It looks like a timezone issue, and it's causing confusion to me at least.

My original data:
gmt -
c(19880101 , 19880101 0100, 19880101 0300, 19880101 0400,
19880101 0500, 19880101 0600)

These were converted to local dates/times with
akst-strptime(gmt,format=%Y%m%d %H%M)-(3600*9) # because I want
local standard, not daylight savings time.

 dput(akst)
structure(c(567993600, 567997200, 568004400, 568008000, 568011600,
568015200), class = c(POSIXt, POSIXct), tzone = )

Which looks like this on my system:
 akst
[1] 1987-12-31 15:00:00 AKST 1987-12-31 16:00:00 AKST 1987-12-31
18:00:00 AKST
[4] 1987-12-31 19:00:00 AKST 1987-12-31 20:00:00 AKST 1987-12-31
21:00:00 AKST

but why does this happen?
z-as.yearmon(akst); z
[1] Jan 1988 Jan 1988 Jan 1988 Jan 1988 Jan 1988 Jan 1988

I would expect this:
[1] Dec 1987 Dec 1987 Dec 1987 Dec 1987 Dec 1987 Dec 1987

which I can get to by doing this:
z-as.yearmon(akst-(3600*9)); z
[1] Dec 1987 Dec 1987 Dec 1987 Dec 1987 Dec 1987 Dec 1987

But I don't understand why the first one doesn't give the answer I
expect (and would like).

Thanks for any help-
Peter

 sessionInfo()
R version 2.10.1 Patched (2010-03-16 r51294)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] zoo_1.6-2

loaded via a namespace (and not attached):
[1] grid_2.10.1lattice_0.18-3 tools_2.10.1

 Sys.timezone()
[1] AKDT

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

2010-03-18 Thread RICHARD M. HEIBERGER
xyplot(1:10 ~ 1:10, ylab=list(expression(atop(PM[2.5] ~ Concentration ~
frac(mu*g,m^3),(random text in brackets, crt=90)


See ?plotmath for atop and many more functions

[[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] Please help with loop, thanks

2010-03-18 Thread Dennis Murphy
 indiv - LETTERS[1:4]
 for(i in seq_along(indiv)) assign(indiv[i], rnorm(10))
 A
 [1] -0.4140121 -0.8506043 -1.6704603 -0.3153009  1.9337826 -0.7736769
 [7] -0.7906979  0.6925713  2.4678820  0.3889229
 B
 [1] -0.03521033 -0.01071611 -0.74209425  1.36974281 -1.22775441  0.29621976
 [7]  0.28208192 -2.11044822  0.06657930 -0.18036208
 C
 [1]  0.8473888  0.5028627  2.4445523  0.6908494  2.2145275 -0.1589881
 [7] -0.4135572  0.1313484 -0.8689705 -0.9267220
 D
 [1] -1.95177791  0.12495833  0.06847564  1.18425425 -1.16638075 -0.30278432
 [7] -0.30268288  0.79178229  0.53021849 -0.32030840

HTH,
Dennis


On Thu, Mar 18, 2010 at 11:44 AM, Mark Na mtb...@gmail.com wrote:

 Dear R helpers,

 I would like to write a loop that makes 4 objects (called A, B, C, and D)
 each of which contains ten random numbers.

 This attempt:

 individuals-c(A,B,C,D)
 for(i in 1:length(individuals)) {
 individuals[i]-rnorm(10)
 }


 does not work because individuals[i] is not the proper way to extract
 each
 letter from the object called individuals (rather, it tries to assign the
 random numbers to various positions within individual)

 So, my question is, what should be to the left of the gets operator in the
 third line?

 Many thanks,

 Mark Na

[[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] Please help with loop, thanks

2010-03-18 Thread Mark Na
Dear R helpers,

I would like to write a loop that makes 4 objects (called A, B, C, and D)
each of which contains ten random numbers.

This attempt:

individuals-c(A,B,C,D)
for(i in 1:length(individuals)) {
individuals[i]-rnorm(10)
}


does not work because individuals[i] is not the proper way to extract each
letter from the object called individuals (rather, it tries to assign the
random numbers to various positions within individual)

So, my question is, what should be to the left of the gets operator in the
third line?

Many thanks,

Mark Na

[[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] merge.zoo produces non unique chron time series

2010-03-18 Thread Gabor Grothendieck
It occurs because the two series have times that are slightly
different. For example, it may appear that the times at positions 909
and 910 are the same but in fact they are different:

 tt - time(zoo.ts.cor)[909:910]; tt
[1] (03/09/09 12:30:00) (03/09/09 12:30:00)
 diff(as.numeric(tt))
[1] 1.818989e-12

Here are two ways to deal with this:


# 1. Use a different date/time class.



# 2. Round off inputs to merge:


rnd - function(x) round(24 * 3600 * x + 0.5) / (24 * 3600)
Rnd - function(x) {
time(x) - chron(rnd(as.numeric(time(x
x
}

zoo.ts.cor.rnd - merge.zoo(Rnd(zoo.ts.pot), Rnd(zoo.ts))



# 3. zoo provides a facility for the user to change how matching is done.
#Define a MATCH method for the class of interest.  In this case
its done like this:


# rnd function is from above
MATCH.chron - function(x, table, nomatch = NA, ...) {
match(rnd(as.numeric(x)), rnd(as.numeric(table)), nomatch = nomatch, 
...)
}

zoo.ts.cor.ok - merge.zoo(zoo.ts.pot, zoo.ts)


On Thu, Mar 18, 2010 at 2:00 PM, Jan Schwanbeck jschw...@gmail.com wrote:
 Dear all,

 merge.zoo produces duplicated time indexes in the example stated below. Can
 anybody explain, what I am doing wrong?

 Many thanks!

 Jan

 (R 2.10.0, WindowsXP)

 require(chron)
 require(zoo)

 # create time series (zoo.ts) with no data from 31Aug2009 14:50 to 3Sep2009
 7:25
 t.st - chron(31/08/2009,09:20:00,format=c(d/m/Y,h:m:s))
 t.nd - chron(31/08/2009,14:50:00,format=c(d/m/Y,h:m:s))
 t.indexA-seq(t.st,t.nd,by=1/(24*12))

 t.st - chron(03/09/2009,07:25:00,format=c(d/m/Y,h:m:s))
 t.nd - chron(03/09/2009,23:55:00,format=c(d/m/Y,h:m:s))
 t.indexB-seq(t.st,t.nd,by=1/(24*12))

 t.index-c(t.indexA,t.indexB)

 zoo.ts - zoo(0,t.index)

 # create reference time series (zoo.ts.pot) without missing time steps
 t.st - head(time(zoo.ts),1)
 t.nd - tail(time(zoo.ts),1)
 t.index-seq(t.st,t.nd,by=1/(24*12))
 zoo.ts.pot - zoo(NA,t.index)

 # merge erroneous time series with reference time series
 zoo.ts.cor - merge.zoo(zoo.ts.pot,zoo.ts)

 
  Do not run: Results:
                              zoo.ts.pot zoo.ts
 (31/08/09 09:20:00)         NA      0
 (31/08/09 09:25:00)         NA      0
 (31/08/09 09:30:00)         NA      0
 ...
 (31/08/09 14:50:00)         NA      0
 (31/08/09 14:55:00)         NA     NA
 (31/08/09 15:00:00)         NA     NA
 (31/08/09 15:05:00)         NA     NA
 ...
 (03/09/09 07:15:00)         NA     NA
 (03/09/09 07:20:00)         NA     NA
 (03/09/09 07:25:00)         NA      0
 (03/09/09 07:30:00)         NA      0
 (03/09/09 07:35:00)         NA      0
 (03/09/09 07:40:00)         NA      0
 (03/09/09 07:45:00)         NA      0
 (03/09/09 07:50:00)         NA      0
 (03/09/09 07:55:00)         NA      0
 (03/09/09 08:00:00)         NA      0
 # everything o.k. up to here
 (03/09/09 08:00:00)         NA     NA
 # from here: every tenth time stamp is duplicated. Why?
 ...
 (03/09/09 08:45:00)         NA      0
 (03/09/09 08:45:00)         NA     NA
 ..
 (03/09/09 09:30:00)         NA      0
 (03/09/09 09:30:00)         NA     NA
 ...

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

2010-03-18 Thread Phil Spector

David -
   I think what you're looking for is something like this:


mydat = data.frame(a=c(1,2,3),b=c(5,1,4))
consolidate.fun = function(data,var1,var2,saved.max){

+data$saved.max = apply(data[,c(var1,var2)],1,max)
+data[,var1] = NULL
+data[,var2] = NULL
+data
+ }

mydat = consolidate.fun(mydat,'a','b','var.max')
mydat

  saved.max
1 5
2 6
3 3

(I changed the name of the data frame, because c is a function
name, and using it as a data frame name causes confusiion.)

The - operator only operates on complete objects, not
columns within a data frame.
- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu




On Thu, 18 Mar 2010, David Young wrote:


Dear List,

I'm getting the error: object of type 'closure' is not subsettable
And am not sure how to get around the problem.  I've included two
short code sets below.  One that shows what I want to do and works,
but without using the function much, and another that tries to use the
function but causes the error.

# THIS WORKS AND SHOWS WHAT I'D LIKE TO DO
a - c(1,2,3)
b - c(5,6,0)
c - data.frame(a,b)

# TAKES THE MAX OF TWO VARS AND SAVES IT TO A NEW VARIABLE AND DELETES OLD 
VARIABLES
consolidate.fun - function( data, var1, var2, saved.max ) {
max - apply( data[,c(var1, var2)], 1, max)

# THIS WORKS BUT I HAVE TO CALL THE DATA FRAME BY NAME RATHER THEN USING THE 
FUNCTION DATA NAME
c[,var.max] - max
c$a - NULL
c$b - NULL
}
consolidate.fun( data=c , var1=a, var2=b, saved.max=var.max )
c

# THIS SHOWS THE MORE COMPLETE USE OF THE FUNCTION'S INTENT, BUT
#  CAUSES THE ERROR IN R.
a - c(1,2,3)
b - c(5,6,0)
c - data.frame(a,b)

# TAKES THE MAX OF TWO VARS AND SAVES IT TO A NEW VARIABLE AND DELETES OLD 
VARIABLES
consolidate.fun - function( data, var1, var2, saved.max ) {
max - apply( data[,c(var1, var2)], 1, max)

# SOURCE OF ERROR.  I'VE TRIED CALLING THE DATA FRAME IN DIFFERENT
#  WAYS, BUT NONE SEEM TO WORK FOR ME.
data[, saved.max ] - max
data[, var1 ] - NULL
data[, var2 ] - NULL
}
consolidate.fun( data=c , var1=a, var2=b, saved.max=var.max )
c

Any helpful comments would be appreciated.


 mailto:dyo...@telefonica.net

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

2010-03-18 Thread jim holtman
better yet consider using a list:

 result - list()
 individuals-c(A,B,C,D)
 for (i in individuals) result[[i]] - runif(10)

 result
$A
 [1] 0.61464497 0.55715954 0.32877732 0.45313145 0.50044097 0.18086636
0.52963060 0.07527575 0.27775593 0.21269952
$B
 [1] 0.28479048 0.89509410 0.44623532 0.77998489 0.88061903 0.41312421
0.06380848 0.33548749 0.72372595 0.33761533
$C
 [1] 0.6304141 0.8406146 0.8561317 0.3913593 0.3804939 0.8954454 0.6443158
0.7410786 0.6053034 0.9030816
$D
 [1] 0.2937302 0.1912601 0.8864509 0.5033395 0.8770575 0.1891936 0.7581031
0.7244989 0.9437248 0.5476466



On Thu, Mar 18, 2010 at 2:44 PM, Mark Na mtb...@gmail.com wrote:

 Dear R helpers,

 I would like to write a loop that makes 4 objects (called A, B, C, and D)
 each of which contains ten random numbers.

 This attempt:

 individuals-c(A,B,C,D)
 for(i in 1:length(individuals)) {
 individuals[i]-rnorm(10)
 }


 does not work because individuals[i] is not the proper way to extract
 each
 letter from the object called individuals (rather, it tries to assign the
 random numbers to various positions within individual)

 So, my question is, what should be to the left of the gets operator in the
 third line?

 Many thanks,

 Mark Na

[[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.htmlhttp://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?

[[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] Please help with loop, thanks

2010-03-18 Thread Mark Na
Many thanks to everyone who helped me solve this problem.

I think I must have described my problem poorly, but Phil, Patrick and Jim
were able to see through the haze and suggest that I use a list to contain
the output from my loop. This solution works very well.

Thanks again for your help, Mark




On Thu, Mar 18, 2010 at 12:44 PM, Mark Na mtb...@gmail.com wrote:

 Dear R helpers,

 I would like to write a loop that makes 4 objects (called A, B, C, and D)
 each of which contains ten random numbers.

 This attempt:

 individuals-c(A,B,C,D)
 for(i in 1:length(individuals)) {
 individuals[i]-rnorm(10)
 }


 does not work because individuals[i] is not the proper way to extract
 each letter from the object called individuals (rather, it tries to assign
 the random numbers to various positions within individual)

 So, my question is, what should be to the left of the gets operator in the
 third line?

 Many thanks,

 Mark Na




-- 
Mark Na
University of Saskatchewan
Saskatoon, Canada

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