[R] numerical summaries across variables.

2009-09-01 Thread rajclinasia

Hi Every one,
I have a dataframe class with name, sex, age, height, Weight.
if i caluclate summary statistics with the below code

numSummary(class[,c(Height, Weight)], groups=class$Name,
statistics=c(mean, sd, quantiles), quantiles=c(0,
  .25,.5,.75,1))

iam getting output like this

Variable: Height 
mean sd   0%  25%  50%  75% 100% n
Alfred  69.0 NA 69.0 69.0 69.0 69.0 69.0 1
Alice   56.5 NA 56.5 56.5 56.5 56.5 56.5 1
Barbara 65.3 NA 65.3 65.3 65.3 65.3 65.3 1
Carol   62.8 NA 62.8 62.8 62.8 62.8 62.8 1

Variable: Weight 
 mean sd0%   25%   50%   75%  100% n
Alfred  112.5 NA 112.5 112.5 112.5 112.5 112.5 1
Alice84.0 NA  84.0  84.0  84.0  84.0  84.0 1
Barbara  98.0 NA  98.0  98.0  98.0  98.0  98.0 1
Carol   102.5 NA 102.5 102.5 102.5 102.5 102.5 1

now my question is i want output like this 

  height weight
Alfred mean 
 sd
 0%   
 25%   
 50%   
 75%  
 100% 
  n
Alice mean 
 sd
 0%   
 25%   
 50%   
 75%  
 100% 
  n
Barbara mean 
 sd
 0%   
 25%   
 50%   
 75%  
 100% 
  n

 it is nothing but a numerical summaries across varibales. is it possible.

Thanks in Advance.


-- 
View this message in context: 
http://www.nabble.com/numerical-summaries-across-variables.-tp25234915p25234915.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] numerical summaries across variables.

2009-09-01 Thread milton ruser
Hi here,

may be you can play with reshape, or may be aggregate and reshape...

good luck

milton

On Tue, Sep 1, 2009 at 2:17 AM, rajclinasia r...@clinasia.com wrote:


 Hi Every one,
 I have a dataframe class with name, sex, age, height, Weight.
 if i caluclate summary statistics with the below code

 numSummary(class[,c(Height, Weight)], groups=class$Name,
 statistics=c(mean, sd, quantiles), quantiles=c(0,
  .25,.5,.75,1))

 iam getting output like this

 Variable: Height
mean sd   0%  25%  50%  75% 100% n
 Alfred  69.0 NA 69.0 69.0 69.0 69.0 69.0 1
 Alice   56.5 NA 56.5 56.5 56.5 56.5 56.5 1
 Barbara 65.3 NA 65.3 65.3 65.3 65.3 65.3 1
 Carol   62.8 NA 62.8 62.8 62.8 62.8 62.8 1

 Variable: Weight
 mean sd0%   25%   50%   75%  100% n
 Alfred  112.5 NA 112.5 112.5 112.5 112.5 112.5 1
 Alice84.0 NA  84.0  84.0  84.0  84.0  84.0 1
 Barbara  98.0 NA  98.0  98.0  98.0  98.0  98.0 1
 Carol   102.5 NA 102.5 102.5 102.5 102.5 102.5 1

 now my question is i want output like this

  height weight
 Alfred mean
 sd
 0%
 25%
 50%
 75%
 100%
  n
 Alice mean
 sd
 0%
 25%
 50%
 75%
 100%
  n
 Barbara mean
 sd
 0%
 25%
 50%
 75%
 100%
  n

  it is nothing but a numerical summaries across varibales. is it possible.

 Thanks in Advance.


 --
 View this message in context:
 http://www.nabble.com/numerical-summaries-across-variables.-tp25234915p25234915.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


[R] decimal sign

2009-09-01 Thread Alexandros Droseltis
Hello!

Is it possible to change the decimal sign in the histogram created by
hist() from dot to comma?

Thanks for any help!

Alexandros

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

2009-09-01 Thread Yonatan Nissenbaum
Hi,



I'm looking for an efficient code that will enable me to reshuffle data
(phenotype) for certain number of individuals and creating a loop that will
randomly simulate it for 1 times *(permutation)*. I also need to find
how I keep the information (p value for each SNP) gathered for all the 1
iterations.

My data set looks like this (n=500):

Individual #

Phenotype

SNP1

SNP2

SNP3

SNP4

SNP5

SNP6

SNP7

SNP8

SNP9

SNP10

SNP11

SNP12

1

0

T

T

G

G

A

C

G

T

A

A

T

C

2

1

A

T

C

G

A

C

G

T

A

G

T

C



Many thanks,



Jonathan

[[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] Function for all 2^N subsets of N

2009-09-01 Thread Ted Harding
Greetings all!
I have been searching the Site for a function, say subsets,
such that for instance

  subsets(10)

would return a (say) matrix of indices to the 2^10 subsets of
N items -- perhaps in the form of 2^10 rows each of which is
10 entries each either TRUE or FALSE. Or 1 or 0. Or ...

I can of course write my own, using good old looping technology
or similar, but it would be good to find one which did it quick
and snappy, at the compiled level.

A Site Search in Function on all subsets didn't seem to yield
anything of the kind, which surprised me. Maybe I overlooked
something ...

(This is prompted by the recent OT discussion on HT vs. HH,
to which I want to respond later).

With thanks,
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 01-Sep-09   Time: 09:09:09
-- XFMail --

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


Re: [R] Function for all 2^N subsets of N

2009-09-01 Thread Gerrit Eichner

Maybe

expand.grid( rep( list( 0:1), 10))

does what you want.

 Best regards  --  Gerrit

-
AOR Dr. Gerrit Eichner Mathematical Institute, Room 305 E
gerrit.eich...@math.uni-giessen.de   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104  Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109  http://www.uni-giessen.de/~gcb7
-

On Tue, 1 Sep 2009, 
ted.hard...@manchester.ac.uk wrote:



Greetings all!
I have been searching the Site for a function, say subsets,
such that for instance

 subsets(10)

would return a (say) matrix of indices to the 2^10 subsets of
N items -- perhaps in the form of 2^10 rows each of which is
10 entries each either TRUE or FALSE. Or 1 or 0. Or ...

I can of course write my own, using good old looping technology
or similar, but it would be good to find one which did it quick
and snappy, at the compiled level.

A Site Search in Function on all subsets didn't seem to yield
anything of the kind, which surprised me. Maybe I overlooked
something ...

(This is prompted by the recent OT discussion on HT vs. HH,
to which I want to respond later).

With thanks,
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 01-Sep-09   Time: 09:09:09
-- XFMail --

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



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


[R] data frame

2009-09-01 Thread Tammy Ma

HI, R user,

I generate the vectors with the same length. I want to put each vector into 
each column of data frame. Why it doesnt work`?

rm-data.frame()

for(a in 1:6){
 rm[,a]-getmeasure(p1,a,speech)
 
 }

thanks a lot

Tammy


_
Share your memories online with anyone you want.
http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1
[[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] Function for all 2^N subsets of N

2009-09-01 Thread Ted Harding

On 01-Sep-09 08:33:41, Gerrit Eichner wrote:
 Maybe
 
 expand.grid( rep( list( 0:1), 10))
 
 does what you want.
   Best regards  --  Gerrit

Thanks! That does seem to do the job. I hadn't thought of expand.grid().
Ted.

 On Tue, 1 Sep 2009, 
 ted.hard...@manchester.ac.uk wrote:
 
 Greetings all!
 I have been searching the Site for a function, say subsets,
 such that for instance

  subsets(10)

 would return a (say) matrix of indices to the 2^10 subsets of
 N items -- perhaps in the form of 2^10 rows each of which is
 10 entries each either TRUE or FALSE. Or 1 or 0. Or ...

 I can of course write my own, using good old looping technology
 or similar, but it would be good to find one which did it quick
 and snappy, at the compiled level.

 A Site Search in Function on all subsets didn't seem to yield
 anything of the kind, which surprised me. Maybe I overlooked
 something ...

 (This is prompted by the recent OT discussion on HT vs. HH,
 to which I want to respond later).

 With thanks,
 Ted.

 
 E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
 Fax-to-email: +44 (0)870 094 0861
 Date: 01-Sep-09   Time: 09:09:09
 -- XFMail --

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

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


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 01-Sep-09   Time: 09:42:18
-- XFMail --

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


Re: [R] Google's R Style Guide

2009-09-01 Thread Corrado
Thanks Duncan, Spencer,

To clarify, the situation is:

1) I have no reasons to choose S3 on S4 or vice versa, or any other coding 
convention
2) Our group has not done any OO developing in R and I would be the first, so I 
can set up the standards
3) I am starting from scratch with a new package, so I do not have any code I 
need to re-use.
4) I am an R OO newbie, so whatever I can learn from the beginning what is 
better and good for me.

So the questions would be two:

1) What coding style guide should we / I follow? Is the google style guide 
good, or is there something better / more prescriptive which makes our 
research group life easier? 
2) What class type should I use? From what you two say, I should use S3 
because is easier to use  what are the disadvantages? Is there an 
advantages / disadvantages table for S3 and S4 classes?

Thanks
-- 
Corrado Topi

Global Climate Change  Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


[R] List of tags in roxygen and use for S4 classes?

2009-09-01 Thread Rainer M Krug
Hi

is there a list of all roxygen tags which are available? I couldn't find them.

I am asking specifically towards the use of roxygen in documenting S4
classes - is that implemented yet (i am using roxygen 0.1 from CRAN at
the moment)?

Thanks

Rainer



-- 
Rainer M. Krug, Centre of Excellence for Invasion Biology,
Stellenbosch University, South Africa

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


Re: [R] Offtopic, HT vs. HH in coin flips

2009-09-01 Thread Ted Harding
On 31-Aug-09 19:16:33, Erik Iverson wrote:
 Dear R-help, 
 Could someone please try to explain this paradox to me? What is
 more likely to show up first in a string of coin tosses, Heads
 then Tails, or Heads then Heads?  
 
##generate 2500 strings of random coin flips
 ht - replicate(2500,
 paste(sample(c(H, T), 100, replace = TRUE),
   collapse = ))
 
## find first occurrence of HT
 mean(regexpr(HT, ht))+1#mean of HT position, 4
 
## find first occurrence of HH
 mean(regexpr(HH, ht))+1#mean of HH position, 6
 
 FYI, this is not homework, I have not been in school in years.
 I saw a similar problem posed in a blog post on the Revolutions R
 blog, and although I believe the answer, I'm having a hard time
 figuring out why this should be? 
 
 Thanks,
 Erik Iverson

Be very careful about the statement of the problem!

[1] The probability that HH will occur first (i.e. before HT)
is the same as the probability that HT will occur first (i.e.
before HH).

[2] However, the probability that the first occurrence of HT
will be on a given position of the H is generally not the same
as the probability that the first occurrence of HH will be on
the same position of the first H.

[1]: At the first occurrence of (either HH or HT), there is
an initial string S, ending in an H, followed by either an H
(for HH) or a T (for HT). Both are equally likely.

So the probability that the first occurrence of (either HH or HT)
is an HH is the same as the probability that it is an HT.

[2]: (A) the first occurrence of an HH is in a sequence of
any collection of H and T provided there is no HH in the
sequence, and the last is H, followed by H.
However, HT is allowed to occur in the sequence.

But (B) the first occurrence of an HT is in a sequence of
(zero or more T) followed by (1 or more H) followed by T.
This is the only pattern in which HT does not occur prior to
the final HT.
Similarly, HH is allowed to pccur in the sequence.

The reason that, in general, the probability of HH first occuring
at a given position is different from the probability if HT first
occurring at that position lies in the differences between the
number of possible sequences satisfying (A), and the number of
possible sequences satisfying (B).

The first few cases (HH or HT first occurring at (k+1), so
that the position of the first H in HH or HT is at k) are,
with their probabilities:

k=1:   HH HT
  1/41/4

K=2:  THH HHT
  THT
  1/8 2/8

k=3: TTHH HHHT
 HTHH THHT
  TTHT
 2/16 3/16

k=4:TTTHH T
THTHH THHHT
HTTHH TTHHT
  TTTHT
 3/32 4/32

The HT case is simple:
  P.HT[k] = Prob(1st HT at (k+1)) = k/(2^(k+1))
Exercise for the reader: Sum(P.HT) = 1

The HH case is more interesting. Experimental scribblings on
parer threw up an hypothesis, which I decided to explore in R.
Thanks to Gerrit Eichner for suggestion the use of expand.grid()!

  ## Function to count sequences giving 1st HH on throw k+1
  countHH - function(k){
M - as.matrix(expand.grid(rep(list(0:1),k)))
ix - (M[,k]==1) ## k must be an H (then k+1 will be H)
for(i in (1:(k-1))){ ix-ix( !((M[,i]==1)(M[,i+1]==1)) ) }
sum(ix)
## list(Count=sum(ix),Which=M[ix,])
  }

Now, ignoring the case k=1:

  HHcounts - NULL
  for(i in (2:12)){ HHcounts-c(HHcounts,countHH(i)) }
  rbind((3:13),HHcounts)

  # [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
  #3456789   10   111213
  #HHcounts12358   13   21   34   5589   144

Lo and Behold, we have a Fibonnaci sequence! Another exercise for
the reader ...

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 01-Sep-09   Time: 10:38:58
-- XFMail --

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


Re: [R] Google style

2009-09-01 Thread Jim Lemon

Duncan Murdoch wrote:

On 8/31/2009 11:50 AM, Mark Knecht wrote:
On Mon, Aug 31, 2009 at 6:36 AM, Terry Therneauthern...@mayo.edu 
wrote:

SNIP

The authors borrowed so much else from C, the semicolon would have been
good too.

Something I have thought myself.
 


I know real R coders will chuckle


I'd say cringe, rather than chuckle.  This is going to make you waste 
a lot of time some day, when you stare and stare at code like Terry's 
and can't figure out what's wrong with it:


zed - function(x,y,z) {
   x + y
 +z;
  }

The value of the function is +z, not x+y+z, even though the C part of 
your brain made you type it that way and reads it as one statement in 
the body, not two.
This is getting interesting. One habit I have developed in R to 
emphasize a line continuation is to always write the above as:


zed-function(x,y,z) {
x+y+
z
}

The trailing operator signalling to me and the interpreter that there's 
more to come. A semicolon after the z would be innocuous. Now I know 
that this marks me as a crabby old fart who learned to program on 
Hollerith cards where there had to be firm conventions on when a line of 
code ended. Still, given the moiety of global warming attributable to 
endless discussions about how many spaces should be used for 
indentation, I think the use of the semicolon as a personal aid to 
interpretation is at worst a harmless affectation.


Jim

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


[R] Odp: data frame

2009-09-01 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 01.09.2009 10:39:42:

 
 HI, R user,
 
 I generate the vectors with the same length. I want to put each vector 
into 
 each column of data frame. Why it doesnt work`?
 
 rm-data.frame()
 
 for(a in 1:6){
  rm[,a]-getmeasure(p1,a,speech)
 
  }

Well, couldn't it be because function getmeasure does not exist?

Error: could not find function getmeasure

and you get another error

rm[,a]
Error in `[.data.frame`(rm, , 1:2) : undefined columns selected

If you need to put a vector to data frame you shall preassign the 
structure, columns and rows.

Or you can use list and as.data.frame

Regards
Petr

 
 thanks a lot
 
 Tammy
 
 
 _
 Share your memories online with anyone you want.
 
http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1

[[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] numerical summaries across variables.

2009-09-01 Thread Jim Lemon

rajclinasia wrote:

Hi Every one,
I have a dataframe class with name, sex, age, height, Weight.
if i caluclate summary statistics with the below code

numSummary(class[,c(Height, Weight)], groups=class$Name,
statistics=c(mean, sd, quantiles), quantiles=c(0,
  .25,.5,.75,1))

iam getting output like this

Variable: Height 
mean sd   0%  25%  50%  75% 100% n

Alfred  69.0 NA 69.0 69.0 69.0 69.0 69.0 1
Alice   56.5 NA 56.5 56.5 56.5 56.5 56.5 1
Barbara 65.3 NA 65.3 65.3 65.3 65.3 65.3 1
Carol   62.8 NA 62.8 62.8 62.8 62.8 62.8 1

Variable: Weight 
 mean sd0%   25%   50%   75%  100% n

Alfred  112.5 NA 112.5 112.5 112.5 112.5 112.5 1
Alice84.0 NA  84.0  84.0  84.0  84.0  84.0 1
Barbara  98.0 NA  98.0  98.0  98.0  98.0  98.0 1
Carol   102.5 NA 102.5 102.5 102.5 102.5 102.5 1

now my question is i want output like this 


  height weight
Alfred mean 
 sd
 0%   
 25%   
 50%   
 75%  
 100% 
  n
Alice mean 
 sd
 0%   
 25%   
 50%   
 75%  
 100% 
  n
Barbara mean 
 sd
 0%   
 25%   
 50%   
 75%  
 100% 
  n


 it is nothing but a numerical summaries across varibales. is it possible.

  

Hi Raj,
I think you may have to write a print function for this. Assign the 
result of numSummary to an object, use str to find out the structure 
and then use cat to display the bits in the format you want. I don't 
have Rcmdr on my system and haven't been able to install it as R refuses 
to believe that I have Tcl-Tk available. Thus I can't tell you exactly 
how to do this.


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] Google's R Style Guide

2009-09-01 Thread Duncan Murdoch

Corrado wrote:

Thanks Duncan, Spencer,

To clarify, the situation is:

1) I have no reasons to choose S3 on S4 or vice versa, or any other coding 
convention
2) Our group has not done any OO developing in R and I would be the first, so I 
can set up the standards
3) I am starting from scratch with a new package, so I do not have any code I 
need to re-use.
4) I am an R OO newbie, so whatever I can learn from the beginning what is 
better and good for me.


So the questions would be two:

1) What coding style guide should we / I follow? Is the google style guide 
good, or is there something better / more prescriptive which makes our 
research group life easier? 
  


I don't think I can answer that.  I'd recommend planning to spend some 
serious time on the decision, and then go by your personal impression.  
S4 is definitely harder to learn but richer, so don't make the decision 
too quickly.  Take a look at John Chamber's new book, try small projects 
in each style, etc.


