Re: [R] Re moving levels of a factor

2009-11-11 Thread Uwe Ligges



Dieter Menne wrote:



Henrik Wahren wrote:

How can one or more levels be removed from a factor of a data frame. There
was a similar post on how to do this when a factor meets some criterion
(e.g. = 2), but I can¹t seem to get that solution to work.
Here, I simply want to drop some levels.




Simply call factor again on the reduced set

a = factor(c(a,b,b,b))
a[-1]
factor(a[-1])

If a is in a data frame, replace a by by df$a.




or  a[-1, drop=TRUE]

Uwe Ligges


Dieter


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] prcomp() PCA vs fastICA() PCA?

2009-11-11 Thread Joel Fürstenberg-Hägg

Hi all,

 

I wonder what the difference is between the functions prcomp and the PCA 
plotting method used in example 3 from the fastICA package. They give totally 
different plots. The reason for asking is that I've earlier used prcomp, but 
now I should do an ICA, and I guess I cannot compare the PCA plot from prcomp 
with the ICA plot if the two PCA plots looks different?

 

Does anyone knows anything about this? Maybe there's a different approach 
that's better?

 

 

if(require(MASS))

{
   x - mvrnorm(n = 1000, mu = c(0, 0), Sigma = matrix(c(10, 3, 3, 1), 2, 2))
   x1 - mvrnorm(n = 1000, mu = c(-1, 2), Sigma = matrix(c(10, 3, 3, 1), 2, 2))
   X - rbind(x, x1)
   a - fastICA(X, 2, alg.typ = deflation, fun = logcosh, alpha = 1,
   method = R, row.norm = FALSE, maxit = 200,
   tol = 0.0001, verbose = TRUE)
   par(mfrow = c(1, 3))
   plot(a$X, main = Pre-processed data)
   plot(a$X%*%a$K, main = PCA components)
   plot(a$S, main = ICA components)
}


PC=prcomp (X, center=T, scale=T)
hcl=hclust(dist(df))
plot(PC$x[,1],PC$x[,2], main=PCA components (prcomp))

 

 

Best regards,

 

Joel
  
_
Nya Windows 7 gör allt lite enklare. Hitta en dator som passar dig!
http://windows.microsoft.com/shop
[[alternative HTML version deleted]]

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


Re: [R] gsub does not support \b?

2009-11-11 Thread Uwe Ligges



Tan, Richard wrote:

Hello, can someone help?  How come
 

gsub(\bINDS\b,INDUSTRIES,ADVANCED ENERGY INDS)

[1] ADVANCED ENERGY INDS



It does, but you need to escape it:

 gsub(\\bINDS\\b,INDUSTRIES,ADVANCED ENERGY INDS)

Uwe Ligges





not ADVANCED ENERGY INDUSTRIES
 
Thanks.

Richard

[[alternative HTML version deleted]]

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


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


Re: [R] What parts of 'Statistical Models in S' are not applicable to R?

2009-11-11 Thread Uwe Ligges



Peng Yu wrote:

According to Amazon review, 'Statistical Models in S' is a key
reference for understanding the methods implemented in several of
S-PLUS' high-end statistical functions, including 'lm()', predict()',
'design()', 'aov()', 'glm()', 'gam()', 'loess()', 'tree()',
'burl.tree()', 'nls()' and 'ms()'.

But since it is for S, some part of the book may not be applicable to
R. Some examples (e.g. interaction.plot()) discussed in this book are
not available in R. Without, working examples, it is sometimes
difficult for me to understand the materials in the book.

Besides the functions mentioned in the Amazon review, could somebody
give me a hint on what chapters (or sections) in this book are not
appropriate to R?



They all are appropriate, but nuances differ these days, as some nuances 
differ for recent S-PLUS versions, 17 years later. It should still be 
fine to learn some relevant concepts.


Best wishes,
Uwe Ligges



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


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


Re: [R] please add this email to the maillist

2009-11-11 Thread Ista Zahn
Hi,
You can ad it yourself:
http://stat.ethz.ch/mailman/listinfo/r-help

-Ista

On Wed, Nov 11, 2009 at 12:57 AM, 杨江伟 jwyan...@gmail.com wrote:
 thanks a lot

 --
 Pleasure should be subordinate to duty.

        [[alternative HTML version deleted]]

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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

2009-11-11 Thread Julia Cains
Dear R helpers
 
 
Suppose I have a following data
 
y  - c(9.21, 9.51, 9.73, 9.88, 10.12. 10.21)
 
t  - c(0, 0.25, 1, 3, 6, 12)
 
I want to find out the polynomial which fits y in terms of t i.e. y = f(t) some 
function of t.
 
e.g.   y = bo + b1*t + (b2 * t^2) + (b3 * t^3) + .. and so on.
 
In Excel I have defined y as independent variable, then defined t, t^2 and t^3 
and using regression I could arrive at the equation 
 
y = 9.505799 + (0.191092 * t) - (0.0225 * t^2) + (0.001245 * t^3)
 
However I feel this is wrong as I am trying to use linear regression but here I 
am having polynomial in t.
 
I am not that good in stats as well as in mathmatics.
 
I request you to kindly help me as to how to express the 'y' in polynomial in 
terms of t.
 
Thanking you in advance
 
Julia
 
 
 
 




Only a man of Worth sees Worth in other men




  
[[alternative HTML version deleted]]

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


Re: [R] [Rd] NetCDF output in R

2009-11-11 Thread nana

Dear Robert,

Thanks for the information.
I tried this but it still did not work well.

I will try some other option.

Nana Browne



There is no key to happiness. The door is always open.

--- On Tue, 11/10/09, Robert J. Hijmans r.hijm...@gmail.com wrote:

From: Robert J. Hijmans r.hijm...@gmail.com
Subject: Re: [Rd] NetCDF output in R
To: nana amabr...@yahoo.com
Cc: r-help@r-project.org, Alice favre favre_al...@yahoo.fr
Date: Tuesday, November 10, 2009, 12:21 PM

Hi Nana,

This is not a r-devel question.

I suspect this should be something like:

write.netcdf.time(paste(path,'cam_fore.nc',sep=), fore[,,times]
,lon,lat,times)

Robert

On Tue, Nov 10, 2009 at 8:31 AM, nana amabr...@yahoo.com wrote:
 Dear CSAG R users,

 I will be glad if someone can point out what I am doing wrong or not doing at 
 all in this.

 I am trying to write out netcdf file in R. I have 26 time step but only the 
 first time step is written.

 For example:
library(ncdf)
path - '/home/work/'
forecast - open.ncdf(paste(path,'cam.1980.2005.nc',sep=))
 fore - get.var.ncdf(forecast,'ppt')
 lon - get.var.ncdf(forecast,'lon')
 lat - get.var.ncdf(forecast,'lat')
dim(fore)[3]
26
 times - 1:dim(fore)[3]
 write.netcdf.time(paste(path,'cam_fore.nc',sep=), fore,lon,lat,times)
 [1] put.var.ncdf: warning: you asked to write 1440 values, but the passed 
 data array has 37440 entries!
 [[1]]
 [1] 6

 Warning message:
 In 1:nt : numerical expression has 26 elements: only the first used


 # function for writing out the netcdf file #
 write.netcdf.time - function(filename='outputfile.nc',data,lons,lats,nt){
 lon - dim.def.ncdf('lon','degrees_east',lons)
 lat - dim.def.ncdf('lat','degrees_north',lats)
 times - 1:nt
 tdim - dim.def.ncdf('time','days since 1980-01-01', times, unlim=TRUE)
 # levs - dim.def.ncdf('lev','pressure',levs)
 var - var.def.ncdf('data','unitless',list(lon,lat,tdim),-999.9)
 ncid - create.ncdf(filename,list(var))
 put.var.ncdf(ncid, var, data)
 close.ncdf(ncid)
 }

 ##end of function###

 Thank you.
 Nana Browne

 

 There is no key to happiness. The door is always open.



        [[alternative HTML version deleted]]

 __
 r-de...@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel




  
[[alternative HTML version deleted]]

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


[R] Nested ANOVA

2009-11-11 Thread Plankton-81

Hello, 

I have the following data and would like to get some hints on how to analyze
tis data, nested analysis? 

Habitats: 2 (Seagrass meadows and sandy bottoms)
Seasons: 4 (Winter, Spring, Summer and Autumn)
Locations: 4 (2 locations for for each habitat and season)
Replicates: 3 replicates for each location within each season and within
each habitat

Kindly regards, 

Stefanos Kalogirou





-- 
View this message in context: 
http://old.nabble.com/Nested-ANOVA-tp26298891p26298891.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] What parts of 'Statistical Models in S' are not applicable to R?

2009-11-11 Thread Emmanuel Charpentier
Le mercredi 11 novembre 2009 à 10:22 +0100, Uwe Ligges a écrit :
 
 Peng Yu wrote:
  According to Amazon review, 'Statistical Models in S' is a key
  reference for understanding the methods implemented in several of
  S-PLUS' high-end statistical functions, including 'lm()', predict()',
  'design()', 'aov()', 'glm()', 'gam()', 'loess()', 'tree()',
  'burl.tree()', 'nls()' and 'ms()'.
  
  But since it is for S, some part of the book may not be applicable to
  R. Some examples (e.g. interaction.plot()) discussed in this book are
  not available in R. Without, working examples, it is sometimes
  difficult for me to understand the materials in the book.
  
  Besides the functions mentioned in the Amazon review, could somebody
  give me a hint on what chapters (or sections) in this book are not
  appropriate to R?
 
 
 They all are appropriate, but nuances differ these days, as some nuances 
 differ for recent S-PLUS versions, 17 years later. It should still be 
 fine to learn some relevant concepts.

You could also note that, at least in the 4th (last) edition of the
book, the authors have marked passages with differences between R and S+
with a marginal R.

Now this book has grow a bit out of date since its lst edition
(2002 ?) : Newer R packages implements various things previously not
implemented in R (e.g. multiple comparisons after ANOVA, previously
available in S+ with the multicomp function, nd implemented (with a
lot more generalizability) in the multcomp package).

A 5th edition might be in order, but that would be a *daunting* task :
The language R has grew (e. g. namespaces), the nature and extend of
avilable tasks has grew *enormously*, and I don't think that producing a
book that would be to 2009 R what VR4 was to 2002 R is doable by a
two-person team, as talented, dedicated and productive as these two
persons might be (modulo Oxford sarcasm :-). Furthermore, these two
persons already give an enormous amount of time and effort to other R
development (search for R-help activity of BV and BDR, or meditate on
the recently published stats on R source activity...).

Such a document would probably have to be something other than a book to
stay up to date and accurate, and even coordinating such a task would
need serious time... Even if it would exclude anything present in the
vrious packages help files, and should limit to tutorial introductions,
examples and discussions, the sheer volume (1700+ packages last time I
looked) and the difficulty of coordination (how do you discuss 5
different packages, implementing various means to solve the same
problem ?) would involve serious organizational difficulties.

So I doubt such a document will get produced in the foreseeable future.
Frequent R-help reading and note-taking is the second-best option...

To come back to R-vs-S+ topic : unless I'm mistaken, R seems to be
currently the dominant version of the S language, and most published S
material will nowadays (implicitly) be aimed at R. This should reduce
the importance of the problem.

Sincerely,

Emmanuel Charpentier

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 parts of 'Statistical Models in S' are not applicable to R?

2009-11-11 Thread Uwe Ligges



Emmanuel Charpentier wrote:

Le mercredi 11 novembre 2009 à 10:22 +0100, Uwe Ligges a écrit :

Peng Yu wrote:

According to Amazon review, 'Statistical Models in S' is a key
reference for understanding the methods implemented in several of
S-PLUS' high-end statistical functions, including 'lm()', predict()',
'design()', 'aov()', 'glm()', 'gam()', 'loess()', 'tree()',
'burl.tree()', 'nls()' and 'ms()'.

But since it is for S, some part of the book may not be applicable to
R. Some examples (e.g. interaction.plot()) discussed in this book are
not available in R. Without, working examples, it is sometimes
difficult for me to understand the materials in the book.

Besides the functions mentioned in the Amazon review, could somebody
give me a hint on what chapters (or sections) in this book are not
appropriate to R?


They all are appropriate, but nuances differ these days, as some nuances 
differ for recent S-PLUS versions, 17 years later. It should still be 
fine to learn some relevant concepts.


You could also note that, at least in the 4th (last) edition of the
book, the authors have marked passages with differences between R and S+
with a marginal R.


I guess you are talking about a very different book .

Uwe Ligges




Now this book has grow a bit out of date since its lst edition
(2002 ?) : Newer R packages implements various things previously not
implemented in R (e.g. multiple comparisons after ANOVA, previously
available in S+ with the multicomp function, nd implemented (with a
lot more generalizability) in the multcomp package).

A 5th edition might be in order, but that would be a *daunting* task :
The language R has grew (e. g. namespaces), the nature and extend of
avilable tasks has grew *enormously*, and I don't think that producing a
book that would be to 2009 R what VR4 was to 2002 R is doable by a
two-person team, as talented, dedicated and productive as these two
persons might be (modulo Oxford sarcasm :-). Furthermore, these two
persons already give an enormous amount of time and effort to other R
development (search for R-help activity of BV and BDR, or meditate on
the recently published stats on R source activity...).

Such a document would probably have to be something other than a book to
stay up to date and accurate, and even coordinating such a task would
need serious time... Even if it would exclude anything present in the
vrious packages help files, and should limit to tutorial introductions,
examples and discussions, the sheer volume (1700+ packages last time I
looked) and the difficulty of coordination (how do you discuss 5
different packages, implementing various means to solve the same
problem ?) would involve serious organizational difficulties.

So I doubt such a document will get produced in the foreseeable future.
Frequent R-help reading and note-taking is the second-best option...

To come back to R-vs-S+ topic : unless I'm mistaken, R seems to be
currently the dominant version of the S language, and most published S
material will nowadays (implicitly) be aimed at R. This should reduce
the importance of the problem.

Sincerely,

Emmanuel Charpentier

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


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


[R] Error in lm() function

2009-11-11 Thread Bogaso

Hi all,

I wanted to have a seasonality study like whether a particular month has
significant effect as compared to others. Here is my data :

0.10499 0   0   1   0   0   0   0   0   0   
0   0
0.00259 0   0   0   1   0   0   0   0   0   
0   0
-0.060150   0   0   0   1   0   0   0   
0   0   0
0.10721 0   0   0   0   0   1   0   0   0   
0   0
0.03597 0   0   0   0   0   0   1   0   0   
0   0
0.10584 0   0   0   0   0   0   0   1   0   
0   0
0.02063 0   0   0   0   0   0   0   0   1   
0   0
-0.035090   0   0   0   0   0   0   0   
0   1   0
-0.034850   0   0   0   0   0   0   0   
0   0   1
0.01632 0   0   0   0   0   0   0   0   0   
0   0
0.06844 1   0   0   0   0   0   0   0   0   
0   0
-0.017660   1   0   0   0   0   0   0   
0   0   0
0.00989 0   0   1   0   0   0   0   0   0   
0   0
0.11673 0   0   0   1   0   0   0   0   0   
0   0
0.01789 0   0   0   0   1   0   0   0   0   
0   0
-0.003230   0   0   0   0   1   0   0   
0   0   0
0.06811 0   0   0   0   0   0   1   0   0   
0   0
-0.012920   0   0   0   0   0   0   1   
0   0   0
-0.122440   0   0   0   0   0   0   0   
1   0   0
-0.066450   0   0   0   0   0   0   0   
0   1   0
-0.033550   0   0   0   0   0   0   0   
0   0   1
0.02308 0   0   0   0   0   0   0   0   0   
0   0
-0.117111   0   0   0   0   0   0   0   
0   0   0
0.06116 0   1   0   0   0   0   0   0   0   
0   0
0.02832 0   0   1   0   0   0   0   0   0   
0   0
0.01441 0   0   0   1   0   0   0   0   0   
0   0
-0.044120   0   0   0   1   0   0   0   
0   0   0
0.05558 0   0   0   0   0   1   0   0   0   
0   0
0.08363 0   0   0   0   0   0   1   0   0   
0   0
-0.010630   0   0   0   0   0   0   1   
0   0   0

i.e. all explanatory variables here are dichotomous. However once I run lm()
i got following error :

 lm(dat[,1]~dat[,-1])
Error in model.frame.default(formula = dat[, 1] ~ dat[, -1],
drop.unused.levels = TRUE) : 
  invalid type (list) for variable 'dat[, -1]'

Can anyone please tell me what to do?

Best,

-- 
View this message in context: 
http://old.nabble.com/Error-in-lm%28%29-function-tp26300324p26300324.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Data transformation

2009-11-11 Thread jim holtman
Try this:

 x - read.table(textConnection(idcode1code2 p
+  148   0.1
+  157   0.9
+  218   0.4
+  262   0.2
+  243   0.6
+  356   0.7
+  375   0.9), header=TRUE)
  closeAllConnections()
  # create object like output from 'melt'
  x.m - data.frame(id=c(x$id, x$id),
+var=paste('var', c(x$code1, x$code2), sep=''),
+variable=rep('p', 2*nrow(x)),
+value=c(x$p, x$p))
 require(reshape)  # use the reshape package
 (x.n - cast(x.m, id ~ var, function(.dat){
+ if (length(.dat) == 0) return(0)  # test for no data; return
zero if that is the case
+ mean(.dat)
+ }))
  id var1 var2 var3 var4 var5 var6 var7 var8
1  1  0.0  0.0  0.0  0.1  0.9  0.0  0.9  0.1
2  2  0.4  0.2  0.6  0.6  0.0  0.2  0.0  0.4
3  3  0.0  0.0  0.0  0.0  0.8  0.7  0.9  0.0



On Tue, Nov 10, 2009 at 11:10 PM, legen lege...@gmail.com wrote:

 Thank you for your kind help. Your script works very well. Would you please
 show me how to change NaN to zero and column variables 1, 2, ..., 8 to var1,
 var2, ..., var8? Thanks again.

 Legen



 jholtman wrote:

 Is this what you want:

 x - read.table(textConnection(id    code1    code2         p
 +  1        4        8           0.1
 +  1        5        7           0.9
 +  2        1        8           0.4
 +  2        6        2           0.2
 +  2        4        3           0.6
 +  3        5        6           0.7
 +  3        7        5           0.9), header=TRUE)
  closeAllConnections()
  # create object like output from 'melt'
  x.m - data.frame(id=c(x$id, x$id), var=c(x$code1, x$code2),
 +     variable=rep('p', 2*nrow(x)), value=c(x$p, x$p))
 require(reshape)  # use the reshape package
 cast(x.m, id ~ var, mean)
   id   1   2   3   4   5   6   7   8
 1  1 NaN NaN NaN 0.1 0.9 NaN 0.9 0.1
 2  2 0.4 0.2 0.6 0.6 NaN 0.2 NaN 0.4
 3  3 NaN NaN NaN NaN 0.8 0.7 0.9 NaN




 On Tue, Nov 10, 2009 at 4:30 PM, legen lege...@gmail.com wrote:

 Dear all,

 I have a dataset as below:

 id    code1    code2         p
  1        4        8           0.1
  1        5        7           0.9
  2        1        8           0.4
  2        6        2           0.2
  2        4        3           0.6
  3        5        6           0.7
  3        7        5           0.9

 I just want to rewrite it as this (vertical to horizontal):

 id   var1  var2  var3  var4  var5  var6  var7  var8
 1        0      0      0    0.1   0.9       0   0.9    0.1
 2     0.4    0.2   0.6    0.6      0    0.2      0    0.4
 3        0      0      0      0    0.8    0.7    0.9      0

 For the third subject, there are two values being equal to 5 in code1 and
 code2, but different values in p:  0.7 and 0.9, so I assigned their
 average
 0.8 in var5.

 Does anybody can help me to handle this? Many thanks for your
 consideration
 and time.

 Legen

 --
 View this message in context:
 http://old.nabble.com/Data-transformation-tp26291568p26291568.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

 What is the problem that you are trying to solve?

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



 --
 View this message in context: 
 http://old.nabble.com/Data-transformation-tp26291568p26295766.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem that you are trying to solve?

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


