Re: [R] RJDBC in Ubuntu

2012-08-02 Thread Pascal Oettli

Hello,

You probably should reconfigure R using:
 R CMD javareconf

before installing the package you want.

And when you install a package, don't forget the quote.

HTH
Pascal


Le 02/08/2012 14:45, am a écrit :

Hi,

I'm working with R on Cassandra and need to install RJDBC on my Ubuntu
virtual machine. The traditional commands (install.packages(RJDBC, dep=TRUE)
and library(RJDBC)) don't work: they throw an error that they can't find the
package. I tried installing it using the Rkward GUI, but can't write to any
of the pre-set directories because of permissions issues. When I try running
it as root, nothing happens.

I finally tried re-running the install.packages(*'*RJDBC*'*, dep=TRUE)
command with quotes around RJDBC, and got the following:

Warning in install.packages(RJDBC, dep = TRUE) :
   argument 'lib' is missing: using
'/home/bigd/R/x86_64-pc-linux-gnu-library/2.10'
also installing the dependency ‘rJava’
trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/rJava_0.9-3.tar.gz'
Content type 'application/x-gzip' length 537153 bytes (524 Kb)
opened URL
==
downloaded 524 Kb
trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/RJDBC_0.2-0.tar.gz'
Content type 'application/x-gzip' length 11178 bytes (10 Kb)
opened URL
==
downloaded 10 Kb
The downloaded packages are in
‘/tmp/Rtmp7Pb3wA/downloaded_packages’
Warning messages:
1: In install.packages(RJDBC, dep = TRUE) :
   installation of package 'rJava' had non-zero exit status
2: In install.packages(RJDBC, dep = TRUE) :
   installation of package 'RJDBC' had non-zero exit status

...but it's still not working.

Any suggestions? Help would be greatly appreciated.

Sincerely,
AM



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

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



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

2012-08-02 Thread Petr Savicky
On Wed, Aug 01, 2012 at 04:55:30AM -0700, khris wrote:
 Hi Petr,
 
 It been sometime since I wrote. But here are the latest developments. 
 
 When I give the binary linear opt problem to lpSolve optimizer than for small 
 instance it gives correct answer but when size of nodes increase let's say 16 
 then there are about 2000 binary variables and lpSolve just does not come 
 back with any answer even after running for a full day. I plan to solve for 
 node size upto atleast 100, so I guess I need to do something fundamentally 
 different.
 
 Now I understand that lpSolve is using Branch and Bound Algorithm which to me 
 looks highly inefficient, for in the wrost case it will try to solve 2^n LP 
 relaxation problem. Maybe that's why I do not get answer even when n=16. So 
 what do I do to make lpSolve solve problem efficiently. 

Integer linear programming is an NP-complete problem and in general requires an
exponential time. It is not surprising that lpSolve failed to solve a problem
with 2000 variables. It can solve some problems with a few hundreds of 
variables,
but not every such problem.

 In the lpSolve document there does not seem to be any option where one can 
 specify which variable should the optimizer use to use LP relaxation first? 
 Is there way to control in some way Branch and Bound algorithm used by 
 lpSolve apart from the going in side the code and tweaking it.

I do not know, whether this may be controlled.

Do you have a specific reason to use lpSolve for your problem?

Petr.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Efficient deterministic algorithm for Matching Weighted Graphs with bounded degree.

2012-08-02 Thread Petr Savicky
On Wed, Aug 01, 2012 at 06:19:29AM -0700, khris wrote:
 Hi Petr,
 
 The following is different line of thought which is posted in different form, 
 maybe you have some wise input on it.
 
 I need to find Efficient(tracktable) deterministic algorithm for Matching 
 Weighted Graphs with bounded degree. Now we all know Graph matching is 
 non-tractable but when degree of vertex has upper bound are there any 
 tractable algorithm? Does this special case comes under 'Finite Parameter 
 Tractability' ?
 
 Also we know that Graph isomorphism where degree of vertex has upper bound 
 has tractable algorithms. So will it be possible to reduce the Graph matching 
 problem with bounded degree to Graph isomorphism of bounded degree problem 
 then our original problem will have tractable solution.
 
 Appreciate any help or pointer which may take us close towards the solutions.

Hi.

There is currently another thread concerning search of graph isomorphism
using package igraph. May be, you can learn something from there.

  https://stat.ethz.ch/pipermail/r-help/2012-July/320141.html
  https://stat.ethz.ch/pipermail/r-help/2012-August/320225.html

Petr.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sub setting a data frame with binomial responses

2012-08-02 Thread arun kirshna [via R]
Hi,

Just two variant's of David's solution:
 idx-apply(mydata[-1],2,function(x) any(!x %in% c(0,5)))
idx
   x1x2x3x4 
 TRUE FALSE FALSE FALSE 
 idx-c(TRUE,idx)
 mydata[,idx]
#second
idx-apply(mydata[-1],2,function(x) all(ifelse(x!=0  x!=5,TRUE,FALSE )))
 mydata[,c(TRUE,idx)]
  n x1
1 5  2
2 5  3
3 5  1
4 5  3
A.K.




__
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/sub-setting-a-data-frame-with-binomial-responses-tp4638702p4638833.html
This email was sent by arun kirshna (via Nabble)
To receive all replies by email, subscribe to this discussion: 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=subscribe_by_codenode=4638702code=ci1oZWxwQHItcHJvamVjdC5vcmd8NDYzODcwMnwtNzg0MjM1NTA4
[[alternative HTML version deleted]]

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


Re: [R] Foreach help!

2012-08-02 Thread Cloneberry
Thank you Michael,
I thought from the beginning that the explanation was something similar.
Now, I try with expand.grid. Just for information, from another forum, I
received the following explanation:*
*

*Louis 
Schenckhttp://www.linkedin.com/groups?viewMemberFeed=gid=2229532memberID=13075768•
You can find the answer in the foreach vignettes on page 3:
http://cran.r-project.org/web/packages/foreach/vignettes/foreach.pdfhttp://www.linkedin.com/redirect?url=http%3A%2F%2Fcran%2Er-project%2Eorg%2Fweb%2Fpackages%2Fforeach%2Fvignettes%2Fforeach%2Epdfurlhash=2uk-_t=tracking_disc
In your case both ii and jj are iteration variables. They both iterate at
the same time. So the length will be only as long as the shortest
iteration. If you are trying to nest loop you will need the %:% operator.
It might look something like:
foreach(jj=1:2) %:% foreach( ii=12:11) %do% {c(ii,jj)} *
Best,
Max




On Thu, Aug 2, 2012 at 1:25 AM, Michael Weylandt [via R] 
ml-node+s789695n463880...@n4.nabble.com wrote:

 I believe that foreach() only goes along the shorter of the
 iteration vectors.

 E.g.,

 foreach(.combine = c, i = 1:10, j = 1:15) %do% print(i + j)

 stops when i == 10 (and j = 10 as well). To make it more explicit

 foreach(.combine = c, i = 1:10, j = 11:25) %do% print(i + j)

 stops when j = 20 because you run out of i

 foreach does not seem designed for exhaustive search -- you might need
 expand.grid() or some such if you want the cartesian product of ii and
 jj.

 Best,
 Michael

 On Wed, Aug 1, 2012 at 9:09 AM, Cloneberry [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=4638803i=0
 wrote:

  Hi,
  just during these vacation days, I'm trying to approach with multicore
  package
  and I have some troubles with foreach.
 
  ex.
  foreach(.combine=c, ii=1:200, jj=1:500) %dopar% makefunction[ii,jj]
 
  Command seem to work but if I see ii and jj value at the and of cycle,
 they
  are both 200
  instead than ii=200 and jj=500.
 
  Why??
  Can someone help me?
 
  Thank you in advance.
 
  Max
 
 
 
 
  --
  View this message in context:
 http://r.789695.n4.nabble.com/Foreach-help-tp4638688.html
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  [hidden email] 
  http://user/SendEmail.jtp?type=nodenode=4638803i=1mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 __
 [hidden email] http://user/SendEmail.jtp?type=nodenode=4638803i=2mailing 
 list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 --
  If you reply to this email, your message will be added to the discussion
 below:
 http://r.789695.n4.nabble.com/Foreach-help-tp4638688p4638803.html
  To unsubscribe from Foreach help!, click 
 herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4638688code=Y2xvbmViZXJyeUBnbWFpbC5jb218NDYzODY4OHwtMTI2ODQwODg0Ng==
 .
 NAMLhttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml





--
View this message in context: 
http://r.789695.n4.nabble.com/Foreach-help-tp4638688p4638834.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


[R] Subseting

2012-08-02 Thread Akhil dua
Hi everyone

I have banking data set in long format with 4 columns.One of these columns
is bank name which consist of 49 banks and I want the data for only 40
banks out of these 49
so can anyone help me on how to get this 40 banks data

My data looks like

Year  Name totalliabilties assets
1990  a  9010
1991  a  8948
1992  a  8734
1993  a  5605
1990  b  9011
1991  b  6943
1992  b  3734
1993  b  4617
1990  c  5510
1991  c  6718
1992  c  3424
1993  c  5335

please keep in mind that I have 49 firms so I cant do
object-data[,c(names of the banks I need the data)]
and then extract the data for these banks out of the whole sample

[[alternative HTML version deleted]]

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


Re: [R] splitting a vector

2012-08-02 Thread Jan van der Laan

I come up with:

runs - function(numbers) {
tmp - diff(c(0, which(diff(numbers) = 0), length(numbers)))
split(numbers, rep(seq_along(tmp), tmp))
}



Can't say it's elegant, but it seems to work


runs(c(1:3, 1:4))

$`1`
[1] 1 2 3

$`2`
[1] 1 2 3 4


runs(c(1,1,1))

$`1`
[1] 1

$`2`
[1] 1

$`3`
[1] 1


runs(c(1:3, 2:3, 3))

$`1`
[1] 1 2 3

$`2`
[1] 2 3

$`3`
[1] 3


HTH,

Jan



capy_bara hettl...@few.vu.nl schreef:


Hello,

I have a vector with positive integer numbers, e.g.


numbers - c(1,2,1,2,3,4,5)


and want to split the vector whenever an element in the vector is smaller or
equal to its predecessor.
Hence I want to obtain two vectors: c(1,2) and c(1,2,3,4,5).
I tried with which(), but it is not so elegant:


numbers[1:(which(numbers=numbers[1])[2]-1)]
numbers[which(numbers=numbers[1])[2]:length(numbers)]


Sure I can do it with a for-loop, but that seems a bit tedious for that
small problem.
Does maybe anyone know a simple and elegant solution for this? I'm searching
for a general solution, since
my vector may change and maybe be split into more than two vectors, e.g.
give five vectors for c(1,1,2,3,4,5,1,2,3,2,3,4,5,6,4,5).

Many thanks in advance,

Hannes







--
View this message in context:  
http://r.789695.n4.nabble.com/splitting-a-vector-tp4638675.html

Sent from the R help mailing list archive at Nabble.com.

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


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

2012-08-02 Thread Jessica Streicher

On 02.08.2012, at 10:44, Akhil dua wrote:

 Hi everyone
 
 I have banking data set in long format with 4 columns.One of these columns
 is bank name which consist of 49 banks and I want the data for only 40
 banks out of these 49
 so can anyone help me on how to get this 40 banks data
 
 My data looks like
 
 Year  Name totalliabilties assets
 1990  a  9010
 1991  a  8948
 1992  a  8734
 1993  a  5605
 1990  b  9011
 1991  b  6943
 1992  b  3734
 1993  b  4617
 1990  c  5510
 1991  c  6718
 1992  c  3424
 1993  c  5335
 
 please keep in mind that I have 49 firms so I cant do
 object-data[,c(names of the banks I need the data)]

That would actually rather be
data[data$Name %in% names, ]

wouldn't it? You want to extract the rows that belong to a bank you want to 
retain?

what are firms? what have the firms to do with the banks and their names?

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

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


Re: [R] Subseting

2012-08-02 Thread Jessica Streicher
data[data$Name %in% names, ]

should work then. You do know which 40 of your 49 banks you want, right?
put their names in the names variable above.

If you want random 40 banks you can do something like this:

allNames-unique(data$Name)
names-sample(allNames,40)

Does that help? You really aren't explaining your problem well^^

On 02.08.2012, at 11:18, Akhil dua wrote:

 sry its not firms 
 its banks 
 
 On Thu, Aug 2, 2012 at 2:42 PM, Jessica Streicher j.streic...@micromata.de 
 wrote:
 
 On 02.08.2012, at 10:44, Akhil dua wrote:
 
  Hi everyone
 
  I have banking data set in long format with 4 columns.One of these columns
  is bank name which consist of 49 banks and I want the data for only 40
  banks out of these 49
  so can anyone help me on how to get this 40 banks data
 
  My data looks like
 
  Year  Name totalliabilties assets
  1990  a  9010
  1991  a  8948
  1992  a  8734
  1993  a  5605
  1990  b  9011
  1991  b  6943
  1992  b  3734
  1993  b  4617
  1990  c  5510
  1991  c  6718
  1992  c  3424
  1993  c  5335
 
  please keep in mind that I have 49 firms so I cant do
  object-data[,c(names of the banks I need the data)]
 
 That would actually rather be
 data[data$Name %in% names, ]
 
 wouldn't it? You want to extract the rows that belong to a bank you want to 
 retain?
 
 what are firms? what have the firms to do with the banks and their names?
 
  and then extract the data for these banks out of the whole sample
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 

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


Re: [R] Subseting

2012-08-02 Thread Jessica Streicher
data[!(data$Name %in% names), ]

then, and names having the 9 names you want to dismiss.

Also please reply to the list as well if you answer, otherwise others won't 
know of the progress made.

On 02.08.2012, at 11:48, Akhil dua wrote:

 This is the only issue actually
 I dotn want to take the pain of writing names of 40 companies 
 rather than this i want to remove the date for 9 companies which i dont need 
 
 On Thu, Aug 2, 2012 at 3:00 PM, Jessica Streicher j.streic...@micromata.de 
 wrote:
 data[data$Name %in% names, ]
 
 should work then. You do know which 40 of your 49 banks you want, right?
 put their names in the names variable above.
 
 If you want random 40 banks you can do something like this:
 
 allNames-unique(data$Name)
 names-sample(allNames,40)
 
 Does that help? You really aren't explaining your problem well^^
 
 On 02.08.2012, at 11:18, Akhil dua wrote:
 
  sry its not firms
  its banks
 
  On Thu, Aug 2, 2012 at 2:42 PM, Jessica Streicher 
  j.streic...@micromata.de wrote:
 
  On 02.08.2012, at 10:44, Akhil dua wrote:
 
   Hi everyone
  
   I have banking data set in long format with 4 columns.One of these columns
   is bank name which consist of 49 banks and I want the data for only 40
   banks out of these 49
   so can anyone help me on how to get this 40 banks data
  
   My data looks like
  
   Year  Name totalliabilties assets
   1990  a  9010
   1991  a  8948
   1992  a  8734
   1993  a  5605
   1990  b  9011
   1991  b  6943
   1992  b  3734
   1993  b  4617
   1990  c  5510
   1991  c  6718
   1992  c  3424
   1993  c  5335
  
   please keep in mind that I have 49 firms so I cant do
   object-data[,c(names of the banks I need the data)]
 
  That would actually rather be
  data[data$Name %in% names, ]
 
  wouldn't it? You want to extract the rows that belong to a bank you want to 
  retain?
 
  what are firms? what have the firms to do with the banks and their names?
 
   and then extract the data for these banks out of the whole sample
  
 [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide 
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
 
 
 
 

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


Re: [R] length of variable in mlogit

2012-08-02 Thread Ingmar Visser
Lee,
A working, or in this case failing, example is necessary to detect what the
problem is.
This would include a statement loading the package that you use to run your
mlogit models; the latter is necessary because there are various packages
with functions that are called mlgoit.
Best, Ingmar

On Wed, Aug 1, 2012 at 3:05 PM, Lee van Cleef l.van.cl...@gmx.net wrote:

 Ingmar, many thanks. I get that one from R:

 Error in model.frame.default(terms(formula, lhs = lhs, rhs = rhs, data =
 data),  :
   variable lengths differ (found for 'X')

 X is the variable I have used.

 Any comment would be much appreciated.

 Best regards!




 --
 View this message in context:
 http://r.789695.n4.nabble.com/length-of-variable-in-mlogit-tp4638323p4638667.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


[R] Chopping a vector up into smaller vectors

2012-08-02 Thread Stephen Eglen
Anyone got a neat way to chop a vector up into smaller subvectors?
This is what I have now, which seems inelegant:

chop - function(v, counts) {
  stopifnot(sum(counts)==length(v))
  end - cumsum(counts)
  beg - c(1, 1+end[-length(end)])
  begend - cbind(beg, end)
  apply(begend, 1, function(x) v[x[1]:x[2]])
}
  

 chop(9:1, c(3,2,4))
[[1]]
[1] 9 8 7

[[2]]
[1] 6 5

[[3]]
[1] 4 3 2 1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Chopping a vector up into smaller vectors

2012-08-02 Thread Eik Vettorazzi
Hi Stephen,
how about this:

chop-function(x,counts){
 stopifnot(sum(counts)==length(x))
 split(9:1,unlist(mapply(rep,seq_along(counts),counts)))
}
chop(9:1,c(3,2,4))

cheers

Am 02.08.2012 12:29, schrieb Stephen Eglen:
 Anyone got a neat way to chop a vector up into smaller subvectors?
 This is what I have now, which seems inelegant:
 
 chop - function(v, counts) {
   stopifnot(sum(counts)==length(v))
   end - cumsum(counts)
   beg - c(1, 1+end[-length(end)])
   begend - cbind(beg, end)
   apply(begend, 1, function(x) v[x[1]:x[2]])
 }
   
 
 chop(9:1, c(3,2,4))
 [[1]]
 [1] 9 8 7
 
 [[2]]
 [1] 6 5
 
 [[3]]
 [1] 4 3 2 1
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. 
Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 

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

2012-08-02 Thread Uwe Ligges



On 27.07.2012 04:46, Jiajie-Yu wrote:

Hi all
  I was running randomForest with R 2.51.1 RStudio 0.96.316. when i fit
a classificassion there is an error cannot allocate vector of size 113.3
Mb.then I  saved  workspace as default and quit RStudio. I try open it
later, it show the error
Error: cannot allocate vector of size 273.3 MbIs it the workspace too
large to run in my computer( memery 4G, but memory.size(), 1199.93 )? or the
other? and what can i do?


Looks like this got no response so far:

The machine you are using to open the file does not have a sufficient 
amount of available memory, so go to a machne that has, open the 
workspace there, and save relevant objects into deparate RData files 
that you can read on machines with less RAM.


Best,
Uwe Ligges





   thank you !

Jiajie-Yu



--
View this message in context: 
http://r.789695.n4.nabble.com/cannot-load-workspace-tp4638040.html
Sent from the R help mailing list archive at Nabble.com.

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



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Best Programming Practices regarding data frames

2012-08-02 Thread Jan T Kim
On Wed, Aug 01, 2012 at 05:13:01PM -0500, R. Michael Weylandt wrote:
 On Wed, Aug 1, 2012 at 4:19 PM, Ramiro Barrantes
 ram...@precisionbioassay.com wrote:
  Hello,
 
  I come from using different programming languages (C++, Mathematica, Perl) 
  but have been using R extensively for several months.  I see the data frame 
  as a key piece of the language and wanted to inquire people's experience 
  regarding its use.
 
  Say you have a data frame D
 
  D - data.frame(some columns)
 
  and you define a function that needs the information from this data frame 
  and is supposed to return a calculation based on some columns of such data 
  frame D.
 
  func - function(d) {}
  #EFFECT: Does calculation X from some columns of d
 
  QUESTION: Would you consider better practice to return the same data.frame 
  but expanded, or would you return a small data frame that consists of the 
  newly computed columns?
 
 I'd say return what you need, no more no less: and if you want to
 reattach it to the input data, do that at the caller level, but don't
 make it required: orthogonality and minimality and all that jazz

One thing I consider an element of good practice is: Whatever type of
object you return, make sure it contains meaningful names.

So if you return an extended data frame in the example above, make
sure the new columns have reasonable names. If you return a new data
frame with rows corresponding to the data frame passed in, then it's
definitely part of the job of func to do something like

rownames(returnedFrame) - rownames(d);

rather than leaving it to its clients to do that.

This is rather basic but I've seen this being neglected sufficiently
many times to write this post...

Regarding whether to return an extended data frame vs just the computed
columns, I'd tend to go with the latter but if I find that clients of
func all merge the columns from the result into the frame passed in,
then doing that might be a responsibility of func as well.

Best regards, Jan

 As Bert points out, note that returning a data.frame is by no means
 necessary -- they aren't primitive data structures like (atomic)
 vectors and lists [we are in a Scheme dialect after all!], but they
 are helpful and well supported. Use them liberally but no more than
 necessary ;-)
 
 Best,
 Michael
 
 
  Some might say, either way, personal preference.  But after using and 
  seeing other's code for some time, I am thinking that returning the result 
  that consists of ONLY the relevant columns is a better practice as it 
  defines the function as only returning what it was intended to return, and 
  leaves it up to the user of the function to do whatever they were intending 
  to do with it (including naming of the new columns, adding them to a data 
  frame, etc.).  This might be a question for a computer programming theory 
  group, but if anybody has any insight from their experience please share.
 
  Thanks in advance,
 
  Ramiro
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
 +- Jan T. Kim ---+
 | email: jtt...@gmail.com|
 | WWW:   http://www.jtkim.dreamhosters.com/  |
 *-=  hierarchical systems are for files, not for humans  =-*

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Chopping a vector up into smaller vectors

2012-08-02 Thread Petr PIKAL
Hi

one of possible options

f- function(x, parts) split(x,rep(1:length(parts),parts))
f(9:1, c(3,2,4))
$`1`
[1] 9 8 7

$`2`
[1] 6 5

$`3`
[1] 4 3 2 1

You can also check if your parts vector agrees with x vector, if you want.

Regards
Petr


 
 Anyone got a neat way to chop a vector up into smaller subvectors?
 This is what I have now, which seems inelegant:
 
 chop - function(v, counts) {
   stopifnot(sum(counts)==length(v))
   end - cumsum(counts)
   beg - c(1, 1+end[-length(end)])
   begend - cbind(beg, end)
   apply(begend, 1, function(x) v[x[1]:x[2]])
 }
 
 
  chop(9:1, c(3,2,4))
 [[1]]
 [1] 9 8 7
 
 [[2]]
 [1] 6 5
 
 [[3]]
 [1] 4 3 2 1
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] Cannot install the 'igraph' package

2012-08-02 Thread K. Elo

Hi!

I want to use R for network analysis and have tried to install the 
'igraph' package. Unfortunately, the installation is aborted by an error:


--snip--
gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG  -I/usr/local/include 
-DUSING_R -I. -Ics -Iglpk -Iglpk/amd -Iglpk/colamd -I/usr/local/include 
-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector 
-funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG 
-DPACKAGE_VERSION=\0.6\ -DINTERNAL_ARPACK -DIGRAPH_THREAD_LOCAL=/**/ 
-fpic  -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector 
-funwind-tables -fasynchronous-unwind-tables -g  -c rinterface.c -o 
rinterface.o

rinterface.c:30:15: fatal error: R.h: File or directory does not exist!
compilation terminated.
make: *** [rinterface.o] Error 1
ERROR: compilation failed for package ‘igraph’
* removing ‘/usr/lib64/R/library/igraph’

The downloaded source packages are in
‘/tmp/RtmpSFsTPv/downloaded_packages’
Updating HTML index of packages in '.Library'
Making packages.html  ... done
Warning message:
In install.packages(igraph) :
  installation of package ‘igraph’ had non-zero exit status

--snip--

And yes, I have asked Mr. Google, but none of the suggested solutions did 
work. I have tried to install previous versions, no success :(


Any ideas how to install 'igraph'?

I use R 2.15.1 on openSuSE 12.1 (64-bit).

Thanks in advance,
Kimmo__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] rpart package: why does predict.rpart require values for unused predictors?

2012-08-02 Thread Jean V Adams
Jason,

In the help file for predict.rpart it says, The predictors referred to in 
the right side of formula(object) must be present by name in newdata.
?predict.rpart

So, that's just the way it is.  There are a couple ways to work around 
this, if you wish.  You could create a data frame with all NAs for the 
unused predictor(s).  For example,
newdata2 - data.frame(Disp.=car.test.frame$Disp., 
Weight=car.test.frame$Weight, HP=as.numeric(rep(NA, 
dim(car.test.frame)[1])))
predict(model, newdata=newdata2)

Or, you could refit the model using only the important factors.  For 
example,
model2 - rpart(Mileage ~ Weight + Disp., car.test.frame)
predict(model2, newdata=newdata)

Jean


Jason Roberts jason.robe...@duke.edu wrote on 08/01/2012 05:17:38 PM:
 
 After fitting and pruning an rpart model, it is often the case that one 
or
 more of the original predictors is not used by any of the splits of the
 final tree. It seems logical, therefore, that values for these unused
 predictors would not be needed for prediction. But when predict() is 
called
 on such models, all predictors seem to be required. Why is that, and can 
it
 be easily circumvented?
 
 Consider this example:
 
  model - rpart(Mileage ~ Weight + Disp. + HP, car.test.frame)
  model
 n= 60 
 
 node), split, n, deviance, yval
   * denotes terminal node
 
 1) root 60 1354.58300 24.58333 
   2) Disp.=134 35  154.4 21.4 
 4) Weight=3087.5 22   61.31818 20.40909 *
 5) Weight 3087.5 13   34.92308 23.07692 *
   3) Disp. 134 25  348.96000 29.04000 
 6) Disp.=97.5 16  101.75000 27.12500 *
 7) Disp. 97.5 9   84.2 32.4 *
  newdata - data.frame(Disp.=car.test.frame$Disp.,
 Weight=car.test.frame$Weight)
  predict(model, newdata=newdata)
 Error in eval(expr, envir, enclos) : object 'HP' not found
 
 In this model, Disp. and Weight were used in splits, but HP was not. 
