[R] Multiv. NR

2004-12-12 Thread Benilton Carvalho
Do you know if R has any multiv. Newton-Raphson routine implemented?
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Frailty Model - parameter inferences

2004-02-13 Thread Benilton Carvalho
Hi, I've been trying to find how to extract the inference info about \theta 
... Is there any easy way to do it?

Thanks,

Benilton

_
Create your own personal Web page with the info you use most, at My MSN. 
http://click.atdmt.com/AVE/go/onm00200364ave/direct/01/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Failing to install on Linux FC4

2006-11-08 Thread Benilton Carvalho
Hi everyone,

I downloaded the source code available at:

http://cran.fhcrc.org/src/base/R-2/R-2.4.0.tar.gz

to a linux machine (Linux 2.6.11-1.1369_FC4smp #1 SMP).

I successfully configured and compiled it, which means I'm able to  
run it from the R-2.4.0/bin directory.

I want to do a system wide installation (via 'sudo make install') and  
help2man fails, ie, when I execute the installation command mentioned  
previously I get:

make[1]: Entering directory `/home/bcarvalh/R-2.4.0/m4'
make[1]: Nothing to be done for `install'.
make[1]: Leaving directory `/home/bcarvalh/R-2.4.0/m4'
make[1]: Entering directory `/home/bcarvalh/R-2.4.0/tools'
make[1]: Nothing to be done for `install'.
make[1]: Leaving directory `/home/bcarvalh/R-2.4.0/tools'
make[1]: Entering directory `/home/bcarvalh/R-2.4.0/doc'
installing doc ...
help2man: can't get `--version' info from ../bin/R
make[1]: *** [R.1] Error 255
make[1]: Leaving directory `/home/bcarvalh/R-2.4.0/doc'
make: *** [install] Error 1

Searching the archive, I did find a similar report (http:// 
tolstoy.newcastle.edu.au/R/devel/06/01/3699.html) but the proposed  
solution did not work for me.

Any suggestion?

Thank you very much,

Benilton Carvalho
PhD Candidate
Department of Biostatistics
Johns Hopkins University

__
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] Selective subsetting

2006-11-10 Thread Benilton Carvalho
A=matrix(1:9,3)
A[lower.tri(A)]

b

On Nov 10, 2006, at 4:50 PM, Davendra Sohal wrote:

 Hi all,
 Here's an interesting (for me, at least!) problem I came across:
 I have a correlation matrix, let's say with 6 variables, A to F, as  
 column
 headings and the same 6 as row headings.
 The matrix is filled with correlation coefficients. Therefore, the  
 diagonal
 is all 1's, and each of the two triangles formed by the diagonal  
 has the
 same 15 correlation coefficients.
 I need to extract these 15 coefficients from this. I don't want the  
 1's and
 I don't want redundant values.
 I tried converting the matrix to a list, using c(m) and then I'm  
 stuck.
 Does something like b = a[x, x+1:n] exist in R? SAS will do it.
 x can be looped to go from 1 to n (n here is 6, of course) and it will
 select the required values, but I cannot make it work.
 Please help.
 Many thanks,
 -DS.

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

2006-11-11 Thread Benilton Carvalho
data = read.delim(lahore.txt)

is enough for what you want to do.

b

On Nov 11, 2006, at 2:11 PM, amna khan wrote:

 Respected Sir
 I request you to please fill the following read.table function and
 read.csvfor my understanding by assuming my data attached with this
 maiL, because I
 am fail to run these functions using manual guidlines.

 read.table(file, header = FALSE, sep = , quote = \',
   dec = ., row.names, col.names,
   as.is = !stringsAsFactors,
   na.strings = NA, colClasses = NA, nrows = -1,
   skip = 0, check.names = TRUE, fill = !blank.lines.skip,
   strip.white = FALSE, blank.lines.skip = TRUE,
   comment.char = #, allowEscapes = FALSE, flush = FALSE,
   stringsAsFactors = default.stringsAsFactors())

 read.csv(file, header = TRUE, sep = ,, quote=\, dec=.,
 fill = TRUE, comment.char=, ...)

 read.delim(file, header = TRUE, sep = \t, quote=\, dec=.,
   fill = TRUE, comment.char=, ...)

 I shall be really thankful to  you.
 REGARDS

 --  
 AMINA SHAHZADI
 Department of Statistics
 GC University Lahore, Pakistan.
 Email:
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 lahore.txt
 __
 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] segfault 'memory not mapped', dual core problem?

2006-11-12 Thread Benilton Carvalho
Mea culpa. Please accept my apologies...

The problem was fixed on R-2.4.0 (final) and what I reported was on  
R-2.4.0 alpha.

Good job of Martin, by the way... The problem was fixed and I didn't  
notice (given that I was always using my work-around).

benilton

__
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] I think a simple question

2006-11-12 Thread Benilton Carvalho
does

getIdx - function(tmpin, x){
   tmp2 = tmpin + x
   out = sort(c(tmpin, tmp2))
   out = out[out=max(tmpin)]
   return(out)
}

do what you want?

b

On Nov 12, 2006, at 5:20 PM, Leeds, Mark ((IED)) wrote:

 I have index ( of a vector ) values of say

 tempin-c(1 31 61   91 121 all the way upto 1411)

 What I want is a function that takes in a number say, x = 5, and gives
 me an new vector
 of

 tempout-1  6 31  36 91  96  121  126  .. 1411   1416

 This can't be so hard but I can't get it and I've honestly tried.
 Obviously, tempin + 5 gives me the missing values but I don't know how
 to interwine them in the order above. Thanks for any help
 you can provide.

mark
 

 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-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] indexing question

2006-11-13 Thread Benilton Carvalho
diff(tmp[idx])

cheers,

b

On Nov 13, 2006, at 3:06 PM, Leeds, Mark ((IED)) wrote:

 I have the following set of indices, call it idx, that correspond  
 to the
 indices of a vector say temp.

  [1]   31   36   41   61   66   71   91   96  101  121  126  131  151
 156  161  181  186  191  211  216  221  241  246  251  271  276  281
 301  306  311  331  336  341  361  366
  [36]  371  391  396  401  421  426  431  451  456  461  481  486  491
 511  516  521  541  546  551  571  576  581  601  606  611  631  636
 641  661  666  671  691  696  701  721
  [71]  726  731  751  756  761  781  786  791  811  816  821  841  846
 851  871  876  881  901  906  911  931  936  941  961  966  971  991
 996 1001 1021 1026 1031 1051 1056 1061
 [106] 1081 1086 1091  1116 1121 1141 1146 1151 1171 1176 1181 1201
 1206 1211 1231 1236 1241 1261 1266 1271 1291 1296 1301 1321 1326 1331
 1351 1356 1361 1381 1386 1391 1411 1416
 [141] 1421


 I want to calculate temp[36] - temp[31] and temp[41] - temp[36]

 Similarly, temp[66] - temp[61] and temp[71] - temp[66]
 .
 .
 .
 .
 Similarly temp[1416]-temp[1411]
   temp[1421] - temp[1416]


 I'm doing this because the above subractions represent pairs of  
 returns
 and the correlations between them wil be calculated eventually.

 In other words, eventually I will have

 X_36_31  ( i.e : temp[36] - temp[31] )
 X_66-61
 X_96-91
 .
 .
 .
 .
 .
 .
 .
 X_1411-1416

 as one vector and

 Y_41-36
 Y_71-66
 Y_101-96
 .
 .
 .
 .
 .
 Y_1416_1421

 as another vector.

 and will calculate the correlation between the two vectors in order to
 get one number.


 The point is I am  really only using the indices 31, 61, 91 etc as
 anchor's so a regular diff(temp[idx]) won't work because it will diff
 all
 the elements that are next to each other ? This is a weird problem.  
 I'm
 still thinking about it. I'm hoping to figure it out before someone
 sends me something but I won't mind so much if I get an external
 solution first. I have no pride.
 

 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-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] Problem with file size

2006-11-13 Thread Benilton Carvalho
Hi everyone,

I have 2 environments (2 different R sessions) as described below:

Session 1:

Name of the environment: CrlmmInfo
Objects in the environment:
index1: logical index - length 238304
index2: logical index - length 238304
priors: list of 4 - (matrix 6x6, 2 vectors of length 6, vector of  
length 2) - all num
params: list of 4:
  centers [238304 x 3 x 2]: num
  scales [238304 x 3 x 2]: num
  N [238304 x 3]: num
  f0 [scalar]: num

If I save this environment to a file, I get a file of 23MB. Great.

Session 2:
 Analogous to Session 1, but replace 238304 by 262264.

If I save the environment on Session 2, I get a file of 8.4GB.

I applied object.size on each of the objects in each environment, and  
this is what I got:

For Session 1:
index1: 16204864
index2: 16204864
priors: 3336
params: 74353584

For Session 2:
index1: 1049096
index2: 1049096
priors: 3336
params: 81829104

Is this increase from 23MB to 8.4GB expected to happen?

Benilton

sessionInfo() on both sessions is identical:

  sessionInfo()
R version 2.4.0 (2006-10-03)
x86_64-unknown-linux-gnu

locale:
LC_CTYPE=en_US.iso885915;LC_NUMERIC=C;LC_TIME=en_US.iso885915;LC_COLLATE 
=en_US.iso885915;LC_MONETARY=en_US.iso885915;LC_MESSAGES=en_US.iso885915 
;LC_PAPER=en_US.iso885915;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASU 
REMENT=en_US.iso885915;LC_IDENTIFICATION=C

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

  version
_
platform   x86_64-unknown-linux-gnu
arch   x86_64
os linux-gnu
system x86_64, linux-gnu
status
major  2
minor  4.0
year   2006
month  10
day03
svn rev39566
language   R
version.string R version 2.4.0 (2006-10-03)

__
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 check a R object's property

2006-11-14 Thread Benilton Carvalho
check class()

but if all you want is to test whether it's a data.frame or not:

is.data.frame()

b

On Nov 14, 2006, at 3:07 PM, Weiwei Shi wrote:

 Hi,
 I am writing a generic function and need to check if an arg is a data
 frame or not. I could use
 is.null(dim(x)) to get what i want. But i want to know if there is a
 function which can tell me whether it is a list, a numeric vector, a
 data frame, a factor and so on. Can R do that?

 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-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] Creating a table

2006-11-14 Thread Benilton Carvalho
tb = table(df$loc, cut(df$year, seq(1970, 1985, by=5), right=F))
rs = rowSums(tb)
tb = cbind(tb, rs)
cs = colSums(tb)
tb = rbind(tb, cs)

cheers,
b

On Nov 14, 2006, at 3:20 PM, Michael Graber wrote:

 Dear R List,

 I am a new to R,  so my question may be easy to answer for you:

 I have a dataframe, for example:

 df-data.frame(loc=c(A,B,A,A,A),
 year=as.numeric(c(1970,1970,1970,1976,1980)))

 and I want to create the following table without using loops:

   1970-74 ; 1975-79 ; 1980-85; rowsum
 A 2   1   1  4
 B 1   00  1
 colsum   31   15

 so that the frequencies of df$loc are shown in the table for different
 time intervals.

 Thanks in advance for any hint,

 Michael Graber

 __
 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] trouble loading example package

2006-11-15 Thread Benilton Carvalho
How do you build your packages?

have you tried

R CMD build --binary mypkg

b

On Nov 16, 2006, at 12:32 AM, Charles Annis, P.E. wrote:

 Greetings:

 I've installed Rtools, MikTeX, perl, minGW, and HTML Help Workshop,  
 and have
 succeeded in making, checking (using R CMD check mypkg) then  
 building the
 simple example package.skeleton(list=c(f,g,d,e),  
 name=mypkg)  R
 CMD build mypkg produces a tarball.  I don't know how to get a zip  
 file.

 But when I try to Install package(s) from local zip files, I get  
 this error
 message:

 Error in gzfile(file, r) : unable to open connection
 In addition: Warning messages:
 1: error -1 in extracting from zip file
 2: cannot open compressed file 'mypkg/DESCRIPTION'

 But when I click on that file in the tarball it opens and shows me  
 what I
 expected.

 I had hoped that I had weathered the hard part - building the  
 package - but
 I still need some help:

 1) How do I get a zipped file, rather than a tarball,
 2) How do I install what I've built?

 Thanks in advance.

 Charles Annis, P.E.

 [EMAIL PROTECTED]
 phone: 561-352-9699
 eFax:  614-455-3265
 http://www.StatisticalEngineering.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] modifying colnames of tables in a loop

2006-11-16 Thread Benilton Carvalho
how about:

for (x in l) colnames(get(x)) - lower.case(colnames(get(x)))

b

On Nov 16, 2006, at 9:01 AM, Werner Wernersen wrote:

 Hi,

 I have a list with the names of tables, e.g.
 l - c(t1,t2,t3)
 and I want to change the colnames of each of the
 tables in a for loop like this:
 for (x in l) {
 colnames(eval(x)) - lower.case(colnames(eval(x)))
 }

 This does not work but could someone give me some help
 to get on the right track?

 Thanks a million,
   Werner

 __
 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] Counting zeros in a matrix

2006-11-28 Thread Benilton Carvalho
countZerosBeforeOnes - function(v)
   sum(v[1:max(which(v == 1))] == 0)

apply(A, 1, countZerosBeforeOnes)

cheers,
b

On Nov 28, 2006, at 4:20 PM, Guenther, Cameron wrote:

 Hi All,

 If you could help me with this problem I would greatly appreciate it.

 Suppose I have a matrix A:

 1 1 1 1 0 1 1 1 1
 1 1 1 0 1 0 1 0 0
 1 0 1 0 0 1 0 0 0
 1 1 0 0 0 0 1 0 0

 I would like, for each row, to sum the number of times a 0 appears in
 front of a 1. So what I would like is to have
Sum
 1 1 1 1 0 1 1 1 1   1
 1 1 1 0 1 0 1 0 0   2
 1 0 1 0 0 1 0 0 0   2
 1 1 0 0 0 0 1 0 0   1

 I tried writing a function to do this but am getting mixed up in the
 [i,j] coding.  This is just an example the real matrix is much larger.

 Thanks in advance.



 Cameron Guenther, Ph.D.
 100 8th Ave. SE
 St. Petersburg, Fl 33701
 727-896-8626 ext. 4305
 [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] tests for NULL objects

2006-11-29 Thread Benilton Carvalho
Hi Everyone,

After searching the subject and not being successful, I was wondering  
if any you could explain me the idea behind the following fact:

all(NULL == 2)  ## TRUE
any(NULL == 2) ## FALSE

Thanks a lot,

Benilton

--
Benilton Carvalho
PhD Candidate
Department of Biostatistics
Johns Hopkins University

__
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] tests for NULL objects

2006-11-29 Thread Benilton Carvalho
Thank you Bert,

Sorry if it sounded like a complain, this is not what I meant.

The situation I had was: given a vector v containing integers or  
NA's, I wanted to know if after excluding the NA's all the remaining  
observations were 2's.

Naively, I assumed that:

all(na.omit(v) == 2)

would do the work, but now I see that it fails if, for example,

v = rep(NA, 10)

But that's okay, just a matter of adding an extra test (already done).

When I asked for clarification about the reasons for this, I assumed  
that:

if all(v) is TRUE == any(v) is TRUE; for all  (logical) v...

When actually:

if all(v) is TRUE == any(v) is TRUE; for all (logical) v of length  
 = 1.

Thank you,

benilton

On Nov 29, 2006, at 6:35 PM, Bert Gunter wrote:

 Merely convention.

 NULL == 2  == logical(0), that is, a logical vector of length 0.  
 It makes
 sense (at least to me) that any(logical(0)) is FALSE, since no  
 elements of
 the vector are TRUE. all(logical(0)) is TRUE since no elements of  
 the vector
 are FALSE.

 I think these are reasonable and fairly standard conventions, but  
 even if
 you disagree, they are certainly not worth making a fuss over and  
 certainly
 cannot be changed without breaking a lot of code, I'm sure.

 Bert Gunter
 Nonclinical Statistics
 7-7374

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Benilton  
 Carvalho
 Sent: Wednesday, November 29, 2006 2:21 PM
 To: R-Mailingliste
 Subject: [R] tests for NULL objects

 Hi Everyone,

 After searching the subject and not being successful, I was wondering
 if any you could explain me the idea behind the following fact:

 all(NULL == 2)  ## TRUE
 any(NULL == 2) ## FALSE

 Thanks a lot,

 Benilton

 --
 Benilton Carvalho
 PhD Candidate
 Department of Biostatistics
 Johns Hopkins University

 __
 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] tests for NULL objects

2006-11-29 Thread Benilton Carvalho

On Nov 29, 2006, at 7:54 PM, Martin Morgan wrote:

 http://en.wikipedia.org/wiki/Empty_set
 which says, in part:
 Operations on the empty set

...
 'any' is like 'sum', 'all' is like 'prod'.

 Martin

Thank you very much Martin.

It's clear now.

Benilton

__
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] require(simecol) error

2006-12-06 Thread Benilton Carvalho
The output of sessionInfo() will be helpful here.

But I can't reproduce that on R 2.4.0 Patched r40106 + simecol (0.3-11).

Maybe you should upgrade the package?

b

On Dec 6, 2006, at 5:06 PM, Milton Cezar Ribeiro wrote:

 Hi there,

   I´m trying to use simecol package but I got the error showed  
 below. I´m runnig R version 2.4.0 (2006-10-03).

   Kind regards,

   miltinho
   Brazil
   ---
 require(simecol)
 Loading required package: simecol
 Error in loadNamespace(package, c(which.lib.loc, lib.loc),  
 keep.source = keep.source) :
 in 'simecol' methods specified for export, but none  
 defined: fixInit, fixParms, fixTimes, plot, print, solver,  
 solver-, out, inputs, inputs-, main, main-, equations,  
 equations-, sim, parms, parms-, init, init-, times, times-
 [1] FALSE
   -

__
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] expression()

2006-12-12 Thread Benilton Carvalho
mtext(expression(beta[max]), side=1, line=2)

is it what you want?

b

On Dec 12, 2006, at 10:59 AM, javier garcia-pintado wrote:

 Hi,
 I'm trying to use expression() to write a text to a graphic in the  
 margin.

 Using:

 mtext(expression(beta),side=1,line=2)

 writes a perfect beta greek character, but I need to add a subindex
 max, and I'm trying:

 mtext(paste(expression(beta),max),side=1,line=2)

 simply writes beta max in the plot.

 Please, Could you tell me what I'm doing wrong?

 By the way, is there a way to add Latex expressions to graphics?  
 Then I
 could use the Latex expression: $\beta_{\mathrm{max}}$. This also  
 would
 be very useful for me for more complex expressions in plots.

 Best regards,

 Javier

 -- 
 Javier García-Pintado
 Institute of Earth Sciences Jaume Almera (CSIC)
 Lluis Sole Sabaris s/n, 08028 Barcelona
 Phone: +34 934095410
 Fax:   +34 934110012
 e-mail:[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.


Re: [R] install.packages

2006-12-13 Thread Benilton Carvalho
install.packages(plotrix)

b.

On Dec 13, 2006, at 1:42 PM, Aimin Yan wrote:

 I try to type this in my R-winEdt.
 but I got these. Do you know?

 Aimin


 install.packages('http://rh-mirror.linux.iastate.edu/CRAN/bin/ 
 windows/contrib/2.4/plotrix_2.1-6.zip')
 Warning in download.packages(pkgs, destdir = tmpd, available =  
 available,  :
   no package
 'http://rh-mirror.linux.iastate.edu/CRAN/bin/windows/contrib/2.4/ 
 plotrix_2.1-6.zip'
 at the repositories

 __
 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] min() return factor class values

2007-01-09 Thread Benilton Carvalho
Milton,

have you looked at the structure of your data.frame?

str(especies.aicc)

Are you sure especies.aicc is defined as numeric?

b

On Jan 9, 2007, at 10:51 AM, Milton Cezar Ribeiro wrote:

 Dear Peter,

   I tryed something like

 head(especies.aicc)
  especie aicc
 1 Attila.rufus 17.15934
 2 Attila.rufus 11.41371
 3 Attila.rufus 11.41371
 4 Attila.rufus 19.55998
 5 Attila.rufus 17.23780
 6 Attila.rufus 19.22545

 especies.min-aggregate.data.frame(especies.aicc,list
  (Especie=especies.aicc$especie),max)

   But it works fine only for mean FUN and not for min and  
 max. Also also, when I use mean I got the following warnings:

 especies.min-aggregate.data.frame(especies.aicc,list
  (Especie=especies.aicc$especie),mean)

   Warning messages:
 1: argument is not numeric or logical: returning NA in: mean.default 
 (X[[1]], ...)
 2: argument is not numeric or logical: returning NA in: mean.default 
 (X[[2]], ...)

   In fact I need only min() and max().

   Miltinho
   -

 Peter Dalgaard [EMAIL PROTECTED] escreveu:
   Milton Cezar Ribeiro wrote:
 Hi R-friends

 I don´t know why the min() function below return the min value  
 as factor. When i force the aicc.min using a as.numeric()  
 function, it return a factor index (1,2,..) and not min value as I  
 want. By the way, I included a sessionInfo() at the end of this e- 
 mail.

 min() is not doing anything out of the ordinary, but cbind'ing it with
 the character vector sp coerces it to character and rbind'ing to a  
 data
 frame turns character vectors into factors...

 The whole thing looks like it could be a straightforward  
 application of
 aggregate().

 In fact I had the same problem (values as factor) on other part of  
 my script and I noticed that it occour when I use cbind(). It is  
 real?

 Any idea?

 Kind regards,

 Miltinho

 especies.aicc.min-data.frame()

 for (sp in levels(especies.aicc$especie))

 + {
 + sele-subset(especies.aicc,especie==sp)
 + especies.aicc.min-rbind(especies.aicc.min,cbind(sp,aicc.min=min 
 (sele$aicc)))
 + }

 especies.aicc.min

 sp aicc.min
 1 Attila.rufus 6.7387056413613
 2 Automolus.leucophthalmus 125.791300522824

 class(especies.aicc.min$aicc.min)

 [1] factor

 ---
 sessionInfo()
 R version 2.4.0 (2006-10-03)
 i386-pc-mingw32
 locale:
 LC_COLLATE=English_Jamaica.1252;LC_CTYPE=English_Jamaica. 
 1252;LC_MONETARY=English_Jamaica. 
 1252;LC_NUMERIC=C;LC_TIME=English_Jamaica.1252
 attached base packages:
 [1] methods stats graphics grDevices utils datasets  
 base





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




  __


   [[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@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 graphics with Linux (libpng)

2007-01-11 Thread Benilton Carvalho
I forgot to mention that

bitmap()

will do what you want without an X11 connection.

b

On Jan 11, 2007, at 1:09 PM, Rebecca Tagett wrote:

 Hello,

 I'm trying to adapt some R code that works on Windows so that it  
 will work
 on a Linux machine.

 The command :

 png(myFile.png, width=600, height=600)

 fails claiming that it is impossible to establish a connection with  
 X11.
 (Error messages are in French, so I'm not pasting them here!)



 I have libpng installed:

 rpm -qa libpng*

 libpng-1.0.12-2

 libpng-devel-1.0.12-2



 So I don't understand why R thinks I'm trying to connect to X11. I  
 haven't
 been able to find many examples of R graphics code specifically for  
 Linux,
 but I have the impression that if libpng is installed, the graphics  
 commands
 are identical. The libpng manual is not useful, because it does not  
 mention
 use of libpng commands in an R environment.



 I'm using R 2.4.1, which I recently installed. Do I have to install  
 a more
 recent libpng ? If so, do I have to reconfigure and remake R ?



 I've also read that no graphics devices are available under R CMD  
 BATCH.
 Does that really mean that I can't create graphics from some R code  
 that I
 launch in noninteractive mode?



 Thanks in advance !



 Rebecca Tagett


   [[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@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 graphics with Linux (libpng)

2007-01-11 Thread Benilton Carvalho
Hi Rebecca,

png (and also jpeg, for example) require an X11 connection.

So, assuming you're working from the command line and that your X11  
server is up, you would need to do something like:

linux$ export DISPLAY=:0.0

before loading R...

and if your linux machine is remote (and you're connecting through  
SSH), you'd need

linux$ ssh -X remote.machine.somewhere

b


On Jan 11, 2007, at 1:09 PM, Rebecca Tagett wrote:

 Hello,

 I'm trying to adapt some R code that works on Windows so that it  
 will work
 on a Linux machine.

 The command :

 png(myFile.png, width=600, height=600)

 fails claiming that it is impossible to establish a connection with  
 X11.
 (Error messages are in French, so I'm not pasting them here!)



 I have libpng installed:

 rpm -qa libpng*

 libpng-1.0.12-2

 libpng-devel-1.0.12-2



 So I don't understand why R thinks I'm trying to connect to X11. I  
 haven't
 been able to find many examples of R graphics code specifically for  
 Linux,
 but I have the impression that if libpng is installed, the graphics  
 commands
 are identical. The libpng manual is not useful, because it does not  
 mention
 use of libpng commands in an R environment.



 I'm using R 2.4.1, which I recently installed. Do I have to install  
 a more
 recent libpng ? If so, do I have to reconfigure and remake R ?



 I've also read that no graphics devices are available under R CMD  
 BATCH.
 Does that really mean that I can't create graphics from some R code  
 that I
 launch in noninteractive mode?



 Thanks in advance !



 Rebecca Tagett


   [[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@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] sort dataframe by field

2007-01-17 Thread Benilton Carvalho
say your data.frame is called df

df[order(df$evidence),]

or

df[order(df$evidence, decreasing=T),] # if you want the other way  
around.

b

On Jan 17, 2007, at 11:21 AM, Milton Cezar Ribeiro wrote:

 Hi there,

   How can I sort (order?) a data.frame using a dataframe field  
 (evidence) as classifyer? My data.frame looks like:

   record   model   evidence
 1 areatotha 6638.32581
 2   areatotha_ca000 8111.01860
 3  areatotha_ca000_Pais 1721.41828
 4   areatotha_ca020  827.33097
 5  areatotha_ca020_Pais 2212.40899
 6   areatotha_ca040 3569.17169
 7  areatotha_ca040_Pais 2940.01636
 8   areatotha_ca060  992.62852
 9  areatotha_ca060_Pais 4237.95709
 10  areatotha_ca080   62.74915
 11 areatotha_ca080_Pais 1726.55082
 12   areatotha_Pais   52.02524
 13  areatotha_ca000 3391.92930
 14 areatotha_ca000_Pais   39.52170
 15  areatotha_ca020  268.55875
 16 areatotha_ca020_Pais   20.43317
 17  areatotha_ca040 1698.75892
 18 areatotha_ca040_Pais   43.90613
 19  areatotha_ca060  350.79857
 20 areatotha_ca060_Pais   51.04471

   Cheers,

   Miltinho, Brazil

  __


   [[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@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 get the index of entry with max value in an array?

2007-01-17 Thread Benilton Carvalho
which.max()
b

On Jan 17, 2007, at 11:20 PM, Feng Qiu wrote:

 Hi all:
  A short question:
  For example,  a=[3,4,6,2,3], obviously the 3rd entry of  
 the array has the maxium value, what I want is index of the maxium  
 value: 3. is there a neat expression to get this index?

 Thank you!

 Best,

 Feng

__
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] Suggestion on how to improve efficiency when using MASS:::hubers on high-dimensional arrays

2007-01-19 Thread Benilton Carvalho
Hi Everyone,

Given the scenario I have, I was wondering if anyone would be able to  
give me a hind on how to get the results from hubers() in a more  
efficient way.

I have an outcome on an array [N x S x D].

I also have a factor (levels 1,2,3) stored on a matrix N x S.

My objective is to get mu and sigma for each of the N rows  
(outcome) stratified by the factor (levels 1, 2 and 3) for each of  
the D levels, but using MASS:hubers().

Ideally the final result would be an array [N x D x 3 x 2].

The following toy example demonstrates what I want to do, and I'd  
like to improve the performance when working on my case, where S=400  
and N  20

Thank you very much for any suggestion.

benilton

## begin toy example
set.seed(1)
N - 100
S - 5
D - 2

outcome - array(rnorm(N*S*D), dim=c(N, S, D))
classes - matrix(sample(c(1:3, NA), N*S, rep=T), ncol=S)

results - array(NA, dim=c(N, D, 3, 2))

library(MASS)
myHubers - function(x)
   if (length(x)1) as.numeric(hubers(x))  else c(NA, NA)

for (n in 1:N)
   for (d in 1:D){
 tmp - outcome[n,,d]
 grp - classes[n,]
 results[n, d,,] - t(sapply(split(tmp, factor(grp, levels=1:3)),  
myHubers))
   }
## end

--
Benilton Carvalho
PhD Candidate
Department of Biostatistics
Johns Hopkins University

__
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] Bartlett test

2007-01-19 Thread Benilton Carvalho
The null hypothesis is that the variances do not differ across  
groups. The Bartlett test is sensitive to non-normality and that  
might lead you to consider something more robust (eg, Levene's test).

b

On Jan 19, 2007, at 9:04 AM, Matthieu Mourroux wrote:

 Bonjour,
 Je voudrais tester l'homoscédasdicité entre des groupes. J'aurais  
 alors aimé savoir quelle était l'hypothèse nulle du test de bartlett.
 Merci pour votre aide.
 Matthieu.

__
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] Installing packages...

2007-01-23 Thread Benilton Carvalho
well, i don't use RGui, but trying:

install.packages(neural, type=source) ## from the R command line

i could not reproduce the error (which may be a problem with the copy  
on the mirror you're using)...
b

On Jan 23, 2007, at 3:09 PM, Nüzhet Dalfes wrote:

 Hi,

 I am a total newbie to R. I am using R (2.4.1) on Mac OS X 10.4.8 and
 trying to install some packages using GUI Packages  Data/Package  
 Installer
 interface...

 Every time I get:

 trying URL
 'http://umfragen.sowi.uni-mainz.de/CRAN/bin/macosx/universal/ 
 contrib/2.4/neural_1.4.1.tgz'
 Content type 'application/x-tar' length 18920 bytes
 opened URL
 ==
 downloaded 18Kb

 Error in gzfile(file, r) : unable to open connection
 In addition: Warning message:
 cannot open compressed file 'neural/DESCRIPTION'


 What am I doing wrong?

 Any help will be much appreciated.

 Nüzhet Dalfes

 Istanbul Tech. Univ.
 __
 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] package servers

2007-01-23 Thread Benilton Carvalho
go to R / Preferences / Startup

than you'll know what to do when you see: Default CRAN mirror.

b

On Jan 23, 2007, at 8:03 PM, Paul Gowder wrote:

 Hi everyone...

 Here's a good one.  I'm using the R installation for mac osx.  An
 overly helpful friend tried to download a couple of packages for me
 (via the menu bar), and in the process, set my default package
 server.  To a server that is not responding.  I can't seem to get R
 to give me the option to set a new server.  Does anyone know how to
 tell R to stop looking for the default server?

 thanks,

   -Paul

__
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] filling the area

2007-01-25 Thread Benilton Carvalho
take a look at:

?polygon

b

On Jan 25, 2007, at 8:18 AM, Mauricio Cardeal wrote:

 Please, how to fill the area under the curve?

 x - c(1:10)
 y - c(rnorm(10))
 plot(x,y)
 lines(x,y)

 Thanks,
 Mauricio Cardeal

__
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] strange behaviour with equality after simple subtraction

2007-01-26 Thread Benilton Carvalho
In addition to Mike's comment:

  x-c(0.1,0.9)
  1-x[2]
[1] 0.1
  x[1]==1-x[2]
[1] FALSE
  all.equal(x[1], 1-x[2])
[1] TRUE

b

On Jan 26, 2007, at 11:40 AM, Mike Prager wrote:

 Not at all strange, an expected property of floating-point
 arithmetic and one of the most frequently asked questions here.

 print(0.1, digits=17)
 [1] 0.1
 print(1 - 0.9, digits=17)
 [1] 0.09998


 A simple description of the issue is at

 http://docs.python.org/tut/node16.html

 In most cases, it suffices to test for approximate difference or
 relative difference. The former would look like this

 if (abs(x[1] - x[2])  eps)) ...

 with eps set to something you think is an insignificant
 difference, say 1.0e-10.


 --  
 Mike Prager, NOAA, Beaufort, NC
 * Opinions expressed are personal and not represented otherwise.
 * Any use of tradenames does not constitute a NOAA endorsement.

 __
 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] Inverse fuction of ecdf

2007-01-28 Thread Benilton Carvalho
?quantile

b

On Jan 28, 2007, at 5:41 PM, Geoffrey Zhu wrote:

 Hi Everyone,

 I want to generate some random numbers according to some empirical
 distribution. Therefore I am looking for the inverse of an empirical
 cumulative distribution function. I haven't found any in R. Can anyone
 give a pointer?

 Thanks,
 Geoffrey

__
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] lmer2 error under Mac OS X on PowerPC G5 but not on Dual-Core Intel Xeon

2007-01-29 Thread Benilton Carvalho
So, I decided to give it a try (and just now noticed that this is the  
example in lmer2)

I just gave it a try on a PPC G4 and it worked as expected. I'm  
copying R-sig-mac (sorry for the crosspost) as the experts there  
might give you a better suggestion.

  fm1 - lmer2(Reaction ~ Days + (Days|Subject), sleepstudy)
  fm1
Linear mixed-effects model fit by REML
Formula: Reaction ~ Days + (Days | Subject)
Data: sleepstudy
   AIC  BIC logLik MLdeviance REMLdeviance
1754 1770 -871.8   1752 1744
Random effects:
Groups   NameVariance Std.Dev. Corr
Subject  (Intercept) 612.128  24.7412
   Days 35.049   5.9202  0.066
Residual 654.970  25.5924
Number of obs: 180, groups: Subject, 18

Fixed effects:
 Estimate Std. Error t value
(Intercept)  251.405  6.825   36.84
Days  10.467  1.5456.77

Correlation of Fixed Effects:
  (Intr)
Days -0.137
  sessionInfo()
R version 2.5.0 Under development (unstable) (2007-01-03 r40349)
powerpc-apple-darwin8.8.0

locale:
C

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

other attached packages:
lme4  Matrix lattice
0.9975-11  0.9975-8   0.14-16


On Jan 29, 2007, at 7:40 AM, Michael Kubovy wrote:

 On Jan 28, 2007, at 9:39 PM, Benilton Carvalho wrote:

 This seems to be due to the fact that you didn't have enough  
 memory when running lmer2.

 I might be wrong, but I think Calloc tries to get contiguous  
 memory, so this might the problem.

 If you are positive that you have enough memory, a gc() might help.

 I have 2 GB memory on this machine. Should be enough, no?

  gc()
   used (Mb) gc trigger (Mb) max used (Mb)
 Ncells 1008175 27.01476915 39.5  1368491 36.6
 Vcells  540055  4.21031040  7.9  1031026  7.9
  (fm1 - lmer2(Reaction ~ Days + (Days|Subject), sleepstudy))
 Error in as.double(start) : Calloc could not allocate (903190944 of  
 4) memory


 On Jan 28, 2007, at 8:35 PM, Michael Kubovy wrote:

 (fm1 - lmer2(Reaction ~ Days + (Days|Subject), sleepstudy))
 Error in as.double(start) : Calloc could not allocate (888475968 of
 4) memory
 *
 sessionInfo()
 R version 2.4.1 (2006-12-18)
 powerpc-apple-darwin8.8.0

 locale:
 C

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

 other attached packages:
  lme4   Matrix   xtable latticeExtra  lattice
 gridBase MASS
 0.9975-11   0.9975-8  1.4-3  0.1-40.14-16
 0.4-3 7.2-31
   JGR   iplots   JavaGDrJava
  1.4-15  1.0-5  0.3-5 0.4-13
 *
 lmer runs the example w/o a problem

 I just tried to run it on on Intel-based MacPro, and lmer2 ran
 without a hitch.
 _
 Professor Michael Kubovy
 University of Virginia
 Department of Psychology
 USPS: P.O.Box 400400Charlottesville, VA 22904-4400
 Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
 Office:B011+1-434-982-4729
 Lab:B019+1-434-982-4751
 Fax:+1-434-982-4766
 WWW:http://www.people.virginia.edu/~mk9y/


__
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] jump in sequence

2007-01-30 Thread Benilton Carvalho
is it sth like:

as.integer(sapply(seq(4, 22, by=9), seq, length.out=3))

you're looking for?

b

On Jan 30, 2007, at 9:29 AM, Adrian DUSA wrote:

 Dear list,

 This should be a simple one, I just cannot see it.
 I need to generate a sequence of the form:
 4  5  6 13 14 15 22 23 24

 That is: starting with 4, make a 3 numbers sequence, jump 6, then  
 another 3
 and so on.
 I can create a whole vector with:
 myvec - rep(rep(c(F, T, F), rep(3, 3)), 3)

 Then see which are TRUE:
 which(myvec)
 [1]  4  5  6 13 14 15 22 23 24


 I'd like to avoid creating the whole vector if possible; for very  
 large ones
 it can be time consuming. There should be a way to only create the  
 proper
 indexes...

 Thanks for any hint,
 Adrian

 -- 
 Adrian Dusa
 Romanian Social Data Archive
 1, Schitu Magureanu Bd
 050025 Bucharest sector 5
 Romania
 Tel./Fax: +40 21 3126618 \
   +40 21 3120210 / int.101

 __
 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] Quick Question about R

2007-01-31 Thread Benilton Carvalho
suppressWarnings(a - as.numeric(c(1, 2, pi, a, 9, z)))

b

On Jan 31, 2007, at 2:35 PM, Konrad wrote:

 Hello,
 Is there a way to convert a character to a number with out getting  
 a warning?  I have a vector that has both numbers and letters in it  
 and I need to convert it to only numbers.  At the moment I'm using  
 as.numeric but it is generating a warning when it converts a  
 letter.  Is there another function out there that will do what I  
 need or is there a way to turn off the warnings as I don't want the  
 warning to be displayed to the end user?

 Konrad Hammel
 Engineer
 Prilink LTD
 [EMAIL PROTECTED]
 905.305.1096

   [[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@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] Help with efficient double sum of max (X_i, Y_i) (X Y vectors)

2007-02-01 Thread Benilton Carvalho
Well, a reproducible example would be nice =)

not tested:

x = rnorm(10)
y = rnorm(20)
mymax - function(t1, t2) apply(cbind(t1, t2), 1, max)
sum(outer(x, y, mymax))

is this sth like what you need?

b

On Feb 1, 2007, at 1:18 PM, Jeffrey Racine wrote:

 Greetings.

 For R gurus this may be a no brainer, but I could not find pointers to
 efficient computation of this beast in past help files.

 Background - I wish to implement a Cramer-von Mises type test  
 statistic
 which involves double sums of max(X_i,Y_j) where X and Y are  
 vectors of
 differing length.

 I am currently using ifelse pointwise in a vector, but have a nagging
 suspicion that there is a more efficient way to do this. Basically, I
 require three sums:

 sum1: \sum_i\sum_j max(X_i,X_j)
 sum2: \sum_i\sum_j max(Y_i,Y_j)
 sum3: \sum_i\sum_j max(X_i,Y_j)

 Here is my current implementation - any pointers to more efficient
 computation greatly appreciated.

   nx - length(x)
   ny - length(y)

   sum1 - 0
   sum3 - 0

   for(i in 1:nx) {
 sum1 - sum1 + sum(ifelse(x[i]x,x[i],x))
 sum3 - sum3 + sum(ifelse(x[i]y,x[i],y))
   }

   sum2 - 0
   sum4 - sum3 # symmetric and identical

   for(i in 1:ny) {
 sum2 - sum2 + sum(ifelse(y[i]y,y[i],y))
   }

 Thanks in advance for your help.

 -- Jeff

 -- 
 Professor J. S. Racine Phone:  (905) 525 9140 x 23825
 Department of EconomicsFAX:(905) 521-8232
 McMaster Universitye-mail: [EMAIL PROTECTED]
 1280 Main St. W.,Hamilton, URL:
 http://www.economics.mcmaster.ca/racine/
 Ontario, Canada. L8S 4M4

 `The generation of random numbers is too important to be left to  
 chance'

 __
 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] Affymetrix data analysis

