Re: [R] Incorrect Dimension

2009-09-18 Thread Schalk Heunis
Marcio
Looking at the script (not much explanation re your intention), I think
there is a couple of problems:
1. Not sure if the attached was supposed to be working code, but the
assignment operator is - not =
2. The functions should be defined OUTSIDE the loop, otherwise you are
redefining the function with every iteration
3. I think the reason you wanted to put it inside the loop is that you need
access to the local variables of the loop, i.e. i and j
The way to do that would be to pass i and j as parameters to your
function, for example

g2 - function(gen, j, i) sample (b1, 1, re = T)

4. Your function g1 returns a matrix and function g2 returns a number, these
should ideally both return objects of the same dimension and class.  I think
this is what you wanted

g1 - function(gen, j, i) {
if (gen[j, i] == 0) al1 [i, 1] + al1 [i, 1]
else if (gen [j, i] == 1) al1 [i, 1] +  al2 [i, 1]
else if (gen [j, i] == 2) al2 [i, 1] +  al2 [i, 1]
else 999
}

5. To make people that respond's life easier, please also provide some code
to initialise variables

Here is working code, which I think does what you wanted:
###
# initialising some variables
loc=200
ind=1000
gen - matrix(rbinom(1000*200,1,0.3),nrow = ind,ncol = loc)
al1 - matrix(rbinom(1000*200,1,0.3),nrow = ind,ncol = loc)
al2 - matrix(rbinom(1000*200,1,0.3),nrow = ind,ncol = loc)
b1 - c(1,2,3)
r2 = 0.7
g - matrix(nrow = ind,ncol = loc)

# defining the functions
g1 - function(gen, j, i) {
if (gen[j, i] == 0) al1 [i, 1] + al1 [i, 1]
else if (gen [j, i] == 1) al1 [i, 1] +  al2 [i, 1]
else if (gen [j, i] == 2) al2 [i, 1] +  al2 [i, 1]
else 999
}
g2 - function(gen, j, i) sample (b1, 1, re = T)

# now loop  - this can be done more efficiently, but did not want to change
your code too much :-)
for (i in 1 : loc) {
for (j in 1 : ind) {
xx - if (runif(1) = (1 - r2)) g1 else g2
g[j, i] - xx(gen, j, i)
}
}

##

HTH
Schalk Heunis


On Fri, Sep 18, 2009 at 4:50 AM, Marcio Resende mresende...@yahoo.com.brwrote:


 I am new in R and i am having trouble here. I´ve already searched in the
 list
 but hasn´t helped
 When i run this script above i get the message Error in gen[j, i] :
 incorrect number of dimensions. However gen is 1000x200 (ind x loc) and so
 is g

 could anybody help me

 for (i in 1 : loc) {  #loc=200
 for (j in 1 : ind) {  #ind=1000

 g1 = function ( gen ) matrix ( if (gen[j, i] == 0) al1 [i, 1] + al1 [i, 1]
 else if (gen [j, i] == 1) al1 [i, 1]   +  al2 [i, 1] else if  (gen [j,
 i] == 2) al2 [i, 1] + al2 [i, 1] else 999, ncol = loc, nrow = ind)


 g2 = function ( gen ) sample (b1, 1, re = T)  #b1 is 1x3 and came from a
 vector 1000X1 (e.g b1 - c(x [1000,1]...)

 xx = if (runif (1) = (1 - r2)) g1 else g2

 g [j, i] = xx (gen [j, i])#g was already generated as an 0 matrix
 (1000x200) and i would like to replace ##by those functios

 }
 }

 Thank you very much
 --
 View this message in context:
 http://www.nabble.com/Incorrect-Dimension-tp25502336p25502336.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] Datetime conversion

2009-09-18 Thread David Winsemius


On Sep 18, 2009, at 1:03 AM, premmad wrote:



I'm relatively new to R .I tried converting the datetime column with  
values
like 01apr1985:00:00:00.000 using strptime(datetime,%d%b%Y).Could  
anyone

help me in this regard .Please reply ASAP i need .


You will need to give us a more complete sample of your code, because  
I don't see a problem:


 strptime(01apr1985:00:00:00.000,%d%b%Y)
[1] 1985-04-01

also works when hours, minutes and seconds format was used:


 strptime(01apr1985:00:00:00.000,%d%b%Y:%H:%M:%S)
[1] 1985-04-01
 strptime(01apr1985:00:00:00.000,%d%b%Y:%T)
[1] 1985-04-01



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] Incorrect Dimension

2009-09-18 Thread Schalk Heunis
On Fri, Sep 18, 2009 at 8:12 AM, Schalk Heunis
schalk.heu...@enerweb.co.zawrote:

 Marcio
 Looking at the script (not much explanation re your intention), I think
 there is a couple of problems:
 1. Not sure if the attached was supposed to be working code, but the
 assignment operator is - not =
 2. The functions should be defined OUTSIDE the loop, otherwise you are
 redefining the function with every iteration
 3. I think the reason you wanted to put it inside the loop is that you need
 access to the local variables of the loop, i.e. i and j
 The way to do that would be to pass i and j as parameters to your
 function, for example

 g2 - function(gen, j, i) sample (b1, 1, re = T)

 4. Your function g1 returns a matrix and function g2 returns a number,
 these should ideally both return objects of the same dimension and class.  I
 think this is what you wanted

 g1 - function(gen, j, i) {
 if (gen[j, i] == 0) al1 [i, 1] + al1 [i, 1]
 else if (gen [j, i] == 1) al1 [i, 1] +  al2 [i, 1]
 else if (gen [j, i] == 2) al2 [i, 1] +  al2 [i, 1]
 else 999
 }

 5. To make people that respond's life easier, please also provide some code
 to initialise variables

 Here is working code, which I think does what you wanted:
 ###
 # initialising some variables
 loc=200
 ind=1000
 gen - matrix(rbinom(1000*200,1,0.3),nrow = ind,ncol = loc)
 al1 - matrix(rbinom(1000*200,1,0.3),nrow = ind,ncol = loc)
 al2 - matrix(rbinom(1000*200,1,0.3),nrow = ind,ncol = loc)
 b1 - c(1,2,3)
 r2 = 0.7
 g - matrix(nrow = ind,ncol = loc)

 # defining the functions
 g1 - function(gen, j, i) {
 if (gen[j, i] == 0) al1 [i, 1] + al1 [i, 1]
 else if (gen [j, i] == 1) al1 [i, 1] +  al2 [i, 1]
 else if (gen [j, i] == 2) al2 [i, 1] +  al2 [i, 1]
 else 999
 }
 g2 - function(gen, j, i) sample (b1, 1, re = T)

  # now loop  - this can be done more efficiently, but did not want to
 change your code too much :-)
 for (i in 1 : loc) {
 for (j in 1 : ind) {
 xx - if (runif(1) = (1 - r2)) g1 else g2
 g[j, i] - xx(gen, j, i)
 }
 }


 ##

 HTH
 Schalk Heunis



 On Fri, Sep 18, 2009 at 4:50 AM, Marcio Resende 
 mresende...@yahoo.com.brwrote:


 I am new in R and i am having trouble here. I´ve already searched in the
 list
 but hasn´t helped
 When i run this script above i get the message Error in gen[j, i] :
 incorrect number of dimensions. However gen is 1000x200 (ind x loc) and
 so
 is g

 could anybody help me

 for (i in 1 : loc) {  #loc=200
 for (j in 1 : ind) {  #ind=1000

 g1 = function ( gen ) matrix ( if (gen[j, i] == 0) al1 [i, 1] + al1 [i,
 1]
 else if (gen [j, i] == 1) al1 [i, 1]   +  al2 [i, 1] else if  (gen [j,
 i] == 2) al2 [i, 1] + al2 [i, 1] else 999, ncol = loc, nrow = ind)


 g2 = function ( gen ) sample (b1, 1, re = T)  #b1 is 1x3 and came from a
 vector 1000X1 (e.g b1 - c(x [1000,1]...)

 xx = if (runif (1) = (1 - r2)) g1 else g2

 g [j, i] = xx (gen [j, i])#g was already generated as an 0 matrix
 (1000x200) and i would like to replace ##by those functios

 }
 }

 Thank you very much
 --
 View this message in context:
 http://www.nabble.com/Incorrect-Dimension-tp25502336p25502336.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] merging data frames with matrix objects when missing cases

2009-09-18 Thread Kari Ruohonen
Hi,
I have faced a problem with the merge() function when trying to merge
two data frames that have a common index but the second one does not
have cases for all indexes in the first one. With usual variables R
fills in the missing cases with NA if all=T is requested. But if the
variable is a matrix R seems to insert NA only to the first column of
the matrix and fill in the rest of the columns by recycling the values.
Here is a toy example:

 df1-data.frame(a=1:3,X1=I(matrix(1:6,ncol=2)))
 df2-data.frame(a=1:2,X2=I(matrix(11:14,ncol=2)))
 merge(df1,df2)
  a X1.1 X1.2 X2.1 X2.2
1 114   11   13
2 225   12   14  
# no all=T, missing cases are dropped

 merge(df1,df2,all=T)
  a X1.1 X1.2 X2.1 X2.2
1 114   11   13
2 225   12   14
3 336   NA   13 
# X2.1 set to NA correctly but X2.2 set to 13 by recycling.

Can I somehow get the behaviour that the third row of the second matrix
X2 in the above example would be filled with NA for all columns? None of
the merge() options does not seem to provide a solution.

regards, Kari

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


Re: [R] RCurl and Google Scholar's EndNote references

2009-09-18 Thread Jarno Tuimala
Hi!

Thanks for the code examples. I'll try to elaborate a bit here.

If you paste this:

http://scholar.google.fi/scholar?hl=fioe=ASCIIq=Frank+Harrell

 to your browser, you'll get the citations, and each citation lists a link
(Import to EndNote) to export a citation in EndNote format.

And, if you save this HTML-file, you'll get the links (they contain a string
info:) pointing to these EndNote files.  For example:

a href=/scholar.enw?q=info:U6Gfb4QPVFMJ:
scholar.google.com/amp;output=citationamp;hl=enamp;oe=ASCIIamp;oe=ASCIIamp;ct=citationamp;cd=0Import
into EndNote/a

Now, if you do this in R:

curl = getCurlHandle()
z = getForm(http://scholar.google.com/scholar;, q ='Frank Harrell', hl =
'en', btnG = 'Search', oe=ASCII, .opts = list(verbose = TRUE), curl =
curl)

object z does not contain any info:-containing links:

grep(info:, z)
integer(0)

Fortunately there is a related:-link that gives us the same ID
(U6Gfb4QPVFMJ) as the info:-link above:

substr(z, gregexpr(related:, z)[[1]]+8, gregexpr(related:, z)[[1]]+19)
[1] U6Gfb4QPVFMJ

Now checking from the Google Scholar page, the correct format for the
EndNote query would appear to be:

http://scholar.google.fi/scholar.enw?q=info:U6Gfb4QPVFMJ:scholar.google.com/output=citationhl=enoe=ASCIIoe=ASCIIct=citationcd=0

You can copy and paste this link to your browser, and save the EndNote
refence as a file.

Yet, when this link is constracted in R:

getURL(paste(http://scholar.google.fi/scholar.enw?q=info:;, substr(z,
gregexpr(related:, z)[[1]]+8, gregexpr(related:, z)[[1]]+19), :
scholar.google.com/output=citationhl=enoe=ASCIIoe=ASCIIct=citationcd=0,
sep=), curl=curl)

the result is an HTML-file containing 403 Forbidden error.

But, this type of a functionality seems to be missing from the Google API
(thank to Peter Konings for the link):

http://code.google.com/p/google-ajax-apis/issues/detail?id=109

- Jarno

2009/9/18 Duncan Temple Lang dun...@wald.ucdavis.edu


 Hi Jarno

 You've only told us half the story. You didn't show how you
 i) performed the original query
 ii) retrieved the URL you used in subsequent queries


 But I can suggest two possible problems.

 a) specifying the cookiejar option tells libcurl where to write the
   cookies that the particular curl handle has collected during its life.
   These are written when the curl handle is destroyed.
   So that wouldn't change the getURL() operation, just change what happens
   when the curl handle is destroyed.

 b) You probably mean to use cookiefile rather than cookiejar so that
   the curl request would read existing cookies from a file.
   But in that case, how did that file get created with the correct cookies.

 c) libcurl will collect cookies in a curl handle as it receives them from a
 server
   as part of a response. And it will use these in subsequent requests to
 that server.
   But you must be using the same curl handle.  Different curl handles are
 entirely
   independent (unless one is copied from another).
   So a possible solution may be that you need to do the initial query with
 the same
   curl handle


 So I would try something like

 curl = getCurlHandle()
 z = getForm(http://scholar.google.com/scholar;, q ='Frank Harrell', hl =
 'en', btnG = 'Search',
  .opts = list(verbose = TRUE), curl = curl)

 dd = htmlParse(z)
 links = getNodeSet(dd, //a...@href])

 # do something to identify the link you want

 tmp = getURL(linkIWant, curl = curl)


 Note that we are using the same curl object in both requests.


 This may not do what you want, but if you let us know the details
 about how you are doing the preceding steps, we should be able to sort
 things out.

  D.


 Jarno Tuimala wrote:
  Hi!
 
  I've performed a Google Scholar Search using a query, let's say Frank
  Harrell, and parsed the links to the EndNote references from the
 resulting
  HTML code. Now I'd like to download all the references automatically. For
  this, I have tried to use RCurl, but I can't seem to get it working: I
  always get error code 403 Forbidden from the web server.
 
  Initially I tried to do this without using cookies:
 
  library(RCurl)
  getURL(
 
 http://scholar.google.fi/scholar.enw?q=info:U6Gfb4QPVFMJ:scholar.google.com/output=citationhl=fioe=ASCIIct=citationcd=0
  )
 
  or
 
  getURLContent(
 
 http://scholar.google.fi/scholar.enw?q=info:U6Gfb4QPVFMJ:scholar.google.com/output=citationhl=fioe=ASCIIct=citationcd=0
  )
  Error: Forbidden
  and then with cookies:
 
   getURL(
 
 http://scholar.google.fi/scholar.enw?q=info:U6Gfb4QPVFMJ:scholar.google.com/output=citationhl=fioe=ASCIIct=citationcd=0
 ,
  .opts=list(cookiejar=cookiejar.txt))
 
  But they both consistently fail the same way. What am I doing wrong?
 
  sessionInfo()
  R version 2.9.0 (2009-04-17)
  i386-pc-mingw32
  locale:
 
 LC_COLLATE=Finnish_Finland.1252;LC_CTYPE=Finnish_Finland.1252;LC_MONETARY=Finnish_Finland.1252;LC_NUMERIC=C;LC_TIME=Finnish_Finland.1252
  attached base packages:
  [1] stats graphics  grDevices 

Re: [R] Suppressing script commands in R console when executing long program

2009-09-18 Thread Ishwor
Steve.
Hi.


 I have a script composing of more than 1000 lines and would like suppress
 the R codes from the console when executing the script (to reduce the
 physical processing time)

 I have tried options(echo=T) but no luck..

 *Q1. Are there any way of suppressing the commands in the R console?*

 Also, when importing spreadsheet consisting of numbers with 1,000 separator
 commas (i.e 1 as 10,000) into R  and performing basic arithmetic, R does
 not seem to recognise these separators..

 *Q2. Is R capable of reading numbers that are represented with 1,000
 separator commas?*
 **
 Many thanks for your expertise in resolving these problems.

You can try putting this in your Rprofile
options(keep.source=F)

This will work in the R cmd but it will not work in the RGui

Goodluck! :-)
-- 
Regards,
Ishwor Gurung

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


Re: [R] define a new family (and a new link function) for gam in gam package

2009-09-18 Thread Corrado
Dear David,

I am using gam in gam package (not in mgcv)  it is possible to force gam 
in mgcv to behave like gam in gam package?

On Thursday 17 September 2009 23:00:17 David Winsemius wrote:
 On Sep 17, 2009, at 1:39 PM, Topi, Corrado wrote:
  Dear R list,
 
  is it possible to define a new family (and a new link function) for
  gam in gam package? How?
 
  I read the help for gam, family, gam.model, make.link but I did not
  find a solution.

 Wood provides an example for negbin with alternate links in package
 mgcv;

 library(mgcv)
 ?negbin
 negbin  # produces the code



-- 
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] problem regarding the data

2009-09-18 Thread meghana kulkarni
Hi,
This is Meghana Kulkarni.
I have a problem regarding the data I am working with.

I have a data frame as follows:
 x

  V1  V2  V3V10
  414 A
  416 A
  417 A
  417 B
  418 A
  421 A
  421 B
  421 C
  422 A
I want to conver this data frame in the following format.

  x

 V1  V2  V3V10
  414 A

  416 A

  417 A
  417 B

  418 A

  421 A
  421 B
  421 C

  422 A

i.e. I want to insert a blank row after new entry in the 1st column. So that
it is easy for me to take readings in next columns when this data frame is
printed.
It would be great if you could tell me how this can be done.

Thank you,
Meghana.

