Re: [R] tcltk lost after update r-base 2.11.1-2hardy0 to 2.11.1-5hardy0

2010-09-06 Thread Peter Dalgaard
On 09/06/2010 07:38 AM, Christian Lederer wrote:
 Dear R-Users,
 
 after the last upgrade from r-base 2.11.1-2hardy0 to 2.11.1-5hardy0
 i lost the tlctk package.
 
 I this a general problem under Ubuntu Hardy or should i search for
 a configuration error on my system?

Assuming that you didn't just msispell it (as you did above), I'd
suspect a build configuration error on the Ubuntu side. If you file a
bug report with them, you'll likely get a quicker resonse than from
people on this list (yea, let's all go see if we can break our
productions systems like Christian did...)

In any case, people do need to know what the symptoms are, and what you
did to upgrade?

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
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.


Re: [R] How to use lm() output for systemfit() 'Seemingly unrelated regression'

2010-09-06 Thread zbynek.jano...@gmail.com

Thanks, it works fine now.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-lm-output-for-systemfit-Seemingly-unrelated-regression-tp2525418p2527946.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] representing NULL values in a vector

2010-09-06 Thread raje...@cse.iitm.ac.in

Hi,

I have a vector who contents should look like this,

c d NULL e f etc
or 
4 5 6 NULL 7 8 9

how can I represent the null value?
[[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] representing NULL values in a vector

2010-09-06 Thread Patrick Burns

Perhaps you mean NA rather than NULL.

If NA is not what you want, then I
think you'll need to explain your
application.

On 06/09/2010 06:00, raje...@cse.iitm.ac.in wrote:


Hi,

I have a vector who contents should look like this,

c d NULL e f etc
or
4 5 6 NULL 7 8 9

how can I represent the null value?
[[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.



--
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')

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


Re: [R] how do I transform this to a for loop

2010-09-06 Thread Karl Brand

Hi Bill,

I didn't make the original post, but its pretty similar to some thing i 
would have queried the list about. But, as an R dilatante i find more 
curious your question-


...but why would you want to do so?

Is this because you'd typically use the given nine lines of explicit 
code to carve up a single dataset into nine symmetrical variants ? Or 
that some contextual information may affect how you would write the 
for() loop?


As i lack the experience to know any better, i perceive your for() loop 
as de rigour in efficient use of R, and the preferance of all 
experienced R user's. But not having any formal education in R or role 
models as such, its only an assumption (compeletely ignoring for the 
moment processing efficiency/speed, rounding error and such).


But which i now question! Explicit, simple crude looking code; or, 
something which demands a little more proficiency with the language?


cheers,

Karl



On 9/6/2010 6:16 AM, bill.venab...@csiro.au wrote:


sseq- c(1, seq(5, 40, by = 5))
for(i in 1:length(sseq))
assign(paste(arima, i, sep=), arima(data.ts[sseq[i]:(sseq[i]+200)], 
order=c(1,1,1)))

...but why would you want to do so?


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of lord12
Sent: Monday, 6 September 2010 10:57 AM
To: r-help@r-project.org
Subject: [R] how do I transform this to a for loop


arima1- arima(data.ts[1:201], order = c(1,1,1))
arima2- arima(data.ts[5:205], order = c(1,1,1))
arima3- arima(data.ts[10:210], order = c(1,1,1))
arima4- arima(data.ts[15:215], order = c(1,1,1))
arima5- arima(data.ts[20:220], order = c(1,1,1))
arima6- arima(data.ts[25:225], order = c(1,1,1))
arima7- arima(data.ts[30:230], order = c(1,1,1))
arima8- arima(data.ts[35:235], order = c(1,1,1))
arima9- arima(data.ts[40:240], order = c(1,1,1))



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

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


Re: [R] representing NULL values in a vector

2010-09-06 Thread Jim Lemon

On 09/06/2010 03:00 PM, raje...@cse.iitm.ac.in wrote:


Hi,

I have a vector who contents should look like this,

c d NULL e f etc
or
4 5 6 NULL 7 8 9

how can I represent the null value?


Hi rajesh,
For character vectors,  will probably suffice, but for numbers, you 
are probably stuck with NA.


Jim

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


[R] replacing functions

2010-09-06 Thread Karen Sargsyan

 Dear All,

Is it possible to replace function with my own? I want to apply pca 
clustering, but
to use some strange correlation function. I'm asking about replacing, 
say, mean() with new content of mean() and use standard other functions, 
which might use mean() as part.


karsar

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


Re: [R] how do I transform this to a for loop

2010-09-06 Thread Paul Hiemstra

Hi Karl,

The why do it like this is probably direct towards creating 9 new 
objects for the arima results (Is this right Bill?). A better option 
would be to create a list with nine entries. This is much easier for any 
subsequent analyses. An example that uses lapply (an efficient syntax 
for loops):


sseq - c(1, seq(5, 40, by = 5))
result_list = lapply(sseq, function(num) {
arima(data.ts[num:(num+200)], order=c(1,1,1))
})

cheers,
Paul

On 09/06/2010 10:46 AM, Karl Brand wrote:

Hi Bill,

I didn't make the original post, but its pretty similar to some thing 
i would have queried the list about. But, as an R dilatante i find 
more curious your question-


...but why would you want to do so?

Is this because you'd typically use the given nine lines of explicit 
code to carve up a single dataset into nine symmetrical variants ? Or 
that some contextual information may affect how you would write the 
for() loop?


As i lack the experience to know any better, i perceive your for() 
loop as de rigour in efficient use of R, and the preferance of all 
experienced R user's. But not having any formal education in R or role 
models as such, its only an assumption (compeletely ignoring for the 
moment processing efficiency/speed, rounding error and such).


But which i now question! Explicit, simple crude looking code; or, 
something which demands a little more proficiency with the language?


cheers,

Karl



On 9/6/2010 6:16 AM, bill.venab...@csiro.au wrote:


sseq- c(1, seq(5, 40, by = 5))
for(i in 1:length(sseq))
assign(paste(arima, i, sep=), 
arima(data.ts[sseq[i]:(sseq[i]+200)], order=c(1,1,1)))


...but why would you want to do so?


-Original Message-
From: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] On Behalf Of lord12

Sent: Monday, 6 September 2010 10:57 AM
To: r-help@r-project.org
Subject: [R] how do I transform this to a for loop


arima1- arima(data.ts[1:201], order = c(1,1,1))
arima2- arima(data.ts[5:205], order = c(1,1,1))
arima3- arima(data.ts[10:210], order = c(1,1,1))
arima4- arima(data.ts[15:215], order = c(1,1,1))
arima5- arima(data.ts[20:220], order = c(1,1,1))
arima6- arima(data.ts[25:225], order = c(1,1,1))
arima7- arima(data.ts[30:230], order = c(1,1,1))
arima8- arima(data.ts[35:235], order = c(1,1,1))
arima9- arima(data.ts[40:240], order = c(1,1,1))






--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 253 5773
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] replacing functions

2010-09-06 Thread Paul Hiemstra

Hi Karsar,

To replace mean you can make a new function with the same name:

l = runif(10)
mean(l)
mean = function(x) return(1)
mean(l)

But there must be a better way...

cheers,
Paul

On 09/06/2010 11:52 AM, Karen Sargsyan wrote:

 Dear All,

Is it possible to replace function with my own? I want to apply pca 
clustering, but
to use some strange correlation function. I'm asking about replacing, 
say, mean() with new content of mean() and use standard other 
functions, which might use mean() as part.


karsar

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

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



--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 253 5773
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] how do I transform this to a for loop

2010-09-06 Thread Ivan Calandra
  Hi Karl,

I think the question here is why would you want to create different 
objects in the loop using assign().
Usually, using lists is better (more efficient?), although I sometimes 
use assign() too in this context. I do it when I want to export the 
object as separate files (xls, Rbin, svg, etc). If I don't need separate 
files, I use lists.
I'm no expert so I'm not even sure I use the correct approach, but it 
might help you get a better understanding.

It would be something like:
sseq- c(1, seq(5, 40, by = 5))
arima - vector(mode=list, length=length(sseq)) ##not sure it is 
necessary, but it might be
for(i in 1:length(sseq)) {
arima[[i]] - arima(data.ts[sseq[i]:(sseq[i]+200)], order=c(1,1,1))
}

HTH,
Ivan


Le 9/6/2010 10:46, Karl Brand a écrit :
 Hi Bill,

 I didn't make the original post, but its pretty similar to some thing 
 i would have queried the list about. But, as an R dilatante i find 
 more curious your question-

 ...but why would you want to do so?

 Is this because you'd typically use the given nine lines of explicit 
 code to carve up a single dataset into nine symmetrical variants ? Or 
 that some contextual information may affect how you would write the 
 for() loop?

 As i lack the experience to know any better, i perceive your for() 
 loop as de rigour in efficient use of R, and the preferance of all 
 experienced R user's. But not having any formal education in R or role 
 models as such, its only an assumption (compeletely ignoring for the 
 moment processing efficiency/speed, rounding error and such).

 But which i now question! Explicit, simple crude looking code; or, 
 something which demands a little more proficiency with the language?

 cheers,

 Karl



 On 9/6/2010 6:16 AM, bill.venab...@csiro.au wrote:

 sseq- c(1, seq(5, 40, by = 5))
 for(i in 1:length(sseq))
 assign(paste(arima, i, sep=), 
 arima(data.ts[sseq[i]:(sseq[i]+200)], order=c(1,1,1)))

 ...but why would you want to do so?


 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of lord12
 Sent: Monday, 6 September 2010 10:57 AM
 To: r-help@r-project.org
 Subject: [R] how do I transform this to a for loop


 arima1- arima(data.ts[1:201], order = c(1,1,1))
 arima2- arima(data.ts[5:205], order = c(1,1,1))
 arima3- arima(data.ts[10:210], order = c(1,1,1))
 arima4- arima(data.ts[15:215], order = c(1,1,1))
 arima5- arima(data.ts[20:220], order = c(1,1,1))
 arima6- arima(data.ts[25:225], order = c(1,1,1))
 arima7- arima(data.ts[30:230], order = c(1,1,1))
 arima8- arima(data.ts[35:235], order = c(1,1,1))
 arima9- arima(data.ts[40:240], order = c(1,1,1))



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

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


[[alternative HTML version deleted]]

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


[R] Finding the two most recent dates

2010-09-06 Thread Newbie19_02

Dear R help,

I have the following data frame:

structure(list(prochi = c(ind_1, ind_1, ind_1, 
ind_1, ind_1, ind_1, ind_1, ind_1, 
ind_1, ind_1), date_1st_event = structure(c(14784, 
14784, 14784, 14784, 14784, 14784, 14784, 14784, 14784, 14784
), class = Date), bp_date = structure(c(12660, 14571, 13392, 
13080, 12012, 13080, 13894, 14622, 12654, 13894), class = Date), 
SBP = c(135L, 160L, 135L, 153L, 150L, 153L, 151L, 126L, 150L, 
151L), DBP = c(85L, 80L, NA, 79L, 82L, 79L, 76L, 60L, 82L, 
91L)), .Names = c(prochi, date_1st_event, bp_date, SBP, 
DBP), row.names = 108:117, class = data.frame)

It consists of repeated measures for the same individual.  What I want to do
is find the two most recent blood pressure readings (SBP and DBP) using
date_1st_event and bp_date.  What I would do to find the most recent date is
to subtract date_1st_event-bp_date and then aggregate by min.  I'm not sure
how to find the two most recent dates.  

Are there some functions that can help me or will I have to write a function
from scratch.  Any help just to point me in the right direction.

Thanks,
Natalie
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Finding-the-two-most-recent-dates-tp2528185p2528185.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] R time series analysis

2010-09-06 Thread matteodefelice


lord12 wrote:
 
 I have a data file with a given time series of price data and I would like
 to split the time series into a test set and training set. I would then
 like to build an ARIMA model on the training set and apply this model on
 test set. 
 
I had recently the same problem and, after checking documentation and
mailing list archives, I discovered that it is not possible to apply the
same model on a different data set. Of course you can create the model on a
part of the dataset and then check the prediction with the remaining part,
as a testing set. But, if you have new data you and you want to apply the
same model on them...nothing! I checked the source code of ARIMA functions
but it was too complex and I hadn't enough time to learn all that stuff.
However I found a little workaround:

1. I calibrate the model on the training part 
2. I create a new model with the same parameters, using fixed (check arima
documentation) on the new data
3. go to step 2. every time you have new data

It worked for me. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-time-series-analysis-tp2527513p2528200.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] representing NULL values in a vector

2010-09-06 Thread Duncan Murdoch

On 06/09/2010 1:00 AM, raje...@cse.iitm.ac.in wrote:

Hi,

I have a vector who contents should look like this,

c d NULL e f etc
or 
4 5 6 NULL 7 8 9


how can I represent the null value?


As others have said, you probably want NA rather than NULL.  If you 
really want NULL, then use a list (a generic vector).  So


x - list(c, d, NULL, e, f)
y - list(4,5,6,NULL, 7,8,9)

You need to be careful when setting values, because

y[[1]] - NULL

will *remove* element 1, not set it to NULL.  To set it to NULL, use

y[1] - list(NULL)

Duncan Murdoch

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


[R] size limit of string/parse a string and convert to vector

2010-09-06 Thread raje...@cse.iitm.ac.in

Hi,
I have a loop as follows,

dataStr - character(0)
 repeat{
  fstr-read.socket(sockfd)
  if(fstr==)
  break
  dataStr-paste(dataStr,fstr)
 }

at what point does dataStr stop accepting(gets full)? I'm sending millions of 
records over the socket and need to know if all of it can go into dataStr.

Also, Incase all of it cannot go into dataStr, I need to parse each 
read.socket. In such a case, 
I have a string as follows,
|1,ab,2.34|2,cd,3.44| how can I parse this to become a list of 2 string 
vectors, namely,
list(c(1,ab,2.34),c(2,cd,3.44))

