Re: [R] Fourier Row and spectral analysis

2009-02-23 Thread Peterko

Hi, i have result from other program.
Original serie have 225 observing, but program use only 224.
the most domain frequencies are f1=1/224 f2=1/122 f3=1/74,66 f4=1/56
f5=1/24,88
When i know these frequencies a can do, new variable ,nubmers of variavle is
2*nubmer of frequencies:
t-1:225
c1-cos(2*pi*f1*t)
s1-sin(2*pi*f1*t)
.
.
.
s5-sin(2*pi*f5*t)

and now a can do lm(y~mean+c1+s1+c2+s2+...+s5)


.


Dieter Menne wrote:
 
 Peterko lanikpeter at gmail.com writes:
 
 Hello, i need to find in time serie, k=1,2,3...(how if possible) most
 domain
 frequencies and than smooth original serie by Fourier row  y=mean +
 a1*Cos(2*pi/freq*t)+b1*Sin(2*pi/freq*t)+a2..
 
 numbers a1,b1 ... i will have from simple regresion, i need only to find
 k
 msot domain frequensies a than i will have a1,b1,ak,bk - coeficients.
 
 
 It is very difficult to understand what you want, mainly the part about
 the
 simple regression in Fourier context. For simple filtering/smoothing,
 check
 
 http://markmail.org/message/qtyxkwlesy75 
 
 
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Fourier-Row-and-spectral-analysis-tp22151652p22157212.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] Filtering a data frame using a string for colum header

2009-02-23 Thread Prof Brian Ripley

I would have used

1) != rather than ! ... ==

2) !(names(my.df) %in% DrHorrible)  since that handles NA names 
(possible, but not easy to get) better.


and note that

3) subset(my.df, select = -DrHorrible) works.

On Mon, 23 Feb 2009, Petr PIKAL wrote:


Hi

r-help-boun...@r-project.org napsal dne 23.02.2009 03:44:41:



Hi Tony,

I GUESS my.df[-DrHorrible] does not tell R which column NUMBER

would

like to remove.
As we know, we could use my.df[-4] and it exactly tells R which column

must

remvoer from your data.

 my.df[-4]
  Angel Buffy Firefly
1 7 8   9
2 8 9   9
3 6 4  10
4 9 9  10
51010  10


I may be not right.


It is a bit deeper than [] selection.


-DrHorrible

Error in -DrHorrible : invalid argument to unary operator, so the error
is within selection operator [...].

If you know the name and you do not want column with this particular name
use

my.df[,!names(my.df)==(DrHorrible)]

Regards
Petr






Chunhao









Date: Sun, 22 Feb 2009 14:48:10 -0800
From: tony.bre...@googlemail.com
To: r-help@r-project.org
Subject: [R] Filtering a data frame using a string for colum header

Hi all,

I was just radomly playing with R and got the following error when
trying to filter a data frame using a string:


Angel - c(7,8,6,9,10)
Buffy - c(8,9,4,9,10)
Firefly - c(9,9,10,10,10)
DrHorrible - c(10,9,9,10,10)
my.df - data.frame(Angel, Buffy, Firefly, DrHorrible)
my.df[DrHorrible]

DrHorrible
1 10
2 9
3 9
4 10
5 10

my.df[-DrHorrible]

Error in -DrHorrible : invalid argument to unary operator




I know how to work around this problem quite easily, I'm just curious
as to why the my.df[-DrHorrible] statement didn't work?

Cheers,
Tony

OS = win XP

sessionInfo()

R version 2.8.1 (2008-12-22)
i386-pc-mingw32

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United

Kingdom.

1252;LC_MONETARY=English_United Kingdom.
1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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




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

http://www.R-project.org/posting-guide.html

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


_
[[elided Hotmail spam]]

   [[alternative HTML version deleted]]

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

http://www.R-project.org/posting-guide.html

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


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



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

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


[R] Build Error on Solaris

2009-02-23 Thread 亿元五角

Dear R user,

 

I try to build R-2.8.1 on SunOS 5.9, and use following command: 

 CC=cc -xarch=v9
 CFLAGS=-xO5 -xlibmil -dalign
 F77=f95 -xarch=v9
 FFLAGS=-xO5 -xlibmil -dalign
 CXX=CC -xarch=v9
 CXXFLAGS=-xO5 -xlibmil -dalign
 FC=f95 -xarch=v9
 FCFLAGS=-xO5 -xlibmil -dalign

 LIBnn=lib

 

 ./configure --prefix=/where/R/installed--enable-R-shlib  --with-x 
--with-readline=no

 

it throws below error message




cc -xarch=v9 -I/R/src/R-2.8.1/include  -I/myiconv/include 
-I/mypng/SunOS/include -I/myjpeg/SunOS/include -I/myzlib/SunOS/include   
-Wno-long-long -KPIC  -xO5  -xlibmil  -dalign -c R_systat.c -o R_systat.o
cc: illegal option -Wno-long-long
*** Error code 1
make: Fatal error: Command failed for target `R_systat.o'
Current working directory /tmp/R.INSTALL.293-0223020058/foreign/src
chmod: WARNING: can't access /R/src/R-2.8.1/library/foreign/libs/*
ERROR: compilation failed for package 'foreign'
** Removing '/R/src/R-2.8.1/library/foreign'
*** Error code 1
make: Fatal error: Command failed for target `foreign.ts'
Current working directory /R/src/R-2.8.1/src/library/Recommended
*** Error code 1
make: Fatal error: Command failed for target `recommended-packages'
Current working directory /R/src/R-2.8.1/src/library/Recommended
*** Error code 1
make: Fatal error: Command failed for target `stamp-recommended'

 

I want to know who can help me to  solve this problem.

 

Thanks,

Jin

_
[[elided Hotmail spam]]

[[alternative HTML version deleted]]

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


Re: [R] Dates and times from Excel

2009-02-23 Thread Hans-Peter Suter
 Excel stores times of the day as fractions of a day so I wrote a function to
 convert the fraction to a number of seconds, extract the hours, minutes and
 seconds and output it in ISO standard format (%H:%M:%S).

What about the 'colClasses' or 'dateTimeAs' argument in 'read.xls'
which gives back an iso-date-time character string. Or you could use
the 'dateTimeToStr' function to convert the date number to a character
string formatted as indicated.

As a question: would additional entries (e.g.) 'posixctdatetime'
and/or 'chrondatetime' for the 'colClasses' argument be useful?

-- 
Regards,
Hans-Peter

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


Re: [R] difference between assignment syntax - vs =

2009-02-23 Thread Thomas Mang

Hi,

thanks for the link.

In the bottom part of the relevant section, you say:
Standard advice is to avoid using '=' when you mean '-'
Is this a formal, generally accepted (R community) advice, or does it 
reflect you personal opinion?
Note I am not asking this question as to criticize by any means, but 
instead I just want to know for my own work (which will be partially 
released to others) if the '-' - style is the preferred one 
(Personally, with a strong background from other programming languages, 
I have always used '=' so far).


thanks,
Thomas



Patrick Burns wrote:

'The R Inferno' page 78 is one source you can
look at.


Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

Thomas Mang wrote:

Hi,

Both operators - and = can be used to make an assignment. My question 
is: Is there a semantic difference between these two? Some time ago, I 
remember I have read that because of some reason, one should be given 
preference over the other - but I cannot remember the source, nor the 
argument, nor which operator the preferred was.


What is the present state ?
Is still one version better than the other, or is it only a matter of 
taste what to use ?


thanks
Thomas

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

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




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

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



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


Re: [R] Function with 'data' parameter

2009-02-23 Thread Greg Pyle (Secretary)
Thanks, worked like a charm.

Greg.

On Feb 22, 1:58 pm, Gavin Simpson gavin.simp...@ucl.ac.uk wrote:
 On Sun, 2009-02-22 at 20:52 +1100, Jim Lemon wrote:
  Greg wrote:
   I'm trying to write a simple function with a data parameter.

   tfun - function(x, y, data = NULL) {
         if(missing(data))
                 dt - data.frame(x=x, group=y)
         else {
                 dt - with(data, data.frame(x=x, group=y))
         }

         return(dt)
   }

   If I pass variables weight and grp from a data.frame, d, like
   this: tfun(d$weight, d$grp), the function works.  However, if I try to
   do the same thing by supplying d, like this: tfun(weight, grp,
   data=d), I receive the following error:

   Error in data.frame(x = x, group = y) : object weight not found

   Can someone please tell me what I'm doing wrong?

  Hi Greg,
  In your function definition, the data argument isn't missing, it's NULL.
  You have to test like this:

  if(is.null(data)) ...

  Does that fix it?

 No, because x and y are still being evaluated and are not present
 anywhere but within 'd'. (I converted the function definition to
 function(x, y, data) and checked that it was executing the else clause
 when data was *not* missing.)

 You could do:

 ## dummy data
 set.seed(1234)
 d - data.frame(weight = rnorm(10),
                 grp = rnorm(10))

 tfun2 - function(x, y, data) {
         x - deparse(substitute(x))
         y - deparse(substitute(y))
         if(missing(data))
                 dt - data.frame(x=x, group=y)
         else {
                 dt - with(data, data.frame(x=data[[x]], group=data[[y]]))
         }
         return(dt)

 }

 tfun2(weight, grp, data = d)

 but that seems a little ugly. Alternatively, make use of a model formula
 and in-built functionality

 tfun3 - function(formula, data) {
         dat - model.frame(formula, data)
         names(dat) - c(x, group)
         return(dat)

 }

 tfun3(weight ~ grp, data = d)

 HTH

 G

 --
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
  Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
  ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
  Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
  Gower Street, London          [w]http://www.ucl.ac.uk/~ucfagls/
  UK. WC1E 6BT.                 [w]http://www.freshwaters.org.uk
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

  signature.asc
  1KViewDownload

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

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


[R] Help with R and MySQL

2009-02-23 Thread Aaron Barzilai
Hello,

This forum has been very helpful to me in the past, and I've run out of ideas 
on how to solve my problem.

I had been using R and MySQL (and Perl) together for quite some time 
successfully on my Windows XP machine. However, I recently had some problems 
with MySQL (the ibdata file had become 35GB on my hard drive, turns out it's a 
known bug with InnoDB), and ultimately the way I fixed my problem with MySQL 
was to upgrade it.  It's working fine now, I can use MySQL however I'd like.  
I'm sticking to MyISAM tables for now, though.

However, I had set up my system so I did a linear regression in R. Originally, 
this was done in R 2.5.0, I would load in the tables from MySQL to R and then 
conduct the regression in R.  However, after solving my MySQL problem, I ran 
into a strange error in R (and DBI/RMySQL).  R connected to the database just 
fine, and I could even show the tables in the database and load two of them 
into R.  However, the tables I loaded successfully were only a single column.  
Every time I tried to load in a recordset that was multiple columns, I got a 
relatively nondescript Windows error(R for Windows terminal front-end has 
encountered a problem and needs to close.  We are sorry for the 
inconvenience.).  To verify that it wasn't a memory issue,  I even tried rs 
- dbSendQuery(con, select 'a', 'b').  This statement causes the error as 
well.

I tried upgrading the packages, and upgrading R from 2.5.0 to 2.8.1.  However, 
I still get the same errors.  Has anyone run into this problem before?  Any 
suggestions on how to solve it?

Thanks in advance,
Aaron


  
[[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] is there any IV probit estimator in R?

2009-02-23 Thread Julian TszKin Chan
Hi

Is there any package in R that allow me to do IV probit, just like the
ivprobit command in stata.

or do i have to carry out the newey's two-step estimator myself?


Regards,
Julian

[[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] Build Error on Solaris

2009-02-23 Thread Prof Brian Ripley

Please do read the posting guide:

1) It says this is not the list for problems about compiled code.

2) It asks you to try the current patched version before posting.
(That works for me.)

If that is not the solution, the problem is in the lines before the 
one you showed us, e.g. I get


checking whether cc -xc99 accepts -Wno-long-long... no

(which incidentally points out that you omitted -xc99 from the 
recommendations). So you will have to be more careful in showing the 
relevant output if you follow up on R-devel.


On Mon, 23 Feb 2009, 亿元五角 wrote:



Dear R user,



I try to build R-2.8.1 on SunOS 5.9, and use following command:

CC=cc -xarch=v9
CFLAGS=-xO5 -xlibmil -dalign
F77=f95 -xarch=v9
FFLAGS=-xO5 -xlibmil -dalign
CXX=CC -xarch=v9
CXXFLAGS=-xO5 -xlibmil -dalign
FC=f95 -xarch=v9
FCFLAGS=-xO5 -xlibmil -dalign

LIBnn=lib



./configure --prefix=/where/R/installed--enable-R-shlib  --with-x 
--with-readline=no



it throws below error message




cc -xarch=v9 -I/R/src/R-2.8.1/include  -I/myiconv/include 
-I/mypng/SunOS/include -I/myjpeg/SunOS/include -I/myzlib/SunOS/include   
-Wno-long-long -KPIC  -xO5  -xlibmil  -dalign -c R_systat.c -o R_systat.o
cc: illegal option -Wno-long-long
*** Error code 1
make: Fatal error: Command failed for target `R_systat.o'
Current working directory /tmp/R.INSTALL.293-0223020058/foreign/src
chmod: WARNING: can't access /R/src/R-2.8.1/library/foreign/libs/*
ERROR: compilation failed for package 'foreign'
** Removing '/R/src/R-2.8.1/library/foreign'
*** Error code 1
make: Fatal error: Command failed for target `foreign.ts'
Current working directory /R/src/R-2.8.1/src/library/Recommended
*** Error code 1
make: Fatal error: Command failed for target `recommended-packages'
Current working directory /R/src/R-2.8.1/src/library/Recommended
*** Error code 1
make: Fatal error: Command failed for target `stamp-recommended'



I want to know who can help me to  solve this problem.



Thanks,

Jin

_
[[elided Hotmail spam]]

[[alternative HTML version deleted]]

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



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


Re: [R] change attributes of all data.frame elements

2009-02-23 Thread Jarrod Hadfield

Hi Philipp,

# Sorry - perhaps I wasn't being very clear. For example, creating the  
data frame:


df-data.frame(y=rnorm(100), x=array(1:100))

# gives 2 elements, the last of which has a dim attribute

lapply(df, dim)

# I would like some way of changing the dim attribute to NULL for all  
elements.


Thanks,

Jarrod




I was wondering whether there was an easy way to change the attributes
of all elements in a data.frame (rather than looping through  
elements)?


Specifically, I would like to set the dim attributes to NULL


Maybe I just don't really understand what you are after. The elements
of a data.frame are vectors so by definition they only have one
dimension. Furthermore, they are required to be the same length -
otherwise it wouldn't be a proper data.frame, anymore.

So I guess you really want to accomplish something I didn't quite
grasp. Could you give an example?

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


The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] difference between assignment syntax - vs =

2009-02-23 Thread Patrick Burns

Since this topic came up, I've been thinking that
that sentence needs more work.

The standard is not from me -- I'm a bit more
agnostic than the statement although I personally
always use '-'.  I'm thinking a revised version
might be something along the lines of:

Standard advice from most long-time R users is
to avoid using '=' when you mean '-'.  However,
as long as you avoid the traps, it is really a matter
of taste.

Rejoinders, etc. will be considered for whenever
a revised Inferno appears.

Pat


Thomas Mang wrote:

Hi,

thanks for the link.

In the bottom part of the relevant section, you say:
Standard advice is to avoid using '=' when you mean '-'
Is this a formal, generally accepted (R community) advice, or does it 
reflect you personal opinion?
Note I am not asking this question as to criticize by any means, but 
instead I just want to know for my own work (which will be partially 
released to others) if the '-' - style is the preferred one 
(Personally, with a strong background from other programming 
languages, I have always used '=' so far).


thanks,
Thomas



Patrick Burns wrote:

'The R Inferno' page 78 is one source you can
look at.


Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

Thomas Mang wrote:

Hi,

Both operators - and = can be used to make an assignment. My 
question is: Is there a semantic difference between these two? Some 
time ago, I remember I have read that because of some reason, one 
should be given preference over the other - but I cannot remember 
the source, nor the argument, nor which operator the preferred was.


What is the present state ?
Is still one version better than the other, or is it only a matter 
of taste what to use ?


thanks
Thomas

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

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




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

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



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

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




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


Re: [R] 1.095e+09 for integers

2009-02-23 Thread Bernardo Rangel Tura
On Sun, 2009-02-22 at 23:42 -0500, Alexy Khrabrov wrote:
 I've had a very long file written out by R with write.table, with  
 fields of time values, converted from POSIXlt as.numeric.  Among 2.5  
 million values, very few had 6 trailing zeroes, and those were output  
 in scientific notation as in the subject.  Is this the default  
 behavior for long integers, and how can it be turned off (with all  
 digits for any integer field in write.table)?  This is important to  
 interoperate with other languages through such text dumps, as some do  
 not expect scientific notation for integers, only for floats.
 
 Cheers,
 Alexy

Alexy 

If I understood your problem you have something like this


as.numeric(12345678912345678)
[1] 1.234568e+16

In this case your solution is using format, like this

format(as.numeric(12345678912345678),scientific=FALSE)
[1] 12345678912345678


-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

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


Re: [R] Using R in Java?

2009-02-23 Thread Fan Shao

Hi nicro,

There's a way that we use a lot in our projects which allows Java to call R
and capture the text/table/image outputs. In Java We call 'Rscript
exampleScript.R' via shell command. The R script should generate an XML file
when it finishes, describing what output was generated, then java can pick
them all up.

We are also trying to look into Biocep -- it looks impressive in terms of
its capability in handling R and bridging Java-R.

Hope this helps.

Thanks
Fan

-- 
View this message in context: 
http://www.nabble.com/Using-R-in-Java--tp22104843p22158387.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/Finance 2009: Applied Finance with R -- Registration now open