Thus I
 expected to be able to perform predictions by providing values for just
 Disp. and Weight, but predict() failed when I tried that, complaining 
that
 HP was not also provided.
 
 Thanks for any help you can provide. My apologies if I simply do not
 understand how this works.
 
 Best regards,
 
 Jason

[[alternative HTML version deleted]]

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


[R] Polygon shaded area

2012-08-02 Thread Jose Narillos de Santos
Hi all,

I have two vectors (columns) called efinal and efinal 2.

I want to plot them on the same plot and draw a shaded area beween the
two lines using function polygon

I have tried all but I don ´t understand the polygon area, can you help me
with examples?

plot(efinal,type=l,ylim=range(min(efinal2),
max(efinal)),ylab=,main=plot)

par(new=T)
plot(efinal2,type=l,ylim=range(min(efinal2), max(efinal)),ylab=)

The efinal are two temporal series I attach?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Cannot install the 'igraph' package

2012-08-02 Thread Uwe Ligges



On 02.08.2012 14:26, K. Elo wrote:

Hi!

I want to use R for network analysis and have tried to install the
'igraph' package. Unfortunately, the installation is aborted by an error:

--snip--
gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG  -I/usr/local/include
-DUSING_R -I. -Ics -Iglpk -Iglpk/amd -Iglpk/colamd -I/usr/local/include
-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector
-funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG
-DPACKAGE_VERSION=\0.6\ -DINTERNAL_ARPACK -DIGRAPH_THREAD_LOCAL=/**/
-fpic  -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2
-fstack-protector -funwind-tables -fasynchronous-unwind-tables -g  -c
rinterface.c -o rinterface.o
rinterface.c:30:15: fatal error: R.h: File or directory does not exist!
compilation terminated.



R.h should be part if your R installation, given the output above 
probably in  /usr/lib64/R/include ?


Uwe Ligges






make: *** [rinterface.o] Error 1
ERROR: compilation failed for package ‘igraph’
* removing ‘/usr/lib64/R/library/igraph’

The downloaded source packages are in
 ‘/tmp/RtmpSFsTPv/downloaded_packages’
Updating HTML index of packages in '.Library'
Making packages.html  ... done
Warning message:
In install.packages(igraph) :
   installation of package ‘igraph’ had non-zero exit status

--snip--

And yes, I have asked Mr. Google, but none of the suggested solutions
did work. I have tried to install previous versions, no success :(

Any ideas how to install 'igraph'?

I use R 2.15.1 on openSuSE 12.1 (64-bit).

Thanks in advance,
Kimmo


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



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


Re: [R] Polygon shaded area

2012-08-02 Thread Uwe Ligges



On 02.08.2012 14:33, Jose Narillos de Santos wrote:

Hi all,

I have two vectors (columns) called efinal and efinal 2.

I want to plot them on the same plot and draw a shaded area beween the
two lines using function polygon

I have tried all but I don ´t understand the polygon area, can you help me
with examples?

plot(efinal,type=l,ylim=range(min(efinal2),
max(efinal)),ylab=,main=plot)

par(new=T)
plot(efinal2,type=l,ylim=range(min(efinal2), max(efinal)),ylab=)

The efinal are two temporal series I attach?



Don't know, at least not attached to the message through R-help.

I don't see what the problem is to construct a polygon()
Just insert x and y values of both series in an appropriate order and 
connect them at the end.


If you fail, provide fully reproducible code (we do not have efinal nor 
efinal 2 for now).


Best,
Uwe Ligges











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



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


Re: [R] Polygon shaded area

2012-08-02 Thread Eik Vettorazzi
Hi Jose,
how about this

example(polygon)

I think the second one is pretty much what you want.

cheers.

Am 02.08.2012 14:33, schrieb Jose Narillos de Santos:
 Hi all,
 
 I have two vectors (columns) called efinal and efinal 2.
 
 I want to plot them on the same plot and draw a shaded area beween the
 two lines using function polygon
 
 I have tried all but I don ´t understand the polygon area, can you help me
 with examples?
 
 plot(efinal,type=l,ylim=range(min(efinal2),
 max(efinal)),ylab=,main=plot)
 
 par(new=T)
 plot(efinal2,type=l,ylim=range(min(efinal2), max(efinal)),ylab=)
 
 The efinal are two temporal series I attach?
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. 
Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Eleaps in package subselect crashes when using include arguement

2012-08-02 Thread Uwe Ligges



On 27.07.2012 07:10, Nathan Stephens wrote:

I'm using eleaps to build a forward selection algorithm iteratively, but
the program unexpectedly crashes. In fact, it completely closes my session
in RStudio. The first 39 steps work fine, but on the 40th step, it
unexpectedly stops with no errors. I've isolated the error to the code
snippit below. There are 39 predictors, and I'm searching for the 40th
best. I've passed in a fisher information matrix and the H matrix. I can't
figure out why the process is stopping at the 40th iteration.

include-scan()
1 2 3 5 8 16 18 19 25 32 33 34 36 37 38 40 41 42 46 49 52 54 55 58 60 62 63
66 67 70 72 74 78 81 83 88 89 100 105
lps - eleaps(x$mat, 40, 40, 1, NULL, include, H=x$H, r=1)


We do not have x, hence cannot reproduce. But if this crashes and x 
contains valid objects $mat and $H for eleaps, please report the full 
bug report including a reproducible example (i.e. including your object 
x) to the package maintainer rather than to this list..


Uwe Ligges





--Nathan

[[alternative HTML version deleted]]

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



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


Re: [R] How to link two R packages together

2012-08-02 Thread Bert Gunter
Josh:

You may be right ... but I still do not think so. Note that the post
begins with:

One of them (PKG1) needs to use the functions
 of the other package (PKG2).

This is exactly what imports are for. I believe that, because he/she
failed to RTFM, he/she is not being accurate in his/her use of the
relevant terms. Certainly, to me at least, it is unclear. Moreover, as
I understand it (see the manual) imports are preferred over
dependencies, as I indicated in my reply.

Anyway, in either case, the central advice is that which both Michael
and I gave: RTFM. Perhaps it's a generation gap (I am old), but I
believe there has been a trend for new R users to post here without
making any significant effort to consult the docs. This strikes me as
intellectually lazy and, frankly, inconsiderate to those like yourself
-- or BDR -- who are willing to give up their time and effort to help
those with legitimate questions. You and others may consider this an
overreaction of course.

Sorry for the rant, but it seems relevant to your close parsing of the thread.

-- Cheers,
Bert

On Wed, Aug 1, 2012 at 10:35 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 On Wed, Aug 1, 2012 at 10:28 PM, Bert Gunter gunter.ber...@gene.com wrote:
 On Wed, Aug 1, 2012 at 6:45 PM, Michael Weylandt
 michael.weyla...@gmail.com wrote:
 Isn't this what package dependencies are for?

 No. It's what package imports are for (preferably).
 As always, the OP should RTFM -- in this case the one to which you
 refer on the next line, especially the NAMESPACES section.

 But note that the original question included, when I load one package
 using 'library(PKG1)', PKG2 can be loaded at the same. which
 imports does not exactly do. They become available to the package, but
 not to the user, so if you really need both packages loaded to the
 search path, then you need a dependency, not imports.

 Cheers,

 Josh


 -- Bert


 See the description of the DESCRIPTION file in Writing R Extensions

 Michael

 On Aug 1, 2012, at 5:27 PM, xuan zhao xuan.z...@sentrana.com wrote:

 Hi,
 I have built two R packages. One of them (PKG1) needs to use the functions
 of the other package (PKG2).
 So I need to link these two packages together, so that the functions of 
 PKG2
 can be available to PKG1. And when I load one package using
 'library(PKG1)', PKG2 can be loaded at the same.
 Any ideas welcome.




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/How-to-link-two-R-packages-together-tp4638765.html
 Sent from the R help mailing list archive at Nabble.com.

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

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



 --

 Bert Gunter
 Genentech Nonclinical Biostatistics

 Internal Contact Info:
 Phone: 467-7374
 Website:
 http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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



 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 Programmer Analyst II, Statistical Consulting Group
 University of California, Los Angeles
 https://joshuawiley.com/



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 link two R packages together

2012-08-02 Thread Joshua Wiley
Hi Bert,

Likewise, you may well be right.  In fact, if I were going to assign
probabilities of being correct given the original post, I would give
you about .7 and me about .3.  I commented for completeness of
discussion.  I definitely see your point, and thank you for a
thoughtful reply to my post. I agree that many questions seem to me
that a quick read of the docs would solve them. That brings up an
interesting point, though.  In a population of 100, if 1-2 people have
a preventable illness, we might be inclined to blame them; what if
40-50 people have the preventable illness?  It seems to me lack of
reading the docs and following the posting guide are at epidemic
proportions. I do not know if it is a generation gap, true laziness,
lack of knowledge that the docs and posting guide _should_ be read
first, or ...

This is slightly OT, but I remember one time when I was working with
someone in person (not in R), and there was a question about how to
customize some graphic.  I immediately went to open up the help files
but the person I was working with said, I don't want look at the
documentation and instead starting searching through a cookbook of
different graphs to try to find the answer.  I was shocked because it
seemed like an innate visceral response to the official docs. Perhaps
our useRs are afflicted with this same condition.

Cheers,

Josh

On Thu, Aug 2, 2012 at 6:42 AM, Bert Gunter gunter.ber...@gene.com wrote:
 Josh:

 You may be right ... but I still do not think so. Note that the post
 begins with:

 One of them (PKG1) needs to use the functions
 of the other package (PKG2).

 This is exactly what imports are for. I believe that, because he/she
 failed to RTFM, he/she is not being accurate in his/her use of the
 relevant terms. Certainly, to me at least, it is unclear. Moreover, as
 I understand it (see the manual) imports are preferred over
 dependencies, as I indicated in my reply.

 Anyway, in either case, the central advice is that which both Michael
 and I gave: RTFM. Perhaps it's a generation gap (I am old), but I
 believe there has been a trend for new R users to post here without
 making any significant effort to consult the docs. This strikes me as
 intellectually lazy and, frankly, inconsiderate to those like yourself
 -- or BDR -- who are willing to give up their time and effort to help
 those with legitimate questions. You and others may consider this an
 overreaction of course.

 Sorry for the rant, but it seems relevant to your close parsing of the thread.

 -- Cheers,
 Bert

 On Wed, Aug 1, 2012 at 10:35 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 On Wed, Aug 1, 2012 at 10:28 PM, Bert Gunter gunter.ber...@gene.com wrote:
 On Wed, Aug 1, 2012 at 6:45 PM, Michael Weylandt
 michael.weyla...@gmail.com wrote:
 Isn't this what package dependencies are for?

 No. It's what package imports are for (preferably).
 As always, the OP should RTFM -- in this case the one to which you
 refer on the next line, especially the NAMESPACES section.

 But note that the original question included, when I load one package
 using 'library(PKG1)', PKG2 can be loaded at the same. which
 imports does not exactly do. They become available to the package, but
 not to the user, so if you really need both packages loaded to the
 search path, then you need a dependency, not imports.

 Cheers,

 Josh


 -- Bert


 See the description of the DESCRIPTION file in Writing R Extensions

 Michael

 On Aug 1, 2012, at 5:27 PM, xuan zhao xuan.z...@sentrana.com wrote:

 Hi,
 I have built two R packages. One of them (PKG1) needs to use the functions
 of the other package (PKG2).
 So I need to link these two packages together, so that the functions of 
 PKG2
 can be available to PKG1. And when I load one package using
 'library(PKG1)', PKG2 can be loaded at the same.
 Any ideas welcome.




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/How-to-link-two-R-packages-together-tp4638765.html
 Sent from the R help mailing list archive at Nabble.com.

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

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



 --

 Bert Gunter
 Genentech Nonclinical Biostatistics

 Internal Contact Info:
 Phone: 467-7374
 Website:
 http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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

Re: [R] Polygon shaded area

2012-08-02 Thread Jose Narillos de Santos
Hi I attach my function. No error message (it seems a line appears but
nothing similar to examples(polygon))



2012/8/2 Eik Vettorazzi e.vettora...@uke.de

 Hi Jose,
 how about this

 example(polygon)

 I think the second one is pretty much what you want.

 cheers.

 Am 02.08.2012 14:33, schrieb Jose Narillos de Santos:
  Hi all,
 
  I have two vectors (columns) called efinal and efinal 2.
 
  I want to plot them on the same plot and draw a shaded area beween the
  two lines using function polygon
 
  I have tried all but I don ´t understand the polygon area, can you help
 me
  with examples?
 
  plot(efinal,type=l,ylim=range(min(efinal2),
  max(efinal)),ylab=,main=plot)
 
  par(new=T)
  plot(efinal2,type=l,ylim=range(min(efinal2), max(efinal)),ylab=)
 
  The efinal are two temporal series I attach?
 
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


 --
 Eik Vettorazzi

 Department of Medical Biometry and Epidemiology
 University Medical Center Hamburg-Eppendorf

 Martinistr. 52
 20246 Hamburg

 T ++49/40/7410-58243
 F ++49/40/7410-57790

 --
 Pflichtangaben gemäß Gesetz über elektronische Handelsregister und
 Genossenschaftsregister sowie das Unternehmensregister (EHUG):

 Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen
 Rechts; Gerichtsstand: Hamburg

 Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden),
 Dr. Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 link two R packages together

2012-08-02 Thread Joshua Wiley
Hi Xuan,

I would expect ~/R/ to be the R_HOME directory, though perhaps I am
wrong.  Also, you only need a depends or an imports, not both.  At a
simplified level, the difference is that importing PKG2 in PKG1 makes
the (exported) functions in PKG2 available to PKG1. Depends also makes
the (exported) functions in PKG2 available to PKG1, but it _also_
makes them available to the user.  This can be good or bad, with the
recommendation now being not to. The reason it can be good is if you
want your users to have access to functions in both packages without
explicitly loading both. However, let's say that function foo() is
defined in PKG2 and in PKG3. PKG1 does not know about PKG3, and the
user had PKG3 loaded prior to loading PKG1. Then when PKG1 loads, PKG2
also loads, and because all the exported functions from PKG2 are
included, PKG2::foo() masks PKG3::foo(), which can be annoying for
users if your package adds unnecessary functions to the search path
potentially masking the versions they wanted to use.

That was a rather convoluted explanation, but hopefully it is somewhat clear.

Sincerely,

Josh