Any help is appreciated
[[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] Strange behavior of interval values in optimize()

2010-09-06 Thread Michael Bernsteiner

Hi all,

I'm using optimize() to find the minimum of the following function f, and 
minimize it (without 

f-function(delta,P,U){
minimiz-P+delta*U
x-minimiz[1]
y-minimiz[2]
z-100*(y-x^2)^2+(1-x)^2
return(z)
}

result-optimize(f, interval=c(-1, 1), P=c(0.99,1.01), U=c(1,0))
result


Nothing unexpected in the output so far:

 result-optimize(f, interval=c(-1, 1), P=c(0.99,1.01), U=c(1,0))
 result
$minimum
[1] 0.01498144

$objective
[1] 2.482991e-05


But, when I choose a larger Interval in the optimization method:

result-optimize(f, interval=c(-100, 10), P=c(0.99,1.01), U=c(1,0))
result

 result-optimize(f, interval=c(-100, 10), P=c(0.99,1.01), U=c(1,0))
 result
$minimum
[1] -1.989997

$objective
[1] 4.01


The result gets worse (even though the old interval is included in the new one).

In fact I don't want any restrictons for the interval values (something like 
interval=(-Inf, Inf) or at least the interval should be as large as possible.

Does anyone know this strange behavior? Where does it come from?

Thank you,
Fabian
  
[[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] representing NULL values in a vector

2010-09-06 Thread raje...@cse.iitm.ac.in
NA is good.thanks

- Original Message -
From: Patrick Burns pbu...@pburns.seanet.com
To: r-help@r-project.org, raje...@cse.iitm.ac.in
Sent: Mon, 06 Sep 2010 13:55:34 +0530 (IST)
Subject: Re: [R] representing NULL values in a vector

Perhaps you mean NA rather than NULL.

If NA is not what you want, then I
think you'll need to explain your
application.

On 06/09/2010 06:00, raje...@cse.iitm.ac.in wrote:

 Hi,

 I have a vector who contents should look like this,

 c d NULL e f etc
 or
 4 5 6 NULL 7 8 9

 how can I represent the null value?
   [[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.


-- 
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')

[[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 cluster vectors of factors

2010-09-06 Thread Rafael Björk
If I understand you correctly and each factor consists of binary data, you
may want to check out monothethic analysis, available in the package
'cluster'.

For a simple example and short description of the method to get you started,
just type in:

require(cluster)
?mona

As far as i know there's nothing strictly theoretically invalid in using
hierarchical clustering on binary data, and you may want to see how results
may differ by trying the example data (and your own data) with other
clustering methods. For example, compare:

require(cluster)
data(animals)

plot(mona(animals))
plot(agnes(animals))


2010/9/2 tueken hannat_tue...@hotmail.com


 Hello all

 I wonder what can i use to cluster vectors which composed of several
 factors.
 lets say around 30 different factors compose a vector, and if the factor is
 present then it encoded as 1, if not presented then it will be encoded as
 0.
 I was thinking of using hierarchical clustering, as i know the distance
 between two vector were calculated through euclidean distance function, but
 i dont think this distance would be correct to separate the data, cause two
 vector with different composition, could end up having similar distance to
 another vector.
 hope someone could give me some clue!
 --
 View this message in context:
 http://r.789695.n4.nabble.com/how-to-cluster-vectors-of-factors-tp2514654p2514654.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


[R] Creating named.list from two matrix columns

2010-09-06 Thread Viki S

Hi Friends,
I am new to R.

On R utility class pages, creating named.list is described with this command :
new(named.list,a=1,b=2)


For large matrix having two columns, such as :

row1   2334
row2   347
row3   379
...

I want to create a named.list like :
$row1
[1] 2334

$row2
[1] 347

...

Can anyone explain how named.list variable can be created by using two 
specified columns of a dataframe or matrix object, where one of the two columns 
is assigned as a name (string) and
other as its corresponding value ?

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] Finding the two most recent dates

2010-09-06 Thread Paul Hiemstra

Hi Natalie,

By far the easiest thing to do is to convert the date to a special date 
class. See as.POSIXct for example. I'm not sure that 14784 means, nor 
what the data says in the bp_date column. Probably the two combine into 
a specific date?


Once you've converted the columns into a POSIXct object, you can use the 
min() function to find the minimum.


cheers,
Paul

On 09/06/2010 12:45 PM, Newbie19_02 wrote:

Dear R help,

I have the following data frame:

structure(list(prochi = c(ind_1, ind_1, ind_1,
ind_1, ind_1, ind_1, ind_1, ind_1,
ind_1, ind_1), date_1st_event = structure(c(14784,
14784, 14784, 14784, 14784, 14784, 14784, 14784, 14784, 14784
), class = Date), bp_date = structure(c(12660, 14571, 13392,
13080, 12012, 13080, 13894, 14622, 12654, 13894), class = Date),
 SBP = c(135L, 160L, 135L, 153L, 150L, 153L, 151L, 126L, 150L,
 151L), DBP = c(85L, 80L, NA, 79L, 82L, 79L, 76L, 60L, 82L,
 91L)), .Names = c(prochi, date_1st_event, bp_date, SBP,
DBP), row.names = 108:117, class = data.frame)

It consists of repeated measures for the same individual.  What I want to do
is find the two most recent blood pressure readings (SBP and DBP) using
date_1st_event and bp_date.  What I would do to find the most recent date is
to subtract date_1st_event-bp_date and then aggregate by min.  I'm not sure
how to find the two most recent dates.

Are there some functions that can help me or will I have to write a function
from scratch.  Any help just to point me in the right direction.

Thanks,
Natalie
   



--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 253 5773
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] Two images functions

2010-09-06 Thread Alaios
Hello everyone.
I would like to ask you what happens when two functions with the same name 
exist. I discovered this today when I wrote
?images (I was trying to understand how it works)

?images gave me the following output: 

Help on topic 'image' was found in the following packages:
Image
 (in package raster in library 
/home/apa/R/x86_64-unknown-linux-gnu-library/2.11)
Display a Color Image
 (in package graphics in library /usr/lib64/R/library)


How can I be sure which function is called when I write Image(x,y,f) or Image(f)

I would like to thank you in advance for your help.

Best Regards
Alex



  
[[alternative HTML version deleted]]

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


Re: [R] anova of glm output

2010-09-06 Thread Dieter Menne


francogrex wrote:
 
 out - glm(response~Var1+Var2+Var3..,family=binomial,data=mydata)
 summary(out)
 stepAIC(out)
 anova(out, test='Chisq')
 I understand that stepAIC is used to select the model with the lowest AIC
 (the best model) but can someone explain what is the purpose of doing the
 anova: anova(out, test='Chisq')? What extra information does it bring?
 Thanks
 

out is of class glm (and lm, if that matters). So we have anova working on
a glm class, which is documented in anova.glm.

You should be aware that this anova depends on the order of you Varx, so be
cautious.

Dieter


-- 
View this message in context: 
http://r.789695.n4.nabble.com/anova-of-glm-output-tp2528336p2528354.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] Creating named.list from two matrix columns

2010-09-06 Thread jim holtman
Is this what you want:

 x
V1   V2
1 row1 2334
2 row2  347
3 row3  379
 x.list - as.list(x$V2)
 names(x.list) - x$V1
 x.list
$row1
[1] 2334

$row2
[1] 347

$row3
[1] 379



On Mon, Sep 6, 2010 at 7:55 AM, Viki S is...@live.com wrote:

 Hi Friends,
 I am new to R.

 On R utility class pages, creating named.list is described with this 
 command :
 new(named.list,a=1,b=2)


 For large matrix having two columns, such as :

 row1   2334
 row2   347
 row3   379
 ...

 I want to create a named.list like :
 $row1
 [1] 2334

 $row2
 [1] 347

 ...

 Can anyone explain how named.list variable can be created by using two 
 specified columns of a dataframe or matrix object, where one of the two 
 columns is assigned as a name (string) and
 other as its corresponding value ?

 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.




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

What is the problem that you are trying to solve?

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


[R] dataframe row names from list

2010-09-06 Thread raje...@cse.iitm.ac.in

Hi,
I have a list which looks like this...
 str(y)
List of 10
 $ : chr [1:4] ABCD 5 0 1
 $ : chr [1:4] DEF 15 1 16
 $ : chr [1:4] AAA 2 17 8
 $ : chr [1:4] SSS 15 25 1
 $ : chr [1:4] III 15 26 4
 $ : chr [1:4] OPQ 7 30 4
 $ : chr [1:4] TYR 14 34 8
 $ : chr [1:4] IRTS 15 42 1
 $ : chr [1:4] LLL 15 43 2
 $ : chr [1:4] AQW 3 45 4
 
I need to create a dataframe whose row names are chr[1] of each vector..ie 
ABCD,DEF,AAA ETC. how can I do this?
[[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] replacing functions

2010-09-06 Thread Dieter Menne


Karen Sargsyan wrote:
 
 Is it possible to replace function with my own? I want to apply pca 
 clustering, but to use some strange correlation function. I'm asking about
 replacing,  say, mean() with new content of mean() and use standard other
 functions,  which might use mean() as part.
 

The usual way would be to get the source code for the function you are
trying to change (or, fast way, with getAnywhere(pca)), copy it to an
editor, and make the changes. However, better always rename it before using,
e.g. pcaKaren - function

If the code you are trying to change is not directly called, but indirectly,
things are more complicated. In most cases, it's easiest to get the whole
package, put it into a different namespace, and make the changes. Easiest
does not mean not easy, though.

Dieter


-- 
View this message in context: 
http://r.789695.n4.nabble.com/replacing-functions-tp2528143p2528361.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] inserting a vector as a row in a data.frame

2010-09-06 Thread raje...@cse.iitm.ac.in

Hi,

is it possible to insert a vector as a row in a data.frame?
[[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] Strange behavior of interval values in optimize()

2010-09-06 Thread Dieter Menne


Michael Bernsteiner wrote:
 
 
 I'm using optimize() to find the minimum of the following function f, and
 minimize it (without 
 .
 But, when I choose a larger Interval in the optimization method:
 
 The result gets worse (even though the old interval is included in the new
 one).
 
 In fact I don't want any restrictons for the interval values (something
 like interval=(-Inf, Inf) or at least the interval should be as large as
 possible.
 
 

The most likely cause is a second minimum.

Dieter

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Strange-behavior-of-interval-values-in-optimize-tp2528208p2528366.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] anova of glm output

2010-09-06 Thread francogrex

Hi, this is more related to understanding some statistics while using R; I've
see such output in a paper:
out - glm(response~Var1+Var2+Var3..,family=binomial,data=mydata)
summary(out)
stepAIC(out)
anova(out, test='Chisq')
I understand that stepAIC is used to select the model with the lowest AIC
(the best model) but can someone explain what is the purpose of doing the
anova: anova(out, test='Chisq')? What extra information does it bring?
Thanks
-- 
View this message in context: 
http://r.789695.n4.nabble.com/anova-of-glm-output-tp2528336p2528336.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to get mypkg-manual.pdf

2010-09-06 Thread Juliet Ndukum
I am building a package say mypkg. Five months ago, when I built the package I 
got the mypkg manual in pdf format. 

Today, after making updates, I build the same package, same name, and steps; 
unfortunately I do not get the manual in pdf format. 
Rather I get the following message: 
cd: can't cd to /cygdrive/c/Documents saving output to 'mypkg-manual.pdf' 
...Done

Could any one help me on how to get the mypkg-manual.pdf.
Thank you in advance for your help.
JN



  
[[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] size limit of string/parse a string and convert to vector

2010-09-06 Thread jim holtman
try this:

 x - |1,ab,2.34|2,cd,3.44|
 # split by the | and remove vectors of zero characters
 x.sp - strsplit(x, '|', fixed = TRUE)[[1]]
 x.sp - x.sp[nchar(x.sp)  0]
 # now split by comma
 x.comma - strsplit(x.sp, ',')
 # you can now access you data
 x.comma
[[1]]
[1] 1ab   2.34

[[2]]
[1] 2cd   3.44



On Mon, Sep 6, 2010 at 6:06 AM, raje...@cse.iitm.ac.in
raje...@cse.iitm.ac.in wrote:

 Hi,
 I have a loop as follows,

 dataStr - character(0)
  repeat{
  fstr-read.socket(sockfd)
  if(fstr==)
  break
  dataStr-paste(dataStr,fstr)
  }

 at what point does dataStr stop accepting(gets full)? I'm sending millions of 
 records over the socket and need to know if all of it can go into dataStr.

 Also, Incase all of it cannot go into dataStr, I need to parse each 
 read.socket. In such a case,
 I have a string as follows,
 |1,ab,2.34|2,cd,3.44| how can I parse this to become a list of 2 string 
 vectors, namely,
 list(c(1,ab,2.34),c(2,cd,3.44))

 Any help is appreciated
        [[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

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


Re: [R] dataframe row names from list

2010-09-06 Thread Ivan Calandra
  Hi!

I'm sure there's an easier way, but that works for me:

test_list - list(c(ABC,5,0), c(DEF,10,1)) ##just a part of 
your example, think about using dput() to create a copy/pastable example
test_df - t(as.data.frame(test_list)[-1,])
rownames(test_df) - t(as.data.frame(test_list)[1,])

HTH,
Ivan

Le 9/6/2010 13:41, raje...@cse.iitm.ac.in a écrit :
 Hi,
 I have a list which looks like this...
 str(y)
 List of 10
   $ : chr [1:4] ABCD 5 0 1
   $ : chr [1:4] DEF 15 1 16
   $ : chr [1:4] AAA 2 17 8
   $ : chr [1:4] SSS 15 25 1
   $ : chr [1:4] III 15 26 4
   $ : chr [1:4] OPQ 7 30 4
   $ : chr [1:4] TYR 14 34 8
   $ : chr [1:4] IRTS 15 42 1
   $ : chr [1:4] LLL 15 43 2
   $ : chr [1:4] AQW 3 45 4

 I need to create a dataframe whose row names are chr[1] of each vector..ie 
 ABCD,DEF,AAA ETC. how can I do this?
   [[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.


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

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


[[alternative HTML version deleted]]

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


Re: [R] max limit of list size and vector size?

2010-09-06 Thread jim holtman
It is easy to store a list of that size:

 x - list(1:1e6, 1:1e6, 1:1e6)
 object.size(x)
12000112 bytes
 str(x)
List of 3
 $ : int [1:100] 1 2 3 4 5 6 7 8 9 10 ...
 $ : int [1:100] 1 2 3 4 5 6 7 8 9 10 ...
 $ : int [1:100] 1 2 3 4 5 6 7 8 9 10 ...

Now it really depends on how you are processing the data.  If you are
appending to a vector each time:

myData - c(myData, newData)

This is not efficient since it may be making copies of the vector each
time to extend it.  It is best to preallocate the vector and then
store the result:

myData - numeric(100)  # hold 1 million values
for (i in 1:1e6)  myData[i] - newData

My rule of thumb is that a single object should take up no more than
25% of the available RAM so that copies can be made during the
processing.

HTH

On Mon, Sep 6, 2010 at 2:54 AM, raje...@cse.iitm.ac.in
raje...@cse.iitm.ac.in wrote:

 Hi,

 Is it possible for me to store a list of vectors of 1 million entries?
 like,
 cc-list(c(1,2,1million),c(1,2,1million))

 also

 what is the length of the longest string in R? I keep getting info from a 
 socket and keep pasting on a string...when will this start becoming a problem?
        [[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

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


Re: [R] inserting a vector as a row in a data.frame

2010-09-06 Thread Ivan Calandra
  Hi again,

see ?rbind

Ivan

Le 9/6/2010 14:11, raje...@cse.iitm.ac.in a écrit :
 Hi,

 is it possible to insert a vector as a row in a data.frame?
   [[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.


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

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


[[alternative HTML version deleted]]

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


Re: [R] Correct coefficients from treatment contrasts?

2010-09-06 Thread David Winsemius


On Sep 6, 2010, at 4:03 AM, B W wrote:

Snipped out formatting detritus and added back many missing speces.

-Hello,I am trying to take the information from the summary of my  
best fit logisticregression model for the occurrence of a high  
elevation plant spp. and create the appropriate equation that will  
calculate probability of occurrence, given the data. My predictors  
include both continuous variables (slope and a second  
orderpolynomial of elevation) and a discrete variable for aspect  
(warm and cool). I have left unchanged the default contrasts option,  
so I believe that thefollowing coefficients were created using  
treatment contrasts.  My question how can I take this summary output  
and create the logistic equation that will allow me to calculate  
probability of occurrence. My interests are touse this to spatially  
display this info in a GIS environment.


I think you should:

-- Read the Posting Guide where you should learn that this is a plain  
text mailing list and that you need to change the configuration of  
your mail client.


-- Read the help page and read other documentation regarding the use  
of the predict function.


I have made adraft equation (shown below) that uses the coefficients  
from this summaryoutput, but this appears to be incorrect – values  
always return zeroprobabilities. Presumably I need to adjust the  
values in some way – but I am unclear as to how to proceed.  
Anyguidance would be appreciated!



 summary (


Call:glm(formula= Po ~ Slope + poly(Elevation, 2) + Aspect_2, family  
= quasibinomial) DevianceResiduals: Min  1Q   Median
3Q Max  -1.0532  -0.4167 -0.2760  -0.1823   3.3376


Coefficients:  Estimate Std. Error t valuePr(| 
t|)(Intercept)  -4.577707   0.222406 -20.583   2e-16 ***



Slope 0.039959   0.003593 11.121   2e-16 ***



poly(Elevation,2)1   8.050898   5.601956  1.437   0.1508



poly(Elevation,2)2 -37.694521   6.297806  -5.985 2.39e-09 ***



Aspect_2w 0.429229   0.174760  2.456   0.0141 *  ---


You may get predictions at the original data points with:

pred  predict(model.Slope.Elevation.Aspect)

 (1/ (1 +  exp(-1 * (-4.577707 + 0.039959*Slope + 8.050898 *  
poly(Elevation, 2)1 + -37.694521 * poly(Elevation, 2)2 + 0.429229*  
Aspect_2w)


Brendan Wilson
2530 Alexis Road
Shoreacres BC
Canada  V1N 4P6
Ph: 1.250.359.5905



[[alternative HTML version deleted]]


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] extracting x,y coordinates from a contour plot

2010-09-06 Thread Charles Annis, P.E.
Thank you, David:

I obviously didn't look hard enough.  This is exactly what I need.

Charles Annis, P.E.

charles.an...@statisticalengineering.com
561-352-9699
http://www.StatisticalEngineering.com

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of David Winsemius
Sent: Monday, September 06, 2010 12:43 AM
To: charles.an...@statisticalengineering.com
Cc: r-help@r-project.org
Subject: Re: [R] extracting x,y coordinates from a contour plot


On Sep 5, 2010, at 11:48 PM, Charles Annis, P.E. wrote:

 Requisite info: R version 2.11.1 (2010-05-31) running on a 64 bit HP  
 Windows
 7 machine.

Doubt that makes much of a difference here.

 I have used contour() for several years.  Now I would like to  
 extract from a
 contour plot the x, y coordinates of a contour z=constant.  This  
 seems as
 though it would be straight-forward but I've been unsuccessful in my
 searches of CRAN.

Suggest you read the help page for contour and the pages to which it  
links as well as working the examples. The answer is illustrated in  
the examples on that page.

 Can anyone provide a hint?

  x - 10*1:nrow(volcano)
  y - 10*1:ncol(volcano)
  xy160 - contourLines(x, y, volcano, nlevels=1, levels=160)
  str(xy160)
List of 2
  $ :List of 3
   ..$ level: num 160
   ..$ x: num [1:165] 110 108 105 102 103 ...
   ..$ y: num [1:165] 295 300 310 320 330 ...
  $ :List of 3
   ..$ level: num 160
   ..$ x: num [1:31] 270 263 262 260 260 ...
   ..$ y: num [1:31] 310 320 330 340 350 ...

-- 
David.

David Winsemius, MD
West Hartford, CT

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

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

2010-09-06 Thread Edward Patzelt
Everyone -

What do the NaN's mean here?  Is this analysis a problem?


Linear mixed-effects model fit by maximum likelihood
 Data: tmp.dat
   AIC  BIClogLik
  1611.251 1638.363 -797.6253

Random effects:
 Formula: ~1 | group_id
 (Intercept) Residual
StdDev: 0.0003077668 9.236715

Fixed effects: AvgTrials ~ time + factor(group_id) + time *
factor(group_id)
   Value Std.Error  DF   t-value p-value
(Intercept)18.159722  3.576664 213  5.077279  0.
time4.192708  1.655674 213  2.532327  0.0121
factor(group_id)2  -6.929563  5.235700   0 -1.323522 NaN
factor(group_id)3  -1.654554  4.189575   0 -0.394922 NaN
time:factor(group_id)2  1.729911  2.423658 213  0.713760  0.4762
time:factor(group_id)3 -2.555111  1.939396 213 -1.317478  0.1891
 Correlation:
   (Intr) time   fc(_)2 fc(_)3 t:(_)2
time   -0.926
factor(group_id)2  -0.683  0.632
factor(group_id)3  -0.854  0.790  0.583
time:factor(group_id)2  0.632 -0.683 -0.926 -0.540
time:factor(group_id)3  0.790 -0.854 -0.540 -0.926  0.583

Standardized Within-Group Residuals:
   Min Q1Med Q3Max
-1.8842754 -0.6979785 -0.3370998  0.5666704  3.0943948

Number of Observations: 219
Number of Groups: 3
Warning message:
In pt(q, df, lower.tail, log.p) : NaNs produced

[[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 on write.xlsx library(xlsx)

2010-09-06 Thread Ravi S. Shankar
Hi Adrian,

 

dat=data.frame(matrix(0,3,3))

 

write.xlsx(dat,z:/dat.xlsx,sheetName=sheet1,append=F)

write.xlsx(dat,z:/dat.xlsx,sheetName=sheet2,append=F)

 

The above code works and creates new worksheets. But if I want to append
to an existing worksheet I seem to get an error.

 

write.xlsx(dat,z:/dat.xlsx,sheetName=sheet2,append=T) - This gives
an error saying The workbook already contains a sheet of this name

 

Could you please let me know how to append data to  an existing sheet
and not create a new sheet each time?

 

Thank you

Ravi

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

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


Re: [R] how do I transform this to a for loop

2010-09-06 Thread Karl Brand

Hi Paul, Ivan,

Hartstikke bedankt and thanks alot for sharing these thoughts. I can see 
'listing up' multiple symmetrical data sets makes a lot of sense. As 
does using lapply() on them which i understand to be more 
efficient/faster than for().


Goodo- with your concensus (and helpful examples) i can tell myself 
investing the extra time to use lapply on lists /will/ pay off in the 
long run vs. copying and pasting (nearly) the same line of code 10 times 
for every data manipulation...


thanks again,

Karl



On 9/6/2010 12:09 PM, Paul Hiemstra wrote:

Hi Karl,

The why do it like this is probably direct towards creating 9 new
objects for the arima results (Is this right Bill?). A better option
would be to create a list with nine entries. This is much easier for any
subsequent analyses. An example that uses lapply (an efficient syntax
for loops):

sseq - c(1, seq(5, 40, by = 5))
result_list = lapply(sseq, function(num) {
arima(data.ts[num:(num+200)], order=c(1,1,1))
})

cheers,
Paul

On 09/06/2010 10:46 AM, Karl Brand wrote:

Hi Bill,

I didn't make the original post, but its pretty similar to some thing
i would have queried the list about. But, as an R dilatante i find
more curious your question-

...but why would you want to do so?

Is this because you'd typically use the given nine lines of explicit
code to carve up a single dataset into nine symmetrical variants ? Or
that some contextual information may affect how you would write the
for() loop?

As i lack the experience to know any better, i perceive your for()
loop as de rigour in efficient use of R, and the preferance of all
experienced R user's. But not having any formal education in R or role
models as such, its only an assumption (compeletely ignoring for the
moment processing efficiency/speed, rounding error and such).

But which i now question! Explicit, simple crude looking code; or,
something which demands a little more proficiency with the language?

cheers,

Karl



On 9/6/2010 6:16 AM, bill.venab...@csiro.au wrote:


sseq- c(1, seq(5, 40, by = 5))
for(i in 1:length(sseq))
assign(paste(arima, i, sep=),
arima(data.ts[sseq[i]:(sseq[i]+200)], order=c(1,1,1)))

...but why would you want to do so?


-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of lord12
Sent: Monday, 6 September 2010 10:57 AM
To: r-help@r-project.org
Subject: [R] how do I transform this to a for loop


arima1- arima(data.ts[1:201], order = c(1,1,1))
arima2- arima(data.ts[5:205], order = c(1,1,1))
arima3- arima(data.ts[10:210], order = c(1,1,1))
arima4- arima(data.ts[15:215], order = c(1,1,1))
arima5- arima(data.ts[20:220], order = c(1,1,1))
arima6- arima(data.ts[25:225], order = c(1,1,1))
arima7- arima(data.ts[30:230], order = c(1,1,1))
arima8- arima(data.ts[35:235], order = c(1,1,1))
arima9- arima(data.ts[40:240], order = c(1,1,1))








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

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


Re: [R] nlme Output

2010-09-06 Thread ONKELINX, Thierry
Dear Edward,

You have no degrees of freedom left to estimate those p-values. Your
design does not allows for the model your implemented. We need a brief
summary of your design in order to help you further.

HTH,

Thierry



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

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

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

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

The plural of anecdote is not data.
~ Roger Brinner

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

 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] Namens Edward Patzelt
 Verzonden: maandag 6 september 2010 15:43
 Aan: r-help@r-project.org
 Onderwerp: [R] nlme Output
 
 Everyone -
 
 What do the NaN's mean here?  Is this analysis a problem?
 
 
 Linear mixed-effects model fit by maximum likelihood
  Data: tmp.dat
AIC  BIClogLik
   1611.251 1638.363 -797.6253
 
 Random effects:
  Formula: ~1 | group_id
  (Intercept) Residual
 StdDev: 0.0003077668 9.236715
 
 Fixed effects: AvgTrials ~ time + factor(group_id) + time *
 factor(group_id)
Value Std.Error  DF   t-value p-value
 (Intercept)18.159722  3.576664 213  5.077279  0.
 time4.192708  1.655674 213  2.532327  0.0121
 factor(group_id)2  -6.929563  5.235700   0 -1.323522 NaN
 factor(group_id)3  -1.654554  4.189575   0 -0.394922 NaN
 time:factor(group_id)2  1.729911  2.423658 213  0.713760  0.4762
 time:factor(group_id)3 -2.555111  1.939396 213 -1.317478  0.1891
  Correlation:
(Intr) time   fc(_)2 fc(_)3 t:(_)2
 time   -0.926
 factor(group_id)2  -0.683  0.632
 factor(group_id)3  -0.854  0.790  0.583
 time:factor(group_id)2  0.632 -0.683 -0.926 -0.540
 time:factor(group_id)3  0.790 -0.854 -0.540 -0.926  0.583
 
 Standardized Within-Group Residuals:
Min Q1Med Q3Max
 -1.8842754 -0.6979785 -0.3370998  0.5666704  3.0943948
 
 Number of Observations: 219
 Number of Groups: 3
 Warning message:
 In pt(q, df, lower.tail, log.p) : NaNs produced
 
   [[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.
 

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

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

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


[R] Aggregating the matrices

2010-09-06 Thread Sergey Goriatchev
Hello everyone.

Say we have the following:

a - matrix(c(-75, 3, 5, 9, 2, 3, 5), nrow=1, dim=list(06092010,
c(ES, PT, Z , CF, GX, ST, EO)))
b - matrix(c(-5, 2, 4, 12, 5), nrow=1, dim=list(06092010, c(PT,
CF, AT, EM, ST)))
d - cbind(a, b)

I want to calculate sums of the columns that have similar column names
and then output this summary
What I want to have is an array that looks like:

ES  PT Z  CF...
-75  -2  5  11...

I tried the following, but it did not work:
aggregate(d, list(colnames(d)), sum)

How can I achieve my objective?

Thank you in advance.

Sergey

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


Re: [R] Finding the two most recent dates

2010-09-06 Thread Newbie19_02

Dear all,

Thanks very much for the replies and for the help.  

This whole  data set consists of about 7000 individuals who have had
multiple blood pressure measures taken over time so I just used one
individual as an example. I'm sorry if it looked like homework...it isn't.

Jim your solution worked really well thanks.  I was thinking of things in
terms of diff time and not order, so thanks.

Natalie


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Finding-the-two-most-recent-dates-tp2528185p2528417.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] Aggregating the matrices

2010-09-06 Thread Gabor Grothendieck
On Mon, Sep 6, 2010 at 9:56 AM, Sergey Goriatchev serg...@gmail.com wrote:
 Hello everyone.

 Say we have the following:

 a - matrix(c(-75, 3, 5, 9, 2, 3, 5), nrow=1, dim=list(06092010,
 c(ES, PT, Z , CF, GX, ST, EO)))
 b - matrix(c(-5, 2, 4, 12, 5), nrow=1, dim=list(06092010, c(PT,
 CF, AT, EM, ST)))
 d - cbind(a, b)

 I want to calculate sums of the columns that have similar column names
 and then output this summary
 What I want to have is an array that looks like:

 ES  PT Z  CF...
 -75  -2  5  11...

 I tried the following, but it did not work:
 aggregate(d, list(colnames(d)), sum)

 How can I achieve my objective?

 Thank you in advance.



Try this:

 library(plyr)
 colSums(rbind.fill(as.data.frame(a), as.data.frame(b)), na.rm = TRUE)
 ES  PT  Z   CF  GX  ST  EO  AT  EM
-75  -2   5  11   2   8   5   4  12




-- 
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] Aggregating the matrices

2010-09-06 Thread David Winsemius


On Sep 6, 2010, at 9:56 AM, Sergey Goriatchev wrote:


Hello everyone.

Say we have the following:

a - matrix(c(-75, 3, 5, 9, 2, 3, 5), nrow=1, dim=list(06092010,
c(ES, PT, Z , CF, GX, ST, EO)))
b - matrix(c(-5, 2, 4, 12, 5), nrow=1, dim=list(06092010, c(PT,
CF, AT, EM, ST)))
d - cbind(a, b)

I want to calculate sums of the columns that have similar column names
and then output this summary
What I want to have is an array that looks like:

ES  PT Z  CF...
-75  -2  5  11...

I tried the following, but it did not work:
aggregate(d, list(colnames(d)), sum)


ES is not in the duplicated column names so perhaps your English  
specification is not what you meant:

 d
  ES PT Z  CF GX ST EO PT CF AT EM ST
06092010 -75  3  5  9  2  3  5 -5  2  4 12  5

 dupled - colnames(d)[duplicated(colnames(d))]
 sapply(dupled, function(x) sum( d[, x]))
PT CF ST
 3  9  3

If you wanted simple a sum over unique column names then it would have  
been somewhat simpler (no need to construct a duplicated set):


 sapply(unique(colnames(d)), function(x) sum( d[, x]))
 ES  PT  Z   CF  GX  ST  EO  AT  EM
-75   3   5   9   2   3   5   4  12



How can I achieve my objective?

Thank you in advance.

Sergey

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


David Winsemius, MD
West Hartford, CT

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


[R] Time Series

2010-09-06 Thread trb1

Hi 

How would I analyse time series with 
- different lengths (i.e. one has 9 entries and the other has 14 entries)
- different frequency (i.e. dates are random - no repeated length)
- multiple values for the same time entry (e.g. 2009-10-23 below)

i.e. my data takes the form:
1st time series

2009-10-07  0.009378
2009-10-19  0.014790
2009-10-23  -0.005946
2009-10-23  0.009096
2009-11-08  0.004189
2009-11-10  -0.004592
2009-11-17  0.009397
2009-11-24  0.003411
2009-12-02  0.003300
2010-01-15  0.010873
2010-01-20  0.010712
2010-01-20  0.022237

2nd time series

2009-09-23  0.076253
2009-10-07  0.039255
2010-02-17  0.039045
2010-03-09  0.024201
2010-03-25  -0.039810
2010-04-13  -0.012428

I am unable to get any functions to work.
A simple plot would be nice! 


Thanks.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Time-Series-tp2528444p2528444.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] Aggregating the matrices

2010-09-06 Thread Sergey Goriatchev
Gabor, David, thank you.

David, your last suggestion is what I need.

Regards,
Sergey

On Mon, Sep 6, 2010 at 16:12, David Winsemius dwinsem...@comcast.net wrote:

 On Sep 6, 2010, at 9:56 AM, Sergey Goriatchev wrote:

 Hello everyone.

 Say we have the following:

 a - matrix(c(-75, 3, 5, 9, 2, 3, 5), nrow=1, dim=list(06092010,
 c(ES, PT, Z , CF, GX, ST, EO)))
 b - matrix(c(-5, 2, 4, 12, 5), nrow=1, dim=list(06092010, c(PT,
 CF, AT, EM, ST)))
 d - cbind(a, b)

 I want to calculate sums of the columns that have similar column names
 and then output this summary
 What I want to have is an array that looks like:

 ES  PT Z  CF...
 -75  -2  5  11...

 I tried the following, but it did not work:
 aggregate(d, list(colnames(d)), sum)

 ES is not in the duplicated column names so perhaps your English
 specification is not what you meant:
 d
          ES PT Z  CF GX ST EO PT CF AT EM ST
 06092010 -75  3  5  9  2  3  5 -5  2  4 12  5

 dupled - colnames(d)[duplicated(colnames(d))]
 sapply(dupled, function(x) sum( d[, x]))
 PT CF ST
  3  9  3

 If you wanted simple a sum over unique column names then it would have been
 somewhat simpler (no need to construct a duplicated set):

 sapply(unique(colnames(d)), function(x) sum( d[, x]))
  ES  PT  Z   CF  GX  ST  EO  AT  EM
 -75   3   5   9   2   3   5   4  12


 How can I achieve my objective?

 Thank you in advance.

 Sergey

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





-- 
Kniven skärpes bara mot stenen.

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


Re: [R] mac: lib/gtk.pkg

2010-09-06 Thread David Winsemius


On Sep 5, 2010, at 10:32 AM, Daniele Sluijters wrote:


Hello,

I'm sorry to just pop-up on the mailing list like this and ask a  
relatively non-R related question but I had no idea whom else to  
contact on this matter.
I'm working on a completely different port of an application to OS X  
which requires GTK and through Google'ing stumbled on a rather  
recent GTK installer for Mac at: http://r.research.att.com/


I was wondering if anyone here knows how GTK and its dependencies  
were packaged into that pkg? It'd be a lifesaver if someone could  
point me in the right direction.


Again, sorry for the non-R related question but this place seemed  
like the only option.


The is an R-SIG-Mac mailing list. It's webpage is at the top of the  
SIG entries on:

http://www.r-project.org/mail.html

I suspect that Simon Urbanek, who maintains the ATT webpages and very  
probably created that package, sometimes reads rhelp but I'm not sure  
on what schedule. You might see if he makes his email address  
available on those pages.


--

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] Aggregate certain rows in a matrix

2010-09-06 Thread Kennedy

Hi,

I have a matrix that looks like this 

  a - c(1,1,1,1,2,2,3,3,3,3)
  b - c(2,2,2,3,4,4,4,5,5,6)
  c - c(1,2,3,4,5,6,7,8,9,10)
  M - matrix(nr=10,nc=3)
  M[,1] - a
  M[,2] - b
  M[,3] - c

 M
  [,1] [,2] [,3]
 [1,]121
 [2,]122
 [3,]123
 [4,]134
 [5,]245
 [6,]246
 [7,]347
 [8,]358
 [9,]359
[10,]36   10

I want to reduce the matrix according to the following: If the values of the
two first columns are the same in two or more rows the values in the third
column of the corresponding rows should be added and only one of the rows
should be keept. Hence the matrix M above should look like this

  1 2 6
  1 3 4
  2 4 11
  3 4 7
  3 5 17
  3 6 10


Thank you

Henrik



-- 
View this message in context: 
http://r.789695.n4.nabble.com/Aggregate-certain-rows-in-a-matrix-tp2528454p2528454.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] calculating area between plot lines

2010-09-06 Thread A. Marcia BARBOSA
Hi everyone. I have these data:

probClass-seq(0,0.9,0.1)
prob1-c(0.0070,0.0911,0.1973,0.2949,0.3936,0.5030,0.5985,0.6869,0.7820,0.8822)
prob2-c(0.0066,0.0791,0.2358,0.3478,0.3714,0.3860,0.6667,0.6400,0.7000,1.)

# which I'm plotting as follows:

plot(probClass,prob1,xlim=c(0,1),ylim=c(0,1),xaxs='i',yaxs='i',type=n)
lines(probClass,prob1)
lines(probClass,prob2)
polygon(c(probClass,rev(probClass)),c(prob2,rev(prob1)),col=red,border=NA)


Given that the total area of the plot is 1, how can I calculate the
area between the plotted lines (red polygon)? I have only found the
areapl function in the splancs package, but it doesn't work for
self-intersecting polygons..

Any help will be gratefully received. Cheers,
Márcia

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


Re: [R] Aggregate certain rows in a matrix

2010-09-06 Thread Dimitris Rizopoulos

one way is the following:

M - cbind(c(1,1,1,1,2,2,3,3,3,3), c(2,2,2,3,4,4,4,5,5,6),
c(1,2,3,4,5,6,7,8,9,10))

ind - do.call(paste, c(as.data.frame(M[, 1:2], sep = \r)))
M[, 3] - ave(M[, 3], ind, FUN = sum)
unique(M)


I hope it helps.

Best,
Dimitris


On 9/6/2010 4:29 PM, Kennedy wrote:


Hi,

I have a matrix that looks like this

   a- c(1,1,1,1,2,2,3,3,3,3)
   b- c(2,2,2,3,4,4,4,5,5,6)
   c- c(1,2,3,4,5,6,7,8,9,10)
   M- matrix(nr=10,nc=3)
   M[,1]- a
   M[,2]- b
   M[,3]- c


M

   [,1] [,2] [,3]
  [1,]121
  [2,]122
  [3,]123
  [4,]134
  [5,]245
  [6,]246
  [7,]347
  [8,]358
  [9,]359
[10,]36   10

I want to reduce the matrix according to the following: If the values of the
two first columns are the same in two or more rows the values in the third
column of the corresponding rows should be added and only one of the rows
should be keept. Hence the matrix M above should look like this

   1 2 6
   1 3 4
   2 4 11
   3 4 7
   3 5 17
   3 6 10


Thank you

Henrik





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

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

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


Re: [R] Aggregate certain rows in a matrix

2010-09-06 Thread Barry Rowlingson
On Mon, Sep 6, 2010 at 3:29 PM, Kennedy henrik.aldb...@gmail.com wrote:

 I want to reduce the matrix according to the following: If the values of the
 two first columns are the same in two or more rows the values in the third
 column of the corresponding rows should be added and only one of the rows
 should be keept. Hence the matrix M above should look like this

  1 2 6
  1 3 4
  2 4 11
  3 4 7
  3 5 17
  3 6 10

Use library(plyr), convert to data frame, do ddply, convert back to
matrix if you want. I'm surprised mmply doesn't do it, but I dont
think it does:

  Md=data.frame(M)
  ddply(Md,c(1,2),function(r){sum(r[,3])})
  X1 X2 V1
1  1  2  6
2  1  3  4
3  2  4 11
4  3  4  7
5  3  5 17
6  3  6 10

plyr is on CRAN and that's the third time today I've told someone to use it.

Barry

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

2010-09-06 Thread Alaios
Hello everyone. 
I would kindly request your help concerning how R converts data between 
different structrures.

In the following example please keep attention on the following two
1) 
I create 
f - GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean, variance, nugget, 
scale, alpha))
with 
image(x,y,f)
   and
image(f)
I get exactly the same image.

then
2)I try to store f inside a raster layer using:
r - setValues(r,as.matrix(f))

then comes the tricky part. I am trying to use image again and get the same 
output as the ouput I got by image(f).
I tried
image(as.matrix(getValues(r)))
which give a completely different output. 
image function expects a matrix... but for some reason as.matrix(getValues(r)) 
returns a huge vector :(
also tried
as.matrix(getValues(r),ncol=ncol(r),nrow=nrow(r)) to force as.matrix to return 
the appropriate matrix but this also failed and I only got back a vector again

Could you please let me understand why this might happening?
Best Regards
Alex

P.S Below you will find part of my code.



...(lines omitted, declarations)
x - seq(1, dimx, step)
y - seq(1, dimy, step)
f - GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean, variance, nugget, 
scale, alpha))

# image(x, y, f) Displays the matrix
# f is a 2x2 matrix of dimension (x,y)

r - raster(nrow=dimx, ncol=dimy)
r - setValues(r,as.matrix(f))
# getValues(r)



  
[[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 get mypkg-manual.pdf

2010-09-06 Thread Duncan Murdoch

On 06/09/2010 9:19 AM, Juliet Ndukum wrote:
I am building a package say mypkg. Five months ago, when I built the package I 
got the mypkg manual in pdf format. 

Today, after making updates, I build the same package, same name, and steps; 
unfortunately I do not get the manual in pdf format. 
Rather I get the following message: 
cd: can't cd to /cygdrive/c/Documents saving output to 'mypkg-manual.pdf' 
...Done


Could any one help me on how to get the mypkg-manual.pdf.


It looks as though you are trying to put it into a file path with spaces 
in it, and the version of R you're using doesn't like the spaces.  Try 
saving it somewhere else.


I believe the current release doesn't care about spaces, but I'm not 
sure of that.  Building a pdf depends on external tools that are 
sometimes out of our control.


Duncan Murdoch


Thank you in advance for your help.
JN



  
	[[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] Time Series

2010-09-06 Thread Gabor Grothendieck
On Mon, Sep 6, 2010 at 10:24 AM, trb1 thomasrbol...@yahoo.co.uk wrote:

 Hi

 How would I analyse time series with
 - different lengths (i.e. one has 9 entries and the other has 14 entries)
 - different frequency (i.e. dates are random - no repeated length)
 - multiple values for the same time entry (e.g. 2009-10-23 below)

 i.e. my data takes the form:
 1st time series

 2009-10-07      0.009378
 2009-10-19      0.014790
 2009-10-23      -0.005946
 2009-10-23      0.009096
 2009-11-08      0.004189
 2009-11-10      -0.004592
 2009-11-17      0.009397
 2009-11-24      0.003411
 2009-12-02      0.003300
 2010-01-15      0.010873
 2010-01-20      0.010712
 2010-01-20      0.022237

 2nd time series

 2009-09-23      0.076253
 2009-10-07      0.039255
 2010-02-17      0.039045
 2010-03-09      0.024201
 2010-03-25      -0.039810
 2010-04-13      -0.012428

 I am unable to get any functions to work.
 A simple plot would be nice!



Try this.  We read in each series taking the last point in the event
that there are multiple points with the same date.  Then we plot each.

If we wish to plot them on the same plot then we merge each series
(for producing points) together with linear interpolations of both
series (for producing lines) and plot.

Lines1 - 2009-10-07  0.009378
2009-10-19  0.014790
2009-10-23  -0.005946
2009-10-23  0.009096
2009-11-08  0.004189
2009-11-10  -0.004592
2009-11-17  0.009397
2009-11-24  0.003411
2009-12-02  0.003300
2010-01-15  0.010873
2010-01-20  0.010712
2010-01-20  0.022237

Lines2 - 2009-09-23  0.076253
2009-10-07  0.039255
2010-02-17  0.039045
2010-03-09  0.024201
2010-03-25  -0.039810
2010-04-13  -0.012428

library(zoo)

z1 - read.zoo(textConnection(Lines1), aggregate = function(x) tail(x, 1))
z2 - read.zoo(textConnection(Lines2), aggregate = function(x) tail(x, 2))

plot(z1, type = o)
plot(z2, type = o)

# or together on the same plot
zz - merge(z1, z2)
zz - merge(z1, z2, na.approx(zz, na.rm = FALSE))
plot(zz, type = c(p, p, l, l), screen = 1:2)


-- 
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] rbind() overwriting data.frame()

2010-09-06 Thread rajesh j
Hi,

first off, I wanna ask how do I declare a data.frame of 0 rows and n
columns?

Coming to my problem,

I have a data.frame of 22 columns by dynamic rows which I insert using
rbind. The total number of rows could go upto 2,00,000. The problem is that
after about 800 or 900 get inserted rbind starts overwriting the data.frame
and I end up with a total of 800-900 rows. What is up with that?
The 22 columns are all strings each having about 10 characters
-- 
Rajesh.J

[[alternative HTML version deleted]]

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


Re: [R] rbind() overwriting data.frame()

2010-09-06 Thread Ivan Calandra
  Hi again!

I'm trying to follow your general goal from your questions today but 
it's not easy.

First, declaring a data.frame of 0 rows is a bad idea. It is much faster 
to define the length and number of rows from the beginning and to fill 
it then.

Second, I don't know how to do it! What I know is that, to my knowledge 
(maybe I overlooked some posts in the archive), there is no easy way to 
do it, such as lists or vectors. The easiest might be to create a list 
with the correct length with list(), fill it with whatever data and then 
convert it to a data.frame with as.data.frame() when it's finished.

Third, for your problem, maybe do.call() can help you. I don't know what 
you did up to now, but it sounds that you tried to do it iteratively (in 
a loop) instead of vectorizing it (though I don't know if do.call() can 
be really called vectorized). There was a post yesterday/today on 
do.call(). You'll surely find it if you look with RSiteSearch().

Last, I don't know if it is relevant for you, but I've read on the list 
many times that matrices are faster to deal with. If all your columns 
and rows have the same type, then you can use matrices.

There are surely guys that know more about this stuff somewhere on the 
list, but I hope it can get you started.
Ivan

Le 9/6/2010 16:56, rajesh j a écrit :
 Hi,

 first off, I wanna ask how do I declare a data.frame of 0 rows and n
 columns?

 Coming to my problem,

 I have a data.frame of 22 columns by dynamic rows which I insert using
 rbind. The total number of rows could go upto 2,00,000. The problem is that
 after about 800 or 900 get inserted rbind starts overwriting the data.frame
 and I end up with a total of 800-900 rows. What is up with that?
 The 22 columns are all strings each having about 10 characters

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

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


[[alternative HTML version deleted]]

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


Re: [R] Aggregate certain rows in a matrix

2010-09-06 Thread David Winsemius


On Sep 6, 2010, at 10:47 AM, Dimitris Rizopoulos wrote:


one way is the following:

M - cbind(c(1,1,1,1,2,2,3,3,3,3), c(2,2,2,3,4,4,4,5,5,6),
   c(1,2,3,4,5,6,7,8,9,10))

ind - do.call(paste, c(as.data.frame(M[, 1:2], sep = \r)))
M[, 3] - ave(M[, 3], ind, FUN = sum)
unique(M)


I had been working on a similar approach with ave( ,paste(), sum)  
inside a datafrmae, but I liked your approach of setting up the  
results of the paste operation as a vector outside of M. (Skips the  
dataframe operation I was using.) The above solution is destructive,  
so I constructed this similar alternative that returns the results  
without altering M:


 cbind(M, ave(M[ , 3], list(M[,1], M[,2]), FUN=sum))[
   !duplicated(M[,1:2]),  
c(1,2,4)]

 [,1] [,2] [,3]
[1,]126
[2,]134
[3,]24   11
[4,]347
[5,]35   17
[6,]36   10





I hope it helps.

Best,
Dimitris


On 9/6/2010 4:29 PM, Kennedy wrote:


Hi,

I have a matrix that looks like this

  a- c(1,1,1,1,2,2,3,3,3,3)
  b- c(2,2,2,3,4,4,4,5,5,6)
  c- c(1,2,3,4,5,6,7,8,9,10)
  M- matrix(nr=10,nc=3)
  M[,1]- a
  M[,2]- b
  M[,3]- c


M

  [,1] [,2] [,3]
 [1,]121
 [2,]122
 [3,]123
 [4,]134
 [5,]245
 [6,]246
 [7,]347
 [8,]358
 [9,]359
[10,]36   10

I want to reduce the matrix according to the following: If the  
values of the
two first columns are the same in two or more rows the values in  
the third
column of the corresponding rows should be added and only one of  
the rows

should be keept. Hence the matrix M above should look like this

  1 2 6
  1 3 4
  2 4 11
  3 4 7
  3 5 17
  3 6 10


Thank you

Henrik





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

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

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


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] rbind() overwriting data.frame()

2010-09-06 Thread ONKELINX, Thierry
This will give a matrix with 0 rows.

data.frame(matrix(nrow = 0,  ncol = 22, dimnames = list(NULL,
LETTERS[1:22])))

But you should avoid growing dataframes is the final dataframe is going
to be large. You are very likely to get memory problems. It is much to
better to create a large enough dataframe and then overwrite the rows.
And it is faster too...

 nrows - 2000
 ncols - 22
 system.time({
+ tmp - data.frame(matrix(nrow = 0,  ncol = ncols))
+ for(i in seq_len(nrows)){
+ tmp - rbind(tmp, rnorm(ncols))
+ }
+ })
   user  system elapsed 
   7.830.027.86 
 system.time({
+ tmp - data.frame(matrix(nrow = nrows,  ncol = ncols))
+ for(i in seq_len(nrows)){
+ tmp[i, ] - rnorm(ncols)
+ }
+ })
   user  system elapsed 
   3.750.003.76 

#In this case an apply construction was even faster

 system.time({
+ tmp - t(sapply(seq_len(nrows), function(i){
+ rnorm(ncols)
+ }))
+ })
   user  system elapsed 
   0.020.000.02 






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

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

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

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

The plural of anecdote is not data.
~ Roger Brinner

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

 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] Namens rajesh j
 Verzonden: maandag 6 september 2010 16:57
 Aan: r-help@r-project.org
 Onderwerp: [R] rbind() overwriting data.frame()
 
 Hi,
 
 first off, I wanna ask how do I declare a data.frame of 0 
 rows and n columns?
 
 Coming to my problem,
 
 I have a data.frame of 22 columns by dynamic rows which I 
 insert using rbind. The total number of rows could go upto 
 2,00,000. The problem is that after about 800 or 900 get 
 inserted rbind starts overwriting the data.frame and I end up 
 with a total of 800-900 rows. What is up with that?
 The 22 columns are all strings each having about 10 characters
 --
 Rajesh.J
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

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

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


Re: [R] Strange behavior of interval values in optimize()

2010-09-06 Thread Michael Bernsteiner

that was my first idea as well, but as the result shows, the minimized function 
value of the wider interval is greater.

In
 addidtion, the problem also exists, if the minimized parameter in the 
case of the larger interval also already lies within the smaller 
interval:


f-function(delta,P,U){
minimiz-P+delta*U
x-minimiz[1]
y-minimiz[2]
z-100*(y-x^2)^2+(1-x)^2
return(z)
}


 result-optimize(f, interval=c(-10, 1), P=c(0.99,1.01), U=c(1,0))
 result
$minimum
[1] 0.01496807

$objective
[1] 2.483522e-05

 
 result-optimize(f, interval=c(-100, 1), P=c(0.99,1.01), U=c(1,0))
 result
$minimum
[1] -1.989994

$objective
[1] 4.01

This does still make no sense for me

Fabian


 Date: Mon, 6 Sep 2010 06:18:16 -0700
 From: dieter.me...@menne-biomed.de
 To: r-help@r-project.org
 Subject: Re: [R] Strange behavior of interval values in optimize()
 
 
 
 Michael Bernsteiner wrote:
  
  
  I'm using optimize() to find the minimum of the following function f, and
  minimize it (without 
  .
  But, when I choose a larger Interval in the optimization method:
  
  The result gets worse (even though the old interval is included in the new
  one).
  
  In fact I don't want any restrictons for the interval values (something
  like interval=(-Inf, Inf) or at least the interval should be as large as
  possible.
  
  
 
 The most likely cause is a second minimum.
 
 Dieter
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Strange-behavior-of-interval-values-in-optimize-tp2528208p2528366.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
  
[[alternative HTML version deleted]]

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


[R] path analysis

2010-09-06 Thread Guy rotem
Hi.

which package i need to install to be able to run Path analysis using r?

many thanks, Guy

-- 
Guy Rotem
Department of Life Sciences
The Spatial Ecology Lab
Ben Gurion University of the Negev
P.O.B. 653   Beer-Sheva 84105
ISRAEL

+972-52-3354485 (mobile)
+972-8-6461350 (lab)

[[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] boxplot knowing Q1, Q3, median, upper and lower whisker value

2010-09-06 Thread David A.

Dear list,

I am using a external program that outputs Q1, Q3, median, upper and lower 
whisker values for various datasets simultaneously in a tab delimited format. 
After importing this text file into R, I would like to plot a boxplot using 
these given values and not the original series of data points, i.e. not using 
something like boxplot(mydata).

Is there an easy way for doing this? If I am not wrong, boxplot() does not 
accept these values as parameters.

Cheers,

Dave 
  
[[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] rbind() overwriting data.frame()

2010-09-06 Thread rajesh j
But If I do that how will I resize later?

On Mon, Sep 6, 2010 at 8:54 PM, ONKELINX, Thierry
thierry.onkel...@inbo.bewrote:

 This will give a matrix with 0 rows.

 data.frame(matrix(nrow = 0,  ncol = 22, dimnames = list(NULL,
 LETTERS[1:22])))

 But you should avoid growing dataframes is the final dataframe is going
 to be large. You are very likely to get memory problems. It is much to
 better to create a large enough dataframe and then overwrite the rows.
 And it is faster too...

  nrows - 2000
  ncols - 22
  system.time({
 + tmp - data.frame(matrix(nrow = 0,  ncol = ncols))
 + for(i in seq_len(nrows)){
 + tmp - rbind(tmp, rnorm(ncols))
 + }
 + })
   user  system elapsed
   7.830.027.86
  system.time({
 + tmp - data.frame(matrix(nrow = nrows,  ncol = ncols))
 + for(i in seq_len(nrows)){
 + tmp[i, ] - rnorm(ncols)
 + }
 + })
   user  system elapsed
   3.750.003.76

 #In this case an apply construction was even faster

  system.time({
 + tmp - t(sapply(seq_len(nrows), function(i){
 + rnorm(ncols)
 + }))
 + })
   user  system elapsed
   0.020.000.02




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

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

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

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

 The plural of anecdote is not data.
 ~ Roger Brinner

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


  -Oorspronkelijk bericht-
  Van: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] Namens rajesh j
  Verzonden: maandag 6 september 2010 16:57
  Aan: r-help@r-project.org
  Onderwerp: [R] rbind() overwriting data.frame()
 
  Hi,
 
  first off, I wanna ask how do I declare a data.frame of 0
  rows and n columns?
 
  Coming to my problem,
 
  I have a data.frame of 22 columns by dynamic rows which I
  insert using rbind. The total number of rows could go upto
  2,00,000. The problem is that after about 800 or 900 get
  inserted rbind starts overwriting the data.frame and I end up
  with a total of 800-900 rows. What is up with that?
  The 22 columns are all strings each having about 10 characters
  --
  Rajesh.J
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

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

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




-- 
Rajesh.J

[[alternative HTML version deleted]]

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


Re: [R] Time Series

2010-09-06 Thread trb1

Thank you very much for your post. 
Your answer has been very helpful.
Is it possible to merge 2 time series?

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Time-Series-tp2528444p2528584.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] rbind() overwriting data.frame()

2010-09-06 Thread rajesh j
Also, when I create the data.frame with matrix and try to rbind, I get
warnings..
Warning messages:
1: In `[-.factor`(`*tmp*`, ri, value = 4) :
  invalid factor level, NAs generated
2: In `[-.factor`(`*tmp*`, ri, value = 5) :
  invalid factor level, NAs generated
3: In `[-.factor`(`*tmp*`, ri, value = 6) :
  invalid factor level, NAs generated


On Mon, Sep 6, 2010 at 9:17 PM, rajesh j akshay.raj...@gmail.com wrote:

 But If I do that how will I resize later?


 On Mon, Sep 6, 2010 at 8:54 PM, ONKELINX, Thierry 
 thierry.onkel...@inbo.be wrote:

 This will give a matrix with 0 rows.

 data.frame(matrix(nrow = 0,  ncol = 22, dimnames = list(NULL,
 LETTERS[1:22])))

 But you should avoid growing dataframes is the final dataframe is going
 to be large. You are very likely to get memory problems. It is much to
 better to create a large enough dataframe and then overwrite the rows.
 And it is faster too...

  nrows - 2000
  ncols - 22
  system.time({
 + tmp - data.frame(matrix(nrow = 0,  ncol = ncols))
 + for(i in seq_len(nrows)){
 + tmp - rbind(tmp, rnorm(ncols))
 + }
 + })
   user  system elapsed
   7.830.027.86
  system.time({
 + tmp - data.frame(matrix(nrow = nrows,  ncol = ncols))
 + for(i in seq_len(nrows)){
 + tmp[i, ] - rnorm(ncols)
 + }
 + })
   user  system elapsed
   3.750.003.76

 #In this case an apply construction was even faster

  system.time({
 + tmp - t(sapply(seq_len(nrows), function(i){
 + rnorm(ncols)
 + }))
 + })
   user  system elapsed
   0.020.000.02




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

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

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

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

 The plural of anecdote is not data.
 ~ Roger Brinner

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


  -Oorspronkelijk bericht-
  Van: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] Namens rajesh j
  Verzonden: maandag 6 september 2010 16:57
  Aan: r-help@r-project.org
  Onderwerp: [R] rbind() overwriting data.frame()
 
  Hi,
 
  first off, I wanna ask how do I declare a data.frame of 0
  rows and n columns?
 
  Coming to my problem,
 
  I have a data.frame of 22 columns by dynamic rows which I
  insert using rbind. The total number of rows could go upto
  2,00,000. The problem is that after about 800 or 900 get
  inserted rbind starts overwriting the data.frame and I end up
  with a total of 800-900 rows. What is up with that?
  The 22 columns are all strings each having about 10 characters
  --
  Rajesh.J
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

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

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




 --
 Rajesh.J





-- 
Rajesh.J

[[alternative HTML version deleted]]

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


[R] WriteXLS problem

2010-09-06 Thread Kenneth Roy Cabrera Torres
Hi R users:

I don't know if you have had the following problem trying to
export to an xls format file in a non windows platform.

I try to use the following packages:
1. dataframes2xls (version 0.4.4) (with phyton 2.7 and 3.1)
2. WriteXLS (version 1.9.0) (with perl and testPerl working)

Even xlsx package that take too long and do not finish.

The data frame I try to export has 269363 row and 116 columns.
In the first one (dataframe2xls) I get this message:

Traceback (most recent call last):
 File
C:/PROGRA~2/R/R-211~1.1PA/library/dataframes2xls/python/csv2xls.py,
line 18, in module
import pyexcelerator
File
C:\PROGRA~2\R\R-211~1.1PA\library\dataframes2xls\python\pyexcelerator
\__init__.py,
line 12, in module from Workbook import Workbook
File
C:\PROGRA~2\R\R-211~1.1PA\library\dataframes2xls\python\pyexcelerator
\Workbook.py,
line 526 boundsheets_len += len(BIFFRecords.BoundSheetRecord(0x00L,
sheet.hidden, sheet.name).get())
^
SyntaxError: invalid syntax

Using the second option I get this message:

Error en get(as.character(i)),envr=envir) :
  objeto '089' no encontrado

Object '089' not found.

Im using this R platform:
sessionInfo()
R version 2.11.1 Patched (2010-08-30 r52848)
Platform: x86_64-unknown-linux-gnu (64-bit)

Locale:
LC_CTYPE=es_CO.UTF-8 

Is the only solution to export to .csv and then
to .xls format with other program like openoffice?

Thank you for your help and advice.

Kenneth

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


Re: [R] WriteXLS problem

2010-09-06 Thread Ivan Calandra
  Hi,

Are you sure you used the correct syntax and object names? It might just 
be because of that...(reading the error messages)
There is another function, xlsReadWrite::write.xls(), that I like a lot: 
it is really easy to use and does not require Perl or Python.

HTH,
Ivan

Le 9/6/2010 18:03, Kenneth Roy Cabrera Torres a écrit :
 Hi R users:

 I don't know if you have had the following problem trying to
 export to an xls format file in a non windows platform.

 I try to use the following packages:
 1. dataframes2xls (version 0.4.4) (with phyton 2.7 and 3.1)
 2. WriteXLS (version 1.9.0) (with perl and testPerl working)

 Even xlsx package that take too long and do not finish.

 The data frame I try to export has 269363 row and 116 columns.
 In the first one (dataframe2xls) I get this message:

 Traceback (most recent call last):
   File
 C:/PROGRA~2/R/R-211~1.1PA/library/dataframes2xls/python/csv2xls.py,
 line 18, inmodule
 import pyexcelerator
 File
 C:\PROGRA~2\R\R-211~1.1PA\library\dataframes2xls\python\pyexcelerator
 \__init__.py,
 line 12, inmodule  from Workbook import Workbook
 File
 C:\PROGRA~2\R\R-211~1.1PA\library\dataframes2xls\python\pyexcelerator
 \Workbook.py,
 line 526 boundsheets_len += len(BIFFRecords.BoundSheetRecord(0x00L,
 sheet.hidden, sheet.name).get())
  ^
 SyntaxError: invalid syntax

 Using the second option I get this message:

 Error en get(as.character(i)),envr=envir) :
objeto '089' no encontrado

 Object '089' not found.

 Im using this R platform:
 sessionInfo()
 R version 2.11.1 Patched (2010-08-30 r52848)
 Platform: x86_64-unknown-linux-gnu (64-bit)

 Locale:
 LC_CTYPE=es_CO.UTF-8

 Is the only solution to export to .csv and then
 to .xls format with other program like openoffice?

 Thank you for your help and advice.

 Kenneth

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


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

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


[[alternative HTML version deleted]]

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


Re: [R] path analysis

2010-09-06 Thread Sarah Goslee
There are lots of options for path analysis in R.

If you go to http://www.rseek.org and type path analysis into the search box,
you will get lots of information on functions/packages, and more general
info as well.

Beyond that, we'd need more specifics about your task.

Sarah

On Mon, Sep 6, 2010 at 10:37 AM, Guy rotem rottem...@gmail.com wrote:
 Hi.

 which package i need to install to be able to run Path analysis using r?

 many thanks, Guy



-- 
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] boxplot knowing Q1, Q3, median, upper and lower whisker value

2010-09-06 Thread Joshua Wiley
Hi Dave,

You can look at the function ?bxp it might work for you.  Alternately,
create a meaningless boxplot object, and then just edit that data, in
which case I know it will work with bxp().

# Create a boxplot, the data does not matter
x - boxplot(1:10)
x # view the data for the boxplot

x$stats - c() # put the stats here, min Q1, median, Q3, max
# or hinges or whatever you like

x$n - c() # the number of observations, though you do not need to change this

bxp(x) # plot boxplot with updated info

HTH,

Josh


On Mon, Sep 6, 2010 at 8:46 AM, David A. dasol...@hotmail.com wrote:

 Dear list,

 I am using a external program that outputs Q1, Q3, median, upper and lower 
 whisker values for various datasets simultaneously in a tab delimited format. 
 After importing this text file into R, I would like to plot a boxplot using 
 these given values and not the original series of data points, i.e. not using 
 something like boxplot(mydata).

 Is there an easy way for doing this? If I am not wrong, boxplot() does not 
 accept these values as parameters.

 Cheers,

 Dave

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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


[R] How to run R on Emacs+ESS

2010-09-06 Thread Stephen Liu
Hi folks,

Debian 504 64-bit

I found following document;
http://www.biostat.wisc.edu/~kbroman/Rintro/

Whether it is the right document for installing Emacs+ESS and R so that R can 
run on Emacs?

TIA

B.R.
Stephen L




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


Re: [R] WriteXLS problem

2010-09-06 Thread Kenneth Roy Cabrera Torres
Thank you Ivan for you answer:
El lun, 06-09-2010 a las 18:11 +0200, Ivan Calandra escribió:
 Hi,
 
 Are you sure you used the correct syntax and object names? It might just 
 be because of that...(reading the error messages)
Im sure, because it works with write.csv or write.table.
 There is another function, xlsReadWrite::write.xls(), that I like a lot: 
 it is really easy to use and does not require Perl or Python.
Unfortunately it works on windows, and I am in a non windows platform
(ubuntu).

Thank you for you advice and help.

Kenneth
 
 HTH,
 Ivan
 
 Le 9/6/2010 18:03, Kenneth Roy Cabrera Torres a crit :
  Hi R users:
 
  I don't know if you have had the following problem trying to
  export to an xls format file in a non windows platform.
 
  I try to use the following packages:
  1. dataframes2xls (version 0.4.4) (with phyton 2.7 and 3.1)
  2. WriteXLS (version 1.9.0) (with perl and testPerl working)
 
  Even xlsx package that take too long and do not finish.
 
  The data frame I try to export has 269363 row and 116 columns.
  In the first one (dataframe2xls) I get this message:
 
  Traceback (most recent call last):
File
  C:/PROGRA~2/R/R-211~1.1PA/library/dataframes2xls/python/csv2xls.py,
  line 18, inmodule
  import pyexcelerator
  File
  C:\PROGRA~2\R\R-211~1.1PA\library\dataframes2xls\python\pyexcelerator
  \__init__.py,
  line 12, inmodule  from Workbook import Workbook
  File
  C:\PROGRA~2\R\R-211~1.1PA\library\dataframes2xls\python\pyexcelerator
  \Workbook.py,
  line 526 boundsheets_len += len(BIFFRecords.BoundSheetRecord(0x00L,
  sheet.hidden, sheet.name).get())
   ^
  SyntaxError: invalid syntax
 
  Using the second option I get this message:
 
  Error en get(as.character(i)),envr=envir) :
 objeto '089' no encontrado
 
  Object '089' not found.
 
  Im using this R platform:
  sessionInfo()
  R version 2.11.1 Patched (2010-08-30 r52848)
  Platform: x86_64-unknown-linux-gnu (64-bit)
 
  Locale:
  LC_CTYPE=es_CO.UTF-8
 
  Is the only solution to export to .csv and then
  to .xls format with other program like openoffice?
 
  Thank you for your help and advice.
 
  Kenneth
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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] How to run R on Emacs+ESS

2010-09-06 Thread Dirk Eddelbuettel

On 6 September 2010 at 09:18, Stephen Liu wrote:
| Hi folks,
| 
| Debian 504 64-bit

Good. All you need is 

   sudo apt-get install ess

| I found following document;
| http://www.biostat.wisc.edu/~kbroman/Rintro/
| 
| Whether it is the right document for installing Emacs+ESS and R so that R can 
| run on Emacs?

There is nothing else to do.  Restart (X)Emacs, whichever variant you use on
Debian, and type M-x R. You now run R inside Emacs.

After that, see http://ess.r-project.org, esp the Documentation tab.

Dirk

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.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] WriteXLS problem

2010-09-06 Thread David Winsemius


On Sep 6, 2010, at 12:25 PM, Kenneth Roy Cabrera Torres wrote:


Thank you Ivan for you answer:
El lun, 06-09-2010 a las 18:11 +0200, Ivan Calandra escribió:

Hi,

Are you sure you used the correct syntax and object names? It might  
just

be because of that...(reading the error messages)

Im sure, because it works with write.csv or write.table.


Sure? You are making the incorrect assumption that those write  
functions have the same syntax. At least for WriteXLS that assumption  
is false. The help page clearly states that the objects need to be  
quoted rather than being referred to by their naked names. The error  
you are getting with your second option suggests to me that you  
offered an unquoted name of an object.


You can offer a vector of quoted names of dataframes to WriteXLS and  
each named dataframe will be converted to a worksheet within the  
workbook.


--
David.


There is another function, xlsReadWrite::write.xls(), that I like a  
lot:

it is really easy to use and does not require Perl or Python.

Unfortunately it works on windows, and I am in a non windows platform
(ubuntu).

Thank you for you advice and help.

Kenneth


HTH,
Ivan

Le 9/6/2010 18:03, Kenneth Roy Cabrera Torres a crit :

Hi R users:

I don't know if you have had the following problem trying to
export to an xls format file in a non windows platform.

I try to use the following packages:
1. dataframes2xls (version 0.4.4) (with phyton 2.7 and 3.1)
2. WriteXLS (version 1.9.0) (with perl and testPerl working)

Even xlsx package that take too long and do not finish.

The data frame I try to export has 269363 row and 116 columns.
In the first one (dataframe2xls) I get this message:

Traceback (most recent call last):
 File
C:/PROGRA~2/R/R-211~1.1PA/library/dataframes2xls/python/ 
csv2xls.py,

line 18, inmodule
import pyexcelerator
File
C:\PROGRA~2\R\R-211~1.1PA\library\dataframes2xls\python 
\pyexcelerator

\__init__.py,
line 12, inmodule  from Workbook import Workbook
File
C:\PROGRA~2\R\R-211~1.1PA\library\dataframes2xls\python 
\pyexcelerator

\Workbook.py,
line 526 boundsheets_len +=  
len(BIFFRecords.BoundSheetRecord(0x00L,

sheet.hidden, sheet.name).get())
^
SyntaxError: invalid syntax

Using the second option I get this message:

Error en get(as.character(i)),envr=envir) :
  objeto '089' no encontrado

Object '089' not found.

Im using this R platform:
sessionInfo()
R version 2.11.1 Patched (2010-08-30 r52848)
Platform: x86_64-unknown-linux-gnu (64-bit)

Locale:
LC_CTYPE=es_CO.UTF-8

Is the only solution to export to .csv and then
to .xls format with other program like openoffice?

Thank you for your help and advice.

Kenneth

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


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] WriteXLS problem

2010-09-06 Thread Kenneth Roy Cabrera Torres
I use the following sintaxis for the packages:

For WriteXLS I use:

writeXLS(todo2009,todo2009.xls)

And for dataframes2xls I use:
dataframe2xls::write.xls(todo2009,todo2009.xls)



El lun, 06-09-2010 a las 12:34 -0400, David Winsemius escribió:
 On Sep 6, 2010, at 12:25 PM, Kenneth Roy Cabrera Torres wrote:
 
  Thank you Ivan for you answer:
  El lun, 06-09-2010 a las 18:11 +0200, Ivan Calandra escribió:
  Hi,
 
  Are you sure you used the correct syntax and object names? It might  
  just
  be because of that...(reading the error messages)
  Im sure, because it works with write.csv or write.table.
 
 Sure? You are making the incorrect assumption that those write  
 functions have the same syntax. At least for WriteXLS that assumption  
 is false. The help page clearly states that the objects need to be  
 quoted rather than being referred to by their naked names. The error  
 you are getting with your second option suggests to me that you  
 offered an unquoted name of an object.
 
 You can offer a vector of quoted names of dataframes to WriteXLS and  
 each named dataframe will be converted to a worksheet within the  
 workbook.


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


Re: [R] How can I fixe convergence=1 in optim

2010-09-06 Thread Ben Bolker
  [forwarding back to r-help for archiving/further discussion]

On 10-09-05 08:48 PM, Sally Luo wrote:
 Prof. Bolker,
  
 Thanks for your reply and the helpful info.
  
 I still have a few questions. 
  
 1. I also tried to use different methods other than BFGS without
 changing their default maxit values, and got very different results. 
 Since I am not that experienced with the optim funciton, I am not sure
 which one is correct or trustworthy?
  
 *If I use method=SANN, that is,*
  
  p-optim(c(-0.2392925,0.4653128,-0.8332286, 0.0657, -0.0031,
 -0.00245, 3.366, 0.5885, -0.8,
 +0.0786,-0.00292,-0.00081, 3.266, -0.3632, -0.49,   
 0.1856, 0.00394, -0.00193, -0.889, 0.5379, -0.63,
 +0.213, 0.00338, -0.00026, -0.8912, -0.3023, -0.56),
 f, method =SANN, y=y,X=X,W=W)
  
 I get:

 There were 50 or more warnings (use warnings() to see the first 50)
  p
 $par
  [1] -0.2392925  0.4653128 -0.8332286  0.0657000 -0.0031000
 -0.0024500  3.366  0.5885000 -0.800  0.0786000 -0.0029200
 -0.0008100
 [13]  3.266 -0.3632000 -0.490  0.1856000  0.0039400 -0.0019300
 -0.889  0.5379000 -0.630  0.213  0.0033800 -0.0002600
 [25] -0.8912000 -0.3023000 -0.560
  
 $value
 [1] -772.3262
  
 $counts
 function gradient
1   NA
  
 $convergence
 [1] 0
  
 $message
 NULL
  warnings()
 Warning messages:
 1: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced
 2: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced
 .
 .
  
 49: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced
 50: In log(det(I_N - pd * wd - po * wo - pw * ww)) : NaNs produced
  
  


for SANN, the convergence criterion is not meaningful, because
SANN does not use a tolerance-based stopping criterion.  As ?optim says,
‘0’ indicates successful completion (which is always the case for
‘SANN’).

 *If I change method to Nelder-Mead, that is:*
  
  p-optim(c(-0.2392925,0.4653128,-0.8332286, 0.0657, -0.0031,
 -0.00245, 3.366, 0.5885, -0.8,
 +0.0786,-0.00292,-0.00081, 3.266, -0.3632, -0.49,   
 0.1856, 0.00394, -0.00193, -0.889, 0.5379, -0.63,
 +0.213, 0.00338, -0.00026, -0.8912, -0.3023, -0.56),
 f, method =Nelder-Mead, y=y,X=X,W=W)
  
 Then I get:

 There were 21 warnings (use warnings() to see them)
  p
 $par
  [1] -0.2392925  0.4653128 -0.8332286  0.0657000 -0.0031000
 -0.0024500  3.366  0.5885000 -0.800  0.0786000 -0.0029200
 -0.0008100
 [13]  3.5184500 -0.3632000 -0.490  0.1856000  0.0039400 -0.0019300
 -0.889  0.5379000 -0.630  0.213  0.0033800 -0.0002600
 [25] -0.8912000 -0.3023000 -0.560
  
 $value
 [1] -772.3568
  
 $counts
 function gradient
  192   NA
  
 $convergence
 [1] 10
  
 ACCORDING TO the R manual, convergence=10 indicates degeneracy of the
 Nelder–Mead simplex.  Could you explain to me what this degeneracy
 means?  Does it mean the optimization gets stuck with a local minimal?


  This means that the Nelder-Mead simplex has shrunk in such a way that
in a least one dimension the extent
of the simplex has shrunk to a point.  It doesn't have anything to do
with local minima (there's not really any
way that a single run of a local optimizer can detect a local minimum). 
You could try re-starting the optimization
from the point at which the previous run stopped.
 2.  I also tried to change the maxit value of BFGS to 1, and got
 the following results. It seems this time the algorithm coverges, but
 the estimation results are quite different from what I got by using
 the method SANN.  In this case, which method should I use? 
  
  p-optim(c(-0.2392925,0.4653128,-0.8332286, 0.0657, -0.0031,
 -0.00245, 3.366, 0.5885, -0.8,
 +0.0786,-0.00292,-0.00081, 3.266, -0.3632, -0.49,   
 0.1856, 0.00394, -0.00193, -0.889, 0.5379, -0.63,
 +0.213, 0.00338, -0.00026, -0.8912, -0.3023, -0.56),
 f, method =BFGS, hessian =TRUE, control=list(maxit=1),y=y,X=X,W=W)

 There were 50 or more warnings (use warnings() to see the first 50)
  p
 $par
  [1]  1.113491e-01  6.347504e-02 -1.570647e-01  7.793766e-02 
 7.011026e-02 -3.075866e-03  3.365178e+00  8.123945e-02 -2.670111e-04
 [10]  7.941502e-02 -2.249492e-04 -1.388776e-03  3.266022e+00
 -4.023881e-01 -6.195116e-03  1.829491e-01 -1.116388e-02 -3.088426e-03
 [19] -8.888543e-01  6.394912e-01  3.425666e-03  2.193541e-01 
 3.743851e-02  8.376799e-05 -8.915029e-01 -5.596738e-01 -1.845092e-03
  
 $value
 [1] -950.553
  
 $counts
 function gradient
31321 1741
  
 $convergence
 [1] 0

  The BFGS result (-950) is much better than the SANN or Nelder-Mead
results (-722).


 3. In Peng's email, he pointed out the importance of choosing good
 initial values in order to get sensible estimates by using optim. 
 Since I am not confident that my initial values are that good and I
 got different estimation results under different methods, in such
 cases, would you recommend any 

[R] poisson distribution

2010-09-06 Thread tamas barjak
Hello!

I need some help.
How I know it to draw the formula of the poisson distribution?

expr-expression(P(xi == k) == frac(lambda^k, factorial(k))*e^-lambda) ---
not good

on the screen the  k!  not the Poisson Formula, but factorial(k)

Thanx!

[[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] Failure to aggregate

2010-09-06 Thread Dimitri Shvorob

I have a (very big - 1.5 rows) dataframe with a (POSIXt  POSIXlt) column h
(hour). Surprisingly, I cannot calculate a simple aggregate over the
dataframe.

 n.h1 = sqldf(select distinct h, count(*) from x group by h)
Error in sqliteExecStatement(con, statement, bind.data) : 
  RS-DBI driver: (error in statement: no such table: x)
In addition: Warning message:
In value[[3L]](cond) : RAW() can only be applied to a 'raw', not a 'double'

 n.h2 = aggregate(x$price, by = x$h, FUN = nrow)
Error in names(y) - c(names(by), names(x)) : 
  'names' attribute [10] must be the same length as the vector [2]

Arrgh...
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Failure-to-aggregate-tp2528613p2528613.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] sample a matrix with one element to be 1 from wishart distribution

2010-09-06 Thread mou sonia
Hi,

I am not sure if this make sense at all. I'd like to sample a matrix, which
follows a wishart / inverted wishart distribution. However, the (1,1)
element of this matrix should always be equal to 1. How can I handle it in
R? Any suggestion is greatly appreciated. Thanks a lot.

Sonia

[[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] Creating named.list from two matrix columns

2010-09-06 Thread Viki S

Hi Jim,
Thanks,

That´s right. But the problem is that it
introduces unnecessary quotes, perhaps due to the format of first
column data in this case :

x-cbind(c(row:1, row:2, row:3), c(4889, 9987, 494))
x1-as.list(x[,2])
names(x1)-x[,1]
 x1
$`row:1`
[1] 4889

$`row:2`
[1] 9987

$`row:3`
[1] 494

How can I avoid unnecessary ` `quotes around the names ?

V

 Date: Mon, 6 Sep 2010 09:14:23 -0400
 Subject: Re: [R] Creating named.list from two matrix columns
 From: jholt...@gmail.com
 To: is...@live.com
 CC: r-help@r-project.org
 
 Is this what you want:
 
  x
 V1   V2
 1 row1 2334
 2 row2  347
 3 row3  379
  x.list - as.list(x$V2)
  names(x.list) - x$V1
  x.list
 $row1
 [1] 2334
 
 $row2
 [1] 347
 
 $row3
 [1] 379
 
 
 
 On Mon, Sep 6, 2010 at 7:55 AM, Viki S is...@live.com wrote:
 
  Hi Friends,
  I am new to R.
 
  On R utility class pages, creating named.list is described with this 
  command :
  new(named.list,a=1,b=2)
 
 
  For large matrix having two columns, such as :
 
  row1   2334
  row2   347
  row3   379
  ...
 
  I want to create a named.list like :
  $row1
  [1] 2334
 
  $row2
  [1] 347
 
  ...
 
  Can anyone explain how named.list variable can be created by using two 
  specified columns of a dataframe or matrix object, where one of the two 
  columns is assigned as a name (string) and
  other as its corresponding value ?
 
  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.
 
 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem that you are trying to solve?
  
[[alternative HTML version deleted]]

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


[R] Over lay 2 scale in same plot

2010-09-06 Thread mamunbabu2001

Hi Everyone,
I have two different data set in 2 different scale. 
I want to plot these two data in the same plot
in their respective scale. So the plot will have 2 different scale.
I have added an image below to show how it should look.
does any bode has any idea how this can be done. 

2 different y scale in same plot..??

http://r.789695.n4.nabble.com/file/n2528661/2scale_ovelay.jpg 

Thanks in advance.

Mamun
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Over-lay-2-scale-in-same-plot-tp2528661p2528661.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] sample a matrix with one element to be 1 from wishart distribution

2010-09-06 Thread mou sonia
Hi,

I am not sure if this make sense at all. I'd like to sample a matrix, which
follows a wishart / inverted wishart distribution. However, the (1,1)
element of this matrix should always be equal to 1. How can I handle it in
R? Any suggestion is greatly appreciated. Thanks a lot.

Sonia

[[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] poisson distribution

2010-09-06 Thread David Winsemius


On Sep 6, 2010, at 1:13 PM, tamas barjak wrote:


Hello!

I need some help.
How I know it to draw the formula of the poisson distribution?

expr-expression(P(xi == k) == frac(lambda^k, factorial(k))*e^- 
lambda) ---

not good


?plotmath

(Do not see factorial as a plotmath function

Try:

expr-expression(P(xi == k) == frac(lambda^k, k*!)*e^-lambda)



on the screen the  k!  not the Poisson Formula, but factorial(k)

Thanx!


-- David.

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


Re: [R] poisson distribution

2010-09-06 Thread tamas barjak
Successful!

Thank you!



2010/9/6 David Winsemius dwinsem...@comcast.net


 On Sep 6, 2010, at 1:13 PM, tamas barjak wrote:

  Hello!

 I need some help.
 How I know it to draw the formula of the poisson distribution?

 expr-expression(P(xi == k) == frac(lambda^k, factorial(k))*e^-lambda)
 ---
 not good


 ?plotmath

 (Do not see factorial as a plotmath function

 Try:

 expr-expression(P(xi == k) == frac(lambda^k, k*!)*e^-lambda)



 on the screen the  k!  not the Poisson Formula, but factorial(k)

 Thanx!


 -- David.


[[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] ERCIM'10: Submission of abstracts

2010-09-06 Thread Uwe Ligges

Dear useRs,

the deadline for submission of abstracts is approaching for ERCIM'10. 
Please upload your abstract until 2010-09-08  if you would like to give 
a presentation at our track on Statistical Algorithms and Software at the


3rd International Conference of the ERCIM WG on
COMPUTING  STATISTICS (ERCIM'10)
10-12 December 2010, Senate House, University of London, UK
http://www.cfe-csda.org/ercim10

Important Dates are:

Submission of abstracts:  2010-09-08
Standard registration:2010-09-14
Tutorial: 2010-12-09
Conference:   2010-12-10 to 2010-12-12

Hope to see you there,
Achim, Bettina and Uwe

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


Re: [R] Failure to aggregate

2010-09-06 Thread David Winsemius


On Sep 6, 2010, at 12:15 PM, Dimitri Shvorob wrote:



I have a (very big - 1.5 rows) dataframe with a (POSIXt  POSIXlt)  
column h

(hour). Surprisingly, I cannot calculate a simple aggregate over the
dataframe.


n.h1 = sqldf(select distinct h, count(*) from x group by h)

Error in sqliteExecStatement(con, statement, bind.data) :
 RS-DBI driver: (error in statement: no such table: x)
In addition: Warning message:
In value[[3L]](cond) : RAW() can only be applied to a 'raw', not a  
'double'



n.h2 = aggregate(x$price, by = x$h, FUN = nrow)


A vector argument (x$price) would only have one row (at most).

nrow(c(1,2)
NULL


Error in names(y) - c(names(by), names(x)) :
 'names' attribute [10] must be the same length as the vector [2]


Try:

tapply(x$price, by = x$h, FUN = length)

--
David.

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


Re: [R] Over lay 2 scale in same plot

2010-09-06 Thread Joshua Wiley
Hi,

Looking at the picture, I think you are just talking about plotting
two datasets.  Here is an example I made up, that looks sort of like
your picture:

# make a barplot
barplot(-50:50)
# add points into the existing plot at the coordinates set by x and y
# and use a line to connect them
points(x = 1:101, y = seq(from = 30, to = -20, length.out = 101), type = l)

Do you have some sample data you could send us of what you are trying
to plot?  We can give more specific feedback if we have some actual
data to work with.

Hope that helps,

Josh

On Mon, Sep 6, 2010 at 9:57 AM, mamunbabu2001 mrashi...@hotmail.com wrote:

 Hi Everyone,
 I have two different data set in 2 different scale.
 I want to plot these two data in the same plot
 in their respective scale. So the plot will have 2 different scale.
 I have added an image below to show how it should look.
 does any bode has any idea how this can be done.

 2 different y scale in same plot..??

 http://r.789695.n4.nabble.com/file/n2528661/2scale_ovelay.jpg

 Thanks in advance.

 Mamun
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Over-lay-2-scale-in-same-plot-tp2528661p2528661.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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] Time Series

2010-09-06 Thread Gabor Grothendieck
On Mon, Sep 6, 2010 at 11:56 AM, trb1 thomasrbol...@yahoo.co.uk wrote:

 Thank you very much for your post.
 Your answer has been very helpful.
 Is it possible to merge 2 time series?


zz is my posted code was formed by merging two univariate and one
multivariate series.

-- 
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] combining collumns for data.frames

2010-09-06 Thread Martin Hughes

Hi

This question is far less simple than the title suggests, please read 
carefully, thanks.

I have 2 sets of data, both read into R

data1-read.table (1.txt, header=T, sep=\t)
data2-read.table (2.txt, header=T, sep=\t)

data1

Taxon   stage1   stage2   stage3   stage4
T1  0  0  1  1
T2  0  1  1  0
T3  0  0  0  1
T4  1  0  0  0


data2 # this is a library file, it contains all possible values of stage 
(Col_1) that may be contained in the data1 file (headers of each column), and 
what they correspond to  
   # in the Col_2 ie stages 1:2 == Group1

Col_1Col_2
Stage1  Group1
Stage2  Group1
Stage3  Group2
Stage4  Group2

 I want to get R to combine the columns in data1 based on the information in 
data2 (Col_2), eg in this instance reduce the columns in data1 from 4 to 2, 
summing up the 
 values within each column of data1 to get the result below

Taxon   group1   group2

T1  0  1

T2  1  1

T3  0  1

T4  1  0

i have many datasets which have different numbers of stage eg one dataset will 
have stage1-10, another will have stage15-35 (data2, Col_2 has all possilbe 
stage values so will say what group they correspond to)

so far i can isolate the rows of data2 which contains the stages in data1 with 
this:

 data1.names-names(data1[,-1])#take the header names 
 from data1 minus the 1st column (this is not found in the data2 library file)
 row.numbers-match(data1.names, data2[,1]) #match the vector containing 
 the data1 column header names to those found in the library file of data2
 data2.small-data2[row.numbers]   #reduce the data2 to 
 only include the same stages as found in the data1 file 

 from here on i dont know what to, really i wanted to just be able to change 
the header names of data1 to their corresponding name that is found in Col_2 
and then use some statement that could merge columns in data1 which were the 
same (and also sum the values at each row and dividing by their value if they 
were greater than 1 (so i only have 0 or 1 again) but i dont know how to do 
that.

Can someone help me to get the desired result  (as in the example above) that 
doe not require me to manually merge columns? ie get the example output in an 
automated way that could take any version of the data1 file (ie with different 
stage values) and using the data2 file (library file - same in each instance) 
get the output similar as in the example above?


Thanks

Martin








  
[[alternative HTML version deleted]]

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


[R] how to change the xlab name?

2010-09-06 Thread tooblue

I simply put,  plot(density(), main=, + xlab = XXX), it says that
I have an unexpected = in it.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-change-the-xlab-name-tp2528733p2528733.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] Failure to aggregate

2010-09-06 Thread Gabor Grothendieck
On Mon, Sep 6, 2010 at 12:15 PM, Dimitri Shvorob
dimitri.shvo...@gmail.com wrote:

 I have a (very big - 1.5 rows) dataframe with a (POSIXt  POSIXlt) column h
 (hour). Surprisingly, I cannot calculate a simple aggregate over the
 dataframe.

 n.h1 = sqldf(select distinct h, count(*) from x group by h)
 Error in sqliteExecStatement(con, statement, bind.data) :
  RS-DBI driver: (error in statement: no such table: x)
 In addition: Warning message:
 In value[[3L]](cond) : RAW() can only be applied to a 'raw', not a 'double'

 n.h2 = aggregate(x$price, by = x$h, FUN = nrow)
 Error in names(y) - c(names(by), names(x)) :
  'names' attribute [10] must be the same length as the vector [2]


Since you are using group by you don't want distinct.

In aggregate use x[price] and x[h] rather than
x$price and x$h or use a formula.

Also use nrow or length in place of NROW.

library(sqldf)
x - data.frame(price = 1:4, h = c(1, 1, 2, 3))
sqldf(select h, count(*) from x group by h)

aggregate(x[price], by = x[h], FUN = NROW)
aggregate(x[price], by = x[h], FUN = length)
aggregate(price ~ h, x, FUN = length)







-- 
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] how to change the xlab name?

2010-09-06 Thread Joshua Wiley
On Mon, Sep 6, 2010 at 11:07 AM, tooblue kai...@berkeley.edu wrote:

 I simply put,  plot(density(), main=, + xlab = XXX), it says that
 I have an unexpected = in it.

You just have an extra ' + ' before the xlab argument:

plot(density(rnorm(100)), main = , xlab = XXX)

ought to do it.

Cheers,
Josh

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/how-to-change-the-xlab-name-tp2528733p2528733.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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] how to change the xlab name?

2010-09-06 Thread David Winsemius


On Sep 6, 2010, at 2:07 PM, tooblue wrote:



I simply put,  plot(density(), main=, + xlab = XXX), it  
says that

I have an unexpected = in it.


It may be a case of a confused parser. You have an extraneous + in  
there:


  = rnorm(100)
 plot(density(), main=,  xlab = XXX)  # works

If on the other hand you wanted to construct a more complex title then  
you will probably need to read the expression and bquote help pages  
and submit a more descriptive problem statement.


--
David.

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


[R] likelyhood maximization problem with polr

2010-09-06 Thread blackscorpio

Dear community,

I am currently trying to fit an ordinal logistic regression model with the
polr function. I often get the same error message :

attempt to find suitable starting values failed, for example with :

require(MASS) 
data(iris) 
polr(Species~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width,iris) 

(I know the response variable Species should be nominal but I do as levels
were ordered for the example). 
I think this is a likelyhood maximization problem ; I tried to solve this by
setting the start option of polr to a null or a random vector by it
doesn't garantee to find a good solution at the end. 

Does anyone have a clue ?

Thanks a lot ! 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/likelyhood-maximization-problem-with-polr-tp2528818p2528818.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] two questions

2010-09-06 Thread Iasonas Lamprianou

Dear friends, two questions

(1) does anyone know if there are any non-parametric equivalents of the two-way 
ANOVA in R? I have an ordinal non-normally distributed dependent variable and 
two factors (gender and city of birth). Normally, one would try a two-way 
anova, but if R has any non-parametric equivalents, that might be great. 
(2) Also, if the interaction of gender and city of birth is statistically 
significant, which post-hoc tests should I run?

Thanks

Jason 


Dr. Iasonas Lamprianou


Assistant Professor (Educational Research and Evaluation)
Department of Education Sciences
European University-Cyprus
P.O. Box 22006
1516 Nicosia
Cyprus 
Tel.: +357-22-713178
Fax: +357-22-590539


Honorary Research Fellow
Department of Education
The University of Manchester
Oxford Road, Manchester M13 9PL, UK
Tel. 0044  161 275 3485
iasonas.lampria...@manchester.ac.uk




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


[R] Help with unexpected symbol errors

2010-09-06 Thread Amit Patel
Hi

I have got a long script which will not run for me as i keep getting errors :

 source(clusterfixV1_4.r)
Error in source(clusterfixV1_4.r) : 
clusterfixV1_4.r: unexpected symbol at
158: eck[k,2] - as.numeric(1)
159:   #ClusterInfo[k,2] - Clustered

I have sorted all the ones i can but i am having a problem here
Can anyone tell me the cause of these problems. Its not a very short or 
straightforward script so i dont expect you to go through the whole thing but 
it 
would be great if you can give me an indication as to what I may be doing wrong.
I havent attached the data that the script uses because I'm pretty sure the 
principles i have used are right
when running the script i get the above error on line 158 and 159
I am more than happy to provide further information(e.g the dataset) if it helps

Many thanks in advance

Amit Patel


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


Re: [R] two questions

2010-09-06 Thread David Winsemius
The usual least-squares methods are fairly robust to departures from  
normality. Furthermore, it is the residuals that are assumed to be  
normally distributed (not the marginal distributions that you are  
probably looking at) , so it does not sound as though you have yet  
examined the data properly. Tell us what the descriptive stats (say  
the means, variance, 10th and 90th percentiles) are on the residuals  
within cells cross-classified by the gender and city-of-birth  
variables (say the means, variance, 10th and 90th percentiles).


On Sep 6, 2010, at 4:34 PM, Iasonas Lamprianou wrote:



Dear friends, two questions

(1) does anyone know if there are any non-parametric equivalents of  
the two-way ANOVA in R? I have an ordinal non-normally distributed  
dependent variable and two factors (gender and city of birth).  
Normally, one would try a two-way anova, but if R has any non- 
parametric equivalents, that might be great.


There is an entire task view page on robust methods if you decide to  
press on with this quest.


(2) Also, if the interaction of gender and city of birth is  
statistically significant, which post-hoc tests should I run?


How many cities are we talking about?


Thanks

Jason


Dr. Iasonas Lamprianou


--

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] PostScript/PDF graphics with another font

2010-09-06 Thread Peter

I am using the standard phonetic font Doulos SIL in a graph
(http://scripts.sil.org/cms/scripts/page.php?site_id=nrsiid=DoulosSILfont)

This is an example:

windowsFonts(IPA=TT Doulos SIL)
barplot(c(1,2,3,4,5),names=c(\u{0251},\u{0252},\u{0253},\u{0254},\u{0255}),family=IPA)

However, I am unable to make an eps or pdf file from this graph. I get the
following error message when trying to save as .eps:

Error: family 'IPA' not included in PostScript device
In addition: Warning messages:
1: font family not found in PostScript font database
[...]

And this when I try to save as .pdf:

Error: Invalid font type
In addition: Warning messages:
1: font family not found in PostScript font database
[...]

I have tried various applications of the functions postscript(),
postscriptFonts(), pdf(), but I only get error messages when I try to tell
it to make use of the Doulos SIL font. I've searched for answers in Nabble
and google as well, but haven't found a solution (at least not one I
understand).

I'm using R 2.11 for Windows.

Thank you
-- 
View this message in context: 
http://r.789695.n4.nabble.com/PostScript-PDF-graphics-with-another-font-tp2528875p2528875.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] dataframe row names from list

2010-09-06 Thread Jim Lemon

On 09/06/2010 09:41 PM, raje...@cse.iitm.ac.in wrote:


Hi,
I have a list which looks like this...

str(y)

List of 10
  $ : chr [1:4] ABCD 5 0 1
  $ : chr [1:4] DEF 15 1 16
  $ : chr [1:4] AAA 2 17 8
  $ : chr [1:4] SSS 15 25 1
  $ : chr [1:4] III 15 26 4
  $ : chr [1:4] OPQ 7 30 4
  $ : chr [1:4] TYR 14 34 8
  $ : chr [1:4] IRTS 15 42 1
  $ : chr [1:4] LLL 15 43 2
  $ : chr [1:4] AQW 3 45 4

I need to create a dataframe whose row names are chr[1] of each vector..ie 
ABCD,DEF,AAA ETC. how can I do this?


Hi rajesh,
Try this:

rownames(mydf)-unlist(lapply(y,[,1))

Jim

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


Re: [R] limit on read.socket?

2010-09-06 Thread Thomas Lumley

On Sat, 4 Sep 2010, raje...@cse.iitm.ac.in wrote:



Hi,

I have the following piece of code,

repeat{

ss-read.socket(sockfd);
if(ss==) break
output-paste(output,ss)
}

but somehow, output is not receiving all the data that is coming through the 
socket.My suspicion is on the if statement. what happens if a white space 
occurs in between the string arriving over the socket?


That's not the problem.  The problem occurs when R reads faster than the data 
are provided -- R will read and there will not be any new data available, so ss 
will be the empty string and the program will end.

In general you can't rely on the sender transmitting data fast enough to keep 
ahead of R.  The example in make.socket() is reading a very small amount of 
data, so it worked reasonably well back in the days when the finger daemon was 
more widely active.   You need some more precise way of knowing when the data 
stream is over.  This could be some sort of 'end of transmission' marker or a 
count of the number of bytes or lines to be expected.

   -thomas

Thomas Lumley
Professor of Biostatistics
University of Washington, Seattle

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


Re: [R] Help with unexpected symbol errors

2010-09-06 Thread jim holtman
We would need to at least see 10 lines either side of the error to
understand its context.  Also take a look with you editor (hex editor
would be handy) to see if there is some unprintable character around
it.  Can you isolate just that portion of the code?  Try putting it
inside a function to see if it will at least be read in without a
syntax error.  This is where you start learning to debug your program
by executing pieces at a time, or in your case, at least compiling
the section of code by trying to source it in with a function to see
what happens.  You might have an unbalanced quote in your script.

On Mon, Sep 6, 2010 at 4:42 PM, Amit Patel amitrh...@yahoo.co.uk wrote:
 Hi

 I have got a long script which will not run for me as i keep getting errors :

 source(clusterfixV1_4.r)
 Error in source(clusterfixV1_4.r) :
 clusterfixV1_4.r: unexpected symbol at
 158: eck[k,2] - as.numeric(1)
 159:                   #ClusterInfo[k,2] - Clustered

 I have sorted all the ones i can but i am having a problem here
 Can anyone tell me the cause of these problems. Its not a very short or
 straightforward script so i dont expect you to go through the whole thing but 
 it
 would be great if you can give me an indication as to what I may be doing 
 wrong.
 I havent attached the data that the script uses because I'm pretty sure the
 principles i have used are right
 when running the script i get the above error on line 158 and 159
 I am more than happy to provide further information(e.g the dataset) if it 
 helps

 Many thanks in advance

 Amit Patel



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





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

What is the problem that you are trying to solve?

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


Re: [R] combining collumns for data.frames

2010-09-06 Thread jim holtman
Try this (after making sure that Col_1 in data2 matches your column
names in data1

 data1 - read.table(textConnection(Taxon   stage1   stage2   stage3   stage4
+ T1  0  0  1  1
+ T2  0  1  1  0
+ T3  0  0  0  1
+ T4  1  0  0  0), header=TRUE)
 data2 - read.table(textConnection(Col_1Col_2
+ stage1  Group1
+ stage2  Group1
+ stage3  Group2
+ stage4  Group2), header=TRUE, as.is=TRUE)
 closeAllConnections()
 # get the columns to summarize by
 colSumz - split(data2$Col_1, data2$Col_2)
 # create the output matrix
 result - matrix(0, nrow=nrow(data1), ncol=length(colSumz))
 colnames(result) - names(colSumz)
 rownames(result) - data1$Taxon
 for (i in names(colSumz)){
+ result[, i] - rowSums(data1[, colSumz[[i]]])
+ }
 result
   Group1 Group2
T1  0  2
T2  1  1
T3  0  1
T4  1  0



On Mon, Sep 6, 2010 at 1:49 PM, Martin Hughes sensei2...@hotmail.com wrote:

 Hi

 This question is far less simple than the title suggests, please read 
 carefully, thanks.

 I have 2 sets of data, both read into R

data1-read.table (1.txt, header=T, sep=\t)
data2-read.table (2.txt, header=T, sep=\t)

data1

 Taxon   stage1   stage2   stage3   stage4
 T1          0          0          1          1
 T2          0          1          1          0
 T3          0          0          0          1
 T4          1          0          0          0


data2 # this is a library file, it contains all possible values of stage 
(Col_1) that may be contained in the data1 file (headers of each column), and 
what they correspond to
           # in the Col_2 ie stages 1:2 == Group1

 Col_1        Col_2
 Stage1      Group1
 Stage2      Group1
 Stage3      Group2
 Stage4      Group2

  I want to get R to combine the columns in data1 based on the information in 
 data2 (Col_2), eg in this instance reduce the columns in data1 from 4 to 2, 
 summing up the
  values within each column of data1 to get the result below

 Taxon   group1   group2

 T1          0          1

 T2          1          1

 T3          0          1

 T4          1          0

 i have many datasets which have different numbers of stage eg one dataset 
 will have stage1-10, another will have stage15-35 (data2, Col_2 has all 
 possilbe stage values so will say what group they correspond to)

 so far i can isolate the rows of data2 which contains the stages in data1 
 with this:

 data1.names-names(data1[,-1])                        #take the header names 
 from data1 minus the 1st column (this is not found in the data2 library file)
 row.numbers-match(data1.names, data2[,1])     #match the vector containing 
 the data1 column header names to those found in the library file of data2
 data2.small-data2[row.numbers]                       #reduce the data2 to 
 only include the same stages as found in the data1 file

  from here on i dont know what to, really i wanted to just be able to change 
 the header names of data1 to their corresponding name that is found in Col_2 
 and then use some statement that could merge columns in data1 which were the 
 same (and also sum the values at each row and dividing by their value if they 
 were greater than 1 (so i only have 0 or 1 again) but i dont know how to do 
 that.

 Can someone help me to get the desired result  (as in the example above) that 
 doe not require me to manually merge columns? ie get the example output in an 
 automated way that could take any version of the data1 file (ie with 
 different stage values) and using the data2 file (library file - same in each 
 instance) get the output similar as in the example above?


 Thanks

 Martin









        [[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

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


Re: [R] nlme Output

2010-09-06 Thread Edward Patzelt
The design is a repeated measures with 3 instances.  There are 3 groups:
 Controls, Heavy Cocaine Users, Light Cocaine Users.

I reshaped the data so that there was one variable for the 3 instances
called AvgTrials.  Time is the indicator of each instance.

Here is the model call:

mod5 - lme(AvgTrials ~ time + factor(group_id) + time*factor(group_id),
random = ~ 1 | group_id, data = tmp.dat, method = ML, na.action = na.omit)

What else would you need here?

-Edward


On Mon, Sep 6, 2010 at 8:52 AM, ONKELINX, Thierry
thierry.onkel...@inbo.bewrote:

 Dear Edward,

 You have no degrees of freedom left to estimate those p-values. Your
 design does not allows for the model your implemented. We need a brief
 summary of your design in order to help you further.

 HTH,

 Thierry

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

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

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

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

 The plural of anecdote is not data.
 ~ Roger Brinner

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


  -Oorspronkelijk bericht-
  Van: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] Namens Edward Patzelt
  Verzonden: maandag 6 september 2010 15:43
  Aan: r-help@r-project.org
  Onderwerp: [R] nlme Output
 
  Everyone -
 
  What do the NaN's mean here?  Is this analysis a problem?
 
 
  Linear mixed-effects model fit by maximum likelihood
   Data: tmp.dat
 AIC  BIClogLik
1611.251 1638.363 -797.6253
 
  Random effects:
   Formula: ~1 | group_id
   (Intercept) Residual
  StdDev: 0.0003077668 9.236715
 
  Fixed effects: AvgTrials ~ time + factor(group_id) + time *
  factor(group_id)
 Value Std.Error  DF   t-value p-value
  (Intercept)18.159722  3.576664 213  5.077279  0.
  time4.192708  1.655674 213  2.532327  0.0121
  factor(group_id)2  -6.929563  5.235700   0 -1.323522 NaN
  factor(group_id)3  -1.654554  4.189575   0 -0.394922 NaN
  time:factor(group_id)2  1.729911  2.423658 213  0.713760  0.4762
  time:factor(group_id)3 -2.555111  1.939396 213 -1.317478  0.1891
   Correlation:
 (Intr) time   fc(_)2 fc(_)3 t:(_)2
  time   -0.926
  factor(group_id)2  -0.683  0.632
  factor(group_id)3  -0.854  0.790  0.583
  time:factor(group_id)2  0.632 -0.683 -0.926 -0.540
  time:factor(group_id)3  0.790 -0.854 -0.540 -0.926  0.583
 
  Standardized Within-Group Residuals:
 Min Q1Med Q3Max
  -1.8842754 -0.6979785 -0.3370998  0.5666704  3.0943948
 
  Number of Observations: 219
  Number of Groups: 3
  Warning message:
  In pt(q, df, lower.tail, log.p) : NaNs produced
 
[[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.
 

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

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




-- 
Edward H. Patzelt
Research Assistant – TRiCAM Lab
University of Minnesota – Psychology/Psychiatry
VA Medical Center
Office: N437 Elliot Hall - Twin Cities Campus
Phone: 612-624-3892  Email: patze...@umn.edu

Please consider the environment before printing this email
www.psych.umn.edu/research/tricam

[[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] Way OT: Does PSA testing reduce prostate cancer mortality?

2010-09-06 Thread Bert Gunter
Hi Folks:

I found the following paper to be an interesting example of how even
well designed and conducted studies -- randomized trials, even -- can
be rendered problematic by systematic effects beyond the control of
the investigators:

http://www.nature.com/nrurol/journal/v7/n9/full/nrurol.2010.120.html

It's about whether PSA testing helps reduce mortality due to prostate
cancer -- an important issue with significant healh, economic, and QOL
impact. After decades of careful work, the answer still seems to be:
we don't know. Perhaps a good lesson in humility for us statisticians
... For those who are interested, enjoy.

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Statistics

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


  1   2   >