[R] Sampling rows from a list

2003-09-19 Thread Erin Hodgess
Dear R People:

Here is a function that someone asked for today.

This is getting the sample from different rows from a list.

Hope this helps!

Sincerely,
Erin
 oe1

function(n) {

a1 - n%%3

n1 - seq(from=2,to=(n-1+a1),by=3)

n2 - c(1:n)[-n1]

if(a1 == 1)n2 - c(n2,n2[length(n2)])

if(a1 == 2)n2 - c(n2,n1[length(n1)])

n3 - length(n2)

y - rep(NA,n3)

i - 1

while(i = n3) {

a4 - n2[i]:n2[(i+1)]

if(length(a4)==1)a4 - c(a4,a4)

y[i:(i+1)] - sample(a4,replace=T,2)

i - i+2

}

return(y)

}



__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Extracting objects from a list of matrix

2003-09-19 Thread ZABALZA-MEZGHANI Isabelle
Hello,

I would like to have an advise about how to extract objects from a list of
matrixs
I have fitted models (stored in an object called model) using a matrix
response and the same formula and data. I get back, from summary.lm, as many
sumarries as I have responses.
Thus I have extract the coefficient matrix for each model with the following
command :

coefficients(summary(model))

My goal is only to get the t values for each model. Generally to extract a
colum from a matrix I do [,t value], and to apply a function to a list I
use lapply. But here, I can not manage to extract the columns, since the
[] function, is not really a function with arguments ...

Can someone give me a solution ? (in avoiding to make a loop around my list
components).

Thanks in advance,

Isabelle.


Isabelle Zabalza-Mezghani
IFP - Reservoir Engineering Department
Rueil-Malmaison - France

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] 3D plotting in R

2003-09-19 Thread Simon Blomberg
I can reccommend ggobi.

http://www.ggobi.org/

Install the binary standalone, and the Rggobi package for R (both are from the above 
site). Works fine for me on Windows 2000, R 1.7.1.

Cheers,

Simon.