On Thu, Aug 2, 2012 at 7:02 AM, Xuan Zhao xuan.z...@sentrana.com wrote:
 Hi All,
 Thank you so much for all the help you have provided, I really appreciate it!
 The problem is solved, I just added PKG2 to the dependency of PKG1 in the 
 description file, also (I don't know if it's necessary or not), I added 
 import(PKG2) to the NAMESPACE file. In addition to that, I install PKG2 
 under a path R can recognize, namely, belong to .libPaths().
 I have tried other ways besides install it under the path R can recognize, 
 like  adding a file ~/.R/check.Environ, whose contents are: 
 'R_LIBS_SITE=${R_LIBS_SITE-'directoryunderwhichPKG2isinstalled'}', but it 
 still doesn't work.
 I looked through the manual, they just say the file 'check.Environ' should be 
 put under '~/.R', but I am not should what the ~/ should be. Is that my 
 home directory or what? Should that be the host? I am not the host of the 
 server, does that matter?
 Thank you so much for the help!
 Yours,
 Xuan

 -Original Message-
 From: Bert Gunter [mailto:gunter.ber...@gene.com]
 Sent: Thursday, August 02, 2012 9:42 AM
 To: Joshua Wiley
 Cc: Michael Weylandt; r-help@r-project.org; Xuan Zhao
 Subject: Re: [R] How to link two R packages together

 Josh:

 You may be right ... but I still do not think so. Note that the post begins 
 with:

 One of them (PKG1) needs to use the functions
 of the other package (PKG2).

 This is exactly what imports are for. I believe that, because he/she failed 
 to RTFM, he/she is not being accurate in his/her use of the relevant terms. 
 Certainly, to me at least, it is unclear. Moreover, as I understand it (see 
 the manual) imports are preferred over dependencies, as I indicated in my 
 reply.

 Anyway, in either case, the central advice is that which both Michael and I 
 gave: RTFM. Perhaps it's a generation gap (I am old), but I believe there has 
 been a trend for new R users to post here without making any significant 
 effort to consult the docs. This strikes me as intellectually lazy and, 
 frankly, inconsiderate to those like yourself
 -- or BDR -- who are willing to give up their time and effort to help those 
 with legitimate questions. You and others may consider this an overreaction 
 of course.

 Sorry for the rant, but it seems relevant to your close parsing of the thread.

 -- Cheers,
 Bert

 On Wed, Aug 1, 2012 at 10:35 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 On Wed, Aug 1, 2012 at 10:28 PM, Bert Gunter gunter.ber...@gene.com wrote:
 On Wed, Aug 1, 2012 at 6:45 PM, Michael Weylandt
 michael.weyla...@gmail.com wrote:
 Isn't this what package dependencies are for?

 No. It's what package imports are for (preferably).
 As always, the OP should RTFM -- in this case the one to which you
 refer on the next line, especially the NAMESPACES section.

 But note that the original question included, when I load one package
 using 'library(PKG1)', PKG2 can be loaded at the same. which
 imports does not exactly do. They become available to the package, but
 not to the user, so if you really need both packages loaded to the
 search path, then you need a dependency, not imports.

 Cheers,

 Josh


 -- Bert


 See the description of the DESCRIPTION file in Writing R Extensions

 Michael

 On Aug 1, 2012, at 5:27 PM, xuan zhao xuan.z...@sentrana.com wrote:

 Hi,
 I have built two R packages. One of them (PKG1) needs to use the
 functions of the other package (PKG2).
 So I need to link these two packages together, so that the
 functions of PKG2 can be available to PKG1. And when I load one
 package using 'library(PKG1)', PKG2 can be loaded at the same.
 Any ideas welcome.




 --
 View this message in context:
 http://r.789695.n4.nabble.com/How-to-link-two-R-packages-together-t
 p4638765.html Sent from the R help mailing list archive at
 Nabble.com.

 __
 

Re: [R] rpart package: why does predict.rpart require values for unused predictors?

2012-08-02 Thread Jason Roberts
Jean,

Thanks for your quick reply and suggestions! 

 In the help file for predict.rpart it says, The predictors referred to in
 the right side of formula(object) must be present by name in newdata.

I was aware of that statement from the help file. I wondered about the
reason for that requirement. It would be convenient for the caller to not
have to provide values for unused predictors. I wondered whether the
requirement to provide them all was related to something I did not
understand, such as surrogate splits, or whether imposing it simply made
rpart itself easier to implement. (No offence intended to the authors for
taking a shortcut, if indeed they did.)

Are you pretty confident that your suggested workarounds will result in a
model that produces identical predictions? I only ask because I'm aware that
rpart has the ability to use surrogate variables in place of predictors that
are missing. But I do not fully understand how that capability works. I do
not know whether it is only used during fitting and not prediction.

Continuing my example, I can see that printcp produces some output
Variables actually used in tree construction:

 printcp(model)

Regression tree:
rpart(formula = Mileage ~ Weight + Disp. + HP, data = car.test.frame)

Variables actually used in tree construction:
[1] Disp.  Weight

...

I can see in the source for printcp how those variables were obtained. But
when doing predictions, is it really safe to only provide them and not HP,
if I expect that there could be missing values for them? When I call
summary, I can see surrogate splits that reference the HP variable:

 summary(model)
Call:
rpart(formula = Mileage ~ Weight + Disp. + HP, data = car.test.frame)
  n= 60 

  CP nsplit rel errorxerror   xstd
1 0.62840234  0 1.000 1.0326274 0.17828576
2 0.12032318  1 0.3715977 0.5271278 0.08627909
3 0.04293478  2 0.2512745 0.4092689 0.07260291
4 0.0100  3 0.2083397 0.3629544 0.06865150

Node number 1: 60 observations,complexity param=0.6284023
  mean=24.58333, MSE=22.57639 
  left son=2 (35 obs) right son=3 (25 obs)
  Primary splits:
  Disp.   134to the right, improve=0.6284023, (0 missing)
  Weight  2567.5 to the right, improve=0.5953491, (0 missing)
  HP  104.5  to the right, improve=0.4085043, (0 missing)
  Surrogate splits:
  Weight  2747.5 to the right, agree=0.900, adj=0.76, (0 split)
  HP  104.5  to the right, agree=0.817, adj=0.56, (0 split)

...

Assuming that the answer is:

1. The best predictions will be obtained by providing values for the
variables actually used in tree construction plus those used as
surrogates, and:

2. If a variable is neither actually used in tree construction nor as a
surrogate, it can be safely set to NA for the prediction.

Do you know of a way to easily identify the variables used as surrogates?

Thanks again for your help, and sorry to write a book in response,

Jason

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 link two R packages together

2012-08-02 Thread Bert Gunter
I will reply inline here, but I believe any further questions about
package development should be posted to the R-devel list rather than
here (please someone correct me if this is wrong).

-- Bert

On Thu, Aug 2, 2012 at 7:02 AM, Xuan Zhao xuan.z...@sentrana.com wrote:
 Hi All,
 Thank you so much for all the help you have provided, I really appreciate it!
 The problem is solved, I just added PKG2 to the dependency of PKG1 in the 
 description file, also (I don't know if it's necessary or not),

From the R extensions manual:
The ‘Imports’ field lists packages whose namespaces are imported from
(as specified in the
‘NAMESPACE’ file) but which do not need to be attached.

Packages declared in the ‘Depends’ field should not
also be in the ‘Imports’ field.  [in the DESCRIPTION file]

So the answer is no -- you should not do this, although as you
apparently did not specify the imports in the DESCRIPTION file, it
should have no effect.

 I added import(PKG2) to the NAMESPACE file.
So remove this.

 In addition to that, I install PKG2 under a path R can recognize,
namely, belong to .libPaths().

Of course. See ?library ?INSTALL  ?install.packages (in R).  This is
the 2nd paragraph of the installation manual, in which ALL your
questions are answered.

-- Bert


 I have tried other ways besides install it under the path R can recognize, 
 like  adding a file ~/.R/check.Environ, whose contents are: 
 'R_LIBS_SITE=${R_LIBS_SITE-'directoryunderwhichPKG2isinstalled'}', but it 
 still doesn't work.
 I looked through the manual, they just say the file 'check.Environ' should be 
 put under '~/.R', but I am not should what the ~/ should be. Is that my 
 home directory or what? Should that be the host? I am not the host of the 
 server, does that matter?
 Thank you so much for the help!
 Yours,
 Xuan

 -Original Message-
 From: Bert Gunter [mailto:gunter.ber...@gene.com]
 Sent: Thursday, August 02, 2012 9:42 AM
 To: Joshua Wiley
 Cc: Michael Weylandt; r-help@r-project.org; Xuan Zhao
 Subject: Re: [R] How to link two R packages together

 Josh:

 You may be right ... but I still do not think so. Note that the post begins 
 with:

 One of them (PKG1) needs to use the functions
 of the other package (PKG2).

 This is exactly what imports are for. I believe that, because he/she failed 
 to RTFM, he/she is not being accurate in his/her use of the relevant terms. 
 Certainly, to me at least, it is unclear. Moreover, as I understand it (see 
 the manual) imports are preferred over dependencies, as I indicated in my 
 reply.

 Anyway, in either case, the central advice is that which both Michael and I 
 gave: RTFM. Perhaps it's a generation gap (I am old), but I believe there has 
 been a trend for new R users to post here without making any significant 
 effort to consult the docs. This strikes me as intellectually lazy and, 
 frankly, inconsiderate to those like yourself
 -- or BDR -- who are willing to give up their time and effort to help those 
 with legitimate questions. You and others may consider this an overreaction 
 of course.

 Sorry for the rant, but it seems relevant to your close parsing of the thread.

 -- Cheers,
 Bert

 On Wed, Aug 1, 2012 at 10:35 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 On Wed, Aug 1, 2012 at 10:28 PM, Bert Gunter gunter.ber...@gene.com wrote:
 On Wed, Aug 1, 2012 at 6:45 PM, Michael Weylandt
 michael.weyla...@gmail.com wrote:
 Isn't this what package dependencies are for?

 No. It's what package imports are for (preferably).
 As always, the OP should RTFM -- in this case the one to which you
 refer on the next line, especially the NAMESPACES section.

 But note that the original question included, when I load one package
 using 'library(PKG1)', PKG2 can be loaded at the same. which
 imports does not exactly do. They become available to the package, but
 not to the user, so if you really need both packages loaded to the
 search path, then you need a dependency, not imports.

 Cheers,

 Josh


 -- Bert


 See the description of the DESCRIPTION file in Writing R Extensions

 Michael

 On Aug 1, 2012, at 5:27 PM, xuan zhao xuan.z...@sentrana.com wrote:

 Hi,
 I have built two R packages. One of them (PKG1) needs to use the
 functions of the other package (PKG2).
 So I need to link these two packages together, so that the
 functions of PKG2 can be available to PKG1. And when I load one
 package using 'library(PKG1)', PKG2 can be loaded at the same.
 Any ideas welcome.




 --
 View this message in context:
 http://r.789695.n4.nabble.com/How-to-link-two-R-packages-together-t
 p4638765.html Sent from the R help mailing list archive at
 Nabble.com.

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

 __
 

Re: [R] Polygon shaded area

2012-08-02 Thread John Kane
 The efinal are two temporal series I attach?

Not attached.  R-help typically strips out any attachment to prevent malware 
being spread.  

The best way to supply sample date is to use the dput() command.  See ?dput for 
details but basically just say dput(myfile) and copy the results into your 
email.  Readers can directly paste the file into their R console and see 
exactly what your data is.

John Kane
Kingston ON Canada


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
https://stat.ethz.ch/mailman/listinfo/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 link two R packages together

2012-08-02 Thread R. Michael Weylandt
On Thu, Aug 2, 2012 at 9:02 AM, Xuan Zhao xuan.z...@sentrana.com wrote:
 Hi All,
 Thank you so much for all the help you have provided, I really appreciate it!
 The problem is solved, I just added PKG2 to the dependency of PKG1 in the 
 description file, also (I don't know if it's necessary or not), I added 
 import(PKG2) to the NAMESPACE file. In addition to that, I install PKG2 
 under a path R can recognize, namely, belong to .libPaths().
 I have tried other ways besides install it under the path R can recognize, 
 like  adding a file ~/.R/check.Environ, whose contents are: 
 'R_LIBS_SITE=${R_LIBS_SITE-'directoryunderwhichPKG2isinstalled'}', but it 
 still doesn't work.

By which you mean  ?

 I looked through the manual, they just say the file 'check.Environ' should be 
 put under '~/.R', but I am not should what the ~/ should be. Is that my 
 home directory or what? Should that be the host? I am not the host of the 
 server, does that matter?
 Thank you so much for the help!
 Yours,
 Xuan

~ is a standard UNIX (POSIX?) shorthand for the user's home
directory. On my Mac it is /Users/mweylandt and I imagine you'd get
something similar on all Linux and BSD systems -- one easy way to see
where it is: go to your terminal and type cd  pwd which will print
it out. No idea what the parallel on Windows is: possibly something
under C:/Documents and Settings but it's been so long since I've had
the misfortune of doing serious work on Windows, I can't remember.

Incidentally, is there a reason you can't put your package in the
regular place?

Finally, see the manuals that Bert, Josh, and I have pointed you to:
they are much more authoritative on these matters than any of us.

Best,
Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 link two R packages together

2012-08-02 Thread Bert Gunter
Inline.

On Thu, Aug 2, 2012 at 7:39 AM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 Hi Xuan,

 I would expect ~/R/ to be the R_HOME directory, though perhaps I am
 wrong.  Also, you only need a depends or an imports, not both.  At a
 simplified level, the difference is that importing PKG2 in PKG1 makes
 the (exported) functions in PKG2 available to PKG1. Depends also makes
 the (exported) functions in PKG2 available to PKG1, but it _also_
 makes them available to the user.  This can be good or bad, with the
 recommendation now being not to. The reason it can be good is if you
 want your users to have access to functions in both packages without
 explicitly loading both.
This is false, I believe.  From the manual:

The R INSTALL facilities check if the version of R used is recent
enough for the package being installed,and the list of packages which
is specified will be attached (after checking version requirements)
before the current package, ...

So including a package in  Depends leads not only to loading, but attaching.

-- Bert

 However, let's say that function foo() is
 defined in PKG2 and in PKG3. PKG1 does not know about PKG3, and the
 user had PKG3 loaded prior to loading PKG1. Then when PKG1 loads, PKG2
 also loads, and because all the exported functions from PKG2 are
 included, PKG2::foo() masks PKG3::foo(), which can be annoying for
 users if your package adds unnecessary functions to the search path
 potentially masking the versions they wanted to use.

 That was a rather convoluted explanation, but hopefully it is somewhat clear.

 Sincerely,

 Josh

 On Thu, Aug 2, 2012 at 7:02 AM, Xuan Zhao xuan.z...@sentrana.com wrote:
 Hi All,
 Thank you so much for all the help you have provided, I really appreciate it!
 The problem is solved, I just added PKG2 to the dependency of PKG1 in the 
 description file, also (I don't know if it's necessary or not), I added 
 import(PKG2) to the NAMESPACE file. In addition to that, I install PKG2 
 under a path R can recognize, namely, belong to .libPaths().
 I have tried other ways besides install it under the path R can recognize, 
 like  adding a file ~/.R/check.Environ, whose contents are: 
 'R_LIBS_SITE=${R_LIBS_SITE-'directoryunderwhichPKG2isinstalled'}', but it 
 still doesn't work.
 I looked through the manual, they just say the file 'check.Environ' should 
 be put under '~/.R', but I am not should what the ~/ should be. Is that my 
 home directory or what? Should that be the host? I am not the host of the 
 server, does that matter?
 Thank you so much for the help!
 Yours,
 Xuan

 -Original Message-
 From: Bert Gunter [mailto:gunter.ber...@gene.com]
 Sent: Thursday, August 02, 2012 9:42 AM
 To: Joshua Wiley
 Cc: Michael Weylandt; r-help@r-project.org; Xuan Zhao
 Subject: Re: [R] How to link two R packages together

 Josh:

 You may be right ... but I still do not think so. Note that the post begins 
 with:

 One of them (PKG1) needs to use the functions
 of the other package (PKG2).

 This is exactly what imports are for. I believe that, because he/she failed 
 to RTFM, he/she is not being accurate in his/her use of the relevant terms. 
 Certainly, to me at least, it is unclear. Moreover, as I understand it (see 
 the manual) imports are preferred over dependencies, as I indicated in my 
 reply.

 Anyway, in either case, the central advice is that which both Michael and I 
 gave: RTFM. Perhaps it's a generation gap (I am old), but I believe there 
 has been a trend for new R users to post here without making any significant 
 effort to consult the docs. This strikes me as intellectually lazy and, 
 frankly, inconsiderate to those like yourself
 -- or BDR -- who are willing to give up their time and effort to help those 
 with legitimate questions. You and others may consider this an overreaction 
 of course.

 Sorry for the rant, but it seems relevant to your close parsing of the 
 thread.

 -- Cheers,
 Bert

 On Wed, Aug 1, 2012 at 10:35 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 On Wed, Aug 1, 2012 at 10:28 PM, Bert Gunter gunter.ber...@gene.com wrote:
 On Wed, Aug 1, 2012 at 6:45 PM, Michael Weylandt
 michael.weyla...@gmail.com wrote:
 Isn't this what package dependencies are for?

 No. It's what package imports are for (preferably).
 As always, the OP should RTFM -- in this case the one to which you
 refer on the next line, especially the NAMESPACES section.

 But note that the original question included, when I load one package
 using 'library(PKG1)', PKG2 can be loaded at the same. which
 imports does not exactly do. They become available to the package, but
 not to the user, so if you really need both packages loaded to the
 search path, then you need a dependency, not imports.

 Cheers,

 Josh


 -- Bert


 See the description of the DESCRIPTION file in Writing R Extensions

 Michael

 On Aug 1, 2012, at 5:27 PM, xuan zhao xuan.z...@sentrana.com wrote:

 Hi,
 I have built two R packages. One of them (PKG1) needs to use the
 

Re: [R] Polygon shaded area

2012-08-02 Thread Jose Narillos de Santos
Hi many thanks,

That is my data.


 dput(efinal)c(0.9525, 0.89785, 0.8931, 0.9308, 0.89335, 0.8729, 0.8521, 
 0.8556,
0.88135, 0.9093, 0.89375, 0.91155, 0.8881, 0.86655, 0.8927, 0.8898,
0.8703, 0.84863, 0.81745, 0.8349, 0.8248, 0.85995, 0.8686, 0.83765,
0.86075, 0.8609, 0.8528, 0.8837, 0.8917, 0.8671, 0.87205, 0.90255,
0.87485, 0.8856, 0.86665, 0.8731, 0.8558, 0.8353, 0.8557130916294,
0.861971323468187, 0.865900731747475, 0.868624652247, 0.870578199623624,
0.871984527163596, 0.872976198154798, 0.873639584912775, 0.8740346818528,
0.87420517054346, 0.874184027040643, 0.873996870459551)
dput(efinal2)c(0.9525, 0.89785, 0.8931, 0.9308, 0.89335, 0.8729,
0.8521, 0.8556,
0.88135, 0.9093, 0.89375, 0.91155, 0.8881, 0.86655, 0.8927, 0.8898,
0.8703, 0.84863, 0.81745, 0.8349, 0.8248, 0.85995, 0.8686, 0.83765,
0.86075, 0.8609, 0.8528, 0.8837, 0.8917, 0.8671, 0.87205, 0.90255,
0.87485, 0.8856, 0.86665, 0.8731, 0.8558, 0.8353, 0.8073853773588,
0.793625614508213, 0.782194675217125, 0.771969223705801, 0.762514145317377,
0.753606286765605, 0.745113084762604, 0.736948166992827, 0.729051539041001,
0.721379519338542, 0.713899131829559, 0.706584757398851)



2012/8/2 John Kane jrkrid...@inbox.com

  The efinal are two temporal series I attach?

 Not attached.  R-help typically strips out any attachment to prevent
 malware being spread.

 The best way to supply sample date is to use the dput() command.  See
 ?dput for details but basically just say dput(myfile) and copy the results
 into your email.  Readers can directly paste the file into their R console
 and see exactly what your data is.

 John Kane
 Kingston ON Canada

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




[[alternative HTML version deleted]]

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


Re: [R] Polygon shaded area

2012-08-02 Thread John Kane

   Data came through fine.
   I  can  never  plot a polygon without help but I think you have a data
   problem.
   Try this:
   efinal == efinal2



   John Kane
   Kingston ON Canada

   -Original Message-
   From: narillosdesan...@gmail.com
   Sent: Thu, 2 Aug 2012 16:55:23 +0200
   To: jrkrid...@inbox.com
   Subject: Re: [R] Polygon shaded area

Hi many thanks,
That is my data.
 dput(efinal)
c(0.9525, 0.89785, 0.8931, 0.9308, 0.89335, 0.8729, 0.8521, 0.8556, 
0.88135, 0.9093, 0.89375, 0.91155, 0.8881, 0.86655, 0.8927, 0.8898, 
0.8703, 0.84863, 0.81745, 0.8349, 0.8248, 0.85995, 0.8686, 0.83765, 
0.86075, 0.8609, 0.8528, 0.8837, 0.8917, 0.8671, 0.87205, 0.90255, 
0.87485, 0.8856, 0.86665, 0.8731, 0.8558, 0.8353, 0.8557130916294, 
0.861971323468187, 0.865900731747475, 0.868624652247, 0.870578199623624, 
0.871984527163596, 0.872976198154798, 0.873639584912775, 0.8740346818528, 
0.87420517054346, 0.874184027040643, 0.873996870459551)
 dput(efinal2)
c(0.9525, 0.89785, 0.8931, 0.9308, 0.89335, 0.8729, 0.8521, 0.8556, 
0.88135, 0.9093, 0.89375, 0.91155, 0.8881, 0.86655, 0.8927, 0.8898, 
0.8703, 0.84863, 0.81745, 0.8349, 0.8248, 0.85995, 0.8686, 0.83765, 
0.86075, 0.8609, 0.8528, 0.8837, 0.8917, 0.8671, 0.87205, 0.90255, 
0.87485, 0.8856, 0.86665, 0.8731, 0.8558, 0.8353, 0.8073853773588, 
0.793625614508213, 0.782194675217125, 0.771969223705801, 0.762514145317377, 
0.753606286765605, 0.745113084762604, 0.736948166992827, 0.729051539041001, 
0.721379519338542, 0.713899131829559, 0.706584757398851)

   2012/8/2 John Kane [1]jrkrid...@inbox.com

