[R] pMCMC versus Pr(|t)

2010-02-26 Thread Max Coltheart


These are generally very similar, for obvious reasons. But in the  
analysis I have just done:

  pvals.fnc(Vcso.lmerC2trimmed, nsim=1)$fixed
   Estimate MCMCmean HPD95lower HPD95upper  pMCMC  
Pr(|t|)
(Intercept) 6.5878   6.5870 6.5126 6.6591 0.0001
0.
cTrial -0.0002  -0.0002-0.0006 0.0002 0.4088
0.3996
lexword-0.0977  -0.0968-0.1228-0.0698 0.0001
0.
conditionpure   0.0892   0.0896 0.0022 0.1781 0.0482
0.1744
lexword:conditionpure  -0.0563  -0.0569-0.0853-0.0287 0.0002
0.0001

there's a large discrepancy for the conditionpure  row. I have not  
been able to find examples of, or discussions of,
how to respond to such discrepancies; so any help would be much  
appreciated.

Max Coltheart


 _
 Professor Max Coltheart AM DSc FASSA FAA FBA
 Emeritus Professor of Cognitive Science, Macquarie University
 Honorary Professor of Psychology, University of Queensland






[[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] Reading multiple csv files

2010-02-26 Thread Madhavi Bhave
Dear R helpers
 
Some particular analysis leads me to various number of output csv files 
depending on some conditions. Say e.g. I have output files variable1.csv, 
variable2.csv, .. Problem is I don't know how many csv files been 
generated. They could be 4, 5 or even 10. Each file will have a column called 
amount.
 
My problem is to find filewise mean(amount) and sd(amount). I need to write a 
loop where all these individual csv files will be read and after reading each 
file, mean and sd will be calculated.
 
I have tried to write some R code which is very absurd. 
 
for (i in 1 : n)  # n is no of input files
 
{
data[i] = read.csv(file = paste(variable, i, .csv, sep = ))$amount
mean(data[i])
sd(data[i])
}
 
I get following error.
 
Error in file(file, rt) : cannot open the connection
In addition: Warning message:
In file(file, rt) :
  cannot open file 'paste(output, i, .csv, sep = )': Invalid argument

 
Please guide
 
Regards
 
Madhavi


  Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! 
http://downloads.yahoo.com/in/internetexplorer/
[[alternative HTML version deleted]]

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


Re: [R] error in lmLists in lme4 package (bug?)

2010-02-26 Thread Dieter Menne


Elizabeth Purdom-2 wrote:
 
 I am trying to use lmLists in the lme4 package and copying over very 
 standard code from the nlme package given in 'Mixed-Effects Models in S 
 and S-Plus'. It appears to not accept an 'I(age-11)' in the formula, 
 though it will accept the formula with out the subtraction of 11 from 
 age. 
 
 

Looks like a bug to me (checked on Windows with lme4a, the development
version). It is specific to lmList, I(age-11) works for lmer.

The special mailing list for lme4-problems is 

r-sig-mixed-mod...@r-project.org 

I have forwarded the link to your message to Douglas Bates.

Dieter


-- 
View this message in context: 
http://n4.nabble.com/error-in-lmLists-in-lme4-package-bug-tp1569432p1570296.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] R: MANOVA help

2010-02-26 Thread shmy

Hello everyone! 

I did a search, didn't quite find what I was looking for. I should warn you
I'm not very good at programming.

I am trying to do a simulation. I have generated data in two separate files.
I want to do a MANOVA, using the files as my categorical variable. Each
files has 4 variables that I generated with the rmnorm() method, the only
difference between them is that I used different means. 

Any ideas? Thank you for your time :-D
-- 
View this message in context: 
http://n4.nabble.com/R-MANOVA-help-tp1570300p1570300.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] Adjust lattice graph axis label on final page

2010-02-26 Thread Deepayan Sarkar
On Thu, Feb 25, 2010 at 3:45 AM, Sebastien Bihorel
sebastien.biho...@cognigencorp.com wrote:
 Dear R-users,

 I was wondering if there was a way to adjust the placement of the axis
 titles for the last page of a multi-page lattice plot (see example below).
 Depending on the total number of panels, the placement of these titles might
 look strange on the last page, if the layout is not adjusted (e.g. in some
 template code).

It's not possible to adjust the labels on a per-page basis.

It _is_ possible to have the two plots fill up the last page, but that
may not be what you want.

xyplot(y~x|id,as.table=T,data=mydata,layout=c(2,3))[1:6]
xyplot(y~x|id,as.table=T,data=mydata,layout=c(2,1))[7:8]

-Deepayan

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

2010-02-26 Thread Lorenzo Isella

Dear All,
Consider a matrix (N x N) where each entry is either zero or one (can
hardly get any simpler).
Now, I would like to plot it as a 'chessboard' where every matrix entry
is a black (1) or white (0) square.
Whatever tool I use to plot it, it should not try to interpolate the
data at all.
I found some online references
http://www.phaget4.org/R/image_matrix.html
but probably I can resort to something much simpler.
Can anyone provide me with a simple example I can modify later on?
Many thanks

Lorenzo

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


Re: [R] Reading multiple csv files

2010-02-26 Thread Patrick Connolly
On Fri, 26-Feb-2010 at 12:15AM -0800, Madhavi Bhave wrote:

| Dear R helpers
| ?

| Some particular analysis leads me to various number of output csv
| files depending on some conditions. Say e.g. I have output files
| variable1.csv, variable2.csv, .. Problem is I don't
| know how many csv files been generated. They could be 4, 5 or even
| 10. Each file will have a column called amount.  ?

| My problem is to find filewise mean(amount) and sd(amount). I need
| to write a loop where all these individual csv files will be read
| and after reading each file, mean and sd will be calculated.  ?

| I have tried to write some R code which is very absurd. 
| ?
| for (i in 1 : n)? # n is no of input files

There's a bit of a problem with your character encoding.  On my
system, I get that question mark which doesn't make syntactic sense.
Just what you have there, I can't guess, so it's a bit hard to work
out what could be the problem (apart from not knowing what size n
should be).


| ?
| {
| data[i] = read.csv(file = paste(variable, i, .csv, sep = ))$amount
| mean(data[i])
| sd(data[i])

You'll need to tell us what your object 'data' is.  You probably need a
list, in which case data[[i]] might work.

| }
| ?
| I get following error.
| ?
| Error in file(file, rt) : cannot open the connection
| In addition: Warning message:
| In file(file, rt) :
| ? cannot open file 'paste(output, i, .csv, sep = )': Invalid argument
| 
| ?
| Please guide

The posting guide might have given you a few ideas.  We don't know
what you did that used output in it to have any idea what could be
behind the Invalid argument message.


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

HTH

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


Re: [R] bwplot() {lattice}

2010-02-26 Thread Deepayan Sarkar
On Fri, Feb 26, 2010 at 8:30 AM, Peng Cai pengcaimaill...@gmail.com wrote:
 Hi All,

 I'm trying to plot boxplot graph. I tried barchart with groups= option and
 it worked fine. But when I try to generate same kind of graph using
 bwplot(), groups= option doesn't seem to work. Though this works,

 yield ~ variety | site * year

 I'm thinking why groups= doesn't work in this case, can anyone help
 please...

Let's see...you have exactly one observation per site/variety/year
combination (otherwise the barchart wouldn't have made sense). So in
the boxplot you want (which is supposed to summarize a distribution,
not a single point), you only have that single point to plot. For
that, you can use

dotplot(yield ~ variety | site, data = barley, auto.key = TRUE,
groups = year, layout = c(6,1), scales=(x=list(rot=45)))

If you try to come up with a more sensible example, you would realize
that boxplots are already grouped (the grouping variable is the
categorical variable in the formula y ~ x, not the 'groups' argument).
Compare

## Is this really what you want?
bwplot(yield ~ variety, data = barley, col = 1, pch = 16,
   panel = panel.superpose, panel.groups = panel.bwplot,
   groups = year, scales=(x=list(rot=45)))

bwplot(yield ~ year | variety, data = barley,
   scales=(x=list(rot=45)), layout = c(10, 1))

-Deepayan



 #Code:
 library(lattice)
 barchart(yield ~ variety | site, data = barley,
         groups = year, layout = c(1,6),
  auto.key = list(points = FALSE, rectangles = TRUE, space = right))

 bwplot(yield ~ variety | site, data = barley,
         groups = year, layout = c(6,1), scales=(x=list(rot=45)),
  auto.key = list(points = FALSE, rectangles = TRUE, space = right))

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

2010-02-26 Thread Ivan Calandra

Since you want input from beginners, here are some thoughts

I had and still have two big problems with R:
- this vectorization thing. I've read many manuals (including R 
inferno), but I'm still not completely clear about it. In simple 
examples, it's fine. But when it gets a bit more complex, then...
Related to it, the *apply functions are still a bit difficult to 
understand. When I have to use them, I just try one and see what 
happens. I don't understand them well enough to know which one I need.
- the second problem is where to find the functions/packages I need. 
There are many options, and that's actually the problem. R Wiki, Rseek, 
RSiteSearch, Crantastic, etc... When you start with R, you discover that 
the capabilities of R are almost unlimited and you don't really know 
where to start, where to find what you need.


As noted in earlier posts, the mailing list is really great, but some 
people are really hard with beginners. It was noted in a discussion a 
few days ago, but it looks like some don't realize how difficult it is 
at the beginning to formulate a good question, clear, with 
self-contained example and so on. Moreover, not everybody speaks English 
natively. I don't mean that you must help, even when the question is 
really vague and not clear and whatever. I'm just saying that if you 
don't want to help (whatever the reason), you don't have to say it 
badly. But in any cases, the mailing list is still really helpful. As 
someone noted (sorry I erased the email so I don't remember who), it 
might be a good idea to split it.


Hope that's what you wanted
Ivan


Le 2/26/2010 08:39, Dieter Menne a écrit :


Patrick Burns wrote:
   

* What were your biggest misconceptions or
stumbling blocks to getting up and running
with R?


 

(This derives partly from teaching)

The fact that this xapply-stuff was not idempotent (worse: not always) and
that you need a monster like do.call() to straighten this out. Nowadays,
plyr comes close.

The concept of environment. With S it was worse, though.

That you cannot change values passed by reference. I noted that the latter
is no problem for students who have not worked with c(++/#) before. That
there is only one return-result in functions.

[ and the likes as an operator.

10 years ago, when I started, the message was: S4 is the future, S3 is
legacy. So I learned S4. Only to never use is in self-written code later.
Might be different for BioConductor people.

That sometimes you can use vectors not in data= (lattice), and sometimes not
(ggplot2). Still a VERY confusing inconsistency.

The why-does-this-not-print FAQ.

Why does par(oma..) not work with lattice?

Dieter





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


Re: [R] Plotting a Trivial Matrix

2010-02-26 Thread baptiste auguie
Hi,

A minimalist example using Grid graphics,



library(RGraphics)

bwImage - function(m, cols=c(white, black),
draw=TRUE, gp=gpar()){

g - imageGrob(nrow(m), ncol(m),
   cols=cols[m+1], gp=gp)

if(draw)
  grid.draw(g)
return(g)
}

m - matrix(rnorm(200)  0,  ncol=20)
bwImage(m)

HTH,

baptiste

On 26 February 2010 09:29, Lorenzo Isella lorenzo.ise...@gmail.com wrote:
 Dear All,
 Consider a matrix (N x N) where each entry is either zero or one (can
 hardly get any simpler).
 Now, I would like to plot it as a 'chessboard' where every matrix entry
 is a black (1) or white (0) square.
 Whatever tool I use to plot it, it should not try to interpolate the
 data at all.
 I found some online references
 http://www.phaget4.org/R/image_matrix.html
 but probably I can resort to something much simpler.
 Can anyone provide me with a simple example I can modify later on?
 Many thanks

 Lorenzo

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




-- 


Baptiste Auguié

Departamento de Química Física,
Universidade de Vigo,
Campus Universitario, 36310, Vigo, Spain

tel: +34 9868 18617
http://webs.uvigo.es/coloides

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

2010-02-26 Thread Lesong Tsai

I use the function 'read.table' to read a data file.

it has  cases.but R only read 75.

why ? I need your help.thx.
-- 
View this message in context: 
http://n4.nabble.com/One-ploblem-tp1570329p1570329.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] R and Wordpress

2010-02-26 Thread Tal Galili
Hi CH,

My solution for this is to work only on the code editor, and never to move
to the visual editor (once I put an R code inside it).

Let me know if it works for you (and what is the link to your blog :) )
Cheers,
Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Feb 25, 2010 at 6:40 AM, C.H. chainsawti...@gmail.com wrote:

 Dear R helpers,

 I have a question regarding wordpress and R. I have asked this
 question in Wordpress support (
 http://wordpress.org/support/topic/368312 ) but there is no answer so
 far, maybe the R community can have a better answer.

 I followed the excellent tutorial on r-statistics-blog (

 http://www.r-statistics.com/2010/02/r-syntax-highlight-on-your-blog-a-wordpress-plugin/
 ) to enable syntax hightlighting but Wordpress keeps breaking -
 into  - and I have to use = instead. (I think = is confusing.)
 And I think it is not related to the theme as well.

 Is there any clue to solve this? I am using Wordpress 2.9.2.

 Regards,

 CH

 --
 CH Chan
 Research Assistant - KWH
 http://www.macgrass.com

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


[[alternative HTML version deleted]]

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


Re: [R] two questions for R beginners

2010-02-26 Thread Mario Valle
My difficulties:
1) Statistics :-) well, I'm learning.
2) Understand what is available *per subject area*. Something like the task 
view for
packages, should be compiled for basic commands/functions. Like: all things 
related to
string manipulation, all things related to number formatting, all *apply 
things, and so
on. Something similar is available for C runtime library functions (like in
http://msdn.microsoft.com/en-us/library/2aza74he(VS.71).aspx ) and is really 
useful, also
to expand the number of functions known.
3) The Diktakt-like: avoid for loops! without clear examples of alternatives. 
I have
found them later in the maillist, but at the beginning it is not simple, 
especially coming
from C/C++.
4) for statement behavior different from C/C++: for(i in 1:0) counts backward 
instead of
stopping.
5) missing small things like ++var

On the positive side:
- it is not too difficult to setup something simple to create a decent chart.
- it is possible to use for loops without feeling guilty. :-)
- documentation is very well done. Maybe some page are still clear only to who 
already
know the argument.
- there are zillions of courses/papers/tutorials to read
- after studying R by myself, now I'm becoming the local R expert, that from a 
workplace
point of view is not bad...

Hope it helps.
Ciao!
mario