[[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] Datetime conversion

2009-09-18 Thread premmad

Thanks for your reply

datetime
01OCT1987:00:00:00.000
12APR2004:00:00:00.000
01DEC1987:00:00:00.000
01OCT1975:00:00:00.000
01AUG1979:00:00:00.000
26JUN2003:00:00:00.000
01JAN1900:00:00:00.000
13MAY1998:00:00:00.000
30SEP1998:00:00:00.000

is in the file and i have imported it in to R and created dataframe test
with variable datetime for extracting only the datepart from it.

test$date-strptime(test$datetime,%d%b%Y)
and i got the following error 

Error in `$-.data.frame`(`*tmp*`, rw, value = list(sec = c(0, 0, 0,  : 
  replacement has 9 rows, data has 14

Is there any other way to solve this, please do reply .


David Winsemius wrote:
 
 
 On Sep 18, 2009, at 1:03 AM, premmad wrote:
 

 I'm relatively new to R .I tried converting the datetime column with  
 values
 like 01apr1985:00:00:00.000 using strptime(datetime,%d%b%Y).Could  
 anyone
 help me in this regard .Please reply ASAP i need .
 
 You will need to give us a more complete sample of your code, because  
 I don't see a problem:
 
   strptime(01apr1985:00:00:00.000,%d%b%Y)
 [1] 1985-04-01
 
 also works when hours, minutes and seconds format was used:
 
  strptime(01apr1985:00:00:00.000,%d%b%Y:%H:%M:%S)
 [1] 1985-04-01
  strptime(01apr1985:00:00:00.000,%d%b%Y:%T)
 [1] 1985-04-01

 
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Datetime-conversion-tp25503138p25503907.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] generating unordered combinations

2009-09-18 Thread Dan Halligan

That's brilliant - thanks.

On 17 Sep 2009, at 23:36, William Dunlap wrote:


There is a 1-1 correspondance between your n-sets
consisting of m possible element types (0 through m-1
in your example) and the number of n-subsets of a (n+m-1)-set.
E.g., your example had m=3 and n=3 and subtracting
1:3 from each column of combn(3+3-1,3) gives your result:


t(combn(3+3-1, 3)-(1:3))

 [,1] [,2] [,3]
[1,]000
[2,]001
[3,]002
[4,]011
[5,]012
[6,]022
[7,]111
[8,]112
[9,]122
[10,]222

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com


-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Dan Halligan
Sent: Thursday, September 17, 2009 1:31 PM
To: r-help@r-project.org
Subject: [R] generating unordered combinations

Hi,

I am trying to generate all unordered combinations of a set of
numbers / characters, and I can only find a (very) clumsy way of  
doing

this using expand.grid.  For example, all unordered combinations of
the numbers 0, 1, 2 are:
0, 0, 0
0, 0, 1
0, 0, 2
0, 1, 1
0, 1, 2
0, 2, 2
1, 1, 1
1, 1, 2
1, 2, 2
2, 2, 2

(I have not included, for example, 1, 0, 0, since it is equivalent to
0, 0, 1).

I have found a way to generate this data.frame using expand.grid as
follows:

g - expand.grid(c(0,1,2), c(0,1,2), c(0,1,2))
for(i in 1:nrow(g)) {
g[i,] - sort(as.character(g[i,]))
}
o - order(g$Var1, g$Var2, g$Var3)
unique(g[o,]).

This is obviously quite clumsy and hard to generalise to a greater
number of characters, so I'm keen to find any other solutions.  Can
anyone suggest a better (more general, quicker) method?

Cheers

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



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


[R] Help a newbie

2009-09-18 Thread ogbos okike
Hello,
To me as a beginner, every problem looks big. Below is what I was asked to
do as part of a code that will solve my problem. I have used read.table to
read my data into R and assigned the column names with colnames(dat)- ... .
But to go from txt- to the last  at the bottom of the table below is what
I am unable to do. Could anybody please tell me how to type or arrive at
txt-
y m d count
..
..

in R.
Thank you for your attention
Ogbos
.

Here is a more extensive example that shows also how to get date or counts
associated to pits/peaks:

txt - 
y  m   d  count
93 02 07 3974.6
93 02 08 3976.7
93 02 09 3955.2
93 02 10 3955.0
93 02 11 3971.8
93 02 12 3972.8
93 02 13 3961.0
93 02 14 3972.8
93 02 15 4008.0
93 02 16 4004.2
93 02 17 3981.2
93 02 18 3996.8
93 02 19 4028.2
93 02 20 4029.5
93 02 21 3953.4
93 02 22 3857.3
93 02 23 3848.3
93 02 24 3869.8
93 02 25 3898.1
93 02 26 3920.5
93 02 27 3936.7
93 02 28 3931.9

con - textConnection(txt)
dat - read.table(con, header = TRUE)
close(con)
dat$date - as.Date(paste(dat$y, dat$m, dat$d), format = %y %m %d)

library(pastecs)
tp - turnpoints(dat$count)

[[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] A stat related question

2009-09-18 Thread RON70

Can I ask a small stat. related question here?

Suppose I have two predictors for a time series processes and accuracy of
predictor is measured from MSEs. My question is, if two predictors give same
MSE then, necessarily they have to be identical? Can anyone provide me any
counter example?

Thanks.
-- 
View this message in context: 
http://www.nabble.com/A-stat-related-question-tp25505618p25505618.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] Help a newbie

2009-09-18 Thread baptiste auguie
I don't understand your question.

Where does your data come from in the first place? Is it stored in a
file, or is it a result of a previous operation in R, or is it
something you need to copy and paste in your script, or ...?

the textConnection() construct is often used to make for
self-contained examples on this list, but the real-world data are
often stored in separate text files (which can be read in read.table()
by specifying the filename).

HTH,

baptiste

2009/9/18 ogbos okike ogbos.ok...@gmail.com:
 Hello,
 To me as a beginner, every problem looks big. Below is what I was asked to
 do as part of a code that will solve my problem. I have used read.table to
 read my data into R and assigned the column names with colnames(dat)- ... .
 But to go from txt- to the last  at the bottom of the table below is what
 I am unable to do. Could anybody please tell me how to type or arrive at
 txt-
 y m d count
 ..
 ..
 
 in R.
 Thank you for your attention
 Ogbos
 .

 Here is a more extensive example that shows also how to get date or counts
 associated to pits/peaks:

 txt - 
 y  m   d  count
 93 02 07 3974.6
 93 02 08 3976.7
 93 02 09 3955.2
 93 02 10 3955.0
 93 02 11 3971.8
 93 02 12 3972.8
 93 02 13 3961.0
 93 02 14 3972.8
 93 02 15 4008.0
 93 02 16 4004.2
 93 02 17 3981.2
 93 02 18 3996.8
 93 02 19 4028.2
 93 02 20 4029.5
 93 02 21 3953.4
 93 02 22 3857.3
 93 02 23 3848.3
 93 02 24 3869.8
 93 02 25 3898.1
 93 02 26 3920.5
 93 02 27 3936.7
 93 02 28 3931.9
 
 con - textConnection(txt)
 dat - read.table(con, header = TRUE)
 close(con)
 dat$date - as.Date(paste(dat$y, dat$m, dat$d), format = %y %m %d)

 library(pastecs)
 tp - turnpoints(dat$count)

        [[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] problem regarding the data

2009-09-18 Thread Jim Lemon

On 09/18/2009 04:10 PM, meghana kulkarni wrote:

Hi,
This is Meghana Kulkarni.
I have a problem regarding the data I am working with.

I have a data frame as follows:
   

x
 

   V1  V2  V3V10
   414 A
   416 A
   417 A
   417 B
   418 A
   421 A
   421 B
   421 C
   422 A
I want to conver this data frame in the following format.

x

  V1  V2  V3V10
   414 A

   416 A

   417 A
   417 B

   418 A

   421 A
   421 B
   421 C

   422 A

i.e. I want to insert a blank row after new entry in the 1st column. So that
it is easy for me to take readings in next columns when this data frame is
printed.
It would be great if you could tell me how this can be done.

   

Hi Meghana,
Try this:

spaceBlocks-function(x,spacevar) {
 thisblock-x[1,spacevar]
 for(row in 1:dim(x)[1]) {
  if(thisblock != x[row,spacevar]) cat(\n)
  for(col in 1:length(unlist(x[row,])))
   cat(as.character(x[row,col]), )
  cat(\n)
  thisblock-x[row,spacevar]
 }
}

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] Datetime conversion

2009-09-18 Thread Girish A.R.

Seems to work alright for me.

datetime -c(
01OCT1987:00:00:00.000,
12APR2004:00:00:00.000,
01DEC1987:00:00:00.000,
01OCT1975:00:00:00.000,
01AUG1979:00:00:00.000,
26JUN2003:00:00:00.000,
01JAN1900:00:00:00.000,
13MAY1998:00:00:00.000,
30SEP1998:00:00:00.000) 

 date-strptime(datetime,%d%b%Y) 
 date
[1] 1987-10-01 2004-04-12 1987-12-01 1975-10-01 1979-08-01
2003-06-26
[7] 1900-01-01 1998-05-13 1998-09-30

cheers,
-Girish


premmad wrote:
 
 Thanks for your reply
 
 datetime
 01OCT1987:00:00:00.000
 12APR2004:00:00:00.000
 01DEC1987:00:00:00.000
 01OCT1975:00:00:00.000
 01AUG1979:00:00:00.000
 26JUN2003:00:00:00.000
 01JAN1900:00:00:00.000
 13MAY1998:00:00:00.000
 30SEP1998:00:00:00.000
 
 is in the test  file and i have imported it in to R and created dataframe
 test with variable datetime for extracting only the datepart from it.
 By using the following function 
 
 test$date-strptime(test$datetime,%d%b%Y)
 and i got the following error 
 
 Error in `$-.data.frame`(`*tmp*`, rw, value = list(sec = c(0, 0, 0,  : 
   replacement has 9 rows, data has 14
 
 Is there any other way to solve this, please do reply .
 
 
 David Winsemius wrote:
 
 
 On Sep 18, 2009, at 1:03 AM, premmad wrote:
 

 I'm relatively new to R .I tried converting the datetime column with  
 values
 like 01apr1985:00:00:00.000 using strptime(datetime,%d%b%Y).Could  
 anyone
 help me in this regard .Please reply ASAP i need .
 
 You will need to give us a more complete sample of your code, because  
 I don't see a problem:
 
   strptime(01apr1985:00:00:00.000,%d%b%Y)
 [1] 1985-04-01
 
 also works when hours, minutes and seconds format was used:
 
  strptime(01apr1985:00:00:00.000,%d%b%Y:%H:%M:%S)
 [1] 1985-04-01
  strptime(01apr1985:00:00:00.000,%d%b%Y:%T)
 [1] 1985-04-01

 
 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.
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Datetime-conversion-tp25503138p25505915.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] Lattice barplot not wokring in for-loop?

2009-09-18 Thread stvienna wiener
Dear List-Members,


I am plotting a barplot with the lattice package. The code works, but
when I execute the same code in a for-loop
no plot is shown. Can't figure what the problem is.
(Maybe I am missing something here, but I tried it with plot device
pdf, calling windows() or X11(), testing on windows and linux, etc.)

INFO: R version 2.9.1 (2009-06-26) using Windows/RGui

require(lattice)

for( z in 1:3) {

## plot works when executed alone,
## however in a for loop no plot is shown...
barchart(yield ~ variety | site, data = barley,
 groups = year, layout = c(1,6), stack = TRUE,
 auto.key = list(points = FALSE, rectangles = TRUE, space = right),
 ylab = Barley Yield (bushels/acre),
 scales = list(x = list(rot = 45)))

}



I can't program any further without solving this.

So, thanks! Really!
Steve

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


Re: [R] Lattice barplot not wokring in for-loop?

2009-09-18 Thread Romain Francois

On 09/18/2009 11:44 AM, stvienna wiener wrote:


Dear List-Members,


I am plotting a barplot with the lattice package. The code works, but
when I execute the same code in a for-loop
no plot is shown. Can't figure what the problem is.
(Maybe I am missing something here, but I tried it with plot device
pdf, calling windows() or X11(), testing on windows and linux, etc.)

INFO: R version 2.9.1 (2009-06-26) using Windows/RGui

require(lattice)

for( z in 1:3) {

## plot works when executed alone,
## however in a for loop no plot is shown...
barchart(yield ~ variety | site, data = barley,
  groups = year, layout = c(1,6), stack = TRUE,
  auto.key = list(points = FALSE, rectangles = TRUE, space = right),
  ylab = Barley Yield (bushels/acre),
  scales = list(x = list(rot = 45)))

}



I can't program any further without solving this.

So, thanks! Really!
Steve


http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/yw8E : New R package : sos
|- http://tr.im/y8y0 : search the graph gallery from R
`- http://tr.im/y8wY : new R package : ant

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


Re: [R] A stat related question

2009-09-18 Thread Meyners, Michael, LAUSANNE, AppliedMathematics
Let's assume you have just three observations, and x-- = 1:3 for your
observations. 

Predictor 1:y = x^2
Predictor 2:y = 1 if x=1
y = 4 if x=2
y = 9 if x=3
y = 0 elsewhere

These predictors are obviously not the same, but will give the same Mean
Squared Error for your data (whatever your observed y-values are). This
should suffice as a counter example. Or did I misunderstand your
question?

HTH, Michael


 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of RON70
 Sent: Freitag, 18. September 2009 11:23
 To: r-help@r-project.org
 Subject: [R] A stat related question
 
 
 Can I ask a small stat. related question here?
 
 Suppose I have two predictors for a time series processes and 
 accuracy of predictor is measured from MSEs. My question is, 
 if two predictors give same MSE then, necessarily they have 
 to be identical? Can anyone provide me any counter example?
 
 Thanks.
 --
 View this message in context: 
 http://www.nabble.com/A-stat-related-question-tp25505618p25505618.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] SVM

2009-09-18 Thread Samuel Okoye
Thank you again for your reply! What I would like to do is to class my sample 
into two group (0,1). I am not sure which method to apply and whether the svm 
is the correct one! However, when I apply the below R code I get two group the 
samples in TRUE and FALSE. Can I take this result to put TRUE samples in group 
A and FALSE samples in group B?

Best wishes,
Samuel

PS: I will not give up to understand statistics!

--- On Thu, 9/17/09, Steve Lianoglou mailinglist.honey...@gmail.com wrote:

From: Steve Lianoglou mailinglist.honey...@gmail.com
Subject: Re: [R] SVM
To: Samuel Okoye samu...@yahoo.com
Cc: r-h...@stat.math.ethz.ch
Date: Thursday, September 17, 2009, 2:47 PM

Hi,

On Sep 17, 2009, at 5:34 PM, Samuel Okoye wrote:

 Thank you for your reply! Yes, I am using the svm and I do not have new data 
 (how do you create new data?), all I have these 12 samples which I want to 
 classify (predict) these into two group so that I do have six sample in each 
 group?

I'm not really sure where to begin ... what are you trying to do, exactly? Why 
do you think you want to build an SVM? What do you expect it to do for you?

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




  
[[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] Datetime conversion

2009-09-18 Thread Girish A.R.

See if this is what you are looking for:

dt - as.data.frame(datetime)
 date-strptime(as.character(dt$datetime),%d%b%Y)
 date
[1] 1987-10-01 2004-04-12 1987-12-01 1975-10-01 1979-08-01
2003-06-26
[7] 1900-01-01 1998-05-13 1998-09-30

cheers,
-Girish



premmad wrote:
 
 Girish it works for me also if its a vector.I have problem if the data is
 stored as dataframe(rows and columns) please do help me in this
 
 Girish A.R. wrote:
 
 Seems to work alright for me.
 
 datetime -c(
 01OCT1987:00:00:00.000,
 12APR2004:00:00:00.000,
 01DEC1987:00:00:00.000,
 01OCT1975:00:00:00.000,
 01AUG1979:00:00:00.000,
 26JUN2003:00:00:00.000,
 01JAN1900:00:00:00.000,
 13MAY1998:00:00:00.000,
 30SEP1998:00:00:00.000) 
 
 date-strptime(datetime,%d%b%Y) 
 date
 [1] 1987-10-01 2004-04-12 1987-12-01 1975-10-01 1979-08-01
 2003-06-26
 [7] 1900-01-01 1998-05-13 1998-09-30
 
 cheers,
 -Girish
 
 
 premmad wrote:
 
 Thanks for your reply
 
 datetime
 01OCT1987:00:00:00.000
 12APR2004:00:00:00.000
 01DEC1987:00:00:00.000
 01OCT1975:00:00:00.000
 01AUG1979:00:00:00.000
 26JUN2003:00:00:00.000
 01JAN1900:00:00:00.000
 13MAY1998:00:00:00.000
 30SEP1998:00:00:00.000
 
 is in the test  file and i have imported it in to R and created
 dataframe test with variable datetime for extracting only the datepart
 from it.
 By using the following function 
 
 test$date-strptime(test$datetime,%d%b%Y)
 and i got the following error 
 
 Error in `$-.data.frame`(`*tmp*`, rw, value = list(sec = c(0, 0, 0, 
 : 
   replacement has 9 rows, data has 14
 
 Is there any other way to solve this, please do reply .
 
 
 David Winsemius wrote:
 
 
 On Sep 18, 2009, at 1:03 AM, premmad wrote:
 

 I'm relatively new to R .I tried converting the datetime column with  
 values
 like 01apr1985:00:00:00.000 using strptime(datetime,%d%b%Y).Could  
 anyone
 help me in this regard .Please reply ASAP i need .
 
 You will need to give us a more complete sample of your code, because  
 I don't see a problem:
 
   strptime(01apr1985:00:00:00.000,%d%b%Y)
 [1] 1985-04-01
 
 also works when hours, minutes and seconds format was used:
 
  strptime(01apr1985:00:00:00.000,%d%b%Y:%H:%M:%S)
 [1] 1985-04-01
  strptime(01apr1985:00:00:00.000,%d%b%Y:%T)
 [1] 1985-04-01

 
 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.
 
 
 
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Datetime-conversion-tp25503138p25506234.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] some irritation with heteroskedasticity testing

2009-09-18 Thread Bunny, lautloscrew.com

Dear all,

Trying to test for heteroskedasticity I tried several test from the  
car package respectively lmtest. Now that they produce rather  
different results i am somewhat clueless how to deal with it.

Here is what I did:

1.  I plotted fitted.values vs residuals and somewhat intuitively  
believe, it isn't really increasing...



2. further I ran the following tests
bptest (studentized and non-studentized), gqtest, ncv.test with the  
following results:


ncv:
Non-constant Variance Score Test
Variance formula: ~ fitted.values
Chisquare = 13.87429Df = 1 p = 0.00194580

Goldfeld-Quandt test
data:  reg
GQ = 1.7092, df1 = 327, df2 = 327, p-value = 7.93e-07


studentized Breusch-Pagan test
data:  reg
BP = 15.8291, df = 23, p-value = 0.92


Breusch-Pagan test
data:  reg
BP = 377.5604, df = 23, p-value  2.8e-18


bptest and gq.test sport pretty straight forward examples saying the  
H0 = homoskedasticity. The ncv.test clarifies the same in its  
description. Thus the studentized bptest appears to be the only one to  
support my first intuition from the graphical solution. I am really  
disturbed what to do know and how to interpret my results... Can  
someone lead the way ?


thx in advance

matt

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


Re: [R] Errors and line numbers in scripts?

2009-09-18 Thread Duncan Murdoch

ws wrote:
Is there a way to have R return the line number in a script when it errors out?  


I call my script like:

$ R --vanilla  script.R  output.txt

I seem to remember a long discussion about this at some point, but I can't 
remember the outcome.


  


The current development version returns much more information about 
error locations.  I don't know if it will handle this case (R doesn't 
get told the filename in case of input redirection, for example).  
Generally the goal is to report error lines during interactive use, 
batch use is assumed to already be debugged.


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] Suppressing script commands in R console when executing long program

2009-09-18 Thread Duncan Murdoch

Ishwor wrote:

Steve.
Hi.


  

I have a script composing of more than 1000 lines and would like suppress
the R codes from the console when executing the script (to reduce the
physical processing time)

I have tried options(echo=T) but no luck..

*Q1. Are there any way of suppressing the commands in the R console?*

Also, when importing spreadsheet consisting of numbers with 1,000 separator
commas (i.e 1 as 10,000) into R  and performing basic arithmetic, R does
not seem to recognise these separators..

*Q2. Is R capable of reading numbers that are represented with 1,000
separator commas?*
**
Many thanks for your expertise in resolving these problems.



You can try putting this in your Rprofile
options(keep.source=F)

This will work in the R cmd but it will not work in the RGui
  


The syntax is wrong there:  that should be options(keep.source=F).  But 
I don't think it addresses either question.


The normal way to execute a script from the console is 
source(filename.R), which by default doesn't echo.


I don't know the answer to Q2, but would guess that the answer is yes; 
just not sure if someone has already written the function to remove the 
commas.


Duncan Murdoch

Goodluck! :-)



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


Re: [R] Datetime conversion

2009-09-18 Thread Girish A.R.

I'm not able to replicate your problem. Here's what I get. See if this is
what you want:

 dt$date-strptime(as.character(dt$datetime),%d%b%Y) 
 dt
datetime   date
1 01OCT1987:00:00:00.000 1987-10-01
2 12APR2004:00:00:00.000 2004-04-12
3 01DEC1987:00:00:00.000 1987-12-01
4 01OCT1975:00:00:00.000 1975-10-01
5 01AUG1979:00:00:00.000 1979-08-01
6 26JUN2003:00:00:00.000 2003-06-26
7 01JAN1900:00:00:00.000 1900-01-01
8 13MAY1998:00:00:00.000 1998-05-13
9 30SEP1998:00:00:00.000 1998-09-30

cheers,
-Girish

===


premmad wrote:
 
 It works but what i need is the result also as a column .
 I tried using the following code .
 dt$new-strptime(as.character(dt$datetime),%d%b%Y.
 It shows the following error
 
 Error in `$-.data.frame`(`*tmp*`, Sa_dt, value = list(sec = c(0, 0,  : 
   replacement has 9 rows, data has 14.
 
 Please help me to solve this
 

-- 
View this message in context: 
http://www.nabble.com/Datetime-conversion-tp25503138p25506493.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] Datetime conversion

2009-09-18 Thread premmad

Girish it works for me also if its a vector.I have problem if the data is
stored as dataframe(rows and columns) please do help me in this

Girish A.R. wrote:
 
 Seems to work alright for me.
 
 datetime -c(
 01OCT1987:00:00:00.000,
 12APR2004:00:00:00.000,
 01DEC1987:00:00:00.000,
 01OCT1975:00:00:00.000,
 01AUG1979:00:00:00.000,
 26JUN2003:00:00:00.000,
 01JAN1900:00:00:00.000,
 13MAY1998:00:00:00.000,
 30SEP1998:00:00:00.000) 
 
 date-strptime(datetime,%d%b%Y) 
 date
 [1] 1987-10-01 2004-04-12 1987-12-01 1975-10-01 1979-08-01
 2003-06-26
 [7] 1900-01-01 1998-05-13 1998-09-30
 
 cheers,
 -Girish
 
 
 premmad wrote:
 
 Thanks for your reply
 
 datetime
 01OCT1987:00:00:00.000
 12APR2004:00:00:00.000
 01DEC1987:00:00:00.000
 01OCT1975:00:00:00.000
 01AUG1979:00:00:00.000
 26JUN2003:00:00:00.000
 01JAN1900:00:00:00.000
 13MAY1998:00:00:00.000
 30SEP1998:00:00:00.000
 
 is in the test  file and i have imported it in to R and created dataframe
 test with variable datetime for extracting only the datepart from it.
 By using the following function 
 
 test$date-strptime(test$datetime,%d%b%Y)
 and i got the following error 
 
 Error in `$-.data.frame`(`*tmp*`, rw, value = list(sec = c(0, 0, 0,  : 
   replacement has 9 rows, data has 14
 
 Is there any other way to solve this, please do reply .
 
 
 David Winsemius wrote:
 
 
 On Sep 18, 2009, at 1:03 AM, premmad wrote:
 

 I'm relatively new to R .I tried converting the datetime column with  
 values
 like 01apr1985:00:00:00.000 using strptime(datetime,%d%b%Y).Could  
 anyone
 help me in this regard .Please reply ASAP i need .
 
 You will need to give us a more complete sample of your code, because  
 I don't see a problem:
 
   strptime(01apr1985:00:00:00.000,%d%b%Y)
 [1] 1985-04-01
 
 also works when hours, minutes and seconds format was used:
 
  strptime(01apr1985:00:00:00.000,%d%b%Y:%H:%M:%S)
 [1] 1985-04-01
  strptime(01apr1985:00:00:00.000,%d%b%Y:%T)
 [1] 1985-04-01

 
 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.
 
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Datetime-conversion-tp25503138p25505976.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] Maximum No.of code in R

2009-09-18 Thread premmad

I tried running 50 lines of ifelse statement in R and the system says context
stack overflow at 50 line.Is it the limitation of R or is there any way
around that can be done to overcome this.Thanks
-- 
View this message in context: 
http://www.nabble.com/Maximum-No.of-code-in-R-tp25506024p25506024.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] Datetime conversion

2009-09-18 Thread premmad

It works but what i need is the result also as a column .
I tried using the following code .
dt$new-strptime(as.character(dt$datetime),%d%b%Y.
It shows the following error

Error in `$-.data.frame`(`*tmp*`, Sa_dt, value = list(sec = c(0, 0,  : 
  replacement has 9 rows, data has 14.

Please help me to solve this
-- 
View this message in context: 
http://www.nabble.com/Datetime-conversion-tp25503138p25506438.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] Datetime conversion

2009-09-18 Thread premmad

The same what you have worked out is my need but i'm getting the following
error  
Error in `$-.data.frame`(`*tmp*`, date, value = list(sec = c(0, 0,  : 
  replacement has 9 rows, data has 14
Please help me in this
-- 
View this message in context: 
http://www.nabble.com/Datetime-conversion-tp25503138p25506705.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] Suppressing script commands in R console when executing long program

2009-09-18 Thread Philipp Pagel
On Fri, Sep 18, 2009 at 03:46:27PM +1000, Steven Kang wrote:
 *Q1. Are there any way of suppressing the commands in the R console?*

I think this has been answered already.

 *Q2. Is R capable of reading numbers that are represented with 1,000
 separator commas?*

I am not aware of an option to read.table and freinds that does this
but you can recover easily:

 foo - read.delim('foo.tbl')
 foo
  A  B
1 1 12,300
2 2 256,001.01
3 3  900.1
4 4 80
 str(foo)
'data.frame':   4 obs. of  2 variables:
 $ A: int  1 2 3 4
 $ B: Factor w/ 4 levels 12,300,256,001.01,..: 1 2 4 3
 foo$B - as.numeric(sub(',', '', as.character(foo$B)))
 foo
  AB
1 1  12300.0
2 2 256001.0
3 3900.1
4 4 80.0
 str(foo)
'data.frame':   4 obs. of  2 variables:
 $ A: int  1 2 3 4
 $ B: num  12300 256001 900 80


cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/

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


Re: [R] Datetime conversion

2009-09-18 Thread Philipp Pagel
 The same what you have worked out is my need but i'm getting the following
 error  
 Error in `$-.data.frame`(`*tmp*`, date, value = list(sec = c(0, 0,  : 
   replacement has 9 rows, data has 14

Please give more detail about what you did. This error is certainly
not from the example used in previous postings, as the data fram eused
there has 9 rows, not 14. Without the details (code) on what you did
its all guesswork. Perhaps you are mixing two data.frames of differnt
shape or ...

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/

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


Re: [R] Datetime conversion

2009-09-18 Thread Girish A.R.

Can you post a reproducible code snippet, along with the output/error
messages, and the output of sessionInfo(). That way other folks on R-help
may be able to offer help.

Here's myl output of sessionInfo()

 sessionInfo()
R version 2.9.2 (2009-08-24) 
i386-pc-mingw32 

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

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

other attached packages:
 [1] RWinEdt_1.8-1  gtools_2.6.1   gmodels_2.15.0
lme4_0.999375-31  
 [5] Matrix_0.999375-30 lattice_0.17-25ggplot2_0.8.3  reshape_0.8.3 
 [9] plyr_0.1.9 proto_0.3-8Design_2.2-0   Hmisc_3.7-0   
[13] survival_2.35-4doBy_4.0.1

loaded via a namespace (and not attached):
[1] cluster_1.12.0   Formula_0.1-3gdata_2.6.1  kinship_1.1.0-23
MASS_7.2-48 
[6] nlme_3.1-93  plm_1.1-4sandwich_2.2-1  


cheers,
-Girish

===

premmad wrote:
 
 The same what you have worked out is my need but i'm getting the following
 error  
 Error in `$-.data.frame`(`*tmp*`, date, value = list(sec = c(0, 0,  : 
   replacement has 9 rows, data has 14
 Please help me in this
 

-- 
View this message in context: 
http://www.nabble.com/Datetime-conversion-tp25503138p25506979.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] Suppressing script commands in R console when executing long program

2009-09-18 Thread Philipp Pagel
On Fri, Sep 18, 2009 at 12:59:16PM +0200, Philipp Pagel wrote:

  foo$B - as.numeric(sub(',', '', as.character(foo$B)))

Thinking about it some more, you should use gsub instead of sub here.
Otherwise only the first occurrence of the thousands separator will be
removed.

cu
Philipp


-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/

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


[R] Error: length(f1) == length(f2) is not TRUE

2009-09-18 Thread A Singh


Dear R users,

I am trying to fit an lmer model with only random effects which is giving 
me the following error:


Error : length(f1) == length(f2) is not TRUE
In addition: Warning messages:
1: In P1L55:family :
 numerical expression has 390 elements: only the first used
2: In P1L55:family :
 numerical expression has 390 elements: only the first used


I am trying to extract variance components for a phenotype 'peg.no', using 
the variable 'family' and a marker column 'P1L55' (which is categorical and 
has 2 levels- 0 and 1), as random effects. There are no fixed effects.


The code I used is as follows:

vc-read.table(...)

vcdf-data.frame(vc)
colms-(vc)[4:13] ##these are the markers
lapply(colms,factor)

try(fit-lmer(peg.no~1 + (1|family/P1L55), na.action=na.include, data=vcdf))


I thought that putting the data into a dataframe would help, along with the 
na.exclude command, because there is a lot of missing data in patches which 
I have replaced with NA's, but I  don't know how to fix this error at all.


Its a bit urgent, and any help is hugely appreciated.

The data files are at:


http://www.4shared.com/file/131980362/460bdafe/Testvcomp10.html (excel)
http://www.4shared.com/file/131980512/dc7308b/Testvcomp10.html
(txt)


Cheers,
Aditi

--
A Singh
aditi.si...@bristol.ac.uk
School of Biological Sciences
University of Bristol

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


Re: [R] Maximum No.of code in R

2009-09-18 Thread Duncan Murdoch

On 9/18/2009 5:49 AM, premmad wrote:

I tried running 50 lines of ifelse statement in R and the system says context
stack overflow at 50 line.Is it the limitation of R or is there any way
around that can be done to overcome this.Thanks


You can always break it up into multiple lines.  For example, the 
following are equivalent if we ignore the presence of the temp variable 
in the second case.


x - ifelse(a, b, ifelse(c, d, e))

and

temp - ifelse(c, d, e)
x - ifelse(a, b, temp)

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] lattice: How to display no box but only a y-axis on the left + Thicker lines

2009-09-18 Thread lith
 1.) How do I make lattice (e.g. barchart) to not draw a box but only a
 y-axis on the left hand side so that the plot looks like barplot with
 default settings?

Does nobody have an idea? Or is the solution that obvious?

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


Re: [R] Datetime conversion

2009-09-18 Thread jim holtman
Your problem is that 'strptime' returns an object of POSIXlt type
which is 9 elements; what you what is: ( you need a POSIXct type)

dt$new-as.POSIXct(strptime(as.character(dt$datetime),%d%b%Y))

On Fri, Sep 18, 2009 at 6:26 AM, premmad mtechp...@gmail.com wrote:

 It works but what i need is the result also as a column .
 I tried using the following code .
 dt$new-strptime(as.character(dt$datetime),%d%b%Y.
 It shows the following error

 Error in `$-.data.frame`(`*tmp*`, Sa_dt, value = list(sec = c(0, 0,  :
  replacement has 9 rows, data has 14.

 Please help me to solve this
 --
 View this message in context: 
 http://www.nabble.com/Datetime-conversion-tp25503138p25506438.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem that you are trying to solve?

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


Re: [R] some irritation with heteroskedasticity testing

2009-09-18 Thread John Fox
Dear matt,

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of Bunny, lautloscrew.com
 Sent: September-18-09 6:18 AM
 To: r-help@r-project.org
 Subject: [R] some irritation with heteroskedasticity testing
 
 Dear all,
 
 Trying to test for heteroskedasticity I tried several test from the
 car package respectively lmtest. Now that they produce rather
 different results i am somewhat clueless how to deal with it.
 Here is what I did:
 
 1.  I plotted fitted.values vs residuals and somewhat intuitively
 believe, it isn't really increasing...

It's often difficult to judge whether the spread of the residuals changes
with the fitted values; you might alternatively try to visualize the fit
with the spread.level.plot() function in the car package.

 
 
 2. further I ran the following tests
 bptest (studentized and non-studentized), gqtest, ncv.test with the
 following results:
 
 ncv:
 Non-constant Variance Score Test
 Variance formula: ~ fitted.values
 Chisquare = 13.87429Df = 1 p = 0.00194580
 
 Goldfeld-Quandt test
 data:  reg
 GQ = 1.7092, df1 = 327, df2 = 327, p-value = 7.93e-07
 

You don't show the function call to gqtest(). If you specified
order.by=fitted(reg), then the two tests are similar, except that gqtest()
by default uses a one-sided alternative hypothesis. If you used the default
for order.by, then the test is probably nonsense. Both tests suggest
heteroscedasticity.

 
 studentized Breusch-Pagan test
 data:  reg
 BP = 15.8291, df = 23, p-value = 0.92
 
 
 Breusch-Pagan test
 data:  reg
 BP = 377.5604, df = 23, p-value  2.8e-18

bp.test() performs the same score test as ncv.test(), except that the
default alternative hypothesis is different -- in bp.test() that the error
variance is a function of a linear combination of the regressors and in
ncv.test() that the error variance is a function of the fitted values (i.e.,
a *particular* linear combination of regressors). Testing against the fitted
values with 1 df will have greater power if this is the real pattern of
heteroscedasticity. That the chisquare is much greater for the general BP
test suggests that the pattern is more complex. The studentized BP test is
robust against non-normal errors. That you would get such a dramatically
different result is surprising and would lead me to guess that the residual
distribution is very heavy-tailed, perhaps with some bad outliers. Without
the data, it's not possible to know.

Regards,
 John

 
 
 bptest and gq.test sport pretty straight forward examples saying the
 H0 = homoskedasticity. The ncv.test clarifies the same in its
 description. Thus the studentized bptest appears to be the only one to
 support my first intuition from the graphical solution. I am really
 disturbed what to do know and how to interpret my results... Can
 someone lead the way ?
 
 thx in advance
 
 matt
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Linear objective function with Quadratic constraints

2009-09-18 Thread vikrant S

I am new to R and I want to solve this following problem using R.

My Objective function is a linear function with Quadratic constraints.I want
to know how to solve this problem and which package will be helpful for me
for solving such type of problems.Moreover my one constraint is linear and
equality constraints and another quadratic constraint is inequality
constraint.
How to solve this problem ?
Plz help Me

Min z = 5 *x1 + 9*x2 + 7.15*x3 + 3.5 *x4
subject to following constraints.
x1 + x2 + x3 + x4 = 9
x1 + x4 =6.55
x3(x3 - 3.6) = 0 

 

 

-- 
View this message in context: 
http://www.nabble.com/Linear-objective-function-with-Quadratic-constraints-tp25507032p25507032.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] Datetime conversion

2009-09-18 Thread premmad

Thanks .I tried its working but when i tried to view the dataframe i got the
following error
Error in edit.data.frame(get(subx, envir = parent), title = subx, ...) : 
  can only handle vector and factor elements


-- 
View this message in context: 
http://www.nabble.com/Datetime-conversion-tp25503138p25507734.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] Datetime conversion

2009-09-18 Thread premmad

Sorry for confusing you all with my inexperienced posting .
I tried as u said if you have 9 rows in the data it is working fine but
please try out the same example as you have suggested earlier with morethan
9 rows.

I tried it as following
datetime -c(
+ 01OCT1987:00:00:00.000,
+  12APR2004:00:00:00.000,
+   01DEC1987:00:00:00.000,
+  01OCT1975:00:00:00.000,
+   01AUG1979:00:00:00.000,
+  26JUN2003:00:00:00.000,
+  01JAN1900:00:00:00.000,
+  13MAY1998:00:00:00.000,
+  30SEP1998:00:00:00.000,
+  30SEP1998:00:00:00.000,
+  30SEP1998:00:00:00.000,
+  30SEP1998:00:00:00.000) 
dt - as.data.frame(datetime) 

dt$date-strptime(as.character(dt$datetime),%d%b%Y) 

and got the following error :

Error in `$-.data.frame`(`*tmp*`, date, value = list(sec = c(0, 0,  : 
  replacement has 9 rows, data has 12.


MY session info details are as follows:

R version 2.9.2 (2009-08-24) 
i386-pc-mingw32 

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

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

other attached packages:
[1] sqldf_0-1.5 gsubfn_0.5-0proto_0.3-8 RSQLite_0.7-2  
DBI_0.2-4   lattice_0.17-25 chron_2.3-30   

loaded via a namespace (and not attached):
[1] grid_2.9.2  tools_2.9.2
-- 
View this message in context: 
http://www.nabble.com/Datetime-conversion-tp25503138p25507205.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] matching pairs regardless of order

2009-09-18 Thread Juliane Struve
Dear list,
 
I am using match() to match pairs of locations, e.g. trip=loc1,loc2 from a 
list of such pairs, e.g. list=(loc1,loc2, loc1,loc3, 
loc2,loc3,loc2,loc1). 
 
In this example match() will match trip with the first element of list, but 
not the 4th, because the order is reversed. 
 
How can I get a match with both ?
 
Many thanks for any help,
 
Juliane 




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


Re: [R] Maximum No.of code in R

2009-09-18 Thread premmad

Thanks for the reply and it is useful.What i want to know here is i'm going
to try and write an automated procedure using batch processing in R by the
way input of the next step is going to be this steps output .so one will not
able to predict the lines please also do answer in taking consideration the
above mentioned criteria in to consideration.Once again thanks for the help
this community is providing actively


-- 
View this message in context: 
http://www.nabble.com/Maximum-No.of-code-in-R-tp25506024p25507509.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

2009-09-18 Thread Steve Lianoglou
Thank you again for your reply! What I would like to do is to class  
my sample into two group (0,1). I am not sure which method to apply  
and whether the svm is the correct one! However, when I apply the  
below R code I get two group the samples in TRUE and FALSE. Can I  
take this result to put TRUE samples in group A and FALSE samples in  
group B?


The SVM packages in R implement SVMs that need to be trained in a  
supervised setting, which means that you have to have data *with*  
labels. Is this what you have?


The SVM will look at the features of each data point and its label,  
and return you a model that can look at *similar* data and predict its  
label (+1 or -1). Since you *already know* the labels of your data  
points, you can give the SVM some of your data that it didn't use for  
training and see how well it can predict their labels.


Lastly, I'm not sure where FALSE and TRUE are coming from, sorry.


PS: I will not give up to understand statistics!


You shouldn't give up, but unfortunately a mailing list isn't the best  
place to learn statistics (or anything really) from.


If you're interested in really learning more about SVMs and other  
machine learning approaches, you can watch Andrew Ng's intro to  
machine learning classes online. The relevant links are at the top of  
this page:


http://ai.stanford.edu/~ang/courses.html

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


[R] Updating R-code in own package

2009-09-18 Thread Katrine Damgaard
Hey everybody!
We have created our own package, and need to do some corrections in the R-code 
of one of the function included in the package.
How can I do that. I have read a manual how to create an R package, but I can't 
find anything about updating R-code in the package.

Best regards,
Katrine



[[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] Compare a group of line slopes

2009-09-18 Thread Juliet Hannah
The test that a slope differs by group is a test that the
variable*group interaction equals
zero (overall test). Maybe searching post-hoc comparisons in
regression will give you some
leads.

On Tue, Sep 15, 2009 at 10:57 AM, Jun Shen jun.shen...@gmail.com wrote:
 Hi, all,

 I am thinking to compare a group of slopes from regression lines to see if
 they are different overall, and then make specific comparisons between
 groups. How can I achieve that in R?  I searched the archives and there are
 only discussions about comparing two lines a time.  Thanks.

 A sample data set is like the following. I would like to compare the
 regression slopes between the five groups. Thanks for your help.

 data-data.frame(x=rep(1:10,5),y=rnorm(50),group=rep(1:5,each=10))

 Jun Shen

        [[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] Updating R-code in own package

2009-09-18 Thread Steve Lianoglou

Hi,

On Sep 18, 2009, at 8:31 AM, Katrine Damgaard wrote:


Hey everybody!
We have created our own package, and need to do some corrections in  
the R-code of one of the function included in the package.
How can I do that. I have read a manual how to create an R package,  
but I can't find anything about updating R-code in the package.


I'm pretty sure the only correct thing to do is just fix the code in  
your package's source tree then reinstall the package wholesale to  
replace the bad code with the fixed code.


-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] lattice: How to display no box but only a y-axis on the left + Thicker lines

2009-09-18 Thread baptiste auguie
No box is easy,

bwplot(y~x, data=data.frame(y=rnorm(10),x=sample(letters[1:3],10,repl=T)),
par.settings=list(axis.line=list(col=NA)))

but that seems to remove all axis lines and ticks as well. You may
have to define a custom panel.axis() function.

An alternative is to use grid.remove() to remove the frame,
bwplot(y~x, data=data.frame(y=rnorm(10),x=sample(letters[1:3],10,repl=T)))
grid.remove(rect,grep=T,global=TRUE)

HTH,

baptiste



2009/9/18 lith minil...@gmail.com:
 1.) How do I make lattice (e.g. barchart) to not draw a box but only a
 y-axis on the left hand side so that the plot looks like barplot with
 default settings?

 Does nobody have an idea? Or is the solution that obvious?

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

2009-09-18 Thread Hans Roggeman
Hi,

 

I have a simple question on interpreting output results from your msm
package in R when using a categorical model with hcovariates i.e.
covariates on the parameters of the emission model. The interpretation
is straightforward for normal distributions, etc. but when using
categorical distributions I get results like these:

 

prob

P(1)0.8597657482

P(2)0.0001943636

P(3)0.0042761544

P(4)0.0002781397

P(5)0.0005549986

P(6)0.1349305955

DC_MAX_POSSIBLE_L1  0.4804758829

DC_MAX_POSSIBLE_L1  0.4216246143

DC_MAX_POSSIBLE_L1 -0.0552074714

DC_MAX_POSSIBLE_L1  0.1899573843

DC_MAX_POSSIBLE_L1  0.0963140485

 

at first glance I thought that 1 unit of DC_MAX_POSSIBLE_L1  was
responsible for increasing the probability of outcome of factor 2 (P(2))
by 0.48 but that does not make sense given that DC_MAX_POSSIBLE_L1 is an
integer ranging from -20 to +20. How do I interpret the results ? 

 

the original call was:

 

msm_pc10 = msm(  OUTCOME ~ TIME, data = myFrame,

  qmatrix = qmatrix

  ,hmodel = list (hmmDist_1,hmmDist_2)

  ,hcovariates = list ( ~ 1 + DC_MAX_POSSIBLE_L1,

 ~ 1 + DC_MAX_POSSIBLE_L1) 

  ,control = list(reltol = 1e-03)

  ,method = BFGS, use.deriv = FALSE, hessian=FALSE,
analyticp=FALSE , est.initprobs=TRUE

);

 

with hmmDist_1 and hmmDist_2 being hmmCat distributions as specified in
the msm manual.

 

 

Thanks!


--
This message is for the named person(s) use only. It may contain confidential 
proprietary or legally privileged information. No confidentiality or privilege 
is waived or lost by any mistransmission. If you receive this message in error, 
please immediately delete it and all copies of it from your system, destroy any 
hard copies of it and notify the sender. You must not, directly or indirectly 
use, disclose, distribute, print, or copy any part of this message if you are 
not the intended recipient. Allston Trading LLC and its subsidiaries and 
affiliates each reserve the right to monitor all e-mail communications through 
its networks. Any views expressed in this message are those of the individual 
sender, except where the message states otherwise and the sender is authorized 
to state them to be the views of any such entity.
--










[[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] Missing link(s) in documentation object

2009-09-18 Thread Jon Olav Skoien

Hi,

I want to cross-reference from the documentation of pkg1 to pkg2, which 
is imported in the NAMESPACE of pkg1, and under Depends in DESCRIPTION 
of pkg1. According to Writing R extensions, this can be done by:

\code{\link{foo}}
when foo is an aliased function in the documentation of pkg2. This works 
as it should when I install the package, but when I run R CMD check 
pgk1, I get a warning:


* checking Rd cross-references ... WARNING
Missing link(s) in documentation object 'fooPkg1.Rd'
 foo

I have tried to change the link to
\code{\link[pkg2]{foo}}
\code{\link[pkg:pkg2]{foo}}
None of these works, the first gives a link that leads to an error page, 
and the second one gives a link that does not work at all. I assume this 
is as it should be; foo.Rd does not exist. However, R CMD check does not 
complain about any of these links...


Why does R CMD check warn me against links that work? I think pkg2 is 
not on the search path when looking for cross-references, but why? R CMD 
check continues to run after the warning without any complaints, and all 
tests rely on pkg2. I am quite sure there is something simple that I 
have overlooked, but cannot figure out what it is.


Best wishes,
Jon

Platform etc:
XP SP3, R 2.9-2, Rtools210 (the problem was also there before upgrading 
from R 2.9-1 and Rtools29 )


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


Re: [R] matching pairs regardless of order

2009-09-18 Thread Henrique Dallazuanna
Try this:

x[mapply(function(x, y)all(x %in% y), strsplit(x, ','), strsplit(trip, ','))]

On Fri, Sep 18, 2009 at 9:47 AM, Juliane Struve
juliane_str...@yahoo.co.uk wrote:
 Dear list,

 I am using match() to match pairs of locations, e.g. trip=loc1,loc2 from a 
 list of such pairs, e.g. list=(loc1,loc2, loc1,loc3, 
 loc2,loc3,loc2,loc1).

 In this example match() will match trip with the first element of list, 
 but not the 4th, because the order is reversed.

 How can I get a match with both ?

 Many thanks for any help,

 Juliane




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




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

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


[R] as.POSIXct(as.Date()) independent of timezone

2009-09-18 Thread Markus Loecher
Dear R users,
I am struggling a bit with the converting dates to full POSIX timestamps, in
particular, I would like to somehow force the timezone to be local, i.e. the
output of
as.POSIXct(as.Date(2008-07-01)) should always be equal to 2008-07-01
00:00:00, is that achievable ? I tried to set the origin and the timezone,
neither of which seems to make a difference.
On my Mac Book Pro (R version 2.9.1) which is set to Eastern US time zone, I
obtain the shifted result:
 as.POSIXct(as.Date(2008-07-01))
[1] 2008-06-30 20:00:00 EDT

And e.g.
 as.POSIXct( Sys.Date())
[1] 2009-09-17 20:00:00 EDT
 Sys.time()
[1] 2009-09-18 10:10:48 EDT

Any help would make life simpler for me.

Thanks,
Markus

[[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] Within-group correlation confidence intervals

2009-09-18 Thread jlwoodard

I'm trying to obtain within-group correlations on a subset of variables. I
first selected my variables using the following command:
mydata$x-mydata[c(iq,education,achievement)]

I'd like to look at correlations among those variables separately for men
and women. My gender variable in mydata is coded 1 (women) and 0 (men).

I have successfully used the following to get within group correlations and
p values:
by(x,gender,function(x) rcorr(as.matrix(x)))

However, I'm also interested in getting confidence intervals for the
correlations as well, using cor.test.  I tried the following without
success.

by(x,gender,function(x) cor.test(as.matrix(x)))

Even if I just use 2 variables (e.g., IQ and education), I get exactly the
same output for men and women with this command:

by(x,gender,function(x) cor.test(iq,education))

I'm still in the learning stages with the by and cor.test functions, so I
assume I'm using it incorrectly.  Is it possible to get the correlation
confidence intervals for each group using this approach?  

Many thanks in advance!

John
-- 
View this message in context: 
http://www.nabble.com/Within-group-correlation-confidence-intervals-tp25509629p25509629.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] Why S4 method is not visible from another package?

2009-09-18 Thread Gábor Csárdi
On Thu, Sep 17, 2009 at 5:59 PM, Martin Morgan mtmor...@fhcrc.org wrote:
 Gábor Csárdi wrote:
 Dear All,

 maybe this is something obvious, I seem to be incapable of
 understanding how S4 works.

 So, in package 'A' I defined a summary method for my class:

 setMethod(summary, signature(object=ListHyperGResult),
           function(object, pvalue=pvalueCutoff(object), categorySize=NULL) {
              whatever
           })

 ListHyperGResult has a subclass, GOListHyperGResult:

 setClass(GOListHyperGResult,
          representation=representation(conditional=logical),
          contains=ListHyperGResult,
          prototype=prototype(testname=GO))

 The summary method is exported in the NAMESPACE:

 exportMethods(summary)

 Package 'B' depends on package 'A', this is stated in the
 'DESCRIPTION' file. If I call 'summary' on a 'GOListHyperGResult' in

 Hi Gabor

 It is not S4 alone, but S4 + name spaces that are giving you problems.

 You probably want to Import: A rather than depends, and importFrom(A,
 summary).

 As it stands, inside the B name space, you find base::summary, whereas
 you've defined a method on summary that has been promoted to a generic
 in one of the packages that A imports (probably AnnotationDbi).

 This is a little bit of a guess; at some level it might seem more
 appropriate to Import: AnnotationDbi and importFrom(AnnotationDbi,
 summary) (or wherever the generic for summary that you are trying to use
 is created).

Martin, thanks, this solved the problem.

But isn't this a bit weird? Suppose I am the author of package 'B' and
want to use the classes defined in package 'A'. I don't care about
exact details of the implementation of these classes, I don't want to
know that they are based on something in package 'C' (AnnotationDbi,
really). But I still have to import specific functions from 'C'.

Moreover, suppose the author of 'C' changes 'summary', e.g. puts it
into another package, 'D' and makes 'C' importing it from 'D'. This
will break my package, 'B' as well.

Anyway, thanks a lot for your help, Best Regards,
Gabor

 Martin



-- 
Gabor Csardi gabor.csa...@unil.ch UNIL DGM

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


Re: [R] matching pairs regardless of order

2009-09-18 Thread jim holtman
Here is an example:

 x - c('loc1,loc2', 'loc2,loc3', 'loc2,loc1', 'loc3,loc1')
 x.s - strsplit(x, ',')
 # now sort them
 x.s - sapply(x.s, sort)
 # create new output
 unique(apply(x.s, 2, paste, collapse=','))
[1] loc1,loc2 loc2,loc3 loc1,loc3



On Fri, Sep 18, 2009 at 8:47 AM, Juliane Struve
juliane_str...@yahoo.co.uk wrote:
 Dear list,

 I am using match() to match pairs of locations, e.g. trip=loc1,loc2 from a 
 list of such pairs, e.g. list=(loc1,loc2, loc1,loc3, 
 loc2,loc3,loc2,loc1).

 In this example match() will match trip with the first element of list, 
 but not the 4th, because the order is reversed.

 How can I get a match with both ?

 Many thanks for any help,

 Juliane




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




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

What is the problem that you are trying to solve?

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


Re: [R] Updating R-code in own package

2009-09-18 Thread Duncan Murdoch

On 9/18/2009 9:05 AM, Steve Lianoglou wrote:

Hi,

On Sep 18, 2009, at 8:31 AM, Katrine Damgaard wrote:


Hey everybody!
We have created our own package, and need to do some corrections in  
the R-code of one of the function included in the package.
How can I do that. I have read a manual how to create an R package,  
but I can't find anything about updating R-code in the package.


I'm pretty sure the only correct thing to do is just fix the code in  
your package's source tree then reinstall the package wholesale to  
replace the bad code with the fixed code.


Yes, that's the simplest way to do it.  It also usually works for 
testing to just source the file containing the fix, to get a new copy in 
the global environment.  This can sometimes fail if the function refers 
to other functions in the package that are not visible in the global 
environment, due to NAMESPACE hiding.  It's possible to manipulate the 
environment of the sourced function (and it's even possible to place it 
into the right place so it just works), but those usually aren't worth 
the trouble.


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] Why S4 method is not visible from another package?

2009-09-18 Thread Martin Morgan
Gábor Csárdi wrote:
 On Thu, Sep 17, 2009 at 5:59 PM, Martin Morgan mtmor...@fhcrc.org wrote:
 Gábor Csárdi wrote:
 Dear All,

 maybe this is something obvious, I seem to be incapable of
 understanding how S4 works.

 So, in package 'A' I defined a summary method for my class:

 setMethod(summary, signature(object=ListHyperGResult),
   function(object, pvalue=pvalueCutoff(object), categorySize=NULL) {
  whatever
   })

 ListHyperGResult has a subclass, GOListHyperGResult:

 setClass(GOListHyperGResult,
  representation=representation(conditional=logical),
  contains=ListHyperGResult,
  prototype=prototype(testname=GO))

 The summary method is exported in the NAMESPACE:

 exportMethods(summary)

 Package 'B' depends on package 'A', this is stated in the
 'DESCRIPTION' file. If I call 'summary' on a 'GOListHyperGResult' in
 Hi Gabor

 It is not S4 alone, but S4 + name spaces that are giving you problems.

 You probably want to Import: A rather than depends, and importFrom(A,
 summary).

 As it stands, inside the B name space, you find base::summary, whereas
 you've defined a method on summary that has been promoted to a generic
 in one of the packages that A imports (probably AnnotationDbi).

 This is a little bit of a guess; at some level it might seem more
 appropriate to Import: AnnotationDbi and importFrom(AnnotationDbi,
 summary) (or wherever the generic for summary that you are trying to use
 is created).
 
 Martin, thanks, this solved the problem.
 
 But isn't this a bit weird? Suppose I am the author of package 'B' and
 want to use the classes defined in package 'A'. I don't care about
 exact details of the implementation of these classes, I don't want to
 know that they are based on something in package 'C' (AnnotationDbi,
 really). But I still have to import specific functions from 'C'.
 
 Moreover, suppose the author of 'C' changes 'summary', e.g. puts it
 into another package, 'D' and makes 'C' importing it from 'D'. This
 will break my package, 'B' as well.

Yes it seems a bit weird at first. But there really is a generic
C::summary that is different from base::summary, and could have, e.g., a
different signature, so you really are interested in C::summary and not
base::summary. Partly the (pleasant, in the long run) surprise here is
that R is separately managing both base::summary and C::summary, and
doing so in a way (via name spaces) that allows control over which will
be used. A second surprise, to the author of C, is that their package
has now become valuable enough to others that C can no longer be changed
at will.

Martin

 
 Anyway, thanks a lot for your help, Best Regards,
 Gabor
 
 Martin

 


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


Re: [R] Maximum No.of code in R

2009-09-18 Thread David Winsemius


On Sep 18, 2009, at 7:58 AM, premmad wrote:



Thanks for the reply and it is useful.What i want to know here is  
i'm going
to try and write an automated procedure using batch processing in R  
by the
way input of the next step is going to be this steps output .so one  
will not
able to predict the lines please also do answer in taking  
consideration the

above mentioned criteria in to consi


Without your code it is difficult to know exactly what you mean. But  
one question (other than when will you show the code?) needs to be  
asked. Have you noted the 7-level nesting limit on ifelse statements  
on the ifelse help page?


--

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] as.POSIXct(as.Date()) independent of timezone

2009-09-18 Thread Gabor Grothendieck
Try this:

 as.POSIXct(format(as.Date(2008-07-01)))
[1] 2008-07-01 EDT

See R News 4/1 for more.

On Fri, Sep 18, 2009 at 10:19 AM, Markus Loecher
markus.loec...@gmail.com wrote:
 Dear R users,
 I am struggling a bit with the converting dates to full POSIX timestamps, in
 particular, I would like to somehow force the timezone to be local, i.e. the
 output of
 as.POSIXct(as.Date(2008-07-01)) should always be equal to 2008-07-01
 00:00:00, is that achievable ? I tried to set the origin and the timezone,
 neither of which seems to make a difference.
 On my Mac Book Pro (R version 2.9.1) which is set to Eastern US time zone, I
 obtain the shifted result:
 as.POSIXct(as.Date(2008-07-01))
 [1] 2008-06-30 20:00:00 EDT

 And e.g.
 as.POSIXct( Sys.Date())
 [1] 2009-09-17 20:00:00 EDT
 Sys.time()
 [1] 2009-09-18 10:10:48 EDT

 Any help would make life simpler for me.

 Thanks,
 Markus

        [[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] define a new family (and a new link function) for gam in gam package

2009-09-18 Thread Simon Wood
 I am using gam in gam package (not in mgcv)  it is possible to force
 gam in mgcv to behave like gam in gam package?
-- not *exactly*, no. But what do you want to do? (i.e. what feature of `gam' 
do you need?)

-- 
 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] Error: length(f1) == length(f2) is not TRUE

2009-09-18 Thread A Singh
I just wanted to know whether the chances of getting help with this would 
be greater if I posted this on the mixed models list, even though I would 
be cross-posting.. ?


--On 18 September 2009 12:41 +0100 A Singh bz...@bristol.ac.uk wrote:



Dear R users,

I am trying to fit an lmer model with only random effects which is giving
me the following error:

Error : length(f1) == length(f2) is not TRUE
In addition: Warning messages:
1: In P1L55:family :
  numerical expression has 390 elements: only the first used
2: In P1L55:family :
  numerical expression has 390 elements: only the first used


I am trying to extract variance components for a phenotype 'peg.no',
using the variable 'family' and a marker column 'P1L55' (which is
categorical and has 2 levels- 0 and 1), as random effects. There are no
fixed effects.

The code I used is as follows:

vc-read.table(...)

vcdf-data.frame(vc)
colms-(vc)[4:13] ##these are the markers
lapply(colms,factor)

try(fit-lmer(peg.no~1 + (1|family/P1L55), na.action=na.include,
data=vcdf))


I thought that putting the data into a dataframe would help, along with
the na.exclude command, because there is a lot of missing data in patches
which I have replaced with NA's, but I  don't know how to fix this error
at all.

Its a bit urgent, and any help is hugely appreciated.

The data files are at:


http://www.4shared.com/file/131980362/460bdafe/Testvcomp10.html (excel)
http://www.4shared.com/file/131980512/dc7308b/Testvcomp10.html
(txt)


Cheers,
Aditi

--
A Singh
aditi.si...@bristol.ac.uk
School of Biological Sciences
University of Bristol







--
A Singh
aditi.si...@bristol.ac.uk
School of Biological Sciences
University of Bristol

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


Re: [R] matching pairs regardless of order

2009-09-18 Thread jim holtman
You are going to have to order your values for comparison.  Use
'strsplit' to split on the comma, then rejoin the data items based on
the sorting order.

On Fri, Sep 18, 2009 at 8:47 AM, Juliane Struve
juliane_str...@yahoo.co.uk wrote:
 Dear list,

 I am using match() to match pairs of locations, e.g. trip=loc1,loc2 from a 
 list of such pairs, e.g. list=(loc1,loc2, loc1,loc3, 
 loc2,loc3,loc2,loc1).

 In this example match() will match trip with the first element of list, 
 but not the 4th, because the order is reversed.

 How can I get a match with both ?

 Many thanks for any help,

 Juliane




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




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

What is the problem that you are trying to solve?

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


Re: [R] Error: length(f1) == length(f2) is not TRUE

2009-09-18 Thread William Dunlap
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of A Singh
 Sent: Friday, September 18, 2009 4:42 AM
 To: r-help@r-project.org
 Subject: [R] Error: length(f1) == length(f2) is not TRUE
 
 
 Dear R users,
 
 I am trying to fit an lmer model with only random effects 
 which is giving 
 me the following error:
 
 Error : length(f1) == length(f2) is not TRUE
 In addition: Warning messages:
 1: In P1L55:family :
   numerical expression has 390 elements: only the first used
 2: In P1L55:family :
   numerical expression has 390 elements: only the first used
 
 
 I am trying to extract variance components for a phenotype 
 'peg.no', using 
 the variable 'family' and a marker column 'P1L55' (which is 
 categorical and 
 has 2 levels- 0 and 1), as random effects. There are no fixed effects.
 
 The code I used is as follows:
 
 vc-read.table(...)
 
 vcdf-data.frame(vc)
 colms-(vc)[4:13] ##these are the markers
 lapply(colms,factor)

Note that you did not change columns 4:13 of vcdf to factors:
you changed copies of them to factors.  Do
   vcdf[4:13] - lapply(vcdf[4:13], factor)
and lmer should be happier.

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com  

 
 try(fit-lmer(peg.no~1 + (1|family/P1L55), 
 na.action=na.include, data=vcdf))
 
 
 I thought that putting the data into a dataframe would help, 
 along with the 
 na.exclude command, because there is a lot of missing data in 
 patches which 
 I have replaced with NA's, but I  don't know how to fix this 
 error at all.
 
 Its a bit urgent, and any help is hugely appreciated.
 
 The data files are at:
 
 
 http://www.4shared.com/file/131980362/460bdafe/Testvcomp10.ht
 ml (excel)
 http://www.4shared.com/file/131980512/dc7308b/Testvcomp10.html
 (txt)
 
 
 Cheers,
 Aditi
 
 --
 A Singh
 aditi.si...@bristol.ac.uk
 School of Biological Sciences
 University of Bristol
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Datetime conversion

2009-09-18 Thread jim holtman
use View to view the dataframe.

On Fri, Sep 18, 2009 at 8:17 AM, premmad mtechp...@gmail.com wrote:

 Thanks .I tried its working but when i tried to view the dataframe i got the
 following error
 Error in edit.data.frame(get(subx, envir = parent), title = subx, ...) :
  can only handle vector and factor elements


 --
 View this message in context: 
 http://www.nabble.com/Datetime-conversion-tp25503138p25507734.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem that you are trying to solve?

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


Re: [R] T-test to check equality, unable to interpret the results.

2009-09-18 Thread Greg Snow
It appears that you have a fundamental misunderstanding of what p-values do and 
do not say (though this misunderstanding is commom).  The following article 
addresses this issue and could help with a better understanding:

 Murdock, D, Tsai, Y, and Adcock, J (2008) _P-Values are Random
 Variables_. The American Statistician. (62) 242-245.

See also the Pvalue.norm.sim function in the TeachingDemos package for 
simulation examples demonstrating points from the article.

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 Robert Hall
 Sent: Wednesday, September 16, 2009 12:55 PM
 To: r-help
 Subject: [R] T-test to check equality, unable to interpret the results.
 
 Hi,
 I have the precision values of a system on two different data sets.
 The snippets of these results are as shown:
 
 sample1: (total 194 samples)
 0.600238
 0.800119
 0.600238
 0.200030
 0.600238
 ...
 ...
 
 sample2: (total 188 samples)
 0.8001
 0.2000
 0.8001
 0.
 0.8001
 0.4001
 ...
 ...
 
 I want to check if these results are statistically significant?
 Intuitively,
 the similarity in the two results mean the results are statistically
 significant.
 I am using the t-test t.test(sample1,sample2)to check for similarity
 amongst
 the two results.
 I get the following output:
 
 ---
 Welch Two Sample t-test
 
 data:  s1p5 and s2p5
 t = 0.9778, df = 374.904, p-value = 0.3288
 alternative hypothesis: true difference in means is not equal to 0
 95 percent confidence interval:
  -0.03170059  0.09441172
 sample estimates:
 mean of x mean of y
 0.5138298 0.4824742
 
 
 I believe the t-test checks for difference amongst the two sets, and p-
 value
  0.05 means both thesets are statistically different. Here while
 checking
 for dissimilarity the p-value is 0.3288, does it mean that higher the
 p-value (while t.test checks for dis-similarity) means more similar the
 results are (which is the case above as the means of the results are
 very
 close!)
 Please help me interpret the results..
 thanks in advance!
 
 --
 Rob Hall
 Masters Student
 ANU
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] Writing Reports from R in Microsoft Office Open XML format (follow-up)

2009-09-18 Thread Tobias Sing
Dear Duncan and other R users,

The department in which I work will soon make some decisions to
improve our reporting. Since I hope that our solution will support R
and Sweave-like functionality (otherwise it wouldn't be an
improvement), I hope it's ok to repeat my question back from June
if there are any news on an odfWeave-like package for weaving
Microsoft Word documents? (in the Office Open XML format).

Duncan, any news on the package? I am also asking on the list again
because there might be developments by others in parallel to what
Duncan has mentioned below?
(For example, maybe someone is thinking of adapting Max Kuhn's
excellent odfWeave package to support the XML format of Microsoft
Word?)

Kind regards,
  Tobias


On Tue, Jun 9, 2009 at 4:22 PM, Duncan Temple Lang
dun...@wald.ucdavis.edu wrote:
 Yes. We will release a version in the next few weeks
 when I have time to wrap it all up.
 There is also a Docbook-based version that uses
 R extensions to Docbook for authoring structured
 documents.

  D.

 Tobias Sing wrote:

 Dear all,

 has someone implemented functionality for writing reports from R in
 Office Open XML format (*), similar to what odfWeave does for the ODF
 format of OpenOffice? It would be great to have a kind of
 ooxmlWeave at least for those of us who are forced to work in an
 MS ecosystem.

 (*) Office Open XML is the default, XML-based, file format for MS
 Word: http://en.wikipedia.org/wiki/Office_Open_XML

 Kind regards,
  Tobias

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] T-test to check equality, unable to interpret the results.

2009-09-18 Thread Greg Snow
Rolf, 

I no longer claim to be young, the naïve part is still up for debate, 
but I find that restricting the null to only include = to be more confusing 
than to have it include the inequality.  To have the alternative be  and the 
null be = implies that we are working on the assumption that  is impossible, a 
stronger assumption than = of the null hypothesis.

I prefer to have all three possibilities explicitly stated between the 2 
hypotheses to cover all possibilities.  An analogy that can be used to explain 
why we do the computation using the = value instead of any or all of the  
values in the = null is:  If you wanted to prove that you are 
smarter/stronger/richer/etc. than a group of people, then all you would need to 
do is prove that you are smarter/stronger/richer/etc. than the 
smartest/strongest/richest/etc.est of the group, not every individual.  Using 
the equality value of the null does the same, if you can find evidence against 
that, then you have found evidence against all other possible values (within 
the null) as well.

-- 
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 Rolf Turner
 Sent: Wednesday, September 16, 2009 2:31 PM
 To: Bert Gunter
 Cc: 'r-help'
 Subject: Re: [R] T-test to check equality, unable to interpret the
 results.
 
 
 On 17/09/2009, at 8:06 AM, Bert Gunter wrote:
 
   snip
 
  Furthermore, the null can be other than equality -- e.g. that the
  mean  of
  the first population is less than the second.
 
   snip
 
 QUIBBLE:  Some elementary texts will indeed state the null hypothesis
 as
 ``mu_1 = mu_2'' when the alternative hypothesis is ``mu_1  mu_2''.
 
 However it seems to me more perspicuous to keep the null hypothesis as
 ``='' and allow only the alternative to change (i.e. to be one of ``!
 ='',
 ``'', or ``'').
 
 One calculates one's *test statistic* using the ``='' (which is the
 ``most extreme'' point of the null hypothesis, the point ``closest'' to
 the alternative, i.e. the point least likely to lead one to reject
 the null.
 
 Thus confusion amongst the young and naive is minimized if one
 insists that
 the null hypothesis is always ``=''.
 
   cheers,
 
   Rolf Turner
 
 ##
 Attention:\ This e-mail message is privileged and
 confid...{{dropped:9}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Writing Reports from R in Microsoft Office Open XML format (follow-up)

2009-09-18 Thread Duncan Temple Lang


Tobias Sing wrote:
 Dear Duncan and other R users,
 
 The department in which I work will soon make some decisions to
 improve our reporting. Since I hope that our solution will support R
 and Sweave-like functionality (otherwise it wouldn't be an
 improvement), I hope it's ok to repeat my question back from June
 if there are any news on an odfWeave-like package for weaving
 Microsoft Word documents? (in the Office Open XML format).
 
 Duncan, any news on the package? 

While I am starting a new quarter in a week,
I expect that I will have a version of it packaged up
before then.

 I am also asking on the list again
 because there might be developments by others in parallel to what
 Duncan has mentioned below?
 (For example, maybe someone is thinking of adapting Max Kuhn's
 excellent odfWeave package to support the XML format of Microsoft
 Word?)


 
 Kind regards,
   Tobias
 
 
 On Tue, Jun 9, 2009 at 4:22 PM, Duncan Temple Lang
 dun...@wald.ucdavis.edu wrote:
 Yes. We will release a version in the next few weeks
 when I have time to wrap it all up.
 There is also a Docbook-based version that uses
 R extensions to Docbook for authoring structured
 documents.

  D.

 Tobias Sing wrote:
 Dear all,

 has someone implemented functionality for writing reports from R in
 Office Open XML format (*), similar to what odfWeave does for the ODF
 format of OpenOffice? It would be great to have a kind of
 ooxmlWeave at least for those of us who are forced to work in an
 MS ecosystem.

 (*) Office Open XML is the default, XML-based, file format for MS
 Word: http://en.wikipedia.org/wiki/Office_Open_XML

 Kind regards,
  Tobias

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

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

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


Re: [R] Error: length(f1) == length(f2) is not TRUE

2009-09-18 Thread A Singh

Hi Bill,

Thanks, I did try out what you suggested but it doesn't seem to work.
I get the same error again.

There's obviously something here that I don't get. Need to figure it out.

Aditi

--On 18 September 2009 08:34 -0700 William Dunlap wdun...@tibco.com wrote:


From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of A Singh
Sent: Friday, September 18, 2009 4:42 AM
To: r-help@r-project.org
Subject: [R] Error: length(f1) == length(f2) is not TRUE


Dear R users,

I am trying to fit an lmer model with only random effects
which is giving
me the following error:

Error : length(f1) == length(f2) is not TRUE
In addition: Warning messages:
1: In P1L55:family :
  numerical expression has 390 elements: only the first used
2: In P1L55:family :
  numerical expression has 390 elements: only the first used


I am trying to extract variance components for a phenotype
'peg.no', using
the variable 'family' and a marker column 'P1L55' (which is
categorical and
has 2 levels- 0 and 1), as random effects. There are no fixed effects.

The code I used is as follows:

vc-read.table(...)

vcdf-data.frame(vc)
colms-(vc)[4:13] ##these are the markers
lapply(colms,factor)


Note that you did not change columns 4:13 of vcdf to factors:
you changed copies of them to factors.  Do
   vcdf[4:13] - lapply(vcdf[4:13], factor)
and lmer should be happier.

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com



try(fit-lmer(peg.no~1 + (1|family/P1L55),
na.action=na.include, data=vcdf))


I thought that putting the data into a dataframe would help,
along with the
na.exclude command, because there is a lot of missing data in
patches which
I have replaced with NA's, but I  don't know how to fix this
error at all.

Its a bit urgent, and any help is hugely appreciated.

The data files are at:


http://www.4shared.com/file/131980362/460bdafe/Testvcomp10.ht
ml (excel)
http://www.4shared.com/file/131980512/dc7308b/Testvcomp10.html
(txt)


Cheers,
Aditi

--
A Singh
aditi.si...@bristol.ac.uk
School of Biological Sciences
University of Bristol

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





--
A Singh
aditi.si...@bristol.ac.uk
School of Biological Sciences
University of Bristol

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


Re: [R] Suppressing script commands in R console when executing long program

2009-09-18 Thread Ishwor
Hi Duncan

 You can try putting this in your Rprofile
 options(keep.source=F)

 This will work in the R cmd but it will not work in the RGui


 The syntax is wrong there:  that should be options(keep.source=F).  But I
 don't think it addresses either question.

I was working from my memory here. Glad you pointed out Duncan :-)

 The normal way to execute a script from the console is source(filename.R),
 which by default doesn't echo.

options(keep.source=F)
options(echo=F)
in RProf. Then doing R CMD -f filename.r (in the shell without )
does it for me but perhaps Duncan's answer is more 'standard' R-ish
way of doing it (i.e., source('filename.R') )

-- 
Regards,
Ishwor Gurung

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


Re: [R] Missing link(s) in documentation object

2009-09-18 Thread Martin Morgan
Jon Olav Skoien wrote:
 Hi,
 
 I want to cross-reference from the documentation of pkg1 to pkg2, which
 is imported in the NAMESPACE of pkg1, and under Depends in DESCRIPTION
 of pkg1. According to Writing R extensions, this can be done by:
 \code{\link{foo}}
 when foo is an aliased function in the documentation of pkg2. This works
 as it should when I install the package, but when I run R CMD check
 pgk1, I get a warning:
 
 * checking Rd cross-references ... WARNING
 Missing link(s) in documentation object 'fooPkg1.Rd'
  foo
 
 I have tried to change the link to
 \code{\link[pkg2]{foo}}
 \code{\link[pkg:pkg2]{foo}}

Hi Jon --

I think the current requirement is \link[pkg2;foo_Rd_file_name]{foo}
where foo_Rd_file_name  is the name (without the .Rd extension) of the
FILE in which foo is documented. This would appear not to be foo.Rd,
because you say \link[pkg2]{foo} fails. This is as documented in Writing
R extensions.

 None of these works, the first gives a link that leads to an error page,
 and the second one gives a link that does not work at all. I assume this
 is as it should be; foo.Rd does not exist. However, R CMD check does not
 complain about any of these links...

Try building with R-devel, where the error messages are more detailed.

 Why does R CMD check warn me against links that work? I think pkg2 is

I think the idea is that the cross-package links as you originally
specified work for some help formats, but not for others (e.g., pdf).

Martin

 not on the search path when looking for cross-references, but why? R CMD
 check continues to run after the warning without any complaints, and all
 tests rely on pkg2. I am quite sure there is something simple that I
 have overlooked, but cannot figure out what it is.
 
 Best wishes,
 Jon
 
 Platform etc:
 XP SP3, R 2.9-2, Rtools210 (the problem was also there before upgrading
 from R 2.9-1 and Rtools29 )
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Writing Reports from R in Microsoft Office Open XML format (follow-up)

2009-09-18 Thread Greg Snow
The people who brought us rexcel are working on sword which is a sweave for ms 
word, the current version  is at:

http://rcom.univie.ac.at/download.html

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 Tobias Sing
 Sent: Friday, September 18, 2009 9:39 AM
 To: Duncan Temple Lang; r help; max.k...@pfizer.com
 Subject: [R] Writing Reports from R in Microsoft Office Open XML format
 (follow-up)
 
 Dear Duncan and other R users,
 
 The department in which I work will soon make some decisions to
 improve our reporting. Since I hope that our solution will support R
 and Sweave-like functionality (otherwise it wouldn't be an
 improvement), I hope it's ok to repeat my question back from June
 if there are any news on an odfWeave-like package for weaving
 Microsoft Word documents? (in the Office Open XML format).
 
 Duncan, any news on the package? I am also asking on the list again
 because there might be developments by others in parallel to what
 Duncan has mentioned below?
 (For example, maybe someone is thinking of adapting Max Kuhn's
 excellent odfWeave package to support the XML format of Microsoft
 Word?)
 
 Kind regards,
   Tobias
 
 
 On Tue, Jun 9, 2009 at 4:22 PM, Duncan Temple Lang
 dun...@wald.ucdavis.edu wrote:
  Yes. We will release a version in the next few weeks
  when I have time to wrap it all up.
  There is also a Docbook-based version that uses
  R extensions to Docbook for authoring structured
  documents.
 
   D.
 
  Tobias Sing wrote:
 
  Dear all,
 
  has someone implemented functionality for writing reports from R in
  Office Open XML format (*), similar to what odfWeave does for the
 ODF
  format of OpenOffice? It would be great to have a kind of
  ooxmlWeave at least for those of us who are forced to work in
 an
  MS ecosystem.
 
  (*) Office Open XML is the default, XML-based, file format for MS
  Word: http://en.wikipedia.org/wiki/Office_Open_XML
 
  Kind regards,
   Tobias
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Writing Reports from R in Microsoft Office Open XML format (follow-up)

2009-09-18 Thread Duncan Temple Lang

I believe that their approach is based on DCOM and the post was about Office 
Open XML.
We have had the ability to do this via DCOM for at least 6 years, but 
unfortunately
DCOM is limited to Windows.


Greg Snow wrote:
 The people who brought us rexcel are working on sword which is a sweave for 
 ms word, the current version  is at:
 
 http://rcom.univie.ac.at/download.html
 
 hope this helps,
 


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lapply - value changes as parameters to function?

2009-09-18 Thread Mark Knecht
Hi,
   I'm trying to get better at things like lapply but it still stumps
me. I have a function I've written, tested and debugged using
individual calls to the function, ala:

ResultList5  = DoAvgCalcs(IndexData, Lookback=5,
SampleSize=TestSamples , Iterations=TestIterations )
ResultList8  = DoAvgCalcs(IndexData, Lookback=8,
SampleSize=TestSamples , Iterations=TestIterations )
ResultList13 = DoAvgCalcs(IndexData, Lookback=13,
SampleSize=TestSamples , Iterations=TestIterations )
ResultList21 = DoAvgCalcs(IndexData, Lookback=21,
SampleSize=TestSamples , Iterations=TestIterations )

The function returns a list of numbers which I use for processing
later. I'd like to run this on a longer list (100's of values for
Lookback) so my thought was to try lapply but so far I cannot get the
darn thing right.

   Let's say I want to run the function on a string of values:

BarTestList = list(seq(5:20))

 So my thought was something like:

x = list(seq(5:20))
ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
SampleSize=TestSamples , Iterations=TestIterations )