The efinal are two temporal series I attach?

 Not attached.  R-help typically strips out any attachment to prevent
 malware being spread.
 The best way to supply sample date is to use the dput() command.  See
 ?dput for details but basically just say dput(myfile) and copy the results
 into your email.  Readers can directly paste the file into their R console
 and see exactly what your data is.
 John Kane
 Kingston ON Canada
 
 FREE ONLINE PHOTOSHARING - Share your photos online with your friends and
 family!
 Visit [2]http://www.inbox.com/photosharing to find out more!
 _

   [3]3D Marine Aquarium Screensaver Preview 
   Free 3D Marine Aquarium Screensaver
   Watch  dolphins,  sharksorcas  on  your  desktop! Check it out at
   [4]www.inbox.com/marineaquarium

References

   1. mailto:jrkrid...@inbox.com
   2. http://www.inbox.com/photosharing
   3. http://www.inbox.com/marineaquarium
   4. http://www.inbox.com/marineaquarium
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Polygon shaded area

2012-08-02 Thread Eik Vettorazzi
Hi Jose,
this should work (but I think you need a deeper understanding, what
plot(efinal) does, see ?plot):

plot(efinal,ylim=range(c(efinal,efinal2)),type=n,ylab=)
xv-seq_along(efinal)
polygon(c(xv,rev(xv)),c(efinal,rev(efinal2)),col=red)

cheers

Am 02.08.2012 16:36, schrieb Jose Narillos de Santos:
 Hi I attach my function. No error message (it seems a line appears but
 nothing similar to examples(polygon))
 
 
 
 2012/8/2 Eik Vettorazzi e.vettora...@uke.de mailto:e.vettora...@uke.de
 
 Hi Jose,
 how about this
 
 example(polygon)
 
 I think the second one is pretty much what you want.
 
 cheers.
 
 Am 02.08.2012 14:33, schrieb Jose Narillos de Santos:
  Hi all,
 
  I have two vectors (columns) called efinal and efinal 2.
 
  I want to plot them on the same plot and draw a shaded area
 beween the
  two lines using function polygon
 
  I have tried all but I don ´t understand the polygon area, can you
 help me
  with examples?
 
  plot(efinal,type=l,ylim=range(min(efinal2),
  max(efinal)),ylab=,main=plot)
 
  par(new=T)
  plot(efinal2,type=l,ylim=range(min(efinal2), max(efinal)),ylab=)
 
  The efinal are two temporal series I attach?
 
 
 
  __
  R-help@r-project.org mailto:R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 --
 Eik Vettorazzi
 
 Department of Medical Biometry and Epidemiology
 University Medical Center Hamburg-Eppendorf
 
 Martinistr. 52
 20246 Hamburg
 
 T ++49/40/7410-58243 tel:%2B%2B49%2F40%2F7410-58243
 F ++49/40/7410-57790 tel:%2B%2B49%2F40%2F7410-57790
 
 --
 Pflichtangaben gemäß Gesetz über elektronische Handelsregister und
 Genossenschaftsregister sowie das Unternehmensregister (EHUG):
 
 Universitätsklinikum Hamburg-Eppendorf; Körperschaft des
 öffentlichen Rechts; Gerichtsstand: Hamburg
 
 Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des
 Vorsitzenden), Dr. Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr.
 Uwe Koch-Gromus
 
 


-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. 
Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Metafor package: Including multiple (categorical) predictors

2012-08-02 Thread Bexkens, Anika
Dear Metafor users,

I'd like to test a model with 2 continuous and 2 categorical moderators in a 
meta regression. One categorical parameter has 2 levels and the other has 4 
levels. If I understand correctly, when I include all moderators in the model, 
Metafor returns main effects of the continuous parameters and contrasts of each 
level of categorical moderators with the intercept (which includes the 
reference level of the categorical parameters).

This makes it possible to see whether different levels of the categorical 
moderator are differentially related to effect size. I include multiple 
moderators and would like to report for each variable whether it is 
significantly moderating effect size. Is it possible to obtain an overall main 
effect of each categorical variable, instead of the contrast effects? Or can I 
only obtain this by including one categorical moderator at a time and reporting 
the omnibus moderator test?

Many thanks,

Anika



[[alternative HTML version deleted]]

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


[R] Predicting Player Sports Scores

2012-08-02 Thread onenoc
Hi, 

I'm new to sports data and want to work on a personal project that involves
predicting player scores, rebounds, blocks, etc., for the NBA and NCAA
basketball.  Anyone have any ideas on where I could get this data and how I
would get it into R efficiently?  Particularly, can I use YQL with R?  In
the past for non-sports projects I read most of the stuff from CSV files,
but I'm wondering if I can use an API for sports data. 

Thanks, 
Alex



--
View this message in context: 
http://r.789695.n4.nabble.com/Predicting-Player-Sports-Scores-tp4638858.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Naive Bayes in R

2012-08-02 Thread Abraham Mathew
I'm developing a naive bayes in R. I have the following data and am trying
to predict on returned (class).

dat = data.frame(home=c(0,1,1,0,0), gender=c(M,M,F,M,F),
returned=c(0,0,1,1,0))
str(dat)

dat$home - as.factor(dat$home)
dat$returned - as.factor(dat$returned)

library(e1071)

m - naiveBayes(returned ~ ., dat)
m

predict(m, dat[1:5,-3])
table(predict=predict(m, dat[1:5,-3]), true=dat[1:5,3])
predict(m, dat[1:5,-3], type = raw)


So far, so good I think (???).

I want to know if there is any diagnostic test to determine the overall
misclassification rate
of a NB classifier, and if there is a function in R that is available to
implement it?


Thanks,
Abraham


-- 
*Abraham Mathew
Statistical Analyst
www.amathew.com
720-648-0108
@abmathewks*

[[alternative HTML version deleted]]

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


[R] Filter a matrix with a matrix HELP!

2012-08-02 Thread Cloneberry
Hi,
just during these vacation days, I'm trying to approach with multicore
package
and I have some troubles with foreach.
What I'm trying to do is to extract a data in coordinate (ii,jj) from a
matrix2,
only if the data in the same coordinate in matrix1 is ==1.
Make this with a nested for take a lot of time because I have thousand of
values.

ex.
Binary_hex = NULL
foreach(ii=1:nrow(matrix2)) %:% foreach(jj=1:ncol(matrix2)) %dopar%
{when(matrix2[ii,jj] == 1) %:% {Binary_hex - c(Binary_hex,
matrix1[ii,jj])}}

During this operation... computer don't work in multicore and the process
take a lot of time,
just like a simple nested for. I think the mistake is in the when
parameter because if I substitute
the when with another function (like sqrt) it work greatly and fast.
Please, give me some suggestion, also with different way.
Thank you in advance.
Max



--
View this message in context: 
http://r.789695.n4.nabble.com/Filter-a-matrix-with-a-matrix-HELP-tp4638871.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Optimize a function with Discrete inputs

2012-08-02 Thread loyolite270
oh sorry ..

The detailed description of the problem is given below

dataFrame is matrix of dim 100X100 with some values
a is a vector of length 1
x is a vector of any length between 1 to 99

funcScore-function(a,x){

sc-0
sc1-0

 for(j in 1:(length(x))){
sc-sc+abs(dataFrame[a,x[j]])
  }

if(length(x)==1){
  sc1-0
}

else{ 
   if(length(x)1){
  for(i in 1:(length(x)-1)){
   for(j in (i+1):(length(x))){
  sc1 - sc1+abs(dataFrame[(x[i]-1),x[j]])
   }
  }
   }
}
   score - sc-sc1
   return(score)
 }

Given the value of a,  i would like to use some optimization function (
value of x) to maximize the score, such that x can be any combination ?

Thanks






--
View this message in context: 
http://r.789695.n4.nabble.com/Optimize-a-function-with-Discrete-inputs-tp4638644p4638851.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Binary Quadratic Opt?

2012-08-02 Thread khris

On Aug 2, 2012, at 12:39 PM, Petr Savicky [via R] wrote:

 On Wed, Aug 01, 2012 at 04:55:30AM -0700, khris wrote: 
  Hi Petr, 
  
  It been sometime since I wrote. But here are the latest developments. 
  
  When I give the binary linear opt problem to lpSolve optimizer than for 
  small instance it gives correct answer but when size of nodes increase 
  let's say 16 then there are about 2000 binary variables and lpSolve just 
  does not come back with any answer even after running for a full day. I 
  plan to solve for node size upto atleast 100, so I guess I need to do 
  something fundamentally different. 
  
  Now I understand that lpSolve is using Branch and Bound Algorithm which to 
  me looks highly inefficient, for in the wrost case it will try to solve 2^n 
  LP relaxation problem. Maybe that's why I do not get answer even when n=16. 
  So what do I do to make lpSolve solve problem efficiently. 
 
 Integer linear programming is an NP-complete problem and in general requires 
 an 
 exponential time. It is not surprising that lpSolve failed to solve a problem 
 with 2000 variables. It can solve some problems with a few hundreds of 
 variables, 
 but not every such problem. 
 

OK. I guess then my approach to solve the Graph matching problem using binary 
opt pr. seems destined to fail. I know you told about Kohenan maps but I am not 
exited about it since it some sort of neural network which involves training. 
So that approach may not be suitable. 
I wrote about another approach, reducing the Graph matching with upper bound 
on degree of vertex to Graph isomorphism where degree of vertex has upper 
bound since Graph isomorphism where degree of vertex has upper bound has 
tractable solution. This approach seems promising.

I also came across solving Graph matching using Simulated Annealing 
(http://randomwalker.info/luther/kaggle-deanonymization/Graph_Matching_via_Simulate.html)
 which also seems promising.

How do you feel about these?


  In the lpSolve document there does not seem to be any option where one can 
  specify which variable should the optimizer use to use LP relaxation first? 
  Is there way to control in some way Branch and Bound algorithm used by 
  lpSolve apart from the going in side the code and tweaking it. 
 
 I do not know, whether this may be controlled. 
 
 Do you have a specific reason to use lpSolve for your problem? 

I thought lpSolve is the best optimizer freely available in R so I was using 
it. Do you recommend another one? But if my model consist of 100,00 binaray 
variable then I assume even commercial optimizer also won't scale?

Appreciate your comments.

Thanks in adv
Khris.




 
 Petr. 
 
 __ 
 [hidden email] mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 
 
 
 If you reply to this email, your message will be added to the discussion 
 below:
 http://r.789695.n4.nabble.com/Binary-Quadratic-Opt-tp4633521p4638835.html
 To unsubscribe from Binary Quadratic Opt?, click here.
 NAML





--
View this message in context: 
http://r.789695.n4.nabble.com/Binary-Quadratic-Opt-tp4633521p4638844.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread arun kirshna [via R]
Hello Gail,

The dat5 was in earlier post.  I forgot to paste it.
Now, your question regarding individual cases,
This is a case that includes nonnumeric columns
list1-list(data.frame(x=1:6,y=c(4,5,3,2,1,8),bw=c(4,18,12,3,4,9),nn=paste0(a,1:6)))
list2-list(data.frame(x=c(1,2,18,16,15),y=c(4,5,9,2,1),bw=c(4,18,22,3,4),nn=paste0(a,1:5)))

list3-list(data.frame(x=c(4,6,9),y=c(8,24,12),bw=c(14,31,36),nn=paste0(a,1:3)))
 
 list4-list(list1,list2,list3)
b-list()
 for(i in 1:3){
 b[[i]]-list()
 b[[i]]-lapply(list4[[i]][[1]],FUN=function(x) x[which.max(x)])
 }
 b
[[1]]
[[1]]$x
[1] 6

[[1]]$y
[1] 8

[[1]]$bw
[1] 18

[[1]]$nn
[1] a6
Levels: a1 a2 a3 a4 a5 a6


[[2]]
[[2]]$x
[1] 18

[[2]]$y
[1] 9

[[2]]$bw
[1] 22

[[2]]$nn
[1] a5
Levels: a1 a2 a3 a4 a5


[[3]]
[[3]]$x
[1] 9

[[3]]$y
[1] 24

[[3]]$bw
[1] 36

[[3]]$nn
[1] a3
Levels: a1 a2 a3

I haven't looked into your dataset that was posted now.  The main problem
was that I was constructing my own data, guessing how your dataset looks
like.

A.K





__
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p4638870.html
This email was sent by arun kirshna (via Nabble)
To receive all replies by email, subscribe to this discussion: 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=subscribe_by_codenode=4638681code=ci1oZWxwQHItcHJvamVjdC5vcmd8NDYzODY4MXwtNzg0MjM1NTA4
[[alternative HTML version deleted]]

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


Re: [R] R_nls_iter error: REAL() can only be applied to a 'numeric', not a 'logical'

2012-08-02 Thread matthewbk

Hi

While trying to simplify the model to create a small reproducible example I 
have found my error.

Previously in order to try and solve another problem, I had changed my Model 
function. However I had made a mistake in doing this and caused the function to 
always output 0. Fixing this error has now fixed the error and brought me back 
to the original problem.

I now get:
singular gradient matrix at initial parameter estimates

It is a very complex model so I am unsure how to fix this yet, but I am going 
to try and use the brute-force algorithm from nls2.

Thanks for the help.

Matthew

Date: Wed, 1 Aug 2012 16:18:07 -0700
From: ml-node+s789695n4638799...@n4.nabble.com
To: matthew_...@hotmail.com
Subject: Re: R_nls_iter error: REAL() can only be applied to a 'numeric', not a 
'logical'



On Wed, Aug 1, 2012 at 11:40 AM, matthewbk [hidden email] wrote:

 Hi



 I am using the nls function in R however it is causing the following error:

 REAL() can only be applied to a 'numeric', not a 'logical'



 Using traceback shows this occurs after the .Call(R_nls_iter, m, ctrl,

 trace) call. However I do not know how to debug this further to find out

 what is causing the error.



 The data I give the nls call definitely starts as numeric. The data.frame is

 generated by using the following:



 d = data.read('data.csv', header=FALSE)

 x = as.numberic(d[,1])

 y = as.numberic(d[,2])

 z = as.numberic(d[,3])

 ...

Certainly no b ?




 dat = data.frame(x,y,z...)



 nls is started by calling:

 mdl = nls(y ~ Model(x,y,z,b1,b2,b3), data = dat)



 Thanks in advance for any help.



 Matthew





This one's actually tricky since that's an error arising from the C

code. I don't think there's an error in the C code, but let's do some

work on debugging. To start with, can you make a small reproducible

example following the advice given here:


http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

To wit, we don't have your dat data (use dput! but please, only a

small-ish subset)  nor the function Model and the lines of code

replaced by ... worry me as well.


Best,

Michael






 --

 View this message in context: 
 http://r.789695.n4.nabble.com/R-nls-iter-error-REAL-can-only-be-applied-to-a-numeric-not-a-logical-tp4638717.html
 Sent from the R help mailing list archive at Nabble.com.



 __

 [hidden email] mailing list

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

__

[hidden email] mailing list

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












If you reply to this email, your message will be added to the 
discussion below:

http://r.789695.n4.nabble.com/R-nls-iter-error-REAL-can-only-be-applied-to-a-numeric-not-a-logical-tp4638717p4638799.html



To unsubscribe from R_nls_iter error: REAL() can only be 
applied to a 'numeric', not a 'logical', click here.

NAML
  



--
View this message in context: 
http://r.789695.n4.nabble.com/R-nls-iter-error-REAL-can-only-be-applied-to-a-numeric-not-a-logical-tp4638717p4638849.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] package memisc: recode examples

2012-08-02 Thread Marion Wenty
Dear Peter and John,

Thank you for your explanations and suggestions. I also got an e-mail from
the R core team, explaining how the message is correct.

This was in fact a langugage/translation problem.

In the German version the part of the message we are talking about is in
English as well:

###
Lade nvtiges Paket: nnet

 Attache Paket: ?car?

 The following object(s) are masked from ?package:memisc?:

 recode
###

 My confusion came from the message being:

 The following object(s) are masked from 'package:A'

instead of

 The following object(s) from 'package:A' are masked

which I find easier to understand. I interpreted the word from as by.

Now I understand how it is meant.

Thank you for your answers,
Marion









2012/7/26 John Kane jrkrid...@inbox.com

 The following object(s) are masked from 'package:A'
 is equivalent to The following object(s) from 'package:A' are masked
 and perhaps that might be a more universally understood phrasing.

 I do find this better but I don't see any real need to change the status
 quo. It becomes fairly obvious after the first few imbroglios.

 On the other hand as they now teach passive sentence structure is harder
 to understand that postive, so perhaps:

 Objects x,yz in package A mask objects x,y z  in package B?

 John Kane
 Kingston ON Canada


  -Original Message-
  From: ehl...@ucalgary.ca
  Sent: Wed, 25 Jul 2012 12:57:33 -0700
  To: marion.we...@gmail.com
  Subject: Re: [R] package memisc: recode examples
 
  On 2012-07-25 09:29, Marion Wenty wrote:
  Thank you, John, for the clarification! :)
 
  I have written to the R core team pointing this out.
 
  Marion
 
  I hope that you included the wording of an improved message.
  I believe that I speak English reasonably well and I disagree
  with John on this. I think that the message is in fact unambiguous.
  I don't know what the German message is, but perhaps it is not
  unambiguous. Perhaps the translation of from to von is at
  fault, since that is certainly not an unambiguous translation.
 
  If the intent were to say that the earlier-loaded package (here
  'memisc') is masking a function in the later-loaded package
  (here 'car') then the message would say something like
  the following object(s) are masked _by_ package:memisc. I find
  it easy to remember that the latest-loaded package is always the
  one doing the masking.
 
  As it is now, when loading package A is followed by loading
  package B, the message
  The following object(s) are masked from 'package:A'
  is equivalent to
  The following object(s) from 'package:A' are masked
  and perhaps that might be a more universally understood phrasing.
 
  Having said that there is, in my opinion, no need to alter the
  status quo, I'll nevertheless make the following suggestion.
  It may be not too difficult to rewrite the function producing
  the messages to say something like:
  Package B is masking:
  from package:A, function1, function2
  from package:C, function3
  etc.
 
  But I confess that I have not looked at the code and hence
  have no idea how much effort would be involved. I do feel
  that R-Core has more important things to occupy them.
 
  Peter Ehlers
 
 
  2012/7/24 John Kane jrkrid...@inbox.com
 
 
  -Original Message-
  From: marion.we...@gmail.com
  Sent: Tue, 24 Jul 2012 15:48:10 +0200
  To: e.vettora...@uke.de
  Subject: Re: [R] package memisc: recode examples
 
  I now tried
 
  find(recode,mode=function)
 
  and got
 
  [1] package:carpackage:memisc - and got a warning
  message, which said:
 
  ##
 
  Lade nvtiges Paket: nnet
 
  Attache Paket: ?car?
 
  The following object(s) are masked from ?package:memisc?:
 
   recode
 
  ##
 
  I would have interpreted this warning the other way around, but this
  might be a language problem of mine
 
  So would I and I'm a native English speaker.  I just think that some
  stats/programmers see the world in a very different way than real
  people.
  :)
 
  
  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
  https://stat.ethz.ch/mailman/listinfo/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!




[[alternative HTML version deleted]]

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

Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread arun kirshna [via R]
Hi,
I am not able to read your dataset.
Getting errors.
source(list1.txt)
Error in paste(locuteur, i, sep = ) : object 'locuteur' not found
Please check.
A.K.




__
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p4638873.html
This email was sent by arun kirshna (via Nabble)
To receive all replies by email, subscribe to this discussion: 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=subscribe_by_codenode=4638681code=ci1oZWxwQHItcHJvamVjdC5vcmd8NDYzODY4MXwtNzg0MjM1NTA4
[[alternative HTML version deleted]]

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


Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread gail
Arun, I see you've defined dat5 in your later message; however the same
applies as to the above: the code doesn't work if the list contains
non-numerical elements.
Gail



--
View this message in context: 
http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p4638859.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread gail
Well but the whole point was to be able to plug in a single command and get
the result for all sublists. If I have to create a new list and type in each
sublist and the column I'm interested in, that completely defeats the
purpose, I might as well just ask for max(sublist$coconut) for each sublist,
that would be just as fast ...



--
View this message in context: 
http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p463.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread gail
Michael, here is the data I am working with. I've shortened it without, I
trust, changing its nature. I am not using any package other than what is
pre-installed. Many thanks, Gail

 dput(list.example)

list