Ivan Calandra wrote:
 Since you want input from beginners, here are some thoughts
 
 I had and still have two big problems with R:
 - this vectorization thing. I've read many manuals (including R 
 inferno), but I'm still not completely clear about it. In simple 
 examples, it's fine. But when it gets a bit more complex, then...
 Related to it, the *apply functions are still a bit difficult to 
 understand. When I have to use them, I just try one and see what 
 happens. I don't understand them well enough to know which one I need.
 - the second problem is where to find the functions/packages I need. 
 There are many options, and that's actually the problem. R Wiki, Rseek, 
 RSiteSearch, Crantastic, etc... When you start with R, you discover that 
 the capabilities of R are almost unlimited and you don't really know 
 where to start, where to find what you need.
 
 As noted in earlier posts, the mailing list is really great, but some 
 people are really hard with beginners. It was noted in a discussion a 
 few days ago, but it looks like some don't realize how difficult it is 
 at the beginning to formulate a good question, clear, with 
 self-contained example and so on. Moreover, not everybody speaks English 
 natively. I don't mean that you must help, even when the question is 
 really vague and not clear and whatever. I'm just saying that if you 
 don't want to help (whatever the reason), you don't have to say it 
 badly. But in any cases, the mailing list is still really helpful. As 
 someone noted (sorry I erased the email so I don't remember who), it 
 might be a good idea to split it.
 
 Hope that's what you wanted
 Ivan
 
 
 Le 2/26/2010 08:39, Dieter Menne a écrit :
 Patrick Burns wrote:

 * What were your biggest misconceptions or
 stumbling blocks to getting up and running
 with R?


  
 (This derives partly from teaching)

 The fact that this xapply-stuff was not idempotent (worse: not always) and
 that you need a monster like do.call() to straighten this out. Nowadays,
 plyr comes close.

 The concept of environment. With S it was worse, though.

 That you cannot change values passed by reference. I noted that the latter
 is no problem for students who have not worked with c(++/#) before. That
 there is only one return-result in functions.

 [ and the likes as an operator.

 10 years ago, when I started, the message was: S4 is the future, S3 is
 legacy. So I learned S4. Only to never use is in self-written code later.
 Might be different for BioConductor people.

 That sometimes you can use vectors not in data= (lattice), and sometimes not
 (ggplot2). Still a VERY confusing inconsistency.

 The why-does-this-not-print FAQ.

 Why does par(oma..) not work with lattice?

 Dieter



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

-- 
Ing. Mario Valle
Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82

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


Re: [R] Plotting a Trivial Matrix

2010-02-26 Thread Jim Lemon

On 02/26/2010 07:29 PM, Lorenzo Isella wrote:

Dear All,
Consider a matrix (N x N) where each entry is either zero or one (can
hardly get any simpler).
Now, I would like to plot it as a 'chessboard' where every matrix entry
is a black (1) or white (0) square.
Whatever tool I use to plot it, it should not try to interpolate the
data at all.
I found some online references
http://www.phaget4.org/R/image_matrix.html
but probably I can resort to something much simpler.
Can anyone provide me with a simple example I can modify later on?


Hi Lorenzo,

trivial_matrix-matrix(sample(0:1,100,TRUE),nrow=10)
require(plotrix)
color2D.matplot(trivial_matrix,main=A trivial Plot)

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] two questions for R beginners

2010-02-26 Thread Patrick Burns

Saeed,

If the R-help list were split, what do you
see as the pieces?

Pat

On 26/02/2010 01:53, Saeed Abu Nimeh wrote:

On Thu, Feb 25, 2010 at 9:31 AM, Patrick Burnspbu...@pburns.seanet.com  wrote:

* What were your biggest misconceptions or
stumbling blocks to getting up and running
with R?


1- Compared to other programming languages it is hard to learn R by
example, because it is hard to find code on the web that will do the
exact thing you are looking for, sometimes you might get lucky though.
By contrast, take Perl for example, it is an easy language to learn by
example.

2- The R mailing list. Beginners get frustrated after they struggle
for a long time to solve a problem and the easiest thing then is to
send an email to the R mailing list. I did this in the past. The best
thing that happened was that my request was neglected and I had to
spend more time on the problem and find a solution by myself
eventually. Do not get me wrong, I am not saying that the mailing list
is bad, but it should be more organized. Maybe broken down into couple
of other mailing lists. This might bring up a good discussion thread.



* What documents helped you the most in this
initial phase?


An Introduction to R by Venables
simpleR – Using R for Introductory Statistics by Verzani



--
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'The R Inferno' and 'A Guide for the Unwilling S User')

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


Re: [R] One ploblem

2010-02-26 Thread Jim Lemon

On 02/26/2010 07:50 PM, Lesong Tsai wrote:


I use the function 'read.table' to read a data file.

it has  cases.but R only read 75.

why ? I need your help.thx.


Hi Lesong,
There were one or two similar posts recently. Are there any single 
quotes (') in your data file?


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] R and Wordpress

2010-02-26 Thread Tsjerk Wassenaar
Hi,

The visual editor should take HTML code, shouldn't it? - would then
be written lt;-
Haven't tried it though.

Cheers,

Tsjerk

On Fri, Feb 26, 2010 at 10:19 AM, Tal Galili tal.gal...@gmail.com wrote:
 Hi CH,

 My solution for this is to work only on the code editor, and never to move
 to the visual editor (once I put an R code inside it).

 Let me know if it works for you (and what is the link to your blog :) )
 Cheers,
 Tal



 Contact
 Details:---
 Contact me: tal.gal...@gmail.com |  972-52-7275845
 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
 www.r-statistics.com (English)
 --




 On Thu, Feb 25, 2010 at 6:40 AM, C.H. chainsawti...@gmail.com wrote:

 Dear R helpers,

 I have a question regarding wordpress and R. I have asked this
 question in Wordpress support (
 http://wordpress.org/support/topic/368312 ) but there is no answer so
 far, maybe the R community can have a better answer.

 I followed the excellent tutorial on r-statistics-blog (

 http://www.r-statistics.com/2010/02/r-syntax-highlight-on-your-blog-a-wordpress-plugin/
 ) to enable syntax hightlighting but Wordpress keeps breaking -
 into  - and I have to use = instead. (I think = is confusing.)
 And I think it is not related to the theme as well.

 Is there any clue to solve this? I am using Wordpress 2.9.2.

 Regards,

 CH

 --
 CH Chan
 Research Assistant - KWH
 http://www.macgrass.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.




-- 
Tsjerk A. Wassenaar, Ph.D.

Computational Chemist
Medicinal Chemist
Neuropharmacologist

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


Re: [R] Plotting a Trivial Matrix

2010-02-26 Thread Lorenzo Isella

baptiste auguie wrote:

Hi,

A minimalist example using Grid graphics,



library(RGraphics)

bwImage - function(m, cols=c(white, black),
draw=TRUE, gp=gpar()){

g - imageGrob(nrow(m), ncol(m),
   cols=cols[m+1], gp=gp)

if(draw)
  grid.draw(g)
return(g)
}

m - matrix(rnorm(200)  0,  ncol=20)
bwImage(m)

HTH,

baptiste

On 26 February 2010 09:29, Lorenzo Isella lorenzo.ise...@gmail.com wrote:
  

Dear All,
Consider a matrix (N x N) where each entry is either zero or one (can
hardly get any simpler).
Now, I would like to plot it as a 'chessboard' where every matrix entry
is a black (1) or white (0) square.
Whatever tool I use to plot it, it should not try to interpolate the
data at all.
I found some online references
http://www.phaget4.org/R/image_matrix.html
but probably I can resort to something much simpler.
Can anyone provide me with a simple example I can modify later on?
Many thanks

Lorenzo

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






  

Thanks Augustine and Jim for the prompt reply.
You both answered my question. To avoid another post, I would simply 
like to know if something along these lines is doable also with ggplot2.

Many thanks

Lorenzo

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


Re: [R] Plotting a Trivial Matrix

2010-02-26 Thread Tobias.Mathow
What about 

http://www.phaget4.org/R/image_matrix.html

try function f.matrix.plot



Tobias Mathow
Forest Research Institute Baden-Wuerttemberg (FVA) 
Wonnhaldestr. 4, D- 79100 Freiburg 
Phone: ++49-761-4018-365
www.fva-bw.de


-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im 
Auftrag von Lorenzo Isella
Gesendet: Freitag, 26. Februar 2010 09:30
An: r-help
Betreff: [R] Plotting a Trivial Matrix

Dear All,
Consider a matrix (N x N) where each entry is either zero or one (can
hardly get any simpler).
Now, I would like to plot it as a 'chessboard' where every matrix entry
is a black (1) or white (0) square.
Whatever tool I use to plot it, it should not try to interpolate the
data at all.
I found some online references
http://www.phaget4.org/R/image_matrix.html
but probably I can resort to something much simpler.
Can anyone provide me with a simple example I can modify later on?
Many thanks

Lorenzo

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

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


[R] R: error using pvcm() on unbalanced panel data

2010-02-26 Thread Millo Giovanni
Dear Liviu,

in general, pvcm is capable of fitting variable coefficients models on 
unbalanced data sets: e.g.,

 data(Grunfeld)
 grun-Grunfeld[-1,] ## 'unbalance' it
 pvcm(inv~value+capital, data=grun)

Model Formula: inv ~ value + capital

Coefficients:
   (Intercept) value   capital
1   -193.77819 0.1272949 0.3765985
2-49.19832 0.1748560 0.3896419
3 -9.95631 0.0265512 0.1516939
4 -6.18996 0.0779478 0.3157182
5 22.70712 0.1623777 0.0031017
6 -8.68554 0.1314548 0.0853743
7 -4.49953 0.0875272 0.1237814
8 -0.50939 0.0528941 0.0924065
9 -7.72284 0.0753879 0.0821036
10 0.16152 0.0045734 0.4373692

 pvcm(inv~value+capital, data=grun, model=random)

Model Formula: inv ~ value + capital

Coefficients:
(Intercept)   value capital 
 -11.7417540.0850460.199632 

so the problem must be within the dataset and the minimum-T requirements for 
fitting vc models. The error message may not be the friendliest, but it 
actually tells you where the problem is.
Let us look at the Hedonic data you used as an example: this is not a panel 
dataset but you can treat it as one, as you did, by grouping obs. for the same 
town. So your N is

 length(unique(Hedonic$townid))
[1] 92

and your T (although here it is not time) is:

 summary(tapply(Hedonic$townid,Hedonic$townid,length))
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
1.0 2.0 4.0 5.5 7.030.0 

as you can see, there are many single observation towns

 which(tapply(Hedonic$townid,Hedonic$townid,length)==1)
 1 10 11 12 13 15 34 45 50 51 52 53 65 66 69 70 73 
 1 10 11 12 13 15 34 45 50 51 52 53 65 66 69 70 73 

So the within model cannot work, as it needs T(K+1) for estimating the 
separate regressions for each town. Why the random vcm doesn't is less 
straightforward.
Let us try a reduced pvcm with K=9 on a subset of data with T10:

 hedo-Hedonic[(Hedonic$townid %in% 
 which(tapply(Hedonic$townid,Hedonic$townid,length)10)),]
 dim(hedo)
[1] 208  15
  Hed - pvcm(mv ~ crim + zn + indus + chas + nox + rm + age + dis +rad 
+  , data=hedo, model = within,index = townid)

This works, but gives bad coefficients, because as it turns out there are also 
many time-invariant variables in the dataset, and of course these are discarded 
in doing timewise regressions!

A closer look at the data reveals that 'chas' is a factor, 'zn' is either 0 or 
20, 'age' is truncated at 100 and so on. Let's see what's in the town with the 
most obs.:

 tapply(hedo$townid,hedo$townid,length)
 5 25 28 29 39 41 46 60 80 81 83 84 85 
22 11 15 30 11 18 12 12 11 13 19 23 11 
 summary(hedo[hedo$townid==29,])
   mv  crim zninduschas   
 Min.   : 9.376   Min.   :1.127   Min.   :0   Min.   :19.58   no :23  
 1st Qu.: 9.655   1st Qu.:1.472   1st Qu.:0   1st Qu.:19.58   yes: 7  
 Median : 9.878   Median :2.152   Median :0   Median :19.58   
 Mean   : 9.973   Mean   :2.111   Mean   :0   Mean   :19.58   
 3rd Qu.:10.093   3rd Qu.:2.430   3rd Qu.:0   3rd Qu.:19.58   
 Max.   :10.820   Max.   :4.097   Max.   :0   Max.   :19.58   
  nox  rm age  dis
 Min.   :36.60   Min.   :24.04   Min.   : 79.20   Min.   :0.2788  
 1st Qu.:36.60   1st Qu.:30.26   1st Qu.: 93.82   1st Qu.:0.4349  
 Median :75.86   Median :35.69   Median : 96.05   Median :0.5615  
 Mean   :57.54   Mean   :37.83   Mean   : 95.16   Mean   :0.5876  
 3rd Qu.:75.86   3rd Qu.:39.71   3rd Qu.: 98.42   3rd Qu.:0.7354  
 Max.   :75.86   Max.   :70.14   Max.   :100.00   Max.   :0.8862  
  rad tax ptratio blacks   
 Min.   :1.609   Min.   :403   Min.   :14.7   Min.   :0.08801  
 1st Qu.:1.609   1st Qu.:403   1st Qu.:14.7   1st Qu.:0.29349  
 Median :1.609   Median :403   Median :14.7   Median :0.35000  
 Mean   :1.609   Mean   :403   Mean   :14.7   Mean   :0.31745  
 3rd Qu.:1.609   3rd Qu.:403   3rd Qu.:14.7   3rd Qu.:0.37402  
 Max.   :1.609   Max.   :403   Max.   :14.7   Max.   :0.39690  
 lstattownid  
 Min.   :-4.058   Min.   :29  
 1st Qu.:-2.534   1st Qu.:29  
 Median :-2.064   Median :29  
 Mean   :-2.186   Mean   :29  
 3rd Qu.:-1.801   3rd Qu.:29  
 Max.   :-1.220   Max.   :29  

whence we see that 'zn', 'indus', 'rad', 'tax', 'ptratio' and, of course, 
'townid' are T-invariant, 'chas' is a factor but at least it varies between yes 
and no. 'nox' is also problematic in that it varies only from time to time...
A feasible formula, whatever this model means, is:

 fm - mv ~ crim  + rm + age + dis + blacks + lstat
 newmodr - pvcm(fm, data=hedo, model=random, index=townid)
 newmodw - pvcm(fm, data=hedo, model=within, index=townid)
 ## all is well now

I hope hereby to have given you some methodological hint for a critical 
overview of your data. PS the pooltest() problem is much the same, as 
pooltest() needs to fit separate regressions.

Best,
Giovanni

-Messaggio originale-
Da: Liviu Andronic 

[R] Boot R

2010-02-26 Thread Cassiano
Hello,

This is my first post, and my english is not very good, but I will try...

I have a problem with boot the R. After that I install ubuntu 9.10 the R
don't run. When I open the terminal and digit R, appear the message:

*/usr/lib/R/bin/exec/R: error while loading shared libraries:
libgfortran.so.3: cannot open shared object file: No such file or directory*

What's happening?
Can anyone help me?

Thank you

-- 
Cassiano Sousa Rosa
Universidade Federal de Viçosa -UFV
Dept. Biologia Animal
Pós-graduação em Entomologia
Lab. Termitologia
Viçosa-MG, Brazil
CEP 36570-000
Tel: (31) 38994017
(31) 97972730

[[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] Plotting a Trivial Matrix

2010-02-26 Thread baptiste auguie
On 26 February 2010 11:12, Lorenzo Isella lorenzo.ise...@gmail.com wrote:

 Thanks Augustine and Jim for the prompt reply.
 You both answered my question. To avoid another post, I would simply like to
 know if something along these lines is doable also with ggplot2.
 Many thanks

 Lorenzo


Augustine???

Anyhow, with ggplot2,

m - matrix(rnorm(200)  0,  ncol=20)

require(ggplot2)

d - melt(m)
qplot(X1, X2, data=d, fill=value, geom=tile) +
  scale_fill_manual(values=c(white, black))

HTH,

baptiste

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


[R] Odp: two questions for R beginners

2010-02-26 Thread Petr PIKAL
Hi

It was class, mode or type.of imported data which I usually believed they 
are something but actually they were something else until I learned that 
when something does not look as I would expect I shall blame myself for 
wrong expectation.

For the time being I would say that reshape and factor ordering especially 
with groupedData objects from nlme are still giving me a headache and many 
trials and errors to get desired result. And of course regular expressions 
but they are not related with R but with my laziness to learn it due to 
fact that on this list there are many clever experts which can solve the 
problem for a fraction of time I could do it myself.

For documents in the beginning I would vote for Paul Johnsons Rtips. About 
10 yars ago it was nice collection of several useful Howto's.

Regards
Petr


r-help-boun...@r-project.org napsal dne 25.02.2010 18:31:19:

 * What were your biggest misconceptions or
 stumbling blocks to getting up and running
 with R?
 
 * What documents helped you the most in this
 initial phase?
 
 I especially want to hear from people who are
 lazy and impatient.
 
 Feel free to write to me off-list.  Definitely
 write off-list if you are just confirming what
 has been said on-list.
 
 -- 
 Patrick Burns
 pbu...@pburns.seanet.com
 http://www.burns-stat.com
 (home of 'The R Inferno' and 'A Guide for the Unwilling S User')
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Boot R

2010-02-26 Thread Alberto Goldoni
Try to use:

sudo R

best regards.


2010/2/26 Cassiano cassian...@gmail.com:
 Hello,

 This is my first post, and my english is not very good, but I will try...

 I have a problem with boot the R. After that I install ubuntu 9.10 the R
 don't run. When I open the terminal and digit R, appear the message:

 */usr/lib/R/bin/exec/R: error while loading shared libraries:
 libgfortran.so.3: cannot open shared object file: No such file or directory*

 What's happening?
 Can anyone help me?

 Thank you

 --
 Cassiano Sousa Rosa
 Universidade Federal de Viçosa -UFV
 Dept. Biologia Animal
 Pós-graduação em Entomologia
 Lab. Termitologia
 Viçosa-MG, Brazil
 CEP 36570-000
 Tel: (31) 38994017
 (31) 97972730

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





-- 
-
Dr. Alberto Goldoni
Bologna, Italy

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


Re: [R] Boot R

2010-02-26 Thread Cassiano

same error...
-- 
View this message in context: http://n4.nabble.com/Boot-R-tp1570427p1570441.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] block matrices

2010-02-26 Thread Gustave Lefou
Thank you Duncan, Kjetil and William.

Kjetil, with rep(0,2), I get a vector. So I have to transpose it.

cbind(A,B, t( rep(0,2) ) )
if C is of length 2. Is that right ?

I like very much Duncan's general solution.

Thanks a lot,
Gustave

2010/2/24 Kjetil Halvorsen kjetilbrinchmannhalvor...@gmail.com

 see below.

 On Wed, Feb 24, 2010 at 12:56 PM, Gustave Lefou gustave5...@gmail.com
 wrote:
  Dear all,
 
  I do not know how to deal with block matrices in R.
 
  For example I have 3 matrices A, B and C.
 
  And I want to produce a new matrix of this form
 
  ( A B 0 )
  ( 0 0 C )
 
  where A, B and C are one-row matrices.

   cbind(A,B,0) or maybe
   cbind(a,B,rep(0, 12))

   cbind(rep(0,2), C)

 
  Apart from A, B and C, all the coefficients are 0.
 
  Is there an easy solution in R for every block matrices ?

 Combine rbind and cbind:
 ?rbind

 Kjetil

 
  Thanks for your help,
  Gustave
 
  P.S. : I have had a look at a function called zoo which looked quite
  complicated to me.
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


[[alternative HTML version deleted]]

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


[R] Hartley's table

2010-02-26 Thread Silvano

Hi,

Does anyone know how to generate Hartley's table in R?

--
Silvano Cesar da Costa
Departamento de Estatística
Universidade Estadual de Londrina
Fone: 3371-4346

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


Re: [R] Hartley's table

2010-02-26 Thread Tobias Verbeke

Hi Silvano,

Is it

library(SuppDists)
?maxFratio

you are looking for ?

Best,
Tobias

Silvano wrote:

Hi,

Does anyone know how to generate Hartley's table in R?

--
Silvano Cesar da Costa
Departamento de Estatística
Universidade Estadual de Londrina
Fone: 3371-4346

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

2010-02-26 Thread Cassiano

Really, I had  ubuntu 9.04 with R normal, so I did upgrade to ubuntu 9.10
then R not run.

After this I remove and reinstall the R by way of synaptic, but the error
continue.
-- 
View this message in context: http://n4.nabble.com/Boot-R-tp1570427p1570550.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] Boot R

2010-02-26 Thread Paul Hiemstra

Cassiano wrote:

Hello,

This is my first post, and my english is not very good, but I will try...

I have a problem with boot the R. After that I install ubuntu 9.10 the R
don't run. When I open the terminal and digit R, appear the message:

*/usr/lib/R/bin/exec/R: error while loading shared libraries:
libgfortran.so.3: cannot open shared object file: No such file or directory*
  

Hi,

R tries to find libgfortran.so.3, which it cannot find. Either it's not 
on your computer, or it's the wrong version. Check if it is installed:


dpkg -l | grep libgfortran

If this last command does not return anything, you need to install using:

sudo apt-get update
sudo apt-get install libgfortran3

probably it is not installed by default and this will solve the problem.

cheers,
Paul


What's happening?
Can anyone help me?

Thank you

  



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



--
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 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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

2010-02-26 Thread Todd DeWees
I have a 280,000 x 11 matrix with various values and many NA values.  What I 
would like to do is get a vector of every unique value in the matrix.

For example:

X = [ 12NA
  43  1
  7  NA  2 ]

Returns:
Unique_X = [ 1, 2, 3, 4, 7]

Thanks,
Todd


[[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] Boot R

2010-02-26 Thread Cassiano

I think I have 'libgfortran'.
After that I digit 'dpkg -l | grep libgfortran' in terminal, I got this
message:

ii  libgfortran2   4.2.4-5ubuntu1   
 
Runtime library for GNU Fortran applications
ii  libgfortran2-dbg   4.2.4-5ubuntu1   
 
Runtime library for GNU Fortran applications
ii  libgfortran3   4.4.1-4ubuntu9   
 
Runtime library for GNU Fortran applications
ii  libgfortran3-dbg   4.4.1-4ubuntu9   
 
Runtime library for GNU Fortran applications

And the error continue:

/usr/lib/R/bin/exec/R: error while loading shared libraries:
libgfortran.so.3: cannot open shared object file: No such file or directory

-- 
View this message in context: http://n4.nabble.com/Boot-R-tp1570427p1570558.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] Unique Values of a Matrix

2010-02-26 Thread Henrique Dallazuanna
Try this:

unique(c(X))

On Fri, Feb 26, 2010 at 10:06 AM, Todd DeWees
t.dew...@cpse.dundee.ac.uk wrote:
 I have a 280,000 x 11 matrix with various values and many NA values.  What I 
 would like to do is get a vector of every unique value in the matrix.

 For example:

 X =     [ 1    2    NA
          4    3      1
          7  NA  2 ]

 Returns:
 Unique_X = [ 1, 2, 3, 4, 7]

 Thanks,
 Todd


        [[alternative HTML version deleted]]

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


Re: [R] Help with simple bootstrap test

2010-02-26 Thread Harry Palmer

Thanks that's exactly what I wanted - and yes resampling of the rows with
replacement was what I should have said.

Now i'm stuck on how to do a bootstrap of the data in each column of the
table separately, but all done in the same go.
-- 
View this message in context: 
http://n4.nabble.com/Help-with-simple-bootstrap-test-tp1569459p1570575.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] Error in Aggregate function

2010-02-26 Thread Meenakshi

Hi,

When I run the Aggregate function in repeat loop, I got the following error:

Error in sort.list(unique.default(x), na.last = TRUE) : 
  'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?

How to solve this error. Anyone can help me. Urgent.

Thanks.
Meenakshi.
-- 
View this message in context: 
http://n4.nabble.com/Error-in-Aggregate-function-tp1570370p1570370.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] two questions for R beginners

2010-02-26 Thread Patrick Burns

On 25/02/2010 20:42, Greg Snow wrote:

Patrick,

I would add one more question:

* where did you look for help expecting answers, but did not find them?



Yes, an excellent additional question.

Pat


If you add hubris to laziness and impatience, you have Larry Wall's 3 virtues 
of a programmer.

[...]


--
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'The R Inferno' and 'A Guide for the Unwilling S User')

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

2010-02-26 Thread RCulloch

Hello R users,

I have been using R for a while now for basic stats but I'm now trying to
get my head around looping scripts and in some places I am failing! 

I have a data set with c. 1200 data points on 98 individual animals with
data on each row representing a daily measure and I am asking the question
what variables affect the animal's behaviour?

the dataset includes these variables for analyses:

presence of behaviour, absence of behaviour, site, year, rain, air temp, ID,
Day

Listed below as they appear in the data set:

BEH_T, BEH_F, SITE, YEAR, PRECIP_MM_DAY,  PUP_AGE_EST, MO_AIR_TEMP,  ID2,
DAY

with BEH_T  BEH_F = the response variable for a binomial GLM

here is the head of the dataset 
(NB there are only two years and two sites)

 BEH_T BEH_F SITE YEAR PRECIP_MM_DAY PUP_AGE_EST MO_AIR_TEMP ID2 DAY
[1,]14101 2007 0  1210.98750   1   1
[2,]37231 2007 0  1311.47333   1   2
[3,]56221 2007 0  1412.16667   1   3
[4,]43231 2007 0  1610.91515   1   5
[5,]62161 2007 0  1712.81026   1   6
[6,]30201 2007 0  19 8.67037   1   8

(Sorry the headings are skewed)

Because I don't want to do too complex a model to start with (just wanting
to learn first with a 'simple' model) I have issues with independence of the
data as there are repeats of individuals - i.e. data taken on the same IDs
on different days. So in order to account for that I have decided to random
sample one data point for each ID then run the GLM on that data for x number
of simulations to see if the explanatory variables are the same/similar
across all models. (This will reduce my data set to 98 data points, but it
is the best way I can see of doing this without doing mixed-effects models,
since not all IDs are seen at both sites in both years).

I am also using the MuMIn package for running all subsets of your model


the code I'm using is:


for (S in 1:2){
Sample.dat-ALL.R[1,]
for (I in 1:98) {
tmp-ALL.R[ALL.R$ID2==I,]
max-dim(tmp)[1]
if (I==1) Sample.dat-tmp[sample(1:max,1),] else {
Sample.dat-rbind(Sample.dat,tmp[sample(1:max,1),])
m1.R-glm(cbind(Sample.dat$BEH_T, Sample.dat$BEH_F) ~ 
Sample.dat$SITE +
Sample.dat$YEAR + Sample.dat$PRECIP_MM_DAY + Sample.dat$PUP_AGE_EST +
Sample.dat$MO_AIR_TEMP, family=binomial) 
mod-dredge(m1.R)}}}

At this point I have two issues if I do it manually then it seems to work
i.e. gives me one output (e.g shown at bottom of post) where I then want to
take the first line, the model with the best AIC using mod[1,] - no problem!

However, letting the code run and for example using print ((mod[1,])) at the
end it prints out the first line of 98 outputs - so I'm not too sure what
I've done wrong here, but it appears to be running a model for each ID -
something basic no doubt!

Ideally, what I want to do is take a random sample of the data then run the
model get one output for that take the top line (i.e. the best AIC) and save
this, then run this routine say 100 times, saving that top line every time,
then having a look at the results and take a model average. Anytime I've got
close to this I have issues with overwriting the previous first line of the
model selection and I can't seem to identify how to set this loop up
properly.

Any advice or guidance would be most appreciated, I have tried to explain my
issues clearly but if more info is required please just ask,

Many thanks in advance to those of you that took the time to read this!

Ross

Ross Culloch
Ph.D. Student
Durham University
UK







Here is an example of the model selection table from usingMuMIn:


Model selection table 
 (Intr)  S.$MO_ S.$PRE   S.$PUP S.$SIT  S.$YEA k  Dev.   AIC  AICc  
delta weight
30 645.8000 0.03841-0.02148 0.2882 -0.3212 5 304.0 687.1 687.7  
0.000  0.707
32 648.8000 0.03811  0.0009399 -0.02172 0.2857 -0.3227 6 304.0 689.0 690.0  
2.249  0.230
26 785.1000-0.02543 0.4678 -0.3905 4 312.8 693.9 694.3  
6.630  0.026
31 794.2000  0.0037260 -0.02627 0.4519 -0.3950 5 312.5 695.5 696.2  
8.493  0.010
22 582.7000 0.04703 0.2641 -0.2899 4 314.7 695.8 696.2  
8.529  0.010
21 582.8000 0.06893-0.01967-0.2899 4 314.9 696.0 696.4  
8.717  0.009
29 573.1000 0.04787 -0.0039980  0.2762 -0.2851 5 314.3 697.4 698.0 
10.330  0.004
28 600.1000 0.06612  0.0046710 -0.02092-0.2985 5 314.4 697.4 698.1 
10.370  0.004
20   0.7526 0.05509-0.01808 0.2450 4 321.0 702.0 702.5 
14.770  0.000
10 530.4000 0.07447-0.2639 3 324.0 703.1 703.3 
15.640  0.000
27   0.7493 0.05556 -0.0022820 -0.01753 0.2519 5 320.8 703.9 704.6 
16.850  0.000
19 530. 0.07455 -0.0001489 -0.2637 4 

Re: [R] Unique Values of a Matrix

2010-02-26 Thread Todd DeWees
Thank you.  That worked.  I had tried it before and failed, but after checking 
with you I realized that the problem was that my data was in a frame instead of 
a matrix.

Thanks again, 
Todd

Todd DeWees, PhD
Statistician
University of Dundee
Mackenzie Building
Kirsty Semple Way
Dundee DD2 4BF
Scotland UK
PH: 01382-420119


-Original Message-
From: Henrique Dallazuanna [mailto:www...@gmail.com] 
Sent: 26 February 2010 1:17 PM
To: Todd DeWees
Cc: r-help@r-project.org
Subject: Re: [R] Unique Values of a Matrix

Try this:

unique(c(X))

On Fri, Feb 26, 2010 at 10:06 AM, Todd DeWees
t.dew...@cpse.dundee.ac.uk wrote:
 I have a 280,000 x 11 matrix with various values and many NA values.  What I 
 would like to do is get a vector of every unique value in the matrix.

 For example:

 X =     [ 1    2    NA
          4    3      1
          7  NA  2 ]

 Returns:
 Unique_X = [ 1, 2, 3, 4, 7]

 Thanks,
 Todd


        [[alternative HTML version deleted]]

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


Re: [R] Unique Values of a Matrix

2010-02-26 Thread David Winsemius


On Feb 26, 2010, at 8:17 AM, Henrique Dallazuanna wrote:


Try this:

unique(c(X))


I did but it returned NA as did:unique(as.vector(X)).

To get rid of the NA's I needed to do:

X[!duplicated(as.vector(X))  !is.na(X)]

(Logical indexing and does need as.vector() , or c() , to straighten  
out the index expression.)


Not sure why applying the straightening to the second logical term is  
not equivalent:

 X[!duplicated(X)  !is.na(as.vector(X))]
[1] 1 2 4 3 1 7 2

This also:
 unique(c(X))[!is.na(unique(c(X)))]
[1] 1 2 4 3 7



On Fri, Feb 26, 2010 at 10:06 AM, Todd DeWees
t.dew...@cpse.dundee.ac.uk wrote:
I have a 280,000 x 11 matrix with various values and many NA  
values.  What I would like to do is get a vector of every unique  
value in the matrix.


For example:

X = [ 12NA
 43  1
 7  NA  2 ]

Returns:
Unique_X = [ 1, 2, 3, 4, 7]

Thanks,
Todd


   [[alternative HTML version deleted]]

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





--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


David Winsemius, MD
Heritage Laboratories
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] Unique Values of a Matrix