[R] architecture of statistical programming language R

2009-11-11 Thread mustafa_binar



hi,
I'm mustafa. I'm a master student Dokuz Eylül University in
Izmir/Turkey.
nbsp;
I focus on Statistical programming language R. I learn architecture
of R. But i don't find out any material in internet. 
Would you like tonbsp;help me this subject? If you have
documentations, would you like to share with me?
nbsp;
If you help me, i have informationsnbsp;about architecture of R and
i'mnbsp;happy. 
nbsp;
More power to you! thanks.


___


Ücretsiz dinlemek için yüzbinlerce þarký Kavun'da! Týkla, dinle.



[[alternative HTML version deleted]]

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


Re: [R] Data transformation

2009-11-11 Thread legen

Your script works very well. Thank you very much.

Legen



Henrique Dallazuanna wrote:
 
 Try this also:
 
 xtabs(rep(p, 2) ~ rep(id, 2) + sprintf(var%d, c(code1, code2)), data =
 x)
 
 On Wed, Nov 11, 2009 at 2:10 AM, legen lege...@gmail.com wrote:

 Thank you for your kind help. Your script works very well. Would you
 please
 show me how to change NaN to zero and column variables 1, 2, ..., 8 to
 var1,
 var2, ..., var8? Thanks again.

 Legen



 jholtman wrote:

 Is this what you want:

 x - read.table(textConnection(id    code1    code2         p
 +  1        4        8           0.1
 +  1        5        7           0.9
 +  2        1        8           0.4
 +  2        6        2           0.2
 +  2        4        3           0.6
 +  3        5        6           0.7
 +  3        7        5           0.9), header=TRUE)
  closeAllConnections()
  # create object like output from 'melt'
  x.m - data.frame(id=c(x$id, x$id), var=c(x$code1, x$code2),
 +     variable=rep('p', 2*nrow(x)), value=c(x$p, x$p))
 require(reshape)  # use the reshape package
 cast(x.m, id ~ var, mean)
   id   1   2   3   4   5   6   7   8
 1  1 NaN NaN NaN 0.1 0.9 NaN 0.9 0.1
 2  2 0.4 0.2 0.6 0.6 NaN 0.2 NaN 0.4
 3  3 NaN NaN NaN NaN 0.8 0.7 0.9 NaN




 On Tue, Nov 10, 2009 at 4:30 PM, legen lege...@gmail.com wrote:

 Dear all,

 I have a dataset as below:

 id    code1    code2         p
  1        4        8           0.1
  1        5        7           0.9
  2        1        8           0.4
  2        6        2           0.2
  2        4        3           0.6
  3        5        6           0.7
  3        7        5           0.9

 I just want to rewrite it as this (vertical to horizontal):

 id   var1  var2  var3  var4  var5  var6  var7  var8
 1        0      0      0    0.1   0.9       0   0.9    0.1
 2     0.4    0.2   0.6    0.6      0    0.2      0    0.4
 3        0      0      0      0    0.8    0.7    0.9      0

 For the third subject, there are two values being equal to 5 in code1
 and
 code2, but different values in p:  0.7 and 0.9, so I assigned their
 average
 0.8 in var5.

 Does anybody can help me to handle this? Many thanks for your
 consideration
 and time.

 Legen

 --
 View this message in context:
 http://old.nabble.com/Data-transformation-tp26291568p26291568.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

 What is the problem that you are trying to solve?

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



 --
 View this message in context:
 http://old.nabble.com/Data-transformation-tp26291568p26295766.html
 Sent from the R help mailing list archive at Nabble.com.

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

 
 
 
 -- 
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://old.nabble.com/Data-transformation-tp26291568p26301029.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] LINEAR MIXED EFFECT

2009-11-11 Thread ANARPCG