2) What class type should I use? From what you two say, I should use S3 
because is easier to use  what are the disadvantages? Is there an 
advantages / disadvantages table for S3 and S4 classes?
  


S3 is much more limited than S4.  It dispatches on just one argument, S4 
can dispatch on several.  S3 allows you to declare things to be of a 
certain class with no checks that anything will actually work; S4 makes 
it easier to be sure that if you say something is of a certain class, it 
really is.  S4 hides more under the hood: if you understand how regular 
R functions work, learning S3 is easy, but there's still a lot to learn 
before you'll be able to use S4 properly.


Duncan Murdoch

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


Re: [R] Google style

2009-09-01 Thread Duncan Murdoch

Jim Lemon wrote:

Duncan Murdoch wrote:
  

On 8/31/2009 11:50 AM, Mark Knecht wrote:

On Mon, Aug 31, 2009 at 6:36 AM, Terry Therneauthern...@mayo.edu 
wrote:

SNIP
  

The authors borrowed so much else from C, the semicolon would have been
good too.


Something I have thought myself.
  
 


I know real R coders will chuckle
  
I'd say cringe, rather than chuckle.  This is going to make you waste 
a lot of time some day, when you stare and stare at code like Terry's 
and can't figure out what's wrong with it:


zed - function(x,y,z) {
   x + y
 +z;
  }

The value of the function is +z, not x+y+z, even though the C part of 
your brain made you type it that way and reads it as one statement in 
the body, not two.

This is getting interesting. One habit I have developed in R to 
emphasize a line continuation is to always write the above as:


zed-function(x,y,z) {
 x+y+
 z
}
  


That's a good habit.  An alternative is to put parentheses around the 
expression:


(x + y
 + z)

will work.
The trailing operator signalling to me and the interpreter that there's 
more to come. A semicolon after the z would be innocuous. Now I know 
that this marks me as a crabby old fart who learned to program on 
Hollerith cards where there had to be firm conventions on when a line of 
code ended. Still, given the moiety of global warming attributable to 
endless discussions about how many spaces should be used for 
indentation, I think the use of the semicolon as a personal aid to 
interpretation is at worst a harmless affectation.
  


I think it's worse.  To me, it's like putting in a comment that is 
wrong, or writing code like this:


 one - 2
 x - x + one

Code has meaning, it's not just a bunch of binary instructions to the 
computer.  If the meaning and the look of the code clash, it is going to 
lead to problems.


Duncan Murdoch

Jim

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



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


Re: [R] Google style

2009-09-01 Thread Ted Harding
On 01-Sep-09 10:25:53, Duncan Murdoch wrote:
 Jim Lemon wrote:
 Duncan Murdoch wrote:
 On 8/31/2009 11:50 AM, Mark Knecht wrote:
 On Mon, Aug 31, 2009 at 6:36 AM, Terry Therneauthern...@mayo.edu 
 wrote:
 SNIP
 The authors borrowed so much else from C, the semicolon would have
 been good too.
 
 Something I have thought myself.
   
 I know real R coders will chuckle
   
 I'd say cringe, rather than chuckle.  This is going to make you waste
 a lot of time some day, when you stare and stare at code like Terry's
 and can't figure out what's wrong with it:

 zed - function(x,y,z) {
x + y
  +z;
   }

 The value of the function is +z, not x+y+z, even though the C part of
 your brain made you type it that way and reads it as one statement in
 the body, not two.
 
 This is getting interesting. One habit I have developed in R to 
 emphasize a line continuation is to always write the above as:

 zed-function(x,y,z) {
  x+y+
  z
 }
   
 
 That's a good habit.  An alternative is to put parentheses around the 
 expression:
 
  (x + y
   + z)
 
 will work.
 The trailing operator signalling to me and the interpreter that
 there's more to come. A semicolon after the z would be innocuous.
 Now I know that this marks me as a crabby old fart who learned
 to program on Hollerith cards where there had to be firm
 conventions on when a line of code ended. Still, given the moiety
 of global warming attributable to endless discussions about how
 many spaces should be used for indentation, I think the use of
 the semicolon as a personal aid to interpretation is at worst a
 harmless affectation.
 
 I think it's worse.  To me, it's like putting in a comment that is 
 wrong, or writing code like this:
 
   one - 2
   x - x + one
 
 Code has meaning, it's not just a bunch of binary instructions to the 
 computer.  If the meaning and the look of the code clash, it is going
 to lead to problems.
 
 Duncan Murdoch

And surely that is precisely the point of Jim's use of ;!
It is, in effect, ignored by R; but to Jim it means This marks the
end of a command. Surely useful, and surely not in the same league
as a comment that is wrong. You may see it as noise, but then
you can filter it out.

As one COF to another, I have to say that Jim's posting took me
back to the early days of my own evolution. That was dandy!
(Dinosaurs are not dead yet).

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 01-Sep-09   Time: 11:37:52
-- XFMail --

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


[R] Article on teaching R

2009-09-01 Thread Stephen Eglen
I've written a short article on my experiences with teaching R to
computational biology graduate students:

http://www.ploscompbiol.org/doi/pcbi.1000482

My lecture notes are available as supplementary material, along with the
beamer/latex sources (from my web page: 
http://www.damtp.cam.ac.uk/user/sje30/downloads.html)

Stephen
-- 
Stephen Eglen, DAMTP, Centre for Mathematical Sciences
Wilberforce Road, Cambridge CB3 0WA, U.K.
Tel +44 (0)1223 765 761   s.j.eg...@damtp.cam.ac.uk
Fax +44 (0)1223 760 419   http://www.damtp.cam.ac.uk/user/eglen

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


Re: [R] decimal sign

2009-09-01 Thread David Winsemius


On Sep 1, 2009, at 3:25 AM, Alexandros Droseltis wrote:


Hello!

Is it possible to change the decimal sign in the histogram created by
hist() from dot to comma?


?options

options(OutDec = ,)

Seems to work as described, at least with hist.
--

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] Computer Modern and Sweave

2009-09-01 Thread Bert Stumm
Hello,

I have a small but nasty problem with the Computer Modern fonts
in connection with Sweave.

Instead of giving my own code, it's probably better to look at a
well established example. There is a nice introduction to using
Sweave at Paul Murrell's website which can be found at:

http://www.stat.auckland.ac.nz/~paul/R/CM/CMR.html

Essentially, what I need from this page are the following 4 files for 
creating my final pdf:

http://www.stat.auckland.ac.nz/~paul/R/CM/cmTutorial.Rnw

( 
  This example needs the according Tex-package and the files for the symbol
  faces found at (the links are also given on the site): 
  http://www.ctan.org/tex-archive/help/Catalogue/entries/cm-lgc.html 
  http://www.stat.auckland.ac.nz/~paul/R/CM/cmsyase.afm
  http://www.stat.auckland.ac.nz/~paul/R/CM/cmsyase.pfb
) 


Creating the tex-file with
 R CMD Sweave cmTutorial.Rnw
and compiling it with
 pdflatex cmTutorial.tex

yields a perfect plot. BUT, if minus signs appear in the plot, it does not
work poperly anymore! Just change the endpoints in the 'histogram'  function to 
'c(-59.5, 76.5)' ( instead of 'c(59.5, 76.5)' ) and run the
two upper commands again. Then, I see a minus sign in the file 
'cmTutorial-latticeShow.pdf' but NOT in the 'cmTutorial.pdf'. 
Very strange is also, that using sth. like mtext(text=-1.987,...) will
give me a nice minus-sign in the pdf.

###
 
Did anybody encounter this problem and could possibly help me with this
question?
How can pdflatex change something in the included pdf?

Cheers,
Frank

-- 

für nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02

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


Re: [R] Google style

2009-09-01 Thread Duncan Murdoch

On 9/1/2009 6:37 AM, (Ted Harding) wrote:

On 01-Sep-09 10:25:53, Duncan Murdoch wrote:

Jim Lemon wrote:

Duncan Murdoch wrote:

On 8/31/2009 11:50 AM, Mark Knecht wrote:
On Mon, Aug 31, 2009 at 6:36 AM, Terry Therneauthern...@mayo.edu 
wrote:

SNIP

The authors borrowed so much else from C, the semicolon would have
been good too.


Something I have thought myself.
  

I know real R coders will chuckle
  

I'd say cringe, rather than chuckle.  This is going to make you waste
a lot of time some day, when you stare and stare at code like Terry's
and can't figure out what's wrong with it:

zed - function(x,y,z) {
   x + y
 +z;
  }

The value of the function is +z, not x+y+z, even though the C part of
your brain made you type it that way and reads it as one statement in
the body, not two.

This is getting interesting. One habit I have developed in R to 
emphasize a line continuation is to always write the above as:


zed-function(x,y,z) {
 x+y+
 z
}
  


That's a good habit.  An alternative is to put parentheses around the 
expression:


 (x + y
  + z)

will work.

The trailing operator signalling to me and the interpreter that
there's more to come. A semicolon after the z would be innocuous.
Now I know that this marks me as a crabby old fart who learned
to program on Hollerith cards where there had to be firm
conventions on when a line of code ended. Still, given the moiety
of global warming attributable to endless discussions about how
many spaces should be used for indentation, I think the use of
the semicolon as a personal aid to interpretation is at worst a
harmless affectation.


I think it's worse.  To me, it's like putting in a comment that is 
wrong, or writing code like this:


  one - 2
  x - x + one

Code has meaning, it's not just a bunch of binary instructions to the 
computer.  If the meaning and the look of the code clash, it is going

to lead to problems.

Duncan Murdoch


And surely that is precisely the point of Jim's use of ;!
It is, in effect, ignored by R; but to Jim it means This marks the
end of a command. Surely useful, and surely not in the same league
as a comment that is wrong. You may see it as noise, but then
you can filter it out.


I think you're missing the point.  Using C-like syntax in R is 
misleading because you will think it has C-like meaning.  You will read


 x + y
   + z;

as one statement, not two. (Actually you could argue that in R there are 
three statements there, but the third one is empty).


This is harmful in the same way using misleading variable names is 
harmful:  as long as you're paying attention you'll get it right, but 
when you are working on a hard problem and can't devote enough neurons 
to this particular task, you'll get it wrong, and have a hard-to-spot 
bug in your code.  You'll decide you need to split a statement across 
two lines, and write it in C style like the statements above, instead of 
in correct R syntax.


Duncan Murdoch



As one COF to another, I have to say that Jim's posting took me
back to the early days of my own evolution. That was dandy!
(Dinosaurs are not dead yet).

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 01-Sep-09   Time: 11:37:52
-- XFMail --

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


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


[R] R functions that count lines of a files

2009-09-01 Thread xue dong
hi, everyone,

do you know if there is a R function that can count the lines of a file
without open it?

something like wc -l  in Unix.

Thanks,

Xue

[[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 functions that count lines of a files

2009-09-01 Thread Ben Bolker


  length(count.fields(foo.txt)) 

?


xue dong wrote:
 
 hi, everyone,
 
 do you know if there is a R function that can count the lines of a file
 without open it?
 
 something like wc -l  in Unix.
 
 Thanks,
 
 Xue
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/R-functions-that-count-lines-of-a-files-tp25239480p25239578.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] Function for all 2^N subsets of N

2009-09-01 Thread Terry Therneau
My first thought was the odometer() function, which is often useful for
tasks like this.  To my surprise it is not a part of the current R.  
  I wonder why?  It shouldn't be an Splus copyright issue as this was a
part of my original S distribution (before Splus even existed), and used
in an example in one of the early books.
  Terry T

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


[R] Syntax for crossed random effects in nlme

2009-09-01 Thread bamsel

Hello R users, 
I've read the posts on this topic, and had a look at the R documentation for
nlme, but I can't seem to make this work. I'd like to be able to fit a mixed
effects model with crossed random effects, but also be able to specify the
covariance matrix structure for the residuals. Here's the syntax using the
lmer function in lme4 (which doesn't currently allow alternate error
covariance structures). Does anybody know how to transform this to work with
nlme?

fit = lmer(data$DV ~ X + time + (X*time) + (1|Item_Number) + (1|Subject),
data)

Much appreciated, 
Ben Amsel
-- 
View this message in context: 
http://www.nabble.com/Syntax-for-crossed-random-effects-in-nlme-tp25239714p25239714.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] Google's R Style Guide

2009-09-01 Thread Martin Morgan
Corrado wrote:
 Thanks Duncan, Spencer,
 
 To clarify, the situation is:
 
 1) I have no reasons to choose S3 on S4 or vice versa, or any other coding 
 convention
 2) Our group has not done any OO developing in R and I would be the first, so 
 I 
 can set up the standards
 3) I am starting from scratch with a new package, so I do not have any code I 
 need to re-use.

One consideration might be the domain in which you are doing
development; Bioconductor for instance makes extensive use of S4 and
your efforts at learning to develop S4 would pay off both in your own
code and in understanding other packages.

 4) I am an R OO newbie, so whatever I can learn from the beginning what is 
 better and good for me.
 
 So the questions would be two:
 
 1) What coding style guide should we / I follow? Is the google style guide 
 good, or is there something better / more prescriptive which makes our 
 research group life easier? 
 2) What class type should I use? From what you two say, I should use S3 
 because is easier to use  what are the disadvantages? Is there an 
 advantages / disadvantages table for S3 and S4 classes?

It seems relevant to compare S3 and S4 code for doing S3-style
programming, leaving more 'advanced' S4 for another day. In S3 I might
define a simple class and method as


makeS3Foo -
function(x=numeric(), y=numeric())
{
if (class(x) != numeric)
stop('x' must be numeric)
if (class(y) != numeric)
stop('y' must be numeric)
l - list(x=x, y=y)
class(l) - S3Foo
l
}

doS3 - function(x, ...) NextMethod(doS3)

doS3.default - function(x, ...) doS3 default

doS3.S3Foo - function(x, ...) doS3 of S3Foo


with an example of use being

 doS3(makeS3Foo())
[1] doS3 of S3Foo


I use 'makeS3Foo' as a constructor, so that whenever I make an instance
of what I'm calling class S3Foo, I have some guarantees about its structure.

The S4 implementation might be


setClass(S4Foo, representation(x=numeric, y=numeric))

makeS4Foo -
function(x = numeric(), y=numeric(), ...)
{
new(S4Foo, x=x, y=y, ...)
}

setGeneric(doS4, function(x, ...) standardGeneric(doS4),
   useAsDefault=function(x, ...) do default)

setMethod(doS4, S4Foo, function(x, ...) doS4 of S4Foo)

and use with

 doS4(makeS4Foo())
[1] doS4 of S4Foo

It seems like the translation between the two is really quite
transparent, and equally arcane to someone new to R.

Some things I get from S4 are a level of automatic type checking

 makeS4Foo(x=bar)
Error in validObject(.Object) :
  invalid class S4Foo object: invalid object for slot x in class
S4Foo: got class character, should be or extend class numeric

a way of knowing that my 'S4Foo' conforms to expectations -- in S3 I can say

  l = list(a=1, b=2)
  class(l) - S3Foo

and have no way of knowing whether this is 'valid' or not; in S4 I would
not use this method of creating a class (I'd use my constructor, or
perhaps 'new' if I were being undisciplined, and get type checking as
above) but if I did I'd be able to find

 class(l) - S4Foo
 validObject(l)
Error in validObject(l) :
  invalid class S4Foo object: slots in class definition but not in
object: x, y

an error when I try and access data not in the class (normally I'd have
made a constructor, and not use slot access @ directly)

 makeS3Foo()$z
NULL
 makeS4Foo()@z
Error: no slot of name z for this object of class S4Foo

and reflection on the class

 getClass(S4Foo)
Class “S4Foo” [in .GlobalEnv]

Slots:

Name:x   y
Class: numeric numeric


Some of the tools for documenting S3 classes and methods are more mature
than for S4 (e.g., package.skeleton does a better job of making a
package containing my existing S3 code objects, but I usually use
package.skeleton to start a project, not to move existing objects into a
new project). The fact that the class has been declared explicitly means
 that I'm expected to document it explicitly (in contrast to, say, the
result of lm(), which is documented only as the return value of the
function) and this then requires decisions about how to group class and
method documentation.

Using more complicated S4 features can be, well, more complicated. But
then these features are not readily available with S3, so...

To touch on a couple of other themes in this thread... Using a '.' in a
variable name seems like a very bad idea, given the way S3 dispatch
works. I like to think of objects as nouns and functions as verbs, and
so prefer to capitalize class names (as though they were proper nouns)
and lower-case function names (so they have a more dynamic sense). And
there are many S4 style issues that are not addressed by the google doc
-- setMethod and setGeneric indentation in particular.

A great feature of emacs-ESS that I've recently discovered (thanks
Deepayan for pointing this out, and also for command completion) is the
C-c C-p command when looking at an Rd file during package development;
it very nicely returns the formatted help page to emacs.

Martin

 
 

Re: [R] R2 for SAR and validation

2009-09-01 Thread Roger Bivand

Did you read the posting guide? Your posting is not comprehensible to most of
the readers of this list, and you have not explained whether this has
anything to do with R, or any of its contributed packages; there are no
clues in included code or code snippets illustrating the problem. Your TLA
is capable of many interpretations. Finally, if you are asking about spatial
autoregression, you might have posted to the R-sig-geo list instead.

If you are asking why lagsarlm() in the spdep package does not provide an R2
value in its summary, try using its log likelihood value, and comparing that
with logLik() of the equivalent lm() model - this is reported in the
summary() of the fitted object. You can calculate a pseudo-R2 by correlating
the observed and fitted values, but the likelihood ratio (or comparisons of
the AIC) are perhaps better founded. The same measures are found in other
implementations (GeoDa, Matlab spatial econometrics toolbox). It is not
obvious what you mean by validate in this context.

Roger Bivand


saniye keser wrote:
 
 
 Hi everyone,
 How can i obtain R2 for SAR model? and how can i validate the results, can
 i use the coefficients directly in a simple formula like y=b0+b1*x1+... or
 do i have to use the complicated formula for SAR (the one with the weight
 matrix and rho and...)?
  
 Thanks for any help! 
 
 
   
   [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/R2-for-SAR-and-validation-tp25225433p25239901.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] SVM coefficients

2009-09-01 Thread marlene marchena
Hi,



A long time I have some problems to run a SVM - regression. Here an example
with the Ozone data that represents very well my own data.



 data(Ozone, package = mlbench)