Simon Blomberg, PhD
Depression  Anxiety Consumer Research Unit
Centre for Mental Health Research
Australian National University
http://www.anu.edu.au/cmhr/
[EMAIL PROTECTED]  +61 (2) 6125 3379


 -Original Message-
 From: Richard A. O'Keefe [mailto:[EMAIL PROTECTED]
 Sent: Friday, 19 September 2003 3:41 PM
 To: [EMAIL PROTECTED]
 Subject: [R] 3D plotting in R
 
 
 A student is trying to cluster some data.  Tree-building 
 things seem to
 be pretty hopeless (we've tried most of the ones in R, I think).
 Multi-dimensional scaling produces somewhat tantalising results:
 things do clump together somewhat, but the clusters overlap a lot.
 I was wondering if these was an artefact of squeezing it down to 2D,
 and whether 3D might be better.  So
 loc - cmdscale(dist(scale(log(data))), k=3)
 plot(loc)
 _but_ I still get a 2D plot.
 
 I know about persp(), and a bunch of other things in R that give me
 a 3d view of a 2d field (plots of a function of 2 arguments, in other
 words).  But I want to plot a bunch of 3D points and label them.
 
 If the worst comes to the worst, I'll dump them out in a file and use
 XLispStat to view them.
 
 I've asked previously whether there's a spinning plot in R, 
 and have been
 told that there isn't and why.  I've been given one anyway, 
 but it calls
 Tcl/Tk, and for some reason that doesn't work in my setup.
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Extracting objects from a list of matrix

2003-09-19 Thread Uwe Ligges
ZABALZA-MEZGHANI Isabelle wrote:

Hello,

I would like to have an advise about how to extract objects from a list of
matrixs
I have fitted models (stored in an object called model) using a matrix
response and the same formula and data. I get back, from summary.lm, as many
sumarries as I have responses.
Thus I have extract the coefficient matrix for each model with the following
command :
coefficients(summary(model))

My goal is only to get the t values for each model. Generally to extract a
colum from a matrix I do [,t value], and to apply a function to a list I
use lapply. But here, I can not manage to extract the columns, since the
[] function, is not really a function with arguments ...
Why not? Try e.g.:

X - matrix(1:4, 2)
[(X,,2)
So in order to solve your problem try:

 lapply(YourList, [, , t-value)

or use an anonymous function:

 lapply(YourList, function(x) x[, t-value])

Uwe Ligges



Can someone give me a solution ? (in avoiding to make a loop around my list
components).
Thanks in advance,

Isabelle.

Isabelle Zabalza-Mezghani
IFP - Reservoir Engineering Department
Rueil-Malmaison - France
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


lapply(., function(x) x[,t value])

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Save object R with tkgetSaveFile

2003-09-19 Thread Peter Wolf
[EMAIL PROTECTED] wrote:

HI, my question is about the function tkgetSavefile not save any file, for 
example the next script run OK but
not save the file who i like to save, how i cant to save and object R with 
tkgetSaveFile, how i use the
function save(objet, file=foo.R) with tkgetSaveFile ¿What is the error?. 
I'm work with R 1.7.1

library(tcltk)
x-1
filetypes - list({Texto {.txt}} {Word {.doc}} {Pdf {.pdf}} {Postscript 
{.ps}} {fuente C{.C}} {Eps {.eps}} {Latex {.tex}} {Todos 
*}) 
fileD - tkgetSaveFile
(filetypes=filetypes,initialdir=c:\\temp,defaultextension=.txt)
save(x,file=foo.R) #how i cant merge tkgetSaveFile with function save 
for to save the object x?
thanks Ruben

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 

Try:

x-1:3
a-tkgetSaveFile()
if(0length(a)) save(x,file=as.character(a))
Peter Wolf

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] what is mechanism of help(foo)?

2003-09-19 Thread Yiming Zhou
I wrote a R package, and installed it. But I don't understand how R can find right 
help content for object foo when calling help(foo). Who can give me underlying 
details or any reference regarding help(foo)?
 
In fact, after installing my package pkg_foo and calling library(pkg_foo), I can 
correcttly use any function and data in pkg_foo. But I can't get help content when I 
type ?function_foo. My package included the files CONTENTS, DESCRIPTION, 
INDEX, TITLE and subdirectories DATA, MAN, HELP, R. 
 
I built it in linux system, and install it in windows system. I tried to build it in 
windows system using Rcmd build package_foo. System complained: can't found 'sh', 
can't found 'tar' and 'gzip'.
 
I appreciate for any advises.
 
Many thanks.
 
Best wishes,
 
Yiming Zhou
 
 


-


[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] About PLS analysis

2003-09-19 Thread Sokratis Alikhanidi
   Dear colleagues,

May you point me out to the PLS module in R system?
I could not find it at all using PLS or partial as the search keywords.

Thank you.
Sokratis.

--
Sokratis ALIKHANIDI, Ph.D.
Department of Knowledge-based Information Engineering
Toyohashi University of Technology
1-1 Hibarigaoka, Tempaku-cho, Toyohashi 441, JAPAN
TEL: 0532-44-6892
FAX: 0532-44-6873
mailto:[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


R: [R] extracting columns with NA's

2003-09-19 Thread Vito Muggeo
If I have understood what you mean, you can use the (surely non-optimal)
code:

#build a matrix 
A-matrix(1:20,nrow=5)
A[2,4]-NA
A[,3]-rep(NA,nrow(A))

#count the missing value in each column
fi-apply(A,2,function(x)sum(is.na(x)))

#exclude column(s) having a number of NA equal to nrow(A). Of course you can
modify the == as well as nrow(A)
A1-A[!which(fi==nrow(A)),]


Hope this help you
best,
vito

- Original Message -
From: antonio rodriguez [EMAIL PROTECTED]
To: R-help [EMAIL PROTECTED]
Sent: Friday, September 19, 2003 11:58 AM
Subject: [R] extracting columns with NA's


 Hi All,

 How do I can delete from a matrix (or array) only those columns which have
 all their values set to NA?

 Cheers

 Antonio Rodriguez
 ---

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] extracting columns with NA's

2003-09-19 Thread Peter Wolf
antonio rodriguez wrote:

Hi All,

How do I can delete from a matrix (or array) only those columns which have
all their values set to NA?
Cheers

Antonio Rodriguez
---
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 

Try:

 x-matrix(1:16,4,4)
 x[col(x)=row(x)]-NA
 x[,! apply(x,2,function(x) all(is.na(x))) ]
[,1] [,2] [,3]
[1,]   NA   NA   NA
[2,]2   NA   NA
[3,]37   NA
[4,]48   12
Peter Wolf

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Installing from RPM on Red Hat 9

2003-09-19 Thread James Wettenhall
Ted,

If you are missing a shared library (libtk8.3.so) then you could 
just find the appropriate rpm on the RedHat9 CDs, perhaps 
tk-8.3.5-88.i386.rpm in /RedHat/RPMS on the second CD, and install 
it with sudo rpm -i.

BUT, there are some known bugs in the Tcl/Tk that comes with 
Redhat 9 (which don't exist in previous Redhat distributions) :

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=89098
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=101678
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=100793
http://www.interlink.com.au/anthony/tech/rh9-tcltk/

What I did recently on Redhat 9 is install Tcl/Tk 8.4 from 
source (configure;make;make install; for Tcl, then for Tk) and 
then install R from source (configure;make;make install).  You 
can get Tcl/Tk source from www.tcl.tk and to build them you need 
the X11 developer's kit which can be installed from rpm off the 
Redhat9 CDs : Install XFree86-devel-4.3.0-2.i386.rpm which requires 
fontconfig-devel-2.1-9.i386.rpm and freetype-2.1.3-6.i386.rpm.

Installing R from source will put it (by default) in 
/usr/local/bin/R rather than /usr/bin/R

HTH,
James

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] extracting the levels of a subset of data

2003-09-19 Thread Philipp Pagel
Hi!

  tmpdata-subset(myd, TYPE==A)
  levels(tmpdata$TYPE)
  [1] A B C
 
 I'd like to get only A as output...

rebuild the factor after subsetting:

tmpdata$TYPE - factor(tmp$TYPE)

If you want the levels of all factors in your data frame to be
adjusted you could also use:

tmpdata - data.frame(as.matrix( subset(myd, TYPE=='A') ))

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] extracting columns with NA's

2003-09-19 Thread Barry Rowlingson
antonio rodriguez wrote:
Hi All,

How do I can delete from a matrix (or array) only those columns which have
all their values set to NA?
 use 'apply' to sweep through columns using a little function that sees 
if all values in a column are NA:

eg: x:
 x
  [,1]  [,2] [,3]  [,4] [,5]   [,6]  [,7]
[1,] 0.8548990NA   NA 0.5548089   NA 0.63123175 0.1101337
[2,] 0.9593472 0.7681048   NA 0.3365029   NA 0.04580849NA
 x[,apply(x,2,function(col){!all(is.na(col))})]

  [,1]  [,2]  [,3]   [,4]  [,5]
[1,] 0.8548990NA 0.5548089 0.63123175 0.1101337
[2,] 0.9593472 0.7681048 0.3365029 0.04580849NA
I imagine solutions requiring fewer and fewer keystrokes will appear in 
R-help presently!

Baz

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] what is mechanism of help(foo)?

2003-09-19 Thread Uwe Ligges
Yiming Zhou wrote:

I wrote a R package, and installed it. But I don't understand how R can find right help content for object foo when calling help(foo). Who can give me underlying details or any reference regarding help(foo)?
 
In fact, after installing my package pkg_foo and calling library(pkg_foo), I can correcttly use any function and data in pkg_foo. But I can't get help content when I type ?function_foo. My package included the files CONTENTS, DESCRIPTION, INDEX, TITLE and subdirectories DATA, MAN, HELP, R. 
 
I built it in linux system, and install it in windows system. I tried to build it in windows system using Rcmd build package_foo. System complained: can't found 'sh', can't found 'tar' and 'gzip'.
 
I appreciate for any advises.
So you haven't installed it on Windows, I guess. You would have seen the 
same complaints during the installation process. So the help files have 
not been build from your Rd files (you have created those files, I presume).