which fails down lower complaining that what it's receiving for
Lookback isn't an integer:

 x = list(seq(5:20))
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,  
 SampleSize=TestSamples , Iterations=TestIterations )
Error in MyLag(df$Close, Lookback) :
  (list) object cannot be coerced to type 'integer'


   Can someone suggest how to do this correctly?

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] Simple as.Date question dealing with a timezone offset

2009-09-18 Thread esawdust

Took me a minute to grok the gsubfn solution, but that is sweet!  very nice.

thank you very much both for the suggestions,

Landon
-- 
View this message in context: 
http://www.nabble.com/Simple-as.Date-question-dealing-with-a-timezone-offset-tp25491955p25512218.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] Sum according observation

2009-09-18 Thread MarcioRibeiro

Hi listers,
I have a simple doubt...
I need to manipulate the data base as:

var1 var2
7  0.1
7  0.1
8  0.12
100.15
120.18
200.31

I would like to aggregate the equal cases as var1 making the sum of var2...
I would get...

var1 var2
7  0.2
8  0.12
100.15
120.18
200.31

Thanks in advance,
Marcio
-- 
View this message in context: 
http://www.nabble.com/Sum-according-observation-tp25510566p25510566.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] lapply - value changes as parameters to function?

2009-09-18 Thread Phil Spector

