Re: [R] R help on write.csv

2011-09-22 Thread Ashish Kumar
IS there a way we can append row wise, so that it all stacks up
horizontally, the way you do it in xlswrite in matlab, where you can even
specify the cell number from where you want to write.

-Ashish

 

From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] 
Sent: Thursday, September 22, 2011 12:03 AM
To: Jan van der Laan
Cc: r-help@r-project.org; ashish.ku...@esteeadvisors.com
Subject: Re: [R] R help on write.csv

 

Oh darn, I had that line and then when I copied it to gmail I thought I'd be
all slick and clean up my code: oh well...just not my day/thread...

It's possible to work around the repeated headers business (change to
something like Call$col.names - !append) but yeah, at this point I'm
thinking its perhaps better practice to direct the OP to the various
connection methods: sink() is nice, but he'll probably have to do something
to convert his object to a CSV like string before printing: 

apply(OBJ, 1, paste, sep=,)

Michael Weylandt

On Wed, Sep 21, 2011 at 11:20 AM, Jan van der Laan e...@dds.nl wrote:

Michael,

You example doesn't seem to work. Append isn't passed on to the write.table
call. You will need to add a

 Call$append- append

to the function. And even then there will be a problem with the headers that
are repeated when appending.


An easier solution is to use write.table directly (I am using Dutch/European
csv format):

data - data.frame(a=1:10, b=1, c=letters[1:10])
write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE,
col.names=TRUE)
write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE,
col.names=FALSE,
append=TRUE)


When first openening a file connection and passing that to write.csv or
write.table data is also appended. The problem with write.csv is that
writing the column names can not be suppressed which will result in repeated
column names:

con - file(d:test2.csv, wt)
write.csv2(data, file=con, row.names=FALSE)
write.csv2(data, file=con, row.names=FALSE)
close(con)

So one will still have to use write.table to avoid this:

con - file(d:test2.csv, wt)
write.table(data, file=con, sep=;, dec=,, row.names=FALSE,
col.names=TRUE)
write.table(data, file=con, sep=;, dec=,, row.names=FALSE,
col.names=FALSE,
append=TRUE)
close(con)

Using a file connection is probably also more efficient when doing a large
number of appends.

Jan









Quoting R. Michael Weylandt michael.weyla...@gmail.com:

Touche -- perhaps we could make one though?

write.csv.append - function(..., append = TRUE)
{
   Call - match.call(expand.dots = TRUE)
   for (argname in c(col.names, sep, dec, qmethod)) if
(!is.null(Call[[argname]]))
   warning(gettextf(attempt to set '%s' ignored, argname),
   domain = NA)
   rn - eval.parent(Call$row.names)
   Call$col.names - if (is.logical(rn)  !rn)
   TRUE
   else NA
   Call$sep - ,
   Call$dec - .
   Call$qmethod - double
   Call[[1L]] - as.name(write.table)
   eval.parent(Call)
}
write.csv.append(1:5,test.csv, append = FALSE)
write.csv.append(1:15, test.csv)

Output seems a little sloppy, but might work for the OP.

Michael Weylandt

On Wed, Sep 21, 2011 at 9:03 AM, Ivan Calandra ivan.calan...@uni-hamburg.de

wrote:

 

I don't think there is an append argument to write.csv() (well, actually
there is one, but set to FALSE).
There is however one to write.table()
Ivan

Le 9/21/2011 14:54, R. Michael Weylandt michael.weyla...@gmail.com a
écrit :

 The append argument of write.csv()?


Michael

On Sep 21, 2011, at 8:01 AM, Ashish Kumarashish.kumar@**

esteeadvisors.com ashish.ku...@esteeadvisors.com  wrote:

 Hi,




I wanted to write the data created using R  on existing csv file. However
everytime I use write.csv, it overwrites the values already there in the
existing csv file. Any workaround on this.



Thanks for your help



Ashish Kumar



Estee Advisors Pvt. Ltd.

Email: ashish.ku...@esteeadvisors.com

Cell: +91-9654072144 tel:%2B91-9654072144 

Direct: +91-124-4637-713 tel:%2B91-124-4637-713 




  [[alternative HTML version deleted]]

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

https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/
listinfo/r-help


PLEASE do read the posting guide http://www.R-project.org/**

posting-guide.html 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-helphttps://stat.ethz.ch/mailman/
listinfo/r-help


PLEASE do read the posting guide http://www.R-project.org/**

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


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



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Dept. Mammalogy
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231 tel:%2B49%280%2940%2042838%206231 
ivan.calan...@uni-hamburg.de


Re: [R] R help on write.csv

2011-09-22 Thread Jan van der Laan
Rowwise is easy. The example code I gave does this: it appends the new 
data /below/ the old. I'll repeat the example below:


con - file(d:test2.csv, wt)
write.table(data, file=con, sep=;, dec=,, row.names=FALSE, 
col.names=TRUE)
write.table(data, file=con, sep=;, dec=,, row.names=FALSE, 
col.names=FALSE, append=TRUE)

close(con)

Or do you mean columnwise where you append columns? This would be very 
difficult in CSV. If you would like to do this you might have a look at 
the various options for exporting to Excel directly.  See for example 
http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows . I have 
no experience in this.


Regards,
Jan

PS I am sorry for my previous triple post. I had a little fight with my 
webmail client.



On 09/22/2011 06:14 AM, Ashish Kumar wrote:


IS there a way we can append row wise, so that it all stacks up 
horizontally, the way you do it in xlswrite in matlab, where you can 
even specify the cell number from where you want to write.


-Ashish

*From:*R. Michael Weylandt [mailto:michael.weyla...@gmail.com]
*Sent:* Thursday, September 22, 2011 12:03 AM
*To:* Jan van der Laan
*Cc:* r-help@r-project.org; ashish.ku...@esteeadvisors.com
*Subject:* Re: [R] R help on write.csv

Oh darn, I had that line and then when I copied it to gmail I thought 
I'd be all slick and clean up my code: oh well...just not my day/thread...


It's possible to work around the repeated headers business (change to 
something like Call$col.names - !append) but yeah, at this point 
I'm thinking its perhaps better practice to direct the OP to the 
various connection methods: sink() is nice, but he'll probably have to 
do something to convert his object to a CSV like string before printing:


apply(OBJ, 1, paste, sep=,)

Michael Weylandt

On Wed, Sep 21, 2011 at 11:20 AM, Jan van der Laan e...@dds.nl 
mailto:e...@dds.nl wrote:


Michael,

You example doesn't seem to work. Append isn't passed on to the 
write.table call. You will need to add a


 Call$append- append

to the function. And even then there will be a problem with the 
headers that are repeated when appending.



An easier solution is to use write.table directly (I am using 
Dutch/European csv format):


data - data.frame(a=1:10, b=1, c=letters[1:10])
write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE, 
col.names=TRUE)
write.table(data, file=test.csv, sep=;, dec=,, row.names=FALSE, 
col.names=FALSE,

append=TRUE)


When first openening a file connection and passing that to write.csv 
or write.table data is also appended. The problem with write.csv is 
that writing the column names can not be suppressed which will result 
in repeated column names:


con - file(d:test2.csv, wt)
write.csv2(data, file=con, row.names=FALSE)
write.csv2(data, file=con, row.names=FALSE)
close(con)

So one will still have to use write.table to avoid this:

con - file(d:test2.csv, wt)
write.table(data, file=con, sep=;, dec=,, row.names=FALSE, 
col.names=TRUE)
write.table(data, file=con, sep=;, dec=,, row.names=FALSE, 
col.names=FALSE,

append=TRUE)
close(con)

Using a file connection is probably also more efficient when doing a 
large number of appends.


Jan







Quoting R. Michael Weylandt michael.weyla...@gmail.com 
mailto:michael.weyla...@gmail.com:


Touche -- perhaps we could make one though?

write.csv.append - function(..., append = TRUE)
{
   Call - match.call(expand.dots = TRUE)
   for (argname in c(col.names, sep, dec, qmethod)) if
(!is.null(Call[[argname]]))
   warning(gettextf(attempt to set '%s' ignored, argname),
   domain = NA)
   rn - eval.parent(Call$row.names)
   Call$col.names - if (is.logical(rn)  !rn)
   TRUE
   else NA
   Call$sep - ,
   Call$dec - .
   Call$qmethod - double
   Call[[1L]] - as.name http://as.name(write.table)
   eval.parent(Call)
}
write.csv.append(1:5,test.csv, append = FALSE)
write.csv.append(1:15, test.csv)

Output seems a little sloppy, but might work for the OP.

Michael Weylandt

On Wed, Sep 21, 2011 at 9:03 AM, Ivan Calandra
ivan.calan...@uni-hamburg.de mailto:ivan.calan...@uni-hamburg.de

wrote:

I don't think there is an append argument to write.csv()
(well, actually
there is one, but set to FALSE).
There is however one to write.table()
Ivan

Le 9/21/2011 14:54, R. Michael Weylandt
michael.weyla...@gmail.com mailto:michael.weyla...@gmail.com a
écrit :

 The append argument of write.csv()?


Michael

On Sep 21, 2011, at 8:01 AM, Ashish Kumarashish.kumar@**

esteeadvisors.com http://esteeadvisors.com
ashish.ku...@esteeadvisors.com
mailto:ashish.ku...@esteeadvisors.com  wrote:

 Hi,




I wanted to write the data created using R  on existing
csv file. However
everytime I use write.csv, it overwrites the values
 

Re: [R] Error: cannot allocate vector of size xxx

2011-09-22 Thread Paul Hiemstra
 On 09/22/2011 04:00 AM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
 Are you running a 32bit or 64bit version of R? Type sessionInfo() to see. 

 Michael

...in addition, how large is your dataset? Please provide us with a self
contained example which reproduces this problem. You could take a look
at the biglm package.

regards,
Paul

 On Sep 21, 2011, at 10:41 PM, Mario Montecinos Carvajal 
 mariomonteci...@gmail.com wrote:

 Hi

 I am a new user of the mail list.

 Mi problem occurs when I try to test a lineal model (lm), becouse appear the
 messaje Error: cannot allocate vector of size xxx

 The data frame whit I am working, Have

 dim(d)
 [1] 7017411

 and the function i am test is:

 lm(length~as.factor(age)*as.factor(year)*as.factor(sex)*soi*k,data=d[d$age
 %in% minage:maxage,])

 I tried with a diferent options for solve this problem, but any one give me
 results.

 I tried with:

 Change in Function: memory.limit(size=4000)

 Change the setting in Windows using  BCDEdit /set

 Change in the memory availability for R, change the path of the program
 (suggested for other user)

 My computer have 4GB RAM, Have 20 GB of Virtual Memory, HDD 300 GB with 200
 GB of free space and Windows 7 as OS and my R version is 2.11.1

 I need solve this problem, any help or suggestion will be very well
 received.

 I've been thinking in change the OS, but this is may last option.

 Regards

 I read


 -- 
 Mario Montecinos C.
 Biologo Marino
 Dr (c) en Ciencias
 Universidad Austral de Chile


 Los acentos han sido omitidos voluntariamente para evitar incompatibilidades
 Evite enviar cartas impresas, cuidemos el medio ambiente y evitemos el
 uso innecesario de papel.

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


-- 
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

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


Re: [R] Limitations of audio processing in R

2011-09-22 Thread Uwe Ligges

Or if people want to do it the R way:

Use the tuneR package and its readWave function that supports reading 
parts of Wave files if the whole file is not relevant. You can specify 
it in many units, see its help page. tuneR has also the tools to cut, 
merge etc. Wave files and analyse it with basic tools.


If you want to deal with the whole thing in R: In CD quality this is 
roughly 2GB: 3 hours x 60 minutes x 60 seconds x 44100 samples x 2 
channels x 2 bytes and you need at least 6 GB to do sensible things with it.


Best,
Uwe Ligges








On 22.09.2011 00:26, Ulisses Camargo wrote:

Dear Ted,
Thank you very much about your answer, it really helped. Now I am working on
the function that will do all the job with sox help.
All the best,
Ulisses

2011/9/21 Ted Hardingted.hard...@wlandres.net


Hi Ulisses!
Yes, get more creative -- or get more memory!

On the creative side, it may be worth thinking about
using an independent (non-R) audio file editor. I'm
writing from the standpoint of a Linux/Unixoid user
here -- I wouldn;t know how to set ebout this in WIndows.

You could use R to create a shell script which would run
the editor in such a way as to extract your 6 random samples,
and save them, where the script would be fed with the
randomly-chosen 5-minute intervals decided by R. This
could be done under the control of R, so you could set
it up for your 1500 or so sets of samples, which (with
the right editing program) could be done quite quickly.

On Linux (also available for Windows) a flexible audio
editor is 'sox' -- see:

  http://en.wikipedia.org/wiki/SoX

To take, say, a 5-minute sample starting at 1 hour,
10 min and 35sec into the audio file infile.wav,
and save this as outfile.wav, you can execute

  sox infile.wav outfile.wav trim 01:10:35 00:05:00

and such a command could easily be generated by R and
fed to a shell script (or simply executed from R by
using the system() command). My test just now with
a 5-minute long sample from a .wav file was completed
in about 5 seconds, so it is quite efficient.

There is a huge number of options for 'sox', allowing
you to manipulate almost any aspect of the editing.

Hoping this helps,
Ted.


On 21-Sep-11 19:55:22, R. Michael Weylandt wrote:

If you are running Windows it may be as simple as using
memory.limit() to allow R more memory -- if you are on
another OS, it may be possible to get the needed memory
by deleting various things in your workspace and running
gc()

Of course, if your computer's memory is3GB, you are
probably going to have trouble with R's keeping all objects
in memory and will have to get more creative.

Michael

On Wed, Sep 21, 2011 at 3:43 PM, Ulisses.Camargo
moliterno.cama...@gmail.com  wrote:


Hello everybody

I am trying to process audio files in R and had some problems
with files size. I惴 using R packages 'audio' and 'sound'.
I惴 trying a really simple thing and it is working well with
small sized .wav files. When I try to open huge audio files
I received this error message: cannot allocate vector of
size 2.7 Gb. My job is open in R a 3-hour .wav file, make six
5-minute random audio subsamples, and than save these new files.
I have to do the same process +1500 times. My problems is not
in build the function to do the job, but in oppening the 3-hour
files. Does anybody knows how to handle big audio files in R?
Another package that allows me to do this work? I believe
this is a really simple thing, but I really donæ„’ know what
to do to solve that memory problem.

Thank you very much for your answers,
all the best!

Ulisses



E-Mail: (Ted Harding)ted.hard...@wlandres.net
Fax-to-email: +44 (0)870 094 0861
Date: 21-Sep-11   Time: 22:05:55
-- XFMail --







__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] comparing mixed binomial model against the same model without random effect

2011-09-22 Thread Simone Santoro

Hi everybody,

If I am correct, you can compare a model with random effect with the same model 
without the random effect by using the nlme function, like this:

no.random.model - gls(Richness ~ NAP * fExp,
  method = REML, data = RIKZ)
random.model - lme(Richness ~NAP * fExp, data = RIKZ,
  random = ~1 | fBeach, method = REML)
anova(no.random.model,random.model)

But, nlme is valid only for the gaussian family, isn't it? In my case I have a 
mixed model with binomial family, like this:

random.model - lme(sex ~hwp+hcp, data = mydata,

  random = ~1 | colony, method = REML)

where sex is a binary variable, hwp and hcp are continuous variable and 
colony is a factor with two levels.
I want to compare this model with another one without the random effect, I have 
tried with the lme4 but after this I cannot figure out how to build this same 
model without the random effect in order to make it comparable to the random 
effect model.

Thanks for any help.
Simone  

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

2011-09-22 Thread Den Alpin
Hi Hadley,
have a look at:

http://www.riani.it/pub/zrc-csda98.pdf
and some Gauss code:
http://www.riani.it/Gauss/procedures/BOXPLOTB.G

Best regards,
Daniele


2011/9/21 Hadley Wickham had...@rice.edu:
 Hi all,

 Does anyone have an R implementation of the queplot (K. M. Goldberg
 and B. Iglewicz. Bivariate extensions of the boxplot. Technometrics,
 34(3):pp. 307–320, 1992)?  I'm struggling with the estimation of the
 asymmetry parameters.

 Hadley

 --
 Assistant Professor / Dobelman Family Junior Chair
 Department of Statistics / Rice University
 http://had.co.nz/

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


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


Re: [R] Reading data in lisp format

2011-09-22 Thread ESTEBAN ALFARO CORTES
Thanks David,

The crx.data is a different database and I would like to use both. I have 
contacted with the developer but he has not answered me.

Regards,

Esteban




De: David Winsemius [mailto:dwinsem...@comcast.net]
Enviado el: mié 21/09/2011 17:08
Para: ESTEBAN ALFARO CORTES
CC: r-help@r-project.org
Asunto: Re: [R] Reading data in lisp format





If you think that R is loosely typed, then examining LiSP code will 
change your mind, or at least give you a new data point further out on 
the Loose-Tight axis. I think you will need to do the processing by 
hand.

The organization of the data is fairly clear. There are logical 
columns with values :neg and :pos, categorical columns with values in 
(id value) pairs, numeric ones and then a group of computed columns 
at the bottom. It also appears that after the first enumeration of ids 
with logical values that subsequent logical variables are defined 
possibly with pos: values only.

So I guess the counter-question is: How important is this particular 
dataset to you??

And  further question might be, are you sure that you don't want the 
dataset that is right next to it: 
ftp://ftp.ics.uci.edu/pub/machine-learning-databases/credit-screening/crx.data

It is well-behaved comma-separated file.
--
David.

On Sep 21, 2011, at 6:39 AM, ESTEBAN ALFARO CORTES wrote:

 Hi,

 I am trying to read the credit.lisp file of the Japanese credit 
 database in UCI repository, but it is in lisp format which I do not 
 know how to read.  I  have not found how to do that in the foreign 
 library

 http://archive.ics.uci.edu/ml/datasets/Japanese+Credit+Screening 
 http://archive.ics.uci.edu/ml/datasets/Japanese+Credit+Screening 
 

 Could anyone help me?

 Best regards,

 Esteban Alfaro

 PS: This is my first time in r-help so I apologize for possible 
 inconveniences.




   [[alternative HTML version deleted]]

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

David Winsemius, MD
West Hartford, CT




[[alternative HTML version deleted]]

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


Re: [R] R-help Digest, Vol 103, Issue 21

2011-09-22 Thread mihalicza . peter
Szeptember 12-től 26-ig irodán kívül vagyok, és az emailjeimet nem érem el.

Sürgős esetben kérem forduljon Kárpáti Edithez (karpati.e...@gyemszi.hu).

Üdvözlettel,
Mihalicza Péter


I will be out of the office from 12 till 26 September with no access to my 
emails.

In urgent cases please contact Ms. Edit Kárpáti (karpati.e...@gyemszi.hu).

With regards,
Peter Mihalicza

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


Re: [R] Reading data in lisp format

2011-09-22 Thread ESTEBAN ALFARO CORTES
Thanks Cesar, 
Any idea for this contents of the file?
 
 

;; positive examples represent people that were granted credit

(def-pred credit_screening :type (:person) 

  :pos

  ((s1) (s2) (s4) (s5) (s6) (s7) (s8) (s9) (s14) (s15) (s17) (s18) (s19)

   (s21) (s22) (s24) (s28) (s29) (s31) (s32) (s35) (s38) (s40) (s41)

   (s42) (s43) (s45) (s46) (s47) (s49) (s50) (s51) (s53) (s54) (s55)

   (s56) (s57) (s59) (s61) (s62) (s63) (s64) (s65) (s66) (s69) (s70)

   (s71) (s72) (s73) (s74) (s75) (s76) (s77) (s78) (s79) (s80) (s81)

   (s83) (s84) (s85) (s86) (s87) (s89) (s90) (s91) (s92) (s93) (s94)

   (s96) (s97) (s98) (s100) (s103) (s104) (s106) (s108) (s110) (s116)

   (s117) (s118) (s119) (s121) (s122) (s123) (s124))

  :neg

  ((s3) (s10) (s11) (s12) (s13) (s16) (s20) (s23) (s25) (s26) (s27) 

   (s30) (s33) (s34) (s36) (s37) (s39) (s44) (s48) (s52) (s58) (s60)

   (s67) (s68) (s82) (s88) (s95) (s99) (s101) (s102) (s105) (s107)

   (s109) (s111) (s112) (s113) (s114) (s115) (s120) (s125)))

 

(def-pred jobless :type (:person) :pos

  ((s3) (s10) (s12) (s23) (s34) (s39) (s44) (s56) (s60) (s82) (s85) (s88)

   (s99) (s115)))

 

;; item purchased that loan is for.

(def-pred purchase_item  :type (:person :atom) :pos

  ((s1 pc) (s2 pc) (s3 pc) (s4 pc) (s5 pc) (s6 pc) (s7 pc) (s8 pc) 

   (s9 pc) (s10 pc) (s11 car) (s12 car) (s13 car) (s14 car) (s15 car) 

   (s16 car) (s17 car) (s18 car) (s19 car) (s20 car) (s21 stereo)

   (s22 stereo) (s23 stereo) (s24 stereo) (s25 stereo) (s26 stereo) 

   (s27 stereo) (s28 stereo) (s29 stereo) (s30 stereo) (s31 stereo) 

   (s32 stereo) (s33 stereo) (s34 stereo) (s35 stereo) (s36 stereo) 

   (s37 stereo) (s38 stereo) (s39 stereo) (s40 stereo) (s41 stereo) 

   (s42 jewel) (s43 jewel) (s44 jewel) (s45 jewel) (s46 jewel) 

   (s47 jewel) (s48 jewel) (s49 jewel) (s50 jewel) (s51 jewel) 

   (s52 jewel) (s53 jewel) (s54 jewel) (s55 jewel) (s56 jewel) 

   (s57 jewel) (s58 jewel) (s59 jewel) (s60 jewel) (s61 jewel) 

   (s62 jewel) (s63 medinstru) (s64 medinstru) (s65 medinstru) 

   (s66 medinstru) (s67 medinstru) (s68 medinstru) (s69 medinstru) 

   (s70 medinstru) (s71 medinstru) (s72 medinstru) (s73 medinstru) 

   (s74 medinstru) (s75 medinstru) (s76 medinstru) (s77 medinstru) 

   (s78 medinstru) (s79 medinstru) (s80 medinstru) (s81 medinstru) 

   (s82 medinstru) (s83 medinstru) (s84 jewel) (s85 stereo)

   (s86 medinstru) (s87 stereo) (s88 stereo) (s89 stereo) 

   (s90 stereo) (s91 stereo) (s92 medinstru) (s93 medinstru) 

   (s94 medinstru) (s95 medinstru) (s96 jewel) (s97 jewel) 

   (s98 jewel) (s99 jewel) (s100 jewel) (s101 jewel) (s102 jewel) 

   (s103 jewel) (s104 jewel) (s105 jewel) (s106 bike) 

   (s107 bike) (s108 bike) (s109 bike) (s110 bike) (s111 bike) 

   (s112 bike) (s113 bike) (s114 bike) (s115 bike) (s116 furniture) 

   (s117 furniture) (s118 furniture) (s119 furniture) 

   (s120 furniture) (s121 furniture) (s122 furniture) 

   (s123 furniture) (s124 furniture) (s125 furniture)))

 