2007-02-01 Thread Benilton Carvalho
The bioconductor mailing list is probably a better place to ask this  
type of question.

[EMAIL PROTECTED]

But we also need to know what arrays are you working with, what the  
errors are, what your sessionInfo() is

Let us know, ok?

b

On Feb 1, 2007, at 5:46 PM, Tristan Coram wrote:

 Hi,



 I am trying to read in my Affymetrix CEL files (48 files, total  
 ~600 MB) but
 I keep getting memory errors.  Can somebody please help me with  
 this.  Or is
 therea remote server I can send my data to for computation?



 Any help is much appreciated.



 Thanks





 Dr. Tristan Coram

 Postdoctoral Research Associate

 Research Plant Pathologist/Geneticist



 United States Department of Agriculture

 Agricultural Research Service

 Wheat Genetics, Quality Physiology  Disease Research



 209 Johnson Hall

 Washington State University

 Pullman, WA 99163



 Office: +1 509 335-1596  Fax: +1 509 335-2553

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

__
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] predict on biglm class

2007-02-12 Thread Benilton Carvalho
Hi Everyone,

I often use the 'safe prediction' feature available through glm().  
Now, I'm at a situation where I must use biglm:::bigglm.

## begin example

library(splines)
library(biglm)
ff - log(Volume)~ns(log(Girth), df=5)
fit.glm - glm(ff, data=trees)
fit.biglm - bigglm(ff, data=trees)
predict(fit.glm, newdata=data.frame(Girth=2:5))

