[R] sql query over local tables

2007-08-28 Thread Jorge Cornejo Donoso
Hi i have to table with IDs in each one.

I want to make a join (as in sql) by the ID. Is any way to use the RODBC
package (or other) in local tables (not a access, mysql, sql, etc. )  and
made the join?

 

Thanks in advance

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] substituting elements in vector according to sample(unique(vector))

2007-08-28 Thread Arthur Wuster

Hello!

Assuming I have a vector, such as

v <- c(1,2,1,2,3,3,1)

This vector has three unique elements: 1, 2, and 3.

> unique(v)
[1] 1 2 3

If I shuffle this vector of unique elements, I get something like this:

> sample(unique(v))
[1] 3 2 1

In the vector v I started with, I would now like to replace each element in
unique(v) with the corresponding element (i.e. the element with the same
index) in sample(unique(v)).

In this case, the result should be something like c(3,2,3,2,1,1,3).

In particular, I would like to do this without a slow for loop.
I have tried things like sub(), but they don't seem to be appropriate.
Can anyone provide an elegant solution?

Thank you,

Arthur Wuster
Theoretical and Computational Biology
MRC Laboratory of Molecular Biology
Cambridge, UK

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


Re: [R] Nodes & edges with similarity matrix

2007-08-28 Thread Gabor Grothendieck
Try this:

# test data
mat <- structure(c(1, 0.325141612, 0.002109751, 0.250153137, 0.0223676,
1, 0.342654, 0.1987485, 0.9723831, 0.9644216, 1, 0.7391222, 0.394331,
0.5460461, 0.7080224, 1), .Dim = c(4L, 4L), .Dimnames = list(
c("a", "b", "c", "d"), c("a", "b", "c", "d")))

library(sna)

# draw edges according to value
gplot(mat, edge.lwd = mat, label = rownames(mat))

# thresholding at 0.5
 gplot(mat > .5, label = rownames(mat))