#I cut the three first variables and splite the data in two parts

Ozone- na.omit(Ozone[, -(1:3)])

 index - 1:nrow(Ozone)

 testset - Ozone[104:203,]

trainset - Ozone[1:103, ]

names(Ozone)



# library(e1071)

# train svm with RBF kernel and without scale

tuneobj = tune.svm(V4 ~ ., data = trainset, gamma = 10^(-6:-3), cost =
10^(1:3))

 summary(tuneobj)$best.parameters

 svm.noscale - svm(V4 ~ ., data = trainset, cost = 1000, gamma =
0.001,scale=FALSE)



Parameters:

   SVM-Type:  eps-regression

 SVM-Kernel:  radial

   cost:  1000

  gamma:  0.001

epsilon:  0.1





Number of Support Vectors:  101



# I get 101 support vectors wich seems to be bad because I have 103 training
observations.

#When I test with the trainset I have good results but when I use the
testset my prediction are pretty bad.



pred.noscale1 - predict( svm.noscale, newdata=trainset, decision.values=T)

crossprod(pred.noscale1 -  trainset$V4)/103

  #[1,] 0.009827706



pred.noscale2- predict( svm.noscale, newdata=testset, decision.values=T)

crossprod(pred.noscale2 -  testset$V4)/100

 #[1,] 82.97046





# primal parameters

w - t(svm.noscale$coefs) %*%svm.noscale$SV



   V5V6   V7   V8   V9   V10  V11
V12
V13

[1,] 44187.34 -265.8382 3741.839 6359.768 5455.063 -646352.6 317.6211 6456
-23256.67

b=svm.noscale$rho

[1] -10.46065



#It seems that I have overfitting. I suppose that the problem comes from not
use scale data #(V5 and V10 are very high).

#Now scaling the data



 svm.scale - svm(V4 ~ ., data = trainset, cost = 1000, gamma = 0.001)



Parameters:

   SVM-Type:  eps-regression

 SVM-Kernel:  radial

   cost:  1000

  gamma:  0.001

epsilon:  0.1



Number of Support Vectors:  86



# It seems better



svm.pred1 - predict( svm.scale, newdata=trainset, decision.values=T)

 crossprod( svm.pred1 -  trainset$V4)/103

 #[1,] 9.459279



 svm.pred2 - predict( svm.scale, newdata=testset, decision.values=T)

 crossprod( svm.pred2 - testset$V4)/100

#  26.51138





# primal parameters

  w - t(svm.scale$coefs) %*%svm.scale$SV



V5V6   V7   V8   V9  V10  V11
V12   V13

[1,] -89.03491 -22.88782 146.8991 56.09881 217.0120 43.01645 -8.27661
50.2729 -60.78473



 b= svm.model$rho

#[1] 18.42264



Looking only to prediction purpose the scale model is good but I’m mainly
interested in w. Is it possible to improve this model to get lower values to
w? Actually I’m trying to run the SVM-GARCH and one condition to the model
is that the sum of

w’s 1 (in my model I have only two independent variables).



If you have any idea how to improve the model or if you find any problem
with it please let me now.



Thanks in advance,


Marlene.



2009/8/31 Noah Silverman n...@smartmediacorp.com

 Thanks,

 I just remember with RapidMiner, there was always a screen showing the
 effective weights assigned to each input variable by the SVM.  These
 numbers themselves weren't good for much, except they really helped to
 visualize the data.  It is rather useful to see how much relative weight
 (significance.) the SVM assigned to each variable.


 On 8/31/09 12:54 AM, Achim Zeileis wrote:
  On Mon, 31 Aug 2009, Noah Silverman wrote:
 
  Steve,
 
  That doesn't work.
 
  I just trained an SVM with 80 variables.
  svm_model$coefs gives me  a list of 10,000 items.  My training set is
  30,000 examples of 80 variables, so I have no idea what the 10,000
  items represent.
 
  Presumably, the coefficients of the support vectors times the training
  labels, see help(svm, package = e1071). See also
http://www.jstatsoft.org/v15/i09/
  for some background information and the different formulations available.
 
  There should be some attribute that lists the weights for each of
  the 80 variables.
 
  Not sure what you are looking for. Maybe David, the author auf svm()
  (and now Cc), can help.
  Z
 
  --
  Noah
 
  On 8/30/09 7:47 PM, Steve Lianoglou wrote:
  Hi,
 
  On Sun, Aug 30, 2009 at 6:10 PM, Noah
  Silvermann...@smartmediacorp.com wrote:
 
  Hello,
 
  I'm using the svm function from the e1071 package.
 
  It works well and gives me nice results.
 
  I'm very curious to see the actual coefficients calculated for each
  input
  variable.  (Other packages, like RapidMiner, show you this
  automatically.)
 
  I've tried looking at attributes for the model and do see a
  coefficients
  item, but printing it returns an NULL result.
 
  Hmm .. I don't see a coefficients attribute, but rather a coefs
  attribute, which I guess is what you're looking for (?)
 
  Run example(svm) to its end and type:
 
  R  m$coefs
[,1]
[1,]  1.00884130
[2,]  1.27446460
[3,]  2.
[4,] -1.
[5,] -0.35480340
[6,] -0.74043692
[7,] 

Re: [R] Google's R Style Guide

2009-09-01 Thread Duncan Murdoch

On 9/1/2009 8:58 AM, Martin Morgan wrote:

Corrado wrote:

Thanks Duncan, Spencer,

To clarify, the situation is:

1) I have no reasons to choose S3 on S4 or vice versa, or any other coding 
convention
2) Our group has not done any OO developing in R and I would be the first, so I 
can set up the standards
3) I am starting from scratch with a new package, so I do not have any code I 
need to re-use.


One consideration might be the domain in which you are doing
development; Bioconductor for instance makes extensive use of S4 and
your efforts at learning to develop S4 would pay off both in your own
code and in understanding other packages.

4) I am an R OO newbie, so whatever I can learn from the beginning what is 
better and good for me.


So the questions would be two:

1) What coding style guide should we / I follow? Is the google style guide 
good, or is there something better / more prescriptive which makes our 
research group life easier? 
2) What class type should I use? From what you two say, I should use S3 
because is easier to use  what are the disadvantages? Is there an 
advantages / disadvantages table for S3 and S4 classes?


It seems relevant to compare S3 and S4 code for doing S3-style
programming, leaving more 'advanced' S4 for another day. In S3 I might
define a simple class and method as


makeS3Foo -
function(x=numeric(), y=numeric())
{
if (class(x) != numeric)
stop('x' must be numeric)
if (class(y) != numeric)
stop('y' must be numeric)
l - list(x=x, y=y)
class(l) - S3Foo
l
}

doS3 - function(x, ...) NextMethod(doS3)

doS3.default - function(x, ...) doS3 default

doS3.S3Foo - function(x, ...) doS3 of S3Foo


with an example of use being


doS3(makeS3Foo())

[1] doS3 of S3Foo



That looks as though it was written by an S4 user.  I would write it 
this way (with some differences in behaviour):


S3Foo - function(x=numeric(), y=numeric()) {
  structure(list(x=as.numeric(x), y=as.numeric(y)), class=S3Foo)
}

The rest of my code would be pretty similar to yours, though I think it 
should use UseMethod(doS3) rather than NextMethod(doS3).


Duncan Murdoch




I use 'makeS3Foo' as a constructor, so that whenever I make an instance
of what I'm calling class S3Foo, I have some guarantees about its structure.

The S4 implementation might be


setClass(S4Foo, representation(x=numeric, y=numeric))

makeS4Foo -
function(x = numeric(), y=numeric(), ...)
{
new(S4Foo, x=x, y=y, ...)
}

setGeneric(doS4, function(x, ...) standardGeneric(doS4),
   useAsDefault=function(x, ...) do default)

setMethod(doS4, S4Foo, function(x, ...) doS4 of S4Foo)

and use with


doS4(makeS4Foo())

[1] doS4 of S4Foo

It seems like the translation between the two is really quite
transparent, and equally arcane to someone new to R.

Some things I get from S4 are a level of automatic type checking


makeS4Foo(x=bar)

Error in validObject(.Object) :
  invalid class S4Foo object: invalid object for slot x in class
S4Foo: got class character, should be or extend class numeric

a way of knowing that my 'S4Foo' conforms to expectations -- in S3 I can say

  l = list(a=1, b=2)
  class(l) - S3Foo

and have no way of knowing whether this is 'valid' or not; in S4 I would
not use this method of creating a class (I'd use my constructor, or
perhaps 'new' if I were being undisciplined, and get type checking as
above) but if I did I'd be able to find


class(l) - S4Foo
validObject(l)

Error in validObject(l) :
  invalid class S4Foo object: slots in class definition but not in
object: x, y

an error when I try and access data not in the class (normally I'd have
made a constructor, and not use slot access @ directly)


makeS3Foo()$z

NULL

makeS4Foo()@z

Error: no slot of name z for this object of class S4Foo

and reflection on the class


getClass(S4Foo)

Class “S4Foo” [in .GlobalEnv]

Slots:

Name:x   y
Class: numeric numeric


Some of the tools for documenting S3 classes and methods are more mature
than for S4 (e.g., package.skeleton does a better job of making a
package containing my existing S3 code objects, but I usually use
package.skeleton to start a project, not to move existing objects into a
new project). The fact that the class has been declared explicitly means
 that I'm expected to document it explicitly (in contrast to, say, the
result of lm(), which is documented only as the return value of the
function) and this then requires decisions about how to group class and
method documentation.

Using more complicated S4 features can be, well, more complicated. But
then these features are not readily available with S3, so...

To touch on a couple of other themes in this thread... Using a '.' in a
variable name seems like a very bad idea, given the way S3 dispatch
works. I like to think of objects as nouns and functions as verbs, and
so prefer to capitalize class names (as though they were proper nouns)
and lower-case function names (so they have a more dynamic 

Re: [R] interactions and stall or memory shortage

2009-09-01 Thread Ben Bolker


  The short answer is that you're trying to make a categorical interaction
out of
continuous variables, so that the resulting factors i2 and i3 have 1050 and
7200
levels respectively.  (Note to people trying to reproduce this example:
you'll
need library(emdbook); library(bbmle); data(Lily_sum) ...)  It'll take me a
little
longer to come up with a more satisfactory answer, but the bottom line is
that interactions in a continuous context are generally *products* rather
than
all combinations of levels ...


alexander russell-2 wrote:
 
 Hello,
 
 After putting together interaction code that worked for a single pair of
 interactions, when I try to evaluate two pairs of interactions(
 flowers*gopher, flowers*rockiness) my computer runs out of memory, and the
 larger desktop I use just doesn't go anywhere after about 20 minutes.
 
 Is it really that big a calculation?
 
 to start:
 
 mle2(minuslogl = Lily_sum$seedlings ~ dnbinom(mu = a, size = k),
 
 start = list(a = 10, k = 1))
 then:
 i2-interaction(Lily_sum$flowers, Lily_sum$gopher)
 
 i3-interaction(Lily_sum$flowers, Lily_sum$rockiness)
 
 mle2(Lily_sum$seedlings ~ dnbinom(mu = a, size = k), start=list(a=10,k=1)
 ,parameters=list(a~i3+i2+Lily_sum$flowers))
 
 (the last run leads to a stalled calculation)
 
 regards,
 
 R
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/interactions-and-stall-or-memory-shortage-tp25221662p25240372.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] Google's R Style Guide

2009-09-01 Thread Gabor Grothendieck
On Tue, Sep 1, 2009 at 8:58 AM, Martin Morganmtmor...@fhcrc.org wrote:
 It seems relevant to compare S3 and S4 code for doing S3-style
 programming, leaving more 'advanced' S4 for another day. In S3 I might
 define a simple class and method as


 makeS3Foo -
    function(x=numeric(), y=numeric())
 {
    if (class(x) != numeric)
        stop('x' must be numeric)
    if (class(y) != numeric)
        stop('y' must be numeric)
    l - list(x=x, y=y)
    class(l) - S3Foo
    l
 }

This shorter version would suffice:

makeS3Foo - function(x = numeric(), y = numeric()) {
   stopifnot(inherits(x, numeric), inherits(y, numeric))
   structure(list(x = x, y = y), class = S3Foo)
}
doS3 - function(x, ...) UseMethod(doS3)
doS3.S3Foo - function(x, ...) doS3 of S3Foo
doS3.default - function(x, ...) doS3 default


 doS3 - function(x, ...) NextMethod(doS3)

 doS3.default - function(x, ...) doS3 default

 doS3.S3Foo - function(x, ...) doS3 of S3Foo


 with an example of use being

 doS3(makeS3Foo())
 [1] doS3 of S3Foo


 I use 'makeS3Foo' as a constructor, so that whenever I make an instance
 of what I'm calling class S3Foo, I have some guarantees about its structure.

 The S4 implementation might be


 setClass(S4Foo, representation(x=numeric, y=numeric))

 makeS4Foo -
    function(x = numeric(), y=numeric(), ...)
 {
    new(S4Foo, x=x, y=y, ...)
 }

 setGeneric(doS4, function(x, ...) standardGeneric(doS4),
           useAsDefault=function(x, ...) do default)

 setMethod(doS4, S4Foo, function(x, ...) doS4 of S4Foo)

 and use with

 doS4(makeS4Foo())
 [1] doS4 of S4Foo

 It seems like the translation between the two is really quite
 transparent, and equally arcane to someone new to R.

 Some things I get from S4 are a level of automatic type checking

 makeS4Foo(x=bar)
 Error in validObject(.Object) :
  invalid class S4Foo object: invalid object for slot x in class
 S4Foo: got class character, should be or extend class numeric

This is also the case for S3 (despite the use of less code for S3).

   makeS3Foo(x = bar)
  Error: inherits(x, numeric) is not TRUE


 a way of knowing that my 'S4Foo' conforms to expectations -- in S3 I can say

  l = list(a=1, b=2)
  class(l) - S3Foo

 and have no way of knowing whether this is 'valid' or not; in S4 I would
 not use this method of creating a class (I'd use my constructor, or
 perhaps 'new' if I were being undisciplined, and get type checking as
 above) but if I did I'd be able to find

Its not too likely that one will do the above if they are given a
constructor like makeS3Foo.  On the other hand the ability
to work at a lower level means that one can create variations
of objects which were not originally anticipated thus avoiding
having to design the system for every possible eventuality.


 class(l) - S4Foo
 validObject(l)
 Error in validObject(l) :
  invalid class S4Foo object: slots in class definition but not in
 object: x, y

 an error when I try and access data not in the class (normally I'd have
 made a constructor, and not use slot access @ directly)

 makeS3Foo()$z
 NULL
 makeS4Foo()@z
 Error: no slot of name z for this object of class S4Foo

 and reflection on the class

 getClass(S4Foo)
 Class “S4Foo” [in .GlobalEnv]

 Slots:

 Name:        x       y
 Class: numeric numeric

But overall its easier to access the methods and objects in
S3 so discovering what is going on is easier.

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


[R] Strange error returned or bug in gam in mgcv????

2009-09-01 Thread Corrado
Dear friends,

what is this error message in gam I cannot understand what it means  
is it a bug?

gam_bray_scot24_pc_0505gam(bray~s(PC1,PC2,PC3,PC4,PC5,
PC1.1,PC2.1,PC3.1,PC4.1,PC5.1),data=dist_scot24_vector_with_climate)

Error in if (length(data) != vl) { :
  missing value where TRUE/FALSE needed
Calls: gam ... smooth.construct - smooth.construct.tp.smooth.spec - array
In addition: Warning message:
In array(0, n * k) : NAs introduced by coercion
Execution halted

Thanks in advance,

Best regards
-- 
Corrado Topi

Global Climate Change  Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] Strange error returned or bug in gam in mgcv????

2009-09-01 Thread David Winsemius


On Sep 1, 2009, at 9:51 AM, Corrado wrote:


Dear friends,

what is this error message in gam I cannot understand what it  
means 

is it a bug?

gam_bray_scot24_pc_0505gam(bray~s(PC1,PC2,PC3,PC4,PC5,
PC1.1,PC2.1,PC3.1,PC4.1,PC5.1),data=dist_scot24_vector_with_climate)


If the code was as posted, you have entered  where you probably  
wanted -.


Error in if (length(data) != vl) { :
 missing value where TRUE/FALSE needed
Calls: gam ... smooth.construct - smooth.construct.tp.smooth.spec - 
 array

In addition: Warning message:
In array(0, n * k) : NAs introduced by coercion
Execution halted

Thanks in advance,

Best regards
--
Corrado Topi

Global Climate Change  Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


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] Strange error returned or bug in gam in mgcv????

2009-09-01 Thread Corrado
Nope Of course, it was just a copy and paste problem 

On Tuesday 01 September 2009 15:00:34 David Winsemius wrote:
 On Sep 1, 2009, at 9:51 AM, Corrado wrote:
  Dear friends,
 
  what is this error message in gam I cannot understand what it
  means 
  is it a bug?
 
  gam_bray_scot24_pc_0505gam(bray~s(PC1,PC2,PC3,PC4,PC5,
  PC1.1,PC2.1,PC3.1,PC4.1,PC5.1),data=dist_scot24_vector_with_climate)

 If the code was as posted, you have entered  where you probably
 wanted -.

  Error in if (length(data) != vl) { :
   missing value where TRUE/FALSE needed
  Calls: gam ... smooth.construct - smooth.construct.tp.smooth.spec -
 
   array
 
  In addition: Warning message:
  In array(0, n * k) : NAs introduced by coercion
  Execution halted
 
  Thanks in advance,
 
  Best regards
  --
  Corrado Topi
 
  Global Climate Change  Biodiversity Indicators
  Area 18,Department of Biology
  University of York, York, YO10 5YW, UK
  Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html and provide commented,
  minimal, self-contained, reproducible code.

 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT



-- 
Corrado Topi

Global Climate Change  Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] Google's R Style Guide (has become S3 vs S4, in part)

2009-09-01 Thread Bryan Hanson
Looks like the discussion is no longer about R Style, but S3 vs S4?

To that end, I asked more or less the same question a few weeks ago, arising
from the much the same motivations.  The discussion was helpful, here's the
link:  

http://www.nabble.com/Need-Advice%3A-Considering-Converting-a-Package-from-S
3-to-S4-tc24901482.html#a24904049