## -1.3161465 -0.2975659  0.4251285  0.9856938

predict(fit.biglm, newdata=data.frame(Girth=2:5))

## Error in predict(fit.biglm, newdata = data.frame(Girth = 2:5)) :
##no applicable method for predict

## end example

So, it is my understanding that there is no 'predict' method for  
'bigglm' class. That suggests me that I need to create my own  
prediction method, right? What would be an efficient way of making  
these predictions that use ns() on a very large dataset?

My initial thought is that saving the Boundary.knots and knots, I  
could create the linear predictor by chunks (and therefore get the  
predictions). Is there a better way of doing this?

Thank you very much.

Benilton Carvalho
Department of Biostatistics
Bloomberg School of Public Health
Johns Hopkins University

__
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] Start and Restart R over SSH

2007-02-19 Thread Benilton Carvalho
Hi Nils,

if the server you're using is *NIX, this is what you can do:

 example
ssh [EMAIL PROTECTED]
screen
R

 do what you need in R
 close the terminal without quitting R 

ssh [EMAIL PROTECTED]
screen -r
 continue working in R 
%% end example

the problem is if you need X... it works until you quit the  
terminal, but screen -r doesn't reconnect the X11.

b


On Feb 19, 2007, at 9:40 AM, Douglas Bates wrote:

 On 2/19/07, Nils Höller [EMAIL PROTECTED] wrote:
 Hi,

 I have some big calculations in R to be done.
 Since I can use R on a server with ssh, i was wondering if I can  
 reopen
 a R Shell after exiting ssh.

 I don't want to use the batch mode and nohup doesn't work.

 I want to use something like
 ssh [EMAIL PROTECTED]
 R
 ---do something in R and start calculation ---
 close ssh but let R remain on the server, doing the calculation

 ssh [EMAIL PROTECTED]
 open the existing R Shell / Process

 Has anyone done something similiar?
 Can you help me or suggest an other solution ?

 I don't think it is possible to reattach to a process started in one
 ssh session from another ssh session.  However, you can put a session
 into the background with the -f flag to ssh.  You haven't told us what
 operating system you are starting the ssh connection on and what
 system will run the R process.  If I had an X server running on the
 local system and the remote system provided X clients like xterm I
 would do this by

 ssh -X -f [EMAIL PROTECTED] xterm

 This should spring up an autonomous xterm window on the local machine
 after which you can run R in it.

 I hope this helps.

 __
 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] linux gplots install unhappy