2010-02-26 Thread Todd DeWees
I found that using 

Sort(unique(c(X)) also works to remove NA  if you don't mind the unique 
values being sorted

Todd DeWees, PhD
Statistician
University of Dundee
Mackenzie Building
Kirsty Semple Way
Dundee DD2 4BF
Scotland UK
PH: 01382-420119


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: 26 February 2010 1:49 PM
To: Henrique Dallazuanna
Cc: Todd DeWees; r-help@r-project.org
Subject: Re: [R] Unique Values of a Matrix


On Feb 26, 2010, at 8:17 AM, Henrique Dallazuanna wrote:

 Try this:

 unique(c(X))

I did but it returned NA as did:unique(as.vector(X)).

To get rid of the NA's I needed to do:

X[!duplicated(as.vector(X))  !is.na(X)]

(Logical indexing and does need as.vector() , or c() , to straighten  
out the index expression.)

Not sure why applying the straightening to the second logical term is  
not equivalent:
  X[!duplicated(X)  !is.na(as.vector(X))]
[1] 1 2 4 3 1 7 2

This also:
  unique(c(X))[!is.na(unique(c(X)))]
[1] 1 2 4 3 7


 On Fri, Feb 26, 2010 at 10:06 AM, Todd DeWees
 t.dew...@cpse.dundee.ac.uk wrote:
 I have a 280,000 x 11 matrix with various values and many NA  
 values.  What I would like to do is get a vector of every unique  
 value in the matrix.

 For example:

 X = [ 12NA
  43  1
  7  NA  2 ]

 Returns:
 Unique_X = [ 1, 2, 3, 4, 7]

 Thanks,
 Todd


[[alternative HTML version deleted]]

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




 -- 
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O

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

David Winsemius, MD
Heritage Laboratories
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] Error in mvpart example

2010-02-26 Thread Wearn, Oliver
Dear all,

I'm getting an error in one of the stock examples in the 'mvpart' package. I 
tried:

require(mvpart)
data(spider)
fit3 - 
rpart(gdist(spider[,1:12],meth=bray,full=TRUE,sq=TRUE)~water+twigs+reft+herbs+moss+sand,spider,method=dist)
 #directly from ?rpart
summary(fit3)

...which returned the following:

Error in apply(formatg(yval, digits - 3), 1, paste, collapse = ,, sep = ) : 
  dim(X) must have a positive length

This seems to be a problem with the cross-validation, since the xerror and 
xstd columns are missing from the summary table as well.

Using the mpart() wrapper results in the same error:

fit4-mvpart(gdist(spider[,1:12],meth=bray,full=TRUE,sq=TRUE)~water+twigs+reft+herbs+moss+sand,spider,method=dist)
summary(fit4)

Note, changing the 'method' argument to =mrt seems, superficially, to solve 
the problem. However, when the dependent variable is a dissimilarity matrix, 
shouldn't method=dist be used (as per the examples)?

Thanks, in advance, for any help on this error.

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


Re: [R] Unique Values of a Matrix

2010-02-26 Thread Henrique Dallazuanna
Or:

na.exclude(unique(c(X)))

On Fri, Feb 26, 2010 at 10:50 AM, Todd DeWees
t.dew...@cpse.dundee.ac.uk wrote:
 I found that using

 Sort(unique(c(X)) also works to remove NA  if you don't mind the unique 
 values being sorted

 Todd DeWees, PhD
 Statistician
 University of Dundee
 Mackenzie Building
 Kirsty Semple Way
 Dundee DD2 4BF
 Scotland UK
 PH: 01382-420119


 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: 26 February 2010 1:49 PM
 To: Henrique Dallazuanna
 Cc: Todd DeWees; r-help@r-project.org
 Subject: Re: [R] Unique Values of a Matrix


 On Feb 26, 2010, at 8:17 AM, Henrique Dallazuanna wrote:

 Try this:

 unique(c(X))

 I did but it returned NA as did:    unique(as.vector(X)).

 To get rid of the NA's I needed to do:

 X[!duplicated(as.vector(X))  !is.na(X)]

 (Logical indexing and does need as.vector() , or c() , to straighten
 out the index expression.)

 Not sure why applying the straightening to the second logical term is
 not equivalent:
   X[!duplicated(X)  !is.na(as.vector(X))]
 [1] 1 2 4 3 1 7 2

 This also:
   unique(c(X))[!is.na(unique(c(X)))]
 [1] 1 2 4 3 7


 On Fri, Feb 26, 2010 at 10:06 AM, Todd DeWees
 t.dew...@cpse.dundee.ac.uk wrote:
 I have a 280,000 x 11 matrix with various values and many NA
 values.  What I would like to do is get a vector of every unique
 value in the matrix.

 For example:

 X =     [ 1    2    NA
          4    3      1
          7  NA  2 ]

 Returns:
 Unique_X = [ 1, 2, 3, 4, 7]

 Thanks,
 Todd


        [[alternative HTML version deleted]]

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




 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O

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

 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT





-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


[R] ggplot2 : bug in coord_equal() ?

2010-02-26 Thread David Hajage
Hello,

I think there is a bug in coord_equal when x s a factor :

ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar()
ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar() + coord_equal(1/2)

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] Odp: Error in Aggregate function

2010-02-26 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 26.02.2010 10:32:34:

 
 Hi,
 
 When I run the Aggregate function in repeat loop, I got the following 
error:

Why and how exactly you use aggregate in loop?

 
 Error in sort.list(unique.default(x), na.last = TRUE) : 
   'x' must be atomic for 'sort.list'
 Have you called 'sort' on a list?
 
 How to solve this error. Anyone can help me. Urgent.

Using this weird construction on my data I do not get any error.

for (i in 2:5) print(aggregate(zeta[,i], list(zeta[,dus]), mean)) 
  Group.1x
1 ano 6.865000
2  ne 6.592727
  Group.1x
1 ano 6.785000
2  ne 6.635455
  Group.1 x
1 ano 0.9426667
2  ne 0.5016364
  Group.1x
1 ano 1.345167
2  ne 1.183727

Please provide at least a code, better with some simple fake data.

Regards
Petr




 
 Thanks.
 Meenakshi.
 -- 
 View this message in context: http://n4.nabble.com/Error-in-Aggregate-
 function-tp1570370p1570370.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] two questions for R beginners

2010-02-26 Thread Paul Hiemstra

Ivan Calandra wrote:

Since you want input from beginners, here are some thoughts

I had and still have two big problems with R:
- this vectorization thing. I've read many manuals (including R 
inferno), but I'm still not completely clear about it. In simple 
examples, it's fine. But when it gets a bit more complex, then...
Related to it, the *apply functions are still a bit difficult to 
understand. When I have to use them, I just try one and see what 
happens. I don't understand them well enough to know which one I need.
- the second problem is where to find the functions/packages I need. 
There are many options, and that's actually the problem. R Wiki, 
Rseek, RSiteSearch, Crantastic, etc... When you start with R, you 
discover that the capabilities of R are almost unlimited and you don't 
really know where to start, where to find what you need.


As noted in earlier posts, the mailing list is really great, but some 
people are really hard with beginners. It was noted in a discussion a 
few days ago, but it looks like some don't realize how difficult it is 
at the beginning to formulate a good question, clear, with 
self-contained example and so on. Moreover, not everybody speaks 
English natively. I don't mean that you must help, even when the 
question is really vague and not clear and whatever. I'm just saying 
that if you don't want to help (whatever the reason), you don't have 
to say it badly. But in any cases, the mailing list is still really 
helpful. As someone noted (sorry I erased the email so I don't 
remember who), it might be a good idea to split it.

Hi everyone,

My 2ct about the mailing list :). I understand that beginners have a 
hard time formulating a good question. But the problem is that we can't 
answer the question when it is unclear. So either I:


- Don't bother answering
- Try do discuss with the author of the question, taking lots of time to 
find out what exactly is the question.

- Send a read the posting guide answer

I mostly do the first, as I have to get things done during my PhD :). So 
this leaves us with kind of a problem, the person mailing the list 
doesn't have the knowledge to ask the right question, the list can't 
answer properly and consequently, the person mailing the list still 
doesn't get the information he/she needs. We could start an R-beginner 
mailing list, but this would also suffer from this problem. What do you 
guys think?


Maybe the mailing list is not the right medium for really basic stuff. 
For that I would recommend a good R-book or (better) a course in R or 
(even better) some colleagues who work with R that you can ask questions to.


cheers,
Paul


Hope that's what you wanted
Ivan


Le 2/26/2010 08:39, Dieter Menne a écrit :


Patrick Burns wrote:
  

* What were your biggest misconceptions or
stumbling blocks to getting up and running
with R?


 

(This derives partly from teaching)

The fact that this xapply-stuff was not idempotent (worse: not 
always) and

that you need a monster like do.call() to straighten this out. Nowadays,
plyr comes close.

The concept of environment. With S it was worse, though.

That you cannot change values passed by reference. I noted that the 
latter