2009-02-23 Thread Dirk Eddelbuettel

   R/Finance 2009: Applied Finance with R
   April 24  25, Chicago, IL, US
  
   The first annual R/Finance conference for applied finance using R , the
   premier free software system for statistical computation and graphics,
   will be held this spring in Chicago, IL, USA on Friday April 24 and
   Saturday April 25.

   The two-day conference will cover topics as diverse as portfolio theory,
   time-series analysis, as well as advanced risk tools, high-performance
   computing, and econometrics. All will be discussed within the context of
   using R as a primary tool for financial risk management and trading.

   Assembled to talk over the two days are some of the industry's most
   recognizable authorities within the world of R and quantitative finance.

   R/Finance 2009 is organized by a leading group of R package authors and
   community contributors, and hosted by the International Center for Futures
   and Derivatives [ICFD] at the University of Illinois at Chicago.

   Conference registration is now open. Special advanced registration pricing is
   available, as well as discounted pricing for academic and student
   registrations. 

   More details and registration information can be found at the website at  

   http://www.RinFinance.com

   For the program committee:

Gib Bassett, Peter Carl, Dirk Eddelbuettel, John Miller,
Brian Peterson, Dale Rosenthal, Jeffrey Ryan


-- 
Three out of two people have difficulties with fractions.

___
r-annou...@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] difference between assignment syntax - vs =

2009-02-23 Thread Thomas Lumley

On Mon, 23 Feb 2009, Patrick Burns wrote:


Since this topic came up, I've been thinking that
that sentence needs more work.

The standard is not from me -- I'm a bit more
agnostic than the statement although I personally
always use '-'.  I'm thinking a revised version
might be something along the lines of:

Standard advice from most long-time R users is
to avoid using '=' when you mean '-'.  However,
as long as you avoid the traps, it is really a matter
of taste.


Although it's probably true that most long-time R users use -, this is at least 
in part because a long-time R user would initially have had to use -, since = 
wasn't available in the distant past.

I would say that it's entirely a matter of taste -- the things that otherwise 
could have been traps are mostly syntax errors.  The only proviso is that if you 
post code using = it is (even more) important to leave spaces around the = than it 
would be for -.

 -thomas



Rejoinders, etc. will be considered for whenever
a revised Inferno appears.

Pat


Thomas Mang wrote:

Hi,

thanks for the link.

In the bottom part of the relevant section, you say:
Standard advice is to avoid using '=' when you mean '-'
Is this a formal, generally accepted (R community) advice, or does it 
reflect you personal opinion?
Note I am not asking this question as to criticize by any means, but instead 
I just want to know for my own work (which will be partially released to 
others) if the '-' - style is the preferred one (Personally, with a strong 
background from other programming languages, I have always used '=' so far).


thanks,
Thomas



Patrick Burns wrote:

'The R Inferno' page 78 is one source you can
look at.


Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

Thomas Mang wrote:

Hi,

Both operators - and = can be used to make an assignment. My question 
is: Is there a semantic difference between these two? Some time ago, I 
remember I have read that because of some reason, one should be given 
preference over the other - but I cannot remember the source, nor the 
argument, nor which operator the preferred was.


What is the present state ?
Is still one version better than the other, or is it only a matter of 
taste what to use ?


thanks
Thomas

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

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




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

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



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




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



Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Filtering a data frame using a string for colum header

2009-02-23 Thread Tony Breyal
Cheers guys,

yeah, I was using this bit of code as my work around:

 filter.col - which(names(my.df)!=DrHorrible)
 my.df[filter.col]

but you guys had better solutions  :-)

Is there an R wish list somewhere? I tried google but couldn't find a
specific location, just various threads here and there. It just seems
to me that if

 my.df2[DrHorrible]

works, then

 my.df2[-DrHorrible]

should work too, in the same way that my.df2[-2] would.

Thanks again, always good to learn new and better ways of doing
things,
Tony Breyal





On 23 Feb, 08:41, Prof Brian Ripley rip...@stats.ox.ac.uk wrote:
 I would have used

 1) != rather than ! ... ==

 2) !(names(my.df) %in% DrHorrible)  since that handles NA names
 (possible, but not easy to get) better.

 and note that

 3) subset(my.df, select = -DrHorrible) works.



 On Mon, 23 Feb 2009, Petr PIKAL wrote:
  Hi

  r-help-boun...@r-project.org napsal dne 23.02.2009 03:44:41:

  Hi Tony,

  I GUESS my.df[-DrHorrible] does not tell R which column NUMBER
  would
  like to remove.
  As we know, we could use my.df[-4] and it exactly tells R which column
  must
  remvoer from your data.

   my.df[-4]
    Angel Buffy Firefly
  1     7     8       9
  2     8     9       9
  3     6     4      10
  4     9     9      10
  5    10    10      10

  I may be not right.

  It is a bit deeper than [] selection.

  -DrHorrible
  Error in -DrHorrible : invalid argument to unary operator, so the error
  is within selection operator [...].

  If you know the name and you do not want column with this particular name
  use

  my.df[,!names(my.df)==(DrHorrible)]

  Regards
  Petr

  Chunhao

  Date: Sun, 22 Feb 2009 14:48:10 -0800
  From: tony.bre...@googlemail.com
  To: r-h...@r-project.org
  Subject: [R] Filtering a data frame using a string for colum header

  Hi all,

  I was just radomly playing with R and got the following error when
  trying to filter a data frame using a string:

  Angel - c(7,8,6,9,10)
  Buffy - c(8,9,4,9,10)
  Firefly - c(9,9,10,10,10)
  DrHorrible - c(10,9,9,10,10)
  my.df - data.frame(Angel, Buffy, Firefly, DrHorrible)
  my.df[DrHorrible]
  DrHorrible
  1 10
  2 9
  3 9
  4 10
  5 10
  my.df[-DrHorrible]
  Error in -DrHorrible : invalid argument to unary operator

  I know how to work around this problem quite easily, I'm just curious
  as to why the my.df[-DrHorrible] statement didn't work?

  Cheers,
  Tony

  OS = win XP
  sessionInfo()
  R version 2.8.1 (2008-12-22)
  i386-pc-mingw32

  locale:
  LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
  Kingdom.
  1252;LC_MONETARY=English_United Kingdom.
  1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

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

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

  _
  [[elided Hotmail spam]]

     [[alternative HTML version deleted]]

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

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

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://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] are arithmetic comparison operators binary?

2009-02-23 Thread Wacek Kusnierczyk
the man page for relational operators (see, e.g., ?'') says:


Binary operators which allow the comparison of values in atomic vectors.

Arguments:

x, y: atomic vectors, symbols, calls, or other objects for which
  methods have been written.


it is somewhat surprizing that the following works:

''(1)
# logical(0)

''()
# logical(0)

''(1,2,3)
# TRUE

what does 'binary' mean here, precisely?  in the first two examples, one
might suspect that '' treats the missing arguments as missing values,
but this would not be coherent with what the man page says:


 Missing values ('NA') and 'NaN' values are regarded as
 non-comparable even to themselves, so comparisons involving them
 will always result in 'NA'.


i can't find the above explained in the documentation.  typing `` shows
that it is a

function(e1, e2) .Primitive()

how come can/should it work with no complaint on input that does not
consist of exactly 2 arguments?
in scheme (which is claimed to have been an inspiration for r),  works
on an arbitrary number of arguments:

()
;; #t
( 1)
;; #t
( 1 2 3)
;; #t
( 1 2 0)
;; #f

but there  is an arity-dispatched procedure, not a binary one, and it
produces sensible output for any number of arguments (arguably for n=0, 1).

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] difference between assignment syntax - vs =

2009-02-23 Thread Wacek Kusnierczyk
Thomas Lumley wrote:

 Although it's probably true that most long-time R users use -, this
 is at least in part because a long-time R user would initially have
 had to use -, since = wasn't available in the distant past.

 I would say that it's entirely a matter of taste -- the things that
 otherwise could have been traps are mostly syntax errors.  The only
 proviso is that if you post code using = it is (even more) important
 to leave spaces around the = than it would be for -.

the reason being ...?

vQ

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


[R] [R-pkgs] New package: exams - Automatic Generation of Standardized Exams

2009-02-23 Thread Bettina Gruen

Dear useRs,

the new R package exams provides Sweave-based automatic generation of
exams with multiple-choice questions and arithmetic problems. The
package is available from CRAN:

http://CRAN.R-project.org/package=exams

It includes a vignette giving an overview of the main design aims and
principles as well as strategies for adaptation and extension.
Hands-on illustrations - based on example exercises and control files
provided in the package - are presented to get new users started easily.

Best,
Bettina

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

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


Re: [R] Fourier Row and spectral analysis

2009-02-23 Thread Dieter Menne
Peterko lanikpeter at gmail.com writes:

 Original serie have 225 observing, but program use only 224.
 the most domain frequencies are f1=1/224 f2=1/122 f3=1/74,66 f4=1/56
 f5=1/24,88
 When i know these frequencies a can do, new variable ,nubmers of variavle is
 2*nubmer of frequencies:
 t-1:225
 c1-cos(2*pi*f1*t)
 s1-sin(2*pi*f1*t)
 .
 .
 .
 s5-sin(2*pi*f5*t)
 
 and now a can do lm(y~mean+c1+s1+c2+s2+...+s5)

Good you got it technically working, but having such highly correlated 
coefs like 1/224 and 1/122 in lm is asking for trouble. These are 
almost DC components in engineering speak for such short periods.

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] [Rd] Semantics of sequences in R

2009-02-23 Thread Wacek Kusnierczyk
Stefan Evert wrote:
 Dear vQ,

 vectors (can-be-considered-lists),

 can you please stop repeating this nonsense?  I don't think anybody
 ever claimed that vectors can be considered list.  

yes, it is nonsense.  yes, there is one person who repeatedly made this
claim.  please read the archives; specifically, [1]. note this statement:

Note that any vector can be considered to be a list.


[1] https://stat.ethz.ch/pipermail/r-help/2009-February/186932.html

when you're talking about nonsense, please attribute it to the right person.


 It's rather the other way round: lists can also be seen as vectors to
 R (possibly they are implemented as such, but I don't much about the
 internals of R).

not *all* lists are vectors;  pairlists are not, though they are lists.


  a - as.list(1:10)
  b - 1:10
  is.vector(a)
 [1] TRUE
  is.list(a)
 [1] TRUE
  is.vector(b)
 [1] TRUE
  is.list(b)
 [1] FALSE

 Hence the confusion about

  mode(as.vector(a))
 [1] list

but
   
mode(unlist(a))
# numeric
class(unlist(a))
# integer



 which prompted the original comment that you are taking so much
 exception to.

which original comment?


 as to it could only work in very specific circumstances -- no, it
 would work for any list whatsoever, provided the user has a correctly
 implemented comparator.  for example, i'd like to sort a list of vectors
 by the vectors' length -- is this a very exotic idea?

 Honestly, I can't think of a situation where I would want to do than
 in R.  In a Perl script, quite likely; but this is a kind of data
 manipulation that R wasn't really designed for IMHO.

irrespectively of how exotic sorting lists of vectors can be in a system
for the manipulation of a comprehensive range of sorts of data, having a
procedure called 'sort.list' complain about being called on a list is a
sure source of confusion. 

how much is it likely that people will want to sort complex numbers in a
system where complex numbers are incomparable?

best,
vQ


 Not that I'd mind having sort() operate properly on lists; it just
 isn't something I miss in the language.

 Best,
 Stefan

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

2009-02-23 Thread Peterko



Dieter Menne wrote:
 
 Peterko lanikpeter at gmail.com writes:
 
 Original serie have 225 observing, but program use only 224.
 the most domain frequencies are f1=1/224 f2=1/122 f3=1/74,66 f4=1/56
 f5=1/24,88
 When i know these frequencies a can do, new variable ,nubmers of variavle
 is
 2*nubmer of frequencies:
 t-1:225
 c1-cos(2*pi*f1*t)
 s1-sin(2*pi*f1*t)
 .
 .
 .
 s5-sin(2*pi*f5*t)
 
 and now a can do lm(y~mean+c1+s1+c2+s2+...+s5)
 
 Good you got it technically working, but having such highly correlated 
 coefs like 1/224 and 1/122 in lm is asking for trouble. These are 
 almost DC components in engineering speak for such short periods.
 
 Dieter
 
 It is next problem, eliminate cerrelation, but i to not know whow to get
 this most domain frequencies in R, this result is from other program.
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Fourier-Row-and-spectral-analysis-tp22151652p22160005.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] difference between assignment syntax - vs =

2009-02-23 Thread Ken Knoblauch
Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no writes:

 
 Thomas Lumley wrote:
 
  Although it's probably true that most long-time R users use -, this
  is at least in part because a long-time R user would initially have
  had to use -, since = wasn't available in the distant past.
 
  I would say that it's entirely a matter of taste -- the things that
  otherwise could have been traps are mostly syntax errors.  The only
  proviso is that if you post code using = it is (even more) important
  to leave spaces around the = than it would be for -.
 
 the reason being ...?
 
 vQ
 

ergonomy!


-- 
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html

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


Re: [R] difference between assignment syntax - vs =

2009-02-23 Thread Wacek Kusnierczyk
Ken Knoblauch wrote:
 Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no writes:

   
 Thomas Lumley wrote:
 
 Although it's probably true that most long-time R users use -, this
 is at least in part because a long-time R user would initially have
 had to use -, since = wasn't available in the distant past.

 I would say that it's entirely a matter of taste -- the things that
 otherwise could have been traps are mostly syntax errors.  The only
 proviso is that if you post code using = it is (even more) important
 to leave spaces around the = than it would be for -.
   
 the reason being ...?

 vQ

 

 ergonomy!

   

ergonomy? 

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] difference between assignment syntax - vs =

2009-02-23 Thread Kenneth Knoblauch

It's easier to read.  Better machine-human interaction.

ergonomic:  (esp. of workplace design) intended to provide optimum  
comfort and to avoid stress or injury.


Quoting Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no:


Ken Knoblauch wrote:

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no writes:



Thomas Lumley wrote:


Although it's probably true that most long-time R users use -, this
is at least in part because a long-time R user would initially have
had to use -, since = wasn't available in the distant past.

I would say that it's entirely a matter of taste -- the things that
otherwise could have been traps are mostly syntax errors.  The only
proviso is that if you post code using = it is (even more) important
to leave spaces around the = than it would be for -.


the reason being ...?

vQ




ergonomy!




ergonomy?

vQ





--
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html

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


Re: [R] Dates and times from Excel

2009-02-23 Thread Erich Neuwirth
RExcel (the addin package for RExcel I wrote)
tries very hard to transfer dates and times
from Excel to R.



David Scott wrote:
 
 I have used xlsReadWrite to read data from an Excel spreadsheet.
 
 I had a problem with converting times of the day so that I could create
 POSIXct date-time objects. I was wondering if there was a better solution.
 
 Excel stores times of the day as fractions of a day so I wrote a
 function to convert the fraction to a number of seconds, extract the
 hours, minutes and seconds and output it in ISO standard format (%H:%M:%S).
 
 Given a date obtained from an Excel date using as.Date I could then make
 up my POSIXct date-time objects.
 
 This seems like it would be such a standard operation that there may be
 existing solutions that I have missed.
 
 Any comments, advice?
 
 David Scott
 
 _
 David ScottDepartment of Statistics
 The University of Auckland, PB 92019
 Auckland 1142,NEW ZEALAND
 Phone: +64 9 373 7599 ext 85055Fax: +64 9 373 7018
 Email:d.sc...@auckland.ac.nz
 
 Graduate Officer, Department of Statistics
 Director of Consulting, Department of Statistics
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 
 No virus found in this incoming message.
 Checked by AVG - www.avg.com 
 Version: 8.0.237 / Virus Database: 270.11.3/1966 - Release Date: 02/22/09 
 17:21:00
 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [Rd] Semantics of sequences in R

2009-02-23 Thread Stefan Evert

can you please stop repeating this nonsense?  I don't think anybody
ever claimed that vectors can be considered list.


yes, it is nonsense.  yes, there is one person who repeatedly made  
this
claim.  please read the archives; specifically, [1]. note this  
statement:


Note that any vector can be considered to be a list.

[1] https://stat.ethz.ch/pipermail/r-help/2009-February/186932.html



Sorry, I missed that one.  Unfortunately I haven't kept a copy of the  
posting I was referring to and I can't find a page that allows me to  
search the February archives.


when you're talking about nonsense, please attribute it to the right  
person.


Well, you _are_ repeating it, aren't you?  Since you are so pedantic  
about the semantics of programming languages, you certainly can't  
complain about that statement.


I take back everything I wrote after that on the matter. Sorry!


It's rather the other way round: lists can also be seen as vectors to
R (possibly they are implemented as such, but I don't much about the
internals of R).


not *all* lists are vectors;  pairlists are not, though they are  
lists.


Didn't someone just say that it would probably be best to hide  
pairlists from users entirely?



but

   mode(unlist(a))
   # numeric
   class(unlist(a))
   # integer


Well, yes, that was the solution, wasn't it?  Since a list is a  
vector, you have to unlist() it explicitly to turn it into a plain  
vector. Except that it flattens the list, which is an entirely  
different operation than a mere mode change.  So I don't really  
understand what that comment was supposed to mean.



Honestly, I can't think of a situation where I would want to do than
in R.  In a Perl script, quite likely; but this is a kind of data
manipulation that R wasn't really designed for IMHO.


irrespectively of how exotic sorting lists of vectors can be in a  
system
for the manipulation of a comprehensive range of sorts of data,  
having a
procedure called 'sort.list' complain about being called on a list  
is a

sure source of confusion.


Only until you read ?sort, isn't it?

how much is it likely that people will want to sort complex numbers  
in a

system where complex numbers are incomparable?


I can only say that I'm not likely to want that either, but obviously  
someone did so it was implemented (I am sure that one factor leading  
to their decision was that this method does not clash with an existing  
function).


Cheers,
Stefan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [Rd] Semantics of sequences in R

2009-02-23 Thread Wacek Kusnierczyk
Stefan Evert wrote:
 can you please stop repeating this nonsense?  I don't think anybody
 ever claimed that vectors can be considered list.

 yes, it is nonsense.  yes, there is one person who repeatedly made this
 claim.  please read the archives; specifically, [1]. note this
 statement:

 Note that any vector can be considered to be a list.

 [1] https://stat.ethz.ch/pipermail/r-help/2009-February/186932.html


 Sorry, I missed that one.  Unfortunately I haven't kept a copy of the
 posting I was referring to and I can't find a page that allows me to
 search the February archives.

 when you're talking about nonsense, please attribute it to the right
 person.

 Well, you _are_ repeating it, aren't you?  Since you are so pedantic
 about the semantics of programming languages, you certainly can't
 complain about that statement.

 I take back everything I wrote after that on the matter. Sorry!

