Re: [R] RMySql inserts \r when using dbWriteTable

2008-11-05 Thread Prof Brian Ripley
You will find this discussed in the list archives: most recently see the 
thread starting


https://stat.ethz.ch/pipermail/r-help/2008-August/170562.html

Bottom line: the package maintainer needs to correct a bug in the package 
code (and did not do so in the subsequent release 0.6-1), but meantime you 
can correct the code as described in that thread.


On Wed, 5 Nov 2008, Albert Nigrin wrote:


I am using R 2.8 and the latest versions of RMySQL on a Windows XP 64 bit
machine.


Please be accurate, as the posting guide asks.  E.g. is this a '64 bit' 
version of R you are running, what are the actual version numbers?



I was wondering if someone could help me figure out how to use dbWriteTable
without inserting \r into my table.  Consider the following code snippet,
which is
run after I connect to my database.

myDFOut = dbReadTable(conn, "myDF")
print(myDFOut)
myDFIn = data.frame(x=paste("x", 1:5, sep = ""), y = paste("y", 1:5, sep =
""))
dbWriteTable(conn, name= "myDF", value = myDFIn, row.names=F, append =TRUE,
eol = "\r\n" )
myDFOut = dbReadTable(conn, "myDF")
print(myDFIn)
print(myDFOut)

I get the output:

myDFOut = dbReadTable(conn, "myDF")
print(myDFOut)

data frame with 0 columns and 0 rows

myDFIn = data.frame(x=paste("x", 1:5, sep = ""), y = paste("y", 1:5, sep =

""))

dbWriteTable(conn, name= "myDF", value = myDFIn, row.names=F, append

=TRUE, eol = "\r\n" )
[1] TRUE

myDFOut = dbReadTable(conn, "myDF")
print(myDFIn)

  x  y
1 x1 y1
2 x2 y2
3 x3 y3
4 x4 y4
5 x5 y5

print(myDFOut)

  xy
1 x1 y1\r
2 x2 y2\r
3 x3 y3\r
4 x4 y4\r
5 x5 y5\r

Is there any way not to insert the "\r" in the database?   I also get the
same output, if I change the eol argument to "\n" in dbWriteTable, as in the
following command.

dbWriteTable(conn, name= "myDF", value = myDFIn, row.names=F, append =TRUE,
eol = "\n" )

I have read previous discussion concerning SQLite, but I still can't figure
out what to do.

Thanks for your help.

Albert

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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,  [EMAIL PROTECTED]
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] Reshape a matrix

2008-11-05 Thread cruz
On Thu, Nov 6, 2008 at 8:53 AM, dinesh kumar <[EMAIL PROTECTED]> wrote:
> Dear R users,
>
> I have a matrix like
>
> A  X1
> B  Y2
> C  Z3
>
> I want to reshape this matrix into this format
>
>X  Y  Z
> A  1
> B 2
> C 3
>

is this what you want?

> matrix(diag(c(1,2,3)),nrow=3,ncol=3,dimnames=list(c("A","B","C"),c("X","Y","Z")))
 X Y Z
A 1 0 0
B 0 2 0
C 0 0 3

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


Re: [R] how to make a multiple plot

2008-11-05 Thread Dieter Menne
amy rheanita  yahoo.com> writes:

> I'm a student. now, I'm studying Nelson-Siegel Extended, a term structure 
> model. I can analyze - estimate parameters and make aplot  - manually, 
> from data  bond in a day.
> I can analyze bond data in a month, like make multiple plot for different
> bont date and make a multiple
> plot to compare parameters in different date.

Try 

par(mfrow=c(2,2)) 

before creating the plot.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 individual equation from {aidsEst} in package [micEcon]?

2008-11-05 Thread Yang Wan
Hi, R core team

 

I am using the function {aidsEst} in package [micEcon] to do an AIDS
model now.  So far, everything is good.  But I want to test the auto
correlation and heteroskedasticity of the individual equation from AIDS
demand system.  How can I return the individual equation?

 

PS: serial correlation test is {bgtest} in package [lmtest] and
heteroskedasticity is {bptest} in package [lmtest], both of which need
the object of formula.

 

Thank you for your answer.

 

 

Christina