(def-pred male :type (:person) :pos

  ((s6) (s7) (s8) (s9) (s10) (s16) (s17) (s18) (s19) (s20) (s21) (s22)

   (s25) (s27) (s29) (s37) (s38) (s39) (s40) (s41) (s42) (s43) (s45)

   (s48) (s49) (s51) (s58) (s59) (s60) (s61) (s62) (s68) (s69) (s70)

   (s71) (s72) (s74) (s76) (s77) (s79) (s80) (s82) (s84) (s86) (s89)

   (s90) (s91) (s92) (s94) (s97) (s98) (s102) (s103) (s104) (s105) (s106)

   (s107) (s108) (s109) (s110) (s121) (s122) (s123) (s124) (s125)))

 

(def-pred female :type (:person) :pos

  ((s1) (s2) (s3) (s4) (s5) (s11) (s12) (s13) (s14) (s15) (s23) (s24) (s26)

   (s28) (s30) (s31) (s32) (s33) (s34) (s35) (s36) (s44) (s46) (s47) (s50)

   (s52) (s53) (s54) (s55) (s56) (s57) (s63) (s64) (s65) (s66) (s67) (s73)

   (s75) (s78) (s81) (s83) (s85) (s87) (s88) (s93) (s95) (s96) (s99) (s100)

   (s101) (s111) (s112) (s113) (s114) (s115) (s116) (s117) (s118) (s119)

   (s120)))

 

(def-pred unmarried :type (:person) :pos

  ((s1) (s2) (s5) (s6) (s7) (s11) (s13) (s14) (s16) (s18) (s22) (s25) (s26)

   (s28) (s30) (s31) (s32) (s33) (s34) (s37) (s41) (s43) (s46) (s48) (s50)

   (s52) (s53) (s54) (s55) (s59) (s60) (s63) (s68) (s70) (s74) (s75) (s76)

   (s78) (s82) (s84) (s86) (s87) (s90) (s93) (s95) (s96) (s97) (s100) (s101)

   (s102) (s104) (s105) (s106) (s107) (s108) (s109) (s114) (s118) (s123)))

 

;; people who live in a problematic region

(def-pred problematic_region :type (:person) :pos

  ((s3) (s5) (s23) (s30) (s33) (s39) (s48) (s60) (s68) (s72) (s76) (s78) 

   (s84) (s105)))

 