it never happened.


 It's rather the other way round: lists can also be seen as vectors to
 R (possibly they are implemented as such, but I don't much about the
 internals of R).

 not *all* lists are vectors;  pairlists are not, though they are lists.

 Didn't someone just say that it would probably be best to hide
 pairlists from users entirely?

this was just a suggestion from a user.  it has no legal power.


 but

mode(unlist(a))
# numeric
class(unlist(a))
# integer

 Well, yes, that was the solution, wasn't it?  Since a list is a
 vector, you have to unlist() it explicitly to turn it into a plain
 vector. Except that it flattens the list, which is an entirely
 different operation than a mere mode change.  So I don't really
 understand what that comment was supposed to mean.

just to make clear (to others, if not to you) that unlisting a list
produces a non-list vector which is not a list.  it was not supposed to
be a counterexample.



 Honestly, I can't think of a situation where I would want to do than
 in R.  In a Perl script, quite likely; but this is a kind of data
 manipulation that R wasn't really designed for IMHO.

 irrespectively of how exotic sorting lists of vectors can be in a system
 for the manipulation of a comprehensive range of sorts of data, having a
 procedure called 'sort.list' complain about being called on a list is a
 sure source of confusion.

 Only until you read ?sort, isn't it?


no.  an interface -- and function names are part of an interface to the
system -- should be as intuitive as possible.  you can always demand
users to carefully read every single bit of the docs, but why make their
life more difficult than necessary?  any guess as to why people tend not
to code in malbolge?


 how much is it likely that people will want to sort complex numbers in a
 system where complex numbers are incomparable?

 I can only say that I'm not likely to want that either, but obviously
 someone did so it was implemented (I am sure that one factor leading
 to their decision was that this method does not clash with an existing
 function).

... while it introduced an ugly incoherence to the language.

vQ

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

2009-02-23 Thread Moumita Das
Hi All,
Sorry to bother everyone again.Ofcourse  Prof Ripley ,Yihui and Uwe had
replied to my email.But this segmentation fault error was not solved.I agree
with Prof Ripley,as he said my R and all other configurations,are very
old.But what i don't understand is ,i was able to run analysis till few days
before,and why suddenly this error.

*The configuartions i use:---*

*R-version
*

* version*

*   _*

*platform   i486-pc-linux-gnu*

*arch   i486*

*os linux-gnu*

*system i486, linux-gnu*

*status Patched*

*major  2*

*minor  4.0*

*year   2006*

*month  11*

*day25*

*svn rev39997*

*language   R*

* *

*R-Package   Version  *

*DBI  0.1-11 *

*RMySQL  0.5-11  *

* *

*MySQL version: 5.0.32*


*A small R- program* *also doesn't run now*,whereas with these same
configurations,i ran correlation analysis,regression analysis for my
datasets.

Now if i do this :---

*library(RMySQL)

myDbconnect-function(dbName,hostName)
{
print(myDbconnect print before driver)
drv-MySQL()
#print(drv)
print(myDbconnect print after driver)
#con - dbConnect(drv, user=xyz, password=xyz,dbname = dbName, host
= hostName)
con-dbConnect(drv)

print(myDbconnect print after connecting the db)
return(con)
}




main-function()
{

 print(inside main)
 dbName-AHP2006
hostName-mia.foresightint.com
con-myDbconnect(dbName,hostName)
 print(hello hello)
}

main()*

Before driver and after driver both the text inside print function are
printed.But in the dbconnect some error occurs.*I do not have access to the
packages,my seniors have that*.All i do is with the scripts.All i read about
segmentation fault is some faulty C-code in the packages.I think the problem
is with DBI package.Just wanted to know* other than any error in the
packages, can a segmentation fault happen*?Because i was not informed about
any changes made in the packages.Where am i going wrong?

*Error:---*

* source(sample.R)
Loading required package: DBI
[1] inside main
[1] myDbconnect print before driver
[1] myDbconnect print after driver

 *** caught segfault ***
address 0x55, cause 'memory not mapped'

Traceback:
 1: .Call(RS_MySQL_newConnection, drvId, con.params, groups,
default.file, PACKAGE = .MySQLPkgName)
 2: mysqlNewConnection(drv, ...)
 3: .class1(object)
 4: .class1(object)
 5: is(object, Cl)
 6: .valueClassTest(standardGeneric(dbConnect), DBIConnection,
dbConnect)
 7: dbConnect(drv, user = xyz, password = xyz, dbname = dbName, host
= hostName)
 8: myDbconnect(dbName, hostName)
 9: main()
10: eval.with.vis(expr, envir, enclos)
11: eval.with.vis(ei, envir)
12: source(sample.R)

Possible actions:
1: abort (with core dump)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:


*
I tried doing some debugging.But could not find a solution.
If i do back tracing :

 *dbConnect*

standardGeneric for dbConnect defined from package DBI

  defined with value class: DBIConnection



function (drv, ...)

.valueClassTest(standardGeneric(dbConnect), DBIConnection,

dbConnect)

environment: 0x839e7e0

Methods may be defined for arguments: drv



 *methods:::.valueClassTest*

*function (object, classes, fname)*

*{*

*if (length(classes)  0) {*

*for (Cl in classes) if (is(object, Cl))*

*return(object)*

*stop(gettextf(invalid value from generic function \%s\, class
\%s\, expected %s,*

*fname, class(object), paste(\, classes, \,*

*sep = , collapse =  or )), domain = NA)*

*}*

*object*

*}*

* mysqlNewConnection*

*function (drv, dbname = , username = , password = , host = ,*

*unix.socket = , port = 0, client.flag = 0, groups = NULL,*

*default.file = character(0))*

*{*

*if (!isIdCurrent(drv))*

*stop(expired manager)*

*con.params - as.character(c(username, password, host, dbname,*

*unix.socket, port, client.flag))*

*groups - as.character(groups)*

*if (length(default.file) == 1) {*

*default.file - file.path(dirname(default.file),
basename(default.file))*

*if (!file.exists(default.file))*

*stop(sprintf(mysql default file %s does not exist,*

*default.file))*

*}*

*drvId - as(drv, integer)*

*conId - .Call(RS_MySQL_newConnection, drvId, con.params,*

*groups, default.file, PACKAGE = .MySQLPkgName)
// here it gets stopped,traceback line 1*

*new(MySQLConnection, Id = conId)*

*}*

-- 
Thanks in advance
Moumita

