Re: [R] Removing display of R row names from list.

2015-07-29 Thread John Kane
Beats me.  You can print a single data frame with
print(dat1, rownames = FALSE) but it is not clear to me how to do it within a 
function.  

I am sure someone who actually know what they are doing will be along in a 
moment. Sorry not to have been of more help.

John Kane
Kingston ON Canada

-Original Message-
From: ntfr...@gmail.com
Sent: Wed, 29 Jul 2015 18:11:36 +0300
To: jrkrid...@inbox.com
Subject: Re: [R] Removing display of R row names from list.

Here is a small example. it is not the real data I am working on but this can 
help

#Chick weight example

names(ChickWeight) - tolower(names(ChickWeight))
chick_m - melt(ChickWeight, id=2:4, na.rm=TRUE)
class(chick_m)

test = function(data){
  i = 1
  table = list()  
  table [[i]] - dcast(chick_m, time ~ variable, mean)
  i = i + 1

  print(table)

}
test(chick_m )

Frederic Ntirenganya
Maseno University,

African Maths Initiative,

Kenya.

Mobile:(+254)718492836

Email: fr...@aims.ac.za

https://sites.google.com/a/aims.ac.za/fredo/ 
[https://sites.google.com/a/aims.ac.za/fredo/]

On Wed, Jul 29, 2015 at 5:12 PM, John Kane jrkrid...@inbox.com wrote:

HI Frederic,
 Can you supply a small example of the problem?

 John Kane
 Kingston ON Canada

  -Original Message-
  From: ntfr...@gmail.com
  Sent: Wed, 29 Jul 2015 14:15:58 +0300
  To: r-help@r-project.org
  Subject: [R] Removing display of R row names from list.
 
   Dear All,
 
  Is there a way to not include the row names when creating the list?
  Thanks!
 
  Regards,
  Frederic.
 
  Frederic Ntirenganya
  Maseno University,
  African Maths Initiative,
  Kenya.
  Mobile:(+254)718492836
  Email: fr...@aims.ac.za
  https://sites.google.com/a/aims.ac.za/fredo/ 
  [https://sites.google.com/a/aims.ac.za/fredo/]
 
        [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help 
  [https://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.

 
 FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
 Check it out at http://www.inbox.com/earth [http://www.inbox.com/earth]


FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Imbalanced random forest

2015-07-29 Thread Max Kuhn
This might help:

http://bit.ly/1MUP0Lj

On Wed, Jul 29, 2015 at 11:00 AM, jpara3 j.para.fernan...@hotmail.com
wrote:

 ¿How can i set up a study with random forest where the response is highly
 imbalanced?



 -

 Guided Tours Basque Country

 Guided tours in the three capitals of the Basque Country: Bilbao,
 Vitoria-Gasteiz and San Sebastian, as well as in their provinces. Available
 languages.

 Travel planners for groups and design of tourist routes across the Basque
 Country.
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Imbalanced-random-forest-tp4710524.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] indices of mismatch element in two vector with missing values

2015-07-29 Thread baccts
Thank you everyone for taking the time to reply.

Thanks Martin and Hervé for your solutions.
Now I just need to remember to check for NA match.



--
View this message in context: 
http://r.789695.n4.nabble.com/indices-of-mismatch-element-in-two-vector-with-missing-values-tp4710497p4710518.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Removing display of R row names from list.

2015-07-29 Thread Bert Gunter
1. Please post in plain text, not HTML.

2. Please do your homework. Data frames (the class of the result of
dcast) **always** have row names. ?data.frame  for details.

3. Read up on S3 methods if you have not done so already (any good R
tutorial will tell you about them, including the Intro to R tutorial
that ships with R). Then see the row.names argument of
?print.data.frame  .


Cheers,
Bert
Bert Gunter

Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
   -- Clifford Stoll


On Wed, Jul 29, 2015 at 8:11 AM, Frederic Ntirenganya ntfr...@gmail.com wrote:
 Here is a small example. it is not the real data I am working on but this
 can help

 #Chick weight example

 names(ChickWeight) - tolower(names(ChickWeight))
 chick_m - melt(ChickWeight, id=2:4, na.rm=TRUE)
 class(chick_m)

 test = function(data){
   i = 1
   table = list()
   table [[i]] - dcast(chick_m, time ~ variable, mean)
   i = i + 1

   print(table)

 }
 test(chick_m )


 Frederic Ntirenganya
 Maseno University,
 African Maths Initiative,
 Kenya.
 Mobile:(+254)718492836
 Email: fr...@aims.ac.za
 https://sites.google.com/a/aims.ac.za/fredo/

 On Wed, Jul 29, 2015 at 5:12 PM, John Kane jrkrid...@inbox.com wrote:

 HI Frederic,
 Can you supply a small example of the problem?

 John Kane
 Kingston ON Canada


  -Original Message-
  From: ntfr...@gmail.com
  Sent: Wed, 29 Jul 2015 14:15:58 +0300
  To: r-help@r-project.org
  Subject: [R] Removing display of R row names from list.
 
   Dear All,
 
  Is there a way to not include the row names when creating the list?
  Thanks!
 
  Regards,
  Frederic.
 
  Frederic Ntirenganya
  Maseno University,
  African Maths Initiative,
  Kenya.
  Mobile:(+254)718492836
  Email: fr...@aims.ac.za
  https://sites.google.com/a/aims.ac.za/fredo/
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/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 EARTH SCREENSAVER - Watch the Earth right on your desktop!
 Check it out at http://www.inbox.com/earth




 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 simulate informative censoring in a Cox PH model?

2015-07-29 Thread Greg Snow
As models become more complex it becomes harder to distinguish
different parts and their effects.  Even for a straight forward linear
regression model if X1 and X2 are correlated with each other then it
becomes difficult to distinguish between the effects of X1^2, X2^2,
and X1*X2.  In your case the informative censoring and model
misspecification are becoming hard to distinguish (and it could be
argued that having informative censoring is really just a form of
model misspecification).  So I don't think so much that you are doing
things wrong, just that you are learning that the models are complex.

Another approach to simulation that you could try is to simulate the
event time and censoring time using copulas (and therefore they can be
correlated to give informative censoring, but without relying on a
term that you could have included in the model) then consider the
event censored if the censoring time is shorter.

On Fri, Jul 24, 2015 at 10:14 AM, Daniel Meddings dpmeddi...@gmail.com wrote:
 Hi Greg

 Many thanks for taking the time to respond to my query. You are right about
 pointing out the distinction between what variables are and are not included
 in the event times process and in the censoring process. I clearly forgot
 this important aspect. I amended my code to do as you advise and now I am
 indeed getting biased estimates when using the informatively censored
 responses. The problem is now that the estimates from the independently
 censored responses are the same - i.e. they are just as biased. Thus the
 bias seems to be due entirely to model mis-specification and not the
 informative censoring.


 To give a concrete example I simulate event times T_i and censoring times
 C_i from the following models;


 T_i~ Weibull(lambda_t(x),v_t),lambda_t(x)=lambda_t*exp( beta_t_0 +
 (beta_t_1*Treat_i) + (beta_t_2*Z_i) + (beta_t_3*Treat_i*Z_i)  )

 C_i~ Weibull(lambda_c(x),v_c),lambda_c(x)=lambda_c*exp( beta_c_0 +
 (beta_c_1*Treat_i) + (beta_c_2*Z_i) + (beta_c_3*Treat_i*Z_i)  )

 D_i~Weibull(lambda_d(x),v_D), lambda_d(x)=lamda_d*exp( beta_d_0)

 where ;

 beta_t_0 = 1,  beta_t_1 = -1,   beta_t_2 = 1,  beta_t_3 = -2,   lambda_t=0.5

 beta_c_0 = 0.2,  beta_c_1 = -2,   beta_c_2 = 2,  beta_c_3 = -2,
 lambda_c=0.5

 beta_d_0 = -0.7,  lambda_d=0.1

 When I fit the cox model to both the informatively censored responses and
 the independent censored responses I include only the Treatment covariate in
 the model.

 I simulate Treatment from a Bernoulli distribution with p=0.5 and Z_i from a
 beta distribution so that Z ranges from 0 to 1 (I like to think of Z as a
 poor prognosis probability where Z_i=1 means a subject is 100% certain to
 have a poor prognosis and Z_i=0 means zero chance). These parameter choices
 give approximately 27% and 25% censoring for the informatively censored
 responses (using C_i) and the independent censored responses (using D_i)
 respectively. I use N=2000 subjects and 2000 simulation replications.

 The above simulation I get estimates of beta_t_2 of -1.526 and -1.537 for
 the informatively censored responses and the independent censored responses
 respectively.

 Furthermore when I fit a cox model to the full responses (no censoring at
 all) I get an estimate of beta_t_2 of -1.542. This represents the best that
 can possibly be done given that Z and Treat*Z are not in the model. Clearly
 censoring is not making much of a difference here - model mis-specification
 dominates.

 I still must be doing something wrong but I cannot figure this one out.

 Thanks

 Dan



 On Thu, Jul 23, 2015 at 12:33 AM, Greg Snow 538...@gmail.com wrote:

 I think that the Cox model still works well when the only information
 in the censoring is conditional on variables in the model.  What you
 describe could be called non-informative conditional on x.

 To really see the difference you need informative censoring that
 depends on something not included in the model.  One option would be
 to use copulas to generate dependent data and then transform the
 values using your Weibul.  Or you could generate your event times and
 censoring times based on x1 and x2, but then only include x1 in the
 model.

 On Wed, Jul 22, 2015 at 2:20 AM, Daniel Meddings dpmeddi...@gmail.com
 wrote:
  I wish to simulate event times where the censoring is informative, and
  to
  compare parameter estimator quality from a Cox PH model with estimates
  obtained from event times generated with non-informative censoring.
  However
  I am struggling to do this, and I conclude rather than a technical flaw
  in
  my code I instead do not understand what is meant by informative and
  un-informative censoring.
 
  My approach is to simulate an event time T dependent on a vector of
  covariates x having hazard function h(t|x)=lambda*exp(beta'*x)v*t^{v-1}.
  This corresponds to T~ Weibull(lambda(x),v), where the scale parameter
  lambda(x)=lambda*exp(beta'*x) depends on x and the shape parameter v is
  fixed. I have N subjects where 

[R] PythonInR. Python script in R with parameters required. Download satellite images from NASA

2015-07-29 Thread Magi Franquesa
Hello,

I'm trying to execute a python script within R (3.2.1 x 64) with the
PythonInR package. I would like to download an order of satellite images
from Nasa using a python script (
http://landsat.usgs.gov/documents/espa_bulk_downloader_v1.0.0.zip) but I
have no success. I first run the pyExecfile command with the *feedparser.py*
script and then the *download_espa_order.py* giving the required parameters
(my mail acount and the order number), here is the code:

setwd(C:/Python27)
install.packages(PythonInR)
library(PythonInR)
pyConnect(pythonExePath=C:/Python27/python.exe)
pyIsConnected()
# autodetectPython(C:/Python27/python.exe)

pyExecfile(C:/Landsat/feedparser.py)
pyExecfile(C:/Landsat/download_espa_order.py -e magifranqu...@gmail.com
-o magifranqu...@gmail.com-07222015-120911 -d C:/Landsat/ESPA)

and I get this error:

Error: unexpected string constant in
pyExecfile(C:/Landsat/download_espa_order.py -e
magifranqu...@gmail.com

The code C:/Landsat/download_espa_order.py -e
magifranqu...@gmail.com -o magifranqu...@gmail.com-07222015-120911
-d C:/Landsat/ESPA runs ok when I use it within
system console.

I appreciate if someone could help me to solve this problem.

Thank you

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Removing display of R row names from list.

2015-07-29 Thread Frederic Ntirenganya
Here is a small example. it is not the real data I am working on but this
can help

#Chick weight example

names(ChickWeight) - tolower(names(ChickWeight))
chick_m - melt(ChickWeight, id=2:4, na.rm=TRUE)
class(chick_m)

test = function(data){
  i = 1
  table = list()
  table [[i]] - dcast(chick_m, time ~ variable, mean)
  i = i + 1

  print(table)

}
test(chick_m )


Frederic Ntirenganya
Maseno University,
African Maths Initiative,
Kenya.
Mobile:(+254)718492836
Email: fr...@aims.ac.za
https://sites.google.com/a/aims.ac.za/fredo/

On Wed, Jul 29, 2015 at 5:12 PM, John Kane jrkrid...@inbox.com wrote:

 HI Frederic,
 Can you supply a small example of the problem?

 John Kane
 Kingston ON Canada


  -Original Message-
  From: ntfr...@gmail.com
  Sent: Wed, 29 Jul 2015 14:15:58 +0300
  To: r-help@r-project.org
  Subject: [R] Removing display of R row names from list.
 
   Dear All,
 
  Is there a way to not include the row names when creating the list?
  Thanks!
 
  Regards,
  Frederic.
 
  Frederic Ntirenganya
  Maseno University,
  African Maths Initiative,
  Kenya.
  Mobile:(+254)718492836
  Email: fr...@aims.ac.za
  https://sites.google.com/a/aims.ac.za/fredo/
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/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 EARTH SCREENSAVER - Watch the Earth right on your desktop!
 Check it out at http://www.inbox.com/earth




[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] vectorized sub, gsub, grep, etc.

2015-07-29 Thread Bert Gunter
There is confusion here. apply() family functions are **NOT**
vectorization -- they ARE loops (at the interpreter level), just done
in functionalized form. Please read background material (John
Chambers's books, MASS, or numerous others) to improve your
understanding and avoid posting erroneous comments.

Cheers,
Bert


Bert Gunter

Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
   -- Clifford Stoll


On Tue, Jul 28, 2015 at 3:00 PM, John Thaden jjtha...@flash.net wrote:
 Adam,The method you propose gives a different result than the prior 
 methods for these example vectors
 X - c(ab, cd, ef)
 patt - c(b, cd, a)
 repl - c(B, CD, A)

 Old method 1

 mapply(function(p, r, x) sub(p, r, x, fixed = TRUE), p=patt, r=repl, x=X)
 gives
   b   cda
 aB CD ef

 Old method 2

 sub2 - function(pattern, replacement, x) {
 len - length(x)
 if (length(pattern) == 1)
 pattern - rep(pattern, len)
 if (length(replacement) == 1)
 replacement - rep(replacement, len)
 FUN - function(i, ...) {
 sub(pattern[i], replacement[i], x[i], fixed = TRUE)
 }
 idx - 1:length(x)
 sapply(idx, FUN)
 }
 sub2(patt, repl, X)
  gives
 [1] aB CD ef

 Your method (I gave it the unique name sub3)
  sub3 - function(pattern, replacement, x) {   len- length(x)  y  - 
 character(length=len)  patlen - length(pattern)  replen - 
 length(replacement)  if(patlen != replen) stop('Error: Pattern and 
 replacement length do not match')  for(i in 1:replen) {
 y[which(x==pattern[i])] - replacement[i]  }  return(y)}sub3(patt, repl, X)
 gives[1]CD 

 Granted, whatever it does, it does it faster
 #Old method 1
 system.time(for(i in 1:5)
 mapply(function(p,r,x) sub(p,r,x, fixed = TRUE),p=patt,r=repl,x=X))
user  system elapsed
2.530.002.52

 #Old method 2
 system.time(for(i in 1:5)sub2(patt, repl, X))   user  system elapsed
2.320.002.32

 #Your proposed method
 system.time(for(i in 1:5) sub3(patt, repl, X))
user  system elapsed
1.020.001.01
  but would it still be faster if it actually solved the same problem?

 -John Thaden




  On Monday, July 27, 2015 11:40 PM, Adam Erickson 
 adam.michael.erick...@gmail.com wrote:

 I know this is an old thread, but I wrote a simple FOR loop with vectorized 
 pattern replacement that is much faster than either of those (it can also 
 accept outputs differing in length from the patterns):
   sub2  - function(pattern, replacement, x) { len   - length(x)y
   - character(length=len)patlen - length(pattern)replen - 
 length(replacement)if(patlen != replen) stop('Error: Pattern and 
 replacement length do not match')for(i in 1:replen) {  
 y[which(x==pattern[i])] - replacement[i]}return(y)  }
 system.time(test - sub2(patt, repl, XX))   user  system elapsed   0  
  0   0
 Cheers,
 Adam
 On Wednesday, October 8, 2008 at 9:38:01 PM UTC-7, john wrote:
 Hello Christos,
   To my surprise, vectorization actually hurt processing speed!#Example
 X - c(ab, cd, ef)
 patt - c(b, cd, a)
 repl - c(B, CD, A)sub2 - function(pattern, replacement, x) {
 len - length(x)
 if (length(pattern) == 1)
 pattern - rep(pattern, len)
 if (length(replacement) == 1)
 replacement - rep(replacement, len)
 FUN - function(i, ...) {
 sub(pattern[i], replacement[i], x[i], fixed = TRUE)
 }
 idx - 1:length(x)
 sapply(idx, FUN)
 }

 system.time(  for(i in 1:1)  sub2(patt, repl, X)  )
user  system elapsed
1.180.071.26 system.time(  for(i in 1:1)  mapply(function(p, 
 r, x) sub(p, r, x, fixed = TRUE), p=patt, r=repl, x=X)  )
user  system elapsed
1.420.051.47

 So much for avoiding loops.
 John Thaden=== At 2008-10-07, 14:58:10 Christos wrote: ===John,
Try the following:

 mapply(function(p, r, x) sub(p, r, x, fixed = TRUE), p=patt, r=repl, x=X)
   b   cda
aB CD ef

-Christos -My Original Message-
 R pattern-matching and replacement functions are
 vectorized: they can operate on vectors of targets.
 However, they can only use one pattern and replacement.
 Here is code to apply a different pattern and replacement for
 every target.  My question: can it be done better?

 sub2 - function(pattern, replacement, x) {
 len - length(x)
 if (length(pattern) == 1)
 pattern - rep(pattern, len)
 if (length(replacement) == 1)
 replacement - rep(replacement, len)
 FUN - function(i, ...) {
 sub(pattern[i], replacement[i], x[i], fixed = TRUE)
 }
 idx - 1:length(x)
 sapply(idx, FUN)
 }

 #Example
 X - c(ab, cd, ef)
 patt - c(b, cd, a)
 repl - c(B, CD, A)
 sub2(patt, repl, X)

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

Re: [R] Removing display of R row names from list.

2015-07-29 Thread Bert Gunter
Is this what you mean?

z - data.frame(a=1:3,b=letters[1:3],row.names=letters[1:3])
zlist - list(one=z,too =z)

for(i in 1:2){print(zlist[[i]],row.names=FALSE); cat(\n)}

 a b
 1 a
 2 b
 3 c

 a b
 1 a
 2 b
 3 c

... which could obviously be within a function.

Cheers,
Bert
Bert Gunter

Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
   -- Clifford Stoll


On Wed, Jul 29, 2015 at 8:32 AM, John Kane jrkrid...@inbox.com wrote:
 Beats me.  You can print a single data frame with
 print(dat1, rownames = FALSE) but it is not clear to me how to do it within a 
 function.

 I am sure someone who actually know what they are doing will be along in a 
 moment. Sorry not to have been of more help.

 John Kane
 Kingston ON Canada

 -Original Message-
 From: ntfr...@gmail.com
 Sent: Wed, 29 Jul 2015 18:11:36 +0300
 To: jrkrid...@inbox.com
 Subject: Re: [R] Removing display of R row names from list.

 Here is a small example. it is not the real data I am working on but this can 
 help

 #Chick weight example

 names(ChickWeight) - tolower(names(ChickWeight))
 chick_m - melt(ChickWeight, id=2:4, na.rm=TRUE)
 class(chick_m)

 test = function(data){
   i = 1
   table = list()
   table [[i]] - dcast(chick_m, time ~ variable, mean)
   i = i + 1

   print(table)

 }
 test(chick_m )

 Frederic Ntirenganya
 Maseno University,

 African Maths Initiative,

 Kenya.

 Mobile:(+254)718492836

 Email: fr...@aims.ac.za

 https://sites.google.com/a/aims.ac.za/fredo/ 
 [https://sites.google.com/a/aims.ac.za/fredo/]

 On Wed, Jul 29, 2015 at 5:12 PM, John Kane jrkrid...@inbox.com wrote:

 HI Frederic,
  Can you supply a small example of the problem?

  John Kane
  Kingston ON Canada

   -Original Message-
   From: ntfr...@gmail.com
   Sent: Wed, 29 Jul 2015 14:15:58 +0300
   To: r-help@r-project.org
   Subject: [R] Removing display of R row names from list.
  
Dear All,
  
   Is there a way to not include the row names when creating the list?
   Thanks!
  
   Regards,
   Frederic.
  
   Frederic Ntirenganya
   Maseno University,
   African Maths Initiative,
   Kenya.
   Mobile:(+254)718492836
   Email: fr...@aims.ac.za
   https://sites.google.com/a/aims.ac.za/fredo/ 
 [https://sites.google.com/a/aims.ac.za/fredo/]
  
 [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
   https://stat.ethz.ch/mailman/listinfo/r-help 
 [https://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.

  
  FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
  Check it out at http://www.inbox.com/earth [http://www.inbox.com/earth]

 
 FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
 family!
 Visit http://www.inbox.com/photosharing to find out more!

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Opposite color in R

2015-07-29 Thread Atte Tenkanen
Hi,

Nope. My point is that color pairs red-green, yellow-violet and blue-orange are 
physically on the opposite sides of the wheel.
I'm not 100% satisfied with this circle, because three of greens and reds are 
so near each other. But this is the best solution thus far :-)
The number of colors, 24, is also fixed in the application.

Atte

 Hi

 I plotted the 'spectrum' and it looked a little small - spectrum colours: red 
 orange yellow green blue indigo violet.
 I suppose you could go to infinite lengths to split it up but is this an 
 improvement?

 I have not gone into the depths of complimentary colours

 library(colorspace)

 ColorsRYB=rbind(colorRamp(c(purple,violet))((0:4)/4)[1:4,],
  colorRamp(c(violet,blue))((0:4)/4)[1:4,],
  colorRamp(c(blue,green))((0:4)/4)[1:4,],
  colorRamp(c(green,yellow))((0:4)/4)[1:4,],
  colorRamp(c(yellow,orange))((0:4)/4)[1:4,],
  colorRamp(c(orange,red))((0:4)/4)[1:4,],
  colorRamp(c(red,purple))((0:4)/4)[1:4,])

 LenCol=length(ColorsRYB[,1])

 ColorsRYBhex=rep(0, LenCol)
 for(i in 1: LenCol)
 {
 ColorsRYBhex[i]=rgb(ColorsRYB[i,1]/255,ColorsRYB[i,2]/255,ColorsRYB[i,3]/255)
 }

 pie(rep(1, LenCol), col = ColorsRYBhex)

 Regards

 Duncan

 Duncan Mackay
 Department of Agronomy and Soil Science
 University of New England
 Armidale NSW 2351
 Email: home:mackay at northnet.com.au  
 https://stat.ethz.ch/mailman/listinfo/r-help




 -Original Message-
 From: R-help [mailto:r-help-bounces at r-project.org  
 https://stat.ethz.ch/mailman/listinfo/r-help] On Behalf Of Atte Tenkanen
 Sent: Tuesday, 28 July 2015 18:22
 To:r-help at r-project.org  https://stat.ethz.ch/mailman/listinfo/r-help
 Subject: [R] Opposite color in R

 It seems that there is no implementation for the traditional artist's
 color circle in R. However I'm searching for such a wheel, because my
 program needs it.

 As said, the description of complementary/opposite-function in package
 colortools is misleading since, for example

 opposite(green) produces violet, not red, but the description of
 complementary-function says

 Complementary or opposite color scheme is formed by colors that are
 opposite each other on the color wheel (example: red and green).

 So, there must be just a lapse in the text.

 I constrained such kind of a color wheel, which is enough near of what
 I need:

 library(colorspace)

 ColorsRYB=rbind(colorRamp(c(red,
 violet))((0:4)/4)[1:4,],colorRamp(c(violet,
 blue))((0:4)/4)[1:4,],colorRamp(c(blue,
 green))((0:4)/4)[1:4,],colorRamp(c(green,
 yellow))((0:4)/4)[1:4,],colorRamp(c(yellow,
 orange))((0:4)/4)[1:4,],colorRamp(c(orange, red))((0:4)/4)[1:4,])

 LenCol=length(ColorsRYB[,1])

 ColorsRYBhex=rep(0, LenCol)
 for(i in 1: LenCol)
 {
 ColorsRYBhex[i]=rgb(ColorsRYB[i,1]/255,ColorsRYB[i,2]/255,ColorsRYB[i,3]/255)
 }

 pie(rep(1, 24), col = ColorsRYBhex)

 Atte T.


 28.7.2015, 2.23, Steve Taylor kirjoitti:
 /  I wonder if the hcl colour space is useful?  Varying hue while keeping 
 chroma and luminosity constant should give varying colours of perceptually 
 the same colourness and brightness.
 //
 //  ?hcl
 //  pie(rep(1,12),col=hcl((1:12)*30,c=70),border=NA)
 //
 //
 //  -Original Message-
 //  From: R-help [mailto:r-help-bounces at r-project.org  
 https://stat.ethz.ch/mailman/listinfo/r-help] On Behalf Of Atte Tenkanen
 //  Sent: Sunday, 26 July 2015 7:50a
 //  To:r-help at r-project.org  
 https://stat.ethz.ch/mailman/listinfo/r-help
 //  Subject: [R] Opposite color in R
 //
 //  Hi,
 //
 //  I have tried to find a way to find opposite or complementary colors in R.
 //
 //  I would like to form a color circle with R like this one:
 //  http://nobetty.net/dandls/colorwheel/complementary_colors.jpg
 //
 //  If you just make a basic color wheel in R, the colors do not form
 //  complementary color circle:
 //
 //  palette(rainbow(24))
 //  Colors=palette()
 //  pie(rep(1, 24), col = Colors)
 //
 //  There is a package ”colortools” where you can find function opposite(),
 //  but it doesn’t work as is said. I tried
 //
 //  library(colortools)
 //  opposite(violet) and got green instead of yellow and
 //
 //  opposite(blue) and got yellow instead of orange.
 //
 //  Do you know any solutions?
 //
 //  Atte Tenkanen
 /


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Daily Category Revenue-Stacked Bar Chart in ggplot2

2015-07-29 Thread Hidden Markov Model
No, I'm not confused. I just posted on R help website. I don't know how to
use the email client to do anything which you are speaking of. If you would
like the posts to be made in an alternative way, then you will need to
provide clear direction. Sending someone to a help page which doesn't
reference what you are speaking about isn't actually helpful. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710543.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Daily Category Revenue-Stacked Bar Chart in ggplot2

2015-07-29 Thread Hidden Markov Model
Alright, I think I understand what you guys are talking about. It is still
not clear the relationship between R-help and Nabble since you guys haven't
actually answered that. 

Again, the best way to provide proper advice is to actually quote to portion
of the website you are sending people to, i.e., To post a message to all
the list members, send email to r-help@r-project.org. 

But this still doesn't address the issue of why that is necessary in the
first place. Indeed, when a post is made the user sees the following
message, which seems to indicate that the method of posting doesn't actually
matter: 

This forum is an archive/gateway which will forward your post to the
r-help@r-project.org mailing list.

Cheers! 





--
View this message in context: 
http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710549.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Rearrange Data Frame

2015-07-29 Thread Stella Xu

My question is about how to select and rearrange the data to a new data
frame
Here is an example:
Samples  counts  time 
A 10   3
A 12   4
A 11   3
B 12   4
B 10   5
C 11   2
C 13   3
Say, if I want to make a new table that only look at “counts” as
below:
AB   C
10 12 11
12 10 13
11
How can I do this in R?
Thank you!
.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Mixed Date Formats

2015-07-29 Thread Sarah Goslee
On Wed, Jul 29, 2015 at 2:45 PM, farnoosh sheikhi via R-help
r-help@r-project.org wrote:
  Hi Arun,
 Hope all is well with you. I have a data with a column for date.The date 
 format is mixed. There are date values with Month/Day/Year format and values 
 with Day/Month/Year format.I don't know how to unify it.I really appreciate 
 your help.Thanks.

You sent this to the R-help list, not just to Arun, so I'm assuming
this is an R question. The best way to get help is to provide a sample
of your data using dput() and to clearly specify what you would like
as the result - unify is a bit vague. paste(x, collapse=) could be
considered unification, after all.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Mixed Date Formats

2015-07-29 Thread farnoosh sheikhi via R-help
 Hi Arun,
Hope all is well with you. I have a data with a column for date.The date format 
is mixed. There are date values with Month/Day/Year format and values with 
Day/Month/Year format.I don't know how to unify it.I really appreciate your 
help.Thanks.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Mixed Date Formats

2015-07-29 Thread Sarah Goslee
I'm assuming you actually want the date column to be character, not factor:
SampleData - structure(list(id = 1:7, value = c(5813L, 8706L, 4049L, 5877L,
1375L, 2223L, 3423L), date = c(19-Dec-11, 07-Dec-11, 06/05/11,
05/12/11, 31/12/2011, 10/19/2011, 01/22/2011)), .Names = c(id,
value, date), row.names = c(NA, -7L), class = data.frame)

  id value   date
1  1  5813  19-Dec-11
2  2  8706  07-Dec-11
3  3  4049   06/05/11
4  4  5877   05/12/11
5  5  1375 31/12/2011
6  6  2223 10/19/2011
7  7  3423 01/22/2011

Given this assemblage of dates, there is a lot of ambiguity. The first
two are clear, but is the third in May or June? Is the fourth May or
December?

I had hoped that the number of digits in the year provided a clue, but
#5 is clearly dd/mm/ while #7 is mm/dd/

Or actually, #3 could be yy/mm/dd too.

I don't see a way to programmatically solve your problem, because
there is no clear way to parse all of these dates because of the
ambiguity.

You could get some of them by checking for values outside the bounds
of legitimate month numbers, or just try it and discard the values
that give NA results:
 as.Date(01/22/2011, %m/%d/%Y)
[1] 2011-01-22
 as.Date(01/22/2011, %d/%m/%Y)
[1] NA

But you need more information to figure out the rest.

Sarah

On Wed, Jul 29, 2015 at 5:15 PM, farnoosh sheikhi farnoosh...@yahoo.com wrote:
 Hi Sarah,

 Thanks for getting back to me.
 Here is an example of my data:
 SampleData - structure(list(id = 1:7, value = c(5813L, 8706L, 4049L, 5877L,
  1375L, 2223L, 3423L), date =
 structure(c(4L, 3L, 2L, 1L, 7L,

 6L, 5L), .Label = c(05/12/11, 06/05/11, 07-Dec-11,

 19-Dec-11, 01/22/2011, 10/19/2011, 31/12/2011

 ), class = factor)), .Names = c(id, value, date), row.names = c(NA,

 -7L), class = data.frame)
 SampleData

 Thanks for your help:).






 On Wednesday, July 29, 2015 1:50 PM, Sarah Goslee sarah.gos...@gmail.com
 wrote:


 On Wed, Jul 29, 2015 at 2:45 PM, farnoosh sheikhi via R-help

 r-help@r-project.org wrote:
  Hi Arun,
 Hope all is well with you. I have a data with a column for date.The date
 format is mixed. There are date values with Month/Day/Year format and values
 with Day/Month/Year format.I don't know how to unify it.I really appreciate
 your help.Thanks.


 You sent this to the R-help list, not just to Arun, so I'm assuming
 this is an R question. The best way to get help is to provide a sample
 of your data using dput() and to clearly specify what you would like
 as the result - unify is a bit vague. paste(x, collapse=) could be
 considered unification, after all.

 Sarah

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Mixed Date Formats

2015-07-29 Thread farnoosh sheikhi via R-help
Hi Sarah,
Thanks for getting back to me.Here is an example of my data:SampleData - 
structure(list(id = 1:7, value = c(5813L, 8706L, 4049L, 5877L,                  
                            1375L, 2223L, 3423L), date = structure(c(4L, 3L, 
2L, 1L, 7L,                                                                     
                  6L, 5L), .Label = c(05/12/11, 06/05/11, 07-Dec-11,      
                                                                                
                     19-Dec-11, 01/22/2011, 10/19/2011, 31/12/2011      
                                                                                
), class = factor)), .Names = c(id, value, date), row.names = c(NA,     
                                                                                
                                                                          -7L), 
class = data.frame)SampleData
Thanks for your help:).
 
 


 On Wednesday, July 29, 2015 1:50 PM, Sarah Goslee sarah.gos...@gmail.com 
wrote:
   

 On Wed, Jul 29, 2015 at 2:45 PM, farnoosh sheikhi via R-help
r-help@r-project.org wrote:
  Hi Arun,
 Hope all is well with you. I have a data with a column for date.The date 
 format is mixed. There are date values with Month/Day/Year format and values 
 with Day/Month/Year format.I don't know how to unify it.I really appreciate 
 your help.Thanks.

You sent this to the R-help list, not just to Arun, so I'm assuming
this is an R question. The best way to get help is to provide a sample
of your data using dput() and to clearly specify what you would like
as the result - unify is a bit vague. paste(x, collapse=) could be
considered unification, after all.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.org


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Rearrange Data Frame

2015-07-29 Thread Sarah Goslee
Hi Stella,

On Wed, Jul 29, 2015 at 1:14 PM, Stella Xu stella...@hli.ubc.ca wrote:

 My question is about how to select and rearrange the data to a new data
 frame
 Here is an example:
 Samples  counts  time
 A 10   3
 A 12   4
 A 11   3
 B 12   4
 B 10   5
 C 11   2
 C 13   3
 Say, if I want to make a new table that only look at “counts” as
 below:
 AB   C
 10 12 11
 12 10 13
 11
 How can I do this in R?
 Thank you!

Your example data doesn't use time at all, and contains a duplicate
pair of A,?,3 - what do you want to have happen there? How should
duplicates be handled? How should the ordering of values work? If
instead that should be a 5, here's something that is almost what you
want (but I find more useful):

x - structure(list(Samples = c(A, A, A, B, B, C, C),
counts = c(10L, 12L, 11L, 12L, 10L, 11L, 13L), time = c(3L,
4L, 5L, 4L, 5L, 2L, 3L)), .Names = c(Samples, counts,
time), class = data.frame, row.names = c(NA, -7L))

library(reshape2)
dcast(x, time ~ Samples, value.var=counts, sum)
  time  A  B  C
12  0  0 11
23 10  0 13
34 12 12  0
45 11 10  0

If you want the results scooted up, I think there was recently a
discussion on this list on doing so.

Sarah
-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Daily Category Revenue-Stacked Bar Chart in ggplot2

2015-07-29 Thread David Winsemius

On Jul 29, 2015, at 1:02 PM, Hidden Markov Model wrote:

 Alright, I think I understand what you guys are talking about. It is still
 not clear the relationship between R-help and Nabble since you guys haven't
 actually answered that. 

Nabble's relationship to Rhelp? Nabble is an ongoing annoyance to the regular 
users and to the list moderators. It's web display format deceives naive users 
(who usually fail to read the Posting Guide as they were directed)  into 
thinking everyone sees what they see, and so they often fail to maintain the 
context of the discussion. Many regular contributors simply ignore the content 
from Nabble-originated postings.

 Again, the best way to provide proper advice is to actually quote to portion
 of the website you are sending people to, i.e., To post a message to all
 the list members, send email to r-help@r-project.org. 
 
 But this still doesn't address the issue of why that is necessary in the
 first place. Indeed, when a post is made the user sees the following
 message, which seems to indicate that the method of posting doesn't actually
 matter: 
 
 This forum is an archive/gateway which will forward your post to the
 r-help@r-project.org mailing list.

Nabble lies. It is not an archive. I periodically get notices telling me that 
my old posts are going to be dropped. The real archive is: 
https://stat.ethz.ch/pipermail/r-help/

Nabble does forward messages to Rhelp and if a message passes the spam filters 
and the human moderators, it gets posted. Nabble then strips off the footers 
from the returned messages.

If you want to complain about Nabble not living up to your expectations, you 
should contact them. We did not ask them to mirror Rhelp.

You are expected to know how to control your own mail-client. Expecting us to 
educate you on the basics of computer use is unreasonable.

 View this message in context: 
 http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710549.html
 

R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] vectorized sub, gsub, grep, etc.

2015-07-29 Thread Adam Erickson
Further refining the vectorized (within a loop) exact string match 
function, I get times below 0.9 seconds while maintaining error checking. 
This is accomplished by removing which() and replacing 1:length() with 
seq_along().

sub2 - function(pattern, replacement, x) {
   len- length(x)
   y  - character(length=len)
   patlen - length(pattern)
   replen - length(replacement)
   if(patlen != replen) stop('Error: Pattern and replacement length do not 
match')
   for(i in seq_along(pattern)) {
 y[x==pattern[i]] - replacement[i]
   }
   return(y)
 }

system.time(for(i in 1:5) sub2(patt, repl, X))
   user  system elapsed 
   0.860.000.86 

Since the ordered vectors are perfectly aligned, might as well do an exact 
string match. Hence, I think this is not off-topic.

Cheers,

Adam

On Wednesday, July 29, 2015 at 8:15:52 AM UTC-7, Bert Gunter wrote:

 There is confusion here. apply() family functions are **NOT** 
 vectorization -- they ARE loops (at the interpreter level), just done 
 in functionalized form. Please read background material (John 
 Chambers's books, MASS, or numerous others) to improve your 
 understanding and avoid posting erroneous comments. 

 Cheers, 
 Bert 


 Bert Gunter 

 Data is not information. Information is not knowledge. And knowledge 
 is certainly not wisdom. 
-- Clifford Stoll 


 On Tue, Jul 28, 2015 at 3:00 PM, John Thaden jjth...@flash.net 
 javascript: wrote: 
  Adam,The method you propose gives a different result than the prior 
 methods for these example vectors 
  X - c(ab, cd, ef) 
  patt - c(b, cd, a) 
  repl - c(B, CD, A) 
  
  Old method 1 
  
  mapply(function(p, r, x) sub(p, r, x, fixed = TRUE), p=patt, r=repl, 
 x=X) 
  gives 
b   cda 
  aB CD ef 
  
  Old method 2 
  
  sub2 - function(pattern, replacement, x) { 
  len - length(x) 
  if (length(pattern) == 1) 
  pattern - rep(pattern, len) 
  if (length(replacement) == 1) 
  replacement - rep(replacement, len) 
  FUN - function(i, ...) { 
  sub(pattern[i], replacement[i], x[i], fixed = TRUE) 
  } 
  idx - 1:length(x) 
  sapply(idx, FUN) 
  } 
  sub2(patt, repl, X) 
   gives 
  [1] aB CD ef 
  
  Your method (I gave it the unique name sub3) 
   sub3 - function(pattern, replacement, x) {   len- length(x)  y   
- character(length=len)  patlen - length(pattern)  replen - 
 length(replacement)  if(patlen != replen) stop('Error: Pattern and 
 replacement length do not match')  for(i in 1:replen) {   
  y[which(x==pattern[i])] - replacement[i]  }  return(y)}sub3(patt, repl, 
 X) 
  gives[1]CD  
  
  Granted, whatever it does, it does it faster 
  #Old method 1 
  system.time(for(i in 1:5) 
  mapply(function(p,r,x) sub(p,r,x, fixed = TRUE),p=patt,r=repl,x=X)) 
 user  system elapsed 
 2.530.002.52 
  
  #Old method 2 
  system.time(for(i in 1:5)sub2(patt, repl, X))   user  system elapsed 
 2.320.002.32 
  
  #Your proposed method 
  system.time(for(i in 1:5) sub3(patt, repl, X)) 
 user  system elapsed 
 1.020.001.01 
   but would it still be faster if it actually solved the same problem? 
  
  -John Thaden 
  
  
  
  
   On Monday, July 27, 2015 11:40 PM, Adam Erickson 
 adam.micha...@gmail.com javascript: wrote: 
  
  I know this is an old thread, but I wrote a simple FOR loop with 
 vectorized pattern replacement that is much faster than either of those (it 
 can also accept outputs differing in length from the patterns): 
sub2  - function(pattern, replacement, x) { len   - length(x)   
  y  - character(length=len)patlen - length(pattern)replen - 
 length(replacement)if(patlen != replen) stop('Error: Pattern and 
 replacement length do not match')for(i in 1:replen) { 
  y[which(x==pattern[i])] - replacement[i]}return(y)  } 
  system.time(test - sub2(patt, repl, XX))   user  system elapsed   0 
   0   0 
  Cheers, 
  Adam 
  On Wednesday, October 8, 2008 at 9:38:01 PM UTC-7, john wrote: 
  Hello Christos, 
To my surprise, vectorization actually hurt processing speed!#Example 
  X - c(ab, cd, ef) 
  patt - c(b, cd, a) 
  repl - c(B, CD, A)sub2 - function(pattern, replacement, x) { 
  len - length(x) 
  if (length(pattern) == 1) 
  pattern - rep(pattern, len) 
  if (length(replacement) == 1) 
  replacement - rep(replacement, len) 
  FUN - function(i, ...) { 
  sub(pattern[i], replacement[i], x[i], fixed = TRUE) 
  } 
  idx - 1:length(x) 
  sapply(idx, FUN) 
  } 
  
  system.time(  for(i in 1:1)  sub2(patt, repl, X)  ) 
 user  system elapsed 
 1.180.071.26 system.time(  for(i in 1:1) 
  mapply(function(p, r, x) sub(p, r, x, fixed = TRUE), p=patt, r=repl, x=X) 
  ) 
 user  system elapsed 
 1.420.051.47 
  
  So much for avoiding loops. 
  John Thaden=== At 2008-10-07, 14:58:10 Christos wrote: ===John, 
 Try the 

Re: [R] Daily Category Revenue-Stacked Bar Chart in ggplot2

2015-07-29 Thread Jeff Newmiller
Since there IS NO R-help website that you can post on, you are definitely being 
confused by the Nabble website. This is a MAILING list that you interact with 
by sending emails to r-help@r-project.org, not a website forum. The trouble 
with Nabble is that it does confuse users, and breaks the continuity of emails 
that people who use it as it was intended to be used depend on.

For example, as a Nabble user you may not even be seeing the following footer 
that the rest of us live by:

PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html and provide commented, minimal, 
self-contained, reproducible code.

A more accurate web rendition of R-help than Nabble presents may be seen here:

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

which is mentioned at the link that you complained did not help you.

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

On July 29, 2015 2:37:56 PM EDT, Hidden Markov Model 
huss...@touchofmodern.com wrote:
No, I'm not confused. I just posted on R help website. I don't know how
to
use the email client to do anything which you are speaking of. If you
would
like the posts to be made in an alternative way, then you will need to
provide clear direction. Sending someone to a help page which doesn't
reference what you are speaking about isn't actually helpful. 



--
View this message in context:
http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710543.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] Duda ' raster package '

2015-07-29 Thread Marcos Bermejo
Hola,

Tengo una matriz ' elev.rad.mx ' que tiene tres columnas: 
1� columna: coordenada x del punto geogr�fico.
2� columna: coordenada y del punto geogr�fico.
3� columna: valores de un radar en el punto geogr�fico (x,y).

Quiero convertir esta matriz a un objeto raster. Para ello, pongo la siguiente 
instrucci�n:
 elev.rad.raster - raster(elev.rad.mx, xmn=355349, xmx=366549, ymn=4468331, 
ymx=4476651)

Lo que me sale por consola al poner '  elev.rad.raster ' es:
 elev.rad.raster

class   : RasterLayer 

dimensions  : 13306, 3, 39918  (nrow, ncol, ncell)

resolution  : 3733.333, 0.6252818  (x, y)

extent  : 355349, 366549, 4468331, 4476651  (xmin, xmax, ymin, ymax)

coord. ref. : NA 

data source : in memory
names   :layer 

values  : 723.13, 4476611  (min, max)


Entonces, mi duda es:

�C�mo puedo convertir o transformar este raster a otro raster (con los mismos 
datos y la misma extensi�n que tiene ' elev.rad.raster ') para que tenga de 
dimensiones 140 140 y de resoluci�n (x,y)=(80,80)?
Lo necesito porque tengo otro raster de ese tipo y quiero juntar los dos en un 
Grid. Para que todo encaje, tienen que tener la misma resoluci�n. 

Muchas gracias de antemano.

Un saludo,

  
[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Daily Category Revenue-Stacked Bar Chart in ggplot2

2015-07-29 Thread Hidden Markov Model
Hi John, 

Great thanks for the examples! I am not sure what you are referring to when
you say a post from Nabble - I posted this directly on R-help. I actually
never heard of Nabble.

Stacked Bar charts are great for when you have a lot of moving parts and
need to be able to zero in on one of them (e.g. Advertising Placements).
Unfortunately, I can't post the data since it is confidential. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710540.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Daily Category Revenue-Stacked Bar Chart in ggplot2

2015-07-29 Thread Jeff Newmiller
Then why do your messages contain the Nabble  footer:

View this message in context: 
http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710540.html
Sent from the R help mailing list archive at Nabble.com.

I think you are confused. You should be looking at

https://stat.ethz.ch/mailman/listinfo/r-help

and using your email client to send emails rather than posting on a web page.

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

On July 29, 2015 2:23:54 PM EDT, Hidden Markov Model 
huss...@touchofmodern.com wrote:
Hi John, 

Great thanks for the examples! I am not sure what you are referring to
when
you say a post from Nabble - I posted this directly on R-help. I
actually
never heard of Nabble.

Stacked Bar charts are great for when you have a lot of moving parts
and
need to be able to zero in on one of them (e.g. Advertising
Placements).
Unfortunately, I can't post the data since it is confidential. 



--
View this message in context:
http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710540.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Daily Category Revenue-Stacked Bar Chart in ggplot2

2015-07-29 Thread Berend Hasselman

 On 29-07-2015, at 20:37, Hidden Markov Model huss...@touchofmodern.com 
 wrote:
 
 No, I'm not confused. I just posted on R help website.

The R help website is  NOT on Nabble. You posted from Nabble as can be seen 
from your message.
It can also be seen in what the internet browser displays. It is what we see in 
our email application.

Jeff gave you the correct advice.
Use your email client. Don’t use Nabble and your internet browser.
See the section Using R help on https://stat.ethz.ch/mailman/listinfo/r-help

Berend

 I don't know how to
 use the email client to do anything which you are speaking of. If you would
 like the posts to be made in an alternative way, then you will need to
 provide clear direction. Sending someone to a help page which doesn't
 reference what you are speaking about isn't actually helpful. 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710543.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Daily Category Revenue-Stacked Bar Chart in ggplot2

2015-07-29 Thread Hidden Markov Model
Alright thanks for clarifying. That's all a bit esoteric. Quite different
from basics off computer use.  None of the documentation anyone mentioned
actually contains any of this. If Nabble is so bad, then why does anyone use
it? It doesn't make sense. You should probably write a wiki going forward so
you won't get upset every-time somebody asks a reasonable question. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710560.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Daily Category Revenue-Stacked Bar Chart in ggplot2

2015-07-29 Thread Bert Gunter
Below.

Bert Gunter

Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom.
   -- Clifford Stoll


On Wed, Jul 29, 2015 at 3:43 PM, Hidden Markov Model
huss...@touchofmodern.com wrote:
 Alright thanks for clarifying. That's all a bit esoteric. Quite different
 from basics off computer use.  None of the documentation anyone mentioned
 actually contains any of this. If Nabble is so bad, then why does anyone use
 it? It doesn't make sense.

**You should probably write a wiki going forward so
 you won't get upset every-time somebody asks a reasonable question.**

Fortune nomination!

(I don't actually agree, but I thought it was amusing)





 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710560.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Daily Category Revenue-Stacked Bar Chart in ggplot2

2015-07-29 Thread Hidden Markov Model
Alright kids, I think we should close this topic since we appear to be
getting further and further off-topic. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431p4710563.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] dplyr help

2015-07-29 Thread Jon BR
Hello,
I've recently discovered the helpful dplyr package.  I'm using the
'aggregate' function as such:


bevs - data.frame(cbind(name = c(Bill, Mary), drink = c(coffee,
tea, cocoa, water), cost = seq(1:8), sex = c(male,female)));
bevs$cost - seq(1:8)

 bevs
  name  drink costsex
1 Bill coffee1   male
2 Marytea2 female
3 Bill  cocoa3   male
4 Mary  water4 female
5 Bill coffee5   male
6 Marytea6 female
7 Bill  cocoa7   male
8 Mary  water8 female


 aggregate(cost ~ name + drink, data = bevs, sum)
  name  drink cost
1 Bill  cocoa   10
2 Bill coffee6
3 Marytea8
4 Mary  water   12

My issue is that I would like to keep a column for 'sex', for which there
is a 1:1 mapping with 'name', such that every time 'Bill' appears, it is
always 'male'.

Does anyone know of a way to accomplish this, with or without dplyr?  The
ideal command(s) would produce this:

  name  drink cost sex
1 Bill  cocoa   10   male
2 Bill coffee6   male
3 Marytea8   female
4 Mary  water   12   female

I would be thankful for any suggestion!

Thanks,
Jonathan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] dplyr help

2015-07-29 Thread Jon BR
Hi Brian,
Thanks for the suggestion, although the command is throwing an error as
such:

 bevs %% group_by(name, sex, drink) %% summarise( cost = sum(cost)) %%
select(name, drink, cost, sex)
Error: unexpected input in bevs %% group_by(name, sex, drink) %%
summarise( 

Your syntax is new to me so I'm not immediately clear on how to fix it; any
idea how?

Thanks again,
Jonathan


On Wed, Jul 29, 2015 at 11:07 PM, Brian Kreeger brian.kree...@gmail.com
wrote:

 ​dplyr solution:

 bevs %% group_by(name, sex, drink) %% summarise(​cost = sum(cost)) %%
 select(name, drink, cost, sex)

 The last select statement puts the output in the column order you wanted
 in your result.

 I hope this helps.

 Brian



 On Wed, Jul 29, 2015 at 9:37 PM, Jon BR jonsle...@gmail.com wrote:

 Hello,
 I've recently discovered the helpful dplyr package.  I'm using the
 'aggregate' function as such:


 bevs - data.frame(cbind(name = c(Bill, Mary), drink = c(coffee,
 tea, cocoa, water), cost = seq(1:8), sex = c(male,female)));
 bevs$cost - seq(1:8)

  bevs
   name  drink costsex
 1 Bill coffee1   male
 2 Marytea2 female
 3 Bill  cocoa3   male
 4 Mary  water4 female
 5 Bill coffee5   male
 6 Marytea6 female
 7 Bill  cocoa7   male
 8 Mary  water8 female
 

  aggregate(cost ~ name + drink, data = bevs, sum)
   name  drink cost
 1 Bill  cocoa   10
 2 Bill coffee6
 3 Marytea8
 4 Mary  water   12

 My issue is that I would like to keep a column for 'sex', for which there
 is a 1:1 mapping with 'name', such that every time 'Bill' appears, it is
 always 'male'.

 Does anyone know of a way to accomplish this, with or without dplyr?  The
 ideal command(s) would produce this:

   name  drink cost sex
 1 Bill  cocoa   10   male
 2 Bill coffee6   male
 3 Marytea8   female
 4 Mary  water   12   female

 I would be thankful for any suggestion!

 Thanks,
 Jonathan

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Vignette using knitr, devtools, and R markdown

2015-07-29 Thread Glenn Schultz

Hi All,
I am writing a Vignette with Knitr using devtools ... actually quite awesome.  
However, I would like to create a table of contents.  I have read the knitr and 
r markdown instructions on TOC and I can create a TOC in a markdown document 
but I cannot translate the command to a vignette - maybe doing something wrong. 
 Does anyone know if I can create a TOC in a vignette using r-markdown and 
devtools?

Glenn  
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] dplyr help

2015-07-29 Thread Jon BR
David,
I do appreciate your help, if not the dose of contempt.  I hope you
feel OK.

Thanks for the tips,
-Jonathan

On Wed, Jul 29, 2015 at 11:14 PM, David Winsemius dwinsem...@comcast.net
wrote:


 On Jul 29, 2015, at 7:37 PM, Jon BR wrote:

  Hello,
 I've recently discovered the helpful dplyr package.  I'm using the
  'aggregate' function as such:

 The `aggregate` function is part of base-R:

  bevs - data.frame(cbind(name = c(Bill, Mary), drink = c(coffee,
  tea, cocoa, water), cost = seq(1:8), sex = c(male,female)));
  bevs$cost - seq(1:8)
 
  bevs
   name  drink costsex
  1 Bill coffee1   male
  2 Marytea2 female
  3 Bill  cocoa3   male
  4 Mary  water4 female
  5 Bill coffee5   male
  6 Marytea6 female
  7 Bill  cocoa7   male
  8 Mary  water8 female
 
 
  aggregate(cost ~ name + drink, data = bevs, sum)
   name  drink cost
  1 Bill  cocoa   10
  2 Bill coffee6
  3 Marytea8
  4 Mary  water   12
 
  My issue is that I would like to keep a column for 'sex', for which there
  is a 1:1 mapping with 'name', such that every time 'Bill' appears, it is
  always 'male'.
 
  Does anyone know of a way to accomplish this, with or without dplyr?

 As pointed out you have not yet demonstrated any dplyr functions.

  The
  ideal command(s) would produce this:
 
   name  drink cost sex
  1 Bill  cocoa   10   male
  2 Bill coffee6   male
  3 Marytea8   female
  4 Mary  water   12   female

 Doesn't this (glaringly obvious?) approach succeed?

  aggregate(cost ~ name + drink+sex, data = bevs, sum)
   name  drinksex cost
 1 Marytea female8
 2 Mary  water female   12
 3 Bill  cocoa   male   10
 4 Bill coffee   male6
 


 
  I would be thankful for any suggestion!
 
  Thanks,
  Jonathan
 
[[alternative HTML version deleted]]
 
 

 Please learn to post in plain text.

 --

 David Winsemius
 Alameda, CA, USA



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] dplyr help

2015-07-29 Thread Brian Kreeger
​dplyr solution:

bevs %% group_by(name, sex, drink) %% summarise(​cost = sum(cost)) %%
select(name, drink, cost, sex)

The last select statement puts the output in the column order you wanted in
your result.

I hope this helps.

Brian



On Wed, Jul 29, 2015 at 9:37 PM, Jon BR jonsle...@gmail.com wrote:

 Hello,
 I've recently discovered the helpful dplyr package.  I'm using the
 'aggregate' function as such:


 bevs - data.frame(cbind(name = c(Bill, Mary), drink = c(coffee,
 tea, cocoa, water), cost = seq(1:8), sex = c(male,female)));
 bevs$cost - seq(1:8)

  bevs
   name  drink costsex
 1 Bill coffee1   male
 2 Marytea2 female
 3 Bill  cocoa3   male
 4 Mary  water4 female
 5 Bill coffee5   male
 6 Marytea6 female
 7 Bill  cocoa7   male
 8 Mary  water8 female
 

  aggregate(cost ~ name + drink, data = bevs, sum)
   name  drink cost
 1 Bill  cocoa   10
 2 Bill coffee6
 3 Marytea8
 4 Mary  water   12

 My issue is that I would like to keep a column for 'sex', for which there
 is a 1:1 mapping with 'name', such that every time 'Bill' appears, it is
 always 'male'.

 Does anyone know of a way to accomplish this, with or without dplyr?  The
 ideal command(s) would produce this:

   name  drink cost sex
 1 Bill  cocoa   10   male
 2 Bill coffee6   male
 3 Marytea8   female
 4 Mary  water   12   female

 I would be thankful for any suggestion!

 Thanks,
 Jonathan

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Mixed Date Formats

2015-07-29 Thread Duncan Mackay
Hi

I wonder if it is easier to convert the dates to character format and then 
reformat using gsub or the like

str(SampleData)
SampleData$date - as.character(SampleData$date)
str(SampleData)

as.Date(
ifelse(nchar(SampleData[,date]) == 9, as.Date(SampleData[,date], format = 
%d-%b-%y),
   ifelse(nchar(SampleData[,date]) == 8, as.Date(SampleData[,date], 
format = %d/%m/%y),
  ifelse(as.numeric(substr(SampleData[,date],1,2))  12,
  as.Date(SampleData[,date], format =  %d/%m/%Y),
  as.Date(SampleData[,date], format =  %m/%d/%Y)) )), 
origin = as.Date(1970-01-01))

Beware of the American format in months jan feb mar oct nov -- will need more 
conditions to be imposed

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of farnoosh 
sheikhi via R-help
Sent: Thursday, 30 July 2015 07:16
To: Sarah Goslee
Cc: R. Help
Subject: Re: [R] Mixed Date Formats

Hi Sarah,
Thanks for getting back to me.Here is an example of my data:SampleData - 
structure(list(id = 1:7, value = c(5813L, 8706L, 4049L, 5877L,  
1375L, 2223L, 3423L), date = structure(c(4L, 3L, 
2L, 1L, 7L, 
  6L, 5L), .Label = c(05/12/11, 06/05/11, 07-Dec-11,  

 19-Dec-11, 01/22/2011, 10/19/2011, 31/12/2011  

), class = factor)), .Names = c(id, value, date), row.names = c(NA, 

  -7L), 
class = data.frame)SampleData
Thanks for your help:).
 
 


 On Wednesday, July 29, 2015 1:50 PM, Sarah Goslee sarah.gos...@gmail.com 
wrote:
   

 On Wed, Jul 29, 2015 at 2:45 PM, farnoosh sheikhi via R-help
r-help@r-project.org wrote:
  Hi Arun,
 Hope all is well with you. I have a data with a column for date.The date 
 format is mixed. There are date values with Month/Day/Year format and values 
 with Day/Month/Year format.I don't know how to unify it.I really appreciate 
 your help.Thanks.

You sent this to the R-help list, not just to Arun, so I'm assuming
this is an R question. The best way to get help is to provide a sample
of your data using dput() and to clearly specify what you would like
as the result - unify is a bit vague. paste(x, collapse=) could be
considered unification, after all.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.org


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] dplyr help

2015-07-29 Thread David Winsemius

On Jul 29, 2015, at 7:37 PM, Jon BR wrote:

 Hello,
I've recently discovered the helpful dplyr package.  I'm using the
 'aggregate' function as such: 

The `aggregate` function is part of base-R:

 bevs - data.frame(cbind(name = c(Bill, Mary), drink = c(coffee,
 tea, cocoa, water), cost = seq(1:8), sex = c(male,female)));
 bevs$cost - seq(1:8)
 
 bevs
  name  drink costsex
 1 Bill coffee1   male
 2 Marytea2 female
 3 Bill  cocoa3   male
 4 Mary  water4 female
 5 Bill coffee5   male
 6 Marytea6 female
 7 Bill  cocoa7   male
 8 Mary  water8 female
 
 
 aggregate(cost ~ name + drink, data = bevs, sum)
  name  drink cost
 1 Bill  cocoa   10
 2 Bill coffee6
 3 Marytea8
 4 Mary  water   12
 
 My issue is that I would like to keep a column for 'sex', for which there
 is a 1:1 mapping with 'name', such that every time 'Bill' appears, it is
 always 'male'.
 
 Does anyone know of a way to accomplish this, with or without dplyr?

As pointed out you have not yet demonstrated any dplyr functions.

 The
 ideal command(s) would produce this:
 
  name  drink cost sex
 1 Bill  cocoa   10   male
 2 Bill coffee6   male
 3 Marytea8   female
 4 Mary  water   12   female

Doesn't this (glaringly obvious?) approach succeed?

 aggregate(cost ~ name + drink+sex, data = bevs, sum)
  name  drinksex cost
1 Marytea female8
2 Mary  water female   12
3 Bill  cocoa   male   10
4 Bill coffee   male6
 


 
 I would be thankful for any suggestion!
 
 Thanks,
 Jonathan
 
   [[alternative HTML version deleted]]
 
 

Please learn to post in plain text.

-- 

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Element-by-element division

2015-07-29 Thread peter dalgaard

 On 28 Jul 2015, at 15:53 , Sarah Goslee sarah.gos...@gmail.com wrote:
 
 Sure, there are lots of ways to do everything in R. But mixing in
 apply muddles the issue, since apply() and sweep() use different logic
 to determine MARGIN.

Actually, apply() and sweep() were designed together and use exactly the SAME 
logic to determine the margin. E.g., to sweep out means according to the last 
two dimensions of an array, you do

 m - array(1:24, c(4,3,2))
 (mm - apply(m, c(2,3), mean))
 [,1] [,2]
[1,]  2.5 14.5
[2,]  6.5 18.5
[3,] 10.5 22.5
 sweep(m, c(2,3), mm, -)
, , 1

 [,1] [,2] [,3]
[1,] -1.5 -1.5 -1.5
[2,] -0.5 -0.5 -0.5
[3,]  0.5  0.5  0.5
[4,]  1.5  1.5  1.5

, , 2

 [,1] [,2] [,3]
[1,] -1.5 -1.5 -1.5
[2,] -0.5 -0.5 -0.5
[3,]  0.5  0.5  0.5
[4,]  1.5  1.5  1.5


The trouble comes when people miss the point and start using apply() in ways it 
wasn't designed for... 

-pd

-- 
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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] indices of mismatch element in two vector with missing values

2015-07-29 Thread Martin Maechler
 Hervé Pagès hpa...@fredhutch.org
 on Tue, 28 Jul 2015 23:07:14 -0700 writes:

 On 07/28/2015 09:58 PM, Peter Alspach wrote:
 One way 
 
 seq(test1)[-which(test1==test2)]

 One question is whether 2 NAs should be considered to match or not.
 The OP doesn't tell but I guess he wants them to match:

 test1 - c(1, 2,  NA, 4, NA, 6)
 test2 - c(1, 2, 3,  NA, NA, 66)

 seq(test1)[-which(test1==test2)]
 # [1] 3 4 5 6

 5 should probably not be there!

 but I imagine there are better ones .
 

Yes, indeed, as logical indexing is
considerably safer than negative indexing with which(.) :

PLEASE, everyone, do remember:

 %%===%%
 %%  There is one ___big__ disadvantage to  [ - which(logical) ] :  %%
 %%  It entirely __fails__ when the logical vector is all FALSE   %%
 %%===%%


  ## Example (remember, we want the indices of *differing* entries):
  ## --- Here, all entries differ, so we want to get  1:8 :

   x - c(NA, 1:7)
   y - c(11:17, NA)

   ## now this
   seq(x)[ - which(x == y) ]  ## gives not what you expect

   ## But logical indexing always works:
x == y  is.na(x) == is.na(y)
   seq(x)[!(x == y  is.na(x) == is.na(y))]

With output :

 x - c(NA, 1:7)
 y - c(11:17, NA)
 ## now this
 seq(x)[ - which(x == y) ]  ## gives not what you expect
integer(0)

 ## But logical indexing always works:
  x == y  is.na(x) == is.na(y)
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
 seq(x)[!(x == y  is.na(x) == is.na(y))]
[1] 1 2 3 4 5 6 7 8
 

Martin Maechler
ETH Zurich


 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of baccts
 Sent: Wednesday, 29 July 2015 8:26 a.m.
 To: r-help@r-project.org
 Subject: [R] indices of mismatch element in two vector with missing 
values
 
 How would you return the index where two vectors differs if they may 
contain missing (NA) values?
 For example:
 test1 - c(1,2,NA);
 test2 - c(1,2,3);
 which(test1!=test2) does not return 3!
 
 Thanks in advance.
 


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] indices of mismatch element in two vector with missing values

2015-07-29 Thread Hervé Pagès

On 07/28/2015 09:58 PM, Peter Alspach wrote:

One way 

seq(test1)[-which(test1==test2)]


One question is whether 2 NAs should be considered to match or not.
The OP doesn't tell but I guess he wants them to match:

test1 - c(1, 2,  NA, 4, NA, 6)
test2 - c(1, 2, 3,  NA, NA, 66)

seq(test1)[-which(test1==test2)]
# [1] 3 4 5 6

5 should probably not be there!

H.



but I imagine there are better ones .

Peter Alspach

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of baccts
Sent: Wednesday, 29 July 2015 8:26 a.m.
To: r-help@r-project.org
Subject: [R] indices of mismatch element in two vector with missing values

How would you return the index where two vectors differs if they may contain 
missing (NA) values?
For example:
test1 - c(1,2,NA);
test2 - c(1,2,3);
which(test1!=test2) does not return 3!

Thanks in advance.






--
View this message in context: 
http://r.789695.n4.nabble.com/indices-of-mismatch-element-in-two-vector-with-missing-values-tp4710497.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
The contents of this e-mail are confidential and may be ...{{dropped:14}}

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



--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Reading data with two rows of variable names using read.zoo

2015-07-29 Thread SW Kim
Thanks, Dan.

Your codes work fine. But I have tens of countries UK, JP, BR, US...,
each of which has ten columns a1, a2, ..., a10 of data. So a little more
automation is needed.

I have been trying to make a list of each country's data and use sapply
thing
to get 
   UK   JP
2009 Q2 65 
2009 Q3 75 
2009 Q4 87 
2010 Q1 67 
2010 Q2 63 

But for me, it was not easy as it looks... 
Thank you in advance!



--
View this message in context: 
http://r.789695.n4.nabble.com/Reading-data-with-two-rows-of-variable-names-using-read-zoo-tp4710496p4710510.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] Método S3 paquete

2015-07-29 Thread Guillermo.Vinue
Hola Rubén,

Muchas gracias. 

Un saludo,

Guillermo

 Hola a ambos,
 
  Otra referencia que puede ser de interés es: 
 http://r-pkgs.had.co.nz y también http://adv-r.had.co.nz (las dos de 
 Hadley Wickham...)
 
  Un saludo, Rubén.
 
 
 El 27/07/2015 a las 10:46, guillermo.vi...@uv.es escribió:
  Hola Carlos,
 
  Muchas gracias por el enlace, me ha sido de gran ayuda. Ya he entendido
  cómo funciona el sistema S3.
 
  Un saludo,
 
  Guillermo
 
  Hola, ¿qué tal?
 
  Sigue
 
http://www.datanalytics.com/2011/08/04/desarrollo-de-paquetes-con-r-iv-funciones-genericas/
  a rajatabla y lo tendrás.
 
  Un saludo,
 
  Carlos J. Gil Bellosta
  http://www.datanalytics.com
 
  P.D.: Si te fijas bien, no estás siguiendo esa guía a rajatabla.
 
  El día 23 de julio de 2015, 16:26,  guillermo.vi...@uv.es escribió:
  Hola,
 
  Estoy tratando de crear un método S3 llamado anthr dentro del
paquete
  que estoy desarrollando, cuyo argumento principal es res que
  básicamente es una lista con un solo componente. Pero si el segundo
  argumento llamado oneSize es FALSE, res es una lista de listas.
 
  Lo que he escrito hasta el momento es lo siguiente:
 
  anthr - function(res, oneSize, nsizes){
 UseMethod(anthr)
  }
 
  anthr.tri - function(res, oneSize, nsizes){
 
 if(oneSize){
   cases - c()
   cases - res$meds
 }else{
   cases - list()
   for (i in 1 : (nsizes - 1)){
 cases[[i]] - res[[i]]$meds
   }
 }
 return(cases)
  }
 
  El problema cuando instalo el paquete y utilizo este método, es
que R no
  me reconoce que res sea una lista. En concreto, me aparece este
error:
 
  Error in UseMethod(anthr) :
 no applicable method for 'anthr' applied to an object of class
list
 
  He tratado de añadir esto:
 
  tri - function(x){
value - list(meds = x$meds)
attr(value, class) - tri
value
  }
 
  pero sigue sin funcionarme. ¿Alguien puede ofrecerme alguna ayuda? .
 
  Muchas gracias de antemano.
 
  Un saludo,
 
  Guillermo
 
  ___
  R-help-es mailing list
  R-help-es@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-help-es
 
  ___
  R-help-es mailing list
  R-help-es@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-help-es
 
 
 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es
 
 

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Stop tkbind

2015-07-29 Thread jpara3
Not any ideas?

Thanks!



--
View this message in context: 
http://r.789695.n4.nabble.com/Stop-tkbind-tp4710476p4710514.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] Método S3 paquete

2015-07-29 Thread rubenfcasal

Hola a ambos,

Otra referencia que puede ser de interés es: 
http://r-pkgs.had.co.nz y también http://adv-r.had.co.nz (las dos de 
Hadley Wickham...)


Un saludo, Rubén.


El 27/07/2015 a las 10:46, guillermo.vi...@uv.es escribió:

Hola Carlos,

Muchas gracias por el enlace, me ha sido de gran ayuda. Ya he entendido
cómo funciona el sistema S3.

Un saludo,

Guillermo


Hola, ¿qué tal?

Sigue

http://www.datanalytics.com/2011/08/04/desarrollo-de-paquetes-con-r-iv-funciones-genericas/

a rajatabla y lo tendrás.

Un saludo,

Carlos J. Gil Bellosta
http://www.datanalytics.com

P.D.: Si te fijas bien, no estás siguiendo esa guía a rajatabla.

El día 23 de julio de 2015, 16:26,  guillermo.vi...@uv.es escribió:

Hola,

Estoy tratando de crear un método S3 llamado anthr dentro del paquete
que estoy desarrollando, cuyo argumento principal es res que
básicamente es una lista con un solo componente. Pero si el segundo
argumento llamado oneSize es FALSE, res es una lista de listas.

Lo que he escrito hasta el momento es lo siguiente:

anthr - function(res, oneSize, nsizes){
   UseMethod(anthr)
}

anthr.tri - function(res, oneSize, nsizes){

   if(oneSize){
 cases - c()
 cases - res$meds
   }else{
 cases - list()
 for (i in 1 : (nsizes - 1)){
   cases[[i]] - res[[i]]$meds
 }
   }
   return(cases)
}

El problema cuando instalo el paquete y utilizo este método, es que R no
me reconoce que res sea una lista. En concreto, me aparece este error:

Error in UseMethod(anthr) :
   no applicable method for 'anthr' applied to an object of class list

He tratado de añadir esto:

tri - function(x){
  value - list(meds = x$meds)
  attr(value, class) - tri
  value
}

pero sigue sin funcionarme. ¿Alguien puede ofrecerme alguna ayuda? .

Muchas gracias de antemano.

Un saludo,

Guillermo

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es



___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es



___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


[R] Removing display of R row names from list.

2015-07-29 Thread Frederic Ntirenganya
 Dear All,

Is there a way to not include the row names when creating the list? Thanks!

Regards,
Frederic.

Frederic Ntirenganya
Maseno University,
African Maths Initiative,
Kenya.
Mobile:(+254)718492836
Email: fr...@aims.ac.za
https://sites.google.com/a/aims.ac.za/fredo/

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 read CSV from web?

2015-07-29 Thread jpara3
data-read.csv(https://raw.githubusercontent.com/sjkiss/Survey/master/mlogit.out.csv,header=T,sep=,;)



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-read-CSV-from-web-tp4710502p4710513.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Stop tkbind

2015-07-29 Thread jpara3
The solution is to create a new tkbind function that has not argument

tkbind(img,button-1,)




--
View this message in context: 
http://r.789695.n4.nabble.com/Stop-tkbind-tp4710476p4710517.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] help_ReverseGeocoding

2015-07-29 Thread shreya ghosh
Thank you for your suggestion. Is there any open source api that won't
rate-limit it?



On Tue, Jul 28, 2015 at 9:38 PM, boB Rudis b...@rudis.net wrote:

 You should use ggmap::revgeocode (it calls google's api) and google
 will rate-limit you. There are also packages to use HERE maps
 geo/revgeo lookups

 http://blog.corynissen.com/2014/10/making-r-package-to-use-here-geocode-api.html
 and the geocode package has GNfindNearestAddress, so tons of options
 to choose from.

 On Tue, Jul 28, 2015 at 11:30 AM, MacQueen, Don macque...@llnl.gov
 wrote:
  My first guess, after a quick glance, is that Google only lets you do a
  limited number of lookups within some period of time.
 
  -Don
 
  --
  Don MacQueen
 
  Lawrence Livermore National Laboratory
  7000 East Ave., L-627
  Livermore, CA 94550
  925-423-1062
 
 
 
 
 
  On 7/27/15, 10:14 PM, R-help on behalf of shreya ghosh
  r-help-boun...@r-project.org on behalf of shreya@gmail.com wrote:
 
 Hi,
 I'm trying to do reversegeocoding on a large dataset. I'm using RJSONIO
 library and using Google map API to get the location of the given lat-lon
 in the dataset. After 100 or 150 successful displaying location
 information
 it is showing
  Warning message - In readLines(con) : cannot open: HTTP status was '0
 (null)'
 and Error : Error in fromJSON(paste(readLines(con), collapse = )) :
   error in evaluating the argument 'content' in selecting a method for
 function 'fromJSON': Error in readLines(con) : cannot open the
 connection
 
 Please help me to solve the issue.
 
 location function is as follows :
 
 location-function(latlng){
  latlngStr -  gsub(' ','%20', paste(latlng, collapse=,))
   library(RJSONIO) #Load Library
   #Open Connection
   connectStr - paste('
 http://maps.google.com/maps/api/geocode/json?sensor=falselatlng=
 ',latlngS
 tr,
 sep=)
   con - url(connectStr)
   data.json - fromJSON(paste(readLines(con), collapse=))
   close(con)
 
   data.json - unlist(data.json)
   if(data.json[status]==OK)
 address - data.json[results.formatted_address]
   print (address)
 }
 
 I'm using R version 3.2.1 and Ubuntu 14.10 OS.
 
 Thank you.
 
 
 
 --
 
 Shreya Ghosh
 
 *9007448845*
 
 -- The mind is not a vessel to be filled, but a fire to be kindled
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.




-- 

Shreya Ghosh

*9007448845*

-- The mind is not a vessel to be filled, but a fire to be kindled

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Imbalanced random forest

2015-07-29 Thread jpara3
¿How can i set up a study with random forest where the response is highly
imbalanced?



-

Guided Tours Basque Country 

Guided tours in the three capitals of the Basque Country: Bilbao, 
Vitoria-Gasteiz and San Sebastian, as well as in their provinces. Available 
languages.

Travel planners for groups and design of tourist routes across the Basque 
Country.
--
View this message in context: 
http://r.789695.n4.nabble.com/Imbalanced-random-forest-tp4710524.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Daily Category Revenue-Stacked Bar Chart in ggplot2

2015-07-29 Thread John Kane
First 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
 and http://adv-r.had.co.nz/Reproducibility.html

Second. It is very annoying to have posts come in from Nabble. Very few R-help 
readers use it and the total context of some post to R-help is usually lost. If 
possible could you post directly to R-help.

We have no idea of what your problem is (see above) but here is a very simple 
example of a stacked barchart using ggplot2. And since I am already complaining 
I have included a side-by-side version of the barchart as well. I think that 
stacked barcharts are not a good idea unless obfuscation is the desired 
outcome. It is too hard to compare quantities with no common baseline.

Good luck.

dat1  -  structure(list(dates = structure(c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 
3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), .Label = c(1, 
2, 3, 4, 5), class = factor), revs = c(40, 7, 40, 20, 
35, 20, 15, 20, 15, 20, 15, 15, 35, 20, 20, 7, 7, 20, 7, 35), 
typrep.LETTERS.1.2...10. = structure(c(1L, 2L, 1L, 2L, 
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
2L), .Label = c(A, B), class = factor)), .Names = c(dates, 
revs, typrep.LETTERS.1.2...10.), row.names = c(NA, -20L
), class = data.frame)

#Stacked barchart
ggplot(dat1, aes(dates, revs, fill = typ)) + geom_bar(stat = identity)


#Grouped or dodged barchart (I don't think these are the real names)
ggplot(dat1, aes(dates, revs, fill = typ)) + geom_bar(stat = identity, 
position=dodge)


John Kane
Kingston ON Canada


 -Original Message-
 From: huss...@touchofmodern.com
 Sent: Mon, 27 Jul 2015 13:53:30 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] Daily Category Revenue-Stacked Bar Chart in ggplot2
 
 I am trying to use the ggplot2 to build a stacked bar chart for daily
 Revenue
 by category. The chart would look have date on the x-axis, and revenue on
 the y axis. The fill would be the categories themselves. I have searched
 a
 great deal and have been unable to find exactly how to do this.
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Daily-Category-Revenue-Stacked-Bar-Chart-in-ggplot2-tp4710431.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords  protects your account.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Removing display of R row names from list.

2015-07-29 Thread John Kane
HI Frederic,
Can you supply a small example of the problem?

John Kane
Kingston ON Canada


 -Original Message-
 From: ntfr...@gmail.com
 Sent: Wed, 29 Jul 2015 14:15:58 +0300
 To: r-help@r-project.org
 Subject: [R] Removing display of R row names from list.
 
  Dear All,
 
 Is there a way to not include the row names when creating the list?
 Thanks!
 
 Regards,
 Frederic.
 
 Frederic Ntirenganya
 Maseno University,
 African Maths Initiative,
 Kenya.
 Mobile:(+254)718492836
 Email: fr...@aims.ac.za
 https://sites.google.com/a/aims.ac.za/fredo/
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 EARTH SCREENSAVER - Watch the Earth right on your desktop!

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


Re: [R] R load error

2015-07-29 Thread John Kane
Try restarting R-Studio. I have found that every once in a while it seems to do 
something squirrelly but I have never isolated the problem enough to do a 
report.

Otherwise,perhaps run R in a terminal and see if it will load the data from 
there to  check if the file is actually okay.

John Kane
Kingston ON Canada


 -Original Message-
 From: ypetsc...@fcrr.org
 Sent: Mon, 27 Jul 2015 15:03:52 -0400
 To: r-help@r-project.org
 Subject: [R] R load error
 
 Greetings - I'm using RStudio and recently updated both it and R. When
 loadings up, I'm now receiving the following error:
 
 Error: ReadItem: unknown type 63, perhaps written by later version of R
 
 I've tried using rm(list=ls())   rm(list=ls(all.names=TRUE)) and detach()
 but nothing works in R. Within RStudio it just continues to try and load
 and I'm unable to interrupt or restart. Any ideas would be greatly
 appreciated.
 
 Yaacov Petscher, Ph.D.
 Associate Director, Florida Center for Reading Research
 Senior Research Associate, Regional Educational Laboratory-Southeast
 (REL-SE) at Florida State University
 2010 Levy Ave
 Suite 100
 Tallahassee, Florida, 32310
 850-645-8963 (p)
 850-644-9085 (f)
 http://www.fcrr.org/for-researchers/petscher2.asp
 
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] VIF threshold implying multicollinearity

2015-07-29 Thread John Kane
Quite, but apparently not a boisterous one? 

John Kane
Kingston ON Canada

-Original Message-
From: cfly...@ncsu.edu
Sent: Mon, 27 Jul 2015 14:35:06 -0400
To: jrkrid...@inbox.com
Subject: Re: [R] VIF threshold implying multicollinearity

No actually it is a quiet good paper! :)

On Mon, Jul 27, 2015 at 8:14 AM, John Kane jrkrid...@inbox.com wrote:

+1
 I, originally,  read it as a stringent criticism of the first paper.

 John Kane
 Kingston ON Canada

  -Original Message-
  From: r.tur...@auckland.ac.nz
  Sent: Mon, 27 Jul 2015 15:12:43 +1200
  To: cfly...@ncsu.edu
  Subject: Re: [R] VIF threshold implying multicollinearity
 
 
  On 27/07/15 13:36, Collin Lynch wrote:
 
  The following sources discuss the issues generally and may be a goof
  pointer to the literature ...
 
  SNIP
 
  I think that the foregoing merits fortune status! :-)
 
  cheers,
 
  Rolf
 
  --
  Technical Editor ANZJS
  Department of Statistics
  University of Auckland
  Phone: +64-9-373-7599 ext. 88276
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help 
  [https://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.

 
 FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
 Visit http://www.inbox.com/photosharing [http://www.inbox.com/photosharing] to 
find out more!


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

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