[[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] lars package - lasso

2008-11-05 Thread Derow, Catherine Kari
Please could you clarify for me for me when using the lars (lasso)  package
what the parameter 'intercept' refers to and what the advantages and
disadvantages of making this TRUE or FALSE are and when it should be
TRUE and when FALSE.  Also please could you clarify how 'eps' works and
when it should be used.  Also please could you let me know exactly what
the  X'X matrix is and what it is used for.  Also please could you clarify
the use of the max.steps parameter.

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

2008-11-05 Thread dinesh kumar
Dear R users,

I have a matrix like

A  X1
B  Y2
C  Z3

I want to reshape this matrix into this format

X  Y  Z
A  1
B 2
C 3



Thanks in advance for your help.


Dinesh

-- 
Dinesh Kumar Barupal
Junior Specialist
Metabolomics Fiehn Lab
UCD Genome Center
451 East Health Science Drive
GBSF Builidng
University of California
DAVIS
95616
http://fiehnlab.ucdavis.edu/staff/kumar

[[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] RMySql inserts \r when using dbWriteTable

2008-11-05 Thread Albert Nigrin
I am using R 2.8 and the latest versions of RMySQL on a Windows XP 64 bit
machine.
I was wondering if someone could help me figure out how to use dbWriteTable 
without inserting \r into my table.  Consider the following code snippet,
which is
run after I connect to my database.

myDFOut = dbReadTable(conn, "myDF")
print(myDFOut)
myDFIn = data.frame(x=paste("x", 1:5, sep = ""), y = paste("y", 1:5, sep =
""))
dbWriteTable(conn, name= "myDF", value = myDFIn, row.names=F, append =TRUE,
eol = "\r\n" )
myDFOut = dbReadTable(conn, "myDF")
print(myDFIn)
print(myDFOut)

I get the output:
> myDFOut = dbReadTable(conn, "myDF")
> print(myDFOut)
data frame with 0 columns and 0 rows
> myDFIn = data.frame(x=paste("x", 1:5, sep = ""), y = paste("y", 1:5, sep =
""))
> dbWriteTable(conn, name= "myDF", value = myDFIn, row.names=F, append
=TRUE, eol = "\r\n" )
[1] TRUE
> myDFOut = dbReadTable(conn, "myDF")
> print(myDFIn)
   x  y
1 x1 y1
2 x2 y2
3 x3 y3
4 x4 y4
5 x5 y5
> print(myDFOut)
   xy
1 x1 y1\r
2 x2 y2\r
3 x3 y3\r
4 x4 y4\r
5 x5 y5\r

Is there any way not to insert the "\r" in the database?   I also get the
same output, if I change the eol argument to "\n" in dbWriteTable, as in the
following command.

dbWriteTable(conn, name= "myDF", value = myDFIn, row.names=F, append =TRUE,
eol = "\n" )

I have read previous discussion concerning SQLite, but I still can't figure
out what to do.

Thanks for your help.

Albert

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

2008-11-05 Thread Dieter Menne
Jiqiang Guo  gmail.com> writes:

> As we know when we use R to execute a r program we can add arguments like
> '--args p1 p2'.  But when I am sourcing another file, is there a way to set
> up some arguments for the sourced program.  Thanks!
> 

In general, you can use Sys.getenv() and .setenv() to pass parameters from the
command line. 

passw=Sys.getenv("PASSW")

But when sourcing, why not simply use R?

mypass = "secret"
source("myfile.r")

Dieter

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

2008-11-05 Thread Prof Brian Ripley

Please note that a more accurate subject line would be

'Problems with links generated by the search page in HTML help in your browser here> on obsolete versions of R'


The problem is almost certainly your browser, not R.  Later versions (>= 
2.7.2) of R mention this in the R-admin manual and provide a direct link 
to the search page on the Rgui menu.  The current manual says (Appendix D)


  There is a known issue with Firefox 3 (and 3.0.1). The links in the
  results page may point to the wrong directory level. This is a bug in
  the way Firefox is interpreting relative URLs, and can be circumvented
  by opening the HTML search page (.../doc/html/SearchEngine.html)
  directly rather than from .../doc/html/index.html as shown by
  help.start().

and on Windows the CHANGES file for 2.7.2 says

o   Rgui has a new menu item 'Html search page' on the Help menu,
which goes directly to the HTML search form.  This is needed
by users of Firefox 3, which generates incorrect links in
search results when the page is accessed via the 'Html help'
menu item (or via help.start()).


The R posting guide asked you to update *before* posting, and that would 
have solved this for you by providing workarounds.  We cannot workaround 
future bugs in other software, but we have been kind enough to do so in 
subsequent versions of R.  (You would also have found this in the mailing 
list archives.)


This issue is known from Firefox 3 (but not even its betas) and other 
browsers based on the same version of the Gecko engine.




On Thu, 6 Nov 2008, Samu Mäntyniemi wrote:

I have this problem with R 2.6.1 and 2.7.1 (have not tried others) running on 
Windows XP:


Html help has wrong links to help files.


That's not what your evidence shows.  It shows that the HTML help search 
page generates links that your browser interprets incorrectly.


The index.html is correctly found 
from


file:///C:/PROGRA~1/R/R-26~1.1/doc/html/index.html

as well as the search engine

file:///C:/PROGRA~1/R/R-26~1.1/doc/html/search/SearchEngine.html

However, when I search for, say, "paste", I will be pointed to

file:///C:/PROGRA~1/R/library/base/html/paste.html


Even that is not correct: the search engine generates a relative URL, 
which the browser has incorrectly interpreted relative to its start page 
and not the current page.



which of course does not exist. Changing this manually to

file:///C:/PROGRA~1/R/R-2.6.1/library/base/html/paste.html

leads me to the correct page.

Any views on how to fix this? I have installed 2.6.1 to another laptop 
without such problems, therefore I suspect that the problem would be somehow 
related to the settings of this particular laptop. However, I do not know 
where to look.


Cheers,

Samu


--
--
Samu Mäntyniemi
University Researcher, PhD
Fisheries and Environmental Management Group (FEM)
Department of Biological and Environmental Sciences
Biocenter 3, room 4414
Viikinkaari 1
P.O. Box 65
FIN-00014 University of Helsinki

Phone: +358 9 191 58710
Fax: +358 9 191 58257

email: [EMAIL PROTECTED]
personal webpage: http://www.helsinki.fi/people/samu.mantyniemi/
FEM webpage: http://www.helsinki.fi/science/fem/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] trouble with html help

2008-11-05 Thread Samu Mäntyniemi
I have this problem with R 2.6.1 and 2.7.1 (have not tried others) 
running on Windows XP:


Html help has wrong links to help files. The index.html is correctly 
found from


file:///C:/PROGRA~1/R/R-26~1.1/doc/html/index.html

as well as the search engine

file:///C:/PROGRA~1/R/R-26~1.1/doc/html/search/SearchEngine.html

However, when I search for, say, "paste", I will be pointed to

file:///C:/PROGRA~1/R/library/base/html/paste.html

which of course does not exist. Changing this manually to

file:///C:/PROGRA~1/R/R-2.6.1/library/base/html/paste.html

leads me to the correct page.

Any views on how to fix this? I have installed 2.6.1 to another laptop 
without such problems, therefore I suspect that the problem would be 
somehow related to the settings of this particular laptop. However, I do 
not know where to look.


Cheers,

Samu


--
--
Samu Mäntyniemi
University Researcher, PhD
Fisheries and Environmental Management Group (FEM)
Department of Biological and Environmental Sciences
Biocenter 3, room 4414
Viikinkaari 1
P.O. Box 65
FIN-00014 University of Helsinki

Phone: +358 9 191 58710
Fax: +358 9 191 58257

email: [EMAIL PROTECTED]
personal webpage: http://www.helsinki.fi/people/samu.mantyniemi/
FEM webpage: http://www.helsinki.fi/science/fem/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Convert text into a variable name

2008-11-05 Thread Daniel Nordlund
> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Xing Yuan
> Sent: Wednesday, November 05, 2008 9:37 PM
> To: Simon Blomberg
> Cc: r-help@r-project.org
> Subject: Re: [R] Convert text into a variable name
> 
> Thanks for the reply, Simon!
> 
> I just want to name a object as the text string. So I have 
> "AGE" then how
> can I do
> 
> somecommand("AGE") = 39
> 
> then I should have
> 
> AGE = 39 in my data set.
> 
> 
> Joe
> 
> 
> 
> On Thu, Nov 6, 2008 at 12:28 AM, Simon Blomberg 
> <[EMAIL PROTECTED]>wrote:
> 
> > ?assign
> >
> > On Thu, 2008-11-06 at 00:03 -0500, Xing Yuan wrote:
> > > Hello R users,
> > >
> > > Does anybody know what command I should use to convert 
> the text string
> > "AGE"
> > > to be variable name AGE so I can assign value to it
> > > e.g. AGE = 39?
> > >
> > > Thank you very much!
> > >
> > > Joe

Simon gave you the answer.  The command is the function assign().  Type
?assign at the R console prompt to read about the function.

Dan

Daniel Nordlund
Bothell, WA USA

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

2008-11-05 Thread Henrik Bengtsson
Hi,

if you instead do:

setConstructorS3("ClassB", function(B=15) {
  extend(ClassA(), "ClassB",
.size2 = B
  );
})

then you'll get:

> objB <- ClassB();
> objB
[1] "Class B: 15"


What was wrong with your setup?
What you ended up doing was to "extend" an object of class 'character'
(with value "ClassA").  With above fix, you now extend an object of
class 'ClassA' (which in turn extend 'Object').

Hope this help

/Henrik

On Wed, Nov 5, 2008 at 2:18 AM, Yuri Volchik <[EMAIL PROTECTED]> wrote:
>
> Hi to all members, i have a question about class inheritance and methods
> using R.oo package:
> I have the following code and it doesn't work, guess i'm doing smth wrong
> and there is nothing in the help.
>
> library(R.oo)
>
> setConstructorS3("ClassA", function(A=15) {
>  extend(Object(), "ClassA",
>.size = A
>  );
> })
>
>
> setMethodS3("print", "ClassA", function(this,...) {
>  print(paste('Class A:',this$.size));
> })
>
>
> objA<-ClassA();
> objA
>
> [1] "Class A: 15"
>
> setConstructorS3("ClassB", function(B=15) {
>  extend("ClassA", "ClassB",
>.size2 = B
>  );
> })
>
>
> setMethodS3("print", "ClassB", function(this,...) {
>  print(paste('Class B:',this$.size2));
> })
>
>
> objB<-ClassB();
> objB
>
> Error in this$.size2 : $ operator is invalid for atomic vectors
>
>
> --
> View this message in context: 
> http://www.nabble.com/Methods-dispatch-and-inheritance-R.oo-tp20339090p20339090.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] Convert text into a variable name

2008-11-05 Thread Xing Yuan
Thanks for the reply, Simon!

I just want to name a object as the text string. So I have "AGE" then how
can I do

somecommand("AGE") = 39

then I should have

AGE = 39 in my data set.


Joe



On Thu, Nov 6, 2008 at 12:28 AM, Simon Blomberg <[EMAIL PROTECTED]>wrote:

> ?assign
>
> On Thu, 2008-11-06 at 00:03 -0500, Xing Yuan wrote:
> > Hello R users,
> >
> > Does anybody know what command I should use to convert the text string
> "AGE"
> > to be variable name AGE so I can assign value to it
> > e.g. AGE = 39?
> >
> > Thank you very much!
> >
> > Joe
> >
> >   [[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.
> --
> Simon Blomberg, BSc (Hons), PhD, MAppStat.
> Lecturer and Consultant Statistician
> Faculty of Biological and Chemical Sciences
> The University of Queensland
> St. Lucia Queensland 4072
> Australia
> Room 320 Goddard Building (8)
> T: +61 7 3365 2506
> http://www.uq.edu.au/~uqsblomb 
> email: S.Blomberg1_at_uq.edu.au
>
> Policies:
> 1.  I will NOT analyse your data for you.
> 2.  Your deadline is your problem.
>
> 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.
>
>

[[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] Convert text into a variable name

2008-11-05 Thread Simon Blomberg
?assign

On Thu, 2008-11-06 at 00:03 -0500, Xing Yuan wrote:
> Hello R users,
> 
> Does anybody know what command I should use to convert the text string "AGE"
> to be variable name AGE so I can assign value to it
> e.g. AGE = 39?
> 
> Thank you very much!
> 
> Joe
> 
>   [[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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

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.

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

2008-11-05 Thread Jiqiang Guo
HI, All,

As we know when we use R to execute a r program we can add arguments like
'--args p1 p2'.  But when I am sourcing another file, is there a way to set
up some arguments for the sourced program.  Thanks!

Regards,

[[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] Convert text into a variable name

2008-11-05 Thread Xing Yuan
Hello R users,

Does anybody know what command I should use to convert the text string "AGE"
to be variable name AGE so I can assign value to it
e.g. AGE = 39?

Thank you very much!

Joe

[[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] trouble with for loop

2008-11-05 Thread Peter Alspach
?try 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Kyeongmi Cheon
> Sent: Thursday, 6 November 2008 4:56 p.m.
> To: R help mailing list
> Subject: [R] trouble with for loop
> 
> Hello,
> I'm having two similar problems with for loop and I would 
> appreciate any help or comment.
> 
> I want to use  "for loop" to calculate series of initial 
> values for an optimization problem. But
> 
> some initial values have my function quit due to problems 
> like calculating the inverse of singular
> 
> matrices. I don't want to make my program check determinants 
> and skip it if it
> 
> is very small. My program stopping for certain iterations is 
> okay but my problem is that the whole
> 
> for loop is ended from there and it does not move to the next 
> iteration. So the rest of the initial values are
> 
> never tried. Here is a simple example:
> 
> 
> 
> mat.inv <- function(theta){
>mat1 <- matrix( theta, nr=2)
>inv <- solve(mat1)
>res <- theta[1]+inv[1,1]
>res
> }
> 
> for (i in 1:7){
>theta4 <- i
>theta.vec <-  c(1,2,2,theta4)
>theta.res <- mat.inv(theta.vec)
>write.table(theta.res, paste("result",i,".txt",sep="")) }
> 
> It stops when i=4. I need to try other values. How would I 
> get it to simply move on to the next
> 
> iteration :i=5,6,7 without checking determinants?
> 
> 
> 
> Another similar problem that I have is that I have thousands 
> of txt files and want to use a for loop
> 
> to read them into R. The file names are consecutive but some 
> of them are missing: For
> 
> example, they are "result1.txt", "result2.txt", 
> "result3.txt", "result5.txt"...  When I use for loop to read 
> it, it gets an error at "result4.txt" so that 
> "result5.txt"...  are not read. I attached an example program 
> here. Could anyone help me? I appreciate your time in advance.
> Kyeongmi
> 
> 
> #create dataset name
> for (i in 1:6){
> assign(paste("newname",i,sep=""), paste("result",i,".txt",sep="")) }
> ls()
> 
> #read data if there are files with the name: "result1.txt", 
> "result2.txt", "result3.txt",
> 
> "result5.txt".
> for (i in 1:6){
>   assign(  paste("r",i,sep=""),
> read.table(get(paste("newname",i,sep="")), header=T))
> 
> }
> 
> # It stops at "result3.txt" so that "result5.txt"...  are not read.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

The contents of this e-mail are privileged and/or confidential to the named
 recipient and are not to be used by any other person and/or organisation.
 If you have received this e-mail in error, please notify the sender and delete
 all material pertaining to this e-mail.

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

2008-11-05 Thread Kyeongmi Cheon
Hello,
I'm having two similar problems with for loop and I would appreciate
any help or comment.

I want to use  "for loop" to calculate series of initial values for an
optimization problem. But

some initial values have my function quit due to problems like
calculating the inverse of singular

matrices. I don't want to make my program check determinants and skip it if it

is very small. My program stopping for certain iterations is okay but
my problem is that the whole

for loop is ended from there and it does not move to the next
iteration. So the rest of the initial values are

never tried. Here is a simple example:



mat.inv <- function(theta){
   mat1 <- matrix( theta, nr=2)
   inv <- solve(mat1)
   res <- theta[1]+inv[1,1]
   res
}

for (i in 1:7){
   theta4 <- i
   theta.vec <-  c(1,2,2,theta4)
   theta.res <- mat.inv(theta.vec)
   write.table(theta.res, paste("result",i,".txt",sep=""))
}

It stops when i=4. I need to try other values. How would I get it to
simply move on to the next

iteration :i=5,6,7 without checking determinants?



Another similar problem that I have is that I have thousands of txt
files and want to use a for loop

to read them into R. The file names are consecutive but some of them
are missing: For

example, they are "result1.txt", "result2.txt", "result3.txt",
"result5.txt"...  When I use for loop to read it, it gets an error at
"result4.txt" so that "result5.txt"...  are not read. I attached an
example program here. Could anyone help me? I appreciate your time in
advance.
Kyeongmi


#create dataset name
for (i in 1:6){
assign(paste("newname",i,sep=""), paste("result",i,".txt",sep=""))
}
ls()

#read data if there are files with the name: "result1.txt",
"result2.txt", "result3.txt",

"result5.txt".
for (i in 1:6){
  assign(  paste("r",i,sep=""),
read.table(get(paste("newname",i,sep="")), header=T))

}

# It stops at "result3.txt" so that "result5.txt"...  are not read.

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


[R] how to make a multiple plot

2008-11-05 Thread amy rheanita
Sorry I have a bad English.
I'm a student. now, I'm studying Nelson-Siegel Extended, a term structure model.
I can analyze - estimate parameters and make aplot  - manually, from data bond 
in a day.
I can analyze bond data in a month, like make multiple plot for different 
bont date and make a multiple plot to compare parameters in different date.
I think I have seen examples like mine in   but I can't.
Do you know where I can find an example of what I am looking for?
thank you




  
[[alternative HTML version deleted]]

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


Re: [R] Problems computing 2-way-mixed-model ANOVA

2008-11-05 Thread Rolf Turner


On 6/11/2008, at 11:13 AM, Lucas Eggert wrote:


Dear Experts,

I am new to R and unfortunately cannot start with a simply statistical
analysis:

I manually determined the volume of the right and left hippocampus in
a group of meditators and in a group of controls. My data-sheet looks
as follows:


observation subject group   age gender  hemisphere  volume
1   am04m   25  f   left3.637
2   am04m   25  f   right   3.713
3   ao08m   47  m   left3.715





68  ws01m   30  m   right   5.258
69  zz03m   35  m   left4.446
70  zz03m   35  m   4.446   4.627
My attempt to compute the according statistic was:

aov = aov(volume~(hemisphere*group)+Error(subject/hemisphere)+
(group),input)

but with this I got the following error message:

In aov(volume ~ (hemisphere * group) + Error(subject/hemisphere) +  :
   Error() Modell ist singulär

I could not figure out what I did wrong. Furthermore, in the next step
I would like to use gender and age as additional covariates in the
model, but I am not sure how to do this either.

  Any help would be very much appreciated!


Look at the last line of your data frame.

cheers,

Rolf Turner
##
Attention: 
This e-mail message is privileged and confidential. If you are not the 
intended recipient please delete the message and notify the sender. 
Any views or opinions presented are solely those of the author.


This e-mail has been scanned and cleared by MailMarshal 
www.marshalsoftware.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] Incrementally building histograms

2008-11-05 Thread Gabor Grothendieck
You can eliminate the loop like this (untested):

cnt <- function(file) {
 data <- scan(file, quiet = TRUE)
 hist(data, plot = FALSE, breaks = breaks)$counts
}
Reduce("+", sapply(files, cnt))


On Wed, Nov 5, 2008 at 8:01 PM, Andre Nathan <[EMAIL PROTECTED]> wrote:
> Hello
>
> I need to build a histogram from data (numbers in the [0,1] interval)
> stored in a number of different files. The total amount of data is very
> large, so I can't load everything to memory and then simply call hist().
> Since what I actually need are the histogram counts, I'm currently doing
> it like this:
>
> breaks <- seq(0, 1, by = 0.01)
> files <- list.files(pattern = "some pattern")
> counts <- 0
> for (file in files) {
>  data <- scan(file, quiet = T)
>  h <- hist(data, plot = F, breaks = breaks)
>  counts <- counts + h$counts
> }
> # and then work with `counts' here
>
> Is there a more efficient and/or idiomatic way to do this?
>
> Thanks,
> Andre
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Incrementally building histograms

2008-11-05 Thread Rolf Turner


On 6/11/2008, at 2:01 PM, Andre Nathan wrote:


Hello

I need to build a histogram from data (numbers in the [0,1] interval)
stored in a number of different files. The total amount of data is  
very
large, so I can't load everything to memory and then simply call  
hist().
Since what I actually need are the histogram counts, I'm currently  
doing

it like this:

breaks <- seq(0, 1, by = 0.01)
files <- list.files(pattern = "some pattern")
counts <- 0
for (file in files) {
  data <- scan(file, quiet = T)
  h <- hist(data, plot = F, breaks = breaks)
  counts <- counts + h$counts
}
# and then work with `counts' here

Is there a more efficient and/or idiomatic way to do this?


No.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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

2008-11-05 Thread Rolf Turner


On 6/11/2008, at 11:39 AM, Armin Meier wrote:


Hi all,
I want to optimize a function fn using optim. This function fn calls
the .C function in it with a function name and arguments given to fn,
i.e. something like this pseudocode:

fn <- function(par, "some params for fn") {... .C 
("Cfunction", ...) ...}

optim(par, fn, "some params for fn")

In my case this doesn't work, but is it possible in general and I made
some error?


Yes it is possible in general, so you've goofed somewhere in your code.
Join the club.

The optim() function doesn't care how ``fn'' does its calculations as  
long
as it does them and doesn't crash.  In particular it doesn't care  
whether

``fn'' calls .C() to do all or part of those computations.

If ``fn'' works on its own (i.e. when not called by optim()) then it  
would
seem that the problem is not with your call to .C() but with the  
syntax of

your call to optim().

Remember that the ... arguments must be given in the name=value form.

Remember that optim() usually doesn't like it if fn() returns Inf or  
NA or NaN.


That's about all I can come up with in the way of ideas.  Good luck.

cheers,

Rolf Turner

P. S. ``... this doesn't work ...'' is too vague to be useful.  In  
what way
doesn't it work?  What sort of error do you get?  If you give the  
information

that the Posting Guide calls for, you may get a more helpful answer.

R. T.

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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

2008-11-05 Thread Ei-ji Nakama
Hi

If you want to use MKL10(no 8 or 9), you should obey instructions of R-admin.
MKL10 needs openmp.  This needs gcc4.2 or later.
OpenMP for Intel was necessary with MKL10.0.1.x (There was not it in a
manual of MKL).
# Please try an additional effect of "-liomp5" in the %*%

# fp-model of Linux of IA32 is 387(80bit) about the precision,
# but SSE2(64bit) is a default in Intel64.
# It is caused by this that results are different.

There was not the problem in R-2.8.0 either
  MKL_LIB_PATH=/opt/intel/mkl/10.0.5.025/lib/em64t
  MKL="   -L${MKL_LIB_PATH}   \
 -Wl,--start-group   \
 ${MKL_LIB_PATH}/libmkl_gf_lp64.a\
 ${MKL_LIB_PATH}/libmkl_gnu_thread.a \
 ${MKL_LIB_PATH}/libmkl_core.a   \
 -Wl,--end-group \
 -liomp5 -lguide -lpthread -lgomp"
  ./configure --with-lapack="$MKL" --with-blas="$MKL"


2008/11/5 Anand Patil <[EMAIL PROTECTED]>:
> Hi all,
> I'm trying to build R from subversion with MKL 10.0.2 on Ubuntu. I tried:
>
> ./configure --with-blas='-L/opt/intel/mkl/10.0.2.018/lib/em64t -lmkl
> -lguide' --with-lapack='/opt/intel/mkl/10.0.2.018/lib/em64t -lmkl
> -lmkl_lapack' --enable-R-shlib
>
> and got:
>
> R is now configured for x86_64-unknown-linux-gnu
>
>  Source directory:  .
>  Installation directory:/usr/local
>
>  C compiler:gcc -std=gnu99  -g -O2
>  Fortran 77 compiler:   gfortran  -g -O2
>
>  C++ compiler:  g++  -g -O2
>  Fortran 90/95 compiler:gfortran -g -O2
>  Obj-C compiler:
>
>  Interfaces supported:  X11
>  External libraries:readline
>  Additional capabilities:   PNG, JPEG, iconv, MBCS, NLS, cairo
>  Options enabled:   shared R library, shared BLAS, R profiling,
> Java
>
>  Recommended packages:  yes
>
> but make then builds R's blas, and when I subsequently do linear algebra in
> R it's obviously not multithreading. What am I doing wrong?
>
> Thanks,
> Anand
>
>[[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.
>
>
>



-- 
EI-JI Nakama  
"\u4e2d\u9593\u6804\u6cbb"  

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

2008-11-05 Thread Andre Nathan
Hello

I need to build a histogram from data (numbers in the [0,1] interval)
stored in a number of different files. The total amount of data is very
large, so I can't load everything to memory and then simply call hist().
Since what I actually need are the histogram counts, I'm currently doing
it like this:

breaks <- seq(0, 1, by = 0.01)
files <- list.files(pattern = "some pattern")
counts <- 0
for (file in files) {
  data <- scan(file, quiet = T)
  h <- hist(data, plot = F, breaks = breaks)
  counts <- counts + h$counts
}
# and then work with `counts' here

Is there a more efficient and/or idiomatic way to do this?

Thanks,
Andre

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 do I read a text (.csv) file to match a matrix/cross tab? (Object confusion??)

2008-11-05 Thread Kellie Wills

read.table doesn't realize the first column should be row names.  Try

read.table("C:/Data/R/NewTarget.csv", header=TRUE, sep=",",  
na.strings="NA", dec=".", row.names="tripid_nu")


Kellie Wills
Engineering Service Manager
REvolution Computing
[EMAIL PROTECTED]


On Nov 5, 2008, at 3:51 PM, Farley, Robert wrote:

I'm having a problem reading data to set control totals for a  
dataframe.
I want to adjust a dataframe based on a 2-d table of values, which I  
get

by using :


CurrentX1Sums <- as.matrix(xtabs(~tripid_nu+lineon, data=SurveyData))




CurrentX2Sums <- apply(CurrentX1Sums, 1, sum)




I've created a .csv file with new (target) sums that looks like this:

tripid_nuWarner Center De Soto  Pierce College  Tampa
ResedaBalboa  Woodley Sepulveda   Van Nuys
Woodman

Valley College  Laurel Canyon  North Hollywood

9011880 5222222
222641

9011890 1111112
111121

9011960 2221221
232211

9011970 1111211
2622224

9012040 2223272
221111

9012050 1111111
222115

 ...{More}...



I'm trying to read/process it like this:


NewTargetData  <- read.table("C:/Data/R/NewTarget.csv", header=TRUE,

sep=",", na.strings="NA", dec=".")


NewTargetX1Sums <- as.matrix(NewTargetData)



NewTargetX2Sums <- apply(NewTargetX1Sums, 1, sum)






The structures of CurrentX1Sums and NewTargetX1Sums are different:




str(CurrentX1Sums)


xtabs [1:55, 1:13] 1 0 1 0 1 0 0 0 0 1 ...

- attr(*, "dimnames")=List of 2

 ..$ tripid_nu: chr [1:55] "9011880" "9011890" "9011960" "9011970" ...

 ..$ lineon   : chr [1:13] "Warner Center" "De Soto" "Pierce College"
"Tampa" ...

- attr(*, "class")= chr [1:2] "xtabs" "table"

- attr(*, "call")= language xtabs(formula = ~tripid_nu + lineon,  
data =

SurveyData)




str(NewTargetX1Sums)


int [1:55, 1:14] 9011880 9011890 9011960 9011970 9012040 9012050
9012130 9012280 9012290 9012720 ...

- attr(*, "dimnames")=List of 2

 ..$ : NULL

 ..$ : chr [1:14] "tripid_nu" "Warner.Center" "De.Soto"
"Pierce.College" ...













Question 1) The structures (CurrentX1Sums , NewTargetX1Sums) are
different.  One way is in the dimension of the rownames.  Instead of
line numbers, I want  tripid_nu.   How do I do that?  What's the
appropriate "structure" for both?





Question 2) Why do the labels in NewTargetData have dots in place of
spaces?  Will that be a problem later when I try to match them with
SurveyData?





Question 3) Ultimately, I want to create a variable in the original
dataframe like:

  SurveyData$NewX1 = TargetX1Sums/ CurrentX1Sums { for each
tripid_nu, lineon combination}

Am I on the right track to do so?  Any hints on what THAT syntax will
look like?









Thanks in advance,












##

#My work to date:


SurveyData <- read.spss("C:/Data/R/orange_delivery.sav",

use.value.labels=TRUE, max.value.labels=Inf, to.data.frame=TRUE)


NewTargetData  <- read.table("C:/Data/R/NewTarget.csv", header=TRUE,

sep=",", na.strings="NA", dec=".")




#---



temp <- sub(' +$', '', SurveyData$direction_)   # Remove spaces

from variable names


SurveyData$direction_ <- temp





#---



SurveyData$StnNum=as.numeric(SurveyData$lineon)



CurrentX1Sums <- as.matrix(xtabs(~tripid_nu+lineon, data=SurveyData))




CurrentX2Sums <- apply(CurrentX1Sums, 1, sum)



NewTargetX1Sums <- as.matrix(NewTargetData)



NewTargetX2Sums <- apply(NewTargetX1Sums, 1, sum)







str(CurrentX1Sums)


xtabs [1:55, 1:13] 1 0 1 0 1 0 0 0 0 1 ...

- attr(*, "dimnames")=List of 2

 ..$ tripid_nu: chr [1:55] "9011880" "9011890" "9011960" "9011970" ...

 ..$ lineon   : chr [1:13] "Warner Center" "De Soto" "Pierce College"
"Tampa" ...

- attr(*, "class")= chr [1:2] "xtabs" "table"

- attr(*, "call")= language xtabs(formula = ~tripid_nu + lineon,  
data =

SurveyData)


str(NewTargetX1Sums)


int [1:55, 1:14] 9011880 9011890 9011960 9011970 9012040 9012050
9012130 9012280 9012290 9012720 ...

- attr(*, "dimnames")=List of 2

 ..$ : NULL

 ..$ : chr [1:14] "tripid_nu" "Warner.Center" "De.Soto"
"Pierce.College" ...








CurrentX1Sums


lineon

tripid_nu Warner Center De Soto Pierce College Tampa Reseda Balboa
Woodley Sepulveda Van Nuys Woodman Valley Coll

[R] How do I read a text (.csv) file to match a matrix/cross tab? (Object confusion??)

2008-11-05 Thread Farley, Robert
I'm having a problem reading data to set control totals for a dataframe.
I want to adjust a dataframe based on a 2-d table of values, which I get
by using :

> CurrentX1Sums <- as.matrix(xtabs(~tripid_nu+lineon, data=SurveyData))


> CurrentX2Sums <- apply(CurrentX1Sums, 1, sum)

 

I've created a .csv file with new (target) sums that looks like this:

tripid_nuWarner Center De Soto  Pierce College  Tampa
ResedaBalboa  Woodley Sepulveda   Van Nuys   Woodman
Valley College  Laurel Canyon  North Hollywood

9011880 5222222
222641

9011890 1111112
111121

9011960 2221221
232211

9011970 1111211
2622224

9012040 2223272
221111

9012050 1111111
222115

  ...{More}...

 

I'm trying to read/process it like this:

> NewTargetData  <- read.table("C:/Data/R/NewTarget.csv", header=TRUE,
sep=",", na.strings="NA", dec=".")

> NewTargetX1Sums <- as.matrix(NewTargetData)

> NewTargetX2Sums <- apply(NewTargetX1Sums, 1, sum)

 

 

The structures of CurrentX1Sums and NewTargetX1Sums are different:

 

> str(CurrentX1Sums)

 xtabs [1:55, 1:13] 1 0 1 0 1 0 0 0 0 1 ...

 - attr(*, "dimnames")=List of 2

  ..$ tripid_nu: chr [1:55] "9011880" "9011890" "9011960" "9011970" ...

  ..$ lineon   : chr [1:13] "Warner Center" "De Soto" "Pierce College"
"Tampa" ...

 - attr(*, "class")= chr [1:2] "xtabs" "table"

 - attr(*, "call")= language xtabs(formula = ~tripid_nu + lineon, data =
SurveyData)

 

> str(NewTargetX1Sums)

 int [1:55, 1:14] 9011880 9011890 9011960 9011970 9012040 9012050
9012130 9012280 9012290 9012720 ...

 - attr(*, "dimnames")=List of 2

  ..$ : NULL

  ..$ : chr [1:14] "tripid_nu" "Warner.Center" "De.Soto"
"Pierce.College" ...

> 

 

 

 

 

Question 1) The structures (CurrentX1Sums , NewTargetX1Sums) are
different.  One way is in the dimension of the rownames.  Instead of
line numbers, I want  tripid_nu.   How do I do that?  What's the
appropriate "structure" for both?

 

 

Question 2) Why do the labels in NewTargetData have dots in place of
spaces?  Will that be a problem later when I try to match them with
SurveyData?

 

 

Question 3) Ultimately, I want to create a variable in the original
dataframe like: 

   SurveyData$NewX1 = TargetX1Sums/ CurrentX1Sums { for each
tripid_nu, lineon combination}

Am I on the right track to do so?  Any hints on what THAT syntax will
look like?

 

 

 

 

Thanks in advance,

 

 

 

 

 


##

#My work to date:

> SurveyData <- read.spss("C:/Data/R/orange_delivery.sav",
use.value.labels=TRUE, max.value.labels=Inf, to.data.frame=TRUE)

> NewTargetData  <- read.table("C:/Data/R/NewTarget.csv", header=TRUE,
sep=",", na.strings="NA", dec=".")

>
#---


> temp <- sub(' +$', '', SurveyData$direction_)   # Remove spaces
from variable names

> SurveyData$direction_ <- temp

>
#---


> SurveyData$StnNum=as.numeric(SurveyData$lineon)

> CurrentX1Sums <- as.matrix(xtabs(~tripid_nu+lineon, data=SurveyData))


> CurrentX2Sums <- apply(CurrentX1Sums, 1, sum)

> NewTargetX1Sums <- as.matrix(NewTargetData)

> NewTargetX2Sums <- apply(NewTargetX1Sums, 1, sum)

> 

> str(CurrentX1Sums)

 xtabs [1:55, 1:13] 1 0 1 0 1 0 0 0 0 1 ...

 - attr(*, "dimnames")=List of 2

  ..$ tripid_nu: chr [1:55] "9011880" "9011890" "9011960" "9011970" ...

  ..$ lineon   : chr [1:13] "Warner Center" "De Soto" "Pierce College"
"Tampa" ...

 - attr(*, "class")= chr [1:2] "xtabs" "table"

 - attr(*, "call")= language xtabs(formula = ~tripid_nu + lineon, data =
SurveyData)

> str(NewTargetX1Sums)

 int [1:55, 1:14] 9011880 9011890 9011960 9011970 9012040 9012050
9012130 9012280 9012290 9012720 ...

 - attr(*, "dimnames")=List of 2

  ..$ : NULL

  ..$ : chr [1:14] "tripid_nu" "Warner.Center" "De.Soto"
"Pierce.College" ...

> 



> CurrentX1Sums

 lineon

tripid_nu Warner Center De Soto Pierce College Tampa Reseda Balboa
Woodley Sepulveda Van Nuys Woodman Valley College Laurel Canyon North
Hollywood

  9011880 1   0  2 1  0  2
1 00   0  1 0
0

  9011890 0   0  0 0  0  0
1 00   0  0 1

[R] Using a background photo in lattice--title and axes missing

2008-11-05 Thread Waichler, Scott R
I am trying to use a background photo in a lattice plot.  I am using the
rimage and TeachingDemos packages to plot the photo and translate from
the photo coordinates in pixels to geographic coordinates, which is what
I want to use for plotting contours, lines, etc.  The (unrunable) code
below does give me a plot showing the photo, color contours, contour
lines, and colorkey, but not the plot title or axes.  How can I get the
title and axes to appear?

  # Define a panel function that fills the true contoured regions with
color.
  # This requires the gridBase package.  panel.contourplot() gives a
stair-step, rectangular
  # pattern caused by the underlying grid.  This custom function from
Deepayan Sarkar
  # fills the contour color regions right up to the contour lines
themselves.
  # This version uses pre-defined colors.
  panel.filledContour2 <- function(x, y, z, subscripts, at, col =
my.colors, ...) {
stopifnot(require("gridBase"))
stopifnot(require("rimage"))  # use for plotting a background photo
stopifnot(require("TeachingDemos")) # use for changing from photo
coordinates (pixels) to geographic coordinates
z <- matrix(z[subscripts], nrow = length(unique(x[subscripts])),
ncol = length(unique(y[subscripts])))
if (!is.double(z)) storage.mode(z) <- "double"
opar <- par(no.readonly = TRUE)
on.exit(par(opar))
if (panel.number() > 1) par(new = TRUE)
par(fig = gridFIG(), omi = c(0, 0, 0, 0), mai = c(0, 0, 0, 0))
cpl <- current.panel.limits() # set the plot window boundaries to
the current panel limits
plot.window(xlim = cpl$xlim, ylim = cpl$ylim, log = "", xaxs = "i",
yaxs = "i")

# Plot the background photo
plot(photo)

# Change from photo to geographic coordinate systems.
# Reference two points in the image coordinate system to the new
coordinate system.
# x1, y1 are in the photo coordinates; x2, y2 are the map/plotting
coordinates you want to work in.
updateusr(x1 = photo.resize.factor * x1r, y1 = photo.resize.factor *
y1r, x2 = x2r, y2 = y2r)

# Plot the color contours
.Internal(filledcontour(as.double(do.breaks(cpl$xlim, nrow(z) - 1)),
as.double(do.breaks(cpl$ylim, ncol(z) - 1)),
z, levels = as.double(at), col = col))

# Add contour lines
contour(as.double(do.breaks(cpl$xlim, nrow(z) - 1)),
as.double(do.breaks(cpl$ylim, ncol(z) - 1)),
z, levels = as.double(at), col = "black",
drawlabels=T, add=T, labcex=0.8)
  }  # end of panel.filledContour2()

  plotfile <- plotfile2b
  png(file = plotfile, width=11, height=8.5, units="in", res=75,
pointsize=12)  # landscape letter
  
  my.cuts <- seq(0, 90, by=10)
  my.colors <- rev(BluetoOrange.10[1:9]) # orange to blue (warm to cold
with increasing time)
  #my.colors <- rgb(col2rgb(my.colors)/255, alpha=0.2)  # make
translucent; only works for pdf, quartz devices
  
  x.limits <- c(593600, 593950)
  x.ticks <- pretty(x.limits, n=5)
  y.limits <- c(113300, 113530)
  y.ticks <- pretty(y.limits, n=5)
  
  p$time[ind.neg] <- 0
  ind <- ind.all.times.injected
  di <- interp(x=p$x[ind], y=p$y[ind], z=p$time[ind], duplicate="mean",
linear=T, 
   xo=seq(x.limits.photo[1], x.limits.photo[2], length =
300), yo=seq(y.limits.photo[1], y.limits.photo[2], length = 300))
  ia <- which(!is.na(di$z))
  grid <- expand.grid(x=di$x, y=di$y)
  
  plot.new()
  
  # contour plot doesn't print a key by default
  print(contourplot(di$z ~ x * y, grid,
# Plot head as filled color contours
panel = panel.filledContour2, subscripts = 1:length(grid$x),

at = my.cuts,
col.regions = my.colors,
colorkey=T,
contour = TRUE, 
aspect="iso", 
as.table=T,
scales = list(x = list(relation="same", alternating = T,
   at =x.ticks.photo, labels = x.ticks.photo,
   limits=x.limits.photo
  ), 
  y = list(relation="same", alternating = T,
   at = y.ticks.photo, labels = y.ticks.photo,
   rot=0,
   limits=y.limits.photo
  )
  ),
xlab=list(label="X (m)", cex=1.1),
ylab=list(label="Y (m)", cex=1.1),
layout=c(1,1), # ncols, nrows
main=list(label="Particle Travel Times", cex=1.2),
strip = F,   # set to FALSE if you don't want strip drawn in plot (a
subtitle)
plot.args = list(newpage = FALSE)
  )) # end print(xyplot())
  dev.off()


Thanks,
Scott Waichler
Pacific Northwest National Laboratory
[EMAIL PROTECTED]

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

2008-11-05 Thread Bert Gunter
I don't think that this answers the poster's question, as he explicitly
mentioned that some row and column indices could be missing.

I think it's simpler and much faster to do this by matrix indexing:

mx <- matrix(NA,nr = max(foo[,1]),ncol = max(foo[,2])) ## fill with NA's
mx[as.matrix(foo[,1:2])] <- foo[,3]

See ?"[" for details.

-- Bert Gunter

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of stephen sefick
Sent: Wednesday, November 05, 2008 2:52 PM
To: Philipp Pagel
Cc: r-help@r-project.org
Subject: Re: [R] Efficient way to fill a matrix

#reshape package should do it
library(reshape)
foo <- data.frame(row=1:5, col=1:3, val=rnorm(15))
cast(foo, row~col)

On Wed, Nov 5, 2008 at 5:47 PM, Philipp Pagel <[EMAIL PROTECTED]> wrote:
>
>Dear R experts,
>
> Suppose I have a data frame of three variables:
>
>> foo <- data.frame(row=1:5, col=1:3, val=rnorm(15))
>> foo
>   row col val
> 11   1 -1.00631642
> 22   2  0.77715344
> 33   3  0.17358793
> 44   1 -1.67226988
> 55   2  1.08218836
> 61   3  1.32961329
> 72   1 -0.51186267
> 83   2 -1.20990127
> 94   3 -0.57786899
> 10   5   1  0.67102887
> 11   1   2  0.05646411
> 12   2   3  0.01146612
> 13   3   1 -3.12094409
> 14   4   2 -1.01932191
> 15   5   3  0.76736702
>
>
> I want to turn this into a matrix of val according to row and col. Let's
also
> assume that some combinations of row and col are missing - i.e. there will
be
> NAs in the resulting Matrix. My current approach is simple and works but
is
> slow for large datasets:
>
> mat <- matrix(nrow=max(foo$row), ncol=max(foo$col))
> for (line in 1:dim(foo)[1]) {
>mat[foo[line, 'row'], foo[line, 'col']] <- foo[line, 'val']
> }
>
>> mat
>   [,1][,2][,3]
> [1,] -1.0063164  0.05646411  1.32961329
> [2,] -0.5118627  0.77715344  0.01146612
> [3,] -3.1209441 -1.20990127  0.17358793
> [4,] -1.6722699 -1.01932191 -0.57786899
> [5,]  0.6710289  1.08218836  0.76736702
>
>
> Can anyone think of a more efficient way?
>
> cu
>Philipp
>
> --
> Dr. Philipp Pagel
> Lehrstuhl für Genomorientierte Bioinformatik
> Technische Universität München
> Wissenschaftszentrum Weihenstephan
> 85350 Freising, Germany
> http://mips.gsf.de/staff/pagel
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Problems computing 2-way-mixed-model ANOVA

2008-11-05 Thread Lucas Eggert
Dear Experts,

I am new to R and unfortunately cannot start with a simply statistical  
analysis:

I manually determined the volume of the right and left hippocampus in  
a group of meditators and in a group of controls. My data-sheet looks  
as follows:


observation subject group   age gender  hemisphere  volume
1   am04m   25  f   left3.637
2   am04m   25  f   right   3.713
3   ao08m   47  m   left3.715
4   ao08m   47  m   right   3.702
5   as11m   43  f   left3.912
6   as11m   43  f   right   4.438
7   bn02c   30  f   left4.497
8   bn02c   30  f   right   4.333
9   ca15c   46  m   left3.346
10  ca15c   46  m   right   3.779
11  cd13m   41  m   left4.167
12  cd13m   41  m   right   4.184
13  dk09m   45  m   left4.289
14  dk09m   45  m   right   4.457
15  dm08c   42  m   left4.084
16  dm08c   42  m   right   3.572
17  donf55  c   47  m   left4.006
18  donf55  c   47  m   right   4.211
19  dr01c   28  m   left3.717
20  dr01c   28  m   right   3.660
21  ds17m   46  m   left4.140
22  ds17m   46  m   right   4.157
23  dts14   m   30  m   left4.830
24  dts14   m   30  m   right   5.081
25  eg19m   46  f   left4.679
26  eg19m   46  f   right   4.123
27  em12m   33  m   left4.183
28  em12m   33  m   right   4.671
29  ew10m   48  m   left4.074
30  ew10m   48  m   right   4.133
31  harp74  c   29  f   left4.449
32  harp74  c   29  f   right   4.505
33  ih18m   26  f   left4.859
34  ih18m   26  f   right   4.635
35  jk20c   26  f   left4.765
36  jk20c   26  f   right   4.582
37  jl22m   29  m   left4.798
38  jl22m   29  m   right   4.970
39  jm05c   24  m   left4.177
40  jm05c   24  m   right   3.878
41  jp16c   49  m   left4.541
42  jp16c   49  m   right   4.468
43  kr16m   28  f   left5.193
44  kr16m   28  f   right   5.367
45  ln06m   31  f   left5.283
46  ln06m   31  f   right   5.971
47  ls06c   29  f   left4.462
48  ls06c   29  f   right   4.517
49  md02m   50  m   left4.733
50  md02m   50  m   right   4.456
51  rp19c   33  m   left4.572
52  rp19c   33  m   right   4.270
53  rs20m   49  m   left5.410
54  rs20m   49  m   right   5.275
55  sinj55  c   49  f   left4.634
56  sinj55  c   49  f   right   4.883
57  sm21m   42  f   left4.499
58  sm21m   42  f   right   4.317
59  sw04c   34  m   left3.956
60  sw04c   34  m   right   4.303
61  sy15m   40  m   left4.429
62  sy15m   40  m   right   4.550
63  ts14c   46  m   left4.233
64  ts14c   46  m   right   4.568
65  wi18c   35  m   left5.101
66  wi18c   35  m   right   5.317
67  ws01m   30  m   left5.221
68  ws01m   30  m   right   5.258
69  zz03m   35  m   left4.446
70  zz03m   35  m   4.446   4.627
My attempt to compute the according statistic was:

aov = aov(volume~(hemisphere*group)+Error(subject/hemisphere)+ 
(group),input)

but with this I got the following error message:

In aov(volume ~ (hemisphere * group) + Error(subject/hemisphere) +  :
   Error() Modell ist singulär

I could not figure out what I did wrong. Furthermore, in the next step  
I would like to use gender and age as additional covariates in the  
model, but I am not sure how to do this either.

  Any help would be very much appreciated!

Thank you,

Sincerely,

Lucas Eggert




[[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] Efficient way to fill a matrix

2008-11-05 Thread Peter Dalgaard

Philipp Pagel wrote:

Dear R experts,

Suppose I have a data frame of three variables:


foo <- data.frame(row=1:5, col=1:3, val=rnorm(15))
foo

   row col val
11   1 -1.00631642
22   2  0.77715344
33   3  0.17358793
44   1 -1.67226988
55   2  1.08218836
61   3  1.32961329
72   1 -0.51186267
83   2 -1.20990127
94   3 -0.57786899
10   5   1  0.67102887
11   1   2  0.05646411
12   2   3  0.01146612
13   3   1 -3.12094409
14   4   2 -1.01932191
15   5   3  0.76736702


I want to turn this into a matrix of val according to row and col. Let's also
assume that some combinations of row and col are missing - i.e. there will be
NAs in the resulting Matrix. My current approach is simple and works but is
slow for large datasets:

mat <- matrix(nrow=max(foo$row), ncol=max(foo$col))
for (line in 1:dim(foo)[1]) {
mat[foo[line, 'row'], foo[line, 'col']] <- foo[line, 'val']
}


mat

   [,1][,2][,3]
[1,] -1.0063164  0.05646411  1.32961329
[2,] -0.5118627  0.77715344  0.01146612
[3,] -3.1209441 -1.20990127  0.17358793
[4,] -1.6722699 -1.01932191 -0.57786899
[5,]  0.6710289  1.08218836  0.76736702


Can anyone think of a more efficient way?


Here's one.

> d <- read.table("clipboard")
> with(d,tapply(val,list(row,col),"[[",1))
   1   2   3
1 -1.0063164  0.05646411  1.32961329
2 -0.5118627  0.77715344  0.01146612
3 -3.1209441 -1.20990127  0.17358793
4 -1.6722699 -1.01932191 -0.57786899
5  0.6710289  1.08218836  0.76736702

or use mean, min, max etc instead of "[[", 1.

Also, there's matrix indexing
> M <- matrix(,5,3)
> attach(d)
> M[cbind(row,col)]<-val
> M
   [,1][,2][,3]
[1,] -1.0063164  0.05646411  1.32961329
[2,] -0.5118627  0.77715344  0.01146612
[3,] -3.1209441 -1.20990127  0.17358793
[4,] -1.6722699 -1.01932191 -0.57786899
[5,]  0.6710289  1.08218836  0.76736702




--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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

2008-11-05 Thread stephen sefick
#reshape package should do it
library(reshape)
foo <- data.frame(row=1:5, col=1:3, val=rnorm(15))
cast(foo, row~col)

On Wed, Nov 5, 2008 at 5:47 PM, Philipp Pagel <[EMAIL PROTECTED]> wrote:
>
>Dear R experts,
>
> Suppose I have a data frame of three variables:
>
>> foo <- data.frame(row=1:5, col=1:3, val=rnorm(15))
>> foo
>   row col val
> 11   1 -1.00631642
> 22   2  0.77715344
> 33   3  0.17358793
> 44   1 -1.67226988
> 55   2  1.08218836
> 61   3  1.32961329
> 72   1 -0.51186267
> 83   2 -1.20990127
> 94   3 -0.57786899
> 10   5   1  0.67102887
> 11   1   2  0.05646411
> 12   2   3  0.01146612
> 13   3   1 -3.12094409
> 14   4   2 -1.01932191
> 15   5   3  0.76736702
>
>
> I want to turn this into a matrix of val according to row and col. Let's also
> assume that some combinations of row and col are missing - i.e. there will be
> NAs in the resulting Matrix. My current approach is simple and works but is
> slow for large datasets:
>
> mat <- matrix(nrow=max(foo$row), ncol=max(foo$col))
> for (line in 1:dim(foo)[1]) {
>mat[foo[line, 'row'], foo[line, 'col']] <- foo[line, 'val']
> }
>
>> mat
>   [,1][,2][,3]
> [1,] -1.0063164  0.05646411  1.32961329
> [2,] -0.5118627  0.77715344  0.01146612
> [3,] -3.1209441 -1.20990127  0.17358793
> [4,] -1.6722699 -1.01932191 -0.57786899
> [5,]  0.6710289  1.08218836  0.76736702
>
>
> Can anyone think of a more efficient way?
>
> cu
>Philipp
>
> --
> Dr. Philipp Pagel
> Lehrstuhl für Genomorientierte Bioinformatik
> Technische Universität München
> Wissenschaftszentrum Weihenstephan
> 85350 Freising, Germany
> http://mips.gsf.de/staff/pagel
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Efficient way to fill a matrix

2008-11-05 Thread Philipp Pagel

Dear R experts,

Suppose I have a data frame of three variables:

> foo <- data.frame(row=1:5, col=1:3, val=rnorm(15))
> foo
   row col val
11   1 -1.00631642
22   2  0.77715344
33   3  0.17358793
44   1 -1.67226988
55   2  1.08218836
61   3  1.32961329
72   1 -0.51186267
83   2 -1.20990127
94   3 -0.57786899
10   5   1  0.67102887
11   1   2  0.05646411
12   2   3  0.01146612
13   3   1 -3.12094409
14   4   2 -1.01932191
15   5   3  0.76736702


I want to turn this into a matrix of val according to row and col. Let's also
assume that some combinations of row and col are missing - i.e. there will be
NAs in the resulting Matrix. My current approach is simple and works but is
slow for large datasets:

mat <- matrix(nrow=max(foo$row), ncol=max(foo$col))
for (line in 1:dim(foo)[1]) {
mat[foo[line, 'row'], foo[line, 'col']] <- foo[line, 'val']
}

> mat
   [,1][,2][,3]
[1,] -1.0063164  0.05646411  1.32961329
[2,] -0.5118627  0.77715344  0.01146612
[3,] -3.1209441 -1.20990127  0.17358793
[4,] -1.6722699 -1.01932191 -0.57786899
[5,]  0.6710289  1.08218836  0.76736702


Can anyone think of a more efficient way?

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

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

2008-11-05 Thread Feldman, Ruben
Hello,

I ran the coxph model and everything worked fine. When I extract the
output from the basehaz(y) function and was wondering if that baseline
is cumulative or not.
I then do:

F(t,t+1)=1-exp(h_0(t+1) exp(coeff(1)*covariate(1)+...))

Does this give me the probability of death from t to t+1 (in which case
the baseline is not cumulative) or the probability of death before t+1
(in which case the baseline is cumulative)

Thanks so much for your help!
R

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

2008-11-05 Thread Armin Meier
Hi all,
I want to optimize a function fn using optim. This function fn calls
the .C function in it with a function name and arguments given to fn,
i.e. something like this pseudocode:

fn <- function(par, "some params for fn") {... .C("Cfunction", ...) ...}
optim(par, fn, "some params for fn")

In my case this doesn't work, but is it possible in general and I made
some error?

Thanks in advance
Armin

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

2008-11-05 Thread Horace Tso
Folks,

I'm making progress moving from Windows to Linux and have RKward up and 
running. I read somewhere that Rkward's supposed to be the Tinn-R for linux and 
Tinn-R has worked out great for me. So naturally I'd like to do the following, 
if possible,

1. How to ask Rkward not to load the last saved image. Right now whenever it 
starts, it loads an image from some obscure corner of my directory. I can't 
quite figure out where it gets that image from. On the command line, I can do 
--no-restore. But there seems to be no place to sneak in these command line 
options under Rkward.  A startup config file hidden somewhere?

2. Customize CTRL-keys. Just out of the box, many menu options do not have a 
control key associated with them. Any way to pick my favorite key?

3. I'm used to typing ?command on the R-console and get a HTML help page pops 
up. But when I do that, a shockingly large window comes up and complains in 
many words about some error which I can't quite figure out what it's saying 
(sorry don't have linux in front of me right now).

4. I see there is an 'Output' tab by default. But command results are sent to 
R-console, and nothing seems to happen in 'Output'.

I have R 2.7.1 running under KDE on openSUSE 10.3.

TIA.

Horace

[[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] Memory limits for large data sets

2008-11-05 Thread stephen sefick
I believe that it depends on the operating system.
memory.limit()
I think this is in the FAQ and search the R email list archive

On Wed, Nov 5, 2008 at 2:53 PM, Alan Cohen <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have several very large data sets (1-7 million observations, sometimes 
> hundreds of variables) that I'm trying to work with in R, and memory seems to 
> be a big issue.  I'm currently using a 2 GB Windows setup, but might have the 
> option to run R on a server remotely.  Windows R seems basically limited to 2 
> GB memory if I'm right; is there the possibility to go much beyond that with 
> server-based R?  In other words, am I limited by R or by my hardware, and how 
> much might R be able to handle if I get the hardware necessary?
>
> Also, any possibility of using web-based R for this kind of thing?
>
> Cheers,
> Alan Cohen
>
> Alan Cohen
> Post-doctoral Fellow
> Centre for Global Health Research
> 70 Richmond St. East, Suite 202A
> Toronto, ON M5C 1N8
> Canada
> (416) 854-3121 (cell)
> (416) 864-6060 ext. 3156 (0ffice)
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Applying a loop with rnorm() to eliminate dupli cate coordinates in a dataframe object

2008-11-05 Thread Ben Bolker
Ricardo Bandin  gmail.com> writes:

> 
> Dear colleagues
> 
> I found duplicate coordinates trying to convert a dataframe object (see the
> attached file) into a geodata one ('geoR' package is needed). My dataframe
> object consists of 2 columns with UTM geographical coordinates and a 3rd
> column with fish densities .
> 
> To overcome the handicap I must add a tiny value generated by rnorm() to
> each geographical coordinate. And it must be in a loop, otherwise the added
> value will be the same for all the coordinates, persisting the duplicates.
> The example given to me was:
> for (i in 1: length(x$coords[1]) { x$coords[1]+rnorm(1,0,1) }
> 
> But I still can not understand this instruction syntaxis. I'll be very
> grateful if somebody can teach me.
> 

  I don't quite understand the syntax either -- and your attachment
seems to have got(ten) lost in translation.  I'm not quite sure
about the structure of your data frame, but *if* it had three
columns x, y, and z the loop above should be

for (i in 1: length(x$x[i]) { x$x[i]+rnorm(1,0,1) }

(the absence of the loop variable "i" in the statement between
the curly brackets is a clue that something is wrong ...)

but you should be able to do this in a vectorized way as

x$x <- x$x+rnorm(length(x$x),0,1)

I would also suggest that you should adjust the
standard deviation of the noise to be small relative
to the magnitude of your coordinates ...

  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.


[R] thanks for the help: how can I save the estimates of a regression model in a file?

2008-11-05 Thread pilar schneider
Thanks for your help
the codes you gave me worked vey well!
cheers
Maria

-- 
-
[EMAIL PROTECTED]

[[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] Memory limits for large data sets

2008-11-05 Thread Alan Cohen
Hello,

I have several very large data sets (1-7 million observations, sometimes 
hundreds of variables) that I'm trying to work with in R, and memory seems to 
be a big issue.  I'm currently using a 2 GB Windows setup, but might have the 
option to run R on a server remotely.  Windows R seems basically limited to 2 
GB memory if I'm right; is there the possibility to go much beyond that with 
server-based R?  In other words, am I limited by R or by my hardware, and how 
much might R be able to handle if I get the hardware necessary?

Also, any possibility of using web-based R for this kind of thing?

Cheers,
Alan Cohen

Alan Cohen
Post-doctoral Fellow
Centre for Global Health Research
70 Richmond St. East, Suite 202A
Toronto, ON M5C 1N8
Canada
(416) 854-3121 (cell)
(416) 864-6060 ext. 3156 (0ffice)

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


Re: [R] (no subject)

2008-11-05 Thread megha patnaik
How are you starting R ?
It is not a directory. Usually, if you simply say

R

at a shell prompt, it starts R for you.


2008/11/6 Aimin Yan <[EMAIL PROTECTED]>

> In linux, when I start R,
>
> I get some message like this:
>
> Error:unexpected '/' in '"/"
>
> Does anyone know why?
>
> AMY
>
> Thanks,
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] (no subject)

2008-11-05 Thread Erik Iverson

Try starting it as, R --vanilla  , do you still get the error?

Do you have a file called .Rprofile in your home directory?

Aimin Yan wrote:

In linux, when I start R,

I get some message like this:

Error:unexpected '/' in '"/"

Does anyone know why?

AMY

Thanks,

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

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


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


[R] (no subject)

2008-11-05 Thread Aimin Yan

In linux, when I start R,

I get some message like this:

Error:unexpected '/' in '"/"

Does anyone know why?

AMY

Thanks,

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


Re: [R] how can I save the estimates of a regression model in a file?

2008-11-05 Thread hadley wickham
On Wed, Nov 5, 2008 at 11:12 AM, pilar schneider
<[EMAIL PROTECTED]> wrote:
> Dear all
> I need some help with R.
> How can I save the estimates of a regression model in a file?
>
> here is what I did:
>
> 1) this is my regression model:
> fit1 <- lm(logmilk ~ logdays + days, data=data2)
>
> 2) however, I want to get the parameters estimates for each individual (by
> group):
> so i did the following:
> by(data2, list(data2$V2),function(.data2) lm(logmilk ~ logdays + days, data=
> .data2))
>
> 3) Then to keep the estimates in a file I did:
> res1 <- by(data2, list(data2$V2),function(.data2) lm(logmilk ~ logdays + V5,
> data= .data2))
>

Here's one way that uses the plyr package (http://had.co.nz/)

# Name the model fitting function
fit_model <- function(df) lm(logmilk ~ logdays + days, data = df)

# Create a list of models for each value of V2
# this is basically equivalent to by, but it deals with labelling a bit better
models <- dlply(data2, .(V2), fit_model)

# Produce a data frame containing the coefficients for each model
ldply(models, coef)

Hadley


-- 
http://had.co.nz/

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

2008-11-05 Thread Vincent Goulet

Le mer. 5 nov. à 12:11, Robert Zimbardo a écrit :


Hi all

Is there going to be a binary of R 2.8.0 for Ubuntu Intrepid Ibex  
i386 -

i.e., not just amd 64bit?


I was going to reply that the binaries have been there for a few days  
already, but I realize I forgot to copy them to my repository. It's  
done now and they will reach CRAN mirrors within the next few hours.


Sorry for the inconvenience.

In the future, please ask Ubuntu related questions on R-SIG-Debian  
(cc'd) where such postings have a far greater chance of being noticed.



Thx,
RZ


---
  Vincent Goulet, Associate Professor
  École d'actuariat
  Université Laval, Québec
  [EMAIL PROTECTED]   http://vgoulet.act.ulaval.ca

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

2008-11-05 Thread Richardson, Patrick
http://www.ats.ucla.edu/stat/R/faq/sort.htm

A great tutorial about sorting data in R.

HTH,

_
Patrick Richardson
Biostatistician - Program of Translational Medicine
Van Andel Research Institute - Webb Lab
Grand Rapids, MI  49503


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rajasekaramya
Sent: Wednesday, November 05, 2008 2:03 PM
To: r-help@r-project.org
Subject: [R] Sort help


  Geneset_name  #Chromosome  #Hit_in_Biomart
original_geneset_len  Missing.genes
 [1,] "AGUIRRE_PANCREAS_CHR12"  "1" "51"
"59" "8"
  [3,] "AGUIRRE_PANCREAS_CHR9"   "1" "24"
"24" "0"
 [4,] "AGUIRRE_PANCREAS_CHR1""1" "30"
"31" "1"
 [5,] "AGUIRRE_PANCREAS_CHR18"  "1" "17"
"17" "0"
 [6,] "AGUIRRE_PANCREAS_CHR7"   "1" "35"
"48" "13"
 [7,] "AGUIRRE_PANCREAS_CHR8"   "1" "55"
"61" "6"

Above is a dataframe information.

i need to sort the entire dataframe based on the  3rd colum. in decending
order.

I tried using order

information[order(information[,3])] but it gives me only the ordered first
coulmn that too i am not sure that it really works.

Kindly let me know with any suggestions.

Regards
Ramya


--
View this message in context: 
http://www.nabble.com/Sort-help-tp20346314p20346314.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.
This email message, including any attachments, is for th...{{dropped:6}}

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


Re: [R] Sort help

2008-11-05 Thread Jorge Ivan Velez
Hi Ramya,
You're almost there. Just specify that you want to order all the data set
based-on the third column. Here is an example:

# Data
information=data.frame(
geneset=letters[1:7],
chromosome=1,
hit=c(51,24,30,17,35,55,61))

# New data
information[order(information[,3],decreasing=TRUE),]

HTH,

Jorge



On Wed, Nov 5, 2008 at 2:02 PM, Rajasekaramya <[EMAIL PROTECTED]>wrote:

>
>  Geneset_name  #Chromosome  #Hit_in_Biomart
> original_geneset_len  Missing.genes
>  [1,] "AGUIRRE_PANCREAS_CHR12"  "1" "51"
> "59" "8"
>  [3,] "AGUIRRE_PANCREAS_CHR9"   "1" "24"
> "24" "0"
>  [4,] "AGUIRRE_PANCREAS_CHR1""1" "30"
> "31" "1"
>  [5,] "AGUIRRE_PANCREAS_CHR18"  "1" "17"
> "17" "0"
>  [6,] "AGUIRRE_PANCREAS_CHR7"   "1" "35"
> "48" "13"
>  [7,] "AGUIRRE_PANCREAS_CHR8"   "1" "55"
> "61" "6"
>
> Above is a dataframe information.
>
> i need to sort the entire dataframe based on the  3rd colum. in decending
> order.
>
> I tried using order
>
> information[order(information[,3])] but it gives me only the ordered first
> coulmn that too i am not sure that it really works.
>
> Kindly let me know with any suggestions.
>
> Regards
> Ramya
>
>
> --
> View this message in context:
> http://www.nabble.com/Sort-help-tp20346314p20346314.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.


[R] Applying a loop with rnorm() to eliminate duplicate coordinates in a dataframe object

2008-11-05 Thread Ricardo Bandin
Dear colleagues

I found duplicate coordinates trying to convert a dataframe object (see the
attached file) into a geodata one ('geoR' package is needed). My dataframe
object consists of 2 columns with UTM geographical coordinates and a 3rd
column with fish densities .

To overcome the handicap I must add a tiny value generated by rnorm() to
each geographical coordinate. And it must be in a loop, otherwise the added
value will be the same for all the coordinates, persisting the duplicates.
The example given to me was:
for (i in 1: length(x$coords[1]) { x$coords[1]+rnorm(1,0,1) }

But I still can not understand this instruction syntaxis. I'll be very
grateful if somebody can teach me.

Thanks for your attention,

-- 
Ricardo Bandin Llanos
[EMAIL PROTECTED]
Estudiante - Magíster Cs. m. Pesquerías
Universidad de Concepción, Región del Bio-Bio, Chile
Celular: (0056-41) 97949957
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sort help

2008-11-05 Thread Rajasekaramya

  Geneset_name  #Chromosome  #Hit_in_Biomart 
original_geneset_len  Missing.genes
 [1,] "AGUIRRE_PANCREAS_CHR12"  "1" "51"
"59" "8"   
  [3,] "AGUIRRE_PANCREAS_CHR9"   "1" "24"   
"24" "0"   
 [4,] "AGUIRRE_PANCREAS_CHR1""1" "30"   
"31" "1"   
 [5,] "AGUIRRE_PANCREAS_CHR18"  "1" "17"   
"17" "0"   
 [6,] "AGUIRRE_PANCREAS_CHR7"   "1" "35"   
"48" "13"  
 [7,] "AGUIRRE_PANCREAS_CHR8"   "1" "55"   
"61" "6"  

Above is a dataframe information.

i need to sort the entire dataframe based on the  3rd colum. in decending
order.

I tried using order

information[order(information[,3])] but it gives me only the ordered first
coulmn that too i am not sure that it really works.

Kindly let me know with any suggestions.

Regards
Ramya

 
-- 
View this message in context: 
http://www.nabble.com/Sort-help-tp20346314p20346314.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 2.8.0 for Ubuntu Intrepid Ibex i386

2008-11-05 Thread Robert Zimbardo
Hi all

Is there going to be a binary of R 2.8.0 for Ubuntu Intrepid Ibex i386 -
i.e., not just amd 64bit?
Thx,
RZ

[[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] sink() within a loop. Solved

2008-11-05 Thread jgarcia
Uwe;
sorry for my last mail. In effect, as you say ,I just needed to explicitly
print() the object to be sinked within the loops.

Thanks you,

Javier



>
>
> [EMAIL PROTECTED] wrote:
>> Hello;
>> It seems to me that this could even by a FAQ, but I cannot find an
>> answer:
>>
>> Why a piece of code that uses sink() does not sinks anything if it is
>> executed within a for loop?
>
> Without sink(), does it print anything in the console? If not: use
> print() in order to print it (i.e. sink it to another connection).
>
> Uwe Ligges
>
>
>>
>>
>> Thanks,
>> Javier
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] sink() within a loop

2008-11-05 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
> Sent: Wednesday, November 05, 2008 10:19 AM
> To: Uwe Ligges
> Cc: r-help@r-project.org
> Subject: Re: [R] sink() within a loop
> 
> Well, I'll put a foo example of my problem:
> 
> I'got a list:
> 
> >a <- list()
> >a$sublist.1 <- list()
> >a$sublist.1$subsublist.1 <- list()
> 
> this code works:
> 
> >zz <- file("foo.txt","w")
> >sink(zz)
> >a
> >sink()
> >close(zz)
> 
> and generates a correct "foo.txt" file containing the 
> structure of the list
> 
> but this code doesn't:
> 
> >for(i in 1){
>  zz <- file("foo.txt","w")
>  sink(zz)
>  a
>  sink()
>  close(zz)
> }
> 
> as the resulting "foo.txt" file is empty
> 
> I don't understand why.
> 
> Javier
> -
> >
> >
> > [EMAIL PROTECTED] wrote:
> >> Hello;
> >> It seems to me that this could even by a FAQ, but I cannot find an
> >> answer:
> >>
> >> Why a piece of code that uses sink() does not sinks 
> anything if it is
> >> executed within a for loop?
> >
> > Without sink(), does it print anything in the console? If not: use
> > print() in order to print it (i.e. sink it to another connection).
> >
> > Uwe Ligges
> >
> >
> >>
> >>
> >> Thanks,
> >> Javier
> >>

Javier,

Uwe gave you the answer.  You need to explicitly print your variable as 
otherwise it will not be output to the console (and available to be be sunk).  
The same would be true if you were doing this inside a function.  For example:

for(i in 1){
  zz <- file("foo.txt","w")
  sink(zz)
  print(a)
  sink()
  close(zz)
}

One other comment.  If you are actually going to do this inside a loop with 
multiple iterations, you will need to either change the file name on each 
iteration, or set the parameter append=TRUE, or you will overwrite data from 
the previous iterations.

Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204
 
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sink() within a loop

2008-11-05 Thread jgarcia
Well, I'll put a foo example of my problem:

I'got a list:

>a <- list()
>a$sublist.1 <- list()
>a$sublist.1$subsublist.1 <- list()

this code works:

>zz <- file("foo.txt","w")
>sink(zz)
>a
>sink()
>close(zz)

and generates a correct "foo.txt" file containing the structure of the list

but this code doesn't:

>for(i in 1){
 zz <- file("foo.txt","w")
 sink(zz)
 a
 sink()
 close(zz)
}

as the resulting "foo.txt" file is empty

I don't understand why.

Javier
-

















>
>
> [EMAIL PROTECTED] wrote:
>> Hello;
>> It seems to me that this could even by a FAQ, but I cannot find an
>> answer:
>>
>> Why a piece of code that uses sink() does not sinks anything if it is
>> executed within a for loop?
>
> Without sink(), does it print anything in the console? If not: use
> print() in order to print it (i.e. sink it to another connection).
>
> Uwe Ligges
>
>
>>
>>
>> Thanks,
>> Javier
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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 can I save the estimates of a regression model in a file?

2008-11-05 Thread Chuck Cleland
On 11/5/2008 12:12 PM, pilar schneider wrote:
> Dear all
> I need some help with R.
> How can I save the estimates of a regression model in a file?
> 
> here is what I did:
> 
> 1) this is my regression model:
> fit1 <- lm(logmilk ~ logdays + days, data=data2)
> 
> 2) however, I want to get the parameters estimates for each individual (by
> group):
> so i did the following:
> by(data2, list(data2$V2),function(.data2) lm(logmilk ~ logdays + days, data=
> .data2))
> 
> 3) Then to keep the estimates in a file I did:
> res1 <- by(data2, list(data2$V2),function(.data2) lm(logmilk ~ logdays + V5,
> data= .data2))
> 
> 4) and this is what I  get for each individual:
> : 1
> Call:
> lm(formula = logmilk ~ logdays + days, data = .data2)
> Coefficients:
> (Intercept)  logdays   days
>3.414105 0.069387-0.001732
> 
> ---
> : 2
> Call:
> lm(formula = logmilk ~ logdays + days, data = .data2)
> 
> Coefficients:
> (Intercept)  logdays   days
>   3.22761140.1223412   -0.0006836
> 
> and so on:
> 
> 
> 5) THE QUESTION is:
> 
> there is a way in R to get an output file as you get in SAS when you use:
> prog reg data=xxx outest=estimate;
> I would need an output that looks like this:
> 
> individual intercept logdays   days   etc
> 1   3.4141050.069387   -0.0006836
> 2   3.2276114   0.1223412  -0.0006836
> 
> n      ..   .
> THANKS FOR YOUR HELP
> 
> Maria 

  Consider something like this:

as.data.frame(t(sapply(split(data2, data2$V2),
function(x){coef(lm(logmilk ~ logdays + days, data = x))})))

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] "Text" function in 3D graph

2008-11-05 Thread Duncan Murdoch

On 11/5/2008 10:59 AM, EVANS David-William wrote:

Fellow R users,

 


I often use « text » to annotate plots in 2 dimensions.  Having grown up to 3 
dimensions recently, I am looking for a similar function.  Could anyone provide 
code for how to annotate points in a 3-d plot?


You need to describe how you are producing the 3d plot.  The rgl package 
has text3d, but it's different in the scatterplot3d package or lattice.


Duncan Murdoch

 


Your help is greatly appreciated.

 


For Sébastien Velazquez.

 


-

Merci de répondre à cette adresse e-mail et à [EMAIL PROTECTED]  .  

Please reply both to this email address and to [EMAIL PROTECTED]  . 

 

 



[[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] relabeling the x-axis of a plot with discontinuous timestamps

2008-11-05 Thread Uwe Ligges



Stoesser, Jochen wrote:

Hi all,

I have two vectors of data:

The first vector contains timestamps (as integers), however the
difference between these dates varies. For instance, the vector can be
c(0, 5 , 10, 20, 25, 30) so that there is a "jump" between the third and
the fourth element.



If these are integers (and no kind of date or time objects), then you 
may want to suppress the x axis at first (argument xaxt="n") and at it 
later on by using


axis(1, at= c(0, 5, 10, 20, 25, 30), labels= c(0, 5, 10, 20, 25, 30))

Uwe Ligges




The second vector contains the associated values that I want to plot
against these timestamps.

My problem is that I can't figure out how to label the x-axis with
timestamps that are not continuous but have jumps, as in the example
above. I tried relabeling the x-axis and using ts objects, but these
approaches seem to require continuous time series.

I appreciate any hint.

Best,
Jochen

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sink() within a loop

2008-11-05 Thread Uwe Ligges



[EMAIL PROTECTED] wrote:

Hello;
It seems to me that this could even by a FAQ, but I cannot find an answer:

Why a piece of code that uses sink() does not sinks anything if it is
executed within a for loop?


Without sink(), does it print anything in the console? If not: use 
print() in order to print it (i.e. sink it to another connection).


Uwe Ligges





Thanks,
Javier

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sink() within a loop

2008-11-05 Thread jgarcia
Hello;
It seems to me that this could even by a FAQ, but I cannot find an answer:

Why a piece of code that uses sink() does not sinks anything if it is
executed within a for loop?


Thanks,
Javier

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] "Text" function in 3D graph

2008-11-05 Thread Uwe Ligges



EVANS David-William wrote:

Fellow R users,

 


I often use « text » to annotate plots in 2 dimensions.  Having grown up to 3 
dimensions recently, I am looking for a similar function.  Could anyone provide 
code for how to annotate points in a 3-d plot?



Depends on the framework you are using for your 3D stuff: Lattice, rgl, 
... ?


Uwe Ligges





 


Your help is greatly appreciated.

 


For Sébastien Velazquez.

 


-

Merci de répondre à cette adresse e-mail et à [EMAIL PROTECTED]  .  

Please reply both to this email address and to [EMAIL PROTECTED]  . 

 

 



[[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] Importing data to a multidimensional array

2008-11-05 Thread Uwe Ligges



Jon Wong wrote:

Hi,
I was wondering if I could get some help on importing data into a
three-dimensional array?

I am importing data from several text files:

dsdir<-"c:/documents and settings/desktop/07082008/" # path to files
dsfb1<-"07082008-DI4129b.dat" # file base name

firsthour<-13 # first hour of observation which changes from 6am to 1pm from
day to day
lasthour<-20 # last hour of observation which also changes from 6 - 8pm

for(i in firsthour:lasthour)
assign(paste("ds",i,"a",sep=""),read.delim(file=paste(dsdir,i,dsfb1,sep=""),
header=F, sep="\t", skip=5))



Always a bad idea to make such assignment, better assign into a list 
"ds" with elements called a13...a20, for example.
You can easily make it 3D by unlist() it and assigning new dim() 
attributes afterwards, for example.


Or perhaps even better, read each data.frame, coerce to a matrix which 
you insert into the correct position of a pre-defined array().


Uwe Ligges



This code generates matrices from ds13a:ds20a containing data from the
respective text files, but I need this in a three-dimensional array for
further processing.  The observation counts in the imported files vary from
one to another, and there is never a set number of files to be imported.
 Any help is greatly appreciated.  Thanks

Sincerely,
Jon

[[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] CPU usage on Windows (R 2.7.1)

2008-11-05 Thread Uwe Ligges



Borja Soto Varela wrote:

Dear R-users,

I'm using R (2.7.1) under windows and I've got a function written in R that
calls a Fortran 77 subroutine using both interface function (.C and
.Fortran). The Fortran 77 source was compiled to a shared library using g77
(3.4.5).
When I call the R wrapper function, it will use the 100% of my CPU during 25
minutes (the fortran algorithm require a lot of time of execution)  . The
same thing if you try the next code:


vec=rexp(2000)
fitdistr(vec,"exponential")


that also use the 100% of my cpu during 30 seconds. In both cases, it makes
R crash when running another program but If I don't do anything, it runs
fine.
Is there any solution to this?. It runs better using Linux?.



Might be a bug in R, the package (i.e. Fortran code) or even with your 
hardware (CPU temperature).


Hence I suggest to try again with a *recent* version of R (i.e. R-2.8.0) 
and a recent version of the package. It would also be nice if you can 
make it better reproducible (I haven't seen it during some quick tries).


Uwe Ligges



Thanks
Borja

[[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] CPU usage on Windows (R 2.7.1)

2008-11-05 Thread Borja Soto Varela
Dear R-users,

I'm using R (2.7.1) under windows and I've got a function written in R that
calls a Fortran 77 subroutine using both interface function (.C and
.Fortran). The Fortran 77 source was compiled to a shared library using g77
(3.4.5).
When I call the R wrapper function, it will use the 100% of my CPU during 25
minutes (the fortran algorithm require a lot of time of execution)  . The
same thing if you try the next code:

> vec=rexp(2000)
> fitdistr(vec,"exponential")

that also use the 100% of my cpu during 30 seconds. In both cases, it makes
R crash when running another program but If I don't do anything, it runs
fine.
Is there any solution to this?. It runs better using Linux?.

Thanks
Borja

[[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] Importing data to a multidimensional array

2008-11-05 Thread Jon Wong
Hi,
I was wondering if I could get some help on importing data into a
three-dimensional array?

I am importing data from several text files:

dsdir<-"c:/documents and settings/desktop/07082008/" # path to files
dsfb1<-"07082008-DI4129b.dat" # file base name

firsthour<-13 # first hour of observation which changes from 6am to 1pm from
day to day
lasthour<-20 # last hour of observation which also changes from 6 - 8pm

for(i in firsthour:lasthour)
assign(paste("ds",i,"a",sep=""),read.delim(file=paste(dsdir,i,dsfb1,sep=""),
header=F, sep="\t", skip=5))

This code generates matrices from ds13a:ds20a containing data from the
respective text files, but I need this in a three-dimensional array for
further processing.  The observation counts in the imported files vary from
one to another, and there is never a set number of files to be imported.
 Any help is greatly appreciated.  Thanks

Sincerely,
Jon

[[alternative HTML version deleted]]

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


[R] Using RGDAL to "copy" header information...

2008-11-05 Thread Jonathan Greenberg

R-geographers...

I'm trying to solve a problem to implement a line-by-line tiled 
processing using RGDAL (read 1 line of an image, process the one line, 
write one line of the image to a binary file).  Everything except for 
the final step I'm able to do using a combination of RGDAL and r-base 
commands.  Below is the basic structure, the input file "elev" can be 
any image file GDAL supports -- the code below just "copies" the image 
one line at a time:


###

library(rgdal)
infile='elev'
outfile_base='testout'
outfile_ext='.bil'
outfile=paste(outfile_base,outfile_ext,sep='')
outcon <- file(outfile, "wb")

infile_info=GDALinfo(infile)
nl=infile_info[[1]]
ns=infile_info[[2]]

for (row in 1:nl) {
   templine <- readGDAL(infile,region.dim=c(1,ns),offset=c(row-1,0))
   writeBin(templine[[1]], outcon,size=4)
}
close(outcon)
# Below doesn't work
# writeGDAL(templine,outfile_base,drivername='EHdr',type="Float32")

###

The issue is this: I need to be able to effectively copy the 
geographic/header information from the input file (the last line almost 
works, but as you can see it sets the line #s to 1, not "ns"), and parse 
it over to the output file (which is some form of a flat binary file -- 
in this case, an Arc Binary Raster, but an ENVI binary output would also 
be good) -- ideally I'd like to be able to modify this header, 
particularly the number type (e.g. if the input file is an integer, and 
I'm writing out a floating point binary, I need that reflected in the 
output header).  I can do this by *manually* creating the output header 
via a series of ascii-writes, but I was wondering if there is a more 
effective way of doing this using RGDAL that might apply generically to 
the header of any binary image file I might write?  Thanks!


--j


--

Jonathan A. Greenberg, PhD
Postdoctoral Scholar
Center for Spatial Technologies and Remote Sensing (CSTARS)
University of California, Davis
One Shields Avenue
The Barn, Room 250N
Davis, CA 95616
Cell: 415-794-5043
AIM: jgrn307, MSN: [EMAIL PROTECTED], Gchat: jgrn307

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 can I save the estimates of a regression model in a file?

2008-11-05 Thread pilar schneider
Dear all
I need some help with R.
How can I save the estimates of a regression model in a file?

here is what I did:

1) this is my regression model:
fit1 <- lm(logmilk ~ logdays + days, data=data2)

2) however, I want to get the parameters estimates for each individual (by
group):
so i did the following:
by(data2, list(data2$V2),function(.data2) lm(logmilk ~ logdays + days, data=
.data2))

3) Then to keep the estimates in a file I did:
res1 <- by(data2, list(data2$V2),function(.data2) lm(logmilk ~ logdays + V5,
data= .data2))

4) and this is what I  get for each individual:
: 1
Call:
lm(formula = logmilk ~ logdays + days, data = .data2)
Coefficients:
(Intercept)  logdays   days
   3.414105 0.069387-0.001732

---
: 2
Call:
lm(formula = logmilk ~ logdays + days, data = .data2)

Coefficients:
(Intercept)  logdays   days
  3.22761140.1223412   -0.0006836

and so on:


5) THE QUESTION is:

there is a way in R to get an output file as you get in SAS when you use:
prog reg data=xxx outest=estimate;
I would need an output that looks like this:

individual intercept logdays   days   etc
1   3.4141050.069387   -0.0006836
2   3.2276114   0.1223412  -0.0006836

n      ..   .
THANKS FOR YOUR HELP

Maria

-- 
-
[EMAIL PROTECTED]

[[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] slow aggregate function

2008-11-05 Thread stephen sefick
sounds like plyr although I have never used it...  If you want help
with code you need to provide reproducible examples.

On Wed, Nov 5, 2008 at 5:11 AM, Bert Jacobs
<[EMAIL PROTECTED]> wrote:
>
>
>
>
> Hi,
>
> I've written the following line of code to make a summary of some data:
>
>
>
> Final.Data.Short  <- as.data.frame(aggregate(Merge.FinalSubset[,8:167],
> list(Location = Merge.FinalSubset $Location,Measure = Merge.FinalSubset
> $Measure,Site = Merge.FinalSubset $Site, Label= Merge.FinalSubset $Label),
> FUN=sum))
>
>
>
> Where "Merge.FinalSubset" is a dataframe of 2640 rows and 167 columns
>
> The result "Final.Data.Short" is a dataframe of  890 rows and 164 columns
>
>
>
> This operation takes at the moment more than a minute. Now I was wondering
> if their exist ways to reduce this operation time by using other code or by
> splitting the original dataframe in smaller bits, make several different
> aggregations, and recompose the dataframe again?
>
>
>
> Thx for helping me out
>
> Bert
>
>
>
>
>
>
>
>
>[[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.
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

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

2008-11-05 Thread David Epstein

I wanted to install the package "gdata". Here are the commands I gave and the
responses:

install.packages("gdata")
Warning in install.packages("gdata") :
  argument 'lib' is missing: using '/Users/dbae/Library/R/library'
trying URL
'http://cran.uk.r-project.org/bin/macosx/universal/contrib/2.8/gdata_2.4.2.tgz'
Content type 'application/x-gzip' length 539288 bytes (526 Kb)
opened URL
==
downloaded 526 Kb


The downloaded packages are in
/tmp/RtmpwY5Qor/downloaded_packages
> library(gdata)
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared library
'/Users/dbae/Library/R/library/gtools/libs/ppc/gtools.so':
  dlopen(/Users/dbae/Library/R/library/gtools/libs/ppc/gtools.so, 6):
Library not loaded:
/Library/Frameworks/R.framework/Versions/2.7/Resources/lib/libR.dylib
  Referenced from: /Users/dbae/Library/R/library/gtools/libs/ppc/gtools.so
  Reason: image not found
Error: package/namespace load failed for 'gdata'

I took a look in /Library/Frameworks/R.framework/Versions/2.7/Resources/
and, indeed, there was a directory "library" but no directory "lib". The
file /Library/Frameworks/R.framework/Versions/2.8/Resources/lib/libR.dylib
is present, but apparently that's not good enough. Any ideas on how I can
make this work?

I am running R 2.8.0 GUI 1.26 (5256) under MacOsX 10.4.11 on a G4 PPC
machine.

Thanks for any help.
David
-- 
View this message in context: 
http://www.nabble.com/library%28gdata%29-fails-tp20343452p20343452.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] Internal and displayed precision of numbers

2008-11-05 Thread Uwe Ligges



Oliver Bandel wrote:

Hello,

many thanks!

BTW: I read your book. :)
It's quite good.


Thank you.



But I didn'tfoud the precision-stuff in it.
Adding information about this topic in the next
edition might be a good idea.


These numeric things are an interesting and important topic, of cours. 
Question is how much to add, since it can be a whole book of its own. I 
am teaching "Computergetützte Statistik" (i.e. something like numerics 
for applied statisticians) this term anyway.


Best,
Uwe






Nevertheless it explains crucial points very good,
and from that starting point, it's easier to understand the
manuals/help-pages.

Ciao,
   Oliver








Zitat von Uwe Ligges <[EMAIL PROTECTED]>:



Oliver Bandel wrote:

Hello,

can the displayed and/or used precision of numbers be
configured? And if... how?


See ?.Machine for the internally used precision.
See ?options and ?format/?formatC/?print for the printed precision.

Uwe Ligges





Ciao,
   Oliver

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

2008-11-05 Thread Erik Iverson

Hello -

Rajasekaramya wrote:

Hi there,

I have a dataframe length.unique.info

length.unique.info

abc 12  345
def  16  550
lmn  6   600


Is this really the output when you print your data.frame?  You may have 
column names for columns 1, 2, and 3?  Is the first column a column of 
row.names, or not?  What does dim(length.unique.info) give?


Assuming you have names for columns "1", "2" and "3", named, e.g., X1, 
X2 and X3


subset(length.unique.info, X2 <= 5 & X3 >= 500, select = c(X1))

I don't know what you're trying to do by indexing with 'i'.

And to answer your question about '&', see ?Logic



I want those names that fall under the condition (length.unique.info[,2][i]
<=5 && length.unique.info[,3][i] >=500)

abcder<-length.unique.info[which(length.unique.info[,2][i] <=5 &&
length.unique.info[,3][i] >= 500),1]

will "&&" look for both the condition.It isnt returning names is there
anything i am missing.Kindly suggest me the way to do it.

Regards
Ramya





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

2008-11-05 Thread Jorge Ivan Velez
Dear Murali,
Here is one way:


set.seed(123)
a <- matrix(abs(rnorm(100)), 10)
b <- rnorm(10)
apply(a,2,function(x) ifelse(b>quantile(b,probs=0.75),-x,x))


HTH,

Jorge





On Wed, Nov 5, 2008 at 11:30 AM, <[EMAIL PROTECTED]> wrote:

> Folks,
>
> I have a matrix:
>
> set.seed(123)
> a <- matrix(rnorm(100), 10)
>
> And a vector:
>
> b <- rnorm(10)
>
> Now, I want to switch the signs of those rows of a corresponding to
> indices in b whose values exceed the 75 %-ile of b
>
> which(b > quantile(b)[4])
> [1] 2 6 10
>
> so I want, in effect:
>
> a[2, ] <-  -a[2, ]
> a[6, ] <- -a[6, ]
> a[10, ] <- -a[10, ]
>
> I thought I could do
>
> a[which(b > quantile(b)[4]), ] <- -a
>
> but that's clearly wrong.
>
> I came up with an sapply():
>
> t(sapply(1 : NROW(a), function(n) ifelse(b > quantile(b)[4], -a[n, ], a[n,
> ])))
>
> Ugh.
>
> What's a good way to achieve this?
>
> Thanks,
>
> Murali
>
>
> ---
> This e-mail is confidential and may be privileged. If you have received it
> by mistake, please notify the sender by return e-mail and delete it from
> your system. You should not disclose, copy or use it for any purpose. The
> information in this e-mail is not contractual. Fortis Investments provides
> no guarantee as to the correctness of this information and accepts no
> responsibility for any action taken on the basis of it. Fortis Investments
> is the trade name for all entities within the Fortis Investment Management
> group.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] "Text" function in 3D graph

2008-11-05 Thread EVANS David-William
Fellow R users,

 

I often use « text » to annotate plots in 2 dimensions.  Having grown up to 3 
dimensions recently, I am looking for a similar function.  Could anyone provide 
code for how to annotate points in a 3-d plot?

 

Your help is greatly appreciated.

 

For Sébastien Velazquez.

 

-

Merci de répondre à cette adresse e-mail et à [EMAIL PROTECTED]  .  

Please reply both to this email address and to [EMAIL PROTECTED]  . 

 

 


[[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] matrix indexing and update

2008-11-05 Thread Dimitris Rizopoulos

you almost have it, e.g., check the following:

set.seed(123)
a <- matrix(rnorm(100), 10)
b <- rnorm(10)

ind <- b > quantile(b, 0.75)
a[ind, ] <- -a[ind, ]
a


I hope it helps.

Best,
Dimitris


[EMAIL PROTECTED] wrote:

Folks,

I have a matrix:

set.seed(123)
a <- matrix(rnorm(100), 10)

And a vector:

b <- rnorm(10)

Now, I want to switch the signs of those rows of a corresponding to 
indices in b whose values exceed the 75 %-ile of b


which(b > quantile(b)[4])
[1] 2 6 10

so I want, in effect:

a[2, ] <-  -a[2, ]
a[6, ] <- -a[6, ]
a[10, ] <- -a[10, ]

I thought I could do

a[which(b > quantile(b)[4]), ] <- -a

but that's clearly wrong. 


I came up with an sapply():

t(sapply(1 : NROW(a), function(n) ifelse(b > quantile(b)[4], -a[n, ], a[n, 
])))


Ugh.

What's a good way to achieve this? 


Thanks,

Murali


---
This e-mail is confidential and may be privileged. If you have received it by 
mistake, please notify the sender by return e-mail and delete it from your 
system. You should not disclose, copy or use it for any purpose. The 
information in this e-mail is not contractual. Fortis Investments provides no 
guarantee as to the correctness of this information and accepts no 
responsibility for any action taken on the basis of it. Fortis Investments is 
the trade name for all entities within the Fortis Investment Management group.

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


[R] read Idrisi file

2008-11-05 Thread Abdou Ali
Dear Sirs,

 

Is there a R function to read an Idrisi image (*.rdc & *.rst)

 

Thanks

 

 

 


[[alternative HTML version deleted]]

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


Re: [R] Internal and displayed precision of numbers

2008-11-05 Thread Oliver Bandel
Hello,

many thanks!

BTW: I read your book. :)
It's quite good.

But I didn'tfoud the precision-stuff in it.
Adding information about this topic in the next
edition might be a good idea.

Nevertheless it explains crucial points very good,
and from that starting point, it's easier to understand the
manuals/help-pages.

Ciao,
   Oliver








Zitat von Uwe Ligges <[EMAIL PROTECTED]>:

>
>
> Oliver Bandel wrote:
> > Hello,
> >
> > can the displayed and/or used precision of numbers be
> > configured? And if... how?
>
>
> See ?.Machine for the internally used precision.
> See ?options and ?format/?formatC/?print for the printed precision.
>
> Uwe Ligges
>
>
>
> >
> >
> > Ciao,
> >Oliver
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] matrix indexing and update

2008-11-05 Thread murali . menon
Folks,

I have a matrix:

set.seed(123)
a <- matrix(rnorm(100), 10)

And a vector:

b <- rnorm(10)

Now, I want to switch the signs of those rows of a corresponding to 
indices in b whose values exceed the 75 %-ile of b

which(b > quantile(b)[4])
[1] 2 6 10

so I want, in effect:

a[2, ] <-  -a[2, ]
a[6, ] <- -a[6, ]
a[10, ] <- -a[10, ]

I thought I could do

a[which(b > quantile(b)[4]), ] <- -a

but that's clearly wrong. 

I came up with an sapply():

t(sapply(1 : NROW(a), function(n) ifelse(b > quantile(b)[4], -a[n, ], a[n, 
])))

Ugh.

What's a good way to achieve this? 

Thanks,

Murali


---
This e-mail is confidential and may be privileged. If you have received it by 
mistake, please notify the sender by return e-mail and delete it from your 
system. You should not disclose, copy or use it for any purpose. The 
information in this e-mail is not contractual. Fortis Investments provides no 
guarantee as to the correctness of this information and accepts no 
responsibility for any action taken on the basis of it. Fortis Investments is 
the trade name for all entities within the Fortis Investment Management group.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] fine grain tick marks for zoo plots

2008-11-05 Thread tolga . i . uzuner
Yes ! Many thanks Gabor.I'll email the relevant people on Axis about this.
Tolga



Tolga Uzuner
Cross-Markets
Chief Investments Office
JP Morgan
6th Floor, 100 Wood Street
London EC2V 7RF
United Kingdom
Asst. Lee Hesketh
Tel: +44-20-3303
Fax: +44-20-77422840




"Gabor Grothendieck" <[EMAIL PROTECTED]> 
05/11/2008 15:40

To
[EMAIL PROTECTED]
cc
r-help@r-project.org
Subject
Re: [R] fine grain tick marks for zoo plots






I think the problem is that there is a bug in R itself.  If we use axis 
instead
of Axis it works even with no check at all:

plotmonths<-function(z,...){
 plot(z,xaxt="n",...)
 tt <- time(z)
 m <- unique(as.Date(as.yearmon(tt)))
 jan <- format(m, "%m") == "01"
 mlab <- substr(months(m[!jan]), 1, 1)
 axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
 axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl = -0.7)
 axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
}

d <- seq(as.Date("2008-01-15"), as.Date("2008-11-04"), by = "day")
z <- zoo(seq_along(d), d)
plotmonths(z)


On Wed, Nov 5, 2008 at 10:08 AM,  <[EMAIL PROTECTED]> wrote:
>
> Hi Gabor,
> Thanks very much.
>
> I tried that:
>
> plotmonths<-function(z,...){
>  plot(z,xaxt="n",...)
>  tt <- time(z)
>  m <- unique(as.Date(as.yearmon(tt)))
>  jan <- format(m, "%m") == "01"
>  mlab <- substr(months(m[!jan]), 1, 1)
>  Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
> #if(abs(as.numeric(head(index(z),1)-tail(index(z),1)))>367)
> if(any(jan))
> Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl =
> -0.7)
>  Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
> }
>
> But that fails with the same error message:
> Error in axis(side, at = z, labels = labels, ...) :
>   'at' and 'labels' lengths differ, 0 != 1
>
> I think the problem is that, if one has a time series that goes from the
> 15th of Jan 2008 to 4 Nov 2008, in the absence of the test above, the 
script
> attempts to place "08" at the very left when that tick does not really 
get
> placed by plot.zoo. By testing that the time series is at least a year 
long,
> one ensures that there is space for the "08" tick.
>
> Tolga
>
>
>
>
> "Gabor Grothendieck" <[EMAIL PROTECTED]>
>
> 05/11/2008 14:47
>
> To
> [EMAIL PROTECTED]
> cc
> r-help@r-project.org
> Subject
> Re: [R] fine grain tick marks for zoo plots
>
>
>
>
> Try
>
> if (any(jan)) ...
>
>
> On Wed, Nov 5, 2008 at 8:55 AM,  <[EMAIL PROTECTED]> wrote:
>>
>> By way of follow-up, this will not work if the time series does not run
>> over
>> a year, as the replacement of January by the year fails on the second 
call
>> to Axis.
>>
>> The following tests for this:
>>
>> plotmonths<-function(z,...){
>>  plot(z,xaxt="n",...)
>>  tt <- time(z)
>>  m <- unique(as.Date(as.yearmon(tt)))
>>  jan <- format(m, "%m") == "01"
>>  mlab <- substr(months(m[!jan]), 1, 1)
>>  Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 
0.7)
>> if(abs(as.numeric(head(index(z),1)-tail(index(z),1)))>367)
>> Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl 
=
>> -0.7)
>>  Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
>> }
>>
>>
>>
>>
>> Tolga I Uzuner/JPMCHASE
>>
>> 04/11/2008 14:16
>>
>> To
>> "Gabor Grothendieck" <[EMAIL PROTECTED]>
>> cc
>> r-help@r-project.org, [EMAIL PROTECTED]
>> Subject
>> Re: [R] fine grain tick marks for zoo plotsLink
>>
>>
>>
>> Many thanks all. The following does the trick for me, taken out of the
>> vignette:
>>
>> plotmonths<-function(z,...){
>>  plot(z,xaxt="n",...)
>>  tt <- time(z)
>>  m <- unique(as.Date(as.yearmon(tt)))
>>  jan <- format(m, "%m") == "01"
>>  mlab <- substr(months(m[!jan]), 1, 1)
>>  Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 
0.7)
>>  Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl = -0.7)
>>  Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
>> }
>>
>> Regards,
>> Tolga
>>
>>
>>
>>
>> "Gabor Grothendieck" <[EMAIL PROTECTED]>
>>
>> 04/11/2008 14:06
>>
>> To
>> [EMAIL PROTECTED]
>> cc
>> r-help@r-project.org
>> Subject
>> Re: [R] fine grain tick marks for zoo plots
>>
>>
>>
>>
>> And there are additional examples in
>> vignette("zoo-faq")
>> and
>> example(xyplot.zoo)
>>
>> On Tue, Nov 4, 2008 at 8:26 AM, Gabor Grothendieck
>> <[EMAIL PROTECTED]> wrote:
>>> example(plot.zoo) has an example.
>>>
>>> On Tue, Nov 4, 2008 at 8:10 AM,  <[EMAIL PROTECTED]> wrote:
 Dear R Users,

 I am trying to get plot.zoo to place monthy tickmarks/labels for a 