Mark -
   The l in lapply refers to that fact that it will *return*
a list, not that it wants a list for input.  You could input 
a list, but then each element of the list would be one of the 
values you wanted processed.  So I think you want


x = seq(5:20)
ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
   SampleSize=TestSamples , Iterations=TestIterations )

This will return a list whose elements are the result of calling
the DoAvgCalcs function with each value contained in x.  If they
were all the same length, and you wanted them simplified to a matrix,
you could use sapply (s for simplify) instead of lapply (l for list).

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


On Fri, 18 Sep 2009, Mark Knecht wrote:


Hi,
  I'm trying to get better at things like lapply but it still stumps
me. I have a function I've written, tested and debugged using
individual calls to the function, ala:

ResultList5  = DoAvgCalcs(IndexData, Lookback=5,
SampleSize=TestSamples , Iterations=TestIterations )
ResultList8  = DoAvgCalcs(IndexData, Lookback=8,
SampleSize=TestSamples , Iterations=TestIterations )
ResultList13 = DoAvgCalcs(IndexData, Lookback=13,
SampleSize=TestSamples , Iterations=TestIterations )
ResultList21 = DoAvgCalcs(IndexData, Lookback=21,
SampleSize=TestSamples , Iterations=TestIterations )

The function returns a list of numbers which I use for processing
later. I'd like to run this on a longer list (100's of values for
Lookback) so my thought was to try lapply but so far I cannot get the
darn thing right.

  Let's say I want to run the function on a string of values:

BarTestList = list(seq(5:20))

So my thought was something like:

x = list(seq(5:20))
ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
SampleSize=TestSamples , Iterations=TestIterations )

which fails down lower complaining that what it's receiving for
Lookback isn't an integer:


x = list(seq(5:20))
ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,  
SampleSize=TestSamples , Iterations=TestIterations )

Error in MyLag(df$Close, Lookback) :
 (list) object cannot be coerced to type 'integer'




  Can someone suggest how to do this correctly?

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.



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

2009-09-18 Thread vinay basavanal

Hi i can get sites that can r code on browser
-- 
View this message in context: 
http://www.nabble.com/R-on-browser-tp25508719p25508719.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] Writing Reports from R in Microsoft Office Open XML format (follow-up)

2009-09-18 Thread Greg Snow
I read the original post as asking if there is something like odfWeave that 
works for msword (I assumed windows, but I guess they could be asking about 
MSword on other platforms, it just sounds like a windows shop).

But yes, sword only works on windows (and is in beta version still) and uses a 
different interface from the standard sweave and odfWeave (process from inside 
word rather than process a file through R).



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


 -Original Message-
 From: Duncan Temple Lang [mailto:dun...@wald.ucdavis.edu]
 Sent: Friday, September 18, 2009 11:00 AM
 To: Greg Snow
 Cc: Tobias Sing; r help
 Subject: Re: [R] Writing Reports from R in Microsoft Office Open XML
 format (follow-up)
 
 
 I believe that their approach is based on DCOM and the post was about
 Office Open XML.
 We have had the ability to do this via DCOM for at least 6 years, but
 unfortunately
 DCOM is limited to Windows.
 
 
 Greg Snow wrote:
  The people who brought us rexcel are working on sword which is a
 sweave for ms word, the current version  is at:
 
  http://rcom.univie.ac.at/download.html
 
  hope this helps,
 
 

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