On 8/28/07, H. Paul Benton <[EMAIL PROTECTED]> wrote:
> Hello,
>
>I apologise if someone has already answered this but I searched and
> googled but didn't find anything.
>
>I have a matrix which gives me the similarity of each item to each
> other. I would like to turn this matrix into something like what they
> have in the graph package with the nodes and edges.
> http://cran.r-project.org/doc/packages/graph.pdf . However I cannot find
> a method to convert my matrix to an object that graph can use.
>
> my similarity matrix looks like:
> > sim[1:4,]
>a  b  c  d
> [a]  1.0  0.0223676  0.9723831  0.3943310
> [b]  0.325141612  1.000  0.9644216  0.5460461
> [c]  0.002109751  0.3426540  1.000  0.7080224
> [d]  0.250153137  0.1987485  0.7391222  1.000
>
> please don't get caught up with the numbers I simple made this to show.
> I have not produce the code yet to make my similitary matrix.
>
> Does anyone know a method to do this or do I have to write something. :(
> If I do any starter code :D jj. If I've read something wrong or
> misunderstood my apologies.
>
> cheers,
>
>
> Paul
>
>
> --
> Research Technician
> Mass Spectrometry
>   o The
>  /
> o Scripps
>  \
>   o Research
>  /
> o Institute
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Nodes & edges with similarity matrix

2007-08-28 Thread Seth Falcon
Along with the example I gave using graphAM, you might also want to
look at the help page for the distGraph class which may be more
directly what you want:

  library("graph")
  class ? distGraph

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


Re: [R] Nodes & edges with similarity matrix

2007-08-28 Thread Seth Falcon
Hi Paul,

"H. Paul Benton" <[EMAIL PROTECTED]> writes:
> I have a matrix which gives me the similarity of each item to each
> other. I would like to turn this matrix into something like what they
> have in the graph package with the nodes and edges.
> http://cran.r-project.org/doc/packages/graph.pdf . However I cannot find
> a method to convert my matrix to an object that graph can use.
>
> my similarity matrix looks like:
>> sim[1:4,]
> a  b  c  d
> [a]  1.0  0.0223676  0.9723831  0.3943310
> [b]  0.325141612  1.000  0.9644216  0.5460461
> [c]  0.002109751  0.3426540  1.000  0.7080224
> [d]  0.250153137  0.1987485  0.7391222  1.000
>
> please don't get caught up with the numbers I simple made this to show.
> I have not produce the code yet to make my similitary matrix.
>
> Does anyone know a method to do this or do I have to write something. :(
> If I do any starter code :D jj. If I've read something wrong or
> misunderstood my apologies.

The matrix you have can be interpreted as an adjacency matrix where a
value of zero means no relationship and a non-zero value indicates an
edge between two nodes with edge weight determined by the value.

You can create a graph object like this:

library("graph")
g <- new("graphAM", adjMat=sim, values=list(weight=0))

The default is to create an undirected graph and in this case you must
provide a symmetric matrix.  Generally I would expect a similarity
matrix to be symmetric, but the similitary (sic) matrix you have above
is not.  In this case, you can use a directed graph:

g <- new("graphAM", adjMat=sim, values=list(weight=0),
 edgemode="directed")

To visualize your graph you can use the Rgraphviz package which will
allow you to do:

  plot(g)

You might also be interested in the RBGL package which provides many
powerful graph algorithms.

All of these packages are available via Bioconductor (no bio required)
and can be installed as:

   source("http://bioconductor.org/biocLite.R";)
   biocLite(c("RBGL", "Rgraphviz"))

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
BioC: http://bioconductor.org/
Blog: http://userprimary.net/user/

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


Re: [R] "subscript out of bounds" Error in predict.naivebayes

2007-08-28 Thread Stephen Weigand
On 8/22/07, Polly He <[EMAIL PROTECTED]> wrote:
> I'm trying to fit a naive Bayes model and predict on a new data set using
> the functions naivebayes and predict (package = e1071).
>
> R version 2.5.1 on a Linux machine
>
> My data set looks like this. "class" is the response and k1 - k3 are the
> independent variables. All of them are factors. The response has 52 levels
> and k1 - k3 have 2-6 levels. I have about 9,300 independent variables but
> omit the long list here for simple demonstration. There are no missing
> values in the observations.
>
>class k1 k2 k3
>   1  0  0  1
>   8  0  0  0
>
> # model fitting, I also tried setting laplace=0 but didn't help
>  nbmodel <- naiveBayes(class~., data=train, laplace=1)
>
> # predict
>  nb.fit <- predict(nbmodel, x.test[,-1])
>
> First I had no trouble fitting the model. R also returned the predictions
> for some of my large data sets. But for some data sets, R can fit the model
> (no error message, nb.model$tables look ok). When I invoked the predict
> function, it kept giving me the following message:
>
> # my data set has 1 response variable and 9318 independent variables
> Error in FUN(1:9319[[4L]], ...) : subscript out of bounds
[...]

In my experience, some predict methods have trouble when
newdata does not have all levels of a factor. This seems
to be the case with predict.naiveBayes:

example(naiveBayes)
predict(model, subset(HouseVotes84, V1 == "n"))

gives

Error in object$tables[[v]] : subscript out of bounds

One workaround is to predict for a "bigger" data set
and retain a subset of the predictions.

Hope this helps,

Stephen


-- 
Rochester, Minn. USA

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] extracting dataset with average imputed values from aregImpute()

2007-08-28 Thread Jessica Z
extracting dataset with average imputed values from aregImpute()
  Dear all:
  after many trials, i am still quite lost on how to exact a dataset with 
average imputed values after running aregImpute()
  take the eg in the aregImpute(Hmisc) documentation(-- which also appeared in 
our R-archive with prof. Frank E Harrell Jr as the author ):
  
the following is the way on how to get a completed dataset (but for 
only one draw of the k multiple imputations)-- btw,i don't quite see what 
"fit.mult.impute"(mentioned below) is for, but seems it has nothing to do with 
my question:
  aregImpute produces a list containing the multiple imputations:
  w <- aregImpute(. . .)
w$imputed$blood.pressure   # gets m by k matrix
  # m = number of subjects with blood pressure missing,
  # k = number of multiple imputations
  To get a completed dataset (but for only one draw of the k multiple 
imputations) see how fit.mult.impute does it.  I have just added the 
following example to the help file for aregImpute.
  set.seed(23)
x <- runif(200)
y <- x + runif(200, -.05, .05)
y[1:20] <- NA
d <- data.frame(x,y)
f <- aregImpute(~ x + y, n.impute=10, match='closest', data=d)
# Here is how to create a completed dataset for imputation
# number 3 as fit.mult.impute would do automatically.  In this
# degenerate case changing 3 to 1-2,4-10 will not alter the results.
completed <- d
imputed <- impute.transcan(f, imputation=3, data=d, list.out=TRUE,
pr=FALSE, check=FALSE)
completed[names(imputed)] <- imputed
completed  # 200 by 2 data frame
   
  ---however, how could one get a completed dataset for the 
average of the K draws of the k multiple imputations? 
  say, after running: 
  w <- aregImpute(. . .)
w$imputed$blood.pressure  
  we gets m by k matrix
 m = number of subjects with blood pressure missing,
 k = number of multiple imputations
  this m by k matrix is for each subject (or say, for each record) with missing 
data. So for each row (record), i could average its k multiple imputation 
results , then store the result in a separate column. HOwever, this could only 
provide myself a dataset with just that m rows (records) which have missing 
data. 
  
what i really want is to get a COMPLETED dataset, with every non-missing value 
there just as they were in the original dataset, and with each 'NA' in the 
original dataset got replaced by its average imputation value (the average of 
its k imputations). 
  
many thanks! 


   
-
[[replacing trailing spam]]

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 calculate mean into a list

2007-08-28 Thread jim holtman
try:

colMeans(do.call('rbind', lapply(a0, mean)))


On 8/28/07, Weiwei Shi <[EMAIL PROTECTED]> wrote:
> Dear Listers:
>
> I have this task and suppose a0 is a list of 10 data.frames, I want to
> calculate like this
> > (a0[[1]]+a0[[2]]+..+a[[10]])/10
>
> Thanks.
>
> --
> Weiwei Shi, Ph.D
> Research Scientist
> GeneGO, Inc.
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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 you are trying to solve?

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Recoding multiple columns consistently

2007-08-28 Thread Ron Crump
Hi,

I have a dataframe that contains pedigree information;
that is individual, sire and dam identities as separate
columns. It also has date of birth.

These identifiers are not numeric, or not sequential.

Obviously, an identifier can appear in one or two columns,
depending on whether it was a parent or not. These should
be consistent.

Not all identifiers appear in the individual column - it
is possible for a parent not to have its own record if its
parents were not known.

Missing parental (sire and/or dam) identifiers can occur.

I need to export the data for use in another program that
requires the pedigree to be coded as integers, increasing
with date of birth (therefore sire and dam always have
lower identifiers than their offspring) and with missing
values coded as 0.

How would I go about doing this?

And a second, simpler related question, if I have a column with
n different values (may be strings or non-sequential integers)
identifying levels (possibly with repeated occurences), how
can I recode them to be sequential from 1 to n?

I can solve both problems in fortran, so could use loops to
do it in R, but feel there should be quicker, more elegant,
"more R" solution.

Thanks for your help.

Ron.

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


Re: [R] alternate methods to perform a calculation

2007-08-28 Thread jim holtman
I think you can use 'outer'

outer(b$xk1, a$x1, function(y,z)abs(z-y))
outer(b$xk2, a$x2, function(y,z)abs(z-y))

On 8/28/07, dxc13 <[EMAIL PROTECTED]> wrote:
>
> Consider a data frame (x) with 2 variables, x1 and x2, having equal values.
> It looks like:
>
> x1   x2
> 11
> 22
> 33
>
> Now, consider a second data frame (xk):
> xk1   xk2
> 0.50.5
> 1.00.5
> 1.50.5
> 2.00.5
> 0.51
> 1.01
> 1.51
> 2.01
> 0.51.5
> 1.01.5
> 1.51.5
> 2.01.5
> 0.52
> 1.02
> 1.52
> 2.02
>
> I have written code to calculate some differences between these two data
> sets; the main idea is to subtract off each element of xk1 from each value
> of x1, and similarly for xk2 and x2.  This is what I have:
>
> w1 <- array(NA,dim=c(nrow(xk),length(x$x1)))
> w2 <- array(NA,dim=c(nrow(xk),length(x$x2)))
> for (j in 1:nrow(xk)) {
>w1[j,] <- abs(x$x1-xk$xk1[j])
>w2[j,] <- abs(x$x2-xk$xk2[j])
> }
>
> Is there  a way to do the above calculation without use of a FOR loop?
> Thank you
>
> Derek
>
>
> --
> View this message in context: 
> http://www.nabble.com/alternate-methods-to-perform-a-calculation-tf4344469.html#a12376906
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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 you are trying to solve?

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


[R] data formatting: from rows to columns

2007-08-28 Thread Duncan Mackay
At 09:11 29/08/07 Jim Holtman wrote

Here is a way using sprintf:

x <- read.table(textConnection(" V2  V3
27  2032567  19
28  2035482  19
126 2472826  19
132 2473320  19
136 2035480 135
145 2062458 135
148 2074927 135
151 2102395 142
156 2027252 142
158 2473082 142"))

# output the data
cat(sprintf("%d\n%d\n\n", x$V2, x$V3), sep='', file='tempxx.txt')

How about

write.table(x,"clipboard",sep="\n",eol="\n\n",col.names = FALSE, row.names 
= FALSE)
2032567
19

2035482
19

2472826
19

2473320
19

2035480
135

2062458
135

2074927
135

2102395
142

2027252
142

2473082
142

Regards

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: [EMAIL PROTECTED]
Ph 02 67729794

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


Re: [R] data formatting: from rows to columns

2007-08-28 Thread jim holtman
Here is a way using sprintf:

x <- read.table(textConnection(" V2  V3
27  2032567  19
28  2035482  19
126 2472826  19
132 2473320  19
136 2035480 135
145 2062458 135
148 2074927 135
151 2102395 142
156 2027252 142
158 2473082 142"))

# output the data
cat(sprintf("%d\n%d\n\n", x$V2, x$V3), sep='', file='tempxx.txt')


On 8/28/07, Federico Calboli <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have some data I need to write as a file from R to use in a different 
> program.
> My data comes as a numeric matrix of n rows and 2 colums, I need to transform
> each row as a two rows 1 col output, and separate the output of each row with 
> a
> blanck line.
>
> Foe instance I need to go from this:
>
>  V2  V3
> 27  2032567  19
> 28  2035482  19
> 126 2472826  19
> 132 2473320  19
> 136 2035480 135
> 145 2062458 135
> 148 2074927 135
> 151 2102395 142
> 156 2027252 142
> 158 2473082 142
>
> to
>
> 2032567
> 19
>
> 2035482
> 19
>
> 2472826
> 19
>
> 2473320
> 19
>
> 2035480
> 135
>
> ...
>
> Any hint? I seem a bit stuck. cat(unlist(data), file ='data.txt', sep = '\n')
> (obviously) does not work...
>
> Cheers,
>
> Fede
>
>
>
>
>
>
> --
> Federico C. F. Calboli
> Department of Epidemiology and Public Health
> Imperial College, St Mary's Campus
> Norfolk Place, London W2 1PG
>
> Tel  +44 (0)20 7594 1602 Fax (+44) 020 7594 3193
>
> f.calboli [.a.t] imperial.ac.uk
> f.calboli [.a.t] gmail.com
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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 you are trying to solve?

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


Re: [R] Nodes & edges with similarity matrix

2007-08-28 Thread Gabor Csardi
Paul,

i have no idea what functionality you need from graph, but 
if the igraph package can do what you want then it can 
easily convert this to a graph for you, basically it is just

threshold <- 0.5
g <- graph.adjacency(sim>threshoold)

or you can create a weighted graph:

g <- graph.adjacency(sim, weighted=TRUE)

or a weighted graph after a threshold:

sim2 <- sim
sim2[ sim Hello,
> 
> I apologise if someone has already answered this but I searched and
> googled but didn't find anything.
> 
> I have a matrix which gives me the similarity of each item to each
> other. I would like to turn this matrix into something like what they
> have in the graph package with the nodes and edges.
> http://cran.r-project.org/doc/packages/graph.pdf . However I cannot find
> a method to convert my matrix to an object that graph can use.
> 
> my similarity matrix looks like:
> > sim[1:4,]
> a  b  c  d
> [a]  1.0  0.0223676  0.9723831  0.3943310
> [b]  0.325141612  1.000  0.9644216  0.5460461
> [c]  0.002109751  0.3426540  1.000  0.7080224
> [d]  0.250153137  0.1987485  0.7391222  1.000
> 
> please don't get caught up with the numbers I simple made this to show.
> I have not produce the code yet to make my similitary matrix.
> 
> Does anyone know a method to do this or do I have to write something. :(
> If I do any starter code :D jj. If I've read something wrong or
> misunderstood my apologies.
> 
> cheers,
> 
> 
> Paul
> 
> 
> -- 
> Research Technician
> Mass Spectrometry
>o The
>   /
> o Scripps
>   \
>o Research
>   /
> o Institute
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor <[EMAIL PROTECTED]>MTA RMKI, ELTE TTK

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


[R] how to calculate mean into a list

2007-08-28 Thread Weiwei Shi
Dear Listers:

I have this task and suppose a0 is a list of 10 data.frames, I want to
calculate like this
> (a0[[1]]+a0[[2]]+..+a[[10]])/10

Thanks.

-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] alternate methods to perform a calculation

2007-08-28 Thread dxc13

Consider a data frame (x) with 2 variables, x1 and x2, having equal values. 
It looks like:

x1   x2
11
22
33

Now, consider a second data frame (xk):
xk1   xk2
0.50.5
1.00.5
1.50.5
2.00.5
0.51
1.01
1.51
2.01
0.51.5
1.01.5
1.51.5
2.01.5
0.52
1.02
1.52
2.02

I have written code to calculate some differences between these two data
sets; the main idea is to subtract off each element of xk1 from each value
of x1, and similarly for xk2 and x2.  This is what I have:

w1 <- array(NA,dim=c(nrow(xk),length(x$x1)))
w2 <- array(NA,dim=c(nrow(xk),length(x$x2))) 
for (j in 1:nrow(xk)) {
w1[j,] <- abs(x$x1-xk$xk1[j])
w2[j,] <- abs(x$x2-xk$xk2[j])
}

Is there  a way to do the above calculation without use of a FOR loop? 
Thank you

Derek


-- 
View this message in context: 
http://www.nabble.com/alternate-methods-to-perform-a-calculation-tf4344469.html#a12376906
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 find the likelihood function?

2007-08-28 Thread francogrex

Hi, I am writing a BRugs code and I need to specify the likelihood for the
gamma distribution and I am specifying it as the pdf:
(pow(b1,a1)/(exp(loggam(a1)))*(exp(-b1*lambda[i]))*pow(lambda[i],(a1-1)))

But it is not accepting it although I know that I could use the pdf in R to
estimate the parameters by MLE. There must be a shorter form that is the
real likelihood function, (I know that for the normal distribution the
likelihood is much shorter than the pdf and it is accepted by BRugs).
Is there like a webpage where the likelihood functions are displayed?

PS: I know that BRugs has a dgamma function and that I do not need to
specify the likelihood function, but it is for some other purpose I am doing
that so that I can afterwards generate a new distribution which is a mixture
of two gamma distributions.

Thanks.

-- 
View this message in context: 
http://www.nabble.com/How-to-find-the-likelihood-function--tf4344480.html#a12376952
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Factor levels

2007-08-28 Thread Sébastien
Peter, Gabor: thanks to both of you.

This 'unique' function is what I was looking for !

Peter Alspach a écrit :
> Sebastain
>
> Does the following work for you?
>
> seb <- read.table(file='clipboard', header=T)
> seb$c
>  [1] w k r s k p l u z s j j x r d j x w q f
> Levels: d f j k l p q r s u w x z
> seb$c <- factor(seb$c, levels=unique(seb$c))
> seb$c
>  [1] w k r s k p l u z s j j x r d j x w q f
> Levels: w k r s p l u z j x d q f
>
> Peter Alspach
>  
>
>   
>> -Original Message-
>> From: [EMAIL PROTECTED] 
>> [mailto:[EMAIL PROTECTED] On Behalf Of Sébastien
>> Sent: Wednesday, 29 August 2007 9:00 a.m.
>> To: Gabor Grothendieck
>> Cc: R-help
>> Subject: Re: [R] Factor levels
>>
>> Ok, I cannot send to you one of my dataset since they are 
>> confidential. 
>> But I can produce a dummy "mini" dataset to illustrate my question. 
>> Let's say I have a csv file with 3 columns and 20 rows which 
>> content is reproduced by the following line.
>>
>>  > mydata<-data.frame(a=1:20,
>> b=sample(100:200,20,replace=T),c=sample(letters[1:26], 20, 
>> replace = T))  > mydata
>> a   b c
>> 1   1 176 w
>> 2   2 141 k
>> 3   3 172 r
>> 4   4 182 s
>> 5   5 123 k
>> 6   6 153 p
>> 7   7 176 l
>> 8   8 170 u
>> 9   9 140 z
>> 10 10 194 s
>> 11 11 164 j
>> 12 12 100 j
>> 13 13 127 x
>> 14 14 137 r
>> 15 15 198 d
>> 16 16 173 j
>> 17 17 113 x
>> 18 18 144 w
>> 19 19 198 q
>> 20 20 122 f
>>
>> If I had to read the csv file, I would use something like: 
>> mydata<-data.frame(read.table(file="c:/test.csv",header=T))
>>
>> Now, if you look at mydata$c, the levels are alphabetically ordered.
>>  > mydata$c
>>  [1] w k r s k p l u z s j j x r d j x w q f
>> Levels: d f j k l p q r s u w x z
>>
>> What I am trying to do is to reorder the levels as to have 
>> them in the order they appear in the table, ie
>> Levels: w k r s p l u z j x d q f
>>
>> Again, keep in mind that my script should be used on datasets 
>> which content are unknown to me. In my example, I have used 
>> letters for mydata$c, but my code may have to handle factors 
>> of numeric or character values (I need to transform specific 
>> columns of my dataset into factors for plotting purposes). My 
>> goal is to let the code scan the content of each factor of my 
>> data.frame during or after the read.table step and reorder 
>> their levels automatically without having to ask the user to 
>> hard-code the level order.
>>
>> In a way, my problem is more related to the way the factor 
>> levels are ordered than to the read.table function, although 
>> I guess there is a link...
>>
>> Gabor Grothendieck a écrit :
>> 
>>> Its not clear from your description what you want
>>>   
>
>   

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Nodes & edges with similarity matrix

2007-08-28 Thread H. Paul Benton
Hello,

I apologise if someone has already answered this but I searched and
googled but didn't find anything.

I have a matrix which gives me the similarity of each item to each
other. I would like to turn this matrix into something like what they
have in the graph package with the nodes and edges.
http://cran.r-project.org/doc/packages/graph.pdf . However I cannot find
a method to convert my matrix to an object that graph can use.

my similarity matrix looks like:
> sim[1:4,]
a  b  c  d
[a]  1.0  0.0223676  0.9723831  0.3943310
[b]  0.325141612  1.000  0.9644216  0.5460461
[c]  0.002109751  0.3426540  1.000  0.7080224
[d]  0.250153137  0.1987485  0.7391222  1.000

please don't get caught up with the numbers I simple made this to show.
I have not produce the code yet to make my similitary matrix.

Does anyone know a method to do this or do I have to write something. :(
If I do any starter code :D jj. If I've read something wrong or
misunderstood my apologies.

cheers,


Paul


-- 
Research Technician
Mass Spectrometry
   o The
  /
o Scripps
  \
   o Research
  /
o Institute

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


Re: [R] Factor levels

2007-08-28 Thread Peter Alspach
Sebastain

Does the following work for you?

seb <- read.table(file='clipboard', header=T)
seb$c
 [1] w k r s k p l u z s j j x r d j x w q f
Levels: d f j k l p q r s u w x z
seb$c <- factor(seb$c, levels=unique(seb$c))
seb$c
 [1] w k r s k p l u z s j j x r d j x w q f
Levels: w k r s p l u z j x d q f

Peter Alspach
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Sébastien
> Sent: Wednesday, 29 August 2007 9:00 a.m.
> To: Gabor Grothendieck
> Cc: R-help
> Subject: Re: [R] Factor levels
> 
> Ok, I cannot send to you one of my dataset since they are 
> confidential. 
> But I can produce a dummy "mini" dataset to illustrate my question. 
> Let's say I have a csv file with 3 columns and 20 rows which 
> content is reproduced by the following line.
> 
>  > mydata<-data.frame(a=1:20,
> b=sample(100:200,20,replace=T),c=sample(letters[1:26], 20, 
> replace = T))  > mydata
> a   b c
> 1   1 176 w
> 2   2 141 k
> 3   3 172 r
> 4   4 182 s
> 5   5 123 k
> 6   6 153 p
> 7   7 176 l
> 8   8 170 u
> 9   9 140 z
> 10 10 194 s
> 11 11 164 j
> 12 12 100 j
> 13 13 127 x
> 14 14 137 r
> 15 15 198 d
> 16 16 173 j
> 17 17 113 x
> 18 18 144 w
> 19 19 198 q
> 20 20 122 f
> 
> If I had to read the csv file, I would use something like: 
> mydata<-data.frame(read.table(file="c:/test.csv",header=T))
> 
> Now, if you look at mydata$c, the levels are alphabetically ordered.
>  > mydata$c
>  [1] w k r s k p l u z s j j x r d j x w q f
> Levels: d f j k l p q r s u w x z
> 
> What I am trying to do is to reorder the levels as to have 
> them in the order they appear in the table, ie
> Levels: w k r s p l u z j x d q f
> 
> Again, keep in mind that my script should be used on datasets 
> which content are unknown to me. In my example, I have used 
> letters for mydata$c, but my code may have to handle factors 
> of numeric or character values (I need to transform specific 
> columns of my dataset into factors for plotting purposes). My 
> goal is to let the code scan the content of each factor of my 
> data.frame during or after the read.table step and reorder 
> their levels automatically without having to ask the user to 
> hard-code the level order.
> 
> In a way, my problem is more related to the way the factor 
> levels are ordered than to the read.table function, although 
> I guess there is a link...
> 
> Gabor Grothendieck a écrit :
> > Its not clear from your description what you want

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


Re: [R] Factor levels

2007-08-28 Thread Gabor Grothendieck
Its the same principle.  Just change the function to be suitable.  This one
arranges the levels according to the input:

library(methods)
setClass("my.factor")
setAs("character", "my.factor",
 function(from) factor(from, levels = unique(from)))

Input <- "a b c
1   1 176 w
2   2 141 k
3   3 172 r
4   4 182 s
5   5 123 k
6   6 153 p
7   7 176 l
8   8 170 u
9   9 140 z
10 10 194 s
11 11 164 j
12 12 100 j
13 13 127 x
14 14 137 r
15 15 198 d
16 16 173 j
17 17 113 x
18 18 144 w
19 19 198 q
20 20 122 f
"
DF <- read.table(textConnection(Input), header = TRUE,
  colClasses = list(c = "my.factor"))
str(DF)


On 8/28/07, Sébastien <[EMAIL PROTECTED]> wrote:
> Ok, I cannot send to you one of my dataset since they are confidential. But
> I can produce a dummy "mini" dataset to illustrate my question. Let's say I
> have a csv file with 3 columns and 20 rows which content is reproduced by
> the following line.
>
> > mydata<-data.frame(a=1:20,
> b=sample(100:200,20,replace=T),c=sample(letters[1:26], 20,
> replace = T))
> > mydata
> a   b c
> 1   1 176 w
> 2   2 141 k
> 3   3 172 r
> 4   4 182 s
> 5   5 123 k
> 6   6 153 p
> 7   7 176 l
> 8   8 170 u
> 9   9 140 z
> 10 10 194 s
> 11 11 164 j
> 12 12 100 j
> 13 13 127 x
> 14 14 137 r
> 15 15 198 d
> 16 16 173 j
> 17 17 113 x
> 18 18 144 w
> 19 19 198 q
> 20 20 122 f
>
> If I had to read the csv file, I would use something like:
> mydata<-data.frame(read.table(file="c:/test.csv",header=T))
>
> Now, if you look at mydata$c, the levels are alphabetically ordered.
> > mydata$c
>  [1] w k r s k p l u z s j j x r d j x w q f
> Levels: d f j k l p q r s u w x z
>
> What I am trying to do is to reorder the levels as to have them in the order
> they appear in the table, ie
> Levels: w k r s p l u z j x d q f
>
> Again, keep in mind that my script should be used on datasets which content
> are unknown to me. In my example, I have used letters for mydata$c, but my
> code may have to handle factors of numeric or character values (I need to
> transform specific columns of my dataset into factors for plotting
> purposes). My goal is to let the code scan the content of each factor of my
> data.frame during or after the read.table step and reorder their levels
> automatically without having to ask the user to hard-code the level order.
>
> In a way, my problem is more related to the way the factor levels are
> ordered than to the read.table function, although I guess there is a link...
>
> Gabor Grothendieck a écrit :
> Its not clear from your description what you want.
Could you be a bit more
> specific including an example.

On 8/28/07, Sébastien <[EMAIL PROTECTED]>
> wrote:

> Thanks Gabor, I have two questions:

1- Is there any difference between your
> code and the following one, with
regards to Fld2 ?
### test ###

> Input <- "Fld1 Fld2
10 A
20 B
30 C
40 A
"
DF <-

> read.table(textConnection(Input), header =
TRUE)

> DF$Fld2<-factor(DF$Fld2,levels= c("C", "A", "B")))

> 2- do you see any way to bring flexibility to your method ? Because,
> it
looks to me as, at this stage, I have to i) know the order of my
> levels
before I read the table and ii) create one class per factor.
My
> problem is that I am not really working on a specific dataset. My goal is
to
> develop R scripts capable of handling datasets which have various
contents
> but close structures. So, I really need to minimize the quantity
> of
"user-specific" code.

Sebastien

Gabor Grothendieck a écrit :
You can
> create your own class and pass that to read table. In

> the example

> below Fld2 is read in with factor levels C, A, B

> in that

> order.

>
library(methods)
setClass("my.levels")
setAs("character",

> "my.levels",

>  function(from) factor(from, levels = c("C", "A", "B")))


###

> test ###

> Input <- "Fld1 Fld2
10 A
20 B
30 C
40 A
"
DF <-

> read.table(textConnection(Input), header = TRUE,

>  colClasses = c("numeric",

> "my.levels"))

> str(DF)
# or
DF <- read.table(textConnection(Input), header =

> TRUE,

>  colClasses = list(Fld2 = "my.levels"))
str(DF)


On 8/28/07,

> Sébastien <[EMAIL PROTECTED]> wrote:

>
> Dear R-users,

> I have found this not-so-recent post in the archives

> -

> http://tolstoy.newcastle.edu.au/R/devel/00a/0291.html -

> while I was

> looking for a particular way to reorder factor levels. The

> question

> addressed by the author was to know if the read.table function

> could be

> modified to order the levels of newly created factors "according to

> the

> order that they appear in the data file". Exactly what I am looking

> for.

> As there was no reply to this post, I wonder if any move have been

> made

> towards the implementation of this suggestion. A quick look

> at

> ?read.table tells me that if this option was implemented, it was not

> in

> the read.table function...

Sebastien

PS: I am sorry to post so many

> messages on the list, but I am learning R

> (basically by trials & errors ;-)

> ) and no one around me has even a

> slight notion about

> it

Re: [R] data manipulation help

2007-08-28 Thread Charles C. Berry
On Tue, 28 Aug 2007, Zheng Lu wrote:

> Dear All:
>
> I have a dataset like
> A=c(0,12,34,5,6,0,4,5,6,0,12,3,4,8,7,0,4,3,5,0,...),I want to add a
> column to this dataset, it must be in
> B=c(1,1,1,1,1,2,2,2,2,3,3,3,3,3,3,4,4,4,4,5,..), How can I create B
> based on the sequence of A. Appreciate.

Do you want

B  <- cumsum( A == 0 )

??

Please use spaces and newlines to make your code more readable!


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

Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


Re: [R] data manipulation help

2007-08-28 Thread Leeds, Mark \(IED\)
below works on you example but someone will have something more elegant.

zeroindices<-which(a == 0)
rep(1:length(zeroindices),c(diff(zeroindices),(length(a)-zeroindices[len
gth(zeroindices)]+1)))






-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Zheng Lu
Sent: Tuesday, August 28, 2007 5:00 PM
To: r-help@stat.math.ethz.ch
Subject: [R] data manipulation help

Dear All:

I have a dataset like
A=c(0,12,34,5,6,0,4,5,6,0,12,3,4,8,7,0,4,3,5,0,...),I want to add a
column to this dataset, it must be in
B=c(1,1,1,1,1,2,2,2,2,3,3,3,3,3,3,4,4,4,4,5,..), How can I create B
based on the sequence of A. Appreciate.


Zheng

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


This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

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


[R] data manipulation help

2007-08-28 Thread Zheng Lu
Dear All:

I have a dataset like 
A=c(0,12,34,5,6,0,4,5,6,0,12,3,4,8,7,0,4,3,5,0,...),I want to add a 
column to this dataset, it must be in 
B=c(1,1,1,1,1,2,2,2,2,3,3,3,3,3,3,4,4,4,4,5,..), How can I create B 
based on the sequence of A. Appreciate.


Zheng

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


Re: [R] Factor levels

2007-08-28 Thread Sébastien
Ok, I cannot send to you one of my dataset since they are confidential. 
But I can produce a dummy "mini" dataset to illustrate my question. 
Let's say I have a csv file with 3 columns and 20 rows which content is 
reproduced by the following line.

 > mydata<-data.frame(a=1:20, 
b=sample(100:200,20,replace=T),c=sample(letters[1:26], 20, replace = T))
 > mydata
a   b c
1   1 176 w
2   2 141 k
3   3 172 r
4   4 182 s
5   5 123 k
6   6 153 p
7   7 176 l
8   8 170 u
9   9 140 z
10 10 194 s
11 11 164 j
12 12 100 j
13 13 127 x
14 14 137 r
15 15 198 d
16 16 173 j
17 17 113 x
18 18 144 w
19 19 198 q
20 20 122 f

If I had to read the csv file, I would use something like: 
mydata<-data.frame(read.table(file="c:/test.csv",header=T))

Now, if you look at mydata$c, the levels are alphabetically ordered.
 > mydata$c
 [1] w k r s k p l u z s j j x r d j x w q f
Levels: d f j k l p q r s u w x z

What I am trying to do is to reorder the levels as to have them in the 
order they appear in the table, ie
Levels: w k r s p l u z j x d q f

Again, keep in mind that my script should be used on datasets which 
content are unknown to me. In my example, I have used letters for 
mydata$c, but my code may have to handle factors of numeric or character 
values (I need to transform specific columns of my dataset into factors 
for plotting purposes). My goal is to let the code scan the content of 
each factor of my data.frame during or after the read.table step and 
reorder their levels automatically without having to ask the user to 
hard-code the level order.

In a way, my problem is more related to the way the factor levels are 
ordered than to the read.table function, although I guess there is a link...

Gabor Grothendieck a écrit :
> Its not clear from your description what you want.
> Could you be a bit more specific including an example.
>
> On 8/28/07, Sébastien <[EMAIL PROTECTED]> wrote:
>   
>> Thanks Gabor, I have two questions:
>>
>> 1- Is there any difference between your code and the following one, with
>> regards to Fld2 ?
>> ### test ###
>> 
>
> Input <- "Fld1 Fld2
> 10 A
> 20 B
> 30 C
> 40 A
> "
> DF <-
>   
>> read.table(textConnection(Input), header =
>> TRUE)
>> 
>
> DF$Fld2<-factor(DF$Fld2,levels= c("C", "A", "B")))
>   
>> 2- do you see any way to bring flexibility to your method ? Because, it
>> looks to me as, at this stage, I have to i) know the order of my levels
>> before I read the table and ii) create one class per factor.
>> My problem is that I am not really working on a specific dataset. My goal is
>> to develop R scripts capable of handling datasets which have various
>> contents but close structures. So, I really need to minimize the quantity of
>> "user-specific" code.
>>
>> Sebastien
>>
>> Gabor Grothendieck a écrit :
>> You can create your own class and pass that to read table. In
>> 
> the example
>   
>> below Fld2 is read in with factor levels C, A, B
>> 
> in that
>   
>> order.
>> 
>
>
> library(methods)
> setClass("my.levels")
> setAs("character",
>   
>> "my.levels",
>> 
>  function(from) factor(from, levels = c("C", "A", "B")))
>
>
> ###
>   
>> test ###
>> 
>
> Input <- "Fld1 Fld2
> 10 A
> 20 B
> 30 C
> 40 A
> "
> DF <-
>   
>> read.table(textConnection(Input), header = TRUE,
>> 
>  colClasses = c("numeric",
>   
>> "my.levels"))
>> 
> str(DF)
> # or
> DF <- read.table(textConnection(Input), header =
>   
>> TRUE,
>> 
>  colClasses = list(Fld2 = "my.levels"))
> str(DF)
>
>
> On 8/28/07,
>   
>> Sébastien <[EMAIL PROTECTED]> wrote:
>> 
>
>   
>> Dear R-users,
>> 
>
> I have found this not-so-recent post in the archives
>   
>> -
>> 
> http://tolstoy.newcastle.edu.au/R/devel/00a/0291.html -
>   
>> while I was
>> 
> looking for a particular way to reorder factor levels. The
>   
>> question
>> 
> addressed by the author was to know if the read.table function
>   
>> could be
>> 
> modified to order the levels of newly created factors "according to
>   
>> the
>> 
> order that they appear in the data file". Exactly what I am looking
>   
>> for.
>> 
> As there was no reply to this post, I wonder if any move have been
>   
>> made
>> 
> towards the implementation of this suggestion. A quick look
>   
>> at
>> 
> ?read.table tells me that if this option was implemented, it was not
>   
>> in
>> 
> the read.table function...
>
> Sebastien
>
> PS: I am sorry to post so many
>   
>> messages on the list, but I am learning R
>> 
> (basically by trials & errors ;-)
>   
>> ) and no one around me has even a
>> 
> slight notion about
>   
>> it...
>> 
>
> __
> R-help@stat.math.ethz.ch
>   
>> mailing
>> list
>> 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do
>   
>> read the posting guide
>> http://www.R-project.org/posting-guide.html
>> 
> and provide
>   
>> commented, minimal, self-contained, reproducible code.
>> 
>
>
>   
>
>   
>