time
 series which spans daily data going back a bit over a year. Right 
now, I
 am getting only one tick mark on the x-axis for the beginning of 
2008.
 How
 can I force plot.zoo to place more regular x-axis tick marks on a
 monthly
 basis ?

 Thanks in advance,
 Tolga


 Generally, this communication is for informational purposes only
 and it is not intended as an offer or solicitatio

Re: [R] perform Kruskal-Wallis test without using the built-in command in R

2008-11-05 Thread stephen sefick
homework?  Anyway, look at the code for kruskal.test I think, and that
should be a good start.

On Tue, Nov 4, 2008 at 5:59 PM, Swanton0822 <[EMAIL PROTECTED]> wrote:
>
> Hi,
> again i am stuck in my presentation, and i have never learn R before in my
> life but need this to be done, so please help me out for a favour:
>
> http://www.nabble.com/file/p20333155/kew.dat kew.dat
>
> run this in R and these comes up:
>
> Month Year   Rain
> 1  Jan 1900  74.40
> 2  Feb 1900  80.50
> 3  Mar 1900  23.60
> 4  Apr 1900  23.60
> 5  May 1900  25.10
> 6  Jun 1900  53.30
> 7  Jul 1900  31.70
> 8  Aug 1900  67.30
> 9  Sep 1900  26.40
> 10 Oct 1900  40.90
> 11 Nov 1900  43.40
> 12 Dec 1900  64.80
> 13 Jan 1901  21.60
> 14 Feb 1901  22.60
> 15 Mar 1901  51.30
> 16 Apr 1901  53.60
> 17 May 1901  11.40
> 18 Jun 1901  32.80
> 19 Jul 1901  53.10
> 20 Aug 1901  47.50
> 21 Sep 1901  38.60
> 22 Oct 1901  48.00
> 23 Nov 1901  11.90
> 24 Dec 1901  82.30
> 25 Jan 1902  18.50
> 26 Feb 1902  21.60
> 27 Mar 1902  44.40
> 28 Apr 1902  12.40
> 29 May 1902  62.20
> 30 Jun 1902  94.20
> 31 Jul 1902  28.70
> 32 Aug 1902  87.60
> 33 Sep 1902  64.00
> 34 Oct 1902  35.30
> 35 Nov 1902  39.90
> 36 Dec 1902  35.10
> 37 Jan 1903  55.60
> 38 Feb 1903  25.10
> 39 Mar 1903  59.70
> 40 Apr 1903  44.70
> 41 May 1903  85.10
> 42 Jun 1903 183.10
> 43 Jul 1903 108.50
> 44 Aug 1903  99.80
> 45 Sep 1903  82.00
> 46 Oct 1903 139.40
> 47 Nov 1903  45.50
> 48 Dec 1903  40.90
> 49 Jan 1904  60.20
> 50 Feb 1904  56.90
> 51 Mar 1904  32.50
> 52 Apr 1904  23.90
> 53 May 1904  67.30
> 54 Jun 1904  27.90
> 55 Jul 1904  51.60
> 56 Aug 1904  42.20
> 57 Sep 1904  42.90
> 58 Oct 1904  41.40
> 59 Nov 1904  44.20
> 60 Dec 1904  47.20
> 61 Jan 1905  27.40
> 62 Feb 1905  17.00
> 63 Mar 1905  80.80
> 64 Apr 1905  38.90
> 65 May 1905  19.00
> 66 Jun 1905 103.10
> 67 Jul 1905  42.90
> 68 Aug 1905  71.10
> 69 Sep 1905  44.40
> 70 Oct 1905  31.00
> 71 Nov 1905  78.70
> 72 Dec 1905  18.80
> 73 Jan 1906  85.30
> 74 Feb 1906  42.90
> 75 Mar 1906  26.20
> 76 Apr 1906  11.20
> 77 May 1906  45.70
> 78 Jun 1906  72.10
> 79 Jul 1906  26.20
> 80 Aug 1906  19.60
> 81 Sep 1906  44.40
> 82 Oct 1906  80.80
> 83 Nov 1906  98.60
> 84 Dec 1906  47.00
> 85 Jan 1907  17.30
> 86 Feb 1907  29.20
> 87 Mar 1907  22.60
> 88 Apr 1907  79.80
> 89 May 1907  42.70
> 90 Jun 1907  71.40
> 91 Jul 1907  45.70
> 92 Aug 1907  45.50
> 93 Sep 1907  13.50
> 94 Oct 1907  92.70
> 95 Nov 1907  52.80
> 96 Dec 1907  91.70
> 97 Jan 1908  46.20
> 98 Feb 1908  30.50
> 99 Mar 1908  61.20
> 100Apr 1908  58.70
> 101May 1908  33.80
> 102Jun 1908  49.50
> 103Jul 1908  62.00
> 104Aug 1908  61.70
> 105Sep 1908  35.80
> 106Oct 1908  55.10
> 107Nov 1908  17.30
> 108Dec 1908  52.80
> 109Jan 1909  18.80
> 110Feb 1909   7.90
> 111Mar 1909  69.30
> 112Apr 1909  44.70
> 113May 1909  40.60
> 114Jun 1909  86.60
> 115Jul 1909  68.10
> 116Aug 1909  33.30
> 117Sep 1909  63.20
> 118Oct 1909  91.40
> 119Nov 1909  17.80
> 120Dec 1909  59.20
> 121Jan 1910  42.70
> 122Feb 1910  70.10
> 123Mar 1910  24.40
> 124Apr 1910  26.90
> 125May 1910  46.70
> 126Jun 1910  67.60
> 127Jul 1910  63.20
> 128Aug 1910  70.90
> 129Sep 1910  11.40
> 130Oct 1910  55.10
> 131Nov 1910  79.00
> 132Dec 1910  89.70
> 133Jan 1911  30.20
> 134Feb 1911  33.30
> 135Mar 1911  33.30
> 136Apr 1911  47.80
> 137May 1911  39.40
> 138Jun 1911  50.30
> 139Jul 1911  21.10
> 140Aug 1911  20.60
> 141Sep 1911  34.50
> 142Oct 1911  76.20
> 143Nov 1911  86.40
> 144Dec 1911 113.00
> 145Jan 1912  87.90
> 146Feb 1912  34.30
> 147Mar 1912  69.10
> 148Apr 1912   3.80
> 149May 1912  32.80
> 150Jun 1912  81.00
> 151Jul 1912  42.70
> 152Aug 1912 134.40
> 153Sep 1912  54.40
> 154Oct 1912  57.90
> 155Nov 1912  42.40
> 156Dec 1912  68.30
> 157Jan 1913  65.00

