Re: [R] bigglm() results different from glm()+Another question

2009-07-09 Thread utkarshsinghal
That was definitely helpful.

if you change your seq to: seq(chunksize, 1-chunksize, chunksize) 
then you won't get the error messages

Even previously, I was not getting any error messages or warnings at 
all, i.e., update removes the extra NA rows silently, for example:

set.seed(1)
xx = data.frame(x1=runif(1,0,10), x2=runif(1,0,10), 
x3=runif(1,0,10))
xx$y = 3 + xx$x1 + 2*xx$x2 + 3*xx$x3 + rnorm(1)
fit1 = biglm(y~x1+x2+x3, data=xx[1:7000,])
fit2 = update(fit1, moredata=xx[7001:1,])
fit3 = update(fit2, moredata=xx[7001:14000,])

Here fit2 and fit3 are exactly same.
Also if the number of rows is not a multiple of chunksize then your 
sequence will not accommodate the last small chunk of data .

Regards
Utkarsh


Greg Snow wrote:

 OK, it appears that the problem is the df.resid component of the biglm 
 object.  Everything else is being updated by the update function 
 except the df.resid piece, so it is based solely on the initial fit 
 and the chunksize used there.  The df.resid piece is then used in the 
 computation of the AIC and hence the differences that you see.  There 
 could also be a difference in the p-values and confidence intervals, 
 but at those high of numbers, the differences are smaller than can be 
 seen at the level of rounding done.

  

 This appears to be a bug/overlooked piece to me, Thomas is cc'd on 
 this so he should be able to fix this.

  

 A work around in the meantime is to do something like:

  fit$df.resid - 1-4

  

 Then compute the AIC.

  

 Also as an aside, if you change your seq to: seq(chunksize, 
 1-chunksize, chunksize) then you won't get the error messages.

  

 Hope this helps,

  

 -- 

 Gregory (Greg) L. Snow Ph.D.

 Statistical Data Center

 Intermountain Healthcare

 greg.s...@imail.org

 801.408.8111

  

 *From:* utkarshsinghal [mailto:utkarsh.sing...@global-analytics.com]
 *Sent:* Wednesday, July 08, 2009 2:24 AM
 *To:* Greg Snow
 *Cc:* Thomas Lumley; r help
 *Subject:* Re: [R] bigglm() results different from glm()+Another question

  

 Hi Greg,

 Many thanks for your precious time. Here is a workable code:

 set.seed(1)
 xx = data.frame(x1=runif(1,0,10), x2=runif(1,0,10), 
 x3=runif(1,0,10))
 xx$y = 3 + xx$x1 + 2*xx$x2 + 3*xx$x3 + rnorm(1)

 chunksize = 500
 fit = biglm(y~x1+x2+x3, data=xx[1:chunksize,])
 for(i in seq(chunksize,1,chunksize)) fit=update(fit, 
 moredata=xx[(i+1):(i+chunksize),])
 AIC(fit)
 [1] 28956.91

 And the AIC for other chunksizes:
 chunksizeAIC
 500  28956.91
 100027956.91
 200025956.91
 250024956.91
 500019956.91
 19956.91

 Also I noted that the estimated coefficients are not dependent on 
 chunksize and AIC is exactly a linear function of chunksize. So I 
 guess it is some problem with the calculation of AIC, may be in some 
 degree of freedom or adding some constant somewhere.

 And my comments below.


 Regards
 Utkarsh


 Greg Snow wrote:

 How many rows does xx have?

 Let's look at your example for chunksize 1, you initially fit
 the first 1 observations, then the seq results in just the
 value 1 which means that you do the update based on vaues
 10001 through 2, if xx only has 1 rows, then this should
 give at least one error.  If xx has 2 or more rows, then only
 chunksize 1 will ever see the 2^th value, the other
 chunksizes will use less of the data.

 Understood your point and apologize that you had to spend time going 
 into the logic inside for loop. I definitely thought of that but my 
 actual problem was the variation in AICs (which I was sure about), so 
 to ignore this loop problem (temporarily), I deliberately chose the 
 chunksizes such that the number of rows is a multiple of chunksize. I 
 knew there is still one extra iteration happening and I checked that 
 it was not causing any problem, the moredata in the last iteration 
 will be all NA's and update does nothing in such a case.

 For example:
 Let's say chunksize=5000, even though xx has only 1 rows, fit2 
 and fit3 below are exactly same.

 fit1 = biglm(y~x1+x2+x3, data=xx[1:5000,])
 fit2 = update(fit1, moredata=xx[5001:1,])
 fit3 = update(fit2, moredata=xx[10001:15000,])
 AIC(fit1); AIC(fit2); AIC(fit3)
 [1] 5018.282
 [1] 19956.91
 [1] 19956.91

 (The AIC matches with the table above and no warnings at all)

 I checked all these things before sending my first mail and dropped 
 the idea of refining the for loop as this will save me a few lines of 
 code and also the loop looks good and easy to understand. Moreover it 
 is neither taking any extra run time nor producing any warnings or errors.


  

 Also looking at the help for update.biglm, the 2^nd argument is 
 moredata not data, so if the code below is the code that you 
 actually ran, then the new data chunks are going into the ... 
 argument (and being ignored as that is there for future expansion and 
 does nothing 

Re: [R] Extracting a column name in loop?

2009-07-09 Thread Moshe Olshansky

If df is your dataframe then names(df) contains the column names and so 
names(df)[i] is the name of i-th column.

--- On Thu, 9/7/09, mister_bluesman mister_blues...@hotmail.com wrote:

 From: mister_bluesman mister_blues...@hotmail.com
 Subject: [R]  Extracting a column name in loop?
 To: r-help@r-project.org
 Received: Thursday, 9 July, 2009, 1:41 AM
 
 Hi,
 
 I am writing a script that will address columns using
 syntax like: 
 
 data_set[,1] 
 
 to extract the data from the first column of my data set,
 for example. This
 code will be placed in a loop (where the column reference
 will be placed by
 a variable). 
 
 What I also need to do is extract the column NAME for a
 given column being
 processed in the loop. The dataframe has been set so that R
 knows that the
 top line refers to column headers. 
 
 Can anyone help me understand how to do this?
 
 Thanks.
 -- 
 View this message in context: 
 http://www.nabble.com/Extracting-a-column-name-in-loop--tp24393160p24393160.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.


[R] Cuminc Plot

2009-07-09 Thread kende jan
Dear All,

here is the example for cumulative incidence analysis with cmprsk package:


set.seed(2)
ss - rexp(100)
gg - factor(sample(1:3,100,replace=TRUE),1:3,c('a','b','c'))
cc - sample(0:2,100,replace=TRUE)
strt - sample(1:2,100,replace=TRUE)
print(xx - cuminc(ss,cc,gg,strt))
plot(xx,lty=1,color=1:6)
 
When I
perform this example, I have 6 curves. 
a 1
b 1
c 1
a 2
b 2
c 2

I would
like to plot only 3 first curves of risk  cc=1 not all of 6 curves.
a 1
b 1
c 1
How I can
do this with R ?
Many thanks
Jan



  
[[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] Node colors in pvclust

2009-07-09 Thread nyk

Is there a way to assign color to nodes as with
hclust/as.dendrogram/dendrapply when using pvclust? 
The problem is that as.dendrogram isn't working on the pvclust objects.

library(pvclust)
pvc - pvclust(matrix, nboot=1000)
plot(pvc)

-- 
View this message in context: 
http://www.nabble.com/Node-colors-in-pvclust-tp24405329p24405329.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] print() to file?

2009-07-09 Thread Moshe Olshansky

One possibility is to use sink (see ?sink).

--- On Thu, 9/7/09, Steve Jaffe sja...@riskspan.com wrote:

 From: Steve Jaffe sja...@riskspan.com
 Subject: [R]  print() to file?
 To: r-help@r-project.org
 Received: Thursday, 9 July, 2009, 5:03 AM
 
 I'd like to write some objects (eg arrays) to a log file.
 cat() flattens them
 out. I'd like them formatted as in 'print' but print only
 writes to stdout.
 Is there a simple way to achieve this result? 
 
 Thanks
 
 -- 
 View this message in context: 
 http://www.nabble.com/print%28%29-to-file--tp24397445p24397445.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] error: no such index at level 2

2009-07-09 Thread Petr PIKAL
Hi

Godmar Back god...@gmail.com napsal dne 08.07.2009 15:28:50:

 On Wed, Jul 8, 2009 at 4:22 AM, Petr PIKAL petr.pi...@precheza.cz 
wrote:
 Hi
 
 r-help-boun...@r-project.org napsal dne 07.07.2009 19:06:17:
 
  Hi,
 
  I am confused about how to select elements from a list.
 
  I'm trying to select all rows of a table 'crossRsorted' such that the
  mean of a related vector is  0.  The related vector is accessible as
  a list element l[[i]] where i is the row index.
 
  I thought this would work:
 
   crossRsorted[mean(q[[ crossRsorted[,1] ]], na.rm = TRUE)  0, ]
  Error in q[[crossRsorted[, 1]]] : no such index at level 2

 Strange, I got completely different error. Couldn't be that only 
***you***
 have crossRsorted?
 
 Ok, fair enough. I'm still thinking of a language in which the meaning 
of 
 operators is apparent from their syntactical structure - probably need 
to read
 more of The R Inferno.
 
 Here's an example that reproduces the problem, I think (though the error 

 message is slightly different):
 
  q-list()
  q[[105]] - as.numeric(c(0,0,1))
  q[[104]] - as.numeric(c(1,1,1))
  q[[10]] - as.integer(c(3,3,1))
  crossRsorted - data.frame(i = c(105, 104,10))
  q[[ crossRsorted[,1] ]]
 Error in q[[crossRsorted[, 1]]] : recursive indexing failed at level 2

for that 
q[crossRsorted[,1]]

works but your real list is much more complicated.

 
 Even though the list 'q' has component 105, 104, and 10, the expression 
q[[ 
 crossRsorted[,1] ]] causes an error.
 Why?
 
 And why does this work:
 
  q[[c(105)]]
 [1] 0 0 1
 
 but not this:
 
  q[[c(105,104)]]
 Error in q[[c(105, 104)]] : subscript out of bounds
  q[[c(105,104,10)]]
 Error in q[[c(105, 104, 10)]] : recursive indexing failed at level 2
 
 even though q[[105]], q[[104], and q[[10]] are perfectly legitimate 
items?
 
 Coming back to my question, how to I express select all i in a vector 
for 
 which q[[i]] meets some predicate, where q is a list?
 
 Thank you for the tip about 'str' - that's the typeof function I've been 

 craving. (I thought 'attributes' or 'summary' was all there was...)
 The output for str in the original problem:
 
 In my original problem, the output is:
 
 
  str(crossRsorted)
 'data.frame':   15750 obs. of  5 variables:
  $ i : num  105 104 9 8 10 9 98 97 10 8 ...
  $ j : num  104 105 8 9 9 10 97 98 8 10 ...
  $ r : num  -0.973 -0.973 0.764 0.764 0.744 ...
  $ n : num  135 135 138 138 138 138 136 136 138 138 ...
  $ pvalue: num  2.90e-86 2.90e-86 0.00 0.00 0.00 ...
 
 and
 
  str(q)
 List of 165
  $ : NULL
  $ : NULL
  $ : NULL
  $ : NULL
  $ :'data.frame':   138 obs. of  1 variable:
   ..$ howdidyouhear: chr [1:138] 0 3 3 3 3 ...
  $ :'data.frame':   138 obs. of  1 variable:
   ..$ approximatelywhendidyoustart: int [1:138] 0 0 5 1 5 5 1 2 6 0 ...
 [ main body deleted ]
  $ :'data.frame':   138 obs. of  1 variable:
   ..$ revisiontestpage: num [1:138] 0 0 0 0 0 0 0 0 0 0 ...

and referring to what you wrote to Henrique

This appears to be doing something different. For instance, my 'q' has 165 
components, but what you suggest has 15750:
 length(q)
[1] 165
 length(q[ crossRsorted[,1] ])
[1] 15750

hardly what I want.

but this is what you asked for.

crossRsorted has 15750 items and all has been selected from q.

length(q[ unique(crossRsorted[,1] ]))
could be what you are looking for. However the result is probably a list 
of data frames not a data frame with rows.

Regards
Petr

 
 basically - a heterogeneous sparse list of NULL and data.frames of types 

 character, num, and int.
 
 However - by construction - the q[[i]] for i in crossRsorted[,1] are all 
non-
 NULL, as in my small reproducible example above.

 with data frame and list
 
 df1[sapply(list1,mean)0,]
 
 selects rows of df1 which correspond to list elements with mean 0
 
 I can't run 'sapply' over my list because sapply will also iterate over 
the 
 NULLs. I want to access only those components in list1 that occur in 
df1[1,].
 
  - Godmar


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


Re: [R] Mysteriously vanishing LD_LIBRARY_PATH

2009-07-09 Thread Patrick Connolly
On Wed, 08-Jul-2009 at 09:40PM -0500, Marc Schwartz wrote:

[]

 When I was using Fedora, several years ago I started to add any
 paths that I needed for LD_LIBRARY_PATH into /etc/ld.so.conf. Then
 run 'sudo ldconfig' to update the configuration.

Since I don't have root access to the CentOS machine, I can't make use
of that suggestion.  However, by modifying the ldpaths file in my home
directory where R is instaled, I could make it the same as it was in
the 2.8.1 installation.

Just why that wasn't a problem before R-2.9.0 and only with CentOS,
I'm no closer to understanding, but I know how to get around the
problem.

[]

Thanks for the suggestion and the one from Godmar Back.  I have it
working.

best

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

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


Re: [R] Best way to export values from a function?

2009-07-09 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 09.07.2009 02:57:33:

 On Wed, Jul 8, 2009 at 8:34 PM, Jason Rupertjasonkrup...@yahoo.com 
wrote:
 
  Maybe there is a great website out there or white paper that discusses 
this 
 but again my Google skills (or lack there of) let me down.
 
 Yeah, R is difficult to search for - I've had partial success with
 rseek.org, though.
 
 
  I would like to know the best way to export several doubles from a 
function,
 where the doubles are not an array.
 
  Here is a contrived function similar to my needs:
 
  multipleoutput-function(x)
  {
 squared-x^2
 cubed-x^3
 exponentioal-exp(x)
 factorialVal-factorial(x)
 
  }
 
 You can always do:
 
  multipleoutput - function (x) { return (c(square = x^2, cube = x^3, 
exp = exp(x))) }
 
 But then you'd have to call it like so:
 
  mapply(multipleoutput, c(0,1,2))
[,1] [,2] [,3]
 square0 1.00 4.00
 cube  0 1.00 8.00
 exp   1 2.718282 7.389056
 
 If you call it like so:
 
  multipleoutput(c(0,1,2))
  square1  square2  square3cube1cube2cube3 exp1 exp2
 0.00 1.00 4.00 0.00 1.00 8.00 1.00 2.718282
 exp3
 7.389056
 
 then R flattens the result.  Weird.

Not so weird. What do you expect from

c(1:5, 10:20, 30:50)

That is basically what your function do. With slight modification you can 
get tabular output without mapply

multipleoutput - function (x) {
result.s - x^2
result.c - x^3
result.e - exp(x)
cbind(square=result.s, cube=result.c, exp=result.e)
}

If the output could be mixed type }numeric, character, ...) use data.frame 
instead of cbind

Regards
Petr


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

2009-07-09 Thread justin bem
Dear all,

I'am using mlogit to test IIA hypothesis. I'get the test statistique who is 
negative, a p-value of 1, and a text saying that the IIA hypothesis is rejeted. 
Does a negative value mean that constraint model is more efficient that that 
the full model ? what to do in this case ?

Sincerly.

 Justin BEM