is no problem for students who have not worked with c(++/#) before. That
there is only one return-result in functions.

[ and the likes as an operator.

10 years ago, when I started, the message was: S4 is the future, S3 is
legacy. So I learned S4. Only to never use is in self-written code 
later.

Might be different for BioConductor people.

That sometimes you can use vectors not in data= (lattice), and 
sometimes not

(ggplot2). Still a VERY confusing inconsistency.

The why-does-this-not-print FAQ.

Why does par(oma..) not work with lattice?

Dieter





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

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



--
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 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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


Re: [R] Adjust lattice graph axis label on final page

2010-02-26 Thread Sebastien Bihorel

Thanks Deepayan,

This confirms what I thought I should do... One follow-up question about 
your suggested code: is it possible to create a lattice graph object 
myplot and modify the layout just for panel 7 and 8, rather than 
creating two graphs with different layouts?


Sebastien

Deepayan Sarkar wrote:

On Thu, Feb 25, 2010 at 3:45 AM, Sebastien Bihorel
sebastien.biho...@cognigencorp.com wrote:
  

Dear R-users,

I was wondering if there was a way to adjust the placement of the axis
titles for the last page of a multi-page lattice plot (see example below).
Depending on the total number of panels, the placement of these titles might
look strange on the last page, if the layout is not adjusted (e.g. in some
template code).



It's not possible to adjust the labels on a per-page basis.

It _is_ possible to have the two plots fill up the last page, but that
may not be what you want.

xyplot(y~x|id,as.table=T,data=mydata,layout=c(2,3))[1:6]
xyplot(y~x|id,as.table=T,data=mydata,layout=c(2,1))[7:8]

-Deepayan



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


Re: [R] R and Wordpress

2010-02-26 Thread D Kelly O'Day

I use Wordpress.com (free public version) and add my R scripts by using
simple html pre ... / wrap around my script.

Here's an example post with R Script.

http://chartsgraphs.wordpress.com/2009/02/05/r-script-to-automatically-chart-web-based-global-temperature-data/
link 

D Kelly O'Day
http://chartsgraphs.wordpress.com


-- 
View this message in context: 
http://n4.nabble.com/R-and-Wordpress-tp1568499p1570653.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] t-distribution values

2010-02-26 Thread Антон Морковин

   Dear all,


   how to calculate  values of t-distribution for given values of d.f. using R
   functions?




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

2010-02-26 Thread Prof. John C Nash
Besides the suggestions made by others, you may want to look at the R-wiki, where there is 
a section on installing rattle and its dependencies, but mostly for Linux distros. Rattle 
involves lots of other tools, which makes it challenging to install.  You could do the 
community a service by adding a section on Windows installs. And someone with Mac 
experience might do likewise. The wiki offers a chance -- but not a guarantee -- that 
information that appears over several posts here can be consolidated.


JN






Message: 1
Date: Thu, 25 Feb 2010 03:06:40 -0800 (PST)
From: chinna durgache...@gmail.com
To: r-help@r-project.org
Subject: [R] how to install rattle for data mining
Message-ID: 1267096000783-1568841.p...@n4.nabble.com
Content-Type: text/plain; charset=us-ascii


 library(rattle)
Loading required package: pmml
Loading required package: XML
Error: package 'XML' could not be loaded
In addition: Warning message:
In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc =
lib.loc) :
  there is no package called 'XML'



i have installed glade package 


install.packages(RGtk2)
 install.packages(rattle)


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


Re: [R] t-distribution values

2010-02-26 Thread Randall Wrong
Hi !

I would try pt for the probability distribution function.

?pt

pt(q=-2, df=5)


2010/2/26 áÎÔÏÎ íÏÒËÏ×ÉÎ a-morko...@yandex.ru


   Dear all,


   how to calculate  values of t-distribution for given values of d.f. using
 R
   functions?




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


[[alternative HTML version deleted]]

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


Re: [R] two questions for R beginners

2010-02-26 Thread Ivan Calandra
You are definitely right...
What to do with bad beginner's questions is not a simple issue.

If a beginner's mailing list is created, who will answer to such 
questions? And moreover, the beginners won't take advantage of the other 
questions (I've personally learned a lot trying to understand the 
questions and answers to other's problems). And also, as you said, the 
problems might persist.
The beginner's mailing list might be good in one aspect though: the 
experts who subscribe to it would be willing to help the beginners to 
get started with R, knowing that the questions might not be clearly stated.

As you pointed out, the mailing list is not the best for basic stuff 
(the question is of course what is basic?). Not everybody knows some 
colleagues who work with R (I'm personally the 1st one to use R in my lab).
I think, somehow and I have no idea how, documentation and guidance to 
search for help should be more accessible as soon as you start with R. 
Maybe a _*clear*_ section on the R homepage or in the introduction to 
R manual like where to find help, including all of the most common 
and useful resources available (from ? and RSiteSearch() to R Wiki and 
Crantastic).

I hope that this whole discussion might help to make the R world better.
Thank you Patrick for initiating it!
Regards,
Ivan

Le 2/26/2010 15:09, Paul Hiemstra a écrit :
 Ivan Calandra wrote:
 Since you want input from beginners, here are some thoughts

 I had and still have two big problems with R:
 - this vectorization thing. I've read many manuals (including R 
 inferno), but I'm still not completely clear about it. In simple 
 examples, it's fine. But when it gets a bit more complex, then...
 Related to it, the *apply functions are still a bit difficult to 
 understand. When I have to use them, I just try one and see what 
 happens. I don't understand them well enough to know which one I need.
 - the second problem is where to find the functions/packages I need. 
 There are many options, and that's actually the problem. R Wiki, 
 Rseek, RSiteSearch, Crantastic, etc... When you start with R, you 
 discover that the capabilities of R are almost unlimited and you 
 don't really know where to start, where to find what you need.

 As noted in earlier posts, the mailing list is really great, but some 
 people are really hard with beginners. It was noted in a discussion a 
 few days ago, but it looks like some don't realize how difficult it 
 is at the beginning to formulate a good question, clear, with 
 self-contained example and so on. Moreover, not everybody speaks 
 English natively. I don't mean that you must help, even when the 
 question is really vague and not clear and whatever. I'm just saying 
 that if you don't want to help (whatever the reason), you don't have 
 to say it badly. But in any cases, the mailing list is still really 
 helpful. As someone noted (sorry I erased the email so I don't 
 remember who), it might be a good idea to split it.
 Hi everyone,

 My 2ct about the mailing list :). I understand that beginners have a 
 hard time formulating a good question. But the problem is that we 
 can't answer the question when it is unclear. So either I:

 - Don't bother answering
 - Try do discuss with the author of the question, taking lots of time 
 to find out what exactly is the question.
 - Send a read the posting guide answer

 I mostly do the first, as I have to get things done during my PhD :). 
 So this leaves us with kind of a problem, the person mailing the list 
 doesn't have the knowledge to ask the right question, the list can't 
 answer properly and consequently, the person mailing the list still 
 doesn't get the information he/she needs. We could start an R-beginner 
 mailing list, but this would also suffer from this problem. What do 
 you guys think?

 Maybe the mailing list is not the right medium for really basic stuff. 
 For that I would recommend a good R-book or (better) a course in R or 
 (even better) some colleagues who work with R that you can ask 
 questions to.

 cheers,
 Paul

 Hope that's what you wanted
 Ivan


 Le 2/26/2010 08:39, Dieter Menne a écrit :

 Patrick Burns wrote:
 * What were your biggest misconceptions or
 stumbling blocks to getting up and running
 with R?


 (This derives partly from teaching)

 The fact that this xapply-stuff was not idempotent (worse: not 
 always) and
 that you need a monster like do.call() to straighten this out. 
 Nowadays,
 plyr comes close.

 The concept of environment. With S it was worse, though.

 That you cannot change values passed by reference. I noted that 
 the latter
 is no problem for students who have not worked with c(++/#) before. 
 That
 there is only one return-result in functions.

 [ and the likes as an operator.

 10 years ago, when I started, the message was: S4 is the future, S3 is
 legacy. So I learned S4. Only to never use is in self-written code 
 later.
 Might be different for BioConductor people.

 That sometimes you can 

Re: [R] Loop overwrite and data output problems

2010-02-26 Thread Ivan Calandra

Hi,
Since I'm not an expert, I still have problems understanding when it's 
not my own work, but I have something that might help you.


if (I==1) Sample.dat-tmp[sample(1:max,1),] else {
Sample.dat-rbind(Sample.dat,tmp[sample(1:max,1),])

This part might not be the best.
I would do something like:
Sample.dat[[I]] - tmp[sample(1:max, 1),]

That way, you will store your line in the Ith element of the list 
Sample.dat. 5you might have to define it first like: Sample.dat - 
list() )

You can then convert it to a matrix using: do.call(rbind, Sample.dat)

It might get you started

HTH,
Ivan


Le 2/26/2010 14:31, RCulloch a écrit :

Hello R users,

I have been using R for a while now for basic stats but I'm now trying to
get my head around looping scripts and in some places I am failing!

I have a data set with c. 1200 data points on 98 individual animals with
data on each row representing a daily measure and I am asking the question
what variables affect the animal's behaviour?

the dataset includes these variables for analyses:

presence of behaviour, absence of behaviour, site, year, rain, air temp, ID,
Day

Listed below as they appear in the data set:

BEH_T, BEH_F, SITE, YEAR, PRECIP_MM_DAY,  PUP_AGE_EST, MO_AIR_TEMP,  ID2,
DAY

with BEH_T  BEH_F = the response variable for a binomial GLM

here is the head of the dataset
(NB there are only two years and two sites)

  BEH_T BEH_F SITE YEAR PRECIP_MM_DAY PUP_AGE_EST MO_AIR_TEMP ID2 DAY
[1,]14101 2007 0  1210.98750   1   1
[2,]37231 2007 0  1311.47333   1   2
[3,]56221 2007 0  1412.16667   1   3
[4,]43231 2007 0  1610.91515   1   5
[5,]62161 2007 0  1712.81026   1   6
[6,]30201 2007 0  19 8.67037   1   8

(Sorry the headings are skewed)

Because I don't want to do too complex a model to start with (just wanting
to learn first with a 'simple' model) I have issues with independence of the
data as there are repeats of individuals - i.e. data taken on the same IDs
on different days. So in order to account for that I have decided to random
sample one data point for each ID then run the GLM on that data for x number
of simulations to see if the explanatory variables are the same/similar
across all models. (This will reduce my data set to 98 data points, but it
is the best way I can see of doing this without doing mixed-effects models,
since not all IDs are seen at both sites in both years).

I am also using the MuMIn package for running all subsets of your model


the code I'm using is:


for (S in 1:2){
Sample.dat-ALL.R[1,]
for (I in 1:98) {
tmp-ALL.R[ALL.R$ID2==I,]
max-dim(tmp)[1]
if (I==1) Sample.dat-tmp[sample(1:max,1),] else {
Sample.dat-rbind(Sample.dat,tmp[sample(1:max,1),])
m1.R-glm(cbind(Sample.dat$BEH_T, Sample.dat$BEH_F) ~ 
Sample.dat$SITE +
Sample.dat$YEAR + Sample.dat$PRECIP_MM_DAY + Sample.dat$PUP_AGE_EST +
Sample.dat$MO_AIR_TEMP, family=binomial)
mod-dredge(m1.R)}}}

At this point I have two issues if I do it manually then it seems to work
i.e. gives me one output (e.g shown at bottom of post) where I then want to
take the first line, the model with the best AIC using mod[1,] - no problem!

However, letting the code run and for example using print ((mod[1,])) at the
end it prints out the first line of 98 outputs - so I'm not too sure what
I've done wrong here, but it appears to be running a model for each ID -
something basic no doubt!

Ideally, what I want to do is take a random sample of the data then run the
model get one output for that take the top line (i.e. the best AIC) and save
this, then run this routine say 100 times, saving that top line every time,
then having a look at the results and take a model average. Anytime I've got
close to this I have issues with overwriting the previous first line of the
model selection and I can't seem to identify how to set this loop up
properly.

Any advice or guidance would be most appreciated, I have tried to explain my
issues clearly but if more info is required please just ask,

Many thanks in advance to those of you that took the time to read this!

Ross

Ross Culloch
Ph.D. Student
Durham University
UK







Here is an example of the model selection table from usingMuMIn:


Model selection table
  (Intr)  S.$MO_ S.$PRE   S.$PUP S.$SIT  S.$YEA k  Dev.   AIC  AICc
delta weight
30 645.8000 0.03841-0.02148 0.2882 -0.3212 5 304.0 687.1 687.7
0.000  0.707
32 648.8000 0.03811  0.0009399 -0.02172 0.2857 -0.3227 6 304.0 689.0 690.0
2.249  0.230
26 785.1000-0.02543 0.4678 -0.3905 4 312.8 693.9 694.3
6.630  0.026
31 794.2000  0.0037260 -0.02627 0.4519 -0.3950 5 312.5 695.5 696.2
8.493  0.010
22 582.7000 0.04703 0.2641 -0.2899 4 314.7 

[R] counting the number of ones in a vector

2010-02-26 Thread Randall Wrong
Dear R users,

I want to count the number of ones in a vector x.

That's what I did : length( x[x==1] )

Is that a good solution ?
Thank you very much,
Randall

[[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] Odp: two questions for R beginners

2010-02-26 Thread Dieter Menne


Petr Pikal wrote:
 
 For the time being I would say that reshape and factor ordering especially 
 with groupedData objects from nlme are still giving me a headache and many 
 trials and errors to get desired result. 
 
 For documents in the beginning I would vote for Paul Johnsons Rtips. About 
 10 yars ago it was nice collection of several useful Howto's.
 
 

Add me for reshape (the base one); the only printed documentation on my
desk. Hadley's Reshape package has tried hard, but was not successful as
plyr.

Factor ordering: yes, definitively, and the risks involved in reordering.
Not, however, groupedData: I was lucky enough to find out rather early that
this was the most confusing feature in nlme, and not required. So my student
script for nlme starts: whenever you read about groupedData, try to forget
it and look for a different example. There is no groupedData in lme4.

And a ++ for Rtips. I never understand, however, why this was possible,
because I know of similar attempts that were blocked because people
complained that permission was required  for quotes. The early days...

Dieter





-- 
View this message in context: 
http://n4.nabble.com/two-questions-for-R-beginners-tp1569384p1570701.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] Odp: Loop overwrite and data output problems

2010-02-26 Thread Petr PIKAL
Hi

I am bit confused what you want to achieve. As I can not reproduce code 
without your data I just guess.

If I understand you want to select from all your data randomly 98 values 
for 98 animals (one for each animal). I presume your id2 is sorted.

One option

# make sorted ids

id2-sample(1:5, 100, replace=T)
id2-sort(id2)

# how many unique ids
len-rle(id2)$lengths
# how many values are from beginning

shift.len-c(0,cumsum(len))[-(length(len)+1)]

# get one value from each id
samp-sapply(sapply(split(id2, id2), function(x) 1:length(x)), sample, 1)

# just test
id2[samp+shift.len]
[1] 1 2 3 4 5

The other option is randomise vector of indices
ss-sample(1:100)

sort data.frame according those randomised indices and select let say 
first one

sapply(split(daf[ss,], daf[ss,1]), function(x) x[1,])

But i believe that there are even better options.

Regards
Petr


 

r-help-boun...@r-project.org napsal dne 26.02.2010 14:31:06:

 
 Hello R users,
 
 I have been using R for a while now for basic stats but I'm now trying 
to
 get my head around looping scripts and in some places I am failing! 
 
 I have a data set with c. 1200 data points on 98 individual animals with
 data on each row representing a daily measure and I am asking the 
question
 what variables affect the animal's behaviour?
 
 the dataset includes these variables for analyses:
 
 presence of behaviour, absence of behaviour, site, year, rain, air temp, 
ID,
 Day
 
 Listed below as they appear in the data set:
 
 BEH_T, BEH_F, SITE, YEAR, PRECIP_MM_DAY,  PUP_AGE_EST, MO_AIR_TEMP, ID2,
 DAY
 
 with BEH_T  BEH_F = the response variable for a binomial GLM
 
 here is the head of the dataset 
 (NB there are only two years and two sites)
 
  BEH_T BEH_F SITE YEAR PRECIP_MM_DAY PUP_AGE_EST MO_AIR_TEMP ID2 DAY
 [1,]14101 2007 0  1210.98750   1   1
 [2,]37231 2007 0  1311.47333   1   2
 [3,]56221 2007 0  1412.16667   1   3
 [4,]43231 2007 0  1610.91515   1   5
 [5,]62161 2007 0  1712.81026   1   6
 [6,]30201 2007 0  19 8.67037   1   8
 
 (Sorry the headings are skewed)
 
 Because I don't want to do too complex a model to start with (just 
wanting
 to learn first with a 'simple' model) I have issues with independence of 
the
 data as there are repeats of individuals - i.e. data taken on the same 
IDs
 on different days. So in order to account for that I have decided to 
random
 sample one data point for each ID then run the GLM on that data for x 
number
 of simulations to see if the explanatory variables are the same/similar
 across all models. (This will reduce my data set to 98 data points, but 
it
 is the best way I can see of doing this without doing mixed-effects 
models,
 since not all IDs are seen at both sites in both years).
 
 I am also using the MuMIn package for running all subsets of your model
 
 
 the code I'm using is:
 
 
 for (S in 1:2){
Sample.dat-ALL.R[1,]
for (I in 1:98)   {
   tmp-ALL.R[ALL.R$ID2==I,]
   max-dim(tmp)[1]
   if (I==1) Sample.dat-tmp[sample(1:max,1),] else {
 Sample.dat-rbind(Sample.dat,tmp[sample(1:max,1),])
   m1.R-glm(cbind(Sample.dat$BEH_T, Sample.dat$BEH_F) ~ 
Sample.dat$SITE +
 Sample.dat$YEAR + Sample.dat$PRECIP_MM_DAY + Sample.dat$PUP_AGE_EST +
 Sample.dat$MO_AIR_TEMP, family=binomial) 
mod-dredge(m1.R)}}}
 
 At this point I have two issues if I do it manually then it seems to 
work
 i.e. gives me one output (e.g shown at bottom of post) where I then want 
to
 take the first line, the model with the best AIC using mod[1,] - no 
problem!
 
 However, letting the code run and for example using print ((mod[1,])) at 
the
 end it prints out the first line of 98 outputs - so I'm not too sure 
what
 I've done wrong here, but it appears to be running a model for each ID -
 something basic no doubt!
 
 Ideally, what I want to do is take a random sample of the data then run 
the
 model get one output for that take the top line (i.e. the best AIC) and 
save
 this, then run this routine say 100 times, saving that top line every 
time,
 then having a look at the results and take a model average. Anytime I've 
got
 close to this I have issues with overwriting the previous first line of 
the
 model selection and I can't seem to identify how to set this loop up
 properly.
 
 Any advice or guidance would be most appreciated, I have tried to 
explain my
 issues clearly but if more info is required please just ask,
 
 Many thanks in advance to those of you that took the time to read this!
 
 Ross
 
 Ross Culloch
 Ph.D. Student
 Durham University
 UK
 
 
 
 
 
 
 
 Here is an example of the model selection table from usingMuMIn:
 
 
 Model selection table 
  (Intr)  S.$MO_ S.$PRE   S.$PUP S.$SIT  S.$YEA k  Dev.   AIC 
AICc 
 delta weight
 30 645.8000 0.03841-0.02148 

Re: [R] two questions for R beginners

2010-02-26 Thread Allen S. Rout
Ivan Calandra ivan.calan...@uni-hamburg.de writes:

 Related to it, the *apply functions are still a bit difficult to
 understand. When I have to use them, I just try one and see what
 happens. I don't understand them well enough to know which one I
 need.


Ditto.  I have ended up with a small collection of black magic
invocations copied from other folks' code, designed to do things like

I wrote a function to read a file and generate a data frame.  Now I
want to iterate (vectorize) this over many files, and get a much
larger data frame.


This may be one specific case of the larger challenge of transforming
R data structures.  A somewhat pedantic set of recipes might usefully
be evolved on e.g. the wiki.



- Allen S. Rout

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


Re: [R] counting the number of ones in a vector

2010-02-26 Thread Nutter, Benjamin
What you did works well.  You could also try the following.

table(x)[1]



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Randall Wrong
Sent: Friday, February 26, 2010 9:41 AM
To: r-help@r-project.org
Subject: [R] counting the number of ones in a vector

Dear R users,

I want to count the number of ones in a vector x.

That's what I did : length( x[x==1] )

Is that a good solution ?
Thank you very much,
Randall

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


===

P Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S.News  World Report (2009).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use\...{{dropped:13}}

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


[R] counting the number of ones in a vector

2010-02-26 Thread Randall Wrong
 Dear R users,

I want to count the number of ones in a vector x.

That's what I did : length( x[x==1] )

Is that a good solution ?

Thank you very much,
Randall

[[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] counting the number of ones in a vector

2010-02-26 Thread Henrique Dallazuanna
Try:

sum(x == 1)

On Fri, Feb 26, 2010 at 11:40 AM, Randall Wrong randall.wr...@gmail.com wrote:
 Dear R users,

 I want to count the number of ones in a vector x.

 That's what I did : length( x[x==1] )

 Is that a good solution ?
 Thank you very much,
 Randall

        [[alternative HTML version deleted]]

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


Re: [R] counting the number of ones in a vector

2010-02-26 Thread Tobias Verbeke

Nutter, Benjamin wrote:

What you did works well.  You could also try the following.

table(x)[1]


or

sum(x==1)

HTH,
Tobias


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Randall Wrong
Sent: Friday, February 26, 2010 9:41 AM
To: r-help@r-project.org
Subject: [R] counting the number of ones in a vector

Dear R users,

I want to count the number of ones in a vector x.

That's what I did : length( x[x==1] )

Is that a good solution ?
Thank you very much,
Randall

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


===

P Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S.News  World Report (2009).  
Visit us online at http://www.clevelandclinic.org for

a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use\...{{dropped:13}}

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




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


Re: [R] locfit: max number of predictors = 6? How interpolate in 5-10D?

2010-02-26 Thread Keith Jewell
Thanks for that suggestion

I've investigated a little more using...
y - rowSums(x) + runif(n)
... just so I had some correlation to play with.

The error I get when it fails is Invalid what in exvval, which I don't 
understand either!
With n=5e3 it worked with 6 variables but not with 7.

I wasn't sure the error was caused by number of variables rather than 
something else, so I tried with...
n - 100

I also tried locfit rather than locfit.raw using...
xd - lapply(1:10, function(x) runif(n))
xd - as.data.frame(xd)
names(xd) - paste(x, 1:10, sep=)
y=rowSums(xd)
xd$y - y
aF - formula(paste(y ~ lp(,paste(names(xd)[1:6], collapse=,), )))
locfit(aF, xd)

Both of these gave the same results, success with 6 variables but not with 
7.

IT APPEARS, the maximum number of predictors is 6, but I don't know locfit 
well, and it may be that other settings would allow more variables.
CAN anyone give a more DEFINITIVE ANSWER?

My current data sets currently reach 5 predictors, and I expect this it 
increase.
 In S-Plus (v6.2.1) I used loess in which Locally quadratic models may have 
at most 4 predictor variables; locally linear models may have at most 15. 
In R stats::loess allows only one to four numeric predictors.
I'd assumed (foolishly) that because locfit didn't mention limits, the only 
limits were practical (memory, time,...) - it seems not :-(
I guess I could write something myself, I only need rough interpolation, 
even straight line interpolation between nearest neighbours would be OK. 
But at first glance it seems non-trivial with a substantial non-fixed number 
of dimensions (nnclust::nnfind to identify neighbours??), and I don't want 
to re-invent wheels.
Can anyone suggest an ALTERNATIVE route for INTERPOLATION in 5-10 
DIMENSIONS?

Best...
(apologies for capitals, not shouting, just highlighting key points for 
those skimming quickly)

Keith Jewell

Liaw, Andy andy_l...@merck.com wrote in message 
news:b10baa7d28d88b45af82813c4a6ffa934ce...@usctmx1157.merck.com...
 Well, I should think there's an obvious (if not elegant) way to test it:

 n - 5e3
 m - 20
 x - matrix(runif(n * m), nrow=n)
 y - rnorm(n)

 require(locfit)
 fit - locfit.raw(x[, 1:10], y)

 The code above took a while on my laptop, and ended up giving some error
 I don't understand.  Not sure if the error was caused by insufficient
 sample size, or some inherent limitation.  At least it didn't choke on
 five variables.  However, if all 20 columns of x is used, locfit.raw()
 will choke because it can't compute the dimension of some variable that
 it needs to allocate memory for.

 I had vague recollection of reading that 5 is the limit somewhere.
 Unfortunately my copy of Local Regression and Likelihood has been MIA
 for a few years, so I can't check there.  In any case it doesn't seem
 like the number of data points and/or computing power are bigger issue.

 Andy

 -Original Message-
 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On Behalf Of Keith Jewell
 Sent: Thursday, February 25, 2010 4:11 AM
 To: r-h...@stat.math.ethz.ch
 Subject: [R] locfit: max number of predictors?

 Hi All,

 In another thread Andy Liaw, who CRAN lists as locfit
 maintainer; said:
 quote
 From: Liaw, Andy andy_l...@merck.com
 To: Guy Green guygr...@netvigator.com; r-help@r-project.org
 Subject: Re: Alternatives to linear regression with multiple variables
 Date: 22 February 2010 17:50

 You can try the locfit package, which I believe can handle up to 5
 variables.  E.g.,
 /quote

 Looking in the locfit documentation (e.g.
 http://www.stats.bris.ac.uk/R/web/packages/locfit/locfit.pdf)
 I can't see an
 upper limit on the number of predictors; if it is 5 I'm
 getting close in one
 of my applications.

 Can anyone confirm or deny the existence of a 'crisp' upper
 limit on the
 number of predictors in locfit?

 If it is 5, or thereabouts, can anyone suggest an alternative
 which can
 handle a few more? (I'm using it for multidimensional interpolation).

 Best regards,

 Keith Jewell

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

 Notice:  This e-mail message, together with any attachme...{{dropped:10}}


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


Re: [R] counting the number of ones in a vector

2010-02-26 Thread Jorge Ivan Velez
Hi Randall,

Try also

sum( x==1 )

HTH,
Jorge


On Fri, Feb 26, 2010 at 9:40 AM, Randall Wrong  wrote:

 Dear R users,

 I want to count the number of ones in a vector x.

 That's what I did : length( x[x==1] )

 Is that a good solution ?
 Thank you very much,
 Randall

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] counting the number of ones in a vector

2010-02-26 Thread Jorge Ivan Velez
Hi Randall,

Try also

sum( x==1 )

HTH,
Jorge


On Fri, Feb 26, 2010 at 9:40 AM, Randall Wrong  wrote:

 Dear R users,

 I want to count the number of ones in a vector x.

 That's what I did : length( x[x==1] )

 Is that a good solution ?
 Thank you very much,
 Randall

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] two questions for R beginners

2010-02-26 Thread Robert Baer
Honestly what I remember as the most difficult thing when I 'first'
started using R was figuring out how to read in my own datasets.  I
eventually discovered the R import/export manual, but somehow this alluded
me initially.  All the R tutorials I was working from simply generated
data or used the built in datasets, and I was ready to work on my own
datasets.

The things that led from frustration to independence was understanding
the difference between data types like matrix and dataframe and learning
there were commands to tell what you were working with at any given time.
Did the data read in as character, numeric, or factor, etc.  Commands
like: str, class, mode, ls, search, help, help.search, etc can help you
figure out what you are doing.

Rob




-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Patrick Burns
Sent: Thursday, February 25, 2010 11:31 AM
To: r-help@r-project.org
Subject: [R] two questions for R beginners

* What were your biggest misconceptions or
stumbling blocks to getting up and running
with R?

* What documents helped you the most in this
initial phase?

I especially want to hear from people who are
lazy and impatient.

Feel free to write to me off-list.  Definitely
write off-list if you are just confirming what
has been said on-list.

-- 
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'The R Inferno' and 'A Guide for the Unwilling S User')

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

2010-02-26 Thread David Hugh-Jones
Hi Thomas

Sorry to bug you again after 6 months! I just wondered if there is a
simple way to find the N after dropping groups with invariant outcomes
- I am reading coxph.object and the structure of the returned object,
but nothing jumps out at me.

With best wishes,
David Hugh-Jones


On 9 July 2009 14:37, Thomas Lumley tlum...@u.washington.edu wrote:
 On Wed, 8 Jul 2009, David Hugh-Jones wrote:

 Hello all

 I'm moving back and forth between stata and R at the moment - of course,
 using R whenever possible :-)

 I'm running conditional logits on some panel data and I get slightly
 different results and different N in the two programs.

 That's probably because you are using method=approximate in R.


 I understand why Stata is dropping the groups with all outcomes the
 same...
 this is inevitable in a conditional logit, right?

 Yes.

 Is R doing the same?

 Yes.

        -thomas


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


Re: [R] two questions for R beginners

2010-02-26 Thread Alain Guillet
I don't want to sound bad but the first thing beginners should do is to 
look at the manual An Introduction to R because most of the simple 
questions have their answers into it. In the same idea, before posting 
to this mailing list, people should (must?) follow the posting guide. 
Indeed it is written there to use some functions like help.search(), 
RSiteSearch() or to read An Introduction to R before posting. Too 
often I think how much I would like people to do their homeworks before 
posting.


I would like to add that I don't feel an R expert but I don't like to 
waste my time answering questions which have an answer you can find 
easily if you respect the posting guide.


Regards,
Alain


On 26-Feb-10 15:30, Ivan Calandra wrote:

You are definitely right...
What to do with bad beginner's questions is not a simple issue.

If a beginner's mailing list is created, who will answer to such
questions? And moreover, the beginners won't take advantage of the other
questions (I've personally learned a lot trying to understand the
questions and answers to other's problems). And also, as you said, the
problems might persist.
The beginner's mailing list might be good in one aspect though: the
experts who subscribe to it would be willing to help the beginners to
get started with R, knowing that the questions might not be clearly stated.

As you pointed out, the mailing list is not the best for basic stuff
(the question is of course what is basic?). Not everybody knows some
colleagues who work with R (I'm personally the 1st one to use R in my lab).
I think, somehow and I have no idea how, documentation and guidance to
search for help should be more accessible as soon as you start with R.
Maybe a _*clear*_ section on the R homepage or in the introduction to
R manual like where to find help, including all of the most common
and useful resources available (from ? and RSiteSearch() to R Wiki and
Crantastic).

I hope that this whole discussion might help to make the R world better.
Thank you Patrick for initiating it!
Regards,
Ivan

Le 2/26/2010 15:09, Paul Hiemstra a écrit :
   

Ivan Calandra wrote:
 

Since you want input from beginners, here are some thoughts

I had and still have two big problems with R:
- this vectorization thing. I've read many manuals (including R
inferno), but I'm still not completely clear about it. In simple
examples, it's fine. But when it gets a bit more complex, then...
Related to it, the *apply functions are still a bit difficult to
understand. When I have to use them, I just try one and see what
happens. I don't understand them well enough to know which one I need.
- the second problem is where to find the functions/packages I need.
There are many options, and that's actually the problem. R Wiki,
Rseek, RSiteSearch, Crantastic, etc... When you start with R, you
discover that the capabilities of R are almost unlimited and you
don't really know where to start, where to find what you need.

As noted in earlier posts, the mailing list is really great, but some
people are really hard with beginners. It was noted in a discussion a
few days ago, but it looks like some don't realize how difficult it
is at the beginning to formulate a good question, clear, with
self-contained example and so on. Moreover, not everybody speaks
English natively. I don't mean that you must help, even when the
question is really vague and not clear and whatever. I'm just saying
that if you don't want to help (whatever the reason), you don't have
to say it badly. But in any cases, the mailing list is still really
helpful. As someone noted (sorry I erased the email so I don't
remember who), it might be a good idea to split it.
   

Hi everyone,

My 2ct about the mailing list :). I understand that beginners have a
hard time formulating a good question. But the problem is that we
can't answer the question when it is unclear. So either I:

- Don't bother answering
- Try do discuss with the author of the question, taking lots of time
to find out what exactly is the question.
- Send a read the posting guide answer

I mostly do the first, as I have to get things done during my PhD :).
So this leaves us with kind of a problem, the person mailing the list
doesn't have the knowledge to ask the right question, the list can't
answer properly and consequently, the person mailing the list still
doesn't get the information he/she needs. We could start an R-beginner
mailing list, but this would also suffer from this problem. What do
you guys think?