CAN ANYONE PLEASE HELP ME WITH THIS
i HAVE TO DO A MIXED EFFECT LINEAR MODEL WITH MY DATA DUE TO THE FACT THAT I
have pseudoreplication!
Although after reading and trying it for several times can get around due to
Error in na.fail.default(list(date = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,  :
missing values in object 
I uploaded my data file
Thank you so much 
Kind regards 
AG
http://old.nabble.com/file/p26300394/rawoctobercalciumexperiment2.txt
rawoctobercalciumexperiment2.txt 

-- 
View this message in context: 
http://old.nabble.com/LINEAR-MIXED-EFFECT-tp26300394p26300394.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Data transformation

2009-11-11 Thread legen

That's what I want. Many thanks for your help.
Legen



jholtman wrote:
 
 Try this:
 
 x - read.table(textConnection(idcode1code2 p
 +  148   0.1
 +  157   0.9
 +  218   0.4
 +  262   0.2
 +  243   0.6
 +  356   0.7
 +  375   0.9), header=TRUE)
  closeAllConnections()
  # create object like output from 'melt'
  x.m - data.frame(id=c(x$id, x$id),
 +var=paste('var', c(x$code1, x$code2), sep=''),
 +variable=rep('p', 2*nrow(x)),
 +value=c(x$p, x$p))
 require(reshape)  # use the reshape package
 (x.n - cast(x.m, id ~ var, function(.dat){
 + if (length(.dat) == 0) return(0)  # test for no data; return
 zero if that is the case
 + mean(.dat)
 + }))
   id var1 var2 var3 var4 var5 var6 var7 var8
 1  1  0.0  0.0  0.0  0.1  0.9  0.0  0.9  0.1
 2  2  0.4  0.2  0.6  0.6  0.0  0.2  0.0  0.4
 3  3  0.0  0.0  0.0  0.0  0.8  0.7  0.9  0.0

 
 
 On Tue, Nov 10, 2009 at 11:10 PM, legen lege...@gmail.com wrote:

 Thank you for your kind help. Your script works very well. Would you
 please
 show me how to change NaN to zero and column variables 1, 2, ..., 8 to
 var1,
 var2, ..., var8? Thanks again.

 Legen



 jholtman wrote:

 Is this what you want:

 x - read.table(textConnection(id    code1    code2         p
 +  1        4        8           0.1
 +  1        5        7           0.9
 +  2        1        8           0.4
 +  2        6        2           0.2
 +  2        4        3           0.6
 +  3        5        6           0.7
 +  3        7        5           0.9), header=TRUE)
  closeAllConnections()
  # create object like output from 'melt'
  x.m - data.frame(id=c(x$id, x$id), var=c(x$code1, x$code2),
 +     variable=rep('p', 2*nrow(x)), value=c(x$p, x$p))
 require(reshape)  # use the reshape package
 cast(x.m, id ~ var, mean)
   id   1   2   3   4   5   6   7   8
 1  1 NaN NaN NaN 0.1 0.9 NaN 0.9 0.1
 2  2 0.4 0.2 0.6 0.6 NaN 0.2 NaN 0.4
 3  3 NaN NaN NaN NaN 0.8 0.7 0.9 NaN




 On Tue, Nov 10, 2009 at 4:30 PM, legen lege...@gmail.com wrote:

 Dear all,

 I have a dataset as below:

 id    code1    code2         p
  1        4        8           0.1
  1        5        7           0.9
  2        1        8           0.4
  2        6        2           0.2
  2        4        3           0.6
  3        5        6           0.7
  3        7        5           0.9

 I just want to rewrite it as this (vertical to horizontal):

 id   var1  var2  var3  var4  var5  var6  var7  var8
 1        0      0      0    0.1   0.9       0   0.9    0.1
 2     0.4    0.2   0.6    0.6      0    0.2      0    0.4
 3        0      0      0      0    0.8    0.7    0.9      0

 For the third subject, there are two values being equal to 5 in code1
 and
 code2, but different values in p:  0.7 and 0.9, so I assigned their
 average
 0.8 in var5.

 Does anybody can help me to handle this? Many thanks for your
 consideration
 and time.

 Legen

 --
 View this message in context:
 http://old.nabble.com/Data-transformation-tp26291568p26291568.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

 What is the problem that you are trying to solve?

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



 --
 View this message in context:
 http://old.nabble.com/Data-transformation-tp26291568p26295766.html
 Sent from the R help mailing list archive at Nabble.com.

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

 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem that you are trying to solve?
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://old.nabble.com/Data-transformation-tp26291568p26300980.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 

Re: [R] Error in lm() function

2009-11-11 Thread Mohamed Lajnef

Hi Bogaso,

Try this
vecnames-names(test[,2:11])
fmla - as.formula(paste(test[,1] ~ , paste(vecnames, collapse= +)))
res-lm(fmla)

Regards
M


Bogaso a écrit :

Hi all,

I wanted to have a seasonality study like whether a particular month has
significant effect as compared to others. Here is my data :

0.10499 0   0   1   0   0   0   0   0   0   
0   0
0.00259 0   0   0   1   0   0   0   0   0   
0   0
-0.060150   0   0   0   1   0   0   0   
0   0   0
0.10721 0   0   0   0   0   1   0   0   0   
0   0
0.03597 0   0   0   0   0   0   1   0   0   
0   0
0.10584 0   0   0   0   0   0   0   1   0   
0   0
0.02063 0   0   0   0   0   0   0   0   1   
0   0
-0.035090   0   0   0   0   0   0   0   
0   1   0
-0.034850   0   0   0   0   0   0   0   
0   0   1
0.01632 0   0   0   0   0   0   0   0   0   
0   0
0.06844 1   0   0   0   0   0   0   0   0   
0   0
-0.017660   1   0   0   0   0   0   0   
0   0   0
0.00989 0   0   1   0   0   0   0   0   0   
0   0
0.11673 0   0   0   1   0   0   0   0   0   
0   0
0.01789 0   0   0   0   1   0   0   0   0   
0   0
-0.003230   0   0   0   0   1   0   0   
0   0   0
0.06811 0   0   0   0   0   0   1   0   0   
0   0
-0.012920   0   0   0   0   0   0   1   
0   0   0
-0.122440   0   0   0   0   0   0   0   
1   0   0
-0.066450   0   0   0   0   0   0   0   
0   1   0
-0.033550   0   0   0   0   0   0   0   
0   0   1
0.02308 0   0   0   0   0   0   0   0   0   
0   0
-0.117111   0   0   0   0   0   0   0   
0   0   0
0.06116 0   1   0   0   0   0   0   0   0   
0   0
0.02832 0   0   1   0   0   0   0   0   0   
0   0
0.01441 0   0   0   1   0   0   0   0   0   
0   0
-0.044120   0   0   0   1   0   0   0   
0   0   0
0.05558 0   0   0   0   0   1   0   0   0   
0   0
0.08363 0   0   0   0   0   0   1   0   0   
0   0
-0.010630   0   0   0   0   0   0   1   
0   0   0

i.e. all explanatory variables here are dichotomous. However once I run lm()
i got following error :

  

lm(dat[,1]~dat[,-1])


Error in model.frame.default(formula = dat[, 1] ~ dat[, -1],
drop.unused.levels = TRUE) : 
  invalid type (list) for variable 'dat[, -1]'


Can anyone please tell me what to do?

Best,

  



--
Mohamed Lajnef
INSERM Unité 955. 
40 rue de Mesly. 94000 Créteil.
Courriel : mohamed.laj...@inserm.fr 
tel.: 01 49 81 31 31 (poste 18470)

Sec : 01 49 81 32 90
fax : 01 49 81 30 99 
Portable:06 15 60 01 62


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Passing MULTIPLE arguments from php file to r scripts

2009-11-11 Thread Moumita Das
Hi friends,
Again i don't know how to pass multiple arguments from php file to r
scripts.

Please have a look at this link ; it gives a very simple explanation of
passing variables from a PHP page to r scipts.Because i have done the same
thing.

http://www.math.ncu.edu.tw/~chenwc/R_note/index.php?item=phpsubitem=ex_1http://www.math.ncu.edu.tw/%7Echenwc/R_note/index.php?item=phpsubitem=ex_1

*CONTENTS OF MY PHP FILE: ex_1.php*

?php**

$cmd = echo 'argv1 - \ex_1.R\; source(argv1)' |  .

 /usr/bin/R --vanilla --slave ;

 $ret = system($cmd);

?

Assigned the file name to argv1 and passed argv1 to source() function for
running r scripts

*CONTENTS OF MY R FILE: ex_1.r*

print(hello)

print(argv1)

When I open the php file in the browser I get these results:---

[1] hello [1] ex_1.R

See here the php file could invoked the desired r script as well as pass the
argument argv1 from the php file and made it available to the r script

Till passing of one argument everything was fine.

*Then I changed the php file ex_1.php:---*

?php**

  $a=1;

 $cmd = echo 'argv1 - \ex_1.R\; source(argv1)' |  .

 /usr/bin/R --vanilla --slave ;

//print($cmd);

  $ret = system($cmd);

?

*Then I changed the r script ex_1.r:---*

print(hello)

print(argv1)

print(argv2)



When I ran the php file neither the php file could invoke the r script nor
the arguments got printed(none of the arghuments got printed,not even argv1
)

So with this change in $cmd :--

$cmd = echo 'argv1 - \ex_1.R\; source(argv1)' |  .echo 'argv2
-.$a.; source(argv1)' |  ./usr/bin/R --vanilla --slave;



Nothing worked.

Again when I changed $cmd to this :--

$cmd = echo 'argv1 - \ex_1.R\; source(argv1)' |  .echo 'argv2
-.$a.; source(argv1)' |  ./usr/bin/R --vanilla --slave--args;

The r script could be invoked and bothe the arguments were available but
with warnings:-

WARNING: unknown option '--slave--args' R version 2.7.1 (2008-06-23)
Copyright (C) 2008 The R Foundation for Statistical Computing ISBN
3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You
are welcome to redistribute it under certain conditions. Type 'license()' or
'licence()' for distribution details. R is a collaborative project with many
contributors. Type 'contributors()' for more information and 'citation()' on
how to cite R or R packages in publications. Type 'demo()' for some demos,
'help()' for on-line help, or 'help.start()' for an HTML browser interface
to help. Type 'q()' to quit R.  argv2 -1; source(argv1)



*How should I pass multiple arguments from a php page to invoke a r scripts
as well as make the arguments passed available to the r script?*


Thanks
Moumita

[[alternative HTML version deleted]]

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


Re: [R] Error: cannot allocate vector of size...

2009-11-11 Thread Jens Oehlschlägel
For me with ff - on a 3 GB notebook - 3e6x100 works out of the box even without 
compression: doubles consume 2.2 GB on disk, but the R process remains under 
100MB, rest of RAM used by file-system-cache.
If you are under windows, you can create the ffdf files in a compressed folder. 
For the random doubles this reduces size on disk to 230MB - which should even 
work on a 1GB notebook.
BTW: the most compressed datatype (vmode) that can handle NAs is logical: 
consumes 2bit per tri-bool. The nextmost compressed is byte covering c(NA, 
-127:127) and consuming its name on disk and in fs-cache.

The code below should give an idea of how to do pairwise stats on columns where 
each pair fits easily into RAM. In the real world, you would not create the 
data but import it using read.csv.ffdf (expect that reading your file takes 
longer than reading/writing the ffdf).

Regards


Jens Oehlschlägel



library(ff)
k - 100
n - 3e6

# creating a ffdf dataframe of the requires size
l - vector(list, k)
for (i in 1:k)
  l[[i]] - ff(vmode=double, length=n, update=FALSE)
names(l) - paste(c, 1:k, sep=)
d - do.call(ffdf, l)

# writing 100 columns of 1e6 random data takes 90 sec
system.time(
for (i in 1:k){
  cat(i,  )
  print(system.time(d[,i] - rnorm(n))[elapsed])
  }
)[elapsed]


m - matrix(as.double(NA), k, k)

# pairwise correlating one column against all others takes ~ 17.5 sec
# pairwise correlating all combinations takes 15 min
system.time(
for (i in 2:k){
  cat(i,  )
  print(system.time({
x - d[[i]][]
for (j in 1:(i-1)){
  m[i,j] - cor(x, d[[j]][])
}
  })[elapsed])
}
)[elapsed]


-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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: cannot allocate vector of size 3.4 Gb

2009-11-11 Thread Benilton Carvalho

Hi Peng,

the major problem about your specific case is that when creating the  
final object, we need to set dimnames() appropriately. This triggers a  
copy of the object and that's where you get the error you describe.


With the current release, unfortunately, there isn't much to do  
(unless you're willing to add more memory). For the next release, I  
have plans of addressing issues like this and reduce memory footprint  
when processing data with the oligo package. It's nothing that can be  
done right now, as it takes some time, but I expect everything to be  
ready for the next release.


If you're trying to run RMA on your data, I can think of ways of  
working around this problem.


Cheers,

b

On Nov 7, 2009, at 5:46 PM, Benilton Carvalho wrote:


ok, i'll take a look at this and get back to you during the week. b

On Nov 7, 2009, at 1:19 PM, Peng Yu wrote:


Most of the 8GB was available, when I run the code, because R was the
only computation session running.

On Sat, Nov 7, 2009 at 7:51 AM, Benilton Carvalho
bcarv...@jhsph.edu wrote:

you haven't answered how much resource you have available when you
try
reading in the data.

with the mouse exon chip, the math is the same i mentioned before.

having 8 GB, you should be able to read in 70 samples of this chip.
if you
can't, that's because you don't have enough resources when trying
to read.

best,

b

On Nov 7, 2009, at 10:12 AM, Peng Yu wrote:


On Fri, Nov 6, 2009 at 8:19 PM, Benilton Carvalho bcarv...@jhsph.edu



wrote:


this is converging to bioc.

let me know what your sessionInfo() is and what type of CEL files
you're
trying to read, additionally provide exactly how you reproduce the
problem.



Here is my sessionInfo(). pname is 'moex10stv1cdf'.


for (f in list.celfiles('.',full.names=T,recursive=T)) {


+   print(f)
+   pname=cleancdfname(whatcdf(f))
+   print(pname)
+ }



sessionInfo()


R version 2.9.2 (2009-08-24)
x86_64-unknown-linux-gnu

locale:

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

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


other attached packages:
[1] pd.moex.1.0.st.v1_2.4.1 RSQLite_0.7-2   DBI_0.2-4
[4] oligo_1.8.3 preprocessCore_1.6.0
oligoClasses_1.6.0
[7] Biobase_2.4.1

loaded via a namespace (and not attached):
[1] affxparser_1.16.0 affyio_1.12.0 Biostrings_2.12.9
IRanges_1.2.3
[5] splines_2.9.2



it appears to me, i'm not sure, that you start a fresh session of
R and
then
tries to read in the data - how much resource do you have
available when
you
try reading in the data? having 8GB RAM does not mean that you
have 8GB
when
you tried the task.

b

On Nov 7, 2009, at 12:08 AM, Peng Yu wrote:


On Fri, Nov 6, 2009 at 5:00 PM, Marc Schwartz marc_schwa...@me.com



wrote:


On Nov 6, 2009, at 4:19 PM, Peng Yu wrote:


On Fri, Nov 6, 2009 at 3:39 PM, Charlie Sharpsteen
ch...@sharpsteen.net
wrote:


On Fri, Nov 6, 2009 at 1:30 PM, Peng Yu pengyu...@gmail.com
wrote:


I run R on a linux machine that has 8GB memory. But R gives
me an
error Error: cannot allocate vector of size 3.4 Gb. I'm
wondering
why it can not allocate 3.4 Gb on a 8GB memory machine. How
to fix
the
problem?


Is it 32-bit R or 64-bit R?

Are you running any other programs besides R?

How far into your data processing does the error occur?

The more statements you execute, the more fragmented R's
available
memory pool becomes.  A 3.4 Gb chunk may no longer be
available.


I'm pretty sure it is 64-bit R. But I need to double check.  
What

command I should use to check?

It seems that it didn't do anything but just read a lot of  
files

before it showed up the above errors.



Check the output of:

.Machine$sizeof.pointer

If it is 4, R was built as 32 bit, if it is 8, R was built as
64 bit.
See
?.Machine for more information.


It is 8. The code that give the error is listed below. There are
70
celfiles. I'm wondering how to investigate what cause the
problem and
fix it.

library(oligo)
cel_files = list.celfiles('.', full.names=T,recursive=T)
data=read.celfiles(cel_files)


You can also check:

R.version$arch

and

.Platform$r_arch

which for 64 bit should show x86_64.

HTH,

Marc Schwartz




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





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Loadings and scores from fastICA?

2009-11-11 Thread Joel Fürstenberg-Hägg

Hi all,

 

Does anyone know how to get the independent components and loadings from an 
Independent Component Analysis (ICA), as well as principal components and 
loadings from a Pricipal Component analysis (PCA) using the fastICA package? Or 
perhaps if there's another way to do ICAs in R?


Below is an example from the fastICA manual 
(http://cran.r-project.org/web/packages/fastICA/fastICA.pdf)

 

if(require(MASS))
{
 x - mvrnorm(n = 1000, mu = c(0, 0), Sigma = matrix(c(10, 3, 3, 1), 2, 2))
 x1 - mvrnorm(n = 1000, mu = c(-1, 2), Sigma = matrix(c(10, 3, 3, 1), 2, 
2))
 X - rbind(x, x1)
 a - fastICA(X, 2, alg.typ = deflation, fun = logcosh, alpha = 1, 
method = R, row.norm = FALSE, maxit = 200, tol = 0.0001, verbose = TRUE)
 par(mfrow = c(1, 3))
 plot(a$X, main = Pre-processed data)
 plot(a$X%*%a$K, main = PCA components)
 plot(a$S, main = ICA components)
}

 

Best regards,

 

Joel
  
_
Hitta kärleken i vinter!
http://dejting.se.msn.com/channel/index.aspx?trackingid=1002952
[[alternative HTML version deleted]]

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


Re: [R] Error in lm() function

2009-11-11 Thread David Winsemius


On Nov 11, 2009, at 7:14 AM, Bogaso wrote:



Hi all,

I wanted to have a seasonality study like whether a particular month  
has

significant effect as compared to others. Here is my data :

0.10499 0   0   1   0   0   0   0   0   0   
0   0
0.00259 0   0   0   1   0   0   0   0   0   
0   0
-0.060150   0   0   0   1   0   0   0   
0   0   0
0.10721 0   0   0   0   0   1   0   0   0   
0   0
0.03597 0   0   0   0   0   0   1   0   0   
0   0
0.10584 0   0   0   0   0   0   0   1   0   
0   0
0.02063 0   0   0   0   0   0   0   0   1   
0   0
-0.035090   0   0   0   0   0   0   0   
0   1   0
-0.034850   0   0   0   0   0   0   0   
0   0   1
0.01632 0   0   0   0   0   0   0   0   0   
0   0
0.06844 1   0   0   0   0   0   0   0   0   
0   0
-0.017660   1   0   0   0   0   0   0   
0   0   0
0.00989 0   0   1   0   0   0   0   0   0   
0   0
0.11673 0   0   0   1   0   0   0   0   0   
0   0
0.01789 0   0   0   0   1   0   0   0   0   
0   0
-0.003230   0   0   0   0   1   0   0   
0   0   0
0.06811 0   0   0   0   0   0   1   0   0   
0   0
-0.012920   0   0   0   0   0   0   1   
0   0   0
-0.122440   0   0   0   0   0   0   0   
1   0   0
-0.066450   0   0   0   0   0   0   0   
0   1   0
-0.033550   0   0   0   0   0   0   0   
0   0   1
0.02308 0   0   0   0   0   0   0   0   0   
0   0
-0.117111   0   0   0   0   0   0   0   
0   0   0
0.06116 0   1   0   0   0   0   0   0   0   
0   0
0.02832 0   0   1   0   0   0   0   0   0   
0   0
0.01441 0   0   0   1   0   0   0   0   0   
0   0
-0.044120   0   0   0   1   0   0   0   
0   0   0
0.05558 0   0   0   0   0   1   0   0   0   
0   0
0.08363 0   0   0   0   0   0   1   0   0   
0   0
-0.010630   0   0   0   0   0   0   1   
0   0   0

i.e. all explanatory variables here are dichotomous. However once I  
run lm()

i got following error :


lm(

Error in model.frame.default(formula = dat[, 1] ~ dat[, -1],
drop.unused.levels = TRUE) :
 invalid type (list) for variable 'dat[, -1]'


Assuming that dat really is a data.frame, then the error message is  
saying you have attempted to pass most of it (since it is a list)  to  
the rhs of the formula and the lm procedure was expecting a vector or  
vectors. What do you get with:


lm( dat[,1]~. , data = dat)

(It would be preferable for readability and possibly even for code  
correctness to refer to the column name for data[,1].)


Can anyone please tell me what to do?


Better to post the output of str(dat) , or even better, the output of  
dput(dat).




Best,


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] dividing a matrix by positive sum or negative sum depending on the sign

2009-11-11 Thread Hao Cen
Hi,

I have a matrix with positive numbers, negative numbers, and NAs. An
example of the matrix is as follows

-1 -1 2 NA
3 3 -2 -1
1 1 NA -2

I need to compute a scaled version of this matrix. The scaling method is
dividing each positive numbers in each row by the sum of positive numbers
in that row and  dividing each negative numbers in each row by the sum of
absolute value of negative numbers in that row.

So the resulting matrix would be

-1/2 -1/2 2/2 NA
3/6 3/6 -2/3 -1/3
1/2 1/2 NA -2/2

Is there an efficient way to do that in R? One way I am using is

1. rowSums for positive numbers in the matrix
2. rowSums for negative numbers in the matrix
3. sweep(mat, 1, posSumVec, posDivFun)
4. sweep(mat, 1, negSumVec, negDivFun)

posDivFun = function(x,y) {
xPosId = x0  !is.na(x)
x[xPosId] = x[xPosId]/y[xPosId]
return(x)
}

negDivFun = function(x,y) {
xNegId = x0  !is.na(x)
x[xNegId] = -x[xNegId]/y[xNegId]
return(x)
}

It is not fast enough though. This scaling is to be applied to large data
sets repetitively. I would like to make it as fast as possible. Any
thoughts on improving it would be appreciated.

Thanks

Jeff

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


[R] R installer can't find math.h, stdio.h

2009-11-11 Thread Ted Harding
This is possibly the wrong list, but anyway ...

Using Linux Debian-4.0 Etch (regularly upgraded).

I set about installing Simon Woods' soap package -- see:

  http://www.maths.bath.ac.uk/~sw283/simon/software.html

So I downloaded the tar archive  soap_0.1-3.tar.gz and then ran
(as root) R CMD INSTALL as follows (and with the following errors):

# R CMD INSTALL /home/ted/Downloads/soap_0.1-3.tar.gz
* installing to library ?/usr/local/lib/R/site-library?
* installing *source* package ?soap? ...
** libs
gcc -std=gnu99 -I/usr/share/R/include  -fpic  -g -O2 -c soap.c -o
soap.o
soap.c:6:18: error: math.h: No such file or directory
soap.c:7:19: error: stdio.h: No such file or directory

[the remaining output being assorted warnings]

Now, I do have math.h and stdio.h:

/usr/i486-linuxlibc1/include/math.h
/usr/i486-linuxlibc1/include/stdio.h

which may be a non-standard place (usually, in the past at any rate,
in /usr/include).

The soap bundle has one file to be compiled: soap/src/soap.c

I have tried to pick my way around what happens when you call
R CMD INSTALL, in order to find where the -I/usr/share/R/include
comes from, so as to enable it to locate math.h and stdio.h,
but I got lost!

Any advice welcome!

With thanks,
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 11-Nov-09   Time: 14:42:21
-- XFMail --

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

2009-11-11 Thread CG Pettersson
Dear all,

W.XP

I recently upgraded to R2.10.0 and did what I usually do: copied all
special libraries from the old installation and then used
update.packages() on the command line. Nothing happened. Then I clicked
on the same command on the droplist which generated
update.packages(ask='graphics'), but still with no effect.

When I tried to load the gregmisc bundle I got error messages telling me
to upgrade the individual packages (like gmodels and gplot).

What has happened and why?
I really liked the automatic scan of my installation followed by semi
automatic installation that used to get triggered by update.packages()

Thanks
/CG

-- 
CG Pettersson, Ph.D.
Swedish University of Agricultural Sciences (SLU)
Dept. of Crop Production Ecology. Box 7043.
SE-750 07 Uppsala, Sweden
cg.petters...@vpe.slu.se

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


Re: [R] Unexpected behavior for as.date()

2009-11-11 Thread Therneau, Terry M., Ph.D.
 
 The date library was written 20 or so years ago.  It was a very good
first effort, but the newer Date library has superior functionality in
nearly every way.   The date library is still available, for legacy
projects such as yours, but I do not advise it for new work.  To answer
your specific questions:

1. What you have is a real bug.  The underlying C routine that scans
through the text returns 0 as a marker for any string it can't figure
out, a year of 'abc'  or month 'charlie' for example.  The S function
then turns these into NA.   I never, ever thought about year 0.  In our
longer term studies at Mayo we have birth dates in the 1800s, it is
rather surprising that a birth date of 1900 hadn't caught me sometime in
the past.  I'll  fix this.

2. The date library predates the strptime function by over 10 years.  It
is not a huge surprise that I neglected to include support for it -- my
oracular abilities are limited.  For an inherited project such as this I
would suggest reading the date() documentation as a first step; it is
not very long since the package is simple.
You want the date.mdy function, which is more straightforward than
strptime (with less capabilities of course).

Terry Therneau


[[alternative HTML version deleted]]

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


[R] End of Month date capture

2009-11-11 Thread Research

Dear R-users,

I have the following zoo object:

   x1x2  x3   x4   
x5 x6
1998-08-31 -0.0704375904  NA  NA   NA   
NA NA
1998-09-01  0.0379028122  NA  NA   NA   
NA 0.00609139
1998-09-02 -0.0038191639  NA  NA   NA   
NA NA
1998-09-03 -0.0083235389  NA  NA   NA   
NA NA
1998-09-04 -0.0085576782  NA  NA 0.0028570541   
NA NA
1998-09-07  0.00  NA  NA   NA   
NA NA
1998-09-08  0.0496459618  NA  NA   NA   
NA NA
1998-09-09 -0.0170081847  NA  NA   NA   
NA NA
1998-09-10 -0.0261897076  NA  NA   NA   
NA NA
1998-09-11  0.0290280530  NA  NA   NA   
NA NA
1998-09-14  0.0202677162  NA  NA   NA   
NA NA
1998-09-15  0.0077005314  NA  NA   NA   
NA NA
1998-09-16  0.0074886581  NA  NA   NA 
-0.002710978 NA
1998-09-17 -0.0257819401  NA  NA   NA   
NA NA
1998-09-18  0.0011966887  NA  NA   NA   
NA NA
1998-09-21  0.0037182403  NA  NA   NA   
NA NA
1998-09-22  0.0055904154  NA  NA   NA   
NA NA
1998-09-23  0.0347982355  NA  NA   NA   
NA NA
1998-09-24 -0.0221650663  NA  NA   NA   
NA NA
1998-09-25  0.0019449387  NA 0.007833611   NA   
NA NA
1998-09-28  0.0037641439  NA  NA   NA   
NA NA
1998-09-29  0.0003146288  NA  NA   NA   
NA NA
1998-09-30 -0.0309894451  NA  NA   NA   
NA NA
1998-10-01 -0.0305704149  NA  NA   NA   
NA 0.
1998-10-02  0.0163000909 -0.03409975  NA 0.0004991463   
NA NA
1998-10-05 -0.0141025660  NA  NA   NA   
NA NA
1998-10-06 -0.0040240279  NA  NA   NA   
NA NA
1998-10-07 -0.0142284540  NA  NA   NA   
NA NA
1998-10-08 -0.0116470759  NA  NA   NA   
NA NA
1998-10-09  0.0256723791  NA  NA   NA   
NA NA
1998-10-12  0.0134404929  NA  NA   NA   
NA NA
1998-10-13 -0.0029209410  NA  NA   NA   
NA NA
1998-10-14  0.0107283327  NA  NA   NA   
NA NA
1998-10-15  0.0408820605  NA  NA   NA   
NA NA
1998-10-16  0.0084890073  NA  NA   NA  
0.006675831 NA
1998-10-19  0.0056352536  NA  NA   NA   
NA NA
1998-10-20  0.0014485122  NA  NA   NA   
NA NA
1998-10-21  0.0056142800  NA  NA   NA   
NA NA
1998-10-22  0.0079687631  NA  NA   NA   
NA NA
1998-10-23 -0.0072680217  NA  NA   NA   
NA NA




I need to create second one which contains the end of each month rows 
only. Is there an easy way of doing this? The data starts at 1998-08-31 
and ends at 2009-11-06.


Many thanks in advance,
Costas

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

2009-11-11 Thread Damjan Krstajic

Dear all,

I will present R language and R software environment to the Statistical Society 
of Serbia.

As I will doing it to professional statisticians it seems unneccesary to
me to present them how R language works in details. I am more
interested to present them with the latest facts regarding R (approximately 
number of users, number of add-on packages etc.) and in general why they should 
start using it.

I would be grateful if anyone could point to me a place where I can find the 
information. Also, any comparisons with other stats packages and languages 
would be much appreciated. 

Thanks in advance.

With kind regards
DK
_
Use Hotmail to send and receive mail from your different email accounts.

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


Re: [R] dividing a matrix by positive sum or negative sum depending on the sign

2009-11-11 Thread Dimitris Rizopoulos

one approach is the following:

mat - rbind(c(-1, -1, 2, NA), c(3, 3, -2, -1), c(1, 1, NA, -2))

mat / ave(abs(mat), row(mat), sign(mat), FUN = sum)


I hope it helps.

Best,
Dimitris


Hao Cen wrote:

Hi,

I have a matrix with positive numbers, negative numbers, and NAs. An
example of the matrix is as follows

-1 -1 2 NA
3 3 -2 -1
1 1 NA -2

I need to compute a scaled version of this matrix. The scaling method is
dividing each positive numbers in each row by the sum of positive numbers
in that row and  dividing each negative numbers in each row by the sum of
absolute value of negative numbers in that row.

So the resulting matrix would be

-1/2 -1/2 2/2 NA
3/6 3/6 -2/3 -1/3
1/2 1/2 NA -2/2

Is there an efficient way to do that in R? One way I am using is

1. rowSums for positive numbers in the matrix
2. rowSums for negative numbers in the matrix
3. sweep(mat, 1, posSumVec, posDivFun)
4. sweep(mat, 1, negSumVec, negDivFun)

posDivFun = function(x,y) {
xPosId = x0  !is.na(x)
x[xPosId] = x[xPosId]/y[xPosId]
return(x)
}

negDivFun = function(x,y) {
xNegId = x0  !is.na(x)
x[xNegId] = -x[xNegId]/y[xNegId]
return(x)
}

It is not fast enough though. This scaling is to be applied to large data
sets repetitively. I would like to make it as fast as possible. Any
thoughts on improving it would be appreciated.

Thanks

Jeff

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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


Re: [R] architecture of statistical programming language R

2009-11-11 Thread Ben Bolker



mustafa_binar wrote:
 
 
 
 
 hi,
 I'm mustafa. I'm a master student Dokuz Eylül University in
 Izmir/Turkey.
 nbsp;
 I focus on Statistical programming language R. I learn architecture
 of R. But i don't find out any material in internet. 
 Would you like tonbsp;help me this subject? If you have
 documentations, would you like to share with me?
 nbsp;
 If you help me, i have informationsnbsp;about architecture of R and
 i'mnbsp;happy. 
 
 

We'd like to make you happy, but this is much too vague. There's quite
a bit of documentation on the main R project site
http://www.r-project.org,
including all of the R manuals, lists of books, etc..  If you have more
specific questions, someone on this list will probably try to help.


-- 
View this message in context: 
http://old.nabble.com/architecture-of-statistical-programming-language-R-tp26301393p26302999.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Introducing R to statisticians

2009-11-11 Thread Duncan Murdoch

On 11/11/2009 10:26 AM, Damjan Krstajic wrote:

Dear all,

I will present R language and R software environment to the Statistical Society 
of Serbia.

As I will doing it to professional statisticians it seems unneccesary to
me to present them how R language works in details. I am more
interested to present them with the latest facts regarding R (approximately 
number of users, number of add-on packages etc.) and in general why they should 
start using it.


Number of users:  I don't know any reliable estimates.  If you don't 
want to make something up, just do a Google search, and pick someone 
else's estimate.  For example, this article (recently cited by David 
Smith on his blog)


http://www.information-management.com/blogs/business_intelligence_bi_statistics-10016491-1.html

says an estimated 2M worldwide users.

Number of add-on packages:  This is easier.  The big repositories are 
CRAN and Bioconductor, with other smaller and private ones not making a 
big difference to the number of packages available.  You can just go to 
those sites and count.


Why should they use it?  That depends on what's wrong with what they're 
using now.  If they (and their clients) are satisfied with what they've 
got, then it's harder to argue that they should switch.  If you know 
their applications you can show how well R does there, but if what 
they've got now is just as good and the price difference doesn't matter 
to them, they won't want to switch.


Duncan Murdoch



I would be grateful if anyone could point to me a place where I can find the information. Also, any comparisons with other stats packages and languages would be much appreciated. 


Thanks in advance.

With kind regards
DK 		 	   		  
_

Use Hotmail to send and receive mail from your different email accounts.

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


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


Re: [R] dividing a matrix by positive sum or negative sum depending on the sign

2009-11-11 Thread David Winsemius


On Nov 11, 2009, at 10:36 AM, Dimitris Rizopoulos wrote:


one approach is the following:

mat - rbind(c(-1, -1, 2, NA), c(3, 3, -2, -1), c(1, 1, NA, -2))

mat / ave(abs(mat), row(mat), sign(mat), FUN = sum)


Very elegant. My solution was a bit more pedestrian, but may have some  
speed advantage:


t( apply(mat, 1, function(x) ifelse( x 0, -x/sum(x[x0], na.rm=T), x/ 
sum(x[x0], na.rm=T) ) ) )



 system.time(replicate(1, t( apply(mat, 1, function(x) ifelse( x  
0, -x/sum(x[x0], na.rm=T), x/sum(x[x0], na.rm=T) ) ) ) ) )

   user  system elapsed
  5.958   0.027   5.977

 system.time(replicate(1, mat / ave(abs(mat), row(mat),  
sign(mat), FUN = sum) ) )

   user  system elapsed
 12.886   0.064  12.886

--
David



I hope it helps.

Best,
Dimitris


Hao Cen wrote:

Hi,
I have a matrix with positive numbers, negative numbers, and NAs. An
example of the matrix is as follows
-1 -1 2 NA
3 3 -2 -1
1 1 NA -2
I need to compute a scaled version of this matrix. The scaling  
method is
dividing each positive numbers in each row by the sum of positive  
numbers
in that row and  dividing each negative numbers in each row by the  
sum of

absolute value of negative numbers in that row.
So the resulting matrix would be
-1/2 -1/2 2/2 NA
3/6 3/6 -2/3 -1/3
1/2 1/2 NA -2/2
Is there an efficient way to do that in R? One way I am using is
1. rowSums for positive numbers in the matrix
2. rowSums for negative numbers in the matrix
3. sweep(mat, 1, posSumVec, posDivFun)
4. sweep(mat, 1, negSumVec, negDivFun)
posDivFun = function(x,y) {
   xPosId = x0  !is.na(x)
   x[xPosId] = x[xPosId]/y[xPosId]
   return(x)
}
negDivFun = function(x,y) {
   xNegId = x0  !is.na(x)
   x[xNegId] = -x[xNegId]/y[xNegId]
   return(x)
}
It is not fast enough though. This scaling is to be applied to  
large data

sets repetitively. I would like to make it as fast as possible. Any
thoughts on improving it would be appreciated.
Thanks
Jeff
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] partial cumsum

2009-11-11 Thread smu
Hello,

I am searching for a function to calculate partial cumsums.

For example it should calculate the cumulative sums until a NA appears,
and restart the cumsum calculation after the NA.

this:

x - c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10)

should become this:

1 3 6 NA 5  11  18  26  35  45


any ideas?

thank you and best regards,

stefan

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


[R] How to get the names of list elements when iterating over a list?

2009-11-11 Thread Peng Yu
I need to get the names of the list elements when I iterate over a
list. I'm wondering how to do so?

alist=list(a=c(1,3),b=c(-1,3),c=c(-2,1))
sapply(alist,function(x){
  #need to use the name of x for some subsequent process
})

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

2009-11-11 Thread Andreia Fonseca
Dear Forum

my machine runs Ubuntu 9.04. I am trying to install Biomart, what I realize
is that something is missing and it can't install XML, RCurl but I don't
know what more to do, I looked in previous posts but I did not find
infoprmation that helped.
Thanks
Andreia
biocLite(biomaRt)
Running biocinstall version 2.3.14 with R version 2.8.1
Your version of R requires version 2.3 of Bioconductor.
Warning in install.packages(pkgs = pkgs, repos = repos, dependencies =
dependencies,  :
  argument 'lib' is missing: using
'/home/user/R/x86_64-pc-linux-gnu-library/2.8'
also installing the dependencies ‘XML’, ‘RCurl’

trying URL 'http://cran.fhcrc.org/src/contrib/XML_2.6-0.tar.gz'
Content type 'application/x-gzip' length 680366 bytes (664 Kb)
opened URL
==
downloaded 664 Kb

trying URL 'http://cran.fhcrc.org/src/contrib/RCurl_1.3-0.tar.gz'
Content type 'application/x-gzip' length 799689 bytes (780 Kb)
opened URL
==
downloaded 780 Kb

trying URL '
http://bioconductor.org/packages/2.3/bioc/src/contrib/biomaRt_1.16.0.tar.gz'
Content type 'application/x-gzip' length 278561 bytes (272 Kb)
opened URL
==
downloaded 272 Kb

* Installing *source* package 'XML' ...
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for sed... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking for xml2-config... no
Cannot find xml2-config
ERROR: configuration failed for package 'XML'
** Removing '/home/user/R/x86_64-pc-linux-gnu-library/2.8/XML'
* Installing *source* package 'RCurl' ...
checking for curl-config... no
Cannot find curl-config
ERROR: configuration failed for package 'RCurl'
** Removing '/home/user/R/x86_64-pc-linux-gnu-library/2.8/RCurl'
* Installing *source* package 'biomaRt' ...
** R
** inst
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths())) :
  there is no package called 'RCurl'