Re: [R] Sum according observation

2009-09-18 Thread Henrique Dallazuanna
Try this:

with(DF, tapply(var2, var1, sum))

On Fri, Sep 18, 2009 at 12:18 PM, MarcioRibeiro mes...@pop.com.br wrote:

 Hi listers,
 I have a simple doubt...
 I need to manipulate the data base as:

 var1 var2
 7      0.1
 7      0.1
 8      0.12
 10    0.15
 12    0.18
 20    0.31

 I would like to aggregate the equal cases as var1 making the sum of var2...
 I would get...

 var1 var2
 7      0.2
 8      0.12
 10    0.15
 12    0.18
 20    0.31

 Thanks in advance,
 Marcio
 --
 View this message in context: 
 http://www.nabble.com/Sum-according-observation-tp25510566p25510566.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

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


Re: [R] generating unordered combinations

2009-09-18 Thread Bryan Keller
The combn solution offered by Bill is great.  It struck me that what you are 
doing, in fact, is generating the null distribution of the two-sample Wilcoxon 
test where the first group has size m and the second group has size n.  In 
general, the length of the array has size choose(n+m-1,m) which gets very big 
very fast.  For example,

 choose(20+20-1,20)
[1] 68923264410

If, on the off chance that you are interested in *summing* the unordered 
combinations across columns, there is a very slick way to do this that takes a 
tiny fraction of the time and memory that generating huge arrays entails.  If 
not, obviously, you already have your solution.

Just in case, here is the code to generate the distribution of sums.  It is 
based on an algorithm due to Harding (1984).

f - function(m,n) {

umax - (m*n+1)

ifelse (umax%%2==0, umaxp - (umax/2)-1, umaxp - (umax-1)/2)
#umaxp is analagous to “M” from Harding (1984)

p - min((m+n),umaxp)
q - min(m,umaxp)

dis - c(1,numeric(umaxp))

if ((n+1)umaxp) {

for (i in 1:q) {#steps for denominator of generating 
function
for (j in i:umaxp) {
dis[j+1] - (dis[j+1] + dis[(j-i)+1])
}
}

} else {

for (i in (n+1):(p)) {  #steps for numerator of generating function
for (j in (umaxp):i) {
dis[j+1] - (dis[j+1] - dis[(j-i)+1])
}
}

for (i in 1:q) {#steps for denominator of generating 
function
for (j in i:umaxp) {
dis[j+1] - (dis[j+1] + dis[(j-i)+1])
}
}

}

ldis - length(dis)
ifelse(umax%%2==0,dis - c(dis,dis[ldis:1]),dis - c(dis,dis[(ldis-1):1]))
dispr - dis/choose((n+m),n)
ws - sum(1:m):sum((n+1):(n+m))
lws - length(ws)
mat3 - cbind(ws,dis,dispr,numeric(lws),numeric(lws))
mat3[,4] - cumsum(mat3[,3])
mat3[,5] - cumsum(mat3[,3][lws:1])[lws:1]
colnames(mat3) - c(W,Freq,Probability,Sum up,Sum down)

print(mat3)
}

 system.time(f(20,20))
   user  system elapsed 
   0.110.000.11 

Bryan




That's brilliant - thanks.

On 17 Sep 2009, at 23:36, William Dunlap wrote:

 There is a 1-1 correspondance between your n-sets
 consisting of m possible element types (0 through m-1
 in your example) and the number of n-subsets of a (n+m-1)-set.
 E.g., your example had m=3 and n=3 and subtracting
 1:3 from each column of combn(3+3-1,3) gives your result:

 t(combn(3+3-1, 3)-(1:3))
  [,1] [,2] [,3]
 [1,]000
 [2,]001
 [3,]002
 [4,]011
 [5,]012
 [6,]022
 [7,]111
 [8,]112
 [9,]122
 [10,]222

 Bill Dunlap
 TIBCO Software Inc - Spotfire Division
 wdunlap tibco.com

 -Original Message-
 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On Behalf Of Dan Halligan
 Sent: Thursday, September 17, 2009 1:31 PM
 To: r-help@r-project.org
 Subject: [R] generating unordered combinations

 Hi,

 I am trying to generate all unordered combinations of a set of
 numbers / characters, and I can only find a (very) clumsy way of  
 doing
 this using expand.grid.  For example, all unordered combinations of
 the numbers 0, 1, 2 are:
 0, 0, 0
 0, 0, 1
 0, 0, 2
 0, 1, 1
 0, 1, 2
 0, 2, 2
 1, 1, 1
 1, 1, 2
 1, 2, 2
 2, 2, 2

 (I have not included, for example, 1, 0, 0, since it is equivalent to
 0, 0, 1).

 I have found a way to generate this data.frame using expand.grid as
 follows:

 g - expand.grid(c(0,1,2), c(0,1,2), c(0,1,2))
 for(i in 1:nrow(g)) {
  g[i,] - sort(as.character(g[i,]))
 }
 o - order(g$Var1, g$Var2, g$Var3)
 unique(g[o,]).

 This is obviously quite clumsy and hard to generalise to a greater
 number of characters, so I'm keen to find any other solutions.  Can
 anyone suggest a better (more general, quicker) method?

 Cheers

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



-
Bryan Keller, Doctoral Student/Project Assistant
Educational Psychology - Quantitative Methods
The University of Wisconsin - Madison

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


Re: [R] Datetime conversion

2009-09-18 Thread Philipp Pagel
On Fri, Sep 18, 2009 at 04:32:27AM -0700, premmad wrote:
 
 Sorry for confusing you all with my inexperienced posting .
 I tried as u said if you have 9 rows in the data it is working fine but
 please try out the same example as you have suggested earlier with morethan
 9 rows.
 
 I tried it as following
 datetime -c(
 + 01OCT1987:00:00:00.000,
 +  12APR2004:00:00:00.000,
 +   01DEC1987:00:00:00.000,
 +  01OCT1975:00:00:00.000,
 +   01AUG1979:00:00:00.000,
 +  26JUN2003:00:00:00.000,
 +  01JAN1900:00:00:00.000,
 +  13MAY1998:00:00:00.000,
 +  30SEP1998:00:00:00.000,
 +  30SEP1998:00:00:00.000,
 +  30SEP1998:00:00:00.000,
 +  30SEP1998:00:00:00.000) 
 dt - as.data.frame(datetime) 
 
 dt$date-strptime(as.character(dt$datetime),%d%b%Y) 
 
 and got the following error :
 
 Error in `$-.data.frame`(`*tmp*`, date, value = list(sec = c(0, 0,  : 
   replacement has 9 rows, data has 12.

Oops - sorry you are right. There is a Problem with inserting the
object. Try this instead:

dt$date - as.Date(dt$datetime, %d%b%Y)

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/

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


Re: [R] lapply - value changes as parameters to function?

2009-09-18 Thread Mark Knecht
Phil,
   Thanks for the reply. Your suggestion is actually the one I started
with (assuming I'm understanding you) but I didn't seem to even get
down into my function, or the error message is from other place within
my function that I haven't discovered yet:

 x = seq(5:20)
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,  
 SampleSize=TestSamples , Iterations=TestIterations )
Error in rep(NA, k) : invalid 'times' argument


   I should write some fake code that gives you all the depth so we
could jsut run it. If no on eelse sees the answer then I'll be back
later with more code that completely runs.

Thanks,
Mark


On Fri, Sep 18, 2009 at 10:16 AM, Phil Spector
spec...@stat.berkeley.edu wrote:
 Mark -
   The l in lapply refers to that fact that it will *return*
 a list, not that it wants a list for input.  You could input a list, but
 then each element of the list would be one of the values you wanted
 processed.  So I think you want

 x = seq(5:20)
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
                       SampleSize=TestSamples , Iterations=TestIterations )

 This will return a list whose elements are the result of calling
 the DoAvgCalcs function with each value contained in x.  If they
 were all the same length, and you wanted them simplified to a matrix,
 you could use sapply (s for simplify) instead of lapply (l for list).

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


 On Fri, 18 Sep 2009, Mark Knecht wrote:

 Hi,
  I'm trying to get better at things like lapply but it still stumps
 me. I have a function I've written, tested and debugged using
 individual calls to the function, ala:

 ResultList5  = DoAvgCalcs(IndexData, Lookback=5,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList8  = DoAvgCalcs(IndexData, Lookback=8,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList13 = DoAvgCalcs(IndexData, Lookback=13,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList21 = DoAvgCalcs(IndexData, Lookback=21,
 SampleSize=TestSamples , Iterations=TestIterations )

 The function returns a list of numbers which I use for processing
 later. I'd like to run this on a longer list (100's of values for
 Lookback) so my thought was to try lapply but so far I cannot get the
 darn thing right.

  Let's say I want to run the function on a string of values:

 BarTestList = list(seq(5:20))

 So my thought was something like:

 x = list(seq(5:20))
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
 SampleSize=TestSamples , Iterations=TestIterations )

 which fails down lower complaining that what it's receiving for
 Lookback isn't an integer:

 x = list(seq(5:20))
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
  SampleSize=TestSamples , Iterations=TestIterations )

 Error in MyLag(df$Close, Lookback) :
  (list) object cannot be coerced to type 'integer'


  Can someone suggest how to do this correctly?

 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.



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


Re: [R] merging data frames with matrix objects when missing cases

2009-09-18 Thread johannes rara
This has something to do with your data.frame structure

see

 str(df1)
'data.frame':   3 obs. of  2 variables:
 $ a : int  1 2 3
 $ X1: 'AsIs' int [1:3, 1:2] 1 2 3 4 5 6
 str(df2)
'data.frame':   2 obs. of  2 variables:
 $ a : int  1 2
 $ X2: 'AsIs' int [1:2, 1:2] 11 12 13 14

This seems to work

 df1-data.frame(a=1:3, b = 1:3, c = 4:6)
 str(df1)
'data.frame':   3 obs. of  3 variables:
 $ a: int  1 2 3
 $ b: int  1 2 3
 $ c: int  4 5 6
 df2-data.frame(a=1:2, d = 11:12, e = 13:14)
 str(df2)
'data.frame':   2 obs. of  3 variables:
 $ a: int  1 2
 $ d: int  11 12
 $ e: int  13 14
 merge(df1,df2)
  a b c  d  e
1 1 1 4 11 13
2 2 2 5 12 14
 merge(df1, df2, all=T)
  a b c  d  e
1 1 1 4 11 13
2 2 2 5 12 14
3 3 3 6 NA NA


2009/9/18 Kari Ruohonen kari.ruoho...@utu.fi:
 Hi,
 I have faced a problem with the merge() function when trying to merge
 two data frames that have a common index but the second one does not
 have cases for all indexes in the first one. With usual variables R
 fills in the missing cases with NA if all=T is requested. But if the
 variable is a matrix R seems to insert NA only to the first column of
 the matrix and fill in the rest of the columns by recycling the values.
 Here is a toy example:

 df1-data.frame(a=1:3,X1=I(matrix(1:6,ncol=2)))
 df2-data.frame(a=1:2,X2=I(matrix(11:14,ncol=2)))
 merge(df1,df2)
  a X1.1 X1.2 X2.1 X2.2
 1 1    1    4   11   13
 2 2    2    5   12   14
 # no all=T, missing cases are dropped

 merge(df1,df2,all=T)
  a X1.1 X1.2 X2.1 X2.2
 1 1    1    4   11   13
 2 2    2    5   12   14
 3 3    3    6   NA   13
 # X2.1 set to NA correctly but X2.2 set to 13 by recycling.

 Can I somehow get the behaviour that the third row of the second matrix
 X2 in the above example would be filled with NA for all columns? None of
 the merge() options does not seem to provide a solution.

 regards, Kari

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] wilcox.test p-value = 0

2009-09-18 Thread Keo Ormsby

Hello Thomas and Bryan,
Thanks for the correction, sorry Murat I was mistaken. Actually your 
answers solved me a problem I was having using multiple fisher.test() on 
nucleic acid sequences, where we come up with hundreds of thousands of p 
values, a lot of which are 0's. Since we have to correct for multiple 
tests, even very, very small p's might end up not being significant, i 
had assumed the 0's were tied p values, but now I know I can use the 
numerator and the denominator to rank the 0's, even if I don't have the 
exact p value.

Best,
Keo.

Marc Schwartz escribió:
Once one gets past the issue of the p value being extremely small, 
irrespective of the test being used, the OP has asked the question of 
how to report it.


Most communities will have standards for how to report p values, 
covering things like how many significant digits and a minimum p value 
threshold to report.


For example, in medicine, it is common to report 'small' p values as 
'p  0.001' or 'p  0.0001'.


Thus, below those numbers, the precision is largely irrelevant and one 
need not report the actual p value.


I just wanted to be sure that we don't lose sight of the forest for 
the trees...  :-)


The OP should consult a relevant guidance document or an experienced 
author in the domain of interest.


HTH,

Marc Schwartz


On Sep 16, 2009, at 9:54 AM, Bryan Keller wrote:

That's right, if the test is exact it is not possible to get a 
p-value of zero.  wilcox.test does not provide an exact p-value in 
the presence of ties so if there are any ties in your data you are 
getting a normal approximation.  Incidentally, if there are any ties 
in your data set I would strongly recommend computing the *exact* 
p-value because using the normal approximation on tied data sets will 
either inflate type I error rate or reduce power depending on how the 
ties are distributed.  Depending on the pattern of ties this can 
result in gross under or over estimation of the p-value.


I guess this is all by way of saying that you should always compute 
the exact p-value if possible.


The package exactRankTests uses the algorithm by Mehta Patel and 
Tsiatis (1984).  If your sample sizes are larger, there is a freely 
available .exe by Cheung and Klotz (1995) that will do exact p-values 
for sample sizes larger than 100 in each group!


You can find it at http://pages.cs.wisc.edu/~klotz/

Bryan


Hi Murat,
I am not an expert in either statistics nor R, but I can imagine 
that since the
default is exact=TRUE, It numerically computes the probability, and 
it may
indeed be 0. if you use wilcox.test(x, y, exact=FALSE) it will give 
you a

normal aproximation, which will most likely be different from zero.


No, the exact p-value can't be zero for a discrete distribution. The 
smallest possible value in this case would, I think, be 
1/choose(length(x)+length(y),length(x)), or perhaps twice that.


More generally, the approach used by format.pvalue() is to display 
very small p-values as 2e-16, where 2e-16 is machine epsilon.  I 
wouldn't want to claim optimality for this choice, but it seems a 
reasonable way to represent very small.


-thomas



Hope this helps.
Keo.

Murat Tasan escribi?:

hi, folks,

how have you gone about reporting a p-value from a test when the
returned value from a test (in this case a rank-sum test) is
numerically equal to 0 according to the machine?

the next lowest value greater than zero that is distinct from zero on
the machine is likely algorithm-dependent (the algorithm of the test
itself), but without knowing the explicit steps of the algorithm
implementation, it is difficult to provide any non-zero value.  i
initially thought to look at .mach...@double.xmin, but i'm not
comfortable with reporting p  .mach...@double.xmin, since without
knowing the specifics of the implementation, this may not be true!

to be clear, if i have data x, and i run the following line, the
returned value is TRUE.

wilcox.test(x)$p.value == 0

thanks for any help on this!


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] wilcox.test p-value = 0

2009-09-18 Thread Keo Ormsby

Hello,
Thanks for the correction, sorry Murat I was mistaken. Actually your 
answers solved me a problem I was having using multiple fisher.test() on 
nucleic acid sequences, where we come up with hundreds of thousands of p 
values, a lot of which are 0's. Since we have to correct for multiple 
tests, even very, very small p's might end up not being significant, i 
had assumed the 0's were tied p values, but now I know I can use the 
numerator and the denominator to rank the 0's, even if I don't have the 
exact p value.

Best,
Keo.

Marc Schwartz escribió:
Once one gets past the issue of the p value being extremely small, 
irrespective of the test being used, the OP has asked the question of 
how to report it.


Most communities will have standards for how to report p values, 
covering things like how many significant digits and a minimum p value 
threshold to report.


For example, in medicine, it is common to report 'small' p values as 
'p  0.001' or 'p  0.0001'.


Thus, below those numbers, the precision is largely irrelevant and one 
need not report the actual p value.


I just wanted to be sure that we don't lose sight of the forest for 
the trees...  :-)


The OP should consult a relevant guidance document or an experienced 
author in the domain of interest.


HTH,

Marc Schwartz


On Sep 16, 2009, at 9:54 AM, Bryan Keller wrote:

That's right, if the test is exact it is not possible to get a 
p-value of zero.  wilcox.test does not provide an exact p-value in 
the presence of ties so if there are any ties in your data you are 
getting a normal approximation.  Incidentally, if there are any ties 
in your data set I would strongly recommend computing the *exact* 
p-value because using the normal approximation on tied data sets will 
either inflate type I error rate or reduce power depending on how the 
ties are distributed.  Depending on the pattern of ties this can 
result in gross under or over estimation of the p-value.


I guess this is all by way of saying that you should always compute 
the exact p-value if possible.


The package exactRankTests uses the algorithm by Mehta Patel and 
Tsiatis (1984).  If your sample sizes are larger, there is a freely 
available .exe by Cheung and Klotz (1995) that will do exact p-values 
for sample sizes larger than 100 in each group!


You can find it at http://pages.cs.wisc.edu/~klotz/

Bryan


Hi Murat,
I am not an expert in either statistics nor R, but I can imagine 
that since the
default is exact=TRUE, It numerically computes the probability, and 
it may
indeed be 0. if you use wilcox.test(x, y, exact=FALSE) it will give 
you a

normal aproximation, which will most likely be different from zero.


No, the exact p-value can't be zero for a discrete distribution. The 
smallest possible value in this case would, I think, be 
1/choose(length(x)+length(y),length(x)), or perhaps twice that.