Maybe the mailing list is not the right medium for really basic stuff.
For that I would recommend a good R-book or (better) a course in R or
(even better) some colleagues who work with R that you can ask
questions to.

cheers,
Paul
 

Hope that's what you wanted
Ivan


Le 2/26/2010 08:39, Dieter Menne a écrit :
   

Patrick Burns wrote:
 

* What were your biggest misconceptions or
stumbling blocks to getting up and running
with R?


   

(This derives 

Re: [R] two questions for R beginners

2010-02-26 Thread Paul Hiemstra

Ivan Calandra wrote:

You are definitely right...
What to do with bad beginner's questions is not a simple issue.

If a beginner's mailing list is created, who will answer to such 
questions? And moreover, the beginners won't take advantage of the other 
questions (I've personally learned a lot trying to understand the 
questions and answers to other's problems). And also, as you said, the 
problems might persist.
The beginner's mailing list might be good in one aspect though: the 
experts who subscribe to it would be willing to help the beginners to 
get started with R, knowing that the questions might not be clearly stated.


As you pointed out, the mailing list is not the best for basic stuff 
(the question is of course what is basic?). Not everybody knows some 
colleagues who work with R (I'm personally the 1st one to use R in my lab).
I think, somehow and I have no idea how, documentation and guidance to 
search for help should be more accessible as soon as you start with R. 
Maybe a _*clear*_ section on the R homepage or in the introduction to 
R manual like where to find help, including all of the most common 
and useful resources available (from ? and RSiteSearch() to R Wiki and 
Crantastic).
  

Hi Ivan (and list),

I think the main problem is not as much that there isn't structure in 
the way R provides documentation / tutorials, but that people have a 
hard time finding the structure. There are task views for certain 
specific fields, but I think a lot of beginners do not know that they 
exist. There are separate mailing lists for specific fields, but I often 
see geographical (my field of expertise) oriented questions on R-help 
that would fit much better on R-sig-geo.


So I think a O my God, I've downloaded R and what now tutorial might 
be a good idea to put very close to the download button of R on CRAN. 
This tutorial would focus not on how to do things in R, but would 
provide guidance to the most obvious sources of information such as Task 
views, specific mailing lists, ways to search list archives, information 
for beginners how to write a good e-mail etc. I think for a lot of 
beginners it is not as much the answer to a specific question that they 
need, but more guidance how to look for answers themselves.


But at the end of the day, R is still not very easy to learn when coming 
from GUI oriented stats programs. In addition, to become reasonably 
fluent in R, you need spend at least a few hours a week on it. SO I 
think we can ease the pain for beginners, but not take away that it 
takes quite some time to become fluent in R.


cheers,
Paul

I hope that this whole discussion might help to make the R world better.
Thank you Patrick for initiating it!
Regards,
Ivan

Le 2/26/2010 15:09, Paul Hiemstra a écrit :
  

Ivan Calandra wrote:


Since you want input from beginners, here are some thoughts

I had and still have two big problems with R:
- this vectorization thing. I've read many manuals (including R 
inferno), but I'm still not completely clear about it. In simple 
examples, it's fine. But when it gets a bit more complex, then...
Related to it, the *apply functions are still a bit difficult to 
understand. When I have to use them, I just try one and see what 
happens. I don't understand them well enough to know which one I need.
- the second problem is where to find the functions/packages I need. 
There are many options, and that's actually the problem. R Wiki, 
Rseek, RSiteSearch, Crantastic, etc... When you start with R, you 
discover that the capabilities of R are almost unlimited and you 
don't really know where to start, where to find what you need.


As noted in earlier posts, the mailing list is really great, but some 
people are really hard with beginners. It was noted in a discussion a 
few days ago, but it looks like some don't realize how difficult it 
is at the beginning to formulate a good question, clear, with 
self-contained example and so on. Moreover, not everybody speaks 
English natively. I don't mean that you must help, even when the 
question is really vague and not clear and whatever. I'm just saying 
that if you don't want to help (whatever the reason), you don't have 
to say it badly. But in any cases, the mailing list is still really 
helpful. As someone noted (sorry I erased the email so I don't 
remember who), it might be a good idea to split it.
  

Hi everyone,

My 2ct about the mailing list :). I understand that beginners have a 
hard time formulating a good question. But the problem is that we 
can't answer the question when it is unclear. So either I:


- Don't bother answering
- Try do discuss with the author of the question, taking lots of time 
to find out what exactly is the question.

- Send a read the posting guide answer

I mostly do the first, as I have to get things done during my PhD :). 
So this leaves us with kind of a problem, the person mailing the list 
doesn't have the knowledge to ask the right question, the list can't 

[R] question to make a vector without loop

2010-02-26 Thread khazaei
Hello all,

I want to define a vector like w[k+1]=w[k]*a/(b+k) for k=1,...,N-1 without
use loop. Is it posible to do in R?

Regards

khazaei

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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: Compare Two dendrograms (Hierarchical Clusterings) ?

2010-02-26 Thread Ricardo Marcacini
Hi,

To compare two dendrogamas, you can use a measure of correlation between the
cophenetic matrices. Example:

mdist - dist(iris[,-5], method=euclidean)
# dendrogram from cluster 1 (single-linkage)
hc1 - hclust(mdist, method=single)
plot(hc1)

# dendrogram from cluster 2 (complete-linkage)
hc2 - hclust(mdist, method=complete)
plot(hc2)

# correlation
cor(cophenetic(hc1),cophenetic(hc2))

For a confidence level, use the Mantel Test from package vegan.

mantel(cophenetic(hc1), cophenetic(hc2))

Good Look.

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


Re: [R] Normal distribution (Lillie.test())

2010-02-26 Thread Bosken

Hi Greg,

I'm making NoiseGenerators with different noise sources and components, the
meaning of my tests with R is to know which NoiseGenerator approached most
the Normal distribution function...

Thanks, for all the reactions.

Bosken 


Greg Snow-2 wrote:
 
 
 Do your NoiseGenerotors need to generate exactly normal data (they don't,
 see SnowsPenultimateNormalityTest), or is there a level of close enough? 
 If I remember correctly, you were testing 2000 values, with that sample
 size most normality tests will find very small differences to be
 significantly different, even if those small differences are practically
 meaningless.
 
 -- 
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 greg.s...@imail.org
 801.408.8111
 
 
-- 
View this message in context: 
http://n4.nabble.com/Normal-distribution-Lillie-test-tp1565083p1570710.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] treemap grouping

2010-02-26 Thread evgeny55

Hi, 
Is there a way to create a treemap with more than 1 grouping.  I've seen a
lot of examples like this:
http://flowingdata.com/2010/02/11/an-easy-way-to-make-a-treemap/ but what if
some of my categories have sub-categories.  Is there an existing function
that can handle this 

thanks 
-- 
View this message in context: 
http://n4.nabble.com/treemap-grouping-tp1570721p1570721.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 calculate the Transitivity (Clustering coefficient) of a Directed graph?

2010-02-26 Thread Sara Khalatbari
Hi all

How can you use iGraph Transitivity function to get the Clustering
coefficient of a Directed graph?

Or how can you use iGraph  to get the Clustering coefficient of a Directed
graph?

Thanks,
Sara