Re: [R] Factor levels

2007-08-28 Thread Gabor Grothendieck
Its not clear from your description what you want.
Could you be a bit more specific including an example.

On 8/28/07, Sébastien <[EMAIL PROTECTED]> wrote:
> Thanks Gabor, I have two questions:
>
> 1- Is there any difference between your code and the following one, with
> regards to Fld2 ?
> ### test ###

Input <- "Fld1 Fld2
10 A
20 B
30 C
40 A
"
DF <-
> read.table(textConnection(Input), header =
> TRUE)

DF$Fld2<-factor(DF$Fld2,levels= c("C", "A", "B")))
> 2- do you see any way to bring flexibility to your method ? Because, it
> looks to me as, at this stage, I have to i) know the order of my levels
> before I read the table and ii) create one class per factor.
> My problem is that I am not really working on a specific dataset. My goal is
> to develop R scripts capable of handling datasets which have various
> contents but close structures. So, I really need to minimize the quantity of
> "user-specific" code.
>
> Sebastien
>
> Gabor Grothendieck a écrit :
> You can create your own class and pass that to read table. In
the example
> below Fld2 is read in with factor levels C, A, B
in that
> order.


library(methods)
setClass("my.levels")
setAs("character",
> "my.levels",
 function(from) factor(from, levels = c("C", "A", "B")))


###
> test ###

Input <- "Fld1 Fld2
10 A
20 B
30 C
40 A
"
DF <-
> read.table(textConnection(Input), header = TRUE,
 colClasses = c("numeric",
> "my.levels"))
str(DF)
# or
DF <- read.table(textConnection(Input), header =
> TRUE,
 colClasses = list(Fld2 = "my.levels"))
str(DF)


On 8/28/07,
> Sébastien <[EMAIL PROTECTED]> wrote:

> Dear R-users,

I have found this not-so-recent post in the archives
> -
http://tolstoy.newcastle.edu.au/R/devel/00a/0291.html -
> while I was
looking for a particular way to reorder factor levels. The
> question
addressed by the author was to know if the read.table function
> could be
modified to order the levels of newly created factors "according to
> the
order that they appear in the data file". Exactly what I am looking
> for.
As there was no reply to this post, I wonder if any move have been
> made
towards the implementation of this suggestion. A quick look
> at
?read.table tells me that if this option was implemented, it was not
> in
the read.table function...

Sebastien

PS: I am sorry to post so many
> messages on the list, but I am learning R
(basically by trials & errors ;-)
> ) and no one around me has even a
slight notion about
> it...

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


Re: [R] Factor levels

2007-08-28 Thread Sébastien
Thanks Gabor, I have two questions:

1- Is there any difference between your code and the following one, with 
regards to Fld2 ?

### test ###

Input <- "Fld1 Fld2
10 A
20 B
30 C
40 A
"
DF <- read.table(textConnection(Input), header = TRUE)

DF$Fld2<-factor(DF$Fld2,levels= c("C", "A", "B")))

2- do you see any way to bring flexibility to your method ? Because, it 
looks to me as, at this stage, I have to i) know the order of my levels 
before I read the table and ii) create one class per factor.
My problem is that I am not really working on a specific dataset. My 
goal is to develop R scripts capable of handling datasets which have 
various contents but close structures. So, I really need to minimize the 
quantity of "user-specific" code.

Sebastien

Gabor Grothendieck a écrit :
> You can create your own class and pass that to read table.  In
> the example below Fld2 is read in with factor levels C, A, B
> in that order.
>
>
> library(methods)
> setClass("my.levels")
> setAs("character", "my.levels",
>   function(from) factor(from, levels = c("C", "A", "B")))
>
>
> ### test ###
>
> Input <- "Fld1 Fld2
> 10 A
> 20 B
> 30 C
> 40 A
> "
> DF <- read.table(textConnection(Input), header = TRUE,
>   colClasses = c("numeric", "my.levels"))
> str(DF)
> # or
> DF <- read.table(textConnection(Input), header = TRUE,
>   colClasses = list(Fld2 = "my.levels"))
> str(DF)
>
>
> On 8/28/07, Sébastien <[EMAIL PROTECTED]> wrote:
>   
>> Dear R-users,
>>
>> I have found this not-so-recent post in the archives  -
>> http://tolstoy.newcastle.edu.au/R/devel/00a/0291.html - while I was
>> looking for a particular way to reorder factor levels. The question
>> addressed by the author was to know if the read.table function could be
>> modified to order the levels of newly created factors "according to the
>> order that they appear in the data file". Exactly what I am looking for.
>> As there was no reply to this post, I wonder if any move have been made
>> towards the implementation of this suggestion. A quick look at
>> ?read.table tells me that if this option was implemented, it was not in
>> the read.table function...
>>
>> Sebastien
>>
>> PS: I am sorry to post so many messages on the list, but I am learning R
>> (basically by trials & errors ;-) ) and no one around me has even a
>> slight notion about it...
>>
>> __
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] help with aggregate(): tables of means for terms in an mlm

2007-08-28 Thread Michael Friendly
I'm trying to extend some work in the car and heplots packages
that requires getting a table of multivariate means for one
(or later, more) terms in an mlm object.  I can do this for
concrete examples, using aggregate(), but can't figure out how to 
generalize it.  I want to return a result that has the factor-level
combinations as rownames, and the means as the body of the table
(aggregate returns the factors as initial columns).

# Examples: m1 & m2 are desired results

 > library(car)
 > soils.mod <- lm(cbind(pH,N,Dens,P,Ca,Mg,K,Na,Conduc) ~ Block + 
Contour*Depth, data=Soils)
 > term.names(soils.mod)
[1] "(Intercept)"   "Block" "Contour"   "Depth"
[5] "Contour:Depth"
 >

 > # response variables
 > resp<- model.response(model.frame(soils.mod))
 > # 1-factor means: term="Contour"
 > m1<-aggregate(resp, list(Soils$Contour), mean)
 > rownames(m1) <- m1[,1]
 > ( m1 <- m1[,-1] )
   pH   N  Dens PCaMg  KNa Conduc
Depression 4.692 0.08731 1.343 188.2 7.101 8.986 0.3781 5.823  6.946
Slope  4.746 0.10594 1.333 159.4 8.109 8.320 0.4156 6.103  6.964
Top4.570 0.11256 1.272 150.9 8.877 8.088 0.6050 4.872  5.856
 >

 > # 2-factor means:  term="Contour:Depth"
 > m2<-aggregate(resp, list(Soils$Contour, Soils$Depth), mean)
 > rownames(m2) <- paste(m2[,1], m2[,2],sep=":")
 > ( m2 <- m2[,-(1:2)] )
 pH   N   Dens P CaMg  K Na 
Conduc
Depression:0-10  5.353 0.17825 0.9775 333.0 10.685 7.235 0.6250 1.5125 
1.473
Slope:0-10   5.508 0.21900 1.0500 258.0 12.248 7.232 0.6350 1.9900 
2.050
Top:0-10 5.332 0.19550 1.0025 242.8 13.385 6.590 0.8000 0.9225 
1.373
Depression:10-30 4.880 0.08025 1.3575 187.5  7.548 9.635 0.4500 4.6400 
5.480
Slope:10-30  5.283 0.10100 1.3475 160.2  9.515 8.980 0.4800 4.9350 
4.910
Top:10-304.850 0.11750 1.3325 147.5 10.238 8.090 0.6500 2.9800 
3.583
Depression:30-60 4.362 0.05050 1.5350 124.2  5.402 9.918 0.2400 7.5875 
9.393
Slope:30-60  4.268 0.06075 1.5100 114.5  5.877 8.968 0.3000 7.6300 
8.925
Top:30-604.205 0.07950 1.3225 116.2  6.620 8.742 0.5450 6.2975 
7.440
Depression:60-90 4.173 0.04025 1.5025 108.0  4.770 9.157 0.1975 9.5525 
11.438
Slope:60-90  3.927 0.04300 1.4225 105.0  4.798 8.100 0.2475 9.8575 
11.970
Top:60-903.893 0.05775 1.4300  97.0  5.268 8.928 0.4250 9.2900 
11.030
 >

Here is the current version of a function that doesn't work, because I
can't supply the factor names to aggregate in the proper way.
Can someone help me make it work?

termMeans.mlm <- function( object, term ) {
resp<- model.response(model.frame(object))
terms <- term.names(soils.mod)
terms <- terms[terms != "(Intercept)"]
factors <- strsplit(term, ":")
# browser()
means <- aggregate(resp, factors, mean)
# rownames(means) <- ...
# means <- means[, -(1:length(factors)]
}

 > termMeans.mlm(soils.mod, "Contour")
Error in FUN(X[[1L]], ...) : arguments must have same length

thanks,
-Michael

-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA

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


Re: [R] Excel

2007-08-28 Thread Rolf Turner

On 28/08/2007, at 7:16 PM, J Dougherty wrote:



> PS, I quit using Excel for most important work after it returned a  
> negative
> variance on some data I was collecting descriptive statistics on.

Those of you who have not seen it should have a look at Jonathan  
Cryer's commentary
on Excel, available at the URL:

http://www.stat.uiowa.edu/~jcryer/JSMTalk2001.pdf

Executive summary:  Friends don't let friends use Excel for statistics.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confidenti...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] The l1ce function in lasso2: The bound and absolute.t parameters.

2007-08-28 Thread Søren Højsgaard
Dear all,
 
I am quite puzzled about the bound and absolute.t arguments to the l1ce 
function in the lasso2 package. (The l1ce function estimates the regression 
parameter b in a regression model y=Xb+e subject to the constraint that |b|https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] quntile(table)?

2007-08-28 Thread Greg Snow
See the wtd.quantile function in the Hmisc package.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Seung Jun
> Sent: Tuesday, August 28, 2007 8:23 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] quntile(table)?
> 
> Hi,
> 
> I have data in the following form:
> 
>   index  count
> -7  32
>  19382
>  22192
>  7 190
> 11 201
> 
> I'd like to get quantiles from the data.  I thought about 
> something like this:
> 
>   index <- c(-7, 1, 2, 7, 11)
>   count <- c(32,  9382, 2192, 190, 201)
>   quantile(rep(index, count))
> 
> It answers correctly, but I feel it's wasteful especially 
> when count is generally large.  So, my question is, is there 
> a way to get quantiles directly from this table (without 
> coding at a low level)?
> 
> Thanks,
> Seung
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Forcing coefficients in lm object

2007-08-28 Thread Greg Snow
The important element in the fit object is named coefficients not coef.  
Sometimes the partial matching can cause confusion when it tries to help.  In 
your case it creates a copy of the coefficients, changes the 2nd value, then 
creates a new component to fit called coef with these values (not changing the 
original coefficients).  Since the predict, print, summary, etc. functions use 
the coefficients element rather than your new coef element, your changes are 
silently ignored.