For what it's worth, I decided, but with some ambivalence, to stay with S3
for now and possibly move to S4 later.  In the spirit of S4, I did write a
function that is nearly the equivalent of validObject for my S3 object of
interest.

Overall, it looked like I would have to spend a lot of time moving to S4,
while staying with S3 would allow me to get the project done and get results
going much faster (see Frank Harrell's comment in the thread above).

As a concrete example (concrete for us non-programmers, non-statisticians),
I recently decided that I wanted to add a descriptive piece of text to a
number of my plots, and it made sense to include the text with the object.
So I just added a list element to the existing S3 object, e.g.
Myobject$descrip  No further work was necessary, I could use it right away.
If instead, if I had made Myobject an S4 object, then I would have to go
back, redefine the object, update validObject, and possibly write some new
accessor and definitely constructor functions.  At least, that's how I
understand the way one uses S4 classes.

Back to trying to get something done!  Bryan
*
Bryan Hanson
Professor of Chemistry  Biochemistry
DePauw University, Greencastle IN USA





On 9/1/09 6:16 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:

 Corrado wrote:
 Thanks Duncan, Spencer,
 
 To clarify, the situation is:
 
 1) I have no reasons to choose S3 on S4 or vice versa, or any other coding
 convention
 2) Our group has not done any OO developing in R and I would be the first, so
 I 
 can set up the standards
 3) I am starting from scratch with a new package, so I do not have any code I
 need to re-use.
 4) I am an R OO newbie, so whatever I can learn from the beginning what is
 better and good for me.
 
 So the questions would be two:
 
 1) What coding style guide should we / I follow? Is the google style guide
 good, or is there something better / more prescriptive which makes our
 research group life easier?
   
 
 I don't think I can answer that.  I'd recommend planning to spend some
 serious time on the decision, and then go by your personal impression.
 S4 is definitely harder to learn but richer, so don't make the decision
 too quickly.  Take a look at John Chamber's new book, try small projects
 in each style, etc.
 
 2) What class type should I use? From what you two say, I should use S3
 because is easier to use  what are the disadvantages? Is there an
 advantages / disadvantages table for S3 and S4 classes?
   
 
 S3 is much more limited than S4.  It dispatches on just one argument, S4
 can dispatch on several.  S3 allows you to declare things to be of a
 certain class with no checks that anything will actually work; S4 makes
 it easier to be sure that if you say something is of a certain class, it
 really is.  S4 hides more under the hood: if you understand how regular
 R functions work, learning S3 is easy, but there's still a lot to learn
 before you'll be able to use S4 properly.
 
 Duncan Murdoch
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Strange error returned or bug in gam in mgcv???? - additional information

2009-09-01 Thread Corrado
Here I pasted the code from when I opened the R shell, so that it possible to 
see what is going on:

http://scsys.co.uk:8002/33309?hl=onsubmit=Format+it!

Thanks in advance
-- 
Corrado Topi

Global Climate Change  Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] SVM coefficients

2009-09-01 Thread Steve Lianoglou

Hi Marlene,

I'm going to cut out much of your post and just cut to the chase:

On Sep 1, 2009, at 9:03 AM, marlene marchena wrote:

Looking only to prediction purpose the scale model is good but I’m  
mainly
interested in w. Is it possible to improve this model to get lower  
values to
w? Actually I’m trying to run the SVM-GARCH and one condition to the  
model

is that the sum of

w’s 1 (in my model I have only two independent variables).

If you have any idea how to improve the model or if you find any  
problem

with it please let me now.



In principle you should be able to do what you're after (of  
course :-), but I'm pretty sure you won't  be able to do this using  
the e1071 package since you're imposing a linear constraint on w (this  
is almost like an l1 w/o using absolute vals of w's components, no?),  
while e1071::svm is solving a convex constraint (l2 on w).


You say you're mainly interested in w, so are you looking for a  
means of doing feature selection? You can stick with e1071 and try  
doing recursive feature elimination (google it, you'll find mucho (aka  
SVM RFE)), or you can rig up an l1-svm which is already implemented  
for you in the penalized svm package (haven't used it myself):


cran: http://cran.r-project.org/web/packages/penalizedSVM/index.html
publication: 
http://bioinformatics.oxfordjournals.org/cgi/content/full/25/13/1711

Does that help?

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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


Re: [R] data frame

2009-09-01 Thread John Kane
Well the data frame has dimensions 0,0, to start with.

Try  dim(rm)  

What is getmeasure and what is it supposed to do?

# btw rm is NOT a good name since it also is a reserved word in R.  It removes 
objects.

To create a data.frame of your six vectors why not just say

mydata - data.frame(V1, V2, V3, V4, V5, V6)

--- On Tue, 9/1/09, Tammy Ma metal_lical...@live.com wrote:

 From: Tammy Ma metal_lical...@live.com
 Subject: [R] data frame
 To: r-help@r-project.org
 Received: Tuesday, September 1, 2009, 4:39 AM
 
 HI, R user,
 
 I generate the vectors with the same length. I want to put
 each vector into each column of data frame. Why it doesnt
 work`?
 
 rm-data.frame()
 
 for(a in 1:6){
  rm[,a]-getmeasure(p1,a,speech)
  
  }
 
 thanks a lot
 
 Tammy
 
 
 _
 Share your memories online with anyone you want.
 http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1
     [[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.
 


  __
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now
http://ca.toolbar.yahoo.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] Plot several graphs in the same window

2009-09-01 Thread swertie

Thank you very much it works well.




Henrique Dallazuanna wrote:
 
 Try this:
 
 par(mfrow = c(8,5), mar = c(1, 1, 1, 1))
 replicate(40, plot(10))
 
 On Mon, Aug 31, 2009 at 4:39 PM, swertie v_coudr...@voila.fr wrote:
 

 Hello, I would like to plot a large number of graphs (43) in a same
 window.
 I
 tried wit par(mfrow=c(8,5)), but when I give the code for the plots I
 receive a error message saying that the margins are to wide. Can someone
 help me? Is it possible to put so many graphs in a single window? Thank
 you
 --
 View this message in context:
 http://www.nabble.com/Plot-several-graphs-in-the-same-window-tp25229263p25229263.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.

 
 
 
 -- 
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O
 
   [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Plot-several-graphs-in-the-same-window-tp25229263p25235251.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] Exclude 0 values from plot

2009-09-01 Thread swertie

Hello, I have a matrix of species abundance with a lot of 0 values. I would
like to plot the species abundance vs date, but I don't want that the 0
values appear as points on my graph. Do you know how I could represent only
non-0 values? Thank you very much
-- 
View this message in context: 
http://www.nabble.com/Exclude-0-values-from-plot-tp25235290p25235290.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] data frame

2009-09-01 Thread Wolfgang Raffelsberger

Try doing somthing like this :

#your vector1  2
vect1 - 2:5
vect2 - c(3,1,6,4)

# put both vectors in data.frame
combVect - data.frame(vect1=vect1, vect2=vect2)

Note :
1) I suggest to avoid naming objects with names of already existing 
functions like rm
2) In R it is usually helpful to see your data as vetors and this way 
you can avoid for for() loop
3) Have also a look at the R-Wiki ( 
http://wiki.r-project.org/rwiki/doku.php ) and the other documents on 
www.r-project.org : There are some very good tutorials about the 
different types of data-structures and objects in R (and their use) !!!


Wolfgang

Tammy Ma a écrit :

HI, R user,

I generate the vectors with the same length. I want to put each vector into 
each column of data frame. Why it doesnt work`?

rm-data.frame()

for(a in 1:6){
 rm[,a]-getmeasure(p1,a,speech)
 
 }


thanks a lot

Tammy
  


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
CNRS UMR7104, IGBMC,  
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France

Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
wolfgang.raffelsberger (a t) igbmc.fr

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

2009-09-01 Thread swertie


Hello, I performed a Mantel test and plotted communitiy similarities. I
would like to add a least square line. I thought about using abline taking
as slope the r-statistic of the Mantel test and calculating the y-intercept
analytically. Is this method correct? Is there any function for this
calculation? Thank you
-- 
View this message in context: 
http://www.nabble.com/Mantel-test-least-square-line-tp25235402p25235402.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] Function to find angle between coordinates?

2009-09-01 Thread clair.crossup...@googlemail.com
Dear all,

I was doing some self study and was wondering if a function already
exists which allows one to determine the angle between points.  e.g.
given the following (x,y) coordinates

input: (0,1); (0,0); (1,0)

would result in:

output: 90 degrees

Best regards
C.C.

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


Re: [R] Exclude 0 values from plot

2009-09-01 Thread suzylee

test[test==0]-NA

see previous post: 

http://www.nabble.com/Replacing-0s-with-NA-td23995885.html#a23996183



swertie wrote:
 
 Hello, I have a matrix of species abundance with a lot of 0 values. I
 would like to plot the species abundance vs date, but I don't want that
 the 0 values appear as points on my graph. Do you know how I could
 represent only non-0 values? Thank you very much
 

-- 
View this message in context: 
http://www.nabble.com/Exclude-0-values-from-plot-tp25235290p25241485.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] permutation and reshuffling

2009-09-01 Thread Greg Snow
Look at ?sample for how to shuffle/permute a single vector (or rows of a data 
frame/matrix) and ?replicate for a way to do it a bunch of times and return the 
results in a nice form.

Hope this helps,

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Yonatan Nissenbaum
 Sent: Tuesday, September 01, 2009 1:35 AM
 To: r-help@r-project.org
 Subject: [R] permutation and reshuffling
 
 Hi,
 
 
 
 I'm looking for an efficient code that will enable me to reshuffle data
 (phenotype) for certain number of individuals and creating a loop that
 will
 randomly simulate it for 1 times *(permutation)*. I also need to
 find
 how I keep the information (p value for each SNP) gathered for all the
 1
 iterations.
 
 My data set looks like this (n=500):
 
 Individual #
 
 Phenotype
 
 SNP1
 
 SNP2
 
 SNP3
 
 SNP4
 
 SNP5
 
 SNP6
 
 SNP7
 
 SNP8
 
 SNP9
 
 SNP10
 
 SNP11
 
 SNP12
 
 1
 
 0
 
 T
 
 T
 
 G
 
 G
 
 A
 
 C
 
 G
 
 T
 
 A
 
 A
 
 T
 
 C
 
 2
 
 1
 
 A
 
 T
 
 C
 
 G
 
 A
 
 C
 
 G
 
 T
 
 A
 
 G
 
 T
 
 C
 
 
 
 Many thanks,
 
 
 
 Jonathan
 
   [[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] Function to find angle between coordinates?

2009-09-01 Thread Gabor Grothendieck
That is if they have length 1 as is the case here.  Normalize them
to length 1, if not.

On Tue, Sep 1, 2009 at 11:06 AM, Gabor
Grothendieckggrothendi...@gmail.com wrote:
 Since the inner product of two vectors if the cos of the
 angle between them:

 A - c(0,1); O - c(0,0); B - c(1,0)
 acos((A-O) %*% (B-O)) * 180 / pi
     [,1]
 [1,]   90


 On Tue, Sep 1, 2009 at 9:08 AM,
 clair.crossup...@googlemail.comclair.crossup...@googlemail.com
 wrote:
 Dear all,

 I was doing some self study and was wondering if a function already
 exists which allows one to determine the angle between points.  e.g.
 given the following (x,y) coordinates

 input: (0,1); (0,0); (1,0)

 would result in:

 output: 90 degrees

 Best regards
 C.C.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Best option for exporting data frame to SPSS?

2009-09-01 Thread Fredrik Karlsson
Dear list,

I am leaving my old position and now need to convert my R data frames
into a format that can be used by an SPSS user replacing me, without
running into conversion problems.
The data set consists of strings in UTF8 encoding and values in double
precision floats. The data set is not terribly large, but I had bit
problems getting it into R due to the large number of unfortunate
characters in the strings (', #,  and so on) so I was just wondering
if there is any way to get the data into a SPSS friendly format (other
than tab-separated files) so that a minimum of conversion is done in
between the two systems.
A data base file (SQLite) would be ideal, but unfortunatelly, I don't
think the recieving end would be able to handle it, i.e. get the data
into SPSS.

Sorry for asking this on the list, but I have found lots of
information about getting data safelly _into_ R in the archive, but
far les about exporting data out of R.

Please give me your best tip.

/Fredrik

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

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


Re: [R] Google's R Style Guide (has become S3 vs S4, in part)

2009-09-01 Thread spencerg

Bryan Hanson wrote:

Looks like the discussion is no longer about R Style, but S3 vs S4?

To that end, I asked more or less the same question a few weeks ago, arising
from the much the same motivations.  The discussion was helpful, here's the
link:  


http://www.nabble.com/Need-Advice%3A-Considering-Converting-a-Package-from-S
3-to-S4-tc24901482.html#a24904049

For what it's worth, I decided, but with some ambivalence, to stay with S3
for now and possibly move to S4 later.  In the spirit of S4, I did write a
function that is nearly the equivalent of validObject for my S3 object of
interest.

Overall, it looked like I would have to spend a lot of time moving to S4,
while staying with S3 would allow me to get the project done and get results
going much faster (see Frank Harrell's comment in the thread above).

As a concrete example (concrete for us non-programmers, non-statisticians),
I recently decided that I wanted to add a descriptive piece of text to a
number of my plots, and it made sense to include the text with the object.
So I just added a list element to the existing S3 object, e.g.
Myobject$descrip  No further work was necessary, I could use it right away.
If instead, if I had made Myobject an S4 object, then I would have to go
back, redefine the object, update validObject, and possibly write some new
accessor and definitely constructor functions.  At least, that's how I
understand the way one uses S4 classes.
  
 It doesn't stop there:  If you keep the same name for your 
redefined S4 class, I don't know what happens when you try to access 
stored objects of that class created before the change, but it might not 
be pretty.  If you give your redefined S4 class a different name, then 
you have a lot more code to change before you can use the redefined 
class like you want. 



 By contrast, with S3, if you have any code that tests the number 
of components in a list, that will have to be changed. 



 Spencer

Back to trying to get something done!  Bryan
*
Bryan Hanson
Professor of Chemistry  Biochemistry
DePauw University, Greencastle IN USA





On 9/1/09 6:16 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:

  

Corrado wrote:


Thanks Duncan, Spencer,

To clarify, the situation is:

1) I have no reasons to choose S3 on S4 or vice versa, or any other coding
convention
2) Our group has not done any OO developing in R and I would be the first, so
I 
can set up the standards

3) I am starting from scratch with a new package, so I do not have any code I
need to re-use.
4) I am an R OO newbie, so whatever I can learn from the beginning what is
better and good for me.

So the questions would be two:

1) What coding style guide should we / I follow? Is the google style guide
good, or is there something better / more prescriptive which makes our
research group life easier?
  
  

I don't think I can answer that.  I'd recommend planning to spend some
serious time on the decision, and then go by your personal impression.
S4 is definitely harder to learn but richer, so don't make the decision
too quickly.  Take a look at John Chamber's new book, try small projects
in each style, etc.



2) What class type should I use? From what you two say, I should use S3
because is easier to use  what are the disadvantages? Is there an
advantages / disadvantages table for S3 and S4 classes?
  
  

S3 is much more limited than S4.  It dispatches on just one argument, S4
can dispatch on several.  S3 allows you to declare things to be of a
certain class with no checks that anything will actually work; S4 makes
it easier to be sure that if you say something is of a certain class, it
really is.  S4 hides more under the hood: if you understand how regular
R functions work, learning S3 is easy, but there's still a lot to learn
before you'll be able to use S4 properly.

Duncan Murdoch

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



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

  



--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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


[R] Re gression - cluster option in STATA

2009-09-01 Thread Sunita22

Hello

In STATA there is command which has regression with clustering option. Can
anyone tell me what is the command for the same in R

for example in STATA

its regress Height Weight, cluster(id)

Thanks in Advance

Regards 

Sunita


-- 
View this message in context: 
http://www.nabble.com/Regression---cluster-option-in-STATA-tp25241948p25241948.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] Function to find angle between coordinates?

2009-09-01 Thread Erik Iverson
?atan2 is a possible starting point. 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of clair.crossup...@googlemail.com
Sent: Tuesday, September 01, 2009 8:09 AM
To: r-help@r-project.org
Subject: [R] Function to find angle between coordinates?

Dear all,

I was doing some self study and was wondering if a function already
exists which allows one to determine the angle between points.  e.g.
given the following (x,y) coordinates

input: (0,1); (0,0); (1,0)

would result in:

output: 90 degrees

Best regards
C.C.

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

2009-09-01 Thread Benoit Boulinguiez
Hi!

simple word thank you Hadley!
an answer bringing a new question... is that possible to mix the colour and
linetype representation with geom_smooth()?

I tried the following code, though it hasn't worked.
I have three different datasets due to non even x-axis (Temp) values I guess
I should handle the matter from this point...no?

CODE
#
air_N2_desorb_plot-ggplot() +

geom_smooth(data=DATA.NC60_N2_v1,

aes(Temp,-DrTGA*100,colour=N2_v1),span=0.05,size=1.6,se=F) +
geom_smooth(data=DATA.NC60_N2_v2,

aes(Temp,-DrTGA*100,colour=N2_v2),span=0.05,size=1.6,se=F) +
geom_smooth(data=DATA.NC60_air_v1,

aes(Temp,-DrTGA*100,colour=Air_v1),span=0.05,size=1.6,se=F) +

geom_smooth(data=DATA.NC60_N2_v1,

aes(Temp,-DrTGA*100,linetype=N2_v1),span=0.05,size=1.6,se=F) +
geom_smooth(data=DATA.NC60_N2_v2,

aes(Temp,-DrTGA*100,linetype=N2_v2),span=0.05,size=1.6,se=F) +
geom_smooth(data=DATA.NC60_air_v1,

aes(Temp,-DrTGA*100,linetype=Air_v1),span=0.05,size=1.6,se=F) +

scale_colour_hue(name=Desorption\n Condition) +