Calls: Anonymous ... code2LazyLoadDB - loadNamespace - namespaceImport
- loadNamespace
Execution halted
ERROR: lazy loading failed for package 'biomaRt'
** Removing '/home/user/R/x86_64-pc-linux-gnu-library/2.8/biomaRt'

The downloaded packages are in
/tmp/RtmpzdpweV/downloaded_packages
Warning messages:
1: In install.packages(pkgs = pkgs, repos = repos, dependencies =
dependencies,  :
  installation of package 'XML' had non-zero exit status
2: In install.packages(pkgs = pkgs, repos = repos, dependencies =
dependencies,  :
  installation of package 'RCurl' had non-zero exit status
3: In install.packages(pkgs = pkgs, repos = repos, dependencies =
dependencies,  :
  installation of package 'biomaRt' had non-zero exit status

[[alternative HTML version deleted]]

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


Re: [R] problems in installing biomart

2009-11-11 Thread Martin Morgan
Hi Andreia --

Andreia Fonseca wrote:
 Dear Forum
 
 my machine runs Ubuntu 9.04. I am trying to install Biomart, what I realize
 is that something is missing and it can't install XML, RCurl but I don't
 know what more to do, I looked in previous posts but I did not find
 infoprmation that helped.
 Thanks
 Andreia
 biocLite(biomaRt)
 Running biocinstall version 2.3.14 with R version 2.8.1
 Your version of R requires version 2.3 of Bioconductor.
 Warning in install.packages(pkgs = pkgs, repos = repos, dependencies =
 dependencies,  :
   argument 'lib' is missing: using
 '/home/user/R/x86_64-pc-linux-gnu-library/2.8'
 also installing the dependencies ‘XML’, ‘RCurl’
 
 trying URL 'http://cran.fhcrc.org/src/contrib/XML_2.6-0.tar.gz'
 Content type 'application/x-gzip' length 680366 bytes (664 Kb)
 opened URL
 ==
 downloaded 664 Kb
 
 trying URL 'http://cran.fhcrc.org/src/contrib/RCurl_1.3-0.tar.gz'
 Content type 'application/x-gzip' length 799689 bytes (780 Kb)
 opened URL
 ==
 downloaded 780 Kb
 
 trying URL '
 http://bioconductor.org/packages/2.3/bioc/src/contrib/biomaRt_1.16.0.tar.gz'
 Content type 'application/x-gzip' length 278561 bytes (272 Kb)
 opened URL
 ==
 downloaded 272 Kb
 
 * Installing *source* package 'XML' ...
 checking for gcc... gcc
 checking for C compiler default output file name... a.out
 checking whether the C compiler works... yes
 checking whether we are cross compiling... no
 checking for suffix of executables...
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... yes
 checking whether gcc accepts -g... yes
 checking for gcc option to accept ANSI C... none needed
 checking how to run the C preprocessor... gcc -E
 checking for sed... /bin/sed
 checking for pkg-config... /usr/bin/pkg-config
 checking for xml2-config... no
 Cannot find xml2-config
 ERROR: configuration failed for package 'XML'

use your operating system package installation manager to install libxml2.

This is a Bioconductor package, so consider asking on the Biocondcutor
mailing list.

Martin

 ** Removing '/home/user/R/x86_64-pc-linux-gnu-library/2.8/XML'
 * Installing *source* package 'RCurl' ...
 checking for curl-config... no
 Cannot find curl-config
 ERROR: configuration failed for package 'RCurl'
 ** Removing '/home/user/R/x86_64-pc-linux-gnu-library/2.8/RCurl'
 * Installing *source* package 'biomaRt' ...
 ** R
 ** inst
 ** preparing package for lazy loading
 Error in loadNamespace(i, c(lib.loc, .libPaths())) :
   there is no package called 'RCurl'
 Calls: Anonymous ... code2LazyLoadDB - loadNamespace - namespaceImport
 - loadNamespace
 Execution halted
 ERROR: lazy loading failed for package 'biomaRt'
 ** Removing '/home/user/R/x86_64-pc-linux-gnu-library/2.8/biomaRt'
 
 The downloaded packages are in
 /tmp/RtmpzdpweV/downloaded_packages
 Warning messages:
 1: In install.packages(pkgs = pkgs, repos = repos, dependencies =
 dependencies,  :
   installation of package 'XML' had non-zero exit status
 2: In install.packages(pkgs = pkgs, repos = repos, dependencies =
 dependencies,  :
   installation of package 'RCurl' had non-zero exit status
 3: In install.packages(pkgs = pkgs, repos = repos, dependencies =
 dependencies,  :
   installation of package 'biomaRt' had non-zero exit status
 
   [[alternative HTML version deleted]]
 
 
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

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


Re: [R] Introducing R to statisticians

2009-11-11 Thread Karl Ove Hufthammer
On Wed, 11 Nov 2009 10:51:53 -0500 Duncan Murdoch murd...@stats.uwo.ca 
wrote:
 If you know their applications you can show how well R does there,

And do mention the (increasing) number of books available. It's only a 
slight exaggeration to say that there are R books on almost any 
application you could think of.

-- 
Karl Ove Hufthammer

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


Re: [R] Implementation of the Shuffled Complex Evolution (SCE-UA) Algorithm

2009-11-11 Thread Hans W Borchers
Simon Seibert simon.seibert at mytum.de writes:

 
 Good evening list,
 I'm looking for an R implementation of the Shuffled Complex
 Evolution” (SCE-UA) algorithm after Duan et al. (1993). Does anybody
 know if there is an extension/ package existing that contains it?
 Thanks very much for your help! Cheers, Simon

I am looking into stochastic global optimization routines, such as variants of
genetic algorithms (GA), particle swarm optimization (PSO), and shuffled complex
(SCE) or differential evolution (DE).

At the moment I am testing a free Matlab implementation of SCE-UA. If that turns
out to be interesting and effective, I will translate it into an R function,
maybe within the next few weeks -- except, of course, someone else is going to
do an implementation of a similar procedure.

Right now I am not totally convinced. Maybe you try your problem with other
approaches available in R (see e.g. the Optimization task view).

Regards
Hans Werner

 Duan QY, Gupta KV, Sorooshian S (1993) Shuffled Complex Evolution
 Approach for Effective and Efficient Global Minimization. In Jour. of
 optimization theorie and applications. Vol 76, 3, 501-521


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 names of list elements when iterating over alist?

2009-11-11 Thread William Dunlap

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu
 Sent: Wednesday, November 11, 2009 8:02 AM
 To: r-h...@stat.math.ethz.ch
 Subject: [R] How to get the names of list elements when 
 iterating over alist?
 
 I need to get the names of the list elements when I iterate over a
 list. I'm wondering how to do so?
 
 alist=list(a=c(1,3),b=c(-1,3),c=c(-2,1))
 sapply(alist,function(x){
   #need to use the name of x for some subsequent process
 })

sapply(X,FUN) and lapply(X,FUN) do the equivalent of
   for(i in seq_along(X))
   FUN(X[[i]])
X[[i]] represents i'th elemenent of the list X,
not a list containing the i'th element.  Hence the name
from the original list X is not part of X[[i]].  If FUN
expects a named list of length 1 then you can do
   sapply(seq_along(X), function(i)FUN(X[i]))
or write your own for loop
   for(i in seq_along(X))
   FUN(X[i])
If FUN wants the name as a separate argument you could do
   sapply(seq_along(X), function(i)FUN(X[[i]], names(X)[i]))
or you could write the equivalent loop by hand.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

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

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


Re: [R] partial cumsum

2009-11-11 Thread William Dunlap


Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of smu
 Sent: Wednesday, November 11, 2009 7:58 AM
 To: r-help@r-project.org
 Subject: [R] partial cumsum
 
 Hello,
 
 I am searching for a function to calculate partial cumsums.
 
 For example it should calculate the cumulative sums until a 
 NA appears,
 and restart the cumsum calculation after the NA.
 
 this:
 
 x - c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10)
 
 should become this:
 
 1 3 6 NA 5  11  18  26  35  45

Perhaps
ave(x, rev(cumsum(rev(is.na(x, FUN=cumsum)
[1]  1  3  6 NA  5 11 18 26 35 45

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
 
 any ideas?
 
 thank you and best regards,
 
 stefan
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


[R] Sweave() within a function: objects not found

2009-11-11 Thread Pfaff, Bernhard Dr.
Dear list subscriber,

suppose, I do have a minimal Sweave file 'test.Rnw':
\documentclass{article}
\begin{document}
printx=
x
@ 
\end{document}


Within R, I define the following function:

f - function(x){
  Sweave(test.Rnw)
}

The call:

f(x = 1:10)

results in the following error message:

 f(x = 1:10)
Writing to file test.tex
Processing code chunks ...
 1 : echo term verbatim (label=printx)

Error:  chunk 1 (label=printx) 
Error in eval(expr, envir, enclos) : object 'x' not found

In principle, I could assign x to the global environment and then the Sweave 
file will be processed correctly:

 f2 - function(x){
+   attach(list(x = x))
+   Sweave(test.Rnw)
+ }
 f2(x = 1:10)
Writing to file test.tex
Processing code chunks ...
 1 : echo term verbatim (label=printx)

You can now run LaTeX on 'test.tex'
 

Kind of a dum question, but how could it be achieved that Sweave recognizes the 
objects within this function call?

Any pointers are most welcome,
Bernhard

 sessionInfo()
R version 2.10.0 (2009-10-26) 
i386-pc-mingw32 

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C   
[5] LC_TIME=German_Germany.1252

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

other attached packages:
[1] fortunes_1.3-6
 

Dr. Bernhard Pfaff
Director
Global Quantitative Equity

Invesco Asset Management Deutschland GmbH
An der Welle 5
D-60322 Frankfurt am Main

Tel: +49 (0)69 29807 230
Fax: +49 (0)69 29807 178
www.institutional.invesco.com
Email: bernhard_pf...@fra.invesco.com

Geschäftsführer: Karl Georg Bayer, Bernhard Langer, Dr. Jens Langewand, 
Alexander Lehmann, Christian Puschmann
Handelsregister: Frankfurt am Main, HRB 28469
Sitz der Gesellschaft: Frankfurt am Main

*
Confidentiality Note: The information contained in this ...{{dropped:10}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 way to specify drop=FALSE as the global default?

2009-11-11 Thread Peng Yu
On Mon, Oct 19, 2009 at 7:57 PM, Peng Yu pengyu...@gmail.com wrote:
 tmp - matrix(1:2)
 tmp
 tmp[,1,drop=FALSE]


 See the above example. Is there a way to make 'drop=FALSE' as global
 default, so that when I say 'tmp[,1]', R will treat it as
 'tmp[,1,drop=FALSE]'?

Is there a way to set drop=FALSE globally? I can't remember to put
drop=FALSE to all the '[]'s. But this indeed causes some weird bugs
for me to figure out.

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


Re: [R] partial cumsum

2009-11-11 Thread Karl Ove Hufthammer
On Wed, 11 Nov 2009 08:53:50 -0800 William Dunlap wdun...@tibco.com 
wrote:
  x - c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10)
  
  should become this:
  
  1 3 6 NA 5  11  18  26  35  45
 
 Perhaps
 ave(x, rev(cumsum(rev(is.na(x, FUN=cumsum)
 [1]  1  3  6 NA  5 11 18 26 35 45

Clever way of putting the NA values at the end of each group. (I had to 
study it quite a bit to understand what was going on, and why! :-) )

I wish cumsum took a 'na.rm' argument, though. It would make stuff like 
this much easier.

-- 
Karl Ove Hufthammer

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


Re: [R] dividing a matrix by positive sum or negative sum depending on the sign

2009-11-11 Thread David Winsemius


On Nov 11, 2009, at 10:57 AM, David Winsemius wrote:



On Nov 11, 2009, at 10:36 AM, Dimitris Rizopoulos wrote:


one approach is the following:

mat - rbind(c(-1, -1, 2, NA), c(3, 3, -2, -1), c(1, 1, NA, -2))

mat / ave(abs(mat), row(mat), sign(mat), FUN = sum)


Very elegant. My solution was a bit more pedestrian, but may have  
some speed advantage:






I am wondering if there might be further performance improvements if  
sums were pre-calculated before the ifelse scaling step.


Perhaps:
 mat - matrix(sample(-4:4, 100, replace=T), ncol=10)
 system.time(replicate(1, t(apply(mat, 1, function(x) {negs - 
sum(x[x0], na.rm=T); poss - sum(x[x0], na.rm=T); ifelse( x 0, -x/ 
negs, x/poss)} ) ) ) )

   user  system elapsed
  9.420   0.103   9.619
 system.time(replicate(1, t( apply(mat, 1, function(x) ifelse( x  
0, -x/sum(x[x0], na.rm=T), x/sum(x[x0], na.rm=T) ) ) ) ) )

   user  system elapsed
  8.206   0.035   8.231

That was only a 15% improvement but I got a 50% improvement by  
replacing the ifelse() with its Boolean algebra equivalent:


 t( apply(mat, 1, function(x) -x*(x 0)/sum(x[x0], na.rm=T) +  
x*(x0)/sum(x[x0], na.rm=T) ) )

 [,1] [,2]   [,3]   [,4]
[1,] -0.5 -0.5  1.000 NA
[2,]  0.5  0.5 -0.667 -0.333
[3,]  0.5  0.5 NA -1.000


 system.time(replicate(1,  t( apply(mat, 1, function(x) -x*(x  
0)/sum(x[x0], na.rm=T) + x*(x0)/sum(x[x0], na.rm=T) ) ) ))

   user  system elapsed
  4.805   0.041   4.839

I could not figure out the Jeff's method of applying the two functions  
he presented, so I am unable to compare any of these methods to his  
strategy.


--
David.



 system.time(replicate(1, t( apply(mat, 1, function(x)  
ifelse( x 0, -x/sum(x[x0], na.rm=T), x/sum(x[x0],  
na.rm=T) ) ) ) ) )

  user  system elapsed
 5.958   0.027   5.977

 system.time(replicate(1, mat / ave(abs(mat), row(mat),  
sign(mat), FUN = sum) ) )

  user  system elapsed
12.886   0.064  12.886

--
David



I hope it helps.

Best,
Dimitris


Hao Cen wrote:

Hi,
I have a matrix with positive numbers, negative numbers, and NAs. An
example of the matrix is as follows
-1 -1 2 NA
3 3 -2 -1
1 1 NA -2
I need to compute a scaled version of this matrix. The scaling  
method is
dividing each positive numbers in each row by the sum of positive  
numbers
in that row and  dividing each negative numbers in each row by the  
sum of

absolute value of negative numbers in that row.
So the resulting matrix would be
-1/2 -1/2 2/2 NA
3/6 3/6 -2/3 -1/3
1/2 1/2 NA -2/2
Is there an efficient way to do that in R? One way I am using is
1. rowSums for positive numbers in the matrix
2. rowSums for negative numbers in the matrix
3. sweep(mat, 1, posSumVec, posDivFun)
4. sweep(mat, 1, negSumVec, negDivFun)
posDivFun = function(x,y) {
  xPosId = x0  !is.na(x)
  x[xPosId] = x[xPosId]/y[xPosId]
  return(x)
}
negDivFun = function(x,y) {
  xNegId = x0  !is.na(x)
  x[xNegId] = -x[xNegId]/y[xNegId]
  return(x)
}
It is not fast enough though. This scaling is to be applied to  
large data

sets repetitively. I would like to make it as fast as possible. Any
thoughts on improving it would be appreciated.
Thanks
Jeff
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] how to use # in a rd doc in url address

2009-11-11 Thread Patrick Giraudoux
I am writing a rd doc, and need to use # in a url adress. This would make:

\url{http://www..org/myfolder/#myanchor}

Of course, I suppose this will not work because # is a special character 
starting a comment line in the rd dialect.  I did not found a similar 
example in Writing R exentions. I am not sure bout using \dQuote{a 
quotation}), and use \sQuote and \dQuote correctly. Does anyone know how 
to get the thing right ?

Patrick

[[alternative HTML version deleted]]

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


Re: [R] partial cumsum

2009-11-11 Thread Karl Ove Hufthammer
On Wed, 11 Nov 2009 18:11:51 +0100 Karl Ove Hufthammer k...@huftis.org 
wrote:
 I wish cumsum took a 'na.rm' argument, though. It would make stuff like 
 this much easier.

Or, more specifically, a 'na.value', which could perhaps default to 
'NA' to get the current behaviour, but which one could set 0 for 
'cumsum', 1 for 'cumprod', Inf for 'cummin' and -Inf for 'cummax'.

-- 
Karl Ove Hufthammer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 use # in a rd doc in url address

2009-11-11 Thread Daniel Malter
x=\url{http://www..org/myfolder/#myanchor};
print(x,quote=F)

Does this work for you? 
Daniel


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von Patrick Giraudoux
Gesendet: Wednesday, November 11, 2009 12:15 PM
An: r-help@r-project.org
Betreff: [R] how to use # in a rd doc in url address

I am writing a rd doc, and need to use # in a url adress. This would make:

\url{http://www..org/myfolder/#myanchor}

Of course, I suppose this will not work because # is a special character
starting a comment line in the rd dialect.  I did not found a similar
example in Writing R exentions. I am not sure bout using \dQuote{a
quotation}), and use \sQuote and \dQuote correctly. Does anyone know how to
get the thing right ?

Patrick

[[alternative HTML version deleted]]

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

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


Re: [R] R.oo and S4?

2009-11-11 Thread Peng Yu
I'm very familiar with C++. In this sense, it is easier for me to
learn R.oo according to your advice. On the other hand, S3 and S4 are
the most used. I'm wondering what would be the best choice for me. Do
you have any recommendation considering the pros and cons of both
ways?

Is it true that packages based on R.oo can not be deposited to CRAN?

On Mon, Oct 26, 2009 at 1:28 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 S3 and S4 are part of the core of R so they would presumably be the
 most used.  S4 is an extension to S3 but adds strong typing and a
 number of other features.  R.oo and proto are packages on CRAN which
 give access to different models of object oriented programming than S3
 and S4. R.oo uses a more conventional model of OO than S3 or S4 that
 is probably closer to what you are used to if you are coming form
 another language while proto uses the prototype model (or pure object
 model). proto tends to apply in user interface applications and there
 is some info on which other packages make use of proto on the proto
 home page at: http://r-proto.googlecode.com

 On Mon, Oct 26, 2009 at 2:47 PM, Peng Yu pengyu...@gmail.com wrote:
 There are different way to make R classes. I know R.oo and S4. I'm
 wondering which one is the current popular one. Which one is current
 recommended when make new R packages? Thank you!

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



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


Re: [R] partial cumsum

2009-11-11 Thread smu
On Wed, Nov 11, 2009 at 08:53:50AM -0800, William Dunlap wrote:
 
 Perhaps
 ave(x, rev(cumsum(rev(is.na(x, FUN=cumsum)
 [1]  1  3  6 NA  5 11 18 26 35 45
 

it takes some time to understand how it works, but it's perfect.

thank you,
 stefan

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


Re: [R] Sweave() within a function: objects not found

2009-11-11 Thread Duncan Murdoch

On 11/11/2009 12:09 PM, Pfaff, Bernhard Dr. wrote:

Dear list subscriber,

suppose, I do have a minimal Sweave file 'test.Rnw':
\documentclass{article}
\begin{document}
printx=
x
@ 
\end{document}



Within R, I define the following function:

f - function(x){
  Sweave(test.Rnw)
}

The call:

f(x = 1:10)

results in the following error message:


f(x = 1:10)

Writing to file test.tex
Processing code chunks ...
 1 : echo term verbatim (label=printx)

Error:  chunk 1 (label=printx) 
Error in eval(expr, envir, enclos) : object 'x' not found


In principle, I could assign x to the global environment and then the Sweave 
file will be processed correctly:


f2 - function(x){

+   attach(list(x = x))
+   Sweave(test.Rnw)
+ }

f2(x = 1:10)

Writing to file test.tex
Processing code chunks ...
 1 : echo term verbatim (label=printx)

You can now run LaTeX on 'test.tex'




Kind of a dum question, but how could it be achieved that Sweave recognizes the 
objects within this function call?


The way you did it is close.  You can attach all the local variables by 
using


attach(environment())

though global variables will take precedence, because attach puts the 
environment 2nd in the search list.  And you'd better remember to detach 
them.


I'd say it's better to make Sweave files self-contained, so that you can 
run R CMD Sweave outside of R, and get the right results.  But if you 
really want to do this, then you can write your own Sweave driver and 
replace the default  RweaveEvalWithOpt  with a function that looks 
elsewhere for variables.


Duncan Murdoch



Any pointers are most welcome,
Bernhard


sessionInfo()
R version 2.10.0 (2009-10-26) 
i386-pc-mingw32 


locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C   
[5] LC_TIME=German_Germany.1252


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


other attached packages:
[1] fortunes_1.3-6




Dr. Bernhard Pfaff
Director
Global Quantitative Equity

Invesco Asset Management Deutschland GmbH
An der Welle 5
D-60322 Frankfurt am Main

Tel: +49 (0)69 29807 230
Fax: +49 (0)69 29807 178
www.institutional.invesco.com
Email: bernhard_pf...@fra.invesco.com

Geschäftsführer: Karl Georg Bayer, Bernhard Langer, Dr. Jens Langewand, 
Alexander Lehmann, Christian Puschmann
Handelsregister: Frankfurt am Main, HRB 28469
Sitz der Gesellschaft: Frankfurt am Main

*
Confidentiality Note: The information contained in this ...{{dropped:10}}

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


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


Re: [R] Introducing R to statisticians

2009-11-11 Thread spencerg
 To me, R is the language of choice for a rapidly increasing number 
of people involved in new statistical algorithm development.  If they 
are happy with the tools they currently use, learning R may be a lot of 
pain for little gain. 



 However, if they want to stay current with the latest developments 
in almost any area of statistics, I know of no better way than to 
subscribe to some of the R mailing lists (or related lists like 
Bioconductor).  To me, reading those is like attending a professional 
meeting a few minutes per day. 



 Hope this helps. 
 Spencer Graves



Ove Hufthammer wrote:
On Wed, 11 Nov 2009 10:51:53 -0500 Duncan Murdoch murd...@stats.uwo.ca 
wrote:
  

If you know their applications you can show how well R does there,



And do mention the (increasing) number of books available. It's only a 
slight exaggeration to say that there are R books on almost any 
application you could think of.


  



--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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


Re: [R] partial cumsum

2009-11-11 Thread William Dunlap
 -Original Message-
 From: smu [mailto:m...@z107.de] 
 Sent: Wednesday, November 11, 2009 9:26 AM
 To: William Dunlap
 Cc: r-help@r-project.org
 Subject: Re: [R] partial cumsum
 
 On Wed, Nov 11, 2009 at 08:53:50AM -0800, William Dunlap wrote:
  
  Perhaps
  ave(x, rev(cumsum(rev(is.na(x, FUN=cumsum)
  [1]  1  3  6 NA  5 11 18 26 35 45
  
 
 it takes some time to understand how it works, but it's perfect.

Note that the 2nd argument assigns a group number
based on the number of NA's prior to the current
position in the vector.  The odd repeated calls to
rev() are there to put the NA's at the ends of the
groups, instead of at the beginnings:
x - c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10)
rev(cumsum(rev(is.na(x
[1] 1 1 1 1 0 0 0 0 0 0
A more natural way to do this is
cumsum(is.na(c(NA,x[-length(x)])))
[1] 1 1 1 1 2 2 2 2 2 2

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 
 thank you,
  stefan
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 use # in a rd doc in url address

2009-11-11 Thread Patrick Giraudoux

Daniel Malter a écrit :

x=\url{http://www..org/myfolder/#myanchor};
print(x,quote=F)

Does this work for you? 
Daniel



  


I am not working on consol mode (which would make your suggestion 
straight applicable), but writing a rd documentationn (the documentation 
that comes out with the command ?myfunction). The rd file has a Latex 
style syntax and I just want to insert the url within this 
documentation. Eg.


\details{
You may want to connect to \url{http://www..org/myfolder/#myanchor}
}

I am not sure one can define a variable and print it in such context...

Best

Patrick







-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von Patrick Giraudoux
Gesendet: Wednesday, November 11, 2009 12:15 PM
An: r-help@r-project.org
Betreff: [R] how to use # in a rd doc in url address

I am writing a rd doc, and need to use # in a url adress. This would make:

\url{http://www..org/myfolder/#myanchor}

Of course, I suppose this will not work because # is a special character
starting a comment line in the rd dialect.  I did not found a similar
example in Writing R exentions. I am not sure bout using \dQuote{a
quotation}), and use \sQuote and \dQuote correctly. Does anyone know how to
get the thing right ?

Patrick

[[alternative HTML version deleted]]

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





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


Re: [R] Comparison of vectors in a matrix

2009-11-11 Thread esterhazy

Yes, thanks for this, this is exactly what I want to do.

However, I have a remaining problem which is how to get R to understand that
each entry in my matrix is a vector of names.

I have been trying to import my text file with the names in each vector of
names enclosed in quotes and separated by commas, or separated by spaces, or
without quotes, etc, with no luck. 

Everytime, R seems to consider the vector of names as just one long name.

In my first colum, for example, I have henry, in the second, mary,
ruth, and in the third mary, joseph, and I have no idea how to get R
to see that mary, ruth, for example, is composed of two strings of text,
rather than just one.

Thanks for any further help!

http://old.nabble.com/file/p26305756/ffoexample.txt ffoexample.txt 

Tony Plate wrote:
 
 Nice problem!
 
 If I understand you correctly, here's how to do it (with list-based
 matrices):
 
 set.seed(1)
 (x - matrix(lapply(rpois(10,2)+1, function(k) sample(letters[1:10],
 size=k)), ncol=2, dimnames=list(1:5,c(A,B
   A   B  
 1 Character,2 Character,5
 2 Character,2 Character,5
 3 Character,3 Character,3
 4 Character,5 Character,3
 5 Character,2 i
 x[1,1]
 [[1]]
 [1] c b
 
 x[1,2]
 [[1]]
 [1] c d a j f
 
 (y - cbind(x, A-B=apply(x, 1, function(ab) setdiff(ab[[1]],
 ab[[2]]
   A   B   A-B
 1 Character,2 Character,5 b
 2 Character,2 Character,5 g
 3 Character,3 Character,3 Character,3
 4 Character,5 Character,3 Character,2
 5 Character,2 i Character,2
 y[1,3]
 [[1]]
 [1] b
 
 
 
 -- Tony Plate
 
 esterhazy wrote:
 Hi,
 
 I have a matrix with two columns, and the elements of the matrix are
 vectors.
 
 So for example, in line 3 of column 1 I have a vector v31=(marc,
 robert,
 marie).
 
 What I need to do is to compare all vectors in column 1 and 2, so as to
 get,
 for example setdiff(v31,v32) into a new column.
 
 Is there a way to do this in R?
 
 Thanks!
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://old.nabble.com/Comparison-of-vectors-in-a-matrix-tp26284855p26305756.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] lme4 glmer how to extract the z values?

2009-11-11 Thread sj
Ben ,

Thanks!  This worked after I updated my version of R (from 2.8.1 to 2.10) .

Best,

Spencer



On Tue, Nov 10, 2009 at 7:04 PM, Ben Bolker bol...@ufl.edu wrote:

 sj ssj1364 at gmail.com writes:

  I am using glmer() from lmer(lme4) to run generalized linear mixed
 models. I
  can't figure out how to extract the z values for  the fixed effects that
 are
  reported using the summary function . Any help would be appreciated.

 library(lme4)
 example(glmer)
 coef(summary(gm1))
 coef(summary(gm1))[,z value]

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


[[alternative HTML version deleted]]

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


Re: [R] how to use # in a rd doc in url address

2009-11-11 Thread Duncan Murdoch

On 11/11/2009 12:15 PM, Patrick Giraudoux wrote:

I am writing a rd doc, and need to use # in a url adress. This would make:

\url{http://www..org/myfolder/#myanchor}


That should work.

Of course, I suppose this will not work because # is a special character 
starting a comment line in the rd dialect. 


That's not correct.  # is only special in R code, and with \url{} the 
text is considered as verbatim text, i.e. only \, %, { and } are special.


 I did not found a similar
example in Writing R exentions. I am not sure bout using \dQuote{a 
quotation}), and use \sQuote and \dQuote correctly. Does anyone know how 
to get the thing right ?


I don't understand this question.

Duncan Murdoch



Patrick

[[alternative HTML version deleted]]

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


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


Re: [R] Comparison of vectors in a matrix

2009-11-11 Thread David Winsemius


On Nov 11, 2009, at 1:02 PM, esterhazy wrote:



Yes, thanks for this, this is exactly what I want to do.

However, I have a remaining problem which is how to get R to  
understand that

each entry in my matrix is a vector of names.

I have been trying to import my text file with the names in each  
vector of
names enclosed in quotes and separated by commas, or separated by  
spaces, or

without quotes, etc, with no luck.


Those are all subsumed under the R whitespace separators that scan  
and the read.* functions use by default.


Everytime, R seems to consider the vector of names as just one long  
name.


In my first colum, for example, I have henry, in the second, mary,
ruth, and in the third mary, joseph, and I have no idea how to  
get R
to see that mary, ruth, for example, is composed of two strings  
of text,

rather than just one.

Thanks for any further help!

http://old.nabble.com/file/p26305756/ffoexample.txt ffoexample.txt


I copied and pasted into a textConnection:

 lines - readLines(textConnection(usernamefriends friendof
+ 26376	paradisacorbasi  zannechaos  filmstarusa  jelliclecat  status   
jennilee_rose  obiwaynekenobi  shaycaron  jillthepill  26376  witchy1   
jumbach  oscarwinner  slai  jenniebennie  tirwen  estall  bront   
zarchasmpgmr  pink_kimono  reidzilla  miz_anneliese  ambelies   
jrianne  henry3730  thufer_hawat  mom2bunky  venaeli  grbenda  ikkin56	 
paradisacorbasi  filmstarusa  jelliclecat jennilee_rose shaycaron  
jillthepill 26376 witchy1 jumbach oscarwinner tirwen estall bront  
zarchasmpgmr pink_kimono reidzilla miz_anneliese ambelies jrianne  
henry3730 ahahaha_ha thufer_hawat mom2bunky venaeli grbenda  
donna_stewart gjanyn
+ aaandy	ma monotony porcelian abrokenstarr seraphimsigrist  
ballena cbaqir _cassyandra darkspree erishkigal pinkdevildances  
lightning_geek a_life_verbatim frozen_wishes lijago tindernight  
crashing_angel sabrina_g giggly_teapot smarties_2087 theinimitable_l  
african_sunset sirenlunaris eagan_bryhtm robomonkeyninja maid_ov_metal  
aubloomiel countdownish queennola pearl007 princess_macaw wolfie_sara  
gypsy_jack may_cash morningchorus vanityflair lyingpeacefully  
squashedfrogs d_e_r_v_i_s_h the_koira lakshmichithra muffinbits  
amaya_aneko jenikaandzhaodi blood_gypsy aura_oneill icemodeled  
wannabesnorlax2	ma frida monotony porcelian abrokenstarr  
seraphimsigrist ballena cbaqir _cassyandra shepardshadows darkspree  
erishkigal pinkdevildances lightning_geek a_life_verbatim  
frozen_wishes lijago tindernight crashing_angel sabrina_g  
giggly_teapot laudanum_tea smarties_2087 theinimitable_l  
african_sunset sirenlunaris eagan_bryhtm robomonkeyninja aaskie  
maid_ov_metal aubloomiel countdownish queennola pearl007  
princess_macaw wolfie_sara gypsy_jack may_cash morningchorus  
vanityflair lyingpeacefully squashedfrogs d_e_r_v_i_s_h the_koira  
lakshmichithra muffinbits amaya_aneko jenikaandzhaodi blood_gypsy  
aura_oneill icemodeled sixtycents wannabesnorlax2))


#realLines will bring in everything up to an EOL.

# and then used scan() on the individual lines:

 col1 - scan(textConnection(lines[1]), what=character)
Read 3 items
 col1
[1] username friends  friendof

 col2 - scan(textConnection(lines[2]), what=character)
Read 58 items


 col3 - scan(textConnection(lines[3]), what=character)
Read 102 items

I have not figured out what you and Tony are doing with these  
collections of character vectors, but this should help with you doing  
the basic data entry.





Tony Plate wrote:


Nice problem!

If I understand you correctly, here's how to do it (with list-based
matrices):


set.seed(1)
(x - matrix(lapply(rpois(10,2)+1, function(k) sample(letters[1:10],
size=k)), ncol=2, dimnames=list(1:5,c(A,B

 A   B
1 Character,2 Character,5
2 Character,2 Character,5
3 Character,3 Character,3
4 Character,5 Character,3
5 Character,2 i

x[1,1]

[[1]]
[1] c b


x[1,2]

[[1]]
[1] c d a j f


(y - cbind(x, A-B=apply(x, 1, function(ab) setdiff(ab[[1]],
ab[[2]]

 A   B   A-B
1 Character,2 Character,5 b
2 Character,2 Character,5 g
3 Character,3 Character,3 Character,3
4 Character,5 Character,3 Character,2
5 Character,2 i Character,2

y[1,3]

[[1]]
[1] b





-- Tony Plate

esterhazy wrote:

Hi,

I have a matrix with two columns, and the elements of the matrix are
vectors.

So for example, in line 3 of column 1 I have a vector v31=(marc,
robert,
marie).

What I need to do is to compare all vectors in column 1 and 2, so  
as to

get,
for example setdiff(v31,v32) into a new column.

Is there a way to do this in R?

Thanks!


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




--
View this message in context: 

Re: [R] LINEAR MIXED EFFECT

2009-11-11 Thread milton ruser
Dear Ana Golveia,

It is completelly impossible someone realise what kind or help you need or
what is happening. I suggest you give a look on the posting guide, mainly
that part about a minimum reproducible code with self explaining
information, etc.

Cheers

milton

On Wed, Nov 11, 2009 at 7:22 AM, ANARPCG a.gouvei...@imperial.ac.uk wrote:


 CAN ANYONE PLEASE HELP ME WITH THIS
 i HAVE TO DO A MIXED EFFECT LINEAR MODEL WITH MY DATA DUE TO THE FACT THAT
 I
 have pseudoreplication!
 Although after reading and trying it for several times can get around due
 to
 Error in na.fail.default(list(date = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,  :
 missing values in object
 I uploaded my data file
 Thank you so much
 Kind regards
 AG
 http://old.nabble.com/file/p26300394/rawoctobercalciumexperiment2.txt
 rawoctobercalciumexperiment2.txt

 --
 View this message in context:
 http://old.nabble.com/LINEAR-MIXED-EFFECT-tp26300394p26300394.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] how to use # in a rd doc in url address

2009-11-11 Thread Patrick Giraudoux

Duncan Murdoch a écrit :

On 11/11/2009 12:15 PM, Patrick Giraudoux wrote:
I am writing a rd doc, and need to use # in a url adress. This 
would make:


\url{http://www..org/myfolder/#myanchor}


That should work.

Of course, I suppose this will not work because # is a special 
character starting a comment line in the rd dialect. 


That's not correct.  # is only special in R code, and with \url{} the 
text is considered as verbatim text, i.e. only \, %, { and } are special.


 I did not found a similar
example in Writing R exentions. I am not sure bout using \dQuote{a 
quotation}), and use \sQuote and \dQuote correctly. Does anyone know 
how to get the thing right ?


I don't understand this question.



You answered it above... There is no reason for using special 
quotation considering your reminder: with \url{} the text is 
considered as verbatim text


Thanks for the focus,

Best,

Patrick

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 use # in a rd doc in url address

2009-11-11 Thread Patrick Giraudoux

Patrick Giraudoux a écrit :

Duncan Murdoch a écrit :

On 11/11/2009 12:15 PM, Patrick Giraudoux wrote:
I am writing a rd doc, and need to use # in a url adress. This 
would make:


\url{http://www..org/myfolder/#myanchor}


That should work.

Of course, I suppose this will not work because # is a special 
character starting a comment line in the rd dialect. 


That's not correct.  # is only special in R code, and with \url{} the 
text is considered as verbatim text, i.e. only \, %, { and } are 
special.


 I did not found a similar
example in Writing R exentions. I am not sure bout using \dQuote{a 
quotation}), and use \sQuote and \dQuote correctly. Does anyone know 
how to get the thing right ?


I don't understand this question.



You answered it above... There is no reason for using special 
quotation considering your reminder: with \url{} the text is 
considered as verbatim text


Thanks for the focus,

Best,

Patrick



Yes, can confirmed it works perfect without any complication... Good 
lesson. Being used to prepare oneself to the worst, one over-anticipates 
it, but occasionally  it does not happen


Cheers,

Patrick

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

2009-11-11 Thread Stefan Zeugner


Duncan Murdoch wrote:

Just declaring it there is the only reasonable way, i.e.

test-function(foo) {
  subtest - function() {
 foo - foo+1
  }
  subtest()
  return(foo)
}

The reason you can't somehow assign it within an existing test is that 
subtest is a different closure every time.  Its environment will be 
the local frame of the call to test, so the foo on the right hand 
side of the assignment will be the value that was passed to test.


An unreasonable way to get what you want is to mess with the 
environment, e.g.


subtest - function() {
   foo - foo+1
}

test - function(foo) {
   mysubtest - subtest  # make a local copy
   environment(mysubtest) - environment()  # attach the local frame

   mysubtest()
   return(foo)
}

This is ugly programming, likely to bite you at some future date.

Duncan Murdoch



Duncan,
Thank you a lot for this clarification.
Unfortunately, I have to get through this at the moment: I have 
subfunctions that are to be used by in the environments of several 
'main' functions: and I prefer not to declare them separately each time.

Therefore I will have to mess with the environment (for now) :-(

In this case, would it be wiser to shift the 'environment messing' to 
the subfunction?
I.e. tell it to manipulate its respective parent environment, as in the 
example below?


subtest - function() {
eval(expression(foo - foo+1),parent.frame())
}

test - function(foo) {
  subtest()
  return(foo)
}


Stefan

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


[R] as.Date from data.frame

2009-11-11 Thread separent

#Hello,

#I loaded data using read.table - I needed to convert a row in the data
frame to date class:

 data

V1  V2  V3  V4
1  2008-05-19  2008-04-19  2008-03-21  2008-02-22
2 38.16999817 30.7008 36.8661 35.18999863
3 37.4754 29.9576 36.4508 35.3661
4 37.4754 30.1462 36.47000122 35.3661
5 37.84999847 30.5669 36.8415 35.74000168
6 38.3839 31.1462 37.3415 36.2746
7 39.1161 31.9085 38.02999878 36.9754
8 39.81000137 32.65000153 38.6831 37.6339
9 40.47000122 33.34999847 39.27999878 38.2746

 data[1,]
  V1 V2 V3 V4
1 2008-05-19 2008-04-19 2008-03-21 2008-02-22

 dates1-as.Date(data[1,])

do not know how to convert 'dates[1,]' to class Date

# However, I can individually convert them all:

 dates1.1-as.Date(data[1,1])

 dates1.1
[1] 2008-05-19

# How can I change the class of the date over the entire row (my original
file contains more than one hundred rows)?
# Thank you very much.
-- 
View this message in context: 
http://old.nabble.com/as.Date-from-data.frame-tp26305830p26305830.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Comparison of vectors in a matrix

2009-11-11 Thread Tony Plate

This is a tricky data entry problem.  The right technique will depend on the fine details of the 
data, and it's not clear what those are.  E.g., when you say In my first column, for example, 
I have henry , it's unclear to me whether or not the double quotes are part of 
the data or not - which is why it's nice to provide reproducible examples.

But, if you do have quoted strings in your data fields as they exist in an R 
matrix, you can do something like the following:


# each element of the matrix x contains one or more quoted strings, separated 
by commas
x - matrix(c('a, b', 'c', 'b', 'd'), ncol=2, dimnames=list(c(row1, row2), 
c(X,Y)))
x
X  Y  
row1 \a\, \b\ \b\

row2 \c\\d\

# use R's parsing and evaluation to turn 'a, b' into c(a, b), and turn 
that
# into a matrix containing character vectors of various lengths.
matrix(lapply(parse(text=paste(c(, x, ))), eval), ncol=ncol(x), 
dimnames=dimnames(x))
X   Y  
row1 Character,2 b

row2 c d




- Tony Plate

esterhazy wrote:

Yes, thanks for this, this is exactly what I want to do.

However, I have a remaining problem which is how to get R to understand that
each entry in my matrix is a vector of names.

I have been trying to import my text file with the names in each vector of
names enclosed in quotes and separated by commas, or separated by spaces, or
without quotes, etc, with no luck. 


Everytime, R seems to consider the vector of names as just one long name.

In my first colum, for example, I have henry, in the second, mary,
ruth, and in the third mary, joseph, and I have no idea how to get R
to see that mary, ruth, for example, is composed of two strings of text,
rather than just one.

Thanks for any further help!

http://old.nabble.com/file/p26305756/ffoexample.txt ffoexample.txt 


Tony Plate wrote:

Nice problem!

If I understand you correctly, here's how to do it (with list-based
matrices):


set.seed(1)
(x - matrix(lapply(rpois(10,2)+1, function(k) sample(letters[1:10],
size=k)), ncol=2, dimnames=list(1:5,c(A,B
  A   B  
1 Character,2 Character,5

2 Character,2 Character,5
3 Character,3 Character,3
4 Character,5 Character,3
5 Character,2 i

x[1,1]

[[1]]
[1] c b


x[1,2]

[[1]]
[1] c d a j f


(y - cbind(x, A-B=apply(x, 1, function(ab) setdiff(ab[[1]],
ab[[2]]
  A   B   A-B
1 Character,2 Character,5 b
2 Character,2 Character,5 g
3 Character,3 Character,3 Character,3

4 Character,5 Character,3 Character,2
5 Character,2 i Character,2

y[1,3]

[[1]]
[1] b

-- Tony Plate

esterhazy wrote:

Hi,

I have a matrix with two columns, and the elements of the matrix are
vectors.

So for example, in line 3 of column 1 I have a vector v31=(marc,
robert,
marie).

What I need to do is to compare all vectors in column 1 and 2, so as to
get,
for example setdiff(v31,v32) into a new column.

Is there a way to do this in R?

Thanks!

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






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


[R] Joint counts and spatial autocorrelation - binary data

2009-11-11 Thread DBK

Hi All, 

I am new to this form and new to R, having just initiated the analysis of my
first project using R. I have been working on a logistic model of land use
change and am concerned about 1) measuring spatial autocorrelation and 2)
including an autocovariate in my model.

Here is what I think I need to do. My dependent variable takes on the value
of either 1 or 0 depending on whether a particular pixel from a random
sample of pixels transitioned from undeveloped to developed during the
study’s time period. I’d like to measure spatial autocorrelation by first
creating a distance matrix which includes the distances from each of my
sample points to every other sample point using latitude and longitude
coordinates. I would then like to divide these distances into bins (e.g. 0
to 500m, 501 to 1000m etc.). I have done this using both the dist() function
in geoR and the earth.dist() function in fossil. Both seem to work. I would
then like to calculate the number of similar states (i.e. joint counts)
between pairs of sample points at various distances (i.e. bin size).  I can
then graph this as proportion of disconcordance in land use change versus
distance (i.e. disconcordance is when one point of the pair transitions and
the other does not) very similar to that done by McDonald and Urban (2006).
I’d expect that as distance increases, the proportion disconcordance
eventually reaches that of the entire sample or more correctly, that of a
totally random spatial process. How can I assess the joint counts most
easily? Are there other approaches folks would recommend? Remember, I am
somewhat of a newbie.

The last wrinkle is that I am using multi-level models, which with varying
intercepts and/or slopes seems to account for some spatial heterogeneity. I
am not sure how to think about the pairing of multilevel and autologistic
approaches. Any insights?

Sample data below
LongLat Trans
-87.942447.464950
-88.045147.464  0
-82.752442.894771
-86.690545.5972 0
-87.731646.579880
-82.476943.056741
-83.431342.428280
-86.259844.370780
-86.255944.668410
-86.246744.679790

-- 
View this message in context: 
http://old.nabble.com/Joint-counts-and-spatial-autocorrelation---binary-data-tp26306008p26306008.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] as.Date from data.frame

2009-11-11 Thread Steve Lianoglou

Hi,

On Nov 11, 2009, at 1:06 PM, separent wrote:



#Hello,

#I loaded data using read.table - I needed to convert a row in the  
data

frame to date class:


data


V1  V2  V3  V4
1  2008-05-19  2008-04-19  2008-03-21  2008-02-22
2 38.16999817 30.7008 36.8661 35.18999863
3 37.4754 29.9576 36.4508 35.3661
4 37.4754 30.1462 36.47000122 35.3661
5 37.84999847 30.5669 36.8415 35.74000168
6 38.3839 31.1462 37.3415 36.2746
7 39.1161 31.9085 38.02999878 36.9754
8 39.81000137 32.65000153 38.6831 37.6339
9 40.47000122 33.34999847 39.27999878 38.2746


data[1,]

 V1 V2 V3 V4
1 2008-05-19 2008-04-19 2008-03-21 2008-02-22


dates1-as.Date(data[1,])


I think this should work if data[1,] returns a vector of characters:

R d - c(2008-05-19, 2008-05-30)
R dd - as.Date(d)
R is(dd)
[1] Date oldClass

Is your first row being treated as factors? Maybe if you convert to  
character first it should work?


R dates1-as.Date(as.character(data[1,]))

But the fact that it works for as.Date(data[1,1]) make it a bit  
weird ...


-steve


do not know how to convert 'dates[1,]' to class Date

# However, I can individually convert them all:


dates1.1-as.Date(data[1,1])



dates1.1

[1] 2008-05-19

# How can I change the class of the date over the entire row (my  
original

file contains more than one hundred rows)?
# Thank you very much.
--
View this message in context: 
http://old.nabble.com/as.Date-from-data.frame-tp26305830p26305830.html
Sent from the R help mailing list archive at Nabble.com.

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


--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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


Re: [R] as.Date from data.frame

2009-11-11 Thread Marc Schwartz

On Nov 11, 2009, at 12:06 PM, separent wrote:



#Hello,

#I loaded data using read.table - I needed to convert a row in the  
data

frame to date class:


data


V1  V2  V3  V4
1  2008-05-19  2008-04-19  2008-03-21  2008-02-22
2 38.16999817 30.7008 36.8661 35.18999863
3 37.4754 29.9576 36.4508 35.3661
4 37.4754 30.1462 36.47000122 35.3661
5 37.84999847 30.5669 36.8415 35.74000168
6 38.3839 31.1462 37.3415 36.2746
7 39.1161 31.9085 38.02999878 36.9754
8 39.81000137 32.65000153 38.6831 37.6339
9 40.47000122 33.34999847 39.27999878 38.2746


data[1,]

 V1 V2 V3 V4
1 2008-05-19 2008-04-19 2008-03-21 2008-02-22


dates1-as.Date(data[1,])


do not know how to convert 'dates[1,]' to class Date

# However, I can individually convert them all:


dates1.1-as.Date(data[1,1])



dates1.1

[1] 2008-05-19

# How can I change the class of the date over the entire row (my  
original

file contains more than one hundred rows)?
# Thank you very much.


In a data frame, you cannot change the data type for a row, without  
changing the data type for the entire column.


That being said, it looks to me like each column contains continuous  
data for a chronological series.


If that is correct, then you want the dates to be the column names and  
not the first row., Thus, when you used read.table(), you should have  
included the argument 'header = TRUE', which would do just that. With  
read.table(), header is FALSE by default.


HTH,

Marc Schwartz

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


Re: [R] as.Date from data.frame

2009-11-11 Thread David Winsemius


On Nov 11, 2009, at 1:06 PM, separent wrote:



#Hello,

#I loaded data using read.table - I needed to convert a row in the  
data

frame to date class:


You _should_ have given the actual code (as the Posting Guide  
requests), but I would guess that you should have added either  
as.is=TRUE or stringsAsFactors=FALSE. As it is, you probably have all  
factors.





data


V1  V2  V3  V4
1  2008-05-19  2008-04-19  2008-03-21  2008-02-22
2 38.16999817 30.7008 36.8661 35.18999863
3 37.4754 29.9576 36.4508 35.3661
4 37.4754 30.1462 36.47000122 35.3661
5 37.84999847 30.5669 36.8415 35.74000168
6 38.3839 31.1462 37.3415 36.2746
7 39.1161 31.9085 38.02999878 36.9754
8 39.81000137 32.65000153 38.6831 37.6339
9 40.47000122 33.34999847 39.27999878 38.2746


data[1,]

 V1 V2 V3 V4
1 2008-05-19 2008-04-19 2008-03-21 2008-02-22


dates1-as.Date(data[1,])


do not know how to convert 'dates[1,]' to class Date


You should have given the actual error message which was probably more  
informative than what your brain interpreted it to mean.


# However, I can individually convert them all:


dates1.1-as.Date(data[1,1])



dates1.1

[1] 2008-05-19

# How can I change the class of the date over the entire row (my  
original

file contains more than one hundred rows)?


Off hand I would say you want to work on a transpose of this data. You  
cannot mix datatypes within columns and it seems fairly clear that the  
rows below number 1 are numeric. Back to the drawing board.



--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] Comparison of vectors in a matrix

2009-11-11 Thread esterhazy

That is wonderful, now I think I am all set! Thanks again!


Tony Plate wrote:
 
 This is a tricky data entry problem.  The right technique will depend on
 the fine details of the data, and it's not clear what those are.  E.g.,
 when you say In my first column, for example, I have henry , it's
 unclear to me whether or not the double quotes are part of the data or not
 - which is why it's nice to provide reproducible examples.
 
 But, if you do have quoted strings in your data fields as they exist in an
 R matrix, you can do something like the following:
 
 # each element of the matrix x contains one or more quoted strings,
 separated by commas
 x - matrix(c('a, b', 'c', 'b', 'd'), ncol=2,
 dimnames=list(c(row1, row2), c(X,Y)))
 x
  X  Y  
 row1 \a\, \b\ \b\
 row2 \c\\d\
 # use R's parsing and evaluation to turn 'a, b' into c(a, b), and
 turn that
 # into a matrix containing character vectors of various lengths.
 matrix(lapply(parse(text=paste(c(, x, ))), eval), ncol=ncol(x),
 dimnames=dimnames(x))
  X   Y  
 row1 Character,2 b
 row2 c d
 
 
 - Tony Plate
 
 esterhazy wrote:
 Yes, thanks for this, this is exactly what I want to do.
 
 However, I have a remaining problem which is how to get R to understand
 that
 each entry in my matrix is a vector of names.
 
 I have been trying to import my text file with the names in each vector
 of
 names enclosed in quotes and separated by commas, or separated by spaces,
 or
 without quotes, etc, with no luck. 
 
 Everytime, R seems to consider the vector of names as just one long name.
 
 In my first colum, for example, I have henry, in the second, mary,
 ruth, and in the third mary, joseph, and I have no idea how to get
 R
 to see that mary, ruth, for example, is composed of two strings of
 text,
 rather than just one.
 
 Thanks for any further help!
 
 http://old.nabble.com/file/p26305756/ffoexample.txt ffoexample.txt 
 
 Tony Plate wrote:
 Nice problem!

 If I understand you correctly, here's how to do it (with list-based
 matrices):

 set.seed(1)
 (x - matrix(lapply(rpois(10,2)+1, function(k) sample(letters[1:10],
 size=k)), ncol=2, dimnames=list(1:5,c(A,B
   A   B  
 1 Character,2 Character,5
 2 Character,2 Character,5
 3 Character,3 Character,3
 4 Character,5 Character,3
 5 Character,2 i
 x[1,1]
 [[1]]
 [1] c b

 x[1,2]
 [[1]]
 [1] c d a j f

 (y - cbind(x, A-B=apply(x, 1, function(ab) setdiff(ab[[1]],
 ab[[2]]
   A   B   A-B
 1 Character,2 Character,5 b
 2 Character,2 Character,5 g
 3 Character,3 Character,3 Character,3
 4 Character,5 Character,3 Character,2
 5 Character,2 i Character,2
 y[1,3]
 [[1]]
 [1] b

 -- Tony Plate

 esterhazy wrote:
 Hi,

 I have a matrix with two columns, and the elements of the matrix are
 vectors.

 So for example, in line 3 of column 1 I have a vector v31=(marc,
 robert,
 marie).

 What I need to do is to compare all vectors in column 1 and 2, so as to
 get,
 for example setdiff(v31,v32) into a new column.

 Is there a way to do this in R?

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



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

-- 
View this message in context: 
http://old.nabble.com/Comparison-of-vectors-in-a-matrix-tp26284855p26306896.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] partial cumsum

2009-11-11 Thread Tony Plate

William Dunlap wrote:


Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  


-Original Message-
From: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] On Behalf Of smu

Sent: Wednesday, November 11, 2009 7:58 AM
To: r-help@r-project.org
Subject: [R] partial cumsum

Hello,

I am searching for a function to calculate partial cumsums.

For example it should calculate the cumulative sums until a 
NA appears,

and restart the cumsum calculation after the NA.

this:

x - c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10)

should become this:

1 3 6 NA 5  11  18  26  35  45


Perhaps
ave(x, rev(cumsum(rev(is.na(x, FUN=cumsum)
[1]  1  3  6 NA  5 11 18 26 35 45



Nice simple function!  Here's a different approach I use that's faster for long 
vectors with many NA values.  Note however, that this approach can suffer from 
catastrophic round-off error because it does a cumsum over the whole vector 
(after replacing NA's with zeros) and then subtracting out the cumsum at the 
most recent NA values.  Most of the body of this function is devoted to 
allowing (an unreasonable degree of) flexibility in specification of where to 
reset.

cumsum.reset - function(x, reset.at=which(is.na(x)), na.rm=F) {
   # compute the cumsum of x, resetting the cumsum to 0 at each element indexed 
by reset.at
   if (is.logical(reset.at)) {
   if (length(reset.at)length(x)) {
   if ((length(reset.at) %% length(x))!=0)
   stop(length of reset.at must be a multiple of length of x)
   x - rep(x, len=length(reset.at))
   } else if (length(reset.at)length(x)) {
   if ((length(x) %% length(reset.at))!=0)
   stop(length of x must be a multiple of length of reset.at)
   reset.at - rep(reset.at, len=length(x))
   }
   reset.at - which(reset.at)
   } else if (!is.numeric(reset.at)) {
   stop(reset.at must be logical or numeric)
   }
   if (length(i - which(reset.at=1)))
   reset.at - reset.at[-i]
   if (any(i - is.na(x[reset.at])))
   x[reset.at[i]] - 0
   if (na.rm  any(i - which(is.na(x
   x[i] - 0
   y - cumsum(x)
   d - diff(c(0, y[reset.at-1]))
   r - rep(0, length(x))
   r[reset.at] - d
   return(y - cumsum(r))
}




x - c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10)
cumsum.reset(x)

[1]  1  3  6  0  5 11 18 26 35 45

ave(x, rev(cumsum(rev(is.na(x, FUN=cumsum)

[1]  1  3  6 NA  5 11 18 26 35 45




The speedup from not breaking the input vector into smaller vectors is (to me) 
surprisingly small -- only a factor of 3:


x - replace(rnorm(1e6), sample(1e6, 1), NA)
all.equal(replace(ave(x, rev(cumsum(rev(is.na(x, FUN=cumsum), is.na(x), 0), 
cumsum.reset(x))

[1] TRUE

system.time(cumsum.reset(x))
  user  system elapsed 
  0.310.030.35 

system.time(ave(x, rev(cumsum(rev(is.na(x, FUN=cumsum))
  user  system elapsed 
  0.990.051.15 




So, I'd go with the ave() approach unless this type of cumsum is the core of a 
long computationally intensive job.  And if that's the case, it would make 
sense to code it in C.

-- Tony Plate


Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
 

any ideas?

thank you and best regards,

stefan

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

and provide commented, minimal, self-contained, reproducible code.



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



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


[R] fitting a glm with matrix of responses

2009-11-11 Thread Murat Tasan
hi all - quick question:

i have a matrix 'y' of response values, with two explanatory variables
'x1' and 'x2'.
tested values of 'x1' and 'x2' are sitting in two vectors 'x1' and
'x2'.
i want to learn model parameters without unrolling the matrix of
response values.
example below:

# some fake data for the example
x1 - 1:5
x2 - 1:10
y - matrix(runif(50), nrow = 5)

# current method:
z - vector()
for(i in x1) for(j in x2) z - c(z, i, j, y[i, j])
z - data.frame(matrix(z, ncol = 3, byrow = TRUE))
colnames(z) - c(x1, x2, y)
m - glm(y ~ x1 + x2 + x1:x2, family = binomial, data = z)

# what i'd like to do, kind of:
m - glm(y ~ x1 + x2 + x1:x2)


basically, i have to unfold the matrix 'y' to a data frame 'z' then
solve.
this is somewhat tedious.
anyone know of a way i can do this more generally, especially if
working in even higher dimensions than 2 (i.e. with an arbitrary-
dimension array of response values)?

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


Re: [R] Automating Plot Commands using a Loop

2009-11-11 Thread Koraelus

Hello,

Thank you for responding! The data is in the same format as the example I
showed earlier. The data is different from matrix to matrix, but the general
format is:

  Time1Time 2   Time3  Time4
Species1 134 5
Species2 345 6
Species33   4 5   6

The problem I had was that I wanted to graph the species values (which are
different from matrix to matrix) through time - i.e. values y-axis and time
x-axis, so I transposed the matrix such that the species would be the
columns and time would be the rows so that this would be easier to code. 

If I code it without using a formula:

plot(Data$Species1,type=o,axes=F,ann=F,ylim=c(0,1))

It works perfectly fine.

Thanks,
Andrew Z.


Why did you transpose the dataframe (TData - t(Data))?  Is your data
in the same structure as is expected.  Provide either the data file
you are plotting, or at least an 'str' of the object.
-- 
View this message in context: 
http://old.nabble.com/Automating-Plot-Commands-using-a-Loop-tp26273268p26306647.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] fisher.test negative value error

2009-11-11 Thread Bhanu Mangipudi
Hi all,

I am new to python, R and rpy2. I having few errors when I am using
'fisher.test' function where I am struck now. Please help to fix these bugs.
My code for fisher.test goes this way

*from rpy2 import *
import rpy2.robjects as robjects
def fisherExact(a,b,c,d):
   v = [a,b,c,d]
   m = robjects.r['matrix'](v,2,2)
   s = robjects.r['fisher.test'](m)
   return s
*

Here the value of a=0,b=1,c=0 and d=1. so the matrix m should be like this

 [,1] [,2]
[1,] 00
[2,] 11

But I am getting an error like this

*File /usr/lib64/python2.6/site-packages/rpy2/robjects/__init__.py, line
422, in __call__
res = super(RFunction, self).__call__(*new_args, **new_kwargs)
rinterface.RRuntimeError: Error in function (x, y = NULL, workspace = 2e+05,
hybrid = FALSE, control = list(),  :
  all entries of 'x' must be nonnegative and finite*

clearly every element of matrix m is +ve but I don't know why I am getting
this error. I am using python 2.6,R-core-2.9.2-1 and rpy2.

Please help me in this regard.

Thanks,
Bhanu.

[[alternative HTML version deleted]]

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


Re: [R] fitting a glm with matrix of responses

2009-11-11 Thread David Winsemius


On Nov 11, 2009, at 2:24 PM, Murat Tasan wrote:


hi all - quick question:

i have a matrix 'y' of response values, with two explanatory variables
'x1' and 'x2'.
tested values of 'x1' and 'x2' are sitting in two vectors 'x1' and
'x2'.
i want to learn model parameters without unrolling the matrix of
response values.
example below:

# some fake data for the example
x1 - 1:5
x2 - 1:10
y - matrix(runif(50), nrow = 5)

# current method:
z - vector()
for(i in x1) for(j in x2) z - c(z, i, j, y[i, j])
z - data.frame(matrix(z, ncol = 3, byrow = TRUE))
colnames(z) - c(x1, x2, y)
m - glm(y ~ x1 + x2 + x1:x2, family = binomial, data = z)

# what i'd like to do, kind of:



m - glm(as.vector(y) ~ expand.grid(x1 , x2)^2)


Perhaps:
 zdf - expand.grid(x1,x2)
 zdf$y - as.vector(y)
 m - glm(as.vector(y) ~ (Var1 + Var2)^2, data=zdf)
 m

Call:  glm(formula = as.vector(y) ~ (Var1 + Var2)^2, data = zdf)

Coefficients:
(Intercept) Var1 Var2Var1:Var2
   0.425943 0.066960-0.001198-0.006480

Degrees of Freedom: 49 Total (i.e. Null);  46 Residual
Null Deviance:  4.067
Residual Deviance: 3.759AIC: 22.5




basically, i have to unfold the matrix 'y' to a data frame 'z' then
solve.


as.vector would do that, but I don't know how well it works within a  
formula.




this is somewhat tedious.
anyone know of a way i can do this more generally, especially if
working in even higher dimensions than 2 (i.e. with an arbitrary-
dimension array of response values)?


?formula

You can get all two way interactions with ( )^2

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] fisher.test negative value error

2009-11-11 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Bhanu Mangipudi
 Sent: Wednesday, November 11, 2009 11:16 AM
 To: r-help@r-project.org
 Subject: [R] fisher.test negative value error
 
 Hi all,
 
 I am new to python, R and rpy2. I having few errors when I am using
 'fisher.test' function where I am struck now. Please help to 
 fix these bugs.
 My code for fisher.test goes this way
 
 *from rpy2 import *
 import rpy2.robjects as robjects
 def fisherExact(a,b,c,d):
v = [a,b,c,d]
m = robjects.r['matrix'](v,2,2)
s = robjects.r['fisher.test'](m)
return s
 *
 
 Here the value of a=0,b=1,c=0 and d=1. so the matrix m should 
 be like this
 
  [,1] [,2]
 [1,] 00
 [2,] 11
 
 But I am getting an error like this
 
 *File 
 /usr/lib64/python2.6/site-packages/rpy2/robjects/__init__.py, line
 422, in __call__
 res = super(RFunction, self).__call__(*new_args, **new_kwargs)
 rinterface.RRuntimeError: Error in function (x, y = NULL, 
 workspace = 2e+05,
 hybrid = FALSE, control = list(),  :
   all entries of 'x' must be nonnegative and finite*

I think you are passing a list matrix to fisher.test, not
a numeric matrix.  E.g.,
   fisher.test(matrix(list(0,1,0,1),2,2))
  Error in fisher.test(matrix(list(0, 1, 0, 1), 2, 2)) : 
all entries of 'x' must be nonnegative and finite
The python v should be a numeric array instead of a list.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  


 
 clearly every element of matrix m is +ve but I don't know why 
 I am getting
 this error. I am using python 2.6,R-core-2.9.2-1 and rpy2.
 
 Please help me in this regard.
 
 Thanks,
 Bhanu.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


Re: [R] as.Date from data.frame

2009-11-11 Thread separent

Hello Gentlemen,

All of your answers were helpfull. Indeed, 'as.is=TRUE' or
'stringsAsFactors=FALSE' avoid importing as factors, as it did when I
imported the table without specifying anything. However, data frames will
not allow different datatypes within a single column, so, for time series, I
should work with a transpose of the table. However, when the time series is
the label of a profile, I should read the table with 'header = TRUE'.

In other words:
* Plotting values of a column (let's say againts observation number) for a
selected time (where time is the name of the series): import data with
'header = TRUE'
* Plotting the evolution of the values for a single observation number
against time: 'header = TRUE'  transpose  'as.is=TRUE'

Kind Regards,

Serge-Étienne Parent
Golder Associés
Canada



separent wrote:
 
 #Hello,
 
 #I loaded data using read.table - I needed to convert a row in the data
 frame to date class:
 
 data
 
 V1  V2  V3  V4
 1  2008-05-19  2008-04-19  2008-03-21  2008-02-22
 2 38.16999817 30.7008 36.8661 35.18999863
 3 37.4754 29.9576 36.4508 35.3661
 4 37.4754 30.1462 36.47000122 35.3661
 5 37.84999847 30.5669 36.8415 35.74000168
 6 38.3839 31.1462 37.3415 36.2746
 7 39.1161 31.9085 38.02999878 36.9754
 8 39.81000137 32.65000153 38.6831 37.6339
 9 40.47000122 33.34999847 39.27999878 38.2746
 
 data[1,]
   V1 V2 V3 V4
 1 2008-05-19 2008-04-19 2008-03-21 2008-02-22
 
 dates1-as.Date(data[1,])
 
 do not know how to convert 'dates[1,]' to class Date
 
 # However, I can individually convert them all:
 
 dates1.1-as.Date(data[1,1])
 
 dates1.1
 [1] 2008-05-19
 
 # How can I change the class of the date over the entire row (my original
 file contains more than one hundred rows)?
 # Thank you very much.
 

-- 
View this message in context: 
http://old.nabble.com/as.Date-from-data.frame-tp26305830p26307735.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] LINEAR MIXED EFFECT

2009-11-11 Thread Dave Atkins


Milton's point is dead-on, and I would highly encourage you to give the
posting guide a look.

That said... you might try na.action = na.omit in your call to...
actually, we don't know what function you are using (see first point). 
Regardless, sounds like you have missing data and na.action is set to
na.fail (ie, fail if any missing data).

cheers, Dave


milton ruser wrote:
 
 Dear Ana Golveia,
 
 It is completelly impossible someone realise what kind or help you need or
 what is happening. I suggest you give a look on the posting guide, mainly
 that part about a minimum reproducible code with self explaining
 information, etc.
 
 Cheers
 
 milton
 
 On Wed, Nov 11, 2009 at 7:22 AM, ANARPCG a.gouvei...@imperial.ac.uk
 wrote:
 

 CAN ANYONE PLEASE HELP ME WITH THIS
 i HAVE TO DO A MIXED EFFECT LINEAR MODEL WITH MY DATA DUE TO THE FACT
 THAT
 I
 have pseudoreplication!
 Although after reading and trying it for several times can get around due
 to
 Error in na.fail.default(list(date = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 
 :
 missing values in object
 I uploaded my data file
 Thank you so much
 Kind regards
 AG
 http://old.nabble.com/file/p26300394/rawoctobercalciumexperiment2.txt
 rawoctobercalciumexperiment2.txt

 --
 View this message in context:
 http://old.nabble.com/LINEAR-MIXED-EFFECT-tp26300394p26300394.html
 Sent from the R help mailing list archive at Nabble.com.

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

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

-- 
View this message in context: 
http://old.nabble.com/LINEAR-MIXED-EFFECT-tp26300394p26308114.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Is there a way to specify drop=FALSE as the global default?

2009-11-11 Thread tlumley

On Wed, 11 Nov 2009, Peng Yu wrote:


On Mon, Oct 19, 2009 at 7:57 PM, Peng Yu pengyu...@gmail.com wrote:

tmp - matrix(1:2)
tmp
tmp[,1,drop=FALSE]


See the above example. Is there a way to make 'drop=FALSE' as global
default, so that when I say 'tmp[,1]', R will treat it as
'tmp[,1,drop=FALSE]'?


Is there a way to set drop=FALSE globally?


No.


I can't remember to put
drop=FALSE to all the '[]'s. But this indeed causes some weird bugs
for me to figure out.


It would probably cause a lot more weird bugs if the behavior of [ depended on 
a global option.

 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

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

2009-11-11 Thread tlumley

On Wed, 11 Nov 2009, Larry Hotchkiss wrote:


Hi,

I'm responding to the question about storage error, trying to read a 300 x 
100 dataset into a data.frame.

I wonder whether you can read the data as strings. If the numbers are all one 
digit, each cell would require just 1 byte instead of 8.


Um, no.


 a-rep(1,10)
object.size(a)

400056 bytes

object.size(a)/length(a)

4.00056 bytes

They are character strings, not individual characters, so some overhead is 
unavoidable.  Even if all the strings are identical you need four bytes per 
string, the same as if the data were read as integers.

 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Partial correlations and p-values

2009-11-11 Thread dadrivr

I'm trying to write code to calculate partial correlations (along with
p-values).  I'm new to R, and I don't know how to do this.  I have searched
and come across different functions, but I haven't been able to get any of
them to work (for example, pcor and pcor.test from the ggm package).

In the following example, I am trying to compute the correlation between x
and y, while controlling for z (partial correlation):

x - c(1,20,14,7,9)
y - c(5,6,7,9,10)
z - c(13,27,16,5,4)

What function can I append to this to find this partial correlation?  Many
thanks!


-- 
View this message in context: 
http://old.nabble.com/Partial-correlations-and-p-values-tp26308463p26308463.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R.oo and S4?

2009-11-11 Thread Gabor Grothendieck
I think it would be best to learn S3 first since that is a fundamental
part of R and S4 is an extension of it and also its very simple so
there is not much to learn.  After that you can branch out.

On Mon, Oct 26, 2009 at 2:28 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 S3 and S4 are part of the core of R so they would presumably be the
 most used.  S4 is an extension to S3 but adds strong typing and a
 number of other features.  R.oo and proto are packages on CRAN which
 give access to different models of object oriented programming than S3
 and S4. R.oo uses a more conventional model of OO than S3 or S4 that
 is probably closer to what you are used to if you are coming form
 another language while proto uses the prototype model (or pure object
 model). proto tends to apply in user interface applications and there
 is some info on which other packages make use of proto on the proto
 home page at: http://r-proto.googlecode.com

 On Mon, Oct 26, 2009 at 2:47 PM, Peng Yu pengyu...@gmail.com wrote:
 There are different way to make R classes. I know R.oo and S4. I'm
 wondering which one is the current popular one. Which one is current
 recommended when make new R packages? Thank you!

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



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


Re: [R] Loadings and scores from fastICA?

2009-11-11 Thread Tony Plate

The help for fastICA says:

The data matrix X is considered to be a linear combination of
non-Gaussian (independent) components i.e. X = SA where columns of
S contain the independent components and A is a linear mixing
matrix.

The value of fastICA is a list with components S (the estimated source matrix) and 
A (the estimated mixing matrix).  Are these what you want?

-- Tony Plate

Joel Fürstenberg-Hägg wrote:

Hi all,

 


Does anyone know how to get the independent components and loadings from an 
Independent Component Analysis (ICA), as well as principal components and 
loadings from a Pricipal Component analysis (PCA) using the fastICA package? Or 
perhaps if there's another way to do ICAs in R?


Below is an example from the fastICA manual 
(http://cran.r-project.org/web/packages/fastICA/fastICA.pdf)

 


if(require(MASS))
{
 x - mvrnorm(n = 1000, mu = c(0, 0), Sigma = matrix(c(10, 3, 3, 1), 2, 2))
 x1 - mvrnorm(n = 1000, mu = c(-1, 2), Sigma = matrix(c(10, 3, 3, 1), 2, 
2))
 X - rbind(x, x1)
 a - fastICA(X, 2, alg.typ = deflation, fun = logcosh, alpha = 1, method = 
R, row.norm = FALSE, maxit = 200, tol = 0.0001, verbose = TRUE)
 par(mfrow = c(1, 3))
 plot(a$X, main = Pre-processed data)
 plot(a$X%*%a$K, main = PCA components)
 plot(a$S, main = ICA components)
}

 


Best regards,

 


Joel
 		 	   		  
_

Hitta kärleken i vinter!
http://dejting.se.msn.com/channel/index.aspx?trackingid=1002952
[[alternative HTML version deleted]]






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


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


[R] thousands separator in console output?

2009-11-11 Thread Patricio Cuarón
Hello, I'm beginning with R and I'm wondering if there's any way to display
large values (e.g. 161651654167) using my system's thousands separator or
scientific notation.

Thanks!

[[alternative HTML version deleted]]

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


[R] plotting time series

2009-11-11 Thread morgi2020

Hi,

I'm new to R.
I've two sort of time series, one sampled every second and other every 30
minutes stored in two data.frames zy1 and zy2.

I've joined the two series using 

date-merge(zy1,zy2, all.x=T,all.y=T)

when I want to make a plot, using the code below, it doesn't work. 
It gives me the following error produced NA error

plot( a~ time,data=z, type=l, ylim=range(30,80))
lines( b~ time,data=z, type=l)

Can you help me?
Thanks
Morgi
-- 
View this message in context: 
http://old.nabble.com/plotting-time-series-tp26308476p26308476.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] eacf

2009-11-11 Thread ECSANT

Dear Michel,

The only thing you need to do is download the TSA package, and read its
document. In this document you're gonna find the command eacf, so it's as
simple as using the source TSA, and in ur Tinn-R just call the instruction
with the options you want.

I expect this information to be useful for you.



Michel Helcias wrote:
 
 I am Brazilian and I don't know how to speak English, for that I apologize
 for my writing.
 I'd like of informations about the extended (sample) autocorrelation
 function (*EACF*) for the time series. where to acquire some related
 command.
 thak you.
 
   [[alternative HTML version deleted]]
 
 __
 r-h...@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
 
 

-- 
View this message in context: http://old.nabble.com/eacf-tp4938311p26308603.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread Stavros Macrakis
When printing data.frames, R aligns columns by padding with spaces.
For example,

print(data.frame(x=c('a','bb','ccc')),right=FALSE)
  x
1 a  |-- vertical bar shows end of line
2 bb |-- vertical bar shows end of line
3 ccc|-- vertical bar shows end of line

Is there some way to suppress the padding for the final column? I
often have data frames which contain a handful of long strings in the
final column which, when printed out, cause wraparound on all the
rows, even those not containing long strings, something like this:

print(data.frame(q=1:3,x=c('a','bb','this is a very long string')),right=FALSE)
  q x   |
  |
1 1 a   |
  |
2 2 bb  |
  |
3 3 this is a very l|
ong string|

where I'd rather have

print(data.frame(q=1:3,x=c('a','bb','this is a very long string')),right=FALSE)
  q x|
1 1 a|
2 2 bb|
3 3 this is a very l|
ong string|

I could of course write my own print function for this, but was
wondering if there was a standard way of doing it.  If not in R,
perhaps there is some way to have ESS delete the final spaces?

Thanks,

 -s

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


Re: [R] thousands separator in console output?

2009-11-11 Thread Marc Schwartz

On Nov 11, 2009, at 3:52 PM, Patricio Cuarón wrote:

Hello, I'm beginning with R and I'm wondering if there's any way to  
display
large values (e.g. 161651654167) using my system's thousands  
separator or

scientific notation.

Thanks!


To get scientific notation as a default for given large values, see ? 
options and note 'scipen', which by default is 0.


 161651654167
[1] 161651654167

options(scipen = -5)

 161651654167
[1] 1.616517e+11

That is about the only way, by default, to adjust the output of  
numeric values, for which R uses ?print.default. You can play with the  
value of scipen to get the behavior you wish for some definition of  
'large' numbers.


If you want to format large numbers with commas as the thousand  
separator, that will not happen by default, but you can use format()  
to do this when outputting numbers as you may need in a function and/ 
or for pretty printing in tables, etc.:


 format(161651654167, big.mark = ,)
[1] 161,651,654,167

Note that the result is a character vector and not numeric.

See ?format and perhaps ?formatC for more information.

HTH,

Marc Schwartz

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


Re: [R] R.oo and S4?

2009-11-11 Thread Henrik Bengtsson
Please what I already wrote in my previous message of this thread.
Also, everything in R.oo is based on S3 and it uses standard R
constructs and data types to achieve what it does.

You can submit packages based on R.oo, and there are several such
packages on CRAN, see 'Reverse dependencies' on
http://cran.r-project.org/web/packages/R.oo/.   Who told you it is not
possible?

/Henik

On Wed, Nov 11, 2009 at 6:26 PM, Peng Yu pengyu...@gmail.com wrote:
 I'm very familiar with C++. In this sense, it is easier for me to
 learn R.oo according to your advice. On the other hand, S3 and S4 are
 the most used. I'm wondering what would be the best choice for me. Do
 you have any recommendation considering the pros and cons of both
 ways?

 Is it true that packages based on R.oo can not be deposited to CRAN?

 On Mon, Oct 26, 2009 at 1:28 PM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 S3 and S4 are part of the core of R so they would presumably be the
 most used.  S4 is an extension to S3 but adds strong typing and a
 number of other features.  R.oo and proto are packages on CRAN which
 give access to different models of object oriented programming than S3
 and S4. R.oo uses a more conventional model of OO than S3 or S4 that
 is probably closer to what you are used to if you are coming form
 another language while proto uses the prototype model (or pure object
 model). proto tends to apply in user interface applications and there
 is some info on which other packages make use of proto on the proto
 home page at: http://r-proto.googlecode.com

 On Mon, Oct 26, 2009 at 2:47 PM, Peng Yu pengyu...@gmail.com wrote:
 There are different way to make R classes. I know R.oo and S4. I'm
 wondering which one is the current popular one. Which one is current
 recommended when make new R packages? Thank you!

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



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


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


Re: [R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread Richard M. Heiberger

Stavros Macrakis wrote:

I could of course write my own print function for this, but was
wondering if there was a standard way of doing it.  If not in R,
perhaps there is some way to have ESS delete the final spaces?
  
ESS, or more precisely emacs, can handle that.  Use the M-x 
toggle-truncate-lines command:

Toggle whether to fold or truncate long lines for the current buffer.

Rich

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


Re: [R] partial cumsum

2009-11-11 Thread Carl Witthoft

quote:
x - c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10)
rev(cumsum(rev(is.na(x
[1] 1 1 1 1 0 0 0 0 0 0
A more natural way to do this is
cumsum(is.na(c(NA,x[-length(x)])))
[1] 1 1 1 1 2 2 2 2 2 2
endquote

Both of which suggest the original problem could also be dealt with by 
using rle().  Something like


xna-is.na(x)
rle(xna)
and then apply cumsum to sections of x based onthe lengths returned by rle

Carl

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 way to specify drop=FALSE as the global default?

2009-11-11 Thread hadley wickham
 See the above example. Is there a way to make 'drop=FALSE' as global
 default, so that when I say 'tmp[,1]', R will treat it as
 'tmp[,1,drop=FALSE]'?

The following code won't change the defaults, but it would at least
let you know when you're making the mistake:

trace_all - function(fs, tracer) {
  lapply(fs, trace, exit = tracer, print=FALSE)
  invisible()
}

functions_with_arg - function(arg, pos) {
  fs - ls(pos=pos)
  present - unlist(lapply(fs, function(x)
is.function(get(x))   !is.null(formals(x)[[arg]])))

  fs[present]
}

trace_all(
  functions_with_arg(drop, package:base),
  quote(if (drop) warning(drop = TRUE, call. = F))
)

 mtcars[1, 2]
[1] 6
Warning message:
drop = TRUE

Unfortunately it doesn't pick up on the generic [ because it is a primitive.

Hadley


-- 
http://had.co.nz/

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


Re: [R] partial cumsum

2009-11-11 Thread Marc Schwartz

On Nov 11, 2009, at 4:45 PM, Carl Witthoft wrote:

 By Bill Dunlap:

quote:
   x - c(1, 2, 3, NA, 5, 6, 7, 8, 9, 10)
   rev(cumsum(rev(is.na(x
   [1] 1 1 1 1 0 0 0 0 0 0
A more natural way to do this is
   cumsum(is.na(c(NA,x[-length(x)])))
   [1] 1 1 1 1 2 2 2 2 2 2
endquote

Both of which suggest the original problem could also be dealt with  
by using rle().  Something like


xna-is.na(x)
rle(xna)
and then apply cumsum to sections of x based onthe lengths returned  
by rle


Carl




Which would be something along the lines of the following:

rle.x - rle(!is.na(x))$lengths

 rle.x
[1] 3 1 6

 as.numeric(unlist(sapply(split(x, rep(seq(along = rle.x), rle.x)),  
cumsum)))

 [1]  1  3  6 NA  5 11 18 26 35 45


Which is what I had been working on until I saw Bill's more elegant  
one-liner solution...  :-)


The interim use of split() gets you 'x' split by where the NA's occur:

 rep(seq(along = rle.x), rle.x)
 [1] 1 1 1 2 3 3 3 3 3 3

 split(x, rep(seq(along = rle.x), rle.x))
$`1`
[1] 1 2 3

$`2`
[1] NA

$`3`
[1]  5  6  7  8  9 10

and then you use cumsum() in sapply() (or lapply()) on each list  
element and coerce the result back to an un-named numeric vector.


Regards,

Marc Schwartz

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


Re: [R] Is there a way to specify drop=FALSE as the global default?

2009-11-11 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of hadley wickham
 Sent: Wednesday, November 11, 2009 3:03 PM
 To: Peng Yu
 Cc: r-h...@stat.math.ethz.ch
 Subject: Re: [R] Is there a way to specify drop=FALSE as the 
 global default?
 
  See the above example. Is there a way to make 'drop=FALSE' as global
  default, so that when I say 'tmp[,1]', R will treat it as
  'tmp[,1,drop=FALSE]'?
 
 The following code won't change the defaults, but it would at least
 let you know when you're making the mistake:

Or you could write wrapper functions for [ and [- that
add the drop=FALSE argument.  E.g.,
  SS - function(x, ..., drop=FALSE) x[..., drop=drop] # 'Safe
Subscripting'
  `SS-` - function(x, ..., value) { x[...] - value ; x }
Use them as
  SS(x, 1, i) # instead of x[1, i] 

Use grep (or codetools::walkCode) to make sure you don't
have any other calls to [ in your code.  (The ss- is
there only so calls to [ on the left side of the assignment
don't attract grep's attention.)

S+ has a subscript2d() that does this and also lets
you use 2 subscripts on vectors (the 2nd must be 1
in that case, but you don't need to use if statements).
subscript2d doesn't even have the drop= argument - if
you want to make a vector from a one column matrix use
as.vector.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 
 trace_all - function(fs, tracer) {
   lapply(fs, trace, exit = tracer, print=FALSE)
   invisible()
 }
 
 functions_with_arg - function(arg, pos) {
   fs - ls(pos=pos)
   present - unlist(lapply(fs, function(x)
 is.function(get(x))   !is.null(formals(x)[[arg]])))
 
   fs[present]
 }
 
 trace_all(
   functions_with_arg(drop, package:base),
   quote(if (drop) warning(drop = TRUE, call. = F))
 )
 
  mtcars[1, 2]
 [1] 6
 Warning message:
 drop = TRUE
 
 Unfortunately it doesn't pick up on the generic [ because it 
 is a primitive.
 
 Hadley
 
 
 -- 
 http://had.co.nz/
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


[R] Convert to time from epoch

2009-11-11 Thread Alon Ben-Ari
Hello R users,

Is anyone familiar with an R function that converts a time expression (
POSIx for example ) to  time (seconds/minutes) from epoch?
I was unable to find any

Best,

Alon

[[alternative HTML version deleted]]

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


Re: [R] Convert to time from epoch

2009-11-11 Thread jim holtman
try this:

 x - Sys.time()
 str(x)
 POSIXct[1:1], format: 2009-11-11 18:40:10
 x
[1] 2009-11-11 18:40:10 EST
 as.numeric(x)  # secs from 1/1/1970
[1] 1257982810



On Wed, Nov 11, 2009 at 6:29 PM, Alon Ben-Ari alon.ben...@gmail.com wrote:
 Hello R users,

 Is anyone familiar with an R function that converts a time expression (
 POSIx for example ) to  time (seconds/minutes) from epoch?
 I was unable to find any

 Best,

 Alon

        [[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

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


Re: [R] Implementation of the Shuffled Complex Evolution (SCE-UA) Algorithm

2009-11-11 Thread Felix Andrews
http://code.google.com/p/ihacres/source/browse/trunk/man/SCEoptim.Rd

http://code.google.com/p/ihacres/source/browse/trunk/R/sce.R
source(http://ihacres.googlecode.com/svn/trunk/R/sce.R;)



2009/11/12 Hans W Borchers hwborch...@googlemail.com:
 Simon Seibert simon.seibert at mytum.de writes:


 Good evening list,
 I'm looking for an R implementation of the Shuffled Complex
 Evolution† (SCE-UA) algorithm after Duan et al. (1993). Does anybody
 know if there is an extension/ package existing that contains it?
 Thanks very much for your help! Cheers, Simon

 I am looking into stochastic global optimization routines, such as variants of
 genetic algorithms (GA), particle swarm optimization (PSO), and shuffled 
 complex
 (SCE) or differential evolution (DE).

 At the moment I am testing a free Matlab implementation of SCE-UA. If that 
 turns
 out to be interesting and effective, I will translate it into an R function,
 maybe within the next few weeks -- except, of course, someone else is going to
 do an implementation of a similar procedure.

 Right now I am not totally convinced. Maybe you try your problem with other
 approaches available in R (see e.g. the Optimization task view).

 Regards
 Hans Werner

 Duan QY, Gupta KV, Sorooshian S (1993) Shuffled Complex Evolution
 Approach for Effective and Efficient Global Minimization. In Jour. of
 optimization theorie and applications. Vol 76, 3, 501-521


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




-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andr...@anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/

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

2009-11-11 Thread Jacob Wegelin


Often I perform the same task on a series of variables in a dataframe, by 
looping through a character vector that holds the names and using paste(), 
eval(), and parse() inside the loop.

For instance:

thesevars-names(environmental)
environmental$ToyOutcome-rnorm(nrow(environmental))

tableOfResults-data.frame(var=thesevars)
tableOfResults$Beta- NA
rownames(tableOfResults)-thesevars

for( thisvar in thesevars) {
thiscommand- paste(thislm - lm( ToyOutcome ~ , thisvar, , 
data=environmental))
eval(parse(text=thiscommand))
tableOfResults[thisvar, Beta] - coef(thislm)[thisvar]
}

print(tableOfResults)

Note that it's not always as simple a task as in this example. Within the loop, 
I might first figure out whether the variable is continuous or categorical, 
then perform an operation depending on its type--maybe lm() for continuous but 
wilcox.test() for dichotomous.

But the use of paste(), eval(), and parse() seems awkward.  Is there a more 
elegant way to approach this?

Thanks

Jacob A. Wegelin
Department of Biostatistics
Virginia Commonwealth University
Richmond VA 23298-0032
U.S.A.

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


Re: [R] loop through variable names

2009-11-11 Thread Gabor Grothendieck
Try this:

lm(environmental[c(ToyOutcome, thisvar)])

or

lm(ToyOutcome ~., environmental[c(ToyOutcome, thisvar)])


On Wed, Nov 11, 2009 at 6:49 PM, Jacob Wegelin jacobwege...@fastmail.fm wrote:

 Often I perform the same task on a series of variables in a dataframe, by
 looping through a character vector that holds the names and using paste(),
 eval(), and parse() inside the loop.

 For instance:

 thesevars-names(environmental)
 environmental$ToyOutcome-rnorm(nrow(environmental))

 tableOfResults-data.frame(var=thesevars)
 tableOfResults$Beta- NA
 rownames(tableOfResults)-thesevars

 for( thisvar in thesevars) {
        thiscommand- paste(thislm - lm( ToyOutcome ~ , thisvar, ,
 data=environmental))
        eval(parse(text=thiscommand))
        tableOfResults[thisvar, Beta] - coef(thislm)[thisvar]
 }

 print(tableOfResults)

 Note that it's not always as simple a task as in this example. Within the
 loop, I might first figure out whether the variable is continuous or
 categorical, then perform an operation depending on its type--maybe lm() for
 continuous but wilcox.test() for dichotomous.

 But the use of paste(), eval(), and parse() seems awkward.  Is there a more
 elegant way to approach this?

 Thanks

 Jacob A. Wegelin
 Department of Biostatistics
 Virginia Commonwealth University
 Richmond VA 23298-0032
 U.S.A.

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


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


[R] naive collinear weighted linear regression

2009-11-11 Thread Mauricio Calvao

Hi there

Sorry for what may be a naive or dumb question.

I have the following data:

 x - c(1,2,3,4) # predictor vector

 y - c(2,4,6,8) # response vector. Notice that it is an exact, 
perfect straight line through the origin and slope equal to 2


 error - c(0.3,0.3,0.3,0.3) # I have (equal) ``errors'', for 
instance, in the measured responses


Of course the best fit coefficients should be 0 for the intercept and 2 
for the slope. Furthermore, it seems completely plausible (or not?) 
that, since the y_i have associated non-vanishing ``errors'' 
(dispersions), there should be corresponding non-vanishing ``errors'' 
associated to the best fit coefficients, right?


When I try:

 fit_mod - lm(y~x,weights=1/error^2)

I get

Warning message:
In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
  extra arguments weigths are just disregarded.

Keeping on, despite the warning message, which I did not quite 
understand, when I type:


 summary(fit_mod)

I get

Call:
lm(formula = y ~ x, weigths = 1/error^2)

Residuals:
 1  2  3  4
-5.067e-17  8.445e-17 -1.689e-17 -1.689e-17

Coefficients:
 Estimate Std. Error   t value Pr(|t|)
(Intercept) 0.000e+00  8.776e-17 0.000e+001
x   2.000e+00  3.205e-17 6.241e+16   2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 7.166e-17 on 2 degrees of freedom
Multiple R-squared: 1,  Adjusted R-squared: 1
F-statistic: 3.895e+33 on 1 and 2 DF,  p-value:  2.2e-16


Naively, should not the column Std. Error be different from zero?? What 
I have in mind, and sure is not what Std. Error means, is that if I 
carried out a large simulation, assuming each response y_i a Gaussian 
random variable with mean y_i and standard deviation 2*error=0.6, and 
then making an ordinary least squares fitting of the slope and 
intercept, I would end up with a mean for these simulated coefficients 
which should be 2 and 0, respectively, and, that's the point, a 
non-vanishing standard deviation for these fitted coefficients, right?? 
This somehow is what I expected should be an estimate or, at least, a 
good indicator, of the degree of uncertainty which I should assign to 
the fitted coefficients; it seems to me these deviations, thus 
calculated as a result of the simulation, will certainly not be zero (or 
 3e-17, for that matter). So this Std. Error does not provide what I, 
naively, think should be given as a measure of the uncertainties or 
errors in the fitted coefficients...


What am I not getting right??

Thanks and sorry for the naive and non-expert question!


--
###
Prof. Mauricio Ortiz Calvao
Federal University of Rio de Janeiro
Institute of Physics, P O Box 68528
CEP 21941-972 Rio de Janeiro, RJ
Brazil

Email: o...@if.ufrj.br
Phone: (55)(21)25627483
Homepage: http://www.if.ufrj.br/~orca
###

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


Re: [R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread RICHARD M. HEIBERGER
On Wed, Nov 11, 2009 at 8:12 PM, Stavros Macrakis macra...@alum.mit.edu wrote:
 Thanks for the suggestion. I'mm familiar with the truncate-lines variable,
 but that's not quite what I was looking for.  I don't want the padding
 spaces displayed, but I do want to see long strings at the end of the line.

Then we can use a different emacs trick.

delete-trailing-whitespaceM-x ... RET
  Command: Delete all the trailing whitespace across the current buffer.
ess-nuke-trailing-whitespace  M-x ... RET
  Command: Nuke all trailing whitespace in the buffer.
whitespace-toggle-trailing-check M-x ... RET
  Command: Toggle the check for trailing space in the local buffer.

Rich

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


Re: [R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread Stavros Macrakis
Thanks for the suggestion. I'mm familiar with the truncate-lines variable,
but that's not quite what I was looking for.  I don't want the padding
spaces displayed, but I do want to see long strings at the end of the line.

Thanks anyway,

   -s

On Wed, Nov 11, 2009 at 5:40 PM, Richard M. Heiberger r...@temple.eduwrote:

 Stavros Macrakis wrote:

 I could of course write my own print function for this, but was
 wondering if there was a standard way of doing it.  If not in R,
 perhaps there is some way to have ESS delete the final spaces?


 ESS, or more precisely emacs, can handle that.  Use the M-x
 toggle-truncate-lines command:
Toggle whether to fold or truncate long lines for the current buffer.

 Rich





[[alternative HTML version deleted]]

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


  1   2   >