2007-02-20 Thread Benilton Carvalho
well, it's complaining because you don't have gtools installed.

how about:

install.packages(gplots, dep=T)

?

b

On Feb 20, 2007, at 1:17 PM, Randy Zelick wrote:

 Hello all,

 I use R on both windows and a mainframe linux installation (RedHat
 enterprise 3.0, which they tell me is soon to be upgraded to 4.0). On
 windows I installed the package gplots without trouble, and it  
 works fine.
 When I attempted to do the same on the unix computer, the following  
 error
 message was forthcoming:




 downloaded 216Kb

 * Installing *source* package 'gplots' ...
 ** R
 ** data
 ** inst
 ** preparing package for lazy loading
 Loading required package: gtools
 Warning in library(pkg, character.only = TRUE, logical = TRUE,  
 lib.loc =
 lib.loc) :
   there is no package called 'gtools'
 Error: package 'gtools' could not be loaded
 Execution halted
 ERROR: lazy loading failed for package 'gplots'
 ** Removing '/n/fs/disk/resuser02/u/zelickr/R/library/gplots'

 The downloaded packages are in
  /tmp/RtmpikM2JW/downloaded_packages
 Warning messages:
 1: installation of package 'gplots' had non-zero exit status in:
 install.packages(gplots, lib = ~/R/library)
 2: cannot create HTML package index in:
 tools:::unix.packages.html(.Library)



 Can someone provide the bit of information I need to progress with  
 this?

 Thanks very much,

 =Randy=

 R. Zelick email: [EMAIL PROTECTED]
 Department of Biology voice: 503-725-3086
 Portland State University fax:   503-725-3888

 mailing:
 P.O. Box 751
 Portland, OR 97207

 shipping:
 1719 SW 10th Ave, Room 246
 Portland, OR 97201

 __
 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] returns from dnorm and dmvnorm

2007-02-26 Thread Benilton Carvalho
well, nobody said that the density must be smaller than 1, right? :-)

it's just the value of the normal density function at the point you  
asked. you may try doing that by hand and, with the correct math,  
you'll get the same thing.

b

On Feb 26, 2007, at 3:03 PM, A Hailu wrote:

 Hi All,
 Why would calls to dnorm and dmvnorm return values that are above  
 1? For
 example,
 dnorm(0.3,mean=0, sd=0.1)
 [1] 3.989423

 This is happening on two different installations of R that I have.

 Thank you.

 Hailu

__
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] Is there a quick way to count the number of times each element in a vector appears?

2007-03-05 Thread Benilton Carvalho
is this what you mean?

tmp - combinations(3, 3, rep=TRUE)
colSums(apply(tmp, 1, duplicated))+1

b

On Mar 6, 2007, at 1:16 AM, Dylan Arena wrote:

 Hi there,


 I'm writing a function that calculates the probability of different
 outcomes of dice rolls (e.g., the sum of the highest three rolls of
 five six-sided dice).  I'm using the combinations function from the
 gtools package, which is great: it gives me a matrix with all of the
 possible combinations (with repetitions allowed).  Now I want to count
 the number of times each element appears in each arrangement so I can
 calculate the number of permutations of that arrangement.  E.g., if I
 get output like:

 combinations(3,3, rep=TRUE)
   [,1] [,2] [,3]
  [1,]111
  [2,]112
  [3,]113
  [4,]122
  [5,]123
  [6,]133
  [7,]222
  [8,]223
  [9,]233
 [10,]333

 I'd like to be able to determine that the first row has 3 repetitions,
 yielding 3!/3! = 1 permutation, while the second row has 3
 repetitions, yielding 3!/2! = 3 permutations, etc.  (This gets harder
 when there are large numbers of dice with many faces.)

 I know there are simple things to do, like iterating over the rows
 with for loops, but I've heard that for loops are sub-optimal in R,
 and I'd like to see what an elegant solution would look like.

 E.g., I might like to use sapply() with whatever function I come up
 with; I thought of using something like duplicated() and just counting
 the number of TRUEs that are returned for each vector (since the
 elements are always returned in non-decreasing order), but I'm
 optimistic that there is a better (faster/cleaner) way.

 So here is my question in a nutshell:
 Does anyone have ideas for how I might efficiently process a matrix
 like that returned by a call to combinations(n, r, rep=TRUE) to
 determine the number of repetitions of each element in each row of the
 matrix?  If so, I'd love to hear them!


 Thanks very much for your time,
 Dylan Arena
 (Statistics M.S. student)

 __
 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] Is there a quick way to count the number of times each element in a vector appears?

2007-03-05 Thread Benilton Carvalho
sorry, i forgot to mention that you will need an extra test |-)

tmp - combinations(3, 3, rep=TRUE)
out - colSums(apply(tmp, 1, duplicated))+1
out[out == 1] - 0

but now, re-reading your message, you say
(..) want to count the number of times each element appears in each  
arrangement (...)

apply(tmp, 1, function(v) table(factor(v, levels=1:3)))

might be what you actually meant.

sorry for the confusion,

b

On Mar 6, 2007, at 2:00 AM, Benilton Carvalho wrote:

 is this what you mean?

 tmp - combinations(3, 3, rep=TRUE)
 colSums(apply(tmp, 1, duplicated))+1

 b

 On Mar 6, 2007, at 1:16 AM, Dylan Arena wrote:

 Hi there,


 I'm writing a function that calculates the probability of different
 outcomes of dice rolls (e.g., the sum of the highest three rolls of
 five six-sided dice).  I'm using the combinations function from the
 gtools package, which is great: it gives me a matrix with all of  
 the
 possible combinations (with repetitions allowed).  Now I want to  
 count
 the number of times each element appears in each arrangement so I can
 calculate the number of permutations of that arrangement.  E.g., if I
 get output like:

 combinations(3,3, rep=TRUE)
   [,1] [,2] [,3]
  [1,]111
  [2,]112
  [3,]113
  [4,]122
  [5,]123
  [6,]133
  [7,]222
  [8,]223
  [9,]233
 [10,]333

 I'd like to be able to determine that the first row has 3  
 repetitions,
 yielding 3!/3! = 1 permutation, while the second row has 3
 repetitions, yielding 3!/2! = 3 permutations, etc.  (This gets harder
 when there are large numbers of dice with many faces.)

 I know there are simple things to do, like iterating over the rows
 with for loops, but I've heard that for loops are sub-optimal in R,
 and I'd like to see what an elegant solution would look like.

 E.g., I might like to use sapply() with whatever function I come up
 with; I thought of using something like duplicated() and just  
 counting
 the number of TRUEs that are returned for each vector (since the
 elements are always returned in non-decreasing order), but I'm
 optimistic that there is a better (faster/cleaner) way.

 So here is my question in a nutshell:
 Does anyone have ideas for how I might efficiently process a matrix
 like that returned by a call to combinations(n, r, rep=TRUE) to
 determine the number of repetitions of each element in each row of  
 the
 matrix?  If so, I'd love to hear them!


 Thanks very much for your time,
 Dylan Arena
 (Statistics M.S. student)

 __
 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-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] substitute variable

2007-03-26 Thread Benilton Carvalho
say your data frame is called tmp

tmp$PRODUCTS[tmp$PRODUCTS  70] - NA

b