[[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] Diagnostics for single-observation deletion in Cox models

2009-02-23 Thread Terry Therneau
 Storer and Crowley (JASA 1985) presented an approach for approximating the
 changes in maximum partial-likelihood parameter estimates for the Cox model
 when a single observation is deleted.  Is there an R implementation of this
 approach?
 
  I found that the approximation of Reid and Crepeau (Biometrika 1985) is 
superior.  It is true that it sometimes underestimates the effect of a large 
outlier, but the Storer and Crowley method does much poorer on the smaller 
residuals, sometimes even getting the wrong sign.  The RC values are returned 
as the 'dfbeta' residuals from a coxph model.  The same residual formula as RC 
was derived by Cain and Lange (Biometrics 1984) in a different way, and also 
arises in the definition of a robust variance for multiple event models.
  
   
   Terry Therneau

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

2009-02-23 Thread baptiste auguie
Paul Murrell's book provides such an example using Grid (figure 5.22).  
A short example is available on his website:


http://www.stat.auckland.ac.nz/~paul/grid/doc/moveline.pdf

It may be possible to use this in conjunction with gridBase.


baptiste


On 22 Feb 2009, at 20:43, Eik Vettorazzi wrote:


hi,
you can use par(xpd=TRUE)  and draw the joining line in every sub  
graph

-  don't know if there is another way with simple graphs
eg:

par(mfcol=c(1,2))
plot(1,1,xlim=c(0,5),main=1st)
op-par(xpd=TRUE)
abline(h=1)

plot(1,1,xlim=c(0,5),main=2nd)
abline(h=1)

hth.

rajesh j schrieb:

hi,
I need to draw a line joining graphs,but abline stops within a  
graph.What do

i do to cover portions between two graphs




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


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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

2009-02-23 Thread tedzzx

Dear all

I am very intersted in writing my own function to deal with some complicated
task, but I don't know how to start. I can't find detial material with
examples teaching me how to write my own functions. Can anyone help me and
recommend me some learning material?

Many Thanks

Ted 
-- 
View this message in context: 
http://www.nabble.com/Help-in-writing-my-own-function-tp22161020p22161020.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] Problem with library(RMySQL), registry pointer problem?

2009-02-23 Thread Yakub

I have the following error: 
 library(RMySQL)
Error in fun(...) : 
  A MySQL Registry key was found but the folder C:\Program Files\MySQL\MySQL
Tools for 5.0\/. doesn't contain a bin or lib/opt folder. That's where we
need to find libmySQL.dll. 
Error : .onLoad failed in 'loadNamespace' for 'RMySQL'
Error: package/namespace load failed for 'RMySQL'

This happens after I install MySQL Tools. Seems that R is pointing to the
wrong registry. Can anyone help?
Thanks
-- 
View this message in context: 
http://www.nabble.com/Problem-with-library%28RMySQL%29%2C-registry-pointer-problem--tp22160354p22160354.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] re ad.table prn file

2009-02-23 Thread canadiangirl19

Dear Forum,

I´ve imported a prn file with read.table
(file(E:/test.prn),sep=\t,skip=3). My problem is now, that my file has a
complicated structure: It is not tabstop seperated, it looks like that:

JEAR  JAN  FEB  MAR  APR
1938154  912
19396  71014
19409

If there are default values, there is no seperation in the line, I want that
the program seperates after every JAN, FEB (in detail after the 18., 24., 36
character). Is there a possibility to seperate after i.e.the 15. character?
i tried with strsplit, but get no satisfying result.
Please help me.  I think I could do this with exel and export it with csv,
but i would like to solve the problem with R.
-- 
View this message in context: 
http://www.nabble.com/read.table-prn-file-tp22161342p22161342.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] incomplete data analysis

2009-02-23 Thread evrim akar
Dear R users,

First of all, thank you for your help about goodness of fit tests.

I have another set of data and i am sure it is incomplete. I searched for
incomplete data analysis with R but I could not find any suggestion, or
method. Lets say (totally hypothetical situation) from a distribution you
can generate a continuous random sample between the numbers 0 and 100. but I
have data from 20 to 80 and the rest is missing. I suspect this data comes
from the distribution I mentioned. If I use tests like ks.test or chi-square
to test if the data comes from this distribution it says NO because it takes
my sample as whole sample.

If there is any suggestion about the package I have to read, or function I
have to use or I can modify, I would be very glad.

Thank you in advance.

PS:I would like to prevent any misunderstanding, I am not asking for a code.
Maybe, I could not find the right words to search and I would appreciate any
help (name of the package or search key words or even if it is possible or
not...)

[[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] re ad.table prn file

2009-02-23 Thread Philipp Pagel
On Mon, Feb 23, 2009 at 05:18:28AM -0800, canadiangirl19 wrote:
 My problem is now, that my file has a
 complicated structure: It is not tabstop seperated, it looks like that:
 
 JEAR  JAN  FEB  MAR  APR
 1938154  912
 19396  71014
 19409
 
 If there are default values, there is no seperation in the line, I want that
 the program seperates after every JAN, FEB (in detail after the 18., 24., 36
 character). Is there a possibility to seperate after i.e.the 15. character?
 i tried with strsplit, but get no satisfying result.

Sounds like read.fwf may solve your problem.

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] how todefine an variable/column in a dataframe as numeric mode

2009-02-23 Thread Mao Jianfeng
Hello dear R-users,

I have a tricky problem of data manipulation with R. Although it seems

very easy, I can not solve it by myselves.

The problem is a variable in my dataset is usually be readed as

factor (variable mode), however I want it be a numeric one. I want

to know how can I define an variable/column in a dataframe as numeric

mode, after I imported a large dataset using read.delim() from a txt

file.

Thanks a lot in advance.

Mao J-F
State Key Lab of Systematics and Evolutionary Botany
Institute of Botany
Chinese Academy of Sciences
Beijing, China

[[alternative HTML version deleted]]

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


Re: [R] how todefine an variable/column in a dataframe as numeric mode

2009-02-23 Thread jim holtman
First of all when read in you can define the class of each column.  It
sounds like you have a non-numeric in that column.  If you are not
using factors, then putting 'as.is=TRUE' will make sure that they are
read in as characters.  If you want to convert a column to numeric, do
the following:

df$col - as.numeric(as.character(df$col))

On Mon, Feb 23, 2009 at 8:35 AM, Mao Jianfeng jianfeng@gmail.com wrote:
 Hello dear R-users,

 I have a tricky problem of data manipulation with R. Although it seems

 very easy, I can not solve it by myselves.

 The problem is a variable in my dataset is usually be readed as

 factor (variable mode), however I want it be a numeric one. I want

 to know how can I define an variable/column in a dataframe as numeric

 mode, after I imported a large dataset using read.delim() from a txt

 file.

 Thanks a lot in advance.

 Mao J-F
 State Key Lab of Systematics and Evolutionary Botany
 Institute of Botany
 Chinese Academy of Sciences
 Beijing, China

[[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

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


Re: [R] Help in writing my own function

2009-02-23 Thread jim holtman
That is covered in chapter 10 of the Intro to R document included in
the distribution.

On Mon, Feb 23, 2009 at 7:56 AM, tedzzx zengzhenx...@gmail.com wrote:

 Dear all

 I am very intersted in writing my own function to deal with some complicated
 task, but I don't know how to start. I can't find detial material with
 examples teaching me how to write my own functions. Can anyone help me and
 recommend me some learning material?

 Many Thanks

 Ted
 --
 View this message in context: 
 http://www.nabble.com/Help-in-writing-my-own-function-tp22161020p22161020.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem that you are trying to solve?

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


Re: [R] Help in writing my own function

2009-02-23 Thread Chuck Cleland
On 2/23/2009 7:56 AM, tedzzx wrote:
 Dear all
 
 I am very intersted in writing my own function to deal with some complicated
 task, but I don't know how to start. I can't find detial material with
 examples teaching me how to write my own functions. Can anyone help me and
 recommend me some learning material?

  Chapter 10 of An Introduction to R would be a good place to start.

http://cran.r-project.org/doc/manuals/R-intro.html

 Many Thanks
 
 Ted 

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


[R] Help with t.test

2009-02-23 Thread Amit Patel
Hi I have managed to do a paired t-test with a data set

i have 5 colums of data im dealing with


GENE              SampA              
SampB              SampC                   
SampVehicle
ctcc                   
859                     
na                     
145                           24
gtcg                   
45                         
5                       
54                           69

and so on but they are much larger columns

each column has been split and i can do t.test on for eg sampA by doing
t.test(sampA, SampVehicle, na.rm=TRUE, paired=TRUE, conf.level=0.95)

what can I do to be able to identify which of the genes are responsible for the 
most variance or are the most significant.

THANKS IN ADVANCE






  
[[alternative HTML version deleted]]

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


[R] r: intergrate behaviour

2009-02-23 Thread Allan Clark
hello R users
 
strange behavior of the integrate function!
i assume this occurs because of the way in which the quadriture is set up! (any 
comments.)
 
f=function(x){exp(-exp(-x)-5*x)/gamma(5)}
 
xx=seq(from=-20, to=20, length.out=1000)
plot(xx,f(xx),type=l)

integrate(f, lower=-Inf, upper= 1)
integrate(f, lower=-Inf, upper= 10)
integrate(f, lower=-10, upper= 11)
integrate(f, lower=-Inf, upper= 11)
integrate(f, lower=-Inf, upper= Inf)
 
 
the results:
 
 integrate(f, lower=-Inf, upper= 1)
0.586 with absolute error  2.1e-06
 
 integrate(f, lower=-Inf, upper= 10)
1 with absolute error  1.6e-06
 
 integrate(f, lower=-10, upper= 11)
1 with absolute error  7.1e-06
 
 integrate(f, lower=-Inf, upper= 11)
1.375693e-06 with absolute error  2.3e-06
 
 integrate(f, lower=-Inf, upper= Inf)
1 with absolute error  3.1e-05
 
 
i dont get the same behaviour for J.K. Lindsey's int function.
 

 
 
 
 
Allan Clark

Lecturer in Statistical Sciences Department
University of Cape Town
7701 Rondebosch
South Africa
TEL (Office): +27-21-650-3228
FAX: +27-21-650-4773
http://web.uct.ac.za/depts/stats/aclark.htm 
 

[[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] re ad.table prn file

2009-02-23 Thread canadiangirl19

I´ve tried with:

write.fwf(test,file=E:/test.prn,widths=6), 
but get the error:
Fehler in write.table(t(as.matrix(colnamesMy)), file = file, append =
append,  : 
unbenutzte(s) Argument(e) (widths = 6)
My matrix hast only one column (so it is a vector), and many rows, I want to
seperate the vector (after 6 character, I don´t know, is the width=6?) in a
matrix with 5 columns. How can I do this? And with format.info I get no
output.

thanks in advance for helping me


Philipp Pagel-5 wrote:
 
 On Mon, Feb 23, 2009 at 05:18:28AM -0800, canadiangirl19 wrote:
 My problem is now, that my file has a
 complicated structure: It is not tabstop seperated, it looks like that:
 
 JEAR  JAN  FEB  MAR  APR
 1938154  912
 19396  71014
 19409
 
 If there are default values, there is no seperation in the line, I want
 that
 the program seperates after every JAN, FEB (in detail after the 18., 24.,
 36
 character). Is there a possibility to seperate after i.e.the 15.
 character?
 i tried with strsplit, but get no satisfying result.
 
 Sounds like read.fwf may solve your problem.
 
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/read.table-prn-file-tp22161342p22162335.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] are arithmetic comparison operators binary?

2009-02-23 Thread Martin Maechler
 WK == Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no
 on Mon, 23 Feb 2009 12:06:32 +0100 writes:

Thank you, Wacek, 
though .. wrong mailing list 

WK the man page for relational operators (see, e.g., ?'') says:
WK 
WK Binary operators which allow the comparison of values in atomic vectors.

WK Arguments:

WK x, y: atomic vectors, symbols, calls, or other objects for which
WK methods have been written.
WK 

WK it is somewhat surprizing that the following works:

WK ''(1)
WK # logical(0)

WK ''()
WK # logical(0)

WK ''(1,2,3)
WK # TRUE

a bit surprising (sic!), indeed, even for me.
Thanks for your notice and report!

If you'd looked a bit in the sources, you'd seen that they
really are supposed to be binary only.

A very small change in the sources does accomplish this, passes
the standard checks (and I cannot imagine reasonable code that
would have relied on the more lenient behavior), so
this will have changed in one of the next versions of R-devel.

Martin Maechler, ETH Zurich


WK what does 'binary' mean here, precisely?  in the first two examples, one
WK might suspect that '' treats the missing arguments as missing values,
WK but this would not be coherent with what the man page says:

WK 
WK Missing values ('NA') and 'NaN' values are regarded as
WK non-comparable even to themselves, so comparisons involving them
WK will always result in 'NA'.
WK 

WK i can't find the above explained in the documentation.  typing `` shows
WK that it is a

WK function(e1, e2) .Primitive()

WK how come can/should it work with no complaint on input that does not
WK consist of exactly 2 arguments?
WK in scheme (which is claimed to have been an inspiration for r),  works
WK on an arbitrary number of arguments:

WK ()
WK ;; #t
WK ( 1)
WK ;; #t
WK ( 1 2 3)
WK ;; #t
WK ( 1 2 0)
WK ;; #f

WK but there  is an arity-dispatched procedure, not a binary one, and it
WK produces sensible output for any number of arguments (arguably for n=0, 
1).

WK vQ

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

2009-02-23 Thread Philipp Pagel
On Mon, Feb 23, 2009 at 06:24:33AM -0800, canadiangirl19 wrote:
 write.fwf(test,file=E:/test.prn,widths=6), 
 but get the error:
 Fehler in write.table(t(as.matrix(colnamesMy)), file = file, append =
 append,  : 
 unbenutzte(s) Argument(e) (widths = 6)
 My matrix hast only one column (so it is a vector), and many rows, I want to
 seperate the vector (after 6 character, I don´t know, is the width=6?) in a
 matrix with 5 columns. How can I do this? And with format.info I get no
 output.

Are you sure the above is your actual code? I didn't even know the
function write.fwf existed. I was suggesting was to READ the file with
read.fwf. Your reply seems to indicate that you are first reading the
file by some other means and then trying to write it back to a file. 

If, for some obscure reason, you really cannot use read.fwf(),
textConnection() would be an option. But it would probably only
complicate things more than necessary.

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.


Re: [R] Problem with library(RMySQL), registry pointer problem?

2009-02-23 Thread Jeffrey Horner

Yakub wrote:
I have the following error: 

library(RMySQL)
Error in fun(...) : 
  A MySQL Registry key was found but the folder C:\Program Files\MySQL\MySQL

Tools for 5.0\/. doesn't contain a bin or lib/opt folder. That's where we
need to find libmySQL.dll. 
Error : .onLoad failed in 'loadNamespace' for 'RMySQL'

Error: package/namespace load failed for 'RMySQL'

This happens after I install MySQL Tools. Seems that R is pointing to the
wrong registry. Can anyone help?


You need to install the client programs and libraries when you install 
the MySQL distribution. Just re-run the MySQL installer again and be 
sure to read the steps carefully.


Best,

Jeff
--
http://biostat.mc.vanderbilt.edu/JeffreyHorner

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

2009-02-23 Thread Ravi Varadhan
When the limits are infinite, it is not a good idea to use large but
finite real numbers as approximate limits.  It is best to use -Inf and/or
+Inf.  See the examples on the help page.  Sometimes, setting a more
stringent convergence criterion, i.e. decreasing rel.tol, helps, but it is
best to use infinite limits.

I think this has to do with the transformation of the region of integration
that is done in all the quadrature rules, so that the resulting region
corresponds to appropriate regions for the corresponding orthogonal
polynomials.  For example, it is (-1, 1) for Gauss-Legendre quadrature.   

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Allan Clark
Sent: Monday, February 23, 2009 8:10 AM
To: r-h...@stat.math.ethz.ch
Subject: [R] r: intergrate behaviour

hello R users
 
strange behavior of the integrate function!
i assume this occurs because of the way in which the quadriture is set up!
(any comments.)
 
f=function(x){exp(-exp(-x)-5*x)/gamma(5)}
 
xx=seq(from=-20, to=20, length.out=1000)
plot(xx,f(xx),type=l)

integrate(f, lower=-Inf, upper= 1)
integrate(f, lower=-Inf, upper= 10)
integrate(f, lower=-10, upper= 11)
integrate(f, lower=-Inf, upper= 11)
integrate(f, lower=-Inf, upper= Inf)
 
 
the results:
 
 integrate(f, lower=-Inf, upper= 1)
0.586 with absolute error  2.1e-06
 
 integrate(f, lower=-Inf, upper= 10)
1 with absolute error  1.6e-06
 
 integrate(f, lower=-10, upper= 11)
1 with absolute error  7.1e-06
 
 integrate(f, lower=-Inf, upper= 11)
1.375693e-06 with absolute error  2.3e-06
 
 integrate(f, lower=-Inf, upper= Inf)
1 with absolute error  3.1e-05
 
 
i dont get the same behaviour for J.K. Lindsey's int function.
 

 
 
 
 
Allan Clark

Lecturer in Statistical Sciences Department University of Cape Town
7701 Rondebosch
South Africa
TEL (Office): +27-21-650-3228
FAX: +27-21-650-4773
http://web.uct.ac.za/depts/stats/aclark.htm 
 

[[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] Help with R and MySQL

2009-02-23 Thread Jeffrey Horner

Aaron Barzilai wrote:

Hello,

This forum has been very helpful to me in the past, and I've run out of ideas 
on how to solve my problem.

I had been using R and MySQL (and Perl) together for quite some time 
successfully on my Windows XP machine. However, I recently had some problems 
with MySQL (the ibdata file had become 35GB on my hard drive, turns out it's a 
known bug with InnoDB), and ultimately the way I fixed my problem with MySQL 
was to upgrade it.  It's working fine now, I can use MySQL however I'd like.  
I'm sticking to MyISAM tables for now, though.

However, I had set up my system so I did a linear regression in R. Originally, this was done in R 2.5.0, I would 
load in the tables from MySQL to R and then conduct the regression in R.  However, after solving my MySQL 
problem, I ran into a strange error in R (and DBI/RMySQL).  R connected to the database just fine, and I could 
even show the tables in the database and load two of them into R.  However, the tables I loaded successfully 
were only a single column.  Every time I tried to load in a recordset that was multiple columns, I got a 
relatively nondescript Windows error(R for Windows terminal front-end has encountered a problem and needs 
to close.  We are sorry for the inconvenience.).  To verify that it wasn't a memory issue,  I even tried 
rs - dbSendQuery(con, select 'a', 'b').  This statement causes the error as well.

I tried upgrading the packages, and upgrading R from 2.5.0 to 2.8.1.  However, 
I still get the same errors.  Has anyone run into this problem before?  Any 
suggestions on how to solve it?



Hi Aaron,

Be sure to read the details of the RMySQL web page:

http://biostat.mc.vanderbilt.edu/RMySQL

You need to make sure and match the version of your MySQL client library 
(not the running MySQL server) with the RMySQL binary that you choose 
from the web page above.


Best,

Jeff
--
http://biostat.mc.vanderbilt.edu/JeffreyHorner

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

2009-02-23 Thread Meir Preiszler
Hi,

I would like to try using a Support Vector Machine on a classification
problem that I'm dealing with. Does such a package exit in R?

Thanks
Meir





Meir Preiszler - Research Engineer
I t a m a r M e d i c a l Ltd. 
Caesarea, Israel:
Tel: +(972) 4 617 7000 ext 232
Fax: +(972) 4 627 5598
Cell: +(972) 54 699 9630
Email: pm...@itamar-medical.com 
Web: www.Itamar-medical.com 
*




88---8---
 This E-mail is confidential information of Itamar medical Ltd. It may also 
  be legally privileged. If you are not the addressee you may not copy, forward,
  disclose or use any part of it. If you have received this message in error,
  please delete it and all copies from your system and notify the sender
  immediately by return E-mail. Internet communications cannot be guaranteed 
  to be timely, secure, error or virus-free. The sender does not accept 
  liability for any errors or omissions. Before printing this email , 
  kindly think about the environment.   Itamar Medical Ltd. MIS Yan Malgin.
88---8---


[[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] autonumber for grouping variable

2009-02-23 Thread clion

Dear R users,
my dataframe looks like this
head(dat)
   Id  sex byear age
1 300   m  2003  50
2 300   m  2003  36
3 402f  2003  29
4 402f  2003  21
5 402f  2003  64
6 150   m  2005  43
...
...(where Id is just the Identification number of Individual, sex (male or
female), byear (=birthyear))

now, I 'd like to add a column, where each Individual gets an automated
number starting from 1, so that I can number them consecutively
something which should look like this:
   Id sex byear age Number
1 300   m  2003  50 1
2 300   m  2003  36 1
3 402f  2003  29 2
4 402f  2003  21 2
5 402f  2003  64 2
6 150   m  2005  43 3
...
...
how can I easily do this?
thanks a lot for any help,
Birte

-- 
View this message in context: 
http://www.nabble.com/%22autonumber%22-for-grouping-variable-tp22163546p22163546.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] autonumber for grouping variable

2009-02-23 Thread Dimitris Rizopoulos

say 'dat' is your data frame, then one way is the following:

f - factor(dat$Id, levels = unique(dat$Id))
dat$Number - unclass(f)
dat


I hope it helps.

Best,
Dimitris


clion wrote:

Dear R users,
my dataframe looks like this
head(dat)
   Id  sex byear age
1 300   m  2003  50
2 300   m  2003  36
3 402f  2003  29
4 402f  2003  21
5 402f  2003  64
6 150   m  2005  43
...
...(where Id is just the Identification number of Individual, sex (male or
female), byear (=birthyear))

now, I 'd like to add a column, where each Individual gets an automated
number starting from 1, so that I can number them consecutively
something which should look like this:
   Id sex byear age Number
1 300   m  2003  50 1
2 300   m  2003  36 1
3 402f  2003  29 2
4 402f  2003  21 2
5 402f  2003  64 2
6 150   m  2005  43 3
...
...
how can I easily do this?
thanks a lot for any help,
Birte



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

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

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


Re: [R] Support Vector Machine

2009-02-23 Thread Crouch, Daniel
Hi,

I use ksvm() in the kernlab package. If I recall correctly it's quite easy to 
implement, and has a choice of different kernals. 

Dan


Daniel Crouch
Research Student
Department of Medical  Molecular Genetics
King's College London
8th Floor, Tower Wing
Guy's Hospital
London SE1 9RT
United Kingdom

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Meir Preiszler [pm...@itamar-medical.com]
Sent: 23 February 2009 15:16
To: r-help@r-project.org
Subject: [R] Support Vector Machine

Hi,

I would like to try using a Support Vector Machine on a classification
problem that I'm dealing with. Does such a package exit in R?

Thanks
Meir





Meir Preiszler - Research Engineer
I t a m a r M e d i c a l Ltd.
Caesarea, Israel:
Tel: +(972) 4 617 7000 ext 232
Fax: +(972) 4 627 5598
Cell: +(972) 54 699 9630
Email: pm...@itamar-medical.com
Web: www.Itamar-medical.com
*




88---8---
 This E-mail is confidential information of Itamar medical Ltd. It may also
  be legally privileged. If you are not the addressee you may not copy, forward,
  disclose or use any part of it. If you have received this message in error,
  please delete it and all copies from your system and notify the sender
  immediately by return E-mail. Internet communications cannot be guaranteed
  to be timely, secure, error or virus-free. The sender does not accept
  liability for any errors or omissions. Before printing this email ,
  kindly think about the environment.   Itamar Medical Ltd. MIS Yan Malgin.
88---8---


[[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] length 1 offset in glm

2009-02-23 Thread Kenneth Knoblauch

Hi,

I'm trying to use an offset with glm.  According to the glm man
page

offset	... This should be NULL or a numeric vector of length either  
one or equal to the number of cases. ...


but with the following example, I get an error if the offset is of length 1

c1 - structure(list(Contr = c(0.028, 0.043, 0.064, 0.097, 0.146, 0.219
+ ), Correct = c(34L, 57L, 94L, 152L, 160L, 160L), Incorrect = c(126L,
+ 103L, 66L, 8L, 0L, 0L)), .Names = c(Contr, Correct, Incorrect
+ ), row.names = c(NA, 6L), class = data.frame)

glm(cbind(Correct, Incorrect) ~ Contr - 1, binomial,
data = c1, offset = qlogis(0.25))

Error in model.frame.default(formula = cbind(Correct, Incorrect) ~ Contr -  :
  variable lengths differ (found for '(offset)')

but not if it has the length of the number of rows of the data frame

glm(cbind(Correct, Incorrect) ~ Contr - 1, binomial,
data = c1, offset = rep(qlogis(0.25), nrow(c1)))

...
Coefficients:
Contr
28.34

Degrees of Freedom: 6 Total (i.e. Null);  5 Residual
Null Deviance:  1342
Residual Deviance: 92.35AIC: 114.3

(I'm not pushing this as a good model...)

I traced the error to this line in glm

mf - eval(mf, parent.frame())

and the error can be fixed if the following code from later in glm is put
before the above line with the additional line that I added to
(re)set the offset of mf

if (!is.null(offset)) {
if (length(offset) == 1)
offset - rep(offset, NROW(Y))
else if (length(offset) != NROW(Y))
stop(gettextf(number of offsets is %d should equal %d  
(number of observations),

length(offset), NROW(Y)), domain = NA)
}

 mf$offset - offset

I don't know if this breaks something important or is a terrible
hack.  Or, am I misreading the way glm should work...

sessionInfo()
R version 2.8.1 Patched (2009-02-22 r47985)
i386-apple-darwin8.11.1

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
[1] tools_2.8.1

Thanks for any enlightenment.

Ken


--
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html

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


Re: [R] Support Vector Machine

2009-02-23 Thread Prof Brian Ripley
The simplest to use is probably svm() in package e1071 or svmlight() 
in klaR, both interfaces to well respected SVM code (but e1071 
includes the C++ code it uses).


See also


help.search(support vector)

MAclinical::svm_x   Classification based on support vector machines
using microarray data only
ROCR::ROCR.hiv  Data set: Support vector machines and neural
networks applied to the prediction of HIV-1
coreceptor usage
chemometrics::svmEval   Support Vector Machine evaluation by CV
e1071::predict.svm  Predict Method for Support Vector Machines
e1071::svm  Support Vector Machines
kernlab::ksvm   Support Vector Machines
kernlab::lssvm  Least Squares Support Vector Machine
kernlab::plot.ksvm  plot method for support vector object
kernlab::predict.ksvm   predict method for support vector object
klaR::predict.svmlight
Interface to SVMlight
klaR::svmlight  Interface to SVMlight
rattle::ISO_8601_to_POSIX_datetime_format
Interal Rattle user interface callbacks.
svcR::findModelCluster
Computation of clustering model by support
vector machine
CMA::svmCMA-methods Support Vector Machine
CMA::svmCMA Support Vector Machine

on my server.

On Mon, 23 Feb 2009, Crouch, Daniel wrote:


Hi,

I use ksvm() in the kernlab package. If I recall correctly it's quite easy to 
implement, and has a choice of different kernals.

Dan


Daniel Crouch
Research Student
Department of Medical  Molecular Genetics
King's College London
8th Floor, Tower Wing
Guy's Hospital
London SE1 9RT
United Kingdom

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Meir Preiszler [pm...@itamar-medical.com]
Sent: 23 February 2009 15:16
To: r-help@r-project.org
Subject: [R] Support Vector Machine

Hi,

I would like to try using a Support Vector Machine on a classification
problem that I'm dealing with. Does such a package exit in R?

Thanks
Meir





Meir Preiszler - Research Engineer
I t a m a r M e d i c a l Ltd.
Caesarea, Israel:
Tel: +(972) 4 617 7000 ext 232
Fax: +(972) 4 627 5598
Cell: +(972) 54 699 9630
Email: pm...@itamar-medical.com
Web: www.Itamar-medical.com
*




88---8---
This E-mail is confidential information of Itamar medical Ltd. It may also
 be legally privileged. If you are not the addressee you may not copy, forward,
 disclose or use any part of it. If you have received this message in error,
 please delete it and all copies from your system and notify the sender
 immediately by return E-mail. Internet communications cannot be guaranteed
 to be timely, secure, error or virus-free. The sender does not accept
 liability for any errors or omissions. Before printing this email ,
 kindly think about the environment.   Itamar Medical Ltd. MIS Yan Malgin.
88---8---


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



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

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


Re: [R] [R-pkgs] New package: exams - Automatic Generation of Standardized Exams

2009-02-23 Thread Adrian Dusa

Dear Bertina,

This is an interesting solutions to generate unique tests for every student, 
and there are also some more possible approaches.
We also faced this problem and our solution was to adopt the Moodle e-learning 
platform (http://www.moodle.org), create a large pool of exercises and each 
student would then get a unique test, with randomly selected questions.

What I am dreaming of (in the long term), is to link R to Moodle to 
automatically generate questions and answers, in the very same approach 
adopted at TU Wien but not with printed PDF files but directly on the server.

The big advantage is the automatic correction of the tests, with no need of 
OCR reading or manually grading, all in a nice MySQL database. Of course, this 
means that exams are given in the computer lab, but since the tests are unique 
we do that over the course of multiple consecutive days.

Useful package nevertheless, thanks very much!
Adrian

On Monday 23 February 2009, Bettina Gruen wrote:
 Dear useRs,

 the new R package exams provides Sweave-based automatic generation of
 exams with multiple-choice questions and arithmetic problems. The
 package is available from CRAN:

 http://CRAN.R-project.org/package=exams

 It includes a vignette giving an overview of the main design aims and
 principles as well as strategies for adaptation and extension.
 Hands-on illustrations - based on example exercises and control files
 provided in the package - are presented to get new users started easily.

 Best,
 Bettina

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


-- 
Adrian Dusa
Romanian Social Data Archive
1, Schitu Magureanu Bd.
050025 Bucharest sector 5
Romania
Tel.:+40 21 3126618 \
 +40 21 3120210 / int.101
Fax: +40 21 3158391


[[alternative HTML version deleted]]

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

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


Re: [R] Support Vector Machine

2009-02-23 Thread Tony Breyal
There's loads of packages in the Machine Learning R Task View:

http://cran.r-project.org/web/views/MachineLearning.html

for example: package e1071 (http://cran.r-project.org/web/packages/
e1071/index.html) has a function called svm()




On 23 Feb, 15:16, Meir Preiszler pm...@itamar-medical.com wrote:
 Hi,

 I would like to try using a Support Vector Machine on a classification
 problem that I'm dealing with. Does such a package exit in R?

 Thanks
 Meir

 
 Meir Preiszler - Research Engineer
 I t a m a r M e d i c a l Ltd.
 Caesarea, Israel:
 Tel: +(972) 4 617 7000 ext 232
 Fax: +(972) 4 627 5598
 Cell: +(972) 54 699 9630
 Email: pm...@itamar-medical.com
 Web:www.Itamar-medical.com
 *

 88---8---
  This E-mail is confidential information of Itamar medical Ltd. It may also
   be legally privileged. If you are not the addressee you may not copy, 
 forward,
   disclose or use any part of it. If you have received this message in error,
   please delete it and all copies from your system and notify the sender
   immediately by return E-mail. Internet communications cannot be guaranteed
   to be timely, secure, error or virus-free. The sender does not accept
   liability for any errors or omissions. Before printing this email ,
   kindly think about the environment.       Itamar Medical Ltd. MIS Yan 
 Malgin.
 88---8---

         [[alternative HTML version deleted]]

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://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] Follow-up to Reply: Overdispersion with binomial distribution

2009-02-23 Thread Jessica L Hite/hitejl/O/VCU

THANKS so very much for your help (previous and future!). I have a two
follow-up questions.

1) You say that dispersion = 1 by definition dispersion changes from 1
to 13.5 when I go from binomial to quasibinomialdoes this suggest that
I should use the binomial? i.e., is the dispersion factor more important
that the

2) Is there a cutoff for too much overdispersion - mine seems to be
huge..Residual deviance: 1580.1  on 123  degrees of freedom
I do have some outliers - but they are legitimate (i.e., not typos).

I included my data belowif it helps


 summary(glm.D93)$dispersion ## 1 (by definition)

Call:
glm(formula = y ~ Pred1, family = binomial)

Deviance Residuals:
   Min  1Q  Median  3Q Max
-9.940  -2.778  -0.710   2.130  10.479

Coefficients:
Estimate Std. Error z value Pr(|z|)
(Intercept)  1.639420.07205  22.753   2e-16 ***
Pred1F  -0.652280.11781  -5.537 3.08e-08 ***
Pred1O  -3.032390.12782 -23.724   2e-16 ***
Pred1SN -3.607140.11057 -32.623   2e-16 ***
Pred1W  -1.221310.10734 -11.378   2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 3506.7  on 127  degrees of freedom
Residual deviance: 1580.1  on 123  degrees of freedom
  (1 observation deleted due to missingness)
AIC: 1863.1

Number of Fisher Scoring iterations: 5

 glm1-glm(y~Pred1,quasibinomial)
 summary(glm1)

Call:
glm(formula = y ~ Pred1, family = quasibinomial)

Deviance Residuals:
   Min  1Q  Median  3Q Max
-9.940  -2.778  -0.710   2.130  10.479

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)   1.6394 0.2646   6.197 7.96e-09 ***
Pred1F   -0.6523 0.4326  -1.508  0.13415
Pred1O   -3.0324 0.4693  -6.461 2.19e-09 ***
Pred1SN  -3.6071 0.4060  -8.885 6.51e-15 ***
Pred1W   -1.2213 0.3941  -3.099  0.00241 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for quasibinomial family taken to be 13.48239)

Null deviance: 3506.7  on 127  degrees of freedom
Residual deviance: 1580.1  on 123  degrees of freedom
  (1 observation deleted due to missingness)
AIC: NA

Number of Fisher Scoring iterations: 5


DATA


Pred1 PercentSurvival
O 0.181818182
O 0
O 0
O 0
O 0
F 0.76667
F 0.967741935
F 0.8
F 0.96667
F 0.8
F 0.775
F 0.641025641
F 0.272727273
F 0.606060606
F 0.621621622
F 0.574468085
F 0.918918919
F 0.85417
F 0.684210526
A 0.438596491
A 0.8
A 0.125
A 0.936507937
A 0.911764706
A 0.75
A 0
A 0.64
A 0.740740741
A 0.703703704
A 0.962962963
A 0.9
A 0.97260274
A 0.842105263
A 0.795454545
A 0.970588235
A 0.75556
A 0.947368421
A 1
A 0.947368421
A 0.785714286
A 0.782178218
A 1
A 0.6
A 0.875
A 0.625
A 0.7
A 1
A 1
A 0.6
A 0.91667
A 0.625
A 0.97826087
A 0.975
A 0.9
A 1
A 1
A 0.930232558
A 0.810810811
O 0
O 0
O 1
O 0
SN0
SN0
SN0.696969697
SN0
SN0.5
SN0
SN0.02778
SN0.6
SN0.052631579
SN0
SN0
SN0
SN0.619047619
SN0
SN0
SN0
SN0.08
SN0
SN0.090909091
SN0
SN0.5
SN0
SN0.78125
SN0
SN0
SN0
SN0
SN0.542857143
SN0
SN0
SN0
SN0
SN0.4
SN0
SN0
SN0.4
O 0.655172414
O 0.238095238
O 0
O 0.409090909
O 0
O 0
O 0.090909091
O 0.310344828
O 0
O 0
O 0
O 0.783783784
W 0.928571429
W 0
W 0.651162791
W 0.3125

W 0.871794872
W 0.511627907
W 0.56667
W 0.756756757
W 0
W 0.7
W 0.55
W 0.826086957
W 0.8
W 0.682926829
W 0.586206897
W 1
W 0.75
W 0.5625

[[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] incomplete data analysis

2009-02-23 Thread Paul Heinrich Dietrich

I like the mi package, or when it's too large I use the Amelia package.


evrim akar wrote:
 
 Dear R users,
 
 First of all, thank you for your help about goodness of fit tests.
 
 I have another set of data and i am sure it is incomplete. I searched for
 incomplete data analysis with R but I could not find any suggestion, or
 method. Lets say (totally hypothetical situation) from a distribution you
 can generate a continuous random sample between the numbers 0 and 100. but
 I
 have data from 20 to 80 and the rest is missing. I suspect this data comes
 from the distribution I mentioned. If I use tests like ks.test or
 chi-square
 to test if the data comes from this distribution it says NO because it
 takes
 my sample as whole sample.
 
 If there is any suggestion about the package I have to read, or function I
 have to use or I can modify, I would be very glad.
 
 Thank you in advance.
 
 PS:I would like to prevent any misunderstanding, I am not asking for a
 code.
 Maybe, I could not find the right words to search and I would appreciate
 any
 help (name of the package or search key words or even if it is possible or
 not...)
 
   [[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.
 
 

-- 
View this message in context: 
http://www.nabble.com/incomplete-data-analysis-tp22161555p22164827.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] Extracting xy from raster based on raster value

2009-02-23 Thread Michelle Greve
Dear Kingsford
Thank you very much for your suggestion. It turns out I had downloaded an old 
version of raster. I also got a reply from the R-forge website with other 
suggestions.
In case anybody using the R-help list is interested, here is the link:
http://r-forge.r-project.org/forum/message.php?msg_id=1269

Regards,
Michelle



- Original Message 
From: Kingsford Jones kingsfordjo...@gmail.com
To: Michelle Greve michelle_gr...@yahoo.com
Cc: R-help@r-project.org
Sent: Sunday, February 22, 2009 7:32:58 PM
Subject: Re: [R] Extracting xy from raster based on raster value

Hi Michelle,

The r-sig-geo list would be the ideal place for this question since
the authors of 'raster' would be likely to see it.

I haven't used the raster package before, but this seems to work:


#install.packages(raster, repos=http://R-Forge.R-project.org;)
r - raster()
r - setValues(r, sample(1:27, ncell(r), replace=1))
plot(r)
r[] - r[]==1
plot(r)

If you'd rather have the non-1 cells be NA, just replace 'r[]==1' with
'ifelse(r[]==1, 1, NA)'

hth,

Kingsford Jones


On Sat, Feb 21, 2009 at 8:46 AM, Michelle Greve
michelle_gr...@yahoo.com wrote:
 I have a raster (which I called glc), which I read
 into R as a raster with raster.create.from.file from the raster package 
 (R-forge). Values in glc range between 1 and 27 (whole numbers only). I'd 
 like to extract all cells with a value of 1 to create
 a new raster with only the cells that have a value of 1, or to extract
 the xy values of all raster cells with a value of 1. Could you please
 help me along? I have tried using several of the functions in the
 raster help package, e.g. raster.get.xy.from.cell, but do not know
 how to specify glc=1. I have tried to use e.g.:
 glc1-raster.get.xy.from.cell(glc,glc==1)
 glc1-raster.get.xy.from.cell(glc, glc[which(glc==1)])

 The reason I specifically used the raster package to read in my files is 
 because I have been unable to read my ascii files (which are very big) into R 
 using read.asciigrid because the ascii files are so big (and none of the 
 various suggestions I found in various R-help archives that I found for 
 increasing memory size were sufficient to allow me to read in my ascii 
 files). Therefore if alternatively somebody knows of another way to read 
 raster or ascii files into R, which would make it easier to conduct the 
 extraction I mentioned in my first paragraph, I would appreciate any 
 suggestions.

 Regards,
 Michelle

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

2009-02-23 Thread choonhong ang
I have used the insurance data from R library and I have 2 questions:
I use the following:
library(MASS)
data(Insurance)
 m1=glm(Claims ~ District + Group + Age + offset(log(Holders)),data =
Insurance, family = poisson)
summary(m1)

Call:
glm(formula = Claims ~ District + Group + Age + offset(log(Holders)),
family = poisson, data = Insurance)
Deviance Residuals:
 Min1QMedian3Q   Max
-2.46558  -0.50802  -0.03198   0.5   1.94026
Coefficients:
 Estimate Std. Error z value Pr(|z|)
(Intercept) -1.810508   0.032972 -54.910   2e-16 ***
District20.025868   0.043016   0.601 0.547597
District30.038524   0.050512   0.763 0.445657
District40.234205   0.061673   3.798 0.000146 ***
Group.L  0.429708   0.049459   8.688   2e-16 ***
Group.Q  0.004632   0.041988   0.110 0.912150
Group.C -0.029294   0.033069  -0.886 0.375696
Age.L   -0.394432   0.049404  -7.984 1.42e-15 ***
Age.Q   -0.000355   0.048918  -0.007 0.994210
Age.C   -0.016737   0.048478  -0.345 0.729910
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 236.26  on 63  degrees of freedom
Residual deviance:  51.42  on 54  degrees of freedom
AIC: 388.74
 (1) In the result above, what is Group.L, Group.Q, Group.C, Age.L, Age.Q,
Age.C ?

 (2) When I copy the Insurance data in csv format (as shown in the
attachement) and run the same procedure the result shown is different from
above result, why ?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] line joining graphs

2009-02-23 Thread Greg Snow
You may want to look at the examples for the cnvrt.coords function in the 
TeachingDemos package for some ideas on how to draw lines between plots.  
However, it is better to use the grconvertX and grconvertY functions rather 
than the cnvrt.coords function (it will be deprecated one of these days).

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of rajesh j
 Sent: Sunday, February 22, 2009 6:09 AM
 To: r-help@r-project.org
 Subject: [R] line joining graphs
 
 hi,
 I need to draw a line joining graphs,but abline stops within a
 graph.What do
 i do to cover portions between two graphs
 
 --
 Rajesh.J
 
   [[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] if statement of a vector

2009-02-23 Thread bioinformatics_guy

right now I have a vector of about 1000 points. I'd like to iterate through
each of these points and and test if it is greater than a certain value and
if not, throw it out.

x=vector
y=empty vector
j=0

for i (0..length[vector])
 if x[i]  10
  y[j] = x[i]
  j++

Thats basically some pseudo code of what I want to do.  Any suggestions?
 
 
-- 
View this message in context: 
http://www.nabble.com/if-statement-of-a-vector-tp22166108p22166108.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] if statement of a vector

2009-02-23 Thread Jorge Ivan Velez
Hi there,

Try this:

x-your.vector
x[x10]

HTH,

Jorge


On Mon, Feb 23, 2009 at 12:31 PM, bioinformatics_guy
wwwhite...@gmail.comwrote:


 right now I have a vector of about 1000 points. I'd like to iterate through
 each of these points and and test if it is greater than a certain value and
 if not, throw it out.

 x=vector
 y=empty vector
 j=0

 for i (0..length[vector])
 if x[i]  10
  y[j] = x[i]
  j++

 Thats basically some pseudo code of what I want to do.  Any suggestions?


 --
 View this message in context:
 http://www.nabble.com/if-statement-of-a-vector-tp22166108p22166108.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] Insurance data in library(MASS)

2009-02-23 Thread Greg Snow
In the Insurance dataset both Age and Group are ordered factors so the default 
encoding for them is orthogonal polynomials (assuming that the user has not 
changed the default).  In the output below the .L indicates that line is for 
the Linear piece of the encoding or the Linear contrast on the groups, .Q is 
for the Quadratic piece/contrast and .C is for Cubic.  If you don't 
understand what is meant by linear/quadratic/cubic, then do some background 
reading on orthogonal polynomials.

If you read the data in yourself from a .csv file, then Age and Group will not 
be ordered factors unless you specifically convert them to be.  Therefore the 
default encoding will be something other than orthogonal polynomials and the 
specific details will be different (though the overall effect will be the same).

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of choonhong ang
 Sent: Monday, February 23, 2009 10:05 AM
 To: r-help@r-project.org
 Subject: [R] Insurance data in library(MASS)
 
 I have used the insurance data from R library and I have 2 questions:
 I use the following:
 library(MASS)
 data(Insurance)
  m1=glm(Claims ~ District + Group + Age + offset(log(Holders)),data =
 Insurance, family = poisson)
 summary(m1)
 
 Call:
 glm(formula = Claims ~ District + Group + Age + offset(log(Holders)),
 family = poisson, data = Insurance)
 Deviance Residuals:
  Min1QMedian3Q   Max
 -2.46558  -0.50802  -0.03198   0.5   1.94026
 Coefficients:
  Estimate Std. Error z value Pr(|z|)
 (Intercept) -1.810508   0.032972 -54.910   2e-16 ***
 District20.025868   0.043016   0.601 0.547597
 District30.038524   0.050512   0.763 0.445657
 District40.234205   0.061673   3.798 0.000146 ***
 Group.L  0.429708   0.049459   8.688   2e-16 ***
 Group.Q  0.004632   0.041988   0.110 0.912150
 Group.C -0.029294   0.033069  -0.886 0.375696
 Age.L   -0.394432   0.049404  -7.984 1.42e-15 ***
 Age.Q   -0.000355   0.048918  -0.007 0.994210
 Age.C   -0.016737   0.048478  -0.345 0.729910
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
 (Dispersion parameter for poisson family taken to be 1)
 Null deviance: 236.26  on 63  degrees of freedom
 Residual deviance:  51.42  on 54  degrees of freedom
 AIC: 388.74
  (1) In the result above, what is Group.L, Group.Q, Group.C, Age.L,
 Age.Q,
 Age.C ?
 
  (2) When I copy the Insurance data in csv format (as shown in the
 attachement) and run the same procedure the result shown is different
 from
 above result, why ?

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

2009-02-23 Thread Prof Brian Ripley
You are asking about support software for a book, and the book 
contains the answers   And it should be given due credit.


On Mon, 23 Feb 2009, choonhong ang wrote:


I have used the insurance data from R library and I have 2 questions:
I use the following:

library(MASS)
data(Insurance)
m1=glm(Claims ~ District + Group + Age + offset(log(Holders)),data =

Insurance, family = poisson)

summary(m1)


Call:
glm(formula = Claims ~ District + Group + Age + offset(log(Holders)),
   family = poisson, data = Insurance)
Deviance Residuals:
Min1QMedian3Q   Max
-2.46558  -0.50802  -0.03198   0.5   1.94026
Coefficients:
Estimate Std. Error z value Pr(|z|)
(Intercept) -1.810508   0.032972 -54.910   2e-16 ***
District20.025868   0.043016   0.601 0.547597
District30.038524   0.050512   0.763 0.445657
District40.234205   0.061673   3.798 0.000146 ***
Group.L  0.429708   0.049459   8.688   2e-16 ***
Group.Q  0.004632   0.041988   0.110 0.912150
Group.C -0.029294   0.033069  -0.886 0.375696
Age.L   -0.394432   0.049404  -7.984 1.42e-15 ***
Age.Q   -0.000355   0.048918  -0.007 0.994210
Age.C   -0.016737   0.048478  -0.345 0.729910
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for poisson family taken to be 1)
   Null deviance: 236.26  on 63  degrees of freedom
Residual deviance:  51.42  on 54  degrees of freedom
AIC: 388.74
(1) In the result above, what is Group.L, Group.Q, Group.C, Age.L, Age.Q,
Age.C ?


See the book ca p.146.


(2) When I copy the Insurance data in csv format (as shown in the
attachement) and run the same procedure the result shown is different from
above result, why ?


Who knows?: you did not deign to tell us what you did with the CSV 
file nor the results you got.  Most likely you did not get the factor 
levels and classes the same as the help file destribes.  Hint: Group 
and Age are ordered factors.


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

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


[R] Get top cluster for each item in a correlation matrix

2009-02-23 Thread Tan, Richard
Hi,
 
I posted a question a few days ago and got extremely well response.
https://stat.ethz.ch/pipermail/r-help/2009-February/188225.html.  Now I
have a somewhat related question:
 
I have a correlation matrix of about 3000 items, with 1 on diagonal (
for example, cor.mat - cor(matrix(rnorm(3000*1000), 1000, 3000)) ).
For each item in the matrix, I want to find the cluster of which 1
belongs to, i.e., the cluster with the highest correlation coeffs, and
generate a data frame with 3 columns like (ID, ID2, cor), where in
each row ID is one of those 3000 items, and ID2 is ID of items with in
that top cluster, and cor is the correlation of ID and ID2.
 
The cluster method is fanny, setting number of clusters to 60.  It is
very time consuming to do a for loop like this:
 
for (i in 1:ncol(cor.mat)) {
  f - fanny(cor.mat[,i],60)
  temp - cbind(ID = i,ID2 = f$clustering, cor = cor.mat[,i])
  temp - temp[which(temp[,2]==f$clustering[i]),]
  if (i == 1) {
out - temp
  } else {
out - rbind(out,temp)
  }
}
out
 
Is there a better way to do it?  
 
Thanks,
Richard 

[[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] trade-off between speed and storage in matrix multiplications

2009-02-23 Thread Camarda, Carlo Giovanni
Dear R-users,

I coded two equivalent ways to perform (in a simplified version)
some matrix multiplications I would like to use in a more general
framework.
In the first case I used Kronecker product and vectorization of a
certain matrix. This approach takes less time, but, as you may guess, I
run out of memory when dimensions are large.
In the second approach, I profited of sparseness and structure of the
matrices and use outer-functions for performing operations. Here it
takes more time, but I have not problem of memory.

Is there any way to enhance the second approach for speeding-up the
whole process? Or, in computing, this is a well-known trade-off between
speed and storage-spaces which I'm not aware (sorry for that).

Please have a look to the example below.

Needless to say that I'd appreciate any suggestion.

Best,
Carlo Giovanni


# dimensions
m - 10
n - 15
# A-matrix
rnA - runif(m*m)
A - matrix(rnA, m, m)
# vector
v - runif(n)
# B-matrix
rnB - runif(m*n)
B - matrix(rnB, m, n)

# first solution: vectorize B + kronecker product = faster but storage
issues
system.time(
for(i in 1:100){
b - c(B)
vKron.A - kronecker(diag(v), A)
SOL1 - vKron.A %*% b
})

# second solution: orig. dims + apply + mapply = slower, but w/o
storage issues
system.time(
for(i in 1:100){
Av - outer(A, v, FUN=*)
Av.df1 - apply(Av, 3, as.data.frame)
Av.df2 - lapply(X=Av.df1, FUN=as.matrix, nrow=m, ncol=m)
SOL2 - mapply(FUN=%*%, Av.df2, as.data.frame(B)) # as a matrix
})





--
This mail has been sent through the MPI for Demographic ...{{dropped:10}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] trade-off between speed and storage in matrix multiplications

2009-02-23 Thread Christos Hatzis
You might want to compare the performance of your version to the kronecker
method of Matrix (Matrix package) that has appropriate versions for sparse
matrices etc.

-Christos

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Camarda, 
 Carlo Giovanni
 Sent: Monday, February 23, 2009 1:18 PM
 To: r-h...@stat.math.ethz.ch
 Subject: [R] trade-off between speed and storage in matrix 
 multiplications
 
 Dear R-users,
 
   I coded two equivalent ways to perform (in a simplified 
 version) some matrix multiplications I would like to use in a 
 more general framework.
 In the first case I used Kronecker product and vectorization 
 of a certain matrix. This approach takes less time, but, as 
 you may guess, I run out of memory when dimensions are large.
 In the second approach, I profited of sparseness and 
 structure of the matrices and use outer-functions for 
 performing operations. Here it takes more time, but I have 
 not problem of memory.
 
 Is there any way to enhance the second approach for 
 speeding-up the whole process? Or, in computing, this is a 
 well-known trade-off between speed and storage-spaces which 
 I'm not aware (sorry for that).
 
 Please have a look to the example below.
 
 Needless to say that I'd appreciate any suggestion.
 
 Best,
 Carlo Giovanni
 
 
 # dimensions
 m - 10
 n - 15
 # A-matrix
 rnA - runif(m*m)
 A - matrix(rnA, m, m)
 # vector
 v - runif(n)
 # B-matrix
 rnB - runif(m*n)
 B - matrix(rnB, m, n)
 
 # first solution: vectorize B + kronecker product = faster 
 but storage issues system.time( for(i in 1:100){
 b - c(B)
 vKron.A - kronecker(diag(v), A)
 SOL1 - vKron.A %*% b
 })
 
 # second solution: orig. dims + apply + mapply = slower, but 
 w/o storage issues system.time( for(i in 1:100){
 Av - outer(A, v, FUN=*)
 Av.df1 - apply(Av, 3, as.data.frame)
 Av.df2 - lapply(X=Av.df1, FUN=as.matrix, nrow=m, ncol=m)
 SOL2 - mapply(FUN=%*%, Av.df2, as.data.frame(B)) # as a matrix
 })
 
 
 
 
 
 --
 This mail has been sent through the MPI for Demographic 
 ...{{dropped:10}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] are arithmetic comparison operators binary?

2009-02-23 Thread Wacek Kusnierczyk
Martin Maechler wrote:
 WK == Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no
 on Mon, 23 Feb 2009 12:06:32 +0100 writes:
 

 Thank you, Wacek, 
 though .. wrong mailing list 
   

apologies.  i was actually asking for explanation, assuming that it
might be my misunderstanding, rather than reporting a bug.

 WK the man page for relational operators (see, e.g., ?'') says:
 WK 
 WK Binary operators which allow the comparison of values in atomic 
 vectors.

 WK Arguments:

 WK x, y: atomic vectors, symbols, calls, or other objects for which
 WK methods have been written.
 WK 

 WK it is somewhat surprizing that the following works:

 WK ''(1)
 WK # logical(0)

 WK ''()
 WK # logical(0)

 WK ''(1,2,3)
 WK # TRUE

 a bit surprising (sic!), indeed, even for me.
 Thanks for your notice and report!
   

you're welcome. 

shouldn't the tests have captured it?  i think you should have a check
for every feature following from the docs.  plus those undocumented, but
assumed by the developers.

 If you'd looked a bit in the sources, you'd seen that they
 really are supposed to be binary only.
   

it wouldn't be nonsensical to let them be of arbitrary arity (in a
well-documented manner), though it might confuse users.

 A very small change in the sources does accomplish this, passes
 the standard checks (and I cannot imagine reasonable code that
 would have relied on the more lenient behavior), so
 this will have changed in one of the next versions of R-devel.
   

thanks.

just a question (i haven't checked the sources, maybe i should):  what
is it that happens when one of the operators is called with n = 0 or 1
argument?  how does it come up with logical(0) rather than NA?

cheers,
vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Obtaining Least Square Means with lme (mixed models)

2009-02-23 Thread Claudia Ceballos
Hi Dear Alex, A few years ago you sent this email to R list:

Hello,
I was wondering how one could obtain LSM for fixed factors in a
mixed-effect model using lme. In other words, if I have model such as:
model-lme(yield~period+treatment+period*treatment,
data=data,random=~1|cow)
how can I get LSM for period, treatment and their interaction?
Thanks a lot!
Alex

What was the response?? I have the same question!

Thanks!
-- 
Claudia Ceballos
Ph.D. Candidate, Department of Ecology, Evolution and Organismal Biology
253 Bessey Hall, Iowa State University, Ames, IA 50011
http://www.public.iastate.edu/~ceballos/

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


Re: [R] Help in writing my own function

2009-02-23 Thread Chun-Hao Tu

Hi Ted,

I strongly recommend a book: S programming by W.N Venables and B.D Ripley ISBN: 
0387-989668

It is easy to read. I love this book so much. Maybe someone has better idea. 

 

Super

Chunhao

 

 
 Date: Mon, 23 Feb 2009 04:56:18 -0800
 From: zengzhenx...@gmail.com
 To: r-help@r-project.org
 Subject: [R] Help in writing my own function
 
 
 Dear all
 
 I am very intersted in writing my own function to deal with some complicated
 task, but I don't know how to start. I can't find detial material with
 examples teaching me how to write my own functions. Can anyone help me and
 recommend me some learning material?
 
 Many Thanks
 
 Ted 
 -- 
 View this message in context: 
 http://www.nabble.com/Help-in-writing-my-own-function-tp22161020p22161020.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.

_
Show them the way! Add maps and directions to your party invites. 

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

2009-02-23 Thread otunno
Hello -

How do I simulate multivariate ARIMA data?

I am familiar with the arima.sim function, which I have used several
times to generate univariate data, but when I type help(arima.sim), the
information I get back reveals nothing about possible multivariate
options.

Please reply when you get a free moment.

Thanks! Ferebee T.

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

2009-02-23 Thread Arne Henningsen
Hi Bernardo,

the systemfit package cannot be used to estimate a system of logistic 
equations.

Arne

On Friday, 20. February 2009 05:19:40, Bernardo Rangel Tura wrote:
 Hi R-masters

 I need yours help about a problema in one of may ongoing researchers.

 In my research the subjects (20 in total) answer 60 questions (20 type
 G, 20 type S and 20 type P).

 Which questions is classified about 3 factor (2 level each) and the
 subject score with 2 scale (not integer value is possible but rare): Val
 range -7 to 7 and other Car range 1 to 7.

 This a code to fake database of research

 Subj-rep(1:20,each=60)
 Sti-rep(c(G,S,P),40)
 SP-rep(c(S,P),60)
 AG-rep(c(A,P),60)
 Mer-rep(c(M,NM),60)
 Car-round(runif(120,1,7),0)
 Val-round(runif(120,-7,7),0)
 base-data.frame(Subj,Sti,SP,AG,Mer,Car,Val)

 In my hypothesis:

 logit(Sti==G) ~ SP+AG+Mer+Car+Val+SP*Car+Mer*Val+AG*Val + errorG

 logit(Sti==S) ~ SP+AG+Mer+Car+Val+SP*Car+Mer*Val+AG*Val + errorS

 logit(Sti==P) ~ SP+AG+Mer+Car+Val+SP*Car+Mer*Val+AG*Val + errorP

 I test and the 3 terms of error (errorG,errorS,errorP) is correlated.

 So I think useful adjust a system of logistic equations to tread the 3
 equations and in same time to obtain estimatives of effects and
 uncorrelated error terms.


 The systemfit package fit linear system and non-linear system but is
 possible adjust a logistic system in R?

 Thanks in advance
-- 
Arne Henningsen
http://www.arne-henningsen.name/

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

2009-02-23 Thread RUSER2009

I am trying to display a set of listboxes in a systematic manner.
For instance, I display Listbox 1, let the user pick the parameters of
interest then destroy it.
Now I display Listbox 2
and so on.

So in essence I would like to create listboxes in a for -loop.

When I try to loop - all the listboxes are displayed simultaneously and
nothing works properly - any comment on how to avoid this. I need the
listboxes to displayed one at a time.

I need to set some flag. I am hoping there are some a parmaters in the
'tkbutton' which will be helpful.

Any comments/suggestions are welcome.



-- 
View this message in context: 
http://www.nabble.com/Listbox-in-R-tp22168569p22168569.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] Listbox in R

2009-02-23 Thread Greg Snow
Look at the tkwait.window function as one possibility.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of RUSER2009
 Sent: Monday, February 23, 2009 12:43 PM
 To: r-help@r-project.org
 Subject: [R] Listbox in R
 
 
 I am trying to display a set of listboxes in a systematic manner.
 For instance, I display Listbox 1, let the user pick the parameters of
 interest then destroy it.
 Now I display Listbox 2
 and so on.
 
 So in essence I would like to create listboxes in a for -loop.
 
 When I try to loop - all the listboxes are displayed simultaneously and
 nothing works properly - any comment on how to avoid this. I need the
 listboxes to displayed one at a time.
 
 I need to set some flag. I am hoping there are some a parmaters in the
 'tkbutton' which will be helpful.
 
 Any comments/suggestions are welcome.
 
 
 
 --
 View this message in context: http://www.nabble.com/Listbox-in-R-
 tp22168569p22168569.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] simple graphing question

2009-02-23 Thread William Deese
I have what should be a simple question but I've been unable to solve
it in a reasonable length of time. For example with data like
 ge
  product response scenario
1wine5 base
2   steel   10 base
3   sugar4 base
4wine  -10   policy
5   steel1   policy
6   sugar  -20   policy

(In reality there would be similar groups of data of various sizes). I
would like to make dotplots with product on the left axis, x's for
policy and o's for base scenario, say in red and blue. I would like to
have horizontal lines from the product names across thru the x's and
o's to the other side. Because positive or negative responses are
important, I would like to have a vertical red line top to bottom at
0. I've experimented with dot.line, add.line to put in horizontal
lines but was unsuccessful. Although the following code puts a red
vertical line in, it is at the plot's left border.

gedot -
function()
{
trellis.par.set(list(fontsize=list(text=12),
dot.symbol=list(pch=c(1,4), col=c(blue,red)) ))
print(dotplot(product ~ response, groups = scenario, pch=c(1,4),
xlab=, ylab=NULL))
panel.abline(v=0, col=red, reference=FALSE)
}

Help please.

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

2009-02-23 Thread David M Smith
If I understand your example correctly, I think you're looking for a
dot-chart like this one from the R Graph Gallery:

http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=150

You'd just need to replace the green/blue circles with X's and O's,
respectively. Provided you reorganize your data the standard dotchart
function should do what you need.  See the code for the chart in the
graph gallery (or here: http://tinyurl.com/dby3jd ).

# David Smith

--
David M Smith da...@revolution-computing.com
Director of Community, REvolution Computing www.revolution-computing.com
Tel: +1 (206) 577-4778 x3203 (Seattle, USA)



On Mon, Feb 23, 2009 at 12:38 PM, William Deese williamde...@gmail.com wrote:

 I have what should be a simple question but I've been unable to solve
 it in a reasonable length of time. For example with data like
  ge
  product response scenario
 1wine5 base
 2   steel   10 base
 3   sugar4 base
 4wine  -10   policy
 5   steel1   policy
 6   sugar  -20   policy

 (In reality there would be similar groups of data of various sizes). I
 would like to make dotplots with product on the left axis, x's for
 policy and o's for base scenario, say in red and blue. I would like to
 have horizontal lines from the product names across thru the x's and
 o's to the other side. Because positive or negative responses are
 important, I would like to have a vertical red line top to bottom at
 0. I've experimented with dot.line, add.line to put in horizontal
 lines but was unsuccessful. Although the following code puts a red
 vertical line in, it is at the plot's left border.

 gedot -
 function()
 {
 trellis.par.set(list(fontsize=list(text=12),
 dot.symbol=list(pch=c(1,4), col=c(blue,red)) ))
 print(dotplot(product ~ response, groups = scenario, pch=c(1,4),
 xlab=, ylab=NULL))
 panel.abline(v=0, col=red, reference=FALSE)
 }

 Help please.

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

2009-02-23 Thread Giovanni Petris

 Date: Mon, 23 Feb 2009 14:03:07 -0500 (EST)
 From: otu...@clemson.edu
 Sender: r-help-boun...@r-project.org
 Importance: Normal
 Precedence: list
 User-Agent: SquirrelMail/1.4.13
 
 Hello -
 
 How do I simulate multivariate ARIMA data?
 

You can use package dlm. There is a function -- dlmModARMA() -- to set
up an ARMA model (univariate or multivariate) in DLM form, and a
function -- dlmForecast() -- to obtain forecasts/simulations
(including pre-sample, which is what you need).

Hope this helps,
Giovanni


 I am familiar with the arima.sim function, which I have used several
 times to generate univariate data, but when I type help(arima.sim), the
 information I get back reveals nothing about possible multivariate
 options.
 
 Please reply when you get a free moment.
 
 Thanks! Ferebee T.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 

Giovanni Petris  gpet...@uark.edu
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Formula that includes previous row values

2009-02-23 Thread Pele

Hi R users,

Is there an easy way in R to generate the results table below using table 1
and the formula (simplified version of the real problem)?  It would be easy
if I knew the R equivalent of SAS's retain function, but could not find one.

Thanks in Advance for any help!

table1:

ID  X2 X3
1.001.00   0
2.000.00
3.001.00
4.003058
5.000.00
6.006.00

Formula: X3 = x2 + (.24 * x3)

where the values in the x3 column of the result table are retained from
previous x3 rows.. Also the first x3 value is initialized to 0 to start

e.g.
for ID=1 we have  1 + .24(0)= 1.00  
for ID=2 we have  0 + .24(1)= 0.24
for ID=3 we have  1 + .24(.24)  = 1.06
for ID=4 we have  3058 + .24(1.06)  = 3058.25
etc.

Results:
ID  X2  x3
1.001.001.00
2.000.000.24
3.001.001.06
4.0030583058.25
5.000.00733.98
6.006.00182.16
-- 
View this message in context: 
http://www.nabble.com/Formula-that-includes-previous-row-values-tp22170010p22170010.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] Slow indexing access for Matrix

2009-02-23 Thread Niels Richard Hansen

Consider the following little benchmark

 require(Matrix)
 tmp - Matrix(c(rep(1,1000),rep(0,9000)),ncol=1)
 ind - sample(1:1,1)
 system.time(tmp[ind,])
   user  system elapsed
  0.004   0.001   0.005

 ind - sample(1:1000,1,replace=TRUE)
 system.time(tmp[ind,])
   user  system elapsed
  0.654   0.006   0.703

 system.time(Matrix(as(tmp,matrix)[ind,]))
   user  system elapsed
  0.005   0.000   0.006

First I access all 1 rows in a random order, which is fast,
but when I access the first 1000 rows 1 times there is a
considerable slowdown. Last I convert back and forth
between matrix and Matrix and get a serious speedup. Am I missing
a point here? Should I not use indexing with [ for the
sparse matrices if I have repeated indices?

I'm running Mac OS X, version 10.5.6, with Matrix package
version 0.999375-21.

I hope that somebody can enlighten me on this issue.

Thanks, Niels


--
Niels Richard Hansen
Associate Professor
Department of Mathematical Sciences
University of Copenhagen
Universitetsparken 5
2100 Copenhagen Ø
Denmark
+45 353 20783

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Formula that includes previous row values

2009-02-23 Thread Jorge Ivan Velez
Dear Pele,
Probably not the best way to proceed but it works:

X-read.table(textConnection(ID  X2
1.001.00
2.000.00
3.001.00
4.003058
5.000.00
6.006.00),header=TRUE)
closeAllConnections()
X

x3-0
for(i in 2:(nrow(X)+1)) x3-c(x3, X$X2[i-1]+0.24*x3[i-1])
X$x3-x3[-1]
X

HTH,

Jorge


On Mon, Feb 23, 2009 at 3:59 PM, Pele drdi...@yahoo.com wrote:


 Hi R users,

 Is there an easy way in R to generate the results table below using table 1
 and the formula (simplified version of the real problem)?  It would be easy
 if I knew the R equivalent of SAS's retain function, but could not find
 one.

 Thanks in Advance for any help!

 table1:

 ID  X2 X3
 1.001.00   0
 2.000.00
 3.001.00
 4.003058
 5.000.00
 6.006.00

 Formula: X3 = x2 + (.24 * x3)

 where the values in the x3 column of the result table are retained from
 previous x3 rows.. Also the first x3 value is initialized to 0 to start

 e.g.
for ID=1 we have  1 + .24(0)= 1.00
for ID=2 we have  0 + .24(1)= 0.24
for ID=3 we have  1 + .24(.24)  = 1.06
for ID=4 we have  3058 + .24(1.06)  = 3058.25
etc.

 Results:
 ID  X2  x3
 1.001.001.00
 2.000.000.24
 3.001.001.06
 4.0030583058.25
 5.000.00733.98
 6.006.00182.16
 --
 View this message in context:
 http://www.nabble.com/Formula-that-includes-previous-row-values-tp22170010p22170010.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] Formula that includes previous row values

2009-02-23 Thread Christos Hatzis
Here's a way without a loop:

x - read.table(textConnection(ID  X2
1.001.00
2.000.00
3.001.00
4.003058
5.000.00
6.006.00),header=TRUE)
closeAllConnections()

x$X3 - append(x$X2, 0, 0)[-nrow(x)]
x$X4 - as.matrix(x[,2:3]) %*% c(1, 0.24)

 x
  ID   X2   X3  X4
1  1101.00
2  2010.24
3  3101.00
4  4 30581 3058.24
5  50 3058  733.92
6  6667.44

-Christos 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Pele
 Sent: Monday, February 23, 2009 4:48 PM
 To: r-help@r-project.org
 Subject: Re: [R] Formula that includes previous row values
 
 
 Hi Jorge - many thanks for you suggestion, but I am looking 
 for a way where I don't have to use a loop.  I meant to 
 include that in my description.
 
 Thanks again!
 
 
 Jorge Ivan Velez wrote:
  
  Dear Pele,
  Probably not the best way to proceed but it works:
  
  X-read.table(textConnection(ID  X2
  1.001.00
  2.000.00
  3.001.00
  4.003058
  5.000.00
  6.006.00),header=TRUE)
  closeAllConnections()
  X
  
  x3-0
  for(i in 2:(nrow(X)+1)) x3-c(x3, X$X2[i-1]+0.24*x3[i-1]) 
 X$x3-x3[-1] 
  X
  
  HTH,
  
  Jorge
  
  
  On Mon, Feb 23, 2009 at 3:59 PM, Pele drdi...@yahoo.com wrote:
  
 
  Hi R users,
 
  Is there an easy way in R to generate the results table 
 below using 
  table
  1
  and the formula (simplified version of the real problem)?  
 It would 
  be easy if I knew the R equivalent of SAS's retain function, but 
  could not find one.
 
  Thanks in Advance for any help!
 
  table1:
 
  ID  X2 X3
  1.001.00   0
  2.000.00
  3.001.00
  4.003058
  5.000.00
  6.006.00
 
  Formula: X3 = x2 + (.24 * x3)
 
  where the values in the x3 column of the result table are retained 
  from previous x3 rows.. Also the first x3 value is 
 initialized to 0 
  to start
 
  e.g.
 for ID=1 we have  1 + .24(0)= 1.00
 for ID=2 we have  0 + .24(1)= 0.24
 for ID=3 we have  1 + .24(.24)  = 1.06
 for ID=4 we have  3058 + .24(1.06)  = 3058.25
 etc.
 
  Results:
  ID  X2  x3
  1.001.001.00
  2.000.000.24
  3.001.001.06
  4.0030583058.25
  5.000.00733.98
  6.006.00182.16
  --
  View this message in context:
  
 http://www.nabble.com/Formula-that-includes-previous-row-values-tp221
  70010p22170010.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.
  
  
 
 --
 View this message in context: 
 http://www.nabble.com/Formula-that-includes-previous-row-value
 s-tp22170010p22170878.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] Slow indexing access for Matrix

2009-02-23 Thread Peter Dalgaard

Niels Richard Hansen wrote:

Consider the following little benchmark

  require(Matrix)
  tmp - Matrix(c(rep(1,1000),rep(0,9000)),ncol=1)
  ind - sample(1:1,1)
  system.time(tmp[ind,])
   user  system elapsed
  0.004   0.001   0.005

  ind - sample(1:1000,1,replace=TRUE)
  system.time(tmp[ind,])
   user  system elapsed
  0.654   0.006   0.703

  system.time(Matrix(as(tmp,matrix)[ind,]))
   user  system elapsed
  0.005   0.000   0.006

First I access all 1 rows in a random order, which is fast,
but when I access the first 1000 rows 1 times there is a
considerable slowdown. Last I convert back and forth
between matrix and Matrix and get a serious speedup. Am I missing
a point here? Should I not use indexing with [ for the
sparse matrices if I have repeated indices?

I'm running Mac OS X, version 10.5.6, with Matrix package
version 0.999375-21.

I hope that somebody can enlighten me on this issue.

Thanks, Niels


The sources have the answer, but I'm as reluctant to read them as you 
are. ;-)


The repeated indices are certainly an important part of it. Notice also 
that you'll have timings like


 ind - sample(1:1,1,replace=TRUE)
 system.time(tmp[ind,])
   user  system elapsed
  0.884   0.000   1.302
 ind - sample(1:1000,1,replace=TRUE)
 system.time(tmp[ind,])
   user  system elapsed
  2.053   0.009   2.268
 ind - sample(1:1,1,replace=FALSE)
 system.time(tmp[ind,])
   user  system elapsed
   0.010.000.01

It is, however, apparently unrelated to the sparseness of the result 
(sampling from 1001:2000 gives the same result).


Also
 ind - sample(1:5000,5000,replace=FALSE)
 ind - c(ind,ind)
 system.time(tmp[ind,])
   user  system elapsed
  1.204   0.001   1.331

has a considerable part of the slowdown, as does

ind - c(1:5000,1:5000)

Presumably the issue is that calculations on sparseness patterns are 
harder when there are repeated indices.


--
   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
~~ - (p.dalga...@biostat.ku.dk)  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] Formula that includes previous row values

2009-02-23 Thread Greg Snow
How about:

x3 - cumsum( x2* 0.24^(5:0) ) / 0.24^(5:0)

with the 5 replaced by the length -1 for the more general case.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Pele
 Sent: Monday, February 23, 2009 1:59 PM
 To: r-help@r-project.org
 Subject: [R] Formula that includes previous row values
 
 
 Hi R users,
 
 Is there an easy way in R to generate the results table below using
 table 1
 and the formula (simplified version of the real problem)?  It would be
 easy
 if I knew the R equivalent of SAS's retain function, but could not find
 one.
 
 Thanks in Advance for any help!
 
 table1:
 
 IDX2 X3
 1.00  1.00   0
 2.00  0.00
 3.00  1.00
 4.00  3058
 5.00  0.00
 6.00  6.00
 
 Formula: X3 = x2 + (.24 * x3)
 
 where the values in the x3 column of the result table are retained from
 previous x3 rows.. Also the first x3 value is initialized to 0 to start
 
 e.g.
   for ID=1 we have  1 + .24(0)= 1.00
   for ID=2 we have  0 + .24(1)= 0.24
   for ID=3 we have  1 + .24(.24)  = 1.06
   for ID=4 we have  3058 + .24(1.06)  = 3058.25
 etc.
 
 Results:
 IDX2  x3
 1.00  1.001.00
 2.00  0.000.24
 3.00  1.001.06
 4.00  30583058.25
 5.00  0.00733.98
 6.00  6.00182.16
 --
 View this message in context: http://www.nabble.com/Formula-that-
 includes-previous-row-values-tp22170010p22170010.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] why results from regression tree (rpart) are totally inconsistent with ordinary regression

2009-02-23 Thread Weidong Gu
Hi,

In my analysis of impacts of insecticide-treated bednets on malaria, I
look at the relationship between malaria incidence and mosquito
behaviors. The condensed data set is copied here. Ordinary regression
(lm) shows that Incidence was negatively related to Mortality. This
makes sense because the latter reflected the strength of killing
mosquitoes by insecticide-treated nets. Since the original data set has
a complex structure with more parameters and scenarios. I guess a tree
model would help explore the structure of the data.  However, regression
tree (rpart(Incidence~Mortality+Deterrence)) indicates that Mortality
was positively related to Incidence. 

How this unintuitive result? Advice is appreciated. 

Weidong Gu, 
Department of Medicine
University of Alabama, Birmingham

Deterrence  Mortality   Incidence
0.695   0.5166
0.255   0.501   48
0.612   0.483   55
0.209   0.158   47
0.499   0.589   53
0.755   0.285   73
0.764   0.351   77
0.749   0.211   64
0.101   0.336   45
0.556   0.066   72
0.576   0.403   45
0.232   0.667   35
0.424   0.891   34
0.432   0.458   54
0.197   0.269   59
0.188   0.523   40
0.291   0.864   32
0.504   0.791   36
0.387   0.138   66
0.710.676   56
0.235   0.183   59
0.358   0.579   41
0.718   0.5749
0.775   0.254   46
0.269   0.633   42
0.443   0.741   40
0.280.438   49
0.385   0.778   37
0.539   0.653   37
0.730.094   84
0.489   0.611   40
0.595   0.431   39
0.305   0.003   69
0.511   0.595   37
0.394   0.798   37
0.369   0.541   47
0.414   0.552   51
0.468   0.858   34
0.311   0.201   59
0.142   0.3643
0.514   0.195   46
0.365   0.325   48
0.608   0.224   67
0.177   0.0462
0.475   0.146   65
0.526   0.702   46
0.735   0.372   43
0.172   0.6636
0.622   0.531   53
0.651   0.055   76
0.223   0.296   54
0.783   0.566   52
0.439   0.698   34
0.527   0.493   41
0.766   0.8949
0.634   0.749   42
0.240.732   35
0.792   0.764   36
0.268   0.823   34
0.418   0.407   53
0.251   0.241   54
0.705   0.843   40
0.546   0.474   55
0.685   0.384   62
0.582   0.086   72
0.630.618   57
0.131   0.028   56
0.555   0.803   41
0.463   0.299   57
0.154   0.164   55
0.406   0.074   66
0.168   0.118   58
0.597   0.323   47
0.672   0.816   42
0.698   0.623   48
0.676   0.177   43
0.743   0.109   81
0.121   0.244   49
0.799   0.014   85
0.450.645   36
0.484   0.448   52
0.585   0.307   68
0.348   0.417   43
0.345   0.459   44
0.374   0.835   30
0.657   0.134   65
0.331   0.022   67
0.141   0.045   66
0.568   0.1 67
0.110.876   30
0.212   0.3946
0.298   0.519   40
0.322   0.721   44
0.201   0.7735
0.641   0.855   39
0.156   0.277   48
0.327   0.714   40
0.663   0.231   44
0.119   0.688   37
0.287   0.354   46

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


Re: [R] why results from regression tree (rpart) are totallyinconsistent with ordinary regression

2009-02-23 Thread Bert Gunter
You did not read the tree graph correctly.  Mortality is **not** positively
related to incidence. You're reading the tree backwards.  Read the output
of summary() on your rpart fit object for clarity.

 -- Bert Gunter
Genentech

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Weidong Gu
Sent: Monday, February 23, 2009 2:39 PM
To: r-help@r-project.org
Subject: [R] why results from regression tree (rpart) are
totallyinconsistent with ordinary regression

Hi,

In my analysis of impacts of insecticide-treated bednets on malaria, I
look at the relationship between malaria incidence and mosquito
behaviors. The condensed data set is copied here. Ordinary regression
(lm) shows that Incidence was negatively related to Mortality. This
makes sense because the latter reflected the strength of killing
mosquitoes by insecticide-treated nets. Since the original data set has
a complex structure with more parameters and scenarios. I guess a tree
model would help explore the structure of the data.  However, regression
tree (rpart(Incidence~Mortality+Deterrence)) indicates that Mortality
was positively related to Incidence. 

How this unintuitive result? Advice is appreciated. 

Weidong Gu, 
Department of Medicine
University of Alabama, Birmingham

Deterrence  Mortality   Incidence
0.695   0.5166
0.255   0.501   48
0.612   0.483   55
0.209   0.158   47
0.499   0.589   53
0.755   0.285   73
0.764   0.351   77
0.749   0.211   64
0.101   0.336   45
0.556   0.066   72
0.576   0.403   45
0.232   0.667   35
0.424   0.891   34
0.432   0.458   54
0.197   0.269   59
0.188   0.523   40
0.291   0.864   32
0.504   0.791   36
0.387   0.138   66
0.710.676   56
0.235   0.183   59
0.358   0.579   41
0.718   0.5749
0.775   0.254   46
0.269   0.633   42
0.443   0.741   40
0.280.438   49
0.385   0.778   37
0.539   0.653   37
0.730.094   84
0.489   0.611   40
0.595   0.431   39
0.305   0.003   69
0.511   0.595   37
0.394   0.798   37
0.369   0.541   47
0.414   0.552   51
0.468   0.858   34
0.311   0.201   59
0.142   0.3643
0.514   0.195   46
0.365   0.325   48
0.608   0.224   67
0.177   0.0462
0.475   0.146   65
0.526   0.702   46
0.735   0.372   43
0.172   0.6636
0.622   0.531   53
0.651   0.055   76
0.223   0.296   54
0.783   0.566   52
0.439   0.698   34
0.527   0.493   41
0.766   0.8949
0.634   0.749   42
0.240.732   35
0.792   0.764   36
0.268   0.823   34
0.418   0.407   53
0.251   0.241   54
0.705   0.843   40
0.546   0.474   55
0.685   0.384   62
0.582   0.086   72
0.630.618   57
0.131   0.028   56
0.555   0.803   41
0.463   0.299   57
0.154   0.164   55
0.406   0.074   66
0.168   0.118   58
0.597   0.323   47
0.672   0.816   42
0.698   0.623   48
0.676   0.177   43
0.743   0.109   81
0.121   0.244   49
0.799   0.014   85
0.450.645   36
0.484   0.448   52
0.585   0.307   68
0.348   0.417   43
0.345   0.459   44
0.374   0.835   30
0.657   0.134   65
0.331   0.022   67
0.141   0.045   66
0.568   0.1 67
0.110.876   30
0.212   0.3946
0.298   0.519   40
0.322   0.721   44
0.201   0.7735
0.641   0.855   39
0.156   0.277   48
0.327   0.714   40
0.663   0.231   44
0.119   0.688   37
0.287   0.354   46

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

2009-02-23 Thread Zainab Jamal
Hi
I am estimating the following coxph function with stratification and 
frailty where each person had multiple events.

m-coxph(Surv(dtime1,status1)~gender+cage+uplf+strata(enum)+frailty(id),xmodel)
 
 head(xmodel)
   id enumdtime status gender cage uplf
1 10086661 2259.1412037  1 MA0.0000
2 10086662   36.7495023  1 MA 2259.1410
3 100866630.3026852  1 MA 2295.8910
4 10086664   46.7493287  1 MA 2296.1930
5 10086665   61.9772917  1 MA 2342.9430
6 10086665  100.9964815  1 MA 2404.9200


If I estimate predict(m,newdata,type=lp) does the output include xbeta or 
does it include xbeta+frailty term?
 
I want to predict the cumulative hazard for each person for their next event at 
a given time in future.What is the best way to compute it? 

Currently I am doing it by pulling the different elements and putting them 
together using my own code.
For example, I get the cumulative baseline hazard from the basehaz function
bh-basehaz(m)
bh$hazard for the strata in which the predicted event is and the time that 
matches to the prediction time.
xbeta from predict function
xbeta-predict(m,newdata,type=lp)
fval-m$frail 

Regards
Zainab 

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


Re: [R] why results from regression tree (rpart) are totallyinconsistent with ordinary regression

2009-02-23 Thread Weidong Gu
Hi Bert,

Thanks for your prompt response. Yeah, summary() shows the correct
answer, seemingly, plot() and text() reverse the direction of = sign, a
bit confusion. 

Weidong Gu


-Original Message-
From: Bert Gunter [mailto:gunter.ber...@gene.com] 
Sent: Monday, February 23, 2009 5:14 PM
To: Weidong Gu; r-help@r-project.org
Subject: RE: [R] why results from regression tree (rpart) are
totallyinconsistent with ordinary regression

You did not read the tree graph correctly.  Mortality is **not**
positively
related to incidence. You're reading the tree backwards.  Read the
output
of summary() on your rpart fit object for clarity.

 -- Bert Gunter
Genentech

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
Behalf Of Weidong Gu
Sent: Monday, February 23, 2009 2:39 PM
To: r-help@r-project.org
Subject: [R] why results from regression tree (rpart) are
totallyinconsistent with ordinary regression

Hi,

In my analysis of impacts of insecticide-treated bednets on malaria, I
look at the relationship between malaria incidence and mosquito
behaviors. The condensed data set is copied here. Ordinary regression
(lm) shows that Incidence was negatively related to Mortality. This
makes sense because the latter reflected the strength of killing
mosquitoes by insecticide-treated nets. Since the original data set has
a complex structure with more parameters and scenarios. I guess a tree
model would help explore the structure of the data.  However, regression
tree (rpart(Incidence~Mortality+Deterrence)) indicates that Mortality
was positively related to Incidence. 

How this unintuitive result? Advice is appreciated. 

Weidong Gu, 
Department of Medicine
University of Alabama, Birmingham

Deterrence  Mortality   Incidence
0.695   0.5166
0.255   0.501   48
0.612   0.483   55
0.209   0.158   47
0.499   0.589   53
0.755   0.285   73
0.764   0.351   77
0.749   0.211   64
0.101   0.336   45
0.556   0.066   72
0.576   0.403   45
0.232   0.667   35
0.424   0.891   34
0.432   0.458   54
0.197   0.269   59
0.188   0.523   40
0.291   0.864   32
0.504   0.791   36
0.387   0.138   66
0.710.676   56
0.235   0.183   59
0.358   0.579   41
0.718   0.5749
0.775   0.254   46
0.269   0.633   42
0.443   0.741   40
0.280.438   49
0.385   0.778   37
0.539   0.653   37
0.730.094   84
0.489   0.611   40
0.595   0.431   39
0.305   0.003   69
0.511   0.595   37
0.394   0.798   37
0.369   0.541   47
0.414   0.552   51
0.468   0.858   34
0.311   0.201   59
0.142   0.3643
0.514   0.195   46
0.365   0.325   48
0.608   0.224   67
0.177   0.0462
0.475   0.146   65
0.526   0.702   46
0.735   0.372   43
0.172   0.6636
0.622   0.531   53
0.651   0.055   76
0.223   0.296   54
0.783   0.566   52
0.439   0.698   34
0.527   0.493   41
0.766   0.8949
0.634   0.749   42
0.240.732   35
0.792   0.764   36
0.268   0.823   34
0.418   0.407   53
0.251   0.241   54
0.705   0.843   40
0.546   0.474   55
0.685   0.384   62
0.582   0.086   72
0.630.618   57
0.131   0.028   56
0.555   0.803   41
0.463   0.299   57
0.154   0.164   55
0.406   0.074   66
0.168   0.118   58
0.597   0.323   47
0.672   0.816   42
0.698   0.623   48
0.676   0.177   43
0.743   0.109   81
0.121   0.244   49
0.799   0.014   85
0.450.645   36
0.484   0.448   52
0.585   0.307   68
0.348   0.417   43
0.345   0.459   44
0.374   0.835   30
0.657   0.134   65
0.331   0.022   67
0.141   0.045   66
0.568   0.1 67
0.110.876   30
0.212   0.3946
0.298   0.519   40
0.322   0.721   44
0.201   0.7735
0.641   0.855   39
0.156   0.277   48
0.327   0.714   40
0.663   0.231   44
0.119   0.688   37
0.287   0.354   46

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Formula that includes previous row values

2009-02-23 Thread Pele

Hi Greg - this is perfect - Thank You!

Also, thanks to everyone for the other suggestions



Greg Snow-2 wrote:
 
 How about:
 
 x3 - cumsum( x2* 0.24^(5:0) ) / 0.24^(5:0)
 
 with the 5 replaced by the length -1 for the more general case.
 
 -- 
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 greg.s...@imail.org
 801.408.8111
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Pele
 Sent: Monday, February 23, 2009 1:59 PM
 To: r-help@r-project.org
 Subject: [R] Formula that includes previous row values
 
 
 Hi R users,
 
 Is there an easy way in R to generate the results table below using
 table 1
 and the formula (simplified version of the real problem)?  It would be
 easy
 if I knew the R equivalent of SAS's retain function, but could not find
 one.
 
 Thanks in Advance for any help!
 
 table1:
 
 ID   X2 X3
 1.00 1.00   0
 2.00 0.00
 3.00 1.00
 4.00 3058
 5.00 0.00
 6.00 6.00
 
 Formula: X3 = x2 + (.24 * x3)
 
 where the values in the x3 column of the result table are retained from
 previous x3 rows.. Also the first x3 value is initialized to 0 to start
 
 e.g.
  for ID=1 we have  1 + .24(0)= 1.00
  for ID=2 we have  0 + .24(1)= 0.24
  for ID=3 we have  1 + .24(.24)  = 1.06
  for ID=4 we have  3058 + .24(1.06)  = 3058.25
 etc.
 
 Results:
 ID   X2  x3
 1.00 1.001.00
 2.00 0.000.24
 3.00 1.001.06
 4.00 30583058.25
 5.00 0.00733.98
 6.00 6.00182.16
 --
 View this message in context: http://www.nabble.com/Formula-that-
 includes-previous-row-values-tp22170010p22170010.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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Formula-that-includes-previous-row-values-tp22170010p22173033.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] array manipulation simple questions

2009-02-23 Thread Λεωνίδας Μπαντής
 
Hi there,
 
I am pretty new to R. Actually I started using it yesterday. I have two 
questions:
 
1.   Suppose I have a-c(1:10)  (or a-array(c(1:10),dim=c(1,10)))
 
and I want to end up with vector b=[0 0 0 0 0 1 1 1 1 1]. i.e. I want to 
substitute alla elements that are 5 with 0 and 5 with 1.
 
I did this by using a for loop. Is there another function to use so as to avoid 
the for?
 
 
2.  Suppose I have a-c(1,1,2,2,3,3)  (or array again)
 
And I want to place a 4,5 before every 2 and end up with a new bigger 
vector b:
 
b=[1 1 4 5 2 4 5 2 3 3]
 
Also I want to find where the 2's in array a (if it was an array) are located 
i.e. positions 3,4.
 
 
Thanx very much in advance!!
 
P.S: Will you inform me via mail or should I visit any blog and post there my 
questions?
 
 


  
___ 
×ñçóéìïðïéåßôå Yahoo!; 
ÂáñåèÞêáôå ôá åíï÷ëçôéêÜ ìçíýìáôá (spam); Ôï Yahoo! Mail 
äéáèÝôåé ôçí êáëýôåñç äõíáôÞ ðñïóôáóßá êáôÜ ôùí åíï÷ëçôéêþí 
ìçíõìÜôùí http://login.yahoo.com/config/mail?.intl=gr

[[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] question about loading date file in R

2009-02-23 Thread 850426

I am trying to load a .csv file in the R commander, but the output window
always showed that Error: bad restore file magic number(file may be
corrupted)--no data loaded. Did any one know why does this happen? btw, I
can open this file in commander by open script file.

Many thanks!
-- 
View this message in context: 
http://www.nabble.com/question-about-loading-date-file-in-R-tp22172562p22172562.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] Simple seq() boolean equality problem

2009-02-23 Thread Daniel G Polhamus

Hi all, thanks in advance for the help.

Can someone explain to me the following result, and what I'm doing wrong 
in the second case?


 seq(-43.7,-43.69,.001)[3]==-43.698
[1] TRUE
 seq(-43.7,-43.69,.001)[2]==-43.699
[1] FALSE
 seq(-43.7,-43.69,.001)[1]==-43.7
[1] TRUE

Dan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] equivalent function to MatLab 'step' ?

2009-02-23 Thread Carl Witthoft

Well, I found out part of the confusion:

The modern versions of MatLab renamed their function from 'step' to 
'stepz' .


Stepz(num,den) provides a calculation of the time-response to a step 
function based on the system state equation defined by the num and den 
coefficients.


So, is there some R function (maybe inside some of the TS packages) 
which do similar Laplace-transform-related calculations?


thanks
Carl

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

2009-02-23 Thread Rolf Turner


On 24/02/2009, at 2:29 PM, Daniel G Polhamus wrote:


Hi all, thanks in advance for the help.

Can someone explain to me the following result, and what I'm doing  
wrong

in the second case?


seq(-43.7,-43.69,.001)[3]==-43.698

[1] TRUE

seq(-43.7,-43.69,.001)[2]==-43.699

[1] FALSE

seq(-43.7,-43.69,.001)[1]==-43.7

[1] TRUE


Floating point arithmetic.  FAQ 7.31.  RTFFAQ.

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] Semantics of sequences in R

2009-02-23 Thread Raubertas, Richard
 

 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan Murdoch
 Sent: Sunday, February 22, 2009 4:13 PM
 
 I think this was posted to the wrong list, so my followup is going to 
 R-devel.
 
 On 22/02/2009 3:42 PM, Stavros Macrakis wrote:
  Inspired by the exchange between Rolf Turner and Wacek 
 Kusnierczyk, I
  thought I'd clear up for myself the exact relationship among the
  various sequence concepts in R, including not only generic vectors
  (lists) and atomic vectors, but also pairlists, factor sequences,
  date/time sequences, and difftime sequences.
  
  I tabulated type of sequence vs. property to see if I could 
 make sense
  of all this.  The properties I looked at were the predicates
  is.{vector,list,pairlist}; whether various sequence operations (c,
  rev, unique, sort, rle) can be used on objects of the various types,
  and if relevant, whether they preserve the type of the 
 input; and what
  the length of class( as.XXX (1:2) ) is.
  
  Here are the results (code to reproduce at end of email):
  
   numer list  plist fact  POSIXct difft
  is.vectorTRUE  TRUE  FALSE FALSE FALSE   FALSE
  is.list  FALSE TRUE  TRUE  FALSE FALSE   FALSE
  is.pairlist  FALSE FALSE TRUE  FALSE FALSE   FALSE
  c_keep?  TRUE  TRUE  FALSE FALSE TRUEFALSE
  rev_keep?TRUE  TRUE  FALSE TRUE  TRUETRUE
  unique_keep? TRUE  TRUE  Err TRUE  TRUEFALSE
  sort_keep?   TRUE  Err Err TRUE  TRUETRUE
  rle_len  2 Err Err Err Err   Err
  
  Alas, this tabulation, rather than clarifying things for me, just
  confused me more -- the diverse treatment of sequences by various
  operations is all rather bewildering.
 
 But you are asking lots of different questions, so of course 
 you should 
 get different answers.  For example, the first three rows are 
 behaving 
 exactly as documented.  (Perhaps the functions should have 
 been designed 
 differently, but a pretty-looking matrix isn't an argument for that. 
 Give some examples of how the documented behaviour is causing 
 problems.)
 
 I think some of the operations in the later rows are undocumented 
 (generally pairlists tend not to be documented, even if in some cases 
 they are supported), and it might make sense to make them more 
 consistent in the undocumented cases.  But it may make more sense to 
 completely hide pairlists, for instance, and then several more of the 
 examples are behaving as documented.  (BTW, your description of your 
 last row doesn't match what you did, as far as I can see.)
 
  Wouldn't it be easier to teach, learn, and use R if there were more
  consistency in the treatment of sequences?  
 
 Which ones in particular should change?  What should they change to? 
 What will break when you do that?

Okay, here is one that should change:  'c()' should do something useful 
with factors, for example return a factor whose levels are the union of
the 
levels of the arguments.  Note that precedent for this already exists 
in base R:

 f1 - factor(letters[1:3])
 f2 - factor(letters[3:5])
 c(f1, f2)
[1] 1 2 3 1 2 3
 str(rbind(data.frame(f=f1), data.frame(f=f2)))
'data.frame':   6 obs. of  1 variable:
 $ f: Factor w/ 5 levels a,b,c,d,..: 1 2 3 3 4 5

So the code and documentation already exist in 'rbind.data.frame'.  As 
for what would break, well, it is hard to imagine any possible use for 
the current behavior, or who could have made use of it.  But you never 
know I guess ...

Rich Raubertas
Merck  Co.

 
   I understand that in
  long-running projects like S/R, there is an accumulation of
  contributions by a variety of authors, but perhaps the time has come
  for some cleanup at least for the base library?
 
 Generally R core members are reluctant to take on work just because 
 someone else thinks it would be nice if they did.  If you want to do 
 this, that's one thing, but if you are just saying that it 
 would be nice 
 if someone else did it, then it's much less likely to get 
 done.  To get 
 someone else to do it you need to convince them that it's a 
 valuable use 
 of their time, and I don't see that yet.
 
 Duncan Murdoch
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
Notice:  This e-mail message, together with any attachme...{{dropped:12}}

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


[R] multinom() and multinomial() interpretation

2009-02-23 Thread Grant Gillis
Hello and thanks in advance for any advice.

I am not clear how, in practice, the multinom() function in nnet and the
multinomial() function in VGAM differ in terms of interpretation.  I
understand that they are fit differently.  Are there certain scenarios where
one is more appropriate than the other?  In my case I have a dependent
variable with 4 categories and 1 binary and 4 continuous independent
variables.  I am fitting 3 models.

Cheers
Grant

[[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] Welcome to the R-help mailing list

2009-02-23 Thread sdzhangping
Dear R users:
Analysis of the impact of a time-dependent covariate (GVHD or use of 
steroid after bone marrow transplantation) on two competing endpoints (invasive 
fungal infection and death) is frequently encountered in the setting of BMT 
data. Coxph package can be used as the following:
for the analysis of GVHD:
  gvhd - coxph(Surv(start,stop,status = =1) ~ GVHD, data=bmt.data)
and the data should be edited as the following:
  patient start stop status(IFI) GVHD
 1 0  15 0 0
 1 15 35 1 1
 2 0  12 0 0
 2 12 20 2 1
 3 0  30 2 0
 4 0  1000 0
 5 0  25 0 0
 5 25 1000 1
   similarly, for steroid:
  steroid - coxph(Surv(start,stop,status = =1) ~ steroid, data=bmt.data)
and the data was edited as the following:
  patient start stop status(IFI) steroid
 1 0  16 0 0
 1 16 35 1 1
 2 0  13 0 0
 2 13 20 2 1
 3 0  14 0 0
 3 14 30 2 1
 4 0  1000 0
 5 0  21 0 0
 5 21 1000 1
 
I wonder how can I analyze the two risk factors (GVHD and steroid) 
concurrently? And how to edit the data. 
How can I manage it if a third baseline risk factor(age for example) was 
included?
 
 Thanks 
 Yours sincerely Ping Zhang 
 Feb 24 2009
 
[[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: calculations for causespecific hazard ratios in a competing risks analysis with timedependent covariates

2009-02-23 Thread sdzhangping
Dear R users:
Analysis of the impact of a time-dependent covariate (GVHD or use of 
steroid after bone marrow transplantation) on two competing endpoints (invasive 
fungal infection and death) is frequently encountered in the setting of BMT 
data. Coxph package can be used as the following:
for the analysis of GVHD:
  gvhd - coxph(Surv(start,stop,status = =1) ~ GVHD, data=bmt.data)
and the data should be edited as the following:
  patient start stop status(IFI) GVHD
 1 0  15 0 0
 1 15 35 1 1
 2 0  12 0 0
 2 12 20 2 1
 3 0  30 2 0
 4 0  1000 0
 5 0  25 0 0
 5 25 1000 1
   similarly, for steroid:
  steroid - coxph(Surv(start,stop,status = =1) ~ steroid, data=bmt.data)
and the data was edited as the following:
  patient start stop status(IFI) steroid
 1 0  16 0 0
 1 16 35 1 1
 2 0  13 0 0
 2 13 20 2 1
 3 0  14 0 0
 3 14 30 2 1
 4 0  1000 0
 5 0  21 0 0
 5 21 1000 1
 
I wonder how can I analyze the two risk factors (GVHD and steroid) 
concurrently? And how to edit the data. 
How can I manage it if a third baseline risk factor(age for example) was 
included?
 
 Thanks 
 Yours sincerely Ping Zhang 
 Feb 24 2009



[[alternative HTML version deleted]]

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


Re: [R] Help with R and MySQL

2009-02-23 Thread Aaron Barzilai
Thanks Jeff, that was exactly the problem.  When I unzipped the version at the 
page below for my version of MySQL (5.1), it worked fine.  The version I 
downloaded through install.packages() must have been for 5.0.

Thanks so much for the help and quick response,
Aaron






From: Jeffrey Horner jeff.hor...@vanderbilt.edu

Cc: R-help@r-project.org
Sent: Monday, February 23, 2009 10:10:02 AM
Subject: Re: [R] Help with R and MySQL

Aaron Barzilai wrote:
 Hello,
 
 This forum has been very helpful to me in the past, and I've run out of ideas 
 on how to solve my problem.
 
 I had been using R and MySQL (and Perl) together for quite some time 
 successfully on my Windows XP machine. However, I recently had some problems 
 with MySQL (the ibdata file had become 35GB on my hard drive, turns out it's 
 a known bug with InnoDB), and ultimately the way I fixed my problem with 
 MySQL was to upgrade it.  It's working fine now, I can use MySQL however I'd 
 like.  I'm sticking to MyISAM tables for now, though.
 
 However, I had set up my system so I did a linear regression in R. 
 Originally, this was done in R 2.5.0, I would load in the tables from MySQL 
 to R and then conduct the regression in R.  However, after solving my MySQL 
 problem, I ran into a strange error in R (and DBI/RMySQL).  R connected to 
 the database just fine, and I could even show the tables in the database and 
 load two of them into R.  However, the tables I loaded successfully were only 
 a single column.  Every time I tried to load in a recordset that was multiple 
 columns, I got a relatively nondescript Windows error(R for Windows terminal 
 front-end has encountered a problem and needs to close.  We are sorry for the 
 inconvenience.).  To verify that it wasn't a memory issue,  I even tried rs 
 - dbSendQuery(con, select 'a', 'b').  This statement causes the error as 
 well.
 
 I tried upgrading the packages, and upgrading R from 2.5.0 to 2.8.1.  
 However, I still get the same errors.  Has anyone run into this problem 
 before?  Any suggestions on how to solve it?


Hi Aaron,

Be sure to read the details of the RMySQL web page:

http://biostat.mc.vanderbilt.edu/RMySQL

You need to make sure and match the version of your MySQL client library (not 
the running MySQL server) with the RMySQL binary that you choose from the web 
page above.

Best,

Jeff
-- http://biostat.mc.vanderbilt.edu/JeffreyHorner



  
[[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] array manipulation simple questions

2009-02-23 Thread jdeisenberg


Λεωνίδας Μπαντής wrote:
  
 1.   Suppose I have a-c(1:10)  (or a-array(c(1:10),dim=c(1,10)))
  
 and I want to end up with vector b=[0 0 0 0 0 1 1 1 1 1]. i.e. I want to
 substitute alla elements that are 5 with 0 and 5 with 1.
 

I think you mean =5, not  5.  In that case, try this:

b - ifelse( a  5, 0, 1) 
 

Λεωνίδας Μπαντής wrote:
 
 2.  Suppose I have a-c(1,1,2,2,3,3)  (or array again)
  
 And I want to place a 4,5 before every 2 and end up with a new
 bigger vector b:
  
 b=[1 1 4 5 2 4 5 2 3 3]
  
 Also I want to find where the 2's in array a (if it was an array) are
 located i.e. positions 3,4.
 

Not sure how to insert the 4,5, but this will find the where the 2's are:
which(a == 2)



-- 
View this message in context: 
http://www.nabble.com/array-manipulation-simple-questions-tp22173710p22175864.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.


  1   2   >