(structure(list(

x = c(379.455895016957, 380.116796110287, 
380.777697203618, 381.438598296949, 382.099499390279, 382.76040048361, 
383.421301576941, 384.082202670271, 384.743103763602, 385.404004856933, 
386.064905950264, 386.725807043594), 

y = c(7.66474496376218e-06, 
6.43440919959401e-06, 5.36894293042274e-06, 4.45194069157015e-06, 
3.66781132570054e-06, 3.00181397191447e-06, 2.45773671502347e-06, 
2.0034233225e-06, 1.62212866305772e-06, 1.3043460449395e-06, 
1.04141214324248e-06, 8.26430099678339e-07), 

bw = 9.02854660253144, 

n = 1102L,

call = density.default(x = read.table(paste(locuteur, 
i, sep = ))$V1[read.table(paste(locuteur, i, sep = ))$V1 != 
0]),

data.name = c(read.table(paste(locuteur, i, sep =
\\))$V1[read.table(paste(locuteur, , 
i, sep = \\))$V1 != 0]), has.na = FALSE),

.Names = c(x, 
y, bw, n, call, data.name, has.na),

class = density),

structure(list(x = c(372.576546447762, 373.241257067042, 
373.905967686322, 374.570678305602, 375.235388924882, 375.900099544162, 
376.564810163442, 377.229520782722, 377.894231402002, 378.558942021282, 
379.223652640562, 379.888363259842), y = c(1.60229850505427e-05, 
1.30822330219271e-05, 1.05973406669671e-05, 8.51514876035057e-06, 
6.78543779138952e-06, 5.41596769065147e-06, 4.28876937728122e-06, 
3.36815237991786e-06, 2.62273082547721e-06, 2.02454969122432e-06, 
1.54894049348427e-06, 1.18505840947482e-06), bw = 7.90353278894747, 
n = 1409L, call = density.default(x = read.table(paste(locuteur, 
i, sep = ))$V1[read.table(paste(locuteur, i, sep = ))$V1 != 
0]), data.name = c(read.table(paste(locuteur, i, sep =
\\))$V1[read.table(paste(locuteur, , 
i, sep = \\))$V1 != 0]), has.na = FALSE), .Names = c(x, 
y, bw, n, call, data.name, has.na), class = density),

structure(list(x = c(383.473231160603, 384.169713215726, 
384.866195270849, 385.562677325973, 386.259159381096, 386.955641436219, 
387.652123491343, 388.348605546466, 389.045087601589, 389.741569656713, 
390.438051711836, 391.134533766959), y = c(2.40798446492758e-06, 
2.04205952412882e-06, 1.72782287870817e-06, 1.45399002130161e-06, 
1.21665858527511e-06, 1.01213493683702e-06, 8.37503296444613e-07, 
6.94344355906326e-07, 5.72200769661348e-07, 4.6862434236517e-07, 
3.81353514437358e-07, 3.08309463721622e-07), bw = 10.0108886969865, 
n = 1522L, call = density.default(x = read.table(paste(locuteur, 
i, sep = ))$V1[read.table(paste(locuteur, i, sep = ))$V1 != 
0]), data.name = c(read.table(paste(locuteur, i, sep =
\\))$V1[read.table(paste(locuteur, , 
i, sep = \\))$V1 != 0]), has.na = FALSE), .Names = c(x, 
y, bw, n, call, data.name, has.na), class = density),

NULL, NULL, NULL, NULL, NULL, NULL)




--
View this message in context: 
http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p4638865.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread gail
Hi,

my dataset is the result of the function density on another set of data.
It refers to that data in its variable call, though since all the results
are actually reproduced (except that I've removed all rows bar 10), I am not
sure why R still needs it. But I've understood now why your code doesn't
work on my data: your sublists are still just dataframes, whereas my
sublists contain all sorts of vectors (2 numerical vectors and 5 other
things). I've changed your data to make it look a bit more like mine, and
you'll see that the code doesn't work. 

mango - list(data.frame(coconut=1:6), y=c(4,5,3,2,1,8),
bw=c(4,18,12,3,4,9), nn=paste0(a,1:6))
banana - list(data.frame(coconut=c(1,2,18,16,15)), y=c(4,5,9,2,1),
bw=c(4,18,22,3,4), nn=paste0(a,1:5))
pineapple - list(data.frame(coconut=c(4,6,9)), y=c(8,24,12),
bw=c(14,31,36), nn=paste0(a,1:3))
list4 - list(mango, banana, pineapple)

b - list()

 for(i in 1:3){
 b[[i]] - list()
 b[[i]] - lapply (list4[[i]]$coconut, FUN=function(x) x[which.max(x)])
 }

b
summary( b)

What I want to end up with is the following:

   coconut
mango   6
banana 18
pineapple   9
(that's for the individual sublists)

and 
   coconut
18
(that's for the list as a whole).

Hope this is becoming a bit clearer ...



--
View this message in context: 
http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p4638876.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to link two R packages together

2012-08-02 Thread Xuan Zhao
Hi All,
Thank you so much for all the help you have provided, I really appreciate it!
The problem is solved, I just added PKG2 to the dependency of PKG1 in the 
description file, also (I don't know if it's necessary or not), I added 
import(PKG2) to the NAMESPACE file. In addition to that, I install PKG2 under 
a path R can recognize, namely, belong to .libPaths(). 
I have tried other ways besides install it under the path R can recognize, like 
 adding a file ~/.R/check.Environ, whose contents are: 
'R_LIBS_SITE=${R_LIBS_SITE-'directoryunderwhichPKG2isinstalled'}', but it still 
doesn't work. 
I looked through the manual, they just say the file 'check.Environ' should be 
put under '~/.R', but I am not should what the ~/ should be. Is that my home 
directory or what? Should that be the host? I am not the host of the server, 
does that matter?
Thank you so much for the help!
Yours,
Xuan

-Original Message-
From: Bert Gunter [mailto:gunter.ber...@gene.com] 
Sent: Thursday, August 02, 2012 9:42 AM
To: Joshua Wiley
Cc: Michael Weylandt; r-help@r-project.org; Xuan Zhao
Subject: Re: [R] How to link two R packages together

Josh:

You may be right ... but I still do not think so. Note that the post begins 
with:

One of them (PKG1) needs to use the functions
 of the other package (PKG2).

This is exactly what imports are for. I believe that, because he/she failed to 
RTFM, he/she is not being accurate in his/her use of the relevant terms. 
Certainly, to me at least, it is unclear. Moreover, as I understand it (see the 
manual) imports are preferred over dependencies, as I indicated in my reply.

Anyway, in either case, the central advice is that which both Michael and I 
gave: RTFM. Perhaps it's a generation gap (I am old), but I believe there has 
been a trend for new R users to post here without making any significant effort 
to consult the docs. This strikes me as intellectually lazy and, frankly, 
inconsiderate to those like yourself
-- or BDR -- who are willing to give up their time and effort to help those 
with legitimate questions. You and others may consider this an overreaction of 
course.

Sorry for the rant, but it seems relevant to your close parsing of the thread.

-- Cheers,
Bert

On Wed, Aug 1, 2012 at 10:35 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 On Wed, Aug 1, 2012 at 10:28 PM, Bert Gunter gunter.ber...@gene.com wrote:
 On Wed, Aug 1, 2012 at 6:45 PM, Michael Weylandt 
 michael.weyla...@gmail.com wrote:
 Isn't this what package dependencies are for?

 No. It's what package imports are for (preferably).
 As always, the OP should RTFM -- in this case the one to which you 
 refer on the next line, especially the NAMESPACES section.

 But note that the original question included, when I load one package 
 using 'library(PKG1)', PKG2 can be loaded at the same. which 
 imports does not exactly do. They become available to the package, but 
 not to the user, so if you really need both packages loaded to the 
 search path, then you need a dependency, not imports.

 Cheers,

 Josh


 -- Bert


 See the description of the DESCRIPTION file in Writing R Extensions

 Michael

 On Aug 1, 2012, at 5:27 PM, xuan zhao xuan.z...@sentrana.com wrote:

 Hi,
 I have built two R packages. One of them (PKG1) needs to use the 
 functions of the other package (PKG2).
 So I need to link these two packages together, so that the 
 functions of PKG2 can be available to PKG1. And when I load one 
 package using 'library(PKG1)', PKG2 can be loaded at the same.
 Any ideas welcome.




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/How-to-link-two-R-packages-together-t
 p4638765.html Sent from the R help mailing list archive at 
 Nabble.com.

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

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



 --

 Bert Gunter
 Genentech Nonclinical Biostatistics

 Internal Contact Info:
 Phone: 467-7374
 Website:
 http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pd
 b-biostatistics/pdb-ncb-home.htm

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



 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 Programmer Analyst II, Statistical Consulting Group University of 
 California, Los Angeles https://joshuawiley.com/



-- 

Bert Gunter
Genentech Nonclinical 

Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread arun kirshna [via R]
Hello,

If I understand it now, can't you do this:
Individual cases:
 list4-list(mango[[1]],banana[[1]],pineapple[[1]])
b-list()
 for(i in 1:3){
 b[[i]]-list()
 b[[i]]-lapply(list4[[i]],FUN=function(x)x[which.max(x)])
 }
b1-data.frame(do.call(rbind,b))
row.names(b1)-c(mango,banana,pineapple)
 b1
  coconut
mango   6
banana 18
pineapple   9
apply(b1,2, function(x) x[which.max(x)])
#$coconut
#$coconut$banana
#[1] 18

#This is what you asked for the result.
A.K.





__
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p4638886.html
This email was sent by arun kirshna (via Nabble)
To receive all replies by email, subscribe to this discussion: 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=subscribe_by_codenode=4638681code=ci1oZWxwQHItcHJvamVjdC5vcmd8NDYzODY4MXwtNzg0MjM1NTA4
[[alternative HTML version deleted]]

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


Re: [R] Binary Quadratic Opt?

2012-08-02 Thread Bert Gunter
This discussion needs to be taken off (this) list, as it appears to
have nothing to do with R.

-- Bert

On Thu, Aug 2, 2012 at 2:27 AM, khris khris...@gmail.com wrote:

 On Aug 2, 2012, at 12:39 PM, Petr Savicky [via R] wrote:

 On Wed, Aug 01, 2012 at 04:55:30AM -0700, khris wrote:
  Hi Petr,
 
  It been sometime since I wrote. But here are the latest developments.
 
  When I give the binary linear opt problem to lpSolve optimizer than for 
  small instance it gives correct answer but when size of nodes increase 
  let's say 16 then there are about 2000 binary variables and lpSolve just 
  does not come back with any answer even after running for a full day. I 
  plan to solve for node size upto atleast 100, so I guess I need to do 
  something fundamentally different.
 
  Now I understand that lpSolve is using Branch and Bound Algorithm which to 
  me looks highly inefficient, for in the wrost case it will try to solve 
  2^n LP relaxation problem. Maybe that's why I do not get answer even when 
  n=16. So what do I do to make lpSolve solve problem efficiently.

 Integer linear programming is an NP-complete problem and in general requires 
 an
 exponential time. It is not surprising that lpSolve failed to solve a problem
 with 2000 variables. It can solve some problems with a few hundreds of 
 variables,
 but not every such problem.


 OK. I guess then my approach to solve the Graph matching problem using binary 
 opt pr. seems destined to fail. I know you told about Kohenan maps but I am 
 not exited about it since it some sort of neural network which involves 
 training. So that approach may not be suitable.
 I wrote about another approach, reducing the Graph matching with upper bound 
 on degree of vertex to Graph isomorphism where degree of vertex has upper 
 bound since Graph isomorphism where degree of vertex has upper bound has 
 tractable solution. This approach seems promising.

 I also came across solving Graph matching using Simulated Annealing 
 (http://randomwalker.info/luther/kaggle-deanonymization/Graph_Matching_via_Simulate.html)
  which also seems promising.

 How do you feel about these?


  In the lpSolve document there does not seem to be any option where one can 
  specify which variable should the optimizer use to use LP relaxation 
  first? Is there way to control in some way Branch and Bound algorithm used 
  by lpSolve apart from the going in side the code and tweaking it.

 I do not know, whether this may be controlled.

 Do you have a specific reason to use lpSolve for your problem?

 I thought lpSolve is the best optimizer freely available in R so I was using 
 it. Do you recommend another one? But if my model consist of 100,00 binaray 
 variable then I assume even commercial optimizer also won't scale?

 Appreciate your comments.

 Thanks in adv
 Khris.





 Petr.

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


 If you reply to this email, your message will be added to the discussion 
 below:
 http://r.789695.n4.nabble.com/Binary-Quadratic-Opt-tp4633521p4638835.html
 To unsubscribe from Binary Quadratic Opt?, click here.
 NAML





 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Binary-Quadratic-Opt-tp4633521p4638844.html
 Sent from the R help mailing list archive at Nabble.com.
 [[alternative HTML version deleted]]

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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

2012-08-02 Thread arun
Hi,
Try this:

Here, in the example dataset, you have 3 banks.  Suppose, I want to delete 2 
banks randomly out of 3, (you can name your specific banks to delete),
dat1-read.table(text=
Year  Name totalliabilties assets
1990  a  90    10
1991  a  89    48
1992  a  87    34
1993  a  56    05
1990  b  90    11
1991  b  69    43
1992  b  37    34
1993  b  46    17
1990  c  55    10
1991  c  67    18
1992  c  34    24
1993  c  53    35
,sep=,header=TRUE)
 names1-sample(letters[1:3],2)
 names1
#[1] b a
subset(dat1,!dat1$Name%in%names1)
#   Year Name totalliabilties assets
#9  1990    c  55 10
#10 1991    c  67 18
#11 1992    c  34 24
#12 1993    c  53 35
A.K.





- Original Message -
From: Akhil dua akhil.dua...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Thursday, August 2, 2012 4:44 AM
Subject: [R] Subseting

Hi everyone

I have banking data set in long format with 4 columns.One of these columns
is bank name which consist of 49 banks and I want the data for only 40
banks out of these 49
so can anyone help me on how to get this 40 banks data

My data looks like

Year  Name totalliabilties assets
1990  a              90            10
1991  a              89            48
1992  a              87            34
1993  a              56            05
1990  b              90            11
1991  b              69            43
1992  b              37            34
1993  b              46            17
1990  c              55            10
1991  c              67            18
1992  c              34            24
1993  c              53            35

please keep in mind that I have 49 firms so I cant do
object-data[,c(names of the banks I need the data)]
and then extract the data for these banks out of the whole sample

    [[alternative HTML version deleted]]

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


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


[R] Restricted VECM-VAR representation

2012-08-02 Thread dha3000
Hey guys, 

I am using the urca and vars package to estimate a VECM.
I already estimated the VECM with the ca.jo, put restrictions on the
cointegration and loading matrix via alrtest, blrtest and ablrtest and
finally reesimated the restricted VECM with cajorls.

Is it possible to transform this restricted VECM  into a level's VAR
version? As it can be done with vec2var and ca.jo.

Because I want to estimate in a second step the impulse response function in
levels, rather than differences. (irf() or even SVAR()).

Thanks a lot, dha!



--
View this message in context: 
http://r.789695.n4.nabble.com/Restricted-VECM-VAR-representation-tp4638874.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] finding the MLEs of IG parameters by EM-Alorithm

2012-08-02 Thread Sara S
Dear all

I'm trying to caculate the MLEs for parameters of Inverse Gaussian
distribution (in a k-sample problem with common mean) by using
EM-Algorithm.  I found some package for EM-Algorithm that are useful
for missing or incomplete data and are not helpful for solving my
problem.
(Exactly, the problem is: Let Xij, i=1,..,k , j=1,...,ni, be a random
sample from IG(μ,λi). So the log-likelihood function is:
log(L)=∑(ni/2)*log(λi)-∑∑ (λi/2*(μ^2)*xij)*((xij-μ)^2)+const.
Find the MLEs for (μ,λ1,...,λk) by EM-Algorithm?)

Could you please help me with that?
I would like to thank you in advance for your help.

best regards,
Sara

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 link two R packages together

2012-08-02 Thread Xuan Zhao
Hi Josh,
Thank you so much for your detailed explanation. It's very clear, and now I can 
understand the difference between depends and imports.
Thank you so much for your help!! I really really appreciate it!
Yours,
Xuan

-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] 
Sent: Thursday, August 02, 2012 10:40 AM
To: Xuan Zhao
Cc: r-help@r-project.org
Subject: Re: [R] How to link two R packages together

Hi Xuan,

I would expect ~/R/ to be the R_HOME directory, though perhaps I am wrong.  
Also, you only need a depends or an imports, not both.  At a simplified level, 
the difference is that importing PKG2 in PKG1 makes the (exported) functions in 
PKG2 available to PKG1. Depends also makes the (exported) functions in PKG2 
available to PKG1, but it _also_ makes them available to the user.  This can be 
good or bad, with the recommendation now being not to. The reason it can be 
good is if you want your users to have access to functions in both packages 
without explicitly loading both. However, let's say that function foo() is 
defined in PKG2 and in PKG3. PKG1 does not know about PKG3, and the user had 
PKG3 loaded prior to loading PKG1. Then when PKG1 loads, PKG2 also loads, and 
because all the exported functions from PKG2 are included, PKG2::foo() masks 
PKG3::foo(), which can be annoying for users if your package adds unnecessary 
functions to the search path potentially masking the versions!
  they wanted to use.

That was a rather convoluted explanation, but hopefully it is somewhat clear.

Sincerely,

Josh

On Thu, Aug 2, 2012 at 7:02 AM, Xuan Zhao xuan.z...@sentrana.com wrote:
 Hi All,
 Thank you so much for all the help you have provided, I really appreciate it!
 The problem is solved, I just added PKG2 to the dependency of PKG1 in the 
 description file, also (I don't know if it's necessary or not), I added 
 import(PKG2) to the NAMESPACE file. In addition to that, I install PKG2 
 under a path R can recognize, namely, belong to .libPaths().
 I have tried other ways besides install it under the path R can recognize, 
 like  adding a file ~/.R/check.Environ, whose contents are: 
 'R_LIBS_SITE=${R_LIBS_SITE-'directoryunderwhichPKG2isinstalled'}', but it 
 still doesn't work.
 I looked through the manual, they just say the file 'check.Environ' should be 
 put under '~/.R', but I am not should what the ~/ should be. Is that my 
 home directory or what? Should that be the host? I am not the host of the 
 server, does that matter?
 Thank you so much for the help!
 Yours,
 Xuan

 -Original Message-
 From: Bert Gunter [mailto:gunter.ber...@gene.com]
 Sent: Thursday, August 02, 2012 9:42 AM
 To: Joshua Wiley
 Cc: Michael Weylandt; r-help@r-project.org; Xuan Zhao
 Subject: Re: [R] How to link two R packages together

 Josh:

 You may be right ... but I still do not think so. Note that the post begins 
 with:

 One of them (PKG1) needs to use the functions
 of the other package (PKG2).

 This is exactly what imports are for. I believe that, because he/she failed 
 to RTFM, he/she is not being accurate in his/her use of the relevant terms. 
 Certainly, to me at least, it is unclear. Moreover, as I understand it (see 
 the manual) imports are preferred over dependencies, as I indicated in my 
 reply.

 Anyway, in either case, the central advice is that which both Michael 
 and I gave: RTFM. Perhaps it's a generation gap (I am old), but I 
 believe there has been a trend for new R users to post here without 
 making any significant effort to consult the docs. This strikes me as 
 intellectually lazy and, frankly, inconsiderate to those like yourself
 -- or BDR -- who are willing to give up their time and effort to help those 
 with legitimate questions. You and others may consider this an overreaction 
 of course.

 Sorry for the rant, but it seems relevant to your close parsing of the thread.

 -- Cheers,
 Bert

 On Wed, Aug 1, 2012 at 10:35 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 On Wed, Aug 1, 2012 at 10:28 PM, Bert Gunter gunter.ber...@gene.com wrote:
 On Wed, Aug 1, 2012 at 6:45 PM, Michael Weylandt 
 michael.weyla...@gmail.com wrote:
 Isn't this what package dependencies are for?

 No. It's what package imports are for (preferably).
 As always, the OP should RTFM -- in this case the one to which you 
 refer on the next line, especially the NAMESPACES section.

 But note that the original question included, when I load one 
 package using 'library(PKG1)', PKG2 can be loaded at the same. 
 which imports does not exactly do. They become available to the 
 package, but not to the user, so if you really need both packages 
 loaded to the search path, then you need a dependency, not imports.

 Cheers,

 Josh


 -- Bert


 See the description of the DESCRIPTION file in Writing R Extensions

 Michael

 On Aug 1, 2012, at 5:27 PM, xuan zhao xuan.z...@sentrana.com wrote:

 Hi,
 I have built two R packages. One of them (PKG1) needs to use the 
 functions of the other 

Re: [R] How to link two R packages together

2012-08-02 Thread Xuan Zhao
Hi Michael,
Thank you so much for the help Michael! When I put my package 'PKG2' (on which 
PKG1 is depending on) in the regular place, perhaps a place R CMD check won't 
look at, then when I try to build PKG1, they will say PKG2 required but not 
found, so I have to put it under a directory R looks at, just the paths under 
'.libPaths()'. 
I read through the manual (the 7th section entitled toolsof R internals), 
and they suggest changing check.Environ under ~/.R, so I have tried to put 
check.Environ ~/.R, ~/ is my home directory which is just the path shown 
after typing cd pwd. But It doesn't work, so I thought ~/ might be 
something else.
Thank you so much for the help, I really appreciate that!
Yours,
Xuan

-Original Message-
From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] 
Sent: Thursday, August 02, 2012 10:46 AM
To: Xuan Zhao
Cc: r-help@r-project.org
Subject: Re: [R] How to link two R packages together

On Thu, Aug 2, 2012 at 9:02 AM, Xuan Zhao xuan.z...@sentrana.com wrote:
 Hi All,
 Thank you so much for all the help you have provided, I really appreciate it!
 The problem is solved, I just added PKG2 to the dependency of PKG1 in the 
 description file, also (I don't know if it's necessary or not), I added 
 import(PKG2) to the NAMESPACE file. In addition to that, I install PKG2 
 under a path R can recognize, namely, belong to .libPaths().
 I have tried other ways besides install it under the path R can recognize, 
 like  adding a file ~/.R/check.Environ, whose contents are: 
 'R_LIBS_SITE=${R_LIBS_SITE-'directoryunderwhichPKG2isinstalled'}', but it 
 still doesn't work.

By which you mean  ?

 I looked through the manual, they just say the file 'check.Environ' should be 
 put under '~/.R', but I am not should what the ~/ should be. Is that my 
 home directory or what? Should that be the host? I am not the host of the 
 server, does that matter?
 Thank you so much for the help!
 Yours,
 Xuan

~ is a standard UNIX (POSIX?) shorthand for the user's home directory. On my 
Mac it is /Users/mweylandt and I imagine you'd get something similar on all 
Linux and BSD systems -- one easy way to see where it is: go to your terminal 
and type cd  pwd which will print it out. No idea what the parallel on 
Windows is: possibly something under C:/Documents and Settings but it's been so 
long since I've had the misfortune of doing serious work on Windows, I can't 
remember.

Incidentally, is there a reason you can't put your package in the regular 
place?

Finally, see the manuals that Bert, Josh, and I have pointed you to:
they are much more authoritative on these matters than any of us.

Best,
Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] phantom NA/NaN/Inf in foreign function call (or something altogether different?)

2012-08-02 Thread Cecile De Cat
Sorry.  I've used:
 library(rms)

I realise I still have a lot to learn to ask questions well - it took me a
long time to compile this one, but I've obviously missed important things.
 Please see below for the session info.

 sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United
Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C

[5] LC_TIME=English_United Kingdom.1252

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

other attached packages:
[1] rms_3.5-0Hmisc_3.9-3  survival_2.36-12

loaded via a namespace (and not attached):
[1] cluster_1.14.2 grid_2.15.0lattice_0.20-6 tools_2.15.0


Many thanks for your help.

Cecile


On 2 August 2012 01:00, R. Michael Weylandt michael.weyla...@gmail.comwrote:

 What package(s) are the functions in question from?

 This might also help:


 http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

 Michael

 On Wed, Aug 1, 2012 at 2:57 AM, Cecile De Cat c.de...@leeds.ac.uk wrote:
  You're right, it's just the 2 columns that are characters that return
  false.  But I don't use them in the analysis (it's the experiments'
  names and the participants' names).
 
  So I guess I'm back to my original question (although I can discard
  one possible cause thanks to you): there appears to be only real
  numbers in the data used for the lrm analysis, and yet it falls over.
 
  Thanks a lot for your help.
 
  Cecile
 
 
  On 31 July 2012 16:42, R. Michael Weylandt michael.weyla...@gmail.com
 wrote:
  What classes are the columns of your data frame?
 
  Note that
 
  is.finite(a) # False
  is.finite(factor(a)) # True
 
  M
 
  On Tue, Jul 31, 2012 at 10:34 AM, Cecile De Cat c.de...@leeds.ac.uk
 wrote:
  Thank you.  This is very useful.  I do indeed get the following:
  table(sapply(dat, is.finite))
   FALSE   TRUE
   28164 253476
 
  But the number of observations returned baffles me, as there should
  only be 14082 in the data.  And when I look at each variable
  individually, none appear to violate is.finite: e.g.
 
  table(sapply(dat$Proficiency, is.finite))
   TRUE
  14082
 
  Sorry if this is a dumb question, but can you help me understand
  what's going on?
 
  Many thanks.
 
  Cecile