labs(x=Temp~(degree*C),y=Weight~Derivative~(%/*degree*C)) +
opts(panel.grid.minor = theme_line(colour = grey94))

print(air_N2_desorb_plot)


Regards/Cordialement


Benoit Boulinguiez 


-Message d'origine-
De : hadley wickham [mailto:h.wick...@gmail.com] 
Envoyé : mercredi 26 août 2009 19:58
À : Benoit Boulinguiez
Cc : r-help@r-project.org
Objet : Re: [R] ggplot2: geom_smooth and legend

Hi Benoit,

You could turn the standard errors off with se = F.  Then they'll be removed
from the legend as well.

Hadley

On Tue, Aug 18, 2009 at 7:43 AM, Benoit
Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote:
 Sorry I forgot the code that goes with

 **CODE
 desorb_plot-ggplot() +

        geom_smooth(data=DATA.B1_SA_N2,
                        
 aes(Temp,DrTGA*100,colour=B1),span=0.1,size=1.6) +
        geom_smooth(data=DATA.FM30K_SA_N2,
                        
 aes(Temp,DrTGA*100,colour=FM30K),span=0.2,size=1.6)
 +
        geom_smooth(data=DATA.NC60_SA_N2,
                        
 aes(Temp,-DrTGA*100,colour=NC60),span=0.1,size=1.6)
 +
        geom_smooth(data=DATA.THC515_SA_N2,

  aes(Temp,DrTGA*100,colour=THC515),span=0.2,size=1.6) +

        scale_colour_hue(name=Adsorbent) +
        labs(x=Temp~(degree*C),y=Weight~Derivative~(%/*degree*C)) +
        opts(panel.grid.minor = theme_line(colour = grey94))

 print(desorb_plot)


 Cordialement / Regards

 ---
 Benoit Boulinguiez
 Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 
 Sciences Chimiques de Rennes
 Avenue du Général Leclerc
 CS 50837
 35708 Rennes CEDEX 7
 Tel 33 (0)2 23 23 80 83
 Fax 33 (0)2 23 23 81 20
 http://www.ensc-rennes.fr/


 Quoting Benoit Boulinguiez benoit.boulingu...@ensc-rennes.fr:

 Hi all,

 Is that possible to remove the grey colour in the legend key that 
 goes with the geom_smooth? In my case it doesn't ease the reading of 
 the legend.

 http://www.4shared.com/file/125864977/e10644f8/desorb.html


 Cordialement / Regards

 ---
 Benoit Boulinguiez
 Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 
 6226 Sciences Chimiques de Rennes
 Avenue du Général Leclerc
 CS 50837
 35708 Rennes CEDEX 7
 Tel 33 (0)2 23 23 80 83
 Fax 33 (0)2 23 23 81 20
 http://www.ensc-rennes.fr/

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




--
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] Function to find angle between coordinates?

2009-09-01 Thread Gabor Grothendieck
Since the inner product of two vectors if the cos of the
angle between them:

 A - c(0,1); O - c(0,0); B - c(1,0)
 acos((A-O) %*% (B-O)) * 180 / pi
 [,1]
[1,]   90


On Tue, Sep 1, 2009 at 9:08 AM,
clair.crossup...@googlemail.comclair.crossup...@googlemail.com
wrote:
 Dear all,

 I was doing some self study and was wondering if a function already
 exists which allows one to determine the angle between points.  e.g.
 given the following (x,y) coordinates

 input: (0,1); (0,0); (1,0)

 would result in:

 output: 90 degrees

 Best regards
 C.C.

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


Re: [R] Google's R Style Guide

2009-09-01 Thread Vitalie S.

On Tue, 01 Sep 2009 10:47:36 +0200, Corrado ct...@york.ac.uk wrote:


Thanks Duncan, Spencer,

To clarify, the situation is:

1) I have no reasons to choose S3 on S4 or vice versa, or any other  
coding

convention
2) Our group has not done any OO developing in R and I would be the  
first, so I

can set up the standards
3) I am starting from scratch with a new package, so I do not have any  
code I

need to re-use.
4) I am an R OO newbie, so whatever I can learn from the beginning what  
is

better and good for me.


From my experience I can recommend tree things:

1) If hierarchy of your classes is complicated ( i.e. at least 3 levels of  
inheritance) and/or you intend to merge functionality of several classes  
into one (multiple inheritance), it's better to use S4, otherwise use S3.  
Majority of statistical models in R seem not to require even 2 levels of  
inheritance and OO is used mainly for method dispatch, so S3 is quite  
sufficient.


2) If your classes are meant to provide functionality for fundamental  
objects that you intend to use latter to build more complex structures,  
then use S4 (example could be super.data.frame or super.matrix, or  
implementation of sets etc). Usually this fundamental objects are  
derived from basic pseudo-classes in R like function and numeric. You  
can use S4 object to build your S3 objects latter without any trouble.  
Though starting R 2.8 one can integrate quite happily S3 objects into S4  
and even inherit S4 from S3, that is somewhat artificial and generally not  
encouraged.



3) If you start with S4 try to avoid writing validity and initialization  
methods at the beginning. Put everything in the constructors, pretty much  
as in S3 style.


Vitalie.


So the questions would be two:

1) What coding style guide should we / I follow? Is the google style  
guide

good, or is there something better / more prescriptive which makes our
research group life easier?
2) What class type should I use? From what you two say, I should use S3
because is easier to use  what are the disadvantages? Is there an
advantages / disadvantages table for S3 and S4 classes?

Thanks



--

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


Re: [R] Re gression - cluster option in STATA

2009-09-01 Thread Bert Gunter
A guess, as I don't know STATA:

?lme (library(nlme) first)

(also perhaps anova with an Error term -- ?anova)

But:

R is not STATA
R is not SAS
R is not SPSS
...

R is R
So do not expect the same paradigms to hold; but because R IS R, one can
always program ways to make them hold.


Bert Gunter
Genentech Nonclinical Biostatistics

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Sunita22
Sent: Tuesday, September 01, 2009 8:03 AM
To: r-help@r-project.org
Subject: [R] Re gression - cluster option in STATA


Hello

In STATA there is command which has regression with clustering option. Can
anyone tell me what is the command for the same in R

for example in STATA

its regress Height Weight, cluster(id)

Thanks in Advance

Regards 

Sunita


-- 
View this message in context:
http://www.nabble.com/Regression---cluster-option-in-STATA-tp25241948p252419
48.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] Google's R Style Guide

2009-09-01 Thread Henrik Bengtsson
On Tue, Sep 1, 2009 at 6:29 AM, Duncan Murdochmurd...@stats.uwo.ca wrote:
 On 9/1/2009 8:58 AM, Martin Morgan wrote:

 Corrado wrote:

 Thanks Duncan, Spencer,

 To clarify, the situation is:

 1) I have no reasons to choose S3 on S4 or vice versa, or any other
 coding convention
 2) Our group has not done any OO developing in R and I would be the
 first, so I can set up the standards
 3) I am starting from scratch with a new package, so I do not have any
 code I need to re-use.

 One consideration might be the domain in which you are doing
 development; Bioconductor for instance makes extensive use of S4 and
 your efforts at learning to develop S4 would pay off both in your own
 code and in understanding other packages.

 4) I am an R OO newbie, so whatever I can learn from the beginning what
 is better and good for me.

 So the questions would be two:

 1) What coding style guide should we / I follow? Is the google style
 guide good, or is there something better / more prescriptive which makes our
 research group life easier? 2) What class type should I use? From what you
 two say, I should use S3 because is easier to use  what are the
 disadvantages? Is there an advantages / disadvantages table for S3 and S4
 classes?

 It seems relevant to compare S3 and S4 code for doing S3-style
 programming, leaving more 'advanced' S4 for another day. In S3 I might
 define a simple class and method as


 makeS3Foo -
    function(x=numeric(), y=numeric())
 {
    if (class(x) != numeric)
        stop('x' must be numeric)
    if (class(y) != numeric)
        stop('y' must be numeric)
    l - list(x=x, y=y)
    class(l) - S3Foo
    l
 }

 doS3 - function(x, ...) NextMethod(doS3)

 doS3.default - function(x, ...) doS3 default

 doS3.S3Foo - function(x, ...) doS3 of S3Foo


 with an example of use being

 doS3(makeS3Foo())

 [1] doS3 of S3Foo


 That looks as though it was written by an S4 user.  I would write it this
 way (with some differences in behaviour):

 S3Foo - function(x=numeric(), y=numeric()) {
  structure(list(x=as.numeric(x), y=as.numeric(y)), class=S3Foo)
 }

 The rest of my code would be pretty similar to yours, though I think it
 should use UseMethod(doS3) rather than NextMethod(doS3).

 Duncan Murdoch



 I use 'makeS3Foo' as a constructor, so that whenever I make an instance
 of what I'm calling class S3Foo, I have some guarantees about its
 structure.

 The S4 implementation might be


 setClass(S4Foo, representation(x=numeric, y=numeric))

 makeS4Foo -
    function(x = numeric(), y=numeric(), ...)
 {
    new(S4Foo, x=x, y=y, ...)
 }

In S3 using R.methodsS3/R.oo utility functions:

library(R.oo);

setConstructorS3(S3Foo, function(x=numeric, y=numeric) {
  # Validate arguments
  stopifnot(inherits(x, numeric));
  stopifnot(inherits(y, numeric));

  extend(list(x=x, y=y), S3Foo);  # similar to structure().
})

Naming guideline: Name the *constructor* function the same as your
class; this will make things consistent and help you and the user.

Note, you don't want to use class(x) != numeric, because class(x)
may return a vector; always use inherits().

Then, to setup methods for this class, do:

setMethodS3(print, S3Foo, function(object, ...) {
  ...
})

setMethodS3(plot, S3Foo, function(object, ...) {
  ...
})

Generic functions are created automagically when missing; no need for
you to specify that explicitly.

Dispatching in S3 is on the first argument only.  FYI, it is extremely
rare that you want to dispatch on other arguments although you hear
that in the context of S4; I only know of one use case with formulas.

One purpose of R.methodsS3/R.oo is to ease any transitions to S4.

/Henrik


 setGeneric(doS4, function(x, ...) standardGeneric(doS4),
           useAsDefault=function(x, ...) do default)

 setMethod(doS4, S4Foo, function(x, ...) doS4 of S4Foo)

 and use with

 doS4(makeS4Foo())

 [1] doS4 of S4Foo

 It seems like the translation between the two is really quite
 transparent, and equally arcane to someone new to R.

 Some things I get from S4 are a level of automatic type checking

 makeS4Foo(x=bar)

 Error in validObject(.Object) :
  invalid class S4Foo object: invalid object for slot x in class
 S4Foo: got class character, should be or extend class numeric

 a way of knowing that my 'S4Foo' conforms to expectations -- in S3 I can
 say

  l = list(a=1, b=2)
  class(l) - S3Foo

 and have no way of knowing whether this is 'valid' or not; in S4 I would
 not use this method of creating a class (I'd use my constructor, or
 perhaps 'new' if I were being undisciplined, and get type checking as
 above) but if I did I'd be able to find

 class(l) - S4Foo
 validObject(l)

 Error in validObject(l) :
  invalid class S4Foo object: slots in class definition but not in
 object: x, y

 an error when I try and access data not in the class (normally I'd have
 made a constructor, and not use slot access @ directly)

 makeS3Foo()$z

 NULL

 makeS4Foo()@z

 Error: no slot of name z for this object of 

Re: [R] ggplot2: geom_smooth and legend

2009-09-01 Thread Benoit Boulinguiez
I cleared out the data frame, I have now one data frame with all the values
in as a function of the experimental condition.

+ successfully mix the linestyle and colour_hue representation of the
geom_smooth though it doesn't look good


NEW CODE
 
air_N2_desorb_plot-ggplot(DATA,aes(Temp,-DrTGA*100,colour=Cond)) +

geom_smooth(span=0.05,size=1.6,se=F,alpha=0.8) +
geom_smooth(aes(linetype=Cond),span=0.05,size=1.6,se=F) +

scale_colour_hue(name=Desorption\n Condition) +
scale_linetype(name=Desorption\n Condition) +

labs(x=Temp~(degree*C),y=Weight~Derivative~(%/*degree*C)) +
opts(panel.grid.minor = theme_line(colour = grey94))

print(air_N2_desorb_plot)




Regards/Cordialement


Benoit Boulinguiez 


-Message d'origine-
De : r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] De
la part de Benoit Boulinguiez
Envoyé : mardi 1 septembre 2009 17:20
À : r-help@r-project.org
Objet : Re: [R] ggplot2: geom_smooth and legend

Hi!

simple word thank you Hadley!
an answer bringing a new question... is that possible to mix the colour and
linetype representation with geom_smooth()?

I tried the following code, though it hasn't worked.
I have three different datasets due to non even x-axis (Temp) values I guess
I should handle the matter from this point...no?

CODE
#
air_N2_desorb_plot-ggplot() +

geom_smooth(data=DATA.NC60_N2_v1,

aes(Temp,-DrTGA*100,colour=N2_v1),span=0.05,size=1.6,se=F) +
geom_smooth(data=DATA.NC60_N2_v2,

aes(Temp,-DrTGA*100,colour=N2_v2),span=0.05,size=1.6,se=F) +
geom_smooth(data=DATA.NC60_air_v1,

aes(Temp,-DrTGA*100,colour=Air_v1),span=0.05,size=1.6,se=F) +

geom_smooth(data=DATA.NC60_N2_v1,

aes(Temp,-DrTGA*100,linetype=N2_v1),span=0.05,size=1.6,se=F) +
geom_smooth(data=DATA.NC60_N2_v2,

aes(Temp,-DrTGA*100,linetype=N2_v2),span=0.05,size=1.6,se=F) +
geom_smooth(data=DATA.NC60_air_v1,

aes(Temp,-DrTGA*100,linetype=Air_v1),span=0.05,size=1.6,se=F) +

scale_colour_hue(name=Desorption\n Condition) +

labs(x=Temp~(degree*C),y=Weight~Derivative~(%/*degree*C)) +
opts(panel.grid.minor = theme_line(colour = grey94))

print(air_N2_desorb_plot)


Regards/Cordialement


Benoit Boulinguiez 


-Message d'origine-
De : hadley wickham [mailto:h.wick...@gmail.com] Envoyé : mercredi 26 août
2009 19:58 À : Benoit Boulinguiez Cc : r-help@r-project.org Objet : Re: [R]
ggplot2: geom_smooth and legend

Hi Benoit,

You could turn the standard errors off with se = F.  Then they'll be removed
from the legend as well.

Hadley

On Tue, Aug 18, 2009 at 7:43 AM, Benoit
Boulinguiezbenoit.boulingu...@ensc-rennes.fr wrote:
 Sorry I forgot the code that goes with

 **CODE
 desorb_plot-ggplot() +

        geom_smooth(data=DATA.B1_SA_N2,
                        
 aes(Temp,DrTGA*100,colour=B1),span=0.1,size=1.6) +
        geom_smooth(data=DATA.FM30K_SA_N2,
                        
 aes(Temp,DrTGA*100,colour=FM30K),span=0.2,size=1.6)
 +
        geom_smooth(data=DATA.NC60_SA_N2,
                        
 aes(Temp,-DrTGA*100,colour=NC60),span=0.1,size=1.6)
 +
        geom_smooth(data=DATA.THC515_SA_N2,

  aes(Temp,DrTGA*100,colour=THC515),span=0.2,size=1.6) +

        scale_colour_hue(name=Adsorbent) +
        labs(x=Temp~(degree*C),y=Weight~Derivative~(%/*degree*C)) +
        opts(panel.grid.minor = theme_line(colour = grey94))

 print(desorb_plot)


 Cordialement / Regards

 ---
 Benoit Boulinguiez
 Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS 6226 
 Sciences Chimiques de Rennes
 Avenue du Général Leclerc
 CS 50837
 35708 Rennes CEDEX 7
 Tel 33 (0)2 23 23 80 83
 Fax 33 (0)2 23 23 81 20
 http://www.ensc-rennes.fr/


 Quoting Benoit Boulinguiez benoit.boulingu...@ensc-rennes.fr:

 Hi all,

 Is that possible to remove the grey colour in the legend key that 
 goes with the geom_smooth? In my case it doesn't ease the reading of 
 the legend.

 http://www.4shared.com/file/125864977/e10644f8/desorb.html


 Cordialement / Regards

 ---
 Benoit Boulinguiez
 Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 Equipe CIP UMR CNRS
 6226 Sciences Chimiques de Rennes
 Avenue du Général Leclerc
 CS 50837
 35708 Rennes CEDEX 7
 Tel 33 (0)2 23 23 80 83
 Fax 33 (0)2 23 23 81 20
 http://www.ensc-rennes.fr/

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




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

[R] Package NP; npregbw; selective bandwidth selection

2009-09-01 Thread otto kässi
Dear R-users,

I am fitting a kernel regression model of the form y ~ x1 + factor(x2)
+ factor(x3)  and am using the function npregbw  in the np-package to
find the optimal bandwidths.

My dataset is relatively large and the optimization takes quite long.
When testing different specifications I have noticed that the optimal
bw for x3 is always very close to zero (around 10^-12 or so).  I am
wondering whether it is possible to hard code the bandwidth related to
x3 to 0 and limit npregbw's choice of bw's those related to x1 and x2?

My intuition suggests that this would reduce the number of parameters
to be optimized from 3 to 2 and thus make the computations quicker.
Furthermore the theoretical literature (e.g. [1]) seems to suggest
that this might be a good idea with categorical variables and big
datasets.

Any comments?

[1] Racine, J.S. and Q. Li (2004), Nonparametric estimation of
regression functions with both categorical and continuous Data,
Journal of Econometrics, 119, 99-130.

Best regards,

Otto Kassi
University of Helsinki
Dept. of Economics

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


[R] Simple question about error on CSV import

2009-09-01 Thread esawdust


I have a substantial CSV to import but can't seem to import even the
simplest CSV.

I'm running the latest stable REvolution R on OS X if that is pertinent.

Here's the contents of a simple test2.csv CSV file:

#,Status,Project  
5842,New,Test

 snortalerts = read.table( /Users/lcox/Documents/test2.csv, header=TRUE,
 sep=,, row.names=#)
Error in data[[rowvar]] : attempt to select less than one element

I can't see how it could get any more simple, yet it doesn't work.  I'm
obviously missing something basic, but based on the error, I can't see what
it is.

Landon
-- 
View this message in context: 
http://www.nabble.com/Simple-question-about-error-on-CSV-import-tp25242899p25242899.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] X11 plot window sizes

2009-09-01 Thread Mark Knecht
Hi,
   I'm not understanding how the width  height parameters are
supposed to work. When I execute the following 4 commands:

X11()
X11(width=20, height=20)
X11(width=20, height=10)
X11(width=40, height=40)

I get the following *approximate* physical sizes on my screen:

6 x 6
8 x 8
12 x 6
8 x 8

   For now I'm assuming that my pointsize isn't quite the same as
expected (1/72) which probably accounts for why I'm getting 6
windows instead of the default 7 window, but why does 20x20 == 40x40,
and why on the 20x10 version do I get a 6 height?

Thanks,
Mark

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


Re: [R] Google's R Style Guide (has become S3 vs S4, in part)

2009-09-01 Thread Martin Morgan
spencerg wrote:
 Bryan Hanson wrote:
 Looks like the discussion is no longer about R Style, but S3 vs S4?

yes nice topic rename!


 To that end, I asked more or less the same question a few weeks ago,
 arising
 from the much the same motivations.  The discussion was helpful,
 here's the
 link: 
 http://www.nabble.com/Need-Advice%3A-Considering-Converting-a-Package-from-S

 3-to-S4-tc24901482.html#a24904049

 For what it's worth, I decided, but with some ambivalence, to stay
 with S3
 for now and possibly move to S4 later.  In the spirit of S4, I did
 write a
 function that is nearly the equivalent of validObject for my S3 object of
 interest.

 Overall, it looked like I would have to spend a lot of time moving to S4,
 while staying with S3 would allow me to get the project done and get
 results
 going much faster (see Frank Harrell's comment in the thread above).

Bryan's original post started me thinking about this, but I didn't
respond. I'd classify myself as an 'S4' 'expert', with my ignorance of
S3 obvious from Duncan's corrections to my earlier post. It's hard for
me to make a comparative statement about S3 vs. S4, and hard really to
know what is 'hard' for someone new to S4, to R, to programming, ... I
would have classified most of the responses in that thread as coming
from 'S3' 'experts'.

 As a concrete example (concrete for us non-programmers,
 non-statisticians),
 I recently decided that I wanted to add a descriptive piece of text to a
 number of my plots, and it made sense to include the text with the
 object.
 So I just added a list element to the existing S3 object, e.g.
 Myobject$descrip  No further work was necessary, I could use it right
 away.
 If instead, if I had made Myobject an S4 object, then I would have to go
 back, redefine the object, update validObject, and possibly write some
 new
 accessor and definitely constructor functions.  At least, that's how I
 understand the way one uses S4 classes.

This is a variant of Gabor's comment, I guess, that it's easy to modify
S3 on an as-needed basis. In S3, forgoing any pretext of 'best
practices', one might

s3 - structure(list(x=1:10, y=10:1), class=MyS3Object)
## some lines of code...
if (aTest)
s3$descraption - A description

(either 'description' or 'discraption' is a typo, uncaught by S3).

In S4 I'd have to change my class definition from

setClass(MyS4Object, representation(x=numeric, y=numeric))

to

setClass(MyS4Object, representation(x=numeric, y=numeric,
 description=character))

but the body of the code would look surprising similar

s4 - new(MyS4Object, x=1:10, y=10:1)
## some lines of code...
if (aTest)
s...@description - A description

(no typo, because I'd have been told that the slot 'discraption' didn't
exist). In the S3 case the (implicit) class definition is a single line,
perhaps nested deep inside a function. In S4 the class definition is in
a single location.

Best practices might make me want to have a validity method (x and y the
same dimensions? 'description' of length 1?), to use a constructor and
accessors (to provide an abstraction to separate the interface from its
implementation), etc., but those issues are about best practices.

A downstream consequence is that s4 always has a 'description' slot
(perhaps initialized with an appropriate default in the 'prototype'
argument of setClass, but that's more advanced), whereas s3 only
sometimes has 'description'. So I'm forced to check
is.null(s3$description) whenever I'm expecting a character vector.

  It doesn't stop there:  If you keep the same name for your
 redefined S4 class, I don't know what happens when you try to access
 stored objects of that class created before the change, but it might not
 be pretty.  If you give your redefined S4 class a different name, then

Actually, the old object is loaded in R. It is not valid
(validObject(originalS4) would complain about 'slots in class definition
not in object'). One might write an 'updateObject' generic and method
that detects and corrects this. This contrasts with S3, where there is
no knowing whether the object is consistent with the current (implicit)
class definition.

 you have a lot more code to change before you can use the redefined
 class like you want.

For slot addition, this is not true -- old code works fine. For slot
removal / renaming, this is analogous to S3 -- code needs reworking; use
of accessors might help isolate code using the class from the
implementation of the class.

A couple of comments on Duncan's

S3Foo - function(x=numeric(), y=numeric()) {
  structure(list(x=as.numeric(x), y=as.numeric(y)), class=S3Foo)
}

I used makeS3Foo to emphasize that it was a constructor, but in my own
code I use S3Foo(). Realizing that, as Henrik has now also pointed out,
I'm far from perfect, the use of as.numeric() combines validity checking
and coercion, which I think is not usually a good thing (even when
efficient). In particular this

  as.numeric(factor(c(one, two, three)))


Re: [R] Simple question about error on CSV import

2009-09-01 Thread esawdust


esawdust wrote:
 
 Here's the contents of a simple test2.csv CSV file:
 
 #,Status,Project  
 5842,New,Test
 
 snortalerts = read.table( /Users/lcox/Documents/test2.csv, header=TRUE,
 sep=,, row.names=#)
 Error in data[[rowvar]] : attempt to select less than one element
 
 Landon
 

Figured out the answer, though it wasn't obvious (to me anyway).  The symbol
# used as the first column label was the problem.   I changed that to be
id and changed the read.table to be:

snortalerts - read.table( /Users/lcox/Documents/test2.csv, header=TRUE,
sep=,, row.names=id)

and it worked fine.  
-- 
View this message in context: 
http://www.nabble.com/Simple-question-about-error-on-CSV-import-tp25242899p25243159.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] pls package

2009-09-01 Thread Payam Minoofar
Thank you so very much. Yes, a statistician friend expressed his  
certainty that NAs cannot be handled by such algorithms, and you just  
answered the R specific questions.

I will prune the data more and feed them into pls as matrices.

I am, in fact, following the examples your provide with the package  
and the Vol 6 no. 3 issue of the R Newsletter.

Payam
__
Payam Minoofar, Ph.D.
Scientist
Meissner Filtration Products
4181 Calle Tesoro
Camarillo, CA 93012
+1 805 388 9911 ext. 159
+1 805 388 5948 fax
payam.minoo...@meissner.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] Simple question about error on CSV import

2009-09-01 Thread William Dunlap

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of esawdust
 Sent: Tuesday, September 01, 2009 8:53 AM
 To: r-help@r-project.org
 Subject: [R] Simple question about error on CSV import
 
 
 
 I have a substantial CSV to import but can't seem to import even the
 simplest CSV.
 
 I'm running the latest stable REvolution R on OS X if that is 
 pertinent.
 
 Here's the contents of a simple test2.csv CSV file:
 
 #,Status,Project  
 5842,New,Test
 
  snortalerts = read.table( 
 /Users/lcox/Documents/test2.csv, header=TRUE,
  sep=,, row.names=#)
 Error in data[[rowvar]] : attempt to select less than one element
 
 I can't see how it could get any more simple, yet it doesn't 
 work.  I'm
 obviously missing something basic, but based on the error, I 
 can't see what
 it is.

Using '#' for the initial column name presents 2 problems:
   (a) # is the default comment character so that line is
   ignored.  Add the read.table argument comment.char=
   to take care of that.
   (b) It looks like the column names are converted to legal
   R names before the row.names=name is processed
   and the # is not legal so it becomes something random
   like X..  If you turn off this conversion to legal names
   with check.names=FALSE then things will work.  It
   might be better to use the index of the row.names column
   instead of the name, as in row.names=1.

E.g.,

 t-#,Status,Project\n5842,New,Test\n
 read.table(textConnection(t), header=TRUE, sep=,, comment.char=,
check.names=FALSE, row.names=#)
 Status Project
5842NewTest
 read.table(textConnection(t), header=TRUE, sep=,, comment.char=,
row.names=1)
 Status Project
5842NewTest

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com 
 
 Landon
 -- 
 View this message in context: 
 http://www.nabble.com/Simple-question-about-error-on-CSV-impor
 t-tp25242899p25242899.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] Simple question about error on CSV import

2009-09-01 Thread Levi Waldron
 By default for read.table,

comment.char = #

so the first line was being treated as a comment line, and when you
specified row.names=#, read.table couldn't find that column.

On Tue, Sep 1, 2009 at 12:07 PM, esawdust lan...@360vl.com wrote:



 esawdust wrote:
 
  Here's the contents of a simple test2.csv CSV file:
 
  #,Status,Project
  5842,New,Test
 
  snortalerts = read.table( /Users/lcox/Documents/test2.csv,
 header=TRUE,
  sep=,, row.names=#)
  Error in data[[rowvar]] : attempt to select less than one element
 
  Landon
 

 Figured out the answer, though it wasn't obvious (to me anyway).  The
 symbol
 # used as the first column label was the problem.   I changed that to be
 id and changed the read.table to be:

 snortalerts - read.table( /Users/lcox/Documents/test2.csv, header=TRUE,
 sep=,, row.names=id)

 and it worked fine.
 --
 View this message in context:
 http://www.nabble.com/Simple-question-about-error-on-CSV-import-tp25242899p25243159.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.




-- 
Levi Waldron
post-doctoral fellow
Jurisica Lab, Ontario Cancer Institute
Division of Signaling Biology
TMDT 9-304D
101 College Street
Toronto, Ontario M5G 1L7
(416)581-7453

[[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] Combining: R + Condor in 2009 ? (+foreach maybe?)

2009-09-01 Thread David M Smith
There's no explicit link between foreach and Condor right now (although
foreach is designed to work with any backend, so someone could write one if
they wanted). If you use the NetworkSpaces back end (registerDoNWS in
REvolutionR Enterprise), and can access members of the Condor cluster
directly, you could always just set up a sleigh manually -- instructions are
in the ParallelR manual. I expect you can do the same with snow (via the
doSNOW package for foreach).
Hope this helps,
# David Smith

On Sun, Aug 30, 2009 at 3:28 PM, Tal Galili tal.gal...@gmail.com wrote:

 Hello dear R-help group (and David Smith from REvolution),

 I would like to perform parallel computing using R with Condor (hopefully
 using foreach or other recommended solutions, if available) for some
 Embarrassingly parallel problem.
 I will start by listing what I found so far, and then go on asking for
 help.

 So far I found the a manual by Xianhong Xie from Rnews_2005-2 (see page 13)
 Talking about R and condor:
 http://cran.r-project.org/doc/Rnews/Rnews_2005-2.pdf

 I also found several references for R and condor in the task views of High
 Performance 
 Computinghttp://cran.r-project.org/web/views/HighPerformanceComputing.html
 :
 http://cran.r-project.org/web/views/HighPerformanceComputing.html
 Stating that: The 
 GridRhttp://cran.r-project.org/web/packages/GridR/index.html package
 by Wegener et al. can be used in a grid computing environment via a web
 service, via ssh or via Condor or Globus.
 I then found a 2008 lecture slides on the subject here:
 http://www.statistik.uni-dortmund.de/useR-2008/tutorials/GridR.pdf

 And an articles showing it was already done:
 http://www.ecmlpkdd2008.org/files/pdf/workshops/ubiqkd/3.pdf
 (But without code examples to my dismay)



 What I wish from you is some guidance.
 Is there a more updated (formal) material on condor and R then Xianhong Xie
 article from 2005?
 Is GridR a good way of making the connection?
 Is using the foreach package relevant or useful here?

 I am not a UNIX person. I never ran R in batch, and any step by step
 instructions (either by referring to links or explaining here) would be of
 great help.

 Thanks in advance,
 Tal

 --


 My contact information:
 Tal Galili
 Phone number: 972-50-3373767
 FaceBook: Tal Galili
 My Blogs:
 http://www.r-statistics.com/
 http://www.talgalili.com
 http://www.biostatistics.co.il


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

Check out our upcoming events schedule at
www.revolution-computing.com/events

[[alternative HTML version deleted]]

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


Re: [R] Strange error returned or bug in gam in mgcv???? - yet more additional information

2009-09-01 Thread Corrado
I am using mgcv 1.4-1.1 on Fedora 9 64 bit on an Opteron server with 8Gb of 
RAM.

On Tuesday 01 September 2009 15:19:28 Corrado wrote:
 Here I pasted the code from when I opened the R shell, so that it possible
 to see what is going on:

 http://scsys.co.uk:8002/33309?hl=onsubmit=Format+it!

 Thanks in advance



-- 
Corrado Topi

Global Climate Change  Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


[R] Plotting point text-labels with lattice splom

2009-09-01 Thread Jockers Matthew
I have read the thread re: Plotting text with lattice but can't seem  
to get from there to what I need. . . would appreciate any advice. . .


I have used splom to plot data of the first three principle components  
from a pca analysis.  Here is the code I have thus far:


 mydata.pr-prcomp(mydata)
 grps - substr(rownames(mydata),1,4)
 super.sym=trellis.par.get(superpose.symbol)
 splom(data.frame(mydata.pr$x[,1:3]),
groups = grps,
panel = panel.superpose,
key = list (title = Four Items in PCA space,
text = list(c(G, H, N, Il)),
points=list(pch=super.sym$pch[1:4],
col=super.sym$col[1:4])))

I would now like to append text labels to each point in the plot that  
will identify the item based on its rowname in the original data set.


so, something like this gets me the labels I want

 labs-substr(rownames(mydata),1,6)

My trouble then comes in figuring out how to get these labels to  
attach to the corresponding points in the plot.


Thanks.
Matt

--
Matthew Jockers
Stanford University
http://www.stanford.edu/~mjockers

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


Re: [R] Strange error returned or bug in gam in mgcv????

2009-09-01 Thread Simon Wood
The basic problem is that you have requested a 10 dimensional thin plate 
spline, with a basis dimension of 196830. In reality it will not be possible 
to compute this, even if you have more than 196830 data. In any case it would 
be unlikely to provide a very useful model --- the simplest function that 
it can theoretically represent will have 3003 degrees of freedom. 

That said the error message is obviously rather unhelpful... Can you tell me 
how many data you are actually trying to fit, and I'll try and track down 
exactly where it's failing, and put in a more informative message.

best,
Simon

 

On Tuesday 01 September 2009 14:51, Corrado wrote:
 Dear friends,

 what is this error message in gam I cannot understand what it means
  is it a bug?

 gam_bray_scot24_pc_0505gam(bray~s(PC1,PC2,PC3,PC4,PC5,
 PC1.1,PC2.1,PC3.1,PC4.1,PC5.1),data=dist_scot24_vector_with_climate)

 Error in if (length(data) != vl) { :
   missing value where TRUE/FALSE needed
 Calls: gam ... smooth.construct - smooth.construct.tp.smooth.spec - array
 In addition: Warning message:
 In array(0, n * k) : NAs introduced by coercion
 Execution halted

 Thanks in advance,

 Best regards

-- 
 Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
 +44 1225 386603  www.maths.bath.ac.uk/~sw283

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


Re: [R] Strange error returned or bug in gam in mgcv????

2009-09-01 Thread Corrado
Dear Simon,

I have stored all information at the link:

http://scsys.co.uk:8002/33309?hl=onsubmit=Format+it!

I have the same problem if I do 
s(PC1)  + . + s(PC10) or 
s(Pc1,PC2,PC3,PC4,PC5)+s(PC6,PC7,PC8,PC9,PC10) or
s(PC1,PC2,PC3,PC6,PC7,PC8) .

I have renamed PC1.1,PC2.1,PC3.1,PC4.1,PC5.1 to PC6,PC7,PC8,PC9,PC10 for 
simplicity.

Regards

On Tuesday 01 September 2009 17:31:04 Simon Wood wrote:
 The basic problem is that you have requested a 10 dimensional thin plate
 spline, with a basis dimension of 196830. In reality it will not be
 possible to compute this, even if you have more than 196830 data. In any
 case it would be unlikely to provide a very useful model --- the simplest
 function that it can theoretically represent will have 3003 degrees of
 freedom.

 That said the error message is obviously rather unhelpful... Can you tell
 me how many data you are actually trying to fit, and I'll try and track
 down exactly where it's failing, and put in a more informative message.

 best,
 Simon

 On Tuesday 01 September 2009 14:51, Corrado wrote:
  Dear friends,
 
  what is this error message in gam I cannot understand what it means
   is it a bug?
 
  gam_bray_scot24_pc_0505gam(bray~s(PC1,PC2,PC3,PC4,PC5,
  PC1.1,PC2.1,PC3.1,PC4.1,PC5.1),data=dist_scot24_vector_with_climate)
 
  Error in if (length(data) != vl) { :
missing value where TRUE/FALSE needed
  Calls: gam ... smooth.construct - smooth.construct.tp.smooth.spec -
  array In addition: Warning message:
  In array(0, n * k) : NAs introduced by coercion
  Execution halted
 
  Thanks in advance,
 
  Best regards



-- 
Corrado Topi

Global Climate Change  Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] online classes or online eduction in statistics? esp. time series analysis and cointegration?

2009-09-01 Thread Chris Bilder
Luna Laurent luna.laurent.ucb at gmail.com writes:

 
 Hi all,
 
 I am looking for low cost online education in statistics. I am thinking of
 taking online classes on time series analysis and cointegration, etc.
 
 Of course, if there are free video lectures, that would be great. However I
 couldn't find any free video lectures at upper-undergraduate and graduate
 level which formally going through the whole timeseries education... That's
 why I would like to enroll in some sort of online degree classes. However, I
 don't want to earn the certificate or the degree; I just want to audit the
 online class specifically in time series analysis and cointegration. Could
 anybody recommend such online education in statistics esp. in time series
 and cointegration, at low cost? Hopefully it's not going to be like a few
 thousand dollars for one class.
 
 Thanks a lot for your pointers in advance!
 
   [[alternative HTML version deleted]]
 
 


Luna,

You are welcome to use my time series course materials at chrisbilder.com/ts. 
While there are no videos, the course notes (schedule web page) are complete 
along with all of the R programs used for the course. I do have video lectures 
available for some other courses through my chrisbilder.com portal. 

Chris

Christopher R. Bilder, Ph.D.
Associate Professor
University of Nebraska-Lincoln
Department of Statistics
Lincoln, NE 68583
Phone: (402) 472-2903
Fax: (402) 472-5179
E-mail: cbild...@unl.edu or ch...@chrisbilder.com
Website: www.chrisbilder.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] Function to find angle between coordinates?

2009-09-01 Thread clair.crossup...@googlemail.com
Thank you very much, these were exactly what i needed!  :-)

C.C.

On 1 Sep, 14:08, clair.crossup...@googlemail.com
clair.crossup...@googlemail.com wrote:
 Dear all,

 I was doing some self study and was wondering if a function already
 exists which allows one to determine the angle between points.  e.g.
 given the following (x,y) coordinates

 input: (0,1); (0,0); (1,0)

 would result in:

 output: 90 degrees

 Best regards
 C.C.

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

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


Re: [R] Exclude 0 values from plot

2009-09-01 Thread swertie

Thank you it worked well 

-- 
View this message in context: 
http://www.nabble.com/Exclude-0-values-from-plot-tp25235290p25244045.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] Strange error returned or bug in gam in mgcv????

2009-09-01 Thread Gavin Simpson
On Tue, 2009-09-01 at 17:55 +0100, Corrado wrote:
 Dear Simon,
 
 I have stored all information at the link:
 
 http://scsys.co.uk:8002/33309?hl=onsubmit=Format+it!

You could have included that in your mail to the list - it is just plain
text after all.

 
 I have the same problem if I do 
 s(PC1)  + . + s(PC10) or 
 s(Pc1,PC2,PC3,PC4,PC5)+s(PC6,PC7,PC8,PC9,PC10) or
 s(PC1,PC2,PC3,PC6,PC7,PC8) .
 
 I have renamed PC1.1,PC2.1,PC3.1,PC4.1,PC5.1 to PC6,PC7,PC8,PC9,PC10 for 
 simplicity.

What does

str(dist_scot24_vector_with_climate)

show? I seem to recall getting similar errors when I'd done something
silly in a data prep routine and had data in a data frame that wasn't
numeric but looked like it was - a factor for example.

If you can't do some quite simple things like the first of your three
alternatives above, that suggests something amiss with the data. That'd
be the first thing to check.

HTH

G

 
 Regards
 
 On Tuesday 01 September 2009 17:31:04 Simon Wood wrote:
  The basic problem is that you have requested a 10 dimensional thin plate
  spline, with a basis dimension of 196830. In reality it will not be
  possible to compute this, even if you have more than 196830 data. In any
  case it would be unlikely to provide a very useful model --- the simplest
  function that it can theoretically represent will have 3003 degrees of
  freedom.
 
  That said the error message is obviously rather unhelpful... Can you tell
  me how many data you are actually trying to fit, and I'll try and track
  down exactly where it's failing, and put in a more informative message.
 
  best,
  Simon
 
  On Tuesday 01 September 2009 14:51, Corrado wrote:
   Dear friends,
  
   what is this error message in gam I cannot understand what it means
    is it a bug?
  
   gam_bray_scot24_pc_0505gam(bray~s(PC1,PC2,PC3,PC4,PC5,
   PC1.1,PC2.1,PC3.1,PC4.1,PC5.1),data=dist_scot24_vector_with_climate)
  
   Error in if (length(data) != vl) { :
 missing value where TRUE/FALSE needed
   Calls: gam ... smooth.construct - smooth.construct.tp.smooth.spec -
   array In addition: Warning message:
   In array(0, n * k) : NAs introduced by coercion
   Execution halted
  
   Thanks in advance,
  
   Best regards
 
 
 
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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

2009-09-01 Thread Frostygoat

Hello,

For insect mortality data I'm trying to get an R script that will take
the data from the raw form and convert it to Lx (% survival) for a
number of treatments.  The raw data has the number of days lived for
each individual for the respective treatment.  Thus, for example, when
R selects the data for a single treatment I end up with the following
vectors:

day=seq(from=0,to=6)
deaths=c(0,0,2,0,0,1,6)

where deaths is the number of deaths on a given day. Now I need to
create a new vector with the number alive for each day and this is
where I'm stuck... I've tried to work various for and while loops but
haven't had success.  The vector should be:

Alive=c(9,9,7,7,7,6,0)

I realize it is a very basic problem that is easily accomplished in
one's head or on a spreadsheet but in the context of the size of the
data set I wish to have R do it for me. I would welcome any
suggestions please.

Best regards.

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

2009-09-01 Thread jonas garcia
Dear list,



I have a character vector such vec.names- c(a, b)

It happens that I have also two R objects called a and b that I would
like to merge. Is it possible to

do something like cbind(vec.names[1], vec.names[2]) ending up with the same
result as cbind(a,b)



Bellow is a reproducible example of what I need to to:



dat- data.frame(A=seq(1,5), B=seq(6,10))

vec.names- c(a, b)

for(i in 1:ncol(dat))

{

tab- dat[,i]-1

assign(vec.names[i], tab)

}



cbind(vec.names[1], vec.names[2])

 [,1] [,2]

[1,] a  b





But I was looking after the following result (using vec.names):



cbind(a,b)

 a b

[1,] 0 5

[2,] 1 6

[3,] 2 7

[4,] 3 8

[5,] 4 9





Thanks in advance



Jonas

[[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] Basic population dynamics

2009-09-01 Thread Henrique Dallazuanna
Try ths:

Alive - sum(deaths) - cumsum(deaths)


On Tue, Sep 1, 2009 at 3:48 PM, Frostygoat frostyg...@gmail.com wrote:


 Hello,

 For insect mortality data I'm trying to get an R script that will take
 the data from the raw form and convert it to Lx (% survival) for a
 number of treatments.  The raw data has the number of days lived for
 each individual for the respective treatment.  Thus, for example, when
 R selects the data for a single treatment I end up with the following
 vectors:

 day=seq(from=0,to=6)
 deaths=c(0,0,2,0,0,1,6)

 where deaths is the number of deaths on a given day. Now I need to
 create a new vector with the number alive for each day and this is
 where I'm stuck... I've tried to work various for and while loops but
 haven't had success.  The vector should be:

 Alive=c(9,9,7,7,7,6,0)

 I realize it is a very basic problem that is easily accomplished in
 one's head or on a spreadsheet but in the context of the size of the
 data set I wish to have R do it for me. I would welcome any
 suggestions please.

 Best regards.

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

[[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] Date format in plot

2009-09-01 Thread swertie

Hello, I plot the abundance of a species in relation to the date. To have the
date as a continous variable I put it in the format standard in excel
(f.ex. 39939 means 06.05.2009). R uses 39939 on the x axis, but I would like
to have 06.05. I tried to use as.Date as suggested in some discussion but
I don't manage to use it, the returned date is not correct. Do you have any
clue? thank you

-- 
View this message in context: 
http://www.nabble.com/Date-format-in-plot-tp25244066p25244066.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] cbind objects using character vectors

2009-09-01 Thread Erik Iverson
Not tested:
Instead of: 

cbind(vec.names[1], vec.names[2])

cbind(get(vec.names[1]), get(vec.names[2]))

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of jonas garcia
Sent: Tuesday, September 01, 2009 12:53 PM
To: r-help@r-project.org
Subject: [R] cbind objects using character vectors

Dear list,



I have a character vector such vec.names- c(a, b)

It happens that I have also two R objects called a and b that I would
like to merge. Is it possible to

do something like cbind(vec.names[1], vec.names[2]) ending up with the same
result as cbind(a,b)



Bellow is a reproducible example of what I need to to:



dat- data.frame(A=seq(1,5), B=seq(6,10))

vec.names- c(a, b)

for(i in 1:ncol(dat))

{

tab- dat[,i]-1

assign(vec.names[i], tab)

}



cbind(vec.names[1], vec.names[2])

 [,1] [,2]

[1,] a  b





But I was looking after the following result (using vec.names):



cbind(a,b)

 a b

[1,] 0 5

[2,] 1 6

[3,] 2 7

[4,] 3 8

[5,] 4 9





Thanks in advance



Jonas

[[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] Date format in plot

2009-09-01 Thread Erik Iverson
We will need a reproducible example!  Please give us R commands that display 
the behavior you're observing:

For example,

I am having trouble understanding the as.Date function.  When I input 39939, I 
would like to get 06.05.2009, but when I try it, I get 

 as.Date(39939)
Error in as.Date.numeric(39939) : 'origin' must be supplied

I looked up what origin Excel uses for its' dates, and it seems like it might 
be January 1, 1900, so I tried

as.Date(39939, origin = 1900-01-01)
[1] 2009-05-08

Then we will much better be able to help you, because we will be able to paste 
your commands into R and see the results and make changes. 

But this still seems to be off by two days.  So did you really mean 06.05, or 
08.05?



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of swertie
Sent: Tuesday, September 01, 2009 12:59 PM
To: r-help@r-project.org
Subject: [R] Date format in plot


Hello, I plot the abundance of a species in relation to the date. To have the
date as a continous variable I put it in the format standard in excel
(f.ex. 39939 means 06.05.2009). R uses 39939 on the x axis, but I would like
to have 06.05. I tried to use as.Date as suggested in some discussion but
I don't manage to use it, the returned date is not correct. Do you have any
clue? 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.


Re: [R] cbind objects using character vectors

2009-09-01 Thread Henrique Dallazuanna
Try this:

 sapply(vec.names, get)

But for this example, you don't need for, try:

 dat - 1

On Tue, Sep 1, 2009 at 2:52 PM, jonas garcia
garcia.jona...@googlemail.comwrote:

 Dear list,



 I have a character vector such vec.names- c(a, b)

 It happens that I have also two R objects called a and b that I would
 like to merge. Is it possible to

 do something like cbind(vec.names[1], vec.names[2]) ending up with the same
 result as cbind(a,b)



 Bellow is a reproducible example of what I need to to:



 dat- data.frame(A=seq(1,5), B=seq(6,10))

 vec.names- c(a, b)

 for(i in 1:ncol(dat))

 {

 tab- dat[,i]-1

 assign(vec.names[i], tab)

 }



 cbind(vec.names[1], vec.names[2])

 [,1] [,2]

 [1,] a  b





 But I was looking after the following result (using vec.names):



 cbind(a,b)

 a b

 [1,] 0 5

 [2,] 1 6

 [3,] 2 7

 [4,] 3 8

 [5,] 4 9





 Thanks in advance



 Jonas

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

[[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] Date format in plot

2009-09-01 Thread David Winsemius


On Sep 1, 2009, at 1:58 PM, swertie wrote:



Hello, I plot the abundance of a species in relation to the date. To  
have the
date as a continous variable I put it in the format standard in  
excel
(f.ex. 39939 means 06.05.2009). R uses 39939 on the x axis, but I  
would like
to have 06.05. I tried to use as.Date as suggested in some  
discussion but
I don't manage to use it, the returned date is not correct. Do you  
have any

clue? thank you


You may need to do some jiggling around because R doesn't agree with  
that number of days since the beginning of the last century:


 as.Date(39939, origin=1900-01-01)
[1] 2009-05-08

Then you need to look at docs re: the formating of date objects. Some  
code might move this process along.


--

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] GLM contrasting question

2009-09-01 Thread Ben Bolker



sodiumfish wrote:
 
 I have run a glm with a final formula of : (dependent variable = parasite
 load, main effects are sex, month, length and weight, with sex:month and
 length:weight first order interactions).
 
 I am using the summary(mod) command to give me the contrasts, which I
 believe use the contr.treatment command. I do not have a treatment group
 as such as I am comparing data from a wild system so I use the relevel
 command to reorder my factors in order to check the difference between
 each level and every other. I then use the coefficients and their related
 p-values to assess whether each level of my factors is significantly
 different from the next. This is fine for most things but  what I really
 want to do is to assess whether there is a significant difference of
 between males and females in any particular month. However, because of my
 interaction term the male and female for any particular month are always
 the missing coefficients and so I can't contrast them with one another.
 
 Is there a way (preferably a relatively simple way) for me to do this. You
 will probably realise from my description above that I am a biologist not
 a statistician, so if anyone can help me in plain English that would be an
 enormous help.
 
 

 It would be a little easier if you gave us a reproducible example.
It sounds like the easiest thing to do would be to partition your data set
by month and run separate models in each month.  If you were running
lm() rather than glm() you could use lmList from the nlme package, but
instead you should look at:

http://finzi.psych.upenn.edu/Rhelp08/2008-February/154519.html

  for a solution.
-- 
View this message in context: 
http://www.nabble.com/GLM-contrasting-question-tp25226439p25244287.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] Simple question about error on CSV import

2009-09-01 Thread esawdust

thank you all for the quick responses and helpful explanations.  I'm just
getting started with R, so I'll get tripped up by some of this until I get
in the groove.

Thanks again,

Landon
-- 
View this message in context: 
http://www.nabble.com/Simple-question-about-error-on-CSV-import-tp25242899p25244282.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] Date format in plot

2009-09-01 Thread David Winsemius


On Sep 1, 2009, at 3:13 PM, Erik Iverson wrote:

We will need a reproducible example!  Please give us R commands that  
display the behavior you're observing:


For example,

I am having trouble understanding the as.Date function.  When I  
input 39939, I would like to get 06.05.2009, but when I try it, I  
get



as.Date(39939)

Error in as.Date.numeric(39939) : 'origin' must be supplied

I looked up what origin Excel uses for its' dates, and it seems like  
it might be January 1, 1900, so I tried


as.Date(39939, origin = 1900-01-01)
[1] 2009-05-08

Then we will much better be able to help you, because we will be  
able to paste your commands into R and see the results and make  
changes.


But this still seems to be off by two days.  So did you really mean  
06.05, or 08.05?


One of the two day discrepancy is because the real date on which Excel  
dates are based is NOT 1900-01-01:


http://support.microsoft.com/default.aspx?scid=kb;en-us;214058

They claim that fixing this would be too difficult and doesn't caus  
very many difficulties anyway, but apparently refuse to publish the  
correct starting date in their documents. Where the other missing day  
went I cannot say. It may have something to do with different  
definitions for where a date is supposed to start.






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

Sent: Tuesday, September 01, 2009 12:59 PM
To: r-help@r-project.org
Subject: [R] Date format in plot


Hello, I plot the abundance of a species in relation to the date. To  
have the
date as a continous variable I put it in the format standard in  
excel
(f.ex. 39939 means 06.05.2009). R uses 39939 on the x axis, but I  
would like
to have 06.05. I tried to use as.Date as suggested in some  
discussion but
I don't manage to use it, the returned date is not correct. Do you  
have any

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


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] Date format in plot

2009-09-01 Thread Gabor Grothendieck
See R News 4/1. The article on dates there discusses how they
work and discusses Excel's dates as well.

On Tue, Sep 1, 2009 at 1:58 PM, swertiev_coudr...@voila.fr wrote:

 Hello, I plot the abundance of a species in relation to the date. To have the
 date as a continous variable I put it in the format standard in excel
 (f.ex. 39939 means 06.05.2009). R uses 39939 on the x axis, but I would like
 to have 06.05. I tried to use as.Date as suggested in some discussion but
 I don't manage to use it, the returned date is not correct. Do you have any
 clue? thank you

 --
 View this message in context: 
 http://www.nabble.com/Date-format-in-plot-tp25244066p25244066.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] package installation error

2009-09-01 Thread Héctor Villalobos
Hi,


This also happens in 2.9.1 and 2.9.2. My personal solution is to look under 
'C:\Program
Files\R\R-2.9.0\library' for a bizarre-named directory (starts with an 'f' and 
has numbers and
letters mixed) , which contains the package directory (in this case 
'robustbase') and move it
up one level (like the other packages). This is annoying, but so far is the 
only solutions I have
found.


On 31 Aug 2009 at 9:32, Duncan Murdoch wrote:

 On 31/08/2009 8:53 AM, Haynes, Maurice (NIH/NICHD) [E] wrote:
  On Sun April 19, you posted the following on R-help:
  After installing 2.9.0 I tried loading packages, but keep getting the 
  following error.
 
  package 'robustbase' successfully unpacked and MD5 sums checked
  Error in normalizePath(path) :
   path[1]=C:\Program Files\R\R-2.9.0\library/robustbase: The system 
  cannot find the file specified
 
 
  I have had the same problem for months.  Have you found a solution?

 There have been two patch releases since 2.9.0.  Have you tried 2.9.2?

 Duncan Murdoch

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



--
Héctor Villalobos hvill...@ipn.mx
 CICIMAR - IPN
 A.P. 592. Col. Centro
 La Paz, Baja California Sur, MÉXICO. 23000
 Tels. (+52 612) 122 53 44; 123 46 58; 123 47 34  ext. 82425
 Fax.  (+52 612) 122 53 22

[[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] understanding the output from gls

2009-09-01 Thread Timothy_Handley

I'd like to compare two models which were fitted using gls, however I'm
having trouble interpreting the results of gls. If any of you could offer
me some advice, I'd greatly appreciate it.

Short explanation of models: These two models have the same fixed-effects
structure (two independent, linear effects), and differ only in that the
second model includes a corExp structure for spatial autocorrelation. (more
detailed explanation of the models at end).

Specific questions:

1. The second model estimates two additional parameters in the process of
fitting the corSpatial object - the range and nugget of the spatial
autocorrelation. Based on this, I would expect the second model to have two
fewer residual degrees of freedom. However, the summary function reports
that both models have the same number of residual degrees of freedom.  Why
is this? (Interestingly, the difference in AIC between the two models
reflects this difference in the number of model parameters)

2. In the model summary, what is the meaning of the small correlation
matrix under the heading Correlation:? At first, I thought that this was
describing possible correlations among the predictor variables, but then I
saw that it also included the model intercept. What do these correlation
value mean?

##More detailed information
##function calls:
  sppl.i.xx = gls(all.all.rch~l10area+newx, data = gtemp, method=ML)
  sppl.i.ex = gls(all.all.rch~l10area+newx, data = gtemp, method=ML,
  correlation = corExp(c(20,.8), form=~x+y|area, nugget=TRUE))

##model summaries

 summary(sppl.i.xx)
Generalized least squares fit by maximum likelihood
  Model: all.all.rch ~ l10area + newx
  Data: gtemp
   AIC BIClogLik
  567.4893 578.572 -279.7446

Coefficients:
   Value Std.Error   t-value p-value
(Intercept) 6.891867 0.3295097 20.915522   0e+00
l10area 6.586182 0.3048870 21.602046   0e+00
newx0.047901 0.0117281  4.084307   1e-04

 Correlation:
(Intr) l10are
l10area -0.364
newx 0.577 -0.007

Standardized residuals:
Min  Q1 Med  Q3 Max
-3.34307266 -0.57949890 -0.07214605  0.64309760  2.66409931

Residual standard error: 2.590313
Degrees of freedom: 118 total; 115 residual

summary(sppl.i.ex)
Generalized least squares fit by maximum likelihood
  Model: all.all.rch ~ l10area + newx
  Data: gtemp
  AIC  BIClogLik
  559.167 575.7911 -273.5835

Correlation Structure: Exponential spatial correlation
 Formula: ~x + y | area
 Parameter estimate(s):
 range nugget
15.4448835  0.3741476

Coefficients:
   Value Std.Error   t-value p-value
(Intercept) 7.621306 0.7648135  9.964921  0.
l10area 6.400442 0.5588160 11.453576  0.
newx0.066535 0.0204417  3.254857  0.0015

 Correlation:
(Intr) l10are
l10area -0.592
newx 0.358  0.014

Standardized residuals:
   Min Q1Med Q3Max
-3.0035983 -0.5990432 -0.2226852  0.5113270  2.263

Residual standard error: 2.820337
Degrees of freedom: 118 total; 115 residual




Tim Handley
Fire Effects Monitor
Santa Monica Mountains National Recreation Area
401 W. Hillcrest Dr.
Thousand Oaks, CA 91360
805-370-2347

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


[R] Read multiple files into dataframe?

2009-09-01 Thread Douglas M. Hultstrand

Hello,

I am fairly new to R programming and am stuck with the following problem.

I am trying to read in multiple files (see attached file or at end of 
email), the files all have the same general header information and 
different precipitation (avgppt) and area (areasqmi) values.  Some times 
the number of records are different in the files.


I want to read in all files (.stdsummary), and create a dataframe that 
contains the area and precipitation for each file (files are different 
duration), and supply a header name that represents the duration (sixth 
line down in header information or extracted from data file 
da_zone1_15hr_1166.stdsummary). 

For example, this is what the final dataframe would look like for 1hr, 
3hr, and 15hr datafiles:
1hrppt  1hrarea3hrppt  3hrarea15hrppt  15hrarea 
3.806.8607.670

3.7116.7817.61
3.6956.7257.525
3.56106.55107.3210
3.33206.17206.9120
2.87505.25505.950
2.451004.351005.02100
1.942003.342004.09200
1.673002.783003.55300

The end result is to perform QC statistics and then plot each set of 
data.  Also, is there away to create a dataframe that has different # of 
records?


Datafile example of file below:

Storm number: 1166
Zone number: 1 (ALL zones)
Number of stations: 172
Total analyzed area (sq mi): 5360.8
Average station density (stns per 1000 sq mi):   na
Duration window (hours): 15
CPP beg hour index: 1
CPP end hour index: 15
Ishohyet interval step (inches): 0.2
Standard area size summary
Begin run date/time: Tue Aug 25 01:17:43 2009
avgppt,  areasqmi
7.67,000.00
7.60,001.00
7.52,005.00
7.32,010.00
6.91,020.00
5.90,050.00
5.02,100.00
4.09,200.00
3.55,300.00
2.96,500.00
2.27,0001000.00
1.64,0002000.00
0.82,0005000.00
0.77,0005360.00

--
-
Douglas M. Hultstrand, MS
Senior Hydrometeorologist
Metstat, Inc. Windsor, Colorado
voice: 970.686.1253
email: dmhul...@metstat.com
web: http://www.metstat.com
-

Storm number: 1166
Zone number: 1 (ALL zones)
Number of stations: 172
Total analyzed area (sq mi): 5360.8
Average station density (stns per 1000 sq mi):   na
Duration window (hours): 15
CPP beg hour index: 1
CPP end hour index: 15
Ishohyet interval step (inches): 0.2
Standard area size summary
Begin run date/time: Tue Aug 25 01:17:43 2009
avgppt,  areasqmi
7.67,000.00
7.60,001.00
7.52,005.00
7.32,010.00
6.91,020.00
5.90,050.00
5.02,100.00
4.09,200.00
3.55,300.00
2.96,500.00
2.27,0001000.00
1.64,0002000.00
0.82,0005000.00
0.77,0005360.00
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] simple 3-dimensional plots?

2009-09-01 Thread ivowel
dear R experts: I am trying to plot an empirical likelihood function in 3d.  
The values are not over a regular grid---I just searched the likelihood  
function to find the optimal value, and then computed a few values around  
it. (each point in the likelihood function takes a very long time to  
compute.)

the likelihood values now sit in a csv file that has three  
columns, mu, sd, and v. I would like to look at my 3d plots to find  
out how well or badly behaved my likelihood function is (and then compute a  
Hessian, my next task).

Is persp() the correct function for this task? something else?

is there a wrapper that takes my x, y, and z values (which come in almost  
random order), and puts them into the format that persp() needs?

pointers appreciated.

sincerely,

/iaw

[[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] Loading file in MAC-Syntax Error

2009-09-01 Thread Awais77

Hi,
If any body can help me regarding a basic problem using R?
I am starting with R and I have problem in loading my file. File is on
Desktop of my MAC and I use code as follows to access it 
/Users/username/Desktop/test.txt/

It always gives me Syntax error message.

Thanks for your help




-- 
View this message in context: 
http://www.nabble.com/Loading-file-in-MAC-Syntax-Error-tp25244312p25244312.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] Read multiple files into dataframe?

2009-09-01 Thread jim holtman
I would put the data into a 'long' instead of 'wide' format since you
say you have files of different lengths.  I took you data and
replicated it 3 time and changed the file name for the duration:

 fileNames - Sys.glob('/da_zone*')  # files to process
 result - lapply(fileNames, function(.file){
+ # read in data after skipping 11 lines
+ .input - read.csv(.file, skip=11)
+ # extract the duration from file name
+ .dur - sub(.*_([[:digit:]]+)hr_.*, \\1, .file, perl=TRUE)
+ # add to the data frame
+ .input$dur - .dur
+ .input
+ })
 # put into a single data.frame
 do.call(rbind, result)
   avgppt areasqmi dur
17.670  15
27.601  15
37.525  15
47.32   10  15
56.91   20  15
65.90   50  15
75.02  100  15
84.09  200  15
93.55  300  15
10   2.96  500  15
11   2.27 1000  15
12   1.64 2000  15
13   0.82 5000  15
14   0.77 5360  15
15   7.670   1
16   7.601   1
17   7.525   1
18   7.32   10   1
19   6.91   20   1
20   5.90   50   1
21   5.02  100   1
22   4.09  200   1
23   3.55  300   1
24   2.96  500   1
25   2.27 1000   1
26   1.64 2000   1
27   0.82 5000   1
28   0.77 5360   1
29   7.670   3
30   7.601   3
31   7.525   3
32   7.32   10   3
33   6.91   20   3
34   5.90   50   3
35   5.02  100   3
36   4.09  200   3
37   3.55  300   3
38   2.96  500   3
39   2.27 1000   3
40   1.64 2000   3
41   0.82 5000   3
42   0.77 5360   3


On Tue, Sep 1, 2009 at 4:24 PM, Douglas M.
Hultstranddmhul...@metstat.com wrote:
 Hello,

 I am fairly new to R programming and am stuck with the following problem.

 I am trying to read in multiple files (see attached file or at end of
 email), the files all have the same general header information and different
 precipitation (avgppt) and area (areasqmi) values.  Some times the number of
 records are different in the files.

 I want to read in all files (.stdsummary), and create a dataframe that
 contains the area and precipitation for each file (files are different
 duration), and supply a header name that represents the duration (sixth line
 down in header information or extracted from data file
 da_zone1_15hr_1166.stdsummary).
 For example, this is what the final dataframe would look like for 1hr, 3hr,
 and 15hr datafiles:
 1hrppt      1hrarea    3hrppt      3hrarea    15hrppt      15hrarea 3.8    0
    6.86    0    7.67    0
 3.71    1    6.78    1    7.6    1
 3.69    5    6.72    5    7.52    5
 3.56    10    6.55    10    7.32    10
 3.33    20    6.17    20    6.91    20
 2.87    50    5.25    50    5.9    50
 2.45    100    4.35    100    5.02    100
 1.94    200    3.34    200    4.09    200
 1.67    300    2.78    300    3.55    300

 The end result is to perform QC statistics and then plot each set of data.
  Also, is there away to create a dataframe that has different # of records?

 Datafile example of file below:

 Storm number: 1166
 Zone number: 1 (ALL zones)
 Number of stations: 172
 Total analyzed area (sq mi):     5360.8
 Average station density (stns per 1000 sq mi):   na
 Duration window (hours): 15
 CPP beg hour index: 1
 CPP end hour index: 15
 Ishohyet interval step (inches): 0.2
 Standard area size summary
 Begin run date/time: Tue Aug 25 01:17:43 2009
 avgppt,  areasqmi
 7.67,000.00
 7.60,001.00
 7.52,005.00
 7.32,010.00
 6.91,020.00
 5.90,050.00
 5.02,100.00
 4.09,200.00
 3.55,300.00
 2.96,500.00
 2.27,0001000.00
 1.64,0002000.00
 0.82,0005000.00
 0.77,0005360.00

 --
 -
 Douglas M. Hultstrand, MS
 Senior Hydrometeorologist
 Metstat, Inc. Windsor, Colorado
 voice: 970.686.1253
 email: dmhul...@metstat.com
 web: http://www.metstat.com
 -


 Storm number: 1166
 Zone number: 1 (ALL zones)
 Number of stations: 172
 Total analyzed area (sq mi):     5360.8
 Average station density (stns per 1000 sq mi):   na
 Duration window (hours): 15
 CPP beg hour index: 1
 CPP end hour index: 15
 Ishohyet interval step (inches): 0.2
 Standard area size summary
 Begin run date/time: Tue Aug 25 01:17:43 2009
 avgppt,  areasqmi
 7.67,000.00
 7.60,001.00
 7.52,005.00
 7.32,010.00
 6.91,020.00
 5.90,050.00
 5.02,100.00
 4.09,200.00
 3.55,300.00
 2.96,500.00
 2.27,0001000.00
 1.64,0002000.00
 0.82,0005000.00
 0.77,0005360.00

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





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

What is the problem 

Re: [R] Loading file in MAC-Syntax Error

2009-09-01 Thread Steve Lianoglou
Hi,

On Tue, Sep 1, 2009 at 4:40 PM, Awais77khan_awai...@yahoo.com wrote:

 Hi,
 If any body can help me regarding a basic problem using R?
 I am starting with R and I have problem in loading my file. File is on
 Desktop of my MAC and I use code as follows to access it
 /Users/username/Desktop/test.txt/

1. Where's your code?
2. Try to remove the trailing slash of your filename

 It always gives me Syntax error message.

What is the error message?

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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


Re: [R] Loading file in MAC-Syntax Error

2009-09-01 Thread David Winsemius


On Sep 1, 2009, at 4:40 PM, Awais77 wrote:



Hi,
If any body can help me regarding a basic problem using R?
I am starting with R and I have problem in loading my file. File is on
Desktop of my MAC and I use code as follows to access it
/Users/username/Desktop/test.txt/


Are you expecting R to read your mind? Where is a function to do  
something with that file?


Read some more introductory material and also read the R Import/Export  
Manual. There is a treasure trove of contributed documentation at the  
r-project website.




It always gives me Syntax error message.

Thanks for your help


--

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] Syntax for crossed random effects in nlme

2009-09-01 Thread Kingsford Jones
Hi Ben,

Pinheiro and Bates 2000 is the real documentation for nlme.  See the
Cell Culture Bioassay example starting on pg 163 for a demonstration
of fitting crossed random effects using pdIdent and pdBlocked objects.

hth,
Kingsford

On Tue, Sep 1, 2009 at 6:44 AM, bamselbenam...@gmail.com wrote:

 Hello R users,
 I've read the posts on this topic, and had a look at the R documentation for
 nlme, but I can't seem to make this work. I'd like to be able to fit a mixed
 effects model with crossed random effects, but also be able to specify the
 covariance matrix structure for the residuals. Here's the syntax using the
 lmer function in lme4 (which doesn't currently allow alternate error
 covariance structures). Does anybody know how to transform this to work with
 nlme?

 fit = lmer(data$DV ~ X + time + (X*time) + (1|Item_Number) + (1|Subject),
 data)

 Much appreciated,
 Ben Amsel
 --
 View this message in context: 
 http://www.nabble.com/Syntax-for-crossed-random-effects-in-nlme-tp25239714p25239714.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] Loading file in MAC-Syntax Error

2009-09-01 Thread Awais77

Thanks for useful replies. It is working now. 
I was typing only read.table(/Users/username/Desktop/test.txt/) without
surrounding the filename with quotes. It works when i use it as
read.table('/Users/khan_awais77/Desktop/test2.txt').

Cheers

 

Awais77 wrote:
 
 Hi,
 If any body can help me regarding a basic problem using R?
 I am starting with R and I have problem in loading my file. File is on
 Desktop of my MAC and I use code as follows to access it 
 /Users/username/Desktop/test.txt/
 
 It always gives me Syntax error message.
 
 Thanks for your help
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Loading-file-in-MAC-Syntax-Error-tp25244312p25248604.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 merge the fitted values from a linear model?

2009-09-01 Thread kayj

Hi All,

I would like to run a linear model where the response is the duration of
relief in days and the regressor is the drug dosage in mg. Then I would like
compute the predicted values of the duration of relief from the model and
merge it into the original data. I am not sure how the merge happens since
if I have missing values in the data, R runs the resgression model but
fitted values for some observations are not being calculated.

Below is my R script

Mydata-read.csv(file=”file1.csv”, header=T)

Model-lm(y ~ x, data=Mydata)
f-fitted(Model)
Newdata-cbind(f , Mydata)

Is Newdata merged correctly?

Thanks for your help
 

-- 
View this message in context: 
http://www.nabble.com/how-to-merge-the-fitted-values-from-a-linear-model--tp25248552p25248552.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] matrix manipulation problem

2009-09-01 Thread Gregory Gentlemen
Dear fellow R-users,

Say we have a matrix x, defined as follows

set.seed(50)
x - matrix(rbinom(100*5,1, p=0.75),nrow=100, ncol=5)

Now the interpretation of x is that each for of x is actually a sequence of 
length 5, and i would like to transform x in such a way that I can describe the 
frequencies of sequences observed among the 100. How can I do this efficiently?

Thanks for any assistance!
Greg



  __
[[elided Yahoo spam]]

[[alternative HTML version deleted]]

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


[R] read and sac files from windows 07

2009-09-01 Thread joel ulises sevilla
Dear friends maybe someone can help this freshman at R, by tell step by step
how can I read files from windows 2003-2007 to Rgui, I had tried all, no see
solution??

[[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] Simple question about data.frame reduction

2009-09-01 Thread Ronaldo Reis Júnior
Hi,

this is a simple question

I have this data.frame:

 test - 
data.frame(var1=c(1,1,1,1,1,1),var2=c(a,a,b,c,d,e),var3=c(a1,a1,b1,a1,c1,d1))
 test
  var1 var2 var3
11a   a1
21a   a1
31b   b1
41c   a1
51d   c1
61e   d1

Then I need to calculate the number of var3 excluding the repeated measure of 
var2.

With tapply I have this:

 tapply(test$var1,test$var3,sum)
a1 b1 c1 d1 
 3  1  1  1

But the correct result is:

a1 b1 c1 d1 
 2  1  1  1

because on factor a1 in var3 I have 2 repeated factor a in var2.

I try a simple solution for it but without success. aggregate function dont 
work with factors (var3 by var1).

Anybody have an idea?

Thanks
Ronaldo
-- 
It's men like him that give the Y chromosome a bad name.
--
 Prof. Ronaldo Reis Júnior
|  .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional
| : :'  : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
| `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
|   `- Fone: (38) 3229-8192 | ronaldo.r...@unimontes.br | chrys...@gmail.com
| http://www.ppgcb.unimontes.br/lecc | ICQ#: 5692561 | LinuxUser#: 205366
--
Favor NÃO ENVIAR arquivos do Word ou Powerpoint
Prefira enviar em PDF, Texto, OpenOffice (ODF), HTML, or RTF.

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


Re: [R] Simple question about data.frame reduction

2009-09-01 Thread Jorge Ivan Velez
Dear Ronaldo,
You were almost there!  Here is a suggestion:

 with(test, tapply(var3, var2, length))
# a b c d e
# 2 1 1 1 1

HTH,
Jorge


2009/9/1 Ronaldo Reis Júnior 

 Hi,

 this is a simple question

 I have this data.frame:

  test -

 data.frame(var1=c(1,1,1,1,1,1),var2=c(a,a,b,c,d,e),var3=c(a1,a1,b1,a1,c1,d1))
  test
  var1 var2 var3
 11a   a1
 21a   a1
 31b   b1
 41c   a1
 51d   c1
 61e   d1

 Then I need to calculate the number of var3 excluding the repeated measure
 of
 var2.

 With tapply I have this:

  tapply(test$var1,test$var3,sum)
 a1 b1 c1 d1
  3  1  1  1

 But the correct result is:

 a1 b1 c1 d1
  2  1  1  1

 because on factor a1 in var3 I have 2 repeated factor a in var2.

 I try a simple solution for it but without success. aggregate function dont
 work with factors (var3 by var1).

 Anybody have an idea?

 Thanks
 Ronaldo
 --
 It's men like him that give the Y chromosome a bad name.
 --
  Prof. Ronaldo Reis Júnior
 |  .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional
 | : :'  : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
 | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
 |   `- Fone: (38) 3229-8192 | ronaldo.r...@unimontes.br |
 chrys...@gmail.com
 | http://www.ppgcb.unimontes.br/lecc | ICQ#: 5692561 | LinuxUser#: 205366
 --
 Favor NÃO ENVIAR arquivos do Word ou Powerpoint
 Prefira enviar em PDF, Texto, OpenOffice (ODF), HTML, or RTF.

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


  1   2   >