Please read ...\rw1071\src\gnuwin32\readme.packages. It tells you which 
additional tools are required to build binary packages and install 
source packages.

Uwe Ligges




Many thanks.
 
Best wishes,
 
Yiming Zhou
 
 

-

	[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] extracting the levels of a subset of data

2003-09-19 Thread Jesus Frias
Hiya

 I'd like to get only A as output...

two solutions:
1.-use unique()

unique(tempdata$TYPE)

to get your answer


2.-or call factor again to reduce the levels:
 tmpd - subset(myd,clas==A)
 levels(tmpd$clas)
[1] A B C
 tmpd$clas - factor(tmpd$clas)
 levels(tmpd$clas)
[1] A


regards,

IOsu

 

-- 
This message has been scanned for content and 
viruses by the DIT ICT Services MailScanner Service,  
and is believed to be clean.
http://www.dit.ie

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] solved: extracting columns with NA's

2003-09-19 Thread antonio rodriguez
Many, many thanks to everybody. It helped a lot

Cheers

Antonio
---

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] what is mechanism of help(foo)?

2003-09-19 Thread Uwe Ligges
Uwe Ligges wrote:

Yiming Zhou wrote:

I wrote a R package, and installed it. But I don't understand how R 
can find right help content for object foo when calling help(foo). 
Who can give me underlying details or any reference regarding 
help(foo)?
 
In fact, after installing my package pkg_foo and calling 
library(pkg_foo), I can correcttly use any function and data in 
pkg_foo. But I can't get help content when I type ?function_foo. 
My package included the files CONTENTS, DESCRIPTION, INDEX, 
TITLE and subdirectories DATA, MAN, HELP, R.  
I built it in linux system, and install it in windows system. I tried 
to build it in windows system using Rcmd build package_foo. System 
complained: can't found 'sh', can't found 'tar' and 'gzip'.
 
I appreciate for any advises.


So you haven't installed it on Windows, I guess. You would have seen the 
same complaints during the installation process. So the help files have 
not been build from your Rd files (you have created those files, I 
presume).

Please read ...\rw1071\src\gnuwin32\readme.packages. It tells you which 
additional tools are required to build binary packages and install 
source packages.

Uwe Ligges
Let me add: Please read the manual Writing R Extensions as well!

Uwe Ligges

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] predict for mlm does not work properly

2003-09-19 Thread ZABALZA-MEZGHANI Isabelle
Hello,

I've just fitted a model with multi-responses, and I get an object of class
lm mlm.
My problem is that as soon as I invoke the predict method for a dataframe
newdata, the methods runs and give me back prediction at the fitting
points but not for newdata.

Does someone has an explanation for this behavior, and some ideas to make
predict.mlm work efficiently.

Thanks in advance

Isabelle Zabalza-Mezghani
IFP-Reservoir Engineering Department
Rueil-Malmaison - France

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] predict for mlm does not work properly

2003-09-19 Thread Liaw, Andy
 From: ZABALZA-MEZGHANI Isabelle 
 
 Hello,
 
 I've just fitted a model with multi-responses, and I get an 
 object of class lm mlm. My problem is that as soon as I 
 invoke the predict method for a dataframe newdata, the 
 methods runs and give me back prediction at the fitting 
 points but not for newdata.

What version of R and on what platform are you doing this?  What were the
commands that you tried?

In R-1.7.1 on WinXPPro, I get:

 df - data.frame(y1=rnorm(10), y2=rnorm(10), x1=rnorm(10),x2=rnorm(10))
 df2 - data.frame(y1=rnorm(10), y2=rnorm(10), x1=rnorm(10),x2=rnorm(10))
 try.mlm - lm(cbind(y1,y2) ~ x1+x2, data=df)
 predict(try.mlm)
y1  y2
1  -0.84974045 -0.19779627
2  -1.08128909  0.17851648
3   0.23572795  0.23167228
4  -0.65118764  0.09273186
5  -0.06741819  0.10396708
6  -0.88852774 -0.05386359
7  -0.21007585  0.07839343
8  -0.07061706  0.01714900
9  -0.67554077  0.07551119
10 -1.36196165  0.33502943
 predict(try.mlm, df2)

  y1y2
  1  -0.66079093  2.772385e-02
  2  -1.25399169  1.344038e-01
  3  -0.64321234  3.044455e-02
  4   0.29611924 -9.523683e-02
  5  -1.01594522  1.557392e-01
  6  -0.04513806 -1.529740e-01
  7  -0.38954683 -2.780412e-03
  8  -1.21828379 -2.460862e-01
  9  -0.38511937  6.092239e-02
  10 -0.34979146 -9.909837e-05

Seems fine to me.

Andy

 
 Does someone has an explanation for this behavior, and some 
 ideas to make predict.mlm work efficiently.
 
 Thanks in advance
 
 Isabelle Zabalza-Mezghani
 IFP-Reservoir Engineering Department
 Rueil-Malmaison - France
 
 __
 [EMAIL PROTECTED] mailing list 
 https://www.stat.math.ethz.ch/mailman/listinfo /r-help


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Evaluating outer observations in an lme object.

2003-09-19 Thread CG Pettersson
Hello everybody!
I´m working with a dataset from twelve fertilizer trials, where the
technical fertilizer product and application method, but not the
intensity of fertilization, is varied. (I´m using R1.7.1 and W2000.)

The call:

ejna1t4b.lme - lme( Yield ~ TrCode, data = ejna1t4,
+   random = ~ 1 | Trial/Block)

works as far as I can understand well, the Block structure of the
trials is used efficiently and everything looks nice according to
plots of the object.

Now I want to evaluate the influence of observations from the
different experimental places (for example soil analyses or rainfall)
- Could I do that without skipping the Trial/Block structure, or do I
have to start from scratch again? The observed values will naturally
only have one level for each Trial, so the term Trial/Block will host
the effects of all observed (and unobserved) phenomena in each trial.
Now I want to know where the effects come from.

I´ve been looking for a text on this, both in MASS and Pinheiro 
Bates, without finding any. Any hints of where to look?