[[alternative HTML version deleted]]

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


Re: [R] te( ) interactions and AIC model selection with GAM

2012-08-02 Thread Simon Wood

Ricardo,

Your second construction (b) is the correct one (in a you are asking for 
one marginal to be a 2 dimensional cubic regression spline, which 
doesn't exist in mgcv).


For visualization, would the example at the end of ?te be the thing to 
do? In 3d I find looking at a series of 2d slices quite useful.


For AIC model comparison, the usual advice applies that although the 
comparisons are a bit more reliable for nested models (since then some 
of the AIC approximations errors are the same in both cases, and cancel 
in the comparison), it is still ok to use AIC for non-nested models 
(i.e. it is *not* like most hypothesis testing where everything falls 
apart if you don't have nesting).


best,
Simon

On 30/07/12 16:50, Ricardogg wrote:

Hello R users,

I'm working with a time-series of several years and to analyze it, I’m using
GAM smoothers from the package mgcv. I’m constructing models where
zooplankton biomass (bm) is the dependent variable and the continuous
explanatory variables are:
-time in Julian days (t), to creat a long-term linear trend
-Julian days of the year (t_year) to create an annual cycle
- Mean temperature of Winter (temp_W), Temperature of September (temp_sept)
or Chla.
Questions:
1) To introduce a tensor product modifying the annual cycle in my model, I
tried 2 different approaches:
- a) gam ( bm ~ t + te (t_year, temp_W, temp_sept, k = c( 5,30), d= ( 1,2),
bs = c( “cc”,”cr”)), data = data)
-b) gam ( bm ~ t + te (t_year, temp_W, temp_sept, k = 5, bs = c(
“cc”,”cr”,”cr”)), data = data)
Here is my problem: when I’m using just 2 variables (e.g., t_year and
temp_W) for the tensor product, I can understand pretty well how the
interpolation works and visualize it with vis.gam() as a 3d plot or a
contour one. But with 3 variables is difficult to me to understand how it
works. Besides, I don’t which one is the proper way to construct it, a) or
b). Finally, when I plot a) or b) as vis.gam (model_name , view= c(“t_year”,
“temp_W”)), How should I interpret the plot? The effect of temp_W on the
annual cycle after considering already the effect of temp_sept or just the
individual effect of Temp_W on the annual cycle?
2) I’m trying to do a model selection using AIC criteria. I have several
questions about it:
- Should I use always the same type of smoothing basis (bs), the same type
of smoother ( e.g te) and the same dimension of the basis (k)? Example:
Option 1:
a) mod1 - gam (bm ~ t, data = data)
b) mod2 - gam (bm ~ te (t, k = 5, bs = “cr”), data = data)
c) mod3 - gam (bm ~ te (t_year, k = 5, bs = “cc”), data = data)
d) mod4 - gam (bm ~ te (t_year, temp_W, k = 5, bs = c(“cc”,”cr”)), data =
data)
e) mod5 - gam (bm ~ te (t_year, temp_W, temp_sept, k = 5, bs =
c(“cc”,”cr”,”cr”)), data = data).
Here the limitation for k = 5, is due to mod5, I don’t use s () because in
mod4 and mod5 te () is used and finally, I always use “cr” and “cc”.
Option 2:
a) mod1 - gam (bm ~ t, data = data)
b) mod2 - gam (bm ~ s (t, k = 13, bs = “cr”), data = data)
c) mod3 - gam (bm ~ s (t_year, k = 13, bs = “cc”), data = data)
d) mod4 - gam (bm ~ te (t_year, temp_W, k = 11, bs = c(“cc”,”cr”)), data =
data)
e) mod5 - gam (bm ~ te (t_year, temp_W, temp_sept, k = 5, bs =
c(“cc”,”cr”,”cr”)), data = data).
I can get lower AIC for each of the models with Option 2, but are they
comparable when I use AIC criteria? Is it therefore the proper way to do it
as in Option 1? AIC (mod1, mod2, mod3, mod4, mod5).

Thank you in advance,
Best regards,
Ricardo González-Gil




--
View this message in context: 
http://r.789695.n4.nabble.com/te-interactions-and-AIC-model-selection-with-GAM-tp4638368.html
Sent from the R help mailing list archive at Nabble.com.

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




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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] te( ) interactions and AIC model selection with GAM

2012-08-02 Thread Will Shadish
Simon, could you clarify this paragraph. We are submitting to a 
psychology journal and I am certain they will be asking us about why it 
is still ok to use AIC for non-nested models. Thanks. Will Shadish


On 8/2/2012 9:49 AM, Simon Wood wrote:
For AIC model comparison, the usual advice applies that although the 
comparisons are a bit more reliable for nested models (since then some 
of the AIC approximations errors are the same in both cases, and 
cancel in the comparison), it is still ok to use AIC for non-nested 
models (i.e. it is *not* like most hypothesis testing where everything 
falls apart if you don't have nesting).


best,
Simon



--
William R. Shadish
Distinguished Professor
Founding Faculty
Chair, Psychological Sciences

Mailing Address:
William R. Shadish
University of California
School of Social Sciences, Humanities and Arts
5200 North Lake Rd
Merced CA  95343

Physical/Delivery Address:
University of California Merced
ATTN: William Shadish
School of Social Sciences, Humanities and Arts
Facilities Services Building A
5200 North Lake Rd.
Merced, CA 95343

209-228-4372 voice
209-228-4390 fax
wshad...@ucmerced.edu
http://faculty.ucmerced.edu/wshadish/index.htm
http://psychology.ucmerced.edu

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


Re: [R] finding the MLEs of IG parameters by EM-Alorithm

2012-08-02 Thread peter dalgaard

On Aug 2, 2012, at 16:01 , Sara S wrote:

 Dear all
 
 I'm trying to caculate the MLEs for parameters of Inverse Gaussian
 distribution (in a k-sample problem with common mean) by using
 EM-Algorithm.  I found some package for EM-Algorithm that are useful
 for missing or incomplete data and are not helpful for solving my
 problem.
 (Exactly, the problem is: Let Xij, i=1,..,k , j=1,...,ni, be a random
 sample from IG(μ,λi). So the log-likelihood function is:
 log(L)=∑(ni/2)*log(λi)-∑∑ (λi/2*(μ^2)*xij)*((xij-μ)^2)+const.
 Find the MLEs for (μ,λ1,...,λk) by EM-Algorithm?)
 
 Could you please help me with that?

No. Its a theory problem, not an R one. You likely need to rephrase the problem 
as a missing-data problem. I don't see how, but the text containing the 
exercise may contain a hint somewhere in the vicinity.

 I would like to thank you in advance for your help.
 
 best regards,
 Sara

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [R] te( ) interactions and AIC model selection with GAM

2012-08-02 Thread Bert Gunter
Well, geez! Without trying to upstage SImon, why not google it yourself?!

http://en.wikipedia.org/wiki/Akaike_information_criterion

(seemed pretty clear to me...)

-- Bert

On Thu, Aug 2, 2012 at 9:54 AM, Will Shadish wshad...@ucmerced.edu wrote:
 Simon, could you clarify this paragraph. We are submitting to a psychology
 journal and I am certain they will be asking us about why it is still ok to
 use AIC for non-nested models. Thanks. Will Shadish

 On 8/2/2012 9:49 AM, Simon Wood wrote:

 For AIC model comparison, the usual advice applies that although the
 comparisons are a bit more reliable for nested models (since then some of
 the AIC approximations errors are the same in both cases, and cancel in the
 comparison), it is still ok to use AIC for non-nested models (i.e. it is
 *not* like most hypothesis testing where everything falls apart if you don't
 have nesting).

 best,
 Simon


 --
 William R. Shadish
 Distinguished Professor
 Founding Faculty
 Chair, Psychological Sciences

 Mailing Address:
 William R. Shadish
 University of California
 School of Social Sciences, Humanities and Arts
 5200 North Lake Rd
 Merced CA  95343

 Physical/Delivery Address:
 University of California Merced
 ATTN: William Shadish
 School of Social Sciences, Humanities and Arts
 Facilities Services Building A
 5200 North Lake Rd.
 Merced, CA 95343

 209-228-4372 voice
 209-228-4390 fax
 wshad...@ucmerced.edu
 http://faculty.ucmerced.edu/wshadish/index.htm
 http://psychology.ucmerced.edu

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Cannot install the 'igraph' package

2012-08-02 Thread K. Elo

Hi!

On Thu, 2 Aug 2012, Uwe Ligges wrote:
R.h should be part if your R installation, given the output above 
probably in /usr/lib64/R/include ?


But there is no such file R.h in my system???

~$ locate \/R.h
~$

Or with 'find':

# find / -name R.h
#

Any ideas?

Kind regards,
Kimmo

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

2012-08-02 Thread Berry Boessenkool


Hey all,

I was wondering about the order of execution of functions and found that, in 
fact, I should look at the topic of buffering output to the console.
Which I did - below are some links of related topics, in case anyone wants to 
read up on it.

I decided to change the concerning lines in the file Rconsole in the 
etc-folder to
   ## Default setting for console buffering: 'yes' or 'no'
   buffered = no
which works fine.
Of course, when I send functions to someone else using a GUI console, I'll 
insert flush.console() at the important positions.

My question is:
should I expect serious computing time issues with this setting?
As posted in [5], calling flush.console too often takes a lot of time...


Thanks very much,
Berry Boessenkool, Potsdam


[1]
http://r.789695.n4.nabble.com/pause-in-function-execution-td882624.htm
[2]
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#The-output-to-the-console-seems-to-be-delayed
[3]
http://r.789695.n4.nabble.com/Obtaining-partial-output-from-a-function-that-does-not-run-to-completion-td991423.html
[4]
http://r.789695.n4.nabble.com/printing-a-variable-during-a-loop-td3006034.html
[5]
http://r.789695.n4.nabble.com/Printing-a-variable-in-a-loop-tp4634673.html
[6]
http://r.789695.n4.nabble.com/How-to-print-console-output-statements-from-within-script-or-function-tp846966.html
[7] Progress-Bars: 
http://ryouready.wordpress.com/2009/03/16/r-monitor-function-progress-with-a-progress-bar/

  
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] te( ) interactions and AIC model selection with GAM

2012-08-02 Thread Will Shadish
Bert, thanks for the very useful link. I am duly chastised for not 
having searched thoroughly enough.


Will

On 8/2/2012 10:02 AM, Bert Gunter wrote:

Well, geez! Without trying to upstage SImon, why not google it yourself?!

http://en.wikipedia.org/wiki/Akaike_information_criterion

(seemed pretty clear to me...)

-- Bert

On Thu, Aug 2, 2012 at 9:54 AM, Will Shadish wshad...@ucmerced.edu wrote:

Simon, could you clarify this paragraph. We are submitting to a psychology
journal and I am certain they will be asking us about why it is still ok to
use AIC for non-nested models. Thanks. Will Shadish

On 8/2/2012 9:49 AM, Simon Wood wrote:

For AIC model comparison, the usual advice applies that although the
comparisons are a bit more reliable for nested models (since then some of
the AIC approximations errors are the same in both cases, and cancel in the
comparison), it is still ok to use AIC for non-nested models (i.e. it is
*not* like most hypothesis testing where everything falls apart if you don't
have nesting).

best,
Simon


--
William R. Shadish
Distinguished Professor
Founding Faculty
Chair, Psychological Sciences

Mailing Address:
William R. Shadish
University of California
School of Social Sciences, Humanities and Arts
5200 North Lake Rd
Merced CA  95343

Physical/Delivery Address:
University of California Merced
ATTN: William Shadish
School of Social Sciences, Humanities and Arts
Facilities Services Building A
5200 North Lake Rd.
Merced, CA 95343

209-228-4372 voice
209-228-4390 fax
wshad...@ucmerced.edu
http://faculty.ucmerced.edu/wshadish/index.htm
http://psychology.ucmerced.edu

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





--
William R. Shadish
Distinguished Professor
Founding Faculty
Chair, Psychological Sciences

Mailing Address:
William R. Shadish
University of California
School of Social Sciences, Humanities and Arts
5200 North Lake Rd
Merced CA  95343

Physical/Delivery Address:
University of California Merced
ATTN: William Shadish
School of Social Sciences, Humanities and Arts
Facilities Services Building A
5200 North Lake Rd.
Merced, CA 95343

209-228-4372 voice
209-228-4390 fax
wshad...@ucmerced.edu
http://faculty.ucmerced.edu/wshadish/index.htm
http://psychology.ucmerced.edu

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


Re: [R] Filter a matrix with a matrix HELP!

2012-08-02 Thread R. Michael Weylandt
On Thu, Aug 2, 2012 at 8:16 AM, Cloneberry clonebe...@gmail.com wrote:
 Hi,
 just during these vacation days, I'm trying to approach with multicore
 package
 and I have some troubles with foreach.
 What I'm trying to do is to extract a data in coordinate (ii,jj) from a
 matrix2,
 only if the data in the same coordinate in matrix1 is ==1.

I think you're making this far too hard -- subsetting is a relatively
cheap operation and shouldn't require this sort of parallelization:

matrix2[matrix1 == 1]

matrix1 == 1 will create a boolean (TRUE/FALSE) matrix which you then
use to pick out a subset of matrix2.

Best,
Michael

 Make this with a nested for take a lot of time because I have thousand of
 values.

 ex.
 Binary_hex = NULL
 foreach(ii=1:nrow(matrix2)) %:% foreach(jj=1:ncol(matrix2)) %dopar%
 {when(matrix2[ii,jj] == 1) %:% {Binary_hex - c(Binary_hex,
 matrix1[ii,jj])}}

 During this operation... computer don't work in multicore and the process
 take a lot of time,
 just like a simple nested for. I think the mistake is in the when
 parameter because if I substitute
 the when with another function (like sqrt) it work greatly and fast.
 Please, give me some suggestion, also with different way.
 Thank you in advance.
 Max



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Filter-a-matrix-with-a-matrix-HELP-tp4638871.html
 Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread Eik Vettorazzi
I still try to figure out, what you are finally asking for, but maybe

res-sapply(list4,function(x)max(x[[1]]$coconut))
names(res)-c(mango, banana, pineapple)
res
max(res)

is worth a try?

Especially i did not get the point of doing something like
x[which.max(x)] because this is in any case just max(x)

if you would like to plug in different functions or want to select
different columns,

