[R] Creating mean C columns out of As and Bs

2013-03-27 Thread Michael Budnick
I am working on a gene expression microarray dataset, each sample has been 
taking from animal A and animal B on the same type of microarray.

I would like to take the mean of these columns and create a dataset with 
columns with data which are means of the corresponding rows of A and B

For example:

TissueExpressionA - HTissue[1:22284, c(29, 39, 57, 59, 63, 69, 71, 73, 77, 79, 
83, 89, 99, 117, 119, 121, 123, 125, 137, 145, 159)]
TissueExpressionB - HTissue[1:22284, c(30, 40, 58, 60, 64, 70, 72, 74, 78, 80, 
84, 90, 100, 118, 120, 122, 124, 126, 138, 146, 160)]


I would like

TissueExpressionC - HTissue[1:22284, c[mean(29,30), mean(39,40), mean(57,58) 
... mean(159,160)]


I hope that makes sense.

If you know of any other method of merging data sets like this any help would 
be appreciated.

Michael Budnick
Graduate Researcher
St. John's University

[[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] Conditional CCA and Monte Carlo - Help!

2013-03-27 Thread MWilson
Hi All,
I am using canonical correspondence analysis to compare a community
composition matrix to a matrix of sample spatial relationships and
environmental variables. In order to parse out how much variance is
explained purely by space (S/E) or the environment (E/S) I am using a
conditional (partial) CCA.  I want to test significance via Monte Carlo but
I can not find a way to do this with a conditional CCA.  I have been using
vegan for the CCA and attempting to use ade4 to run a Monte Carlo. However,
these two packages conflict when it comes to CCA.  If I use vegan I can run
a conditional CCA, and if I use ade4 I can do a Monte Carlo - but I can't
figure out how to do a conditional CCA with ade4 OR a Monte Carlo with
vegan.  If anyone has experience with this I would be truly grateful for
your help!  I am fairly new to R, and I have quickly found myself in a place
where Google-ing has no longer proven useful.  Below are my scripts and
error messages.

Using Vegan:
 vare.cca - cca(InvertR.csv ~ Space1 + Space2... + Condition(Env1) +
 Condition(Env2)..., HabitatSpaceR.csv)
 randtest(vare.cca, nrepet = 1000)
Error in randtest.cca(vare.cca, nrepet = 1000) : 
  Object of class dudi expected

Using ade4:
 vare.cca - cca(InvertR.csv ~ Space1 + Space2... + Condition(Env1) +
 Condition(Env2)..., HabitatSpaceR.csv)
Error in cca(InvertR.csv ~ Space1 + Space2... + Condition(Env1) +
Condition(Env2)... +  : 
  data.frame expected





--
View this message in context: 
http://r.789695.n4.nabble.com/Conditional-CCA-and-Monte-Carlo-Help-tp4662572.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] Creating mean C columns out of As and Bs

2013-03-27 Thread David Winsemius

On Mar 26, 2013, at 6:50 PM, Michael Budnick wrote:

 I am working on a gene expression microarray dataset, each sample has been 
 taking from animal A and animal B on the same type of microarray.
 
 I would like to take the mean of these columns and create a dataset with 
 columns with data which are means of the corresponding rows of A and B
 
 For example:
 
 TissueExpressionA - HTissue[1:22284, c(29, 39, 57, 59, 63, 69, 71, 73, 77, 
 79, 83, 89, 99, 117, 119, 121, 123, 125, 137, 145, 159)]
 TissueExpressionB - HTissue[1:22284, c(30, 40, 58, 60, 64, 70, 72, 74, 78, 
 80, 84, 90, 100, 118, 120, 122, 124, 126, 138, 146, 160)]
 
 
 I would like
 
 TissueExpressionC - HTissue[1:22284, c[mean(29,30), mean(39,40), mean(57,58) 
 ... mean(159,160)]
 

mean(29,30) will evaluate to 29.5 which would have picked out a single column

allmeans - colMeans(HTissue[1:22284, sort( c(30, 40, 58, 60, 64, 70, 72, 74, 
78, 80, 84, 90, 100, 118, 120, 122, 124, 126, 138, 146, 160), c(29, 39, 57, 59, 
63, 69, 71, 73, 77, 79, 83, 89, 99, 117, 119, 121, 123, 125, 137, 145, 159))  ]
# I do not see a pattern in this pairing.
# Will return a vector rather than a data.frame.

len - length( sort( c(30, 40, 58, 60, 64, 70, 72, 74, 78, 80, 84, 90, 100, 
118, 120, 122, 124, 126, 138, 146, 160), c(29, 39, 57, 59, 63, 69, 71, 73, 77, 
79, 83, 89, 99, 117, 119, 121, 123, 125, 137, 145, 159))  )

sapply(seq(1, len-1, by=2), function(colA) mean( c(allmeans[colA:(colA+1)]) ) )
#should return a vector that is half the length of len

Testing not done in the absence of data.


 
 I hope that makes sense.

Perhaps.

 
 If you know of any other method of merging data sets like this any help would 
 be appreciated.
 
 Michael Budnick
 Graduate Researcher
 St. John's University
 
   [[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.

David Winsemius
Alameda, CA, USA

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

2013-03-27 Thread PIKAL Petr
Hi

If you can not share information you need to solve your problems yourself.

you can trace code by some print statements

sn-(S-n);snfact-gamma(sn); print(sn)

or use 
?debug

as Sarah pointed out, n is probably greater than 100 and in that case gamma(sn) 
results in NaN.

Regards
Petr



 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Sahana Srinivasan
 Sent: Tuesday, March 26, 2013 4:52 PM
 To: Berend Hasselman
 Cc: r-help@r-project.org
 Subject: Re: [R] NaNS Error Message
 
 Hi, sorry I can't provide the reproducible code - the formula is
 currently being worked on for a research paper so I can't really give
 out details in that regard.
 That being said, k is initialized to 1 at the beginning of the loop. n
 has various values (whole numbers, 0 or greater, no upper limit).
 
 
 
 On Tue, Mar 26, 2013 at 3:41 PM, Berend Hasselman b...@xs4all.nl
 wrote:
 
 
  On 26-03-2013, at 16:25, Sahana Srinivasan
  sahanasrinivasan...@gmail.com
  wrote:
 
   Hi,
   I'm using R to do a series of calculation and I have gotten several
   warnings that say NaNS produced. Whatever I could read on line
   gives me an idea that this warning is produced when the number is
   use is a
  negative
   log or otherwise mathematically problematic.
   I'm getting this error while using factorial() and gamma () on
   strictly positive numbers (always greater than zero).
   Here is a snippet of my code:
   k goes from 1 to a positive limit.
   S is always 100.
   Only positive values of n are allowed into the loop.
  
   if(n0)
   {
   while(k=lim)
 {
  
   sn-(S-n);snfact-gamma(sn);
   sn2-(2-n+S);sn2gam-gamma(sn2);
  
   num-(ngam*sn2gam);
  
  
   nk2-(2+k-(2*n)+S);
   nk2gam-gamma(nk2);
   den-(k*nk2gam);
   prob-(num/den);
  
   sum-(as.numeric((k*prob))+sum);
  
   k-k+1;
 }
   }
  
   The error message  received for every instance of this loop is :
   In gamma(sn) : NaNs produced
   In gamma(sn2) : NaNs produced
   In gamma(nk2) : NaNs produced
  
 
  This not reproducible code.
  Where is ngam?
  Where is k set to 1?
  What value does n have?
 
  Berend
 
 
 
   [[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] Averaging Out many rows from a column AND funtion to string

2013-03-27 Thread Alaios
Dear all,
1) I have a very large matrix of 
str(keep) 
 num [1:153899, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ... 
that  I would like to reduce its size to something like

str(keep) 
 num [1:1000, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ...  
or anything similar in size as this is a matrix that needs plotting (so is ok 
if it is 1000 row, 995, or 1123)

I think what I need here is a way of selecting multiple rows and averaging per 
column (notice that the column number should stay the same)

b. I would like to be able to convert strings that are function names to real 
function calls. For example I have something like

LogFunction- function(){}
FunctionIndex- rbind (c(1,LogFunction),
           c(2,TakeFunction)
          )
print(sprintf('Using the function %s',FunctionIndex[1,1]))
# call the FunctionIndex[1,1] somehow 



I would like to thank you in advance for your help

Regards
Alex

[[alternative HTML version deleted]]

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


[R] conditional Dataframe filling

2013-03-27 Thread Camilo Mora

Hi everyone:

This may be trivial but I just have not been able to figure it out.

Imagine the following dataframe:
a b c d
TRUE  TRUE  TRUE  TRUE
FALSE FALSE FALSE TRUE
FALSE  TRUE  FALSE  FALSE

I would like to create a new dataframe, in which TRUE gets 0 but if  
false then add 1 to the cell to the left. So the results for the  
example above should be something like:


a b c d
0 0 0 0
1 2 3 0
1 0 1 2

I wonder if you may know?.

Thanks,

Camilo




Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
 Provider code: 313
 Phone 776 2282
 From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 parentheses and degree symbol together?

2013-03-27 Thread Patrick Connolly
On Tue, 26-Mar-2013 at 05:05PM +0900, Pascal Oettli wrote:

| Hi,
| 
| You are right. The following should solve that problem:
| 
| plot(0, 0, pch = )
| text(0, .5, expression(Temperature~(degree*C)))

It's not *exactly* the same.  It uses a different font family for the
brackets, evidently from the Symbol family, not Helvetica (or
whatever).  Probably more appropriate since it's more akin to the
other characters' features.

So, not only more elegant, but better looking.



| 
| HTH,
| Pascal
| 
| 
| On 26/03/13 16:55, Patrick Connolly wrote:
| On Tue, 26-Mar-2013 at 04:20PM +0900, Pascal Oettli wrote:
| 
| | Hi,
| |
| | Is it what you are looking for?
| |
| | plot(0, 0, pch = )
| | text(0, .5, expression(Temperature~(degree ~ C)))
| 
| That produces an unwanted space between the degree symbol and the C.
| The search continues.
| 
| Thanks
| 
| | text(0, .4, substitute(paste(Temperature, B * degree, C)), list(B
| | =  ()))
| |
| | Hope this help,
| | Pascal
| |
| |
| |
| | On 26/03/13 16:12, Patrick Connolly wrote:
| | I'm interested in using a regular bracket with the degree symbol as an
| | axis label but it's somewhat simpler to show what I mean in a text
| | statement.
| | 
| | plot(0, 0, pch = )
| | 
| | If I'm easy to please, this would suffice:
| | text(0, .5, expression(Temperature * degree ~ C))
| | 
| | But I'm not that easily pleased.  I prefer it to look like this:
| | text(0, .4, substitute(paste(Temperature, B * degree, C)), list(B = 
 ()))
| | 
| | It looks fine, but I'm sure there's a more elegant way to do it.
| | 
| | Is there?
| | 
| | 
| 

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

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


Re: [R] conditional Dataframe filling

2013-03-27 Thread Blaser Nello
Here's a possible solution. 

dd - structure(list(a = c(TRUE, FALSE, FALSE),
 b = c(TRUE, FALSE, TRUE),
 c = c(TRUE, FALSE, FALSE),
 d = c(TRUE, TRUE, FALSE)), 
.Names = c(a, b, c, d), 
row.names = c(NA, -3L), 
class = data.frame)

ds - as.data.frame(t(apply(!dd, 1, cumsum)-apply(dd, 1, cumsum)))
ds[as.matrix(dd)] - 0
ds

Best,
Nello

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Camilo Mora
Sent: Mittwoch, 27. März 2013 09:32
To: r-help@r-project.org
Subject: [R] conditional Dataframe filling

Hi everyone:

This may be trivial but I just have not been able to figure it out.

Imagine the following dataframe:
a b c d
TRUE  TRUE  TRUE  TRUE
FALSE FALSE FALSE TRUE
FALSE  TRUE  FALSE  FALSE

I would like to create a new dataframe, in which TRUE gets 0 but if false then 
add 1 to the cell to the left. So the results for the example above should be 
something like:

a b c d
0 0 0 0
1 2 3 0
1 0 1 2

I wonder if you may know?.

Thanks,

Camilo




Camilo Mora, Ph.D.
Department of Geography, University of Hawaii Currently available in Colombia
Phone:   Country code: 57
  Provider code: 313
  Phone 776 2282
  From the USA or Canada you have to dial 011 57 313 776 2282 
http://www.soc.hawaii.edu/mora/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Averaging Out many rows from a column AND funtion to string

2013-03-27 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Alaios
 Sent: Wednesday, March 27, 2013 9:13 AM
 To: R help
 Subject: [R] Averaging Out many rows from a column AND funtion to
 string
 
 Dear all,
 1) I have a very large matrix of
 str(keep)
  num [1:153899, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ...
 that  I would like to reduce its size to something like
 
 str(keep)
  num [1:1000, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ... or anything
 similar in size as this is a matrix that needs plotting (so is ok if it
 is 1000 row, 995, or 1123)
 
 I think what I need here is a way of selecting multiple rows and
 averaging per column (notice that the column number should stay the
 same)

Make an index variable and aggregate values according it

Something like
idx-cut(1:153899, 153)
keep.ag-aggregate(keep, list(idx), mean)


 
 b. I would like to be able to convert strings that are function names
 to real function calls. For example I have something like
 
 LogFunction- function(){}
 FunctionIndex- rbind (c(1,LogFunction),
            c(2,TakeFunction)
           )
 print(sprintf('Using the function %s',FunctionIndex[1,1])) # call the
 FunctionIndex[1,1] somehow

I am not sure if I understand correctly. 

Is this what you want?
myf -function(fun=mean, arg) eval(call(fun, arg))

Regards
Petr

 
 
 
 I would like to thank you in advance for your help
 
 Regards
 Alex
 
   [[alternative HTML version deleted]]

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


Re: [R] Averaging Out many rows from a column AND funtion to string

2013-03-27 Thread Alaios
see inline




 From: PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 11:24 AM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Alaios
 Sent: Wednesday, March 27, 2013 9:13 AM
 To: R help
 Subject: [R] Averaging Out many rows from a column AND funtion to
 string
 
 Dear all,
 1) I have a very large matrix of
 str(keep)
  num [1:153899, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ...
 that  I would like to reduce its size to something like
 
 str(keep)
  num [1:1000, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ... or anything
 similar in size as this is a matrix that needs plotting (so is ok if it
 is 1000 row, 995, or 1123)
 
 I think what I need here is a way of selecting multiple rows and
 averaging per column (notice that the column number should stay the
 same)

Make an index variable and aggregate values according it

Something like
idx-cut(1:153899, 153)
keep.ag-aggregate(keep, list(idx), mean)

1) Thanks that returned a data frame.. How I can have a matrix at the end?
2) I want to have a string that can be used also for calling a function with 
the same name. Think of using mean to call mean. I need to have R interpret 
the string in different ways.

Regards
Alex

 
 b. I would like to be able to convert strings that are function names
 to real function calls. For example I have something like
 
 LogFunction- function(){}
 FunctionIndex- rbind (c(1,LogFunction),
            c(2,TakeFunction)
           )
 print(sprintf('Using the function %s',FunctionIndex[1,1])) # call the
 FunctionIndex[1,1] somehow

I am not sure if I understand correctly. 

Is this what you want?
myf -function(fun=mean, arg) eval(call(fun, arg))

Regards
Petr

 
 
 
 I would like to thank you in advance for your help
 
 Regards
 Alex
 
     [[alternative HTML version deleted]]
[[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] Newey West HAC for pooled cross-section data

2013-03-27 Thread Achim Zeileis

On Tue, 26 Mar 2013, SHISHIR MATHUR wrote:

Thanks for the reply Achim. The reason I suspect autocorrelation is 
because I think that  within the same neighborhood, homes sold a few 
months back are likely to impact the price of homes sold subsequently.


This may well be spatial (auto)correlation rather than temporal 
autocorrelation.


In fact the DW test and Breusch-Pagan test come out to be significant. 
So even though the data is not time series (that is, I do not have 
repeated observations for the same house),   however, the houses sold 
close in time to each other are in the data set.


If there is a unique ordering of all observations by time, then you could 
in principle apply an autocorrelation correction for the data, e.g., via 
Newey-West.


But from what you describe above, it seems to be more important to capture 
spatial effects in the data, e.g., by using a spatial lag model (see 
lagsarlm in spdep) or by using an additive spatial effect (see e.g. gam 
in mgcv).



Thanks,
Shish

On Tue, Mar 26, 2013 at 3:51 PM, Achim Zeileis achim.zeil...@uibk.ac.at
wrote:
  On Tue, 26 Mar 2013, SHISHIR MATHUR wrote:

Hello:
My dataset set contains several thousand rows of
data, with each row
containing information for a house. The variables
include the sale price of
the house, the quarter and year of sale, the
attributes of the house, and
the attributes of the neighborhood and the city in
which the house is
located. The data is for a 10-year period. No house
is repeated in the
dataset. In summary, the dataset can be termed
pooled cross-section data.

My question: Can I estimate Newey-West HAC standard
errors for a model that
estimates the effect of various independent
variables on the sale price of
the house?  My understanding is that Newey-West can
be used for time series
and panel data. However, I am not sure whether it
can be used for pooled
cross-section data.  If yes, can you refer me to a
specific source, such as
a paper or a book?


  The result of your aggregation is a cross-section data set.
  Thus, there should be no correlation between the different
  observations - or in other terms, the ordering of your
  observations is completely arbitrary.

  Consequently, there may be heteroskedasticity but not
  autocorrelation. So you may use HC standard errors but HAC
  should not be necessary. (Using HAC standard errors will still
  be consistent but less efficient.)


--
Best,
Shish

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




--
Best,
Shishir

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

2013-03-27 Thread Twaha Mlwilo

Baer,Thank you for help.huu

 Date: Mon, 25 Mar 2013 08:20:28 -0500
 From: rb...@atsu.edu
 To: petr.pi...@precheza.cz
 CC: uddessy2...@hotmail.com; r-h...@stat.math.ethz.ch
 Subject: Re: [R] Automatic script for updating packages in R
 
 try,
 update.packages(ask='graphics', checkBuilt=TRUE)
 ?update.packages
 ?download.file
 ?url  #  file:// URLs
 
 On 3/25/2013 6:09 AM, PIKAL Petr wrote:
  Hi
 
  Strange, I thought that only Windows users are sending Html mail and 
  providing sparse info describing their problems.
 
  I presume, you use 2.15.3 R version.
 
  There is some readme in Ubuntu CRAN repository and if you followed that and 
  fail it would be necessary to provide at least what you did (some code) and 
  what was the error messages.
 
  http://cran.r-project.org/bin/linux/ubuntu/README
 
  Regards
  Petr
 
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
  project.org] On Behalf Of Twaha Mlwilo
  Sent: Monday, March 25, 2013 11:21 AM
  To: r-h...@stat.math.ethz.ch
  Subject: [R] Automatic script for updating packages in R
 
 
  Hello all,Good day,Internet access have been a problem , and learning R
 
 
 
  forced to download packages manual.I  have google for script for
  automatic R update didnt getPlease any one with help?am using ubuntu
  12.04R-2.5.3Thank you
 [[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.
 
 
 -- 
 
 Robert W. Baer, Ph.D.
 Professor of Physiology
 Kirksille College of Osteopathic Medicine
 A. T. Still University of Health Sciences
 Kirksville, MO 63501 USA
 
  
[[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] Averaging Out many rows from a column AND funtion to string

2013-03-27 Thread PIKAL Petr
Hi

From: Alaios [mailto:ala...@yahoo.com]
Sent: Wednesday, March 27, 2013 11:46 AM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string

see inline


From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Alaios ala...@yahoo.commailto:ala...@yahoo.com; R help 
R-help@r-project.orgmailto:R-help@r-project.org
Sent: Wednesday, March 27, 2013 11:24 AM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
 [mailto:r-help-bounces@r-
 project.orghttp://project.org/] On Behalf Of Alaios
 Sent: Wednesday, March 27, 2013 9:13 AM
 To: R help
 Subject: [R] Averaging Out many rows from a column AND funtion to
 string

 Dear all,
 1) I have a very large matrix of
 str(keep)
  num [1:153899, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ...
 that  I would like to reduce its size to something like

 str(keep)
  num [1:1000, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ... or anything
 similar in size as this is a matrix that needs plotting (so is ok if it
 is 1000 row, 995, or 1123)

 I think what I need here is a way of selecting multiple rows and
 averaging per column (notice that the column number should stay the
 same)

Make an index variable and aggregate values according it

Something like
idx-cut(1:153899, 153)
keep.ag-aggregate(keep, list(idx), mean)

1) Thanks that returned a data frame.. How I can have a matrix at the end?

use as.matrix(data.frame) on numeric part
2) I want to have a string that can be used also for calling a function with 
the same name. Think of using mean to call mean. I need to have R interpret 
the string in different ways.

To call mean of what? I am sure I do not understand what is your intention.
LogFunction- function(){}
FunctionIndex- rbind (c(1,LogFunction),
   c(2,TakeFunction))
print(sprintf('Using the function %s',FunctionIndex[1,1]))
This does not contain much clue.
Regards
Petr
PS. Do not use HTML mail messages.
Regards
Alex


 b. I would like to be able to convert strings that are function names
 to real function calls. For example I have something like

 LogFunction- function(){}
 FunctionIndex- rbind (c(1,LogFunction),
c(2,TakeFunction)
   )
 print(sprintf('Using the function %s',FunctionIndex[1,1])) # call the
 FunctionIndex[1,1] somehow

I am not sure if I understand correctly.

Is this what you want?
myf -function(fun=mean, arg) eval(call(fun, arg))

Regards
Petr




 I would like to thank you in advance for your help

 Regards
 Alex

 [[alternative HTML version deleted]]



[[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] conditional Dataframe filling

2013-03-27 Thread arun


Hi,
You could try:
dat1- read.table(text=
a    b    c    d
TRUE  TRUE  TRUE  TRUE
FALSE FALSE FALSE TRUE
FALSE  TRUE  FALSE  FALSE
,sep=,header=TRUE)
dat2-dat1
 dat2[]-t(apply(1*!dat1,1,function(x) 
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum
 dat2
#  a b c d
#1 0 0 0 0
#2 1 2 3 0
#3 1 0 1 2
A.K.


- Original Message -
From: Camilo Mora cm...@dal.ca
To: r-help@r-project.org
Cc: 
Sent: Wednesday, March 27, 2013 4:31 AM
Subject: [R] conditional Dataframe filling

Hi everyone:

This may be trivial but I just have not been able to figure it out.

Imagine the following dataframe:
a     b     c     d
TRUE  TRUE  TRUE  TRUE
FALSE FALSE FALSE TRUE
FALSE  TRUE  FALSE  FALSE

I would like to create a new dataframe, in which TRUE gets 0 but if false then 
add 1 to the cell to the left. So the results for the example above should be 
something like:

a     b     c     d
0     0     0     0
1     2     3     0
1     0     1     2

I wonder if you may know?.

Thanks,

Camilo




Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
         Provider code: 313
         Phone 776 2282
         From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/

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

2013-03-27 Thread arun
HI,

Just a correction:

:

dat2[]-t(apply(!dat1,1,function(x) 
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum  #should also work
A.K.



- Original Message -
From: arun smartpink...@yahoo.com
To: Camilo Mora cm...@dal.ca
Cc: R help r-help@r-project.org
Sent: Wednesday, March 27, 2013 9:09 AM
Subject: Re: [R] conditional Dataframe filling



Hi,
You could try:
dat1- read.table(text=
a    b    c    d
TRUE  TRUE  TRUE  TRUE
FALSE FALSE FALSE TRUE
FALSE  TRUE  FALSE  FALSE
,sep=,header=TRUE)
dat2-dat1
 dat2[]-t(apply(1*!dat1,1,function(x) 
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum
 dat2
#  a b c d
#1 0 0 0 0
#2 1 2 3 0
#3 1 0 1 2
A.K.


- Original Message -
From: Camilo Mora cm...@dal.ca
To: r-help@r-project.org
Cc: 
Sent: Wednesday, March 27, 2013 4:31 AM
Subject: [R] conditional Dataframe filling

Hi everyone:

This may be trivial but I just have not been able to figure it out.

Imagine the following dataframe:
a     b     c     d
TRUE  TRUE  TRUE  TRUE
FALSE FALSE FALSE TRUE
FALSE  TRUE  FALSE  FALSE

I would like to create a new dataframe, in which TRUE gets 0 but if false then 
add 1 to the cell to the left. So the results for the example above should be 
something like:

a     b     c     d
0     0     0     0
1     2     3     0
1     0     1     2

I wonder if you may know?.

Thanks,

Camilo




Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
         Provider code: 313
         Phone 776 2282
         From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/

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

2013-03-27 Thread catalin roibu
Hello all!
I want to create animated chart of temperature variation in last century.
how can I do this with R?

Thank you!

-- 
---
Catalin-Constantin ROIBU
Forestry engineer, PhD
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
   +4 0766 71 76 58
FAX:+4 0230 52 16 64
silvic.usv.ro

[[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 do I show real values on a log10 histogram

2013-03-27 Thread Martin Maechler
 Shane Carey careys...@gmail.com
 on Tue, 26 Mar 2013 11:03:20 + writes:

 Yup, Ive tried all these things and I think Johns might be
 the best approach,

well, :-) 
you have not yet seen the following one :

if(!require(sfsmisc)) install.packages(sfsmisc)
require(sfsmisc)

## the data:
   set.seed(1); summary(x - rlnorm(100, m = 2, sdl = 3))
## the plot (w/o  x-axis) :
   r - hist(log10(x), xaxt = n, xlab = x [log scale])
## the nice axis:
   axt - axTicks(1)
   eaxis(1, at = axt, labels = pretty10exp(10^axt, drop.1=TRUE))


Martin Maechler,
ETH Zurich


 thanks

 On Tue, Mar 26, 2013 at 11:01 AM, PIKAL Petr
 petr.pi...@precheza.cz wrote:

 Hi
 
 maybe axis(3, (x)^10)
 
 Regards Petr
 
  -Original Message-  From:
 r-help-boun...@r-project.org [mailto:r-help-bounces@r- 
 project.org] On Behalf Of Shane Carey  Sent: Tuesday,
 March 26, 2013 11:19 AM  To: r-help@r-project.org 
 Subject: [R] How do I show real values on a log10
 histogram
 
  Hi,
 
  I have a histogram with values logged to the base 10
 
  hist(log10(x),breaks=60)
 
  How do I show the log values on the x-axis and a second
 x-axis showing  the real values?
 
  Thanks
 
  --
  Shane
 
  [[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.
 



 -- 
 Shane

   [[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] Averaging Out many rows from a column AND funtion to string

2013-03-27 Thread Alaios
see inline





 From: PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 1:50 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string



Hi
 

Sent: Wednesday, March 27, 2013 11:46 AM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string
 
see inline
 



From:PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 11:24 AM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Alaios
 Sent: Wednesday, March 27, 2013 9:13 AM
 To: R help
 Subject: [R] Averaging Out many rows from a column AND funtion to
 string
 
 Dear all,
 1) I have a very large matrix of
 str(keep)
  num [1:153899, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ...
 that  I would like to reduce its size to something like
 
 str(keep)
  num [1:1000, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ... or anything
 similar in size as this is a matrix that needs plotting (so is ok if it
 is 1000 row, 995, or 1123)
 
 I think what I need here is a way of selecting multiple rows and
 averaging per column (notice that the column number should stay the
 same)

Make an index variable and aggregate values according it

Something like
idx-cut(1:153899, 153)
keep.ag-aggregate(keep, list(idx), mean)

1) Thanks that returned a data frame.. How I can have a matrix at the end?


use as.matrix(data.frame) on numeric part

a bit of my code that you can re run. I convert a 30,30 matrix to a 10,30.  
but it looks at the end that I do not get the Data part of the data.fram 
correctly: 

Data-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
idx-cut(1:30, 10)
keep.ag-aggregate(Data, list(idx), mean)
str(as.matrix(keep.ag) ) # it does not look like integers









2) I want to have a string that can be used also for calling a function with 
the same name. Think of using mean to call mean. I need to have R interpret 
the string in different ways.


To call „mean“ of what? I am sure I do not understand what is your 
intention.
LogFunction- function(){}
FunctionIndex- rbind (c(1,LogFunction),
               c(2,TakeFunction))
print(sprintf('Using the function %s',FunctionIndex[1,1]))
This does not contain much clue.
Regards
Petr
PS. Do not use HTML mail messages. 
Regards
Alex

 
 b. I would like to be able to convert strings that are function names
 to real function calls. For example I have something like
 
 LogFunction- function(){}
 FunctionIndex- rbind (c(1,LogFunction),
                c(2,TakeFunction)
               )
 print(sprintf('Using the function %s',FunctionIndex[1,1])) # call the
 FunctionIndex[1,1] somehow

I am not sure if I understand correctly. 

Is this what you want?
myf -function(fun=mean, arg) eval(call(fun, arg))

Regards
Petr

 
 
 
 I would like to thank you in advance for your help
 
 Regards
 Alex
 
     [[alternative HTML version deleted]]
[[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 do I show real values on a log10 histogram

2013-03-27 Thread John Kane
Well, I don't think that is what Shane wants either but my suggestion is 
clearly wrong.  I was reading the question as a dual axis not just a 
suplimentary , equivalent value axis.  DUH.

What I think he wants is what IIRC  Petr orginally suggested which is this..
 Create the data to be graphed
x-1:5
y1-x
y2-x^2

# Set the par values
   # op  - par(las=1,xaxs=r,mai=c(1,1,1,1))

# Draw the  plot
plot(x,y1,xlim=c(0,5),ylim=c(0,5), ylab=y1, las = 1)
title(main=Equvalent Axes in R)
axis(3, labels = c(10, 100, 1,000, 10,000, 100,000), at=1:5)
text(12, 50, y2, srt = 270, xpd = TRUE)
par(op)  # reset par 



John Kane
Kingston ON Canada


 -Original Message-
 From: maech...@stat.math.ethz.ch
 Sent: Wed, 27 Mar 2013 14:37:58 +0100
 To: careys...@gmail.com
 Subject: Re: [R] How do I show real values on a log10 histogram
 
 Shane Carey careys...@gmail.com
 on Tue, 26 Mar 2013 11:03:20 + writes:
 
  Yup, Ive tried all these things and I think Johns might be
  the best approach,
 
 well, :-)
 you have not yet seen the following one :
 
 if(!require(sfsmisc)) install.packages(sfsmisc)
 require(sfsmisc)
 
 ## the data:
set.seed(1); summary(x - rlnorm(100, m = 2, sdl = 3))
 ## the plot (w/o  x-axis) :
r - hist(log10(x), xaxt = n, xlab = x [log scale])
 ## the nice axis:
axt - axTicks(1)
eaxis(1, at = axt, labels = pretty10exp(10^axt, drop.1=TRUE))
 
 
 Martin Maechler,
 ETH Zurich
 
 
  thanks
 
  On Tue, Mar 26, 2013 at 11:01 AM, PIKAL Petr
  petr.pi...@precheza.cz wrote:
 
  Hi
 
  maybe axis(3, (x)^10)
 
  Regards Petr
 
   -Original Message-  From:
  r-help-boun...@r-project.org [mailto:r-help-bounces@r- 
  project.org] On Behalf Of Shane Carey  Sent: Tuesday,
  March 26, 2013 11:19 AM  To: r-help@r-project.org 
  Subject: [R] How do I show real values on a log10
  histogram
  
   Hi,
  
   I have a histogram with values logged to the base 10
  
   hist(log10(x),breaks=60)
  
   How do I show the log values on the x-axis and a second
  x-axis showing  the real values?
  
   Thanks
  
   --
   Shane
  
   [[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.
 
 
 
 
  --
  Shane
 
  [[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.


Receive Notifications of Incoming Messages
Easily monitor multiple email accounts  access them with a click.
Visit http://www.inbox.com/notifier and check it 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] animated charts

2013-03-27 Thread Shane Carey
maybe try the shiny examples that use googleviz. Have a look at the
following link:
https://code.google.com/p/google-motion-charts-with-r/

I would be interested to know what you decide.

Thanks
On Wed, Mar 27, 2013 at 1:20 PM, catalin roibu catalinro...@gmail.comwrote:

 Hello all!
 I want to create animated chart of temperature variation in last century.
 how can I do this with R?

 Thank you!

 --
 ---
 Catalin-Constantin ROIBU
 Forestry engineer, PhD
 Forestry Faculty of Suceava
 Str. Universitatii no. 13, Suceava, 720229, Romania
 office phone +4 0230 52 29 78, ext. 531
 mobile phone   +4 0745 53 18 01
+4 0766 71 76 58
 FAX:+4 0230 52 16 64
 silvic.usv.ro

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




-- 
Shane

[[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 do I show real values on a log10 histogram

2013-03-27 Thread Shane Carey
Yes, what I wanted was the original suggestion and that is what I went
with. John, I found a solution around par also. There is a function called
split.screen that allows you split the screen up, and also use par at the
same time.

Thanks everyone for all your help.

Cheers

On Wed, Mar 27, 2013 at 2:02 PM, John Kane jrkrid...@inbox.com wrote:

 Well, I don't think that is what Shane wants either but my suggestion is
 clearly wrong.  I was reading the question as a dual axis not just a
 suplimentary , equivalent value axis.  DUH.

 What I think he wants is what IIRC  Petr orginally suggested which is
 this..
  Create the data to be graphed
 x-1:5
 y1-x
 y2-x^2

 # Set the par values
# op  - par(las=1,xaxs=r,mai=c(1,1,1,1))

 # Draw the  plot
 plot(x,y1,xlim=c(0,5),ylim=c(0,5), ylab=y1, las = 1)
 title(main=Equvalent Axes in R)
 axis(3, labels = c(10, 100, 1,000, 10,000, 100,000),
 at=1:5)
 text(12, 50, y2, srt = 270, xpd = TRUE)
 par(op)  # reset par



 John Kane
 Kingston ON Canada


  -Original Message-
  From: maech...@stat.math.ethz.ch
  Sent: Wed, 27 Mar 2013 14:37:58 +0100
  To: careys...@gmail.com
  Subject: Re: [R] How do I show real values on a log10 histogram
 
  Shane Carey careys...@gmail.com
  on Tue, 26 Mar 2013 11:03:20 + writes:
 
   Yup, Ive tried all these things and I think Johns might be
   the best approach,
 
  well, :-)
  you have not yet seen the following one :
 
  if(!require(sfsmisc)) install.packages(sfsmisc)
  require(sfsmisc)
 
  ## the data:
 set.seed(1); summary(x - rlnorm(100, m = 2, sdl = 3))
  ## the plot (w/o  x-axis) :
 r - hist(log10(x), xaxt = n, xlab = x [log scale])
  ## the nice axis:
 axt - axTicks(1)
 eaxis(1, at = axt, labels = pretty10exp(10^axt, drop.1=TRUE))
 
 
  Martin Maechler,
  ETH Zurich
 
 
   thanks
 
   On Tue, Mar 26, 2013 at 11:01 AM, PIKAL Petr
   petr.pi...@precheza.cz wrote:
 
   Hi
  
   maybe axis(3, (x)^10)
  
   Regards Petr
  
-Original Message-  From:
   r-help-boun...@r-project.org [mailto:r-help-bounces@r- 
   project.org] On Behalf Of Shane Carey  Sent: Tuesday,
   March 26, 2013 11:19 AM  To: r-help@r-project.org 
   Subject: [R] How do I show real values on a log10
   histogram
   
Hi,
   
I have a histogram with values logged to the base 10
   
hist(log10(x),breaks=60)
   
How do I show the log values on the x-axis and a second
   x-axis showing  the real values?
   
Thanks
   
--
Shane
   
[[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.
  
 
 
 
   --
   Shane
 
   [[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.

 
 Receive Notifications of Incoming Messages
 Easily monitor multiple email accounts  access them with a click.
 Visit http://www.inbox.com/notifier and check it out!





-- 
Shane

[[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] Odd graphic device behavior

2013-03-27 Thread John Kane
Any chance that you made an earlier call to par() resetting cex in your 
session?  I just had that happen.

John Kane
Kingston ON Canada


 -Original Message-
 From: tea...@gmail.com
 Sent: Tue, 26 Mar 2013 10:15:33 -0400
 To: r-help@r-project.org
 Subject: [R] Odd graphic device behavior
 
 I'm experiencing odd graphics device behavior running R 2.15.3 on Ubuntu.
 Regardless of what I try like:
 
 require(stats)
 plot(cars)
 lines(lowess(cars))
 plot(sin, -pi, 2*pi)
 
 for example, the graphics device fills the entire screen with the graphic
 and a very large font. When I shrink the graphics device window, the
 lettering remains large and the line thicknesses stay quite thick. It may
 have been some time since I have done any R work on my Ubuntu computer,
 but
 clearly this did not happen previously.
 
 Does anyone have any thoughts?
 
 Thank you,
 Tom
 
   [[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.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
desktop!

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


Re: [R] How do I show real values on a log10 histogram

2013-03-27 Thread John Kane

Glad it worked.  Sorry to mislead you so badly.

   John Kane
   Kingston ON Canada

   -Original Message-
   From: careys...@gmail.com
   Sent: Wed, 27 Mar 2013 14:09:58 +
   To: jrkrid...@inbox.com
   Subject: Re: [R] How do I show real values on a log10 histogram

   Yes, what I wanted was the original suggestion and that is what I went with.
   John,  I  found a solution around par also. There is a function called
   split.screen that allows you split the screen up, and also use par at the
   same time.
   Thanks everyone for all your help.
   Cheers
   On Wed, Mar 27, 2013 at 2:02 PM, John Kane [1]jrkrid...@inbox.com wrote:

 Well, I don't think that is what Shane wants either but my suggestion is
 clearly wrong.  I was reading the question as a dual axis not just a
 suplimentary , equivalent value axis.  DUH.
 What I think he wants is what IIRC  Petr orginally suggested which is
 this..

Create the data to be graphed

 x-1:5

   y1-x
   y2-x^2
   # Set the par values

# op  - par(las=1,xaxs=r,mai=c(1,1,1,1))
 # Draw the  plot
 plot(x,y1,xlim=c(0,5),ylim=c(0,5), ylab=y1, las = 1)
 title(main=Equvalent Axes in R)
 axis(3, labels = c(10, 100, 1,000, 10,000, 100,000),
 at=1:5)

   text(12, 50, y2, srt = 270, xpd = TRUE)
   par(op)  # reset par
   John Kane
   Kingston ON Canada
-Original Message-

From: [2]maech...@stat.math.ethz.ch
Sent: Wed, 27 Mar 2013 14:37:58 +0100
To: [3]careys...@gmail.com
Subject: Re: [R] How do I show real values on a log10 histogram
   
Shane Carey [4]careys...@gmail.com
on Tue, 26 Mar 2013 11:03:20 + writes:
   
 Yup, Ive tried all these things and I think Johns might be
 the best approach,
   
well, :-)
you have not yet seen the following one :
   
if(!require(sfsmisc)) install.packages(sfsmisc)
require(sfsmisc)
   
## the data:
   set.seed(1); summary(x - rlnorm(100, m = 2, sdl = 3))
## the plot (w/o  x-axis) :
   r - hist(log10(x), xaxt = n, xlab = x [log scale])
## the nice axis:
   axt - axTicks(1)
   eaxis(1, at = axt, labels = pretty10exp(10^axt, drop.1=TRUE))
   
   
Martin Maechler,
ETH Zurich
   
   
 thanks
   
 On Tue, Mar 26, 2013 at 11:01 AM, PIKAL Petr
 [5]petr.pi...@precheza.cz wrote:
   
 Hi

 maybe axis(3, (x)^10)

 Regards Petr

  -Original Message-  From:
 [6]r-help-boun...@r-project.org [mailto:[7]r-help-bounces@r- 
 [8]project.org] On Behalf Of Shane Carey  Sent: Tuesday,
 March 26, 2013 11:19 AM  To: [9]r-help@r-project.org 
 Subject: [R] How do I show real values on a log10
 histogram
 
  Hi,
 
  I have a histogram with values logged to the base 10
 
  hist(log10(x),breaks=60)
 
  How do I show the log values on the x-axis and a second
 x-axis showing  the real values?
 
  Thanks
 
  --
  Shane
 
  [[alternative HTML version deleted]]
 
  __ 
 [10]R-help@r-project.org mailing list 
 [11]https://stat.ethz.ch/mailman/listinfo/r-help  PLEASE do
 read the posting guide [12]http://www.R-project.org/posting-
  guide.html  and provide commented, minimal,
 self-contained, reproducible code.

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

 
 Receive Notifications of Incoming Messages
 Easily monitor multiple email accounts  access them with a click.
 Visit [19]http://www.inbox.com/notifier and check it out!

   --
   Shane
 _

   [20]3D Earth Screensaver Preview 
   Free 3D Earth Screensaver
   Watch   the   Earth   right   on   your   desktop!  Check  it  out  at
   [21]www.inbox.com/earth

References

   1. mailto:jrkrid...@inbox.com
   2. mailto:maech...@stat.math.ethz.ch
   3. mailto:careys...@gmail.com
   

Re: [R] animated charts

2013-03-27 Thread Andrius Druzinis
Dear Catalin,

If you have an R function that plots a fragment of your data and takes the
specific fragment selection as parameter, you can readily turn this into a
Shiny app. The slider control (see example in
http://rstudio.github.com/shiny/tutorial/#sliders) in Shiny can be animated
(you can have a play button) which seems to be just what you need.

Kind regards,

Andrius


2013/3/27 catalin roibu catalinro...@gmail.com

 Hello all!
 I want to create animated chart of temperature variation in last century.
 how can I do this with R?

 Thank you!

 --
 ---
 Catalin-Constantin ROIBU
 Forestry engineer, PhD
 Forestry Faculty of Suceava
 Str. Universitatii no. 13, Suceava, 720229, Romania
 office phone +4 0230 52 29 78, ext. 531
 mobile phone   +4 0745 53 18 01
+4 0766 71 76 58
 FAX:+4 0230 52 16 64
 silvic.usv.ro

 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] FMOLS DOLS and ADL regression

2013-03-27 Thread Chien-Ho Wang
Whether can any R package run Full modified OLS (Phillips and Hansen 1990 ), 
DOLS (Stock and Watson 1993) and ADL model (Pesaran and Shin 2001) for 
cointegrated VAR model?

I cannot find any useful order in VAR and SVAR package.

Thanks.

Eric Wang 

[[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] Crrstep help

2013-03-27 Thread Kathy Han
Hi,

I'm using crrstep package to do stepwise covariate selection for the Fine 
Gray competing risks regression model. However, I keep getting an error
(please see below). Please help!!

 PHstep -
crrstep(years~1+var1+var2+var3+var4+var5,scope.min=~1,censorcmprsk,
data=crisk, direction=c(forward), crr.object = FALSE, trace = TRUE, steps
= 100)

crrstep(formula = years ~ 1 + var1+var2+var3+var4+var5, scope.min = ~1,
etype = censorcmprsk, data = crisk, direction = c(forward),
crr.object = FALSE, trace = TRUE, steps = 100)
*Error in crr(ftime, fstatus, cov1, variance = TRUE, ...) :
  unused argument(s) (variance = TRUE)*

Thank you very much!

[[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] Distance calculation

2013-03-27 Thread arun
HI,
Try this:


dat1- read.csv(DQP.csv,sep=\t)
res- do.call(cbind,lapply(seq_len(nrow(dat1)),function(i) 
do.call(rbind,lapply(split(rbind(dat1[i,],dat1[-i,]),1:nrow(rbind(dat1[i,],dat1[-i,]))),
 function(x) {x1-rbind(dat1[i,],x);colnames(x1)-gsub([.],,colnames(x1));
 if({indx- colSums(x1[,2:3]==0);indx[1]==0  indx[2]==1 }) #2 peaks 1 peak 
comparison
{x2- x1[order(x1$Peak2t,x1$Npeak2t),];
with(x2,{abs((Peak1v[1]-Peak1v[2])*(Peak1t[1]-Peak1t[2]))+abs((Peak1v[1]-Peak2v[2])*((Peak1t[1]+12)-Peak2t[2]))+
 
abs((Npeak1v[1]-Npeak1v[2])*(Npeak1t[1]-Npeak1t[2]))+abs((Npeak1v[1]-Npeak2v[2])*((Npeak1t[1]+12)-Npeak2t[2]))
 })
}
else #cases where peaks are similar 
{with(x1,{abs((Peak1v[1]-Peak1v[2])*(Peak1t[1]-Peak1t[2]))+abs((Peak2v[1]-Peak2v[2])*(Peak2t[1]-Peak2t[2]))
 + 
abs((Npeak1v[1]-Npeak1v[2])*(Npeak1t[1]-Npeak1t[2]))+abs((Npeak2v[1]-Npeak2v[2])*(Npeak2t[1]-Npeak2t[2]))})
}

}

res2-do.call(cbind,lapply(seq_len(ncol(res)),function(i) 
c(c(tail(res[seq(1,i,1),i],-1),0),res[-c(1:i),i])))
row.names(res2)-1:nrow(res2)

 dim(res2)
#[1] 124 124
 res2[1:5,1:5]
#    [,1]   [,2]  [,3]  [,4]   [,5]
#1  0.000  1.512 7.031 3.662 13.030
#2  1.512  0.000 7.109 4.880 18.731
#3  7.031  7.109 0.000 0.056  1.280
#4  3.662  4.880 0.056 0.000  0.584
#5 13.030 18.731 1.280 0.584  0.000


A.K.




From: eliza botto eliza_bo...@hotmail.com
To: smartpink...@yahoo.com smartpink...@yahoo.com 
Sent: Wednesday, March 27, 2013 8:58 AM
Subject: RE: Distance calculation



Dear Arun,
I would like to ask a small question.
In the distance calculation procedure, if there are only 2 peaks and 1 peaks 
stations and there are no 3 and 4 peaks stations, like the file i attached. How 
to modify the script below to eliminate 3 peaks and 4 peaks scripts??
I hope you mind my hasty questioning
Thanks in advance
Elisa

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Averaging Out many rows from a column AND funtion to string

2013-03-27 Thread PIKAL Petr
Hi

 str(as.matrix(keep.ag[,-1]) )  # does look like numeric
num [1:10, 1:30] 75.1 93 79 81.7 76.3 ...
- attr(*, dimnames)=List of 2
  ..$ : NULL
  ..$ : chr [1:30] V1 V2 V3 V4 ...

Please read and follow what was recommended.

quote

use as.matrix(data.frame) on numeric part
  ^^^

aggregate produces data frame with its first column being your idx variable, 
which is factor. Trying to convert it whole to matrix results in character 
matrix. You need to exclude first column from conversion

And please can you explain how mean(rnorm(whatever)) shall be integer?

Regards
Petr

From: Alaios [mailto:ala...@yahoo.com]
Sent: Wednesday, March 27, 2013 3:01 PM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string

see inline



From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Alaios ala...@yahoo.commailto:ala...@yahoo.com; R help 
R-help@r-project.orgmailto:R-help@r-project.org
Sent: Wednesday, March 27, 2013 1:50 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string


Hi

From: Alaios [mailto:ala...@yahoo.com]
Sent: Wednesday, March 27, 2013 11:46 AM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string

see inline


From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Alaios ala...@yahoo.commailto:ala...@yahoo.com; R help 
R-help@r-project.orgmailto:R-help@r-project.org
Sent: Wednesday, March 27, 2013 11:24 AM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
 [mailto:r-help-bounces@r-
 project.orghttp://project.org/] On Behalf Of Alaios
 Sent: Wednesday, March 27, 2013 9:13 AM
 To: R help
 Subject: [R] Averaging Out many rows from a column AND funtion to
 string

 Dear all,
 1) I have a very large matrix of
 str(keep)
  num [1:153899, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ...
 that  I would like to reduce its size to something like

 str(keep)
  num [1:1000, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ... or anything
 similar in size as this is a matrix that needs plotting (so is ok if it
 is 1000 row, 995, or 1123)

 I think what I need here is a way of selecting multiple rows and
 averaging per column (notice that the column number should stay the
 same)

Make an index variable and aggregate values according it

Something like
idx-cut(1:153899, 153)
keep.ag-aggregate(keep, list(idx), mean)

1) Thanks that returned a data frame.. How I can have a matrix at the end?
use as.matrix(data.frame) on numeric part

a bit of my code that you can re run. I convert a 30,30 matrix to a 10,30.  but 
it looks at the end that I do not get the Data part of the data.fram correctly:
Data-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
idx-cut(1:30, 10)
keep.ag-aggregate(Data, list(idx), mean)
str(as.matrix(keep.ag) ) # it does not look like integers







2) I want to have a string that can be used also for calling a function with 
the same name. Think of using mean to call mean. I need to have R interpret 
the string in different ways.
To call „mean“ of what? I am sure I do not understand what is your 
intention.
LogFunction- function(){}
FunctionIndex- rbind (c(1,LogFunction),
   c(2,TakeFunction))
print(sprintf('Using the function %s',FunctionIndex[1,1]))
This does not contain much clue.
Regards
Petr
PS. Do not use HTML mail messages.
Regards
Alex


 b. I would like to be able to convert strings that are function names
 to real function calls. For example I have something like

 LogFunction- function(){}
 FunctionIndex- rbind (c(1,LogFunction),
c(2,TakeFunction)
   )
 print(sprintf('Using the function %s',FunctionIndex[1,1])) # call the
 FunctionIndex[1,1] somehow

I am not sure if I understand correctly.

Is this what you want?
myf -function(fun=mean, arg) eval(call(fun, arg))

Regards
Petr




 I would like to thank you in advance for your help

 Regards
 Alex

 [[alternative HTML version deleted]]



[[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] Averaging Out many rows from a column AND funtion to string

2013-03-27 Thread Alaios
I have fixed it like that:


keep-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
ShrinkTo-500
idx-cut(1:nrow(keep), ShrinkTo)
keep.ag-aggregate(keep, list(idx), mean)
PlotMe-data.matrix(keep.ag[2:ShrinkTo])

The only problem is that takes ages to finish. Would it be possible to 
convert it to something like lapply?

Regards
Alex





 From: PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 4:02 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string



Hi
 
 str(as.matrix(keep.ag[,-1]) )  # does look like numeric
num [1:10, 1:30] 75.1 93 79 81.7 76.3 ...
- attr(*, dimnames)=List of 2
  ..$ : NULL
  ..$ : chr [1:30] V1 V2 V3 V4 ...
 
Please read and follow what was recommended.
 
quote
 
use as.matrix(data.frame) on numeric part
                                        
                  ^^^
 
aggregate produces data frame with its first column being your idx variable, 
which is factor. Trying to convert it whole to matrix results in character 
matrix. You need to exclude first column from conversion
 
And please can you explain how mean(rnorm(whatever)) shall be integer?
 
Regards
Petr
 

Sent: Wednesday, March 27, 2013 3:01 PM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string
 
see inline
 
 



From:PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 1:50 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string


Hi
 

Sent: Wednesday, March 27, 2013 11:46 AM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string
 
see inline
 



From:PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 11:24 AM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Alaios
 Sent: Wednesday, March 27, 2013 9:13 AM
 To: R help
 Subject: [R] Averaging Out many rows from a column AND funtion to
 string
 
 Dear all,
 1) I have a very large matrix of
 str(keep)
  num [1:153899, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ...
 that  I would like to reduce its size to something like
 
 str(keep)
  num [1:1000, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ... or anything
 similar in size as this is a matrix that needs plotting (so is ok if it
 is 1000 row, 995, or 1123)
 
 I think what I need here is a way of selecting multiple rows and
 averaging per column (notice that the column number should stay the
 same)

Make an index variable and aggregate values according it

Something like
idx-cut(1:153899, 153)
keep.ag-aggregate(keep, list(idx), mean)

1) Thanks that returned a data frame.. How I can have a matrix at the end?
use as.matrix(data.frame) on numeric part
 
a bit of my code that you can re run. I convert a 30,30 matrix to a 10,30.  
but it looks at the end that I do not get the Data part of the data.fram 
correctly: 
Data-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
idx-cut(1:30, 10)
keep.ag-aggregate(Data, list(idx), mean)
str(as.matrix(keep.ag) ) # it does not look like integers
 
 
 
 
 
 
 
2) I want to have a string that can be used also for calling a function with 
the same name. Think of using mean to call mean. I need to have R interpret 
the string in different ways.
To call „mean“ of what? I am sure I do not understand what is your 
intention.
LogFunction- function(){}
FunctionIndex- rbind (c(1,LogFunction),
               c(2,TakeFunction))
print(sprintf('Using the function %s',FunctionIndex[1,1]))
This does not contain much clue.
Regards
Petr
PS. Do not use HTML mail messages. 
Regards
Alex

 
 b. I would like to be able to convert strings that are function names
 to real function calls. For example I have something like
 
 LogFunction- function(){}
 FunctionIndex- rbind (c(1,LogFunction),
                c(2,TakeFunction)
               )
 print(sprintf('Using the function %s',FunctionIndex[1,1])) # call the
 FunctionIndex[1,1] somehow

I am not sure if I understand correctly. 

Is this what you want?
myf -function(fun=mean, arg) eval(call(fun, arg))

Regards
Petr

 
 
 
 I would like to thank you in advance for your help
 
 Regards
 Alex
 
     [[alternative HTML version deleted]]
[[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] Controlling Raster plots

2013-03-27 Thread Alaios
Hi,
I have a few raster layers and I would like to customized their x and y axis.

I have tried already something like:


require('raster')
keep-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
xlab-seq(100e6,200e6,length.out=5)
test-raster(keep)
plot(test,ylab=,xaxt=n,yaxt=n)
axis(1, at=seq(0,1,length.out=5), xlab)

that normally would work in any other plot function.

Could you please help me add the xaxis ?

I would like to thank you in advance for your reply

Regards
Alex

[[alternative HTML version deleted]]

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


Re: [R] Averaging Out many rows from a column AND funtion to string

2013-03-27 Thread PIKAL Petr
Hi

 system.time({
+ keep-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
+ ShrinkTo-500
+ idx-cut(1:nrow(keep), ShrinkTo)
+ keep.ag-aggregate(keep, list(idx), mean)
+ PlotMe-as.matrix(keep.ag[,-1])
+ })
   user  system elapsed
  29.230.14   29.37


It takes 30 seconds when using 30 rows. It is not enough time to get a cup 
of tee, which I do not consider ages. Maybe split lapply approach or 
data.matrix or  **ply could be quicker but I do not consider worth spending 
hours to elaborate some solution which will spare 20 sec computing time.

Regards
Petr

From: Alaios [mailto:ala...@yahoo.com]
Sent: Wednesday, March 27, 2013 4:12 PM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string

I have fixed it like that:


keep-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
ShrinkTo-500
idx-cut(1:nrow(keep), ShrinkTo)
keep.ag-aggregate(keep, list(idx), mean)
PlotMe-data.matrix(keep.ag[2:ShrinkTo])

The only problem is that takes ages to finish. Would it be possible to 
convert it to something like lapply?

Regards
Alex



From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Alaios ala...@yahoo.commailto:ala...@yahoo.com; R help 
R-help@r-project.orgmailto:R-help@r-project.org
Sent: Wednesday, March 27, 2013 4:02 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string


Hi

 str(as.matrix(keep.aghttp://keep.ag/[,-1]) )  # does look like numeric
num [1:10, 1:30] 75.1 93 79 81.7 76.3 ...
- attr(*, dimnames)=List of 2
  ..$ : NULL
  ..$ : chr [1:30] V1 V2 V3 V4 ...

Please read and follow what was recommended.

quote

use as.matrix(data.frame) on numeric part
  ^^^

aggregate produces data frame with its first column being your idx variable, 
which is factor. Trying to convert it whole to matrix results in character 
matrix. You need to exclude first column from conversion

And please can you explain how mean(rnorm(whatever)) shall be integer?

Regards
Petr

From: Alaios [mailto:ala...@yahoo.com]
Sent: Wednesday, March 27, 2013 3:01 PM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string

see inline



From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Alaios ala...@yahoo.commailto:ala...@yahoo.com; R help 
R-help@r-project.orgmailto:R-help@r-project.org
Sent: Wednesday, March 27, 2013 1:50 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

From: Alaios [mailto:ala...@yahoo.com]
Sent: Wednesday, March 27, 2013 11:46 AM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string

see inline


From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Alaios ala...@yahoo.commailto:ala...@yahoo.com; R help 
R-help@r-project.orgmailto:R-help@r-project.org
Sent: Wednesday, March 27, 2013 11:24 AM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
 [mailto:r-help-bounces@r-
 project.orghttp://project.org/] On Behalf Of Alaios
 Sent: Wednesday, March 27, 2013 9:13 AM
 To: R help
 Subject: [R] Averaging Out many rows from a column AND funtion to
 string

 Dear all,
 1) I have a very large matrix of
 str(keep)
  num [1:153899, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ...
 that  I would like to reduce its size to something like

 str(keep)
  num [1:1000, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ... or anything
 similar in size as this is a matrix that needs plotting (so is ok if it
 is 1000 row, 995, or 1123)

 I think what I need here is a way of selecting multiple rows and
 averaging per column (notice that the column number should stay the
 same)

Make an index variable and aggregate values according it

Something like
idx-cut(1:153899, 153)
keep.ag-aggregate(keep, list(idx), mean)

1) Thanks that returned a data frame.. How I can have a matrix at the end?
use as.matrix(data.frame) on numeric part

a bit of my code that you can re run. I convert a 30,30 matrix to a 10,30.  but 
it looks at the end that I do not get the Data part of the data.fram correctly:
Data-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
idx-cut(1:30, 10)
keep.ag-aggregate(Data, list(idx), mean)
str(as.matrix(keep.ag) ) # it does not look like integers







2) I want to have a string that can be used also for calling a function with 
the same name. Think of using mean to call mean. I need to have R interpret 
the string in different ways.
To call „mean“ of what? I am sure I do not understand what is your 
intention.
LogFunction- function(){}
FunctionIndex- rbind (c(1,LogFunction),
   c(2,TakeFunction))
print(sprintf('Using the function %s',FunctionIndex[1,1]))
This does not contain much clue.
Regards

Re: [R] Averaging Out many rows from a column AND funtion to string

2013-03-27 Thread Alaios
Well my true matrix is 

of


num [1:153899, 1:3415]

that I want to convert to something like

num [1:1000, 1:3415] (keeping column number the same).

I only give subsets here to allow others to run the code at their computer

Thanks a lot

Regards
Alex




 From: PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 4:45 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string



Hi
 
 system.time({
+ keep-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
+ ShrinkTo-500
+ idx-cut(1:nrow(keep), ShrinkTo)
+ keep.ag-aggregate(keep, list(idx), mean)
+ PlotMe-as.matrix(keep.ag[,-1])
+ })
   user  system elapsed 
  29.23    0.14   29.37 
  
 
It takes 30 seconds when using 30 rows. It is not enough time to get a cup 
of tee, which I do not consider ages. Maybe split lapply approach or 
data.matrix or  **ply could be quicker but I do not consider worth spending 
hours to elaborate some solution which will spare 20 sec computing time.
 
Regards
Petr 
 

Sent: Wednesday, March 27, 2013 4:12 PM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string
 
I have fixed it like that:


keep-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
ShrinkTo-500
idx-cut(1:nrow(keep), ShrinkTo)
keep.ag-aggregate(keep, list(idx), mean)
PlotMe-data.matrix(keep.ag[2:ShrinkTo])

The only problem is that takes ages to finish. Would it be possible to 
convert it to something like lapply?

Regards
Alex
 
 



From:PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 4:02 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string


Hi
 
 str(as.matrix(keep.ag[,-1]) )  # does look like numeric
num [1:10, 1:30] 75.1 93 79 81.7 76.3 ...
- attr(*, dimnames)=List of 2
  ..$ : NULL
  ..$ : chr [1:30] V1 V2 V3 V4 ...
 
Please read and follow what was recommended.
 
quote
 
use as.matrix(data.frame) on numeric part
                                        
                  ^^^
 
aggregate produces data frame with its first column being your idx variable, 
which is factor. Trying to convert it whole to matrix results in character 
matrix. You need to exclude first column from conversion
 
And please can you explain how mean(rnorm(whatever)) shall be integer?
 
Regards
Petr
 

Sent: Wednesday, March 27, 2013 3:01 PM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string
 
see inline
 
 



From:PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 1:50 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string
 
Hi
 

Sent: Wednesday, March 27, 2013 11:46 AM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string
 
see inline
 



From:PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 11:24 AM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Alaios
 Sent: Wednesday, March 27, 2013 9:13 AM
 To: R help
 Subject: [R] Averaging Out many rows from a column AND funtion to
 string
 
 Dear all,
 1) I have a very large matrix of
 str(keep)
  num [1:153899, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ...
 that  I would like to reduce its size to something like
 
 str(keep)
  num [1:1000, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ... or anything
 similar in size as this is a matrix that needs plotting (so is ok if it
 is 1000 row, 995, or 1123)
 
 I think what I need here is a way of selecting multiple rows and
 averaging per column (notice that the column number should stay the
 same)

Make an index variable and aggregate values according it

Something like
idx-cut(1:153899, 153)
keep.ag-aggregate(keep, list(idx), mean)

1) Thanks that returned a data frame.. How I can have a matrix at the end?
use as.matrix(data.frame) on numeric part
 
a bit of my code that you can re run. I convert a 30,30 matrix to a 10,30.  
but it looks at the end that I do not get the Data part of the data.fram 
correctly: 
Data-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
idx-cut(1:30, 10)
keep.ag-aggregate(Data, list(idx), mean)
str(as.matrix(keep.ag) ) # it does not look like integers
 
 
 
 
 
 
 
2) I want to have a string that can be used also for calling a function with 
the same name. Think of using mean to call mean. I need to have R interpret 
the string in different ways.
To call „mean“ of what? I am sure I do not understand what is your 
intention.
LogFunction- function(){}
FunctionIndex- rbind (c(1,LogFunction),
               c(2,TakeFunction))
print(sprintf('Using the function %s',FunctionIndex[1,1]))
This does not 

[R] find and replace characters in a string

2013-03-27 Thread Shane Carey
Hi,

I have a string of text as follows LOI .

How do I replace the dot with (%)

gsub(.,(%),LOI .)

gives

(%)(%)(%)(%)(%)

Thanks
-- 
Shane

[[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] Odd graphic device behavior

2013-03-27 Thread Thomas Adams
John,

Thanks for the suggestion, but no. I have even gone so far as to rebuild R
from source, re-booted my computer, and tried the 'experiment':

 require(stats)
 plot(cars)

immediately after starting R. Still the same result. I think it must be
related to some default Ubuntu Unity window manager default I can't sort
out.

Regards,
Tom


On Wed, Mar 27, 2013 at 10:14 AM, John Kane jrkrid...@inbox.com wrote:

 Any chance that you made an earlier call to par() resetting cex in your
 session?  I just had that happen.

 John Kane
 Kingston ON Canada


  -Original Message-
  From: tea...@gmail.com
  Sent: Tue, 26 Mar 2013 10:15:33 -0400
  To: r-help@r-project.org
  Subject: [R] Odd graphic device behavior
 
  I'm experiencing odd graphics device behavior running R 2.15.3 on Ubuntu.
  Regardless of what I try like:
 
  require(stats)
  plot(cars)
  lines(lowess(cars))
  plot(sin, -pi, 2*pi)
 
  for example, the graphics device fills the entire screen with the graphic
  and a very large font. When I shrink the graphics device window, the
  lettering remains large and the line thicknesses stay quite thick. It may
  have been some time since I have done any R work on my Ubuntu computer,
  but
  clearly this did not happen previously.
 
  Does anyone have any thoughts?
 
  Thank you,
  Tom
 
[[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.

 
 FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on
 your desktop!
 Check it out at http://www.inbox.com/marineaquarium




[[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] find and replace characters in a string

2013-03-27 Thread arun
txt-  LOI .
gsub([.],%,txt)
#[1] LOI %
A.K.






From: Shane Carey careys...@gmail.com
To: r-help@r-project.org 
Sent: Wednesday, March 27, 2013 12:09 PM
Subject: [R] find and replace characters in a string

Hi,

I have a string of text as follows LOI .

How do I replace the dot with (%)

gsub(.,(%),LOI .)

gives

(%)(%)(%)(%)(%)

Thanks
-- 
Shane

    [[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] find and replace characters in a string

2013-03-27 Thread Rui Barradas

Hello,

The period is a metacharacter so you have to escape it.
The period is escaped with a '\'. In it's turn, '\' is a metacharacter 
so it needs to be escaped. Hence the double'\\'.


x - LOI .
gsub(\\., (%), x)


Hope this helps,

Rui Barradas

Em 27-03-2013 16:09, Shane Carey escreveu:

Hi,

I have a string of text as follows LOI .

How do I replace the dot with (%)

gsub(.,(%),LOI .)

gives

(%)(%)(%)(%)(%)

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.


Re: [R] Averaging Out many rows from a column AND funtion to string

2013-03-27 Thread PIKAL Petr
Hi

Such a big matrix is above capability of my computer as it requires about 4GB 
(If I compute it correctly) and I have only 2GB.

Maybe you could try package data.table which is designed for fast data 
manipulation.

Regards
Petr


From: Alaios [mailto:ala...@yahoo.com]
Sent: Wednesday, March 27, 2013 5:05 PM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string

Well my true matrix is
of



num [1:153899, 1:3415]

that I want to convert to something like

num [1:1000, 1:3415] (keeping column number the same).

I only give subsets here to allow others to run the code at their computer

Thanks a lot

Regards
Alex


From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Alaios ala...@yahoo.commailto:ala...@yahoo.com; R help 
R-help@r-project.orgmailto:R-help@r-project.org
Sent: Wednesday, March 27, 2013 4:45 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string


Hi

 system.time({
+ keep-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
+ ShrinkTo-500
+ idx-cut(1:nrow(keep), ShrinkTo)
+ keep.ag-aggregate(keep, list(idx), mean)
+ PlotMe-as.matrix(keep.aghttp://keep.ag/[,-1])
+ })
   user  system elapsed
  29.230.14   29.37


It takes 30 seconds when using 30 rows. It is not enough time to get a cup 
of tee, which I do not consider ages. Maybe split lapply approach or 
data.matrix or  **ply could be quicker but I do not consider worth spending 
hours to elaborate some solution which will spare 20 sec computing time.

Regards
Petr

From: Alaios [mailto:ala...@yahoo.com]
Sent: Wednesday, March 27, 2013 4:12 PM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string

I have fixed it like that:


keep-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
ShrinkTo-500
idx-cut(1:nrow(keep), ShrinkTo)
keep.ag-aggregate(keep, list(idx), mean)
PlotMe-data.matrix(keep.ag[2:ShrinkTo])

The only problem is that takes ages to finish. Would it be possible to 
convert it to something like lapply?

Regards
Alex



From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Alaios ala...@yahoo.commailto:ala...@yahoo.com; R help 
R-help@r-project.orgmailto:R-help@r-project.org
Sent: Wednesday, March 27, 2013 4:02 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

 str(as.matrix(keep.aghttp://keep.ag/[,-1]) )  # does look like numeric
num [1:10, 1:30] 75.1 93 79 81.7 76.3 ...
- attr(*, dimnames)=List of 2
  ..$ : NULL
  ..$ : chr [1:30] V1 V2 V3 V4 ...

Please read and follow what was recommended.

quote

use as.matrix(data.frame) on numeric part
  ^^^

aggregate produces data frame with its first column being your idx variable, 
which is factor. Trying to convert it whole to matrix results in character 
matrix. You need to exclude first column from conversion

And please can you explain how mean(rnorm(whatever)) shall be integer?

Regards
Petr

From: Alaios [mailto:ala...@yahoo.com]
Sent: Wednesday, March 27, 2013 3:01 PM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string

see inline



From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Alaios ala...@yahoo.commailto:ala...@yahoo.com; R help 
R-help@r-project.orgmailto:R-help@r-project.org
Sent: Wednesday, March 27, 2013 1:50 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

From: Alaios [mailto:ala...@yahoo.com]
Sent: Wednesday, March 27, 2013 11:46 AM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string

see inline


From: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz
To: Alaios ala...@yahoo.commailto:ala...@yahoo.com; R help 
R-help@r-project.orgmailto:R-help@r-project.org
Sent: Wednesday, March 27, 2013 11:24 AM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
 [mailto:r-help-bounces@r-
 project.orghttp://project.org/] On Behalf Of Alaios
 Sent: Wednesday, March 27, 2013 9:13 AM
 To: R help
 Subject: [R] Averaging Out many rows from a column AND funtion to
 string

 Dear all,
 1) I have a very large matrix of
 str(keep)
  num [1:153899, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ...
 that  I would like to reduce its size to something like

 str(keep)
  num [1:1000, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ... or anything
 similar in size as this is a matrix that needs plotting (so is ok if it
 is 1000 row, 995, or 1123)

 I think what I need here is a way of selecting multiple rows and
 averaging per column (notice that the column number should stay the
 same)

Make an index variable and aggregate values 

Re: [R] find and replace characters in a string

2013-03-27 Thread PIKAL Petr
Although I am not an expert, this is simple.

txt-  LOI .
gsub(.,%,txt, fixed=TRUE)

Regards
Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Rui Barradas
 Sent: Wednesday, March 27, 2013 5:17 PM
 To: Shane Carey
 Cc: r-help@r-project.org
 Subject: Re: [R] find and replace characters in a string
 
 Hello,
 
 The period is a metacharacter so you have to escape it.
 The period is escaped with a '\'. In it's turn, '\' is a metacharacter
 so it needs to be escaped. Hence the double'\\'.
 
 x - LOI .
 gsub(\\., (%), x)
 
 
 Hope this helps,
 
 Rui Barradas
 
 Em 27-03-2013 16:09, Shane Carey escreveu:
  Hi,
 
  I have a string of text as follows LOI .
 
  How do I replace the dot with (%)
 
  gsub(.,(%),LOI .)
 
  gives
 
  (%)(%)(%)(%)(%)
 
  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.


Re: [R] when to use which apply function?

2013-03-27 Thread C W
Thanks for pointing that out.

Mike

On Tue, Mar 26, 2013 at 6:53 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Mar 26, 2013, at 2:51 PM, C W wrote:

  Dear list,
 
  I am a little confused as to when to use apply, sapply, tapply, vapply,
  replicate.  I've encountered this several times,
  This is time, this is what I am working on,
 
  mat - matrix(c(seq(from=1, to=10), rnorm(10)), ncol=2)
 
  a=1; b=5
 
  newfun - function(x, y, a, b)
 
  {
 
  x*y+a+b
 
  }
 
  sapply(i=1:10, newfun(x=mat[i, 1], y=mat[i, 2], a=a, b=b))
 
  Error in match.fun(FUN) : argument FUN is missing, with no default
 
  I want to use ith row of mat, evaluate newfun().  Am I making a parameter
  mistake,

 There is nothing that would naturally catch the values. After they are
 evaluated sequentially by `sapply` the values 1:10 no longer are named i
 and so don't naturally fall into the slots you thought you had constructed
 for them. By constructing an anonymous function with any formal argument
 name (as already demonstrated by another poster)  you could get to use
 positional matching.

  or should I use a different apply function?

 Yes, some other function since all those operations are vectorized, this
 could be more easily done with:

  mat[ ,1]*mat[ ,2]+a+b   # and no need for a loop, right?

 --

 David Winsemius
 Alameda, CA, USA



[[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] Odd graphic device behavior

2013-03-27 Thread David Winsemius

On Mar 27, 2013, at 9:07 AM, Thomas Adams wrote:

 John,
 
 Thanks for the suggestion, but no. I have even gone so far as to rebuild R
 from source, re-booted my computer, and tried the 'experiment':
 
 require(stats)
 plot(cars)
 
 immediately after starting R. Still the same result. I think it must be
 related to some default Ubuntu Unity window manager default I can't sort
 out.

Have your deleted the default workspace and history files? When they get 
corrupted, odd things can happen.


 
 Regards,
 Tom
 
 
 On Wed, Mar 27, 2013 at 10:14 AM, John Kane jrkrid...@inbox.com wrote:
 
 Any chance that you made an earlier call to par() resetting cex in your
 session?  I just had that happen.
 
 John Kane
 Kingston ON Canada
 
 
 -Original Message-
 From: tea...@gmail.com
 Sent: Tue, 26 Mar 2013 10:15:33 -0400
 To: r-help@r-project.org
 Subject: [R] Odd graphic device behavior
 
 I'm experiencing odd graphics device behavior running R 2.15.3 on Ubuntu.
 Regardless of what I try like:
 
 require(stats)
 plot(cars)
 lines(lowess(cars))
 plot(sin, -pi, 2*pi)
 
 for example, the graphics device fills the entire screen with the graphic
 and a very large font. When I shrink the graphics device window, the
 lettering remains large and the line thicknesses stay quite thick. It may
 have been some time since I have done any R work on my Ubuntu computer,
 but
 clearly this did not happen previously.
 
 Does anyone have any thoughts?
 
 Thank you,
 Tom
 
  [[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.
 
 
 FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on
 your desktop!
 Check it out at http://www.inbox.com/marineaquarium
 
 
 
 
   [[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.

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 while using register from fda package

2013-03-27 Thread zoe richards
Hi all,

I think I've run into an error caused by my computer's having too little
computational power, but I'm not sure.  I used the following code to
perform continuous registration on two functional objects:

lambda1 - 10E-2
norder=8
samples-seq(0,780,length=781)
nbasis - length(samples)+norder-2
mybasis-create.bspline.basis(c(0,780),nbasis,norder)
myfdPar-fdPar(mybasis,4,lambda1)
myfd.unemployment - smooth.basis(samples,unemployment.rate,myfdPar)$fd
myfd.unemployment.squared - smooth.basis(samples,unemp.squared,myfdPar)$fd
lambda2-10E-2
myfdPar-fdPar(mybasis,4,lambda2)
myfd.inflation - smooth.basis(samples,inflation.rate,myfdPar,)$fd
myfd.inflation.squared - smooth.basis(samples,inflation.squared,myfdPar)$fd
plot(myfd.inflation)
#register
lambda=1
nbasis=myfd.unemployment$basis$nbasis
ntrial=1
y0fd=mean(myfd.inflation)
yfd=myfd.unemployment
coef0-matrix(0,nbasis,ntrial)
wfd-fd(coef0,mybasis)
wfdPar=fdPar(coef0,2,lambda)
reglist-register.fd(y0fd,yfd,wfdPar,iterlim=10,dbglev=1)

I get the following error after the last command:
Error in matrix(0, length(x), nbaspr) : too many elements specified

Is this error associated with my computer's not having sufficient power to
perform the registration?  I can't think of what else that might be going
on...

Thanks,

Zoe Richards

[[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] Setting up a model in package dlm()

2013-03-27 Thread Eric Przybylinski
Hello,

I apologize for such a basic question, but I have been trying to do this in
multiple packages without much success.  I am trying to set up a state
space model for Kalman filtering.  I am using package dlm.  The DLM is
specified by:

observation: y(t) = F(t)*theta(t) + v(t)
state: theta(t) = G(t)*theta(t-1) + w(t)

I have no problem setting up a simple example where F is constant.  I am
trying to set up a model where F(t) (the output matrix) has time varying
values (x1(t),x2(t)).  I keep getting an incompatible dimension error
despite trying a number of different permutations.  I do have a copy of the
Petris book, but I haven't had a chance to give it a thorough read at this
point.  Any assistance would be greatly appreciated:

Example code:
#n x p  output matrix
FMat-cbind(rnorm(123),rnorm(123))

#p x p state transition matrix
GMat-matrix(c(1,0,0,1),ncol=2)

#p x p system noise distribution
WMat-matrix(c(0.02,0,0,0.02),ncol=2)

# nxn measurement noise
Vmat-matrix(0,ncol=123,nrow=123)
diag(Vmat)-0.02

#initial state mean and variance
m0Vec-c(1,1)
c0Vec-c(0.05,0.05)
ssMod-dlm(FF=FMat,V=Vmat,GG=GMat,W=WMat,m0=m0Vec,C0=c0Vec)

Resulting error:

Error in dlm(FF = FMat, V = Vmat, GG = GMat, W = WMat, m0 = m0Vec, C0
= c0Vec) :
  Incompatible dimensions of matrices

[[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] Weighted Kaplan-Meier estimates with R

2013-03-27 Thread rm
Thanks to all of you for your very helpful comments! As Terry suggested,
svykm is what I was looking for.

While testing that I get the same results with the package survey as with
the package survival, I encountered the issue of how to draw survival
curves.  Apparently the implementations in the two packages differ, as I
show below.

I would very much welcome your views, since the tail of the survival curve
has a major impact on the interpretation of my results. In my data, the last
‘death’ occurs at 2094 days, while the last censoring time is 3297 days.  If
possible, I would like to say something about the probability between 2100
days and 3300 days.

So, my question is that after the last observed death, in the very simple
example below at 883 days, how should one draw the survival curve? The graph
produced by svykm (package survey) ends at 883 days, whereas survfit
(package survival) continues the graph all the way to the last censoring
time, which is at 1022 days.

Please run the code below to see my point. There are no weights. With
weights, I face the same issue.

require(survival)
lungSubSet - lung
S - Surv(lung$time,lung$status)
sKm - survfit(S~1)
##
require(survey)
svyDesignObject- svydesign(id=~1,weights=~1,data=lungSubSet)
svyKm - svykm(S~1,design=svyDesignObject,se=T)
##
plot(svyKm,xlim=c(0,1200))
lines(sKm,conf.int=T,mark.time=F,col='green')




--
View this message in context: 
http://r.789695.n4.nabble.com/Re-Weighted-Kaplan-Meier-estimates-with-R-tp4662494p4662619.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] Odd graphic device behavior

2013-03-27 Thread peter dalgaard

On Mar 27, 2013, at 18:11 , David Winsemius wrote:

 
 On Mar 27, 2013, at 9:07 AM, Thomas Adams wrote:
 
 John,
 
 Thanks for the suggestion, but no. I have even gone so far as to rebuild R
 from source, re-booted my computer, and tried the 'experiment':
 
require(stats)
plot(cars)
 
 immediately after starting R. Still the same result. I think it must be
 related to some default Ubuntu Unity window manager default I can't sort
 out.
 
 Have your deleted the default workspace and history files? When they get 
 corrupted, odd things can happen.
 

...or try R --vanilla

The immediate suspicion is that something is tampering with your graphics 
device options, so

- figure out what device you are using (dev.list())
- if it is X11, have a look at X11.options()
- try running X11(width=7, height=7) to see if the automagic settings get it 
wrong.

- try system(xdpyinfo); this may give a long list of gibberish, but look  for 
dimensions and resolution and see if they look sane. E.g., I get

screen #0:
  dimensions:2560x1418 pixels (677x375 millimeters)
  resolution:96x96 dots per inch




 
 
 Regards,
 Tom
 
 
 On Wed, Mar 27, 2013 at 10:14 AM, John Kane jrkrid...@inbox.com wrote:
 
 Any chance that you made an earlier call to par() resetting cex in your
 session?  I just had that happen.
 
 John Kane
 Kingston ON Canada
 
 
 -Original Message-
 From: tea...@gmail.com
 Sent: Tue, 26 Mar 2013 10:15:33 -0400
 To: r-help@r-project.org
 Subject: [R] Odd graphic device behavior
 
 I'm experiencing odd graphics device behavior running R 2.15.3 on Ubuntu.
 Regardless of what I try like:
 
 require(stats)
 plot(cars)
 lines(lowess(cars))
 plot(sin, -pi, 2*pi)
 
 for example, the graphics device fills the entire screen with the graphic
 and a very large font. When I shrink the graphics device window, the
 lettering remains large and the line thicknesses stay quite thick. It may
 have been some time since I have done any R work on my Ubuntu computer,
 but
 clearly this did not happen previously.
 
 Does anyone have any thoughts?
 
 Thank you,
 Tom
 
 [[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.
 
 
 FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on
 your desktop!
 Check it out at http://www.inbox.com/marineaquarium
 
 
 
 
  [[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.
 
 David Winsemius
 Alameda, CA, USA
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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] a similar question

2013-03-27 Thread arun
Hi Elisa,
Try this:
dat1- read.csv(DQV.csv,sep=\t)

res- do.call(cbind,lapply(seq_len(nrow(dat1)),function(i) 
do.call(rbind,lapply(split(rbind(dat1[i,],dat1[-i,]),1:nrow(rbind(dat1[i,],dat1[-i,]))),function(x)
 {x1- rbind(dat1[i,],x); colnames(x1)- gsub([.],,colnames(x1));
if({indx- colSums(is.na(x1)); indx[2]==0  indx[3]==1}) # 2 peaks 1 peak 
comparison
{x2- x1[rev(order(x1$Peak2v, x1$Npeak2v)),];
with(x2,{abs(Peak1v[1]-Peak1v[2])+abs(Peak1v[1]-Peak2v[2]) + 
abs(Npeak1v[1]-Npeak1v[2])+abs(Npeak1v[1]-Npeak2v[2]) })
}

else {x1[is.na(x1)]-0; x1; #cases where peaks are similar
with(x1,{abs(Peak1v[1]-Peak1v[2])+ abs(Peak2v[1]-Peak2v[2])+ 
abs(Npeak1v[1]-Npeak1v[2])+ abs(Npeak2v[1]-Npeak2v[2])})
}

}


res2-do.call(cbind,lapply(seq_len(ncol(res)),function(i) 
c(c(tail(res[seq(1,i,1),i],-1),0),res[-c(1:i),i])))
row.names(res2)-1:nrow(res2)
dim(res2)
#[1] 124 124
res2[1:5,1:5]
#   [,1]  [,2]  [,3]  [,4]  [,5]
#1 0.000 0.8024471 2.3537210 2.1929718 3.7746302
#2 0.8024471 0.000 3.1233237 2.9954189 4.5442329
#3 2.3537210 3.1233237 0.000 0.4094026 0.8108279
#4 2.1929718 2.9954189 0.4094026 0.000 0.8571442
#5 3.7746302 4.5442329 0.8108279 0.8571442 0.000

A.K.







From: eliza botto eliza_bo...@hotmail.com
To: smartpink...@yahoo.com smartpink...@yahoo.com 
Sent: Wednesday, March 27, 2013 12:07 PM
Subject: RE: a similar question



Dear Arun,
The last question regarding this distance measurement is that how to modify the 
following codes for calculation of distance if we have 2 peaks atmost. The data 
file is attached

Thanks in advance
Elisa


 Date: Tue, 26 Mar 2013 16:02:01 -0700
 From: smartpink...@yahoo.com
 Subject: Re: a similar question
 To: eliza_bo...@hotmail.com
 CC: r-help@r-project.org
 
 HI Elisa,
 
 You need to review the formulas.  Some of them (especially between 84  85 or 
 4  84 is not making sense, possibly typos).  I changed it according to the 
 pattern of the formulas.
 source(ElisaNew.txt)
 #mat1 # dataset
 
 res-do.call(cbind,lapply(seq_len(nrow(mat1)),function(i) 
 do.call(rbind,lapply(split(rbind(mat1[i,],mat1[-i,]),1:nrow(rbind(mat1[i,],mat1[-i,]))),
  function(x) {x1- rbind(mat1[i,],x);x1-as.data.frame(x1);
 if({indx-colSums(is.na(x1));indx[1]==0  indx[2]==0  indx[3]==1  
 indx[4]==2}) #3 peaks 2 peaks comparison
  {x2- x1[rev(order(x1$Peak3,x1$Npeak3)),];
 with(x2,{abs(Peak1[1]-Peak1[2])+abs(Peak2[1]-Peak2[2])+abs(Peak1[1]-Peak3[2]) 
 + abs(Npeak1[1]-Npeak1[2])+abs(Npeak2[1]-Npeak2[2])+abs(Npeak1[1]-Npeak3[2])})
 }
 
 else if({indx[1]==0  indx[2]==1  indx[3]==2  indx[4]==2}) #2 peaks 1 peak 
 comparison
 {x3- x1[rev(order(x1$Peak2,x1$Npeak2)),];
 with(x3,{abs(Peak1[1]-Peak1[2])+ abs(Peak1[1]-Peak2[2])+ 
 abs(Npeak1[1]-Npeak1[2])+ abs(Npeak1[1]-Npeak2[2])})
 }
 else if({indx[1]==0  indx[2]==0  indx[3]==1  indx[4]==1}) #4 peaks 2 peaks 
 comparison
 {x4- x1[rev(order(x1$Peak3,x1$Peak4,x1$Npeak3,x1$Npeak4)),];
 with(x4,{abs(Peak1[1]-Peak1[2])+abs(Peak2[1]-Peak2[2])+ 
 abs(Peak1[1]-Peak3[2])+ abs(Peak2[1]-Peak4[2])+ 
 abs(Npeak1[1]-Npeak1[2])+abs(Npeak2[1]-Npeak2[2])+ abs(Npeak1[1]-Npeak3[2])+ 
 abs(Npeak2[1]-Npeak4[2])})
 }
 
 else if({indx[1]==0  indx[2]==0  indx[3]==0  indx[4]==1}) #4 peaks 3 peaks 
 comparison
 {x5- x1[rev(order(x1$Peak4,x1$Npeak4)),];
 with(x5,{abs(Peak1[1]-Peak1[2])+abs(Peak2[1]-Peak2[2])+ 
 abs(Peak3[1]-Peak3[2])+ abs(Peak1[1]-Peak4[2])+ 
 abs(Npeak1[1]-Npeak1[2])+abs(Npeak2[1]-Npeak2[2])+ abs(Npeak3[1]-Npeak3[2])+ 
 abs(Npeak1[1]-Npeak4[2])})
 }
 else if({indx[1]==0  indx[2]==1  indx[3]==1  indx[4]==1}) #4 peak 1 peak 
 comparison
 {x6- 
 x1[rev(order(x1$Peak2,x1$Peak3,x1$Peak4,x1$Npeak2,x1$Npeak3,x1$Npeak4)),];
 with(x6,{abs(Peak1[1]-Peak1[2])+ 
 abs(Peak1[1]-Peak2[2])+abs(Peak1[1]-Peak3[2])+ abs(Peak1[1]-Peak4[2])+ 
 abs(Npeak1[1]-Npeak1[2])+ abs(Npeak1[1]-Npeak2[2])+abs(Npeak1[1]-Npeak3[2])+ 
 abs(Npeak1[1]-Npeak4[2])})
 }
 else if({indx[1]==0  indx[2]==1  indx[3]==1  indx[4]==2}) # 3 peaks 1 peak 
 comparison
 {x7- x1[rev(order(x1$Peak2,x1$Peak3,x1$Npeak2,x1$Npeak3)),];
 with(x7,{abs(Peak1[1]-Peak1[2])+abs(Peak1[1]-Peak2[2])+abs(Peak1[1]-Peak3[2])+
  abs(Npeak1[1]-Npeak1[2])+abs(Npeak1[1]-Npeak2[2])+abs(Npeak1[1]-Npeak3[2])})
 }
 else {x1[is.na(x1)]-0; x1; #cases where peaks are similar
 with(x1,{abs(Peak1[1]-Peak1[2])+ abs(Peak2[1]-Peak2[2])+ 
 abs(Peak3[1]-Peak3[2])+abs(Peak4[1]-Peak4[2]) + abs(Npeak1[1]-Npeak1[2])+ 
 abs(Npeak2[1]-Npeak2[2])+ abs(Npeak3[1]-Npeak3[2])+abs(Npeak4[1]-Npeak4[2])})
 }
 
 }
 
 res2-do.call(cbind,lapply(seq_len(ncol(res)),function(i) 
 c(c(tail(res[seq(1,i,1),i],-1),0),res[-c(1:i),i])))
 row.names(res2)-1:nrow(res2)
 dim(res2)
 #[1] 124 124
 res2[1:5,1:5]
 #   [,1]  [,2]  [,3] [,4]  [,5]
 #1   0.0  65.59415  86.62556 407.9987 104.78294
 #2  65.59415   0.0  42.14256 307.3830  39.18879
 #3  86.62556  42.14256   0.0 314.4331  33.88839
 #4 407.99871 307.38297 314.43309   0. 266.78887
 #5 104.78294  39.18879  33.88839 

Re: [R] Odd graphic device behavior

2013-03-27 Thread Thomas Adams
Peter,

Thank you.

When I run: X11(width=7, height=7), I get the same full-screen graphics
device window.
Running dev.list() gives me X11cairo
Running system(xdpyinfo) looks reasonable

I tried running options(device=x11) at the R prompt, but this did not
seem to change anything.

When I started R with R --vanilla and then did:

 require(stats)
  plot(cars)

I got:

Error in plot.new() : figure margins too large

... but the window was a reasonable size. However, after I resized the
graphics device window modestly and re-ran plot(cars), the plot was
generated in the resized window, but the lettering was large as before and
the lines were thick as they were previously.

Regards,
Tom


On Wed, Mar 27, 2013 at 1:43 PM, peter dalgaard pda...@gmail.com wrote:


 On Mar 27, 2013, at 18:11 , David Winsemius wrote:

 
  On Mar 27, 2013, at 9:07 AM, Thomas Adams wrote:
 
  John,
 
  Thanks for the suggestion, but no. I have even gone so far as to
 rebuild R
  from source, re-booted my computer, and tried the 'experiment':
 
 require(stats)
 plot(cars)
 
  immediately after starting R. Still the same result. I think it must be
  related to some default Ubuntu Unity window manager default I can't sort
  out.
 
  Have your deleted the default workspace and history files? When they get
 corrupted, odd things can happen.
 

 ...or try R --vanilla

 The immediate suspicion is that something is tampering with your graphics
 device options, so

 - figure out what device you are using (dev.list())
 - if it is X11, have a look at X11.options()
 - try running X11(width=7, height=7) to see if the automagic settings get
 it wrong.

 - try system(xdpyinfo); this may give a long list of gibberish, but look
  for dimensions and resolution and see if they look sane. E.g., I get

 screen #0:
   dimensions:2560x1418 pixels (677x375 millimeters)
   resolution:96x96 dots per inch




 
 
  Regards,
  Tom
 
 
  On Wed, Mar 27, 2013 at 10:14 AM, John Kane jrkrid...@inbox.com
 wrote:
 
  Any chance that you made an earlier call to par() resetting cex in your
  session?  I just had that happen.
 
  John Kane
  Kingston ON Canada
 
 
  -Original Message-
  From: tea...@gmail.com
  Sent: Tue, 26 Mar 2013 10:15:33 -0400
  To: r-help@r-project.org
  Subject: [R] Odd graphic device behavior
 
  I'm experiencing odd graphics device behavior running R 2.15.3 on
 Ubuntu.
  Regardless of what I try like:
 
  require(stats)
  plot(cars)
  lines(lowess(cars))
  plot(sin, -pi, 2*pi)
 
  for example, the graphics device fills the entire screen with the
 graphic
  and a very large font. When I shrink the graphics device window, the
  lettering remains large and the line thicknesses stay quite thick. It
 may
  have been some time since I have done any R work on my Ubuntu
 computer,
  but
  clearly this did not happen previously.
 
  Does anyone have any thoughts?
 
  Thank you,
  Tom
 
  [[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.
 
  
  FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on
  your desktop!
  Check it out at http://www.inbox.com/marineaquarium
 
 
 
 
   [[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.
 
  David Winsemius
  Alameda, CA, USA
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 --
 Peter Dalgaard, Professor
 Center for Statistics, Copenhagen Business School
 Solbjerg Plads 3, 2000 Frederiksberg, Denmark
 Phone: (+45)38153501
 Email: pd@cbs.dk  Priv: pda...@gmail.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] Time trends with GAM

2013-03-27 Thread Antonio P. Ramos
Thanks.


On Tue, Mar 26, 2013 at 4:45 AM, Simon Wood s.w...@bath.ac.uk wrote:

 For 1) see reply just sent to R help...
 Re: [R] Use pcls in mgcv package to achieve constrained cubic spline
 (I'm assuming you mean to fix the value of the smooth at a particular knot
 location - i.e. to impose a constraint like f(t_0) = b).

 For 2) try 'model.matrix', or 'predict.gam' with argument
 'type=lpmatrix' (see ?predict.gam)


 On 23/03/13 01:05, Antonio P. Ramos wrote:

 Hi all,

 I am using GAM to model time trends in a logistic regression. Yet I would
 like to extract the the fitted spline from it to add it to another model,
 that cannot be fitted in GAM or GAMM.

 Thus I have 2 questions:

 1) How can I fit a smoother over time so that I force one knot to be at a
 particular location while letting the model to find the other knots?


  2) how can I extract the matrix from the fitted GAM so that I can use it
 in
 as an impute for a different model.

 The types of models I am running are to the following form:

 gam - gam(mortality.under.2~ maternal_age_c+ I(maternal_age_c^2)+
 s(birth_year,by=wealth2) +
   + wealth2 + sex +
   residence+ maternal_educ + birth_order,
 ,data=colombia2,family=**binomial)

 I've read the extensive documentation for the GAM but I am not sure still.
 Any suggestion is really appreciated.

 Thanks,

 Antonio Pedro

 [[alternative HTML version deleted]]

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



 --
 Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
 +44 (0)1225 386603   http://people.bath.ac.uk/sw283


[[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] Archieve of mails from R forum

2013-03-27 Thread Katherine Gobin
Dear R helpers,

Everyday I do receive many many mails from R forum and after some period of 
times, INBOX is filled with numerous mails. At times if for some period of 
time, I haven't accessed mails, it becomes difficult to keep track of mails and 
many times simply due to the volume (and owing to the lack of time due to 
office constraints), I have to simply delete the mails without opening them and 
I understand this is a huge loss.

If in case I wish to refer to all the old emails that have been appeared in the 
R forum, where do I get these? Is there any list where I will get subject-wise 
of thread-wise archive of old emails? I understand that will be an ocean of 
quality information and one can learn a lot from these old mails and I don't 
need to keep track of my emails all the time.
 

Kindly guide.

Regards

Katherine

[[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] Archieve of mails from R forum

2013-03-27 Thread Marc Schwartz

On Mar 27, 2013, at 1:58 PM, Katherine Gobin katherine_go...@yahoo.com wrote:

 Dear R helpers,
 
 Everyday I do receive many many mails from R forum and after some period of 
 times, INBOX is filled with numerous mails. At times if for some period of 
 time, I haven't accessed mails, it becomes difficult to keep track of mails 
 and many times simply due to the volume (and owing to the lack of time due to 
 office constraints), I have to simply delete the mails without opening them 
 and I understand this is a huge loss.
 
 If in case I wish to refer to all the old emails that have been appeared in 
 the R forum, where do I get these? Is there any list where I will get 
 subject-wise of thread-wise archive of old emails? I understand that will be 
 an ocean of quality information and one can learn a lot from these old mails 
 and I don't need to keep track of my emails all the time.
 
 
 Kindly guide.
 
 Regards
 
 Katherine
 

The official archives for R-Help are here:

  https://stat.ethz.ch/pipermail/r-help/

and these are mirrored in various locations, such as:

  http://www.mail-archive.com/r-help@stat.math.ethz.ch/
  http://dir.gmane.org/gmane.comp.lang.r.general

You can also search the archives for all R lists at:

  http://rseek.org/
  http://finzi.psych.upenn.edu/search.html
  http://tolstoy.newcastle.edu.au/R/


My recommendation would be to set up a mail filter or rule (using 
r-help@r-project.org in the the sender and cc: address fields) so that the list 
e-mails are automatically moved from your main inbox to a folder just for these 
e-mails and you can then browse them as your schedule permits, rather than 
having them interspersed with other e-mails in the same location. I do this 
with a number of the R related lists and have a folder for each one to keep 
them separated. Most e-mail clients and/or online services have some type of 
filtering or rule configuration available to do this.

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] Archieve of mails from R forum

2013-03-27 Thread Mason
http://r-help.markmail.org/ has a nice interface for searching the
archives, too.

On Wed, Mar 27, 2013 at 12:18 PM, Marc Schwartz marc_schwa...@me.comwrote:


 On Mar 27, 2013, at 1:58 PM, Katherine Gobin katherine_go...@yahoo.com
 wrote:

  Dear R helpers,
 
  Everyday I do receive many many mails from R forum and after some period
 of times, INBOX is filled with numerous mails. At times if for some period
 of time, I haven't accessed mails, it becomes difficult to keep track of
 mails and many times simply due to the volume (and owing to the lack of
 time due to office constraints), I have to simply delete the mails without
 opening them and I understand this is a huge loss.
 
  If in case I wish to refer to all the old emails that have been appeared
 in the R forum, where do I get these? Is there any list where I will get
 subject-wise of thread-wise archive of old emails? I understand that will
 be an ocean of quality information and one can learn a lot from these old
 mails and I don't need to keep track of my emails all the time.
 
 
  Kindly guide.
 
  Regards
 
  Katherine
 

 The official archives for R-Help are here:

   https://stat.ethz.ch/pipermail/r-help/

 and these are mirrored in various locations, such as:

   http://www.mail-archive.com/r-help@stat.math.ethz.ch/
   http://dir.gmane.org/gmane.comp.lang.r.general

 You can also search the archives for all R lists at:

   http://rseek.org/
   http://finzi.psych.upenn.edu/search.html
   http://tolstoy.newcastle.edu.au/R/


 My recommendation would be to set up a mail filter or rule (using
 r-help@r-project.org in the the sender and cc: address fields) so that
 the list e-mails are automatically moved from your main inbox to a folder
 just for these e-mails and you can then browse them as your schedule
 permits, rather than having them interspersed with other e-mails in the
 same location. I do this with a number of the R related lists and have a
 folder for each one to keep them separated. Most e-mail clients and/or
 online services have some type of filtering or rule configuration available
 to do this.

 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.


[[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] conditional Dataframe filling

2013-03-27 Thread Camilo Mora

Dear Arun,

Thank you very  much for your help with this.I did not know where to  
start looking to solve that problem, so I truly appreciate your input.


The line of code you sent seems to work but it duplicates the results.  
Do you know why that may happen?

Below is a larger database, to which I apply your line of code.

Thank you very much again,
Camilo


dat1 - structure(list(
w = c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE),
x = c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),
y =  
c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE),

z = c(TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE)),
row.names = c(NA, -13L),
class = data.frame)

dat1-t(dat1)
colnames(dat1)-c(a,b,c,d,e,f,g,h,i,j,k, l,m)

dat2-dat1

dat2[]-t(apply(!dat1,1,function(x)  
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum














Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
 Provider code: 313
 Phone 776 2282
 From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/



Quoting arun smartpink...@yahoo.com:


HI,

Just a correction:

:

dat2[]-t(apply(!dat1,1,function(x)  
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum  #should  
also work

A.K.



- Original Message -
From: arun smartpink...@yahoo.com
To: Camilo Mora cm...@dal.ca
Cc: R help r-help@r-project.org
Sent: Wednesday, March 27, 2013 9:09 AM
Subject: Re: [R] conditional Dataframe filling



Hi,
You could try:
dat1- read.table(text=
a    b    c    d
TRUE  TRUE  TRUE  TRUE
FALSE FALSE FALSE TRUE
FALSE  TRUE  FALSE  FALSE
,sep=,header=TRUE)
dat2-dat1
 dat2[]-t(apply(1*!dat1,1,function(x)  
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum

 dat2
#  a b c d
#1 0 0 0 0
#2 1 2 3 0
#3 1 0 1 2
A.K.


- Original Message -
From: Camilo Mora cm...@dal.ca
To: r-help@r-project.org
Cc:
Sent: Wednesday, March 27, 2013 4:31 AM
Subject: [R] conditional Dataframe filling

Hi everyone:

This may be trivial but I just have not been able to figure it out.

Imagine the following dataframe:
a     b     c     d
TRUE  TRUE  TRUE  TRUE
FALSE FALSE FALSE TRUE
FALSE  TRUE  FALSE  FALSE

I would like to create a new dataframe, in which TRUE gets 0 but if  
false then add 1 to the cell to the left. So the results for the  
example above should be something like:


a     b     c     d
0     0     0     0
1     2     3     0
1     0     1     2

I wonder if you may know?.

Thanks,

Camilo




Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
         Provider code: 313
         Phone 776 2282
         From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Averaging Out many rows from a column AND funtion to string

2013-03-27 Thread Law, Jason
This completes in about a second on my system and uses the actual matrix 
dimensions you quote:

  nr - 153899
  nc - 3415
  keep - rnorm(nr * nc, 80, 20)
  dim(keep) - c(nr, nc)
  shrink.to - 1000
  system.time(
{
  idx - rep(1:shrink.to, length.out = nr)
  plot.me - sweep(rowsum(keep, idx), 1, tabulate(idx), , FUN = '/')
})
   user  system elapsed 
   0.920.000.9

Jason Law
Statistician
City of Portland
Bureau of Environmental Services
Water Pollution Control Laboratory
6543 N Burlington Avenue
Portland, OR 97203-5452
503-823-1038
jason@portlandoregon.gov


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Alaios
Sent: Wednesday, March 27, 2013 9:05 AM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string

Well my true matrix is 

of


num [1:153899, 1:3415]

that I want to convert to something like

num [1:1000, 1:3415] (keeping column number the same).

I only give subsets here to allow others to run the code at their computer

Thanks a lot

Regards
Alex




 From: PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 4:45 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string



Hi
 
 system.time({
+ keep-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
+ ShrinkTo-500
+ idx-cut(1:nrow(keep), ShrinkTo)
+ keep.ag-aggregate(keep, list(idx), mean)
+ PlotMe-as.matrix(keep.ag[,-1])
+ })
   user  system elapsed
  29.23    0.14   29.37 
  
 
It takes 30 seconds when using 30 rows. It is not enough time to get a cup 
of tee, which I do not consider ages. Maybe split lapply approach or 
data.matrix or  **ply could be quicker but I do not consider worth spending 
hours to elaborate some solution which will spare 20 sec computing time.
 
Regards
Petr 
 

Sent: Wednesday, March 27, 2013 4:12 PM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string
 
I have fixed it like that:


keep-matrix(data=rnorm(900,80,20),nrow=30,ncol=30)
ShrinkTo-500
idx-cut(1:nrow(keep), ShrinkTo)
keep.ag-aggregate(keep, list(idx), mean)
PlotMe-data.matrix(keep.ag[2:ShrinkTo])

The only problem is that takes ages to finish. Would it be possible to 
convert it to something like lapply?

Regards
Alex
 
 



From:PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 4:02 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string


Hi
 
 str(as.matrix(keep.ag[,-1]) )  # does look like numeric
num [1:10, 1:30] 75.1 93 79 81.7 76.3 ...
- attr(*, dimnames)=List of 2
  ..$ : NULL
  ..$ : chr [1:30] V1 V2 V3 V4 ...
 
Please read and follow what was recommended.
 
quote
 
use as.matrix(data.frame) on numeric part
  ^^^
 
aggregate produces data frame with its first column being your idx variable, 
which is factor. Trying to convert it whole to matrix results in character 
matrix. You need to exclude first column from conversion
 
And please can you explain how mean(rnorm(whatever)) shall be integer?
 
Regards
Petr
 

Sent: Wednesday, March 27, 2013 3:01 PM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string
 
see inline
 
 



From:PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 1:50 PM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string
 
Hi
 

Sent: Wednesday, March 27, 2013 11:46 AM
To: PIKAL Petr; R help
Subject: Re: [R] Averaging Out many rows from a column AND funtion to string
 
see inline
 



From:PIKAL Petr petr.pi...@precheza.cz

Sent: Wednesday, March 27, 2013 11:24 AM
Subject: RE: [R] Averaging Out many rows from a column AND funtion to string

Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- 
 project.org] On Behalf Of Alaios
 Sent: Wednesday, March 27, 2013 9:13 AM
 To: R help
 Subject: [R] Averaging Out many rows from a column AND funtion to 
 string
 
 Dear all,
 1) I have a very large matrix of
 str(keep)
  num [1:153899, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ...
 that  I would like to reduce its size to something like
 
 str(keep)
  num [1:1000, 1:3415] -98.6 -95.8 -96.4 -95.8 -98 ... or anything 
 similar in size as this is a matrix that needs plotting (so is ok if 
 it is 1000 row, 995, or 1123)
 
 I think what I need here is a way of selecting multiple rows and 
 averaging per column (notice that the column number should stay the
 same)

Make an index variable and aggregate values according it

Something like
idx-cut(1:153899, 153)
keep.ag-aggregate(keep, list(idx), mean)

1) Thanks that returned a data frame.. How I can have a matrix at the end?
use as.matrix(data.frame) on numeric part
 
a bit of my code that you can re run. I convert a 

Re: [R] conditional Dataframe filling

2013-03-27 Thread arun
Dear Camilo,

How do you want to deal with the NAs?

If I remove the NAs:
dat1 - structure(list(
w = c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE),
x = c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),
y = c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE),
z = c(TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE)),
row.names = c(NA, -13L),
class = data.frame)

dat1-t(dat1)
colnames(dat1)-c(a,b,c,d,e,f,g,h,i,j,k, l,m)
dat1- as.data.frame(na.omit(dat1))
dat2-dat1
dat2[]-t(apply(!dat1,1,function(x) 
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum
 dat2
#  a b c d e f g h i j k l m
#w 0 0 0 0 0 1 2 3 4 0 0 0 0
#y 1 2 3 4 5 0 0 1 2 0 0 0 1
#z 0 0 0 0 1 0 0 0 1 0 0 0 1


 dat1
#  a b c d e f g h i    j    k    l m
#w  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE TRUE TRUE TRUE  TRUE
#y FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE TRUE TRUE TRUE FALSE
#z  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE TRUE TRUE TRUE FALSE


A.K.





- Original Message -
From: Camilo Mora cm...@dal.ca
To: arun smartpink...@yahoo.com
Cc: R help r-help@r-project.org
Sent: Wednesday, March 27, 2013 3:27 PM
Subject: Re: [R] conditional Dataframe filling

Dear Arun,

Thank you very  much for your help with this.I did not know where to start 
looking to solve that problem, so I truly appreciate your input.

The line of code you sent seems to work but it duplicates the results. Do you 
know why that may happen?
Below is a larger database, to which I apply your line of code.

Thank you very much again,
Camilo


dat1 - structure(list(
w = c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE),
x = c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),
y = c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE),
z = c(TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE)),
row.names = c(NA, -13L),
class = data.frame)

dat1-t(dat1)
colnames(dat1)-c(a,b,c,d,e,f,g,h,i,j,k, l,m)

dat2-dat1

dat2[]-t(apply(!dat1,1,function(x) 
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum













Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
         Provider code: 313
         Phone 776 2282
         From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/



Quoting arun smartpink...@yahoo.com:

 HI,
 
 Just a correction:
 
 :
 
 dat2[]-t(apply(!dat1,1,function(x) 
 unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum  #should also work
 A.K.
 
 
 
 - Original Message -
 From: arun smartpink...@yahoo.com
 To: Camilo Mora cm...@dal.ca
 Cc: R help r-help@r-project.org
 Sent: Wednesday, March 27, 2013 9:09 AM
 Subject: Re: [R] conditional Dataframe filling
 
 
 
 Hi,
 You could try:
 dat1- read.table(text=
 a    b    c    d
 TRUE  TRUE  TRUE  TRUE
 FALSE FALSE FALSE TRUE
 FALSE  TRUE  FALSE  FALSE
 ,sep=,header=TRUE)
 dat2-dat1
  dat2[]-t(apply(1*!dat1,1,function(x) 
 unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum
  dat2
 #  a b c d
 #1 0 0 0 0
 #2 1 2 3 0
 #3 1 0 1 2
 A.K.
 
 
 - Original Message -
 From: Camilo Mora cm...@dal.ca
 To: r-help@r-project.org
 Cc:
 Sent: Wednesday, March 27, 2013 4:31 AM
 Subject: [R] conditional Dataframe filling
 
 Hi everyone:
 
 This may be trivial but I just have not been able to figure it out.
 
 Imagine the following dataframe:
 a     b     c     d
 TRUE  TRUE  TRUE  TRUE
 FALSE FALSE FALSE TRUE
 FALSE  TRUE  FALSE  FALSE
 
 I would like to create a new dataframe, in which TRUE gets 0 but if false 
 then add 1 to the cell to the left. So the results for the example above 
 should be something like:
 
 a     b     c     d
 0     0     0     0
 1     2     3     0
 1     0     1     2
 
 I wonder if you may know?.
 
 Thanks,
 
 Camilo
 
 
 
 
 Camilo Mora, Ph.D.
 Department of Geography, University of Hawaii
 Currently available in Colombia
 Phone:   Country code: 57
          Provider code: 313
          Phone 776 2282
          From the USA or Canada you have to dial 011 57 313 776 2282
 http://www.soc.hawaii.edu/mora/
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Weighted Kaplan-Meier estimates with R

2013-03-27 Thread Thomas Lumley
On Thu, Mar 28, 2013 at 5:07 AM, rm r...@wippies.se wrote:


 While testing that I get the same results with the package survey as with
 the package survival, I encountered the issue of how to draw survival
 curves.  Apparently the implementations in the two packages differ, as I
 show below.

 I would very much welcome your views, since the tail of the survival curve
 has a major impact on the interpretation of my results. In my data, the
 last
 ‘death’ occurs at 2094 days, while the last censoring time is 3297 days.
  If
 possible, I would like to say something about the probability between 2100
 days and 3300 days.

 So, my question is that after the last observed death, in the very simple
 example below at 883 days, how should one draw the survival curve? The
 graph
 produced by svykm (package survey) ends at 883 days, whereas survfit
 (package survival) continues the graph all the way to the last censoring
 time, which is at 1022 days.



If you don't ask for standard errors, svykm() also draws the curve all the
way out to 1022 days.  The problem is with the standard error estimation
under complex sampling -- to save memory it computes the standard errors
only at event times.  It shouldn't be too hard to get it to extend that to
the last censoring time, but the reason it isn't too hard is that the curve
and standard error estimates don't change after the last failure time, so
it won't be particularly useful.

   -thomas


-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

[[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] conditional Dataframe filling

2013-03-27 Thread Camilo Mora

Thanks Arun,

Well that is interesting. My intention was to have a dataframe with  
the same number of rows in the original data, and for the rows with  
NAs, then return NA (If there are NAs, often the entire row has NAs).  
What is interesting is that in your code with NAs, the row that has  
NAs gets NAs in the output, which is what I am looking for.


I guess a solution is to subset complete rows and then run your line  
of code. Unless there is an alternative, to tell cumsum to leave NAs  
as NAs?


Thanks again,

Camilo


Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
 Provider code: 313
 Phone 776 2282
 From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/



Quoting arun smartpink...@yahoo.com:


Dear Camilo,

How do you want to deal with the NAs?

If I remove the NAs:
dat1 - structure(list(
w = c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE),
x = c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),
y =  
c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE),

z = c(TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE)),
row.names = c(NA, -13L),
class = data.frame)

dat1-t(dat1)
colnames(dat1)-c(a,b,c,d,e,f,g,h,i,j,k, l,m)
dat1- as.data.frame(na.omit(dat1))
dat2-dat1
dat2[]-t(apply(!dat1,1,function(x)  
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum

 dat2
#  a b c d e f g h i j k l m
#w 0 0 0 0 0 1 2 3 4 0 0 0 0
#y 1 2 3 4 5 0 0 1 2 0 0 0 1
#z 0 0 0 0 1 0 0 0 1 0 0 0 1


 dat1
#  a b c d e f g h i    j    k    l m
#w  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE TRUE TRUE TRUE  TRUE
#y FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE TRUE TRUE TRUE FALSE
#z  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE TRUE TRUE TRUE FALSE


A.K.





- Original Message -
From: Camilo Mora cm...@dal.ca
To: arun smartpink...@yahoo.com
Cc: R help r-help@r-project.org
Sent: Wednesday, March 27, 2013 3:27 PM
Subject: Re: [R] conditional Dataframe filling

Dear Arun,

Thank you very  much for your help with this.I did not know where to  
start looking to solve that problem, so I truly appreciate your input.


The line of code you sent seems to work but it duplicates the  
results. Do you know why that may happen?

Below is a larger database, to which I apply your line of code.

Thank you very much again,
Camilo


dat1 - structure(list(
w = c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE),
x = c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),
y =  
c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE),

z = c(TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE)),
row.names = c(NA, -13L),
class = data.frame)

dat1-t(dat1)
colnames(dat1)-c(a,b,c,d,e,f,g,h,i,j,k, l,m)

dat2-dat1

dat2[]-t(apply(!dat1,1,function(x)  
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum














Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
         Provider code: 313
         Phone 776 2282
         From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/



Quoting arun smartpink...@yahoo.com:


HI,

Just a correction:

:

dat2[]-t(apply(!dat1,1,function(x)  
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum   
#should also work

A.K.



- Original Message -
From: arun smartpink...@yahoo.com
To: Camilo Mora cm...@dal.ca
Cc: R help r-help@r-project.org
Sent: Wednesday, March 27, 2013 9:09 AM
Subject: Re: [R] conditional Dataframe filling



Hi,
You could try:
dat1- read.table(text=
a    b    c    d
TRUE  TRUE  TRUE  TRUE
FALSE FALSE FALSE TRUE
FALSE  TRUE  FALSE  FALSE
,sep=,header=TRUE)
dat2-dat1
 dat2[]-t(apply(1*!dat1,1,function(x)  
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum

 dat2
#  a b c d
#1 0 0 0 0
#2 1 2 3 0
#3 1 0 1 2
A.K.


- Original Message -
From: Camilo Mora cm...@dal.ca
To: r-help@r-project.org
Cc:
Sent: Wednesday, March 27, 2013 4:31 AM
Subject: [R] conditional Dataframe filling

Hi everyone:

This may be trivial but I just have not been able to figure it out.

Imagine the following dataframe:
a     b     c     d
TRUE  TRUE  TRUE  TRUE
FALSE FALSE FALSE TRUE
FALSE  TRUE  FALSE  FALSE

I would like to create a new dataframe, in which TRUE gets 0 but if  
false then add 1 to the cell to the left. So the results for the  
example above should be something like:


a     b     c     d
0     0     0     0
1     2     3     0
1     0     1     2

I wonder if you may know?.

Thanks,

Camilo




Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
         Provider code: 313
         Phone 776 2282
         From the USA or Canada you have to dial 011 57 313 776 2282

Re: [R] ggplot2: Controlling line width of panel borders

2013-03-27 Thread thomas . parr
This is an old post, but I had the exact problem described here and after 
two days of monkeying around in theme, I wanted to provide the non-ggplot 
related solution. 

In summary, the problem is that in the faceted plots, lines on the right an 
bottom in the subplots appear to be thicker than faceted.  This is a 
problem with the graphics device you are using (a windows x11 device I 
suspect).  I have provided a slightly more concise illustration of the 
problem. 

x11()
p - ggplot(mtcars, aes(mpg, wt)) + geom_point()
p + facet_grid(. ~ cyl)+
theme_bw()+  #drop a mostly white theme on for contrast
theme(panel.border = element_rect(fill=NA, colour = black, size=1)) #bump 
up the border size to 1, the minimum for many publications.

Now do the same with: 

pdf(file=mygraphic.pdf)
p - ggplot(mtcars, aes(mpg, wt)) + geom_point()
p + facet_grid(. ~ cyl)+
theme_bw()+  #drop a mostly white theme on for contrast
theme(panel.border = element_rect(fill=NA, colour = black, 
size=1))   #bump up the border size to 
1, the minimum for many publications.
dev.off()

This will output directly to a file so you will need to hunt it down. 
 Inspect it and you will see that there is no problem, everything looks 
exactly the way you coded it.

In short, the problem is not with ggplot.  X11(), I assume,  or some unseen 
process calling a windows graphic device is just not visually representing 
the code properly.  If you use a pdf graphics device to output the figure 
the problem goes away.  However, this means you can't view it 
instantly... but you do have a vectorized figure.

Trust your code not your graphics device.





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

2013-03-27 Thread arun
Dear Camilo,

You can do this:
dat1 - structure(list(
w = c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE),
x = c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),
y = c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE),
z = c(TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE)),
row.names = c(NA, -13L),
class = data.frame)

dat1-t(dat1)
colnames(dat1)-c(a,b,c,d,e,f,g,h,i,j,k, l,m)
dat1- as.data.frame(dat1)
dat2-dat1
dat2[rowSums(is.na(dat2))==0,]- 
t(apply(!dat1[rowSums(is.na(dat1))==0,],1,function(x) 
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum

dat2
#   a  b  c  d  e  f  g  h  i  j  k  l  m
#w  0  0  0  0  0  1  2  3  4  0  0  0  0
#x NA NA NA NA NA NA NA NA NA NA NA NA NA
#y  1  2  3  4  5  0  0  1  2  0  0  0  1
#z  0  0  0  0  1  0  0  0  1  0  0  0  1


Suppose if NAs are there but not for the entire row (if I understand 
correctly), you wanted to have the whole row NA, right.

datNew- structure(list(a = c(TRUE, NA, FALSE, TRUE, TRUE), b = c(TRUE, 
NA, FALSE, TRUE, TRUE), c = c(TRUE, NA, FALSE, TRUE, FALSE), 
    d = c(TRUE, NA, FALSE, TRUE, FALSE), e = c(TRUE, NA, FALSE, 
    FALSE, NA), f = c(FALSE, NA, TRUE, TRUE, NA), g = c(FALSE, 
    NA, TRUE, TRUE, TRUE), h = c(FALSE, NA, FALSE, TRUE, FALSE
    ), i = c(FALSE, NA, FALSE, FALSE, NA), j = c(TRUE, NA, TRUE, 
    TRUE, TRUE), k = c(TRUE, NA, TRUE, TRUE, FALSE), l = c(TRUE, 
    NA, TRUE, TRUE, FALSE), m = c(TRUE, NA, FALSE, FALSE, TRUE
    )), .Names = c(a, b, c, d, e, f, g, h, i, 
j, k, l, m), row.names = c(w, x, y, z, u), class = 
data.frame)

datNew
#  a b c d e f g h i    j k l m
#w  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE TRUE  TRUE  TRUE  TRUE
#x    NA    NA    NA    NA    NA    NA    NA    NA    NA   NA    NA    NA    NA
#y FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE TRUE  TRUE  TRUE FALSE
#z  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE TRUE  TRUE  TRUE FALSE
#u  TRUE  TRUE FALSE FALSE    NA    NA  TRUE FALSE    NA TRUE FALSE FALSE  TRUE

dat2New- datNew
dat2New[rowSums(is.na(dat2New))==0,]-t(apply(!datNew[rowSums(is.na(datNew))==0,],1,function(x)
 unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum
dat2New[rowSums(is.na(dat2New))!=0  
rowSums(is.na(dat2New))!=ncol(dat2New),]-NA
 dat2New
#   a  b  c  d  e  f  g  h  i  j  k  l  m
#w  0  0  0  0  0  1  2  3  4  0  0  0  0
#x NA NA NA NA NA NA NA NA NA NA NA NA NA
#y  1  2  3  4  5  0  0  1  2  0  0  0  1
#z  0  0  0  0  1  0  0  0  1  0  0  0  1
#u NA NA NA NA NA NA NA NA NA NA NA NA NA
A.K.






- Original Message -
From: Camilo Mora cm...@dal.ca
To: arun smartpink...@yahoo.com
Cc: R help r-help@r-project.org
Sent: Wednesday, March 27, 2013 4:10 PM
Subject: Re: [R] conditional Dataframe filling

Thanks Arun,

Well that is interesting. My intention was to have a dataframe with  
the same number of rows in the original data, and for the rows with  
NAs, then return NA (If there are NAs, often the entire row has NAs).  
What is interesting is that in your code with NAs, the row that has  
NAs gets NAs in the output, which is what I am looking for.

I guess a solution is to subset complete rows and then run your line  
of code. Unless there is an alternative, to tell cumsum to leave NAs  
as NAs?

Thanks again,

Camilo


Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
          Provider code: 313
          Phone 776 2282
          From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/



Quoting arun smartpink...@yahoo.com:

 Dear Camilo,

 How do you want to deal with the NAs?

 If I remove the NAs:
 dat1 - structure(list(
 w = c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE),
 x = c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),
 y =  
 c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE),
 z = c(TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE)),
 row.names = c(NA, -13L),
 class = data.frame)

 dat1-t(dat1)
 colnames(dat1)-c(a,b,c,d,e,f,g,h,i,j,k, l,m)
 dat1- as.data.frame(na.omit(dat1))
 dat2-dat1
 dat2[]-t(apply(!dat1,1,function(x)  
 unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum
  dat2
 #  a b c d e f g h i j k l m
 #w 0 0 0 0 0 1 2 3 4 0 0 0 0
 #y 1 2 3 4 5 0 0 1 2 0 0 0 1
 #z 0 0 0 0 1 0 0 0 1 0 0 0 1


  dat1
 #  a b c d e f g h i    j    k    l m
 #w  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE TRUE TRUE TRUE  TRUE
 #y FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE TRUE TRUE TRUE FALSE
 #z  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE TRUE TRUE TRUE FALSE


 A.K.





 - Original Message -
 From: Camilo Mora cm...@dal.ca
 To: arun smartpink...@yahoo.com
 Cc: R help r-help@r-project.org
 Sent: Wednesday, March 27, 2013 3:27 PM
 Subject: Re: [R] conditional Dataframe 

Re: [R] conditional Dataframe filling

2013-03-27 Thread Camilo Mora

Nice!.

Thanks,

Camilo

Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
 Provider code: 313
 Phone 776 2282
 From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/



Quoting arun smartpink...@yahoo.com:


Dear Camilo,

You can do this:
dat1 - structure(list(
w = c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE),
x = c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),
y =  
c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE),

z = c(TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE)),
row.names = c(NA, -13L),
class = data.frame)

dat1-t(dat1)
colnames(dat1)-c(a,b,c,d,e,f,g,h,i,j,k, l,m)
dat1- as.data.frame(dat1)
dat2-dat1
dat2[rowSums(is.na(dat2))==0,]-  
t(apply(!dat1[rowSums(is.na(dat1))==0,],1,function(x)  
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum


dat2
#   a  b  c  d  e  f  g  h  i  j  k  l  m
#w  0  0  0  0  0  1  2  3  4  0  0  0  0
#x NA NA NA NA NA NA NA NA NA NA NA NA NA
#y  1  2  3  4  5  0  0  1  2  0  0  0  1
#z  0  0  0  0  1  0  0  0  1  0  0  0  1


Suppose if NAs are there but not for the entire row (if I understand  
correctly), you wanted to have the whole row NA, right.


datNew- structure(list(a = c(TRUE, NA, FALSE, TRUE, TRUE), b = c(TRUE,
NA, FALSE, TRUE, TRUE), c = c(TRUE, NA, FALSE, TRUE, FALSE),
    d = c(TRUE, NA, FALSE, TRUE, FALSE), e = c(TRUE, NA, FALSE,
    FALSE, NA), f = c(FALSE, NA, TRUE, TRUE, NA), g = c(FALSE,
    NA, TRUE, TRUE, TRUE), h = c(FALSE, NA, FALSE, TRUE, FALSE
    ), i = c(FALSE, NA, FALSE, FALSE, NA), j = c(TRUE, NA, TRUE,
    TRUE, TRUE), k = c(TRUE, NA, TRUE, TRUE, FALSE), l = c(TRUE,
    NA, TRUE, TRUE, FALSE), m = c(TRUE, NA, FALSE, FALSE, TRUE
    )), .Names = c(a, b, c, d, e, f, g, h, i,
j, k, l, m), row.names = c(w, x, y, z, u), class =  
data.frame)


datNew
#  a b c d e f g h i    j  
k l m
#w  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE TRUE  TRUE   
TRUE  TRUE
#x    NA    NA    NA    NA    NA    NA    NA    NA    NA   NA     
NA    NA    NA
#y FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE TRUE  TRUE   
TRUE FALSE
#z  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE TRUE  TRUE   
TRUE FALSE
#u  TRUE  TRUE FALSE FALSE    NA    NA  TRUE FALSE    NA TRUE FALSE  
FALSE  TRUE


dat2New- datNew
dat2New[rowSums(is.na(dat2New))==0,]-t(apply(!datNew[rowSums(is.na(datNew))==0,],1,function(x)  
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum
dat2New[rowSums(is.na(dat2New))!=0   
rowSums(is.na(dat2New))!=ncol(dat2New),]-NA

 dat2New
#   a  b  c  d  e  f  g  h  i  j  k  l  m
#w  0  0  0  0  0  1  2  3  4  0  0  0  0
#x NA NA NA NA NA NA NA NA NA NA NA NA NA
#y  1  2  3  4  5  0  0  1  2  0  0  0  1
#z  0  0  0  0  1  0  0  0  1  0  0  0  1
#u NA NA NA NA NA NA NA NA NA NA NA NA NA
A.K.






- Original Message -
From: Camilo Mora cm...@dal.ca
To: arun smartpink...@yahoo.com
Cc: R help r-help@r-project.org
Sent: Wednesday, March 27, 2013 4:10 PM
Subject: Re: [R] conditional Dataframe filling

Thanks Arun,

Well that is interesting. My intention was to have a dataframe with
the same number of rows in the original data, and for the rows with
NAs, then return NA (If there are NAs, often the entire row has NAs).
What is interesting is that in your code with NAs, the row that has
NAs gets NAs in the output, which is what I am looking for.

I guess a solution is to subset complete rows and then run your line
of code. Unless there is an alternative, to tell cumsum to leave NAs
as NAs?

Thanks again,

Camilo


Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
          Provider code: 313
          Phone 776 2282
          From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/



Quoting arun smartpink...@yahoo.com:


Dear Camilo,

How do you want to deal with the NAs?

If I remove the NAs:
dat1 - structure(list(
w = c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE),
x = c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),
y =
c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE),
z = c(TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE)),
row.names = c(NA, -13L),
class = data.frame)

dat1-t(dat1)
colnames(dat1)-c(a,b,c,d,e,f,g,h,i,j,k, l,m)
dat1- as.data.frame(na.omit(dat1))
dat2-dat1
dat2[]-t(apply(!dat1,1,function(x)
unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum
 dat2
#  a b c d e f g h i j k l m
#w 0 0 0 0 0 1 2 3 4 0 0 0 0
#y 1 2 3 4 5 0 0 1 2 0 0 0 1
#z 0 0 0 0 1 0 0 0 1 0 0 0 1


 dat1
#  a b c d e f g h i    j     
k    l m
#w  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE TRUE TRUE  
TRUE  TRUE
#y FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE 

[R] prop.test correct true and false gives same answer

2013-03-27 Thread David Arnold
All,

How come both of these are the same.  Both say 1-sample proportions test
without continuity correction. I would suspect one would say without and
one would say with.


 prop.test(118,236,.5,correct=FALSE,conf.level=0.95)

1-sample proportions test without continuity correction

data:  118 out of 236, null probability 0.5 
X-squared = 0, df = 1, p-value = 1
alternative hypothesis: true p is not equal to 0.5 
95 percent confidence interval:
 0.4367215 0.5632785 
sample estimates:
  p 
0.5 

 prop.test(118,236,.5,correct=TRUE,conf.level=0.95)

1-sample proportions test without continuity correction

data:  118 out of 236, null probability 0.5 
X-squared = 0, df = 1, p-value = 1
alternative hypothesis: true p is not equal to 0.5 
95 percent confidence interval:
 0.4367215 0.5632785 
sample estimates:
  p 
0.5 




--
View this message in context: 
http://r.789695.n4.nabble.com/prop-test-correct-true-and-false-gives-same-answer-tp4662659.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] conditional Dataframe filling

2013-03-27 Thread arun
Hi Camilo,
No problem.

In case, you wanted to process the partial NA rows, this could help:
datNew- structure(list(a = c(TRUE, NA, FALSE, TRUE, TRUE), b = c(TRUE,
NA, FALSE, TRUE, TRUE), c = c(TRUE, NA, FALSE, TRUE, FALSE),
    d = c(TRUE, NA, FALSE, TRUE, FALSE), e = c(TRUE, NA, FALSE,
    FALSE, NA), f = c(FALSE, NA, TRUE, TRUE, NA), g = c(FALSE,
    NA, TRUE, TRUE, TRUE), h = c(FALSE, NA, FALSE, TRUE, FALSE
    ), i = c(FALSE, NA, FALSE, FALSE, NA), j = c(TRUE, NA, TRUE,
    TRUE, TRUE), k = c(TRUE, NA, TRUE, TRUE, FALSE), l = c(TRUE,
    NA, TRUE, TRUE, FALSE), m = c(TRUE, NA, FALSE, FALSE, TRUE
    )), .Names = c(a, b, c, d, e, f, g, h, i,
j, k, l, m), row.names = c(w, x, y, z, u), class = 
data.frame)
dat2New- datNew

dat2New[rowSums(is.na(dat2New))==0 | rowSums(is.na(dat2New))!=ncol(dat2New),]- 
t(apply(!datNew[rowSums(is.na(datNew))==0 | 
rowSums(is.na(datNew))!=ncol(datNew),],1,function(x) {x[!is.na(x)]- 
unlist(lapply(split(x[!is.na(x)],cumsum(c(0,abs(diff(x[!is.na(x)]),cumsum));x}))
 dat2New
#   a  b  c  d  e  f  g  h  i  j  k  l  m
#w  0  0  0  0  0  1  2  3  4  0  0  0  0
#x NA NA NA NA NA NA NA NA NA NA NA NA NA
#y  1  2  3  4  5  0  0  1  2  0  0  0  1
#z  0  0  0  0  1  0  0  0  1  0  0  0  1
#u  0  0  1  2 NA NA  0  1 NA  0  1  2  0
 datNew
#  a b c d e f g h i    j k l m
#w  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE TRUE  TRUE  TRUE  TRUE
#x    NA    NA    NA    NA    NA    NA    NA    NA    NA   NA    NA    NA    NA
#y FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE TRUE  TRUE  TRUE FALSE
#z  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE TRUE  TRUE  TRUE FALSE
#u  TRUE  TRUE FALSE FALSE    NA    NA  TRUE FALSE    NA TRUE FALSE FALSE  TRUE
 
A.K.






- Original Message -
From: Camilo Mora cm...@dal.ca
To: arun smartpink...@yahoo.com
Cc: R help r-help@r-project.org
Sent: Wednesday, March 27, 2013 4:49 PM
Subject: Re: [R] conditional Dataframe filling

Nice!.

Thanks,

Camilo

Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
          Provider code: 313
          Phone 776 2282
          From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/



Quoting arun smartpink...@yahoo.com:

 Dear Camilo,

 You can do this:
 dat1 - structure(list(
 w = c(TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE),
 x = c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),
 y =  
 c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE),
 z = c(TRUE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE)),
 row.names = c(NA, -13L),
 class = data.frame)

 dat1-t(dat1)
 colnames(dat1)-c(a,b,c,d,e,f,g,h,i,j,k, l,m)
 dat1- as.data.frame(dat1)
 dat2-dat1
 dat2[rowSums(is.na(dat2))==0,]-  
 t(apply(!dat1[rowSums(is.na(dat1))==0,],1,function(x)  
 unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum

 dat2
 #   a  b  c  d  e  f  g  h  i  j  k  l  m
 #w  0  0  0  0  0  1  2  3  4  0  0  0  0
 #x NA NA NA NA NA NA NA NA NA NA NA NA NA
 #y  1  2  3  4  5  0  0  1  2  0  0  0  1
 #z  0  0  0  0  1  0  0  0  1  0  0  0  1


 Suppose if NAs are there but not for the entire row (if I understand  
 correctly), you wanted to have the whole row NA, right.

 datNew- structure(list(a = c(TRUE, NA, FALSE, TRUE, TRUE), b = c(TRUE,
 NA, FALSE, TRUE, TRUE), c = c(TRUE, NA, FALSE, TRUE, FALSE),
     d = c(TRUE, NA, FALSE, TRUE, FALSE), e = c(TRUE, NA, FALSE,
     FALSE, NA), f = c(FALSE, NA, TRUE, TRUE, NA), g = c(FALSE,
     NA, TRUE, TRUE, TRUE), h = c(FALSE, NA, FALSE, TRUE, FALSE
     ), i = c(FALSE, NA, FALSE, FALSE, NA), j = c(TRUE, NA, TRUE,
     TRUE, TRUE), k = c(TRUE, NA, TRUE, TRUE, FALSE), l = c(TRUE,
     NA, TRUE, TRUE, FALSE), m = c(TRUE, NA, FALSE, FALSE, TRUE
     )), .Names = c(a, b, c, d, e, f, g, h, i,
 j, k, l, m), row.names = c(w, x, y, z, u), class =  
 data.frame)

 datNew
 #  a b c d e f g h i    j  
 k l m
 #w  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE TRUE  TRUE   
 TRUE  TRUE
 #x    NA    NA    NA    NA    NA    NA    NA    NA    NA   NA 
 NA    NA    NA
 #y FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE FALSE FALSE TRUE  TRUE   
 TRUE FALSE
 #z  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE TRUE  TRUE   
 TRUE FALSE
 #u  TRUE  TRUE FALSE FALSE    NA    NA  TRUE FALSE    NA TRUE FALSE  
 FALSE  TRUE

 dat2New- datNew
 dat2New[rowSums(is.na(dat2New))==0,]-t(apply(!datNew[rowSums(is.na(datNew))==0,],1,function(x)
   
 unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum
 dat2New[rowSums(is.na(dat2New))!=0   
 rowSums(is.na(dat2New))!=ncol(dat2New),]-NA
  dat2New
 #   a  b  c  d  e  f  g  h  i  j  k  l  m
 #w  0  0  0  0  0  1  2  3  4  0  0  0  0
 #x NA NA NA NA NA NA NA NA NA NA NA NA NA
 #y  1  2  3  4  5  0  0  1  2  0  0  0  1
 #z  0  0  0  0  1  0  0  0  1  0  0  0  1
 #u NA NA NA NA NA NA NA NA 

Re: [R] prop.test correct true and false gives same answer

2013-03-27 Thread Albyn Jones
?prop.test is helpful.

Continuity correction is used only if it does not exceed the
difference between sample and null proportions in absolute value.

albyn

On Wed, Mar 27, 2013 at 02:04:51PM -0700, David Arnold wrote:
 All,
 
 How come both of these are the same.  Both say 1-sample proportions test
 without continuity correction. I would suspect one would say without and
 one would say with.
 
 
  prop.test(118,236,.5,correct=FALSE,conf.level=0.95)
 
   1-sample proportions test without continuity correction
 
 data:  118 out of 236, null probability 0.5 
 X-squared = 0, df = 1, p-value = 1
 alternative hypothesis: true p is not equal to 0.5 
 95 percent confidence interval:
  0.4367215 0.5632785 
 sample estimates:
   p 
 0.5 
 
  prop.test(118,236,.5,correct=TRUE,conf.level=0.95)
 
   1-sample proportions test without continuity correction
 
 data:  118 out of 236, null probability 0.5 
 X-squared = 0, df = 1, p-value = 1
 alternative hypothesis: true p is not equal to 0.5 
 95 percent confidence interval:
  0.4367215 0.5632785 
 sample estimates:
   p 
 0.5 
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/prop-test-correct-true-and-false-gives-same-answer-tp4662659.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.
 

-- 
Albyn Jones
Reed College
jo...@reed.edu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Archieve of mails from R forum

2013-03-27 Thread Katherine Gobin
Dear Sir,

Thanks a lot for the input. I am sure it will go a long way for me to 
understand R.

Thanks again.

Regards

Katherine

--- On Wed, 27/3/13, Mason ma...@verbasoftware.com wrote:

From: Mason ma...@verbasoftware.com
Subject: Re: [R] Archieve of mails from R forum
To: Marc Schwartz marc_schwa...@me.com
Cc: Katherine Gobin katherine_go...@yahoo.com, r-help@r-project.org help 
r-help@r-project.org
Date: Wednesday, 27 March, 2013, 7:30 PM

http://r-help.markmail.org/ has a nice interface for searching the archives, 
too.

On Wed, Mar 27, 2013 at 12:18 PM, Marc Schwartz marc_schwa...@me.com wrote:



On Mar 27, 2013, at 1:58 PM, Katherine Gobin katherine_go...@yahoo.com wrote:



 Dear R helpers,



 Everyday I do receive many many mails from R forum and after some period of 
 times, INBOX is filled with numerous mails. At times if for some period of 
 time, I haven't accessed mails, it becomes difficult to keep track of mails 
 and many times simply due to the volume (and owing to the lack of time due to 
 office constraints), I have to simply delete the mails without opening them 
 and I understand this is a huge loss.




 If in case I wish to refer to all the old emails that have been appeared in 
 the R forum, where do I get these? Is there any list where I will get 
 subject-wise of thread-wise archive of old emails? I understand that will be 
 an ocean of quality information and one can learn a lot from these old mails 
 and I don't need to keep track of my emails all the time.






 Kindly guide.



 Regards



 Katherine





The official archives for R-Help are here:



  https://stat.ethz.ch/pipermail/r-help/



and these are mirrored in various locations, such as:



  http://www.mail-archive.com/r-help@stat.math.ethz.ch/

  http://dir.gmane.org/gmane.comp.lang.r.general



You can also search the archives for all R lists at:



  http://rseek.org/

  http://finzi.psych.upenn.edu/search.html

  http://tolstoy.newcastle.edu.au/R/





My recommendation would be to set up a mail filter or rule (using 
r-help@r-project.org in the the sender and cc: address fields) so that the list 
e-mails are automatically moved from your main inbox to a folder just for these 
e-mails and you can then browse them as your schedule permits, rather than 
having them interspersed with other e-mails in the same location. I do this 
with a number of the R related lists and have a folder for each one to keep 
them separated. Most e-mail clients and/or online services have some type of 
filtering or rule configuration available to do this.




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.




[[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] A simple perceptron neural network (nnet)

2013-03-27 Thread Arturo HULK
can u explain me, how it works your code??? please. i´m also doing a simple
perceptron for homework on R and i dont know where to start.

[[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] prop.test correct true and false gives same answer

2013-03-27 Thread Ted Harding
On 27-Mar-2013 21:04:51 David Arnold wrote:
 All,
 How come both of these are the same.  Both say 1-sample proportions
 test without continuity correction. I would suspect one would say
 without and one would say with.
 
 
 prop.test(118,236,.5,correct=FALSE,conf.level=0.95)
 
   1-sample proportions test without continuity correction
 
 data:  118 out of 236, null probability 0.5 
 X-squared = 0, df = 1, p-value = 1
 alternative hypothesis: true p is not equal to 0.5 
 95 percent confidence interval:
  0.4367215 0.5632785 
 sample estimates:
   p 
 0.5 
 
 prop.test(118,236,.5,correct=TRUE,conf.level=0.95)
 
   1-sample proportions test without continuity correction
 
 data:  118 out of 236, null probability 0.5 
 X-squared = 0, df = 1, p-value = 1
 alternative hypothesis: true p is not equal to 0.5 
 95 percent confidence interval:
  0.4367215 0.5632785 
 sample estimates:
   p 
 0.5

Note what is said (admittedly somewhat deeply tucked away)
under Details in ?prop.test:

 Continuity correction is used only if it does not exceed
  the difference between sample and null proportions
  in absolute value.

In your example, the sample proportion exactly matches the
null-hypothesis proportion (0.5).

Confirmation:
[A] Your same example:
  prop.test(118,236,.5,correct=TRUE,conf.level=0.95)
  # 1-sample proportions test without continuity correction
  # data:  118 out of 236, null probability 0.5 
  # X-squared = 0, df = 1, p-value = 1
  # alternative hypothesis: true p is not equal to 0.5 
  # 95 percent confidence interval:
  #  0.4367215 0.5632785 
  # sample estimates:
  #   p 
  # 0.5 

[B1] Slightly change x, but keep correct=TRUE:
  prop.test(117,236,.5,correct=TRUE,conf.level=0.95)
  # 1-sample proportions test with continuity correction
  # data:  117 out of 236, null probability 0.5 
  # X-squared = 0.0042, df = 1, p-value = 0.9481
  # alternative hypothesis: true p is not equal to 0.5 
  # 95 percent confidence interval:
  #  0.4304724 0.5611932 
  # sample estimates:
  # p 
  # 0.4957627 

[B2] Slightly change x, but now correct=FALSE:
  prop.test(117,236,.5,correct=FALSE,conf.level=0.95)
  # 1-sample proportions test without continuity correction
  # data:  117 out of 236, null probability 0.5 
  # X-squared = 0.0169, df = 1, p-value = 0.8964
  # alternative hypothesis: true p is not equal to 0.5 
  # 95 percent confidence interval:
  #  0.4325543 0.5591068 
  # sample estimates:
  # p 
  # 0.4957627 

So it doesn't do the requested continuity correction in [A] because
there is no need to. But in [B1] it makes a difference (compare
with [B2]), so it does it.

Hoping this helps,
Ted.

-
E-Mail: (Ted Harding) ted.hard...@wlandres.net
Date: 27-Mar-2013  Time: 21:21:39
This message was sent by 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.


Re: [R] Odd graphic device behavior

2013-03-27 Thread peter dalgaard

On Mar 27, 2013, at 19:26 , Thomas Adams wrote:

 Peter,
 
 Thank you. 
 
 When I run: X11(width=7, height=7), I get the same full-screen graphics 
 device window.
 Running dev.list() gives me X11cairo
 Running system(xdpyinfo) looks reasonable
 
 I tried running options(device=x11) at the R prompt, but this did not seem 
 to change anything.

And X11.options() said what?

 
 When I started R with R --vanilla and then did:
 
  require(stats)
   plot(cars)
 
 I got:
 
 Error in plot.new() : figure margins too large
 
 ... but the window was a reasonable size. However, after I resized the 
 graphics device window modestly and re-ran plot(cars), the plot was generated 
 in the resized window, but the lettering was large as before and the lines 
 were thick as they were previously.

Something's clearly up with the device's notion of pointsize. Or inches.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.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] ::manzhang::

2013-03-27 Thread Man Zhang
http://www.signdesignbooks.com/acsw/df.km?flnu

  
 



Man Zhang





























































  3/27/2013 11:31:04 PM
 






















bf
 
iopo rarv rsh atzwnxfqoijhcwndgcyyyvtllyxaqkmiftoh  hhtshnfaeaoeqixpkgebigw
cjbvhl

[[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] Passing arguments between apply and l(s)apply functions vs. nested for loop

2013-03-27 Thread Mark Orr
Hi R community, 
I have a question concerning passing arguments between apply and lapply?  Or 
maybe, once my problem is explained, the question is really about how to best 
transform my nested for loops into list/matrix operations;  I am just beginning 
this transformation away from nested  for  loops, so I beg of you to have some 
lenience regarding my ignorance.

Part I:
I used a set of nested for loops for a computation, which works as fine as it 
is slow--very slow.  My needs are on the order of about 2 iterations; in 
nested loop format this is millions of calculations.   To give you a sense of 
what I'm trying to do, it may help to first see the nested for loop (this code 
is run-able via copy-and-paste):

#START CODE SNIPPET

#LIST AND VECTOR
rm(list=ls())
l - list(1:3,2:3,4:10,7:9)
v - 1:3

#USED IN j loop to catch values
catch.mat - matrix(NA,nrow=length(v),ncol=length(l))

#LOOPS
for (i in 1:length(v)){
  for (j in 1:length(l)) {
catch.mat[i,j] - sum(l[[j]]==i)
  }
}

#SIMPLY APPLY OVER catch.mat
catch.all - apply(catch.mat,1,sum) 

catch.mat
catch.all

#END CODE SNIPPET

This does exactly what I want,  catch.all provides the number of elements in 
 l  for which each element of  v  is a member, given the constraint that 
within each element in  l  the sub-elements are unique.


Part II:  
However, for my data set it takes about 3 days to run.  So, I stumbled onto 
list and matrix operations (apply family of functions) and have been working to 
coerce my code above into an apply-like format.  Here is my best example (of 
several failings of different sorts), after trying for several hours and 
reading much on the web and in some books: 


#THIS CODE SNIPPET IS PASTE-ABLE AFTER RUNNING FIRST SNIPPET ABOVE

#SIMPLE TEST TO SHOW THAT apply is passing elements from mat.1 to f.1
f.1 - function(x){
  i - x
  print(x)
  print(i)
}

mat.1 - matrix(1:2318,nrow=1,ncol=2318)
apply(mat.1,1,f.1)

#THAT GAVE EXPECTED RESULTS

#THEN I ADD A NEW FUNCTION
f.2 - function(x,l=l){
  i - x
  rm(x)
  return(sum(lapply(l,function(x) sum(x==i
}

mat.1 - matrix(1:2318,nrow=1,ncol=2318)
apply(mat.1,1,f.2)

#BUT GET ERROR
# apply(mat.1,1,f.2)
#Error in lapply(l, function(x) sum(x == i)) : 
# promise already under evaluation: recursive default argument reference or 
earlier problems?

#BUT I KNOW THAT the lapply in f.2 works
sapply(l,function(x) sum(x==2))
sum(sapply(l,function(x) sum(x==2)))

#END CODE SNIPPET


I Am totally stuck, as I really don't understand the internals of R or S well 
enough to get a sense of what is the root of this problem in my code.

I would appreciate some guidance by example, not by reference.  I don't think 
further reading of existing texts, unless extremely basic, is going to help me. 
 

Thanks, 
Mark Orr


Mark G. Orr, Ph.D.
Epidemiology Merit Fellow
Assoc. Research Scientist
Columbia Univ.-Mailman Sch. Public Health
Department of Epidemiology
722 W. 168th St., RM 528
New York, NY

T:  212-305-3815
F:  212-342-5168

mo2...@columbia.edu

http://chbdlab.org/



[[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] lmer, p-values and all that

2013-03-27 Thread Michael Grant

Dear Help:

I am trying to follow Professor Bates' recommendation, quoted by Professor 
Crawley in The R Book, p629, to determine whether I should model data using the 
'plain old' lm function or the mixed model function lmer by using the syntax 
anova(lmModel,lmerModel).  Apparently I've not understood the recommendation or 
the proper likelihood ratio test in question (or both) for I get this error 
message: Error: $ operator not defined for this S4 class.

Would someone be kind enough to point out my blunder?

Thank you,
Michael Grant


[[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 interactive networks in R

2013-03-27 Thread Sachinthaka Abeywardana
Hi all,

I was wondering if there was package/ tutorial somewhere so that I can
plot INTERACTIVE networks in R. What I mean by interactive is that you
can zoom in, twist and rotate, and if necessary move nodes around.

Any thoughts?

Thanks,
Sachin

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

2013-03-27 Thread Peter Maclean
 
After installing updated twitteR and ROAuth, I am still getting the same error 
as stated in these links. As there anyone who has been able to solve the 
prolem? Suggested solution do not work.
 
http://stackoverflow.com/questions/9916283/twitter-roauth-and-windows-register-ok-but-certificate-verify-failed
 
http://stackoverflow.com/questions/7411215/oauth-authentication-with-twitter-api-failed
 

Peter Maclean
Department of Economics
UDSM
[[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] Archieve of mails from R forum

2013-03-27 Thread David Winsemius

On Mar 27, 2013, at 12:18 PM, Marc Schwartz wrote:

 
 On Mar 27, 2013, at 1:58 PM, Katherine Gobin katherine_go...@yahoo.com 
 wrote:
 
 Dear R helpers,
 
 Everyday I do receive many many mails from R forum and after some period of 
 times, INBOX is filled with numerous mails. At times if for some period of 
 time, I haven't accessed mails, it becomes difficult to keep track of mails 
 and many times simply due to the volume (and owing to the lack of time due 
 to office constraints), I have to simply delete the mails without opening 
 them and I understand this is a huge loss.
 
 If in case I wish to refer to all the old emails that have been appeared in 
 the R forum, where do I get these? Is there any list where I will get 
 subject-wise of thread-wise archive of old emails? I understand that will be 
 an ocean of quality information and one can learn a lot from these old mails 
 and I don't need to keep track of my emails all the time.
 
 
 Kindly guide.
 
 Regards
 
 Katherine
 
 
 The official archives for R-Help are here:
 
  https://stat.ethz.ch/pipermail/r-help/
 
 and these are mirrored in various locations, such as:
 
  http://www.mail-archive.com/r-help@stat.math.ethz.ch/
  http://dir.gmane.org/gmane.comp.lang.r.general
 
 You can also search the archives for all R lists at:
 
  http://rseek.org/
  http://finzi.psych.upenn.edu/search.html

Sadly, the finzi.psych repository is no longer archiving rhelp and hasn't been 
doing so for several years.

  http://tolstoy.newcastle.edu.au/R/

I was glad you didn't link to Nabble, which is neither an archive and has been 
a portal for spam.

 My recommendation would be to set up a mail filter or rule (using 
 r-help@r-project.org in the the sender and cc: address fields) so that the 
 list e-mails are automatically moved from your main inbox to a folder just 
 for these e-mails and you can then browse them as your schedule permits, 
 rather than having them interspersed with other e-mails in the same location. 
 I do this with a number of the R related lists and have a folder for each one 
 to keep them separated. Most e-mail clients and/or online services have some 
 type of filtering or rule configuration available to do this.
 
 Regards,
 
 Marc Schwartz
-- 

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Archieve of mails from R forum

2013-03-27 Thread Marc Schwartz

On Mar 27, 2013, at 7:53 PM, David Winsemius dwinsem...@comcast.net wrote:

 
 On Mar 27, 2013, at 12:18 PM, Marc Schwartz wrote:
 
 
 On Mar 27, 2013, at 1:58 PM, Katherine Gobin katherine_go...@yahoo.com 
 wrote:
 
 Dear R helpers,
 
 Everyday I do receive many many mails from R forum and after some period of 
 times, INBOX is filled with numerous mails. At times if for some period of 
 time, I haven't accessed mails, it becomes difficult to keep track of mails 
 and many times simply due to the volume (and owing to the lack of time due 
 to office constraints), I have to simply delete the mails without opening 
 them and I understand this is a huge loss.
 
 If in case I wish to refer to all the old emails that have been appeared in 
 the R forum, where do I get these? Is there any list where I will get 
 subject-wise of thread-wise archive of old emails? I understand that will 
 be an ocean of quality information and one can learn a lot from these old 
 mails and I don't need to keep track of my emails all the time.
 
 
 Kindly guide.
 
 Regards
 
 Katherine
 
 
 The official archives for R-Help are here:
 
 https://stat.ethz.ch/pipermail/r-help/
 
 and these are mirrored in various locations, such as:
 
 http://www.mail-archive.com/r-help@stat.math.ethz.ch/
 http://dir.gmane.org/gmane.comp.lang.r.general
 
 You can also search the archives for all R lists at:
 
 http://rseek.org/
 http://finzi.psych.upenn.edu/search.html
 
 Sadly, the finzi.psych repository is no longer archiving rhelp and hasn't 
 been doing so for several years.


Ah, ok. Interesting. I had not used it in quite some time, in deference to 
using rseek.org. Thanks for the heads up David.


 
 http://tolstoy.newcastle.edu.au/R/
 
 I was glad you didn't link to Nabble, which is neither an archive and has 
 been a portal for spam.


Yeah. As R-Devel co-moderator, I am well aware of that. No reasons to drive 
more traffic there... :-)

Regards,

Marc


 
 My recommendation would be to set up a mail filter or rule (using 
 r-help@r-project.org in the the sender and cc: address fields) so that the 
 list e-mails are automatically moved from your main inbox to a folder just 
 for these e-mails and you can then browse them as your schedule permits, 
 rather than having them interspersed with other e-mails in the same 
 location. I do this with a number of the R related lists and have a folder 
 for each one to keep them separated. Most e-mail clients and/or online 
 services have some type of filtering or rule configuration available to do 
 this.
 
 Regards,
 
 Marc Schwartz
 -- 
 
 David Winsemius
 Alameda, CA, USA
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] lmer, p-values and all that

2013-03-27 Thread Ben Bolker
Michael Grant michael.grant at colorado.edu writes:

 
 
 Dear Help:
 
 I am trying to follow Professor Bates' recommendation, quoted by
 Professor Crawley in The R Book, p629, to determine whether I should
 model data using the 'plain old' lm function or the mixed model
 function lmer by using the syntax anova(lmModel,lmerModel).
 Apparently I've not understood the recommendation or the proper
 likelihood ratio test in question (or both) for I get this error
 message: Error: $ operator not defined for this S4 class.

  I don't have the R Book handy (some more context would be extremely
useful!  I would think it would count as fair use to quote the
passage you're referring to ...)
 
 Would someone be kind enough to point out my blunder?

  You should probably repost this to the r-sig-mixed-mod...@r-project.org
mailing list.

  My short answer would be: (1) I don't think you can actually
use anova() to compare likelihoods between lm() and lme()/lmer()
fits in the way that you want: *maybe* for lme() [don't recall],
but almost certainly not for lmer().  See http://glmm.wikidot.com/faq
for methods for testing significance/inclusion of random factors
(short answer: you should *generally* try to make the decision
whether to include random factors or not on _a priori_ grounds,
not on the basis of statistical tests ...)

  Ben Bolker

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

2013-03-27 Thread David Winsemius

On Mar 27, 2013, at 7:00 PM, Ben Bolker wrote:

 Michael Grant michael.grant at colorado.edu writes:
 
 
 
 Dear Help:
 
 I am trying to follow Professor Bates' recommendation, quoted by
 Professor Crawley in The R Book, p629, to determine whether I should
 model data using the 'plain old' lm function or the mixed model
 function lmer by using the syntax anova(lmModel,lmerModel).
 Apparently I've not understood the recommendation or the proper
 likelihood ratio test in question (or both) for I get this error
 message: Error: $ operator not defined for this S4 class.
 
  I don't have the R Book handy (some more context would be extremely
 useful!  I would think it would count as fair use to quote the
 passage you're referring to ...)

This is the quoted Rhelp entry:

http://tolstoy.newcastle.edu.au/R/help/05/01/10006.html

(I'm unable to determine whether it applies to the question at hand.)

 
 Would someone be kind enough to point out my blunder?
 
  You should probably repost this to the r-sig-mixed-mod...@r-project.org
 mailing list.
 
  My short answer would be: (1) I don't think you can actually
 use anova() to compare likelihoods between lm() and lme()/lmer()
 fits in the way that you want: *maybe* for lme() [don't recall],
 but almost certainly not for lmer().  See http://glmm.wikidot.com/faq
 for methods for testing significance/inclusion of random factors
 (short answer: you should *generally* try to make the decision
 whether to include random factors or not on _a priori_ grounds,
 not on the basis of statistical tests ...)
 
  Ben Bolker
 

-- 
David Winsemius
Alameda, CA, USA

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

2013-03-27 Thread Nicole Ford
i literally just ran one.

when i ran one of mine and the did summary(mod) i get the following:

 mod - lmer(dem ~ xbar + cpi + (1 | country), data=wvsAB)
 summary(mod)
Linear mixed model fit by REML 
Formula: dem ~ xbar + cpi + (1 | country) 
   Data: wvsAB 
   AIC   BIC logLik deviance REMLdev
 34383 34418 -1718734355   34373
Random effects:
 Groups   NameVariance Std.Dev.

with a bunch more stuff below.


On Mar 27, 2013, at 10:00 PM, Ben Bolker wrote:

 Michael Grant michael.grant at colorado.edu writes:
 
 
 
 Dear Help:
 
 I am trying to follow Professor Bates' recommendation, quoted by
 Professor Crawley in The R Book, p629, to determine whether I should
 model data using the 'plain old' lm function or the mixed model
 function lmer by using the syntax anova(lmModel,lmerModel).
 Apparently I've not understood the recommendation or the proper
 likelihood ratio test in question (or both) for I get this error
 message: Error: $ operator not defined for this S4 class.
 
  I don't have the R Book handy (some more context would be extremely
 useful!  I would think it would count as fair use to quote the
 passage you're referring to ...)
 
 Would someone be kind enough to point out my blunder?
 
  You should probably repost this to the r-sig-mixed-mod...@r-project.org
 mailing list.
 
  My short answer would be: (1) I don't think you can actually
 use anova() to compare likelihoods between lm() and lme()/lmer()
 fits in the way that you want: *maybe* for lme() [don't recall],
 but almost certainly not for lmer().  See http://glmm.wikidot.com/faq
 for methods for testing significance/inclusion of random factors
 (short answer: you should *generally* try to make the decision
 whether to include random factors or not on _a priori_ grounds,
 not on the basis of statistical tests ...)
 
  Ben Bolker
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] lmer, p-values and all that

2013-03-27 Thread Nicole Ford
i meant to add, i am not sure if an example lmer model woulf be helpful, 
since i can't see the OP.


On Mar 27, 2013, at 10:13 PM, Nicole Ford wrote:

 i literally just ran one.
 
 when i ran one of mine and the did summary(mod) i get the following:
 
 mod - lmer(dem ~ xbar + cpi + (1 | country), data=wvsAB)
 summary(mod)
 Linear mixed model fit by REML 
 Formula: dem ~ xbar + cpi + (1 | country) 
   Data: wvsAB 
   AIC   BIC logLik deviance REMLdev
 34383 34418 -1718734355   34373
 Random effects:
 Groups   NameVariance Std.Dev.
 
 with a bunch more stuff below.
 
 
 On Mar 27, 2013, at 10:00 PM, Ben Bolker wrote:
 
 Michael Grant michael.grant at colorado.edu writes:
 
 
 
 Dear Help:
 
 I am trying to follow Professor Bates' recommendation, quoted by
 Professor Crawley in The R Book, p629, to determine whether I should
 model data using the 'plain old' lm function or the mixed model
 function lmer by using the syntax anova(lmModel,lmerModel).
 Apparently I've not understood the recommendation or the proper
 likelihood ratio test in question (or both) for I get this error
 message: Error: $ operator not defined for this S4 class.
 
 I don't have the R Book handy (some more context would be extremely
 useful!  I would think it would count as fair use to quote the
 passage you're referring to ...)
 
 Would someone be kind enough to point out my blunder?
 
 You should probably repost this to the r-sig-mixed-mod...@r-project.org
 mailing list.
 
 My short answer would be: (1) I don't think you can actually
 use anova() to compare likelihoods between lm() and lme()/lmer()
 fits in the way that you want: *maybe* for lme() [don't recall],
 but almost certainly not for lmer().  See http://glmm.wikidot.com/faq
 for methods for testing significance/inclusion of random factors
 (short answer: you should *generally* try to make the decision
 whether to include random factors or not on _a priori_ grounds,
 not on the basis of statistical tests ...)
 
 Ben Bolker
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] lmer, p-values and all that

2013-03-27 Thread Nicole Ford
i did find this for you, down towards the end, they discuss the anova method.

i am on my way to a bayesian analysis/lmer is a step towards that- so i won't 
be doing anova.  i can't be of much specific help with that question, but here 
you go.

https://stat.ethz.ch/pipermail/r-sig-mixed-models/2011q1/015591.html
On Mar 27, 2013, at 10:13 PM, Nicole Ford wrote:

 i literally just ran one.
 
 when i ran one of mine and the did summary(mod) i get the following:
 
 mod - lmer(dem ~ xbar + cpi + (1 | country), data=wvsAB)
 summary(mod)
 Linear mixed model fit by REML 
 Formula: dem ~ xbar + cpi + (1 | country) 
   Data: wvsAB 
   AIC   BIC logLik deviance REMLdev
 34383 34418 -1718734355   34373
 Random effects:
 Groups   NameVariance Std.Dev.
 
 with a bunch more stuff below.
 
 
 On Mar 27, 2013, at 10:00 PM, Ben Bolker wrote:
 
 Michael Grant michael.grant at colorado.edu writes:
 
 
 
 Dear Help:
 
 I am trying to follow Professor Bates' recommendation, quoted by
 Professor Crawley in The R Book, p629, to determine whether I should
 model data using the 'plain old' lm function or the mixed model
 function lmer by using the syntax anova(lmModel,lmerModel).
 Apparently I've not understood the recommendation or the proper
 likelihood ratio test in question (or both) for I get this error
 message: Error: $ operator not defined for this S4 class.
 
 I don't have the R Book handy (some more context would be extremely
 useful!  I would think it would count as fair use to quote the
 passage you're referring to ...)
 
 Would someone be kind enough to point out my blunder?
 
 You should probably repost this to the r-sig-mixed-mod...@r-project.org
 mailing list.
 
 My short answer would be: (1) I don't think you can actually
 use anova() to compare likelihoods between lm() and lme()/lmer()
 fits in the way that you want: *maybe* for lme() [don't recall],
 but almost certainly not for lmer().  See http://glmm.wikidot.com/faq
 for methods for testing significance/inclusion of random factors
 (short answer: you should *generally* try to make the decision
 whether to include random factors or not on _a priori_ grounds,
 not on the basis of statistical tests ...)
 
 Ben Bolker
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


Re: [R] lmer, p-values and all that

2013-03-27 Thread Ben Bolker
On 13-03-27 10:10 PM, David Winsemius wrote:
 
 On Mar 27, 2013, at 7:00 PM, Ben Bolker wrote:
 
 Michael Grant michael.grant at colorado.edu writes:
 Dear Help:

 I am trying to follow Professor Bates' recommendation, quoted by
 Professor Crawley in The R Book, p629, to determine whether I should
 model data using the 'plain old' lm function or the mixed model
 function lmer by using the syntax anova(lmModel,lmerModel).
 Apparently I've not understood the recommendation or the proper
 likelihood ratio test in question (or both) for I get this error
 message: Error: $ operator not defined for this S4 class.

  I don't have the R Book handy (some more context would be extremely
 useful!  I would think it would count as fair use to quote the
 passage you're referring to ...)
 
 This is the quoted Rhelp entry:
 
 http://tolstoy.newcastle.edu.au/R/help/05/01/10006.html
 
 (I'm unable to determine whether it applies to the question at hand.)

  OK, I misspoke -- sorry.  I think the lmer()/lme() likelihoods are
actually comparable; it's GLMMs (glmer(), with no analogue in lme()-land
except
for MASS::glmmPQL, which doesn't give you log-likelihoods at all)
where the problem arises.

  You can (1) use lme(), (2)  look at http://glmm.wikidot.com/faq for
suggestions about testing random-effects terms (including perhaps
don't do it at all), or (3) construct the likelihood ratio test
yourself as follows:

library(nlme)
data(Orthodont)
fm1 - lme(distance~age,random=~1|Subject,data=Orthodont)
fm0 - lm(distance~age,data=Orthodont)
anova(fm1,fm0)[[p-value]]
detach(package:nlme,unload=TRUE)
library(lme4.0) ## stable version of lme4
fm2 - lmer(distance~age+(1|Subject),data=Orthodont,REML=FALSE)
anova(fm2,fm0) ## fails
ddiff - -2*c(logLik(fm0)-logLik(fm2))
pchisq(ddiff,1,lower.tail=FALSE)
## not identical to above but close enough

 

 Would someone be kind enough to point out my blunder?

  You should probably repost this to the r-sig-mixed-mod...@r-project.org
 mailing list.

  My short answer would be: (1) I don't think you can actually
 use anova() to compare likelihoods between lm() and lme()/lmer()
 fits in the way that you want: *maybe* for lme() [don't recall],
 but almost certainly not for lmer().  See http://glmm.wikidot.com/faq
 for methods for testing significance/inclusion of random factors
 (short answer: you should *generally* try to make the decision
 whether to include random factors or not on _a priori_ grounds,
 not on the basis of statistical tests ...)

  Ben Bolker



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Passing arguments between apply and l(s)apply functions vs. nested for loop

2013-03-27 Thread Charles Berry
Mark Orr mo2259 at columbia.edu writes:

 
 Hi R community, 
 I have a question concerning passing arguments between apply and lapply?
[snip]
 
 #START CODE SNIPPET
 
 #LIST AND VECTOR
 rm(list=ls())
 l - list(1:3,2:3,4:10,7:9)
 v - 1:3
 
 #USED IN j loop to catch values
 catch.mat - matrix(NA,nrow=length(v),ncol=length(l))
 
 #LOOPS
 for (i in 1:length(v)){
   for (j in 1:length(l)) {
 catch.mat[i,j] - sum(l[[j]]==i)
   }
 }
 
 #SIMPLY APPLY OVER catch.mat
 catch.all - apply(catch.mat,1,sum) 
 
 catch.mat
 catch.all
 

Given the constraint you state about uniqueness,

 table(factor(unlist(l),v))

1 2 3 
1 2 2 

gives the same answer as catch.all --- up to names which you can 
remove with unname(table(factor(unlist(l),v)))


[deleted]
 
 #THEN I ADD A NEW FUNCTION
 f.2 - function(x,l=l){
   i - x
   rm(x)
   return(sum(lapply(l,function(x) sum(x==i
 }
 
 mat.1 - matrix(1:2318,nrow=1,ncol=2318)
 apply(mat.1,1,f.2)
 
 #BUT GET ERROR
 # apply(mat.1,1,f.2)
 #Error in lapply(l, function(x) sum(x == i)) : 
 # promise already under evaluation: recursive default argument reference or
earlier problems?


Always helps to ponder the error message --- 'recursive default argument'.

Here is an example:

foo - function(x=x) x

 foo() ## here it comes again!
Error in foo() : 
  promise already under evaluation: recursive default argument reference 
  or earlier problems?
 foo(1) # this works
[1] 1
 

The default is what you use when the argument is not given in the call.

And x=x confuses the evaluator. 

You can avoid confusion by choosing a different name like this:

 foo - function(xx=x) xx
 x - 3
 foo()
[1] 3
 


[rest deleted]

HTH,

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

2013-03-27 Thread Lauren Zhang
Hi,
I met tough problems when calling R in PHP. I have tried several ways, but none 
of them succeed. 
first of all, I tried Rserve, but I failed to connect to it.
Then, I tried cmd.exe. I get the result when I use R CMD BATCH --vanilla... 
in cmd, but I have no idea how to call cmd in php.
I know system() is good to call other systems, I triedbut I get no result in 
my html page.
if you could provide some suggestion or examples, i would appreciate your help.

the code in my php is:
$cmd=R CMD BATCH--vanilla --slave delete.r;
$res=system($cmd);

the code in the delete.r file is:
setwd(c://wamp//www//analysis);
x-4;
y-3;
z-x*y;
sink(125.txt);
png(file=125.png);
barplot(z,border=dark blue)
title(main=list(earning of comparison,font=4));
plot(x,z);
dev.off()

[[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] CRAN R Help

2013-03-27 Thread arun
Dear Katherine,

For your first question:

If you are creating these files in a specific folder, then
list.files()
#[1] Individual_Present_Value_BONDS.csv  Individual_Present_Value_Equity.csv
#[3] Individual_Present_Value_FOREX.csv 

gives you which files are present.  But, suppose you have other files too in 
the folder and you want to check only the above mentioned files.

I added one more file in the working folder.
 list.files()
#[1] Individual_Present_Value_BONDS.csv  Individual_Present_Value_Equity.csv
#[3] Individual_Present_Value_FOREX.csv  test.txt  

list.files()[grep(BONDS|Equity|FOREX, list.files())] #only the concerned 
files could be seen
#[1] Individual_Present_Value_BONDS.csv  Individual_Present_Value_Equity.csv
#[3] Individual_Present_Value_FOREX.csv 

#Removed ..._BONDS.csv from the folder.
list.files()[grep(BONDS|Equity|FOREX, list.files())]
#[1] Individual_Present_Value_Equity.csv Individual_Present_Value_FOREX.csv 

Second question: (added the ..._BONDS.csv into the folder)

#Read the 3 files in a list
lst1- lapply(list.files()[grep(BONDS|Equity|FOREX, 
list.files())],function(x) {x1-read.csv(x,sep=,,stringsAsFactors=FALSE); 
colnames(x1)[1]- simulations;x1}) # one of the dataset had Simulations as 
first column

#Merge with a subset of data 

library(plyr)
lstSub- 
lapply(list.files()[grep(BONDS|Equity|FOREX,list.files())],function(x) 
{x1-head(read.csv(x,sep=,,stringsAsFactors=FALSE)); colnames(x1)[1]- 
simulations;x1}) #subset


 join_all(lstSub,type=inner,by=simulations) # depending on your needs, you 
can change to type=full

head(join_all(lstSub,type=inner,by=simulations),2) #looks like columns are 
in the same order as in the individual dataset
#  simulations T_Bond_14.50_2011A T_Bond_14.50_2012B T_Bond_15.50_2010D
#1  Current_PV   184300.7   178906.3   104177.5
#2 Simualtion_no_1   184545.6   178712.6   104431.7
 # T_Bond_15.50_2010E T_Bond_15.50_2011B Equity_A Equity_B Equity_C Equity_D
#1   225164.0    1006044 113718.3 392252.5 344494.2  6074407
#2   225727.8    1006456 114838.4 397470.2 346675.5  5943718
 # Trans_no.1.Sell.USD Trans_no.2.Sell.USD Trans_no.3.Buy.AUD
#1    -5819794   -15122103   78567139
#2    -6937125   -17368874   78217006
 # Trans_no.4.Sell.USD Trans_no.5.Buy.EURO Trans_no.6.Sell.USD
#1   -18621066    10340611   -24023002
#2   -21423091    16831727   -27356539
 # Trans_no.7.Buy.EURO Trans_no.8.Sell.USD Trans_no.9.Buy.GBP
#1    10340611   -24023002  -20486447
#2    16831727   -27356539  -18408896
 # Trans_no.10.Sell.USD Trans_no.11.Buy.CHF Trans_no.12.Sell.USD
#1    -48273317 5435002 -4647643
#2    -54892776 5652627 -5279506
 # Trans_no.13.Sell.USD
#1 -8657418
#2 -9780783

I hope this helps.
A.K.




 From: Katherine Gobin katherine_go...@yahoo.com
To: smartpink...@yahoo.com 
Sent: Wednesday, March 27, 2013 6:17 PM
Subject: CRAN R Help
 

Dear Mr Arun,
 
Sorry to bother you again. Last week you had given me the
question about what will happen to my R – code if say bonds or equity or forex 
something
is missing?.
Your  this question
has acted like CLUE to me and accordingly I had developed the R –code. And I
think now it’s working  (at least as of
now as R has always thrown some surprises ahead of me and hence I am using the 
phrase
“at least as of now”). 

However, although I had managed say about 95% of the job, I
need one small favor from you if possible.

I have three output csv files and the names are as given
below.
 
individual_Present_Value_BONDS.csv
individual_Present_Value_Equity.csv
individual_Present_Value_FOREX.csv

I have attached these files in zip format for your
reference. Each of these files have first column as common column. So I can
combine these files (after reading these as data.frames) using merge command. 

However, there are two problems. 



(1) I am not sure if the file exists or not.
Depending on the presence in portfolio, file is created. E.g. if there is no
Equity, ‘individual_Present_Value_Equity.csv’ will not be created. So how do I
merge these files only after testing if the file exists or not.


(2)    Also, assuming the files are merged, then the
columns in the merged data.frame are not in the same order as they are in the
individual files. i.e. the columns get mixed up in the 


For me the first task is more
important. Will it be possible for you to help me out.  Sorry again for writing 
directly to you. I
wrote directly to you because you are already aware of my problem and secondly,
I don’t know if we can attach the files to the R forum mails.
Sorry to bother you once again.
 
Regards
 
Katherine

__
R-help@r-project.org mailing 

Re: [R] how to call R in PHP

2013-03-27 Thread Jeff Newmiller
While someone around here might know about PHP (I don't h, the fact that you 
don't know how to call system suggests that you should be asking in a PHP help 
forum.

Rserve can be used for interactive sessions, but web services usually aren't 
designed that way, so you probably want to call R with batch arguments the same 
way you would call it from the command interpreter, but not actually via the 
command interpreter.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Lauren Zhang zxj19880...@yahoo.cn wrote:

Hi,
I met tough problems when calling R in PHP. I have tried several ways,
but none of them succeed.��
first of all, I tried Rserve, but I failed to connect to it.
Then, I tried cmd.exe. I get the result when I use��R CMD BATCH
--vanilla... in cmd, but I have no idea how to call cmd in php.
I know system() is good to call other systems, I triedbut I get no
result in my html page.
if you could provide some suggestion or examples, i would appreciate
your help.

the code in my php is���
$cmd=R CMD BATCH--vanilla --slave delete.r;
$res=system($cmd);

the code in the delete.r file is:
setwd(c://wamp//www//analysis);
x-4;
y-3;
z-x*y;
sink(125.txt);
png(file=125.png);
barplot(z,border=dark blue)
title(main=list(earning of comparison,font=4));
plot(x,z);
dev.off()

   [[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] new question

2013-03-27 Thread arun
Hi,
Regarding the first question:
ListFacGroup-  lapply(ListFacGroup,unique)
 Spec(ListFacGroup,0.05)
#
 #   Seq Mod z a2 c2 c3 t2
#1    aAATATAGPR  1-n_acPro/ 2  1  0  0  1
#2 aAAASSPVGVGQR  1-n_acPro/ 2  1  0  0  1
#3  aAGAAGGR  1-n_acPro/ 2  1  1  0  1
#4   AAALQAK 2  1  0  1  1
#5    aAGAGPEMVR  1-n_acPro/ 2  2  2  1  2
#6 aEQQQFYLLLGNLLSPDNVVR 1-_Carbamoylation/ 2  1  0  0  1
#7 aEQQQFYLLLGNLLSPDNVVR 1-_Carbamoylation/ 3  1  0  0  1
#8 aEQQQFYLLLGNLLSPDNVVR  1-n_acPro/ 2  0  1  0  0
#9 aEQQQFYLLLGNLLSPDNVVR  1-n_acPro/ 3  1  2  2  1
#10  APGTAEK 2  0  1  0  0
#11    aSAPQQLSDEELFSQLR  1-n_acPro/ 2  1  0  0  1
#12  aVGNAVPCGAR  1-n_acPro/ 2  1  1  1  1
#13    AWEEPSSGNGTAR 2  1  1  1  1
#14  aAAAELSLLEK  1-n_acPro/ 1  1  0  0  1
#15  aAAAELSLLEK  1-n_acPro/ 2  1  1  1  1
#16 EVLGLILR 2  1  1  1  1
#17  aAAAGAAAEGEAPAEMGALLLEK  1-n_acPro/ 3  1  1  1  1
#18  aAAAPGTAVGATGSGIAGLAVYR 1-_Carbamoylation/ 3  0  0  1  0
#19  aAAAPGTAVGATGSGIAGLAVYR  1-n_acPro/ 3  1  0  0  1
#20 aAAANSGSSLPLFDCPTWAGKPPPGLHLDVVK  1-n_acPro/ 3  1  0  0  1
#21  AAAkAAK 8-K_ac/ 2  0  1  0  0
#22 aAAAVGAGHGAGGPGAASSSGGAR  1-n_acPro/ 2  0  1  1  0
#23 aAAAVGAGHGAGGPGAASSSGGAR  1-n_acPro/ 3  0  0  1  0
#24 aAADGDDSLYPIAVLIDELR  1-n_acPro/ 2  0  0  1  0


2nd question: I am not sure I understand it correctly.
A.K.




 From: Vera Costa veracosta...@gmail.com
To: arun smartpink...@yahoo.com 
Sent: Wednesday, March 27, 2013 7:07 PM
Subject: Re: new question
 

Hi.
With the data in attach,the results has duplicated. I think it's better only 
one rows with the information. 
The 2nd question,about t test,it's what you did,but for frequencies directly. 
You understand? Thank you very much

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