On Mar 26, 2007, at 12:31 PM, Sergio Della Franca wrote:

 Dear R-Helpers,

 I want to substitute the contents of a variable under some contitions.

 I.e., I have this data set:

 YEAR   PRODUCTS
 1  80
 2  90
 3  50
 4  60
 5  30

 I want to perform this condition:
 if products 70 then products=NA else products=products.

 I'd like to achive the seguent result:

  YEAR   PRODUCTS
 1  NA
 2  NA
 3  50
 4  60
 5  30
 How can i develop this?


 Thank you in advance.


 Sergio Della Franca

   [[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@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] substitute variable

2007-03-26 Thread Benilton Carvalho
condition1 | condition2 (or)
condition1  condition2 (and)

tmp$PRODUCTS[tmp$PRODUCTS  70 | tmp$PRODUCTS   20] - NA

b

On Mar 26, 2007, at 12:47 PM, Sergio Della Franca wrote:

 Ok, this run correctly.

 Now i want to perform much more conditions, i.e.:

 tmp$PRODUCTS[tmp$PRODUCTS  70] - NA

 and

 tmp$PRODUCTS[tmp$PRODUCTS  20] - NA.

 How can i perform this double condition in the same code?


 2007/3/26, Benilton Carvalho [EMAIL PROTECTED]: say your data  
 frame is called tmp

 tmp$PRODUCTS[tmp$PRODUCTS  70] - NA

 b

 On Mar 26, 2007, at 12:31 PM, Sergio Della Franca wrote:

  Dear R-Helpers,
 
  I want to substitute the contents of a variable under some  
 contitions.
 
  I.e., I have this data set:
 
  YEAR   PRODUCTS
  1  80
  2  90
  3  50
  4  60
  5  30
 
  I want to perform this condition:
  if products 70 then products=NA else products=products.
 
  I'd like to achive the seguent result:
 
   YEAR   PRODUCTS
  1  NA
  2  NA
  3  50
  4  60
  5  30
  How can i develop this?
 
 
  Thank you in advance.
 
 
  Sergio Della Franca
 
[[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@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 drop variables using a wildcard and logic...

2007-03-26 Thread Benilton Carvalho
if 'test' is your data frame...

test[, grep([tT]$, names(test))]

b

On Mar 26, 2007, at 3:06 PM, [EMAIL PROTECTED] wrote:

 Dear R users

 I would like to make a new dataframe  from an existing dataframe,  
 retaining
 ONLY those variables that end in the letter t

 I have searched the help archives and consulted several reference  
 books but
 cannot seem to find an example.

 Any ideas...? Thanks!

 Mark

   [[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@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] .duplicate question

2007-03-28 Thread Benilton Carvalho
have you tried replacing

.duplicate()

in your my.causality() by

vars:::.duplicate()

?

b

On Mar 28, 2007, at 3:11 PM, Leeds, Mark ((IED)) wrote:

 I am using the vars package and it calls a function causality() which
 then calls something
 called .duplicate. I had to modify the causality function slightly for
 my purposes and
 I called it my.causality()  but now the .duplicate function is no  
 longer
 known to the my.causality function.
 I'm fairly certain that this is due to my lack of expertise in R  
 but if
 someone could tell me how
 to make the my.causality function know about .duplicate, it would be
 appreciated. Thanks.


   
 Mark
 

 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-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] string into command

2007-03-28 Thread Benilton Carvalho
cmd = mylist = list(a = 5, b = 7)
(eval(parse(text=cmd)))


b

On Mar 28, 2007, at 11:38 AM, Brian Dolan wrote:

 Hello,

 I would like to take the string

 mylist = list(a = 5, b = 7)

 and evaluate it as a list.  I have attempted to use parse and  
 several other functions with no success.

 Thanks for your time.

 -brian dolan

 ~~~

 may all your sequences converge


   [[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@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] pattern search

2007-04-04 Thread Benilton Carvalho
how about:

length(gregexpr(the, Text)[[1]])

?

b

On Apr 4, 2007, at 10:49 AM, Schmitt, Corinna wrote:

 Dear R-experts,

 I'm looking for an easy possibility for pattern search. I have got a
 string and a special pattern. I would like to know if the pattern
 appears in the string, if yes where does it appear (position) and the
 number of appearance.

 Example:

 Text = c(If the sun shines, no clouds should be seen in the sky!)
 SearchPattern = c(the)
 NumberOfAppearance = 0
 NumberOfLetters = 0

 -- NumberOfAppearance should be 2 in the end

 How can I get the string length (=number of letters stored in Text)?

 Has anyone a good idea?

 Thanks, Corinna

 __
 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] How do I print a string without the initial [1]?

2007-04-18 Thread Benilton Carvalho
  x=a\n
  cat(x)
a

On Apr 18, 2007, at 5:31 PM, steve wrote:

 If I print a sting I get an initial [1]:

 xx=a
 xx
 [1] a


 How do I get it to print just

 a

__
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] like apply(x,1,sum), but using multiplication?

2007-05-07 Thread Benilton Carvalho
see

?prod

b

On May 7, 2007, at 2:25 PM, Jose Quesada wrote:

 Hi,

 I need to multiply all columns in a matrix so something like
 apply(x,2,sum), but using multiplication should do.
 I have tried apply(x,2,*)
 I know this must be trivial, but I get:
 Error in FUN(newX[, i], ...) : invalid unary operator

 The help for apply states that unary operators must be quoted. I tried
 single quotes too, with the same results.

 Thanks,
 -Jose

 --  
 Jose Quesada, PhD.
 http://www.andrew.cmu.edu/~jquesada

 __
 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] names of objects in .rda

2007-05-11 Thread Benilton Carvalho
Hi everyone,

sorry if this was discussed before (and in this situation, could you  
please point me to the discussion in the archive? My search didn't  
seem to be effective).

Is there a way of getting the names of objects in a .rda file without  
having to load it?

Thank you very much,

benilton

--
PhD Candidate
Department of Biostatistics
Bloomberg School of Public Health
Johns Hopkins University

__
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 computation of trimmed stats?

2007-05-14 Thread Benilton Carvalho
Hi everyone,

I was wondering if there is anything already implemented for  
efficient (row-wise) computation of group-specific trimmed stats  
(mean and sd on the trimmed vector) on large matrices.

For example:

set.seed(1)
nc = 300
nr = 25
x = matrix(rnorm(nc*nr), ncol=nc)
g = matrix(sample(1:3, nr*nc, rep=T), ncol=nc)

trimmedMeanByGroup - function(y, grp, trim=.05)
   tapply(y, factor(grp, levels=1:3), mean, trim=trim)

sapply(1:10, function(i) trimmedMeanByGroup(x[i,], g[i,]))

works fine... but:

  system.time(sapply(1:nr, function(i) trimmedMeanByGroup(x[i,], g 
[i,])))
user  system elapsed
399.928   0.019 399.988

does not look interesting for me.

Maybe some package has some implementation of the above?

Thank you very much,
-b

--
Benilton Carvalho
PhD Candidate
Department of Biostatistics
Bloomberg School of Public Health
Johns Hopkins University
[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] conversion into capital letter

2007-05-15 Thread Benilton Carvalho
help(toupper)

b

On May 15, 2007, at 2:41 AM, [EMAIL PROTECTED] wrote:


 Dear all,


 I would need a function which convert small letter into capital  
 letter (at
 least the first letter of a character variable).

 Does such a function exist in R ?

 Thanks by advance

 Jessica



--
Benilton Carvalho
PhD Candidate
Department of Biostatistics
Bloomberg School of Public Health
Johns Hopkins University
[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] help with executing instruction every i-th run of loop

2007-05-17 Thread Benilton Carvalho
if (i %% 1000 == 0)

b

On May 17, 2007, at 10:56 AM, Mark W Kimpel wrote:

 I am running a very long loop and would like to save intermediate
 results in case of a system or program crash. Here is the skeleton of
 what my code would be:

 for (i in 1:zillion)
{
 results[[i]]-do.something.function()
 if (logical.test(i)) {save(results, results.tmp)}
}

 logical.test would test to see if i/1000 has no remainder. What R
 function would test that?

 Is there an even better way to address my need?

 Thanks,
 Mark
 --  

 ---

 Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
 Indiana University School of Medicine

 15032 Hunter Court, Westfield, IN  46074

 (317) 490-5129 Work,  Mobile  VoiceMail
 (317) 663-0513 Home (no voice mail please)

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



--
Benilton Carvalho
PhD Candidate
Department of Biostatistics
Bloomberg School of Public Health
Johns Hopkins University
[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] error message

2007-05-22 Thread Benilton Carvalho
install.packages(RMySQL, dep=T)

should fix it for you.

b

ps: The error says RMySQL is the problem... it is not complaining  
about R itself (although it would not be a bad idea, given that the  
latest R is v 2.5.0, so it would be a better idea to start by  
upgrading your R)

On May 22, 2007, at 11:59 AM, karen power wrote:

 Hi,

 I am trying to install the package exonmap and RMySQL however I keep
 getting the following error:

 Error in library(pkg, character.only = TRUE) :
 'RMySQL' is not a valid package -- installed  2.0.0?

 I have R version 2.4.1 so I know its not a version issue. I deleted  
 and
 reinstalled the folders again and the same thing happened. Has anyone
 any ideas?

 Thanks,

 Karen

__
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] What is the maximum size of a matrix?

2007-06-01 Thread Benilton Carvalho
AFAIK, it only depends on how much free memory you have.
b

On Jun 1, 2007, at 5:05 PM, Guanrao Chen wrote:

 hi, Rers

 I tried to find out the max size (# of rows, # of
 columns) of a matrix that is allowed by R but failed.

 Can anybody let me know?

 Thanks!
 Guanrao

__
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] Windows source in Linux

2007-06-01 Thread Benilton Carvalho
iconv on your linux box should do the work.
b

On Jun 1, 2007, at 7:19 PM, Alberto Vieira Ferreira Monteiro wrote:

 I have a windows source file.r, with the default charset of windows.
 I can't use it in Linux as source(file.r), because Linux's  
 default is
 Unicode. How can I read it?

 Alberto Monteiro

__
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] Why is the R mailing list so hard to figure out?

2007-06-04 Thread Benilton Carvalho
Well, I have my email client to organize everything by thread...  
which does the work for me...

ethz: Eidgenössische Technische Hochschule Zürich
ch: Confœderatio Helvetica

best,
b

On Jun 4, 2007, at 7:25 PM, Robert Wilkins wrote:

 Why does the R mailing list need such an unusual and customized  
 user interface?

 Last January, I figured out how to read Usenet mailing lists ( or
 Usenet groups ) and they all pretty much work the same, learn to use
 one, you've learned to use them all ( gnu.misc.discuss ,
 comp.lang.lisp , and so on ).

 What's the best way to view and read discussions in this group for
 recent days? Can I view the postings for the current day via Google
 Groups?

 I hope I'm posting correctly.

 What does ethz and ch stand for? Is ch for Switzerland?


 Robert

__
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] name of the variable that will contain the result of a function

2007-06-06 Thread Benilton Carvalho
Hi everyone,

say I have a function called 'foo', which takes the argument arg1.

Is there any mechanism that I can use to learn about the variable  
where foo(arg1) is going to be stored?

For example:

x - foo(arg1)

so, inside foo() I'd like to be able to get the string x.

if,

foo(arg1)

was used insted, I'd like to get NA.

thank you very much,

b






--
Benilton Carvalho
PhD Candidate
Department of Biostatistics
Bloomberg School of Public Health
Johns Hopkins University
[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] How to do clustering

2007-06-07 Thread Benilton Carvalho
sorry, I hit send before finishing my thoughts...

and as for clustering microarray data, you might want to consider the  
bioconductor mailing list...

[EMAIL PROTECTED]

b

On Jun 7, 2007, at 10:42 PM, ssls sddd wrote:

 Dear List,

 I have another question to bother you about how to do clustering.
 My data consists of 49 columns (49 variables) and 238804 rows.
 I would like to do hierarchical clustering (unsupervised clustering
 and PCA). So far I tried pvclust (www.is.titech.ac.jp/~shimo/prog/ 
 *pvclust*
 /)
 but I always had the problem like for R like cannot allocate the  
 memory.

 I am curious about what else packages can perform the clustering  
 analysis
 while memory efficient.

 Meanwhile, is there any way that I can extract the features of each  
 cluster.

 In other words, I would like to identify which are responsible for
 classifying these
 variables (samples).

 Thanks a lot!

 Sincerely,

 Alex

   [[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@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 do clustering

2007-06-07 Thread Benilton Carvalho
Hi Alex,

just in case you're trying to get genotypes from the Affymetrix 500K  
set, you might want to check the oligo package available on  
BioConductor.

best,
b

On Jun 7, 2007, at 10:42 PM, ssls sddd wrote:

 Dear List,

 I have another question to bother you about how to do clustering.
 My data consists of 49 columns (49 variables) and 238804 rows.
 I would like to do hierarchical clustering (unsupervised clustering
 and PCA). So far I tried pvclust (www.is.titech.ac.jp/~shimo/prog/ 
 *pvclust*
 /)
 but I always had the problem like for R like cannot allocate the  
 memory.

 I am curious about what else packages can perform the clustering  
 analysis
 while memory efficient.

 Meanwhile, is there any way that I can extract the features of each  
 cluster.

 In other words, I would like to identify which are responsible for
 classifying these
 variables (samples).

 Thanks a lot!

 Sincerely,

 Alex

   [[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@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] find position

2007-06-10 Thread Benilton Carvalho
which(a == .4)[1]

b

On Jun 10, 2007, at 4:45 AM, gallon li wrote:

 find the position of the first value who equals certain number in a  
 vector:

 Say a=c(0,0,0,0,0.2, 0.2, 0.4,0.4,0.5)

 i wish to return the index value in a for which the value in the  
 vector is
 equal to 0.4 for the first time. in this case, it is 7.

   [[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@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] p-value from GEE why factor 2*pnorm?

2007-06-11 Thread Benilton Carvalho
the recommendation was to use lower.tail=FALSE.

b

On Jun 11, 2007, at 11:21 AM, Carmen Meier wrote:

 I got an answer for the other question (thank you)

 But there is another question  (I am afraid this is a basic  
 question ...)

 In this tread there is a hint hwo to calculate the p-vlue of an GEE:
 _http://finzi.psych.upenn.edu/R/Rhelp02a/archive/74150.html_

 Then, get the P values using a normal approximation for the
 distribution of z:

 / 2 * pnorm(abs(coef(summary(fm1))[,5]), lower.tail = FALSE) /
 (Intercept) TPTLD  0. 0.04190831

 1. why is the result multiplicated  with 2? There is a P-value  
 between 1 and 2
 with the results below and multiplicated with 2:

 2*pnorm(c 
 (1.8691945,0.5882351,2.4903091,1.9287802,2.3172983,2.2092593,2.2625959 
 ,1.6395695),
 lower.tail =TRUE)

 Regards Carmen

__
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] p-value from GEE why factor 2*pnorm?

2007-06-11 Thread Benilton Carvalho
Well, AFAIK, the definition of a p-value is the probability of  
observing something at least as extreme as the observed data.

If you observed z, and Z follows a std-normal

p-value = P( Z  -abs(z) ) + P( Z  abs(z) )
   = 2*P ( Z  abs(z) )
   = 2*pnorm(z, lower.tail=FALSE)

try z=0 (you should get 1) and z=1.96 (you should get 5%)

b

On Jun 11, 2007, at 11:34 AM, Carmen Meier wrote:

 Benilton Carvalho schrieb:
 the recommendation was to use lower.tail=FALSE.

 b

 O
 but then the results are significant and this does not match the
 observation.
 The results are matching the observations if the formula is

 pnorm(c 
 (1.8691945,0.5882351,2.4903091,1.9287802,2.3172983,2.2092593,2.2625959 
 ,1.6395695),
 lower.tail =TRUE)

 so I have any unknown problem  anywhere :-(

 REgards Carmen

__
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] Rearranging Capture History Data in R

2007-06-11 Thread Benilton Carvalho
date = c(1, 1, 1, 1, 2, 2, 3, 3, 4)
tag = c(1, 2, 3, 4, 2, 4, 1, 2, 4)
table(factor(tag, levels=1:4), factor(date, levels=1:4))

(not sure how you got Tag 1/Date 4 = 1)


On Jun 11, 2007, at 3:11 PM, [EMAIL PROTECTED] wrote:

 What code can i use to convert a table like this:

 Tag#Date
 1   1
 2   1
 3   1
 4   1
 2   2
 4   2
 1   3
 2   3
 4   4

 Into one like this:

 Tag 1 2 3 4 #Date header
 1   1 0 0 1
 2   1 1 1 0
 3   1 0 0 0
 4   1 1 0 1

 Thanks,


 Ben Cox
 Research Assistant (M.S.)
 Montana Cooperative Fishery Research Unit
 301 Lewis Hall
 Montana State University
 Bozeman, MT 59717
 (406)994-6643

 __
 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] Build Windows pkgs from source - online

2007-06-12 Thread Benilton Carvalho
Hi,

First of all, I apologize for sending out this message, as I'm sure  
the answer is on the archives, but I just can't find it.

Not long ago, there was a discussion about building Windows packages  
from the source code and someone posted a link to a website  to which  
we could submit the source and get the Windows version a while later.

Could someone point me to that website or to where I can find such info?

Thanks,

-benilton

__
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] plot via xyplot not being saved

2007-06-15 Thread Benilton Carvalho
Hi everyone,

it's been a while I've been trying to save a plot created via  
lattice:::xyplot

if I have a file tst.R with the following code:

y - rnorm(100)
x - rnorm(100)
z - sample(letters[1:4], 100, rep=T)
library(lattice)
bitmap(tst.png)
xyplot(y~x|z)
dev.off()

and I source it, I get the tst.png file, which is a blank page.

If I copy and paste instead, I get the correct plot.

Any suggestion?

Thank you very much,

b

  sessionInfo()
R version 2.5.0 (2007-04-23)
x86_64-unknown-linux-gnu

locale:
LC_CTYPE=en_US.iso885915;LC_NUMERIC=C;LC_TIME=en_US.iso885915;LC_COLLATE 
=en_US.iso885915;LC_MONETARY=en_US.iso885915;LC_MESSAGES=en_US.iso885915 
;LC_PAPER=en_US.iso885915;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASU 
REMENT=en_US.iso885915;LC_IDENTIFICATION=C

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

other attached packages:
lattice
0.15-4

__
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] plot via xyplot not being saved

2007-06-15 Thread Benilton Carvalho
So, if those statements are inside a function, I have to make my  
function to have an 'echo' argument/functionality? eg.:

## begin test.R
test - function(n){
   y - rnorm(n)
   x - rnorm(n)
   z - sample(letters[1:4], n, rep=T)
   library(lattice)
   bitmap(tst.png)
   xyplot(y~x|z)
   dev.off()
}

test(100)
## end test.R

source(test.R, echo=T)

also fails in this case...

thanks a lot,

b


On Jun 15, 2007, at 8:53 PM, [EMAIL PROTECTED] wrote:

 On 6/15/07, Benilton Carvalho [EMAIL PROTECTED] wrote:
 Hi everyone,

 it's been a while I've been trying to save a plot created via
 lattice:::xyplot

 if I have a file tst.R with the following code:

 y - rnorm(100)
 x - rnorm(100)
 z - sample(letters[1:4], 100, rep=T)
 library(lattice)
 bitmap(tst.png)
 xyplot(y~x|z)
 dev.off()

 and I source it, I get the tst.png file, which is a blank page.

 If I copy and paste instead, I get the correct plot.

 Any suggestion?

 Use

 source(..., echo = TRUE)

 -Deepayan

__
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] plot via xyplot not being saved

2007-06-15 Thread Benilton Carvalho
Thank you Deepayan,

I understand the behavior of not printing out the results inside the  
functions.

What I didn't know was that for xyplot() saving the plot actually  
meant save the result I see, which does not happen with plot(), in  
which case my function test() works just fine if I replaced xyplot()  
by plot().

Thank you very much,

b

On Jun 16, 2007, at 12:26 AM, [EMAIL PROTECTED] wrote:

 On 6/15/07, Benilton Carvalho [EMAIL PROTECTED] wrote:
 So, if those statements are inside a function, I have to make my
 function to have an 'echo' argument/functionality? eg.:

 ## begin test.R
 test - function(n){
y - rnorm(n)
x - rnorm(n)
z - sample(letters[1:4], n, rep=T)
library(lattice)
bitmap(tst.png)
xyplot(y~x|z)
dev.off()
 }

 test(100)
 ## end test.R

 source(test.R, echo=T)

 also fails in this case...

 Yes. The following will produce some output (the values of x + y and x
 - y) if you type it out at the R prompt:

 x - rnorm(10)
 y - rnorm(10)
 x + y
 x - y

 If you put that in a file and source it, nothing will get printed,
 unless you have echo=TRUE. If you define

 test - function(){
x - rnorm(10)
y - rnorm(10)
x + y
x - y
 }

 calling test() at the R prompt will only print x - y and not x + y,  
 and so on.

 This is all standard R behaviour. If you want something to be printed
 irrespective of context, use print(), e.g.

 print(x + y)

 or

 print(xyplot(y~x|z))

 This is also mentioned in the R FAQ.

 -Deepayan

__
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] Creating directory under Windows R session

2007-06-20 Thread Benilton Carvalho
?dir.create

b

On Jun 20, 2007, at 8:07 AM, Milton Cezar Ribeiro wrote:

 Hi all,

 How can I create (and check the existence of) a directory in a R  
 session under Windows(xp)?

 Kind regards,

 Miltinho

__
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] create matrix from comparing two vectors

2007-06-26 Thread Benilton Carvalho
outer(test, fac, )

-b

On Jun 26, 2007, at 2:13 PM, Van Campenhout Bjorn wrote:

 hi all, sorry for this basic question, I think I know I should use ? 
 apply, but it is really confusing me...

 I want to create a matrix by comparing two vectors.  Eg:

 test-seq(1:10)
 fac-c(3,6,9)

 and i want to end up with a 10*3 matrix with a boolean that tests  
 if testfac, so something like:

 1 1 1
 1 1 1
 0 1 1
 0 1 1
 0 1 1
 0 0 1
 0 0 1
 0 0 1
 0 0 0
 0 0 0

 I can't find the solution without using a loop...

 B

   [[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@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] stack multiple plots on one page

2007-06-28 Thread Benilton Carvalho
or just type:

pairs.default

b

On Jun 28, 2007, at 2:36 PM, Henrique Dallazuanna wrote:

 https://svn.r-project.org/R/branches/R-2-5-branch/src/library/ 
 graphics/R/pairs.R

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

 On 28/06/07, Jiong Zhang, PhD [EMAIL PROTECTED] wrote:

 Hi All,

 I typed pairs to see its code but did not get what I want.  How  
 do I
 see its code?

 What I am trying to do, is to stack about 10 scatter plots on one  
 page
 as the way pairs does.  I have about 150 variables in my table.
 Instead of plotting 150X150 pairs using pairs, I only need to  
 plot 10
 pairs.

 Thanks.

 jiong
 The email message (and any attachments) is for the sole use of the
 intended recipient(s) and may contain confidential information.  Any
 unauthorized review, use, disclosure or distribution is  
 prohibited.  If you
 are not the intended recipient, please contact the sender by reply  
 email and
 destroy all copies of the original message (and any attachments).   
 Thank
 You.



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


   [[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@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] why this doesn't work for qqnorm

2007-06-28 Thread Benilton Carvalho
qqnorm(table[,1])

is what you want, isn't it?

and other forms would include:

par(ask=TRUE)
results = apply(table, 2, qqnorm)
par(ask=FALSE)

b

On Jun 28, 2007, at 9:50 PM, Jiong Zhang, PhD wrote:

 I want to qqnorm every column in a table.  When I try the first column
 using

 qqnorm(table$column1), it worked.

 But when I use

 qqnorm(table[1]), it tells me Error in stripchart(x1, ...) : invalid
 plotting method.

 What happen?  How can I make a function that qqnorms every column?

 thanks a lot.

 -jiong

__
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] Comparison: glm() vs. bigglm()

2007-06-29 Thread Benilton Carvalho
Hi,

Until now, I thought that the results of glm() and bigglm() would  
coincide. Probably a naive assumption?

Anyways, I've been using bigglm() on some datasets I have available.  
One of the sets has 15M observations.

I have 3 continuous predictors (A, B, C) and a binary outcome (Y).  
And tried the following:

m1 - bigglm(Y~A+B+C, family=binomial(), data=dataset1, chunksize=10e6)
m2 - bigglm(Y~A*B+C, family=binomial(), data=dataset1, chunksize=10e6)
imp - m1$deviance-m2$deviance

For my surprise imp was negative.

I then tried the same models, using glm() instead... and as I  
expected, imp was positive.

I also noticed differences on the coefficients estimated by glm() and  
bigglm() - small differences, though, and CIs for the coefficients (a  
given coefficient compared across methods) overlap.

Are such incrongruences expected? What can I use to check for  
convergence with bigglm(), as this might be one plausible cause for a  
negative difference on the deviances?

Thank you very much,

-benilton

  sessionInfo()
R version 2.5.0 (2007-04-23)
x86_64-unknown-linux-gnu

locale:
LC_CTYPE=en_US.iso885915;LC_NUMERIC=C;LC_TIME=en_US.iso885915;LC_COLLATE 
=en_US.iso885915;LC_MONETARY=en_US.iso885915;LC_MESSAGES=en_US.iso885915 
;LC_PAPER=en_US.iso885915;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASU 
REMENT=en_US.iso885915;LC_IDENTIFICATION=C

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

other attached packages:
biglm
0.4

__
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] Comparison: glm() vs. bigglm()

2007-06-29 Thread Benilton Carvalho
Hi Peter,

thank you very much for your feedback.

As for your observations, I do realize that I'm using 1.5 chunks for  
this particular case (10e6 gives around 8 chunks on other sets).

I just noticed that I didn't add the difference in the deviances that  
I observed:

m1$deviance-m2$deviance
[1] -93196.69

Thank you very much for the suggestion, I'll give it a try.

Best,
benilton

On Jun 29, 2007, at 11:05 AM, Peter Dalgaard wrote:

 Benilton Carvalho wrote:
 Hi,

 Until now, I thought that the results of glm() and bigglm() would
 coincide. Probably a naive assumption?

 Anyways, I've been using bigglm() on some datasets I have available.
 One of the sets has 15M observations.

 I have 3 continuous predictors (A, B, C) and a binary outcome (Y).
 And tried the following:

 m1 - bigglm(Y~A+B+C, family=binomial(), data=dataset1,  
 chunksize=10e6)
 m2 - bigglm(Y~A*B+C, family=binomial(), data=dataset1,  
 chunksize=10e6)
 imp - m1$deviance-m2$deviance

 For my surprise imp was negative.

 I then tried the same models, using glm() instead... and as I
 expected, imp was positive.

 I also noticed differences on the coefficients estimated by glm() and
 bigglm() - small differences, though, and CIs for the coefficients (a
 given coefficient compared across methods) overlap.

 Are such incrongruences expected? What can I use to check for
 convergence with bigglm(), as this might be one plausible cause for a
 negative difference on the deviances?

 It doesn't sound right, but I cannot reproduce your problem on a  
 similar
 sized problem (it pretty much killed my machine...). Some  
 observations:

 A: You do realize that you are only using 1.5 chunks? (15M vs. 10e6
 chunksize)

 B: Deviance changes are O(1) under the null hypothesis but the  
 deviances
 themselves are O(N). In a smaller variant (N=1e5), I got

 m1$deviance
 [1] 138626.4
 m2$deviance
 [1] 138626.4
 m2$deviance - m1$deviance
 [1] -0.05865785

 This does leave some scope for roundoff to creep in. You may want to
 play with a lower setting of tol=...

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


__
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] A More efficient method?

2007-07-04 Thread Benilton Carvalho
C1 - rep(-1, length(Cat))
C1[Cat == b]] - 1

b

On Jul 4, 2007, at 9:44 AM, Keith Alan Chamberlain wrote:

 Dear Rhelpers,

 Is there a faster way than below to set a vector based on values from
 another vector? I'd like to call a pre-existing function for this,  
 but one
 which can also handle an arbitrarily large number of categories.  
 Any ideas?

 Cat=c('a','a','a','b','b','b','a','a','b')# Categorical variable
 C1=vector(length=length(Cat)) # New vector for numeric values

 # Cycle through each column and set C1 to corresponding value of Cat.
 for(i in 1:length(C1)){
   if(Cat[i]=='a') C1[i]=-1 else C1[i]=1
 }

 C1
 [1] -1 -1 -1  1  1  1 -1 -1  1
 Cat
 [1] a a a b b b a a b

 Sincerely,
 KeithC.
 Psych Undergrad, CU Boulder (US)
 RE McNair Scholar

 __
 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] Source inside source

2007-07-16 Thread Benilton Carvalho
the smarter thing is to write a package, so you don't need source()  
at all.

but your problem will be fixed if you use the full path instead:

source(/home/user/dir1/dir2/file2.R)

(and obviously you could pass the path as an argument to whatever  
function you're using...)

b

On Jul 16, 2007, at 6:11 PM, Alberto Monteiro wrote:

 Is there a way to know where is the source, so as to make a source  
 call
 inside another source smarter?

 As an example:

 file1.R is in directory /files/dir1/

 file2.R is in directory /files/dir1/dir2/

 In file1.R, there is this line:

 source(dir2/file2.R)

 So, if I setwd to /files/dir1/, and then I call source(file1.R),
 it will run correctly. However, if I setwd to /files, then
 call source(dir1/file1.R), it will give an error when
 trying to source file2.R

 Alberto Monteiro

 __
 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] data.restore() in R 2.5.1 for Windows 95 and later

2007-07-16 Thread Benilton Carvalho
The R  Data Import/Export also says that this function is in the  
foreign package. :-)

b

On Jul 16, 2007, at 11:38 PM, Brad Christoffersen wrote:

 To Whom It May Concern:

 I want to read in an S-PLUS data dump and I used

 data.restore(filepath/filename)

 (in R 2.5.1 for Windows 95 and later) and I get the message

 Error: could not find function data.restore

 I have also tried read.S() and read.dta() with the same result.  I  
 cannot find
 any of these functions in the R Help for package base, although  
 data.restore()
 is mentioned in the R Data Import/Export manual.  I have also tried  
 apropos()
 and character(0) returns.  Additionally, I tried

 getS3method(data,restore)

 but get

 Error in getS3method(data, restore) : no function 'data' could  
 be found

 In addition, I tried

 dget(filepath/filename)

 and it was taking a very long time to import the desired data dump  
 objects which
 previously took a shorter time using data.restore in SPlus.

 Any help is much appreciated!

 Thanks,

 Brad Christoffersen
 Graduate Student
 University of Arizona

 __
 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] Classification

2007-07-18 Thread Benilton Carvalho
maybe:

x = c(.2, .1, .8, .3, .7, .6, .01, .2, .5, 1, 1)
breaks = seq(0, 1, .2)
LETTERS[1:(length(breaks)-1)][cut(x, breaks)]

b

On Jul 18, 2007, at 1:50 PM, Doran, Harold wrote:

 Michael

 Assume your data frame is called data and your variable is called
 V1. Converting this to a factor is:

 data$V1 - factor(data$V1)

 Creating the classes can be done using ifelse(). Something like

 data$class - ifelse(data$V1  .21, A, ifelse(data$V1  .41, B, C))

 Harold


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Ing.
 Michal Kneifl, Ph.D.
 Sent: Wednesday, July 18, 2007 1:37 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Classification

 Hi,
 I am also a quite new user of R and would like to ask you for help:
 I have a data frame where all columns are numeric variables.
 My aim is to convert one columnt in factors.
 Example:
 MD
 0.2
 0.1
 0.8
 0.3
 0.7
 0.6
 0.01
 0.2
 0.5
 1
 1


 I want to make classes:
 0-0.2 A
 0.21-0.4 B
 0.41-0.6 C
 . and so on

 So after classification I wil get:
 MD
 A
 A
 D
 B
 .
 .
 .
 and so on

 Please could you give an advice to a newbie?
 Thanks a lot in advance..

 Michael

 __
 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-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: Do GLM by groups

2007-07-19 Thread Benilton Carvalho
Check the following example for by():

  require(stats)
  attach(warpbreaks)
  by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x))

or just type:
example(by)

b