BP 1917 Yaoundé
Tél (237) 76043774



  
[[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] heatmap.2: question regarding the raw z-score

2009-07-09 Thread Chrysanthi A.
Thanks a lot..! What exactly the sweep function is doing? Also, is there a
possibility instead of using the mean of the whole row to get only the mean
of a group of the row values? So the values in the matrix (heat map) used in
the comparison are z-scores and not the intensities of the gene expressions,
right?

Also, as I can understand from the code, heatmap is using distfun function
for the clusering. Can I use pearson correlation for the clustering? My main
object of using the heatmap is to examine the expression levels of the
marker genes and to confirm that the marker genes are clearly differentially
expressed in the two subtypes of the disease that I examine.

Many thanks,

Chrysanthi.


2009/7/8 James W. MacDonald jmac...@med.umich.edu

 Hi Chrysanthi,


 Chrysanthi A. wrote:

 Hi,

 I am analysing gene expression data using the heatmap.2 function in R and
 I
 was wondering what is the formula of the raw z-score bar which shows the
 colors for each pixel.
 According to that post:
 https://mailman.stat.ethz.ch/pipermail/r-help/2006-September/113598.html,
 it
 is the

 (actual value - mean of the group) / standard deviation.

 But, mean of which group? Mean of the gene vector? And actual value of
 that
 gene on a sample?  I would be grateful if you could give me some more
 details about it or even if there is a book/manual that I could address
 to..


 How about looking at the code?

if (scale == row) {
retval$rowMeans - rm - rowMeans(x, na.rm = na.rm)
x - sweep(x, 1, rm)
retval$rowSDs - sx - apply(x, 1, sd, na.rm = na.rm)
x - sweep(x, 1, sx, /)
}
else if (scale == column) {
retval$colMeans - rm - colMeans(x, na.rm = na.rm)
x - sweep(x, 2, rm)
retval$colSDs - sx - apply(x, 2, sd, na.rm = na.rm)
x - sweep(x, 2, sx, /)
}

 So the z-score is calculated on either the row or column (or the default of
 none).

 I don't see how you can get something saying 'raw z-score'. I get either
 'Row Z-Score' or 'Column Z-Score'. So assuming you meant Row Z-Score, then
 the rows are centered and scaled by subtracting the mean of the row from
 every value and then dividing the resulting values by the standard deviation
 of the row.

 Best,

 Jim



 Thanks a lot,

 Chrysanthi.

 *
 *

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


 --
 James W. MacDonald, M.S.
 Biostatistician
 Douglas Lab
 University of Michigan
 Department of Human Genetics
 5912 Buhl
 1241 E. Catherine St.
 Ann Arbor MI 48109-5618
 734-615-7826


[[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] r bug (?) display of data

2009-07-09 Thread Marc Jekel

Hi R Fans,

I stumbled across a strange (I think) bug in R 2.9.1. I have read in a 
data file with 5934 rows and 9 columns with the commands:


daten = data.frame(read.table(C:/fussball.dat,header=TRUE))

Then I needed a subset of the data file:

newd = daten[daten[,1]!=daten[,2],]

-- two values do not meet the logical specification and are dropped.

The strange thing about it: When I print the newd in the R Console, the 
output still shows 5934 rows. When I check the number of rows with 
NROW(newd) , I get 5932 as output. When I print newd[5934, ], I get NAs. 
When I print newd[5932, ] I get the row that is listed in line 5934 when 
I just type in newd. This is totally crazy! Has anyone had the same 
problem? Thanks for a post.


Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Ordering zoo-object by its index

2009-07-09 Thread Sergey Goriatchev
Hello everyone,

Say I have zoo object

x.Date - as.Date(2003-02-01) + c(1, 3, 7, 9, 14) - 1
x - zoo(rnorm(5), x.Date)
y - zoo(rt(5, df=2), x.Date)
z - zoo(rt(5, df=5), x.Date)

Data - merge(x,y,z)

What should I do to make the latest values appear at the top?

Thank you for your help!

Regards,
Sergey

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


Re: [R] r bug (?) display of data

2009-07-09 Thread Peter Dalgaard

Marc Jekel wrote:

Hi R Fans,

I stumbled across a strange (I think) bug in R 2.9.1. I have read in a 
data file with 5934 rows and 9 columns with the commands:


daten = data.frame(read.table(C:/fussball.dat,header=TRUE))

Then I needed a subset of the data file:

newd = daten[daten[,1]!=daten[,2],]

-- two values do not meet the logical specification and are dropped.

The strange thing about it: When I print the newd in the R Console, the 
output still shows 5934 rows. When I check the number of rows with 
NROW(newd) , I get 5932 as output. When I print newd[5934, ], I get NAs. 
When I print newd[5932, ] I get the row that is listed in line 5934 when 
I just type in newd. This is totally crazy! Has anyone had the same 
problem? Thanks for a post.


You're confusing row names and row numbers. When you printed newd, did 
you actually count the number of lines? Thought so...


It isn't any stranger than this:

 data.frame(x=rnorm(6),y=rnorm(6))[-5,]
   x  y
1  0.9457385 -1.1398275
2 -1.1683732 -0.7269941
3  0.9942821  0.9310146
4 -2.0839580 -0.6261567
6  1.7225233  0.2457897


--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 bug (?) display of data

2009-07-09 Thread Uwe Ligges



Marc Jekel wrote:

Hi R Fans,

I stumbled across a strange (I think) bug in R 2.9.1. I have read in a 
data file with 5934 rows and 9 columns with the commands:


daten = data.frame(read.table(C:/fussball.dat,header=TRUE))

Then I needed a subset of the data file:

newd = daten[daten[,1]!=daten[,2],]

-- two values do not meet the logical specification and are dropped.

The strange thing about it: When I print the newd in the R Console, the 
output still shows 5934 rows. 


No 5932 rows, but with the original rownames (with 2 of them missing).

Uwe  Ligges


When I check the number of rows with
NROW(newd) , I get 5932 as output. When I print newd[5934, ], I get NAs. 
When I print newd[5932, ] I get the row that is listed in line 5934 when 
I just type in newd. This is totally crazy! Has anyone had the same 
problem? Thanks for a post.


Marc

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

2009-07-09 Thread Uwe Ligges
Which curve? How do you want to specify it? Where is the reproducible 
example (we do not have all your data to quickly test it)?


Best,
Uwe Ligges



Haoda Fu wrote:

To the Lattice expert -

I am new to the lattice package and I would like to add a curve to the 
xyplot(). I know that I need to use panel function to add it. But it doesn't work. Is there anyone can help me out on how to transfer the data into the function?


The following is my code and I would like to add lines for xx,yy


xx - seq(0,1,length = 100);
yy - mean(PS$theta)*(1-exp(mean(PS$k)*xx))/(1-exp(mean(PS$k)))

ts1 - xyplot(VCFB ~ Visit , groups = ID, data = CFB_M, type = c('g','l'),strip 
= strip.custom(style =4), as.table=TRUE,xlab = 'Time',ylab = 'FBG CFB',main = '3mg 
Change from Baseline FBG',panel=function (xx,yy,...) {
panel.xyplot(...);
panel.lines(xx,yy,...);});

Many thanks!!
Best,
Haoda

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

2009-07-09 Thread Uwe Ligges



Alfonso Rojas wrote:

Hello,
I tried to run the package but it shows me the following error:
In addition: Warning message:
package 'picante' was built under R version 2.10.0
Error in library(picante) : .First.lib failed for 'picante'



Try to reinstall a binary version that fits to your version of R (which 
obviously is not R-devel, but you have not told which one you are using) 
- or install the package from sources.


Best,
Uwe Ligges


What could I do to run picante in mac R version?

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

2009-07-09 Thread Uwe Ligges

Rebecca,

the attachments have been stripped off by the mailing list.


Rebecca Sela wrote:

That's good to know.  I have attached three Rd files that gave errors (others 
gave identical errors).  I would love to know what is wrong with them.

I'm using 2.1.1 because that is what is installed on the Linux computer I have 
access to.  (I haven't bothered figuring out how to assemble a package in 
Windows.)


You should *really* upgrade! That version is outdated for several years now.

How to do it on Windows: See the R Installation and Administration 
manual with its corresponding section.


Best,
Uwe



Thank you for your help!

Rebecca


- Original Message -
From: Uwe Ligges lig...@statistik.tu-dortmund.de
To: Rebecca Sela rs...@stern.nyu.edu
Cc: r-help r-help@r-project.org
Sent: Wednesday, July 8, 2009 6:11:33 PM GMT -05:00 US/Canada Eastern
Subject: Re: [R] \dQuote in packages

The difference you are experiencing is the new Rd2 parser that is more 
picky now (but also prevents to produce wrong documentation files).


If you make the code of the Rd available, someone might be able to help.

Are you really under R-2.1.1 ??? That is really ancient!


Best,
Uwe Ligges



Rebecca Sela wrote:

I am in the process of submitting a package to CRAN.  R CMD check ran 
successfully on the package on my local computer, using R version 2.1.1.  
However, on the computers for CRAN (with version 2.10.0), the following errors 
occurred:

Warning in parse_Rd(./man/predict.Rd, encoding = unknown) :
  ./man/predict.Rd:28: unknown macro '\dquote'
*** error on file ./man/predict.Rd
Error : ./man/predict.Rd:28: Unrecognized macro \dquote
Warning in parse_Rd(./man/print.Rd, encoding = unknown) :
  ./man/print.Rd:17: unexpected UNKNOWN '\sideeffects'
Warning in parse_Rd(./man/simpleREEMdata.Rd, encoding = unknown) :
  ./man/simpleREEMdata.Rd:10: unknown macro '\item'

Are \dquote, \sideeffects, and \item not supported in newer versions of R?  Is 
there some underlying problem that I should fix that makes these show up?

Thank you very much.

Rebecca

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Save rgl plot3d Graph as Image

2009-07-09 Thread Duncan Murdoch

Patrick Gedeon wrote:

Dear Users:
I wish to save 3d scatter plots I have generated using the plot3d command in
the rgl package. Any image format such as .tiff would work. Can anyone tell
me how to do this?
Try snapshot3d(), or rgl.postscript().  The postscript conversion is 
somewhat limited, but produces better quality when it works, because 
it's not just a bitmap.


Duncan Murdoch

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


[R] Bug in package.skeleton, R 2.9.0?

2009-07-09 Thread Daniel Klevebring
Dear all,

I am using package.skeleton to build a small packages of misc function  
for personal use. I have recently discovered that the option  
force=TRUE doesn't seem to do what is meant to do. Here's what I'm  
doing:

  setwd(/Users/danielk/Documents/R/packages/dk)
  files - paste(codebase, dir(codebase, pattern=.R), sep=/)
  package.skeleton(name=dk, force=TRUE, code_files=files)
Creating directories ...
Creating DESCRIPTION ...
Creating Read-and-delete-me ...
Copying code files ...
Making help files ...
Done.
Further steps are described in './dk/Read-and-delete-me'.
 

Now, everything seems fine, but changes to files in me codebase  
folder, doesn't come along if the folder dk/R already contains the  
files, even though I use force=TRUE. If I remove the dk/R folder or  
the dk folder altogether, the changes come along so to me it seems  
that it's the overwrite part that doesn't work as it should - or am I  
doing something wrong here?

See below for sessionInfo.

Thanks a bunch
Daniel



  sessionInfo()
R version 2.9.0 (2009-04-17)
i386-apple-darwin8.11.1

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

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


--

Contact information:

Daniel Klevebring
M. Sc. Eng., Ph.D. Student
Dept of Gene Technology
Royal Institute of Technology, KTH
SE-106 91 Stockholm, Sweden

Visiting address: Roslagstullsbacken 21, B3
Delivery address: Roslagsvägen 30B, 104 06, Stockholm
Invoice address: KTH Fakturaserice, Ref DAKL KTHBIO, Box 24075,  
SE-10450 Stockholm
E-mail: dan...@biotech.kth.se
Phone: +46 8 5537 8337 (Office)
Phone: +46 704 71 65 91 (Mobile)
Web: http://www.biotech.kth.se/genetech/index.html
Fax: +46 8 5537 8481


[[alternative HTML version deleted]]

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


Re: [R] R-help Digest, Vol 77, Issue 9

2009-07-09 Thread SIES 73
Hi,

This may be due to several reasons. That I can think about:

1) Ensure you close *all* possibly open workbooks:

nBooks - xl[[Workbooks]]$Count();
for (i in seq_len(nBooks))
xl[[Workbooks]]$item(i)$Close(SaveChanges=FALSE);

2) The excel application reference does not seem to be really released until 
the garbage collector runs. So this may help:

xl$Quit();
xl - NULL; 
gc();

3) Ensure you don't have any hanging reference to the excel application 
(sometimes from previous runs of your code that failed). If your code is inside 
a function, wrap the code in point 1 and 2 on an on.exit() call to ensure that 
excel is properly closed each time.


Hope this helps.

Enrique

--

Date: Wed, 8 Jul 2009 16:06:57 +0300
From: Lauri Nikkinen lauri.nikki...@iki.fi
Subject: [R] RDCOMClient: how to close Excel process?
To: r-h...@stat.math.ethz.ch
Message-ID:
ba8c09910907080606n29b8a537uac5ba1788376f...@mail.gmail.com
Content-Type: text/plain; charset=windows-1252

Hi,

I?m using R package RDCOMClient (http://www.omegahat.org/RDCOMClient/)
to retrieve data from MS Excel workbook. I?m using the code below to
count the number of sheets in the workbook and then loop the data from
sheets in to a list.

# R code ###
library(gdata)
library(RDCOMClient)

xl - COMCreate(Excel.Application)
sh - xl$Workbooks()$Open(normalizePath(sample_file.xls))$Sheets()$Count()

DF.list - list()
for (i in 1:sh) {
   DF.list[[i]] - read.xls(sample_file.xls, sheet=i,
stringsAsFactors = FALSE)
   }
##

COMCreate opens Excel process and it can be seen from Windows Task
Manager. When I try to open sample_file.xls in Excel, it just flashes
in the screen and shuts down. When I kill (via task manager) the Excel
process COMCreate started, sample_file.xls will open normally.

The question is, how can I close the Excel process COMCreate started.
xl$Close() doesn?t seem to work. The same problem have been presented
in this post to R-help:
http://tolstoy.newcastle.edu.au/R/help/06/04/25990.html

-L

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


Re: [R] Population pyramids

2009-07-09 Thread Jim Lemon

Victor Manuel Garcia Guerrero wrote:

Hi, I hope somebody can help me with this issue: I am doing population pyramids 
using the barplot command, so in the left side I have male age structure and in 
the right side the female age structure. To plot the male age structure I put 
the data in negative numbers. Now, I want to change the sign in the bar plot in 
such way that I have no-sign numbers, both in left and right side of the graph. 
I have been trying all day long and I could not succed.

  

Hi Victor,
I can get part of the way there with pyramid.plot and plotCI, but it 
would take some concentrated hacking to do it properly. If you can't 
find another solution, let me know.


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] Ordering zoo-object by its index

2009-07-09 Thread Gabor Grothendieck
To display that object in reverse time order try this:

as.data.frame(Data)[nrow(Data):1, ]


On Thu, Jul 9, 2009 at 5:21 AM, Sergey Goriatchevserg...@gmail.com wrote:
 Hello everyone,

 Say I have zoo object

 x.Date - as.Date(2003-02-01) + c(1, 3, 7, 9, 14) - 1
 x - zoo(rnorm(5), x.Date)
 y - zoo(rt(5, df=2), x.Date)
 z - zoo(rt(5, df=5), x.Date)

 Data - merge(x,y,z)

 What should I do to make the latest values appear at the top?

 Thank you for your help!

 Regards,
 Sergey

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


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


Re: [R] Ordering zoo-object by its index

2009-07-09 Thread Sergey Goriatchev
Hi, Gabor

Thank you!
That is exactly what I did, even before your email. :-)

Regards,
Sergey

On Thu, Jul 9, 2009 at 12:52, Gabor Grothendieckggrothendi...@gmail.com wrote:
 To display that object in reverse time order try this:

 as.data.frame(Data)[nrow(Data):1, ]


 On Thu, Jul 9, 2009 at 5:21 AM, Sergey Goriatchevserg...@gmail.com wrote:
 Hello everyone,

 Say I have zoo object

 x.Date - as.Date(2003-02-01) + c(1, 3, 7, 9, 14) - 1
 x - zoo(rnorm(5), x.Date)
 y - zoo(rt(5, df=2), x.Date)
 z - zoo(rt(5, df=5), x.Date)

 Data - merge(x,y,z)

 What should I do to make the latest values appear at the top?

 Thank you for your help!

 Regards,
 Sergey

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





-- 
I'm not young enough to know everything. /Oscar Wilde
Experience is one thing you can't get for nothing. /Oscar Wilde
When you are finished changing, you're finished. /Benjamin Franklin
Tell me and I forget, teach me and I remember, involve me and I learn.
/Benjamin Franklin
Luck is where preparation meets opportunity. /George Patten

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


Re: [R] Best way to export values from a function?

2009-07-09 Thread Godmar Back
On Thu, Jul 9, 2009 at 4:50 AM, Petr PIKAL petr.pi...@precheza.cz wrote:

 Hi

 r-help-boun...@r-project.org napsal dne 09.07.2009 02:57:33:

  On Wed, Jul 8, 2009 at 8:34 PM, Jason Rupertjasonkrup...@yahoo.com
 wrote:
  
   Maybe there is a great website out there or white paper that discusses
 this
  but again my Google skills (or lack there of) let me down.
 
  Yeah, R is difficult to search for - I've had partial success with
  rseek.org, though.
 
  
   I would like to know the best way to export several doubles from a
 function,
  where the doubles are not an array.
  
   Here is a contrived function similar to my needs:
  
   multipleoutput-function(x)
   {
  squared-x^2
  cubed-x^3
  exponentioal-exp(x)
  factorialVal-factorial(x)
  
   }
 
  You can always do:
 
   multipleoutput - function (x) { return (c(square = x^2, cube = x^3,
 exp = exp(x))) }
 
  But then you'd have to call it like so:
 
   mapply(multipleoutput, c(0,1,2))
 [,1] [,2] [,3]
  square0 1.00 4.00
  cube  0 1.00 8.00
  exp   1 2.718282 7.389056
 
  If you call it like so:
 
   multipleoutput(c(0,1,2))
   square1  square2  square3cube1cube2cube3 exp1 exp2
  0.00 1.00 4.00 0.00 1.00 8.00 1.00 2.718282
  exp3
  7.389056
 
  then R flattens the result.  Weird.

 Not so weird. What do you expect from

 c(1:5, 10:20, 30:50)


You mean what I expect personally, with my background?
I'd expect a jagged array of arrays.

1 2 3 4 5
10 11 12 .. 20
30 31 .. 50

If operator c() constructs an array out of its arguments, and if the
sequence operator : constructs an array, then c(1:5) should construct an
array of arrays.



 That is basically what your function do. With slight modification you can
 get tabular output without mapply

 multipleoutput - function (x) {
 result.s - x^2
 result.c - x^3
 result.e - exp(x)
 cbind(square=result.s, cube=result.c, exp=result.e)
 }


Just for clarification: is there any significance to your using the . in the
names result.s, result.c, etc. like there would be in some other languages
where dot is an operator?

 - Godmar

[[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] Ordering zoo-object by its index

2009-07-09 Thread Gabor Grothendieck
One additional thought. If the reason you want to do that is
just so that you can see the last few rows more easily then

tail(Data)

will display the last few rows or tail(Data, 10) will display
the last 10 rows.

On Thu, Jul 9, 2009 at 7:36 AM, Sergey Goriatchevserg...@gmail.com wrote:
 Hi, Gabor

 Thank you!
 That is exactly what I did, even before your email. :-)

 Regards,
 Sergey

 On Thu, Jul 9, 2009 at 12:52, Gabor Grothendieckggrothendi...@gmail.com 
 wrote:
 To display that object in reverse time order try this:

 as.data.frame(Data)[nrow(Data):1, ]


 On Thu, Jul 9, 2009 at 5:21 AM, Sergey Goriatchevserg...@gmail.com wrote:
 Hello everyone,

 Say I have zoo object

 x.Date - as.Date(2003-02-01) + c(1, 3, 7, 9, 14) - 1
 x - zoo(rnorm(5), x.Date)
 y - zoo(rt(5, df=2), x.Date)
 z - zoo(rt(5, df=5), x.Date)

 Data - merge(x,y,z)

 What should I do to make the latest values appear at the top?

 Thank you for your help!

 Regards,
 Sergey

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





 --
 I'm not young enough to know everything. /Oscar Wilde
 Experience is one thing you can't get for nothing. /Oscar Wilde
 When you are finished changing, you're finished. /Benjamin Franklin
 Tell me and I forget, teach me and I remember, involve me and I learn.
 /Benjamin Franklin
 Luck is where preparation meets opportunity. /George Patten


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


Re: [R] Best way to export values from a function?

2009-07-09 Thread Petr PIKAL
Hi

Godmar Back god...@gmail.com napsal dne 09.07.2009 14:09:42:

 On Thu, Jul 9, 2009 at 4:50 AM, Petr PIKAL petr.pi...@precheza.cz 
wrote:
 Hi
 
 r-help-boun...@r-project.org napsal dne 09.07.2009 02:57:33:
 

snip

 Not so weird. What do you expect from
 
 c(1:5, 10:20, 30:50)
 
 You mean what I expect personally, with my background?
 I'd expect a jagged array of arrays.
 
 1 2 3 4 5
 10 11 12 .. 20
 30 31 .. 50
 
 If operator c() constructs an array out of its arguments, and if the 
sequence 
 operator : constructs an array, then c(1:5) should construct an array of 
arrays.

 is.array(1:5)
[1] FALSE
 is.vector(1:5)