Thanks
/CG

CG Pettersson, MSci, PhD Stud.
Swedish University of Agricultural Sciences
Dep. of Ecology and Crop Production. Box 7043
SE-750 07 Uppsala

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] 3D plotting in R

2003-09-19 Thread ucgamdo
For plotting 3D points, you might want to check the function 'cloud' in the
'lattice' package (some good examples in the help file), you can feed the 3
most important factors to the function and see a 3d rep of your data. A
perhaps, a better 3D representation comes from the function 'sm.density' in
the 'sm' package, follow the examples for the 3d case in help(sm.density).
If the data aggregates itself visually in obvious clusters, you can use the
functions 'pam' (for small datasets) or 'clara' (for larger ones) in the
package 'cluster' to identify which elements belong to each cluster. In
this case you should first determine visually, how many cluster are
present, and them, feed this value into these functions, say 

clara('data', k = 4)

where 'data' would, for example, be a 3 columns matrix representing some
sort of Principal Component Analysis, etc. and 4 is the number of groups
you suspect are present in your data.

Alternatevely, you can try independent component analysis on your data. I
think is more powerful analysis that goes beyond the classic principal
components stuff. Check package 'fastICA' in CRAN for details.

Hope this is useful.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] newby problem - concatenate lists

2003-09-19 Thread Axel Benz
Hi,
a very basic question:
What ist the easiest way in R to concatenate two lists of vectors?
E.g, I have
x-list(c(1,2))
y-list(c(3,4))
and I want to receive
list(c(1,2),c(3,4))

thank you!

Axel

Fraunhofer Institut fuer
Arbeitswirtschaft und Organisation (IAO)
Dipl. Inf. Axel Benz
Nobelstr. 12
D-70569 Stuttgart
Germany
Tel. +49(0)7119702289
Fax. +49(0)7119702192
mail: mailto:[EMAIL PROTECTED]
www: http://www.vis.iao.fhg.de



[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] newby problem - concatenate lists

2003-09-19 Thread Wiener, Matthew
c(x,y) will do it.
Hope this helps -Matt