More generally, the approach used by format.pvalue() is to display 
very small p-values as 2e-16, where 2e-16 is machine epsilon.  I 
wouldn't want to claim optimality for this choice, but it seems a 
reasonable way to represent very small.


-thomas



Hope this helps.
Keo.

Murat Tasan escribi?:

hi, folks,

how have you gone about reporting a p-value from a test when the
returned value from a test (in this case a rank-sum test) is
numerically equal to 0 according to the machine?

the next lowest value greater than zero that is distinct from zero on
the machine is likely algorithm-dependent (the algorithm of the test
itself), but without knowing the explicit steps of the algorithm
implementation, it is difficult to provide any non-zero value.  i
initially thought to look at .mach...@double.xmin, but i'm not
comfortable with reporting p  .mach...@double.xmin, since without
knowing the specifics of the implementation, this may not be true!

to be clear, if i have data x, and i run the following line, the
returned value is TRUE.

wilcox.test(x)$p.value == 0

thanks for any help on this!


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lapply - value changes as parameters to function?

2009-09-18 Thread jim holtman
Change the order of the parameters in your function so that Lookback
is the first one.  The first parameter of the lapply is what is passed
to the function as its first parameter.  Now just have

ResultList - lapply(x, DoAvgCalcs, IndexData=IndexData,
SampleSize=TestSamples, Iteration=TestIterations)


On Fri, Sep 18, 2009 at 1:32 PM, Mark Knecht markkne...@gmail.com wrote:
 Phil,
   Thanks for the reply. Your suggestion is actually the one I started
 with (assuming I'm understanding you) but I didn't seem to even get
 down into my function, or the error message is from other place within
 my function that I haven't discovered yet:

 x = seq(5:20)
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,  
 SampleSize=TestSamples , Iterations=TestIterations )
 Error in rep(NA, k) : invalid 'times' argument


   I should write some fake code that gives you all the depth so we
 could jsut run it. If no on eelse sees the answer then I'll be back
 later with more code that completely runs.

 Thanks,
 Mark


 On Fri, Sep 18, 2009 at 10:16 AM, Phil Spector
 spec...@stat.berkeley.edu wrote:
 Mark -
   The l in lapply refers to that fact that it will *return*
 a list, not that it wants a list for input.  You could input a list, but
 then each element of the list would be one of the values you wanted
 processed.  So I think you want

 x = seq(5:20)
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
                       SampleSize=TestSamples , Iterations=TestIterations )

 This will return a list whose elements are the result of calling
 the DoAvgCalcs function with each value contained in x.  If they
 were all the same length, and you wanted them simplified to a matrix,
 you could use sapply (s for simplify) instead of lapply (l for list).

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


 On Fri, 18 Sep 2009, Mark Knecht wrote:

 Hi,
  I'm trying to get better at things like lapply but it still stumps
 me. I have a function I've written, tested and debugged using
 individual calls to the function, ala:

 ResultList5  = DoAvgCalcs(IndexData, Lookback=5,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList8  = DoAvgCalcs(IndexData, Lookback=8,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList13 = DoAvgCalcs(IndexData, Lookback=13,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList21 = DoAvgCalcs(IndexData, Lookback=21,
 SampleSize=TestSamples , Iterations=TestIterations )

 The function returns a list of numbers which I use for processing
 later. I'd like to run this on a longer list (100's of values for
 Lookback) so my thought was to try lapply but so far I cannot get the
 darn thing right.

  Let's say I want to run the function on a string of values:

 BarTestList = list(seq(5:20))

 So my thought was something like:

 x = list(seq(5:20))
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
 SampleSize=TestSamples , Iterations=TestIterations )

 which fails down lower complaining that what it's receiving for
 Lookback isn't an integer:

 x = list(seq(5:20))
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
  SampleSize=TestSamples , Iterations=TestIterations )

 Error in MyLag(df$Close, Lookback) :
  (list) object cannot be coerced to type 'integer'


  Can someone suggest how to do this correctly?

 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.



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




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

What is the problem that you are trying to solve?

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


Re: [R] R on browser

2009-09-18 Thread Steve Lianoglou

Hi,

On Sep 18, 2009, at 9:32 AM, vinay basavanal wrote:


Hi i can get sites that can r code on browser


Oh don't mean to sound rude, but can you try to rephrase your question?

I think a lot of people are having a hard time understanding what  
you're really asking, but we'd be happy to help.


Thanks,
-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] Error: length(f1) == length(f2) is not TRUE (fwd)

2009-09-18 Thread A Singh



-- Forwarded Message --
Date: 18 September 2009 19:24 +0100
From: A Singh bz...@bristol.ac.uk
To: William Dunlap wdun...@tibco.com
Subject: RE: [R] Error: length(f1) == length(f2) is not TRUE

Yup, they are all factors- and its still doesn't work.
Getting to the stage where I can use 'summary()' is the problem- the error
stalls the process before a summary can be output.

I tried the same code, but using 'family' and P1L55 as independent random
factors, and that works.

(I actually tried this with a new marker P1L74)


try(fit-lmer(peg.no~1 + (1|family) + (1|P1L74), na.action=na.exclude))
summary(fit)


Linear mixed model fit by REML
Formula: peg.no ~ 1 + (1 | family) + (1 | P1L74)
 AIC  BIC logLik deviance REMLdev
2981 2997  -1487 29762973
Random effects:
Groups   NameVariance Std.Dev.
family   (Intercept) 87.86380 9.37357
P1L74(Intercept)  0.48815 0.69868
Residual 92.11681 9.59775
Number of obs: 390, groups: family, 57; P1L74, 2

Fixed effects:
   Estimate Std. Error t value
(Intercept)96.40   1.49   64.71

..but the nested random effect ..(1|family/P1L74).. is where the error
occurs. And its the same error.

Error : length(f1) == length(f2) is not TRUE
In addition: Warning messages:
1: In P1L55:family :
 numerical expression has 390 elements: only the first used
2: In P1L55:family :
 numerical expression has 390 elements: only the first used

My design is a very unbalanced one. Do you think that can be the problem?




--On 18 September 2009 09:11 -0700 William Dunlap wdun...@tibco.com wrote:


Look at the output of summary(vcdf) and make sure
that 'family' and 'P1L55' columns are factors.  Perhaps
columns 4:13 did not include them.

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com


-Original Message-
From: A Singh [mailto:aditi.si...@bristol.ac.uk]
Sent: Friday, September 18, 2009 9:03 AM
To: William Dunlap; r-help@r-project.org
Subject: RE: [R] Error: length(f1) == length(f2) is not TRUE

Hi Bill,

Thanks, I did try out what you suggested but it doesn't seem to work.
I get the same error again.

There's obviously something here that I don't get. Need to
figure it out.

Aditi

--On 18 September 2009 08:34 -0700 William Dunlap
wdun...@tibco.com wrote:

 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On Behalf Of A Singh
 Sent: Friday, September 18, 2009 4:42 AM
 To: r-help@r-project.org
 Subject: [R] Error: length(f1) == length(f2) is not TRUE


 Dear R users,

 I am trying to fit an lmer model with only random effects
 which is giving
 me the following error:

 Error : length(f1) == length(f2) is not TRUE
 In addition: Warning messages:
 1: In P1L55:family :
   numerical expression has 390 elements: only the first used
 2: In P1L55:family :
   numerical expression has 390 elements: only the first used


 I am trying to extract variance components for a phenotype
 'peg.no', using
 the variable 'family' and a marker column 'P1L55' (which is
 categorical and
 has 2 levels- 0 and 1), as random effects. There are no
fixed effects.

 The code I used is as follows:

 vc-read.table(...)

 vcdf-data.frame(vc)
 colms-(vc)[4:13] ##these are the markers
 lapply(colms,factor)

 Note that you did not change columns 4:13 of vcdf to factors:
 you changed copies of them to factors.  Do
vcdf[4:13] - lapply(vcdf[4:13], factor)
 and lmer should be happier.

 Bill Dunlap
 TIBCO Software Inc - Spotfire Division
 wdunlap tibco.com


 try(fit-lmer(peg.no~1 + (1|family/P1L55),
 na.action=na.include, data=vcdf))


 I thought that putting the data into a dataframe would help,
 along with the
 na.exclude command, because there is a lot of missing data in
 patches which
 I have replaced with NA's, but I  don't know how to fix this
 error at all.

 Its a bit urgent, and any help is hugely appreciated.

 The data files are at:


 http://www.4shared.com/file/131980362/460bdafe/Testvcomp10.ht
 ml (excel)
 http://www.4shared.com/file/131980512/dc7308b/Testvcomp10.html
 (txt)


 Cheers,
 Aditi

 --
 A Singh
 aditi.si...@bristol.ac.uk
 School of Biological Sciences
 University of Bristol

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




--
A Singh
aditi.si...@bristol.ac.uk
School of Biological Sciences
University of Bristol









--
A Singh
aditi.si...@bristol.ac.uk
School of Biological Sciences
University of Bristol




-- End Forwarded Message --



--
A Singh
aditi.si...@bristol.ac.uk
School of Biological Sciences
University of Bristol

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

[R] Predicting the Present with R at Google

2009-09-18 Thread Roger Koenker

I thought some R-help readers might enjoy seeing the paper by Hal Varian on
predicting the present
using R and Google Trends that is linked via the following blog comment:

http://googleresearch.blogspot.com/2009/04/predicting-present-with-google-trends.html

Apologies in advance if this has already been mentioned,  I didn't see it in
the achives.


-- 
View this message in context: 
http://www.nabble.com/Predicting-the-Present-with-R-at-Google-tp25513381p25513381.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] missing values at a combination of two factors

2009-09-18 Thread Timothy Clough
Dear All,

I have two factors: GROUP and PATIENT, where PATIENT is nested within  
GROUP.

 levels(example$GROUP)
[1] 0 1 2 3 4

  levels(example$PATIENT)
[1] 1 2 3

There are three observations at each combination of these factors.   
However, there are no observations for PATIENT = 3 and GROUP = 4.

  table(example$GROUP, example$PATIENT)

 1 2 3
   0 3 3 3
   1 3 3 3
   2 3 3 3
   3 3 3 3
   4 3 3 0

  When I run an ANOVA on these factors

  fit - lm(ABUNDANCE ~ GROUP + GROUP/PATIENT, data = example)

I receive an NA in the parameter estimate corresponding to missing  
combination.

  summary(fit)

Call:
lm(formula = ABUNDANCE ~ GROUP + GROUP/PATIENT, data = example)

Residuals:
 Min  1Q  Median  3Q Max
-1.2985 -0.4284  0.1998  0.3663  0.8585

Coefficients: (1 not defined because of singularities)
 Estimate Std. Error t value Pr(|t|)
(Intercept) 13.183200.37333  35.312   2e-16 ***
GROUP1   0.618610.52797   1.1720.251
GROUP2   0.189930.52797   0.3600.722
GROUP3   0.271630.52797   0.5140.611
GROUP4  -0.281730.52797  -0.5340.598
GROUP0:PATIENT2  0.126430.52797   0.2390.812
GROUP1:PATIENT2 -0.726170.52797  -1.3750.180
GROUP2:PATIENT2 -0.263600.52797  -0.4990.621
GROUP3:PATIENT2  0.042930.52797   0.0810.936
GROUP4:PATIENT2  0.598120.52797   1.1330.267
GROUP0:PATIENT3  0.281470.52797   0.5330.598
GROUP1:PATIENT3 -0.364520.52797  -0.6900.496
GROUP2:PATIENT3 -0.347370.52797  -0.6580.516
GROUP3:PATIENT3 -0.551190.52797  -1.0440.305
GROUP4:PATIENT3   NA NA  NA   NA
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.6466 on 28 degrees of freedom
Multiple R-squared: 0.1867, Adjusted R-squared: -0.191
F-statistic: 0.4943 on 13 and 28 DF,  p-value: 0.9093


I need to perform a contrast on various levels of GROUP/PATIENT, and  
the NA prevents me from doing so.  Is there a way to manipulate the  
levels of the factors so that an NA is not present in the parameter  
estimates?

Thanks,
Tim



[[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] lapply - value changes as parameters to function?

2009-09-18 Thread Mark Knecht
Thanks Jim. That did the trick.

I had wondered in passing about that as all the examples in the
?lapply page were pretty simple and each time it was the first
argument. However I didn't read that this was a requirement so I
didn't go there. Is this really stated and I just cannot see it or
possibly should some extra verbiage be added. (Heck - it's Open Source
- guess I could do it myself and submit it to who ever manages that
stuff!)

Again, thanks!

Cheers,
Mark

On Fri, Sep 18, 2009 at 11:06 AM, jim holtman jholt...@gmail.com wrote:
 Change the order of the parameters in your function so that Lookback
 is the first one.  The first parameter of the lapply is what is passed
 to the function as its first parameter.  Now just have

 ResultList - lapply(x, DoAvgCalcs, IndexData=IndexData,
 SampleSize=TestSamples, Iteration=TestIterations)


 On Fri, Sep 18, 2009 at 1:32 PM, Mark Knecht markkne...@gmail.com wrote:
 Phil,
   Thanks for the reply. Your suggestion is actually the one I started
 with (assuming I'm understanding you) but I didn't seem to even get
 down into my function, or the error message is from other place within
 my function that I haven't discovered yet:

 x = seq(5:20)
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,  
 SampleSize=TestSamples , Iterations=TestIterations )
 Error in rep(NA, k) : invalid 'times' argument


   I should write some fake code that gives you all the depth so we
 could jsut run it. If no on eelse sees the answer then I'll be back
 later with more code that completely runs.

 Thanks,
 Mark


 On Fri, Sep 18, 2009 at 10:16 AM, Phil Spector
 spec...@stat.berkeley.edu wrote:
 Mark -
   The l in lapply refers to that fact that it will *return*
 a list, not that it wants a list for input.  You could input a list, but
 then each element of the list would be one of the values you wanted
 processed.  So I think you want

 x = seq(5:20)
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
                       SampleSize=TestSamples , Iterations=TestIterations )

 This will return a list whose elements are the result of calling
 the DoAvgCalcs function with each value contained in x.  If they
 were all the same length, and you wanted them simplified to a matrix,
 you could use sapply (s for simplify) instead of lapply (l for list).

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


 On Fri, 18 Sep 2009, Mark Knecht wrote:

 Hi,
  I'm trying to get better at things like lapply but it still stumps
 me. I have a function I've written, tested and debugged using
 individual calls to the function, ala:

 ResultList5  = DoAvgCalcs(IndexData, Lookback=5,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList8  = DoAvgCalcs(IndexData, Lookback=8,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList13 = DoAvgCalcs(IndexData, Lookback=13,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList21 = DoAvgCalcs(IndexData, Lookback=21,
 SampleSize=TestSamples , Iterations=TestIterations )

 The function returns a list of numbers which I use for processing
 later. I'd like to run this on a longer list (100's of values for
 Lookback) so my thought was to try lapply but so far I cannot get the
 darn thing right.

  Let's say I want to run the function on a string of values:

 BarTestList = list(seq(5:20))

 So my thought was something like:

 x = list(seq(5:20))
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
 SampleSize=TestSamples , Iterations=TestIterations )

 which fails down lower complaining that what it's receiving for
 Lookback isn't an integer:

 x = list(seq(5:20))
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
  SampleSize=TestSamples , Iterations=TestIterations )

 Error in MyLag(df$Close, Lookback) :
  (list) object cannot be coerced to type 'integer'


  Can someone suggest how to do this correctly?

 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.



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




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

 What is the problem that you are trying to solve?


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

[R] Ruuid missing Gtk glib.dylib

2009-09-18 Thread Christopher Bare
Hi,

I get an error indicating a missing library from the package 'Ruuid'.
I suppose this means I should install RGtk. I just thought I'd
document the error. Maybe a dependency entry is missing?

R 2.9.0
OS X 10.5.8

Thanks,

- chris


 biocLite('Ruuid')
Using R version 2.9.0, biocinstall version 2.4.12.
Installing Bioconductor version 2.4 packages:
[1] Ruuid
Please wait...

Warning: unable to access index for repository
http://brainarray.mbni.med.umich.edu/bioc/bin/macosx/universal/contrib/2.9
trying URL 
'http://bioconductor.org/packages/2.4/bioc/bin/macosx/universal/contrib/2.9/Ruuid_1.22.0.tgz'
Content type 'application/x-gzip' length 66343 bytes (64 Kb)
opened URL
==
downloaded 64 Kb


The downloaded packages are in

/var/folders/n3/n3Xa3tJRED4hkXZd5y3QWk+++TI/-Tmp-//RtmpkHt9YC/downloaded_packages
 library(Ruuid)
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared library
'/Library/Frameworks/R.framework/Resources/library/Ruuid/libs/i386/Ruuid.so':
  
dlopen(/Library/Frameworks/R.framework/Resources/library/Ruuid/libs/i386/Ruuid.so,
6): Library not loaded:
/Library/Frameworks/GTK+.framework/Versions/2.14.X11/Resources/lib/libglib-2.0.0.dylib
  Referenced from:
/Library/Frameworks/R.framework/Resources/library/Ruuid/libs/i386/Ruuid.so
  Reason: image not found
Error: package/namespace load failed for 'Ruuid'
Error in args(getuuid) : no function to return from, jumping to top level


 J. Christopher Bare
 Institute for Systems Biology

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


Re: [R] Ruuid missing Gtk glib.dylib

2009-09-18 Thread David Winsemius
We are in the same boat (which I think is caused in my case by never  
having been successful in installing a 64 bit version of Gtk+ on my  
Mac, if such a beast exists). My errors are a tad bit different than  
yours. Are you attempting this from an R64 version? I get no error  
when I install Ruuid from the BioConductor binary repository and then  
execute:


library(Ruuid)  # no errors

(This question should have gone to either the Bioconductor mailing  
list or the Mac-sig.list)


--
David.

 sessionInfo()
R version 2.9.2 (2009-08-24)
i386-apple-darwin9.8.0

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

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

other attached packages:
[1] Ruuid_1.22.0

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