(def-pred age :type (:person :number) :pos

  ((s1 18) (s2 20) (s3 25) (s4 40) (s5 50) (s6 18) (s7 22)

   (s8 28) (s9 40) (s10 50) (s11 18) (s12 20) (s13 25) 

   (s14 38) (s15 50) (s16 19) (s17 21) (s18 25) (s19 38) 

   (s20 50) (s21 42) (s22 28) (s23 55) (s24 21) (s25 81) 

   (s26 23) (s27 35) (s28 47) (s29 98) (s30 68) (s31 27) 

   (s32 19) (s33 23) (s34 25) (s35 31) (s36 34) (s37 20) 

   (s38 32) (s39 38) (s40 45) (s41 57) (s42 25) (s43 42) 

   (s44 61) (s45 48) 

[R] Subsetting a zooreg object using window / subset

2011-09-22 Thread Wesley Roberts
Dear R users,


I am currently working in subsetting a zooreg() object using either window or 
subset. I have a solution but it may be a bit cumbersome when I start working 
with actual data. Your inputs would be greatly appreciated.

Example: I have a zooreg() object that starts in 1997 and ends in 2001. This 
object contains daily data for the 4 years

aa-zooreg(1:1825,start=as.Date(1997-01-01))

My aim is to subset the data according to seasons (Southern Hemisphere) for 
continuous years: December - January - February (DJF-Summer: 1997-2001), March 
- April - May (MAM-Autumn: 1997-2001), June - July - August (JJA-Winter: 
1997-2001), September - October - November (SON-Spring: 1997-2001) thereby 
analysing the seasons data only for all years. The example below is only for 
DJF but I would like to replicate the analysis for each season.

My solution so far uses subset to select the monthly data for each year and 
then rbind() the results.

bb - subset(aa, 
index(aa)=as.Date(1998-12-01)index(aa)=as.Date(1999-02-28))
cc - subset(aa, 
index(aa)=as.Date(1999-12-01)index(aa)=as.Date(2000-02-28))
dd - subset(aa, 
index(aa)=as.Date(2000-12-01)index(aa)=as.Date(2001-02-28))

ee- rbind(bb,cc,dd)

The method above appears to do the job just fine except that I have around 30 
locations (catchments) each with varying data availability and some with over 
20 years worth of data. Ideally I would like to combine the second set of 
commands into a single command where I specify the start and end year and the 
months that I am interested in.

Any advice on this matter would be greatly appreciated.

Many thanks and kind regards,
Wesley

Wesley Roberts PhD.
Researcher: Earth Observation
Natural Resources  the Environment (NRE)
CSIR
Tel: +27 (0)21 888-2490
Fax: +27 (0)21 888-2693
skype: roberts-w
 
 



-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail 
legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at 
http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.

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

2011-09-22 Thread pallavi dhage
Hi

Interested in learning  R programming via workshop/short course in India. 
Request all to suggest any.
[[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] Subsetting a zooreg object using window / subset

2011-09-22 Thread Gabor Grothendieck
On Thu, Sep 22, 2011 at 6:48 AM, Wesley Roberts wrobe...@csir.co.za wrote:
 Dear R users,


 I am currently working in subsetting a zooreg() object using either window or 
 subset. I have a solution but it may be a bit cumbersome when I start working 
 with actual data. Your inputs would be greatly appreciated.

 Example: I have a zooreg() object that starts in 1997 and ends in 2001. This 
 object contains daily data for the 4 years

 aa-zooreg(1:1825,start=as.Date(1997-01-01))

 My aim is to subset the data according to seasons (Southern Hemisphere) for 
 continuous years: December - January - February (DJF-Summer: 1997-2001), 
 March - April - May (MAM-Autumn: 1997-2001), June - July - August 
 (JJA-Winter: 1997-2001), September - October - November (SON-Spring: 
 1997-2001) thereby analysing the seasons data only for all years. The example 
 below is only for DJF but I would like to replicate the analysis for each 
 season.

 My solution so far uses subset to select the monthly data for each year and 
 then rbind() the results.

 bb - subset(aa, 
 index(aa)=as.Date(1998-12-01)index(aa)=as.Date(1999-02-28))
 cc - subset(aa, 
 index(aa)=as.Date(1999-12-01)index(aa)=as.Date(2000-02-28))
 dd - subset(aa, 
 index(aa)=as.Date(2000-12-01)index(aa)=as.Date(2001-02-28))

 ee- rbind(bb,cc,dd)

 The method above appears to do the job just fine except that I have around 30 
 locations (catchments) each with varying data availability and some with over 
 20 years worth of data. Ideally I would like to combine the second set of 
 commands into a single command where I specify the start and end year and the 
 months that I am interested in.


This gives the season (1 = djf, 2 = mam, 3 = jja, 5 = son):

seas - as.numeric(format(as.yearqtr(as.yearmon(time(aa)) + 1/12), %q))

and this picks out djf:

aa[seas == 1]


-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] Reading data in lisp format

2011-09-22 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 22/09/11 10:13, ESTEBAN ALFARO CORTES wrote:
 Thanks David,
 
 The crx.data is a different database and I would like to use both.
 I have contacted with the developer but he has not answered me.

I would suggest talk to folks using emacs, as emacs is written in lisp
(well - elsisp)and particularly, especially the guys from org-mode
(http://orgmode.org/), because they deal with all kinds of languages
(including R) http://orgmode.org/worg/org-contrib/babel/. Very
helpfull mailing list (http://orgmode.org/index.html#sec-5-2).
I am quite sure, that somebody there should be able to help.

Rainer

 
 Regards,
 
 Esteban
 
 
 
 
 De: David Winsemius [mailto:dwinsem...@comcast.net] Enviado el:
 mié 21/09/2011 17:08 Para: ESTEBAN ALFARO CORTES CC: 
 r-help@r-project.org Asunto: Re: [R] Reading data in lisp format
 
 
 
 
 
 If you think that R is loosely typed, then examining LiSP code will
  change your mind, or at least give you a new data point further
 out on the Loose-Tight axis. I think you will need to do the
 processing by hand.
 
 The organization of the data is fairly clear. There are logical 
 columns with values :neg and :pos, categorical columns with values
 in (id value) pairs, numeric ones and then a group of computed 
 columns at the bottom. It also appears that after the first 
 enumeration of ids with logical values that subsequent logical 
 variables are defined possibly with pos: values only.
 
 So I guess the counter-question is: How important is this
 particular dataset to you??
 
 And  further question might be, are you sure that you don't want
 the dataset that is right next to it: 
 ftp://ftp.ics.uci.edu/pub/machine-learning-databases/credit-screening/crx.data


 
It is well-behaved comma-separated file. -- David.
 
 On Sep 21, 2011, at 6:39 AM, ESTEBAN ALFARO CORTES wrote:
 
 Hi,
 
 I am trying to read the credit.lisp file of the Japanese credit
  database in UCI repository, but it is in lisp format which I do
 not know how to read.  I  have not found how to do that in the
 foreign library
 
 http://archive.ics.uci.edu/ml/datasets/Japanese+Credit+Screening 
 http://archive.ics.uci.edu/ml/datasets/Japanese+Credit+Screening

 
 
 Could anyone help me?
 
 Best regards,
 
 Esteban Alfaro
 
 PS: This is my first time in r-help so I apologize for possible 
 inconveniences.
 
 
 
 
 [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the
 posting guide http://www.R-project.org/posting-guide.html and
 provide commented, minimal, self-contained, reproducible code.
 
 David Winsemius, MD West Hartford, CT
 
 
 
 
 [[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.


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :   +33 - (0)9 53 10 27 44
Cell:   +33 - (0)6 85 62 59 98
Fax :   +33 - (0)9 58 10 27 44

Fax (D):+49 - (0)3 21 21 25 22 44

email:  rai...@krugs.de

Skype:  RMkrug
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk57JDwACgkQoYgNqgF2egrnOwCfaHw0ayhVoNlqkDfbwx8lXFVW
AAcAnAwSyzlEK7eQJBnK0jMogIbLk64U
=b961
-END PGP SIGNATURE-

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


Re: [R] Subsetting a zooreg object using window / subset

2011-09-22 Thread Achim Zeileis

On Thu, 22 Sep 2011, Gabor Grothendieck wrote:


On Thu, Sep 22, 2011 at 6:48 AM, Wesley Roberts wrobe...@csir.co.za wrote:

Dear R users,


I am currently working in subsetting a zooreg() object using either window or 
subset. I have a solution but it may be a bit cumbersome when I start working 
with actual data. Your inputs would be greatly appreciated.

Example: I have a zooreg() object that starts in 1997 and ends in 2001. This 
object contains daily data for the 4 years

aa-zooreg(1:1825,start=as.Date(1997-01-01))

My aim is to subset the data according to seasons (Southern Hemisphere) for 
continuous years: December - January - February (DJF-Summer: 1997-2001), March 
- April - May (MAM-Autumn: 1997-2001), June - July - August (JJA-Winter: 
1997-2001), September - October - November (SON-Spring: 1997-2001) thereby 
analysing the seasons data only for all years. The example below is only for 
DJF but I would like to replicate the analysis for each season.

My solution so far uses subset to select the monthly data for each year and 
then rbind() the results.

bb - subset(aa, 
index(aa)=as.Date(1998-12-01)index(aa)=as.Date(1999-02-28))
cc - subset(aa, 
index(aa)=as.Date(1999-12-01)index(aa)=as.Date(2000-02-28))
dd - subset(aa, 
index(aa)=as.Date(2000-12-01)index(aa)=as.Date(2001-02-28))

ee- rbind(bb,cc,dd)

The method above appears to do the job just fine except that I have around 30 
locations (catchments) each with varying data availability and some with over 
20 years worth of data. Ideally I would like to combine the second set of 
commands into a single command where I specify the start and end year and the 
months that I am interested in.



This gives the season (1 = djf, 2 = mam, 3 = jja, 5 = son):

seas - as.numeric(format(as.yearqtr(as.yearmon(time(aa)) + 1/12), %q))


An alternative route might be to go via the mon component of POSIXlt, 
e.g.,


  as.POSIXlt(time(aa))$mon %in% c(11, 0, 1)

instead of

  seas == 1

etc.


and this picks out djf:

aa[seas == 1]


--
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] Error in as.vector(data) optim() / fkf()

2011-09-22 Thread Kristian Lind
Dear R users,

When running the program below I receive the following error message:
fit - optim(parm, objective, yt = tyield, hessian = TRUE)
Error in as.vector(data) :
  no method for coercing this S4 class to a vector

I can't figure out what the problem is exactly. I imagine that it has
something to do with tyield being a matrix.  Any help on explaining what's
going on and how to solve this is much appreciated.

Thank you,

Kristian

library(FKF) #loading Fast Kalman Filter package
library(Matrix) # matrix exponential package

K_1 = 0.1156
K_2 = 0.17
sigma_1 = 0.1896
sigma_2 = 0.2156
lambda_1 = 0
lambda_2 = -0.5316
theta_1 = 0.1513
theta_2 = 0.2055

#test data
tyield - matrix(data = rnorm(200), nrow =2, ncol =100)

# defining dimensions
m - 2 # m is the number of state variables
n - 100 # is the length of the observed sample
d - 2 # is the number of observed variables.
theta - c(theta_1, theta_2)
h - t - 1/52 # time between observations

## creating state space representation of 2-factor CIR model follwing
Driessen and Geyer et al.
CIR2ss - function(K_1, K_2, sigma_1, sigma_2, lambda_1, lambda_2, theta_1,
theta_2){
  ## defining auxilary parameters
phi_11 - sqrt((K_1+lambda_1)^2+2*sigma_1^2)
  phi_21 - sqrt((K_1+lambda_2)^2+2*sigma_2^2)
phi_12 - K_1+lambda_1+phi_11
phi_22 - K_2+lambda_2+phi_12
phi_13 - -2*K_1*theta_1/sigma_1^2
phi_23 - -2*K_2*theta_2/sigma_2^2
phi_14 - 2*phi_11+phi_21*(exp(phi_11*t)-1)
phi_24 - 2*phi_12+phi_22*(exp(phi_12*t)-1)
phi - array(c(phi_11, phi_21, phi_12, phi_22, phi_13, phi_23, phi_14,
phi_24), c(4,2))
a - array(0, c(d,n))
for(t in n:1){
  a[,n-(t+1)] -
-phi_13/(n-(t+1))*log(2*phi_11*exp(phi_12*(n-(t+1))/2)/phi_14)-phi_23/(n-(t+1))*log(2*phi_21*exp(phi_22*(n-(t+1))/2)/phi_24)
}
b - array(c(1,0,0,1,0), c(d,m,n))
j - -array(c(K_1, 0, 0, K_2), c(2,2))*h
explh - expm(j)
Tt - array(explh, c(m,m,n)) #array giving the factor of the transition
equation
Zt - b #array giving the factor of the measurement equation
ct - a #matrix giving the intercept of the measurement equation
dt - (diag(m)-expm(-array(c(K_1, 0, 0, K_2), c(2,2))*h))*theta #matrix
giving the intercept of the transition equation
GGt - array(c(1,0,0,1), c(d,d,n)) #array giving the variance of the
disturbances of the measurement equation
HHt - array(c(1,0,0,1), c(m,m,n)) #array giving the variance of the
innovations of the transition equation
a0 - c(0, 0) #vector giving the initial value/estimation of the state
variable
P0 - matrix(1e6, nrow = 2, ncol = 2) # matrix giving the variance of a0
return(list(a0 = a0, P0 = P0, ct = ct, dt = dt, Zt = Zt, Tt = Tt, GGt =
GGt,
HHt = HHt))
}

## Objective function passed to optim
objective - function(parm, yt) {
  sp - CIR2ss(parm[K_1], parm[K_2], parm[sigma_1], parm[sigma_2],
parm[lambda_1], parm[lambda_2],
   parm[theta_1], parm[theta_2])
  ans - fkf(a0 = sp$a0, P0 = sp$P0, dt = sp$dt, ct = sp$ct, Tt = sp$Tt,
   Zt = sp$Zt, HHt = sp$HHt, GGt = sp$GGt, yt = yt)
  return(-ans$loglik)
}

parm - c(K_1 = 0.1156, K_2 = 0.17, sigma_1 = 0.1896, sigma_2 = 0.2156,
  lambda_1 = 0, lambda_2 = -0.5316, theta_1 = 0.1513, theta_2 =
0.2055) # initial parameters

##optimizing objective function
 fit - optim(parm, objective, yt = tyield, hessian = TRUE)
 print(fit)

[[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 in interpreting paired t-test

2011-09-22 Thread S Ellison
Late, I know, but if method comparison id the interest, the methcomp package on 
CRAN does Bland-Altman plots and passing-Bablock regression, both clinical 
chemistry staples for method comparison.

S Ellison

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Pedro Mardones
 Sent: 21 September 2011 19:12
 To: Marc Schwartz
 Cc: R-help@r-project.org
 Subject: Re: [R] help in interpreting paired t-test
 
 Thanks for all the replies and comments. I've followed Marc's 
 suggestion of using the Bland-Altman's approach which I found 
 pretty clarifying for comparing data collected on the same subjects.
 
 BR,
 PM
 ***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


Re: [R] help in interpreting paired t-test

2011-09-22 Thread peter dalgaard

On Sep 21, 2011, at 18:39 , Marc Schwartz wrote:

 Jeremy,
 
 Correlation alone is irrelevant when comparing two separate sets of 
 measurements on the same specimen. Correlation does not mean good agreement, 
 but good agreement tends to infer high correlation.

Marc,

I think Jeremy is well aware of that. He just said that the power to detect a 
(small) difference is higher when the correlation is higher. (Since V(X-Y) = 
2*(1-rho)*sigma^2 if X and Y have the same variance sigma^2)

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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-installing R

2011-09-22 Thread Andrey A
Dear R users
How does one completely uninstall R from their machine? Going to control
panelprograms does not do it for me. After installing the new version it
will still remember my previous workspace and all packages I've installed.
Thank you.

[[alternative HTML version deleted]]

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


[R] Header auslesen und bei Regression verwenden

2011-09-22 Thread BiGBeN76
Hi.

 First, a little preliminary observation: in this thread, it is indeed a
(multiple linear) regression model, the real problem is but my opinion on
general questions about R assign.

 So as I said, I want to do a regression analysis, however, for several
target variables or data tables. This case, although the target variable is
always the same, but the data comes from different sectors, ie, I have
several data tables as covariates for different sectors, which can in size,
better said the number of columns or different covariates. All of these
tables but have a partially similar structure: in the first column gives the
metric target variable, (n is fixed) in the next n are the metrical
covariates and last m (m is variable) the categorical covariates can be
found. The data is read from the csv-table in a matrix MX as follows:

/MX - read.csv2(C://…/….csv, header=TRUE)/

The general R-code for stepwise linear regression is as follows:

/step(regr - lm(Zielvariable~
   Covariate_1
   + Covariate_2
   +…
   + Covariate_n
   +factor(Covariate_n+1)
   +factor(Covariate_n+2)
   +…
   +factor(Covariate_n+m)
   , data=MX))/

Here are the covariates, the column names and factor points to a
categorical covariate. I would like to make my program so that it would be
universally used for the analysis with each of these tables. To make it
work, so my idea must first be read the column headings. R may provide for a
more elegant, solution unknown to me, but I have it solved as follows:

/heads - dimnames(MX)[[2]]/

Now, the individual head - values ​​to get correct position as follows:

/step(regr - lm(heads[1]~
   heads[2]
   + heads[3]
   +…
   + heads[n]
   +factor(heads[n+1])
   +factor(heads[n+2])
   +…
   +factor(heads[n+m])
   , data=Matrix))/

, where n is a fixed number, and m = length (head)-n-1.

 I can well imagine how I could implement in MATLAB, but in R I'm no
professional and I hope for your help. Is there a way in the lm function a
for loop to integrate, or possibly to create an appropriate string and then
to take over the function? Or you may consider yourself, other alternative
solutions?

 In any case, I am happy about every suggestion and thank you in advance.

--
View this message in context: 
http://r.789695.n4.nabble.com/Header-auslesen-und-bei-Regression-verwenden-tp3833364p3833364.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] need help on melt/cast

2011-09-22 Thread Eugene Kanshin
Hello,
I need to convert dataframe from:

ID   T0   T1   T2
A1 2 3
B4 5 6
C7 8 9

to:

ID Variable Value
A   T0   1
A   T1   2
A   T2   3
B   T0   4
B   T1   5
B   T2   6
C   T0   7
C   T1   8
C   T2   9

i tried to use melt cast but it gives me all the time not exactly what I
need.
Thank you.

[[alternative HTML version deleted]]

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


Re: [R] Subsetting a zooreg object using window / subset

2011-09-22 Thread Wesley Roberts
Many thanks Gabor,

That is exactly what I needed.

Regards,
W.

 Gabor Grothendieck ggrothendi...@gmail.com 22/09/2011 13:52 
On Thu, Sep 22, 2011 at 6:48 AM, Wesley Roberts wrobe...@csir.co.za wrote:
 Dear R users,


 I am currently working in subsetting a zooreg() object using either window or 
 subset. I have a solution but it may be a bit cumbersome when I start working 
 with actual data. Your inputs would be greatly appreciated.

 Example: I have a zooreg() object that starts in 1997 and ends in 2001. This 
 object contains daily data for the 4 years

 aa-zooreg(1:1825,start=as.Date(1997-01-01))

 My aim is to subset the data according to seasons (Southern Hemisphere) for 
 continuous years: December - January - February (DJF-Summer: 1997-2001), 
 March - April - May (MAM-Autumn: 1997-2001), June - July - August 
 (JJA-Winter: 1997-2001), September - October - November (SON-Spring: 
 1997-2001) thereby analysing the seasons data only for all years. The example 
 below is only for DJF but I would like to replicate the analysis for each 
 season.

 My solution so far uses subset to select the monthly data for each year and 
 then rbind() the results.

 bb - subset(aa, 
 index(aa)=as.Date(1998-12-01)index(aa)=as.Date(1999-02-28))
 cc - subset(aa, 
 index(aa)=as.Date(1999-12-01)index(aa)=as.Date(2000-02-28))
 dd - subset(aa, 
 index(aa)=as.Date(2000-12-01)index(aa)=as.Date(2001-02-28))

 ee- rbind(bb,cc,dd)

 The method above appears to do the job just fine except that I have around 30 
 locations (catchments) each with varying data availability and some with over 
 20 years worth of data. Ideally I would like to combine the second set of 
 commands into a single command where I specify the start and end year and the 
 months that I am interested in.


This gives the season (1 = djf, 2 = mam, 3 = jja, 5 = son):

seas - as.numeric(format(as.yearqtr(as.yearmon(time(aa)) + 1/12), %q))

and this picks out djf:

aa[seas == 1]


-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com


-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail 
legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at 
http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.

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

2011-09-22 Thread Meredith Jantzen
Hello, 
 
I am having some difficulty converting my gam code to a correct gamm code, and 
I'm really hoping someone will be able to help me.   
 
I was previously using this script for my overdispersed gam data:
 
M30 -gam(efuscus~s(mic, k=7) +temp +s(date)+s(For3k, k=7) + pressure+ 
humidity, family=negbin(c(1,10)), data=efuscus)   
 
My gam.check gave me the attached result.  In order to deal with my 
heterogeneity, I need to switch over to a gamm structure and use at least one, 
but possibly multiple, variance structures, and I am starting by applying 
varPower to my temperature covariate.  (Efuscus is my square root transformed 
response variable).
  
Here is the code I have for the gamm:
 
K1 -(efuscus~s(mic, k=7) +temp +s(date)+s(For3k, k=7) + pressure+ humidity+ 
windspeed + year)
M17.4A -gamm(K1, method=REML, family=negbin(c(1,10), data=efuscus, 
weights=varPower(form=~temp)) 
 
With my various versions of the script, the two error messages I have been 
getting repeatedly are: Error in eval(expr, envir, enclos) : object 'temp' not 
found, and Error: unexpected symbol in: M17.4A -gamm(K1, method=REML, 
family=negbin(c(1,10), data=efuscus, weights=varPower(form=~temp)) 
 
I know I must be missing something obvious that is causing my script not to 
work...I've been looking at both Wood (2006) and Zuur's Mixed Models book for 
examples but none of them are completely the same as my situation, which is 
causing me to get tripped up.   
 
Am I defining my negative binomial family correctly for the situation?  Do I 
need to somehow define the variance term before I apply it?
 
Thank you very much.  I appreciate your time and patience. 
Meredith  
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-installing R

2011-09-22 Thread R. Michael Weylandt
You need to uninstall packages directly (they are kept independently of R,
which is actually quite helpful when updating so you don't have to get them
all anew): this can be done within R by combining remove.packages() and
installed.packages(). To delete the workspace you need to manually remove
the .Rdata folder in your start-up working directory.

Hope this helps

Michael

On Thu, Sep 22, 2011 at 8:47 AM, Andrey A ava...@gmail.com wrote:

 Dear R users
 How does one completely uninstall R from their machine? Going to control
 panelprograms does not do it for me. After installing the new version it
 will still remember my previous workspace and all packages I've installed.
 Thank you.

[[alternative HTML version deleted]]

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


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

2011-09-22 Thread Uwe Ligges



On 22.09.2011 14:47, Andrey A wrote:

Dear R users
How does one completely uninstall R from their machine? Going to control
panelprograms does not do it for me. After installing the new version it
will still remember my previous workspace and all packages I've installed.


This seems to be Windows?

remove.packages() removes packages. You found the way to uninstall the 
part that got installed, The uninstaller won't install stuff you 
installed independently (such as packages, additional config files). The 
workspace is just a file called .RData in your working directory. 
Since it is user data, the user has to delete it himself.
If you uninstall MS Word, it also won't remove all your .doc / .docx 
files - at least I hope so.


Uwe Ligges







Thank you.

[[alternative HTML version deleted]]

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


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


Re: [R] need help on melt/cast

2011-09-22 Thread Doran, Harold
?reshape

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Eugene Kanshin [kanshin...@gmail.com]
Sent: Thursday, September 22, 2011 9:54 AM
To: r-help@r-project.org
Subject: [R] need help on melt/cast

Hello,
I need to convert dataframe from:

ID   T0   T1   T2
A1 2 3
B4 5 6
C7 8 9

to:

ID Variable Value
A   T0   1
A   T1   2
A   T2   3
B   T0   4
B   T1   5
B   T2   6
C   T0   7
C   T1   8
C   T2   9

i tried to use melt cast but it gives me all the time not exactly what I
need.
Thank you.

[[alternative HTML version deleted]]

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

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


Re: [R] need help on melt/cast

2011-09-22 Thread Dimitris Rizopoulos

You can use function reshape(), e.g.,

DF - data.frame(ID = LETTERS[1:3],
T0 = c(1,4,7), T1 = c(2,5,8), T2 = c(3,6,9))

DF.new - reshape(DF, idvar = ID, direction = long,
varying = list(2:4), times = names(DF[-1]))
DF.new
DF.new[order(DF.new$ID), ]


I hope it helps.

Best,
Dimitris


On 9/22/2011 3:54 PM, Eugene Kanshin wrote:

Hello,
I need to convert dataframe from:

ID   T0   T1   T2
A1 2 3
B4 5 6
C7 8 9

to:

ID Variable Value
A   T0   1
A   T1   2
A   T2   3
B   T0   4
B   T1   5
B   T2   6
C   T0   7
C   T1   8
C   T2   9

i tried to use melt cast but it gives me all the time not exactly what I
need.
Thank you.

[[alternative HTML version deleted]]

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



--
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
Web: http://www.erasmusmc.nl/biostatistiek/

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


Re: [R] Header auslesen und bei Regression verwenden

2011-09-22 Thread Jeff Newmiller
If you explicitly convert your categorical covariates to factors before you 
regress, you can use the dot notation (see help on lm) to refer to the rest 
of the columns not otherwise specified in your formula.
---
Jeff Newmiller The . . Go Live...
DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

BiGBeN76 johann.ma...@gmx.de wrote:

Hi.

First, a little preliminary observation: in this thread, it is indeed a
(multiple linear) regression model, the real problem is but my opinion on
general questions about R assign.

So as I said, I want to do a regression analysis, however, for several
target variables or data tables. This case, although the target variable is
always the same, but the data comes from different sectors, ie, I have
several data tables as covariates for different sectors, which can in size,
better said the number of columns or different covariates. All of these
tables but have a partially similar structure: in the first column gives the
metric target variable, (n is fixed) in the next n are the metrical
covariates and last m (m is variable) the categorical covariates can be
found. The data is read from the csv-table in a matrix MX as follows:

/MX - read.csv2(C://…/….csv, header=TRUE)/

The general R-code for stepwise linear regression is as follows:

/step(regr - lm(Zielvariable~
Covariate_1
+ Covariate_2
+…
+ Covariate_n
+factor(Covariate_n+1)
+factor(Covariate_n+2)
+…
+factor(Covariate_n+m)
, data=MX))/

Here are the covariates, the column names and factor points to a
categorical covariate. I would like to make my program so that it would be
universally used for the analysis with each of these tables. To make it
work, so my idea must first be read the column headings. R may provide for a
more elegant, solution unknown to me, but I have it solved as follows:

/heads - dimnames(MX)[[2]]/

Now, the individual head - values ​​to get correct position as follows:

/step(regr - lm(heads[1]~
heads[2]
+ heads[3]
+…
+ heads[n]
+factor(heads[n+1])
+factor(heads[n+2])
+…
+factor(heads[n+m])
, data=Matrix))/

, where n is a fixed number, and m = length (head)-n-1.

I can well imagine how I could implement in MATLAB, but in R I'm no
professional and I hope for your help. Is there a way in the lm function a
for loop to integrate, or possibly to create an appropriate string and then
to take over the function? Or you may consider yourself, other alternative
solutions?

In any case, I am happy about every suggestion and thank you in advance.

--
View this message in context: 
http://r.789695.n4.nabble.com/Header-auslesen-und-bei-Regression-verwenden-tp3833364p3833364.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] need help on melt/cast

2011-09-22 Thread Uwe Ligges
I can never remember what melt, cast and all that means, hence I simpy 
use reshape() which does not even require any additional package:


reshape(dat, direction=long, idvar = ID,
  varying=list(2:4), v.names=Value, times=names(dat)[2:4])

Uwe Ligges


On 22.09.2011 15:54, Eugene Kanshin wrote:

Hello,
I need to convert dataframe from:

ID   T0   T1   T2
A1 2 3
B4 5 6
C7 8 9

to:

ID Variable Value
A   T0   1
A   T1   2
A   T2   3
B   T0   4
B   T1   5
B   T2   6
C   T0   7
C   T1   8
C   T2   9

i tried to use melt cast but it gives me all the time not exactly what I
need.
Thank you.

[[alternative HTML version deleted]]

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] the opposite of lag() in panel data

2011-09-22 Thread Cecilia Carmo
Hi R-helpers

 

I want a function that performs the opposite of lag() with panel data.

I have transformed my data before with pdata.frame(mydata,
index=c(groupindex, “timeindex))

And then I’ve done lag(mydata, -1) but it doesn’t work. 

 

The error message was:

Error in rep(1, ak) : invalid 'times' argument

 

Thank you in advance,

 

Cecília Carmo


[[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] the opposite of lag() in panel data

2011-09-22 Thread R. Michael Weylandt
Is there perhaps a particular package you are interested in here? I'm not
aware of a pdata.frame function... This certainly works with the xts
class. If you just mean a regular data.frame() perhaps some of the ideas in
this old thread will work with a little tweaking:
http://www.mail-archive.com/r-help@r-project.org/msg142805.html

Michael Weylandt

On Thu, Sep 22, 2011 at 10:36 AM, Cecilia Carmo cecilia.ca...@ua.pt wrote:

 Hi R-helpers



 I want a function that performs the opposite of lag() with panel data.

 I have transformed my data before with pdata.frame(mydata,
 index=c(groupindex, “timeindex))

 And then I’ve done lag(mydata, -1) but it doesn’t work.



 The error message was:

 Error in rep(1, ak) : invalid 'times' argument



 Thank you in advance,



 Cecília Carmo


[[alternative HTML version deleted]]


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



[[alternative HTML version deleted]]

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


Re: [R] negative binomial GAMM with variance structures

2011-09-22 Thread Simon Wood
gamm can't estimate the theta parameter for a negative binomial 
automatically. It can only work with fixed user supplied values for 
theta (i.e. negbin(2.3) should work, but negbin(c(1,10)) won't). Is 
negative binomial the only thing you can use here (it doesn't seem like 
the most natural choice for a variable that's  been sqrt transformed)?

Simon

ps. Your checking plot didn't come through --- you can send it offline, 
if you want.

On 09/22/2011 02:59 PM, Meredith Jantzen wrote:
 Hello,

 I am having some difficulty converting my gam code to a correct gamm code, 
 and I'm really hoping someone will be able to help me.

 I was previously using this script for my overdispersed gam data:

 M30-gam(efuscus~s(mic, k=7) +temp +s(date)+s(For3k, k=7) + pressure+ 
 humidity, family=negbin(c(1,10)), data=efuscus)

 My gam.check gave me the attached result.  In order to deal with my 
 heterogeneity, I need to switch over to a gamm structure and use at least 
 one, but possibly multiple, variance structures, and I am starting by 
 applying varPower to my temperature covariate.  (Efuscus is my square root 
 transformed response variable).

 Here is the code I have for the gamm:

 K1-(efuscus~s(mic, k=7) +temp +s(date)+s(For3k, k=7) + pressure+ humidity+ 
 windspeed + year)
 M17.4A-gamm(K1, method=REML, family=negbin(c(1,10), data=efuscus, 
 weights=varPower(form=~temp))

 With my various versions of the script, the two error messages I have been 
 getting repeatedly are: Error in eval(expr, envir, enclos) : object 'temp' 
 not found, and Error: unexpected symbol in: M17.4A-gamm(K1, method=REML, 
 family=negbin(c(1,10), data=efuscus, weights=varPower(form=~temp))

 I know I must be missing something obvious that is causing my script not to 
 work...I've been looking at both Wood (2006) and Zuur's Mixed Models book for 
 examples but none of them are completely the same as my situation, which is 
 causing me to get tripped up.

 Am I defining my negative binomial family correctly for the situation?  Do I 
 need to somehow define the variance term before I apply it?

 Thank you very much.  I appreciate your time and patience.
 Meredith


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


[[alternative HTML version deleted]]

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


[R] NLS- check convergence

2011-09-22 Thread Diviya Smith
Hi there,

I am having some trouble with NLS convergence for my function. I was
wondering if there is a way to check the value of the indicator function for
all the iterations to look at the surface of the likelihood function.

Any help would be most appreciated.

Thanks,
Diviya

[[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] the opposite of lag() in panel data

2011-09-22 Thread Cecilia Carmo
Yes, I want to it with plm package for panel data in dataframes.

 

Thank you,

 

Cecília Carmo

 

De: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] 
Enviada: quinta-feira, 22 de Setembro de 2011 16:06
Para: Cecilia Carmo
Cc: r-help@r-project.org
Assunto: Re: [R] the opposite of lag() in panel data

 

Is there perhaps a particular package you are interested in here? I'm not
aware of a pdata.frame function... This certainly works with the xts
class. If you just mean a regular data.frame() perhaps some of the ideas in
this old thread will work with a little tweaking:
http://www.mail-archive.com/r-help@r-project.org/msg142805.html

Michael Weylandt

On Thu, Sep 22, 2011 at 10:36 AM, Cecilia Carmo cecilia.ca...@ua.pt wrote:

Hi R-helpers



I want a function that performs the opposite of lag() with panel data.

I have transformed my data before with pdata.frame(mydata,
index=c(groupindex, “timeindex))

And then I’ve done lag(mydata, -1) but it doesn’t work.



The error message was:

Error in rep(1, ak) : invalid 'times' argument



Thank you in advance,



Cecília Carmo


   [[alternative HTML version deleted]]


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




[[alternative HTML version deleted]]

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


Re: [R] nlm's Hessian update method

2011-09-22 Thread John C Nash
BFGS is actually Fletcher's (1970) variable metric code that I modified with 
him in
January 1976 in Dundee and then modified very, very slightly (to insist that 
termination
only occurred on a steepest descent search -- this messes up the approximated 
inverse
Hessian, but I have an experimental Rvmminx in the optimization and solver 
project on
R-forge for those interested).

I haven't looked at the internals of nlm to judge the precise update used. 
However, the
code is there in R-2.13.1 under src/appl/uncmin.c, where at first glance a 
simple finite
difference approximation to the Hessian seems to be used. (numDeriv would 
likely do
better, even without the analytic gradient, because it uses an extrapolation 
process to
improve the approximation.)

Given that you do not have  a huge problem, it is likely safer to use numDeriv 
to compute
the Hessian when you need it, preferably using the Jacobian function on the 
(analytic)
gradient if the latter is available. That is what we do in optimx. Currently I 
am doing a
back to basics refactoring of optimx. The updated version is working, but I 
expect it
will be a few more weeks before I have a sufficiently comprehensive set of 
tests in place
and run. However, if someone is eager, I can provide access to the code 
earlier. Contact
me off-list. The existing version on CRAN works reasonably well, but the code 
was getting
too heavily patched.

John Nash



Date: Thu, 22 Sep 2011 12:15:41 +1000 From: Amy Willis amy.wil...@anu.edu.au 
To:
r-help@r-project.org Subject: [R] nlm's Hessian update method Message-ID:
343e6871-4564-4d9d-90f0-f2c9b30ea...@anu.edu.au Content-Type: text/plain;
charset=us-ascii Hi R-help! I'm trying to understand how R's nlm function 
updates its
estimate of the Hessian matrix. The Dennis/Schnabel book cited in the 
references presents
a number of different ways to do this, and seems to conclude that the 
positive-definite
secant method (BFGS) works best in practice (p201). However, when I run my code 
through
the optim function with the method as BFGS, slightly different estimates are 
produced to
that of nlm:
  optim(strt,jointll2,method=BFGS,hessian=T)$par
   -0.4016808 0.6057144 0.3744790-7.1819734 3.0230386 
0.4446641

  nlm(jointll2,strt,hessian=T)$estimate
[1] -0.4016825  0.6057159  0.3744765 -7.1819737  3.0230386  0.4446623

Can anyone tell me if nlm employs the BFGS method for updating its estimates? 
Or does it
use another algorithm?


Thank you!



--


On 09/22/2011 06:00 AM, r-help-requ...@r-project.org wrote:
 Date: Thu, 22 Sep 2011 12:15:41 +1000 From: Amy Willis 
 amy.wil...@anu.edu.au To:
 r-help@r-project.org Subject: [R] nlm's Hessian update method Message-ID:
 343e6871-4564-4d9d-90f0-f2c9b30ea...@anu.edu.au Content-Type: text/plain;
 charset=us-ascii Hi R-help! I'm trying to understand how R's nlm function 
 updates its
 estimate of the Hessian matrix. The Dennis/Schnabel book cited in the 
 references presents
 a number of different ways to do this, and seems to conclude that the 
 positive-definite
 secant method (BFGS) works best in practice (p201). However, when I run my 
 code through
 the optim function with the method as BFGS, slightly different estimates 
 are produced to
 that of nlm:
  optim(strt,jointll2,method=BFGS,hessian=T)$par
-0.4016808 0.6057144 0.3744790-7.1819734 3.0230386 
 0.4446641 
 
  nlm(jointll2,strt,hessian=T)$estimate
 [1] -0.4016825  0.6057159  0.3744765 -7.1819737  3.0230386  0.4446623
 
 Can anyone tell me if nlm employs the BFGS method for updating its estimates? 
 Or does it use another algorithm?
 
 
 Thank you!
 
 
 
 --

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


[R] Problems with as.POSIXct

2011-09-22 Thread KENNETH R CABRERA
Hi R users:

This is a very strange problem:

Why this instruction shows me NA?, 
and any other date shows me that error!

as.POSIXct(strptime(1992-5-3,format=%Y-%m-%d))

This is my R version on windows 7.
R version 2.13.1 Patched (2011-08-25 r56794)

Thank you for your help.

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


[R] R.oo: do work on data member at construction

2011-09-22 Thread Ben qant
Hello,

I'd like to 'do work' on data members upon construction (i.e. without
implementing it in a get method). Is this the best way to create data member
'z' upon construction? I'm thinking if .z=paste(x,y) below gets more complex
I'll run into issues.

setConstructorS3(MyClass, function(x=NA,y=NA,...) {
  this - extend(Object(), MyClass,
.x=x,
.y=y,
.z=paste(x,y)
  )

})
setMethodS3(getX, MyClass, function(this, ...) {
  this$.x;
})
setMethodS3(getY, MyClass, function(this, ...) {
  this$.y;
})
setMethodS3(getZ, MyClass, function(this, ...) {
  this$.z;
})

 mc = MyClass('a','b')
 mc$x
[1] a
 mc$y
[1] b
 mc$z
[1] a b


Thanks,

ben

[[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] corrigendum on fixed effects and R2 in within models

2011-09-22 Thread Millo Giovanni
Dear list, dear Cecilia and Daniel,

sorry for coming in ten days late, I've been very busy lately so I came
across this email only today.

This is just to make some points clearer re: fixed effects and r2 in
package 'plm', to both you and the list. In particular, to make you
aware of some additional features.

Please see my comments below, with '##'. 

Best,
Giovanni 

 original thread --

Message: 49
Date: Mon, 5 Sep 2011 21:43:02 -0700 (PDT)
From: Daniel Malter dan...@umd.edu
To: r-help@r-project.org
Subject: Re: [R] plm package, R squared, dummies in panel data
Message-ID: 1315284182071-3792582.p...@n4.nabble.com
Content-Type: text/plain; charset=UTF-8

Hi, I answered this question before in this post:
http://r.789695.n4.nabble.com/Regressions-with-fixed-effect-in-R-td21733
14.html
, specifically in my message from May 11, 2010; 4:30pm.

However, I believe the newer version of plm shows an R-squared, which
should
be the within R-squared. 

## it is, at least in the case of within models. Actually, for each
model it is the r-squared on the relevant transformed data.

Why the programmers of the package decided to not
show the others or to not provide a test of the significance of the
a(i)s, I
don't know.

## in fact we do, and we have done since mid-2010 (shortly after the
thread you reference in your post). See ?r.squared, and in particular be
aware of the 'model' argument. The a_i are there as well, see below. PS
as for the general reason for not doing something, lack of time is
always a good guess ;^)

As for your second question, the plm function has an option as to
whether
the FEs should be id, time, or twoways, i.e., for id and time. I
would
guess that then the time FEs are not estimated either but differenced
out,
too.

## sort of. The standard way for estimating one or two-ways FE models is
to demean the data. If you want the first-difference model, try plm(...,
model=fd).
## The fixed effects are nevertheless available, they can be recovered
later: see ?fixef and ?summary.fixef for t-tests for significance of
single effects. See ?pooltest for the joint test of significance of all
FEs. 

 This should affect the within/between variance and therefore the within
and between R-squareds.

## it is the (different flavours of-) r2s that are *defined* according
to the transformation used. Yet, as I said above, you can have them all,
just ask (-the software!).

HTH,
Daniel


Cecilia Carmo wrote:
 
 Hi R-helpers,
 
  
 
 I have two questions I hope you could help me with them:
 
  
 
 In the plm package how can I calculate the R2 within, R2 between and
R2
 overall? Is there any special reason to not display these values?
 
  
 
 When using first differences do I need to have some special care with
 dummies (both year dummies and industry dummies)? 
 
 (A friend who works with Stata told me that there is necessary to
 construct
 some ?accumulated dummies?.)
 
  
 
 Thank you very much,
 
  
 
 Cec?lia Carmo
 
 (Universidade de Aveiro ? Portugal)
-- end original thread -

Giovanni Millo, PhD
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4,
34132 Trieste (Italy)
tel. +39 040 671184
fax  +39 040 671160

 
Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:12}}

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


Re: [R] Problems with as.POSIXct

2011-09-22 Thread William Dunlap
Didn't Columbia switch to a year of daylight
savings time at what would have been midnight
May 3, 1992 (so midnight did not exist that day)?

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of KENNETH R
 CABRERA
 Sent: Thursday, September 22, 2011 8:59 AM
 To: r-help@r-project.org
 Cc: krcab...@gmail.com
 Subject: [R] Problems with as.POSIXct
 
 Hi R users:
 
 This is a very strange problem:
 
 Why this instruction shows me NA?,
 and any other date shows me that error!
 
 as.POSIXct(strptime(1992-5-3,format=%Y-%m-%d))
 
 This is my R version on windows 7.
 R version 2.13.1 Patched (2011-08-25 r56794)
 
 Thank you for your help.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] How to adjust the y-axis range in barplot properly

2011-09-22 Thread Benedikt Drosse

Hello R-Users,
it might be a rather simple problem I have, but I couldn't find any 
solution online. Thus, here is my problem:


I would like to adjust the y-axis range in a barplot, since all my 
values are 70. Therefore I would like to only visualize the y-axis from 
60-100 (example 1).
The problem is, the range of the y-axis is adjusted, but the barsize 
stays the same and vanishes from the plot area.
How can I cut the y-axis and the bars in a proper way. Unfortunatlely 
I dit not get gap.barplot function to work on the matrix in example 1.


I would be very greatful for some ideas and help,
cheers,
Benedikt

example 1:
data - as.matrix(rbind(c(85:90), c(75:80)))
barplot(data, beside=TRUE)
barplot(data, ylim=c(60,90), beside=TRUE)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] image.plot for non-regular grid: round pixel

2011-09-22 Thread Sebastian Schubert
Hi,

I am very new to R so I hope this is not stupid. Here a small example:
(I use R version 2.13.1)

library(fields)

## round pixel
x=matrix(1:100,ncol=10)
y=matrix(1:100,ncol=10)
for(i in 1:10){
  x[i,] - 1:10 + i
  y[i,] - 1:10 + i/20
}


#x=1:10
#y=1:10

z=matrix(1:100,ncol=10)

pdf(test.pdf)

image.plot(x,y,z)

dev.off()


With that, the generated pixels have round corners. Uncommenting the 
second assignements for x and y results in rectangular pixel.

For the actual data which I wanted to plot the round corners look much 
worse. What can I do to get non-round pixels?

Thanks a lot!

Sebastian


signature.asc
Description: This is a digitally signed message part.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problems with as.POSIXct

2011-09-22 Thread Prof Brian Ripley

What timezone is this?

In America/Bogota there was no midnight that day, so the time would be 
invalid.  The Olson database has


# Colombia
# Rule  NAMEFROMTO  TYPEIN  ON  AT  SAVELETTER/S
RuleCO  1992only-   May  3  0:001:00S
RuleCO  1993only-   Apr  4  0:000 
-

# Zone  NAMEGMTOFF  RULES   FORMAT  [UNTIL]
ZoneAmerica/Bogota  -4:56:20 -  LMT 1884 Mar 13
-4:56:20 -  BMT 1914 Nov 23 # Bogota Mean Time
-5:00   CO  CO%sT   # Colombia Time

When all else fails, read the help:

 Character input is first converted to class ‘POSIXlt’ by
 ‘strptime’: numeric input is first converted to ‘POSIXct’.  Any
 conversion that needs to go between the two date-time classes
 requires a timezone: conversion from ‘POSIXlt’ to ‘POSIXct’
 will validate times in the selected timezone.  One issue is what
 happens at transitions to and from DST, for example in the UK

 as.POSIXct(strptime('2011-03-27 01:30:00', '%Y-%m-%d %H:%M:%S'))
 as.POSIXct(strptime('2010-10-31 01:30:00', '%Y-%m-%d %H:%M:%S'))

 are respectively invalid (the clocks went forward at 1:00 GMT to
 2:00 BST) and ambiguous (the clocks went back at 2:00 BST to 1:00
 GMT).


On Thu, 22 Sep 2011, KENNETH R CABRERA wrote:


Hi R users:

This is a very strange problem:

Why this instruction shows me NA?,
and any other date shows me that error!

as.POSIXct(strptime(1992-5-3,format=%Y-%m-%d))

This is my R version on windows 7.
R version 2.13.1 Patched (2011-08-25 r56794)

Thank you for your help.

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



--
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] How to adjust the y-axis range in barplot properly

2011-09-22 Thread Luke Miller
This should do the trick:

barplot(data, ylim=c(60,90), beside=TRUE, xpd = FALSE)

As usual, check ?barplot first for clues on how to customize the plot
to your specifications.

On Thu, Sep 22, 2011 at 11:49 AM, Benedikt Drosse dro...@mpipz.mpg.de wrote:

 Hello R-Users,
 it might be a rather simple problem I have, but I couldn't find any solution 
 online. Thus, here is my problem:

 I would like to adjust the y-axis range in a barplot, since all my values are 
 70. Therefore I would like to only visualize the y-axis from 60-100 (example 
 1).
 The problem is, the range of the y-axis is adjusted, but the barsize stays 
 the same and vanishes from the plot area.
 How can I cut the y-axis and the bars in a proper way. Unfortunatlely I dit 
 not get gap.barplot function to work on the matrix in example 1.

 I would be very greatful for some ideas and help,
 cheers,
 Benedikt

 example 1:
 data - as.matrix(rbind(c(85:90), c(75:80)))
 barplot(data, beside=TRUE)
 barplot(data, ylim=c(60,90), beside=TRUE)

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



--
___
Luke Miller
Postdoctoral Researcher
Marine Science Center
Northeastern University
Nahant, MA
(781) 581-7370 x318

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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.oo: do work on data member at construction

2011-09-22 Thread Henrik Bengtsson
On Thu, Sep 22, 2011 at 9:06 AM, Ben qant ccqu...@gmail.com wrote:
 Hello,

 I'd like to 'do work' on data members upon construction (i.e. without
 implementing it in a get method). Is this the best way to create data member
 'z' upon construction? I'm thinking if .z=paste(x,y) below gets more complex
 I'll run into issues.

 setConstructorS3(MyClass, function(x=NA,y=NA,...) {
  this - extend(Object(), MyClass,
    .x=x,
    .y=y,
    .z=paste(x,y)
  )

Looks good to me and is standard R procedure where you work with the
*arguments*.  You can also work on the object after it's been
instantiated, e.g.

 setConstructorS3(MyClass, function(x=NA,y=NA,...) {
  this - extend(Object(), MyClass,
   .x=x,
   .y=y,
   .z=NULL
  )

  # Assign z
  this$.z - paste(this$.x, this$.y);

  this;
})

Note that if .z always a function of .x and .y it is redundant.  Then
an alternative is to create it on the fly, i.e.

setMethodS3(getZ, MyClass, function(this, ...) {
  x - this$.x;
  y - this$.;
  z - paste(x, y);
  z;
})

You can then make it clever and cache the results so that it is only
calculated once, e.g.

setMethodS3(getZ, MyClass, function(this, ...) {
  z - this$.z;
  if (is.null(z)) {
x - this$.x;
y - this$.;
z - paste(x, y);
this$.z - z;
  }
  z;
})

However, you then have to make sure to reset z (this$.z - NULL)
whenever .x or .y is changed.

/Henrik


 })
 setMethodS3(getX, MyClass, function(this, ...) {
  this$.x;
 })
 setMethodS3(getY, MyClass, function(this, ...) {
  this$.y;
 })
 setMethodS3(getZ, MyClass, function(this, ...) {
  this$.z;
 })

 mc = MyClass('a','b')
 mc$x
 [1] a
 mc$y
 [1] b
 mc$z
 [1] a b


 Thanks,

 ben

        [[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] ARIMA - Skipping intermediate lags

2011-09-22 Thread Bogaso Christofer
Dear Prof. Repley, may I know in details why ignoring intermediate lags are
sin? How the statistical properties will be worse than not ignoring them? If
I am correct then, ignoring some parameters means we know the population
values for them. Therefore in this case, my MSE estimate should be smaller
(or, my prediction will be more accurate) isn't it?

Thanks and regards,

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Prof Brian Ripley
Sent: 21 September 2011 13:32
To: leighton155
Cc: r-help@r-project.org
Subject: Re: [R] ARIMA - Skipping intermediate lags

On Tue, 20 Sep 2011, leighton155 wrote:

 Hello,

 I am a new R user.  I am trying to use the arima command, but I have a 
 question on intermediate lags.  I want to run in R the equivalent 
 Stata command of ARIMA d.yyy, AR(5) MA(5 7).  This would tell the 
 program I am interested in AR lag 5, MA lag 5, and MA lag 7, all while 
 skipping the intermediate lags of AR 1-4, and MA 1-4, 6.  Is there any 
 way to do this in R?  Thank you.

Yes.  See the 'fixed' argument on the help page.  Note that this is not
recommended in general 


 --
 View this message in context: 
 http://r.789695.n4.nabble.com/ARIMA-Skipping-intermediate-lags-tp38284
 49p3828449.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.


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


Re: [R] need help on melt/cast

2011-09-22 Thread John Kane
And I always have a problem with reshape(). Mind you I often have similar 
problems with melt()

Anyway with the data.frame xx, try

 melt(xx, id=c(ID))



--- On Thu, 9/22/11, Uwe Ligges lig...@statistik.tu-dortmund.de wrote:

 From: Uwe Ligges lig...@statistik.tu-dortmund.de
 Subject: Re: [R] need help on melt/cast
 To: Eugene Kanshin kanshin...@gmail.com
 Cc: r-help@r-project.org
 Received: Thursday, September 22, 2011, 10:30 AM
 I can never remember what melt, cast
 and all that means, hence I simpy 
 use reshape() which does not even require any additional
 package:
 
 reshape(dat, direction=long, idvar = ID,
    varying=list(2:4), v.names=Value,
 times=names(dat)[2:4])
 
 Uwe Ligges
 
 
 On 22.09.2011 15:54, Eugene Kanshin wrote:
  Hello,
  I need to convert dataframe from:
 
 
 ID   T0   T1   T2
  A    1     2 
    3
  B    4     5 
    6
  C    7     8 
    9
 
  to:
 
  ID Variable Value
  A       T0   
    1
  A       T1   
    2
  A       T2   
    3
  B       T0   
    4
  B       T1   
    5
  B       T2   
    6
  C       T0   
    7
  C       T1   
    8
  C       T2   
    9
 
  i tried to use melt cast but it gives me all the time
 not exactly what I
  need.
  Thank you.
 
      [[alternative HTML version
 deleted]]
 
  __
  R-help@r-project.org
 mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained,
 reproducible code.
 
 __
 R-help@r-project.org
 mailing list
 https://stat.ethz.ch/mailman/listinfo/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] need help on melt/cast

2011-09-22 Thread David Winsemius


On Sep 22, 2011, at 12:28 PM, John Kane wrote:


And I always have a problem with reshape().


Me too.


Mind you I often have similar problems with melt()


Many fewer, though.


Anyway with the data.frame xx, try

melt(xx, id=c(ID))


Just

newdf -  melt(xx)   #  would have succeeded here.

--  
David




--- On Thu, 9/22/11, Uwe Ligges lig...@statistik.tu-dortmund.de  
wrote:



From: Uwe Ligges lig...@statistik.tu-dortmund.de
Subject: Re: [R] need help on melt/cast
To: Eugene Kanshin kanshin...@gmail.com
Cc: r-help@r-project.org
Received: Thursday, September 22, 2011, 10:30 AM
I can never remember what melt, cast
and all that means, hence I simpy
use reshape() which does not even require any additional
package:

reshape(dat, direction=long, idvar = ID,
   varying=list(2:4), v.names=Value,
times=names(dat)[2:4])

Uwe Ligges


On 22.09.2011 15:54, Eugene Kanshin wrote:

Hello,
I need to convert dataframe from:



ID   T0   T1   T2

A1 2

   3

B4 5

   6

C7 8

   9


to:

ID Variable Value
A   T0

   1

A   T1

   2

A   T2

   3

B   T0

   4

B   T1

   5

B   T2

   6

C   T0

   7

C   T1

   8

C   T2

   9


i tried to use melt cast but it gives me all the time

not exactly what I

need.
Thank you.


David Winsemius, MD
West Hartford, CT

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


Re: [R] R.oo: do work on data member at construction

2011-09-22 Thread Ben qant
Thank you very much! I'm using the first example.

For others: there are two simple typos in Henrik's email below:  pretty sure
y - this$.; should be  y - this$.y;

Thanks again...

Corrected below...

Ben

 Hello,

 I'd like to 'do work' on data members upon construction (i.e. without
 implementing it in a get method). Is this the best way to create data
member
 'z' upon construction? I'm thinking if .z=paste(x,y) below gets more
complex
 I'll run into issues.

 setConstructorS3(MyClass, function(x=NA,y=NA,...) {
  this - extend(Object(), MyClass,
.x=x,
.y=y,
.z=paste(x,y)
  )

Looks good to me and is standard R procedure where you work with the
*arguments*.  You can also work on the object after it's been
instantiated, e.g.

 setConstructorS3(MyClass, function(x=NA,y=NA,...) {
  this - extend(Object(), MyClass,
   .x=x,
   .y=y,
   .z=NULL
  )

 # Assign z
 this$.z - paste(this$.x, this$.y);

 this;
})

Note that if .z always a function of .x and .y it is redundant.  Then
an alternative is to create it on the fly, i.e.

setMethodS3(getZ, MyClass, function(this, ...) {
  x - this$.x;
 y - this$.y;
 z - paste(x, y);
 z;
})

You can then make it clever and cache the results so that it is only
calculated once, e.g.

setMethodS3(getZ, MyClass, function(this, ...) {
  z - this$.z;
 if (is.null(z)) {
   x - this$.x;
   y - this$.y;
   z - paste(x, y);
   this$.z - z;
 }
 z;
})

However, you then have to make sure to reset z (this$.z - NULL)
whenever .x or .y is changed.

/Henrik




On Thu, Sep 22, 2011 at 10:18 AM, Henrik Bengtsson h...@biostat.ucsf.eduwrote:

 On Thu, Sep 22, 2011 at 9:06 AM, Ben qant ccqu...@gmail.com wrote:
  Hello,
 
  I'd like to 'do work' on data members upon construction (i.e. without
  implementing it in a get method). Is this the best way to create data
 member
  'z' upon construction? I'm thinking if .z=paste(x,y) below gets more
 complex
  I'll run into issues.
 
  setConstructorS3(MyClass, function(x=NA,y=NA,...) {
   this - extend(Object(), MyClass,
 .x=x,
 .y=y,
 .z=paste(x,y)
   )

 Looks good to me and is standard R procedure where you work with the
 *arguments*.  You can also work on the object after it's been
 instantiated, e.g.

  setConstructorS3(MyClass, function(x=NA,y=NA,...) {
   this - extend(Object(), MyClass,
.x=x,
.y=y,
.z=NULL
   )

  # Assign z
  this$.z - paste(this$.x, this$.y);

  this;
 })

 Note that if .z always a function of .x and .y it is redundant.  Then
 an alternative is to create it on the fly, i.e.

 setMethodS3(getZ, MyClass, function(this, ...) {
   x - this$.x;
  y - this$.;
  z - paste(x, y);
  z;
 })

 You can then make it clever and cache the results so that it is only
 calculated once, e.g.

 setMethodS3(getZ, MyClass, function(this, ...) {
   z - this$.z;
  if (is.null(z)) {
x - this$.x;
y - this$.;
z - paste(x, y);
this$.z - z;
  }
  z;
 })

 However, you then have to make sure to reset z (this$.z - NULL)
 whenever .x or .y is changed.

 /Henrik

 
  })
  setMethodS3(getX, MyClass, function(this, ...) {
   this$.x;
  })
  setMethodS3(getY, MyClass, function(this, ...) {
   this$.y;
  })
  setMethodS3(getZ, MyClass, function(this, ...) {
   this$.z;
  })
 
  mc = MyClass('a','b')
  mc$x
  [1] a
  mc$y
  [1] b
  mc$z
  [1] a b
 
 
  Thanks,
 
  ben
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


[[alternative HTML version deleted]]

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


[R] create variables through a loop

2011-09-22 Thread Changbin Du
HI, Dear R community,

I am trying to created new variables and put into a data frame through a
loop.

My original data set:

head(first)
  probe_name chr_id position array1
1C-7SARK  1   849467 10
2C-4WYLN  1   854278 10
3C-3BFNY  1   854471 10
4C-7ONNE  1   874460 10
5C-6HYCN  1   874571 10
6C-7SCGC  1   874609 10


I have 48 other array data from a list result.fun
array2=result.fun[[1]]
array3=result.fun[[2]]
.
.

I want the following results:

  probe_name chr_id position array1 array2 array3
1C-7SARK  1   849467 10 10   10
2C-4WYLN  1   854278 10 10   10
3C-3BFNY  1   854471 10  10   10
4C-7ONNE  1   874460 10 10   10
5C-6HYCN  1   874571 10 10   10
6C-7SCGC  1   874609 10 10   10


I used the following codes:

for (i in 2:3) {

assign(lab=paste(array, i, sep=), value=result.fun[[i-1]])

first -cbind(first, lab)

}

*Error in assign(lab = paste(array, i, sep = ), value = result.fun[[i -
:
  unused argument(s) (lab = paste(array, i, sep = ))*


Can anyone give some hits or helps?

Thanks so much!






-- 
Sincerely,
Changbin
--

[[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] create variables through a loop

2011-09-22 Thread R. Michael Weylandt
There is no lab= argument for assign() hence the error. Did someone
provide you with example code that suggested such a thing? remove lab=
entirely or replace it with x= to make your code work. More generally type
?assign or args(assign) to see what the arguments for a function are.

More generally, this sort of thing may be best handled in a list rather than
an set of independent variables.

Michael Weylandt

On Thu, Sep 22, 2011 at 1:07 PM, Changbin Du changb...@gmail.com wrote:

 HI, Dear R community,

 I am trying to created new variables and put into a data frame through a
 loop.

 My original data set:

 head(first)
  probe_name chr_id position array1
 1C-7SARK  1   849467 10
 2C-4WYLN  1   854278 10
 3C-3BFNY  1   854471 10
 4C-7ONNE  1   874460 10
 5C-6HYCN  1   874571 10
 6C-7SCGC  1   874609 10


 I have 48 other array data from a list result.fun
 array2=result.fun[[1]]
 array3=result.fun[[2]]
 .
 .

 I want the following results:

  probe_name chr_id position array1 array2 array3
 1C-7SARK  1   849467 10 10   10
 2C-4WYLN  1   854278 10 10   10
 3C-3BFNY  1   854471 10  10   10
 4C-7ONNE  1   874460 10 10   10
 5C-6HYCN  1   874571 10 10   10
 6C-7SCGC  1   874609 10 10   10


 I used the following codes:

 for (i in 2:3) {

 assign(lab=paste(array, i, sep=), value=result.fun[[i-1]])

 first -cbind(first, lab)

 }

 *Error in assign(lab = paste(array, i, sep = ), value = result.fun[[i -
 :
  unused argument(s) (lab = paste(array, i, sep = ))*


 Can anyone give some hits or helps?

 Thanks so much!






 --
 Sincerely,
 Changbin
 --

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] create variables through a loop

2011-09-22 Thread Changbin Du
HI, Michael,

I tried use x and got the following:

 for (i in 2:3) {
+
+ assign(x=paste(array, i, sep=), value=result.fun[[i-1]])
+
+ first -cbind(first, x)
+
+ }
*Error in cbind(first, x) : object 'x' not found
*

But I checked the
 ls()
 array2   array3were created.

Can I put them into the first data set by loop, or manually?

Thanks!


P.S   I search the similar codes from google and can not work as I expected.

Thanks!



On Thu, Sep 22, 2011 at 10:11 AM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

 There is no lab= argument for assign() hence the error. Did someone
 provide you with example code that suggested such a thing? remove lab=
 entirely or replace it with x= to make your code work. More generally type
 ?assign or args(assign) to see what the arguments for a function are.

 More generally, this sort of thing may be best handled in a list rather
 than an set of independent variables.

 Michael Weylandt

 On Thu, Sep 22, 2011 at 1:07 PM, Changbin Du changb...@gmail.com wrote:

 HI, Dear R community,

 I am trying to created new variables and put into a data frame through a
 loop.

 My original data set:

 head(first)
  probe_name chr_id position array1
 1C-7SARK  1   849467 10
 2C-4WYLN  1   854278 10
 3C-3BFNY  1   854471 10
 4C-7ONNE  1   874460 10
 5C-6HYCN  1   874571 10
 6C-7SCGC  1   874609 10


 I have 48 other array data from a list result.fun
 array2=result.fun[[1]]
 array3=result.fun[[2]]
 .
 .

 I want the following results:

  probe_name chr_id position array1 array2 array3
 1C-7SARK  1   849467 10 10   10
 2C-4WYLN  1   854278 10 10   10
 3C-3BFNY  1   854471 10  10   10
 4C-7ONNE  1   874460 10 10   10
 5C-6HYCN  1   874571 10 10   10
 6C-7SCGC  1   874609 10 10   10


 I used the following codes:

 for (i in 2:3) {

 assign(lab=paste(array, i, sep=), value=result.fun[[i-1]])

 first -cbind(first, lab)

 }

 *Error in assign(lab = paste(array, i, sep = ), value = result.fun[[i
 -
 :
  unused argument(s) (lab = paste(array, i, sep = ))*


 Can anyone give some hits or helps?

 Thanks so much!






 --
 Sincerely,
 Changbin
 --

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





-- 
Sincerely,
Changbin
--

[[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] Wrapper of linearHypothesis (car) for post-hoc of repeated measures ANOVA

2011-09-22 Thread Helios de Rosario
For some time I have been looking for a convenient way of performing
post-hoc analysis to Repeated Measures ANOVA, that would be acceptable
if sphericity is violated (i.e. leaving aside post-hoc to lme models).

The best solution I found was John Fox's proposal to similar requests
in R-help:
http://tolstoy.newcastle.edu.au/R/e2/help/07/09/26518.html 
http://tolstoy.newcastle.edu.au/R/e10/help/10/04/1663.html 

However, I think that using linearHypothesis() is not as
straightforward as I would desire for testing specific contrasts between
factor levels. The hypotheses must be defined as linear combinations of
the model coefficients (subject to response transformations according to
the intra-subjects design), which may need some involved calculations if
one is thinking on differences between this and that factor levels
(either between-subjects or intra-subjects), and the issue gets worse
for post-hoc tests on interaction effects.

For that reason, I have spent some time in writing a wrapper to
linearHypothesis() that might be helpful in those situations. I copy the
commented code at the end of this message, because although I have
successfully used it in some cases, I would like more knowledgeable
people  to put it to test (and eventually help me create a worthwile
contribution for other people that could find it useful).

This function (which I have called factorltest.mlm) needs the
multivariate linear model and the intrasubject-related arguments (idata,
idesign...) that would be passed on to Anova() (from car) for a repeated
measures analysis, or directly the Anova.mlm object returned by Anova()
instead of idata, idesign... (I have tried to explain it clearly in the
commentaries to the code.)

Moreover, it needs an argument levelcomb: a list that represents the
level combinations of factors to be tested. There are different ways of
representing those combinations (through names of factor levels, or
coefficient vectors/matrices), and depending on the elements of that
list the test is made for main effects, simple effects, interaction
contrasts, etc.

For instance, let me use an example with the OBrienKaiser data set (as
in the help documentation for Anova() and linearHypothesis()).

The calculation of the multivariate linear model and Anova is copied
from those help files:

 phase - factor(rep(c(pretest, posttest, followup), c(5, 5,
5)),
+ levels=c(pretest, posttest, followup))
 hour - ordered(rep(1:5, 3))
 idata - data.frame(phase, hour)
 mod.ok - lm(cbind(pre.1, pre.2, pre.3, pre.4, pre.5, 
+post.1, post.2, post.3, post.4, post.5, 
+fup.1, fup.2, fup.3, fup.4, fup.5) ~ 
treatment*gender, 
+   data=OBrienKaiser)
 av.ok - Anova(mod.ok, idata=idata, idesign=~phase*hour)

Then, let's suppose that I want to test pairwise comparisons for the
significant main effect treatment (whose levels are
c(control,A,B)). For the specific contrast between treatment A
and the control group I can define levelcomb in the following
(equivalent) ways:

 levelcomb - list(treatment=c(A,control))
 levelcomb - list(treatment=c(A=1,control=-1))
 levelcomb - list(treatment=c(-1,1,0))

Now, let's suppose that I am interested in the (marginally) significant
interaction between treatment and phase. First I test the simple main
effect of phase for different levels of treament (e.g. for the control
group). To do this, levelcomb must have one variable for each
interacting factor (treatment and phase): levelcomb$treatment will
specify the treatment that I want to fix for the simple main effects
test (control), and levelcomb$phase will have a NA value to represent
that I want to test all orthogonal contrasts within that factor:

 levelcomb - list(treatment=control,phase=NA)

I could also use numeric vectors to define the levels of treatment
that I want to fix, as in the previous example, or if I want a more
complicated combination (e.g. if I want to test the phase effect for
pooled treatments A and B):

 levelcomb - list(treatment=c(A=1,B=1),phase=NA)

The NA value can be replaced by the specific contrast matrix that I
would like to use. For instance, the previous statement is equivalent to
the following one:

 levelcomb - list(treatment=c(0,1,1),phase=contr.sum(levels(phase)))

And then, let's see an example of interaction contrast: I want to see
if the difference between the pre-test phase and the following two,
itself differs between the control group and the two treatments. This
would be

 levelcomb - list(treatment=c(2,-1,-1),phase=c(2,-1,-1))
or
 levelcomb -
list(treatment=c(control=2,A=-1,B=-1),phase=c(pretest=2,posttest=-1,followup=-1))

etc.

Now, to perform the test I just use this levelcomb list object with
the model and ANOVA previously performed, in the following way:

 factorltest.mlm(mod.ok,levelcomb,av.ok)

Or if I want to use idata and idesign directly:

 factorltest.mlm(mod.ok,levelcomb,idata=idata,idesign=~phase*hour)

Of course, this function only performs one test at a 

Re: [R] create variables through a loop

2011-09-22 Thread R. Michael Weylandt
There are a few ways to proceed from here. If you are really committed to
this loop + assign idea, I'd provide the following code:

for( i in 2:3) {
label - paste(array, i, sep=)
assign(label, value = result.fun[[i-1]] )
first - cbind(first, get(label))
}

However, this is generally pretty inefficient. Why not something more like
the following?

first.out - do.call(cbind, list(first, result.fun))

If you need the names to be arrayi you can add this line:
colnames(first.out) - c(colnames(first), paste(array,
seq(length(result.fun)), sep=))

I'm unable to test this on your (unprovided) data, but here's an example of
how this works:

first = data.frame(x = 1:3, y = 6:8, z = 11:13)

a = data.frame(a = 1:3)
b = data.frame(b = 4:6)
result.fun = list(a,b)

first.out - do.call(cbind, list(first, result.fun))
print(first.out)

which provides this output.

x y  z a b
1 1 6 11 1 4
2 2 7 12 2 5
3 3 8 13 3 6

More generally, you really should read about how arguments and assignments
work in R. See, e.g., 8.2.26 in the R inferno.

Michael Weylandt

On Thu, Sep 22, 2011 at 1:21 PM, Changbin Du changb...@gmail.com wrote:

 HI, Michael,

 I tried use x and got the following:

  for (i in 2:3) {
 +
 + assign(x=paste(array, i, sep=), value=result.fun[[i-1]])
 +
 + first -cbind(first, x)
 +
 + }
 *Error in cbind(first, x) : object 'x' not found
 *

 But I checked the
  ls()
  array2   array3were created.

 Can I put them into the first data set by loop, or manually?

 Thanks!


 P.S   I search the similar codes from google and can not work as I
 expected.

 Thanks!



 On Thu, Sep 22, 2011 at 10:11 AM, R. Michael Weylandt 
 michael.weyla...@gmail.com wrote:

 There is no lab= argument for assign() hence the error. Did someone
 provide you with example code that suggested such a thing? remove lab=
 entirely or replace it with x= to make your code work. More generally type
 ?assign or args(assign) to see what the arguments for a function are.

 More generally, this sort of thing may be best handled in a list rather
 than an set of independent variables.

 Michael Weylandt

 On Thu, Sep 22, 2011 at 1:07 PM, Changbin Du changb...@gmail.com wrote:

 HI, Dear R community,

 I am trying to created new variables and put into a data frame through a
 loop.

 My original data set:

 head(first)
  probe_name chr_id position array1
 1C-7SARK  1   849467 10
 2C-4WYLN  1   854278 10
 3C-3BFNY  1   854471 10
 4C-7ONNE  1   874460 10
 5C-6HYCN  1   874571 10
 6C-7SCGC  1   874609 10


 I have 48 other array data from a list result.fun
 array2=result.fun[[1]]
 array3=result.fun[[2]]
 .
 .

 I want the following results:

  probe_name chr_id position array1 array2 array3
 1C-7SARK  1   849467 10 10   10
 2C-4WYLN  1   854278 10 10   10
 3C-3BFNY  1   854471 10  10   10
 4C-7ONNE  1   874460 10 10   10
 5C-6HYCN  1   874571 10 10   10
 6C-7SCGC  1   874609 10 10   10


 I used the following codes:

 for (i in 2:3) {

 assign(lab=paste(array, i, sep=), value=result.fun[[i-1]])

 first -cbind(first, lab)

 }

 *Error in assign(lab = paste(array, i, sep = ), value = result.fun[[i
 -
 :
  unused argument(s) (lab = paste(array, i, sep = ))*


 Can anyone give some hits or helps?

 Thanks so much!






 --
 Sincerely,
 Changbin
 --

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





 --
 Sincerely,
 Changbin
 --



[[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] create variables through a loop

2011-09-22 Thread R. Michael Weylandt
Actually, I think you can make that even easier:

first.out - cbind(first, result.fun)

Michael Weylandt

On Thu, Sep 22, 2011 at 1:37 PM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

 There are a few ways to proceed from here. If you are really committed to
 this loop + assign idea, I'd provide the following code:

 for( i in 2:3) {
 label - paste(array, i, sep=)
 assign(label, value = result.fun[[i-1]] )
 first - cbind(first, get(label))
 }

 However, this is generally pretty inefficient. Why not something more like
 the following?

 first.out - do.call(cbind, list(first, result.fun))

 If you need the names to be arrayi you can add this line:
 colnames(first.out) - c(colnames(first), paste(array,
 seq(length(result.fun)), sep=))

 I'm unable to test this on your (unprovided) data, but here's an example of
 how this works:

 first = data.frame(x = 1:3, y = 6:8, z = 11:13)

 a = data.frame(a = 1:3)
 b = data.frame(b = 4:6)
 result.fun = list(a,b)

 first.out - do.call(cbind, list(first, result.fun))
 print(first.out)

 which provides this output.

 x y  z a b
 1 1 6 11 1 4
 2 2 7 12 2 5
 3 3 8 13 3 6

 More generally, you really should read about how arguments and assignments
 work in R. See, e.g., 8.2.26 in the R inferno.

 Michael Weylandt


 On Thu, Sep 22, 2011 at 1:21 PM, Changbin Du changb...@gmail.com wrote:

 HI, Michael,

 I tried use x and got the following:

  for (i in 2:3) {
 +
 + assign(x=paste(array, i, sep=), value=result.fun[[i-1]])
 +
 + first -cbind(first, x)
 +
 + }
 *Error in cbind(first, x) : object 'x' not found
 *

 But I checked the
  ls()
  array2   array3were created.

 Can I put them into the first data set by loop, or manually?

 Thanks!


 P.S   I search the similar codes from google and can not work as I
 expected.

 Thanks!



 On Thu, Sep 22, 2011 at 10:11 AM, R. Michael Weylandt 
 michael.weyla...@gmail.com wrote:

 There is no lab= argument for assign() hence the error. Did someone
 provide you with example code that suggested such a thing? remove lab=
 entirely or replace it with x= to make your code work. More generally type
 ?assign or args(assign) to see what the arguments for a function are.

 More generally, this sort of thing may be best handled in a list rather
 than an set of independent variables.

 Michael Weylandt

 On Thu, Sep 22, 2011 at 1:07 PM, Changbin Du changb...@gmail.comwrote:

 HI, Dear R community,

 I am trying to created new variables and put into a data frame through a
 loop.

 My original data set:

 head(first)
  probe_name chr_id position array1
 1C-7SARK  1   849467 10
 2C-4WYLN  1   854278 10
 3C-3BFNY  1   854471 10
 4C-7ONNE  1   874460 10
 5C-6HYCN  1   874571 10
 6C-7SCGC  1   874609 10


 I have 48 other array data from a list result.fun
 array2=result.fun[[1]]
 array3=result.fun[[2]]
 .
 .

 I want the following results:

  probe_name chr_id position array1 array2 array3
 1C-7SARK  1   849467 10 10   10
 2C-4WYLN  1   854278 10 10   10
 3C-3BFNY  1   854471 10  10   10
 4C-7ONNE  1   874460 10 10   10
 5C-6HYCN  1   874571 10 10   10
 6C-7SCGC  1   874609 10 10   10


 I used the following codes:

 for (i in 2:3) {

 assign(lab=paste(array, i, sep=), value=result.fun[[i-1]])

 first -cbind(first, lab)

 }

 *Error in assign(lab = paste(array, i, sep = ), value =
 result.fun[[i -
 :
  unused argument(s) (lab = paste(array, i, sep = ))*


 Can anyone give some hits or helps?

 Thanks so much!






 --
 Sincerely,
 Changbin
 --

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





 --
 Sincerely,
 Changbin
 --




[[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] Problem with error message in Rcmdr

2011-09-22 Thread Beaulieu . Jake
Hello,

I just upgraded to R version 2.13.1 and am running Rcmdr version 1.7-0. 
Prior to the upgrade, Rcmdr returned descriptive error messages.  However, 
since the upgrade the only error message Rcmdr supplies is:

ERROR:
text

How can I convince Rcmdr to return useful error messages again?

Thanks,
Jake B 
[[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] Quelplot

2011-09-22 Thread Richard M. Heiberger
Hadley,

I forwarded your request to Boris and Ken.  Here is Boris' response.

Rich


Dear Richard:

   I looked a bit more and found the second edition of book referenced, Rand
R Wilcox, Introduction to Robust Estimation and Hypothesis Testing, Second
Edition, Academic Press, 2005. It has over 600 quotes on google scholar. If
my memory is correct, Wilcox developed code for relplots and possibly
quelplots.

Best Wishes,
Boris

On Wed, Sep 21, 2011 at 3:11 PM, Hadley Wickham had...@rice.edu wrote:

 Hi all,

 Does anyone have an R implementation of the queplot (K. M. Goldberg
 and B. Iglewicz. Bivariate extensions of the boxplot. Technometrics,
 34(3):pp. 307–320, 1992)?  I'm struggling with the estimation of the
 asymmetry parameters.

 Hadley

 --
 Assistant Professor / Dobelman Family Junior Chair
 Department of Statistics / Rice University
 http://had.co.nz/

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


[[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] create variables through a loop

2011-09-22 Thread Jean-Christophe BOUËTTÉ
Hi,
It's hard to provide you with working code when you don't provide a
reproducible example, but do you really need to create variables? What
about (untested):

for (i in 1:2) {
  first -cbind(first, result.fun[[i]])
}

you will then have to look at
names(first)
and change the last part of it to
paste(array,2:3,sep=)

Hope that works!
JC

2011/9/22 Changbin Du changb...@gmail.com:
 HI, Michael,

 I tried use x and got the following:

 for (i in 2:3) {
 +
 + assign(x=paste(array, i, sep=), value=result.fun[[i-1]])
 +
 + first -cbind(first, x)
 +
 + }
 *Error in cbind(first, x) : object 'x' not found
 *

 But I checked the
  ls()
     array2       array3    were created.

 Can I put them into the first data set by loop, or manually?

 Thanks!


 P.S   I search the similar codes from google and can not work as I expected.

 Thanks!



 On Thu, Sep 22, 2011 at 10:11 AM, R. Michael Weylandt 
 michael.weyla...@gmail.com wrote:

 There is no lab= argument for assign() hence the error. Did someone
 provide you with example code that suggested such a thing? remove lab=
 entirely or replace it with x= to make your code work. More generally type
 ?assign or args(assign) to see what the arguments for a function are.

 More generally, this sort of thing may be best handled in a list rather
 than an set of independent variables.

 Michael Weylandt

 On Thu, Sep 22, 2011 at 1:07 PM, Changbin Du changb...@gmail.com wrote:

 HI, Dear R community,

 I am trying to created new variables and put into a data frame through a
 loop.

 My original data set:

 head(first)
  probe_name chr_id position array1
 1    C-7SARK      1   849467     10
 2    C-4WYLN      1   854278     10
 3    C-3BFNY      1   854471     10
 4    C-7ONNE      1   874460     10
 5    C-6HYCN      1   874571     10
 6    C-7SCGC      1   874609     10


 I have 48 other array data from a list result.fun
 array2=result.fun[[1]]
 array3=result.fun[[2]]
 .
 .

 I want the following results:

  probe_name chr_id position array1 array2 array3
 1    C-7SARK      1   849467     10     10       10
 2    C-4WYLN      1   854278     10     10       10
 3    C-3BFNY      1   854471     10      10       10
 4    C-7ONNE      1   874460     10     10       10
 5    C-6HYCN      1   874571     10     10       10
 6    C-7SCGC      1   874609     10     10       10


 I used the following codes:

 for (i in 2:3) {

 assign(lab=paste(array, i, sep=), value=result.fun[[i-1]])

 first -cbind(first, lab)

 }

 *Error in assign(lab = paste(array, i, sep = ), value = result.fun[[i
 -
 :
  unused argument(s) (lab = paste(array, i, sep = ))*


 Can anyone give some hits or helps?

 Thanks so much!






 --
 Sincerely,
 Changbin
 --

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





 --
 Sincerely,
 Changbin
 --

        [[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] create variables through a loop

2011-09-22 Thread Jean-Christophe BOUËTTÉ
On how to use named vs. positional arguments, you can also have a look
at section 2.3 of an introduction to R.

2011/9/22 Jean-Christophe BOUËTTÉ jcboue...@gmail.com:
 Hi,
 It's hard to provide you with working code when you don't provide a
 reproducible example, but do you really need to create variables? What
 about (untested):

 for (i in 1:2) {
  first -cbind(first, result.fun[[i]])
 }

 you will then have to look at
 names(first)
 and change the last part of it to
 paste(array,2:3,sep=)

 Hope that works!
 JC

 2011/9/22 Changbin Du changb...@gmail.com:
 HI, Michael,

 I tried use x and got the following:

 for (i in 2:3) {
 +
 + assign(x=paste(array, i, sep=), value=result.fun[[i-1]])
 +
 + first -cbind(first, x)
 +
 + }
 *Error in cbind(first, x) : object 'x' not found
 *

 But I checked the
  ls()
     array2       array3    were created.

 Can I put them into the first data set by loop, or manually?

 Thanks!


 P.S   I search the similar codes from google and can not work as I expected.

 Thanks!



 On Thu, Sep 22, 2011 at 10:11 AM, R. Michael Weylandt 
 michael.weyla...@gmail.com wrote:

 There is no lab= argument for assign() hence the error. Did someone
 provide you with example code that suggested such a thing? remove lab=
 entirely or replace it with x= to make your code work. More generally type
 ?assign or args(assign) to see what the arguments for a function are.

 More generally, this sort of thing may be best handled in a list rather
 than an set of independent variables.

 Michael Weylandt

 On Thu, Sep 22, 2011 at 1:07 PM, Changbin Du changb...@gmail.com wrote:

 HI, Dear R community,

 I am trying to created new variables and put into a data frame through a
 loop.

 My original data set:

 head(first)
  probe_name chr_id position array1
 1    C-7SARK      1   849467     10
 2    C-4WYLN      1   854278     10
 3    C-3BFNY      1   854471     10
 4    C-7ONNE      1   874460     10
 5    C-6HYCN      1   874571     10
 6    C-7SCGC      1   874609     10


 I have 48 other array data from a list result.fun
 array2=result.fun[[1]]
 array3=result.fun[[2]]
 .
 .

 I want the following results:

  probe_name chr_id position array1 array2 array3
 1    C-7SARK      1   849467     10     10       10
 2    C-4WYLN      1   854278     10     10       10
 3    C-3BFNY      1   854471     10      10       10
 4    C-7ONNE      1   874460     10     10       10
 5    C-6HYCN      1   874571     10     10       10
 6    C-7SCGC      1   874609     10     10       10


 I used the following codes:

 for (i in 2:3) {

 assign(lab=paste(array, i, sep=), value=result.fun[[i-1]])

 first -cbind(first, lab)

 }

 *Error in assign(lab = paste(array, i, sep = ), value = result.fun[[i
 -
 :
  unused argument(s) (lab = paste(array, i, sep = ))*


 Can anyone give some hits or helps?

 Thanks so much!






 --
 Sincerely,
 Changbin
 --

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





 --
 Sincerely,
 Changbin
 --

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

2011-09-22 Thread Hadley Wickham
Thanks Rich - unfortunately, as far as I can, tell Rand Wilcox only
developed relplot code.
Hadley

On Thu, Sep 22, 2011 at 12:52 PM, Richard M. Heiberger r...@temple.edu wrote:
 Hadley,

 I forwarded your request to Boris and Ken.  Here is Boris' response.

 Rich


 Dear Richard:

    I looked a bit more and found the second edition of book referenced, Rand
 R Wilcox, Introduction to Robust Estimation and Hypothesis Testing, Second
 Edition, Academic Press, 2005. It has over 600 quotes on google scholar. If
 my memory is correct, Wilcox developed code for relplots and possibly
 quelplots.

 Best Wishes,
 Boris

 On Wed, Sep 21, 2011 at 3:11 PM, Hadley Wickham had...@rice.edu wrote:

 Hi all,

 Does anyone have an R implementation of the queplot (K. M. Goldberg
 and B. Iglewicz. Bivariate extensions of the boxplot. Technometrics,
 34(3):pp. 307–320, 1992)?  I'm struggling with the estimation of the
 asymmetry parameters.

 Hadley

 --
 Assistant Professor / Dobelman Family Junior Chair
 Department of Statistics / Rice University
 http://had.co.nz/

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





-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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


Re: [R] create variables through a loop

2011-09-22 Thread Changbin Du
Thank, Jean, appreciated your help!

On Thu, Sep 22, 2011 at 10:52 AM, Jean-Christophe BOUËTTÉ 
jcboue...@gmail.com wrote:

 Hi,
 It's hard to provide you with working code when you don't provide a
 reproducible example, but do you really need to create variables? What
 about (untested):

 for (i in 1:2) {
  first -cbind(first, result.fun[[i]])
 }

 you will then have to look at
 names(first)
 and change the last part of it to
 paste(array,2:3,sep=)

 Hope that works!
 JC

 2011/9/22 Changbin Du changb...@gmail.com:
  HI, Michael,
 
  I tried use x and got the following:
 
  for (i in 2:3) {
  +
  + assign(x=paste(array, i, sep=), value=result.fun[[i-1]])
  +
  + first -cbind(first, x)
  +
  + }
  *Error in cbind(first, x) : object 'x' not found
  *
 
  But I checked the
   ls()
  array2   array3were created.
 
  Can I put them into the first data set by loop, or manually?
 
  Thanks!
 
 
  P.S   I search the similar codes from google and can not work as I
 expected.
 
  Thanks!
 
 
 
  On Thu, Sep 22, 2011 at 10:11 AM, R. Michael Weylandt 
  michael.weyla...@gmail.com wrote:
 
  There is no lab= argument for assign() hence the error. Did someone
  provide you with example code that suggested such a thing? remove lab=
  entirely or replace it with x= to make your code work. More generally
 type
  ?assign or args(assign) to see what the arguments for a function are.
 
  More generally, this sort of thing may be best handled in a list rather
  than an set of independent variables.
 
  Michael Weylandt
 
  On Thu, Sep 22, 2011 at 1:07 PM, Changbin Du changb...@gmail.com
 wrote:
 
  HI, Dear R community,
 
  I am trying to created new variables and put into a data frame through
 a
  loop.
 
  My original data set:
 
  head(first)
   probe_name chr_id position array1
  1C-7SARK  1   849467 10
  2C-4WYLN  1   854278 10
  3C-3BFNY  1   854471 10
  4C-7ONNE  1   874460 10
  5C-6HYCN  1   874571 10
  6C-7SCGC  1   874609 10
 
 
  I have 48 other array data from a list result.fun
  array2=result.fun[[1]]
  array3=result.fun[[2]]
  .
  .
 
  I want the following results:
 
   probe_name chr_id position array1 array2 array3
  1C-7SARK  1   849467 10 10   10
  2C-4WYLN  1   854278 10 10   10
  3C-3BFNY  1   854471 10  10   10
  4C-7ONNE  1   874460 10 10   10
  5C-6HYCN  1   874571 10 10   10
  6C-7SCGC  1   874609 10 10   10
 
 
  I used the following codes:
 
  for (i in 2:3) {
 
  assign(lab=paste(array, i, sep=), value=result.fun[[i-1]])
 
  first -cbind(first, lab)
 
  }
 
  *Error in assign(lab = paste(array, i, sep = ), value =
 result.fun[[i
  -
  :
   unused argument(s) (lab = paste(array, i, sep = ))*
 
 
  Can anyone give some hits or helps?
 
  Thanks so much!
 
 
 
 
 
 
  --
  Sincerely,
  Changbin
  --
 
 [[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.
 
 
 
 
 
  --
  Sincerely,
  Changbin
  --
 
 [[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.
 




-- 
Sincerely,
Changbin
--

Changbin Du
Data Analysis Group, Affymetrix Inc
6550 Emeryville, CA, 94608

[[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] create variables through a loop

2011-09-22 Thread Changbin Du
HI, Michael,

The following codes are great!

first.out - do.call(cbind, list(first, result.fun))

colnames(first.out) - c(colnames(first), paste(array,
seq(length(result.fun)), sep=))

 head(first.out)
  probe_name chr_id position array1 array2 array3 array4 array5 array6
array7
1C-7SARK  1   849467 10 10 10 10 10 10
10
2C-4WYLN  1   854278 10 10 10 10 10 10
10
3C-3BFNY  1   854471 10 10 10 10 10 10
10
4C-7ONNE  1   874460 10 10 10 10 10 10
10
5C-6HYCN  1   874571 10 10 10 10 10 10
10
6C-7SCGC  1   874609 10 10 10 10 10 10
10
  array8 array9 array10 array11 array12 array13 array14 array15 array16
array17
1 10 10  10  10  10  10  10  10  10
10
2 10 10  10  10  10  10  10  10  10
10
3 10 10  10  10  10  10  10  10  10
10
4 10 10  10  10  10  10  10  10  10
10
5 10 10  10  10  10  10  10  10  10
10
6 10 10  10  10  10  10  10  10  10
10
  array18 array19 array20 array21 array22 array23 array24 array25 array26
1  10  10  10  10  10  10  10  10  10
2  10  10  10  10  10  10  10  10  10
3  10  10  10  10  10  10  10  10  10
4  10  10  10  10  10  10  10  10  10
5  10  10  10  10  10  10  10  10  10
6  10  10  10  10  10  10  10  10  10
  array27 array28 array29 array30 array31 array32 array33 array34 array35
1  10  10  10  10  10  10  10  10  10
2  10  10  10  10  10  10  10  10  10
3  10  10  10  10  10  10  10  10  10
4  10  10  10  10  10  10  10  10  10
5  10  10  10  10  10  10  10  10  10
6  10  10  10  10  10  10  10  10  10
  array36 array37 array38 array39 array40 array41 array42 array43 array44
1  10  10  10  10  10  10  10  10  10
2  10  10  10  10  10  10  10  10  10
3  10  10  10  10  10  10  10  10  10
4  10  10  10  10  10  10  10  10  10
5  10  10  10  10  10  10  10  10  10
6  10  10  10  10  10  10  10  10  10
  array45 array46 array47 array48
1  10  10  10  10
2  10  10  10  10
3  10  10  10  10
4  10  10  10  10
5  10  10  10  10
6  10  10  10  10


Appreciated your great helps!




On Thu, Sep 22, 2011 at 10:55 AM, Changbin Du changb...@gmail.com wrote:

 Thanks so much, Michael!


 head(first)
   probe_name chr_id position array1
 1C-7SARK  1   849467 10
 2C-4WYLN  1   854278 10
 3C-3BFNY  1   854471 10
 4C-7ONNE  1   874460 10
 5C-6HYCN  1   874571 10
 6C-7SCGC  1   874609 10

 for( i in 2:3) {
 + label - paste(array, i, sep=)
 + assign(label, value = result.fun[[i-1]] )
 + first - cbind(first, get(label))
 + }

  head(first)
   probe_name chr_id position array1 get(label) get(label)

 1C-7SARK  1   849467 10 10 10
 2C-4WYLN  1   854278 10 10 10
 3C-3BFNY  1   854471 10 10 10
 4C-7ONNE  1   874460 10 10 10
 5C-6HYCN  1   874571 10 10 10
 6C-7SCGC  1   874609 10 10 10

 **
 I can use the codes to change the columns names.

 colnames(first.out) - c(colnames(first), paste(array,
 seq(length(result.fun)), sep=))


 I am running:

  first.out - do.call(cbind, list(first, result.fun))

 and

  first.out - cbind(first, result.fun)

 IT has been 10 mins, and I will let you know the results.

 Thanks so much for the great helps!






 On Thu, Sep 22, 2011 at 10:37 AM, R. Michael Weylandt 
 michael.weyla...@gmail.com wrote:

 There are a few ways to proceed from here. If you are really committed to
 this loop + assign idea, I'd provide the following code:

 for( i in 2:3) {
 label - paste(array, i, sep=)
 assign(label, value = result.fun[[i-1]] )
 first - cbind(first, get(label))
 }

 However, this is generally pretty inefficient. Why not something more like
 the following?

 first.out - do.call(cbind, list(first, result.fun))

 If you need the names to be arrayi you can add this line:
 colnames(first.out) - 

Re: [R] create variables through a loop

2011-09-22 Thread David Winsemius


On Sep 22, 2011, at 2:06 PM, Changbin Du wrote:


HI, Michael,

The following codes are great!

first.out - do.call(cbind, list(first, result.fun))


Would this have been easier?

 dat[ , c(1:3, rep(4, 5))]
  probe_name chr_id position array1 array1.1 array1.2 array1.3
1C-7SARK  1   849467 10   10   10   10
2C-4WYLN  1   854278 10   10   10   10
3C-3BFNY  1   854471 10   10   10   10
4C-7ONNE  1   874460 10   10   10   10
5C-6HYCN  1   874571 10   10   10   10
6C-7SCGC  1   874609 10   10   10   10
  array1.4
1   10
2   10
3   10
4   10
5   10
6   10

With the obvious substitution of 45 as the second argument to `rep`  
where you currently see 5.




colnames(first.out) - c(colnames(first), paste(array,
seq(length(result.fun)), sep=))


They may or may not need to be renamed.

--
David.




head(first.out)

 probe_name chr_id position array1 array2 array3 array4 array5 array6
array7
1C-7SARK  1   849467 10 10 10 10 10 10
10
2C-4WYLN  1   854278 10 10 10 10 10 10
10
3C-3BFNY  1   854471 10 10 10 10 10 10
10
4C-7ONNE  1   874460 10 10 10 10 10 10
10
5C-6HYCN  1   874571 10 10 10 10 10 10
10
6C-7SCGC  1   874609 10 10 10 10 10 10
10
 array8 array9 array10 array11 array12 array13 array14 array15 array16
array17
1 10 10  10  10  10  10  10  10   
10

10
2 10 10  10  10  10  10  10  10   
10




snipped extraneous output.


Appreciated your great helps!




On Thu, Sep 22, 2011 at 10:55 AM, Changbin Du changb...@gmail.com  
wrote:



Thanks so much, Michael!


head(first)
 probe_name chr_id position array1
1C-7SARK  1   849467 10
2C-4WYLN  1   854278 10
3C-3BFNY  1   854471 10
4C-7ONNE  1   874460 10
5C-6HYCN  1   874571 10
6C-7SCGC  1   874609 10

for( i in 2:3) {
+ label - paste(array, i, sep=)
+ assign(label, value = result.fun[[i-1]] )
+ first - cbind(first, get(label))
+ }

head(first)
 probe_name chr_id position array1 get(label) get(label)

1C-7SARK  1   849467 10 10 10
2C-4WYLN  1   854278 10 10 10
3C-3BFNY  1   854471 10 10 10
4C-7ONNE  1   874460 10 10 10
5C-6HYCN  1   874571 10 10 10
6C-7SCGC  1   874609 10 10 10

**
I can use the codes to change the columns names.

colnames(first.out) - c(colnames(first), paste(array,
seq(length(result.fun)), sep=))


I am running:


first.out - do.call(cbind, list(first, result.fun))


and


first.out - cbind(first, result.fun)


IT has been 10 mins, and I will let you know the results.

Thanks so much for the great helps!






On Thu, Sep 22, 2011 at 10:37 AM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

There are a few ways to proceed from here. If you are really  
committed to

this loop + assign idea, I'd provide the following code:

for( i in 2:3) {
   label - paste(array, i, sep=)
   assign(label, value = result.fun[[i-1]] )
   first - cbind(first, get(label))
}

However, this is generally pretty inefficient. Why not something  
more like

the following?

first.out - do.call(cbind, list(first, result.fun))

If you need the names to be arrayi you can add this line:
colnames(first.out) - c(colnames(first), paste(array,
seq(length(result.fun)), sep=))

I'm unable to test this on your (unprovided) data, but here's an  
example

of how this works:

first = data.frame(x = 1:3, y = 6:8, z = 11:13)

a = data.frame(a = 1:3)
b = data.frame(b = 4:6)
result.fun = list(a,b)

first.out - do.call(cbind, list(first, result.fun))
print(first.out)

which provides this output.

   x y  z a b
1 1 6 11 1 4
2 2 7 12 2 5
3 3 8 13 3 6

More generally, you really should read about how arguments and  
assignments

work in R. See, e.g., 8.2.26 in the R inferno.

Michael Weylandt


On Thu, Sep 22, 2011 at 1:21 PM, Changbin Du changb...@gmail.com  
wrote:



HI, Michael,

I tried use x and got the following:


for (i in 2:3) {

+
+ assign(x=paste(array, i, sep=), value=result.fun[[i-1]])
+
+ first -cbind(first, x)
+
+ }
*Error in cbind(first, x) : object 'x' not found
*

But I checked the
ls()
array2   array3were created.

Can I put them into the first data set by loop, or manually?

Thanks!


P.S   I search the similar codes from google and can not work as I
expected.

Thanks!



On Thu, Sep 22, 2011 at 10:11 AM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

There is no lab= argument for assign() hence the error. Did  
someone
provide you with example code that suggested such a 

[R] suggestions argument in rbga function in genalg package

2011-09-22 Thread Joseph Boyer
Would someone be so kind as to provide example code where they use the 
suggestions argument in  the rgba function
In genalg? I can't get it to work.

The following code works just fine:

GenFit -rbga(Lower, Upper, evalFunc = evaluate)

Lower and Upper are each numeric vectors with 7 elements. Evaluate is an 
objective function.
However, when I want to use a suggested chromosome, I get an error message. My 
code is

start - c(1,0.1,10, 100,1,100,1)

suggestions - list(start)

GenFit -rbga(Lower, Upper, suggestions = suggestions, evalFunc = evaluate)

The error message is:

Error in 1:suggestionCount : argument of length 0

Thanks.



[[alternative HTML version deleted]]

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


Re: [R] Quelplot

2011-09-22 Thread Michael Friendly

On 9/21/2011 3:11 PM, Hadley Wickham wrote:

Hi all,

Does anyone have an R implementation of the queplot (K. M. Goldberg
and B. Iglewicz. Bivariate extensions of the boxplot. Technometrics,
34(3):pp. 307–320, 1992)?  I'm struggling with the estimation of the
asymmetry parameters.


Do you have some code you have tried or don't you know how to calculate 
P_1 and P_2?  The description is not particularly explicit, but the

major/minor axes of the ellipse are defined in terms of standard scores
for X and Y as
Z1 = Y + X
Z2 = Y - X

If you can figure out what they mean by proportion of the total 
standard deviation due to residuals..., then something like


P_1 = sum(Z_10) / n
P_2 = sum(Z_20) / n

Maybe Boris can help.

Thanks for bringing this to our attention.  If the bagplot is a totally
non-parametric analog of a bivariate boxplot, the quelplot might
be a 2df parametric version.

-Michael



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [R] Proportions of a vector

2011-09-22 Thread Jim Silverton

 Hi all,
 I have a vector xm say:  xm = c(1,2,3,4,5,5,5,6,6)

 I want to return a vector with the corresponding probabilities based on the
 amount of times the numbers occurred. For example, I should get the
 following vector for xm:
 prob.xm = c(1/9, 1/9, 1/9, 1/9, 3/9, 3/9, 3/9, 2/9, 2/9)


Using prop.table gives:


Usage (with table)

 prob.xm - round( prop.table(table(xm)), digits=3)
 prob.xm
xm
   1 2 3 4 5 6
0.111 0.111 0.111 0.111 0.333 0.222

But I want the entire length of probabilities, not just a condensed version.
Any help is greatl appreciated.



-- 
Thanks,
Jim.

[[alternative HTML version deleted]]

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


Re: [R] Proportions of a vector

2011-09-22 Thread Sarah Goslee
If the values in xm are always going to be consecutive integers 1:n, then this:

 prob.xm[xm]
xm
1 2 3 4 5 5 5 6 6
0.111 0.111 0.111 0.111 0.333 0.333 0.333 0.222 0.222


otherwise:
 prob.xm[as.numeric(as.factor(xm))]
xm
1 2 3 4 5 5 5 6 6
0.111 0.111 0.111 0.111 0.333 0.333 0.333 0.222 0.222

(equivalent in this case).

Sarah

On Thu, Sep 22, 2011 at 3:41 PM, Jim Silverton jim.silver...@gmail.com wrote:

 Hi all,
 I have a vector xm say:  xm = c(1,2,3,4,5,5,5,6,6)

 I want to return a vector with the corresponding probabilities based on the
 amount of times the numbers occurred. For example, I should get the
 following vector for xm:
 prob.xm = c(1/9, 1/9, 1/9, 1/9, 3/9, 3/9, 3/9, 2/9, 2/9)


 Using prop.table gives:


 Usage (with table)

 prob.xm - round( prop.table(table(xm)), digits=3)
 prob.xm
 xm
   1     2     3     4     5     6
 0.111 0.111 0.111 0.111 0.333 0.222

 But I want the entire length of probabilities, not just a condensed version.
 Any help is greatl appreciated.




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

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


Re: [R] Proportions of a vector

2011-09-22 Thread R. Michael Weylandt
Try this:

long.prop.table - function(x) {
x - as.factor(x)
p = tabulate(x)/length(x)
p[x]
}

Michael Weylandt

On Thu, Sep 22, 2011 at 3:41 PM, Jim Silverton jim.silver...@gmail.comwrote:

 
  Hi all,
  I have a vector xm say:  xm = c(1,2,3,4,5,5,5,6,6)
 
  I want to return a vector with the corresponding probabilities based on
 the
  amount of times the numbers occurred. For example, I should get the
  following vector for xm:
  prob.xm = c(1/9, 1/9, 1/9, 1/9, 3/9, 3/9, 3/9, 2/9, 2/9)
 

 Using prop.table gives:


 Usage (with table)

  prob.xm - round( prop.table(table(xm)), digits=3)
  prob.xm
 xm
   1 2 3 4 5 6
 0.111 0.111 0.111 0.111 0.333 0.222

 But I want the entire length of probabilities, not just a condensed
 version.
 Any help is greatl appreciated.



 --
 Thanks,
 Jim.

[[alternative HTML version deleted]]

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


[[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] solving linear equations

2011-09-22 Thread varunshivashankar
Hi Bolker,

Sorry for the late reply and thank you very much. The code works fine.
I am indeed sorry for telling you it was a linear equation.

I am just trying to use the R code to perform the curve fitting problem for
the team of biologists. The data given to me was a sample data and they told
me they use the 4 parameter and 5 parameter log logistic functions, they
haven't exactly given me anything else. Is there a more general way to find
the parameters and hence perform curve fitting on a given set of data.

I just want to know how you came up with the initial values of a and d. I
would also like to know if there is a formula or an approximation, given the
data, to find the same, as they want the process to be automated.

Please do let me know, and I am much obliged to whatever help I get.

Varun

--
View this message in context: 
http://r.789695.n4.nabble.com/solving-linear-equations-tp3811144p3834421.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] Quelplot

2011-09-22 Thread Goldberg, Ken [JRDUS]
Hi Hadley,

Thank-you for your interest in the quelplot. I agree that Rand Wilcox only 
published relplot code. I do not know of any other R or S implementations. I 
wrote all of my code in HTBasic (Rocky Mountain BASIC) originally. I later 
copied some of it to SAS proc iml, but I think that was just the multivariate 
analog of the relplot (including the bivariate relplot). 

I wonder if there is a typo in the Technometrics article, because the quelplot 
always worked fine for me but I recall somebody else having trouble with 
programming it. I think I sent that person my HTBasic code back in the early 
1990's. Perhaps that was Rand. I think I did send it to somebody who asked for 
it in Australia.

I will have to search for my code. I know I have it on my PC in HTBasic format, 
but it has been a long time since I used it and may have to work a bit even to 
print it or to get it out into a DOS text file. I may have a DOS text file of 
it at home on a 3.5 diskette, but even if I could find it, I doubt if I could 
find a disk drive to read it! When I get it in a useable format, I can send you 
that code, or at least the parts of it relevant to the quelplot, if you would 
like it. Perhaps just browsing it would show the problem you are having with my 
Technometrics article, whether it was a typo or just something that I wrote 
poorly. There may just be a few subroutines that would need translating from 
HTBasic into R, and that when added to Rand Wilcox's library would give his 
software the quelplot capacity.

Hadley, I took your R/Splus Fundamentals and Programming Techniques course 5 
years ago in Washington DC, but have used R just a couple of times since. I've 
rarely programmed in R, but this would be a good project for me to start with. 
It may be a few weeks though until I can get started on any of this though, but 
I will keep you informed.

Regards, 
 Ken 
 
Kenneth M. Goldberg, Ph.D. 
Associate Director, Nonclinical Statistics 
Johnson  Johnson Pharmaceutical Research  Development, LLC
965 Chesterbrook Boulevard, Mailstop C-4-1
Wayne, PA 19087
Tel  610-651-6924   Fax 610-651-6717
kgold...@its.jnj.com

Confidentiality Notice:  This e-mail transmission may contain confidential or 
legally privileged information that is intended only for the individual or 
entity named in the e-mail address.  If you are not the intended recipient, you 
are hereby notified that any disclosure, copying, distribution, or reliance 
upon the contents of this e-mail is strictly prohibited. If you have received 
this e-mail transmission in error, please reply to the sender, so that Centocor 
can arrange for proper delivery, and then please delete the message from your 
inbox.  Thank you.






Does anyone have an R implementation of the queplot (K. M. Goldberg
 and B. Iglewicz. Bivariate extensions of the boxplot. Technometrics,
 34(3):pp. 307-320, 1992)?  I'm struggling with the estimation of the
 asymmetry parameters.

-Original Message-
From: h.wick...@gmail.com [mailto:h.wick...@gmail.com] On Behalf Of Hadley 
Wickham
Sent: Thursday, September 22, 2011 1:56 PM
To: Richard M. Heiberger
Cc: R-help; BORIS IGLEWICZ; Goldberg, Ken [JRDUS]
Subject: Re: [R] Quelplot

Thanks Rich - unfortunately, as far as I can, tell Rand Wilcox only
developed relplot code.
Hadley

On Thu, Sep 22, 2011 at 12:52 PM, Richard M. Heiberger r...@temple.edu wrote:
 Hadley,

 I forwarded your request to Boris and Ken.  Here is Boris' response.

 Rich


 Dear Richard:

    I looked a bit more and found the second edition of book referenced, Rand
 R Wilcox, Introduction to Robust Estimation and Hypothesis Testing, Second
 Edition, Academic Press, 2005. It has over 600 quotes on google scholar. If
 my memory is correct, Wilcox developed code for relplots and possibly
 quelplots.

 Best Wishes,
 Boris

 On Wed, Sep 21, 2011 at 3:11 PM, Hadley Wickham had...@rice.edu wrote:

 Hi all,

 Does anyone have an R implementation of the queplot (K. M. Goldberg
 and B. Iglewicz. Bivariate extensions of the boxplot. Technometrics,
 34(3):pp. 307-320, 1992)?  I'm struggling with the estimation of the
 asymmetry parameters.

 Hadley

 --
 Assistant Professor / Dobelman Family Junior Chair
 Department of Statistics / Rice University
 http://had.co.nz/

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





-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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

[R] How make a x,y dataset from a formula based entry

2011-09-22 Thread trekvana
Hello all, 

So I am using the (formula entry) method for randomForests:

randomForest(y~x1+x2+...+x39+x40,data=xxx,...) but the issue is that some of
the items in that package dont take a formula entry - you have to explicitly
state the y and x vector:

randomForest(x=xxx[,c('x1','x2',...,'x40')],y=xxx[,'y'],...)

Now my question is whether there is a function/way to tell R to take a
formula and make the two corresponding datasets [x,y] (that way I dont have
to create the x dataset manually with all 40 variables I have).

There must be a more elegant way to do this than
x=xxx[,c('x1','x2',...,'x40')] 

Thanks!
George

--
View this message in context: 
http://r.789695.n4.nabble.com/How-make-a-x-y-dataset-from-a-formula-based-entry-tp3834477p3834477.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How make a x,y dataset from a formula based entry

2011-09-22 Thread Jean-Christophe BOUËTTÉ
Hello,
You can check ?model.frame.
I do not know however to extract only the right-hand of left-hand part
of a formula.

JC

2011/9/22 trekvana trekv...@aol.com:
 Hello all,

 So I am using the (formula entry) method for randomForests:

 randomForest(y~x1+x2+...+x39+x40,data=xxx,...) but the issue is that some of
 the items in that package dont take a formula entry - you have to explicitly
 state the y and x vector:

 randomForest(x=xxx[,c('x1','x2',...,'x40')],y=xxx[,'y'],...)

 Now my question is whether there is a function/way to tell R to take a
 formula and make the two corresponding datasets [x,y] (that way I dont have
 to create the x dataset manually with all 40 variables I have).

 There must be a more elegant way to do this than
 x=xxx[,c('x1','x2',...,'x40')]

 Thanks!
 George

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/How-make-a-x-y-dataset-from-a-formula-based-entry-tp3834477p3834477.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] Limitations of audio processing in R

2011-09-22 Thread Carl Witthoft
With all due respect to those of us (including me) who love R,  when it 
comes to audio processing w/ freeware,


Audacity   FTW.

'nuff said

Carl

--
-
Sent from my Cray XK6

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


Re: [R] create variables through a loop

2011-09-22 Thread Dennis Murphy
Hi:

Here's one approach with package reshape2. I copied the same data
frame 10 times to illustrate the idea, but as long as your data frames
have the same structure (same variables, same dimension), this should
work.

library('plyr')
library('reshape2')

# Use your example data as the template:
ds - read.table(textConnection(
 probe_name chr_id position  y
1C-7SARK  1   849467 10
2C-4WYLN  1   854278 10
3C-3BFNY  1   854471 10
4C-7ONNE  1   874460 10
5C-6HYCN  1   874571 10
6C-7SCGC  1   874609 10), header = TRUE, stringsAsFactors = FALSE)
closeAllConnections()

# Note how I use y for the response instead of arrayxx.

# Copy the data frame 10 times and put it into a list; these are
# placeholders for the real data frames
L - lapply(seq_len(10), function(i) ds)

# Name the list components array01  - array10, ...
names(L) - c(paste('array0', 1:9, sep = ''), 'array10')

# The advantage of using rbind in conjunction with ldply() is that it outputs
# the list names as an .id variable
u - ldply(L, rbind)
head(u)

# Reshape the data so that the y values in each component are associated
# with the component name:
dcast(u, probe_name + chr_id + position ~ .id, value_var = 'y')
  probe_name chr_id position array01 array02 array03 array04 array05 array06
1C-3BFNY  1   854471  10  10  10  10  10  10
2C-4WYLN  1   854278  10  10  10  10  10  10
3C-6HYCN  1   874571  10  10  10  10  10  10
4C-7ONNE  1   874460  10  10  10  10  10  10
5C-7SARK  1   849467  10  10  10  10  10  10
6C-7SCGC  1   874609  10  10  10  10  10  10
  array07 array08 array09 array10
1  10  10  10  10
2  10  10  10  10
3  10  10  10  10
4  10  10  10  10
5  10  10  10  10
6  10  10  10  10

HTH,
Dennis

On Thu, Sep 22, 2011 at 10:07 AM, Changbin Du changb...@gmail.com wrote:
 HI, Dear R community,

 I am trying to created new variables and put into a data frame through a
 loop.

 My original data set:

 head(first)
  probe_name chr_id position array1
 1    C-7SARK      1   849467     10
 2    C-4WYLN      1   854278     10
 3    C-3BFNY      1   854471     10
 4    C-7ONNE      1   874460     10
 5    C-6HYCN      1   874571     10
 6    C-7SCGC      1   874609     10


 I have 48 other array data from a list result.fun
 array2=result.fun[[1]]
 array3=result.fun[[2]]
 .
 .

 I want the following results:

  probe_name chr_id position array1 array2 array3
 1    C-7SARK      1   849467     10     10       10
 2    C-4WYLN      1   854278     10     10       10
 3    C-3BFNY      1   854471     10      10       10
 4    C-7ONNE      1   874460     10     10       10
 5    C-6HYCN      1   874571     10     10       10
 6    C-7SCGC      1   874609     10     10       10


 I used the following codes:

 for (i in 2:3) {

 assign(lab=paste(array, i, sep=), value=result.fun[[i-1]])

 first -cbind(first, lab)

 }

 *Error in assign(lab = paste(array, i, sep = ), value = result.fun[[i -
 :
  unused argument(s) (lab = paste(array, i, sep = ))*


 Can anyone give some hits or helps?

 Thanks so much!






 --
 Sincerely,
 Changbin
 --

        [[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] Bivariate Scatter Plots with Lattice

2011-09-22 Thread Rich Shepard

  Data frame has this structure:

'data.frame':   11169 obs. of  4 variables:
 $ stream  : Factor w/ 37 levels Burns,CIL,..: 1 1 1 1 1 1 1 1 1 1 ...
 $ sampdate: Date, format: 1987-07-23 1987-09-17 ...
 $ param   : Factor w/ 8 levels As,Ca,Cl,..: 1 1 1 1 1 1 1 1 1 1 ...
 $ quant   : num  0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0 ...

  I want to create scatter plots of the concentrations (numeric column
'quant') for two specified chemicals (factor column 'param') for all dates
and streams (factor column 'stream') in which there are data.

  Looking in ?lattice and Deepayan's book did not provide an example. I've
tried varies formulae but without success, and would appreciate a pointer to
documentation and examples of how to write such an expression.

Rich

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


Re: [R] Bivariate Scatter Plots with Lattice

2011-09-22 Thread Dennis Murphy
Hi:

Question: Do you want 37 different panels with plots of quant vs. date
by param, or two panels (one per chemical) with all 37 streams? If you
only want two of the eight chemicals, I'd suggest using subset() to
select out the pair you want and then redefine the param factor so
that the subset data frame has two factor levels instead of eight.
Since there are several ways to interpret 'in which there are data',
you might want to expound a little further about your intentions in
that regard.

HTH,
Dennis

On Thu, Sep 22, 2011 at 3:03 PM, Rich Shepard rshep...@appl-ecosys.com wrote:
  Data frame has this structure:

 'data.frame':   11169 obs. of  4 variables:
  $ stream  : Factor w/ 37 levels Burns,CIL,..: 1 1 1 1 1 1 1 1 1 1 ...
  $ sampdate: Date, format: 1987-07-23 1987-09-17 ...
  $ param   : Factor w/ 8 levels As,Ca,Cl,..: 1 1 1 1 1 1 1 1 1 1 ...
  $ quant   : num  0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0 ...

  I want to create scatter plots of the concentrations (numeric column
 'quant') for two specified chemicals (factor column 'param') for all dates
 and streams (factor column 'stream') in which there are data.

  Looking in ?lattice and Deepayan's book did not provide an example. I've
 tried varies formulae but without success, and would appreciate a pointer to
 documentation and examples of how to write such an expression.

 Rich

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

2011-09-22 Thread David Winsemius


On Sep 22, 2011, at 6:03 PM, Rich Shepard wrote:


 Data frame has this structure:

'data.frame':   11169 obs. of  4 variables:
$ stream  : Factor w/ 37 levels Burns,CIL,..: 1 1 1 1 1 1 1 1 1  
1 ...

$ sampdate: Date, format: 1987-07-23 1987-09-17 ...
$ param   : Factor w/ 8 levels As,Ca,Cl,..: 1 1 1 1 1 1 1 1 1  
1 ...

$ quant   : num  0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0 ...

 I want to create scatter plots of the concentrations (numeric column
'quant') for two specified chemicals (factor column 'param') for all  
dates

and streams (factor column 'stream') in which there are data.


Scatterplots are for two variables with  continuous valued data. You  
are asking about one such variable, apparently within some combination  
of groups of discrete variables. Look at dotplot or bwplot examples.




 Looking in ?lattice and Deepayan's book did not provide an example.  
I've
tried varies formulae but without success, and would appreciate a  
pointer to

documentation and examples of how to write such an expression.


The problem is with the choice of plotting function not fitting the  
problem, not with the formula.


--

David Winsemius, MD
West Hartford, CT

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


[R] How to do Multiple Comparisons for a Mixed Effects Model

2011-09-22 Thread Allan Carson

Hello everyone I am currently trying to conduct analysis of my graduate thesis 
data using a mixed effects model and I have reached an impass. When I try to 
conduct a multiple comparison, I get an error (See below):  fm3- 
lme(abovegroundbiomass.m.2~medium*amelioration*fertilizer*treatment, 
random=~1|block/medium/amelioration/fertilizer)  tukeytest-glht(fm3, 
linfct=mcp(treatment=Tukey))
Error in contrMat(table(mf[[nm]]), type = types[pm]) : 
  less than two groups
 

I wonder if anyone could help me interpret this error. Many thanks. Allan Carson

  
[[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] Error: cannot allocate vector of size xxx

2011-09-22 Thread Mario Montecinos Carvajal
Michale and Paul

Thanks for your quick response.

Michael, I am running a 32bit version of R

 sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32


Paul, the dimension of the Data Frame with I am workis is
 dim(d)
 [1] 7017411
And the size of the file that contains the data is 2946 Kb


The script that I use for manage the data is:

#clean the workspace
rm(list = ls(all = TRUE))

#Increase the memory size
memory.limit(size=4000)

#Set Directory of WorkSpace where whe have the data
setwd('C:/Users/XXX/XXX/R/')

#load data
dat - read.table('dat_fin_age.txt')

#delete empty registry
d-na.omit(dat)
remove(dat) # remove dat (intermedia object) for release resource

#Asigned the name to the variables in the data
names(d)-
c('pesq','year','month','sex','length','weigth','mature','age','soi','temp','k')

#define the ages over the analysis is focuses.
minage-1 # minimum age
maxage-6 # maximum age

# One of the diferent lm I have been tested

l6w-lm(length~as.factor(age)*as.factor(year)*as.factor(sex)*soi*k,data=d[d$age
%in% minage:maxage,])

Today I will prove your recommendation to use the package biglm

Thanks to both for your Help

Regards

2011/9/22 Paul Hiemstra paul.hiems...@knmi.nl

  On 09/22/2011 04:00 AM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:
  Are you running a 32bit or 64bit version of R? Type sessionInfo() to see.
 
  Michael

 ...in addition, how large is your dataset? Please provide us with a self
 contained example which reproduces this problem. You could take a look
 at the biglm package.

 regards,
 Paul

  On Sep 21, 2011, at 10:41 PM, Mario Montecinos Carvajal 
 mariomonteci...@gmail.com wrote:
 
  Hi
 
  I am a new user of the mail list.
 
  Mi problem occurs when I try to test a lineal model (lm), becouse appear
 the
  messaje Error: cannot allocate vector of size xxx
 
  The data frame whit I am working, Have
 
  dim(d)
  [1] 7017411
 
  and the function i am test is:
 
 
 lm(length~as.factor(age)*as.factor(year)*as.factor(sex)*soi*k,data=d[d$age
  %in% minage:maxage,])
 
  I tried with a diferent options for solve this problem, but any one give
 me
  results.
 
  I tried with:
 
  Change in Function: memory.limit(size=4000)
 
  Change the setting in Windows using  BCDEdit /set
 
  Change in the memory availability for R, change the path of the program
  (suggested for other user)
 
  My computer have 4GB RAM, Have 20 GB of Virtual Memory, HDD 300 GB with
 200
  GB of free space and Windows 7 as OS and my R version is 2.11.1
 
  I need solve this problem, any help or suggestion will be very well
  received.
 
  I've been thinking in change the OS, but this is may last option.
 
  Regards
 
  I read
 
 
  --
  Mario Montecinos C.
  Biologo Marino
  Dr (c) en Ciencias
  Universidad Austral de Chile
 
 
  Los acentos han sido omitidos voluntariamente para evitar
 incompatibilidades
  Evite enviar cartas impresas, cuidemos el medio ambiente y evitemos el
  uso innecesario de papel.
 
 [[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.


 --
 Paul Hiemstra, Ph.D.
 Global Climate Division
 Royal Netherlands Meteorological Institute (KNMI)
 Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
 P.O. Box 201 | 3730 AE | De Bilt
 tel: +31 30 2206 494

 http://intamap.geo.uu.nl/~paul
 http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770




-- 
Mario Montecinos C.
Biologo Marino
Dr (c) en Ciencias
Universidad Austral de Chile


Los acentos han sido omitidos voluntariamente para evitar incompatibilidades
Evite enviar cartas impresas, cuidemos el medio ambiente y evitemos el
uso innecesario de papel.

[[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] create variables through a loop

2011-09-22 Thread Changbin Du
HI, Dennis,

Thanks for the helps! All roads to Rome, appreciated!



On Thu, Sep 22, 2011 at 2:54 PM, Dennis Murphy djmu...@gmail.com wrote:

 Hi:

 Here's one approach with package reshape2. I copied the same data
 frame 10 times to illustrate the idea, but as long as your data frames
 have the same structure (same variables, same dimension), this should
 work.

 library('plyr')
 library('reshape2')

 # Use your example data as the template:
 ds - read.table(textConnection(
  probe_name chr_id position  y
 1C-7SARK  1   849467 10
 2C-4WYLN  1   854278 10
 3C-3BFNY  1   854471 10
 4C-7ONNE  1   874460 10
 5C-6HYCN  1   874571 10
 6C-7SCGC  1   874609 10), header = TRUE, stringsAsFactors =
 FALSE)
 closeAllConnections()

 # Note how I use y for the response instead of arrayxx.

 # Copy the data frame 10 times and put it into a list; these are
 # placeholders for the real data frames
 L - lapply(seq_len(10), function(i) ds)

 # Name the list components array01  - array10, ...
 names(L) - c(paste('array0', 1:9, sep = ''), 'array10')

 # The advantage of using rbind in conjunction with ldply() is that it
 outputs
 # the list names as an .id variable
 u - ldply(L, rbind)
 head(u)

 # Reshape the data so that the y values in each component are associated
 # with the component name:
 dcast(u, probe_name + chr_id + position ~ .id, value_var = 'y')
  probe_name chr_id position array01 array02 array03 array04 array05 array06
 1C-3BFNY  1   854471  10  10  10  10  10
  10
 2C-4WYLN  1   854278  10  10  10  10  10
  10
 3C-6HYCN  1   874571  10  10  10  10  10
  10
 4C-7ONNE  1   874460  10  10  10  10  10
  10
 5C-7SARK  1   849467  10  10  10  10  10
  10
 6C-7SCGC  1   874609  10  10  10  10  10
  10
  array07 array08 array09 array10
 1  10  10  10  10
 2  10  10  10  10
 3  10  10  10  10
 4  10  10  10  10
 5  10  10  10  10
 6  10  10  10  10

 HTH,
 Dennis

 On Thu, Sep 22, 2011 at 10:07 AM, Changbin Du changb...@gmail.com wrote:
  HI, Dear R community,
 
  I am trying to created new variables and put into a data frame through a
  loop.
 
  My original data set:
 
  head(first)
   probe_name chr_id position array1
  1C-7SARK  1   849467 10
  2C-4WYLN  1   854278 10
  3C-3BFNY  1   854471 10
  4C-7ONNE  1   874460 10
  5C-6HYCN  1   874571 10
  6C-7SCGC  1   874609 10
 
 
  I have 48 other array data from a list result.fun
  array2=result.fun[[1]]
  array3=result.fun[[2]]
  .
  .
 
  I want the following results:
 
   probe_name chr_id position array1 array2 array3
  1C-7SARK  1   849467 10 10   10
  2C-4WYLN  1   854278 10 10   10
  3C-3BFNY  1   854471 10  10   10
  4C-7ONNE  1   874460 10 10   10
  5C-6HYCN  1   874571 10 10   10
  6C-7SCGC  1   874609 10 10   10
 
 
  I used the following codes:
 
  for (i in 2:3) {
 
  assign(lab=paste(array, i, sep=), value=result.fun[[i-1]])
 
  first -cbind(first, lab)
 
  }
 
  *Error in assign(lab = paste(array, i, sep = ), value = result.fun[[i
 -
  :
   unused argument(s) (lab = paste(array, i, sep = ))*
 
 
  Can anyone give some hits or helps?
 
  Thanks so much!
 
 
 
 
 
 
  --
  Sincerely,
  Changbin
  --
 
 [[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.
 




-- 
Sincerely,
Changbin
--

[[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] (sin asunto)

2011-09-22 Thread Ruth Arias
hello,

I want to  know as mortality in different families of epiphytes after selective 
logging in the forest
I want to make a survival analysis with left and right censored data.  My study 
begins in 2004 but I have many individuals who enter the study in 2007
I have tried this:
                    surara-survfit(Surv(fecha,estado)~categoria)
fecha= time 

estado= dead
categoria= control and experimental

but it is working just with right censored data
[[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] Error: cannot allocate vector of size xxx

2011-09-22 Thread David Winsemius


On Sep 22, 2011, at 5:00 PM, Mario Montecinos Carvajal wrote:


Michale and Paul

Thanks for your quick response.

Michael, I am running a 32bit version of R


sessionInfo()

R version 2.11.1 (2010-05-31)
i386-pc-mingw32


Paul, the dimension of the Data Frame with I am workis is
dim(d)

[1] 7017411

And the size of the file that contains the data is 2946 Kb


Not a very big dataset for a workspace that should be 2GB or more.




The script that I use for manage the data is:

#clean the workspace
rm(list = ls(all = TRUE))


I hate it when people put that code in without a warning and  
preferably commented out. Some us boobs have been known to paste in  
code without mentally single stepping through it.




#Increase the memory size
memory.limit(size=4000)

#Set Directory of WorkSpace where whe have the data
setwd('C:/Users/XXX/XXX/R/')

#load data
dat - read.table('dat_fin_age.txt')

#delete empty registry
d-na.omit(dat)
remove(dat) # remove dat (intermedia object) for release resource

#Asigned the name to the variables in the data
names(d)-
c 
('pesq 
','year 
','month','sex','length','weigth','mature','age','soi','temp','k')


Bad idea to use length as a variable name. It is a function name.



#define the ages over the analysis is focuses.
minage-1 # minimum age
maxage-6 # maximum age


At this point you should have offered:

 str(d)



# One of the diferent lm I have been tested




You are constructing a 5-way interaction that will have way more  
interactions than you will know what to do with. Why not start out  
with a simple model and move up from there? If these ages and years  
are integer valued then you may not have enough  data to support such  
a model with only 70k records.


What do these models tell you?

l6w.lin - lm(length~as.factor(age) + as.factor(year) + as.factor(sex)  
+soi + k,


Or:

l6w.2way - lm(length~ (as.factor(age) + as.factor(year) +  
as.factor(sex) +soi + k)^2 ,




data=d[d$age
%in% minage:maxage,])


A much safer way to handle this would be:

data=subset(d, age = minage  age = maxage)

%in% is a set operation and you are passing it a vector of integers  
rather than a range.





Today I will prove your recommendation to use the package biglm


Should not be necessary. The problem lies elsewhere.



Thanks to both for your Help

Regards

2011/9/22 Paul Hiemstra paul.hiems...@knmi.nl


On 09/22/2011 04:00 AM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
Are you running a 32bit or 64bit version of R? Type sessionInfo()  
to see.


Michael


...in addition, how large is your dataset? Please provide us with a  
self
contained example which reproduces this problem. You could take a  
look

at the biglm package.

regards,
Paul


On Sep 21, 2011, at 10:41 PM, Mario Montecinos Carvajal 

mariomonteci...@gmail.com wrote:



Hi

I am a new user of the mail list.

Mi problem occurs when I try to test a lineal model (lm), becouse  
appear

the

messaje Error: cannot allocate vector of size xxx

The data frame whit I am working, Have


dim(d)

[1] 7017411

and the function i am test is:


lm 
(length~as.factor(age)*as.factor(year)*as.factor(sex)*soi*k,data=d[d 
$age

%in% minage:maxage,])

I tried with a diferent options for solve this problem, but any  
one give

me

results.

I tried with:

Change in Function: memory.limit(size=4000)

Change the setting in Windows using  BCDEdit /set

Change in the memory availability for R, change the path of the  
program

(suggested for other user)

My computer have 4GB RAM, Have 20 GB of Virtual Memory, HDD 300  
GB with

200

GB of free space and Windows 7 as OS and my R version is 2.11.1

I need solve this problem, any help or suggestion will be very well
received.

I've been thinking in change the OS, but this is may last option.

Regards

I read



David Winsemius, MD
West Hartford, CT

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


Re: [R] Bivariate Scatter Plots with Lattice

2011-09-22 Thread Rich Shepard

On Thu, 22 Sep 2011, Dennis Murphy wrote:


Question: Do you want 37 different panels with plots of quant vs. date
by param, or two panels (one per chemical) with all 37 streams? If you
only want two of the eight chemicals,


Dennis,

  I want only 2 chemicals per plot.


I'd suggest using subset() to select out the pair you want and then
redefine the param factor so that the subset data frame has two factor
levels instead of eight.


  Sure. I keep working with the original data set and haven't yet fully
learned to create subsets as needed.


Since there are several ways to interpret 'in which there are data', you
might want to expound a little further about your intentions in that
regard.


  What I mean that over all locations and chemicals the earliest date for
which there is data is 1980-03-01. However, some chemicals might not have
been required to be monitored before, say, 1990. If the pair in a given plot
have no data prior to 1990 (for example), that's what I want as the xlim.

Thanks,

Rich

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


Re: [R] Bivariate Scatter Plots with Lattice

2011-09-22 Thread Rich Shepard

On Thu, 22 Sep 2011, David Winsemius wrote:


Scatterplots are for two variables with  continuous valued data. You are
asking about one such variable, apparently within some combination of
groups of discrete variables. Look at dotplot or bwplot examples.


David,

  Good catch. Point noted.

Thanks,

Rich

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


Re: [R] Limitations of audio processing in R

2011-09-22 Thread Spencer Graves

Hi, Carl:


  1.  I've used Audacity and it seemed fine -- though I haven't 
used it much.



  2.  What's FTW?  (None of the Wikipedia disambiguation entries 
seemed to fit.)



  Thanks,
  Spencer


On 9/22/2011 2:41 PM, Carl Witthoft wrote:
With all due respect to those of us (including me) who love R,  when 
it comes to audio processing w/ freeware,


Audacity   FTW.

'nuff said

Carl


--
Spencer Graves, PE, PhD
President and Chief Technology Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567
web:  www.structuremonitoring.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] Identifying Package for Function

2011-09-22 Thread Rich Shepard

  While reading ?subset I'm referred to learn about dropvalues() as a
following operation. Yet, when I issue ?dropvalue I see, No documentation
for '?dropvalues' in specified packages and libraries:.

  How do I identify the library/package that contains a specific function
such as, in this case, dropvalues()?

Rich

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


[R] How to turn a LaTeX Sweave file (Rnw) into .HTML/.odf/.docx? (under windows)

2011-09-22 Thread Tal Galili
Hello dear R help members,
I have found several references on how to do this, my question is if anyone
is actually using them - and if there are some strong points on what to use,
and how well it is working out.

My goal is to be able to easily create docs from R, but to be able to share
it with other researchers (who do not use LaTeX) so they could easily
copy/paste the tables and edit them for their needs (pdf is not solving this
for me).

The only reasonable solution I came by so far is to use HTML markup coupled
with R2HTML (or odfWeave or R2wd).  But nothing that can work with
LaTeX-HTML (easily)

I have asked a similar question here:
http://stackoverflow.com/questions/7512897/how-to-turn-a-latex-sweave-file-rnw-into-html
And also noticed it was asked half a year ago here:
http://tex.stackexchange.com/questions/4145/workflow-for-converting-latex-into-open-office-ms-word-format
The general issue of TeX to HTML was discussed also in these places:
http://tex.stackexchange.com/questions/50/how-can-i-convert-math-less-latex-documents-into-microsoft-word

And obviously the following page offers other good resources to consider:
http://cran.r-project.org/web/views/ReproducibleResearch.html

p.s: I search the R-help for this topic, but sweave html didn't seem to
yield good results - my apologies if this has been heavily debated before -
links would be welcomed as well.


Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[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] Limitations of audio processing in R

2011-09-22 Thread Jeff Newmiller
1) I don't know about automated clipping using Audacity.

2) en.wiktionary.org/wiki/for_the_win
---
Jeff Newmiller The . . Go Live...
DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Spencer Graves spencer.gra...@structuremonitoring.com wrote:

Hi, Carl:


1. I've used Audacity and it seemed fine -- though I haven't 
used it much.


2. What's FTW? (None of the Wikipedia disambiguation entries 
seemed to fit.)


Thanks,
Spencer


On 9/22/2011 2:41 PM, Carl Witthoft wrote:
 With all due respect to those of us (including me) who love R, when 
 it comes to audio processing w/ freeware,

 Audacity FTW.

 'nuff said

 Carl


 -- 
 Spencer Graves, PE, PhD
 President and Chief Technology Officer
 Structure Inspection and Monitoring, Inc.
 751 Emerson Ct.
 San José, CA 95126
 ph: 408-655-4567
 web: www.structuremonitoring.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] Identifying Package for Function

2011-09-22 Thread Michael Sumner
Do you perhaps mean ?droplevels, as mentioned in See Also of subset help?

Otherwise, where exactly do you see 'dropvalues' referred to?

Cheers, Mike.

On Fri, Sep 23, 2011 at 9:08 AM, Rich Shepard rshep...@appl-ecosys.com wrote:
  While reading ?subset I'm referred to learn about dropvalues() as a
 following operation. Yet, when I issue ?dropvalue I see, No documentation
 for '?dropvalues' in specified packages and libraries:.

  How do I identify the library/package that contains a specific function
 such as, in this case, dropvalues()?

 Rich

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




-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@gmail.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] Identifying Package for Function

2011-09-22 Thread B77S
Where is dropvalue(s) mentioned? 

  ?subset 

  subset: logical expression indicating elements or rows to keep:
  missing values are taken as false.

  select: expression, indicating columns to select from a data frame.

drop: passed on to ‘[’ indexing operator.

 ...: further arguments to be passed to or from other methods.

Details:

 This is a generic function, with methods supplied for matrices,
 data frames and vectors (including lists).  Packages and users can
 add further methods.

 For ordinary vectors, the result is simply ‘x[subset 
 !is.na(subset)]’.

 For data frames, the ‘subset’ argument works on the rows.  Note
 that ‘subset’ will be evaluated in the data frame, so columns can
 be referred to (by name) as variables in the expression (see the
 examples).

 The ‘select’ argument exists only for the methods for data frames
 and matrices.  It works by first replacing column names in the
 selection expression with the corresponding column numbers in the
 data frame and then using the resulting integer vector to index
 the columns.  This allows the use of the standard indexing
 conventions so that for example ranges of columns can be specified
 easily, or single columns can be dropped (see the examples).

 The ‘drop’ argument is passed on to the indexing method for
 matrices and data frames: note that the default for matrices is
 different from that for indexing.

Value:

 An object similar to ‘x’ contain just the selected elements (for a
 vector), rows and columns (for a matrix or data frame), and so on.

Author(s):

 Peter Dalgaard and Brian Ripley

See Also:

 ‘[’, ‘transform’

Examples:

 subset(airquality, Temp  80, select = c(Ozone, Temp))
 subset(airquality, Day == 1, select = -Temp)
 subset(airquality, select = Ozone:Wind)
 
 with(airquality, subset(Ozone, Temp  80))
 
 ## sometimes requiring a logical 'subset' argument is a nuisance
 nm - rownames(state.x77)
 start_with_M - nm %in% grep(^M, nm, value=TRUE)
 subset(state.x77, start_with_M, Illiteracy:Murder)





Rich Shepard wrote:
 
 While reading ?subset I'm referred to learn about dropvalues() as a
 following operation. Yet, when I issue ?dropvalue I see, No documentation
 for '?dropvalues' in specified packages and libraries:.
 
How do I identify the library/package that contains a specific function
 such as, in this case, dropvalues()?
 
 Rich
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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://r.789695.n4.nabble.com/Identifying-Package-for-Function-tp3835227p3835252.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] Limitations of audio processing in R

2011-09-22 Thread Spencer Graves

Hi, Michael  Ulisses:


ULISSES:  If you haven't already, I suggest you look at the hexView 
package including the R News article cited below and the readRaw 
function in particular.  I just used readRaw(filename, offset=4, 
nbytes=8) to read bytes 5:12 in filename;  in this case, filename was 
*.wma created by the Windows 7 Sound Recorder.



MICHAEL:  Thanks.


  Spencer


On 9/21/2011 4:25 PM, Michael Sumner wrote:

On Thu, Sep 22, 2011 at 8:08 AM, Spencer Graves
spencer.gra...@structuremonitoring.com  wrote:

A more general question:  What tools are available in R for reading parts of
binary files?  'scan' allows you to 'skip' a certain number of records and
read the next 'nlines'.  Unfortunately, scan only seems to work for text
files not binary, and I cannot find a comparable function that would work
for binary files.  I tried library(sos);  (rb- findFn('read binary')).
  This produced 299 matches.  Something there might solve the problem, but I
haven't taken the time to study it carefully.  I hope someone else will
know.


  Spencer


?readBin and ?seek

Also see Viewing Binary Files with the hexView Package in RNews
Volume 7/1, April 2007.

http://www.r-project.org/doc/Rnews/Rnews_2007-1.pdf

Cheers, Mike.



On 9/21/2011 2:15 PM, Ken wrote:

Also with Linux you can add more swap memory(which I'm pretty sure R
spills into if it hasn't reached it's  internal limits on 32 bit
installations). Windows pagefile is kind of obnoxious.
Ken Hutchison

On Sep 21, 2554 BE, at 5:05 PM, (Ted Harding)ted.hard...@wlandres.net
  wrote:


Hi Ulisses!
Yes, get more creative -- or get more memory!

On the creative side, it may be worth thinking about
using an independent (non-R) audio file editor. I'm
writing from the standpoint of a Linux/Unixoid user
here -- I wouldn;t know how to set ebout this in WIndows.

You could use R to create a shell script which would run
the editor in such a way as to extract your 6 random samples,
and save them, where the script would be fed with the
randomly-chosen 5-minute intervals decided by R. This
could be done under the control of R, so you could set
it up for your 1500 or so sets of samples, which (with
the right editing program) could be done quite quickly.

On Linux (also available for Windows) a flexible audio
editor is 'sox' -- see:

  http://en.wikipedia.org/wiki/SoX

To take, say, a 5-minute sample starting at 1 hour,
10 min and 35sec into the audio file infile.wav,
and save this as outfile.wav, you can execute

  sox infile.wav outfile.wav trim 01:10:35 00:05:00

and such a command could easily be generated by R and
fed to a shell script (or simply executed from R by
using the system() command). My test just now with
a 5-minute long sample from a .wav file was completed
in about 5 seconds, so it is quite efficient.

There is a huge number of options for 'sox', allowing
you to manipulate almost any aspect of the editing.

Hoping this helps,
Ted.


On 21-Sep-11 19:55:22, R. Michael Weylandt wrote:

If you are running Windows it may be as simple as using
memory.limit() to allow R more memory -- if you are on
another OS, it may be possible to get the needed memory
by deleting various things in your workspace and running
gc()

Of course, if your computer's memory is3GB, you are
probably going to have trouble with R's keeping all objects
in memory and will have to get more creative.

Michael

On Wed, Sep 21, 2011 at 3:43 PM, Ulisses.Camargo
moliterno.cama...@gmail.comwrote:


Hello everybody

I am trying to process audio files in R and had some problems
with files size. I´m using R packages 'audio' and 'sound'.
I´m trying a really simple thing and it is working well with
small sized .wav files. When I try to open huge audio files
I received this error message: cannot allocate vector of
size 2.7 Gb. My job is open in R a 3-hour .wav file, make six
5-minute random audio subsamples, and than save these new files.
I have to do the same process +1500 times. My problems is not
in build the function to do the job, but in oppening the 3-hour
files. Does anybody knows how to handle big audio files in R?
Another package that allows me to do this work? I believe
this is a really simple thing, but I really don´t know what
to do to solve that memory problem.

Thank you very much for your answers,
all the best!

Ulisses


E-Mail: (Ted Harding)ted.hard...@wlandres.net
Fax-to-email: +44 (0)870 094 0861
Date: 21-Sep-11   Time: 22:05:55
-- XFMail --

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

Re: [R] Identifying Package for Function

2011-09-22 Thread Rich Shepard

On Fri, 23 Sep 2011, Michael Sumner wrote:


Do you perhaps mean ?droplevels, as mentioned in See Also of subset help?


  Yep. Mis-translation between the help page and the working page.

Mea culpa!

Rich

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


Re: [R] Bivariate Scatter Plots with Lattice

2011-09-22 Thread Dennis Murphy
I don't see the problem. AFAICT, you want plots of quant vs. sampdate
by chemicals for each of the 37 streams. Essentially, you seem to want
two superimposed time plots in each panel. A time plot is a
scatterplot with a time-ordered (usually horizontal) axis.

If you use ggplot2 or lattice to generate the conditioning plots, the
default is to use common scales for all panels; this makes eyeball
comparisons between plots easier. If you want flexible scales,
particularly on the time axis, you'll need to adjust the scales. It's
a bit easier to do this in ggplot2, but the lattice approach isn't
overly difficult if you have some decent documentation (like the
Lattice book) at hand.

Dennis

On Thu, Sep 22, 2011 at 3:50 PM, Rich Shepard rshep...@appl-ecosys.com wrote:
 On Thu, 22 Sep 2011, David Winsemius wrote:

 Scatterplots are for two variables with  continuous valued data. You are
 asking about one such variable, apparently within some combination of
 groups of discrete variables. Look at dotplot or bwplot examples.

 David,

  Good catch. Point noted.

 Thanks,

 Rich

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


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


Re: [R] How to turn a LaTeX Sweave file (Rnw) into .HTML/.odf/.docx? (under windows)

2011-09-22 Thread Abhijit Dasgupta
So, I was playing around a bit on my Mac 

LyX can do Sweave (see http://wiki.lyx.org/LyX/LyxWithRThroughSweave), and will 
actually output HTML or ODT. However, on a cursory pass, I couldn't get the 
graphics to translate, since the Sweave driver translates the graphics as .ps 
or .pdf files, and I'm not sure the HTML translator looks for them or can 
accept them. The math actually translates nicely. So there is probably 
potential here.

Abhijit


On Sep 22, 2011, at 7:09 PM, Tal Galili wrote:

 Hello dear R help members,
 I have found several references on how to do this, my question is if anyone
 is actually using them - and if there are some strong points on what to use,
 and how well it is working out.
 
 My goal is to be able to easily create docs from R, but to be able to share
 it with other researchers (who do not use LaTeX) so they could easily
 copy/paste the tables and edit them for their needs (pdf is not solving this
 for me).
 
 The only reasonable solution I came by so far is to use HTML markup coupled
 with R2HTML (or odfWeave or R2wd).  But nothing that can work with
 LaTeX-HTML (easily)
 
 I have asked a similar question here:
 http://stackoverflow.com/questions/7512897/how-to-turn-a-latex-sweave-file-rnw-into-html
 And also noticed it was asked half a year ago here:
 http://tex.stackexchange.com/questions/4145/workflow-for-converting-latex-into-open-office-ms-word-format
 The general issue of TeX to HTML was discussed also in these places:
 http://tex.stackexchange.com/questions/50/how-can-i-convert-math-less-latex-documents-into-microsoft-word
 
 And obviously the following page offers other good resources to consider:
 http://cran.r-project.org/web/views/ReproducibleResearch.html
 
 p.s: I search the R-help for this topic, but sweave html didn't seem to
 yield good results - my apologies if this has been heavily debated before -
 links would be welcomed as well.
 
 
 Tal
 
 
 
 Contact
 Details:---
 Contact me: tal.gal...@gmail.com |  972-52-7275845
 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
 www.r-statistics.com (English)
 --
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


[R] Correlation of variables with repeated measures.

2011-09-22 Thread Heverkuhn Heverkuhn
Hello
I have a dataframe  that looks like this:

Date   Min Subj VAR1  VAR2   VAR3
1  8/30/2011  5min1 34.41042 126.08490 55.3548387
2  8/30/2011 10min1 34.53030 133.81343 61.600
3  8/30/2011 15min1 34.66297 118.38193 11.800
4  8/30/2011 20min1 34.82770 110.77767  6.600
5  8/30/2011  5min2 36.36994 116.24861 41.2258065
6  8/30/2011 10min2 36.37420 101.16457 13.600
7  8/30/2011 15min2 36.37453  92.26340  0.400
8  8/30/2011 20min2 36.37697  87.73650  0.000
9  8/30/2011  5min3 35.25667 146.90037 10.0645161
10 8/30/2011 10min3 35.36654 139.49364  6.000
11 8/30/2011 15min3 35.33833 135.75633  0.400
12 8/30/2011 20min3 36.01337 127.83797  0.000
13 8/30/2011  5min4 35.26742  84.78603  0.9677419
14 8/30/2011 10min4 35.17913  91.27093  1.800
15 8/30/2011 15min4 35.09825  92.03692 13.400
16 8/30/2011 20min4 35.36823  88.73337  4.800

and so on for more days.

I would like to check the correlation and p of  variables VAR1 VAR2 VAR3.

if I use cor.test(tel$VAR1, tel$VAR2)
 the observations are considered independent, and Indeed I got df=14
I have seen that I can obtain a correlation for each block using this
script:
http://stackoverflow.com/questions/2336056/how-to-do-correlation-with-blocks-or-repeated-measures

 I was wandering what I should do for obtain a correlation that account for
all the blocks.

[[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] Adding weights to optim

2011-09-22 Thread Ahnate Lim
I realize this may be more of a math question. I have the following optim:

optim(c(0.0,1.0),logis.op,x=d1_all$SOA,y=as.numeric(md1[,i]))

which uses the following function:

logis.op - function(p,x,y) {

  ypred - 1.0 / (1.0 + exp((p[1] - x) / p[2]));

res - sum((y-ypred)^2)

return(res)

}

I would like to add weights to the optim. Do I have to alter the logis.op
function by adding an additional weights parameter? And if so, how would I
change the ypred formula? Would I just substitute x with x*w?

[[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] Error: cannot allocate vector of size xxx

2011-09-22 Thread Mario Montecinos Carvajal
David

Thanks for the time that you spent in read and understand my mail, as well
as for your response and recomendations. I apologize if my attempt to put
comment in my code, not was enought.

I appreciate a lot your suggestion and I will take care of change the
variable name length for avoid confusion.

Maybe you have reason about the origin the problem, related to a model with
a lot of interaction and few data for this interaction becouse my variables
age and year are integer.

But, I tested this code in another machine with WinVista and previus version
of R, and with a data frame with 40 k register and I did not have any
problem (at that moment I had not the complete data and only had the half of
years - 1997 to 2008 - that I have now - 1984 - 2008).

I started testing simple model, but I am very interested in test this
complex model, that has been giving me  problems.

In relation to the model that I have problem. I used the syntax that I was
believed that allowed test all the factors with all the interaction (for
intruction of my teachers  is 
lm(length~as.factor(age)*as.factor(year)*as.factor(sex)*soi*k ), but now I
believe maybe this is incorrect, maybe the syntax correct is that suggest
for you (lm(length~ (as.factor(age) + as.factor(year) + as.factor(sex) +soi
+ k)^2), I will tray with this and after tell you.

As data my workspace have 2.5 GB of memory.

Regards David

2011/9/22 David Winsemius dwinsem...@comcast.net


 On Sep 22, 2011, at 5:00 PM, Mario Montecinos Carvajal wrote:

  Michale and Paul

 Thanks for your quick response.

 Michael, I am running a 32bit version of R

  sessionInfo()

 R version 2.11.1 (2010-05-31)
 i386-pc-mingw32


 Paul, the dimension of the Data Frame with I am workis is
 dim(d)

 [1] 7017411

 And the size of the file that contains the data is 2946 Kb


 Not a very big dataset for a workspace that should be 2GB or more.




 The script that I use for manage the data is:

 #clean the workspace
 rm(list = ls(all = TRUE))


 I hate it when people put that code in without a warning and preferably
 commented out. Some us boobs have been known to paste in code without
 mentally single stepping through it.



 #Increase the memory size
 memory.limit(size=4000)

 #Set Directory of WorkSpace where whe have the data
 setwd('C:/Users/XXX/XXX/R/**')

 #load data
 dat - read.table('dat_fin_age.txt')

 #delete empty registry
 d-na.omit(dat)
 remove(dat) # remove dat (intermedia object) for release resource

 #Asigned the name to the variables in the data
 names(d)-
 c('pesq','year','month','sex',**'length','weigth','mature','**
 age','soi','temp','k')


 Bad idea to use length as a variable name. It is a function name.



 #define the ages over the analysis is focuses.
 minage-1 # minimum age
 maxage-6 # maximum age


 At this point you should have offered:

  str(d)



 # One of the diferent lm I have been tested



 You are constructing a 5-way interaction that will have way more
 interactions than you will know what to do with. Why not start out with a
 simple model and move up from there? If these ages and years are integer
 valued then you may not have enough  data to support such a model with only
 70k records.

 What do these models tell you?

 l6w.lin - lm(length~as.factor(age) + as.factor(year) + as.factor(sex) +soi
 + k,

 Or:

 l6w.2way - lm(length~ (as.factor(age) + as.factor(year) + as.factor(sex)
 +soi + k)^2 ,



  data=d[d$age
 %in% minage:maxage,])


 A much safer way to handle this would be:

 data=subset(d, age = minage  age = maxage)

 %in% is a set operation and you are passing it a vector of integers rather
 than a range.




 Today I will prove your recommendation to use the package biglm


 Should not be necessary. The problem lies elsewhere.



 Thanks to both for your Help

 Regards

 2011/9/22 Paul Hiemstra paul.hiems...@knmi.nl

  On 09/22/2011 04:00 AM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:

 Are you running a 32bit or 64bit version of R? Type sessionInfo() to
 see.

 Michael


 ...in addition, how large is your dataset? Please provide us with a self
 contained example which reproduces this problem. You could take a look
 at the biglm package.

 regards,
 Paul

  On Sep 21, 2011, at 10:41 PM, Mario Montecinos Carvajal 

 mariomonteci...@gmail.com wrote:


  Hi

 I am a new user of the mail list.

 Mi problem occurs when I try to test a lineal model (lm), becouse
 appear

 the

 messaje Error: cannot allocate vector of size xxx

 The data frame whit I am working, Have

  dim(d)

 [1] 7017411

 and the function i am test is:


  lm(length~as.factor(age)*as.**factor(year)*as.factor(sex)***
 soi*k,data=d[d$age

 %in% minage:maxage,])

 I tried with a diferent options for solve this problem, but any one
 give

 me

 results.

 I tried with:

 Change in Function: memory.limit(size=4000)

 Change the setting in Windows using  BCDEdit /set

 Change in the memory availability for R, change the path of the program
 (suggested 

Re: [R] How to turn a LaTeX Sweave file (Rnw) into .HTML/.odf/.docx? (under windows)

2011-09-22 Thread Duncan Murdoch

On 11-09-22 8:38 PM, Abhijit Dasgupta wrote:

So, I was playing around a bit on my Mac 

LyX can do Sweave (see http://wiki.lyx.org/LyX/LyxWithRThroughSweave), and will 
actually output HTML or ODT. However, on a cursory pass, I couldn't get the 
graphics to translate,

 since the Sweave driver translates the graphics as .ps or .pdf files,

Just a note:  Sweave is more flexible nowadays, thanks to some big 
improvements by Brian Ripley.  It can produce png or jpeg figures if you 
need those.


Can't help much with the original problem.  R doesn't use .tex when it 
needs to produce HTML:  it uses .texi (texinfo) or its own  .Rd format. 
 The latter is unlikely to suit general purpose documents, it's just 
for help pages.  The former is a bit of a PITA to use.


Duncan Murdoch




and I'm not sure the HTML translator looks for them or can accept them. 
The math actually translates nicely. So there is probably potential here.


Abhijit


On Sep 22, 2011, at 7:09 PM, Tal Galili wrote:


Hello dear R help members,
I have found several references on how to do this, my question is if anyone
is actually using them - and if there are some strong points on what to use,
and how well it is working out.

My goal is to be able to easily create docs from R, but to be able to share
it with other researchers (who do not use LaTeX) so they could easily
copy/paste the tables and edit them for their needs (pdf is not solving this
for me).

The only reasonable solution I came by so far is to use HTML markup coupled
with R2HTML (or odfWeave or R2wd).  But nothing that can work with
LaTeX-HTML (easily)

I have asked a similar question here:
http://stackoverflow.com/questions/7512897/how-to-turn-a-latex-sweave-file-rnw-into-html
And also noticed it was asked half a year ago here:
http://tex.stackexchange.com/questions/4145/workflow-for-converting-latex-into-open-office-ms-word-format
The general issue of TeX to HTML was discussed also in these places:
http://tex.stackexchange.com/questions/50/how-can-i-convert-math-less-latex-documents-into-microsoft-word

And obviously the following page offers other good resources to consider:
http://cran.r-project.org/web/views/ReproducibleResearch.html

p.s: I search the R-help for this topic, but sweave html didn't seem to
yield good results - my apologies if this has been heavily debated before -
links would be welcomed as well.


Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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


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


Re: [R] Error: cannot allocate vector of size xxx

2011-09-22 Thread Mario Montecinos Carvajal
Paul

I tested your suggestion of use the BIGLM package. With this package, model
run with out any problem.

regards


2011/9/22 David Winsemius dwinsem...@comcast.net


 On Sep 22, 2011, at 5:00 PM, Mario Montecinos Carvajal wrote:

  Michale and Paul

 Thanks for your quick response.

 Michael, I am running a 32bit version of R

  sessionInfo()

 R version 2.11.1 (2010-05-31)
 i386-pc-mingw32


 Paul, the dimension of the Data Frame with I am workis is
 dim(d)

 [1] 7017411

 And the size of the file that contains the data is 2946 Kb


 Not a very big dataset for a workspace that should be 2GB or more.




 The script that I use for manage the data is:

 #clean the workspace
 rm(list = ls(all = TRUE))


 I hate it when people put that code in without a warning and preferably
 commented out. Some us boobs have been known to paste in code without
 mentally single stepping through it.



 #Increase the memory size
 memory.limit(size=4000)

 #Set Directory of WorkSpace where whe have the data
 setwd('C:/Users/XXX/XXX/R/**')

 #load data
 dat - read.table('dat_fin_age.txt')

 #delete empty registry
 d-na.omit(dat)
 remove(dat) # remove dat (intermedia object) for release resource

 #Asigned the name to the variables in the data
 names(d)-
 c('pesq','year','month','sex',**'length','weigth','mature','**
 age','soi','temp','k')


 Bad idea to use length as a variable name. It is a function name.



 #define the ages over the analysis is focuses.
 minage-1 # minimum age
 maxage-6 # maximum age


 At this point you should have offered:

  str(d)



 # One of the diferent lm I have been tested



 You are constructing a 5-way interaction that will have way more
 interactions than you will know what to do with. Why not start out with a
 simple model and move up from there? If these ages and years are integer
 valued then you may not have enough  data to support such a model with only
 70k records.

 What do these models tell you?

 l6w.lin - lm(length~as.factor(age) + as.factor(year) + as.factor(sex) +soi
 + k,

 Or:

 l6w.2way - lm(length~ (as.factor(age) + as.factor(year) + as.factor(sex)
 +soi + k)^2 ,



  data=d[d$age
 %in% minage:maxage,])


 A much safer way to handle this would be:

 data=subset(d, age = minage  age = maxage)

 %in% is a set operation and you are passing it a vector of integers rather
 than a range.




 Today I will prove your recommendation to use the package biglm


 Should not be necessary. The problem lies elsewhere.



 Thanks to both for your Help

 Regards

 2011/9/22 Paul Hiemstra paul.hiems...@knmi.nl

  On 09/22/2011 04:00 AM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:

 Are you running a 32bit or 64bit version of R? Type sessionInfo() to
 see.

 Michael


 ...in addition, how large is your dataset? Please provide us with a self
 contained example which reproduces this problem. You could take a look
 at the biglm package.

 regards,
 Paul

  On Sep 21, 2011, at 10:41 PM, Mario Montecinos Carvajal 

 mariomonteci...@gmail.com wrote:


  Hi

 I am a new user of the mail list.

 Mi problem occurs when I try to test a lineal model (lm), becouse
 appear

 the

 messaje Error: cannot allocate vector of size xxx

 The data frame whit I am working, Have

  dim(d)

 [1] 7017411

 and the function i am test is:


  lm(length~as.factor(age)*as.**factor(year)*as.factor(sex)***
 soi*k,data=d[d$age

 %in% minage:maxage,])

 I tried with a diferent options for solve this problem, but any one
 give

 me

 results.

 I tried with:

 Change in Function: memory.limit(size=4000)

 Change the setting in Windows using  BCDEdit /set

 Change in the memory availability for R, change the path of the program
 (suggested for other user)

 My computer have 4GB RAM, Have 20 GB of Virtual Memory, HDD 300 GB with

 200

 GB of free space and Windows 7 as OS and my R version is 2.11.1

 I need solve this problem, any help or suggestion will be very well
 received.

 I've been thinking in change the OS, but this is may last option.

 Regards

 I read



 David Winsemius, MD
 West Hartford, CT




-- 
Mario Montecinos C.
Biologo Marino
Dr (c) en Ciencias
Universidad Austral de Chile


Los acentos han sido omitidos voluntariamente para evitar incompatibilidades
Evite enviar cartas impresas, cuidemos el medio ambiente y evitemos el
uso innecesario de papel.

[[alternative HTML version deleted]]

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


Re: [R] How to turn a LaTeX Sweave file (Rnw) into .HTML/.odf/.docx? (under windows)

2011-09-22 Thread Michael Hannon
 I have found several references on how to do this, my question is if anyone
 is actually using them - and if there are some strong points on what to use,
 and how well it is working out.

 My goal is to be able to easily create docs from R, but to be able to share
 it with other researchers (who do not use LaTeX) so they could easily
 copy/paste the tables and edit them for their needs (pdf is not solving this
 for me).

 The only reasonable solution I came by so far is to use HTML markup coupled
 with R2HTML (or odfWeave or R2wd).  But nothing that can work with
 LaTeX-HTML (easily)

[...]

Hi, Tal.  This isn't an answer to the question you asked, but the Emacs
Org-Mode package is pretty good at exporting to various file formats (and the
source code, including tables, is purely text anyway).  Have a look at:

    http://orgmode.org/

and, in particular:

    http://orgmode.org/guide/Exporting.html#Exporting

Even if this does, in principle, solve your problem, it may be too big a gulp
to swallow if you're not already using Emacs.

-- Mike

[[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] Plot map by region using kasc and adehabitat

2011-09-22 Thread Alex Olssen
Hi there,

I thought it would be useful to answer my own question for anybody
else searching Google.

An easy way to split a national map into smaller maps at lower levels
of aggregation is to use the function
mask()
in the package
raster

Alex

On 21 September 2011 19:20, Paul Hiemstra paul.hiems...@knmi.nl wrote:
  On 09/21/2011 01:39 AM, Alex Olssen wrote:
 Dear R-help,

 I have a raster map which has a measure of profitability of land by
 parcel over several regions of geographic aggregation (think of
 counties).  This data is stored in an ASCII file.  If I type

 plot(profit)

 I get a raster map of profit per parcel for all regions.  I want to
 plot separate maps for each county.  I used kasc to combine the profit
 map with a county map from a separate ASCII file.

 data.kasc - as.kasc(list(profit, county))

 Can anyone help me plot profit maps for each county separately?

 Kind regards,
 Alex

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

 ...to make us more willing to answer the question:

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

 Paul

 --
 Paul Hiemstra, Ph.D.
 Global Climate Division
 Royal Netherlands Meteorological Institute (KNMI)
 Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
 P.O. Box 201 | 3730 AE | De Bilt
 tel: +31 30 2206 494

 http://intamap.geo.uu.nl/~paul
 http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770



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

2011-09-22 Thread Brian Tsai
Hi,

I'm interested in building a Cox PH model for survival modeling, using 2
covariates (x1 and x2).   x1 represents a 'baseline' covariate, whereas x2
represents a 'new' covariate, and my goal is to figure out where x2 adds
significant predictive information over x1.

Ideally, I could get a p-value for doing this.  Originally, I thought of
doing some kind of likelihood ratio test (LRT), where i measure the
(partial) likelihood of the model with just x1, then with x1 and x2, then it
becomes a LRT with 1 degree of freedom.  But when i use the summary()
function for coxph(), i get the following output (shown at the bottom).

I have two questions:

1) What exactly are the p-values in the Pr(|z|) representing?  I understand
that the coefficients have standard errors, etc., but i'm not sure how the
p-value there is calculated.

2) At the bottom, where it shows the results of an LRT with 2df, i don't
quite understand what model the ratio is being tested against.  If the
current model has two variables (x1 and x2), and those are the extra degrees
of freedom, then the baseline should then have 0 variables, but that's not
really a Cox model?

thanks for any help.

Brian


 summary(coxph(Surv(myTime,Event)~x1+x2))
Call:
coxph(formula = Surv(myTime, Event) ~ x1 + x2)

  n= 211

  coef exp(coef) se(coef) z Pr(|z|)
x1 0.03594   1.03660  0.17738 0.203  0.83942
x2 0.53829   1.71308  0.17775 3.028  0.00246 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

   exp(coef) exp(-coef) lower .95 upper .95
x1 1.037 0.96470.7322 1.468
x2 1.713 0.58371.2091 2.427

Rsquare= 0.111   (max possible= 0.975 )
Likelihood ratio test= 21.95  on 2 df,   p=1.714e-05
Wald test= 20.29  on 2 df,   p=3.924e-05
Score (logrank) test = 22.46  on 2 df,   p=1.328e-05

[[alternative HTML version deleted]]

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


  1   2   >