[R] Dataframe help

2008-11-05 Thread Rajasekaramya

Hi there,

I have a dataframe length.unique.info
> length.unique.info
abc 12  345
def  16  550
lmn  6   600
I want those names that fall under the condition (length.unique.info[,2][i]
<=5 && length.unique.info[,3][i] >=500)

abcder<-length.unique.info[which(length.unique.info[,2][i] <=5 &&
length.unique.info[,3][i] >= 500),1]

will "&&" look for both the condition.It isnt returning names is there
anything i am missing.Kindly suggest me the way to do it.

Regards
Ramya



-- 
View this message in context: 
http://www.nabble.com/Dataframe-help-tp20343288p20343288.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] Ottawa area R Users meeting

2008-11-05 Thread Paul Gilbert
There will be a meeting of the Ottawa Gatineau R Users Group on Monday 
November 10 from 4pm to 6pm. More details are provided below. Please 
pass this message along to friends you think may be interested.


Paul Gilbert
_

Dear R friends:

To get OGRUG going again I've reserved room DMS 6160 in the Desmarais 
Building of the University of Ottawa for 1600-1800 November 10. This is 
the big curved building opposite National Defence HQ at 55 Laurier E. 
The transitway stops are at the door or across the road. Parking exists 
in the basement -- bring gold or at least a gold credit card if you 
intend to drive!  6160 is on the 6th floor.