One option is to spell out coefficients fully to replace that (though that 
could end up breaking other things), another possible option is to create the 
model using offsets (but I'm not sure how that would work in this case).

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> [EMAIL PROTECTED]
> Sent: Tuesday, August 28, 2007 7:33 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Forcing coefficients in lm object
> 
> Dear all,
> 
> I would like to use predict.lm() with an existing lm object 
> but with new arbitrary coefficients. I modify 'fit$coef' (see 
> example below) "by hand" but the actual model in 'fit' used 
> for prediction does not seem to be altered (although fit$coef is!).
> 
> Can anyone please help me do this properly?
> 
> Thanks in advance,
> 
> Jérémie
> 
> 
> 
> > dat <- data.frame(y=c(0,25,32,15), x=as.factor(c(1,1,2,2))) fit <- 
> > lm(y ~ x, data=dat) fit
> 
> Call:
> lm(formula = y ~ x, data = dat)
> 
> Coefficients:
> (Intercept)   x2  
>12.5 11.0  
> 
> > fit$coef[[2]] <- 100
> > dat.new <- data.frame(x=as.factor(c(1,2,1,2)))
> > predict.lm(fit, dat.new)
>1234 
> 12.5 23.5 12.5 23.5 
> > fit
> 
> Call:
> lm(formula = y ~ x, data = dat)
> 
> Coefficients:
> (Intercept)   x2  
>12.5 11.0  
> 
> > fit$coef
> (Intercept)  x2 
>12.5   100.0 
> >
> 
> 
> 
> Jérémie Lebrec
> Dept. of Medical Statistics and Bioinformatics Leiden 
> University Medical Center Postzone S-05-P P.O. Box 9600 2300 
> RC Leiden The Netherlands [EMAIL PROTECTED]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] RUnit and tracing errors

2007-08-28 Thread Ken Williams
Hi,

What's a good way to quickly determine the location of a failure in my RUnit
test suite?  For instance, if I do the following:

==
> library(RUnit)
> runTestSuite( defineTestSuite("MyTests", "src/r", testFuncRegexp="metrics") )


Executing test function test.metrics  ... Timing stopped at: 0.461 0.041 0.5
0 0 
Error in checkEquals(m$meanBPrefB, mean(c(33/100, 16/49))) :
Mean relative  difference: 0.3516807
 done successfully.

Number of test functions: 1
Number of errors: 0
Number of failures: 1
==

That doesn't give me any indication of where in test.metrics() the failure
was, so I generally end up inserting debug print statements, or loading my
test file directly and debugging the test.metrics function, or similar.

Is there any RUnit function analogous to traceback(), or a way to
interrogate the result of runTestSuite() to show me a stack trace?

I understand I can get a stack trace for an error, but I don't see a way to
get one for a failure.

Thanks,

-- 
Ken Williams
Research Scientist
The Thomson Corporation
Eagan, MN

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


Re: [R] ordered factors in data.frame

2007-08-28 Thread Greg Snow
Sorry this has taken so long to get back to you, I have been out of the office 
a lot recently.
 
The documentation for read.table suggests that since an as.ordered function 
exists, that you could just use "ordered" as a column class, but I don't know 
how well that works in practice.  In general I think it is better to let 
read.table create regular factors, then change them to ordered factors by hand 
afterwards.  For regular factors, the default ordering (since order does not 
matter) is alphabetical by factor level.  This is not usually the correct 
ordering for ordered factors and read.table has no way of knowing what the 
proper order should be.  When you change them by hand you can specify the 
ordering rather than taking the usually wrong default.
 
 

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



 