[1] TRUE


Why. Not much is said about arrays in man page for c. The operator 
concatenates its arguments. If they are vectors the output is again a 
vector. If they are lists the output is list.

try
c(1:5,10:20)
c(1:5, list(10:20)
c(1:5, data.frame(10:20)

and regarding arrays, matrices and vectors - AFAIK arrays and matrices are 
just vectors with dim attribute, which is stripped by c 
 
c is sometimes used for its side effect of removing attributes except 
names, for example to turn an array into a vector. as.vector is a more 
intuitive way to do this, but also drops names. Note too that methods 
other than the default are not required to do this (and they will almost 
certainly preserve a class attribute). 

  
 
 That is basically what your function do. With slight modification you 
can
 get tabular output without mapply
 
 multipleoutput - function (x) {
 result.s - x^2
 result.c - x^3
 result.e - exp(x)
 cbind(square=result.s, cube=result.c, exp=result.e)
 }
 
 Just for clarification: is there any significance to your using the . in 
the 
 names result.s, result.c, etc. like there would be in some other 
languages 
 where dot is an operator?

No. AFAIK one dot does not have any special meaning unless you use it in 
the beginning of name. In that case the variable is not listed by ls() 
function. See ?ls and argument all.names

Regards
Petr

  
  - Godmar

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

2009-07-09 Thread Brecknock, Peter
Hi All
 
Apologies if this is not the correct mailing list for this question. 
 
I have installed RExcel and RCom from CRAN. R is indicating that I need
an additional file/package statconnDCOM from rcom.univie.ac.at
 
I have been trying to access this website over the last 2 days be it
appears to be down. 
 
Does anyone know when this site is likely to be back up and/or know of
an alternative source for the statconnDCOM file?
 
Kind regards
 
Pete  
 

This e-mail may contain confidential or proprietary information
belonging to the BP group and is intended only for the use of the
recipients named above.  If you are not the intended recipient, please
immediately notify the sender and either delete this email or return to
the sender immediately.  You may not review, copy or distribute this
email.  Within the bounds of law, this part of BP retains all emails and
IMs and may monitor them to ensure compliance with BP's internal
policies and for other legitimate business purposes.

 

[[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] Reading from Google Docs

2009-07-09 Thread Duncan Temple Lang


Thanks for pointing that out.
Yes, the link on the package web site was for 0.2-1 and
that was the one used to build the binary for Windows.
Now updated in both places and the binary repository will
give 0.2-2.

How to find the version of an installed package?

  packageDescription(RGoogleDocs)

 D.

Farrel Buchinsky wrote:

Dear Duncan

On my home computer I was able to use  install.packages(RGoogleDocs, 
repos = http://www.omegahat.org/R;)


But, alas it would not read the data in the spreadsheet. It went back to 
its nasty ways

Error in !includeEmpty : invalid argument type

That is what I was getting with version 0.2-1.You then sent me link to 
0.2-2 (in source code) which is what worked.


Is it possible that that the windows binary version you put in omegahat 
was 0.2-1 and not 0.2-2?
 
I did not know how to tell what version had been installed.

Farrel Buchinsky
Google Voice Tel: (412) 567-7870



On Wed, Jul 8, 2009 at 22:53, Duncan Temple Lang 
dun...@wald.ucdavis.edu mailto:dun...@wald.ucdavis.edu wrote:




Farrel Buchinsky wrote:

  


Boy oh boy that process of getting source to binary was super
painful. Now
that I have the package as binary I can share the whole folder
with my
coworker and she is able to use RGoogleDocs. I intend to use the
same
process for the other two windows machines that I use. I really
do not want
to go through the same installation and path hassles all over again.

Should I post my directory containing the binary files somewhere
so that
others do not have to experience pain. Does etiquette dictate
that I should
post the directory to help other or does etiquette dictate that
it is Duncan
Temple Lang's code and thus it his prerogative to distribute his
work as he
wishes?


Etiquette is one thing and the license another.
Both encourage you to help others and make the
binary available to others.
And indeed,  I hope that Windows users do build binaries
for others and remove the additional work from those
who provide the software in the first place.

Having seen this thread today, I did put a binary
version of RGoogleDocs on the Omegahat repository
so

 install.packages(RGoogleDocs, repos = http://www.omegahat.org/R;)

should install it and, if I had had time earlier, saved you the hardship
of building the binary.  Sorry to do it so soon after.

 D.





Farrel Buchinsky
Google Voice Tel: (412) 567-7870



On Wed, Jul 8, 2009 at 12:59, Farrel Buchinsky fjb...@gmail.com
mailto:fjb...@gmail.com wrote:

Does changing the path in Windows work in real time or does
one need to
restart the computer for the changes to take effect.
Farrel Buchinsky
Google Voice Tel: (412) 567-7870



On Wed, Jul 8, 2009 at 12:04, Gabor Grothendieck
ggrothendi...@gmail.com mailto:ggrothendi...@gmail.comwrote:

Its safer just to temporarily add it to your path.

Unfortunately Rtools has a find command that conflicts with
the find command in Windows so if you add the Rtools
bin directory to your path permanently then you could
find other programs stop working.  That actually happened
to me once and it took the longest time until I discovered
that Rtools was the culprit.

If you follow the advice I gave you normally won't have
that problem.

On Wed, Jul 8, 2009 at 11:21 AM, Duncan
Murdochmurd...@stats.uwo.ca mailto:murd...@stats.uwo.ca
wrote:

On 08/07/2009 10:13 AM, Farrel Buchinsky wrote:

Forgive my naivte, but how do I make windows
find tar. In other words

from

where do I issue the command and what is the
command.

You need to install the toolset, and let the
installer set your path.

Duncan Murdoch

Farrel Buchinsky
Google Voice Tel: (412) 567-7870



On Wed, Jul 8, 2009 at 10:09, Duncan Murdoch
murd...@stats.uwo.ca mailto:murd...@stats.uwo.ca

wrote:

On 08/07/2009 10:02 AM, Farrel Buchinsky wrote:

I  have previously read R Installation
and Administration. I read

it

again. It does not help me
The relevant paragraph is below. But I
need lower level instructions.
 

Re: [R] RDCOMClient: how to close Excel process?

2009-07-09 Thread J. R. M. Hosking

Lauri Nikkinen wrote:

Thanks again. That did not work either. I get


library(RDCOMClient)
xl - COMCreate(Excel.Application)
wk  - xl$Workbooks()
sh - wk$Open(normalizePath(sample_file.xls))$Sheets()$Count()

wk$Close()

[1] TRUE

xl$Quit()

NULL

and there is still Excel process open in the Task manager (and
sample_file.xls won't open).

-L


In my experience, the Excel process will not go away if any
Excel-related object has been created but not destroyed.  I suggest that
you explictly remove all Excel objects with rm() and run gc() at the end
to clean up:

  library(RDCOMClient)
  xl - COMCreate(Excel.Application)
  wk - xl$Workbooks()
  sh-wk$Open(normalizePath(sample_file.xls))$Sheets()$Count()
  wk$Close()
  xl$Quit()
  rm(sh)
  rm(wk)
  rm(xl)
  gc()



J. R. M. Hosking

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


[R] T.test error help

2009-07-09 Thread Amit Patel

Hi I am implementing the t.test in a loop and where the data is the same i get 
an error message. 

Error in t.test.default(Samp3, Samp1, na.rm = TRUE, var.equal = FALSE,  : 
  data are essentially constant

The script i am using is 

for (i in 1:length(zz[,1])) {

Samp1 - zz[i,2:17]
Samp2 - zz[i,18:33]
Samp3 - zz[i,34:47]
Samp4 - zz[i,48:63] 

TTestResult[i,2] - t.test(Samp2, Samp1, na.rm=TRUE, var.equal = FALSE, 
paired=FALSE, conf.level=0.95)$p.value


TTestResult[i,3] - t.test(Samp3, Samp1, na.rm=TRUE, var.equal = FALSE, 
paired=FALSE, conf.level=0.95)$p.value

TTestResult[i,4] - t.test(Samp4, Samp1, na.rm=TRUE, var.equal = FALSE, 
paired=FALSE, conf.level=0.95)$p.value

}

Is there a way to make my loop ignore this problem and go onto the next 
iteration





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Apply weights to the Efron Approximation

2009-07-09 Thread Bessy

Dear all,

I want to apply weights to my sample data set and I am struggling with the
Efron Approximation with weights.

I have got one sample data shown as below:

customerweekarrest  fin age raceweight 1weight 
2weight 3
1   20  1   1   27  1   2   15  2
2   17  1   0   18  1   2   19  1
3   25  1   1   19  0   2   20  1
4   52  0   1   23  1   2   5   1
5   52  0   0   19  0   2   11  1
6   25  1   0   19  0   2   26  1

I applied four different weighted Efron Formulas (all are derived by myself)
to the data set above and have got the following results for 3 weight sets
based on those 4 formulas, respectively.

weight 1Formula 1   Formula 2 Formula 3  Formula 4  
 
R software  replicated by weights   
fin-0.235912234  -0.530843641  -0.471823965 -0.471823965  
-0.4718  -0.5308
age  -0.052005981   -0.122613988 -0.104018973 -0.104018973   -0.104
-0.1226 
race0.637573013  1.404345693  1.275165398   1.275165398 1.2752  
  1.4043

weight 2Formula 1  Formula 2 Formula 3  Formula 4   
R
softwarereplicated by weight
fin 0.600334761  -0.32212452  -0.178028949  -0.244162408  -0.25062  
-0.32212
age 0.105321888  -0.214932275 -0.112459016  -0.146957807  -0.14607  
-0.21493
race5.742146326  2.2589341822.043479975 1.921804334 1.94056
2.25893 

weight 3Formula 1   Formula 2Formula 3   Formula 4  

R software  replicated by weights   
fin -0.984946984  -0.909980273  -0.333235566-0.80272443-0.802724
-0.90998
age 0.036891147 0.03225069 -0.194126398 -0.004544225   -0.004544
0.03225 
race0.962911927 1.3052554251.435340831  1.318038014  
1.318038
1.30526 

replicated by weights means that I also replicated individuals as many
times as indicated by weights and applied unweighted Efron approximation to
the replication of the dataset. 

The formula 4 can give me same results as the unweighted ones if I apply the
same weights to each individual and also can give me the close results to
the ones calculated by R (efron method+weights) if I apply different weights
to each individual. these results are close to the R's but not exactly the
same. 

I don't know why and what the problem is with my formulas. Could anyone give
me some help, please?

I will really appreciate it.

I have attached my four weighted Efron formulas with this message already.
Bessy 
http://www.nabble.com/file/p24410214/Weighted%2BEfron%2BApproximation_Formulas_Examples.pdf
Weighted+Efron+Approximation_Formulas_Examples.pdf 
-- 
View this message in context: 
http://www.nabble.com/Apply-weights-to-the-Efron-Approximation-tp24410214p24410214.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] Converting indices of a matrix subset

2009-07-09 Thread Steve Lianoglou

Hi Nathan,

On Jul 8, 2009, at 10:20 PM, Nathan S. Watson-Haigh wrote:


I have two matrices:


m1 - matrix(1,4,4)
m1

[,1] [,2] [,3] [,4]
[1,]1111
[2,]1111
[3,]1111
[4,]1111


m2 - matrix(0,3,3)
diag(m2) - 1
m2

[,1] [,2] [,3]
[1,]100
[2,]010
[3,]001

I want to get indicies from m2 such that they match indicies as  
though they came

from the lower right of m1. Here's how things work:


ind1 - which(m1 == 1)
ind1

[1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16

ind2 - which(m2 == 1)
ind2

[1] 1 5 9


I would like ind2 to be offset so they look like indicies from the  
lower right

of m1:

ind2

[1] 6 11 16



I have written some utility functions I use often[1], and have  
sub2ind function that works in a similar fashion to the MATLAB  
function of the same name. It's somehow long and convoluted because  
you can send in your arguments 12 different ways from sunday, so:


sub2ind - function(x, y, nrow, ncol=NULL) {
  ## Returns a linear index for the (x,y) coordinates passed in.
  if (is.matrix(x) || is.data.frame(x)) {
stopifnot(ncol(x) == 2)
if (!missing(y)) {
  if (missing(nrow)) {
nrow - y
  } else {
ncol - nrow
nrow - y
  }
}
y - x[,2]
x - x[,1]
  }

  if (is.matrix(nrow)) {
d - dim(nrow)
nrow - d[1]
ncol - d[2]
  } else if (is.null(ncol)) {
stop(Dimensions of matrix under-specified)
  }

  # Sanity check to ensure we got each var doing what it should be  
doing
  if (length(x) != length(y) || length(nrow) != 1 || length(ncol) !=  
1) {

stop(I'm confused)
  }

  ((x - 1) + ((y - 1) * nrow)) + 1

}

R m1 - matrix(1,4,4)
R m2 - matrix(0,3,3)
R ind2 - which(m2 == 1, arr.ind=T) + 1
R ind2
 row col
[1,]   2   2
[2,]   3   3
[3,]   4   4

R my.ind2 - sub2ind(ind2, nrow=4, ncol=4)
# my.ind2 - sub2ind(ind2[,1], ind2[,2], 4, 4)
# my.ind2 - sub2ind(ind2[,1], ind2[,2], m1)
# my.ind2 - sub2ind(ind2, m1)
R my.ind2
[1]  6 11 16

I think that gets you to where you want to be :-)

-steve

[1] They can be found here if your intersted, there isn't much  
documentation there, but I'll fix that some time later :-)

http://github.com/lianos/ARE.utils/tree/master

--
Steve Lianoglou
Graduate Student: Physiology, Biophysics and Systems Biology
Weill Medical College of Cornell University

Contact Info: http://cbio.mskcc.org/~lianos

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

2009-07-09 Thread Steve Lianoglou

Hi,

On Jul 9, 2009, at 9:19 AM, Amit Patel wrote:



Hi I am implementing the t.test in a loop and where the data is the  
same i get an error message.


Error in t.test.default(Samp3, Samp1, na.rm = TRUE, var.equal =  
FALSE,  :

 data are essentially constant

The script i am using is

for (i in 1:length(zz[,1])) {

Samp1 - zz[i,2:17]
Samp2 - zz[i,18:33]
Samp3 - zz[i,34:47]
Samp4 - zz[i,48:63]

TTestResult[i,2] - t.test(Samp2, Samp1, na.rm=TRUE, var.equal =  
FALSE, paired=FALSE, conf.level=0.95)$p.value



TTestResult[i,3] - t.test(Samp3, Samp1, na.rm=TRUE, var.equal =  
FALSE, paired=FALSE, conf.level=0.95)$p.value


TTestResult[i,4] - t.test(Samp4, Samp1, na.rm=TRUE, var.equal =  
FALSE, paired=FALSE, conf.level=0.95)$p.value


}

Is there a way to make my loop ignore this problem and go onto the  
next iteration


Yes, see: ?try and ?tryCatch

For example:

R log(10)
[1] 2.302585

R log(a)
Error in log(a) : Non-numeric argument to mathematical function

R a - tryCatch(log(10), error=function(e) {
+ cat(There was an error\n)
+ NA
+ })

R b - tryCatch(log(a), error=function(e) {
+ cat(There was an error\n)
+ NA
+ })
There was an error

R a
[1] 2.302585

R b
[1] NA

-steve

--
Steve Lianoglou
Graduate Student: Physiology, Biophysics and Systems Biology
Weill Medical College of Cornell University

Contact Info: http://cbio.mskcc.org/~lianos

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


Re: [R] Ordering zoo-object by its index

2009-07-09 Thread Sergey Goriatchev
Hi, Gabor

Yes, I am familiar with tail() function. I use it extensively on a day
to day basis.
In this particular case I needed to order a zoo object by date, after
I have created it with RBloomberg.

Thank you for your time!

Regards,
Sergey

On Thu, Jul 9, 2009 at 14:36, Gabor Grothendieckggrothendi...@gmail.com wrote:
 One additional thought. If the reason you want to do that is
 just so that you can see the last few rows more easily then

 tail(Data)

 will display the last few rows or tail(Data, 10) will display
 the last 10 rows.

 On Thu, Jul 9, 2009 at 7:36 AM, Sergey Goriatchevserg...@gmail.com wrote:
 Hi, Gabor

 Thank you!
 That is exactly what I did, even before your email. :-)

 Regards,
 Sergey

 On Thu, Jul 9, 2009 at 12:52, Gabor Grothendieckggrothendi...@gmail.com 
 wrote:
 To display that object in reverse time order try this:

 as.data.frame(Data)[nrow(Data):1, ]


 On Thu, Jul 9, 2009 at 5:21 AM, Sergey Goriatchevserg...@gmail.com wrote:
 Hello everyone,

 Say I have zoo object

 x.Date - as.Date(2003-02-01) + c(1, 3, 7, 9, 14) - 1
 x - zoo(rnorm(5), x.Date)
 y - zoo(rt(5, df=2), x.Date)
 z - zoo(rt(5, df=5), x.Date)

 Data - merge(x,y,z)

 What should I do to make the latest values appear at the top?

 Thank you for your help!

 Regards,
 Sergey

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





 --
 I'm not young enough to know everything. /Oscar Wilde
 Experience is one thing you can't get for nothing. /Oscar Wilde
 When you are finished changing, you're finished. /Benjamin Franklin
 Tell me and I forget, teach me and I remember, involve me and I learn.
 /Benjamin Franklin
 Luck is where preparation meets opportunity. /George Patten





-- 
I'm not young enough to know everything. /Oscar Wilde
Experience is one thing you can't get for nothing. /Oscar Wilde
When you are finished changing, you're finished. /Benjamin Franklin
Tell me and I forget, teach me and I remember, involve me and I learn.
/Benjamin Franklin
Luck is where preparation meets opportunity. /George Patten

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


Re: [R] clogit comparison between Stata and R

2009-07-09 Thread Thomas Lumley

On Wed, 8 Jul 2009, David Hugh-Jones wrote:


Hello all

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

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


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



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


Yes.


Is R doing the same?


Yes.

-thomas

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


Re: [R] heatmap.2: question regarding the raw z-score

2009-07-09 Thread James W. MacDonald

Hi Chrysanthi,

Chrysanthi A. wrote:


Thanks a lot..! What exactly the sweep function is doing? Also, is there 
a possibility instead of using the mean of the whole row to get only the 
mean of a group of the row values? So the values in the matrix (heat 
map) used in the comparison are z-scores and not the intensities of the 
gene expressions, right? 


I was trying to give a subtle hint below, but maybe I should be a bit 
more blunt. One of the coolest things about R is that it is free, and 
there are these sweet listservs where people give advice and help for 
free as well.


HOWEVER, there is still a price to pay, and that is with your time. All 
of these functions have help pages that the developers spent time 
writing, and the code is there for you to peruse. Because of this, there 
is some expectation that you would have done so prior to asking 
questions. Now I have read the help page for sweep, and quite frankly it 
is a bit confusing. The term 'sweep' is used without definition, so if 
one doesn't know what that means the help page is less than helpful. But 
it doesn't take much time or effort to empirically see what it does:


 a - matrix(rnorm(25), ncol=5)
 a
   [,1]   [,2]   [,3][,4][,5]
[1,]  0.6841637 -1.0590185 -0.1719887 -0.01916011 -1.61936817
[2,]  0.5707217  1.4790968  1.6736991 -0.72158518  1.22467334
[3,]  0.4440499 -0.3382888 -0.1504191  0.32140022  1.83780859
[4,] -0.6659568  3.0573678 -1.5709904 -1.35618488 -0.01717017
[5,] -0.3182206  2.2777597 -0.2325356 -0.02001414  1.77440090
 rm - rowMeans(a)
 rm
[1] -0.4370743  0.8453211  0.4229102 -0.1105869  0.6962780
 sweep(a, 1, rm, -)
[,1]   [,2]   [,3]   [,4][,5]
[1,]  1.12123808 -0.6219441  0.2650857  0.4179142 -1.18229384
[2,] -0.27459943  0.6337756  0.8283779 -1.5669063  0.37935220
[3,]  0.02113977 -0.7611990 -0.5733293 -0.1015100  1.41489842
[4,] -0.55536988  3.1679546 -1.4604035 -1.2455980  0.09341672
[5,] -1.01449866  1.5814817 -0.9288137 -0.7162922  1.07812286

For your second question:

?heatmap.2




Also, as I can understand from the code, heatmap is using distfun 
function for the clusering. Can I use pearson correlation for the 
clustering? My main object of using the heatmap is to examine the 
expression levels of the marker genes and to confirm that the marker 
genes are clearly differentially expressed in the two subtypes of the 
disease that I examine.


No, heatmap.2() is not using distfun for the clustering. There isn't a 
function by that name in either gplots nor base R. If you look at the 
help page, you can see that distfun is an argument to the function, and 
the default is to use the dist() function.


You can use Pearson correlation, but in my experience it takes some 
work. Again, if you read the help page, you can see that the Rowv and 
Colv arguments can be one of TRUE, FALSE, NULL, or a dendrogram. So if 
you want to use Pearson correlation, you should supply heatmap.2() with 
dendrograms produced using that correlation. So an example:


a - matrix(rnorm(50), ncol=5)
rowv - as.dendrogram(hclust(as.dist(1-cor(t(a)
colv - as.dendrogram(hclust(as.dist(1-cor(a
heatmap.2(a, scale=row, Rowv=rowv, Colv=colv)

Best,

Jim





Many thanks,

Chrysanthi.


2009/7/8 James W. MacDonald jmac...@med.umich.edu 
mailto:jmac...@med.umich.edu


Hi Chrysanthi,


Chrysanthi A. wrote:

Hi,

I am analysing gene expression data using the heatmap.2 function
in R and I
was wondering what is the formula of the raw z-score bar which
shows the
colors for each pixel.
According to that post:

https://mailman.stat.ethz.ch/pipermail/r-help/2006-September/113598.html,
it
is the

(actual value - mean of the group) / standard deviation.

But, mean of which group? Mean of the gene vector? And actual
value of that
gene on a sample?  I would be grateful if you could give me some
more
details about it or even if there is a book/manual that I could
address
to..


How about looking at the code?

   if (scale == row) {
   retval$rowMeans - rm - rowMeans(x, na.rm = na.rm)
   x - sweep(x, 1, rm)
   retval$rowSDs - sx - apply(x, 1, sd, na.rm = na.rm)
   x - sweep(x, 1, sx, /)
   }
   else if (scale == column) {
   retval$colMeans - rm - colMeans(x, na.rm = na.rm)
   x - sweep(x, 2, rm)
   retval$colSDs - sx - apply(x, 2, sd, na.rm = na.rm)
   x - sweep(x, 2, sx, /)
   }

So the z-score is calculated on either the row or column (or the
default of none).

I don't see how you can get something saying 'raw z-score'. I get
either 'Row Z-Score' or 'Column Z-Score'. So assuming you meant Row
Z-Score, then the rows are centered and scaled by subtracting the
mean of the row from every value and then dividing the resulting
values 

Re: [R] Dantzig Selector

2009-07-09 Thread roger koenker

There is an experimental version available here:

http://www.econ.uiuc.edu/~roger/research/sparse/sfn.html

that uses the interior point code in the package quantreg.  There is
an option to exploit possible sparsity of the X matrix.

Comments would be welcome.


url:www.econ.uiuc.edu/~rogerRoger Koenker
email   rkoen...@uiuc.edu   Department of Economics
vox:217-333-4558University of Illinois
fax:217-244-6678Champaign, IL 61820


On Jul 8, 2009, at 6:35 PM, tzygmund mcfarlane wrote:


Hi,

I was wondering if there was an R package or routines for the Dantzig
Selector (Candes  Tao, 2007). I know Emmanuel Candes has Matlab
routines to do this but I was wondering if someone had ported those to
R.

Thanks,

T

---Reference---

@article{candes2007dantzig,
 title={{The Dantzig selector: statistical estimation when p is much
larger than n}},
 author={Candes, E. and Tao, T.},
 journal={Annals of Statistics},
 volume={35},
 number={6},
 pages={2313--2351},
 year={2007},
 publisher={Hayward, Calif.[etc] Institute of Mathematical  
Statistics [etc]}

}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RDCOMClient: how to close Excel process?

2009-07-09 Thread Lauri Nikkinen
This solution worked:

nBooks - xl[[Workbooks]]$Count();
for (i in seq_len(nBooks))
xl[[Workbooks]]$item(i)$Close(SaveChanges=FALSE);

from

http://www.mail-archive.com/r-help@r-project.org/msg61498.html

Thanks!

-L

2009/7/9 Lauri Nikkinen lauri.nikki...@iki.fi:
 Thanks again. That did not work either. I get

 library(RDCOMClient)
 xl - COMCreate(Excel.Application)
 wk  - xl$Workbooks()
 sh - wk$Open(normalizePath(sample_file.xls))$Sheets()$Count()

 wk$Close()
 [1] TRUE
 xl$Quit()
 NULL


 and there is still Excel process open in the Task manager (and
 sample_file.xls won't open).

 -L

 2009/7/8 Henrique Dallazuanna www...@gmail.com:
 Then, you can try this:

 xl - COMCreate(Excel.Application)
 wk  - xl$Workbooks()
 sh - wk$Open(normalizePath(sample_file.xls))$Sheets()$Count()

 wk$Close()
 xl$Quit()



 On Wed, Jul 8, 2009 at 10:19 AM, Lauri Nikkinen lauri.nikki...@iki.fi
 wrote:

 Thanks but that did not work. xl$Quit() does not kill the Excel
 process and sample_file.xls will not open.

 I'm using Windows XP SP2 and R 2.8.1

 -L

 2009/7/8 Henrique Dallazuanna www...@gmail.com:
  Try this:
 
  xl$Quit()
 
  On Wed, Jul 8, 2009 at 10:06 AM, Lauri Nikkinen lauri.nikki...@iki.fi
  wrote:
 
  Hi,
 
  I’m using R package RDCOMClient (http://www.omegahat.org/RDCOMClient/)
  to retrieve data from MS Excel workbook. I’m using the code below to
  count the number of sheets in the workbook and then loop the data from
  sheets in to a list.
 
  # R code ###
  library(gdata)
  library(RDCOMClient)
 
  xl - COMCreate(Excel.Application)
  sh -
  xl$Workbooks()$Open(normalizePath(sample_file.xls))$Sheets()$Count()
 
  DF.list - list()
  for (i in 1:sh) {
    DF.list[[i]] - read.xls(sample_file.xls, sheet=i,
  stringsAsFactors = FALSE)
    }
  ##
 
  COMCreate opens Excel process and it can be seen from Windows Task
  Manager. When I try to open sample_file.xls in Excel, it just flashes
  in the screen and shuts down. When I kill (via task manager) the Excel
  process COMCreate started, sample_file.xls will open normally.
 
  The question is, how can I close the Excel process COMCreate started.
  xl$Close() doesn’t seem to work. The same problem have been presented
  in this post to R-help:
  http://tolstoy.newcastle.edu.au/R/help/06/04/25990.html
 
  -L
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
  --
  Henrique Dallazuanna
  Curitiba-Paraná-Brasil
  25° 25' 40 S 49° 16' 22 O
 



 --
 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] naming of columns in R dataframe consisting of mixed data (alphanumeric and numeric)

2009-07-09 Thread Mary A. Marion
Hello,

I have an r function that creates the following dataframe tresults2.
Notice that column 1 does not have a column heading.

Tresults2:
 [,1]
estparam 18.0
nullval  20.0
. . .
ciWidth   2.04622
HalfInterval  1.02311

pertinent code:
results-cbind( estparam, nullval, t, pv_left, pv_right, pv_two_t, 
estse, df,  cc, tbox, llim, ulim, ciWidth, HalfInterval)
tresults-round((results),5)
tresults2-data.frame(t(tresults))
names(tresults2)-c(Statistic , Value)
tresults2

===
After transposing my dataframe tresults2 consists of 2 columns.  
Col1=alphanumeric data (this really is a variable name) and
col2=numeric data (this is value of varaiable).

how do I name columns when columns are different (alphanumeric and numeric)
to avoid the following error:

Error in names(tresults2) - c(Statistic , Value) :
  'names' attribute [2] must be the same length as the vector [1]

Am I to use c( , ) or list( , ) with a dataframe?

Thank you for your help.
Sincerely,
Mary A. Marion





[[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] treating a data symbol like a character

2009-07-09 Thread Andrew Yee
Hi, is there a way to treat a data symbol, e.g. one with pch = 16, as a
character?
Specifically, I'm interested in creating a line of text as follows using the
text() function

O alpha O beta O gamma

where the O is pch 16 and filled with a specific color.

Not sure if this is possible or not.

Thanks,
Andrew

[[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] treating a data symbol like a character

2009-07-09 Thread Jorge Ivan Velez
Hi Andrew,
Do you want to put the symbols you described as a legend in a plot?  If so,
here is one way:

x - rnorm(3)
plot(x, pch = 16, cex = 1.1, col = 1:3)
legend('topleft', ncol = 3,
c(expression(alpha), expression(beta), expression(gamma)), pch = 16,
cex = 1.1, col = 1:3)

Is you do not want to use legend, but place the symbols in each plot, then:

plot(x, pch = 16, cex = 1.1, col = 1:3)
text(1.05,1.01*x[1], expression(alpha) )
text(2.05,1.01*x[2], expression(beta) )
text(2.95,1.01*x[3], expression(gamma) )

should get you close.

See ?text, ?expression and ?legend for more information.

HTH,

Jorge


On Thu, Jul 9, 2009 at 10:53 AM, Andrew Yee y...@post.harvard.edu wrote:

 Hi, is there a way to treat a data symbol, e.g. one with pch = 16, as a
 character?
 Specifically, I'm interested in creating a line of text as follows using
 the
 text() function

 O alpha O beta O gamma

 where the O is pch 16 and filled with a specific color.

 Not sure if this is possible or not.

 Thanks,
 Andrew

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] plm Issues

2009-07-09 Thread Damien Moore
Hi List

I'm having difficulty understanding how plm should work with dynamic
formulas. See the commands and output below on a standard data set. Notice
that the first summary(plm(...)) call returns the same result as the second
(it shouldn't if it actually uses the lagged variable requested). The third
call results in error (trying to use diff'ed variable in regression)

Other info: I'm running R 2.7.2 on WinXP

cheers



*data(Gasoline,package=Ecdat)
Gasoline_plm-plm.data(Gasoline,c(country,year))
pdim(Gasoline_plm)
**Balanced Panel: n=18, T=19, N=342
*
*summary(plm(lgaspcar~lincomep,data=Gasoline_plm**))
**Oneway (individual) effect Within Model

Call:
plm(formula = lgaspcar ~ lincomep, data = Gasoline_plm)

Balanced Panel: n=18, T=19, N=342

Residuals :
Min.  1st Qu.   Median  3rd Qu. Max.
-0.40100 -0.08410 -0.00858  0.08770  0.73400

Coefficients :
 Estimate Std. Error t-value  Pr(|t|)
lincomep -0.761830.03535 -21.551  2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares: 17.061
Residual Sum of Squares: 6.9981
Multiple R-Squared: 0.58981
F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

** summary(plm(lgaspcar~lag(lincomep),data=Gasoline_plm))
**Oneway (individual) effect Within Model

Call:
plm(formula = lgaspcar ~ lag(lincomep), data = Gasoline_plm)

Balanced Panel: n=18, T=19, N=342

Residuals :
Min.  1st Qu.   Median  3rd Qu. Max.
-0.40100 -0.08410 -0.00858  0.08770  0.73400

Coefficients :
  Estimate Std. Error t-value  Pr(|t|)
lag(lincomep) -0.761830.03535 -21.551  2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares: 17.061
Residual Sum of Squares: 6.9981
Multiple R-Squared: 0.58981
F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981

*
*summary(plm(lgaspcar~diff(lincomep),data=Gasoline_plm))*
*Error in model.frame.default(formula = lgaspcar ~ diff(lincomep), data =
mydata,  :
  variable lengths differ (found for 'diff(lincomep)')
*

[[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] treating a data symbol like a character

2009-07-09 Thread Andrew Yee
Thanks for your help.
I should have been more clear in my initial e-mail.  I shouldn't have used
'alpha' or 'beta,' to avoid confusion with them as Greek symbols.  I should
have stated something like:

O foo O abcd O John

While I'm familiar with using legend to make the filled boxes, I'm
interested in creating a one line legend of sorts, but manually using
text() with both data symbols defined by pch and text on the same line.  Or
is this not possible?  I guess at the end of the day, I could use both
points() and text().

Thanks,
Andrew

On Thu, Jul 9, 2009 at 11:03 AM, Jorge Ivan Velez
jorgeivanve...@gmail.comwrote:

 Hi Andrew,
 Do you want to put the symbols you described as a legend in a plot?  If so,
 here is one way:

 x - rnorm(3)
 plot(x, pch = 16, cex = 1.1, col = 1:3)
 legend('topleft', ncol = 3,
 c(expression(alpha), expression(beta), expression(gamma)), pch =
 16, cex = 1.1, col = 1:3)

 Is you do not want to use legend, but place the symbols in each plot, then:

 plot(x, pch = 16, cex = 1.1, col = 1:3)
 text(1.05,1.01*x[1], expression(alpha) )
 text(2.05,1.01*x[2], expression(beta) )
 text(2.95,1.01*x[3], expression(gamma) )

 should get you close.

 See ?text, ?expression and ?legend for more information.

 HTH,

 Jorge


  On Thu, Jul 9, 2009 at 10:53 AM, Andrew Yee y...@post.harvard.edu wrote:

  Hi, is there a way to treat a data symbol, e.g. one with pch = 16, as a
 character?
 Specifically, I'm interested in creating a line of text as follows using
 the
 text() function

 O alpha O beta O gamma

 where the O is pch 16 and filled with a specific color.

 Not sure if this is possible or not.

 Thanks,
 Andrew

[[alternative HTML version deleted]]

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




[[alternative HTML version deleted]]

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


Re: [R] treating a data symbol like a character

2009-07-09 Thread Jorge Ivan Velez
Hi Andrew,
If I understand correctly, then

# Data
x - c(3,4,2)

# Collection of text and symbols
Text - c('foo', 'abcd', 'John')
PCH - c('+','O','$')

# Plotting
plot(x, pch = PCH)
legend('topright', pch = PCH, Text, ncol = 3)

should be close to what you want. Note that the text() / points()
combination could be avoided when using legend().

Best,

Jorge


On Thu, Jul 9, 2009 at 11:08 AM, Andrew Yee  wrote:

 Thanks for your help.
 I should have been more clear in my initial e-mail.  I shouldn't have used
 'alpha' or 'beta,' to avoid confusion with them as Greek symbols.  I should
 have stated something like:

 O foo O abcd O John

 While I'm familiar with using legend to make the filled boxes, I'm
 interested in creating a one line legend of sorts, but manually using
 text() with both data symbols defined by pch and text on the same line.  Or
 is this not possible?  I guess at the end of the day, I could use both
 points() and text().

 Thanks,
 Andrew

 On Thu, Jul 9, 2009 at 11:03 AM, Jorge Ivan Velez  wrote:

 Hi Andrew,
 Do you want to put the symbols you described as a legend in a plot?  If
 so, here is one way:

 x - rnorm(3)
 plot(x, pch = 16, cex = 1.1, col = 1:3)
 legend('topleft', ncol = 3,
 c(expression(alpha), expression(beta), expression(gamma)), pch =
 16, cex = 1.1, col = 1:3)

 Is you do not want to use legend, but place the symbols in each plot,
 then:

 plot(x, pch = 16, cex = 1.1, col = 1:3)
 text(1.05,1.01*x[1], expression(alpha) )
 text(2.05,1.01*x[2], expression(beta) )
 text(2.95,1.01*x[3], expression(gamma) )

 should get you close.

 See ?text, ?expression and ?legend for more information.

 HTH,

 Jorge


  On Thu, Jul 9, 2009 at 10:53 AM, Andrew Yee  wrote:

  Hi, is there a way to treat a data symbol, e.g. one with pch = 16, as a
 character?
 Specifically, I'm interested in creating a line of text as follows using
 the
 text() function

 O alpha O beta O gamma

 where the O is pch 16 and filled with a specific color.

 Not sure if this is possible or not.

 Thanks,
 Andrew

[[alternative HTML version deleted]]

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





[[alternative HTML version deleted]]

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


Re: [R] treating a data symbol like a character

2009-07-09 Thread Andrew Yee
Great, that's a good starting point.
Andrew

On Thu, Jul 9, 2009 at 11:20 AM, Jorge Ivan Velez
jorgeivanve...@gmail.comwrote:


 Hi Andrew,
 If I understand correctly, then

 # Data
 x - c(3,4,2)

 # Collection of text and symbols
 Text - c('foo', 'abcd', 'John')
 PCH - c('+','O','$')

 # Plotting
 plot(x, pch = PCH)
 legend('topright', pch = PCH, Text, ncol = 3)

 should be close to what you want. Note that the text() / points()
 combination could be avoided when using legend().

 Best,

 Jorge


 On Thu, Jul 9, 2009 at 11:08 AM, Andrew Yee  wrote:

  Thanks for your help.
 I should have been more clear in my initial e-mail.  I shouldn't have used
 'alpha' or 'beta,' to avoid confusion with them as Greek symbols.  I should
 have stated something like:

 O foo O abcd O John

 While I'm familiar with using legend to make the filled boxes, I'm
 interested in creating a one line legend of sorts, but manually using
 text() with both data symbols defined by pch and text on the same line.  Or
 is this not possible?  I guess at the end of the day, I could use both
 points() and text().

 Thanks,
 Andrew

 On Thu, Jul 9, 2009 at 11:03 AM, Jorge Ivan Velez  wrote:

 Hi Andrew,
 Do you want to put the symbols you described as a legend in a plot?  If
 so, here is one way:

 x - rnorm(3)
 plot(x, pch = 16, cex = 1.1, col = 1:3)
 legend('topleft', ncol = 3,
 c(expression(alpha), expression(beta), expression(gamma)), pch =
 16, cex = 1.1, col = 1:3)

 Is you do not want to use legend, but place the symbols in each plot,
 then:

 plot(x, pch = 16, cex = 1.1, col = 1:3)
 text(1.05,1.01*x[1], expression(alpha) )
 text(2.05,1.01*x[2], expression(beta) )
 text(2.95,1.01*x[3], expression(gamma) )

 should get you close.

 See ?text, ?expression and ?legend for more information.

 HTH,

 Jorge


  On Thu, Jul 9, 2009 at 10:53 AM, Andrew Yee  wrote:

  Hi, is there a way to treat a data symbol, e.g. one with pch = 16, as a
 character?
 Specifically, I'm interested in creating a line of text as follows using
 the
 text() function

 O alpha O beta O gamma

 where the O is pch 16 and filled with a specific color.

 Not sure if this is possible or not.

 Thanks,
 Andrew

[[alternative HTML version deleted]]

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






[[alternative HTML version deleted]]

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


[R] How to: initialize, setValidity, copy-constructor

2009-07-09 Thread Renaud Gaujoux

Hello list,

I'm having troubles setting up a basic calss hierarchy with S4.
Here is a simplified schema of what I'd like to do:

- Two classes: A and B that extends A
- Ensure that the slots added by B are consistent with the slots of A
- Let A initialize itself (I'm not supposed to know the internal cooking 
of A)

- By default set the slots of B based on the slots that A initialized

Another question is: what is the recommended way of implementing a 
copy-constructor in R?


I know that all of this is easily done in C++. The constructor of each 
class is called recursively back-up to the root class. Validity checks 
can be performed after/during associated initialization. 
Copy-constructor are basics in C++.


Here below is a piece of code that I thought would work (but it does 
not... therefore my post), what's wrong with it?
I think the main issue is when is the validity check performed: why is 
it performed before the end of the initialize method?


Thank you for your help.
Renaud

# define class A with a single numeric slot
setClass('A', representation(a='numeric'))

# define class B that extends class A, adding another numeric slot
setClass('B', representation('A', b='numeric'))
# we want for example to ensure that slots a and b have the same length
setValidity('B',
function(object){
cat(*** B::validate ***\n)
print(object)
cat(*\n)
if( length(obj...@a) != length(obj...@b) ) return('Inconsistent lengths')
TRUE
}
)
# As a default behaviour if b is not provided, we want slot b to be 
equal to slot a

setMethod('initialize', 'B',
function(.Object, b, ...){
cat(*** B::initialize ***\n)
print(.Object)

# Let the superclass (A) initialize itself via callNextMethod
# I thought it would only do that: initialize and optionnaly validate 
the class A part of the object

#But it generates an ERROR: apparently it calls the validation method of B,
# before leaving me a chance to set slot b to a valid value
.Object - callNextMethod(.Object, ...)

# now deal with the class B part of the object
cat(*** Test missing b ***\n)
if( missing(b) ){
cat(*** b is MISSING ***\n)
b - .obj...@a
}

# set slot b
.obj...@b - b

.Object
}
)

### Testing

# empty A: OK
aObj - new('A')
aObj

# class A with some data: OK
aObj - new('A', a=c(1,2) )
aObj

# empty B: OK
bObj - new('B')
bObj

# initialize B setting the slot of class A: ERROR
bObj - new('B', a=c(1,2))

# initialize B setting only the slot class B: OK!! Whereas it produces a 
non valid object.

bObj - new('B', b=c(1,2))
bObj

# RESULTS:

 # empty A: OK
 aObj - new('A')
 aObj
An object of class “A”
Slot a:
numeric(0)


 # class A with some data: OK
 aObj - new('A', a=c(1,2) )
 aObj
An object of class “A”
Slot a:
[1] 1 2


 # empty B: OK
 bObj - new('B')
*** B::initialize ***
An object of class “B”
Slot b:
numeric(0)

Slot a:
numeric(0)

*** Test missing b ***
*** b is MISSING ***
 bObj
An object of class “B”
Slot b:
numeric(0)

Slot a:
numeric(0)


 # initialize B setting the slot of class A: ERROR
 bObj - new('B', a=c(1,2))
*** B::initialize ***
An object of class “B”
Slot b:
numeric(0)

Slot a:
numeric(0)

*** B::validate ***
An object of class “B”
Slot b:
numeric(0)

Slot a:
[1] 1 2

*
Error in validObject(.Object) :
invalid class B object: Inconsistent lengths

 # initialize B setting only the slot class B: OK!! Whereas it creates 
a non valid object.

 bObj - new('B', b=c(1,2))
*** B::initialize ***
An object of class “B”
Slot b:
numeric(0)

Slot a:
numeric(0)

*** Test missing b ***
 bObj
An object of class “B”
Slot b:
[1] 1 2

Slot a:
numeric(0)



-
 sessionInfo()
R version 2.9.1 (2009-06-26)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_ZA.UTF-8;LC_NUMERIC=C;LC_TIME=en_ZA.UTF-8;LC_COLLATE=en_ZA.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_ZA.UTF-8;LC_PAPER=en_ZA.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_ZA.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
[1] Biobase_2.4.1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] correct way to subset a vector

2009-07-09 Thread Juliet Hannah
Hi,

#make example data
dat - data.frame(matrix(rnorm(15),ncol=5))
colnames(dat) - c(ab,cd,ef,gh,ij)

If I want to get a subset of the data for the middle 3 columns, and I
know the names of the start column and the end column, I can do this:

mysub - subset(dat,select=c(cd:gh))

If I wanted to do this just on the column names, without subsetting
the data, how could I do this?

mynames - colnames(dat);

#mynames
#[1] ab cd ef gh ij

Is there an easy way to create the vector c(cd,ef,gh) as I did
above using something similar to cd:gh?

Thanks,

Juliet

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


Re: [R] Population pyramids

2009-07-09 Thread Daniel Malter

Victor, use the axes=FALSE option, as you do. Then use the labels and at
options in the axis argument to place the tickmark labels in the negative
plot manually


par(mfrow=c(1,2),bty=n,mai=c(0.5, 0.25, 0.25, 0.25))

x=rgamma(1000,10,0.3)

barplot(height=t(-x), width = 0.825, space = NULL,
names.arg = NULL, legend.text = c(Inf 95%,Mediana,Sup 95%),
beside = FALSE,
horiz = TRUE, density = NULL, angle = 0,
axes = FALSE,
col = c(yellow,Blue,orange), border = par(fg),
main = Mujeres,
xlim =NULL, ylim = NULL, xpd = TRUE, log = ,
axisnames = FALSE,
 
axis(1,hadj=NA,padj=NA,cex.axis=0.75,labels=c(0,10,20,30,40,50,
60,70),at=c(0,-10,-20,-30,-40,-50,-60,-70)))


barplot(height=t(x), width = 0.825, space = NULL,
names.arg = NULL, legend.text = c(Inf 95%,Mediana,Sup 95%),
beside = FALSE,
axes=FALSE,
horiz = TRUE, density = NULL, angle = 0,
col = c(yellow,Blue,orange), border = par(fg),
main = Mujeres,
xlim =NULL, ylim = NULL, xpd = TRUE, log = ,
axisnames = FALSE,
axis(1,cex.axis=0.75))

That should do. Best,
Daniel


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: Victor Manuel Garcia Guerrero [mailto:vmgar...@colmex.mx] 
Gesendet: Thursday, July 09, 2009 1:44 AM
An: Daniel Malter; r-help@r-project.org
Betreff: RE: [R] Population pyramids

Yes the code is the next:

par(mfrow=c(1,2),bty=n,mai=c(0.5, 0.25, 0.25, 0.25))

barplot(height=t(icNM2005.dat), width = 0.825, space = NULL,
names.arg = NULL, legend.text = NULL, beside = FALSE,
horiz = TRUE, density = NULL, angle = 0,
col = c(yellow,Blue,orange), border = par(fg),
main = Hombres,
xlim =NULL, ylim = NULL, xpd = TRUE, log = ,
axes = FALSE, axisnames = FALSE,cex.axis=0.75)
axis(1,pretty(c(-1200,0),n=12),
hadj=NA,padj=NA,cex.axis=0.75,las=2)


barplot(height=t(icNF2005.dat), width = 0.825, space = NULL,
names.arg = NULL, legend.text = c(Inf 95%,Mediana,Sup 95%),
beside = FALSE,
horiz = TRUE, density = NULL, angle = 0,
col = c(yellow,Blue,orange), border = par(fg),
main = Mujeres,
xlim =NULL, ylim = NULL, xpd = TRUE, log = ,
axes = FALSE, axisnames = FALSE,cex.axis=0.75)
axis(2,pretty(c(0:105),n=21),hadj=0.5,padj=0.5,cex.axis=0.75,
las=2)
axis(1,pretty(c(0:1200),n=5),
hadj=NA,padj=NA,cex.axis=0.5,las=1)


Víctor Manuel García Guerrero
Doctorado en Estudios de Población,
CEDUA, COLMEX
Camino al Ajusco N° 20, Pedregal de Sta. Teresa C.P.10740, Tlalpan, México,
D.F.
* : vmgar...@colmex.mx
( : 5617-9016



-Mensaje original-
De: Daniel Malter [mailto:dan...@umd.edu] Enviado el: jue 09/07/2009 12:15
Para: Victor Manuel Garcia Guerrero; r-help@r-project.org
Asunto: AW: [R] Population pyramids
 
Can you provide a self-contained example of what you did so far (i.e. code
for simulating some data and code for the plot)? That would greatly help to
help you find a solution.

Daniel 


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: Victor Manuel Garcia Guerrero [mailto:vmgar...@colmex.mx]
Gesendet: Thursday, July 09, 2009 12:48 AM
An: Daniel Malter; r-help@r-project.org
Betreff: RE: [R] Population pyramids

Yes, but my issue is because I need to plot a pop pyramid with confidence
intervals, and the pyramid function does not work in that way. Thanks
Daniel.


-Mensaje original-
De: Daniel Malter [mailto:dan...@umd.edu] Enviado el: mié 08/07/2009 11:36
Para: Victor Manuel Garcia Guerrero; r-help@r-project.org
Asunto: AW: [R] Population pyramids
 
have you tried the pyramid function in the epicalc package?

best,
daniel 


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von Victor Manuel Garcia Guerrero
Gesendet: Thursday, July 09, 2009 12:25 AM
An: r-help@r-project.org
Betreff: [R] Population pyramids

Hi, I hope somebody can help me with this issue: I am doing population
pyramids using the barplot command, so in the left side I have male age
structure and in the right side the female age structure. To plot the male
age structure I put the data in negative numbers. Now, I want to change the
sign in the bar plot in such way that I have no-sign numbers, both in left
and right side of the graph. I have been trying all day long and I could not
succed.

Thanks...

Victor

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

2009-07-09 Thread Daniel Malter
put another condition in your loop

if(all.equal(x,y)=TRUE) i=i+1 else t.test...

something in that direction.

best,
daniel 


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von Amit Patel
Gesendet: Thursday, July 09, 2009 9:20 AM
An: r-help@r-project.org
Betreff: [R] T.test error help


Hi I am implementing the t.test in a loop and where the data is the same i
get an error message. 

Error in t.test.default(Samp3, Samp1, na.rm = TRUE, var.equal = FALSE,  : 
  data are essentially constant

The script i am using is 

for (i in 1:length(zz[,1])) {

Samp1 - zz[i,2:17]
Samp2 - zz[i,18:33]
Samp3 - zz[i,34:47]
Samp4 - zz[i,48:63] 

TTestResult[i,2] - t.test(Samp2, Samp1, na.rm=TRUE, var.equal = FALSE,
paired=FALSE, conf.level=0.95)$p.value


TTestResult[i,3] - t.test(Samp3, Samp1, na.rm=TRUE, var.equal = FALSE,
paired=FALSE, conf.level=0.95)$p.value

TTestResult[i,4] - t.test(Samp4, Samp1, na.rm=TRUE, var.equal = FALSE,
paired=FALSE, conf.level=0.95)$p.value

}

Is there a way to make my loop ignore this problem and go onto the next
iteration





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] correct way to subset a vector

2009-07-09 Thread Steve Lianoglou

Hi,

On Jul 9, 2009, at 11:40 AM, Juliet Hannah wrote:


Hi,

#make example data
dat - data.frame(matrix(rnorm(15),ncol=5))
colnames(dat) - c(ab,cd,ef,gh,ij)

If I want to get a subset of the data for the middle 3 columns, and I
know the names of the start column and the end column, I can do this:

mysub - subset(dat,select=c(cd:gh))

If I wanted to do this just on the column names, without subsetting
the data, how could I do this?

mynames - colnames(dat);

#mynames
#[1] ab cd ef gh ij

Is there an easy way to create the vector c(cd,ef,gh) as I did
above using something similar to cd:gh?


How about just taking your mynames vector? eg:

R mynames[2:4]
[1] cd ef gh

R dat[, mynames[2:4]]
  cd ef  gh
1  1.7745386  1.0958930 -0.07213304
2  0.7480372 -0.1364458 -0.62848211
3 -0.5477843  1.5811382 -0.74404103

-steve

--
Steve Lianoglou
Graduate Student: Physiology, Biophysics and Systems Biology
Weill Medical College of Cornell University

Contact Info: http://cbio.mskcc.org/~lianos

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


Re: [R] wordStem problems in R 2.9, Fedora 11; Linux Kernel 2.6.29.5-191.fc11.i586

2009-07-09 Thread Reitsma, Rene - COB
Duncan,

Thanks for helping. I reinstalled Rstem from source (using the omegahat
URL) and this time things are working. :-)

RR

 

-Original Message-
From: Duncan Temple Lang [mailto:dun...@wald.ucdavis.edu] 
Sent: Tuesday, July 07, 2009 5:33 PM
To: Reitsma, Rene - COB
Cc: r-help@r-project.org
Subject: Re: [R] wordStem problems in R 2.9, Fedora 11; Linux Kernel
2.6.29.5-191.fc11.i586

Hi Rene

   Can you tell us the version of the Rstem package you installed.
Rstem_0.3-1 from
  http://www.omegahat.org/Rstem/

or

 install.packages(Rstem, repos = http://www.omegahat.org/R;)

work fine for me.

I seem to recall this being a problem with an older version of Rstem.

   D.

Reitsma, Rene - COB wrote:
 Dear All,
 
 I just updated from Fedora 9 to Fedora 11, kernel version
 2.6.29.5-191.fc11.i586. I'm running R 2.9.
 
 I successfully installed package Rstem from source (it always ran fine
 for me in F9). However:
 
 wordStem(c(This,is,a,test))
 Error in wordStem(c(This, is, a, test)) : 
   VECTOR_ELT() can only be applied to a 'list', not a 'character'
 
 Any idea what causes this / how I can fix this?
 
 RR
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 error help

2009-07-09 Thread Uwe Ligges



Daniel Malter wrote:

put another condition in your loop

if(all.equal(x,y)=TRUE) i=i+1 else t.test...

something in that direction.



Sorry, but that's neither valid R code nor sensible in this case.
See my suggestions below.





best,
daniel 



-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von Amit Patel
Gesendet: Thursday, July 09, 2009 9:20 AM
An: r-help@r-project.org
Betreff: [R] T.test error help


Hi I am implementing the t.test in a loop and where the data is the same i
get an error message. 

Error in t.test.default(Samp3, Samp1, na.rm = TRUE, var.equal = FALSE,  : 
  data are essentially constant


The script i am using is 


for (i in 1:length(zz[,1])) {



for(i in seq_along(zz[,1])){

should be safer.



Samp1 - zz[i,2:17]
Samp2 - zz[i,18:33]
Samp3 - zz[i,34:47]
Samp4 - zz[i,48:63] 


TTestResult[i,2] - t.test(Samp2, Samp1, na.rm=TRUE, var.equal = FALSE,
paired=FALSE, conf.level=0.95)$p.value


TTestResult[i,3] - t.test(Samp3, Samp1, na.rm=TRUE, var.equal = FALSE,
paired=FALSE, conf.level=0.95)$p.value

TTestResult[i,4] - t.test(Samp4, Samp1, na.rm=TRUE, var.equal = FALSE,
paired=FALSE, conf.level=0.95)$p.value

}

Is there a way to make my loop ignore this problem and go onto the next
iteration



yes, you can wrap it in try() and check the object with
if(inherits(object, try-error)) later on in order to do something 
different (e.g. assign an NA) in case of an error.


Uwe Ligges







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

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

2009-07-09 Thread Mary A. Marion

Hello,

I would like R software to printout a sentence including a statement such as
Ho: mu=5 vs Ha: mu ne 5 where ne stands for the math symbol notequal
and mu is greek letter for u.  How to do?  Most of the help questions I have
seen  have been those involving graphs.

Thank you.
Sincerely,
Mary A. Marion

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Logistic Regression: Likelihoo-Ratio Based Confidence Intervals

2009-07-09 Thread alex the lipenator
Hello!

I hope this email finds you all well.  I have a rather elementary question.  I 
am interested in obtaining likelihood ratio-based confidence intervals of 
logistic regression parameter estimates (i.e., the MLE).  How do I specify 
likelihood ratio CIs in the confint() function, or do I need to use some 
other function?

Thank you for your time,

Alex

 



  
[[alternative HTML version deleted]]

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


Re: [R] correct way to subset a vector

2009-07-09 Thread Marc Schwartz

On Jul 9, 2009, at 10:40 AM, Juliet Hannah wrote:


Hi,

#make example data
dat - data.frame(matrix(rnorm(15),ncol=5))
colnames(dat) - c(ab,cd,ef,gh,ij)

If I want to get a subset of the data for the middle 3 columns, and I
know the names of the start column and the end column, I can do this:

mysub - subset(dat,select=c(cd:gh))

If I wanted to do this just on the column names, without subsetting
the data, how could I do this?

mynames - colnames(dat);

#mynames
#[1] ab cd ef gh ij

Is there an easy way to create the vector c(cd,ef,gh) as I did
above using something similar to cd:gh?

Thanks,

Juliet




Using the same presumption that the desired values are consecutive in  
the vector:


# Use which() to get the indices for the start and end of the subset
 mynames[which(mynames == cd):which(mynames == gh)]
[1] cd ef gh


You can encapsulate that in a function:

subset.vector - function(x, start, end)
{
  x[which(x == start):which(x == end)]
}

 subset.vector(mynames, cd, gh)
[1] cd ef gh



Note that you can also do this:

 names(subset(dat, select = cd:gh))
[1] cd ef gh

but that actually goes through the process of subsetting the data  
frame first, which potentially introduces a lot of overhead and memory  
use if the data frame is large. It also presumes that the desired  
vector is a subset of the column names of the initial data frame.



To use the same sequence based approach as is used in  
subset.data.frame(), you can do what is used internally within that  
function:


subset.vector - function(x, select)
{
  nl - as.list(1L:length(x))
  names(nl) - x
  vars - eval(substitute(select), nl)
  x[vars]
}


 subset.vector(mynames, select = cd:gh)
[1] cd ef gh



BTW, well done on recognizing that you can use the sequence of column  
names for the 'select' argument. A lot of folks, even experienced  
useRs, don't realize that you can do that...  :-)


HTH,

Marc Schwartz

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


Re: [R] math symbols in R

2009-07-09 Thread Bert Gunter
?plotmath

Bert Gunter
Genentech Nonclinical Biostatistics


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Mary A. Marion
Sent: Thursday, July 09, 2009 12:04 PM
To: r-help@r-project.org
Subject: [R] math symbols in R

Hello,

I would like R software to printout a sentence including a statement such as
Ho: mu=5 vs Ha: mu ne 5 where ne stands for the math symbol notequal
and mu is greek letter for u.  How to do?  Most of the help questions I have
seen  have been those involving graphs.

Thank you.
Sincerely,
Mary A. Marion

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

2009-07-09 Thread Lorenzo Isella

Dear All,
I am not very into object-oriented programming, but I would like to 
learn the ropes for some R applications.

Quoting from the online R language definition (paragraph 5.1)

Consider the following simple example. A point in two-dimensional 
Euclidean space can be specified by its Cartesian (x-y) or polar 
(r-theta) coordinates. Hence, to store information about the location 
of the point, we could define two classes, |xypoint| and 
|rthetapoint|. All the `xypoint' data structures are lists with an 
x-component and a y-component. All `rthetapoint' objects are lists 
with an r-component and a theta-component.


Now, suppose we want to get the x-position from either type of object. 
This can easily be achieved through generic functions. We define the 
generic function |xpos| as follows.


 xpos - function(x, ...)
 UseMethod(xpos)
  


Now we can define methods:

 xpos.xypoint - function(x) x$x
 xpos.rthetapoint - function(x) x$r * cos(x$theta)
  

The user simply calls the function |xpos| with either representation 
as the argument. The internal dispatching method finds the class of 
the object and calls the appropriate methods.


I am a bit confused: when calling e.g. xpos.rthetapoint, I understand 
that x contains the polar representation of a point, so x=(r,theta), 
but  how do I exactly  write it to pass it to xpos.rthetapoint? I have 
made several attempts, but so far none of them works, so I may have 
misunderstood something.

Many thanks

Lorenzo

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


[R] assigning vector name by increasing index in loop

2009-07-09 Thread cbc123

Hello

I have a large data table that I wish to divide in to vectors, as in 
 v1 v2 v3 v4 v5
id11   2  34   5
id26  7   8   9  10

newv1 - c(table[1,1], table[3,1], table [5,1])
newv2-c(table[1,2], table[3,2]. table[5,2])

...and so forth.  How do I do this using a loop?
-- 
View this message in context: 
http://www.nabble.com/assigning-vector-name-by-increasing-index-in-loop-tp24410532p24410532.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] Extracting a column name in loop?

2009-07-09 Thread mister_bluesman

Thank you both for that. Much appreciated.


mister_bluesman wrote:
 
 Hi,
 
 I am writing a script that will address columns using syntax like: 
 
 data_set[,1] 
 
 to extract the data from the first column of my data set, for example.
 This code will be placed in a loop (where the column reference will be
 placed by a variable). 
 
 What I also need to do is extract the column NAME for a given column being
 processed in the loop. The dataframe has been set so that R knows that the
 top line refers to column headers. 
 
 Can anyone help me understand how to do this?
 
 Thanks.
 

-- 
View this message in context: 
http://www.nabble.com/Extracting-a-column-name-in-loop--tp24393160p24407422.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] Executing an error prone function without stopping a script

2009-07-09 Thread Tolga I Uzuner

Dear R Users,

I've used this a long time ago but have forgotten. Trawling aroung the various 
sources somehow does not lead me to it. How can I execute an error prone 
function without stopping a script if it goes wrong ?

Thanks in advance,
Tolga


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
[[alternative HTML version deleted]]

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


Re: [R] How to: initialize, setValidity, copy-constructor

2009-07-09 Thread Martin Morgan
Hi Renaud --

Renaud Gaujoux ren...@mancala.cbio.uct.ac.za writes:

 Hello list,

 I'm having troubles setting up a basic calss hierarchy with S4.
 Here is a simplified schema of what I'd like to do:

 - Two classes: A and B that extends A
 - Ensure that the slots added by B are consistent with the slots of A
 - Let A initialize itself (I'm not supposed to know the internal
   cooking of A)
 - By default set the slots of B based on the slots that A initialized

 Another question is: what is the recommended way of implementing a
 copy-constructor in R?

 I know that all of this is easily done in C++. The constructor of each
 class is called recursively back-up to the root class. Validity checks
 can be performed after/during associated
 initialization. Copy-constructor are basics in C++.

 Here below is a piece of code that I thought would work (but it does
 not... therefore my post), what's wrong with it?
 I think the main issue is when is the validity check performed: why is
 it performed before the end of the initialize method?

loosely, new(B, ...) calls initialize(prototypeOfB, ...).
initialize,B-method uses callNextMethod(), so initialize,A-method sees
as .Object the value prototypeOfB.  If initialize,A-method is
well-behaved, it'll call initialize,ANY-method, which also sees
prototypeOfB. You'll see that, when the ... argument is not empty

  getMethod(initialize, ANY)

eventually calls validObject, in this case on prototypeOfB. Hence what
you are seeing, an 'early' check on the validity of B.

There are many creative ways around this in initialize,B-method, e.g.,
assigning B slots before callNextMethod(), or explicitly creating a
new instance of A from appropriate supplied arguments (in
initialize,B-method, name arguments meant to initialize B slots and
pass ... to the A constructor) and using that to initialize B, etc.

The approach I find most palatable (not meant to be real code) is to
have a constructor

  B - function(x, y, z, ...) {
 # do all the work to map x, y, z into slots of A, B (or an
 # instance of A and slots of B), then...
 new(B, a=, b=, ...) # or new(B, instanceOfA, b=, ...)
  }

and avoid writing explicit initialize methods. 

Oddly enough, this solution leads to a copy constructor, viz.,

  initialize(instanceOfB, b=)

I'm not sure that this really does anything more than move the
'pattern' from the initialize method to the constructor.

Martin

 Thank you for your help.
 Renaud

 # define class A with a single numeric slot
 setClass('A', representation(a='numeric'))

 # define class B that extends class A, adding another numeric slot
 setClass('B', representation('A', b='numeric'))
 # we want for example to ensure that slots a and b have the same length
 setValidity('B',
 function(object){
 cat(*** B::validate ***\n)
 print(object)
 cat(*\n)
 if( length(obj...@a) != length(obj...@b) ) return('Inconsistent lengths')
 TRUE
 }
 )
 # As a default behaviour if b is not provided, we want slot b to be
   equal to slot a
 setMethod('initialize', 'B',
 function(.Object, b, ...){
 cat(*** B::initialize ***\n)
 print(.Object)

 # Let the superclass (A) initialize itself via callNextMethod
 # I thought it would only do that: initialize and optionnaly validate
   the class A part of the object
 #But it generates an ERROR: apparently it calls the validation method of B,
 # before leaving me a chance to set slot b to a valid value
 .Object - callNextMethod(.Object, ...)

 # now deal with the class B part of the object
 cat(*** Test missing b ***\n)
 if( missing(b) ){
 cat(*** b is MISSING ***\n)
 b - .obj...@a
 }

 # set slot b
 .obj...@b - b

 .Object
 }
 )

 ### Testing

 # empty A: OK
 aObj - new('A')
 aObj

 # class A with some data: OK
 aObj - new('A', a=c(1,2) )
 aObj

 # empty B: OK
 bObj - new('B')
 bObj

 # initialize B setting the slot of class A: ERROR
 bObj - new('B', a=c(1,2))

 # initialize B setting only the slot class B: OK!! Whereas it produces
   a non valid object.
 bObj - new('B', b=c(1,2))
 bObj

 # RESULTS:

   # empty A: OK
   aObj - new('A')
   aObj
 An object of class “A”
 Slot a:
 numeric(0)

  
   # class A with some data: OK
   aObj - new('A', a=c(1,2) )
   aObj
 An object of class “A”
 Slot a:
 [1] 1 2

  
   # empty B: OK
   bObj - new('B')
 *** B::initialize ***
 An object of class “B”
 Slot b:
 numeric(0)

 Slot a:
 numeric(0)

 *** Test missing b ***
 *** b is MISSING ***
   bObj
 An object of class “B”
 Slot b:
 numeric(0)

 Slot a:
 numeric(0)

  
   # initialize B setting the slot of class A: ERROR
   bObj - new('B', a=c(1,2))
 *** B::initialize ***
 An object of class “B”
 Slot b:
 numeric(0)

 Slot a:
 numeric(0)

 *** B::validate ***
 An object of class “B”
 Slot b:
 numeric(0)

 Slot a:
 [1] 1 2

 *
 Error in validObject(.Object) :
 invalid class B object: Inconsistent lengths
  
   # initialize B setting only the slot class B: OK!! Whereas it
  creates a non valid object.
   bObj - new('B', 

Re: [R] R-help Digest, Vol 77, Issue 9

2009-07-09 Thread Lauri Nikkinen
Thanks, this worked!!!

nBooks - xl[[Workbooks]]$Count();
for (i in seq_len(nBooks))
xl[[Workbooks]]$item(i)$Close(SaveChanges=FALSE);

-L

2009/7/9 Bengoechea Bartolomé Enrique (SIES 73)
enrique.bengoec...@credit-suisse.com:
 Hi,

 This may be due to several reasons. That I can think about:

 1) Ensure you close *all* possibly open workbooks:

        nBooks - xl[[Workbooks]]$Count();
        for (i in seq_len(nBooks))
                xl[[Workbooks]]$item(i)$Close(SaveChanges=FALSE);

 2) The excel application reference does not seem to be really released until 
 the garbage collector runs. So this may help:

        xl$Quit();
        xl - NULL;
        gc();

 3) Ensure you don't have any hanging reference to the excel application 
 (sometimes from previous runs of your code that failed). If your code is 
 inside a function, wrap the code in point 1 and 2 on an on.exit() call to 
 ensure that excel is properly closed each time.


 Hope this helps.

 Enrique

 --

 Date: Wed, 8 Jul 2009 16:06:57 +0300
 From: Lauri Nikkinen lauri.nikki...@iki.fi
 Subject: [R] RDCOMClient: how to close Excel process?
 To: r-h...@stat.math.ethz.ch
 Message-ID:
        ba8c09910907080606n29b8a537uac5ba1788376f...@mail.gmail.com
 Content-Type: text/plain; charset=windows-1252

 Hi,

 I?m using R package RDCOMClient (http://www.omegahat.org/RDCOMClient/)
 to retrieve data from MS Excel workbook. I?m using the code below to
 count the number of sheets in the workbook and then loop the data from
 sheets in to a list.

 # R code ###
 library(gdata)
 library(RDCOMClient)

 xl - COMCreate(Excel.Application)
 sh - xl$Workbooks()$Open(normalizePath(sample_file.xls))$Sheets()$Count()

 DF.list - list()
 for (i in 1:sh) {
   DF.list[[i]] - read.xls(sample_file.xls, sheet=i,
 stringsAsFactors = FALSE)
   }
 ##

 COMCreate opens Excel process and it can be seen from Windows Task
 Manager. When I try to open sample_file.xls in Excel, it just flashes
 in the screen and shuts down. When I kill (via task manager) the Excel
 process COMCreate started, sample_file.xls will open normally.

 The question is, how can I close the Excel process COMCreate started.
 xl$Close() doesn?t seem to work. The same problem have been presented
 in this post to R-help:
 http://tolstoy.newcastle.edu.au/R/help/06/04/25990.html

 -L



 --


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


[R] more than one mathematical annotation into a legend

2009-07-09 Thread Thomas Roth (geb. Kaliwe)

Dear members,

Is there a way to put more than one mathematical annotation into a 
legend together with a calculated value?


x = 2
plot(1:10)

#Works
legend(8, 8,  substitute(t[m] == x))

#does not work
legend(4,4, c(substitute(t[m] == x), substitute(t[n] == x)))

Thanks


Thomas Roth

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] executing an error prone function without stopping a script

2009-07-09 Thread Tolga I Uzuner
Dear R Users,

I've used this a long time ago but have forgotten. Trawling aroung the various 
sources somehow does not lead me to it. How can I execute an error prone 
function without stopping a script if it goes wrong ?

Thanks in advance,
Tolga


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
[[alternative HTML version deleted]]

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


Re: [R] Creating and Using Objects in R

2009-07-09 Thread Gabor Grothendieck
Here it is done without S3.  Note that UseMethod
is basically just an alternative to an if statement.
Perhaps this makes it more understandable.

x1 - list(x = 1, y = 2)
class(x1) - xypoint
x2 - list(r = 1, theta = pi/2)
class(x2) - rthetapoint

XPOS - function(x) {
if (inherits(x, xypoint)) xpos.xypoint(x)
else if (inherits(x, rthetapoint)) xpos.rthetapoint(x)
else stop(Cannot find appropriate class)
}

XPOS(x1) # without S3
xpos(x1) # using S3

XPOS(x2) # without S3
xpos(x2) # using S3


On Thu, Jul 9, 2009 at 12:24 PM, Lorenzo Isellalorenzo.ise...@gmail.com wrote:
 Dear All,
 I am not very into object-oriented programming, but I would like to learn
 the ropes for some R applications.
 Quoting from the online R language definition (paragraph 5.1)

 Consider the following simple example. A point in two-dimensional
 Euclidean space can be specified by its Cartesian (x-y) or polar (r-theta)
 coordinates. Hence, to store information about the location of the point, we
 could define two classes, |xypoint| and |rthetapoint|. All the `xypoint'
 data structures are lists with an x-component and a y-component. All
 `rthetapoint' objects are lists with an r-component and a theta-component.

 Now, suppose we want to get the x-position from either type of object.
 This can easily be achieved through generic functions. We define the generic
 function |xpos| as follows.

     xpos - function(x, ...)
         UseMethod(xpos)

 Now we can define methods:

     xpos.xypoint - function(x) x$x
     xpos.rthetapoint - function(x) x$r * cos(x$theta)

 The user simply calls the function |xpos| with either representation as
 the argument. The internal dispatching method finds the class of the object
 and calls the appropriate methods.

 I am a bit confused: when calling e.g. xpos.rthetapoint, I understand that x
 contains the polar representation of a point, so x=(r,theta), but  how do I
 exactly  write it to pass it to xpos.rthetapoint? I have made several
 attempts, but so far none of them works, so I may have misunderstood
 something.
 Many thanks

 Lorenzo

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


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


Re: [R] Tex fonts in R plots

2009-07-09 Thread cls59


KARAVASILIS GEORGE wrote:
 
 Hello, R users.
 I would like to display the font of Math Mode of MikTex 2.3, WinEdt 5.4 
 in R plots, e.g. in xlab, ylab or legend.
 How can I do that?
 Thank you in advance.
 
 

A colleague and I have developed a package called pgfSweave that turns R
plots created inside a Sweave document into code that can be interpreted by
PGF/TikZ package for LaTeX. The end result of this process is that the text
in your figures are typeset with the same fonts used in the rest of your TeX
document.

The package can be found at: 

http://r-forge.r-project.org/projects/pgfsweave/
 
It has been used by the authors to typeset academic papers on windows and
produces good results. However we are still classifying it as an alpha
product because it has not been tested extensively.

Currently the underlying utility that translates R graphics into PGF form is
the java utility eps2pgf which may be found at:

http://sourceforge.net/projects/eps2pgf/

You may be interested in using this utility by it's self if you just want to
prep graphics for LaTeX and don't want to use Sweave. Simply create your
graphs in R using the eps() driver and process them using eps2pgf. 

eps2pgf has some drawbacks- it takes a few seconds to translate a graph and
certain R graphics commands, such as setting text size using cex, are not
respected.

Good luck!

-Charlie


-
Charlie Sharpsteen
Undergraduate
Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: 
http://www.nabble.com/Tex-fonts-in-R-plots-tp24382492p24414007.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] executing an error prone function without stopping a script

2009-07-09 Thread cls59



TU wrote:
 
 Dear R Users,
 
 I've used this a long time ago but have forgotten. Trawling aroung the
 various sources somehow does not lead me to it. How can I execute an error
 prone function without stopping a script if it goes wrong ?
 
 Thanks in advance,
 Tolga
 
 


See ?try

Basically, wrapping the function call in the try() function will make it so
that errors do not halt your script:

result - try( function( args ) )

You can then handle errors in your own way:

if( class(result) == 'try-error' ){
  # Error handling stuff.
}

-
Charlie Sharpsteen
Undergraduate
Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: 
http://www.nabble.com/executing-an-error-prone-function-without-stopping-a-script-tp24413760p24414337.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] X-axis labels not displayed when changing ylim

2009-07-09 Thread Sarah Bonnin

Dear R users,

I am encountering a x axis labeling problem on quite basic plots...
I use the following code which displays the labels on the x-axis with a 
45 degrees angle:


p - plot(myobject1, type=b, col=red,cex=1, lwd=2, axes=FALSE, 
ann=FALSE, ylim=c(0,70))

title(main=title, font.main=4)
axis(side=1, lab=F)
text(axTicks(1), par(usr)[3] - 2, srt=45, adj=1,labels=mylabels,xpd=T, 
cex=0.8, font=2)

axis(side=2, las=1, cex.axis=0.8, font=2)

I set up the ylim from 0 to 70 for plotting that object myobject1 - 
works well.
However, when i try to use the same script with another set of data 
myobject2 (same number of points, same labels, but different 
values...) that ranges from 0 to 2 (ylim changed to c(0,2)), the 
labels on the x axis disappear...
When i try to run the same lines for myobject2 but putting the ylim 
higher c(0,50), the labels on the x axis are displayed.


I picked up some pieces of code here and there so i may do an obvious 
mistake but cannot figure out what it is! I tried to modify the text 
parameters adj or par(usr)..., unsuccessfully...
I hope i made it clear, there must be a scaling problem that i really 
don't get...

I run R 2.8.0 under Windows XP Pro.

Thank you for your help!

Sarah

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


Re: [R] more than one mathematical annotation into a legend

2009-07-09 Thread Zhiliang Ma
On Thu, Jul 9, 2009 at 9:39 AM, Thomas Roth (geb.
Kaliwe)hamstersqu...@web.de wrote:
try this:

legend(4,4, expression(t[m] == x, t[n] == x))

cheers,
Zhiliang

 Dear members,

 Is there a way to put more than one mathematical annotation into a legend
 together with a calculated value?

 x = 2
 plot(1:10)

 #Works
 legend(8, 8,  substitute(t[m] == x))

 #does not work
 legend(4,4, c(substitute(t[m] == x), substitute(t[n] == x)))

 Thanks


 Thomas Roth

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Compiling R-2.9.1 on Mac OS X 10.4

2009-07-09 Thread Sinha, Raktim, DFCI
Hello,

 

I am trying to compile R-2.9.1 on Mac OS-X 10.4 using --enable-R-shlib.

 

I am not comfortable with Mac/Linux environments and trying to follow the
instructions from CRAN site to every detail.

The Mac OS did not have a gcc (gcc -version did not work). So I did the
following:

 

## For gcc 4.2 and Fortran 4.2.4 Compilers

Download gcc-4.2-5566-darwin8-all.tar.gz from
http://r.research.att.com/tools/#gcc42

unpacked using: sudo tar fvxz gcc-4.2-5566-darwin8-all.tar.gz -C /

Made gcc-4.2 default: sudo link gcc-4.2 gcc

Made g++-4.2 default: sudo link g++-4.2 g++ 

 

I downloaded the source and tried compiling using:

./configure --with-blas='-framework vecLib' --with-lapack --with-ICU \

   --with-aqua --enable-R-framework --enable-R-shlib

 

Got the following error:

Configure: error: C compiler cannot create executables

 

I have attached the compile.log file.

I would really appreciate some help.

 

Raktim

Bioinformatics Engineer

DFCI, Harvard Med School

Boston

 



The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Issues with file.info?

2009-07-09 Thread Jason Rupert

Are there any tricks associated with file.info? 

I just tried it on a directory folder and it returned NA for all fields for all 
files.  I tried it on a different folder with different files and it still 
returned NA.  

I tried it on a specific file and it returned all the proper info correctly. 

Just wondering if there are any tricks I've overlooked.

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


Re: [R] Compiling R-2.9.1 on Mac OS X 10.4

2009-07-09 Thread Marc Schwartz

On Jul 9, 2009, at 12:12 PM, Sinha, Raktim, DFCI wrote:


Hello,



I am trying to compile R-2.9.1 on Mac OS-X 10.4 using --enable-R- 
shlib.




I am not comfortable with Mac/Linux environments and trying to  
follow the

instructions from CRAN site to every detail.

The Mac OS did not have a gcc (gcc -version did not work). So I did  
the

following:



## For gcc 4.2 and Fortran 4.2.4 Compilers

Download gcc-4.2-5566-darwin8-all.tar.gz from
http://r.research.att.com/tools/#gcc42

unpacked using: sudo tar fvxz gcc-4.2-5566-darwin8-all.tar.gz -C /

Made gcc-4.2 default: sudo link gcc-4.2 gcc

Made g++-4.2 default: sudo link g++-4.2 g++



I downloaded the source and tried compiling using:

./configure --with-blas='-framework vecLib' --with-lapack --with-ICU \

  --with-aqua --enable-R-framework --enable-R-shlib



Got the following error:

Configure: error: C compiler cannot create executables



I have attached the compile.log file.

I would really appreciate some help.



The log file did not survive the list spam filters, but is there a  
particular reason that you are compiling from source?


A universal binary installation package (which is built using --enable- 
R-shlib) is available from a CRAN mirror such as:


  http://cran.us.r-project.org/

You might want to review the OSX FAQ as well:

  http://cran.us.r-project.org/bin/macosx/RMacOSX-FAQ.html

If you really need to build from source, which is not for the feint of  
heart, begin by reviewing section 2 of the FAQ.


HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] 'scan' in a script?

2009-07-09 Thread Mark Knecht
When I use the scan function in the Rgui console it works as expected.
However it seems that when I put the same command in a script file it
doesn't wait for input.

Is there an option to scan to make it wait for input when used in a
script? Or is there possibly a different function that will do in a
script the same sort of thing as scan does in the console?

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] Substituting numerical values using `apply'

2009-07-09 Thread Santiago Olivella
Thank you all for your help.

SO.

Henrique Dallazuanna wrote:
 Try this:

 sapply(names(DF), function(n)ifelse(DF[,n] %in% c(1, 2), n, NA))

 Where DF is your data.frame

 On Wed, Jul 8, 2009 at 5:25 PM, Olivella olive...@wustl.edu 
 mailto:olive...@wustl.edu wrote:


 Hello,

 I wish to perform a substitution of certain numerical values in a data
 matrix with the corresponding column name. For instance, if I have
 a data
 matrix
 V1  V2  V3
 201
 012
 150
 500

 I want to substitute the `1' and the `2' for the corresponding
 column name,
 and make everything else `NA' like this
 V1V2V3
 V1NAV3
 NAV2V3
 V1NANA
 NANANA

 I have done this using an explicit `for' loop, but it takes a
 really long
 time to finish. Is there any way I can do this using `apply' or
 some form of
 implicit looping?

 Thank you for your help,

 SO
 --
 View this message in context:
 
 http://www.nabble.com/Substituting-numerical-values-using-%60apply%27-tp24398687p24398687.html
 Sent from the R help mailing list archive at Nabble.com.

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

-- 
-
Santiago Olivella
Ph.D. Program in Political Science
Washington University in St. Louis
solivella.wustl.edu


[[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] Lattice xyplot: same scales within one factor

2009-07-09 Thread Orion Buske
I am using R 2.8.1 and lattice to produce xyplots conditioned on
two factors. What I would like is to have the scales be free between values
of one factor, but some within. Thus, in the example:

xyplot(mpg ~ disp | factor(gear) + factor(cyl), mtcars,
scales=list(x=list(relation=free)))

rather than having the x scales be free within a gear as well, I want it to
be the same for the gear, but free between cyl (and thus only have x scales
below the bottom panels with no scales or white space in the middle between
panels).

Any help would be greatly appreciated

-Orion

[[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] Compiling R-2.9.1 on Mac OS X 10.4

2009-07-09 Thread Don MacQueen
I used to build from source on Mac OS X, but I stopped when I found I 
could do everything I needed to do from the binary on CRAN. That 
includes building my own packages that use fortran, or building the 
one or two CRAN packages that use C code and do not have Mac binaries 
on CRAN.


In addition to which, if you were to install the Mac binary from 
CRAN, there's an optional install of gcc, and that might even be an 
easier way to get a gcc on your machine. You can still build R from 
sources separately, even if you've already installed the binary.


For further help on building from source, I'd suggest asking again on 
R-sig-Mac.


-Don

At 1:12 PM -0400 7/9/09, Sinha, Raktim, DFCI wrote:

Hello,



I am trying to compile R-2.9.1 on Mac OS-X 10.4 using --enable-R-shlib.



I am not comfortable with Mac/Linux environments and trying to follow the
instructions from CRAN site to every detail.

The Mac OS did not have a gcc (gcc -version did not work). So I did the
following:



## For gcc 4.2 and Fortran 4.2.4 Compilers

Download gcc-4.2-5566-darwin8-all.tar.gz from
http://*r.research.att.com/tools/#gcc42

unpacked using: sudo tar fvxz gcc-4.2-5566-darwin8-all.tar.gz -C /

Made gcc-4.2 default: sudo link gcc-4.2 gcc

Made g++-4.2 default: sudo link g++-4.2 g++



I downloaded the source and tried compiling using:

./configure --with-blas='-framework vecLib' --with-lapack --with-ICU \

   --with-aqua --enable-R-framework --enable-R-shlib



Got the following error:

Configure: error: C compiler cannot create executables



I have attached the compile.log file.

I would really appreciate some help.



Raktim

Bioinformatics Engineer

DFCI, Harvard Med School

Boston





The information in this e-mail is intended only for the...{{dropped:26}}


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


Re: [R] Reading from Google Docs

2009-07-09 Thread Johannes Huesing
Gabor Grothendieck ggrothendi...@gmail.com [Wed, Jul 08, 2009 at 10:31:30PM 
CEST]:
[...]
 
     [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible
  code.
 
 
     [[alternative HTML version deleted]]
 
 
 
 
 
 
  
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
      [[alternative HTML version deleted]]
 
 
 
 
 
  
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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.

Do you think more people will pay attention when you repeat this
over and over?

-- 
Johannes Hüsing   There is something fascinating about science. 
  One gets such wholesale returns of conjecture 
mailto:johan...@huesing.name  from such a trifling investment of fact.  
  
http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi)

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


Re: [R] naming of columns in R dataframe consisting of mixed data (alphanumeric and numeric)

2009-07-09 Thread Etienne B. Racine



Mary A. Marion-2 wrote:
 
 Hello,
 
 I have an r function that creates the following dataframe tresults2.
 Notice that column 1 does not have a column heading.
 
 Tresults2:
  [,1]
 estparam 18.0
 nullval  20.0
 . . .
 ciWidth   2.04622
 HalfInterval  1.02311
 
 pertinent code:
 results-cbind( estparam, nullval, t, pv_left, pv_right, pv_two_t, 
 estse, df,  cc, tbox, llim, ulim, ciWidth, HalfInterval)
 tresults-round((results),5)
 tresults2-data.frame(t(tresults))
 names(tresults2)-c(Statistic , Value)
 tresults2
 
 ===
 After transposing my dataframe tresults2 consists of 2 columns.  
 Col1=alphanumeric data (this really is a variable name) and
 col2=numeric data (this is value of varaiable).
 
 how do I name columns when columns are different (alphanumeric and
 numeric)
 to avoid the following error:
 
 Error in names(tresults2) - c(Statistic , Value) :
   'names' attribute [2] must be the same length as the vector [1]
 
You tried to give a name to a column that do not exist (the second one you
called value). You can check that using str(tresults2).
The name of the columns should not (well, I don't see how) interfere with
the type (or class) they contain.

You can create a Value column by using tresults2$Value - your_value



 
 Am I to use c( , ) or list( , ) with a dataframe?
 
You picked the right one ( c() )... to give the names, I guess this is what
you were asking.

Cheers,
Etienne


 Thank you for your help.
 Sincerely,
 Mary A. Marion
 

-- 
View this message in context: 
http://www.nabble.com/naming-of-columns-in-R-dataframe-consisting-of-mixed-data-%28alphanumeric-and-numeric%29-tp24411614p24416676.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] 'scan' in a script?

2009-07-09 Thread jim holtman
Exactly how are you using it?  How you executing your script?  Are you
using cut/paste or source?  Have you tried 'readline'?

More details on what you mean by it does not work as expected.

On Thu, Jul 9, 2009 at 2:24 PM, Mark Knechtmarkkne...@gmail.com wrote:
 When I use the scan function in the Rgui console it works as expected.
 However it seems that when I put the same command in a script file it
 doesn't wait for input.

 Is there an option to scan to make it wait for input when used in a
 script? Or is there possibly a different function that will do in a
 script the same sort of thing as scan does in the console?

 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.




-- 
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] Issues with file.info?

2009-07-09 Thread jim holtman
Works fine for me on 2.9.1:

 file.info('/jph')
 size isdir mode   mtime   ctime
atime exe
/jph0  TRUE  777 2009-06-29 15:15:13 2008-02-14 09:31:26
2009-07-09 15:57:04  no




On Thu, Jul 9, 2009 at 2:02 PM, Jason Rupertjasonkrup...@yahoo.com wrote:

 Are there any tricks associated with file.info?

 I just tried it on a directory folder and it returned NA for all fields for 
 all files.  I tried it on a different folder with different files and it 
 still returned NA.

 I tried it on a specific file and it returned all the proper info correctly.

 Just wondering if there are any tricks I've overlooked.

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

2009-07-09 Thread Rolf Turner


On 10/07/2009, at 2:55 AM, Gaurav Kumar wrote:


Hi,

I'm new to R and would like to know, how one can populate the list  
with array data.
I'm reading a tab separated table in R. The data in the table looks  
something like this.


#Table Data
CompABC
Extracellular103268535759
Nucleus4560347783442744

#R code
myData - read.table(table.data,
header=T,
sep=\t,
comment.char = #
);
inp - scan(table.data, what=list(comp= , A=, B=, C=));
n - c(0:length(inp$comp));
myList=list();
for(i in n-1)
{
obj -c(as.numeric(myData$A[i]),as.numeric(myData$B 
[i]),as.numeric(myData$C[i]));


}

Need help to know if there is any function in R to push obj to myList


(a) You apparently ``replied'' to an R-help digest, and included  
megabytes
of totally irrelevant material in your post.  It took me several  
minutes to delete it.


STEP ONE:  LEARN HOW TO USE EMAIL!!!

(b) Do the following:

myList - list();
for(i in n-1)
{
myList[[i]] -c(as.numeric(myData$A[i]),as.numeric(myData$B 
[i]),as.numeric(myData$C[i]));


}

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.


Re: [R] Issues with file.info?

2009-07-09 Thread Jason Rupert

Issue was with an entire directory/folder or list of files in a directory.  It 
seemed to work fine for a single file or being sent a single file/folder.  

I will try to generate some example code to demonstrate the problem. 

Thanks again for all the replies. 



--- On Thu, 7/9/09, jim holtman jholt...@gmail.com wrote:

 From: jim holtman jholt...@gmail.com
 Subject: Re: [R] Issues with file.info?
 To: Jason Rupert jasonkrup...@yahoo.com
 Cc: R-help@r-project.org
 Date: Thursday, July 9, 2009, 3:04 PM
 Works fine for me on 2.9.1:
 
  file.info('/jph')
      size isdir mode   
            mtime 
              ctime
     atime exe
 /jph    0  TRUE  777 2009-06-29
 15:15:13 2008-02-14 09:31:26
 2009-07-09 15:57:04  no
 
 
 
 
 On Thu, Jul 9, 2009 at 2:02 PM, Jason Rupertjasonkrup...@yahoo.com
 wrote:
 
  Are there any tricks associated with file.info?
 
  I just tried it on a directory folder and it returned
 NA for all fields for all files.  I tried it on a different
 folder with different files and it still returned NA.
 
  I tried it on a specific file and it returned all the
 proper info correctly.
 
  Just wondering if there are any tricks I've
 overlooked.
 
  __
  R-help@r-project.org
 mailing list
  https://stat.ethz.ch/mailman/listinfo/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] Issues with file.info?

2009-07-09 Thread Rolf Turner


On 10/07/2009, at 6:02 AM, Jason Rupert wrote:



Are there any tricks associated with file.info?

I just tried it on a directory folder and it returned NA for all  
fields for all files.  I tried it on a different folder with  
different files and it still returned NA.


I tried it on a specific file and it returned all the proper info  
correctly.


Just wondering if there are any tricks I've overlooked.


Yes.  You've overlooked the trick of telling us about the specifics of
your operating system, version of R, etc., and of showing exactly what
commands you ``tried'', i.e. of reading the Posting Guide.

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] Lattice xyplot: same scales within one factor

2009-07-09 Thread OB
I am using R 2.8.1 and lattice to produce xyplots conditioned on
two factors. What I would like is to have the scales be free between values
of one factor, but some within. Thus, in this example,

xyplot(mpg ~ disp | factor(gear) + factor(cyl), mtcars,
    scales=list(x=list(relation=free)))

rather than having the x scales be free within a gear as well, I want it to
be the same for the gear, but free between cyl (and thus only have x scales
below the bottom panels with no scales or white space in the middle between
panels).

Any help would be greatly appreciated!

-Orion

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


Re: [R] X-axis labels not displayed when changing ylim

2009-07-09 Thread Patrick Connolly
On Thu, 09-Jul-2009 at 05:36PM +0200, Sarah Bonnin wrote:

 Dear R users,

 I am encountering a x axis labeling problem on quite basic plots...
 I use the following code which displays the labels on the x-axis with a  
 45 degrees angle:

 p - plot(myobject1, type=b, col=red,cex=1, lwd=2, axes=FALSE,  
 ann=FALSE, ylim=c(0,70))
 title(main=title, font.main=4)
 axis(side=1, lab=F)
 text(axTicks(1), par(usr)[3] - 2, srt=45, adj=1,labels=mylabels,xpd=T,  

I think this part is what's not transferable to a smaller range of
y-values.

par(usr)[3] will be much smaller when ylim goes to only 2 instead of
70.  Subtract 2 from that, and you have a very different kettle of
fish.

Without knowing anything about myobject1 and myobject2 I could be
completely ooff the mark, of cours.

HTH





 cex=0.8, font=2)
 axis(side=2, las=1, cex.axis=0.8, font=2)

 I set up the ylim from 0 to 70 for plotting that object myobject1 -  
 works well.
 However, when i try to use the same script with another set of data  
 myobject2 (same number of points, same labels, but different  
 values...) that ranges from 0 to 2 (ylim changed to c(0,2)), the  
 labels on the x axis disappear...
 When i try to run the same lines for myobject2 but putting the ylim  
 higher c(0,50), the labels on the x axis are displayed.

 I picked up some pieces of code here and there so i may do an obvious  
 mistake but cannot figure out what it is! I tried to modify the text  
 parameters adj or par(usr)..., unsuccessfully...
 I hope i made it clear, there must be a scaling problem that i really  
 don't get...
 I run R 2.8.0 under Windows XP Pro.

 Thank you for your help!

 Sarah

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

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

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


Re: [R] 'scan' in a script?

2009-07-09 Thread Mark Knecht
Jim,
   In Rgui there is a feature to create a new script so I open that
and get a blank editor. I put these commands in the script

MyNames = scan(what=)
MyNames

   Whether I ask Rgui to run the whole script as a script - not
sourced - it runs the first command, doesn't wait for input and then
runs the second command. I see

 MyNames
character(0)


   If I right click the first line and ask it to run the selection or
line then R waits for the input.

   If I source the file then the opposite happens. It does the scan
correctly, waiting for me to make entries. When I finish it doesn't
print what's in MyNames, as shown here where I typed in happy sad test
go and hit enter.

 source(C:\\Users\\Mark\\Documents\\R\\Test Cases\\scan from script.R)
1: happy sad test go
5:
Read 4 items


   Possibly (probably!) this is a misunderstanding on my part, but
it's something I need to start looking at as the reason for me
checking out R at all was as a potential way to develop a complete
program, as opposed to writing it in C, so I need to start looking at
how to give it input (file names, directory paths, user requests)
other than changing source code.

   I hope this is clear enough and I appreciate your inputs.

Cheers,
Mark

On Thu, Jul 9, 2009 at 1:02 PM, jim holtmanjholt...@gmail.com wrote:
 Exactly how are you using it?  How you executing your script?  Are you
 using cut/paste or source?  Have you tried 'readline'?

 More details on what you mean by it does not work as expected.

 On Thu, Jul 9, 2009 at 2:24 PM, Mark Knechtmarkkne...@gmail.com wrote:
 When I use the scan function in the Rgui console it works as expected.
 However it seems that when I put the same command in a script file it
 doesn't wait for input.

 Is there an option to scan to make it wait for input when used in a
 script? Or is there possibly a different function that will do in a
 script the same sort of thing as scan does in the console?

 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.




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

 What is the problem that you are trying to solve?


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


[R] Strange t-test error: grouping factor must have exactly 2 levels while it does...

2009-07-09 Thread Tymek W
Hi,

Could anyone tell me what is wrong:

 length(unique(mydata$myvariable))
[1] 2


and in t-test:

(...)
Error in t.test.formula(othervariable ~ myvariable, mydata) :
  grouping factor must have exactly 2 levels


I re-checked the code and still don't get what is wrong.

Moreover, there is some strange behavior:

/1 It seems that the error is vulnerable to NA'a, because it affects
some variables in data set with NA's and doesn't affect same ones in
dataset with NA's removed.

/2 It seems it works differently with different ways of using
variables in t.test:

eg. it hapends here: t.test(x~y, dataset) and does not here:
t.test(dataset[['x']]~dataset[['y']])

Does anyone have any ideas?

Greetz,
Timo

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


[R] How to combine two rows (in a dataframe) into a third row?

2009-07-09 Thread Mark Na
Dear R-helpers,

I have two rows in my dataframe:

IDVALUE
1A10
1B15

and I would like to combine these two rows into a single (new) row in my
dataframe:

IDVALUE
125

...simply by specifying a new value for ID and summing the two VALUES.

I have been trying to do this with with rbind, but it's not working.

I'd appreciate any pointers.

Thanks, Mark Na

[[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] SSOAP failure

2009-07-09 Thread nermin sarlak

Hi,

 I’m using R package SSOAP to retrieve data from web services. I’m using the 
code below to
 
   # R code ###
library(SSOAP)
 then I call the nwis.R which exists in SSOAP example folder. However system 
gives me following errors:

 
Error in parse (text=paste(text, collapse=”\n”)):
Unexpected input in “function (x’…,obj=new(‘”
 
I could not understand why I get this error. I am very appreciate anybody help 
me. 
nermin

 

_


[[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] datadist() in Design library

2009-07-09 Thread array chip

Hi I got an error message using datadist() from Design package:

 library(Design,T)
 dd - datadist(beta.final)  
 options(datadist=dd) 
 lrm(Disease ~ gsct+apcct+rarct, x=TRUE, y=TRUE)
Error in eval(expr, envir, enclos) : object Disease not found

All variables inclduing response variable Disease are in the data frame 
beta.final, why then Disease can not be found? I thought with datadist(), 
all variables are presented to the model fitting functions. maybe I am wrong?

thanks

John

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


Re: [R] Executing an error prone function without stopping a script

2009-07-09 Thread Duncan Murdoch

Tolga I Uzuner wrote:

Dear R Users,

I've used this a long time ago but have forgotten. Trawling aroung the various 
sources somehow does not lead me to it. How can I execute an error prone 
function without stopping a script if it goes wrong ?

  


See ?try.

Duncan Murdoch

Thanks in advance,
Tolga


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
	[[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] Stratified data summaries

2009-07-09 Thread Hayes, Rachel M
Hi All,

 

I'm trying to automate a data summary using summary or describe from the
HMisc package.  I want to stratify my data set by patient_type.  I was
hoping to do something like:

 

Describe(myDataFrame ~ patient_type)

 

I can create data subsets and run the describe function one at a time,
but there's got to be a better way.  Any suggestions?

 

Rachel


[[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] datadist() in Design library

2009-07-09 Thread Jorge Ivan Velez
Dear John,
Have you tried it specifying the 'data' argument as suggested in lrm help?

Try this:

 lrm(Disease ~ gsct + apcct + rarct,  data = beta.final, x = TRUE,  y = TRUE
)

HTH,

Jorge


On Thu, Jul 9, 2009 at 6:46 PM, array chip arrayprof...@yahoo.com wrote:


 Hi I got an error message using datadist() from Design package:

  library(Design,T)
  dd - datadist(beta.final)
  options(datadist=dd)
  lrm(Disease ~ gsct+apcct+rarct, x=TRUE, y=TRUE)
 Error in eval(expr, envir, enclos) : object Disease not found

 All variables inclduing response variable Disease are in the data frame
 beta.final, why then Disease can not be found? I thought with
 datadist(), all variables are presented to the model fitting functions.
 maybe I am wrong?

 thanks

 John

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] How to combine two rows (in a dataframe) into a third row?

2009-07-09 Thread Peter Alspach
Tena koe Mark

?tapply

with the index argument some suitable substring of your ID column.

HTH 

Peter Alspach 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Mark Na
 Sent: Friday, 10 July 2009 10:28 a.m.
 To: r-help@r-project.org
 Subject: [R] How to combine two rows (in a dataframe) into a 
 third row?
 
 Dear R-helpers,
 
 I have two rows in my dataframe:
 
 IDVALUE
 1A10
 1B15
 
 and I would like to combine these two rows into a single 
 (new) row in my
 dataframe:
 
 IDVALUE
 125
 
 ...simply by specifying a new value for ID and summing the two VALUES.
 
 I have been trying to do this with with rbind, but it's not working.
 
 I'd appreciate any pointers.
 
 Thanks, Mark Na
 
   [[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.
 

The contents of this e-mail are confidential and may be subject to legal 
privilege.
 If you are not the intended recipient you must not use, disseminate, 
distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received 
this
 e-mail in error, please notify the sender and delete all material pertaining 
to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the 
individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] validate() in Design library

2009-07-09 Thread array chip

Hi, another question about validate() in Design library. The arugment B of 
this function is number of repetition for method=bootstrap, which is easy to 
understand; but for method=crossvalidation, B is the number of groups of 
omitted observations. This is confusing, I don't understand what it means. 
Let's say 5-fold cross validation, all samples are divided into 5 groups of 
equal number of samples, 4 groups will be used as training and the model 
developed there will be tested in the 1 group left-over. And the process 
circulate for all 5 groups. What does the B argument mean in this example? 
B=5? or B=1 because 1 group of samples omitted from model development?

Thanks

Yi

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


Re: [R] datadist() in Design library

2009-07-09 Thread array chip

Dear Jorge, Yes, with data=beta.final in the lrm(), it worked. But I thought 
one of the reasons for datadist() is to make it unnecessary to specify the data 
frame in the lrm(). Maybe I am completely wrong here.

Thanks

John

--- On Thu, 7/9/09, Jorge Ivan Velez jorgeivanve...@gmail.com wrote:

 From: Jorge Ivan Velez jorgeivanve...@gmail.com
 Subject: Re: [R] datadist() in Design library
 To: array chip arrayprof...@yahoo.com
 Cc: R mailing list r-help@r-project.org
 Date: Thursday, July 9, 2009, 6:55 PM
 Dear John,
 Have you tried it specifying the 'data'
 argument as suggested in lrm help?
 Try this:
  lrm(Disease ~ gsct +
 apcct + rarct,  data = beta.final, x
 = TRUE,  y = TRUE)
 
 
 HTH,
 Jorge
 
 On Thu, Jul 9, 2009 at 6:46 PM,
 array chip arrayprof...@yahoo.com
 wrote:
 
 
 
 
 Hi I got an error message using datadist() from Design
 package:
 
 
 
  library(Design,T)
 
  dd - datadist(beta.final)
 
  options(datadist=dd)
 
  lrm(Disease ~ gsct+apcct+rarct, x=TRUE, y=TRUE)
 
 Error in eval(expr, envir, enclos) : object
 Disease not found
 
 
 
 All variables inclduing response variable
 Disease are in the data frame
 beta.final, why then Disease can not
 be found? I thought with datadist(), all variables are
 presented to the model fitting functions. maybe I am wrong?
 
 
 
 
 
 thanks
 
 
 
 John
 
 
 
 __
 
 R-help@r-project.org
 mailing list
 
 https://stat.ethz.ch/mailman/listinfo/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] 'scan' in a script?

2009-07-09 Thread Gabor Grothendieck
Check out:

http://tolstoy.newcastle.edu.au/R/help/03a/6855.html

On Thu, Jul 9, 2009 at 2:24 PM, Mark Knechtmarkkne...@gmail.com wrote:
 When I use the scan function in the Rgui console it works as expected.
 However it seems that when I put the same command in a script file it
 doesn't wait for input.

 Is there an option to scan to make it wait for input when used in a
 script? Or is there possibly a different function that will do in a
 script the same sort of thing as scan does in the console?

 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] Compiling R-2.9.1 on Mac OS X 10.4

2009-07-09 Thread Sinha, Raktim, DFCI
Matt  Don -- Thanks a lot for the comments. I think I need to figure out why
JRI is not recognizing the R installation as shared library build first, and go
from there.

I will try post back on r-sig-mac if I need too.
Best,
Raktim


-Original Message-
From: Marc Schwartz [mailto:marc_schwa...@me.com] 
Sent: Thursday, July 09, 2009 3:36 PM
To: Sinha, Raktim, DFCI
Subject: Re: [R] Compiling R-2.9.1 on Mac OS X 10.4


On Jul 9, 2009, at 2:08 PM, Sinha, Raktim, DFCI wrote:

 Hi Matt,

Marc

and please post follow ups back to the list. That way, you get a wider  
audience of folks who can reply to your query and you don't impose on  
specific individuals. To your own benefit, you are not waiting for one  
specific individual, who may not be available to respond to you. Keep  
in mind, we are all volunteers and most of us have full time jobs  
which will keep us busy.

As Don noted, there is also a specific R list for OSX related queries.  
More information here:

   https://stat.ethz.ch/mailman/listinfo/r-sig-mac

If the comments below are not helpful, please post follow ups there  
after subscribing.

 I am trying to compile JRI(http://www.rforge.net/JRI/) for Mac, Win  
  Linux
 which loads R dynamic library into Java.

 I had no problems doing it with Windows as the binary is built using
 --enable-R-shlib but for Linux and Mac its giving me errors.

 The specific errors of Mac:

 /Library/Frameworks/R.framework/Resources/bin/config: line 1: make:  
 command not
 found
 /Library/Frameworks/R.framework/Resources/bin/config: line 1: make:  
 command not
 found
 R was not built as a library
 configure: error: R was not compiled with --enable-R-shlib


If you are going to compile from source, the first thing that you need  
to do is to install the XCode Tools package, which is from Apple and  
available on the OSX install DVD or from Apple, all of which is noted  
in the OSX FAQ I pointed you to. XCode Tools provides the basic  
compiling environment and tools, with the exception of a FORTRAN  
compiler, which is available from the CRAN OSX Tools page as a binary.

I don't use JRI, but would suggest that you review the guidance in  
their FAQ, which points to certain system configuration things that  
you need to do to get it to work with R.

 *** You must have libR.so or equivalent in order to use JRI ***

 I Installed R-2.9.1 from the same location you pointed me too. Also  
 I was
 following the instructions from the same site you referred to, to  
 compile on
 Mac.

As noted, you should not have to compile R from source, as the result  
of your compilation will be essentially identical to the binary  
available from CRAN. If you are not comfortable with low level system  
operations, I would urge you to steer away from building R from  
source. Even for most Linux distributions, there are pre-compiled R  
binaries available via the normal package management tools and they  
too are typically built with R as a shared library.

You should be able to install JRI using the command noted on the JRI  
web site, after installing the R binary:

   install.packages(rJava)

There is an OSX binary available on the CRAN mirrors.


 Is there a way I get the log file across?

You can try to rename the file with a .txt extension or better, upload  
it someplace and post the URL to it, which would be a better option,  
so as not to send a large attachment to the list.

HTH,

Marc


 Thanks
 Raktim



 -Original Message-
 From: Marc Schwartz [mailto:marc_schwa...@me.com]
 Sent: Thursday, July 09, 2009 2:03 PM
 To: Sinha, Raktim, DFCI
 Cc: r-help@r-project.org
 Subject: Re: [R] Compiling R-2.9.1 on Mac OS X 10.4

 On Jul 9, 2009, at 12:12 PM, Sinha, Raktim, DFCI wrote:

 Hello,



 I am trying to compile R-2.9.1 on Mac OS-X 10.4 using --enable-R-
 shlib.



 I am not comfortable with Mac/Linux environments and trying to
 follow the
 instructions from CRAN site to every detail.

 The Mac OS did not have a gcc (gcc -version did not work). So I did
 the
 following:



 ## For gcc 4.2 and Fortran 4.2.4 Compilers

 Download gcc-4.2-5566-darwin8-all.tar.gz from
 http://r.research.att.com/tools/#gcc42

 unpacked using: sudo tar fvxz gcc-4.2-5566-darwin8-all.tar.gz -C /

 Made gcc-4.2 default: sudo link gcc-4.2 gcc

 Made g++-4.2 default: sudo link g++-4.2 g++



 I downloaded the source and tried compiling using:

 ./configure --with-blas='-framework vecLib' --with-lapack --with- 
 ICU \

  --with-aqua --enable-R-framework --enable-R-shlib



 Got the following error:

 Configure: error: C compiler cannot create executables



 I have attached the compile.log file.

 I would really appreciate some help.


 The log file did not survive the list spam filters, but is there a
 particular reason that you are compiling from source?

 A universal binary installation package (which is built using -- 
 enable-
 R-shlib) is available from a CRAN mirror such as:

   http://cran.us.r-project.org/

 You might want to 

Re: [R] Converting indices of a matrix subset

2009-07-09 Thread Nathan S. Watson-Haigh
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Steven,

This looks great. Thanks!

Nathan


Steve Lianoglou wrote:
 Hi Nathan,
 
 On Jul 8, 2009, at 10:20 PM, Nathan S. Watson-Haigh wrote:
 
 I have two matrices:

 m1 - matrix(1,4,4)
 m1
 [,1] [,2] [,3] [,4]
 [1,]1111
 [2,]1111
 [3,]1111
 [4,]1111

 m2 - matrix(0,3,3)
 diag(m2) - 1
 m2
 [,1] [,2] [,3]
 [1,]100
 [2,]010
 [3,]001

 I want to get indicies from m2 such that they match indicies as  
 though they came
 from the lower right of m1. Here's how things work:

 ind1 - which(m1 == 1)
 ind1
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
 ind2 - which(m2 == 1)
 ind2
 [1] 1 5 9


 I would like ind2 to be offset so they look like indicies from the  
 lower right
 of m1:
 ind2
 [1] 6 11 16
 
 
 I have written some utility functions I use often[1], and have  
 sub2ind function that works in a similar fashion to the MATLAB  
 function of the same name. It's somehow long and convoluted because  
 you can send in your arguments 12 different ways from sunday, so:
 
 sub2ind - function(x, y, nrow, ncol=NULL) {
## Returns a linear index for the (x,y) coordinates passed in.
if (is.matrix(x) || is.data.frame(x)) {
  stopifnot(ncol(x) == 2)
  if (!missing(y)) {
if (missing(nrow)) {
  nrow - y
} else {
  ncol - nrow
  nrow - y
}
  }
  y - x[,2]
  x - x[,1]
}
 
if (is.matrix(nrow)) {
  d - dim(nrow)
  nrow - d[1]
  ncol - d[2]
} else if (is.null(ncol)) {
  stop(Dimensions of matrix under-specified)
}
 
# Sanity check to ensure we got each var doing what it should be  
 doing
if (length(x) != length(y) || length(nrow) != 1 || length(ncol) !=  
 1) {
  stop(I'm confused)
}
 
((x - 1) + ((y - 1) * nrow)) + 1
 
 }
 
 R m1 - matrix(1,4,4)
 R m2 - matrix(0,3,3)
 R ind2 - which(m2 == 1, arr.ind=T) + 1
 R ind2
   row col
 [1,]   2   2
 [2,]   3   3
 [3,]   4   4
 
 R my.ind2 - sub2ind(ind2, nrow=4, ncol=4)
 # my.ind2 - sub2ind(ind2[,1], ind2[,2], 4, 4)
 # my.ind2 - sub2ind(ind2[,1], ind2[,2], m1)
 # my.ind2 - sub2ind(ind2, m1)
 R my.ind2
 [1]  6 11 16
 
 I think that gets you to where you want to be :-)
 
 -steve
 
 [1] They can be found here if your intersted, there isn't much  
 documentation there, but I'll fix that some time later :-)
 http://github.com/lianos/ARE.utils/tree/master
 
 --
 Steve Lianoglou
 Graduate Student: Physiology, Biophysics and Systems Biology
 Weill Medical College of Cornell University
 
 Contact Info: http://cbio.mskcc.org/~lianos
 
 
 


- --
- 
Dr. Nathan S. Watson-Haigh
OCE Post Doctoral Fellow
CSIRO Livestock Industries
Queensland Bioscience Precinct
St Lucia, QLD 4067
Australia

Tel: +61 (0)7 3214 2922
Fax: +61 (0)7 3214 2900
Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html
- 

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpWfCQACgkQ9gTv6QYzVL5zQQCffRi6SUNhtrfbMdBKadYSHGVe
00YAni90MgPiUOlBmcEq90FB/Zj/50Hz
=rZ4B
-END PGP SIGNATURE-

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


[R] Comparing Probit and Logit Coefficients Across Groups

2009-07-09 Thread OSTERFELD Marius
Hi,

I want to compare probit coefficients across groups with the method proposed by 
Allison (1999). The method corrects for unobserved heterogeneity in binary 
regression models. I can find only a SAS macro on the author's homepage 
(http://www.ssc.upenn.edu/~allison/glogit.sas). Has anyone of you ever 
implemented this method in R or knows how to integrate the macro?

Thank you very very much for your kind help and any tips!

Marius

__
Marius Osterfeld
Rue Francois Guillimann 5
CH-1700 Fribourg

Lehrstuhl für Makroökonomie,
Industrie- und Wachstumspolitik
Boulevard de Pérolles 90
CH-1700 Fribourg

Tel. (Büro): 0041 26 300 93 81
Natel: 0041 79 269 19 26
Tel. (CH): 0041 26 321 15 59
Tel. (D): 0049 2461 1859



[[alternative HTML version deleted]]

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


  1   2   >