Paul Gilbert and I went to the Use R meeting in Dortmund and will give 
an appreciation of what we learned at that meeting, which was very well 
attended.


We will also try to gain a picture of the usage of R in Ottawa by 
exchange of information, with the aim of making OGRUG a modest but 
effective resource for R users in the region.


As an ongoing agenda item, may I suggest that we invite anyone with a 
particular question, glitch, note or such about R to bring it up. For 
items needing some "show" as well as "tell", please email me materials 
and I'll try to arrange for presentation. As an example, I'll show a 
2-line script that draws multi-page graphs (e.g., stock market trades by 
the minute for last month over 10 by 2 sheets of paper).


Please share this with others who may be interested.


Cheers,

John Nash <[EMAIL PROTECTED]>


La version française suit le texte anglais.



This email may contain privileged and/or confidential in...{{dropped:26}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] fine grain tick marks for zoo plots

2008-11-05 Thread Gabor Grothendieck
I think the problem is that there is a bug in R itself.  If we use axis instead
of Axis it works even with no check at all:

plotmonths<-function(z,...){
 plot(z,xaxt="n",...)
 tt <- time(z)
 m <- unique(as.Date(as.yearmon(tt)))
 jan <- format(m, "%m") == "01"
 mlab <- substr(months(m[!jan]), 1, 1)
 axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
 axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl = -0.7)
 axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
}