On Jul 19, 2007, at 1:18 PM, Hongmei Jia wrote:


 Dear All,

 I'm trying to do 'glm' analysis by groups just like in SAS you use by
 variable.   I don't know how to do it in R, anyone can help with  
 this?
 i.e.

 groupline  rep  value
 1  1   1   0.2
 1  1   2   0.3
 1 1   3   0.23
 1 2   1   0.2
 1 2   2   0.3
 1 2  3   0.23
 2  1   1   0.2
 2  1   2   0.3
 2 1   3   0.23
 2 2   1   0.2
 2 2   2   0.3
 2 2  3   0.23

 in SAS we say:
 model value=line rep;
 by group;

 How can I do this in R?

 Thanks,

 Hongmei Jia

 __
 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] Dataframe of factors transform speed?

2007-07-19 Thread Benilton Carvalho
it looks like that whatever method you used to genotype the 1002  
samples on the STY array gave you a transposed matrix of genotype  
calls. :-)

i'd use:

genoT = read.table(yourFile, stringsAsFactors = FALSE)

as a starting point... but I don't think that would be efficient (as  
you'd need to fix one column at a time - lapply).

i'd preprocess yourFile before trying to load it:

cat yourFile | sed -e 's/AA/1/g' | sed -e 's/AB/2/g' | sed -e 's/BB/3/ 
g'  outFile

and, now, in R:

genoT = read.table(outFile, header=TRUE)

b

On Jul 19, 2007, at 11:51 PM, Latchezar Dimitrov wrote:

 Hello,

 This is a speed question. I have a dataframe genoT:

 dim(genoT)
 [1]   1002 238304

 str(genoT)
 'data.frame':   1002 obs. of  238304 variables:
  $ SNP_A.4261647: Factor w/ 3 levels 0,1,2: 3 3 3 3 3 3 3 3 3 3
 ...
  $ SNP_A.4261610: Factor w/ 3 levels 0,1,2: 1 1 3 3 1 1 1 2 2 2
 ...
  $ SNP_A.4261601: Factor w/ 3 levels 0,1,2: 1 1 1 1 1 1 1 1 1 1
 ...
  $ SNP_A.4261704: Factor w/ 3 levels 0,1,2: 3 3 3 3 3 3 3 3 3 3
 ...
  $ SNP_A.4261563: Factor w/ 3 levels 0,1,2: 3 1 2 1 2 3 2 3 3 1
 ...
  $ SNP_A.4261554: Factor w/ 3 levels 0,1,2: 1 1 NA 1 NA 2 1 1  
 2 1
 ...
  $ SNP_A.4261666: Factor w/ 3 levels 0,1,2: 1 1 2 1 1 1 1 1 1 2
 ...
  $ SNP_A.4261634: Factor w/ 3 levels 0,1,2: 3 3 2 3 3 3 3 3 3 2
 ...
  $ SNP_A.4261656: Factor w/ 3 levels 0,1,2: 1 1 2 1 1 1 1 1 1 2
 ...
  $ SNP_A.4261637: Factor w/ 3 levels 0,1,2: 1 3 2 3 2 1 2 1 1 3
 ...
  $ SNP_A.4261597: Factor w/ 3 levels AA,AB,BB: 2 2 3 3 3 2 1  
 2 2 3
 ...
  $ SNP_A.4261659: Factor w/ 3 levels AA,AB,BB: 3 3 3 3 3 3 3  
 3 3 3
 ...
  $ SNP_A.4261594: Factor w/ 3 levels AA,AB,BB: 2 2 2 1 1 1 2  
 2 2 2
 ...
  $ SNP_A.4261698: Factor w/ 2 levels AA,AB: 1 1 1 1 1 1 1 1 1  
 1 ...
  $ SNP_A.4261538: Factor w/ 3 levels AA,AB,BB: 2 3 2 2 3 2 2  
 1 1 2
 ...
  $ SNP_A.4261621: Factor w/ 3 levels AA,AB,BB: 1 1 1 1 1 1 1  
 1 1 1
 ...
  $ SNP_A.4261553: Factor w/ 3 levels AA,AB,BB: 1 1 2 1 1 1 1  
 1 1 1
 ...
  $ SNP_A.4261528: Factor w/ 2 levels AA,AB: 1 1 1 1 1 1 1 1 1  
 1 ...
  $ SNP_A.4261579: Factor w/ 3 levels AA,AB,BB: 1 1 1 1 1 2 1  
 1 1 2
 ...
  $ SNP_A.4261513: Factor w/ 3 levels AA,AB,BB: 2 1 2 2 2 NA 1  
 NA 2
 1 ...
  $ SNP_A.4261532: Factor w/ 3 levels AA,AB,BB: 1 2 2 1 1 1 3  
 1 1 1
 ...
  $ SNP_A.4261600: Factor w/ 2 levels AB,BB: 2 2 2 2 2 2 2 2 2  
 2 ...
  $ SNP_A.4261706: Factor w/ 2 levels AA,BB: 1 1 1 1 1 1 1 1 1  
 1 ...
  $ SNP_A.4261575: Factor w/ 3 levels AA,AB,BB: 1 1 1 1 1 1 1  
 2 2 1
 ...

 Its columns are factors with different number of levels (from 1 to 3 -
 that's what I got from read.table, i.e., it dropped missing levels). I
 want to convert it to uniform factors with 3 levels. The 1st 10 rows
 above show already converted columns and the rest are not yet  
 converted.
 Here's my attempt wich is a complete failure as speed:

 system.time(
 + for(j in 1:(10 )){ #-- this is to try 1st 10 cols and
 measure the time, it otherwise is ncol(genoT) instead of 10

 +gt-genoT[[j]]  #-- this is to avoid 2D indices
 +for(l in 1:length([EMAIL PROTECTED])){
 +  levels(gt)[l] - switch([EMAIL PROTECTED],AA=0,AB=1,BB=2)
 #-- convert levels to 0,1, or 2
 +  genoT[[j]]-factor(gt,levels=0:2)   #-- make a 3-level  
 factor
 and put it back
 +}
 + }
 + )
 [1] 785.085   4.358 789.454   0.000   0.000

 789s for 10 columns only!

 To me it seems like replacing 10 x 3 levels and then making a  
 factor of
 1002 element vector x 10 is a negligible amount of operations  
 needed.

 So, what's wrong with me? Any idea how to accelerate significantly the
 transformation or (to go to the very beginning) to make read.table  
 use a
 fixed set of levels (AA,AB, and BB) and not to drop any  
 (missing)
 level?

 R-devel_2006-08-26, Sun Solaris 10 OS - x86 64-bit

 The machine is with 32G RAM and AMD Opteron 285 (2.? GHz) so it's not
 it.

 Thank you very much for the help,

 Latchezar Dimitrov,
 Analyst/Programmer IV,
 Wake Forest University School of Medicine,
 Winston-Salem, North Carolina, 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-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] Dataframe of factors transform speed?

2007-07-20 Thread Benilton Carvalho
set.seed(123)
genoT = lapply(1:24, function(i) factor(sample(c(AA, AB,  
BB), 1000, prob=sample(c(1, 1000, 1000), 3), rep=T)))
names(genoT) = paste(snp, 1:24, sep=)
genoT = as.data.frame(genoT)
dim(genoT)
class(genoT)
system.time(out - lapply(genoT, function(x) match(x, c(AA, AB,  
BB))-1))
##
##
user  system elapsed
119.288   0.004 119.339

(for all 240K)

best,
b

ps: note that out is a list.