[[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] pallet with open intervals

2010-02-26 Thread Julien Mullet

Hi,

I have a question concerning color pallets. I am currently plotting
geophysical fields with spplot (sp package) and I would like to create a
pallet with open boundaries. For instance, I have a field whose values vary
between -7 et 1, but a few values are much higher, for instance 28 or 32. As
a result, I would like to create a palette with, for instance, 8 intervals
within the range [-7,1] and two more colors for values lower than -7 or
higher than 1. Here is an example of such a pallet:
http://n4.nabble.com/file/n1570791/pallet.jpg 

Do you have any idea of how to create such a pallet?

Thanks,

Julien
-- 
View this message in context: 
http://n4.nabble.com/pallet-with-open-intervals-tp1570791p1570791.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] question to make a vector without loop

2010-02-26 Thread Joshua Wiley
Dear Khazaei,

What about this?

w - 1:10
N - length(w)
a - 1
b - 1
w[2:(N-1)] - w[2:(N-1)]*(a/(b+(2:(N-1
 w
 [1]  1.000  0.667  0.750  0.800  0.833  0.8571429
 [7]  0.875  0.889  0.900 10.000
Note that here I assumed a and b were constants 1 and 1, respectively.
It is no problem to substitute vectors in for them.  As long as a and b
are the same length or a multiple of k...N-1, you can substitute them
directly in the formula above and R will just keep using them until it is
done.

Hope that helps,


Josh


On Fri, Feb 26, 2010 at 7:23 AM, khaz...@ceremade.dauphine.fr wrote:

 Hello all,

 I want to define a vector like w[k+1]=w[k]*a/(b+k) for k=1,...,N-1 without
 use loop. Is it posible to do in R?

 Regards

 khazaei

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




-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

[[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 calculate the Transitivity (Clustering coefficient) of a Directed graph?

2010-02-26 Thread Sara Khalatbari
Hi all

How can you use iGraph Transitivity function to get the Clustering
coefficient of a Directed graph?

Or how can you use iGraph  to get the Clustering coefficient of a Directed
graph?

Thanks,
Sara

[[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] question to make a vector without loop

2010-02-26 Thread Uwe Ligges



On 26.02.2010 16:23, khaz...@ceremade.dauphine.fr wrote:

Hello all,

I want to define a vector like w[k+1]=w[k]*a/(b+k) for k=1,...,N-1 without
use loop. Is it posible to do in R?


Sure:


wMake - function(w, a, b, n){
w * (a^(0:(n-1))) / cumprod(c(1, (b+1):(b+n-1)))
}

wMake(w=1, a=2, b=3, n=10)

Uwe Ligges





Regards

khazaei

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

2010-02-26 Thread Ivan Calandra

Hi again Paul,


Hi Ivan (and list),

I think the main problem is not as much that there isn't structure in 
the way R provides documentation / tutorials, but that people have a 
hard time finding the structure. There are task views for certain 
specific fields, but I think a lot of beginners do not know that they 
exist. 


You're definitely right... what is it?! where to find them?

So I think a O my God, I've downloaded R and what now tutorial might 
be a good idea to put very close to the download button of R on CRAN. 
This tutorial would focus not on how to do things in R, but would 
provide guidance to the most obvious sources of information such as 
Task views, specific mailing lists, ways to search list archives, 
information for beginners how to write a good e-mail etc. I think for 
a lot of beginners it is not as much the answer to a specific question 
that they need, but more guidance how to look for answers themselves.


I think that would indeed help a lot. I can only agree with your last 
sentence. Is someone already working on this kind of manual? Is it 
planed? etc?



cheers,
Paul

Regards,
Ivan

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

2010-02-26 Thread Keith Jewell
Hi all,

I hit a small snag. Here is my workaround (copied verbatim from my aide 
memoire) in case it helps others. (or anyone knows a better way... ;-)

Best regards,

Keith Jewell.

The site library file is defined (in Renviron.site 
R_LIBS_SITE=//Server02/stats/R/library/%v) via a UNC name something like 
//Server02/stats/R/library/2.10.

As of now [Feb 2010, R version 2.10.1 (2009-12-14)] the menu Packages|Update 
Packages... [=update.packages(ask='graphics')] fails at the last step when 
it can't copy files to a directory named like that. It works if the site 
library is defined via a mapped drive like L:\\R\\library\\2.10, but we 
don't want to require all users to have this drive mapped. The workaround is 
thus:

In order to update packages:

a) have an appropriate mapped drive (e.g. Stats on 'server02')

b) start R-Gui from that mapped drive. This will give the site library via 
the UNC and the base library via the mapped drive thus:
 .libPaths()
[1] //Server02/stats/R/library/2.10 L:/R/R-Current/library

c) use .LibPaths(new= ) to add the drive mapped path to the beginning of the 
list
 .libPaths(new=choose.dir()) # navigate to folder on mapped drive
 .libPaths()
[1] L:\\R\\library\\2.10//Server02/stats/R/library/2.10 
L:/R/R-Current/library

update.packages(ask='graphics') will now work

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

2010-02-26 Thread Thomas Adams

Paul,

I think your point you need [to] spend at least a few hours a week on 
it is key. Since I am not doing statistics daily, more in fits  starts 
as my latest project -may- require, my approach has been more task 
oriented. A less-than-ideal approach. So, I think your suggestion is 
on-the-mark.


Tom


Paul Hiemstra wrote:

Ivan Calandra wrote:

You are definitely right...
What to do with bad beginner's questions is not a simple issue.

If a beginner's mailing list is created, who will answer to such 
questions? And moreover, the beginners won't take advantage of the 
other questions (I've personally learned a lot trying to understand 
the questions and answers to other's problems). And also, as you 
said, the problems might persist.
The beginner's mailing list might be good in one aspect though: the 
experts who subscribe to it would be willing to help the beginners 
to get started with R, knowing that the questions might not be 
clearly stated.


As you pointed out, the mailing list is not the best for basic stuff 
(the question is of course what is basic?). Not everybody knows 
some colleagues who work with R (I'm personally the 1st one to use R 
in my lab).
I think, somehow and I have no idea how, documentation and guidance 
to search for help should be more accessible as soon as you start 
with R. Maybe a _*clear*_ section on the R homepage or in the 
introduction to R manual like where to find help, including all 
of the most common and useful resources available (from ? and 
RSiteSearch() to R Wiki and Crantastic).
  

Hi Ivan (and list),

I think the main problem is not as much that there isn't structure in 
the way R provides documentation / tutorials, but that people have a 
hard time finding the structure. There are task views for certain 
specific fields, but I think a lot of beginners do not know that they 
exist. There are separate mailing lists for specific fields, but I 
often see geographical (my field of expertise) oriented questions on 
R-help that would fit much better on R-sig-geo.


So I think a O my God, I've downloaded R and what now tutorial might 
be a good idea to put very close to the download button of R on CRAN. 
This tutorial would focus not on how to do things in R, but would 
provide guidance to the most obvious sources of information such as 
Task views, specific mailing lists, ways to search list archives, 
information for beginners how to write a good e-mail etc. I think for 
a lot of beginners it is not as much the answer to a specific question 
that they need, but more guidance how to look for answers themselves.


But at the end of the day, R is still not very easy to learn when 
coming from GUI oriented stats programs. In addition, to become 
reasonably fluent in R, you need spend at least a few hours a week on 
it. SO I think we can ease the pain for beginners, but not take away 
that it takes quite some time to become fluent in R.


cheers,
Paul

I hope that this whole discussion might help to make the R world better.
Thank you Patrick for initiating it!
Regards,
Ivan

Le 2/26/2010 15:09, Paul Hiemstra a écrit :
 

Ivan Calandra wrote:
   

Since you want input from beginners, here are some thoughts

I had and still have two big problems with R:
- this vectorization thing. I've read many manuals (including R 
inferno), but I'm still not completely clear about it. In simple 
examples, it's fine. But when it gets a bit more complex, then...
Related to it, the *apply functions are still a bit difficult to 
understand. When I have to use them, I just try one and see what 
happens. I don't understand them well enough to know which one I need.
- the second problem is where to find the functions/packages I 
need. There are many options, and that's actually the problem. R 
Wiki, Rseek, RSiteSearch, Crantastic, etc... When you start with R, 
you discover that the capabilities of R are almost unlimited and 
you don't really know where to start, where to find what you need.


As noted in earlier posts, the mailing list is really great, but 
some people are really hard with beginners. It was noted in a 
discussion a few days ago, but it looks like some don't realize how 
difficult it is at the beginning to formulate a good question, 
clear, with self-contained example and so on. Moreover, not 
everybody speaks English natively. I don't mean that you must help, 
even when the question is really vague and not clear and whatever. 
I'm just saying that if you don't want to help (whatever the 
reason), you don't have to say it badly. But in any cases, the 
mailing list is still really helpful. As someone noted (sorry I 
erased the email so I don't remember who), it might be a good idea 
to split it.
  

Hi everyone,

My 2ct about the mailing list :). I understand that beginners have a 
hard time formulating a good question. But the problem is that we 
can't answer the question when it is unclear. So either I:


- Don't bother answering
- Try do discuss with the author of 

Re: [R] Defective help pages

2010-02-26 Thread Uwe Ligges



On 24.02.2010 21:34, Peter Danenberg wrote:

I'm trying to diagnose a bizarre problem in which the help files
invoked from R are partially defective. help(), for instance, is
missing the Description, Arguments and See Also sections; as are help
files for other commands (see below).


Peter, I just tried ?help with R-2.10.1 on 2 Windows and 2 Linux 
flavours. All of them had correct help pages. Looks like something is 
broken on your OS (unreported).


This seems to be plain text help, right?
Does the html version give the same result?

Best wishes,
Uwe





I've built 2.8.1, 2.10.1 and HEAD with the same results; do I need to
set an environment or configuration variable?

   help   package:utils   R Documentation

   Documentation

   Description:


   Usage:

help(topic, package = NULL, lib.loc = NULL,
 verbose = getOption(verbose),
 try.all.packages = getOption(help.try.all.packages),
 help_type = getOption(help_type))

   Arguments:











   Details:

The following types of help are available:

   * Plain text help






   Offline help:



   Note:



   References:

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
Language_.  Wadsworth  Brooks/Cole.

   See Also:



   Examples:

help()
help(help)  # the same

help(lapply)

help(for) # or ?for, but quotes/backticks are
needed

help(package=splines) # get help even when package is not
loaded

topi- women
help(topi)

try(help(bs, try.all.packages=FALSE)) # reports not found (an
error)
help(bs, try.all.packages=TRUE)   # reports can be found
# in package 'splines'

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


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


Re: [R] question to make a vector without loop

2010-02-26 Thread Linlin Yan
For general purpose of recursion formula, you could do it like this:
 make.vector - function(w, n, a, b) c(w, sapply(1:(n-1), function(x) w - w 
 * a / (b + x)))
 make.vector(w = 1, n = 4, a = 24, b = 1)
[1]   1  12  96 576

On Fri, Feb 26, 2010 at 11:23 PM,  khaz...@ceremade.dauphine.fr wrote:
 Hello all,

 I want to define a vector like w[k+1]=w[k]*a/(b+k) for k=1,...,N-1 without
 use loop. Is it posible to do in R?

 Regards

 khazaei

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

2010-02-26 Thread Dwayne Blind
Dear all,

Do you use a text editor ? What would you recommend for Windows users ? What
about Tinn-R ?

Thank you very much,
Dwayne

[[alternative HTML version deleted]]

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


[R] Problem accessing sub-methods of functions stored in a vector

2010-02-26 Thread Matt Asher

Hi folks,

I am having trouble accessing sub-functions when the main function is 
stored in an array. For example, the following test code works fine:


fcns = c(abs, sqrt)
fcns[[1]](-2)
fcns[[2]](2)

However, when I try to access sub-functions declared within list() in a 
function, this only works directly. When I try to access these within an 
array only the first declared sub-function is run. For example I have 
the function:


agent - function(id) {

# MANY VARIABLES DECLARED

 list( 
set_id = function(newid) {

id - newid
   },
  
   get_id = function(newid) {

   return(id)
   },

   # LOTS MORE SUB FUNCTIONS
   )
}

If I create a variable to hold this function, I can then access all the 
subfunctions without problem Example:


myAgent = agent(1)
myAgent$get_id() # Works fine

However, once this function is stored in a vector, I can no longer 
access the subfunctions.


agents = c(agent(1), agent(2))

agents[[1]] # This shows the set_id function only, unnamed

agents[[1]]$get_id() # Leads to error below:

Error in agents[[1]]$get_id : object of type 'closure' is not subsettable

How can I access these sub methods within the vector?

I am using R version 2.8.1

TIA for the help!

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


[R] biclust package

2010-02-26 Thread linda garcia
Dear all,
 I am using biclust package for biclustering. I wanted to
know how can I extract my clusters from the object?


library(biclust)
test - matrix(rnorm(5000), 100, 50)

test[11:20,11:20] - rnorm(100, 3, 0.1)

loma - binarize(test,2)

res - biclust(x=loma, method=BCBimax(), minr=4, minc=4, number=10)

res


Thanks for your help


-- 
Linda Garcia

[[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] ggplot2 : bug in coord_equal() ?

2010-02-26 Thread hadley wickham
Hi David,

That's the behaviour I'd expect - the plot is 5 x 13000.  What were
you expecting?

Hadley

On Fri, Feb 26, 2010 at 8:06 AM, David Hajage dhajag...@gmail.com wrote:
 Hello,

 I think there is a bug in coord_equal when x s a factor :

 ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar()
 ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar() + coord_equal(1/2)

 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.




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

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


Re: [R] question to make a vector without loop

2010-02-26 Thread William Dunlap

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of 
 khaz...@ceremade.dauphine.fr
 Sent: Friday, February 26, 2010 7:23 AM
 To: r-help@r-project.org
 Subject: [R] question to make a vector without loop
 
 Hello all,
 
 I want to define a vector like w[k+1]=w[k]*a/(b+k) for 
 k=1,...,N-1 without
 use loop. Is it posible to do in R?

It would be nice to see your loopy solution.
However, you could use cumprod (cumulative
products):
   c(w[1], w[1] * cumprod(a/(b+seq_len(N-1)))
E.g.,
w-7
a-2
b-1
for(k in 1:9) w[k+1] - w[k] * a / (b+k)
w
[1] 7.00 7.00 4.67 2.33 0.93
[6] 0.31 0.09 0.02 0.0049382716 0.0009876543
c(w[1], w[1]*cumprod(a/(b+seq_len(9
[1] 7.00 7.00 4.67 2.33 0.93
[6] 0.31 0.09 0.02 0.0049382716 0.0009876543

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 
 Regards
 
 khazaei
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] counting the number of ones in a vector

2010-02-26 Thread Nutter, Benjamin
But if x has any missing values:

 x - c(1, 1, 1, NA, NA, 2, 1, NA)
 
 sum( x == 1)
[1] NA
 
 sum(x==1, na.rm=TRUE)
[1] 4




-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Henrique Dallazuanna
Sent: Friday, February 26, 2010 9:47 AM
To: Randall Wrong
Cc: r-help@r-project.org
Subject: Re: [R] counting the number of ones in a vector

Try:

sum(x == 1)

On Fri, Feb 26, 2010 at 11:40 AM, Randall Wrong randall.wr...@gmail.com wrote:
 Dear R users,

 I want to count the number of ones in a vector x.

 That's what I did : length( x[x==1] )

 Is that a good solution ?
 Thank you very much,
 Randall

        [[alternative HTML version deleted]]

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




--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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


===

P Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S.News  World Report (2009).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use\...{{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] Legend's attribute

2010-02-26 Thread Uwe Ligges



On 26.02.2010 05:22, Yi Du wrote:

Hi there,


I use plot(type=o) to draw the line. And I need put some legend to this
line. But how can I let the legend to display the line type in the graph
generated from type=o? I can only find the lty in the legend. But I tried
several times and still failed.



Use both  pch=1, lty=1  as arguments.



Also, if I use abline(h=0.08) to draw a horizontal line and I also want to
show 0.08 in the y-axis, how can I do it?



See ?mtext

Uwe Ligges




Many thanks,


Yi



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


Re: [R] text editors

2010-02-26 Thread Erik Iverson

Dwayne Blind wrote:

Dear all,

Do you use a text editor ? What would you recommend for Windows users ? What
about Tinn-R ?



Dwayne,

Perhaps you have seen http://www.sciviews.org/_rgui/ , it has 
information on several possibilities.  It would be hard to pull me away 
from using Emacs with ESS (http://ess.r-project.org/), both on Windows 
and Linux.  I use Emacs for a lot of things now, but ESS was the gateway 
that helped me learn it.  The fact that there is always a version of 
Emacs on all the platforms I might be faced with helps a lot too.  I 
know nothing about Tinn-R, but my recollection is that people who use it 
seem to like it just fine.


Erik

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


Re: [R] Problem accessing sub-methods of functions stored in a vector

2010-02-26 Thread Uwe Ligges



On 26.02.2010 16:33, Matt Asher wrote:

Hi folks,

I am having trouble accessing sub-functions when the main function is
stored in an array. For example, the following test code works fine:

fcns = c(abs, sqrt)
fcns[[1]](-2)
fcns[[2]](2)

However, when I try to access sub-functions declared within list() in a
function, this only works directly. When I try to access these within an
array only the first declared sub-function is run. For example I have
the function:

agent - function(id) {

# MANY VARIABLES DECLARED

list( set_id = function(newid) {
id - newid
},
get_id = function(newid) {
return(id)
},

# LOTS MORE SUB FUNCTIONS
)
}

If I create a variable to hold this function, I can then access all the
subfunctions without problem Example:

myAgent = agent(1)
myAgent$get_id() # Works fine

However, once this function is stored in a vector, I can no longer
access the subfunctions.

agents = c(agent(1), agent(2))



agents is still a list (or in other words a vector of mode list), but 
since you c()'ed, it has one hierarchy level less than you expect.


In order to make your code below work, you rather need:

agents - list(agent(1), agent(2))

Anyway, I hope you know that lexical scoping will yield in the 
environments attached to all those functions they have been generated in 
and you know about possible consequences. If not, you really should not 
be doing this ... (nor using - ) ...




agents[[1]] # This shows the set_id function only, unnamed

agents[[1]]$get_id() # Leads to error below:

Error in agents[[1]]$get_id : object of type 'closure' is not subsettable

How can I access these sub methods within the vector?

I am using R version 2.8.1



... and upgrade to some recent version of R.


Uwe Ligges



TIA for the help!

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


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


Re: [R] Restructure some data

2010-02-26 Thread Doran, Harold
Thank you both for your replies; both are very useful. The larger issue at hand 
is that the data will actually be huge, thus the end result will be a very 
large, sparse data frame.

So, I decided to put all three possible solutions to a timing test and see what 
they yield. I simulated 15000 possible students and created an item pool of 300 
total items that could be selected. I fixed the number of total items each 
students sees to 3, although this will truly be on the order of 50 in the real 
world problem.

So, first the new data for testing all three solutions.

item.pool - paste(item, 1:300, sep = )
N - 15000
set.seed(54321)
dat - data.frame(id = c(1:N), first.item = sample(item.pool, N, replace=TRUE), 
second.item = sample(item.pool, N,replace=TRUE), third.item = 
sample(item.pool, N,replace=TRUE),
score1 = sample(c(0,1), N,replace=TRUE), score2 = sample(c(0,1), 
N,replace=TRUE), score3 = sample(c(0,1), N,replace=TRUE))

Now, my original loop is in the function 'harold', I created a new function 
bill and phil. I modified Bill's code only to reflect my original naming 
conventions. Timing results for each solution are below.

 system.time(result - harold(dat))
   user  system elapsed 
1347.85  441.92 1799.75

 system.time(result - bill(dat))
   user  system elapsed 
   0.040.040.09

 system.time(result - phil(dat))
   user  system elapsed 
   4.420.004.42

The loop timing is laughable; so it is out. Clearly, Phil wins from the golf 
viewpoint, but Bill's solution is quite fast. Phil, it is actually quite 
irrelevant that the original ordering of the columns is not preserved since 
that can be easily remedied in a post-hoc reordering of columns.

Again, thank you both.
Harold

harold - function(dat){
Nstu - nrow(dat)
df - matrix(NA, ncol = length(item.pool), nrow = Nstu)
colnames(df) - item.pool
for(i in 1:Nstu){
for(j in 2:4){
rr - which(dat[i,j] == colnames(df))
df[i,rr] - dat[i, (j+3)]
}
}
df
}
system.time(result - harold(dat))

bill - function(dat) {
L - length(item.pool)
items - as.matrix(dat[2:4])
scores - as.matrix(dat[, 5:7])
retval - matrix(NA_real_, nrow = nrow(dat), ncol = L,
dimnames = list(character(), item.pool))
retval[cbind(dat$id, match(items, item.pool))] - scores
retval
  }
system.time(result - bill(dat))

phil - function(dat){
df - tapply(as.vector(as.matrix(dat[5:7])),
list(rep(dat$id,3),as.vector(as.matrix(dat[2:4]))),I)
df
}
system.time(result - phil(dat))

-Original Message-
From: Phil Spector [mailto:spec...@stat.berkeley.edu] 
Sent: Thursday, February 25, 2010 5:38 PM
To: Doran, Harold
Cc: r-help@r-project.org
Subject: Re: [R] Restructure some data

Harold -
Here's what I came up with:

  tapply(as.vector(as.matrix(dat[5:7])),
+ list(rep(dat$id,3),as.vector(as.matrix(dat[2:4]))),I)
   item1 item10 item2 item3 item4 item5 item7 item9
1NA NA 1NANA 1NA 0
2 0 NANANANA 1 1NA
3 1 NA 0 1NANANANA
4NA NANA 1 0NA 0NA
5NA  1NA 0 1NANANA

I thought there would be a way to use xtabs, but I had
trouble preserving the NAs.

The columns aren't in the right order, and the item6 column is
missing, but it's pretty close.
Thanks for the easily reproducible example, and the interesting
puzzle.

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Thu, 25 Feb 2010, Doran, Harold wrote:

 Suppose I have a data frame like dat below. For some context, this is the 
 format that represents student's taking a computer adaptive test. first.item 
 is the first item that student was administered and then score.1 is the 
 student's response to that item and so forth.

 item.pool - paste(item, 1:10, sep = )
 set.seed(54321)
 dat - data.frame(id = c(1,2,3,4,5), first.item = sample(item.pool, 5, 
 replace=TRUE),
second.item = sample(item.pool, 5,replace=TRUE), third.item = 
 sample(item.pool, 5,replace=TRUE),
score1 = sample(c(0,1), 5,replace=TRUE), score2 = 
 sample(c(0,1), 5,replace=TRUE), score3 = sample(c(0,1), 5,replace=TRUE))

 I need to restructure this into a new format. The new matrix df (after the 
 loop) is exactly what I want in the end. But, I'm annoyed at myself for not 
 thinking of a more efficient way to restructure this without using a loop.

 df - matrix(NA, ncol = length(item.pool), nrow = nrow(dat))
 colnames(df) - unique(item.pool)

 for(i in 1:5){
for(j in 2:4){

Re: [R] Adjust lattice graph axis label on final page

2010-02-26 Thread Deepayan Sarkar
On Fri, Feb 26, 2010 at 6:14 AM, Sebastien Bihorel
sebastien.biho...@cognigencorp.com wrote:
 Thanks Deepayan,

 This confirms what I thought I should do... One follow-up question about
 your suggested code: is it possible to create a lattice graph object myplot
 and modify the layout just for panel 7 and 8, rather than creating two
 graphs with different layouts?

Sure:

p - xyplot(y~x|id,as.table=T,data=mydata)
update(p[1:6], layout = c(2, 3))
update(p[7:8], layout = c(2, 1))

-Deepayan


 Sebastien

 Deepayan Sarkar wrote:

 On Thu, Feb 25, 2010 at 3:45 AM, Sebastien Bihorel
 sebastien.biho...@cognigencorp.com wrote:


 Dear R-users,

 I was wondering if there was a way to adjust the placement of the axis
 titles for the last page of a multi-page lattice plot (see example
 below).
 Depending on the total number of panels, the placement of these titles
 might
 look strange on the last page, if the layout is not adjusted (e.g. in
 some
 template code).


 It's not possible to adjust the labels on a per-page basis.

 It _is_ possible to have the two plots fill up the last page, but that
 may not be what you want.

 xyplot(y~x|id,as.table=T,data=mydata,layout=c(2,3))[1:6]
 xyplot(y~x|id,as.table=T,data=mydata,layout=c(2,1))[7:8]

 -Deepayan



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] possible arrangements of across sample ties for runs test

2010-02-26 Thread Dale Steele
I'm trying to implement the two-sample Wald-Wolfowitz runs test.  Daniel
(1990) suggests a method to deal with ties across samples.  His suggestion
is to prepare ordered arrangements, one resulting in the fewest number of
runs, and one resulting in the largest number of runs.  Then take the mean
of these.  The code below counts 9 runs for my example data where '60' is
tied across samples.

X -  c(58, 62, 55, 60, 60, 67)
n1 - length(X)
Y - c(60, 59, 72, 73, 56, 53, 50, 50)
n2 - length(Y)
data - c(X, Y)
names(data) - c(rep(X, n1), rep(Y, n2))
data - sort(data)
runs - rle(names(data))
r - length(runs$lengths)
r

Y  Y  Y  X  Y  X  Y  X  X  Y  X  X  Y  Y
50 50 53 55 56 58 59 60 60 60 62 67 72 73 -- r = 9 runs

The other possible orderings are:

Y  Y  Y  X  Y  X  Y  X  Y  X  X  X  Y  Y  -- 9 runs
50 50 53 55 56 58 59 60 60 60 62 67 72 73

Y  Y  Y  X  Y  X  Y  Y  X  X  X  X  Y  Y  -- 7 runs
50 50 53 55 56 58 59 60 60 60 62 67 72 73

How to I generate the other possible orderings?  Thus, far, I've found a day
to identify cross sample duplicates...

# find the ties across samples
dd - data[duplicated(data)]  #find all duplicates
idd - dd  %in% X  dd  %in% Y #determine found in both X and Y
duplicates - dd[idd]

Thanks!  --Dale

[[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] question to make a vector without loop

2010-02-26 Thread Gabor Grothendieck
A general facility for this is Reduce:

f - function(w, k, a = 2, b = 1) w*a / (b+k)
c(7, Reduce(f, 2:9, 7, accumulate = TRUE))

the result of which is:
 c(7, Reduce(f, 2:9, 7, accumulate = TRUE))
 [1] 7.00 7.00 4.67 2.33 0.93
0.31 0.09 0.02 0.0049382716 0.0009876543


On Fri, Feb 26, 2010 at 10:23 AM,  khaz...@ceremade.dauphine.fr wrote:
 Hello all,

 I want to define a vector like w[k+1]=w[k]*a/(b+k) for k=1,...,N-1 without
 use loop. Is it posible to do in R?

 Regards

 khazaei

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

2010-02-26 Thread Gabor Grothendieck
There is a list here:
http://www.sciviews.org/_rgui/projects/Editors.html

On Fri, Feb 26, 2010 at 11:10 AM, Dwayne Blind dwaynebl...@gmail.com wrote:
 Dear all,

 Do you use a text editor ? What would you recommend for Windows users ? What
 about Tinn-R ?

 Thank you very much,
 Dwayne

        [[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] two questions for R beginners

2010-02-26 Thread Paul Hiemstra

Thomas Adams wrote:

Paul,

I think your point you need [to] spend at least a few hours a week on 
it is key. Since I am not doing statistics daily, more in fits  
starts as my latest project -may- require, my approach has been more 
task oriented. A less-than-ideal approach. So, I think your suggestion 
is on-the-mark.


Tom
I also see co-workers who would like to work with R, see the benefit of 
R etc, but don't have the time to learn and maintain R. But I'm not 
really sure how to fix this, it seems impossible to have both easy, 
intuitive  to use and power and flexibility.


cheers,
Paul



Paul Hiemstra wrote:

Ivan Calandra wrote:

You are definitely right...
What to do with bad beginner's questions is not a simple issue.

If a beginner's mailing list is created, who will answer to such 
questions? And moreover, the beginners won't take advantage of the 
other questions (I've personally learned a lot trying to understand 
the questions and answers to other's problems). And also, as you 
said, the problems might persist.
The beginner's mailing list might be good in one aspect though: the 
experts who subscribe to it would be willing to help the beginners 
to get started with R, knowing that the questions might not be 
clearly stated.


As you pointed out, the mailing list is not the best for basic stuff 
(the question is of course what is basic?). Not everybody knows 
some colleagues who work with R (I'm personally the 1st one to use R 
in my lab).
I think, somehow and I have no idea how, documentation and guidance 
to search for help should be more accessible as soon as you start 
with R. Maybe a _*clear*_ section on the R homepage or in the 
introduction to R manual like where to find help, including all 
of the most common and useful resources available (from ? and 
RSiteSearch() to R Wiki and Crantastic).
  

Hi Ivan (and list),

I think the main problem is not as much that there isn't structure in 
the way R provides documentation / tutorials, but that people have a 
hard time finding the structure. There are task views for certain 
specific fields, but I think a lot of beginners do not know that they 
exist. There are separate mailing lists for specific fields, but I 
often see geographical (my field of expertise) oriented questions on 
R-help that would fit much better on R-sig-geo.


So I think a O my God, I've downloaded R and what now tutorial 
might be a good idea to put very close to the download button of R on 
CRAN. This tutorial would focus not on how to do things in R, but 
would provide guidance to the most obvious sources of information 
such as Task views, specific mailing lists, ways to search list 
archives, information for beginners how to write a good e-mail etc. I 
think for a lot of beginners it is not as much the answer to a 
specific question that they need, but more guidance how to look for 
answers themselves.


But at the end of the day, R is still not very easy to learn when 
coming from GUI oriented stats programs. In addition, to become 
reasonably fluent in R, you need spend at least a few hours a week on 
it. SO I think we can ease the pain for beginners, but not take away 
that it takes quite some time to become fluent in R.


cheers,
Paul
I hope that this whole discussion might help to make the R world 
better.

Thank you Patrick for initiating it!
Regards,
Ivan

Le 2/26/2010 15:09, Paul Hiemstra a écrit :
 

Ivan Calandra wrote:
  

Since you want input from beginners, here are some thoughts

I had and still have two big problems with R:
- this vectorization thing. I've read many manuals (including R 
inferno), but I'm still not completely clear about it. In simple 
examples, it's fine. But when it gets a bit more complex, then...
Related to it, the *apply functions are still a bit difficult to 
understand. When I have to use them, I just try one and see what 
happens. I don't understand them well enough to know which one I 
need.
- the second problem is where to find the functions/packages I 
need. There are many options, and that's actually the problem. R 
Wiki, Rseek, RSiteSearch, Crantastic, etc... When you start with 
R, you discover that the capabilities of R are almost unlimited 
and you don't really know where to start, where to find what you 
need.


As noted in earlier posts, the mailing list is really great, but 
some people are really hard with beginners. It was noted in a 
discussion a few days ago, but it looks like some don't realize 
how difficult it is at the beginning to formulate a good question, 
clear, with self-contained example and so on. Moreover, not 
everybody speaks English natively. I don't mean that you must 
help, even when the question is really vague and not clear and 
whatever. I'm just saying that if you don't want to help (whatever 
the reason), you don't have to say it badly. But in any cases, the 
mailing list is still really helpful. As someone noted (sorry I 
erased the email so I don't remember who), it might be a good 

Re: [R] biclust package

2010-02-26 Thread Uwe Ligges



On 26.02.2010 17:04, linda garcia wrote:

Dear all,
  I am using biclust package for biclustering. I wanted to
know how can I extract my clusters from the object?


library(biclust)
test- matrix(rnorm(5000), 100, 50)

test[11:20,11:20]- rnorm(100, 3, 0.1)

loma- binarize(test,2)

res- biclust(x=loma, method=BCBimax(), minr=4, minc=4, number=10)

res


Thanks for your help





According to ?biclust which links to the Biclust class, there are slots 
that indicate cluster assigmnets in:


r...@rowxnumber
r...@numberxcol

Uwe Ligges

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


Re: [R] Boot R

2010-02-26 Thread Paul Hiemstra

Cassiano wrote:

I think I have 'libgfortran'.
After that I digit 'dpkg -l | grep libgfortran' in terminal, I got this
message:

ii  libgfortran2   4.2.4-5ubuntu1
Runtime library for GNU Fortran applications
ii  libgfortran2-dbg   4.2.4-5ubuntu1
Runtime library for GNU Fortran applications
ii  libgfortran3   4.4.1-4ubuntu9
Runtime library for GNU Fortran applications
ii  libgfortran3-dbg   4.4.1-4ubuntu9
Runtime library for GNU Fortran applications


And the error continue:

/usr/lib/R/bin/exec/R: error while loading shared libraries:
libgfortran.so.3: cannot open shared object file: No such file or directory

  

if you do:

sudo updatedb
locate libgfortran | grep so

does it find the file? And in which path?

cheers,
Paul

--
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 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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


Re: [R] Boot R

2010-02-26 Thread Paul Hiemstra

Cassiano wrote:

I think I have 'libgfortran'.
After that I digit 'dpkg -l | grep libgfortran' in terminal, I got this
message:

ii  libgfortran2   4.2.4-5ubuntu1
Runtime library for GNU Fortran applications
ii  libgfortran2-dbg   4.2.4-5ubuntu1
Runtime library for GNU Fortran applications
ii  libgfortran3   4.4.1-4ubuntu9
Runtime library for GNU Fortran applications
ii  libgfortran3-dbg   4.4.1-4ubuntu9
Runtime library for GNU Fortran applications


And the error continue:

/usr/lib/R/bin/exec/R: error while loading shared libraries:
libgfortran.so.3: cannot open shared object file: No such file or directory

  

Cassiano wrote:
After sudo updatedb - nothing

after locate libgfortran | grep so

//usr/lib/libgfortran.so.2
/usr/lib/libgfortran.so.2.0.0
/usr/lib/libgfortran.so.3.0.0
/usr/lib/debug/usr/lib/libgfortran.so.2.0.0
/usr/lib/debug/usr/lib/libgfortran.so.3.0.0
/usr/lib/gcc/i486-linux-gnu/4.4/libgfortran.so
/
My reply:
The point is that R is expecting /usr/lib/libgfortran.so.3 but your 
computer has /usr/lib/libgfortran.so.3.0.0. A trick is to make a 
symbolic link from /usr/lib/libgfortran.so.3 to 
/usr/lib/libgfortran.so.3.0.0. /usr/lib/libgfortran.so only points to 
/usr/lib/libgfortran.so.3.0.0 in that case:


sudo ln -s /usr/lib/libgfortran.so.3.0.0 /usr/lib/libgfortran.so.3

This should fix the problem.

cheers,
Paul

--
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 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

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


Re: [R] question to make a vector without loop

2010-02-26 Thread Joshua Wiley
My apologies, I misread your formula.  Here is a clearer example anyways:

w - 1:10
N - length(w)
a - 1
b - 1
k - 1:(N-1)
w[k+1] - w[k]*(a/(b+k))
w
 [1] 1.000 0.500 0.667 0.750 0.800 0.833 0.8571429
 [8] 0.875 0.889 0.900


Best,

Josh
On Fri, Feb 26, 2010 at 7:23 AM, khaz...@ceremade.dauphine.fr wrote:

 Hello all,

 I want to define a vector like w[k+1]=w[k]*a/(b+k) for k=1,...,N-1 without
 use loop. Is it posible to do in R?

 Regards

 khazaei

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




-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

[[alternative HTML version deleted]]

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


  1   2   >