d <- seq(as.Date("2008-01-15"), as.Date("2008-11-04"), by = "day")
z <- zoo(seq_along(d), d)
plotmonths(z)


On Wed, Nov 5, 2008 at 10:08 AM,  <[EMAIL PROTECTED]> wrote:
>
> Hi Gabor,
> Thanks very much.
>
> I tried that:
>
> plotmonths<-function(z,...){
>  plot(z,xaxt="n",...)
>  tt <- time(z)
>  m <- unique(as.Date(as.yearmon(tt)))
>  jan <- format(m, "%m") == "01"
>  mlab <- substr(months(m[!jan]), 1, 1)
>  Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
> #if(abs(as.numeric(head(index(z),1)-tail(index(z),1)))>367)
> if(any(jan))
> Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl =
> -0.7)
>  Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
> }
>
> But that fails with the same error message:
> Error in axis(side, at = z, labels = labels, ...) :
>   'at' and 'labels' lengths differ, 0 != 1
>
> I think the problem is that, if one has a time series that goes from the
> 15th of Jan 2008 to 4 Nov 2008, in the absence of the test above, the script
> attempts to place "08" at the very left when that tick does not really get
> placed by plot.zoo. By testing that the time series is at least a year long,
> one ensures that there is space for the "08" tick.
>
> Tolga
>
>
>
>
> "Gabor Grothendieck" <[EMAIL PROTECTED]>
>
> 05/11/2008 14:47
>
> To
> [EMAIL PROTECTED]
> cc
> r-help@r-project.org
> Subject
> Re: [R] fine grain tick marks for zoo plots
>
>
>
>
> Try
>
> if (any(jan)) ...
>
>
> On Wed, Nov 5, 2008 at 8:55 AM,  <[EMAIL PROTECTED]> wrote:
>>
>> By way of follow-up, this will not work if the time series does not run
>> over
>> a year, as the replacement of January by the year fails on the second call
>> to Axis.
>>
>> The following tests for this:
>>
>> plotmonths<-function(z,...){
>>  plot(z,xaxt="n",...)
>>  tt <- time(z)
>>  m <- unique(as.Date(as.yearmon(tt)))
>>  jan <- format(m, "%m") == "01"
>>  mlab <- substr(months(m[!jan]), 1, 1)
>>  Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
>> if(abs(as.numeric(head(index(z),1)-tail(index(z),1)))>367)
>> Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl =
>> -0.7)
>>  Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
>> }
>>
>>
>>
>>
>> Tolga I Uzuner/JPMCHASE
>>
>> 04/11/2008 14:16
>>
>> To
>> "Gabor Grothendieck" <[EMAIL PROTECTED]>
>> cc
>> r-help@r-project.org, [EMAIL PROTECTED]
>> Subject
>> Re: [R] fine grain tick marks for zoo plotsLink
>>
>>
>>
>> Many thanks all. The following does the trick for me, taken out of the
>> vignette:
>>
>> plotmonths<-function(z,...){
>>  plot(z,xaxt="n",...)
>>  tt <- time(z)
>>  m <- unique(as.Date(as.yearmon(tt)))
>>  jan <- format(m, "%m") == "01"
>>  mlab <- substr(months(m[!jan]), 1, 1)
>>  Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
>>  Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl = -0.7)
>>  Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
>> }
>>
>> Regards,
>> Tolga
>>
>>
>>
>>
>> "Gabor Grothendieck" <[EMAIL PROTECTED]>
>>
>> 04/11/2008 14:06
>>
>> To
>> [EMAIL PROTECTED]
>> cc
>> r-help@r-project.org
>> Subject
>> Re: [R] fine grain tick marks for zoo plots
>>
>>
>>
>>
>> And there are additional examples in
>> vignette("zoo-faq")
>> and
>> example(xyplot.zoo)
>>
>> On Tue, Nov 4, 2008 at 8:26 AM, Gabor Grothendieck
>> <[EMAIL PROTECTED]> wrote:
>>> example(plot.zoo) has an example.
>>>
>>> On Tue, Nov 4, 2008 at 8:10 AM,  <[EMAIL PROTECTED]> wrote:
 Dear R Users,

 I am trying to get plot.zoo to place monthy tickmarks/labels for a time
 series which spans daily data going back a bit over a year. Right now, I
 am getting only one tick mark on the x-axis for the beginning of 2008.
 How
 can I force plot.zoo to place more regular x-axis tick marks on a
 monthly
 basis ?

 Thanks in advance,
 Tolga


 Generally, this communication is for informational purposes only
 and it is not intended as an offer or solicitation for the purchase
 or sale of any financial instrument or as an official confirmation
 of any transaction. In the event you are receiving the offering
 materials attached below related to your interest in hedge funds or
 private equity, this communication may be intended as an offer or
 solicitation for the purchase or sale of such fund(s).  All market
 prices, data and other information are not warranted as to