fun-max # or min, median etc
sapply(lapply(list4,[[,1),fun)

could be a start, where lapply(list4,[[,1) extracts the first object
in each sublist - which is in your case a data.frame with just one
column ('coconut'), where 'fun' can be applied to. So to address
'coconut' explicitly, just nest this lapply approach:

sapply(lapply(lapply(list4,[[,1),[[,coconut),fun)
#or use an anonymous extractor function
sapply(lapply(list4,function(x)x[[1]][[coconut]]),fun)

cheers

Am 02.08.2012 16:09, schrieb gail:
 Hi,
 
 my dataset is the result of the function density on another set of data.
 It refers to that data in its variable call, though since all the results
 are actually reproduced (except that I've removed all rows bar 10), I am not
 sure why R still needs it. But I've understood now why your code doesn't
 work on my data: your sublists are still just dataframes, whereas my
 sublists contain all sorts of vectors (2 numerical vectors and 5 other
 things). I've changed your data to make it look a bit more like mine, and
 you'll see that the code doesn't work. 
 
 mango - list(data.frame(coconut=1:6), y=c(4,5,3,2,1,8),
 bw=c(4,18,12,3,4,9), nn=paste0(a,1:6))
 banana - list(data.frame(coconut=c(1,2,18,16,15)), y=c(4,5,9,2,1),
 bw=c(4,18,22,3,4), nn=paste0(a,1:5))
 pineapple - list(data.frame(coconut=c(4,6,9)), y=c(8,24,12),
 bw=c(14,31,36), nn=paste0(a,1:3))
 list4 - list(mango, banana, pineapple)
 
 b - list()
 
  for(i in 1:3){
  b[[i]] - list()
  b[[i]] - lapply (list4[[i]]$coconut, FUN=function(x) x[which.max(x)])
  }
 
 b
 summary( b)
 
 What I want to end up with is the following:
 
coconut
 mango   6
 banana 18
 pineapple   9
 (that's for the individual sublists)
 
 and 
coconut
 18
 (that's for the list as a whole).
 
 Hope this is becoming a bit clearer ...
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p4638876.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. 
Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Optimize a function with Discrete inputs

2012-08-02 Thread R. Michael Weylandt
On Thu, Aug 2, 2012 at 5:58 AM, loyolite270 loyolite...@gmail.com wrote:
 oh sorry ..

 The detailed description of the problem is given below

 dataFrame is matrix of dim 100X100 with some values

Odd name for something that's not a dataFrame (i.e., data.frame != matrix)

 a is a vector of length 1
 x is a vector of any length between 1 to 99

 funcScore-function(a,x){

 sc-0
 sc1-0

  for(j in 1:(length(x))){
 sc-sc+abs(dataFrame[a,x[j]])
   }

 if(length(x)==1){
   sc1-0
 }

 else{
if(length(x)1){
   for(i in 1:(length(x)-1)){
for(j in (i+1):(length(x))){
   sc1 - sc1+abs(dataFrame[(x[i]-1),x[j]])
}
   }
}
 }
score - sc-sc1
return(score)
  }


Surely you can write this more efficiently:

score - function(a, x, datfrm){
sc - sum(abs(datfrm[a, x]))

# Something similar for sc1

   sc - sc1
}

Depending on how fast you get it (and I expect massive speed ups upon
rewrite if you vectorize properly), an exhaustive search via combn()
or expand.grid() might work -- otherwise, see combinatorial
optimization pointers, as I noted earlier.

Best,
Michael


 Given the value of a,  i would like to use some optimization function (
 value of x) to maximize the score, such that x can be any combination ?

 Thanks






 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Optimize-a-function-with-Discrete-inputs-tp4638644p4638851.html
 Sent from the R help mailing list archive at Nabble.com.

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] te( ) interactions and AIC model selection with GAM

2012-08-02 Thread Simon Wood

On 02/08/12 18:02, Bert Gunter wrote:

Well, geez! Without trying to upstage SImon, why not google it yourself?!

http://en.wikipedia.org/wiki/Akaike_information_criterion

-- one or two slightly surprising statements in there though :-)
I quite like the coverage in Davison (2003) Statistical Models Section 
4.7. Burnham and Anderson (2002) Model Selection and Multi Model 
inference: a practical information theoretic approach, Springer, is a 
longer treatment.


best,
Simon



(seemed pretty clear to me...)

-- Bert

On Thu, Aug 2, 2012 at 9:54 AM, Will Shadish wshad...@ucmerced.edu wrote:

Simon, could you clarify this paragraph. We are submitting to a psychology
journal and I am certain they will be asking us about why it is still ok to
use AIC for non-nested models. Thanks. Will Shadish

On 8/2/2012 9:49 AM, Simon Wood wrote:


For AIC model comparison, the usual advice applies that although the
comparisons are a bit more reliable for nested models (since then some of
the AIC approximations errors are the same in both cases, and cancel in the
comparison), it is still ok to use AIC for non-nested models (i.e. it is
*not* like most hypothesis testing where everything falls apart if you don't
have nesting).

best,
Simon



--
William R. Shadish
Distinguished Professor
Founding Faculty
Chair, Psychological Sciences

Mailing Address:
William R. Shadish
University of California
School of Social Sciences, Humanities and Arts
5200 North Lake Rd
Merced CA  95343

Physical/Delivery Address:
University of California Merced
ATTN: William Shadish
School of Social Sciences, Humanities and Arts
Facilities Services Building A
5200 North Lake Rd.
Merced, CA 95343

209-228-4372 voice
209-228-4390 fax
wshad...@ucmerced.edu
http://faculty.ucmerced.edu/wshadish/index.htm
http://psychology.ucmerced.edu

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







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

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

2012-08-02 Thread Petr Savicky
On Thu, Aug 02, 2012 at 02:27:43AM -0700, khris wrote:
 
 On Aug 2, 2012, at 12:39 PM, Petr Savicky [via R] wrote:
 
  On Wed, Aug 01, 2012 at 04:55:30AM -0700, khris wrote: 
   Hi Petr, 
   
   It been sometime since I wrote. But here are the latest developments. 
   
   When I give the binary linear opt problem to lpSolve optimizer than for 
   small instance it gives correct answer but when size of nodes increase 
   let's say 16 then there are about 2000 binary variables and lpSolve just 
   does not come back with any answer even after running for a full day. I 
   plan to solve for node size upto atleast 100, so I guess I need to do 
   something fundamentally different. 
   
   Now I understand that lpSolve is using Branch and Bound Algorithm which 
   to me looks highly inefficient, for in the wrost case it will try to 
   solve 2^n LP relaxation problem. Maybe that's why I do not get answer 
   even when n=16. So what do I do to make lpSolve solve problem 
   efficiently. 
  
  Integer linear programming is an NP-complete problem and in general 
  requires an 
  exponential time. It is not surprising that lpSolve failed to solve a 
  problem 
  with 2000 variables. It can solve some problems with a few hundreds of 
  variables, 
  but not every such problem. 
  
 
 OK. I guess then my approach to solve the Graph matching problem using binary 
 opt pr. seems destined to fail. I know you told about Kohenan maps but I am 
 not exited about it since it some sort of neural network which involves 
 training. So that approach may not be suitable. 
 I wrote about another approach, reducing the Graph matching with upper bound 
 on degree of vertex to Graph isomorphism where degree of vertex has upper 
 bound since Graph isomorphism where degree of vertex has upper bound has 
 tractable solution. This approach seems promising.
 
 I also came across solving Graph matching using Simulated Annealing 
 (http://randomwalker.info/luther/kaggle-deanonymization/Graph_Matching_via_Simulate.html)
  which also seems promising.
 
 How do you feel about these?

I agree with Bert that this does not belong to this list. The only thing,
which i can suggest for graph isomorphism is to try igraph package. If you
have questions concerning its use, start a new thread. I have no experience
with graph isomorphism and igraph.

   In the lpSolve document there does not seem to be any option where one 
   can specify which variable should the optimizer use to use LP relaxation 
   first? Is there way to control in some way Branch and Bound algorithm 
   used by lpSolve apart from the going in side the code and tweaking it. 
  
  I do not know, whether this may be controlled. 
  
  Do you have a specific reason to use lpSolve for your problem? 
 
 I thought lpSolve is the best optimizer freely available in R so I was using 
 it. Do you recommend another one? But if my model consist of 100,00 binaray 
 variable then I assume even commercial optimizer also won't scale?

The problem is not that lpSolve is not a good solver, but that integer
linear programming is not suitable for your problem, since it requires too
large instances to express graph isomorphism. I do not believe that other
solvers can handle these instances significantly better.

Petr.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] parallel SNOW slower than single core?

2012-08-02 Thread Jie
Dear All,

I am learning parallel in R and start with the package snow. I did a test
about running time and the parallel version is much slower than the regulat
code. My laptop is X200s with dual core intel L9400 cpu.
Should I make more clusters than 2? Or how to improve the performance?

# install.packages(snow)
library(snow)
cl - makeCluster(2)
t1 - proc.time()
a - c()
for (i in 1:1000)
{
a[i] - sum(parSapply(cl, 1:15, get(+), 2))
}
proc.time()-t1
t2 - proc.time()
a - c()
for (i in 1:1000)
{
a[i] - sum(sapply(1:15, +, 2))
}
proc.time()-t2

[[alternative HTML version deleted]]

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


[R] Subset data

2012-08-02 Thread antonio.bso...@sapo.pt
Hi 
Need a little help. This is easy question, but i´m new to R.
I want to subset a data frame called vef1 using a variable that is a factor 
called edad11, 0 if under 11 years, 1 otherwise.
I tried:
vef1.sub-subset(vef1, edad11==0)
The code runs correctly but i get a empty dataframe.
If i use this code in Deducer everything is OK.
Can you help me?
Thanks in advance
Antonio Sousa
Portugal

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

2012-08-02 Thread ch chor
Hi all,

I have made a lot of attempts with ts package and arima model for
forecasting.
Now I am looking on zoo package.
I follow Gabor's steps from another post on leap years

https://stat.ethz.ch/pipermail/r-help/2011-February/269069.html

and I am confused in that step:

# put dates (without Feb 29's) back to view
d.mts - do.call(cbind, d[1:3])
zd - zoo(coredata(d.mts), time(zz))
View(zd)

Where does d[1:3] refers?
Having created a zooreg time series, how will I continue with the
forecasting? Is it the same way as when I was using the tseries
package?

Thanks in advance
christina

[[alternative HTML version deleted]]

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


[R] need help and its urgent!

2012-08-02 Thread Humayera Islam
Can you tell me what does the option zero in genpoisson{VGAM} mean?

 zero An integer vector, containing the value 1 or 2. If so, *ë* or
*theta*respectively are modelled as an intercept only. If set to
NULL then both linear/additive predictors are modelled as functions of the
explanatory variables.

To fit a simple model like log(theta/(1-phi))=bo+b1x, which value of zero
should i use 1 or 2 or NULL? Please help me its urgent!

Thanks!

[[alternative HTML version deleted]]

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


Re: [R] te( ) interactions and AIC model selection with GAM

2012-08-02 Thread Ricardogg

- About the visualization, my question is more about interpretation. In the
case of  :

 model_name - gam ( bm  ~ t + te (t_year, temp_W, temp_sept, k = 5, bs = c(
“cc”,”cr”,”cr”)), data = data) 

* a)* vis.gam (model_name , view= c(“t_year”, “temp_W”))

*b)* vis.gam (model_name , view= c(“t_year”, “temp_sept”))

I imagine that what we see in a) is the effect on t_year by temp_W but  this
effect is also affected by temp-sept right? In other words, is what we see
the effect of temp_W on  t_year considering the other element of the model
which is temp-sept?

- About AIC model selection, my question is more focus on whether it is
necessary to use the same  the same type of smoother ( e.g te) and the same
dimension of the basis (k) for different model comparison...that is, if I
have a complex model in my list of models that I want to compare like:

gam ( bm ~ t + te (t_year, temp_W, temp_sept, k = 5, bs = c(
“cc”,”cr”,”cr”)), data = data) 

should I always use as type smoother te () instead of using s ( ) and always
fix the k as k = 5?? Here the maximum k I can put is k = 5.

for example, let's say I have another simpler model in my list of models I
want to compare in which I want to check the relationship between bm and t. 
Can I write it like /gam (bm ~ s(t, k = 13, bs = “cr”), data = data) /? Or I
have to write like/ gam (bm ~ te (t, k = 5, bs = “cr”), data = data)/ to do
the comparison in the same conditions for all the models?

Thank you very much for your response Simon,

Best regards,

Ricardo












--
View this message in context: 
http://r.789695.n4.nabble.com/te-interactions-and-AIC-model-selection-with-GAM-tp4638368p4638922.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread arun kirshna [via R]



Hi Elk,
Thanks for the input.  Somehow, I got entangled with which.max.  I should
have used max. 
lapply(list4,function(x) max(x[[1]]$coconut))
[[1]]
[1] 6

[[2]]
[1] 18

[[3]]
[1] 9
 max(unlist(lapply(list4,function(x) max(x[[1]]$coconut
#[1] 18
A.K.








___
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p4638923.html

To unsubscribe from apply function over same column of all objects in a list, 
visit 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4638681code=ci1oZWxwQHItcHJvamVjdC5vcmd8NDYzODY4MXwtNzg0MjM1NTA4
[[alternative HTML version deleted]]

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


Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread arun kirshna [via R]
Hello,

I was in a hurry at the time, when I replied.
You could do one thing: extract sublist using:
list4 - list(mango, banana, pineapple) 
b1-list()
 for(i in 1:3){
 b1[[i]]-list()
 b1[[i]]-list4[[i]][1]
 }
 b1
b-list()
 for(i in 1:3){
 b[[i]]-list()
 b[[i]]-lapply(b1[[i]][[1]],FUN=function(x)x[which.max(x)])
 }

b2-data.frame(do.call(rbind,b))
row.names(b2)-c(mango,banana,pineapple)
 b2 
 apply(b2,2, function(x) x[which.max(x)]) 
$coconut
$coconut$banana
[1] 18

I guess, this is much better than calling individual sublists.
A.K.




__
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p4638907.html
This email was sent by arun kirshna (via Nabble)
To receive all replies by email, subscribe to this discussion: 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=subscribe_by_codenode=4638681code=ci1oZWxwQHItcHJvamVjdC5vcmd8NDYzODY4MXwtNzg0MjM1NTA4
[[alternative HTML version deleted]]

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


[R] predictions from hurdle model

2012-08-02 Thread erin
I ran a negative binomial logit hurdle model and am now trying to plot the
effects of a continuous predictor variable (the only variable in my model)
on the count and zero component and the overall mean response.  I'm confused
because for some values, the predicted overall mean is higher than the mean
of the non-zero counts (range of predicted overall means=2.2-11.0; range of
non-zero count means=2.8-4.6).  Is this possible or did I do something
wrong?  I did not expect these results because I thought the probability of
getting a zero response should reduce the overall mean below the non-zero
count mean.

I attached the relevant code and output  below.  Any thoughts or suggestions
would be much appreciated!  I'm new to hurdle models and their
interpretation.  Thank you,
Erin

 library(pscl)
 nbhurdle.prev-hurdle(LLF.a~y.prev,data=full.cts,dist=negbin)
 summary(nbhurdle.prev)

Call:
hurdle(formula = LLF.a ~ y.prev, data = full.cts, dist = negbin)

Pearson residuals:
Min  1Q  Median  3Q Max 
-0.6398 -0. -0. -0.1363  7.3145 

Count model coefficients (truncated negbin with log link):
 Estimate Std. Error z value Pr(|z|)
(Intercept)  1.031508   0.470804   2.191  0.02846 *  
y.prev   0.005042   0.001835   2.747  0.00601 ** 
Log(theta)  -1.856429   0.561709  -3.305  0.00095 ***
Zero hurdle model coefficients (binomial with logit link):
 Estimate Std. Error z value Pr(|z|)
(Intercept) -0.915944   0.103853  -8.820   2e-16 ***
y.prev   0.048832   0.009079   5.379 7.51e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Theta: count = 0.1562
Number of iterations in BFGS optimization: 20 
Log-likelihood: -931.7 on 5 Df

 y.prev-seq(0,100,by=1)
 newdata-data.frame(y.prev)
 nonzero-1-predict(nbhurdle.prev,newdata=newdata,type=prob)
 countmean-predict(nbhurdle.prev,newdata=newdata,type=count)
 allmean-predict(nbhurdle.prev,newdata=newdata,type=response)
 plot(y.prev,nonzero[,1],type=b)
 plot(y.prev,countmean,type=b)
 plot(y.prev, allmean, type = b)





--
View this message in context: 
http://r.789695.n4.nabble.com/predictions-from-hurdle-model-tp4638924.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread arun kirshna [via R]
Hi Elk,

I tried to test with another case where coconut is in different position in
the sublist.
mango - list( y=c(4,5,3,2,1,8), bw=c(4,18,12,3,4,9),
nn=paste0(a,1:6),data.frame(coconut=1:6))
banana - list(data.frame(coconut=c(1,2,18,16,15)), y=c(4,5,9,2,1),
bw=c(4,18,22,3,4), nn=paste0(a,1:5))
pineapple - list(data.frame(coconut=c(4,6,9)), y=c(8,24,12),
bw=c(14,31,36), nn=paste0(a,1:3)) 
list5-list(mango,banana,pineapple)
#Your code
fun-max # or min, median etc
sapply(lapply(list5,[[,1),fun) 
[1]  8 18  9
# Here, first number should be 6, instead it did the max of y from mango.
#Then, I tried second solution of yours
sapply(lapply(lapply(list5,[[,1),[[,coconut),fun) 
#Error in FUN(X[[1L]], ...) : subscript out of bounds
#Third solution
 sapply(lapply(list5,function(x)x[[1]][[coconut]]),fun)
#Error in x[[1]][[coconut]] : subscript out of bounds

#I tried with another way to come up with the result (not as elegant)
b3-do.call(c,list5)
names(b3)[4]-mango
 names(b3)[5]-banana
 names(b3)[9]-pineapple
 b4-data.frame(key=names(b3),value=unlist(lapply(b3,FUN=function(x)
max(x
 key1-c(mango,banana,pineapple)
 b5-subset(b4, b4$key%in% key1)
 b5
#key value
#4 mango 6
#5banana18
#9 pineapple 9
b6-within(b5,{value-as.numeric(as.character(value))})
max(b6$value)
#[1] 18
A.K.






__
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p4638926.html
This email was sent by arun kirshna (via Nabble)

[[alternative HTML version deleted]]

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


Re: [R] parallel SNOW slower than single core?

2012-08-02 Thread R. Michael Weylandt
I'm not surprised -- you're doing a fairly trivial calculation so the
overhead of setting up the parallelization is likely more than the
benefit from halving the computation time. Do it on a larger
calculation and I imagine the performance will be better -- I might
just be pulling this out of thin air, but I think I remember reading
slides from Luke Tierney saying one had to be adding vectors of size
= 30k or so for parallelization to have a meaningful benefit.
Obviously sizes will be lower for operations more expensive than
addition.

Michael

On Thu, Aug 2, 2012 at 1:13 PM, Jie jimmycl...@gmail.com wrote:
 Dear All,

 I am learning parallel in R and start with the package snow. I did a test
 about running time and the parallel version is much slower than the regulat
 code. My laptop is X200s with dual core intel L9400 cpu.
 Should I make more clusters than 2? Or how to improve the performance?

 # install.packages(snow)
 library(snow)
 cl - makeCluster(2)
 t1 - proc.time()
 a - c()
 for (i in 1:1000)
 {
 a[i] - sum(parSapply(cl, 1:15, get(+), 2))
 }
 proc.time()-t1
 t2 - proc.time()
 a - c()
 for (i in 1:1000)
 {
 a[i] - sum(sapply(1:15, +, 2))
 }
 proc.time()-t2

 [[alternative HTML version deleted]]

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

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


[R] Ad Hoc comparison non parametric ANCOVA

2012-08-02 Thread Luis Fernando García Hernández
Dear R Users,

Recently I began to use R. I`m interested about comparing several
regression curves. REcently I found the package sm and the function
sm.ancova which I understand allows me to do this. I applied this function
to my data (seven regression curves) and I found that there are significant
differences. Nevertheless, when I want to find out where are the
differences, the package tells that it allows only paired comparisons.

Do you have any idea if this package makes only paired comparisons or if
does it allow to perform multiple comparisons?

Thanks in advance!

[[alternative HTML version deleted]]

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


Re: [R] Subset data

2012-08-02 Thread R. Michael Weylandt
Hmmm a trivial mockup suggests this should work:

x - factor(sample(c(0, 1), 30, TRUE)

x == 0

so perhaps you could work up a reproducible example for us: see this
site for more details on how to do so:

http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Best,
Michael

On Thu, Aug 2, 2012 at 1:15 PM, antonio.bso...@sapo.pt
antonio.bso...@sapo.pt wrote:
 Hi
 Need a little help. This is easy question, but i´m new to R.
 I want to subset a data frame called vef1 using a variable that is a factor 
 called edad11, 0 if under 11 years, 1 otherwise.
 I tried:
 vef1.sub-subset(vef1, edad11==0)
 The code runs correctly but i get a empty dataframe.
 If i use this code in Deducer everything is OK.
 Can you help me?
 Thanks in advance
 Antonio Sousa
 Portugal

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

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


Re: [R] package rms nomogram

2012-08-02 Thread David Winsemius


On Aug 1, 2012, at 8:09 PM, B787s wrote:

well, the article from this high impact factor journal mentioned  
about each
step for building a nomogram including interpretation without going  
too much

detail into statistical concept.
All I want to know is what the R code does to come up with the  
graph, and
not raising attention or get someone to review what the posting  
needs to be

and what I need to know. My question is at the end, unanswered.


Well, indeed. You might want to examine your own contributions to this  
difficulty you are facing. You cited an article (probably) in a  
journal that is not available to me without several hours of work on  
my part. (You also cited it only by misspelling the first author's  
name ... which you misspelled.) Apparently it was not on a  
particularly high level of mathematical detail. You are posting only  
with the name of airplanes but otherwise without any identification.  
You offer no information about your efforts at searching for  
tutorials. (I found several readily available.) Please read the  
Posting Guide for better understanding of how the contributors to this  
mailing list view the responsibilities of questioners.


--
David Winsemius, MD
Alameda, CA, USA

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


Re: [R] Subset data

2012-08-02 Thread arun
Hello,
You need to use,
subset(vef1,vef1$edad1==0)

vef1-read.table(text=
age  edad1
12 1
10 0
9  0
14 1
15 1
,sep=,header=TRUE) 

subset(vef1,vef1$edad1==0)
  age edad1
2  10 0
3   9 0
A.K.



- Original Message -
From: antonio.bso...@sapo.pt antonio.bso...@sapo.pt
To: r-help@r-project.org
Cc: 
Sent: Thursday, August 2, 2012 2:15 PM
Subject: [R] Subset data

Hi 
Need a little help. This is easy question, but i´m new to R.
I want to subset a data frame called vef1 using a variable that is a factor 
called edad11, 0 if under 11 years, 1 otherwise.
I tried:
vef1.sub-subset(vef1, edad11==0)
The code runs correctly but i get a empty dataframe.
If i use this code in Deducer everything is OK.
Can you help me?
Thanks in advance
Antonio Sousa
Portugal

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


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


[R] multiple comparisons for GAMs

2012-08-02 Thread Bird_Girl
Hi,

I have a question regarding whether it is possible to do post hoc tests on a
model fit with GAM {mgcv}.  My response variable is abundance (no.
individuals per plot), and I have one continuous predictor (light) and one
factor (height) which includes 7 levels. 

 mod2=gam(log_abundance~s(light)+height+te(light,by=height)+s(long)+s(lat))

The relationship between log_abundance and light at the seven levels of
height all differ significantly from the overall relationship between
log_abundance and light, and relationships at most of the 7 levels are not
linear.  I would like to do some kind of multiple comparison or post hoc
test to determine whether the relationship between log_abundance and light
differs significantly among the different levels of height (i.e., is the
relationship at 200 m different from that at 400 m)? Is there any way to do
this?

Thanks in advance, and I apologize if this is a stupid question – I am new
to R.




--
View this message in context: 
http://r.789695.n4.nabble.com/multiple-comparisons-for-GAMs-tp4638935.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Changing the classification threshold for cost function

2012-08-02 Thread SiBorg
Dear All

I am trying to perform leave-one-out cross validation on a logistic
regression model using cv.glm from the boot package in R.

As I understand it, the standard cost function:

cost-function(r,pi=0) mean(abs(r-pi)0.5)

Uses a 50% risk threshold to classify cases as positive or negative and
calculates the prediction error based on this.

I would like to alter this threshold to, say, nearer 5% or 1%, and calculate
the prediction error at the lower level.  This is because in my model, none
of the patients are at more than 50% risk of developing the condition before
they are screened, hence 50% gives no useful information on the model.  The
model is more useful in removing the very low risk patients from the number
needed to screen.

Can anybody tell me how to rewrite the cost function so that the
classification error at the 5% or 1% level can be used as the cut-off
instead of the 50% level.  Furthermore, in this scenario false positives
(i.e. patients who are predicted to be at higher risk but then don't develop
the condition) are more acceptable than false negatives (patients who are
predicted at low risk but then get the condition).  This is because any
patient at low risk doesn't get screened and therefore doesn't get treated.

Is there any way of penalising the model only on false negatives rather than
false positives at the lower cut-off value?

Thanks in advance for your help.



--
View this message in context: 
http://r.789695.n4.nabble.com/Changing-the-classification-threshold-for-cost-function-tp4638936.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Subset data

2012-08-02 Thread David Winsemius


On Aug 2, 2012, at 12:00 PM, arun wrote:


Hello,
You need to use,
subset(vef1,vef1$edad1==0)


That should not be necessary (and quite defeats the usual value of  
subset()'s nonstandard evaluation):


 vef1-read.table(text=
+ age  edad1
+ 12 1
+ 10 0
+ 9  0
+ 14 1
+ 15 1
+ , header=TRUE)

 subset(vef1, edad1==0)
  age edad1
2  10 0
3   9 0

--
David.



vef1-read.table(text=
age  edad1
12 1
10 0
9  0
14 1
15 1
,sep=,header=TRUE)

subset(vef1,vef1$edad1==0)
  age edad1
2  10 0
3   9 0
A.K.



- Original Message -
From: antonio.bso...@sapo.pt antonio.bso...@sapo.pt
To: r-help@r-project.org
Cc:
Sent: Thursday, August 2, 2012 2:15 PM
Subject: [R] Subset data

Hi
Need a little help. This is easy question, but i´m new to R.
I want to subset a data frame called vef1 using a variable that is a  
factor called edad11, 0 if under 11 years, 1 otherwise.

I tried:
vef1.sub-subset(vef1, edad11==0)
The code runs correctly but i get a empty dataframe.
If i use this code in Deducer everything is OK.
Can you help me?
Thanks in advance
Antonio Sousa
Portugal

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


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


David Winsemius, MD
Alameda, CA, USA

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


Re: [R] apply function over same column of all objects in a list

2012-08-02 Thread Eik Vettorazzi
Hi Arun,
if you name the data.frame in the list, e.g.
mango - list( y=c(4,5,3,2,1,8), bw=c(4,18,12,3,4,9),
nn=paste0(a,1:6),target=data.frame(coconut=1:6))
banana - list(target=data.frame(coconut=c(1,2,18,16,15)), y=c(4,5,9,2,1),
bw=c(4,18,22,3,4), nn=paste0(a,1:5))
pineapple - list(target=data.frame(coconut=c(4,6,9)), y=c(8,24,12),
bw=c(14,31,36), nn=paste0(a,1:3))
list6-list(mango,banana,pineapple)

then
sapply(lapply(list5,[[,target),max)

still works.

Regards

Am 02.08.2012 20:21, schrieb arun kirshna [via R]:
 Hi Elk,
 
 I tried to test with another case where coconut is in different position in
 the sublist.
 mango - list( y=c(4,5,3,2,1,8), bw=c(4,18,12,3,4,9),
 nn=paste0(a,1:6),data.frame(coconut=1:6))
 banana - list(data.frame(coconut=c(1,2,18,16,15)), y=c(4,5,9,2,1),
 bw=c(4,18,22,3,4), nn=paste0(a,1:5))
 pineapple - list(data.frame(coconut=c(4,6,9)), y=c(8,24,12),
 bw=c(14,31,36), nn=paste0(a,1:3)) 
 list5-list(mango,banana,pineapple)
 #Your code
 fun-max # or min, median etc
 sapply(lapply(list5,[[,1),fun) 
 [1]  8 18  9
 # Here, first number should be 6, instead it did the max of y from mango.
 #Then, I tried second solution of yours
 sapply(lapply(lapply(list5,[[,1),[[,coconut),fun) 
 #Error in FUN(X[[1L]], ...) : subscript out of bounds
 #Third solution
  sapply(lapply(list5,function(x)x[[1]][[coconut]]),fun)
 #Error in x[[1]][[coconut]] : subscript out of bounds
 
 #I tried with another way to come up with the result (not as elegant)
 b3-do.call(c,list5)
 names(b3)[4]-mango
  names(b3)[5]-banana
  names(b3)[9]-pineapple
  b4-data.frame(key=names(b3),value=unlist(lapply(b3,FUN=function(x)
 max(x
  key1-c(mango,banana,pineapple)
  b5-subset(b4, b4$key%in% key1)
  b5
 #key value
 #4 mango 6
 #5banana18
 #9 pineapple 9
 b6-within(b5,{value-as.numeric(as.character(value))})
 max(b6$value)
 #[1] 18
 A.K.
 
 
 
 
 
 
 __
 If you reply to this email, your message will be added to the discussion 
 below:
 http://r.789695.n4.nabble.com/apply-function-over-same-column-of-all-objects-in-a-list-tp4638681p4638926.html
 This email was sent by arun kirshna (via Nabble)
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Can anyone explain me how to use genpoisson{VGAM} ? Its urgent please!

2012-08-02 Thread Humayera Islam
Dear All,

I have some questions regarding using the genpoisson{VGAM} .

genpoisson(llambda=elogit, ltheta=loge,
   elambda=if(llambda==elogit) list(min=-1,max=1) else list(),
   etheta=list(), ilambda=NULL, itheta=NULL,
   use.approx=TRUE, method.init=1, zero=1)

and I am understanding the part  zero An integer vector, containing the
value 1 or 2. If so, *λ* or *theta* respectively are modeled as an
intercept only. If set to NULL then both linear/additive predictors are
modelled as functions of the explanatory variables.


For a simple generalized model like mu=exp(a+bx)=theta/(1-phi) which option
to select 0/1/NULL. I am not getting the parameterization used here. PLease
help!

Thanks!

[[alternative HTML version deleted]]

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


[R] summary(svyglm) Pr ( | t |) ?

2012-08-02 Thread Diana Marcela Martinez Ruiz

Hello

I want to know if the summary of the logistic model with survey
 Pr ( | t |) to test if the coefficient of the model is significant,
 ie is the p_valor wald test for the model coefficients,
 for I am interested to know if the three levels of the variable educational 
level are significant to the model (significance of handling 0.2), 
I present below the results of my model

 summary(mod.logis)

Call:
svyglm(formula = APES_DICOT ~ Nivel_Educativo + Ocupacion_principal + 
Afiliacion_salud + Tiene_cuidador + Presencia_enfer_cronica + 
Consumo_tabaco + Consumo_alcohol + Presencia_Dolor + Frec_dolor_cronico + 
Punt_min_mental + ABC_fis + ABC_instr + Anergia + 
Actividad_fisica_ultimo_año + 
Perdida_peso_no_intensionada + Lenta_velocidad_marcha + 
Disminucion_fuerza_agarre + 
Hospitalizacion_ultimo_año + Urgencias_ultimo_año + Miedo_caer, 
design = Muestra.comp, family = quasibinomial())

Survey design:
svydesign(id = ~b, strata = ~d, nest = TRUE, weights = ~c, data = am18, 
fpc = ~e)

Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept) -3.100841.85632  -1.670   0.1104
Nivel_EducativoNinguno/No recuerda   1.525560.88735   1.719   0.1010
Nivel_EducativoPrimaria  1.162560.64404   1.805   0.0861 .  
Nivel_EducativoSecundaria0.557711.04909   0.532   0.6009

Thanks
[[alternative HTML version deleted]]

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


[R] ggplot does not show in knitr

2012-08-02 Thread firdaus.janoos
Hello,

I'm having some issues getting a ggplot figure to show up in the knitr
output, when placed in a loop.

Specifically, I have a loop inside a knitr chunk :

```{r fitting, warning=FALSE, fig.width=10, fig.height=10, fig.keep='high'}
for (t in 1:T)
{
  # do a regression of tgt.vals ~ predictors and compute coeffs and
fitted values (fit.vals / fit.adj.vals)

plot( x=tgt.vals, y=fit.vals );
plot( x=tgt.vals, y = fit.adj.vals );

qplot( x = pred.names, y = coeffs);

}

```

The html output file shows the output of first 2 plot commands but not that
of the qplot command. Even if i remove the 2 plots and keep only the qplot
in the loop, it does not display in the html output.
The qplot just by itself, not in a loop, displays fine. Also, there are no
issues when I run in regular R.

Any suggestions of what is going on ?

[[alternative HTML version deleted]]

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


[R] Need Help in Finite Element Analysis

2012-08-02 Thread Abdul
Hi everybody
I need help to solve the following problem in finite element 
A field variable f(x,y)=xᵌ y  is defined over a rectangle domain 
Ω={K: 0≤x≥4 , 0≤y≥6” Given the expression
g=∬_(0   0)^(6   4)▒〖X^3  Y dx dy〗
And assume the following bilinear interpolation shape functions are used to
discretize the spatial geometric variable x and y:
N1= ¼ (1-z)(1-e)
N1= ¼ (1+z)(1-e)
N1= ¼ (1+z)(1+e)
N1= ¼ (1-z)(1+e)

Where -1 ≤ z ,  e ≤ 1  for the local coordinates, z  e
Determine the value of g using Guass quadrature numerical integration
method.
Explain any similarity or difference between your answer and the exact
solution. 

Please advise 

Thanks to all





--
View this message in context: 
http://r.789695.n4.nabble.com/Need-Help-in-Finite-Element-Analysis-tp4638943.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Cannot install the 'igraph' package

2012-08-02 Thread Prof Brian Ripley

On 02/08/2012 18:06, K. Elo wrote:

Hi!

On Thu, 2 Aug 2012, Uwe Ligges wrote:

R.h should be part if your R installation, given the output above
probably in /usr/lib64/R/include ?


But there is no such file R.h in my system???

~$ locate \/R.h
~$

Or with 'find':

# find / -name R.h
#

Any ideas?


You may bave a micro-packaged distribution (some form of SuSE as I 
recall): is there a separate R-devel RPM?  (Fedora had one an one time.)


Otherwise you need to talk to your distribution provider: as R said it 
*should* be there.



Kind regards,
Kimmo

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Need Help in Finite Element Analysis

2012-08-02 Thread Sarah Goslee
Abdul, this list is not for answering your homework questions.

On Thu, Aug 2, 2012 at 4:23 PM, Abdul abdul_fata...@yahoo.ca wrote:
 Hi everybody
 I need help to solve the following problem in finite element
 A field variable f(x,y)=xᵌ y  is defined over a rectangle domain
 Ω={K: 0≤x≥4 , 0≤y≥6” Given the expression
 g=∬_(0   0)^(6   4)▒〖X^3  Y dx dy〗
 And assume the following bilinear interpolation shape functions are used to
 discretize the spatial geometric variable x and y:
 N1= ¼ (1-z)(1-e)
 N1= ¼ (1+z)(1-e)
 N1= ¼ (1+z)(1+e)
 N1= ¼ (1-z)(1+e)

 Where -1 ≤ z ,  e ≤ 1  for the local coordinates, z  e
 Determine the value of g using Guass quadrature numerical integration
 method.
 Explain any similarity or difference between your answer and the exact
 solution.

 Please advise

 Thanks to all




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

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


Re: [R] ggplot does not show in knitr

2012-08-02 Thread Michael Weylandt
You need to explicitly print() the graphs to make them show -- or in recent 
ggplot2 versions I think you can also use plot() as an alias. 

Michael

On Aug 2, 2012, at 2:37 PM, firdaus.janoos fjan...@bwh.harvard.edu wrote:

 Hello,
 
 I'm having some issues getting a ggplot figure to show up in the knitr
 output, when placed in a loop.
 
 Specifically, I have a loop inside a knitr chunk :
 
 ```{r fitting, warning=FALSE, fig.width=10, fig.height=10, fig.keep='high'}
 for (t in 1:T)
 {
  # do a regression of tgt.vals ~ predictors and compute coeffs and
 fitted values (fit.vals / fit.adj.vals)
 
plot( x=tgt.vals, y=fit.vals );
plot( x=tgt.vals, y = fit.adj.vals );
 
qplot( x = pred.names, y = coeffs);
 
 }
 
 ```
 
 The html output file shows the output of first 2 plot commands but not that
 of the qplot command. Even if i remove the 2 plots and keep only the qplot
 in the loop, it does not display in the html output.
 The qplot just by itself, not in a loop, displays fine. Also, there are no
 issues when I run in regular R.
 
 Any suggestions of what is going on ?
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] parallel SNOW slower than single core?

2012-08-02 Thread Prof Brian Ripley

On 02/08/2012 19:13, Jie wrote:

Dear All,

I am learning parallel in R and start with the package snow. I did a test
about running time and the parallel version is much slower than the regulat
code. My laptop is X200s with dual core intel L9400 cpu.


The OS matters far more.  Overheads on Windows are much higher than on 
Linux for example.



Should I make more clusters than 2? Or how to improve the performance?


Not use such small tasks.  This is discussed in the 'parallel' vignette 
(and we do suggest you start with 'parallel' these days).



# install.packages(snow)
library(snow)
cl - makeCluster(2)
t1 - proc.time()
a - c()
for (i in 1:1000)
{
a[i] - sum(parSapply(cl, 1:15, get(+), 2))
}
proc.time()-t1
t2 - proc.time()


See ?system.time


a - c()
for (i in 1:1000)
{
a[i] - sum(sapply(1:15, +, 2))
}
proc.time()-t2




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Need Help in Finite Element Analysis

2012-08-02 Thread Michael Weylandt


On Aug 2, 2012, at 3:23 PM, Abdul abdul_fata...@yahoo.ca wrote:

 Hi everybody
 I need help to solve the following problem in finite element 
 A field variable f(x,y)=xᵌ y  is defined over a rectangle domain 
 Ω={K: 0≤x≥4 , 0≤y≥6” Given the expression
 g=∬_(0   0)^(6   4)▒〖X^3  Y dx dy〗
 And assume the following bilinear interpolation shape functions are used to
 discretize the spatial geometric variable x and y:
 N1= ¼ (1-z)(1-e)
 N1= ¼ (1+z)(1-e)
 N1= ¼ (1+z)(1+e)
 N1= ¼ (1-z)(1+e)
 
 Where -1 ≤ z ,  e ≤ 1  for the local coordinates, z  e
Determine the value of g using Guass quadrature numerical integration
 method.
Explain any similarity or difference between your answer and the exact
 solution. 
 

My apologies but there's a no homework policy on this list -- good luck!

Michael


 Please advise 
 
 Thanks to all
 
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Need-Help-in-Finite-Element-Analysis-tp4638943.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Need Help in Finite Element Analysis

2012-08-02 Thread Bert Gunter
On Thu, Aug 2, 2012 at 1:23 PM, Abdul abdul_fata...@yahoo.ca wrote:
 Hi everybody
 I need help to solve the following problem in finite element

We don't do homework on this list. Especially homework that has
essentially nothing to do with R.

-- Bert

 A field variable f(x,y)=xᵌ y  is defined over a rectangle domain
 Ω={K: 0≤x≥4 , 0≤y≥6” Given the expression
 g=∬_(0   0)^(6   4)▒〖X^3  Y dx dy〗
 And assume the following bilinear interpolation shape functions are used to
 discretize the spatial geometric variable x and y:
 N1= ¼ (1-z)(1-e)
 N1= ¼ (1+z)(1-e)
 N1= ¼ (1+z)(1+e)
 N1= ¼ (1-z)(1+e)

 Where -1 ≤ z ,  e ≤ 1  for the local coordinates, z  e
 Determine the value of g using Guass quadrature numerical integration
 method.
 Explain any similarity or difference between your answer and the exact
 solution.

 Please advise

 Thanks to all





 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Need-Help-in-Finite-Element-Analysis-tp4638943.html
 Sent from the R help mailing list archive at Nabble.com.

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ggplot does not show in knitr

2012-08-02 Thread firdaus.janoos
Could you elaborate on this ? Where would the print /plot statement go ?

On Thu, Aug 2, 2012 at 4:38 PM, Michael Weylandt michael.weyla...@gmail.com
 wrote:

 You need to explicitly print() the graphs to make them show -- or in
 recent ggplot2 versions I think you can also use plot() as an alias.

 Michael

 On Aug 2, 2012, at 2:37 PM, firdaus.janoos fjan...@bwh.harvard.edu
 wrote:

  Hello,
 
  I'm having some issues getting a ggplot figure to show up in the knitr
  output, when placed in a loop.
 
  Specifically, I have a loop inside a knitr chunk :
 
  ```{r fitting, warning=FALSE, fig.width=10, fig.height=10,
 fig.keep='high'}
  for (t in 1:T)
  {
   # do a regression of tgt.vals ~ predictors and compute coeffs and
  fitted values (fit.vals / fit.adj.vals)
 
 plot( x=tgt.vals, y=fit.vals );
 plot( x=tgt.vals, y = fit.adj.vals );
 
 qplot( x = pred.names, y = coeffs);
 
  }
 
  ```
 
  The html output file shows the output of first 2 plot commands but not
 that
  of the qplot command. Even if i remove the 2 plots and keep only the
 qplot
  in the loop, it does not display in the html output.
  The qplot just by itself, not in a loop, displays fine. Also, there are
 no
  issues when I run in regular R.
 
  Any suggestions of what is going on ?
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


Re: [R] summary(svyglm) Pr ( | t |) ?

2012-08-02 Thread John Fox
Dear Diana,

The Anova() function in the car package will produce a Wald test for each
term in a model fit by svyglm().

I hope this helps,
 John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Diana Marcela Martinez Ruiz
 Sent: August-02-12 4:14 PM
 To: Ayuda en R; tlum...@uw.edu
 Subject: [R] summary(svyglm) Pr ( | t |) ?
 
 
 Hello
 
 I want to know if the summary of the logistic model with survey  Pr ( | t
|) to
 test if the coefficient of the model is significant,  ie is the p_valor
wald test
 for the model coefficients,  for I am interested to know if the three
levels of
 the variable educational level are significant to the model (significance
of
 handling 0.2), I present below the results of my model
 
  summary(mod.logis)
 
 Call:
 svyglm(formula = APES_DICOT ~ Nivel_Educativo + Ocupacion_principal +
 Afiliacion_salud + Tiene_cuidador + Presencia_enfer_cronica +
 Consumo_tabaco + Consumo_alcohol + Presencia_Dolor +
 Frec_dolor_cronico +
 Punt_min_mental + ABC_fis + ABC_instr + Anergia +
 Actividad_fisica_ultimo_aqo +
 Perdida_peso_no_intensionada + Lenta_velocidad_marcha +
 Disminucion_fuerza_agarre +
 Hospitalizacion_ultimo_aqo + Urgencias_ultimo_aqo + Miedo_caer,
 design = Muestra.comp, family = quasibinomial())
 
 Survey design:
 svydesign(id = ~b, strata = ~d, nest = TRUE, weights = ~c, data = am18,
 fpc = ~e)
 
 Coefficients:
 Estimate Std. Error t value
Pr(|t|)
 (Intercept) -3.100841.85632  -1.670
0.1104
 Nivel_EducativoNinguno/No recuerda   1.525560.88735   1.719
0.1010
 Nivel_EducativoPrimaria  1.162560.64404   1.805
0.0861 .
 Nivel_EducativoSecundaria0.557711.04909   0.532
0.6009
 
 Thanks
   [[alternative HTML version deleted]]

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


  1   2   >