From: Birgit Lemcke [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 24, 2007 2:13 AM
To: Greg Snow
Cc: R Hilfe
Subject: Re: [R] ordered factors in data.frame


Thanks a lot Greg for your help. 

This works fine.

Normally I use a vector to set the classes for the variables:

Classe<-cclasses <- c(rep("factor", 14), rep("numeric", 4))
Table1<-read.table("Name", sep = ";", colClasses = Classe)


How can I implement to set colClasses as ordererd factor here.


Following works not:


Classe<-cclasses <- c(rep("factor", 61), rep("numeric", 14), 
rep("odered", 10))


Thanks in advance

Birgit







Am 23.08.2007 um 21:21 schrieb Greg Snow:


The attach function only attachs a copy of the data (changes to 
the data don't show up in the attached copy).  Also you need to tell R what to 
do with the result of as.ordered (where to save it).

Try something like:


table$V3 <- as.ordered(table$V3)


Or


table <- transform(table, V3=as.ordered(V3) )


Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111




-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of Birgit Lemcke
Sent: Thursday, August 23, 2007 11:28 AM
To: R Hilfe
Subject: [R] ordered factors in data.frame

Hello I need a tiny peace of help. (PPC Mac Os X 
10.4.10; R 2.5.1)

I have a data.frame with numeric and factor variables.
I would like to convert same of the factors to ordered 
factors.

I tried with:

attach (table)

as.ordered (V3)

but this gives me only the V3 Vector as ordred back but 
in 
the data.frame (str(Table)) it is still not ordered.

How can I do that?

Thanks for your help.

I am still a beginner.

Greetings

Birgit

Now I would like to
Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
[EMAIL PROTECTED]






[[alternative HTML version deleted]]






Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
[EMAIL PROTECTED]
 






[[alternative HTML version deleted]]

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


Re: [R] data formatting: from rows to columns

2007-08-28 Thread James W. MacDonald
Hi Federico,

Federico Calboli wrote:
> Hi All,
> 
> I have some data I need to write as a file from R to use in a different 
> program. 
> My data comes as a numeric matrix of n rows and 2 colums, I need to transform 
> each row as a two rows 1 col output, and separate the output of each row with 
> a 
> blanck line.
> 
> Foe instance I need to go from this:
> 
>   V2  V3
> 27  2032567  19
> 28  2035482  19
> 126 2472826  19
> 132 2473320  19
> 136 2035480 135
> 145 2062458 135
> 148 2074927 135
> 151 2102395 142
> 156 2027252 142
> 158 2473082 142
> 
> to
> 
> 2032567
> 19
> 
> 2035482
> 19
> 
> 2472826
> 19
> 
> 2473320
> 19
> 
> 2035480
> 135
> 
> ...
> 
> Any hint? I seem a bit stuck. cat(unlist(data), file ='data.txt', sep = '\n') 
> (obviously) does not work...

Likely somebody will come up with something better, but this works. Say 
the matrix above is called 'mat':

con <- file("filename.txt", "w")
for(i in 1:dim(mat)[1]) cat(paste(mat[i,], collapse="\n"), "\n\n", file=con)
close(con)

Best,

Jim


> 
> Cheers,
> 
> Fede
> 
> 
> 
> 
> 
> 

-- 
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623

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


Re: [R] Rmpi and x86

2007-08-28 Thread Prof Brian Ripley
On Tue, 28 Aug 2007, Martin Morgan wrote:

> Edna --
>
> I'll keep this on the list, so that others will learn, and others will
> correct me when I give bad advice!
>
>> relocation R_X86_64_32 against `lam_mpi_comm_world' can not be used
>> when making a shared object; recompile with -fPIC
>
> This likely means that your lam was not built with the --enable-shared
> configure option, as documented in the installation guide. (It might
> also mean that R was not configure with --enable-R-shlib; the message
> is opaque to me).

The line above is

/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/libmpi.a(infoset.o):

so it means lam needs to be rebuilt either with --enable-shared or just 
with -fPIC added to CFLAGS.  (Users migrating from i386 Linux to x86_64 
Linux got quite used to this quirk.)

> I believe others on the list have only had success with specific
> versions of LAMMPI, so that would be the next place to look (after
> sorting out the shared library issue)
>
> Martin
>
> "Edna Bell" <[EMAIL PROTECTED]> writes:
>
>> Here is what happens:
>> Note: lam-7.1.4
>>
>> linux-tw9c:/home/bell/Desktop/R-2.5.1/bin # ./R CMD INSTALL --clean
>> Rmpi_0.5-3.tar.gz
>> * Installing to library '/home/bell/Desktop/R-2.5.1/library'
>> * Installing *source* package 'Rmpi' ...
>> checking for gcc... gcc
>> checking for C compiler default output... a.out
>> checking whether the C compiler works... yes
>> checking whether we are cross compiling... no
>> checking for suffix of executables...
>> checking for suffix of object files... o
>> checking whether we are using the GNU C compiler... yes
>> checking whether gcc accepts -g... yes
>> checking for gcc option to accept ANSI C... none needed
>> checking how to run the C preprocessor... gcc -E
>> checking for egrep... grep -E
>> checking for ANSI C header files... yes
>> checking for sys/types.h... yes
>> checking for sys/stat.h... yes
>> checking for stdlib.h... yes
>> checking for string.h... yes
>> checking for memory.h... yes
>> checking for strings.h... yes
>> checking for inttypes.h... yes
>> checking for stdint.h... yes
>> checking for unistd.h... yes
>> checking mpi.h usability... yes
>> checking mpi.h presence... yes
>> checking for mpi.h... yes
>> Try to find libmpi or libmpich ...
>> checking for main in -lmpi... yes
>> Try to find liblam ...
>> checking for main in -llam... yes
>> checking for openpty in -lutil... yes
>> checking for main in -lpthread... yes
>> configure: creating ./config.status
>> config.status: creating src/Makevars
>> ** libs
>> gcc -std=gnu99 -I/home/bell/Desktop/R-2.5.1/include
>> -I/home/hodgesse/Desktop/R-2.5.1/include -DPACKAGE_NAME=\"\"
>> -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
>> -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
>> -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1
>> -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
>> -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1   -DMPI2 -I/usr/local/include
>> -fpic  -g -O2 -c conversion.c -o conversion.o
>> gcc -std=gnu99 -I/home/bell/Desktop/R-2.5.1/include
>> -I/home/bell/Desktop/R-2.5.1/include -DPACKAGE_NAME=\"\"
>> -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
>> -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
>> -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1
>> -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
>> -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1   -DMPI2 -I/usr/local/include
>> -fpic  -g -O2 -c internal.c -o internal.o
>> gcc -std=gnu99 -I/home/bell/Desktop/R-2.5.1/include
>> -I/home/bell/Desktop/R-2.5.1/include -DPACKAGE_NAME=\"\"
>> -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
>> -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
>> -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1
>> -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
>> -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1   -DMPI2 -I/usr/local/include
>> -fpic  -g -O2 -c RegQuery.c -o RegQuery.o
>> gcc -std=gnu99 -I/home/bell/Desktop/R-2.5.1/include
>> -I/home/bell/Desktop/R-2.5.1/include -DPACKAGE_NAME=\"\"
>> -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
>> -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
>> -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1
>> -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
>> -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1   -DMPI2 -I/usr/local/include
>> -fpic  -g -O2 -c Rmpi.c -o Rmpi.o
>> gcc -std=gnu99 -shared -L/usr/local/lib64 -o Rmpi.so conversion.o
>> internal.o RegQuery.o Rmpi.o -lmpi -llam -lutil -lpthread
>> /usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/bin/ld:
>> /usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/libmpi.a(infoset.o):
>> relocation R_X86_64_32 against `lam_mpi_comm_world' can not be used
>> when making a shared object; recompile with -fPIC
>> /usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/libmpi.a:
>> could not read symbols: Bad

Re: [R] logic operation on an array

2007-08-28 Thread Charles C. Berry

an array is just a vector with attributes.

> all ( diag(2) == 0 )
[1] FALSE
> all ( diag(2)*0 == 0 )
[1] TRUE
>

On Tue, 28 Aug 2007, Gang Chen wrote:

> I want to check whether all the components of a vector (or an array)
> are 0, and if they are I will skip the later computations. Of course
> I can create a loop to go through all the components. However is
> there an R function for this purpose more efficient than looping?
>
> Thanks a lot,
> Gang
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Variance explained by cluster analysis

2007-08-28 Thread jiho
Hello,

As suggested in "De'ath, 2002. Multivariate regression trees: A new  
technique for modelling species-environment relationships. Ecology, 83 
(4):1105-1117" (for those interested), I am trying to compare the  
performance of a multivariate regression tree to a cluster analysis.  
A simple partitioning with k clusters (as done by `pam`) seemed  
straightforward and appropriate to compare to an MRT with k leaves.
Now I am looking for a measure of how much variance each of these  
methods explains. The MRT analysis provides me with such a measure. I  
was wondering what I could use in a cluster analysis. When plotting  
the pam object with which.plots=clusplot, there is a message at the  
bottom of the plot: "These two components explain x% of the point  
variability". Can I safely assume that this is a percentage of  
variance explained by the k clusters? Is there anything else that I  
could compute?
More generally, am I totally wrong in comparing these two methods?  
Are there some references particularly appropriate to this? (NB: I am  
already hunting down the Kaufman, L. and Rousseeuw
  book)

Thank you in advance for your help.

JiHO
---
http://jo.irisson.free.fr/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Interpreting the eigen value of a population matrix (2nd try)

2007-08-28 Thread Anouk Simard
Thanks for telling me that you could not get my message, I hope this work
better...

so my question was:

I built a population matrix to which I applied the fonction eigen in order
to find the main parameters about my population. I know that the first
eigen value correspond to lambda or exponential growth rate of my
population. My problem is that I want to have the 95% confidence interval
of the specific lambda (1.056 in the case). Is there a way to do that? Are
the other eigen value shown in the output could help me doing it.
I would very appreciate any help.
Thanks for your time

$values
[1] 1.0561867+0.000i 0.0749653+0.5249157i 0.0749653-0.5249157i
[4] 0.4498348+0.0795373i 0.4498348-0.0795373i -0.3357868+0.000i
$vectors
[1,] -0.72849129+0i -0.11058308+0.3293511i -0.11058308-0.3293511i
0.00244042+0.03012017i 0.00244042-0.03012017i
[2,] -0.41384232+0i 0.35124594+0.1765638i 0.35124594-0.1765638i
0.01004458+0.03839895i 0.01004458-0.03839895i
[3,] -0.27427879+0i 0.29630718-0.4260863i 0.29630718+0.4260863i
0.02540181+0.05526223i 0.02540181-0.05526223i
[4,] -0.34274458+0i -0.62502691+0.000i -0.62502691+0.000i
0.55688585-0.17705587i 0.55688585+0.17705587i
[5,] -0.31754610+0i 0.19351247+0.1625154i 0.19351247-0.1625154i
-0.73460380+0.i -0.73460380+0.i
[6,] -0.06705781+0i -0.00340804-0.0295753i -0.00340804+0.0295753i
0.30711075+0.13557984i 0.30711075-0.13557984i

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


[R] data formatting: from rows to columns

2007-08-28 Thread Federico Calboli
Hi All,

I have some data I need to write as a file from R to use in a different 
program. 
My data comes as a numeric matrix of n rows and 2 colums, I need to transform 
each row as a two rows 1 col output, and separate the output of each row with a 
blanck line.

Foe instance I need to go from this:

  V2  V3
27  2032567  19
28  2035482  19
126 2472826  19
132 2473320  19
136 2035480 135
145 2062458 135
148 2074927 135
151 2102395 142
156 2027252 142
158 2473082 142

to

2032567
19

2035482
19

2472826
19

2473320
19

2035480
135

...

Any hint? I seem a bit stuck. cat(unlist(data), file ='data.txt', sep = '\n') 
(obviously) does not work...

Cheers,

Fede






-- 
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG

Tel  +44 (0)20 7594 1602 Fax (+44) 020 7594 3193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com

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


Re: [R] Excel

2007-08-28 Thread bogdan romocea
On a related note, there's one other amazingly stupid thing that Excel
(2002 SP3) does - it exports to CSV the numbers as you see them
displayed, and not as they were entered/imported in the first place.
For example, 1.2345678 will be exported to CSV/tab delimited as 1.23
if that column is formatted to show 2 decimals. Whoever doesn't pay
attention gets what s/he deserves for trusting Excel in the first
place.


> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of David Scott
> Sent: Monday, August 27, 2007 10:11 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Excel
>
>
> A common process when data is obtained in an Excel
> spreadsheet is to save
> the spreadsheet as a .csv file then read it into R. Experienced users
> might have learned to be wary of dates (as I have) but
> possibly have not
> experienced what just happened to me. I thought I might just
> share it with
> r-help as a cautionary tale.
>
> I received an Excel file giving patient details. Each patient
> had an ID
> code in the form of three letters followed by four digits.
> (Actually a New
> Zealand National Health Identification.) I saved the .xls
> file as .csv.
> Then I opened up the .csv (with Excel) to look at it. In the
> column of ID
> codes I saw: Aug-99. Clicking on that entry it showed 1/08/2699.
>
> In a column of character data, Excel had interpreted AUG2699
> as a date.
>
> The .csv did not actually have a date in that cell, but if I
> had saved the
> .csv file it would have.
>
> David Scott
>
> _
> David Scott Department of Statistics, Tamaki Campus
>   The University of Auckland, PB 92019
>   Auckland 1142,NEW ZEALAND
> Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000
> Email: [EMAIL PROTECTED]
>
> Graduate Officer, Department of Statistics
> Director of Consulting, Department of Statistics
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Factor levels

2007-08-28 Thread Gabor Grothendieck
You can create your own class and pass that to read table.  In
the example below Fld2 is read in with factor levels C, A, B
in that order.


library(methods)
setClass("my.levels")
setAs("character", "my.levels",
  function(from) factor(from, levels = c("C", "A", "B")))


### test ###

Input <- "Fld1 Fld2
10 A
20 B
30 C
40 A
"
DF <- read.table(textConnection(Input), header = TRUE,
  colClasses = c("numeric", "my.levels"))
str(DF)
# or
DF <- read.table(textConnection(Input), header = TRUE,
  colClasses = list(Fld2 = "my.levels"))
str(DF)


On 8/28/07, Sébastien <[EMAIL PROTECTED]> wrote:
> Dear R-users,
>
> I have found this not-so-recent post in the archives  -
> http://tolstoy.newcastle.edu.au/R/devel/00a/0291.html - while I was
> looking for a particular way to reorder factor levels. The question
> addressed by the author was to know if the read.table function could be
> modified to order the levels of newly created factors "according to the
> order that they appear in the data file". Exactly what I am looking for.
> As there was no reply to this post, I wonder if any move have been made
> towards the implementation of this suggestion. A quick look at
> ?read.table tells me that if this option was implemented, it was not in
> the read.table function...
>
> Sebastien
>
> PS: I am sorry to post so many messages on the list, but I am learning R
> (basically by trials & errors ;-) ) and no one around me has even a
> slight notion about it...
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Rmpi and x86

2007-08-28 Thread Martin Morgan
Edna --

I'll keep this on the list, so that others will learn, and others will
correct me when I give bad advice!

> relocation R_X86_64_32 against `lam_mpi_comm_world' can not be used
> when making a shared object; recompile with -fPIC

This likely means that your lam was not built with the --enable-shared
configure option, as documented in the installation guide. (It might
also mean that R was not configure with --enable-R-shlib; the message
is opaque to me).

I believe others on the list have only had success with specific
versions of LAMMPI, so that would be the next place to look (after
sorting out the shared library issue)

Martin

"Edna Bell" <[EMAIL PROTECTED]> writes:

> Here is what happens:
> Note: lam-7.1.4
>
> linux-tw9c:/home/bell/Desktop/R-2.5.1/bin # ./R CMD INSTALL --clean
> Rmpi_0.5-3.tar.gz
> * Installing to library '/home/bell/Desktop/R-2.5.1/library'
> * Installing *source* package 'Rmpi' ...
> checking for gcc... gcc
> checking for C compiler default output... a.out
> checking whether the C compiler works... yes
> checking whether we are cross compiling... no
> checking for suffix of executables...
> checking for suffix of object files... o
> checking whether we are using the GNU C compiler... yes
> checking whether gcc accepts -g... yes
> checking for gcc option to accept ANSI C... none needed
> checking how to run the C preprocessor... gcc -E
> checking for egrep... grep -E
> checking for ANSI C header files... yes
> checking for sys/types.h... yes
> checking for sys/stat.h... yes
> checking for stdlib.h... yes
> checking for string.h... yes
> checking for memory.h... yes
> checking for strings.h... yes
> checking for inttypes.h... yes
> checking for stdint.h... yes
> checking for unistd.h... yes
> checking mpi.h usability... yes
> checking mpi.h presence... yes
> checking for mpi.h... yes
> Try to find libmpi or libmpich ...
> checking for main in -lmpi... yes
> Try to find liblam ...
> checking for main in -llam... yes
> checking for openpty in -lutil... yes
> checking for main in -lpthread... yes
> configure: creating ./config.status
> config.status: creating src/Makevars
> ** libs
> gcc -std=gnu99 -I/home/bell/Desktop/R-2.5.1/include
> -I/home/hodgesse/Desktop/R-2.5.1/include -DPACKAGE_NAME=\"\"
> -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
> -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
> -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1
> -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
> -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1   -DMPI2 -I/usr/local/include
> -fpic  -g -O2 -c conversion.c -o conversion.o
> gcc -std=gnu99 -I/home/bell/Desktop/R-2.5.1/include
> -I/home/bell/Desktop/R-2.5.1/include -DPACKAGE_NAME=\"\"
> -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
> -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
> -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1
> -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
> -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1   -DMPI2 -I/usr/local/include
> -fpic  -g -O2 -c internal.c -o internal.o
> gcc -std=gnu99 -I/home/bell/Desktop/R-2.5.1/include
> -I/home/bell/Desktop/R-2.5.1/include -DPACKAGE_NAME=\"\"
> -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
> -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
> -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1
> -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
> -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1   -DMPI2 -I/usr/local/include
> -fpic  -g -O2 -c RegQuery.c -o RegQuery.o
> gcc -std=gnu99 -I/home/bell/Desktop/R-2.5.1/include
> -I/home/bell/Desktop/R-2.5.1/include -DPACKAGE_NAME=\"\"
> -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
> -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1
> -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1
> -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
> -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1   -DMPI2 -I/usr/local/include
> -fpic  -g -O2 -c Rmpi.c -o Rmpi.o
> gcc -std=gnu99 -shared -L/usr/local/lib64 -o Rmpi.so conversion.o
> internal.o RegQuery.o Rmpi.o -lmpi -llam -lutil -lpthread
> /usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/bin/ld:
> /usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/libmpi.a(infoset.o):
> relocation R_X86_64_32 against `lam_mpi_comm_world' can not be used
> when making a shared object; recompile with -fPIC
> /usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/libmpi.a:
> could not read symbols: Bad value
> collect2: ld returned 1 exit status
> make: *** [Rmpi.so] Error 1
> chmod: cannot access `/home/bell/Desktop/R-2.5.1/library/Rmpi/libs/*':
> No such file or directory
> ERROR: compilation failed for package 'Rmpi'
> ** Removing '/home/bell/Desktop/R-2.5.1/library/Rmpi'
> linux-tw9c:/home/bell/Desktop/R-2.5.1/bin #
>
>
>
> On 8/28/07, Martin Morgan <[EMAIL PROTECTED]> wrote:
>> Hi Edna --
>>
>> I have Rmpi 0.5-3 under R 2.5.1

[R] Factor levels

2007-08-28 Thread Sébastien
Dear R-users,

I have found this not-so-recent post in the archives  - 
http://tolstoy.newcastle.edu.au/R/devel/00a/0291.html - while I was 
looking for a particular way to reorder factor levels. The question 
addressed by the author was to know if the read.table function could be 
modified to order the levels of newly created factors "according to the 
order that they appear in the data file". Exactly what I am looking for.
As there was no reply to this post, I wonder if any move have been made 
towards the implementation of this suggestion. A quick look at 
?read.table tells me that if this option was implemented, it was not in 
the read.table function...

Sebastien

PS: I am sorry to post so many messages on the list, but I am learning R 
(basically by trials & errors ;-) ) and no one around me has even a 
slight notion about it...

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


Re: [R] Experimental Design with R

2007-08-28 Thread S Ellison
A full factorial can be generated using expand.grid.
Try AlgDesign, BHH2 and conf.design for various fractional and D-optimal design 
generators; they all work.
I haven't tried the experiment package yet, though the synopsis looks 
interesting.
The 'Design' package itself I found disappointing for the kind of industrial 
experiments that Taguchi designs are aimed at; that clearly has other (and 
rather bigger!) aims; a case of differing interpretations of what 'Design' 
really is.

AFAIK, though, none of those do Taguchi designs, response surface designs or 
much on mixture designs as such... and there seem to be no R tools targeted at 
process/formulation optimisation at the analysis stage. For example, there 
isn't a simple-to-use quadratic response surface modelling widget that allows 
you to drop terms quickly and easily and then find maxima on the resulting 
fitted surface (assuming you trust it as far as you can spit). It can all be 
done with lm, optim and a bit of patience, but not exactly intuitively.  Bit of 
a gap in the R arsenal, that, I felt. Sadly (before someone points out the 
obvious remedy) not one I have time to write a package for myself. 

But I too, may have missed something and would welcome correction.

Steve Ellison



>>> Marc BERVEILLER <[EMAIL PROTECTED]> 28/08/2007 14:11:53 >>>
Dear R-users,

I want to know if there is a package that allows to define different 
experimental designs (factorial, orthogonal, taguchi)
and to compare them.
I don't found one in the R-web site, but it is possible I missed it!

Thank you in advance

Sincerely,
Marc

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

***
This email and any attachments are confidential. Any use, co...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] attempt at making a polygon class failed

2007-08-28 Thread Leeds, Mark \(IED\)
I was reading a presentation of Professor Peng's and typed the
presentation code into R but I changed it to make plot.polygon a 
separate function instread of defining the function in SetMethod itself
as he did. Is that the problem with the code below because
plot(p) just gives me zero. Thanks.


setClass("polygon", representation(x = "numeric",
   y = "numeric"))

plot <- function(object)
{
return(0)
}

setGeneric("plot")

plot.polygon <- function(x, y, ...) {
xlim <- range([EMAIL PROTECTED])
ylim <- range([EMAIL PROTECTED])
plot(0,0, type = "n", xlim = xlim, ylim = ylim, ...)
xp <- c([EMAIL PROTECTED], [EMAIL PROTECTED])
yp <- c([EMAIL PROTECTED], [EMAIL PROTECTED])
lines(xp, yp)
}


setMethod("plot","polygon",plot.polygon)

p <- new("polygon", x = c(1,2,3,4), y = c(1,2,3,1))

plot(p)


This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

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


Re: [R] Forcing coefficients in lm object

2007-08-28 Thread Prof Brian Ripley

It is fit$coefficients, not fit$coef .


From the help page:


name: A literal character string or a name (possibly backtick
  quoted).  For extraction, this is normally (see under
  Environments) partially matched to the 'names' of the object.

Note the qualifier 'for extraction', so you assigned a new element with 
name 'coef', and predict.lm used fit$coefficients.



On Tue, 28 Aug 2007, [EMAIL PROTECTED] wrote:


Dear all,

I would like to use predict.lm() with an existing lm object but with new arbitrary 
coefficients. I modify 'fit$coef' (see example below) "by hand" but the actual 
model in 'fit' used for prediction does not seem to be altered (although fit$coef is!).

Can anyone please help me do this properly?

Thanks in advance,

Jérémie




dat <- data.frame(y=c(0,25,32,15), x=as.factor(c(1,1,2,2)))
fit <- lm(y ~ x, data=dat)
fit


Call:
lm(formula = y ~ x, data = dat)

Coefficients:
(Intercept)   x2
  12.5 11.0


fit$coef[[2]] <- 100
dat.new <- data.frame(x=as.factor(c(1,2,1,2)))
predict.lm(fit, dat.new)

  1234
12.5 23.5 12.5 23.5

fit


Call:
lm(formula = y ~ x, data = dat)

Coefficients:
(Intercept)   x2
  12.5 11.0


fit$coef

(Intercept)  x2
  12.5   100.0






Jérémie Lebrec
Dept. of Medical Statistics and Bioinformatics
Leiden University Medical Center
Postzone S-05-P
P.O. Box 9600
2300 RC Leiden
The Netherlands
[EMAIL PROTECTED]

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



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Efficient way to parse string and construct data.frame

2007-08-28 Thread Gabor Grothendieck
Try this:

> s <- c("1 ,2 ,3",  "4 ,5 ,6")
> read.csv(textConnection(s), header = FALSE)
  V1 V2 V3
1  1  2  3
2  4  5  6
>


On 8/28/07, yoo <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I have this list of strings
> [1] "1 ,2 ,3"  "4 ,5 ,6"
>
> Is there an efficient way to convert it to data.frame:
>   V1  V2  V3
> 1   1   23
> 2   4   56
>
> Like I can use strsplit to get to a list of split strings.. and then use say
> a = strsplit(mylist, ",")
> data.frame(V1 = lapply(a, function(x){x[1]}), V2 = lapply(a,
> function(x){x[2]}),.)
>
> but i'm loop through that list so many times.. so I'm hesitated to use
> that..
>
> Thanks a lot for your great help before and this time as well!!
> - boy
> --
> View this message in context: 
> http://www.nabble.com/Efficient-way-to-parse-string-and-construct-data.frame-tf4342441.html#a12370234
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Efficient way to parse string and construct data.frame

2007-08-28 Thread Henrique Dallazuanna
Hi,

do.call("rbind", lapply(strsplit(mylist, ","), as.numeric))

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

On 28/08/07, yoo <[EMAIL PROTECTED]> wrote:
>
>
> Hi all,
>
> I have this list of strings
> [1] "1 ,2 ,3"  "4 ,5 ,6"
>
> Is there an efficient way to convert it to data.frame:
>V1  V2  V3
> 1   1   23
> 2   4   56
>
> Like I can use strsplit to get to a list of split strings.. and then use
> say
> a = strsplit(mylist, ",")
> data.frame(V1 = lapply(a, function(x){x[1]}), V2 = lapply(a,
> function(x){x[2]}),.)
>
> but i'm loop through that list so many times.. so I'm hesitated to use
> that..
>
> Thanks a lot for your great help before and this time as well!!
> - boy
> --
> View this message in context:
> http://www.nabble.com/Efficient-way-to-parse-string-and-construct-data.frame-tf4342441.html#a12370234
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Efficient way to parse string and construct data.frame

2007-08-28 Thread yoooooo

Hi all, 

I have this list of strings
[1] "1 ,2 ,3"  "4 ,5 ,6"

Is there an efficient way to convert it to data.frame:
   V1  V2  V3
1   1   23
2   4   56

Like I can use strsplit to get to a list of split strings.. and then use say
a = strsplit(mylist, ",")
data.frame(V1 = lapply(a, function(x){x[1]}), V2 = lapply(a,
function(x){x[2]}),.)

but i'm loop through that list so many times.. so I'm hesitated to use
that.. 

Thanks a lot for your great help before and this time as well!! 
- boy
-- 
View this message in context: 
http://www.nabble.com/Efficient-way-to-parse-string-and-construct-data.frame-tf4342441.html#a12370234
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Experimental Design with R

2007-08-28 Thread Bert Gunter
Please use R's search tools.

RSiteSearch("experimental design", restr = "funct") 

finds optBlock() in the AlgDesign package as the 10th hit.

Whether this package will have what you want is another issue. 

Bert Gunter
Genentech Nonclinical Statistics

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Marc BERVEILLER
Sent: Tuesday, August 28, 2007 6:12 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Experimental Design with R

Dear R-users,

I want to know if there is a package that allows to define different
experimental designs (factorial, orthogonal, taguchi)
and to compare them.
I don't found one in the R-web site, but it is possible I missed it!

Thank you in advance

Sincerely,
Marc

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] lm.ridge fit with some dummy variables (w/o intercept)

2007-08-28 Thread Young Cho
I have columns which sum to one. They are membership dummies, fractions are
allowed - I made an example:

x <- c( 9.899898,6.9555431,-1.251,0.5200,0.480,0.000,-2.2384737,
16.791361,6.8924369,-3.286,0.78846154,0.2115385,0.000,-0.4720061,
6.115735,-5.8381799,-1.176,1.,0.000,0.000,-0.6312019,
10.325595,5.4950276,-2.634,1.,0.000,0.000,1.4729420,
3.800141,4.1287662,-2.243,0.8300,0.170,0.000,,0.9314859,
2.159567,-2.3952889,-4.645,0.5300,0.000,0.470,0.7252069,
21.536111,3.3844964,-4.352,1.,0.000,0.000,-0.9931833,
7.526573,-1.1675684,-5.023,1.,0.000,0.000,0.2397390,
28.684897,-0.4594389,-3.233,0.8900,0.070,0.040,0.6017004,
0.894931,-0.9059129,-5.023,0.04347826,0.000,0.9565217,0.6081505)
x = matrix(x,ncol=10)
x = t(x)
colnames(x) = c('a','b','c','d','e','f','y')
>  x
  a  b  c  d e f  y
 [1,]  9.899898  6.9555431 -1.251 0.5200 0.480 0.000 -2.2384737
 [2,] 16.791361  6.8924369 -3.286 0.78846154 0.2115385 0.000 -0.4720061
 [3,]  6.115735 -5.8381799 -1.176 1. 0.000 0.000 -0.6312019
 [4,] 10.325595  5.4950276 -2.634 1. 0.000 0.000  1.4729420
 [5,]  3.800141  4.1287662 -2.243 0.8300 0.170 0.000  0.9314859
 [6,]  2.159567 -2.3952889 -4.645 0.5300 0.000 0.470  0.7252069
 [7,] 21.536111  3.3844964 -4.352 1. 0.000 0.000 -0.9931833
 [8,]  7.526573 -1.1675684 -5.023 1. 0.000 0.000  0.2397390
 [9,] 28.684897 -0.4594389 -3.233 0.8900 0.070 0.040  0.6017004
[10,]  0.894931 -0.9059129 -5.023 0.04347826 0.000 0.9565217  0.6081505

> apply(x[,4:6],1,sum)
 [1] 1 1 1 1 1 1 1 1 1 1

I am trying to use lm.ridge and got some problems on how to extract
parameter estimates. E.g., for lambda = 0 case (I cut and pasted at the
bottom), how to backout the coef estimate to match them with lm fit? In
general, for any given lambda, how to back out the original scale coef
estimates?

> lm.fit = lm(y~.-a-1,data=data.frame(x),weights=a)
> ridge.fit = lm.ridge(y~.-a-1,data=data.frame(x),weights=a,lambda=0)
> ridge.fit
 b  c  d  e  f
 0.1125886  0.1748883  0.9122774 -5.9140208  1.8784332
> lm.fit

Call:
lm(formula = y ~ . - a - 1, data = data.frame(x), weights = a)

Coefficients:
   b c d e f
 0.04232   0.32343   1.36039  -4.67399   3.29727

Thanks so much in advance!

Young

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Interpreting the eigen value of a population matrix (2nd try)

2007-08-28 Thread Anouk Simard
Thanks for telling me that you could not get my message, I hope this work
better...

so my question was:

I built a population matrix to which I applied the fonction eigen in order
to find the main parameters about my population. I know that the first
eigen value correspond to lambda or exponential growth rate of my
population. My problem is that I want to have the 95% confidence interval
of the specific lambda (1.056 in the case). Is there a way to do that? Are
the other eigen value shown in the output could help me doing it. 
I would very appreciate any help. 
Thanks for your time

$values
[1] 1.0561867+0.000i 0.0749653+0.5249157i 0.0749653-0.5249157i
[4] 0.4498348+0.0795373i 0.4498348-0.0795373i -0.3357868+0.000i
$vectors
[1,] -0.72849129+0i -0.11058308+0.3293511i -0.11058308-0.3293511i
0.00244042+0.03012017i 0.00244042-0.03012017i
[2,] -0.41384232+0i 0.35124594+0.1765638i 0.35124594-0.1765638i
0.01004458+0.03839895i 0.01004458-0.03839895i
[3,] -0.27427879+0i 0.29630718-0.4260863i 0.29630718+0.4260863i
0.02540181+0.05526223i 0.02540181-0.05526223i
[4,] -0.34274458+0i -0.62502691+0.000i -0.62502691+0.000i
0.55688585-0.17705587i 0.55688585+0.17705587i
[5,] -0.31754610+0i 0.19351247+0.1625154i 0.19351247-0.1625154i
-0.73460380+0.i -0.73460380+0.i
[6,] -0.06705781+0i -0.00340804-0.0295753i -0.00340804+0.0295753i
0.30711075+0.13557984i 0.30711075-0.13557984i

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


Re: [R] Rmpi and x86

2007-08-28 Thread Martin Morgan
Hi Edna --

I have Rmpi 0.5-3 under R 2.5.1 with LAM 7.1.2 installed on an x86_64
SuSE 10.0. 

I installed (as a regular user, to my own disc space) LAM and ran
through some basic checks (lamboot / lamhalt, checking that I could
compile the demo programs)

After downloading Rmpi_0.5.3.tar.gz, I did

CC=mpicc R CMD INSTALL --clean Rmpi_0.5.3.tar.gz

the configure script of Rmpi found libmpi and liblam in my LAMHOME,
and also -lutil and -lpthread. Source files compiled without any
issues, and the package installed. If I have not issued a lamboot
command, inside R,

> library(Rmpi)

loads the library and indicates that it is starting lam. If I have
already issued lamboot, then library(Rmpi) loads as expected.

Where do things go wrong for you?

Martin

"Edna Bell" <[EMAIL PROTECTED]> writes:

> Dear R Gurus:
>
> Is there a problem with Rmpi on x86 with SUSE 10.1, please?
>
> I've tried everything and it still won't load.
>
> Has anyone else dealt with this please?
>
> Thanks,
> Edna Bell
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Martin Morgan
Bioconductor / Computational Biology
http://bioconductor.org

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] logic operation on an array

2007-08-28 Thread Gang Chen
I want to check whether all the components of a vector (or an array)  
are 0, and if they are I will skip the later computations. Of course  
I can create a loop to go through all the components. However is  
there an R function for this purpose more efficient than looping?

Thanks a lot,
Gang

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Experimental Design with R

2007-08-28 Thread Marc BERVEILLER
Dear R-users,

I want to know if there is a package that allows to define different 
experimental designs (factorial, orthogonal, taguchi)
and to compare them.
I don't found one in the R-web site, but it is possible I missed it!

Thank you in advance

Sincerely,
Marc

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


Re: [R] oddity with method definition

2007-08-28 Thread Faheem Mitha



On Tue, 28 Aug 2007, Faheem Mitha wrote:


Warning message:
in the method signature for function "bar" no definition for class: 
“baz” in: matchSignature(signature, fdef, where)


I'm being dense. That just means that the class "baz" has not been 
defined, presumably.

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


Re: [R] oddity with method definition

2007-08-28 Thread Faheem Mitha


Hi Dr Lumley,

Thanks to you and Dr. Murdoch for your helpful explanations. See below.

On Mon, 27 Aug 2007, Thomas Lumley wrote:


On Mon, 27 Aug 2007, Faheem Mitha wrote:



setClass("foo", representation(x="numeric"))

bar <- function(object)
  {
return(0)
  }

bar.foo <- function(object)
  {
print([EMAIL PROTECTED])
  }
setMethod("bar", "foo", bar.foo)

bar(f)

# bar(f) gives 1.


Not for me. It gives

bar(f)

Error: object "f" not found
Error in bar(f) : error in evaluating the argument 'object' in selecting a
method for function 'bar'

However, if I do
f = new("foo", x= 1)
first, it gives 1.


bar <- function(object)
  {
return(0)
  }


Here you have masked the generic bar() with a new function bar(). 
Redefining bar() is the problem, not the second setMethod().



bar.foo <- function(object)
  {
print([EMAIL PROTECTED])
  }
setMethod("bar", "foo", bar.foo)


Because there was a generic bar(), even though it is overwritten by the 
new bar(), setMethod() doesn't automatically create another generic.



f = new("foo", x= 1)

bar(f)

# bar(f) gives 0, not 1.



Because bar() isn't a generic function

bar

function(object)
  {
return(0)
  }


If you had used setGeneric() before setMethod(), as recommended, your 
example would have done what you expected, but it would still have wiped 
out any previous methods for bar() -- eg, try
 setMethod("bar","baz", function(object) print("baz")) before you 
redefine bar(), and notice that getMethod("bar","baz") no longer finds 
it.


Actually, it does not appear to be wiped. getMethod finds the "baz" 
version and the "foo" version, but it seems to use the default even for 
foo, which is of course wrong. Am I missing something? See below. Thanks.


I do get this warning message. Don't know what it means, though.

Warning message:
in the method signature for function "bar" no definition for class: 
“baz” in: matchSignature(signature, fdef, where)


   Faheem.

setClass("foo", representation(x="numeric"))

bar <- function(object)
  {
return(0)
  }

setGeneric("bar")

bar.foo <- function(object)
  {
print([EMAIL PROTECTED])
  }

setMethod("bar", "foo", bar.foo)

setMethod("bar", "baz", function(object) print("baz"))

bar <- function(object)
  {
return(0)
  }

bar.foo <- function(object)
   {
print([EMAIL PROTECTED])
   }
setMethod("bar", "foo", bar.foo)

f = new("foo", x= 1)
bar(f) # returns 0

*

getMethod("bar", "baz")

Method Definition:

function (object)
print("baz")

Signatures:
object
target  "baz"
defined "baz"


getMethod("bar", "foo")

Method Definition:

function (object)
{
print([EMAIL PROTECTED])
}

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


Re: [R] quntile(table)?

2007-08-28 Thread roger koenker
You could use:

require(quantreg)
  rq(index ~ 1, weights=count, tau=0:5/5)

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


On Aug 28, 2007, at 9:22 AM, Seung Jun wrote:

> Hi,
>
> I have data in the following form:
>
>   index  count
> -7  32
>  19382
>  22192
>  7 190
> 11 201
>
> I'd like to get quantiles from the data.  I thought about something  
> like this:
>
>   index <- c(-7, 1, 2, 7, 11)
>   count <- c(32,  9382, 2192, 190, 201)
>   quantile(rep(index, count))
>
> It answers correctly, but I feel it's wasteful especially when count
> is generally large.  So, my question is, is there a way to get
> quantiles directly from this table (without coding at a low level)?
>
> Thanks,
> Seung
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Interpreting the eigen value of a population matrix

2007-08-28 Thread Ted Harding
On 28-Aug-07 14:12:22, Marie Anouk Simard wrote:




It would seem (from the headers) that Marie sent her message
within a "TNEF" attachment, which the R-help server has duly
stripped off!

I would suggest thatshe re-sends her message in plain text,
so that we can all read it (and it will not get stripped).

Ted.

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


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 28-Aug-07   Time: 15:29:12
-- XFMail --

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] quntile(table)?

2007-08-28 Thread Seung Jun
Hi,

I have data in the following form:

  index  count
-7  32
 19382
 22192
 7 190
11 201

I'd like to get quantiles from the data.  I thought about something like this:

  index <- c(-7, 1, 2, 7, 11)
  count <- c(32,  9382, 2192, 190, 201)
  quantile(rep(index, count))

It answers correctly, but I feel it's wasteful especially when count
is generally large.  So, my question is, is there a way to get
quantiles directly from this table (without coding at a low level)?

Thanks,
Seung

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Interpreting the eigen value of a population matrix

2007-08-28 Thread Marie Anouk Simard

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


Re: [R] Forcing coefficients in lm object

2007-08-28 Thread Henrique Dallazuanna
Hi,

names(fit)
fit$coefficients[[2]] <- 100

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

On 28/08/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Dear all,
>
> I would like to use predict.lm() with an existing lm object but with new
> arbitrary coefficients. I modify 'fit$coef' (see example below) "by hand"
> but the actual model in 'fit' used for prediction does not seem to be
> altered (although fit$coef is!).
>
> Can anyone please help me do this properly?
>
> Thanks in advance,
>
> Jérémie
>
>
>
> > dat <- data.frame(y=c(0,25,32,15), x=as.factor(c(1,1,2,2)))
> > fit <- lm(y ~ x, data=dat)
> > fit
>
> Call:
> lm(formula = y ~ x, data = dat)
>
> Coefficients:
> (Intercept)   x2
>12.5 11.0
>
> > fit$coef[[2]] <- 100
> > dat.new <- data.frame(x=as.factor(c(1,2,1,2)))
> > predict.lm(fit, dat.new)
>1234
> 12.5 23.5 12.5 23.5
> > fit
>
> Call:
> lm(formula = y ~ x, data = dat)
>
> Coefficients:
> (Intercept)   x2
>12.5 11.0
>
> > fit$coef
> (Intercept)  x2
>12.5   100.0
> >
>
>
>
> Jérémie Lebrec
> Dept. of Medical Statistics and Bioinformatics
> Leiden University Medical Center
> Postzone S-05-P
> P.O. Box 9600
> 2300 RC Leiden
> The Netherlands
> [EMAIL PROTECTED]
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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

2007-08-28 Thread Petr PIKAL
[EMAIL PROTECTED] napsal dne 28.08.2007 13:33:13:

> You don't have installed the akima pakage.
> 
> install.packages("akima", dep=T)

And wait about two months and update your R version to 2.6.0. Or update 
now to 2.5.1

Regards

Petr


> 
> -- 
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
> 
> On 28/08/07, Ola Asteman <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > I got the Warning message below when I tried to load Locfit. What is
> > wrong?
> >
> > Regards
> > Ola Asteman
> >
> >
> > 
> 
--
> >
> > R version 2.4.0 (2006-10-03)
> > Copyright (C) 2006 The R Foundation for Statistical Computing
> > ISBN 3-900051-07-0
> >
> > R is free software and comes with ABSOLUTELY NO WARRANTY.
> > You are welcome to redistribute it under certain conditions.
> > Type 'license()' or 'licence()' for distribution details.
> >
> > R is a collaborative project with many contributors.
> > Type 'contributors()' for more information and
> > 'citation()' on how to cite R or R packages in publications.
> >
> > Type 'demo()' for some demos, 'help()' for on-line help, or
> > 'help.start()' for an HTML browser interface to help.
> > Type 'q()' to quit R.
> >
> > > library(foreign)
> > > library(mgcv)
> > This is mgcv 1.3-19
> > > library(locfit)
> > Loading required package: akima
> > Error: package 'akima' could not be loaded
> > In addition: Warning message:
> > there is no package called 'akima' in: library(pkg, character.only = 
TRUE,
> > logical = TRUE, lib.loc = lib.loc)
> > >
> >
> >
> >
> >
> > 
--
> > This e-mail and any attachment may be confidential and m...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Forcing coefficients in lm object

2007-08-28 Thread J.J.P.Lebrec
Dear all,

I would like to use predict.lm() with an existing lm object but with new 
arbitrary coefficients. I modify 'fit$coef' (see example below) "by hand" but 
the actual model in 'fit' used for prediction does not seem to be altered 
(although fit$coef is!).

Can anyone please help me do this properly?

Thanks in advance,

Jérémie



> dat <- data.frame(y=c(0,25,32,15), x=as.factor(c(1,1,2,2)))
> fit <- lm(y ~ x, data=dat)
> fit

Call:
lm(formula = y ~ x, data = dat)

Coefficients:
(Intercept)   x2  
   12.5 11.0  

> fit$coef[[2]] <- 100
> dat.new <- data.frame(x=as.factor(c(1,2,1,2)))
> predict.lm(fit, dat.new)
   1234 
12.5 23.5 12.5 23.5 
> fit

Call:
lm(formula = y ~ x, data = dat)

Coefficients:
(Intercept)   x2  
   12.5 11.0  

> fit$coef
(Intercept)  x2 
   12.5   100.0 
>



Jérémie Lebrec
Dept. of Medical Statistics and Bioinformatics
Leiden University Medical Center
Postzone S-05-P
P.O. Box 9600
2300 RC Leiden
The Netherlands
[EMAIL PROTECTED]

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


Re: [R] Column naming mystery

2007-08-28 Thread Werner Wernersen
Hi,

thank a lot for your answers! 

As other people get the correct result but I get this
mysterious result with this script even after running
it on a freshly started R, it must be a problem with
my particular R setup. I'll try updating.

Thanks for the help, now I know where I have to
search.
  Werner

--- Søren Højsgaard <[EMAIL PROTECTED]>
schrieb:

> I'd be glad to help, but I don't think I understand
> the problem. Here's what I get:
> > x <-
>
as.data.frame(matrix(ncol=3,seq(1,12),dimnames=list(c(),c("hh","total","total.inf"
> > x
>   hh total total.inf
> 1  1 5 9
> 2  2 610
> 3  3 711
> 4  4 812
> > summaryBy(total+total.inf~hh,x,FUN=sum)
>   hh total.sum total.inf.sum
> 1  1 5 9
> 2  2 610
> 3  3 711
> 4  4 812
> 
> Looks as expected to me. 
> 
> Regards
> Søren Højsgaard
>  
> 
> 
> -Oprindelig meddelelse-
> Fra: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] På vegne
> af Werner Wernersen
> Sendt: 27. august 2007 15:21
> Til: r-help@stat.math.ethz.ch
> Emne: Re: [R] Column naming mystery
> 
> Sorry that the problem description was not
> sufficient.
> Here is a self-contained code replicating the
> problem:
> 
> require(doBy)
> x <-
>
as.data.frame(matrix(ncol=3,seq(1,12),dimnames=list(c(),c("hh","total","total.inf"
> summaryBy(total+total.inf~hh,x,FUN=sum)
> 
> What surprises me are the zeros in the resulting
> total.sum column. The problem remains if total.inf
> is renamed to totalinf or total_inf but not if
> renamed to ttotal.inf .
> 
> Can anyone explain to me what the rules for naming
> columns are so that I can avoid such mistakes in the
> future?
> 
> Thanks a lot!
> 
> 
>   
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] validate (package Design): error message "subscript out of bounds"

2007-08-28 Thread Dirk Eddelbuettel

On 28 August 2007 at 08:04, Frank E Harrell Jr wrote:
| Wentzel-Larsen, Tore wrote:
| > Thanks,
| > I use Design version 2.1-1 (and as provided, R 2.5.1 on Windows XP).
| 
| Sorry I missed the latter.
| 
| > The redundancies in object names were for my own convience, as part of 
| > a larger command file, and the validation of this univariate model was
| > only included to ease comparison with the main multivariate model. I have 
| 
| A minor point: adding more variables to the right hand side makes the 
| model a multivariable model.  It is still univariate as it has only one 
| dependent variable.
| 
| > tried to access Design version 2.0_12, but only managed to access version
| > 2.1_1 of Design in my Windows implementation of R2.5.1 (the choice of 
| > operative system is made by my institution and I am only entitled to use 
| > Windows).
| 
| My mistake again.  I forgot that the Debian repositories for CRAN are 
| behind. 

In which way?  I se that ...

[EMAIL PROTECTED]:~$ wajig policy r-cran-design
r-cran-design:
  Installed: (none)
  Candidate: 2.1-1-1
  Version table:
 2.1-1-1 0
500 http://ron testing/main Packages
 -1 http://ron unstable/main Packages
[EMAIL PROTECTED]:~$ wajig policy r-cran-hmisc
r-cran-hmisc:
  Installed: 3.4-2-2
  Candidate: 3.4-2-2
  Version table:
 *** 3.4-2-2 0
500 http://ron testing/main Packages
 -1 http://ron unstable/main Packages
100 /var/lib/dpkg/status
[EMAIL PROTECTED]:~$ 

... both Hmisc and Design are at current version in both testing and
unstable, and these are the versions on CRAN.  What am I missing?

Thanks, Dirk 

| 
| Frank
| 
| > Best, Tore
| > 
| > -Opprinnelig melding-
| > Fra: Frank E Harrell Jr [mailto:[EMAIL PROTECTED] 
| > Sendt: 28. august 2007 03:17
| > Til: Wentzel-Larsen, Tore
| > Kopi: r-help@stat.math.ethz.ch
| > Emne: Re: [R] validate (package Design): error message "subscript out of 
bounds"
| > 
| > Wentzel-Larsen, Tore wrote:
| >> Dear R users 
| >>
| >> I use Windows XP, R2.5.1 (I have read the posting guide, I have 
| >> contacted the package maintainer first, it is not homework).
| >>
| >> In a research project on renal cell carcinoma we want to compute 
| >> Harrell's c index, with optimism correction, for a multivariate 
| >> Cox regression and also for some univariate Cox models.
| >> For some of these univariate models I have encountered an error
| >> message (and no result produced) from the function validate i 
| >> Frank Harrell's Design package:
| >>
| >> Error in Xb(x[, xcol, drop = FALSE], coef, non.slopes, non.slopes.in.x,  : 
| >> subscript out of bounds
| >>
| >> The following is an artificial example wherein I have been able to 
| >> reproduce this error message (actual data has been changed to preserve
| >> confidentiality):
| > 
| > I could not reproduce the error on R 2.5.1 on linux using version 2.0-12 
| > of Design (you did not provide this information).
| > 
| > Your code involved a good deal of extra typing.  Here is a streamlined 
| > version:
| > 
| > bc <- data.frame(time1 = c(9,24,28,43,58,62,66,107,116,118,123,
| > 127,129,131,137,138,139,140,148,169,176,179,188,196,210,218,
| > 
| > bc
| > 
| > library(Design)
| > 
| > dd <- with(bc, datadist(bc1, age, adjto.cat='first'))
| > options(datadist = 'dd')
| > 
| > f <- cph(Surv(time1,status1) ~ bc1,
| >   data = bc, x=TRUE, y=TRUE, surv=TRUE)
| > anova(f)
| > f
| > summary(f)
| > 
| > val <- validate(f, B=200, dxy=TRUE)
| > 
| > I don't get much value of putting the type of an object as part of the 
| > object's name, as information within objects defines the object type/class.
| > 
| > There is little reason to validate a one degree of freedom model.
| > 
| > Frank
| > 
| >> library(Design)
| >>
| >> # an example data frame:
| >> frame.bc <- data.frame(time1 = c(9,24,28,43,58,62,66,107,116,118,123,
| >>127,129,131,137,138,139,140,148,169,176,179,188,196,210,218,
| >>1,1,1,2,2,3,4,8,23,32,33,34,43,44,48,51,52,54,59,59,60,60,62,
| >>65,65,68,70,72,73,74,81,84,88,98,99,106,107,115,115,117,119,
| >>120,122,122,122,122,126,128,130,135,136,136,138,149,151,154,
| >>157,159,161,164,164,164,166,172,172,176,179,180,183,183,184,
| >>187,190,197,201,201,203,203,203,209,210,214,219,227,233,4,18,
| >>49,113,147,1,1,2,2,2,2,2,3,4,6,6,6,6,6,6,6,6,9,9,9,9,9,10,10,
| >>10,11,12,12,12,13,14,14,17,18,18,19,19,20,20,21,21,21,21,22,23,
| >>23,24,28,28,29,29,32,34,35,38,38,48,48,52,52,54,54,56,64,67,67,
| >>69,70,70,72,84,88,90,114,115,140,142,154,171,195),
| >>status1 = c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
| >>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
| >>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
| >>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
| >>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
| >>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

Re: [R] validate (package Design): error message "subscript out of bounds"

2007-08-28 Thread Frank E Harrell Jr
Wentzel-Larsen, Tore wrote:
> Thanks,
> I use Design version 2.1-1 (and as provided, R 2.5.1 on Windows XP).

Sorry I missed the latter.

> The redundancies in object names were for my own convience, as part of 
> a larger command file, and the validation of this univariate model was
> only included to ease comparison with the main multivariate model. I have 

A minor point: adding more variables to the right hand side makes the 
model a multivariable model.  It is still univariate as it has only one 
dependent variable.

> tried to access Design version 2.0_12, but only managed to access version
> 2.1_1 of Design in my Windows implementation of R2.5.1 (the choice of 
> operative system is made by my institution and I am only entitled to use 
> Windows).

My mistake again.  I forgot that the Debian repositories for CRAN are 
behind.  I updated to latest Design in CRAN and found the bug.  I will 
send a separate note with a new version of the function in question for 
you to source( ) to override the current function.

Frank

> Best, Tore
> 
> -Opprinnelig melding-
> Fra: Frank E Harrell Jr [mailto:[EMAIL PROTECTED] 
> Sendt: 28. august 2007 03:17
> Til: Wentzel-Larsen, Tore
> Kopi: r-help@stat.math.ethz.ch
> Emne: Re: [R] validate (package Design): error message "subscript out of 
> bounds"
> 
> Wentzel-Larsen, Tore wrote:
>> Dear R users 
>>
>> I use Windows XP, R2.5.1 (I have read the posting guide, I have 
>> contacted the package maintainer first, it is not homework).
>>
>> In a research project on renal cell carcinoma we want to compute 
>> Harrell's c index, with optimism correction, for a multivariate 
>> Cox regression and also for some univariate Cox models.
>> For some of these univariate models I have encountered an error
>> message (and no result produced) from the function validate i 
>> Frank Harrell's Design package:
>>
>> Error in Xb(x[, xcol, drop = FALSE], coef, non.slopes, non.slopes.in.x,  : 
>> subscript out of bounds
>>
>> The following is an artificial example wherein I have been able to 
>> reproduce this error message (actual data has been changed to preserve
>> confidentiality):
> 
> I could not reproduce the error on R 2.5.1 on linux using version 2.0-12 
> of Design (you did not provide this information).
> 
> Your code involved a good deal of extra typing.  Here is a streamlined 
> version:
> 
> bc <- data.frame(time1 = c(9,24,28,43,58,62,66,107,116,118,123,
>   127,129,131,137,138,139,140,148,169,176,179,188,196,210,218,
> 
> bc
> 
> library(Design)
> 
> dd <- with(bc, datadist(bc1, age, adjto.cat='first'))
> options(datadist = 'dd')
> 
> f <- cph(Surv(time1,status1) ~ bc1,
>   data = bc, x=TRUE, y=TRUE, surv=TRUE)
> anova(f)
> f
> summary(f)
> 
> val <- validate(f, B=200, dxy=TRUE)
> 
> I don't get much value of putting the type of an object as part of the 
> object's name, as information within objects defines the object type/class.
> 
> There is little reason to validate a one degree of freedom model.
> 
> Frank
> 
>> library(Design)
>>
>> # an example data frame:
>> frame.bc <- data.frame(time1 = c(9,24,28,43,58,62,66,107,116,118,123,
>>  127,129,131,137,138,139,140,148,169,176,179,188,196,210,218,
>>  1,1,1,2,2,3,4,8,23,32,33,34,43,44,48,51,52,54,59,59,60,60,62,
>>  65,65,68,70,72,73,74,81,84,88,98,99,106,107,115,115,117,119,
>>  120,122,122,122,122,126,128,130,135,136,136,138,149,151,154,
>>  157,159,161,164,164,164,166,172,172,176,179,180,183,183,184,
>>  187,190,197,201,201,203,203,203,209,210,214,219,227,233,4,18,
>>  49,113,147,1,1,2,2,2,2,2,3,4,6,6,6,6,6,6,6,6,9,9,9,9,9,10,10,
>>  10,11,12,12,12,13,14,14,17,18,18,19,19,20,20,21,21,21,21,22,23,
>>  23,24,28,28,29,29,32,34,35,38,38,48,48,52,52,54,54,56,64,67,67,
>>  69,70,70,72,84,88,90,114,115,140,142,154,171,195),
>>  status1 = c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
>>  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
>>  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
>>  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
>>  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
>>  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
>>  1,1,1,1,1),
>>  bc1 = factor(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
>>  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
>>  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
>>  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,
>>  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
>>  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2),
>>  labels=c('bc.1','bc.2')),
>>  age = c(58,68,23,20,50,43,41,69,20,48,19,27,39,20,65,49,70,59,31,43,25,
>>  61,60,45,34,59,32,58,30,62,26,44,52,29,40,57,33,18,50,50,55,51,38,34,
>>  69,56,67,38,66,21,48,39

Re: [R] Excel

2007-08-28 Thread Robert A LaBudde
At 01:21 AM 8/28/2007, David wrote:
>On Tue, 28 Aug 2007, Robert A LaBudde wrote:
>
>>If you format the column as "Text", you won't have this problem. By
>>leaving the cells as "General", you leave it up to Excel to guess at
>>the correct interpretation.
>
>Not true actually. I had converted the column to Text because I saw 
>the interpretation as a date in the .xls file. I saved the .csv file 
>*after* the column had been converted to Text. Looking at the .csv 
>file in a text editor, the entry is correct.
>

You need to convert the column to Text before you enter the data. 
This tells Excel the presumption to use.

Converting to Text after you enter the values has no effect on 
previously entered values.

I've tested this using Excel 2000.


Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: [EMAIL PROTECTED]
Least Cost Formulations, Ltd.URL: http://lcfltd.com/
824 Timberlake Drive Tel: 757-467-0954
Virginia Beach, VA 23464-3239Fax: 757-467-2947

"Vere scire est per causas scire"

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


Re: [R] Column naming mystery

2007-08-28 Thread Søren Højsgaard
I'd be glad to help, but I don't think I understand the problem. Here's what I 
get:
> x <- 
> as.data.frame(matrix(ncol=3,seq(1,12),dimnames=list(c(),c("hh","total","total.inf"
> x
  hh total total.inf
1  1 5 9
2  2 610
3  3 711
4  4 812
> summaryBy(total+total.inf~hh,x,FUN=sum)
  hh total.sum total.inf.sum
1  1 5 9
2  2 610
3  3 711
4  4 812

Looks as expected to me. 

Regards
Søren Højsgaard
 


-Oprindelig meddelelse-
Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne af Werner Wernersen
Sendt: 27. august 2007 15:21
Til: r-help@stat.math.ethz.ch
Emne: Re: [R] Column naming mystery

Sorry that the problem description was not sufficient.
Here is a self-contained code replicating the problem:

require(doBy)
x <-
as.data.frame(matrix(ncol=3,seq(1,12),dimnames=list(c(),c("hh","total","total.inf"
summaryBy(total+total.inf~hh,x,FUN=sum)

What surprises me are the zeros in the resulting total.sum column. The problem 
remains if total.inf is renamed to totalinf or total_inf but not if renamed to 
ttotal.inf .

Can anyone explain to me what the rules for naming columns are so that I can 
avoid such mistakes in the future?

Thanks a lot!


  

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


Re: [R] FW: How to fit an linear model withou intercept

2007-08-28 Thread Eik Vettorazzi
Hi Mark,
I don't know wether you recived a sufficient reply or not, so here are 
my comments to your problem.
Supressing the constant term in a regression model will probably lead to 
a violation of the classical assumptions for this model.
 From the OLS normal equations (in matrix notation)
 (1)  (X'X)b=X'y
and the definition of the OLS residuals
 (2)  e = y-Xb
you get - by substituting y form (2) in (1)
   (X'X)b=(X'X)b+X'e
and hence
   X'e =0.
Without a constant term you cannot assure, that the ols residuals 
e=(y-Xb) will have zero mean, wich holds when involving a constant term, 
since the first equation of X'e = 0 gives in this case sum(e)=0.

For decomposing the TSS (y'y) into ESS (b'X'Xb) and RSS (e'e), which is 
needed to compute R², you will need X'e=0, because then the 
cross-product term b'X'e vanishes.
Correct me if I'm wrong.

Leeds, Mark (IED) schrieb:
> Park, Eik : Could you start from the bottom and read this when you have
> time. I really appreciate it.
>
> Basically, in a nutshell, my question is the "Hi John" part and I want
> to do my study correctly. Thanks a lot.
>
>
>
> -Original Message-
> From: Leeds, Mark (IED) 
> Sent: Thursday, August 23, 2007 1:05 PM
> To: 'John Sorkin'
> Cc: '[EMAIL PROTECTED]'
> Subject: RE: [R] How to fit an linear model withou intercept
>
>  Hi John : I'm from the R-list obviously and that was a nice example
> that I cut and pasted and learned from.  I'm Sorry to bother you but I
> had a non R question that I didn't want to pose to the R-list because I
> think It's been discussed a lot in the past but I never focused on the
> discussion. 
>
> I need to do a study where I decide between two different univariate
> regressions models. The LHS is the same in both cases and it's not the
> goal of the study to build a prediction model but rather to see which
> RHS ( univariate ) explains the LHS better. 
> It's actually in a time series framework also but that's not relevant
> for my question. My question has 2 parts : 
>
> 1) I was leaning towards using the R squared as the decision criteria (
> I will be Regressing monthly and over a couple of years so I will have
> about 24 rsquareds. I have tons of data For one monthly regression so I
> don't have to just do one big regression over the whole time period )
> but I noticed in your previous example that the model with intercept (
> compared to the model forced to have zero intercept ) had a lower R^2
> and a lower standard error at the same time ! So this asymmetry
> leads me to think that maybe I should be using standard error rather
> than Rsquared as my criteria ?
>
> 2) This is possibly related to 1 : Isn't there a problem with using the
> Rsquared for anything when you force no intercept ?
> I think I remember seeing discussions about this on the list. That's why
> I was thinking of including the intercept.
> ( intercept in my problem really has no meaning but I wanted to retain
> the validity of the Rsquared ) But, now that I see your email, maybe I
> should be still including an intercept and using standard error as the
> criteria.
> Or maybe when you include an intercept ( in both cases ) you don't get
> this asymmetry between Rsquared and standrd error. 
> I was surprised to see the asymmetry  but maybe it happens because one
> is comparing model with intercept to a model without intercept and no
> intercept probably renders the rsquared critieria meaningless in the
> latter.
>
> Thanks for any insight you can provide. I can also center and go without
> intercept because it sounded like you DEFINITELY preferred that Method
> over just not including an intercept at all.  I was thinking of sending
> this question to the R-list but I didn't want to get hammered because I
> know that this is not a new discussion. Thanks so much.
>
>
>   
> Mark
>
> P.S : How the heck did you get an MD and a Ph.D ? Unbelievable. Did you
> do them at the same time ? 
>
>
>
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of John Sorkin
> Sent: Thursday, August 23, 2007 9:29 AM
> To: David Barron; Michal Kneifl; r-help
> Subject: Re: [R] How to fit an linear model withou intercept
>
> Michael,
> Assuming you want a model with an intercept of zero, I think we need to
> ask you why you want an intercept of zero. When a "normal" regression
> indicates a non-zero intercet, forcing the regression line to have a
> zero intercept changes the meaning of the regression coefficients. If
> for some reason you want to have a zero intercept, but do not want to
> change the meaning of the regression coefficeints, i.e. you still what
> to minimize the sum of the square deviations from the BLUE (Best
> Leastsquares Unibiased Estimator) of the regression, you can center your
> dependent and indepdent variables re-run the regression. Centering means
> subtracting the mean of each variable from the variable before
> performing the regression. When you do this, the int

Re: [R] Changing tcl in boxplot

2007-08-28 Thread Uwe Ligges


[EMAIL PROTECTED] wrote:
> How can I change the tick marks in a boxplot so that they lie on the
> inside of the x and y axes? In plot I have been setting tcl=0.2 but
> that doesn't do anything in boxplot. What am I missing?

You cannot set "tcl" in arbitrary plot functions, but you can set it for 
the current device, hence

  par(tcl=0.2)
  boxplot(1:10)

does the trick.

Uwe Ligges


> Thanks,
> Emily
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Changing tcl in boxplot

2007-08-28 Thread ilikelotsofbroccoli
How can I change the tick marks in a boxplot so that they lie on the
inside of the x and y axes? In plot I have been setting tcl=0.2 but
that doesn't do anything in boxplot. What am I missing?
Thanks,
Emily

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


Re: [R] Limiting size of pairs plots

2007-08-28 Thread Prof Brian Ripley

From ?pairs


 The graphical parameter 'oma' will be set by 'pairs.default'
 unless supplied as an argument.

so try

pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species", pch = 21,
  bg = c("red", "green3", "blue")[unclass(iris$Species)],
  oma = c(8,3,5,3))



On Tue, 28 Aug 2007, Sébastien wrote:


Dear R-users,

I would like to add a legend at the bottom of pairs plots (it's my first
use of this function). With the plot function, I usually add some
additional space at the bottom when I define the size of the graphical
device (using mar); grid functions then allows me to draw my legend as I
want.
Unfortunatley, this technique does not seem to work with the pairs
function as the generated plots use all the available space on the
device (see below). I guess I am missing a key argument... my attempts
to modify the oma, mar, usr arguments were unsuccesfull, and I could not
find any helpful threads on the archives.

As usual, any advice would be greatly appreciated

Sebastien


pdf(file="C:/test.pdf", width=6, height= 6 + 0.2*6)

par(mar=c(5 + 6,4,4,2)+0.1)

pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species", pch = 21,
bg = c("red", "green3", "blue")[unclass(iris$Species)])

dev.off()

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



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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

2007-08-28 Thread Henrique Dallazuanna
You don't have installed the akima pakage.

install.packages("akima", dep=T)

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

On 28/08/07, Ola Asteman <[EMAIL PROTECTED]> wrote:
>
>
>
> I got the Warning message below when I tried to load Locfit. What is
> wrong?
>
> Regards
> Ola Asteman
>
>
> --
>
> R version 2.4.0 (2006-10-03)
> Copyright (C) 2006 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
>
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
>
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
>
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
>
> > library(foreign)
> > library(mgcv)
> This is mgcv 1.3-19
> > library(locfit)
> Loading required package: akima
> Error: package 'akima' could not be loaded
> In addition: Warning message:
> there is no package called 'akima' in: library(pkg, character.only = TRUE,
> logical = TRUE, lib.loc = lib.loc)
> >
>
>
>
>
> --
> This e-mail and any attachment may be confidential and may a...{{dropped}}
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Limiting size of pairs plots

2007-08-28 Thread Sébastien
Dear R-users,

I would like to add a legend at the bottom of pairs plots (it's my first 
use of this function). With the plot function, I usually add some 
additional space at the bottom when I define the size of the graphical 
device (using mar); grid functions then allows me to draw my legend as I 
want.
Unfortunatley, this technique does not seem to work with the pairs 
function as the generated plots use all the available space on the 
device (see below). I guess I am missing a key argument... my attempts 
to modify the oma, mar, usr arguments were unsuccesfull, and I could not 
find any helpful threads on the archives.

As usual, any advice would be greatly appreciated

Sebastien


pdf(file="C:/test.pdf", width=6, height= 6 + 0.2*6)

par(mar=c(5 + 6,4,4,2)+0.1)

pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species", pch = 21, 
bg = c("red", "green3", "blue")[unclass(iris$Species)])

dev.off()

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Nested functions.

2007-08-28 Thread nalluri pratap
Hi All,
   
  I have two variables X, Y. The question is "if the value of X is equal to 
one, then the values in Y have to be reversed other wise it should not perfom 
any action. I think this should be done using lapply function?
   
  Example
   
  Y values : 1 2 3  NA
  X  Y (ORIGINAL) Y (REVERSED)
  1 NA   1
  0   ---
  1   2 3
  1   1 4
  1   3 2
  ...
   
  Can anyone provide solution to this?
   
  Thanks,
  Pratap  
   

   
-

[[alternative HTML version deleted]]

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


Re: [R] outdated R and package dependencies; was: R Help

2007-08-28 Thread Uwe Ligges


Ola Asteman wrote:
> 
> I got the Warning message below when I tried to load Locfit. What is wrong?


Please read the posting guide which suggests to use a sensible subject line.



> Regards
> Ola Asteman
> 
> --
> 
> R version 2.4.0 (2006-10-03)


It makes sense to upgrade to a recent version of R.



> Copyright (C) 2006 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
> 
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
> 
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
> 
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
> 
>> library(foreign)
>> library(mgcv)
> This is mgcv 1.3-19
>> library(locfit)

How was locfit installed?

   install.packages("locfit", dependencies = TRUE)

should also install the package's dependencies - and you have not all 
installed, among them "akima".

Uwe Ligges





> Loading required package: akima
> Error: package 'akima' could not be loaded
> In addition: Warning message:
> there is no package called 'akima' in: library(pkg, character.only = TRUE,
> logical = TRUE, lib.loc = lib.loc)
> 
> 
> 
> --
> This e-mail and any attachment may be confidential and may a...{{dropped}}
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] a problem with the varimax() fonction (stat package)

2007-08-28 Thread Thierry Worch
Hi,I am puzzled with different results in R, compared to SPSS and 
Senstools.Net. After running a PCA on the three software (for R, I use the PCA 
function programmed on the FactoMineR package), I extracted the loadings. In 
the three cases, the loadings are exactly identical.Then, I applied the varimax 
rotation on these loadings, and unfortunately, the results differ. A quick look 
at the resulting rotation matrix (rotmat) shows me, that the results are 
"sorted" differently. Here are my results for the rotation matrix:On R: > 
complet.varimax <- varimax(complet.loadings,normalize=T)$rotmat> 
complet.varimax  [,1][,2][,3][,4]   [,5]   [,6]   [,7]   
[,8][1,]  0.529  -0.034  -0.411  -0.428  0.013 -0.297 -0.399  0.344[2,] -0.119  
 0.715  -0.194  -0.058  0.517 -0.219 -0.068 -0.337[3,]  0.081   0.087   0.722  
-0.017  0.250 -0.472  0.092  0.413[4,]  0.110   0.039  -0.172   0.860  0.139 
-0.013 -0.343  0.284[5,] -0.159  -0.353  -0.419   0.010  0.502 -0.114  0.578  
0.275[6,!
 ] -0.122  -0.065   0.184  -0.240  0.502  0.670 -0.357  0.248[7,]  0.612   
0.409   0.026   0.070 -0.061  0.420  0.497  0.159[8,] -0.522   0.427  -0.181  
-0.107 -0.379  0.043  0.042  0.595On SPSS and Senstools.Net:Rotation dim 1  
  dim 2dim 3dim 4dim 5dim 6dim 7dim 8dim 1-0,53 
   -0,41-0,43-0,40 0,03-0,34-0,30-0,01dim 2 
0,12-0,19-0,06-0,07-0,71 0,34-0,22-0,52dim 3
-0,08 0,72-0,02 0,09-0,09-0,41-0,47-0,25dim 4   
 -0,11-0,17 0,86-0,34-0,04-0,28-0,01-0,14dim 5  
   0,16-0,42 0,01 0,58 0,35-0,27-0,11-0,50dim 6 
0,12 0,18-0,24-0,36 0,07-0,25 0,67-0,50dim 7
 0,61-0,03-0,07-0,50 0,41 0,16-0,42-0,06dim 8   
 -0,52 0,18 0,11-0,04 0,43 0,60-0,04-0,38 Here, 
we can clearly see, that the results are!
  similar, but sorted differently (in R, the second column correspond t
o the 5th column in SPSS or Senstools.Net).Concerning the loadings after 
rotation, the results are different to (permutation are seen too).Please, could 
someone explain me what's happening?Personally, I have the feeling that the 
results differ...is it true? Which results should I trust?Should you need any 
further information for answering me, do not hesitate to contact me ([EMAIL 
PROTECTED]).I look forward to your response.Best regards, WORCH Thierry
_

[[replacing trailing spam]]

[[alternative HTML version deleted]]

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

2007-08-28 Thread Ola Asteman


I got the Warning message below when I tried to load Locfit. What is wrong?

Regards
Ola Asteman

--

R version 2.4.0 (2006-10-03)
Copyright (C) 2006 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(foreign)
> library(mgcv)
This is mgcv 1.3-19
> library(locfit)
Loading required package: akima
Error: package 'akima' could not be loaded
In addition: Warning message:
there is no package called 'akima' in: library(pkg, character.only = TRUE,
logical = TRUE, lib.loc = lib.loc)
>



--
This e-mail and any attachment may be confidential and may a...{{dropped}}

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

2007-08-28 Thread [EMAIL PROTECTED]
Using rcmdr i performed a pca
now i would like to build the orrelation matrix starting from the scores 
given by rcmdr...
any function about?
moreover, i should transform the pca components values from 0 to 256.

tahnks
duccio

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


Re: [R] validate (package Design): error message "subscript out of bounds"

2007-08-28 Thread Wentzel-Larsen, Tore
Thanks,
I use Design version 2.1-1 (and as provided, R 2.5.1 on Windows XP).
The redundancies in object names were for my own convience, as part of 
a larger command file, and the validation of this univariate model was
only included to ease comparison with the main multivariate model. I have 
tried to access Design version 2.0_12, but only managed to access version
2.1_1 of Design in my Windows implementation of R2.5.1 (the choice of 
operative system is made by my institution and I am only entitled to use 
Windows).
Best, Tore

-Opprinnelig melding-
Fra: Frank E Harrell Jr [mailto:[EMAIL PROTECTED] 
Sendt: 28. august 2007 03:17
Til: Wentzel-Larsen, Tore
Kopi: r-help@stat.math.ethz.ch
Emne: Re: [R] validate (package Design): error message "subscript out of bounds"

Wentzel-Larsen, Tore wrote:
> Dear R users 
> 
> I use Windows XP, R2.5.1 (I have read the posting guide, I have 
> contacted the package maintainer first, it is not homework).
> 
> In a research project on renal cell carcinoma we want to compute 
> Harrell's c index, with optimism correction, for a multivariate 
> Cox regression and also for some univariate Cox models.
> For some of these univariate models I have encountered an error
> message (and no result produced) from the function validate i 
> Frank Harrell's Design package:
> 
> Error in Xb(x[, xcol, drop = FALSE], coef, non.slopes, non.slopes.in.x,  : 
> subscript out of bounds
> 
> The following is an artificial example wherein I have been able to 
> reproduce this error message (actual data has been changed to preserve
> confidentiality):

I could not reproduce the error on R 2.5.1 on linux using version 2.0-12 
of Design (you did not provide this information).

Your code involved a good deal of extra typing.  Here is a streamlined 
version:

bc <- data.frame(time1 = c(9,24,28,43,58,62,66,107,116,118,123,
127,129,131,137,138,139,140,148,169,176,179,188,196,210,218,

bc

library(Design)

dd <- with(bc, datadist(bc1, age, adjto.cat='first'))
options(datadist = 'dd')

f <- cph(Surv(time1,status1) ~ bc1,
  data = bc, x=TRUE, y=TRUE, surv=TRUE)
anova(f)
f
summary(f)

val <- validate(f, B=200, dxy=TRUE)

I don't get much value of putting the type of an object as part of the 
object's name, as information within objects defines the object type/class.

There is little reason to validate a one degree of freedom model.

Frank

> 
> library(Design)
> 
> # an example data frame:
> frame.bc <- data.frame(time1 = c(9,24,28,43,58,62,66,107,116,118,123,
>   127,129,131,137,138,139,140,148,169,176,179,188,196,210,218,
>   1,1,1,2,2,3,4,8,23,32,33,34,43,44,48,51,52,54,59,59,60,60,62,
>   65,65,68,70,72,73,74,81,84,88,98,99,106,107,115,115,117,119,
>   120,122,122,122,122,126,128,130,135,136,136,138,149,151,154,
>   157,159,161,164,164,164,166,172,172,176,179,180,183,183,184,
>   187,190,197,201,201,203,203,203,209,210,214,219,227,233,4,18,
>   49,113,147,1,1,2,2,2,2,2,3,4,6,6,6,6,6,6,6,6,9,9,9,9,9,10,10,
>   10,11,12,12,12,13,14,14,17,18,18,19,19,20,20,21,21,21,21,22,23,
>   23,24,28,28,29,29,32,34,35,38,38,48,48,52,52,54,54,56,64,67,67,
>   69,70,70,72,84,88,90,114,115,140,142,154,171,195),
>   status1 = c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
>   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
>   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
>   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
>   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
>   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
>   1,1,1,1,1),
>   bc1 = factor(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
>   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
>   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
>   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,
>   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
>   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2),
>   labels=c('bc.1','bc.2')),
>   age = c(58,68,23,20,50,43,41,69,20,48,19,27,39,20,65,49,70,59,31,43,25,
>   61,60,45,34,59,32,58,30,62,26,44,52,29,40,57,33,18,50,50,55,51,38,34,
>   69,56,67,38,66,21,48,39,62,62,29,68,66,19,60,39,55,42,24,29,56,61,40,
>   52,19,40,33,67,66,51,48,63,60,58,68,60,53,20,45,62,37,38,61,63,43,67,
>   49,39,43,67,49,69,32,37,32,63,33,47,66,39,23,57,26,61,20,49,69,30,40,
>   29,38,66,60,69,69,44,65,25,41,53,18,55,45,59,49,27,51,29,67,26,24,26,
>   47,23,50,27,35,45,32,26,45,45,63,39,39,22,38,27,31,27,49,65,66,49,39,
>   21,51,49,55,63,19,26,50,21,24,34,65,33,55,33,36,53,48,25,54,58,60,34,
>   47,23,34,60,39,34,22,30,41,55,64,48,34,54))
> frame.bc
> 
> # preparing for a simple univariate Cox regression:
> dd.bc <- datadist(frame.bc[, c('bc1','age')], adjto.cat='

Re: [R] Excel

2007-08-28 Thread J Dougherty
On Monday 27 August 2007 22:21, David Scott wrote:
> On Tue, 28 Aug 2007, Robert A LaBudde wrote:
> > If you format the column as "Text", you won't have this problem. By
> > leaving the cells as "General", you leave it up to Excel to guess at
> > the correct interpretation.
>
> Not true actually. I had converted the column to Text because I saw the
> interpretation as a date in the .xls file. I saved the .csv file *after*
> the column had been converted to Text. Looking at the .csv file in a text
> editor, the entry is correct.
>
> I have just rechecked this.
>
> On reopening the .csv using Excel, the entry AUG2699 had been interpreted
> as a date, and was showing as Aug-99. Most bizarre is that the NHI value
> of AUG1838 has *not* been interpreted as a date.
>
Actually, in Excel 2000, he's right.  What you have to is be sure of is that 
the "'" that denotes a text entry precedes EVERY entry that can be confused 
with a date.  Selecting the entire column and setting the format to "text" 
*before* data is entered does this.  It will also create an appropriate *.csv 
file.  Excel is notable too because it will automatically convert "date-like" 
entries as you type.  In a column of IDs or similar critical data, that 
behaviour is really bad.  I have never tried the MS site, but I haven't been 
able to find any entry about how to turn that particular automatic behaviour 
off. 

However, while I have not experimented extensively, as far as I have 
experimented, OpenOffice spreadsheet does not behave this way.

JWDougherty

PS, I quit using Excel for most important work after it returned a negative 
variance on some data I was collecting descriptive statistics on.

JWD

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