>>

Re: [R] Simple rep() question duplicating times and dates.

2008-11-05 Thread John Kane
I don't have R on this machine to try it but it looks good to me.  I had even 
got as far as seq() but completely missed the use of "each".  

Thanks very much.

--- On Wed, 11/5/08, Gustaf Rydevik <[EMAIL PROTECTED]> wrote:

> From: Gustaf Rydevik <[EMAIL PROTECTED]>
> Subject: Re: [R] Simple rep() question duplicating times and dates.
> To: [EMAIL PROTECTED]
> Cc: "R R-help" <[EMAIL PROTECTED]>
> Received: Wednesday, November 5, 2008, 10:14 AM
> On Wed, Nov 5, 2008 at 4:02 PM, John Kane
> <[EMAIL PROTECTED]> wrote:
> >
> > I want to create a data.frame of time and date for a
> year.  I started with the idea of simply producing two
> vectors (time and date)
> >
> > The first part ( time) is easy.
> >  rep(1:24, 365)
> >
> > But how do I get a series of 24 dates for O1 January
> 2005 and repeat this to 31 December 2005.
> >
> > It should be easy but I don't see it.
> >
> > Thanks
> 
> 
> Hi John,
> 
> ?Date leads you to (among other things) ?seq.Date.
> 
> Something like this should work:
> 
> time<-rep(1:24, 365)
> dates<-seq(as.Date("01012005",format="%d%m%Y"),as.Date("31122005",format="%d%m%Y"),by=1)
> TimeFrame<-data.frame(time)
> TimeFrame$dates<-rep(dates,each=24)
> 
> 
> Regards,
> Gustaf
> -- 
> Gustaf Rydevik, M.Sci.
> tel: +46(0)703 051 451
> address:Essingetorget 40,112 66 Stockholm, SE
> skype:gustaf_rydevik

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


Re: [R] Simple rep() question duplicating times and dates.

2008-11-05 Thread Gustaf Rydevik
On Wed, Nov 5, 2008 at 4:02 PM, John Kane <[EMAIL PROTECTED]> wrote:
>
> I want to create a data.frame of time and date for a year.  I started with 
> the idea of simply producing two vectors (time and date)
>
> The first part ( time) is easy.
>  rep(1:24, 365)
>
> But how do I get a series of 24 dates for O1 January 2005 and repeat this to 
> 31 December 2005.
>
> It should be easy but I don't see it.
>
> Thanks


Hi John,

?Date leads you to (among other things) ?seq.Date.

Something like this should work:

time<-rep(1:24, 365)
dates<-seq(as.Date("01012005",format="%d%m%Y"),as.Date("31122005",format="%d%m%Y"),by=1)
TimeFrame<-data.frame(time)
TimeFrame$dates<-rep(dates,each=24)


Regards,
Gustaf
-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] latent class analysis of nominal and continuous indicators

2008-11-05 Thread Xu Jun
Dear R-help listers,

I am a new convert to R. I am trying to use a r package to conduct latent
class analysis as a triangulation check of my cluster analysis using the
cluster package in R. I have about 30 cases and 6 indicators, some of which
are binary indicators and others are ratio-level variables (percentages). I
looked around for information in flexmix, lca, and poLCA, and couldn't find
anything relevant or probably I missed them. I checked MPlus, and it seems
to me MPlus can handle latent class analysis with indicators of different
measurement levels (continous or nominal). And my intuition is that R ought
to be able to it. Any ideas about which package I should use and any
examples that I can model after.

As a long-time user of Stata, I am also used to making easy tables (of
regression results like those in published journal articles) using the
estout command. I am not sure if R has similar functionalities. Thanks!

Jun Xu, Ph.D.
Assistant Professor
Ball State University
Muncie, IN 47306

[[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 2 txt file

2008-11-05 Thread John Kane
> From: Alessandro <[EMAIL PROTECTED]>
> Subject: [R] merge 2 txt file
> To: [EMAIL PROTECTED], r-help@r-project.org
> Received: Tuesday, November 4, 2008, 6:52 PM
> Hi all,
> 
>  
> 
> I have two txt file with X,Y,Z column and I need to merge
> together
> 
>  
> 
> I tried 
> 
> file_all <-
> merge("file1.txt","file2.txt")
> 
> but I don't sure about the result. Is It this code
> correct?

Who knows?  We need some information on what the files contain and how you want 
to "merge" them.

The best thing to do is to follow the posting guidelines and provide a small 
working example of what the data looks like and what you are trying to do.

You might want to take a look at ?cbind and ?rbind.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] fine grain tick marks for zoo plots

2008-11-05 Thread tolga . i . uzuner
Hi Gabor,
Thanks very much. 

I tried that:

plotmonths<-function(z,...){
 plot(z,xaxt="n",...)
 tt <- time(z)
 m <- unique(as.Date(as.yearmon(tt)))
 jan <- format(m, "%m") == "01" 
 mlab <- substr(months(m[!jan]), 1, 1)
 Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
#if(abs(as.numeric(head(index(z),1)-tail(index(z),1)))>367) 
if(any(jan)) 
Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl = 
-0.7)
 Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
}

But that fails with the same error message:
Error in axis(side, at = z, labels = labels, ...) : 
  'at' and 'labels' lengths differ, 0 != 1

I think the problem is that, if one has a time series that goes from the 
15th of Jan 2008 to 4 Nov 2008, in the absence of the test above, the 
script attempts to place "08" at the very left when that tick does not 
really get placed by plot.zoo. By testing that the time series is at least 
a year long, one ensures that there is space for the "08" tick.

Tolga





"Gabor Grothendieck" <[EMAIL PROTECTED]> 
05/11/2008 14:47

To
[EMAIL PROTECTED]
cc
r-help@r-project.org
Subject
Re: [R] fine grain tick marks for zoo plots






Try

if (any(jan)) ...


On Wed, Nov 5, 2008 at 8:55 AM,  <[EMAIL PROTECTED]> wrote:
>
> By way of follow-up, this will not work if the time series does not run 
over
> a year, as the replacement of January by the year fails on the second 
call
> to Axis.
>
> The following tests for this:
>
> plotmonths<-function(z,...){
>  plot(z,xaxt="n",...)
>  tt <- time(z)
>  m <- unique(as.Date(as.yearmon(tt)))
>  jan <- format(m, "%m") == "01"
>  mlab <- substr(months(m[!jan]), 1, 1)
>  Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
> if(abs(as.numeric(head(index(z),1)-tail(index(z),1)))>367)
> Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl =
> -0.7)
>  Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
> }
>
>
>
>
> Tolga I Uzuner/JPMCHASE
>
> 04/11/2008 14:16
>
> To
> "Gabor Grothendieck" <[EMAIL PROTECTED]>
> cc
> r-help@r-project.org, [EMAIL PROTECTED]
> Subject
> Re: [R] fine grain tick marks for zoo plotsLink
>
>
>
> Many thanks all. The following does the trick for me, taken out of the
> vignette:
>
> plotmonths<-function(z,...){
>  plot(z,xaxt="n",...)
>  tt <- time(z)
>  m <- unique(as.Date(as.yearmon(tt)))
>  jan <- format(m, "%m") == "01"
>  mlab <- substr(months(m[!jan]), 1, 1)
>  Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
>  Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl = -0.7)
>  Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
> }
>
> Regards,
> Tolga
>
>
>
>
> "Gabor Grothendieck" <[EMAIL PROTECTED]>
>
> 04/11/2008 14:06
>
> To
> [EMAIL PROTECTED]
> cc
> r-help@r-project.org
> Subject
> Re: [R] fine grain tick marks for zoo plots
>
>
>
>
> And there are additional examples in
> vignette("zoo-faq")
> and
> example(xyplot.zoo)
>
> On Tue, Nov 4, 2008 at 8:26 AM, Gabor Grothendieck
> <[EMAIL PROTECTED]> wrote:
>> example(plot.zoo) has an example.
>>
>> On Tue, Nov 4, 2008 at 8:10 AM,  <[EMAIL PROTECTED]> wrote:
>>> Dear R Users,
>>>
>>> I am trying to get plot.zoo to place monthy tickmarks/labels for a 
time
>>> series which spans daily data going back a bit over a year. Right now, 
I
>>> am getting only one tick mark on the x-axis for the beginning of 2008.
>>> How
>>> can I force plot.zoo to place more regular x-axis tick marks on a 
monthly
>>> basis ?
>>>
>>> Thanks in advance,
>>> Tolga
>>>
>>>
>>> Generally, this communication is for informational purposes only
>>> and it is not intended as an offer or solicitation for the purchase
>>> or sale of any financial instrument or as an official confirmation
>>> of any transaction. In the event you are receiving the offering
>>> materials attached below related to your interest in hedge funds or
>>> private equity, this communication may be intended as an offer or
>>> solicitation for the purchase or sale of such fund(s).  All market
>>> prices, data and other information are not warranted as to
>>> completeness or accuracy and are subject to change without notice.
>>> Any comments or statements made herein do not necessarily reflect
>>> those of JPMorgan Chase & Co., its subsidiaries and affiliates.
>>>
>>> This transmission may contain information that is privileged,
>>> confidential, legally privileged, and/or exempt from disclosure
>>> under applicable law. If you are not the intended recipient, you
>>> are hereby notified that any disclosure, copying, distribution, or
>>> use of the information contained herein (including any reliance
>>> thereon) is STRICTLY PROHIBITED. Although this transmission and any
>>> attachments are believed to be free of any virus or other defect
>>> that might affect any computer system into which it is received and
>>> opened, it is the responsibility of the recipient to ensure that it
>>> is virus free and no responsi

[R] Simple rep() question duplicating times and dates.

2008-11-05 Thread John Kane

I want to create a data.frame of time and date for a year.  I started with the 
idea of simply producing two vectors (time and date)

The first part ( time) is easy.
 rep(1:24, 365)

But how do I get a series of 24 dates for O1 January 2005 and repeat this to 31 
December 2005.

It should be easy but I don't see it.

Thanks 


  __
[[elided Yahoo spam]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Internal and displayed precision of numbers

2008-11-05 Thread John Kane
sprintf() for displayed numbers perhaps.  

--- On Wed, 11/5/08, Oliver Bandel <[EMAIL PROTECTED]> wrote:

> From: Oliver Bandel <[EMAIL PROTECTED]>
> Subject: [R] Internal and displayed precision of numbers
> To: r-help@r-project.org
> Received: Wednesday, November 5, 2008, 8:38 AM
> Hello,
> 
> can the displayed and/or used precision of numbers be
> configured? And if... how?
> 
> 
> Ciao,
>Oliver
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] fine grain tick marks for zoo plots

2008-11-05 Thread Gabor Grothendieck
Try

if (any(jan)) ...