-Original Message-
From: Axel Benz [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 19, 2003 8:57 AM
To: [EMAIL PROTECTED]
Subject: [R] newby problem - concatenate lists


Hi,
a very basic question:
What ist the easiest way in R to concatenate two lists of vectors?
E.g, I have
x-list(c(1,2))
y-list(c(3,4))
and I want to receive
list(c(1,2),c(3,4))

thank you!

Axel

Fraunhofer Institut fuer
Arbeitswirtschaft und Organisation (IAO)
Dipl. Inf. Axel Benz
Nobelstr. 12
D-70569 Stuttgart
Germany
Tel. +49(0)7119702289
Fax. +49(0)7119702192
mail: mailto:[EMAIL PROTECTED]
www: http://www.vis.iao.fhg.de



[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Weird problem with my code....

2003-09-19 Thread Guy Nason
Hi,

Thanks to Barry Rawlinson and Sundar Dorai-Raj the problem was solved.

The problem was that I was doing integer division when I should have 
been doing float division followed by ceil or floor.

Sorry about that and many thanks to those who took the time to look at this.

Best,
Guy
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] newby problem - concatenate lists

2003-09-19 Thread Liaw, Andy
Lists are just like vectors:

 x-list(c(1,2))
 y-list(c(3,4))
 c(x,y)
[[1]]
[1] 1 2

[[2]]
[1] 3 4

HTH,
Andy

 -Original Message-
 From: Axel Benz [mailto:[EMAIL PROTECTED] 
 Sent: Friday, September 19, 2003 8:57 AM
 To: [EMAIL PROTECTED]
 Subject: [R] newby problem - concatenate lists
 
 
 Hi,
 a very basic question:
 What ist the easiest way in R to concatenate two lists of 
 vectors? E.g, I have
 x-list(c(1,2))
 y-list(c(3,4))
 and I want to receive
 list(c(1,2),c(3,4))
 
 thank you!
 
 Axel
 
 Fraunhofer Institut fuer
 Arbeitswirtschaft und Organisation (IAO)
 Dipl. Inf. Axel Benz
 Nobelstr. 12
 D-70569 Stuttgart
 Germany
 Tel. +49(0)7119702289
 Fax. +49(0)7119702192
 mail: mailto:[EMAIL PROTECTED]
 www: http://www.vis.iao.fhg.de 
 
 
 
   [[alternative HTML version deleted]]
 
 __
 [EMAIL PROTECTED] mailing list 
 https://www.stat.math.ethz.ch/mailman/listinfo /r-help


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] newby problem - concatenate lists

2003-09-19 Thread Uwe Ligges
Axel Benz wrote:

Hi,
a very basic question:
What ist the easiest way in R to concatenate two lists of vectors?
E.g, I have
x-list(c(1,2))
y-list(c(3,4))
and I want to receive
list(c(1,2),c(3,4))
What about c(x, y) ???

Uwe Ligges



thank you!

Axel

Fraunhofer Institut fuer
Arbeitswirtschaft und Organisation (IAO)
Dipl. Inf. Axel Benz
Nobelstr. 12
D-70569 Stuttgart
Germany
Tel. +49(0)7119702289
Fax. +49(0)7119702192
mail: mailto:[EMAIL PROTECTED]
www: http://www.vis.iao.fhg.de

	[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] list subsets passing parameters question.

2003-09-19 Thread Thomas W Blackwell
Eryk  -

Question 1:  Square brackets work, just the same as for
vectors, and return a (smaller or larger) list object.
The new thing with lists, not available (or needed) with
vectors, is double square brackets, which return one list
element as itself, not enclosed in a list.
See  help(Subscript).

Question 2:  No, I don't think there's a way to pass a
whole string of parameters without some kind of complicated
 eval(parse(...)) syntax (which I've never tried to use myself).

I will comment that the REASON I have never tried to use
this is that I am running R inside of emacs, so it's much
easier to edit the buffer and modify and re-run a command
than it would be to figure out some fancy syntactic way of
doing it.

-  tom blackwell  -  u michigan medical school  -  ann arbor  -

On Fri, 19 Sep 2003, Wolski wrote:

 Hi!

 Is there a way to get a subset of a list?
 I looking for some function like the function available for arrays and dataframe.

 x-1:10
 x[-c(1,2)] for arrays

 or
 x-data.frame(a=1,b=2)
 subset(x,select=-a)

 But one for a list
 x-list(a=1,a=2)
 subset(x,select=-a)

 The second problem i have are that i want to store parmeters to the plot.default 
 function in a list. eg.: pars-list(xlim=c(0,100),xlab=irrelevant , 
 ylab=incredible important).
 and call the plot.default function with this list as parameters.

 I know that there are the way with eval(parse(text = paste(plot.default,

 Is there a different one?

 Eryk

 Dipl. bio-chem. Eryk Witold Wolski@MPI-MG Dep. Vertebrate Genomics
 Ihnestrasse 73 14195 Berlin  'v'
 tel: 0049-30-84131285   /   \
 mail: [EMAIL PROTECTED]---W-W

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Hall-Wellner-Bands

2003-09-19 Thread Ralf Strobl
Hi,
does there exists a R-function computing Hall-Wellner-Confidence-Bands?
Thanks,
Ralf Strobl

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] About PLS analysis

2003-09-19 Thread Spencer Graves
Where did you search?  From www.r-project.org - search - R site 
search, I just got 84 matches for pls and 63 for partial least 
squares.  A generalization of PLS is structural equations, for which 
I got 53 matches.  The third match for pls mentioned package 
pls.pcr, which presumably is still available.  I have not used this, 
so I can't say if this is still available and if it is whether something 
else might be better.  Have you tried this? 

hope this helps. 
spencer graves

Sokratis Alikhanidi wrote:

  Dear colleagues,

May you point me out to the PLS module in R system?
I could not find it at all using PLS or partial as the search keywords.
Thank you.
Sokratis.
--
Sokratis ALIKHANIDI, Ph.D.
Department of Knowledge-based Information Engineering
Toyohashi University of Technology
1-1 Hibarigaoka, Tempaku-cho, Toyohashi 441, JAPAN
TEL: 0532-44-6892
FAX: 0532-44-6873
mailto:[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] 3D plotting in R

2003-09-19 Thread Thomas Lumley
On Fri, 19 Sep 2003, Richard A. O'Keefe wrote:
 I know about persp(), and a bunch of other things in R that give me
 a 3d view of a 2d field (plots of a function of 2 arguments, in other
 words).  But I want to plot a bunch of 3D points and label them.


I would try {g,x}gobi.

-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] newby problem - concatenate lists

2003-09-19 Thread Thomas Lumley
On Fri, 19 Sep 2003, Axel Benz wrote:

 Hi,
 a very basic question:
 What ist the easiest way in R to concatenate two lists of vectors?
 E.g, I have
 x-list(c(1,2))
 y-list(c(3,4))
 and I want to receive
 list(c(1,2),c(3,4))

c(x,y)

-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] list subsets passing parameters question.

2003-09-19 Thread Thomas Lumley
On Fri, 19 Sep 2003, Wolski wrote:

 The second problem i have are that i want to store parmeters to the plot.default 
 function in a list. eg.: pars-list(xlim=c(0,100),xlab=irrelevant , 
 ylab=incredible important).
 and call the plot.default function with this list as parameters.

 I know that there are the way with eval(parse(text = paste(plot.default,


do.call(f,list(a,b,c))

calls f(a,b,c)

which I think is what you want.

-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Very long console input lines

2003-09-19 Thread alessandro . valli
Thank you Spencer,
but it seems not to work with strings :

myquery - c(select . very long string = gives syntax error
myquery - {c(select . very long string= gives syntax error

It seems that the closing  is required in any case.

Thank you in any case,
Alessandro Valli


-Original Message-
From: Spencer Graves [mailto:[EMAIL PROTECTED]
Sent: Mittwoch, 17. September 2003 18:46
To: Valli, Alessandro
Cc: [EMAIL PROTECTED]
Subject: Re: [R] Very long console input lines


Have you considered enclosing the very long string in parentheses?  
Then R will know that it is not syntactically correct until it reaches 
the end.  To avoid that kind of thing, I routinely include ( just to 
the right of - in virtually any statement that might otherwise get 
split onto two lines in a way that the first might be evaluated without 
the second. 

hope this helps.  spencer graves
p.s.  I got this from Venables and Ripley, but I can't remember which 
book or which page. 

[EMAIL PROTECTED] wrote:

Hallo all,

I got a problem executing R in batch-mode via a perl-script (under Win2000) : 
   system (Rterm.exe --slave --no-save --no-restore \Rfile.r \NUL);
The R execution is aborting with syntax error due to very-long lines.
My solution is converting
a - c(very long string)
to
a - paste(short string 1,\n
short string 2,\n
  ...,\n
short string n)
It is not very elegant ...
Does anybody know a better solution ?

Thank you in advance,
Alessandro Valli

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
  


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Saving with tkgetSaveFile

2003-09-19 Thread solares
HI, i'm trying to save a data frame with the next script:
x-c(1,2,3)#suposse here the data frame
a-tkgetSaveFile()
a-tkgetSaveFile()
save(x,file=as.character(a))

but i obtain the next warning message:
Warning messages: 
1: the condition has length  1 and only the first element will be used in: 
if (file == ) stop(`file' must be non-empty string) 
2: only first element of `description' argument used

and nothing file is saved, ¿What is the error? Thanks Ruben

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Saving with tkgetSaveFile

2003-09-19 Thread Thomas W Blackwell
Ruben  -

Why not simply   save(x, file=new.file.name)  ?

See  help(save), help(files).  The file name must be
quoted, and it must be passed as a named argument to save().

-  tom blackwell  -  u michigan medical school  -  ann arbor  -

On Fri, 19 Sep 2003 [EMAIL PROTECTED] wrote:

 HI, i'm trying to save a data frame with the next script:
 x-c(1,2,3)#suposse here the data frame
 a-tkgetSaveFile()
 a-tkgetSaveFile()
 save(x,file=as.character(a))

 but i obtain the next warning message:
 Warning messages:
 1: the condition has length  1 and only the first element will be used in:
 if (file == ) stop(`file' must be non-empty string)
 2: only first element of `description' argument used

 and nothing file is saved, ¿What is the error? Thanks Ruben

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Job Announcement

2003-09-19 Thread Dirk Enzmann
The Criminological Research Institute of Lower Saxony (KFN) in Germany 
(Hannover) seeks a quantitative methodologist (Psychologist/Sociologist) 
to work in a research project on the developmental consequences of 
incarceration of juvenile delinquents.

For more detailed information see:

http://www.kfn.de/KFN_180903.pdf

Application deadline is October 12, 2003, but applications will be
accepted until the position is filled.
More information about the Institute is available at our home page 
http://www.kfn.de

*
Dr. Dirk Enzmann
Criminological Research Institute of Lower Saxony
Luetzerodestr. 9
D-30161 Hannover
Germany
phone: +49-511-348.36.32
fax:   +49-511-348.36.10
email: [EMAIL PROTECTED]
http://www.kfn.de

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Very long console input lines

2003-09-19 Thread Thomas Lumley
On Fri, 19 Sep 2003 [EMAIL PROTECTED] wrote:

 Thank you Spencer,
 but it seems not to work with strings :

 myquery - c(select . very long string   = gives syntax error
 myquery - {c(select . very long string  = gives syntax error


I think you will have to rewrite this somehow.  If you have a known  upper
limit on line length you could modify the limit in the R source, but it's
probably easier to put the
  select  very long string
into a separate file and use readLines() on it, bypassing the limit in the
parser.

-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Installing from RPM on Red Hat 9

2003-09-19 Thread Ted Harding
On 19-Sep-03 James Wettenhall wrote:
 
 BUT, there are some known bugs in the Tcl/Tk that comes with 
 Redhat 9 (which don't exist in previous Redhat distributions) :
 
 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=89098
 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=101678
 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=100793
 http://www.interlink.com.au/anthony/tech/rh9-tcltk/

Thanks, James! Most revealing and worth being made aware of. I've
downloaded the rebuilt Tcl and Tk RPMs from the last-named website,
had no problems with 'rpm -U ... ' on them, and will see if all is
now well. (If not, I'll roll up my sleeves, adopt your practice,
and rebuild from source).

Best wishes,
Ted.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Updating R

2003-09-19 Thread Uwe Ligges
Jason Skelton wrote:

Could anyone advise me on the easist way of upgrading R from 1.6.2 to 
1.7.1 ? is there a script like the bioconductor update.packages ?
or do I have to download the tar file and build it again ?
apologies for the trivial questions from a biologist
The latter.

Uwe Ligges

many thanks

Jason
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] angle and distance between sets of vectors

2003-09-19 Thread Petr Pikal
Dear all

I want to find a distance between two points in three dimensional space and an 
angle between two vectors from [0,0,0] to specified points. I searched archives 
and found some solution using dist but I am not sure how to use it if I have 
several sets of such points.

Here is some example

#Four points

y - c(1,0,0)
z - c(1,1,0)
x - 2*z
v - 2*x

# two sets

mata-rbind(y,x)

 mata
  [,1] [,2] [,3]
y100
x220

matb-rbind(z,v)

 matb
  [,1] [,2] [,3]
z110
v440

# I want a distances and angles

 dist(rbind(y,z))
[1] 1
 dist(rbind(y/sum(y),z/sum(z)))
[1] 0.7071068


 dist(rbind(x,v))
[1] 2.828427
 dist(rbind(x/sum(x),v/sum(v)))
[1] 0


# they are actually here but they are a little bit hidden
 
 dist(rbind(mata,matb))
 yxz
x 2.236068  
z 1.00 1.414214 
v 5.00 2.828427 4.242641

 dist(rbind(mata/rowSums(mata),matb/rowSums(matb)))
  y x z
x 0.7071068
z 0.7071068 0  
v 0.7071068 0 0

Before I start programming a for loop (something like that)

for (i in 1:length(mata)) result-dist(rbind(mata[i,],matb[i,]))

I would like to ask some more experienced if there is a way how to get a vector 
of distances and angles directly?

Something like
some.experienced.use.of.dist(mata,matb) resulting in matrix or dataframe or 2 
vectors or whatever

   distanceangle
1 1, .7071068
2 2.828427, 0

will be greatly appreciated.
Thanks

Petr Pikal
Petr Pikal
[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] using matrix data for function

2003-09-19 Thread Brian . J . GREGOR
It seems to me that the simplest approach is as follows. Say you have a
function as follows:
dosomething - function(x,y) 0.523*x^2 + 0.34*y
Then you just use apply as follows to get your result (assuming that the
first column of matrix m contains the x values and the second column
contains the y values:
apply(m, 1, function(x) dosomething(x[1], x[2]))

Brian Gregor, P.E.
Transportation Planning Analysis Unit
Oregon Department of Transportation
[EMAIL PROTECTED]
(503) 986-4120


-Original Message-
 From: Bing Zhang [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, September 17, 2003 2:03 PM
 To: r-help
 Subject: [R] using matrix data for function
 
 
 Hi All,
 
 I have a function, f(x,y)
 I have a matrix of data, m,  with the 1st column is x and the 
 2nd column is y What's the best way to get f(x,y) for each 
 row of the matrix? I tried 
 result-f(m[,1],m[,2]) but it doesn't work.
 
 Thanks!
 
 Bing

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] survreg distributions

2003-09-19 Thread Olivia Lau
Hi,

I need to find out if the exponential, weibull, and log-normal
distributions in the survreg package use the same
parameterizations as in the functions rexp, rweibull, and
rlnorm.  I have looked at the R-help and Venables  Ripley
(2002), and they have different functional forms for the
Weibull, for example.

If the parameterizations are different, is there an easy way to
use the link function to take random draws from the survreg
distributions?

In addition, does anyone know what the functional form for the
lognormal is, with respect to the survreg package?  I looked in
VR (p. 353), but I can't seem to map that parameterization (in
terms of tau and lambda) onto the standard lognormal
parameterization.

Any advice is greatly appreciated.

Yours,

Olivia Lau.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Evaluating outer observations in an lme object.

2003-09-19 Thread CG Pettersson
Oh, the question might have been more precisely formulated I guess...

update surely helps a lot in the practical work at the computer. But
that is not my problem. The problem is where and how to introduce the
variables in the command.

I´ve tried things like: random = ~ P.AL | Trial/Block 
as the random call, looking for some sort of direct effect from the
soil analysis P.AL. That results in a worse model than without the
term, possibly becouse the effect of the soil already is,
implicitlely, inside the term Trial.
What I am looking for is a way of evaluating several factors that have
just one observation for each Trial, still having the the nice
Trial/Block structure present in the model. 

Or am I just stupid?

/CG

---
 Might update help?  spencer graves
 
 CG Pettersson wrote:
 
 Hello everybody!
 I´m working with a dataset from twelve fertilizer trials, where the
 technical fertilizer product and application method, but not the
 intensity of fertilization, is varied. (I´m using R1.7.1 and
W2000.)
 
 The call:
 
 ejna1t4b.lme - lme( Yield ~ TrCode, data = ejna1t4,
 +   random = ~ 1 | Trial/Block)
 
 works as far as I can understand well, the Block structure of the
 trials is used efficiently and everything looks nice according to
 plots of the object.
 
 Now I want to evaluate the influence of observations from the
 different experimental places (for example soil analyses or
rainfall)
 - Could I do that without skipping the Trial/Block structure, or do
I
 have to start from scratch again? The observed values will
naturally
 only have one level for each Trial, so the term Trial/Block will
host
 the effects of all observed (and unobserved) phenomena in each
trial.
 Now I want to know where the effects come from.
 
 I´ve been looking for a text on this, both in MASS and Pinheiro 
 Bates, without finding any. Any hints of where to look?
 
 Thanks
 /CG
 
 CG Pettersson, MSci, PhD Stud.
 Swedish University of Agricultural Sciences
 Dep. of Ecology and Crop Production. Box 7043
 SE-750 07 Uppsala
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
   
 
 
 
CG Pettersson, MSci, PhD Stud.
Swedish University of Agricultural Sciences
Dep. of Ecology and Crop Production. Box 7043
SE-750 07 Uppsala

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] What is wrong with m?

2003-09-19 Thread Anna Pryor

I've been programming in one directory and recently switched to another 
directory.  It appears that in doing so I've uncovered a problem.  My 
environment was saving something so that my code would work and now I don't 
know how to fix it.  I have the following bit of code:

  for(i in 1:index){
indexList = lst[i]
for(j in 2:jobs-1){
   indexList = c(indexList,lst[i+index*j])
}
   saveList[i,] = indexList

   }


   for (i in 1:index){
m[i] = median(saveList[i,])

}
m

In my new directory, I am getting the complaint that object m is not found.  
Does anyone know what that means?

Anna

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Locate first index

2003-09-19 Thread Cezar Augusto de Freitas Anselmo
Hi, all. I'd like to know if exists a manner to get the first index where
a condition is attained in a vector. For example,

There is a better solution than 

first.index - table(subject[corretor==27])[1]

(give me the subject for the first time that corretor is 27)?

Thanks,


Cezar Freitas (ICQ 109128967)
IMECC - UNICAMP
Campinas, SP - Brasil

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Locate first index

2003-09-19 Thread Spencer Graves
Have you considered which, as in the following: 
 a - rep(1:2, 2)
 a
[1] 1 2 1 2
 which(a==1)
[1] 1 3
 which(a==1)[1]
[1] 1

hope this helps.  spencer graves

Cezar Augusto de Freitas Anselmo wrote:

Hi, all. I'd like to know if exists a manner to get the first index where
a condition is attained in a vector. For example,
There is a better solution than 

first.index - table(subject[corretor==27])[1]

(give me the subject for the first time that corretor is 27)?

Thanks,


Cezar Freitas (ICQ 109128967)
IMECC - UNICAMP
Campinas, SP - Brasil
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] What is wrong with m?

2003-09-19 Thread Douglas Bates
Spencer Graves [EMAIL PROTECTED] writes:

 For m[1] - ... to work, m must already be defined.  To fix this,
 execute m - rep(NA, index) before your second for loop, and it
 should work. hope this helps. spencer graves

If saveList is actually a list, it would be more effective to use

 m = sapply(saveList, median)

That way there is no need to generate m and then change each element
of m in a loop.

One neglected aspect of the S language is the ability to apply
functions to structures instead of iterating over the components of a
structure.  Phil Spector's book An Introduction to S and S-PLUS
emphasizes this.

 Anna Pryor wrote:
 
  I've been programming in one directory and recently switched to
  another directory.  It appears that in doing so I've uncovered a
  problem.  My environment was saving something so that my code would
  work and now I don't know how to fix it.  I have the following bit
  of code:
 
 
   for(i in 1:index){
 indexList = lst[i]
  for(j in 2:jobs-1){
indexList = c(indexList,lst[i+index*j])
 }
saveList[i,] = indexList
 
}
 
 
for (i in 1:index){
  m[i] = median(saveList[i,])
 
 }
 m
 
  In my new directory, I am getting the complaint that object m is
  not found.  Does anyone know what that means?
 
 
 Anna
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 
 
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

-- 
Douglas Bates[EMAIL PROTECTED]
Statistics Department608/262-2598
University of Wisconsin - Madisonhttp://www.stat.wisc.edu/~bates/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Locate first index

2003-09-19 Thread Marc Schwartz
On Fri, 2003-09-19 at 13:15, Cezar Augusto de Freitas Anselmo wrote:
 Hi, all. I'd like to know if exists a manner to get the first index where
 a condition is attained in a vector. For example,
 
 There is a better solution than 
 
 first.index - table(subject[corretor==27])[1]
 
 (give me the subject for the first time that corretor is 27)?
 
 Thanks,


first.index - min(which(corretor == 27))

For example:

corretor - c(15, 23, 27, 34, 25, 27, 26)

which(corretor == 27)
[1] 3 6

min(which(corretor == 27))
[1] 3

See ?which

HTH,

Marc Schwartz

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Locate first index

2003-09-19 Thread Douglas Bates
It may be easier to use the match function which is defined to return
the index of the first match.

 corretor - c(15, 23, 27, 34, 25, 27, 26)
 match(27, corretor)
[1] 3

Marc Schwartz [EMAIL PROTECTED] writes:

 On Fri, 2003-09-19 at 13:15, Cezar Augusto de Freitas Anselmo wrote:
  Hi, all. I'd like to know if exists a manner to get the first index where
  a condition is attained in a vector. For example,
  
  There is a better solution than 
  
  first.index - table(subject[corretor==27])[1]
  
  (give me the subject for the first time that corretor is 27)?
  
  Thanks,
 
 
 first.index - min(which(corretor == 27))
 
 For example:
 
 corretor - c(15, 23, 27, 34, 25, 27, 26)
 
 which(corretor == 27)
 [1] 3 6
 
 min(which(corretor == 27))
 [1] 3
 
 See ?which

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Locate first index

2003-09-19 Thread Marc Schwartz
On Fri, 2003-09-19 at 15:57, Douglas Bates wrote:
 It may be easier to use the match function which is defined to return
 the index of the first match.
 
  corretor - c(15, 23, 27, 34, 25, 27, 26)
  match(27, corretor)
 [1] 3


True and presumably much faster as the size of the search vector and the
offset of the first match increases. If this is being done repeatedly,
timing would become important.

Thanks for pointing that out.

Marc

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Saludos desde Madrid

2003-09-19 Thread Veronica
Hola amig@:
Me llamo Verónica. Te escribo desde Madrid, España y formo parte de un equipo del 
Movimiento Humanista.

Hoy son ya millones de personas las que experimentan cómo la sociedad en que vivimos 
se deshumaniza día a día. El ser humano ha perdido todo valor, el mundo se mueve en 
torno al dinero y en base al egoísmo, mientras las personas van quedando cada vez más 
desamparadas. De este modo, mientras cada uno está  preocupado de sus propios 
problemas, todos vivimos cada vez peor.

Sin embargo los humanistas sabemos que el absurdo de la globalización dirigida, 
pensada sólo en términos económicos por los grandes bancos y multinacionales, no va a 
triunfar. Existe otro proceso de mundialización donde el ser humano ha crecido 
internamente y se encamina a la formación de una Nación Humana Universal. Hay una 
nueva sensibilidad en el ser humano que experimenta que cualquier cosa que pase en 
cualquier punto del planeta termina por afectarle a uno mismo. Este es un proceso 
histórico irreversible y así lo sienten ya en su corazón millones de personas.

Todo ser humano tiene derecho a una vida digna por el simple hecho de haber nacido. Y 
en el interior de todo ser humano hay algo muy grande que está buscando expresarse en 
el mundo.

Nuestro proyecto consiste en conectar y organizar a esos millones de personas de 
sensibilidad humanista.

Si estás interesado en saber más de nuestra propuesta, por favor sigue estos pasos:
1- Abre un mensaje nuevo
2- Escribe en el asunto la palabra SI
3- Envíalo a la dirección: [EMAIL PROTECTED]

Esperamos tu mensaje.

Un saludo afectuoso.
Verónica

==
Este mensaje se envía una única vez, por tanto no es
necesario que te des de baja de ninguna lista. Si su
contenido no es de tu interés, disculpanos.

No obstante, si conoces a otras personas a quienes
pueda interesar nuestra propuesta, te pedimos que
les reenvies este mensaje. Gracias de antemano.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] using aggregate with survey-design and survey functions

2003-09-19 Thread TyagiAnupam
Hi R users,

I am trying to use the aggregate function with a survey design object and 
survey functions, but get the following error. I think I am incorrectly using the 
syntax somehow, and it may not be possible to access variables directly by 
name in a survey-design object. Am I right? How do I fix this problem? I have 
used aggregate with mean and weighted.mean, and that works fine. I am trying 
to find out where the difference is. What would be an efficient alternative 
to aggregate for a large dataset?

 s - aggregate(income,list(age,sex),function(x) (svymean(~x,design=d.na)))
Error in aggregate(income, list(age, sex), function(x) (svymean(~x,  : 
Object income not found
 

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] modelling open source software

2003-09-19 Thread TyagiAnupam
The following paper may be of interest to some. The author is generous about 
sharing a recently revised version.
A 
HREF=http://papers.ssrn.com/sol3/papers.cfm?abstract_id=259648;http://papers.ssrn.com/sol3/papers.cfm?abstract_id=259648/A

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] using aggregate with survey-design and survey functions

2003-09-19 Thread Spencer Graves
What do you get from the following: 

 is.element(income, objects())

spencer graves

[EMAIL PROTECTED] wrote:

Hi R users,

I am trying to use the aggregate function with a survey design object and 
survey functions, but get the following error. I think I am incorrectly using the 
syntax somehow, and it may not be possible to access variables directly by 
name in a survey-design object. Am I right? How do I fix this problem? I have 
used aggregate with mean and weighted.mean, and that works fine. I am trying 
to find out where the difference is. What would be an efficient alternative 
to aggregate for a large dataset?

 

s - aggregate(income,list(age,sex),function(x) (svymean(~x,design=d.na)))
   

Error in aggregate(income, list(age, sex), function(x) (svymean(~x,  : 
   Object income not found

	[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] using aggregate with survey-design and survey functions

2003-09-19 Thread TyagiAnupam
In a message dated 9/19/03 7:46:07 PM Pacific Daylight Time, 
[EMAIL PROTECTED] writes:

 What do you get from the following: 
 
is.element(income, objects())
 
 spencer graves
 

 is.element(income, objects())
[1] FALSE

The following may give further info about why I am getting this. Design 
object is d.na

 attributes(d.na)
$names
[1] cluster   strataprob  allprob   call  variables
[7] nPSU 

$class
[1] survey.design

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help