This was what happend when I ran the following code in the R64 GUI  
console:

 source(http://bioconductor.org/biocLite.R;)
 biocLite(Ruuid)
Using R version 2.9.2, biocinstall version 2.4.12.
Installing Bioconductor version 2.4 packages:
[1] Ruuid
Please wait...

Warning in install.packages(pkgs = pkgs, repos = repos, dependencies =  
dependencies,  :
  argument 'lib' is missing: using '/Users/davidwinsemius/Library/R/ 
2.9/library'

Warning: unable to access index for repository 
http://brainarray.mbni.med.umich.edu/bioc/bin/macosx/leopard/contrib/2.9
trying URL 
'http://bioconductor.org/packages/2.4/bioc/bin/macosx/leopard/contrib/2.9/Ruuid_1.22.0.tgz'
Content type 'application/x-gzip' length 70572 bytes (68 Kb)
opened URL
==
downloaded 68 Kb


The downloaded packages are in
	/var/folders/xS/xSUsVXTIHEiP7OLJg2OXmU+++TI/-Tmp-//RtmpoaE55s/ 
downloaded_packages

 library(Ruuid)
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared library '/Users/davidwinsemius/Library/R/2.9/ 
library/Ruuid/libs/x86_64/Ruuid.so':
  dlopen(/Users/davidwinsemius/Library/R/2.9/library/Ruuid/libs/ 
x86_64/Ruuid.so, 6): Library not loaded: /Library/Frameworks/GTK 
+.framework/Versions/2.14.X11/Resources/lib/libglib-2.0.0.dylib
  Referenced from: /Users/davidwinsemius/Library/R/2.9/library/Ruuid/ 
libs/x86_64/Ruuid.so

  Reason: no suitable image found.  Did find:
	/Library/Frameworks/GTK+.framework/Versions/2.14.X11/Resources/lib/ 
libglib-2.0.0.dylib: no matching architecture in universal wrapper

Error: package/namespace load failed for 'Ruuid'



On Sep 18, 2009, at 2:58 PM, Christopher Bare wrote:


Hi,

I get an error indicating a missing library from the package 'Ruuid'.
I suppose this means I should install RGtk. I just thought I'd
document the error. Maybe a dependency entry is missing?

R 2.9.0
OS X 10.5.8

Thanks,

- chris



biocLite('Ruuid')

Using R version 2.9.0, biocinstall version 2.4.12.
Installing Bioconductor version 2.4 packages:
[1] Ruuid
Please wait...

Warning: unable to access index for repository
http://brainarray.mbni.med.umich.edu/bioc/bin/macosx/universal/contrib/2.9
trying URL 
'http://bioconductor.org/packages/2.4/bioc/bin/macosx/universal/contrib/2.9/Ruuid_1.22.0.tgz'
Content type 'application/x-gzip' length 66343 bytes (64 Kb)
opened URL
==
downloaded 64 Kb


The downloaded packages are in
	/var/folders/n3/n3Xa3tJRED4hkXZd5y3QWk+++TI/-Tmp-//RtmpkHt9YC/ 
downloaded_packages

library(Ruuid)

Error in dyn.load(file, DLLpath = DLLpath, ...) :
 unable to load shared library
'/Library/Frameworks/R.framework/Resources/library/Ruuid/libs/i386/ 
Ruuid.so':
 dlopen(/Library/Frameworks/R.framework/Resources/library/Ruuid/libs/ 
i386/Ruuid.so,

6): Library not loaded:
/Library/Frameworks/GTK+.framework/Versions/2.14.X11/Resources/lib/ 
libglib-2.0.0.dylib

 Referenced from:
/Library/Frameworks/R.framework/Resources/library/Ruuid/libs/i386/ 
Ruuid.so

 Reason: image not found
Error: package/namespace load failed for 'Ruuid'
Error in args(getuuid) : no function to return from, jumping to top  
level



J. Christopher Bare
Institute for Systems Biology

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Error: length(f1) == length(f2) is not TRUE

2009-09-18 Thread A Singh


Bill,

It worked!!!


lmer(data=vcdf, peg.no~1 + (1|family/P1L55))


Linear mixed model fit by REML
Formula: peg.no ~ 1 + (1 | family/P1L55)
  Data: vcdf
 AIC  BIC logLik deviance REMLdev
2981 2997  -1487 29762973
Random effects:
Groups   NameVariance   Std.Dev.
P1L55:family (Intercept) 4.6659e-11 6.8308e-06
family   (Intercept) 8.7571e+01 9.3579e+00
Residual 9.2269e+01 9.6057e+00
Number of obs: 390, groups: P1L55:family, 82; family, 57

Fixed effects:
   Estimate Std. Error t value
(Intercept)   96.577  1.37670.2

It seems as if all along it was the na.action=na.exclude that was working 
against me, because it probably threw out NAs in a way that made column 
lengths incompatible.


It seemed to work with some other models I had tried, but here it was 
clearly a problem.

Your example was brilliant for breaking it down.

Thanks a huge bunch, and cheers!

Aditi


--On 18 September 2009 11:40 -0700 William Dunlap wdun...@tibco.com wrote:


From: A Singh [mailto:aditi.si...@bristol.ac.uk]
Sent: Friday, September 18, 2009 11:24 AM
To: William Dunlap
Subject: RE: [R] Error: length(f1) == length(f2) is not TRUE

Yup, they are all factors- and its still doesn't work.
Getting to the stage where I can use 'summary()' is the
problem- the error
stalls the process before a summary can be output.


I meant to get a summary of the input, vcdf, not of
the output of lmer.  Make sure that vcdf$family and
all the vcdf$P* things are factors.

Here is a short example that gives an error like yours.
Without seeing your data I can't say for sure yours
is similar.  You need to at least show the output of
summary(vcdf).


library(lme4)
d - data.frame(y=log(1:36), expand.grid(g2=1:2,g3=11:13,g6=101:106))
sapply(d,class)

yg2g3g6
numeric integer integer integer

lmer(data=d, y~1 + (1|g2))

Linear mixed model fit by REML
Formula: y ~ 1 + (1 | g2)
   Data: d
 AIC BIC   logLikdeviance
 98.784754747615 103.53531156298 -46.392377373808 90.735690977203
 REMLdev
 92.784754747615
Random effects:
 Groups   NameVariance  Std.Dev.
 g2   (Intercept) 0.000 0.000
 Residual 0.748809753022119 0.865337941513094
Number of obs: 36, groups: g2, 2

Fixed effects:
Estimate   Std. Error t value
(Intercept) 2.65888040394842 0.14422299035915 18.435898446754

lmer(data=d, y~1 + (1|g2/g6))

Error: length(f1) == length(f2) is not TRUE
In addition: Warning messages:
1: In g6:g2 : numerical expression has 36 elements: only the first used
2: In g6:g2 : numerical expression has 36 elements: only the first used

Now change the d$g* columns to be factors with

d[2:4] - lapply(d[2:4],factor)
# and check with summary(d)
summary(d) # or sapply(d,class)

   y g2  g3   g6
 Min.   :0.000   1:18   11:12   101:6
 1st Qu.:2.27624496408   2:18   12:12   102:6
 Median :2.91740536853  13:12   103:6
 Mean   :2.65888040395  104:6
 3rd Qu.:3.30492877705  105:6
 Max.   :3.58351893846  106:6

lmer(data=d, y~1 + (1|g2))

Linear mixed model fit by REML
Formula: y ~ 1 + (1 | g2)
   Data: d
 AIC BIC   logLikdeviance
 98.784754747615 103.53531156298 -46.392377373808 90.735690977203
 REMLdev
 92.784754747615
Random effects:
 Groups   NameVariance  Std.Dev.
 g2   (Intercept) 0.000 0.000
 Residual 0.748809753022119 0.865337941513094
Number of obs: 36, groups: g2, 2

Fixed effects:
Estimate   Std. Error t value
(Intercept) 2.65888040394842 0.14422299035915 18.435898446754

lmer(data=d, y~1 + (1|g2/g6))

Linear mixed model fit by REML
Formula: y ~ 1 + (1 | g2/g6)
   Data: d
 AIC BIC   logLikdeviance
 63.097147876589 69.431223630414 -27.548573938295 54.113964539198
 REMLdev
 55.097147876589
Random effects:
 Groups   NameVariance   Std.Dev.
 g6:g2(Intercept) 0.6928532833231706 0.832378089165717
 g2   (Intercept) 0. 0.000
 Residual 0.0955486486847417 0.309109444509128
Number of obs: 36, groups: g6:g2, 12; g2, 2

Fixed effects:
   Estimate  Std. Error t value
(Intercept) 2.6588804039484 0.2457461012621 10.819623954533



I tried the same code, but using 'family' and P1L55 as
independent random
factors, and that works.

(I actually tried this with a new marker P1L74)

 try(fit-lmer(peg.no~1 + (1|family) + (1|P1L74),
na.action=na.exclude))
 summary(fit)

Linear mixed model fit by REML
Formula: peg.no ~ 1 + (1 | family) + (1 | P1L74)
  AIC  BIC logLik deviance REMLdev
 2981 2997  -1487 29762973
Random effects:
 Groups   NameVariance Std.Dev.
 family   (Intercept) 87.86380 9.37357
 P1L74

Re: [R] Writing Reports from R in Microsoft Office Open XML format (follow-up)

2009-09-18 Thread Tobias Sing
Thanks Duncan and Greg for the replies so far.

Duncan, many thanks for your continued work on this; please let us (or
at least me) know when your package will be available.

Greg, the DCOM option sounds great, but we run R on a Linux cluster,
and therefore it would be good to be able to write the reports in MS
Word XML format from there without relying on Windows-specific
functionality.

Kind regards,
  Tobias

On Fri, Sep 18, 2009 at 7:23 PM, Greg Snow greg.s...@imail.org wrote:
 I read the original post as asking if there is something like odfWeave that 
 works for msword (I assumed windows, but I guess they could be asking about 
 MSword on other platforms, it just sounds like a windows shop).

 But yes, sword only works on windows (and is in beta version still) and uses 
 a different interface from the standard sweave and odfWeave (process from 
 inside word rather than process a file through R).



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


 -Original Message-
 From: Duncan Temple Lang [mailto:dun...@wald.ucdavis.edu]
 Sent: Friday, September 18, 2009 11:00 AM
 To: Greg Snow
 Cc: Tobias Sing; r help
 Subject: Re: [R] Writing Reports from R in Microsoft Office Open XML
 format (follow-up)


 I believe that their approach is based on DCOM and the post was about
 Office Open XML.
 We have had the ability to do this via DCOM for at least 6 years, but
 unfortunately
 DCOM is limited to Windows.


 Greg Snow wrote:
  The people who brought us rexcel are working on sword which is a
 sweave for ms word, the current version  is at:
 
  http://rcom.univie.ac.at/download.html
 
  hope this helps,
 
 


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


Re: [R] Ruuid missing Gtk glib.dylib

2009-09-18 Thread Martin Morgan
Hi Chris --

Christopher Bare wrote:
 Hi,
 
 I get an error indicating a missing library from the package 'Ruuid'.
 I suppose this means I should install RGtk. I just thought I'd
 document the error. Maybe a dependency entry is missing?
 
 R 2.9.0
 OS X 10.5.8
 
 Thanks,
 
 - chris
 
 
 biocLite('Ruuid')
 Using R version 2.9.0, biocinstall version 2.4.12.
 Installing Bioconductor version 2.4 packages:
 [1] Ruuid
 Please wait...
 
 Warning: unable to access index for repository
 http://brainarray.mbni.med.umich.edu/bioc/bin/macosx/universal/contrib/2.9
 trying URL 
 'http://bioconductor.org/packages/2.4/bioc/bin/macosx/universal/contrib/2.9/Ruuid_1.22.0.tgz'
 Content type 'application/x-gzip' length 66343 bytes (64 Kb)
 opened URL
 ==
 downloaded 64 Kb
 
 
 The downloaded packages are in
   
 /var/folders/n3/n3Xa3tJRED4hkXZd5y3QWk+++TI/-Tmp-//RtmpkHt9YC/downloaded_packages
 library(Ruuid)
 Error in dyn.load(file, DLLpath = DLLpath, ...) :
   unable to load shared library
 '/Library/Frameworks/R.framework/Resources/library/Ruuid/libs/i386/Ruuid.so':
   
 dlopen(/Library/Frameworks/R.framework/Resources/library/Ruuid/libs/i386/Ruuid.so,
 6): Library not loaded:
 /Library/Frameworks/GTK+.framework/Versions/2.14.X11/Resources/lib/libglib-2.0.0.dylib
   Referenced from:
 /Library/Frameworks/R.framework/Resources/library/Ruuid/libs/i386/Ruuid.so
   Reason: image not found
 Error: package/namespace load failed for 'Ruuid'
 Error in args(getuuid) : no function to return from, jumping to top level

You're installing a binary (pre-built) package, and your system has to
play by the same rules as the system that was used to build the package.
So you'll need to follow the directions here

  http://r.research.att.com/#other

or, as a more robust long-term solution, configure your system to build
packages from source (also on the page linked above) and use
biocLite(Ruuid, type=source)

Martin

 
 
  J. Christopher Bare
  Institute for Systems Biology
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Emacs and ESS help

2009-09-18 Thread Data Analytics Corp.

Hi,

I decided to try emacs and ess with R, but to no avail.  How are these 
things suppose to work with R - or work, period?  I downloaded the 
latest windows versions of each and installed them as the documentation 
says.  But then the documentation for ess says to add (require 
'ess-site) to /.emacs and restart emacs.  Where is /.emacs  I opened 
the ess-site.el file and it also says to add the line to /.emacs.  Can 
anyone help me on this?  And once I get this problem fixed, how do I 
interact with R or any other package (S+, Stata, SAS, etc.)?  I'm 
running Windows Vista on a Thinkpad.


Any and all help is deeply appreciated.

Thanks,

Walt



--


Walter R. Paczkowski, Ph.D.
Data Analytics Corp.
44 Hamilton Lane
Plainsboro, NJ 08536

(V) 609-936-8999
(F) 609-936-3733
dataanalyt...@earthlink.net
www.dataanalyticscorp.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] Writing Reports from R in Microsoft Office Open XML format (follow-up)

2009-09-18 Thread David Winsemius

That website says:
Our components and applications for seamless integration allow to  
embed statistics software from the R project and data analysis and  
computation services from Scilab into applications on Microsoft  
Windows, MacOS X and Linux.


Does anyone know if the claim to be supporting versions for Mac and  
Linux has substance? None of the applications that I attempted  
accessing from that download site appear to be *NIX compatible. They  
are all .exe files or require statconnDCOM, which I do not believe  
runs outside of WinXP.


--
David

On Sep 18, 2009, at 12:51 PM, Greg Snow wrote:

The people who brought us rexcel are working on sword which is a  
sweave for ms word, the current version  is at:


http://rcom.univie.ac.at/download.html

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 Tobias Sing
Sent: Friday, September 18, 2009 9:39 AM
To: Duncan Temple Lang; r help; max.k...@pfizer.com
Subject: [R] Writing Reports from R in Microsoft Office Open XML  
format

(follow-up)

Dear Duncan and other R users,

The department in which I work will soon make some decisions to
improve our reporting. Since I hope that our solution will support R
and Sweave-like functionality (otherwise it wouldn't be an
improvement), I hope it's ok to repeat my question back from June
if there are any news on an odfWeave-like package for weaving
Microsoft Word documents? (in the Office Open XML format).

Duncan, any news on the package? I am also asking on the list again
because there might be developments by others in parallel to what
Duncan has mentioned below?
(For example, maybe someone is thinking of adapting Max Kuhn's
excellent odfWeave package to support the XML format of Microsoft
Word?)

Kind regards,
 Tobias


On Tue, Jun 9, 2009 at 4:22 PM, Duncan Temple Lang
dun...@wald.ucdavis.edu wrote:

Yes. We will release a version in the next few weeks
when I have time to wrap it all up.
There is also a Docbook-based version that uses
R extensions to Docbook for authoring structured
documents.

 D.

Tobias Sing wrote:


Dear all,

has someone implemented functionality for writing reports from R in
Office Open XML format (*), similar to what odfWeave does for the

ODF

format of OpenOffice? It would be great to have a kind of
ooxmlWeave at least for those of us who are forced to work in

an

MS ecosystem.

(*) Office Open XML is the default, XML-based, file format for MS
Word: http://en.wikipedia.org/wiki/Office_Open_XML

Kind regards,
 Tobias

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





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


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


David Winsemius, MD
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] lapply - value changes as parameters to function?

2009-09-18 Thread Bert Gunter
 It **IS** stated explicitly, though perhaps not so obviously,  already in
the help file,  In the Note section at the end it says:

... This means that the recorded call is always of the form FUN(X[[0L]],
...), with 0L replaced by the current integer index. ...

So you need to read more carefully ...

Bert Gunter
Genentech Nonclinical Statistics

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Mark Knecht
Sent: Friday, September 18, 2009 11:55 AM
To: jim holtman
Cc: r-help; Phil Spector
Subject: Re: [R] lapply - value changes as parameters to function?

Thanks Jim. That did the trick.

I had wondered in passing about that as all the examples in the
?lapply page were pretty simple and each time it was the first
argument. However I didn't read that this was a requirement so I
didn't go there. Is this really stated and I just cannot see it or
possibly should some extra verbiage be added. (Heck - it's Open Source
- guess I could do it myself and submit it to who ever manages that
stuff!)

Again, thanks!

Cheers,
Mark

On Fri, Sep 18, 2009 at 11:06 AM, jim holtman jholt...@gmail.com wrote:
 Change the order of the parameters in your function so that Lookback
 is the first one.  The first parameter of the lapply is what is passed
 to the function as its first parameter.  Now just have

 ResultList - lapply(x, DoAvgCalcs, IndexData=IndexData,
 SampleSize=TestSamples, Iteration=TestIterations)


 On Fri, Sep 18, 2009 at 1:32 PM, Mark Knecht markkne...@gmail.com wrote:
 Phil,
   Thanks for the reply. Your suggestion is actually the one I started
 with (assuming I'm understanding you) but I didn't seem to even get
 down into my function, or the error message is from other place within
 my function that I haven't discovered yet:

 x = seq(5:20)
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
 SampleSize=TestSamples , Iterations=TestIterations )
 Error in rep(NA, k) : invalid 'times' argument


   I should write some fake code that gives you all the depth so we
 could jsut run it. If no on eelse sees the answer then I'll be back
 later with more code that completely runs.

 Thanks,
 Mark


 On Fri, Sep 18, 2009 at 10:16 AM, Phil Spector
 spec...@stat.berkeley.edu wrote:
 Mark -
   The l in lapply refers to that fact that it will *return*
 a list, not that it wants a list for input.  You could input a list, but
 then each element of the list would be one of the values you wanted
 processed.  So I think you want

 x = seq(5:20)
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
                       SampleSize=TestSamples , Iterations=TestIterations
)

 This will return a list whose elements are the result of calling
 the DoAvgCalcs function with each value contained in x.  If they
 were all the same length, and you wanted them simplified to a matrix,
 you could use sapply (s for simplify) instead of lapply (l for list).

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


 On Fri, 18 Sep 2009, Mark Knecht wrote:

 Hi,
  I'm trying to get better at things like lapply but it still stumps
 me. I have a function I've written, tested and debugged using
 individual calls to the function, ala:

 ResultList5  = DoAvgCalcs(IndexData, Lookback=5,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList8  = DoAvgCalcs(IndexData, Lookback=8,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList13 = DoAvgCalcs(IndexData, Lookback=13,
 SampleSize=TestSamples , Iterations=TestIterations )
 ResultList21 = DoAvgCalcs(IndexData, Lookback=21,
 SampleSize=TestSamples , Iterations=TestIterations )

 The function returns a list of numbers which I use for processing
 later. I'd like to run this on a longer list (100's of values for
 Lookback) so my thought was to try lapply but so far I cannot get the
 darn thing right.

  Let's say I want to run the function on a string of values:

 BarTestList = list(seq(5:20))

 So my thought was something like:

 x = list(seq(5:20))
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
 SampleSize=TestSamples , Iterations=TestIterations )

 which fails down lower complaining that what it's receiving for
 Lookback isn't an integer:

 x = list(seq(5:20))
 ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x,
  SampleSize=TestSamples , Iterations=TestIterations )

 Error in MyLag(df$Close, Lookback) :
  (list) object cannot be coerced to type 'integer'


  Can someone suggest how to do this correctly?

 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 

[R] Unable to install lme4

2009-09-18 Thread Zege, Andrew
I am unable to install package lme4, after several attempts to do so using 
various repository URLs.
Just to make sure everything works fine with proxy, connection, etc, I 
installed ggplot2 and it worked fine.

I am using command

install.packages(lme4, lib=/myRlibs),

optionally using contrib argument with different URLs.

Error message the I get is

Warning message;
In install.packages(lme4, lib=/myRlibs)
 package 'lme4' is not available


Some other details, not sure how relevant are:

getOption(repos) returns http://lib.stat.cmu.edu/R/CRAN;

I tried setting contrib to various other URL, such as  
http://cran.mtu.edu/src/contrib; or Berkeley URL, but with no success.
Actually, when I did available.packages() on this repos, I didn't see lme4 in 
the package indices.
My machine has x86_64bit RedHat Linux.

Would appreciate any tips or directions,

Thanks
Andre

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