On Wed, Nov 5, 2008 at 8:55 AM,  <[EMAIL PROTECTED]> wrote:
>
> By way of follow-up, this will not work if the time series does not run over
> a year, as the replacement of January by the year fails on the second call
> to Axis.
>
> The following tests for this:
>
> plotmonths<-function(z,...){
>  plot(z,xaxt="n",...)
>  tt <- time(z)
>  m <- unique(as.Date(as.yearmon(tt)))
>  jan <- format(m, "%m") == "01"
>  mlab <- substr(months(m[!jan]), 1, 1)
>  Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
> if(abs(as.numeric(head(index(z),1)-tail(index(z),1)))>367)
> Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl =
> -0.7)
>  Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
> }
>
>
>
>
> Tolga I Uzuner/JPMCHASE
>
> 04/11/2008 14:16
>
> To
> "Gabor Grothendieck" <[EMAIL PROTECTED]>
> cc
> r-help@r-project.org, [EMAIL PROTECTED]
> Subject
> Re: [R] fine grain tick marks for zoo plotsLink
>
>
>
> Many thanks all. The following does the trick for me, taken out of the
> vignette:
>
> plotmonths<-function(z,...){
>  plot(z,xaxt="n",...)
>  tt <- time(z)
>  m <- unique(as.Date(as.yearmon(tt)))
>  jan <- format(m, "%m") == "01"
>  mlab <- substr(months(m[!jan]), 1, 1)
>  Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
>  Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl = -0.7)
>  Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
> }
>
> Regards,
> Tolga
>
>
>
>
> "Gabor Grothendieck" <[EMAIL PROTECTED]>
>
> 04/11/2008 14:06
>
> To
> [EMAIL PROTECTED]
> cc
> r-help@r-project.org
> Subject
> Re: [R] fine grain tick marks for zoo plots
>
>
>
>
> And there are additional examples in
> vignette("zoo-faq")
> and
> example(xyplot.zoo)
>
> On Tue, Nov 4, 2008 at 8:26 AM, Gabor Grothendieck
> <[EMAIL PROTECTED]> wrote:
>> example(plot.zoo) has an example.
>>
>> On Tue, Nov 4, 2008 at 8:10 AM,  <[EMAIL PROTECTED]> wrote:
>>> Dear R Users,
>>>
>>> I am trying to get plot.zoo to place monthy tickmarks/labels for a time
>>> series which spans daily data going back a bit over a year. Right now, I
>>> am getting only one tick mark on the x-axis for the beginning of 2008.
>>> How
>>> can I force plot.zoo to place more regular x-axis tick marks on a monthly
>>> basis ?
>>>
>>> Thanks in advance,
>>> Tolga
>>>
>>>
>>> Generally, this communication is for informational purposes only
>>> and it is not intended as an offer or solicitation for the purchase
>>> or sale of any financial instrument or as an official confirmation
>>> of any transaction. In the event you are receiving the offering
>>> materials attached below related to your interest in hedge funds or
>>> private equity, this communication may be intended as an offer or
>>> solicitation for the purchase or sale of such fund(s).  All market
>>> prices, data and other information are not warranted as to
>>> completeness or accuracy and are subject to change without notice.
>>> Any comments or statements made herein do not necessarily reflect
>>> those of JPMorgan Chase & Co., its subsidiaries and affiliates.
>>>
>>> This transmission may contain information that is privileged,
>>> confidential, legally privileged, and/or exempt from disclosure
>>> under applicable law. If you are not the intended recipient, you
>>> are hereby notified that any disclosure, copying, distribution, or
>>> use of the information contained herein (including any reliance
>>> thereon) is STRICTLY PROHIBITED. Although this transmission and any
>>> attachments are believed to be free of any virus or other defect
>>> that might affect any computer system into which it is received and
>>> opened, it is the responsibility of the recipient to ensure that it
>>> is virus free and no responsibility is accepted by JPMorgan Chase &
>>> Co., its subsidiaries and affiliates, as applicable, for any loss
>>> or damage arising in any way from its use. If you received this
>>> transmission in error, please immediately contact the sender and
>>> destroy the material in its entirety, whether in electronic or hard
>>> copy format. Thank you.
>>> Please refer to http://www.jpmorgan.com/pages/disclosures for
>>> disclosures relating to UK legal entities.
>>>[[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.
>>>
>>
>
>
> 
>
> Generally, this communication is for informational purposes only and it is
> not intended as an offer or solicitation for the purchase or sale of any
> financial instrument or as an official confirmation of any transaction. In
> the event you are receiving the offering materials attached below related to
> your interest in hedge funds or priva

Re: [R] Avoiding loops & apply -function

2008-11-05 Thread Yohan Chalabi
 "DM" == David Masson <[EMAIL PROTECTED]>
 on Wed, 05 Nov 2008 15:13:37 +0100

   DM> I have a question concerning avoiding loops.
   DM> I know the function "apply" and I have used it several times, but I feel 
   DM> blocked
   DM> with this situation :
   DM> 
   DM> E <- array(X, dim = c(L,nlon,nlat) )
   DM> data <- matrix(Y, nrow=nlon, ncol=nlat )
   DM> G <- vector(length=L)
   DM> 
   DM>for (l in 1:L)
   DM> {
   DM>   G[l] <- function.F(data,E[l,,])
   DM> }
   DM> 
   DM> 
   DM> -  "E" is a 3-dimensional array filled with a given data X.
   DM> -  "data" is a (nlon*nlat) matrix filled with given data Y.
   DM> -  "G" is my output vector.
   DM> 
   DM> I want to apply the function "function.F", but this function has an 
   DM> argument that depends
   DM> on the index "l" ...

do you mean something like that?

sapply(1:L, function(idx, data, E) function.F(data, E[idx,,]), data, E)

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

2008-11-05 Thread David Masson

I have a question concerning avoiding loops.
I know the function "apply" and I have used it several times, but I feel 
blocked

with this situation :

E <- array(X, dim = c(L,nlon,nlat) )
data <- matrix(Y, nrow=nlon, ncol=nlat )
G <- vector(length=L)

  for (l in 1:L)
   {
 G[l] <- function.F(data,E[l,,])
   }


-  "E" is a 3-dimensional array filled with a given data X.
-  "data" is a (nlon*nlat) matrix filled with given data Y.
-  "G" is my output vector.

I want to apply the function "function.F", but this function has an 
argument that depends

on the index "l" ...


Thanks for your help!

David

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

2008-11-05 Thread Fredrik Karlsson
Hi,

Sorry about that. Sure, here is some further information:


> summary(InekeReduc)
 segorg intorg l2group mani  score
 Belfast:3782   Belfast:3782   1: 2604   1   :2480   Min.   :  1.000
 L2 :7502   L2 :7440   2:12462   2   :2542   1st Qu.:  1.000
 German :3782   German :3844 3   :2480   Median :  2.000
 4   :2480   Mean   :  3.011
 5   :2480   3rd Qu.:  5.000
 NA's:2604   Max.   :  6.000
 NA's   :200.000
> summary( fit <- aov( score ~ segorg * intorg ,data=InekeReduc) )
 Df Sum Sq Mean Sq  F valuePr(>F)
segorg2  150257512 2219.063 < 2.2e-16 ***
intorg2   1019 509  150.441 < 2.2e-16 ***
segorg:intorg 4164  41   12.086 8.299e-10 ***
Residuals 14857  50297   3
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
200 observations deleted due to missingness
> TukeyHSD(fit,"segorg:intorg")
  Tukey multiple comparisons of means
95% family-wise confidence level

Fit: aov(formula = score ~ segorg * intorg, data = InekeReduc)

$`segorg:intorg`
  diff lwrupr p adj
L2:Belfast-Belfast:Belfast  1.59590485  1.33909758  1.8527121 0.000
German:Belfast-Belfast:Belfast  3.04430961  2.71827718  3.3703420 0.000
Belfast:L2-Belfast:Belfast  0.24375305 -0.01369296  0.5011991 0.0801617
L2:L2-Belfast:Belfast   1.55958957  1.30211188  1.8170673 0.000
German:L2-Belfast:Belfast   2.96873225  2.71126512  3.2261994 0.000
Belfast:German-Belfast:Belfast  0.44195992  0.12355001  0.7603698 0.0005667
L2:German-Belfast:Belfast   2.36192845  2.10440839  2.6194485 0.000
German:German-Belfast:Belfast   3.42962398  3.0098  3.7481470 0.000
German:Belfast-L2:Belfast   1.44840476  1.19092315  1.7058864 0.000
Belfast:L2-L2:Belfast  -1.35215180 -1.51425695 -1.1900466 0.000
L2:L2-L2:Belfast   -0.03631527 -0.19847075  0.1258402 0.9988643
German:L2-L2:Belfast1.37282740  1.21068871  1.5349661 0.000
Belfast:German-L2:Belfast  -1.15394493 -1.40170389 -0.9061860 0.000
L2:German-L2:Belfast0.76602360  0.60380087  0.9282463 0.000
German:German-L2:Belfast1.83371914  1.58581484  2.0816234 0.000
Belfast:L2-German:Belfast  -2.80055656 -3.05867524 -2.5424379 0.000
L2:L2-German:Belfast   -1.48472003 -1.74287033 -1.2265697 0.000
German:L2-German:Belfast   -0.07557736 -0.33371711  0.1825624 0.9925827
Belfast:German-German:Belfast  -2.60234969 -2.92130373 -2.2833957 0.000
L2:German-German:Belfast   -0.68238116 -0.94057371 -0.4241886 0.000
German:German-German:Belfast0.38531438  0.06624743  0.7043813 0.0056382
L2:L2-Belfast:L21.31583652  1.15267135  1.4790017 0.000
German:L2-Belfast:L22.72497920  2.56183071  2.8881277 0.000
Belfast:German-Belfast:L2   0.19820687 -0.05021410  0.4466278 0.2441352
L2:German-Belfast:L22.11817540  1.95494338  2.2814074 0.000
German:German-Belfast:L23.18587093  2.93730501  3.4344369 0.000
German:L2-L2:L2 1.40914267  1.24594419  1.5723412 0.000
Belfast:German-L2:L2   -1.11762966 -1.36608347 -0.8691758 0.000
L2:German-L2:L2 0.80233887  0.63905689  0.9656209 0.000
German:German-L2:L2 1.87003441  1.62143567  2.1186331 0.000
Belfast:German-German:L2   -2.52677233 -2.77521518 -2.2783295 0.000
L2:German-German:L2-0.60680380 -0.77006911 -0.4435385 0.000
German:German-German:L2 0.46089174  0.21230395  0.7094795 0.003
L2:German-Belfast:German1.91996853  1.67147082  2.1684662 0.000
German:German-Belfast:German2.98766407  2.67639017  3.2989380 0.000
German:German-L2:German 1.06769554  0.81905292  1.3163382 0.000

/Fredrik

On Wed, Nov 5, 2008 at 1:15 PM, hadley wickham <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 5, 2008 at 5:42 AM, Fredrik Karlsson <[EMAIL PROTECTED]>
wrote:
>> Dear list,
>>
>> Sorry to ask you this, but I just ran a TukeyHSD on an model with a
>> two thee level factors as independent variables and a numeric score
>> dependent variable.
>> The aov gives a significant interaction effect, and using the
>> TukeyHSD, I get almost every row to be exactly 0.000. Should I be
>> worried??
>
> You should be worried that you did not provide any information to
> reproduce your problem.  How can you expect anyone else to give you
> advice?
>
> Hadley
>
>
> --
> http://had.co.nz/
>



-- 
"Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it."

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https

Re: [R] Internal and displayed precision of numbers

2008-11-05 Thread Uwe Ligges



Oliver Bandel wrote:

Hello,

can the displayed and/or used precision of numbers be
configured? And if... how?



See ?.Machine for the internally used precision.
See ?options and ?format/?formatC/?print for the printed precision.

Uwe Ligges






Ciao,
   Oliver

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

2008-11-05 Thread Rodrigo Aluizio
Sorry for don't make the data available. My bad.
But anyway the Richard's fourth solution works quite well.

Thank you very much!

Rodrigo.

-Mensagem original-
De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Enviada em: quarta-feira, 5 de novembro de 2008 10:59
Para: Rodrigo Aluizio
Cc: r-help@r-project.org; [EMAIL PROTECTED]
Assunto: Re: [R] Barplot Labels Problem

> I’m using barplot function. I pretend to create a horizontal barplot 
with
> two different information (side by side) for a species list. Well I can
> generate the graph easily, but the problem is that the labels with the
> species names are cut by device window!! I’ve tried lots of par 
functions
> none seems to work properly.
> 
> Below are the script.
> 
> 
> 
> Height is a matrix of species and two column of numerical data. I used
> par(las=) function to make the labels horizontal. When I do this they 
are
> cut by the device window. If I don’t do that the label stay vertical and
> make nonsense with the graph.
> 
> 
> 
> library(xlsReadWrite)
> 
> Spp<-read.xls('SppPrincipaisFVeFT.xls',sheet=1,rowNames=T)
> 
> Spp<-as.matrix(Spp)
> 
> 
barplot(t(Spp),axis.lty='solid',horiz=T,beside=T,las=1,col=c('lightgray','bl
> ack'),main='Main Speceis')
> 
> legend('topright',c('Living Fauna','Dead
> Fauna'),fill=c('lightgray','black'),bty='n')

I can't recreate your code, since you haven't made the file 
SppPrincipaisFVeFT.xls available.  I guess it's something like this:

x = c(monkey=25, giraffe=13, rhinocerous=46, squirrel=5, "sting ray"=36, 
cheetah=2, penguin=69, chicken=43)
par(las=1)
barplot(x)

On my machine, not all the animal names are shown when the device window 
opens.  You have several options to solve this.

1. Make the device bigger.  Either drag the corner of the window or, if 
you are writing directly to a file, try something like:
png("animal barplot.png", width=1200, height=800)
par(las=1)
barplot(x)
dev.off()

2. Make the axis text smaller, e.g.
barplot(x, cex.names=0.5)

3. Abbreviate the names, e.g.
barplot(x, names.arg=abbreviate(names(x)))

4. You can also get a little extra room by decreasing the plot margins and 
the amount of space between bars, e.g.
par(las=1, mar=c(2.5,3,0.5, 0.3))
barplot(x, space=0.05)

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] fine grain tick marks for zoo plots

2008-11-05 Thread tolga . i . uzuner
By way of follow-up, this will not work if the time series does not run 
over a year, as the replacement of January by the year fails on the second 
call to Axis. 

The following tests for this:

plotmonths<-function(z,...){
 plot(z,xaxt="n",...)
 tt <- time(z)
 m <- unique(as.Date(as.yearmon(tt)))
 jan <- format(m, "%m") == "01" 
 mlab <- substr(months(m[!jan]), 1, 1)
 Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
if(abs(as.numeric(head(index(z),1)-tail(index(z),1)))>367) 
Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl = 
-0.7)
 Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
}





Tolga I Uzuner/JPMCHASE
04/11/2008 14:16

To
"Gabor Grothendieck" <[EMAIL PROTECTED]>
cc
r-help@r-project.org, [EMAIL PROTECTED]
Subject
Re: [R] fine grain tick marks for zoo plots





Many thanks all. The following does the trick for me, taken out of the 
vignette:

plotmonths<-function(z,...){
 plot(z,xaxt="n",...)
 tt <- time(z)
 m <- unique(as.Date(as.yearmon(tt)))
 jan <- format(m, "%m") == "01"
 mlab <- substr(months(m[!jan]), 1, 1)
 Axis(side = 1, at = m[!jan], labels = mlab, tcl = -0.3, cex.axis = 0.7)
 Axis(side = 1, at = m[jan], labels = format(m[jan], "%y"), tcl = -0.7)
 Axis(side = 1, at = unique(as.Date(as.yearqtr(tt))), labels = FALSE)
}

Regards,
Tolga





"Gabor Grothendieck" <[EMAIL PROTECTED]> 
04/11/2008 14:06

To
[EMAIL PROTECTED]
cc
r-help@r-project.org
Subject
Re: [R] fine grain tick marks for zoo plots






And there are additional examples in
vignette("zoo-faq")
and
example(xyplot.zoo)

On Tue, Nov 4, 2008 at 8:26 AM, Gabor Grothendieck
<[EMAIL PROTECTED]> wrote:
> example(plot.zoo) has an example.
>
> On Tue, Nov 4, 2008 at 8:10 AM,  <[EMAIL PROTECTED]> wrote:
>> Dear R Users,
>>
>> I am trying to get plot.zoo to place monthy tickmarks/labels for a time
>> series which spans daily data going back a bit over a year. Right now, 
I
>> am getting only one tick mark on the x-axis for the beginning of 2008. 
How
>> can I force plot.zoo to place more regular x-axis tick marks on a 
monthly
>> basis ?
>>
>> Thanks in advance,
>> Tolga
>>
>>
>> Generally, this communication is for informational purposes only
>> and it is not intended as an offer or solicitation for the purchase
>> or sale of any financial instrument or as an official confirmation
>> of any transaction. In the event you are receiving the offering
>> materials attached below related to your interest in hedge funds or
>> private equity, this communication may be intended as an offer or
>> solicitation for the purchase or sale of such fund(s).  All market
>> prices, data and other information are not warranted as to
>> completeness or accuracy and are subject to change without notice.
>> Any comments or statements made herein do not necessarily reflect
>> those of JPMorgan Chase & Co., its subsidiaries and affiliates.
>>
>> This transmission may contain information that is privileged,
>> confidential, legally privileged, and/or exempt from disclosure
>> under applicable law. If you are not the intended recipient, you
>> are hereby notified that any disclosure, copying, distribution, or
>> use of the information contained herein (including any reliance
>> thereon) is STRICTLY PROHIBITED. Although this transmission and any
>> attachments are believed to be free of any virus or other defect
>> that might affect any computer system into which it is received and
>> opened, it is the responsibility of the recipient to ensure that it
>> is virus free and no responsibility is accepted by JPMorgan Chase &
>> Co., its subsidiaries and affiliates, as applicable, for any loss
>> or damage arising in any way from its use. If you received this
>> transmission in error, please immediately contact the sender and
>> destroy the material in its entirety, whether in electronic or hard
>> copy format. Thank you.
>> Please refer to http://www.jpmorgan.com/pages/disclosures for
>> disclosures relating to UK legal entities.
>>[[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.
>>
>




Generally, this communication is for informational purposes only
and it is not intended as an offer or solicitation for the purchase
or sale of any financial instrument or as an official confirmation
of any transaction. In the event you are receiving the offering
materials attached below related to your interest in hedge funds or
private equity, this communication may be intended as an offer or
solicitation for the purchase or sale of such fund(s).  All market
prices, data and other information are not warranted as to
completeness or accuracy and are subject to change without notice.
Any comments or statements made herein do not necessarily

[R] lars package help!

2008-11-05 Thread CHAND SOHAIL
Hi everybody,
 
I am trying to implement lasso using the lars package but I don't know how to 
extract the optimal solution. There is predict.lars function to extract the 
coefficients against some specified "s".
 
I want to know how I can get the optimal choice of "lambda" i.e. the lagrange's 
multiplier.
 
Regards,
Sohail

This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.


[[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] Internal and displayed precision of numbers

2008-11-05 Thread Oliver Bandel
Hello,

can the displayed and/or used precision of numbers be
configured? And if... how?


Ciao,
   Oliver

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

2008-11-05 Thread Gabor Grothendieck
Just one comment.  The code posted works as shown
but if in your case Lines is actually composed of separate
lines rather than one big string as in my example then
you will need to add a simplify = c argument to
each strapply call.

On Wed, Nov 5, 2008 at 7:32 AM, Gabor Grothendieck
<[EMAIL PROTECTED]> wrote:
> Here is another solution made slightly shorter by using
> strapply twice:
>
> z <- zoo(strapply(Lines, "[0-9]+[.][0-9]+", as.numeric)[[1]],
>  strapply(Lines, "-..-..", as.Date)[[1]])
>
> or to create a data frame:
>
> DF <- data.frame(date = strapply(Lines, "-..-..", as.Date)[[1]],
> price = strapply(Lines, "[0-9]+[.][0-9]+", as.numeric)[[1]])
>
> On Wed, Nov 5, 2008 at 6:22 AM, Gabor Grothendieck
> <[EMAIL PROTECTED]> wrote:
>> As others have pointed out its close to XML but not quite
>> there; however, you could use strapply in gsubfn to extract
>> the data.  It pulls out the data matching the regular expression
>> giving vector, vec, consisting of: date price date price ...
>> Pulling out even and odd elements separately and
>> converting them to Date and numeric, respectively, gives the
>> resulting data.frame.
>>
>> See
>> http://gsubfn.googlecode.com
>> for more on the gsubfn package and
>> the three zoo vignettes in the zoo package for more on it.
>>
>> Lines <- '- 
>>  2005-01-17T00:00:00+05:30
>>  10149
>>  1288.40002
>>  
>> - 
>>  2005-01-18T00:00:00+05:30
>>  10149
>>  1291.69995
>>  
>> - 
>>  2005-01-19T00:00:00+05:30
>>  10149
>>  1288.19995
>>  '
>>
>> library(gsubfn)
>> vec <- strapply(Lines, "-..-..|[0-9]+[.][0-9]+")[[1]]
>> ix <- seq_along(vec) %% 2 == 1
>> DF <- data.frame(date = as.Date(vec[ix]), price = as.numeric(vec[!ix]))
>>
>> # or, instead of the last line, you could convert it to a zoo object so
>> # that its in a more convenient form for time series manipulation:
>>
>> library(zoo)
>> z <- zoo(as.numeric(vec[!ix]), as.Date(vec[ix]))
>>
>>
>>
>> On Wed, Nov 5, 2008 at 1:22 AM, RON70 <[EMAIL PROTECTED]> wrote:
>>>
>>> Hi everyone,
>>>
>>> I have this kind of raw dataset :
>>>
>>> - 
>>>  2005-01-17T00:00:00+05:30
>>>  10149
>>>  1288.40002
>>>  
>>> - 
>>>  2005-01-18T00:00:00+05:30
>>>  10149
>>>  1291.69995
>>>  
>>> - 
>>>  2005-01-19T00:00:00+05:30
>>>  10149
>>>  1288.19995
>>>  
>>>
>>> I was looking for some R procedure to extract data from this, that should be
>>> in following format :
>>>
>>> 2005-01-17 1288.40002
>>> 2005-01-18 1291.69995
>>> 2005-01-19 1288.19995
>>>
>>> Can R help me to do this?
>>>
>>> --
>>> View this message in context: 
>>> http://www.nabble.com/How-to-extract-following-data-tp20336690p20336690.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] TukeyHSD and 0.0000000

2008-11-05 Thread hadley wickham
On Wed, Nov 5, 2008 at 5:42 AM, Fredrik Karlsson <[EMAIL PROTECTED]> wrote:
> Dear list,
>
> Sorry to ask you this, but I just ran a TukeyHSD on an model with a
> two thee level factors as independent variables and a numeric score
> dependent variable.
> The aov gives a significant interaction effect, and using the
> TukeyHSD, I get almost every row to be exactly 0.000. Should I be
> worried??

You should be worried that you did not provide any information to
reproduce your problem.  How can you expect anyone else to give you
advice?

Hadley


-- 
http://had.co.nz/

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

2008-11-05 Thread Richard . Cotton
> I’m using barplot function. I pretend to create a horizontal barplot 
with
> two different information (side by side) for a species list. Well I can
> generate the graph easily, but the problem is that the labels with the
> species names are cut by device window!! I’ve tried lots of par 
functions
> none seems to work properly.
> 
> Below are the script.
> 
> 
> 
> Height is a matrix of species and two column of numerical data. I used
> par(las=) function to make the labels horizontal. When I do this they 
are
> cut by the device window. If I don’t do that the label stay vertical and
> make nonsense with the graph.
> 
> 
> 
> library(xlsReadWrite)
> 
> Spp<-read.xls('SppPrincipaisFVeFT.xls',sheet=1,rowNames=T)
> 
> Spp<-as.matrix(Spp)
> 
> 
barplot(t(Spp),axis.lty='solid',horiz=T,beside=T,las=1,col=c('lightgray','bl
> ack'),main='Main Speceis')
> 
> legend('topright',c('Living Fauna','Dead
> Fauna'),fill=c('lightgray','black'),bty='n')

I can't recreate your code, since you haven't made the file 
SppPrincipaisFVeFT.xls available.  I guess it's something like this:

x = c(monkey=25, giraffe=13, rhinocerous=46, squirrel=5, "sting ray"=36, 
cheetah=2, penguin=69, chicken=43)
par(las=1)
barplot(x)

On my machine, not all the animal names are shown when the device window 
opens.  You have several options to solve this.

1. Make the device bigger.  Either drag the corner of the window or, if 
you are writing directly to a file, try something like:
png("animal barplot.png", width=1200, height=800)
par(las=1)
barplot(x)
dev.off()

2. Make the axis text smaller, e.g.
barplot(x, cex.names=0.5)

3. Abbreviate the names, e.g.
barplot(x, names.arg=abbreviate(names(x)))

4. You can also get a little extra room by decreasing the plot margins and 
the amount of space between bars, e.g.
par(las=1, mar=c(2.5,3,0.5, 0.3))
barplot(x, space=0.05)

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential information intended
for the addressee(s) only. If this message was sent to you in error,
you must not disseminate, copy or take any action in reliance on it and
we request that you notify the sender immediately by return email.

Opinions expressed in this message and any attachments are not
necessarily those held by the Health and Safety Laboratory or any person
connected with the organisation, save those by whom the opinions were
expressed.

Please note that any messages sent or received by the Health and Safety
Laboratory email system may be monitored and stored in an information
retrieval system.



Scanned by MailMarshal - Marshal's comprehensive email content security
solution. Download a free evaluation of MailMarshal at www.marshal.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] Barplot Labels Problem

2008-11-05 Thread Duncan Murdoch

On 05/11/2008 7:16 AM, Rodrigo Aluizio wrote:

Hi List, well I’ve already asked this before, but I can’t figure out a
solution for the problem after trying many different ways.

So I writing again…

I’m using barplot function. I pretend to create a horizontal barplot with
two different information (side by side) for a species list. Well I can
generate the graph easily, but the problem is that the labels with the
species names are cut by device window!! I’ve tried lots of par functions
none seems to work properly.

Below are the script.

 


Height is a matrix of species and two column of numerical data. I used
par(las=) function to make the labels horizontal. When I do this they are
cut by the device window. If I don’t do that the label stay vertical and
make nonsense with the graph.


You probably want a larger left margin.  That means increasing the 
second component of par("mar").


I'd demonstrate, but your example code isn't reproducible.

People:  you get much better answers if you post code that is easy for 
others to run.  Then they can modify it and you'll get an example that 
works, rather than speculation about what might work.  Don't rely on 
non-base packages (unless you are asking about one of them); don't post 
huge datasets or huge R scripts.  Work out what is the essence of your 
question, and extract the code to show just that.


Duncan Murdoch



 


library(xlsReadWrite)

Spp<-read.xls('SppPrincipaisFVeFT.xls',sheet=1,rowNames=T)

Spp<-as.matrix(Spp)

barplot(t(Spp),axis.lty='solid',horiz=T,beside=T,las=1,col=c('lightgray','bl
ack'),main='Main Speceis')

legend('topright',c('Living Fauna','Dead
Fauna'),fill=c('lightgray','black'),bty='n')

 


Thanks for your attention

 


___
MSc.   Rodrigo Aluizio
Centro de Estudos do Mar/UFPR
Laboratório de Micropaleontologia
Avenida Beira Mar s/n - CEP 83255-000
Pontal do Paraná - PR - BRASIL


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


  1   2   >