On Jul 20, 2007, at 2:01 AM, Latchezar Dimitrov wrote:

 Hi,

 -Original Message-
 From: Benilton Carvalho [mailto:[EMAIL PROTECTED]
 Sent: Friday, July 20, 2007 12:25 AM
 To: Latchezar Dimitrov
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Dataframe of factors transform speed?

 it looks like that whatever method you used to genotype the
 1002 samples on the STY array gave you a transposed matrix of
 genotype calls. :-)

 It only looks like :-)

 Otherwise it is correctly created dataframe of 1002 samples X (big
 number) of columns (SNP genotypes). It worked perfectly until I  
 decided
 to put together to cohorts independently processed in R already. I got
 stuck with my lack of foreseeing. Otherwise I would have put 3 dummy
 lines w/ AA,AB, and AB on each one to make sure all 3 genotypes are
 present and that's it! Lesson for the future :-)

 Maybe I am not using columns and rows appropriately here but the
 dataframe is correct (I have not used FORTRAN since FORTRAN IV ;-)  
 - as
 str says 1002 observ. of (big number) vars.


 i'd use:

 genoT = read.table(yourFile, stringsAsFactors = FALSE)

 as a starting point... but I don't think that would be
 efficient (as you'd need to fix one column at a time - lapply).

 No it was not efficient at all. 'matter of fact nothing is more
 efficient then loading already read data, alas :-(


 i'd preprocess yourFile before trying to load it:

 cat yourFile | sed -e 's/AA/1/g' | sed -e 's/AB/2/g' | sed -e
 's/BB/3/ g'  outFile

 and, now, in R:

 genoT = read.table(outFile, header=TRUE)

 ... Too late ;-) As it must be clear now I have two dataframes I  
 want to
 put together with rbind(geno1,geno2). The issue again is
 uniformization of factor variables w/ missing factors - they  
 ended up
 like levels AA,BB on one of the and levels AB,BB on the other which
 means as.numeric of AA is 1 on the 1st and as.numeric of AB is 1 on  
 the
 second - complete mess. That's why I tried to make both uniform, i.e.
 levels AA,AB, and BB for every SNP and then rbind works.

 In any case my 1st questions remains: What's wrong with me? :-)

 Thanks,
 Latchezar


 b

 On Jul 19, 2007, at 11:51 PM, Latchezar Dimitrov wrote:

 Hello,

 This is a speed question. I have a dataframe genoT:

 dim(genoT)
 [1]   1002 238304

 str(genoT)
 'data.frame':   1002 obs. of  238304 variables:
  $ SNP_A.4261647: Factor w/ 3 levels 0,1,2: 3 3 3 3 3
 3 3 3 3 3
 ...
  $ SNP_A.4261610: Factor w/ 3 levels 0,1,2: 1 1 3 3 1
 1 1 2 2 2
 ...
  $ SNP_A.4261601: Factor w/ 3 levels 0,1,2: 1 1 1 1 1
 1 1 1 1 1
 ...
  $ SNP_A.4261704: Factor w/ 3 levels 0,1,2: 3 3 3 3 3
 3 3 3 3 3
 ...
  $ SNP_A.4261563: Factor w/ 3 levels 0,1,2: 3 1 2 1 2
 3 2 3 3 1
 ...
  $ SNP_A.4261554: Factor w/ 3 levels 0,1,2: 1 1 NA 1 NA 2 1 1
 2 1
 ...
  $ SNP_A.4261666: Factor w/ 3 levels 0,1,2: 1 1 2 1 1
 1 1 1 1 2
 ...
  $ SNP_A.4261634: Factor w/ 3 levels 0,1,2: 3 3 2 3 3
 3 3 3 3 2
 ...
  $ SNP_A.4261656: Factor w/ 3 levels 0,1,2: 1 1 2 1 1
 1 1 1 1 2
 ...
  $ SNP_A.4261637: Factor w/ 3 levels 0,1,2: 1 3 2 3 2
 1 2 1 1 3
 ...
  $ SNP_A.4261597: Factor w/ 3 levels AA,AB,BB: 2 2 3 3 3 2 1
 2 2 3
 ...
  $ SNP_A.4261659: Factor w/ 3 levels AA,AB,BB: 3 3 3 3 3 3 3
 3 3 3
 ...
  $ SNP_A.4261594: Factor w/ 3 levels AA,AB,BB: 2 2 2 1 1 1 2
 2 2 2
 ...
  $ SNP_A.4261698: Factor w/ 2 levels AA,AB: 1 1 1 1 1 1 1 1 1
 1 ...
  $ SNP_A.4261538: Factor w/ 3 levels AA,AB,BB: 2 3 2 2 3 2 2
 1 1 2
 ...
  $ SNP_A.4261621: Factor w/ 3 levels AA,AB,BB: 1 1 1 1 1 1 1
 1 1 1
 ...
  $ SNP_A.4261553: Factor w/ 3 levels AA,AB,BB: 1 1 2 1 1 1 1
 1 1 1
 ...
  $ SNP_A.4261528: Factor w/ 2 levels AA,AB: 1 1 1 1 1 1 1 1 1
 1 ...
  $ SNP_A.4261579: Factor w/ 3 levels AA,AB,BB: 1 1 1 1 1 2 1
 1 1 2
 ...
  $ SNP_A.4261513: Factor w/ 3 levels AA,AB,BB: 2 1 2
 2 2 NA 1 NA
 2
 1 ...
  $ SNP_A.4261532: Factor w/ 3 levels AA,AB,BB: 1 2 2 1 1 1 3
 1 1 1
 ...
  $ SNP_A.4261600: Factor w/ 2 levels AB,BB: 2 2 2 2 2 2 2 2 2
 2 ...
  $ SNP_A.4261706: Factor w/ 2 levels AA,BB: 1 1 1 1 1 1 1 1 1
 1 ...
  $ SNP_A.4261575: Factor w/ 3 levels AA,AB,BB: 1 1 1 1 1 1 1
 2 2 1
 ...

 Its columns are factors with different number of levels
 (from 1 to 3 -
 that's what I got from read.table, i.e., it dropped missing
 levels). I
 want to convert it to uniform factors with 3 levels. The
 1st 10 rows
 above show already converted columns and the rest are not yet
 converted.
 Here's my attempt wich is a complete failure as speed:

 system.time(
 + for(j in 1:(10 )){ #-- this is to try 1st 10 cols and
 measure the time, it otherwise is ncol(genoT) instead of 10

Re: [R] automatically jpeg output

2007-07-20 Thread Benilton Carvalho
jpeg(...) ##if you have X11
bitmap(..., type=jpeg) ##otherwise

b

On Jul 20, 2007, at 11:34 AM, Ding, Rebecca wrote:

 Dear R users,

 I used R to draw many histograms and I would like to automatically  
 save
 them into a jpeg file. I tried the following code since I know .ps  
 file
 could be saved like this way:

 postscript(AYA_ELA.jpeg,horizontal=F,onefile=T)
 ..#some funtions inside here
 dev.off()

 There was a jpeg file, however, there is no pictures inside. Any
 suggestion?

 Thanks.

 Rebecca

__
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-mean-values for targeted rows

2007-07-20 Thread Benilton Carvalho
set.seed(123)
N = 3
K = 400
theData = matrix(rnorm(N*K), ncol=K)
theData = as.data.frame(theData)
theData = cbind(indicator = sample(0:1, N, rep=T), theData)

  system.time(results - colMeans(subset(theData, indicator == 1)))
user  system elapsed
   2.309   1.319   3.853


b


On Jul 20, 2007, at 6:17 PM, Diogo Alagador wrote:

 Hi all,

 I'm handling massive data.frames and matrices in R (3 x 400).
 In the 1st column, say, I have 0s and 1s indicating rows that  
 matter; other columns have probability values.
 One simple task I would like to do would be to get the column mean  
 values for signaled rows (the ones with 1)
 As a very fresh programmer I have build a simple function in R  
 which should not be very efficient indeed! It works well for  
 current-dimension matrices, but it just not goes so well in huge ones.

 meanprob-function(Robj){
 NLINE-dim(Robj)[1];
 NCOLUMN-dim(Robj)[2];
 mprob-c(rep(0,(NCOLUMN-1)));
 for (i in 2:NCOLUMN){
 sumprob-0;
 pa-0;
 for (j in 1:NLINE){
 if(Robj[j,1]!=0){
 pa-pa+1;
 sumprob-Robj[j,i]+sumprob;
 }
 }
 mprob[i-1]-sumprob/pa;
 }
 return(mprob);
 }


 So I only see 3 ways to get through the problem:

 - to reformulate the function to gain efficiency;
 - to establish a C-routine (for example), where loops are more  
 speedy, and then interfacing with R;
 - to find some function/ package that already do that.

 Can anybody illuminate my way here,

 Mush thanks,

 Diogo Andre' Alagador

   [[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@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] avoiding timconsuming for loop renaming identifiers

2007-07-20 Thread Benilton Carvalho
as.integer(factor(dta[[school_id]]))

b

On Jul 20, 2007, at 9:26 PM, [EMAIL PROTECTED] wrote:

 Hi All

 I was wondering if I can avoid a time-consuming for loop on my  
 60 obs dataset.

 school_id   y
 8   9.87
 8   8.89
 8   7.89
 8   8.88
 20  6.78
 20  9.99
 20  8.79
 31  10.1
 31  11

 There are, say, 143 different schools in this 60 obs dataset.

 I need to thave sequential identifiers, 1,2,3,4,5,...,143.

 I was using an awkward for look that took 30 minutes to run.
 sid = 1
 dta$sid[1] = 1
 for (i in 2:nrow(dta)) {
 if (dta$school_id[i] != dta$school_[i-1]) sid = sid+1
 dta$sid[i] = sid
 }

 Any hints appreciated.

 Thanks Toby

 __
 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] Write columns from within a list to a matrix?

2007-07-22 Thread Benilton Carvalho
test - lapply(1:3, function(i) cbind(runif(15), rnorm(15,2)))
sapply(test, [, 16:30)

b

On Jul 22, 2007, at 3:39 PM, [EMAIL PROTECTED] wrote:

 Hello,

 I think I have a mental block when it comes to working with lists.   
 lapply and sapply appear to do some magical things, but I can't  
 seem to master their usage.

 As an example, I would like to convert a column within a list to a  
 matrix, with the list element corresponding to the new matrix column.

 #Here is a simplified example: .
 test=vector(list, 3)
 for (i in 1:3){ test[[i]]=cbind(runif(15), rnorm(15,2)) }  #create  
 example list (I'm sure there is a better way to do this too).

 #Now, I wan to get the second column back out, converting it from a  
 list to a matrix.  This works, but gets confusing/inefficient when  
 I have multiple complex lists I am trying to manage.

 savecol2=matrix(0,15,0)
 for (i in 1:3){
 savecol2=cbind(savecol2, test[[i]][,1])
 }

 #Something like??:  (of course this doesn't work)
 savecol2=sapply(test, [[, function(x) x[2,])

 Thank you!

 Jeff

 __
 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] Write columns from within a list to a matrix?

2007-07-22 Thread Benilton Carvalho
oh! and if you want to be less ad-hoc:

sapply(test, function(x) x[,2])

b

On Jul 22, 2007, at 3:50 PM, Benilton Carvalho wrote:

 test - lapply(1:3, function(i) cbind(runif(15), rnorm(15,2)))
 sapply(test, [, 16:30)

 b

 On Jul 22, 2007, at 3:39 PM, [EMAIL PROTECTED] wrote:

 Hello,

 I think I have a mental block when it comes to working with  
 lists.  lapply and sapply appear to do some magical things, but I  
 can't seem to master their usage.

 As an example, I would like to convert a column within a list to a  
 matrix, with the list element corresponding to the new matrix column.

 #Here is a simplified example: .
 test=vector(list, 3)
 for (i in 1:3){ test[[i]]=cbind(runif(15), rnorm(15,2)) }  #create  
 example list (I'm sure there is a better way to do this too).

 #Now, I wan to get the second column back out, converting it from  
 a list to a matrix.  This works, but gets confusing/inefficient  
 when I have multiple complex lists I am trying to manage.

 savecol2=matrix(0,15,0)
 for (i in 1:3){
 savecol2=cbind(savecol2, test[[i]][,1])
 }

 #Something like??:  (of course this doesn't work)
 savecol2=sapply(test, [[, function(x) x[2,])

 Thank you!

 Jeff

 __
 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] apply incompatible dimensions error

2007-07-24 Thread Benilton Carvalho
are you positive that your function is doing what you expect it to do?

it looks like you want something like:

sapply(1:10, function(i) cor(mat1[i,], mat2[i,]))

b

On Jul 24, 2007, at 11:05 AM, Bernzweig, Bruce ((Consultant)) wrote:

 Hi,

 I've created the following two matrices (mat1 and mat2) and a function
 (f) to calculate the correlations between the two on a row by row  
 basis.

   mat1 - matrix(sample(1:500,50), ncol = 5,
   dimnames=list(paste(row, 1:10, sep=),
   paste(col, 1:5, sep=)))

   mat2 - matrix(sample(501:1000,50), ncol = 5,
   dimnames=list(paste(row, 1:10, sep=),
   paste(col, 1:5, sep=)))

   f - function(x,y) cor(x,y)

 When the matrices are squares (# rows = # columns) I have no problems.

 However, when they are not (as in the example above with 5 columns and
 10 rows), I get the following error:

 apply(mat1, 1, f, y=mat2)
 Error in cor(x, y, na.method, method == kendall) :
 incompatible dimensions

 Any help would be appreciated.  Thanks!

 - Bruce



 **
 Please be aware that, notwithstanding the fact that the pers... 
 {{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.


Re: [R] apply incompatible dimensions error

2007-07-24 Thread Benilton Carvalho
that's garbor's suggestion then.
sorry for the misunderstanding. :-)
b

On Jul 24, 2007, at 11:35 AM, Bernzweig, Bruce ((Consultant)) wrote:

 Thanks Benilton,

 I know what I want to do, just not sure how to do it using R.  The  
 help
 documentation is not very clear.

 What I am trying to do is calculate correlations on a row against row
 basis:  mat1 row1 x mat2 row1, mat1 row1 x mat2 row2, ... mat1 row1 x
 mat2 row-n, mat1 row-n, mat2 row-n

 - Bruce

 -Original Message-
 From: Benilton Carvalho [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, July 24, 2007 11:31 AM
 To: Bernzweig, Bruce (Consultant)
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] apply  incompatible dimensions error

 are you positive that your function is doing what you expect it to do?

 it looks like you want something like:

 sapply(1:10, function(i) cor(mat1[i,], mat2[i,]))

 b

 On Jul 24, 2007, at 11:05 AM, Bernzweig, Bruce ((Consultant)) wrote:

 Hi,

 I've created the following two matrices (mat1 and mat2) and a  
 function
 (f) to calculate the correlations between the two on a row by row
 basis.

  mat1 - matrix(sample(1:500,50), ncol = 5,
  dimnames=list(paste(row, 1:10, sep=),
  paste(col, 1:5, sep=)))

  mat2 - matrix(sample(501:1000,50), ncol = 5,
  dimnames=list(paste(row, 1:10, sep=),
  paste(col, 1:5, sep=)))

  f - function(x,y) cor(x,y)

 When the matrices are squares (# rows = # columns) I have no  
 problems.

 However, when they are not (as in the example above with 5 columns  
 and
 10 rows), I get the following error:

 apply(mat1, 1, f, y=mat2)
 Error in cor(x, y, na.method, method == kendall) :
 incompatible dimensions

 Any help would be appreciated.  Thanks!

 - Bruce



 * 
 *
 Please be aware that, notwithstanding the fact that the pers...
 {{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.



 **
 Please be aware that, notwithstanding the fact that the person sending
 this communication has an address in Bear Stearns' e-mail system, this
 person is not an employee, agent or representative of Bear Stearns.
 Accordingly, this person has no power or authority to represent, make
 any recommendation, solicitation, offer or statements or disclose
 information on behalf of or in any way bind Bear Stearns or any of its
 affiliates.
 **

__
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] generating symmetric matrices

2007-07-30 Thread Benilton Carvalho
after dat.cor use:

Rmat[lower.tri(Rmat)] - dat.cor
Rmat - t(Rmat)
Rmat[lower.tri(Rmat)] - dat.cor

b

On Jul 27, 2007, at 11:28 PM, Gregory Gentlemen wrote:

 Greetings,

 I have a seemingly simple task which I have not been able to solve  
 today. I want to construct a symmetric matrix of arbtriray size w/o  
 using loops. The following I thought would do it:

 p - 6
 Rmat - diag(p)
 dat.cor - rnorm(p*(p-1)/2)
 Rmat[outer(1:p, 1:p, )] - Rmat[outer(1:p, 1:p, )] - dat.cor

 However, the problem is that the matrix is filled by column and so  
 the resulting matrix is not symmetric.

 I'd be grateful for any adive and/or solutions.

 Gregory




 -




   [[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@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] xtable with vector

2007-07-30 Thread Benilton Carvalho
a - matrix(1:6, nr=1)
colnames(a) - paste(col, 1:6)
xtable(a)


On Jul 28, 2007, at 12:39 PM, Stefan Nachtnebel wrote:

 Hello,

 Is there a possibility to use xtable with a vector to generate a latex
 table? I always get an error, that no applicable method is available.

 For example:

 b-1:12
 dim(b)-c(2,6)
 dimnames(b)[[2]]-paste(col,1:6)
 xtable(b)

 works fine and does not raise an error, but

 a-1:6
 names(a)-paste(col,1:6)
 xtable(b)

 does not work.

 Regards, Stefan

__
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] Positioning text in top left corner of plot

2007-08-07 Thread Benilton Carvalho
maybe this is what you want?

plot(rnorm(10))
legend(topleft, A), bty=n)

?

b

On Aug 7, 2007, at 11:08 AM, Daniel Brewer wrote:

 Simple question how can you position text in the top left hand  
 corner of
 a plot?  I am plotting multiple plots using par(mfrow=c(2,3)) and  
 all I
 want to do is label these plots a), b), c) etc.  I have been fiddling
 around with both text and mtext but without much luck.  text is  
 fine but
  each plot has a different scale on the axis and so this makes it
 problematic.  What is the best way to do this?

 Many thanks

 Dan
 -- 
 **
 Daniel Brewer, Ph.D.

 Institute of Cancer Research
 Email: [EMAIL PROTECTED]
 **

 The Institute of Cancer Research: Royal Cancer Hospital, a  
 charitable Company Limited by Guarantee, Registered in England  
 under Company No. 534147 with its Registered Office at 123 Old  
 Brompton Road, London SW7 3RP.

 This e-mail message is confidential and for use by the add...{{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] length of a string

2007-09-05 Thread Benilton Carvalho
As long as you keep in mind Prof. Ripley's comment, you're going to  
be fine with nchar().

http://tolstoy.newcastle.edu.au/R/e2/devel/07/05/3450.html

Remember that what you want exactly is given by nchar(obj,  
type=chars), which is **NOT** the default on R 2.5.1 (only on  
R-2.6.0).

In your particular situation, assuming R-2.5.1, nchar(obj) works, but  
i'm afraid it's only a coincidence.

b

On Sep 5, 2007, at 11:05 AM, (Ted Harding) wrote:

 On 05-Sep-07 13:50:57, João Fadista wrote:
 Dear all,

 I would like to know how can I compute the length of a string in a
 dataframe. Example:

 SEQUENCE   ID
 TGCTCCCATCTCCACGGHR04FS00645
 ACTGAACTCCCATCTCCAAT  HR0595847847

 I would like to know how to compute the length of each SEQUENCE.

 Best regards,
 João Fadista

   nchar(ACTGAACTCCCATCTCCAAT)
   [1] 20

 seems to work. Find it, and related functions, with

   help.search(character)

 As it happens, help.search(string) will not help!

 Best wishes,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 05-Sep-07   Time: 15:05:22
 -- 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-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] SQL like function?

2007-09-06 Thread Benilton Carvalho
observation %in% ID

b

On Sep 7, 2007, at 1:40 AM, Takatsugu Kobayashi wrote:

 Hi RUsers,

 I am wonder if I can search observations whose IDs matches any of the
 values in another vector, such as in MySQL. While I am learing  
 MySQL for
 future database management, I appreciate if anyone could give me a  
 hint.

 Suppose I have one 5*1 vector containing observation IDs and
 frequencies, and one 3*1 vector containing observation IDs.

 observation-c(1,2,3,4,5)
 ID-c(1,3,4)

 Then, I would like to program a code that returns a results showing
 matched observations like

 result: TRUE FALSE TRUE TRUE FALSE

 I am reading S programming, but I cannot find a way to do this.

 Thank you very much.

 Taka

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