Re: [R] frequency table?

2011-12-05 Thread Jim Lemon

On 12/04/2011 08:21 PM, set wrote:

Hello R-users,

I've got a file with individuals as colums and the clusters where they occur
in as rows. And I wanted a table which tells me how many times each
individual occurs with another. I don't really know how such a table is
called...it is not a frequency tableMy eventual goal is to make
Venn-diagrams from the occurence of my individuals.

So I've this:

cluster   ind1 ind2 ind3 etc.
10  1 2
23   01
31   1 1

And I want to go to this:
 ind1  ind2  ind3
ind1  0  42
ind2  4  04
ind3  2   4   1

is there a way to do this?


Hi set,
Your example is a bit hard to figure out. In particular, individual 1 
seems to be in cluster 2 three times, and individual 3 in cluster 1 
twice. I could understand it if the top table looked like this:


cluster   ind1 ind2 ind3 ...
1011 ...
2101 ...
3111 ...

That tells me that individual 1 is in cluster 2 and 3 but not in cluster 
1, and so on. If you look at the first example in the intersectDiagram 
function in the plotrix package, you will see something similar, except 
that individuals are rows and common attributes (belonging to sets) are 
columns. You can get an intersection diagram from that showing how many 
individuals are in each combination of sets. This is similar to a Venn 
diagram, except that the population of each intersection is represented 
by the width of a rectangle and a text representation of that population.


Thinking about it, maybe you are trying to represent both types of 
individuals (that is, there exists more than one of individual type 1 
and so on) and attributes (belonging to clusters). In this case you are 
trying to get the intersections of two independent groups of sets.


So, I created a dataset in which individuals can have personal 
characteristics (sex, age) and scholastic characteristics (which 
subjects they study).


funnystuff-data.frame(math=sample(c(0,1),100,TRUE),
 biology=sample(c(0,1),100,TRUE),
 english=sample(c(0,1),100,TRUE),
 sex=sample(c(0,1),100,TRUE),
 over18=sample(c(0,1),100,TRUE))
library(plotrix)
intersectDiagram(funnystuff,main=Studies by sex and age,sep=\n)

This gives me an interesting diagram from which I can get various 
intersections of these two groups of attributes. Is this what you are 
seeking?


Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Spatstat - problem with which.marks and as.pp

2011-12-05 Thread karajamu

I forgot to change the header, so I guess no one read my mail. That's why I'm 
trying it again...


 
 
 Hello everbody,
 
 I am new to this mailing list and hope to find some help.
 I'm trying to get into the spatstat package and encountered two problems. 
 First a graphical one:
 There is an example dataset called finpines which has several marks 
 (http://www.oga-lab.net/RGM2/func.php?rd_id=spatstat:finpines)
 When I pass the given code from the website to R 
 
 
 
 data(finpines)
 
 plot(unmark(finpines), main=Finnish pines: locations)
 plot(finpines, which.marks=height, main=heights)
 
 plot(finpines, which.marks=diameter, main=diameters)
 I get the warning
 
 Warnmeldung:
 In symbols(c(-1.993875, -1.019901, -4.914071, -4.469962, -4.303847,  :
   which.marks ist kein Grafikparameter
 
 Something like which.marks is not a graphic parameter; and the plots for 
 height and diameter show now differences.
 
 Furthermore, I  want to create a ppp with several marks, but I did not figure 
 out how this works.
 Trying
 
 X - as.ppp(mydata, owin(c(174, 178), c(29, 33)))
 
 just gives the error
 
 Error in as.ppp(mydata, owin(c(174, 178), c(29, 33))) : 
   X must be a two-column or three-column data frame
 
 The data set looks something like
 
 Date   X   YMar1Mar2Mar3
 
 1.1.4   3 50   6  A
 2.1.2   1 40   9  A
 3.1.5   8 35   12B
 
 But how can I integrate two or more marks in a three-column data frame, when 
 two columns are already needed for the X and Y coordinates?
 
 I hope you can help me with this.
 
 Cheers
 sina
 
 
 
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
  
[[alternative HTML version deleted]]

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


[R] ANNOUNCEMENT: Call for Proposals for The R Series from Chapman Hall/CRC

2011-12-05 Thread Calver, Rob
Chapman  Hall/CRC: The R Series

 

We are delighted to announce that our new series of books on R is up and 
running, with two books already published and another nine forthcoming 
(including three set to publish in 2012). We are keen to receive proposals for 
books covering all aspects of the development and application of R software. If 
you have an idea for a book, please contact one of the series editors or one of 
the Chapman  Hall/CRC statistics acquisitions editors below. Please provide 
brief details of topic, audience, aims and scope, and include an outline if 
possible.

 

Aims and Scope

This book series reflects the recent rapid growth in the development and 
application of R, the programming language and software environment for 
statistical computing and graphics. R is now widely used in academic research, 
education, and industry. It is constantly growing, with new versions of the 
core software released regularly and more than 2,600 packages available. It is 
difficult for the documentation to keep pace with the expansion of the 
software, and this vital book series provides a forum for the publication of 
books covering many aspects of the development and application of R.

 

The scope of the series is wide, covering three main threads:

· Applications of R to specific disciplines such as biology, 
epidemiology, genetics, engineering, finance, and the social sciences.

· Using R for the study of topics of statistical methodology, such as 
linear and mixed modeling, time series, Bayesian methods, and missing data.

· The development of R, including programming, building packages, and 
graphics.

 

The books will appeal to programmers and developers of R software, as well as 
applied statisticians and data analysts in many fields. The books will feature 
detailed worked examples and R code fully integrated into the text, ensuring 
their usefulness to researchers, practitioners and students.

 

Series Editors

John M. Chambers (Department of Statistics, Stanford University, USA; 
j...@stat.stanford.edu)

Torsten Hothorn (Institut für Statistik, Ludwig-Maximilians-Universität, 
München, Germany; torsten.hoth...@stat.uni-muenchen.de)

Duncan Temple Lang (Department of Statistics, University of California, Davis, 
USA; dun...@wald.ucdavis.edu)

Hadley Wickham (Department of Statistics, Rice University, Houston, Texas, USA; 
had...@rice.edu)

 

Published Books

· R Graphics, Second Edition – Murrell

· Statistical Computing in C++ and R – Eubank  Kupresanin

 

Forthcoming Books

· Event History Analysis with R – Broström

· Programming Graphical User Interfaces in R – Verzani  Lawrence

· Customer  Business Analytics: Applied Data Mining for Business 
Decision Making Using R – Krider  Putler

· Measurement of Individual Stated Preferences Using R – Aizaki, 
Nakatani  Sato

· Starting Quantitative Analysis with R – Fruehwald

· Modeling of Longitudinal and Time-to-Event Data with Applications in 
R – Rizopoulos

· Nonparametric Statistical Methods Using R – Kloke  McKean

· Numerical Methods in Science and Engineering Using R – Bloomfield

· Extended Rasch Modeling in R: Theory and Practice – Maier, Mair  
Hatzinger

 

We look forward to hearing from you.

 

Best regards,

 

Rob Calver (rob.cal...@informa.com)

David Grubbs (david.gru...@taylorandfrancis.com)

John Kimmel (john.kim...@taylorandfrancis.com)






The information contained in this email message may be confidential. If you are 
not the intended recipient, any use, interference with, disclosure or copying 
of this material is unauthorised and prohibited. Although this message and any 
attachments are believed to be free of viruses, no responsibility is accepted 
by Informa for any loss or damage arising in any way from receipt or use 
thereof.  Messages to and from the company are monitored for operational 
reasons and in accordance with lawful business practices. 
If you have received this message in error, please notify us by return and 
delete the message and any attachments.  Further enquiries/returns can be sent 
to postmas...@informa.com

Taylor  Francis Group is a trading name of Informa UK Limited, registered in 
England under no. 1072954







The information contained in this email message may be confidential. If you are 
not the intended recipient, any use, interference with, disclosure or copying 
of this material is unauthorised and prohibited. Although this message and any 
attachments are believed to be free of viruses, no responsibility is accepted 
by Informa for any loss or damage 

Re: [R] [rggobi] ggplot like pdf output

2011-12-05 Thread S Ellison


 neither the *DescribeDisplay* package, nor *ggplot* are available in 2.13.2.

ggplot's package name is ggplot2. It certainly _was_ available for 2.13.2.

S***
This email and any attachments are confidential. Any use...{{dropped:8}}

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

2011-12-05 Thread bcdc
Hi,

I'm trying to assign iterative names to variable, but all my attempts have
failed. I have a loop, and for every iteration, I need to create a variable,
and I'd like to name them iteratively, such as:

for(i in 1:10)
{
   x_i - c(values)
}

I need it to return ten variables: x_1, x_2, ..., x_10

How can I do it?

Thank you very much!
Beatriz

--
View this message in context: 
http://r.789695.n4.nabble.com/iterative-variable-names-tp4159888p4159888.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] iterative variable names

2011-12-05 Thread Uwe Ligges



On 05.12.2011 11:00, bcdc wrote:

Hi,

I'm trying to assign iterative names to variable, but all my attempts have
failed. I have a loop, and for every iteration, I need to create a variable,
and I'd like to name them iteratively, such as:

for(i in 1:10)
{
x_i- c(values)
}



You actually want to create a list of objects that you return in the end.

Uwe Ligges



I need it to return ten variables: x_1, x_2, ..., x_10

How can I do it?

Thank you very much!
Beatriz

--
View this message in context: 
http://r.789695.n4.nabble.com/iterative-variable-names-tp4159888p4159888.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] iterative variable names

2011-12-05 Thread Jim Holtman
?assign

for (i in 1:10) assign(paste('x_', i, sep = ''), i)

but before you do this, consider using a 'list'; check the archives since this 
is asked a lot.
Sent from my iPad

On Dec 5, 2011, at 5:00, bcdc bia@gmail.com wrote:

 Hi,
 
 I'm trying to assign iterative names to variable, but all my attempts have
 failed. I have a loop, and for every iteration, I need to create a variable,
 and I'd like to name them iteratively, such as:
 
 for(i in 1:10)
 {
   x_i - c(values)
 }
 
 I need it to return ten variables: x_1, x_2, ..., x_10
 
 How can I do it?
 
 Thank you very much!
 Beatriz
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/iterative-variable-names-tp4159888p4159888.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] problems using the thin plate spline method

2011-12-05 Thread Mintewab Bezabih
Dear Sarah and R users, 

Sorry again for not being explicit enough. Here is my full problem


dat - read.table(E:/thin plate/thin plate.csv, header=T, sep=,)
dat
names(dat) - c(x1, x2, y)
library(fields)
plot (dat)

#load the fields package (containing Tps) and fit a thin plate spline
tpsfit - Tps(cbind(x1, x2), y, scale.type=unscaled)

What I meant when I said the graph works is when I do plot(dat) it does plot of 
all my three variables. If I do plot(x1,y), though, I get the 'object x1 not 
found' error message. 

Same when I do the next line tpsfit - Tps(cbind(x1, x2), y, 
scale.type=unscaled). I get the same error message. 

I tried your suggestion of checking str(x1) and I get the same error message 
(object x1 not found). 
I also typed ls() and I get dat after that command. 

I followed the r tutorial guide to read my data and I am following the r 
tutorial to guide me to apply the thin plate spline method. 

Regards, 

Mintewab

Från: Sarah Goslee [sarah.gos...@gmail.com]
Skickat: den 4 december 2011 15:21
Till: Mintewab Bezabih
Kopia: r-help@r-project.org
Ämne: Re: [R] problems using the thin plate spline method

Hello,

On Sun, Dec 4, 2011 at 8:08 AM, Mintewab Bezabih
mintewab.beza...@economics.gu.se wrote:
 Dear R users and Jeff,

 Sorry for not being quite explicit in my earlier message.

And you are still not explicit. We have no idea what you've done.

 My main problem is while my data seem to be read into R well (I manage to 
 graph them and all), I cannot get the following line to work.

 tpsfit - Tps(cbind(x1, x2), y, scale.type=unscaled)

 and I get the following error message

 Error in as.matrix(x) :
  error in evaluating the argument 'x' in selecting a method for function 
 'as.matrix': Error: object 'x1' not found

I'd have to guess that there's no object x1. What does ls() tell you? str(x1)?

What do your data look like? You were already given instructions on how to
include sample data to construct a reproducible example. You said that
graphing your data worked; how did you do so?

The posting guide and the advice you were already given were both
offered for a reason. The querent needs to do the work of formulating
an understandable and answerable question.

Sarah

 thanks for help
 minti
 
 Från: Jeff Newmiller [jdnew...@dcn.davis.ca.us]
 Skickat: den 3 december 2011 17:45
 Till: Mintewab Bezabih; r-help@r-project.org
 Ämne: Re: [R] problems using the thin plate spline method

 I can tell that you are puzzled and confused. Unfortunately, I am not 
 psychic, so I cannot tell what you did, and therefore cannot tell where you 
 went astray.

 The solution is for you to read the posting guide mentioned at the bottom of 
 every R-help message. Spend a little time to create a small bit of data like 
 yours if your actual data is large (subset and dput are useful for this). 
 Remember to include the output of sessionInfo, and so on. Many times you are 
 likely to find the answer yourself by going through these steps, but they are 
 essential for communication.

 Good luck.
 Sent from my phone. Please excuse my brevity.

 Mintewab Bezabih mintewab.beza...@economics.gu.se wrote:

Dear R users,

I am a beginner in R trying to apply the thin plate spline method to my
climate data. I used the example in R to do so, and the lines seem to
run fine ( I am not getting errors) but I am not getting any output in
the form of graph or anything. I got a warning message saying that
'surface extends beyond box'.

Any help is much appreciated.
thanks
minti


--
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] Data alignment

2011-12-05 Thread Petr PIKAL
 
 Re: [R] Data alignment
 
 Thanks for your suggestions. I will try them.
 
 The - in my original post was actually only there to serve as a 
separator
 so that it is easier for you to see the data structure but apparently it
 rather confused you... sorry :)

That is why dput is to be used. Try this by yourself

 dput(y)
structure(c(2L, 1L, 1L, NA, 2L, 1L, NA, NA, 2L, NA, NA, NA, NA, 
1L, NA, NA, NA, 2L, NA, 1L, NA, 2L, NA, 3L, NA), .Dim = c(5L, 
5L), .Dimnames = list(NULL, c(, BMW, Mercedes, VW, Skoda
)))

x-structure(c(2L, 1L, 1L, NA, 2L, 1L, NA, NA, 2L, NA, NA, NA, NA, 
1L, NA, NA, NA, 2L, NA, 1L, NA, 2L, NA, 3L, NA), .Dim = c(5L, 
5L), .Dimnames = list(NULL, c(, BMW, Mercedes, VW, Skoda
)))

 all.equal(x,y)
[1] TRUE


Regards
Petr




 
 --
 View this message in context: http://r.789695.n4.nabble.com/Data-
 alignment-tp4153024p4153112.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] problem merging data with different shapes

2011-12-05 Thread Petr PIKAL
Hi
 
 
 I have been trying to merge datasets, one of which has a long format 
 (Adata) and one has a (different) long format (Bdata):
 
 Adata  Bdata
 subject order bpm  subject order trial agegroup gender
 1 1   70.21  1 3   2   1
 1 1   69.51  2 1   2   1
 1 1   68.81  3 2   2   1 
 1 2   69.12  1 2   1   2
 1 270 2  2 3   1   2
 1 2   70.52  3 1   1   2
 1 3   70.2...
 1 3 
 1 3
 2 1 
 2 1 
 ...   ...
 
 In the end I would like to have a dataset that contains A unchanged with 

 the additional information from B added.
 
 subject order bpm trial agegroup gender
 1 1   70.2  3   2   1
 1 1   69.5  3   2   1 
 1 1   68.8  3   2   1 
 ... 
 I have tried:
 newdataframe - merge(Adata,Bdata, by= c(subject, order), sort = 
FALSE)

Hm it seems that it should work. Try

newdataframe - merge(Adata,Bdata, by= c(subject, order), all=TRUE)

Regards
Petr

 
 For some reason, the trial column is not matched to the subject and 
order 
 information, despite them being identified as key-variables for the 
merge.
 (The same is true for other variables, the actual dataset has more 
 variables and trials, but this is essentially the problem.)
 So it results in something like:
 subject order bpm trial agegroup gender
 1 1   70.2  3   2   1
 1 1   69.5  2   2   1 
 1 1   68.8  1   2   1 
 
 What could be my mistake?
 
 Thank you VERY much.
 Miriam
 
 
 -- 
 
 
 
 
 --
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Problem with parsing HTML table

2011-12-05 Thread Philipp Chapkovski
Hello!
Can anybody help to convert this table (in fact there are two adjacent
tables) into dataset?
http://www.khantu-mansy.vybory.izbirkom.ru/region/region/khantu-mansy?action=showroot=86214tvd=2862000216095vrn=100100028713299region=86global=truesub_region=86prver=0pronetvd=nullvibid=2862000216095type=233
with ReadHTMLTable it doesn't work at all :(

[[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] nipals in the chemometrics package in R

2011-12-05 Thread zz dd
Hello
The solution maybe there but i need to compute it into R if someone can
help me :
(Previously store score vector t in score matrix T; store loading vector p
in loading matrix P) that's done by nipals in chemometrics
After use of nipals function you have T and P matrix

First : Calculate the residual matrix of X. Stop if the elements of Xres
are very small
because no further PCA components are reasonable :
Xres= X-u.b(T)

u : improved score vector
b: loading vector
X : a mean-centered matrix

Second : Replace X with Xres and continue with step 2 (with nipals
chemometrics...) for calculation of the next PCA
component.

If someone can help me ?
Thank's a lot


2011/12/1 zz dd void1...@gmail.com

 Hello
 i need some precision about nipals in the chemometrics package in R .

 When i use nipals in chemometrics i obtain T and P matrix.

 I really don't understand what to do with these two matrix to obtain
 the scores for every the component (like in spss fo example)

 Comp1Comp2   Comp3
 quest1 0,8434  0,54333   0,3466
 quest2 0,665   0,7655  0,433

 Thank you very much for your help
 (I know that X=TP+E)... But don't understand else


[[alternative HTML version deleted]]

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


Re: [R] problems using the thin plate spline method

2011-12-05 Thread Jeff Newmiller
Try

plot( dat$x1, dat$y )

or

plot( x1, y, data=dat )

Note that your example is still not reproducible because you have not supplied 
the data or a shortened version of your data for us to work with. Also, your 
problem is not with thin plates but with plot, and reading the help for that 
function by typing

?plot

at the R command line would have provided you with more examples and usage info 
on how to get around this problem.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Mintewab Bezabih mintewab.beza...@economics.gu.se wrote:

Dear Sarah and R users, 

Sorry again for not being explicit enough. Here is my full problem


dat - read.table(E:/thin plate/thin plate.csv, header=T, sep=,)
dat
names(dat) - c(x1, x2, y)
library(fields)
plot (dat)

#load the fields package (containing Tps) and fit a thin plate spline
tpsfit - Tps(cbind(x1, x2), y, scale.type=unscaled)

What I meant when I said the graph works is when I do plot(dat) it does
plot of all my three variables. If I do plot(x1,y), though, I get the
'object x1 not found' error message. 

Same when I do the next line tpsfit - Tps(cbind(x1, x2), y,
scale.type=unscaled). I get the same error message. 

I tried your suggestion of checking str(x1) and I get the same error
message (object x1 not found). 
I also typed ls() and I get dat after that command. 

I followed the r tutorial guide to read my data and I am following the
r tutorial to guide me to apply the thin plate spline method. 

Regards, 

Mintewab

Från: Sarah Goslee [sarah.gos...@gmail.com]
Skickat: den 4 december 2011 15:21
Till: Mintewab Bezabih
Kopia: r-help@r-project.org
Ämne: Re: [R] problems using the thin plate spline method

Hello,

On Sun, Dec 4, 2011 at 8:08 AM, Mintewab Bezabih
mintewab.beza...@economics.gu.se wrote:
 Dear R users and Jeff,

 Sorry for not being quite explicit in my earlier message.

And you are still not explicit. We have no idea what you've done.

 My main problem is while my data seem to be read into R well (I
manage to graph them and all), I cannot get the following line to work.

 tpsfit - Tps(cbind(x1, x2), y, scale.type=unscaled)

 and I get the following error message

 Error in as.matrix(x) :
  error in evaluating the argument 'x' in selecting a method for
function 'as.matrix': Error: object 'x1' not found

I'd have to guess that there's no object x1. What does ls() tell you?
str(x1)?

What do your data look like? You were already given instructions on how
to
include sample data to construct a reproducible example. You said that
graphing your data worked; how did you do so?

The posting guide and the advice you were already given were both
offered for a reason. The querent needs to do the work of formulating
an understandable and answerable question.

Sarah

 thanks for help
 minti
 
 Från: Jeff Newmiller [jdnew...@dcn.davis.ca.us]
 Skickat: den 3 december 2011 17:45
 Till: Mintewab Bezabih; r-help@r-project.org
 Ämne: Re: [R] problems using the thin plate spline method

 I can tell that you are puzzled and confused. Unfortunately, I am not
psychic, so I cannot tell what you did, and therefore cannot tell where
you went astray.

 The solution is for you to read the posting guide mentioned at the
bottom of every R-help message. Spend a little time to create a small
bit of data like yours if your actual data is large (subset and dput
are useful for this). Remember to include the output of sessionInfo,
and so on. Many times you are likely to find the answer yourself by
going through these steps, but they are essential for communication.

 Good luck.
 Sent from my phone. Please excuse my brevity.

 Mintewab Bezabih mintewab.beza...@economics.gu.se wrote:

Dear R users,

I am a beginner in R trying to apply the thin plate spline method to
my
climate data. I used the example in R to do so, and the lines seem to
run fine ( I am not getting errors) but I am not getting any output
in
the form of graph or anything. I got a warning message saying that
'surface extends beyond box'.

Any help is much appreciated.
thanks
minti


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


[R] Subsetting a data frame

2011-12-05 Thread natalie.vanzuydam
Hi R users,

I really need help with subsetting  data frames:

I have a large database of medical records and I want to be able to match
patterns from a list of search terms .

I've used this simplified data frame in a previous example:


db - structure(list(ind = c(ind1, ind2, ind3, ind4), test1 = c(1, 
2, 1.3, 3), test2 = c(56L, 27L, 58L, 2L), test3 = c(1.1, 28, 
9, 1.2)), .Names = c(ind, test1, test2, test3), class =
data.frame, row.names = c(NA, 
-4L)) 

terms_include - c(1,2,3) 
terms_exclude - c(1.1,1.2,1.3) 


So in this example I want to include all the terms from terms include as
long as they don't occur with terms exclude in the same row of the data
frame.

Previously I was given this function which works very well if you want to
match exactly:


f - function(x)  !any(x %in% terms_exclude)  any(x %in% terms_include) 
db[apply(db[, -1], 1, f), ] 

   ind test1 test2 test3 
2 ind2 227  28.0 
4 ind4 3 2   1.2 


I would like to know if there is a way to write a similar function that
looks for matches that start with the query string:  as in
grepl(^pattern,x)  

I started writing a function but am not sure how to get it to return the
dataframe or matrix:


for (i in 1:length(terms_include)){
db_new - apply(db,2, grepl,pattern=i)
}

Applying this function gives me:

db_new - structure(c(FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, 
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), .Dim = c(4L, 
4L), .Dimnames = list(NULL, c(ind, test1, test2, test3
)))

So the above is searching the pattern anywhere in the dataframe instead of
just at the beginning of the string.  

How would I incorporate look for terms to include but don't return the row
of the data frame if it also includes one of the terms to exclude while
using partial matching?

I hope that this makes sense.

Many thanks,
Natalie

-
Natalie Van Zuydam

PhD Student
University of Dundee
nvanzuy...@dundee.ac.uk
--
View this message in context: 
http://r.789695.n4.nabble.com/Subsetting-a-data-frame-tp4160127p4160127.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] nipals in the chemometrics package in R

2011-12-05 Thread Jeff Newmiller
This is not a homework help list.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

zz dd void1...@gmail.com wrote:

Hello
The solution maybe there but i need to compute it into R if someone can
help me :
(Previously store score vector t in score matrix T; store loading
vector p
in loading matrix P) that's done by nipals in chemometrics
After use of nipals function you have T and P matrix

First : Calculate the residual matrix of X. Stop if the elements of
Xres
are very small
because no further PCA components are reasonable :
Xres= X-u.b(T)

u : improved score vector
b: loading vector
X : a mean-centered matrix

Second : Replace X with Xres and continue with step 2 (with nipals
chemometrics...) for calculation of the next PCA
component.

If someone can help me ?
Thank's a lot


2011/12/1 zz dd void1...@gmail.com

 Hello
 i need some precision about nipals in the chemometrics package in R .

 When i use nipals in chemometrics i obtain T and P matrix.

 I really don't understand what to do with these two matrix to obtain
 the scores for every the component (like in spss fo example)

 Comp1Comp2   Comp3
 quest1 0,8434  0,54333   0,3466
 quest2 0,665   0,7655  0,433

 Thank you very much for your help
 (I know that X=TP+E)... But don't understand else


   [[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] problems using the thin plate spline method

2011-12-05 Thread Mintewab Bezabih
Dear Jeff and R users,

Thanks Jeff. 

Your first plot suggestion worked. And when I stick dat$x1, dat$x2,dat$y, 
tpsfit seems to work as well. But it gives me a new error message 

tpsfit - Tps(cbind(dat$x1, dat$x2), dat$y, scale.type=unscaled)

Warning message:
In gcv.Krig(out, nstep.cv = nstep.cv, verbose = verbose, cost = out$cost,  :
  Value of pure error estimate  is outside possible range

Then I get error messages for the subsequent lines as well.

I have now attached the data. And here is the full code I am trying to run. 


dat - read.table(E:/thin plate/thin plate.csv, header=T, sep=,)
names(dat) - c(x1, x2, y)
library(fields)
plot (dat)

#load the fields package (containing Tps) and fit a thin plate spline
tpsfit - Tps(cbind(dat$x1, dat$x2), dat$y, scale.type=unscaled)

#predict the thin plate spline on the fine grid and plot the fitting
ngrid - length(xf); grid - cbind(rep(xf, ngrid), rep(xf, rep(ngrid, ngrid)))
out.p1 - predict(tpsfit, grid)


persp(xf, xf, matrix(out.p1, ngrid, ngrid, byrow=F), theta=130, phi=20,
  expand=0.45, xlab=x1, ylab=x2, zlab=y, xlim=c(0,1), ylim=c(0,1),
  zlim=range(zf), ticktype=detailed, scale=F, main=gcv fitting)

Many thanks once again. 

regards
mintewab



Från: Jeff Newmiller [jdnew...@dcn.davis.ca.us]
Skickat: den 5 december 2011 12:39
Till: Mintewab Bezabih; Sarah Goslee
Kopia: r-help@r-project.org
Ämne: Re: [R] problems using the thin plate spline method

Try

plot( dat$x1, dat$y )

or

plot( x1, y, data=dat )

Note that your example is still not reproducible because you have not supplied 
the data or a shortened version of your data for us to work with. Also, your 
problem is not with thin plates but with plot, and reading the help for that 
function by typing

?plot

at the R command line would have provided you with more examples and usage info 
on how to get around this problem.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
---
Sent from my phone. Please excuse my brevity.

Mintewab Bezabih mintewab.beza...@economics.gu.se wrote:

Dear Sarah and R users,

Sorry again for not being explicit enough. Here is my full problem


dat - read.table(E:/thin plate/thin plate.csv, header=T, sep=,)
dat
names(dat) - c(x1, x2, y)
library(fields)
plot (dat)

#load the fields package (containing Tps) and fit a thin plate spline
tpsfit - Tps(cbind(x1, x2), y, scale.type=unscaled)

What I meant when I said the graph works is when I do plot(dat) it does
plot of all my three variables. If I do plot(x1,y), though, I get the
'object x1 not found' error message.

Same when I do the next line tpsfit - Tps(cbind(x1, x2), y,
scale.type=unscaled). I get the same error message.

I tried your suggestion of checking str(x1) and I get the same error
message (object x1 not found).
I also typed ls() and I get dat after that command.

I followed the r tutorial guide to read my data and I am following the
r tutorial to guide me to apply the thin plate spline method.

Regards,

Mintewab

Från: Sarah Goslee [sarah.gos...@gmail.com]
Skickat: den 4 december 2011 15:21
Till: Mintewab Bezabih
Kopia: r-help@r-project.org
Ämne: Re: [R] problems using the thin plate spline method

Hello,

On Sun, Dec 4, 2011 at 8:08 AM, Mintewab Bezabih
mintewab.beza...@economics.gu.se wrote:
 Dear R users and Jeff,

 Sorry for not being quite explicit in my earlier message.

And you are still not explicit. We have no idea what you've done.

 My main problem is while my data seem to be read into R well (I
manage to graph them and all), I cannot get the following line to work.

 tpsfit - Tps(cbind(x1, x2), y, scale.type=unscaled)

 and I get the following error message

 Error in as.matrix(x) :
  error in evaluating the argument 'x' in selecting a method for
function 'as.matrix': Error: object 'x1' not found

I'd have to guess that there's no object x1. What does ls() tell you?
str(x1)?

What do your data look like? You were already given instructions on how
to
include sample data to construct a reproducible example. You said that
graphing your data worked; how did you do so?

The posting guide and the advice you were already given were both
offered for a reason. The querent needs to do the work of formulating
an understandable and answerable question.

Sarah

 thanks for help
 minti
 
 Från: Jeff Newmiller [jdnew...@dcn.davis.ca.us]
 Skickat: den 3 december 2011 17:45
 Till: Mintewab Bezabih; r-help@r-project.org
 Ämne: Re: [R] problems using the thin plate spline 

[R] how to just download file on disk by the link

2011-12-05 Thread Philipp Chapkovski
Sorry for stupid question but is there any way to just download file (excel
file) from the url to the disk with a certain name?
Now it seems that I should open it (via read.xls) and then write it by
write.xls. But I am pretty sure it should be something much easier?

[[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] extract cov matrix in summary.rq and use as a matrix.

2011-12-05 Thread Julia Lira

Dear all,

I need to extract the covariance matrix of my quantile regression estimation to 
use in a test. My regression is:

qf2_1 - summary(rq(wb2 ~ apv2 + vol2, tau = phi2[1]), cov = TRUE)

I can extract the covaraince matrix by using: qf2_1 [3]. However, if I try to 
use it in the test, it does not work. I only need to transform qf2_1[3] in a 
matrix 3x3. I have already tried: matrix(qf2_1[3], nrow=3, ncol=3) but it also 
does not work. By using the latter, I find:
 [,1]  [,2]  [,3] 
[1,] Numeric,9 Numeric,9 Numeric,9
[2,] Numeric,9 Numeric,9 Numeric,9
[3,] Numeric,9 Numeric,9 Numeric,9

Is there any other way to do it?

Thanks a lot in advance!

All the best,

Julia






  
[[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] Toggle cASE

2011-12-05 Thread Eik Vettorazzi
Hi Antonio,
how about this:

txt2 - useRs may fly into JFK or laGuardia
chartr(a-zA-Z, A-Za-z, txt2)


Cheers.

Am 05.12.2011 08:11, schrieb Tonio:
 Hello R-help list,
  
 I am looking for way to toggle the case of the characters like a flip-flop; 
 that is from ''Hello'' to hELLO or vice versa.
  
 I know that there are a number of functions like casefold, tolower, toupper, 
 etc. but these functions change the case in an uniform way.
  
 Thanks in advance,
  
 Antonio Rivero Ostoic
  
  
  
  
 Antonio Rivero Ostoic
 PhD Student, Department of Leadership and Strategy
 From 1 Jul until 31 Dec 2011
 Tel.+61 3 8344 4300
 Fax +61 3 9347 6618
 Email   j...@sdu.dk
 Addr.   The University of Melbourne, Victoria 3010  Australia
 -
 UNIVERSITY OF SOUTHERN DENMARK
 Sdr. Stationsvej 28 · DK-4200   Slagelse · Denmark · Tel. +45 6550 1000 ·
 www.sdu.dk
 
   [[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

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 just download file on disk by the link

2011-12-05 Thread Gabor Grothendieck
On Mon, Dec 5, 2011 at 7:03 AM, Philipp Chapkovski chapkov...@gmail.com wrote:
 Sorry for stupid question but is there any way to just download file (excel
 file) from the url to the disk with a certain name?
 Now it seems that I should open it (via read.xls) and then write it by
 write.xls. But I am pretty sure it should be something much easier?


read.xls in the gdata package can take the url of an Excel file and
will read it into R.  (It transparently downloads it into a temporary
file and then reads it from there.)

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at 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] nipals in the chemometrics package in R

2011-12-05 Thread zz dd
Thank you for your brevity you don't have to say more things to show who
you are.
Else if you don't understand what we are talking about, you shouldn't  be
rude and insulting.
May be you are quite young please take time to read Nonaka and Takeuchi and
moreover Takanashi to uderstand the way to go from information to knowledge
to wisdom that's quite useful for IS / IT and should bring you a bit of
etiquette.
*I have a dream* *that one day this nation will rise up and live out the
true meaning of its creed : “We hold these truths to be self-evident : that
all men are created equal.”*

Have a nice day.

2011/12/5 Jeff Newmiller jdnew...@dcn.davis.ca.us

 This is not a homework help list.
 ---
 Jeff NewmillerThe .   .  Go Live...
 DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live
 Go...
  Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
 /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
 ---
 Sent from my phone. Please excuse my brevity.

 zz dd void1...@gmail.com wrote:

 Hello
 The solution maybe there but i need to compute it into R if someone can
 help me :
 (Previously store score vector t in score matrix T; store loading
 vector p
 in loading matrix P) that's done by nipals in chemometrics
 After use of nipals function you have T and P matrix
 
 First : Calculate the residual matrix of X. Stop if the elements of
 Xres
 are very small
 because no further PCA components are reasonable :
 Xres= X-u.b(T)
 
 u : improved score vector
 b: loading vector
 X : a mean-centered matrix
 
 Second : Replace X with Xres and continue with step 2 (with nipals
 chemometrics...) for calculation of the next PCA
 component.
 
 If someone can help me ?
 Thank's a lot
 
 
 2011/12/1 zz dd void1...@gmail.com
 
  Hello
  i need some precision about nipals in the chemometrics package in R .
 
  When i use nipals in chemometrics i obtain T and P matrix.
 
  I really don't understand what to do with these two matrix to obtain
  the scores for every the component (like in spss fo example)
 
  Comp1Comp2   Comp3
  quest1 0,8434  0,54333   0,3466
  quest2 0,665   0,7655  0,433
 
  Thank you very much for your help
  (I know that X=TP+E)... But don't understand else
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

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


[R] spatial analysis

2011-12-05 Thread Marianne.ZEYRINGER
Dear all,
 
I am a PhD student in energy modelling. I am completely stuck with the
following problem and would be very grateful for any kind of help.
I have cells and each cell is assigned a number. I would like to form
clusters of cells where the sum of the cell numbers in each cluster must
not exceed 250. One restriction is that only neighbouring cells can be
formed into clusters. In the end I would like to have a list with all
possible cell combinations.

Is it possible to do this with R If yes, I would very much appreciate
all possible hints how to solve it.

Thanks a lot in advance and kindest regards,
Marianne 

[[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] extract cov matrix in summary.rq and use as a matrix.

2011-12-05 Thread R. Michael Weylandt michael.weyla...@gmail.com
I'm not at my desk so this is untested, but I'm pretty sure double brackets 
will do the trick:

qf2_1[[3]]

M 

On Dec 5, 2011, at 7:14 AM, Julia Lira julia.l...@hotmail.co.uk wrote:

 
 Dear all,
 
 I need to extract the covariance matrix of my quantile regression estimation 
 to use in a test. My regression is:
 
 qf2_1 - summary(rq(wb2 ~ apv2 + vol2, tau = phi2[1]), cov = TRUE)
 
 I can extract the covaraince matrix by using: qf2_1 [3]. However, if I try to 
 use it in the test, it does not work. I only need to transform qf2_1[3] in a 
 matrix 3x3. I have already tried: matrix(qf2_1[3], nrow=3, ncol=3) but it 
 also does not work. By using the latter, I find:
 [,1]  [,2]  [,3] 
 [1,] Numeric,9 Numeric,9 Numeric,9
 [2,] Numeric,9 Numeric,9 Numeric,9
 [3,] Numeric,9 Numeric,9 Numeric,9
 
 Is there any other way to do it?
 
 Thanks a lot in advance!
 
 All the best,
 
 Julia
 
 
 
 
 
 
 
[[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] equating approximate values

2011-12-05 Thread R. Michael Weylandt michael.weyla...@gmail.com
Change which to which.min, but then you won't easily be able to get the 
corresponding x,y indices. Look at the arrayInd() function to translate the 
result to a particular x,y. 

Michael

On Dec 4, 2011, at 7:04 PM, vamshi999 vamshi...@gmail.com wrote:

 this is exactly what i wanted. 
 
 How to i select only the minimum value from this?. 
 
 thank you 
 
 
 
 
 My apologies: you need an abs() call as well:
 
 which(abs(outer(x, y, -))  threshold, arr.ind = TRUE)
 
 Michael
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/equating-approximate-values-tp4157551p4158691.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] problems using the thin plate spline method

2011-12-05 Thread R. Michael Weylandt michael.weyla...@gmail.com
Your data was scrubbed by the server. Use dput() to create a plain text 
representation of dat you can put in the body of the email. 

Michael

On Dec 5, 2011, at 6:54 AM, Mintewab Bezabih mintewab.beza...@economics.gu.se 
wrote:

 Dear Jeff and R users,
 
 Thanks Jeff. 
 
 Your first plot suggestion worked. And when I stick dat$x1, dat$x2,dat$y, 
 tpsfit seems to work as well. But it gives me a new error message 
 
 tpsfit - Tps(cbind(dat$x1, dat$x2), dat$y, scale.type=unscaled)
 
 Warning message:
 In gcv.Krig(out, nstep.cv = nstep.cv, verbose = verbose, cost = out$cost,  :
  Value of pure error estimate  is outside possible range
 
 Then I get error messages for the subsequent lines as well.
 
 I have now attached the data. And here is the full code I am trying to run. 
 
 
 dat - read.table(E:/thin plate/thin plate.csv, header=T, sep=,)
 names(dat) - c(x1, x2, y)
 library(fields)
 plot (dat)
 
 #load the fields package (containing Tps) and fit a thin plate spline
 tpsfit - Tps(cbind(dat$x1, dat$x2), dat$y, scale.type=unscaled)
 
 #predict the thin plate spline on the fine grid and plot the fitting
 ngrid - length(xf); grid - cbind(rep(xf, ngrid), rep(xf, rep(ngrid, ngrid)))
 out.p1 - predict(tpsfit, grid)
 
 
 persp(xf, xf, matrix(out.p1, ngrid, ngrid, byrow=F), theta=130, phi=20,
  expand=0.45, xlab=x1, ylab=x2, zlab=y, xlim=c(0,1), ylim=c(0,1),
  zlim=range(zf), ticktype=detailed, scale=F, main=gcv fitting)
 
 Many thanks once again. 
 
 regards
 mintewab
 
 
 
 Från: Jeff Newmiller [jdnew...@dcn.davis.ca.us]
 Skickat: den 5 december 2011 12:39
 Till: Mintewab Bezabih; Sarah Goslee
 Kopia: r-help@r-project.org
 Ämne: Re: [R] problems using the thin plate spline method
 
 Try
 
 plot( dat$x1, dat$y )
 
 or
 
 plot( x1, y, data=dat )
 
 Note that your example is still not reproducible because you have not 
 supplied the data or a shortened version of your data for us to work with. 
 Also, your problem is not with thin plates but with plot, and reading the 
 help for that function by typing
 
 ?plot
 
 at the R command line would have provided you with more examples and usage 
 info on how to get around this problem.
 ---
 Jeff NewmillerThe .   .  Go Live...
 DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
 /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
 ---
 Sent from my phone. Please excuse my brevity.
 
 Mintewab Bezabih mintewab.beza...@economics.gu.se wrote:
 
 Dear Sarah and R users,
 
 Sorry again for not being explicit enough. Here is my full problem
 
 
 dat - read.table(E:/thin plate/thin plate.csv, header=T, sep=,)
 dat
 names(dat) - c(x1, x2, y)
 library(fields)
 plot (dat)
 
 #load the fields package (containing Tps) and fit a thin plate spline
 tpsfit - Tps(cbind(x1, x2), y, scale.type=unscaled)
 
 What I meant when I said the graph works is when I do plot(dat) it does
 plot of all my three variables. If I do plot(x1,y), though, I get the
 'object x1 not found' error message.
 
 Same when I do the next line tpsfit - Tps(cbind(x1, x2), y,
 scale.type=unscaled). I get the same error message.
 
 I tried your suggestion of checking str(x1) and I get the same error
 message (object x1 not found).
 I also typed ls() and I get dat after that command.
 
 I followed the r tutorial guide to read my data and I am following the
 r tutorial to guide me to apply the thin plate spline method.
 
 Regards,
 
 Mintewab
 
 Från: Sarah Goslee [sarah.gos...@gmail.com]
 Skickat: den 4 december 2011 15:21
 Till: Mintewab Bezabih
 Kopia: r-help@r-project.org
 Ämne: Re: [R] problems using the thin plate spline method
 
 Hello,
 
 On Sun, Dec 4, 2011 at 8:08 AM, Mintewab Bezabih
 mintewab.beza...@economics.gu.se wrote:
 Dear R users and Jeff,
 
 Sorry for not being quite explicit in my earlier message.
 
 And you are still not explicit. We have no idea what you've done.
 
 My main problem is while my data seem to be read into R well (I
 manage to graph them and all), I cannot get the following line to work.
 
 tpsfit - Tps(cbind(x1, x2), y, scale.type=unscaled)
 
 and I get the following error message
 
 Error in as.matrix(x) :
 error in evaluating the argument 'x' in selecting a method for
 function 'as.matrix': Error: object 'x1' not found
 
 I'd have to guess that there's no object x1. What does ls() tell you?
 str(x1)?
 
 What do your data look like? You were already given instructions on how
 to
 include sample data to construct a reproducible example. You said that
 graphing your data worked; how did you do so?
 
 The posting guide and the advice you were already given were both
 

Re: [R] Subsetting a data frame

2011-12-05 Thread jim holtman
does this do what you want:

 db - structure(list(ind = c(ind1, ind2, ind3, ind4), test1 = c(1,
+ 2, 1.3, 3), test2 = c(56L, 27L, 58L, 2L), test3 = c(1.1, 28,
+ 9, 1.2)), .Names = c(ind, test1, test2, test3), class =
+ data.frame, row.names = c(NA,
+ -4L))

 terms_include - c(1,2,3)
 terms_exclude - c(1.1,1.2,1.3)

 f.match - function(obj, inc, exc){
+ pat - paste(^(, paste(inc, collapse = |), ), sep = '')
+ patex - paste(exc, collapse = |)
+ isMatch - apply(obj, 1, function(x) any(grepl(pat, x)))
+ notMatch - !apply(obj, 1, function(x) any(grepl(patex, x)))
+ obj[isMatch  notMatch,]
+ }

 db
   ind test1 test2 test3
1 ind1   1.056   1.1
2 ind2   2.027  28.0
3 ind3   1.358   9.0
4 ind4   3.0 2   1.2
 f.match(db, terms_include, terms_exclude)
   ind test1 test2 test3
2 ind2 22728


On Mon, Dec 5, 2011 at 6:32 AM, natalie.vanzuydam nvanzuy...@gmail.com wrote:
 Hi R users,

 I really need help with subsetting  data frames:

 I have a large database of medical records and I want to be able to match
 patterns from a list of search terms .

 I've used this simplified data frame in a previous example:


 db - structure(list(ind = c(ind1, ind2, ind3, ind4), test1 = c(1,
 2, 1.3, 3), test2 = c(56L, 27L, 58L, 2L), test3 = c(1.1, 28,
 9, 1.2)), .Names = c(ind, test1, test2, test3), class =
 data.frame, row.names = c(NA,
 -4L))

 terms_include - c(1,2,3)
 terms_exclude - c(1.1,1.2,1.3)


 So in this example I want to include all the terms from terms include as
 long as they don't occur with terms exclude in the same row of the data
 frame.

 Previously I was given this function which works very well if you want to
 match exactly:


 f - function(x)  !any(x %in% terms_exclude)  any(x %in% terms_include)
 db[apply(db[, -1], 1, f), ]

   ind test1 test2 test3
 2 ind2     2    27  28.0
 4 ind4     3     2   1.2


 I would like to know if there is a way to write a similar function that
 looks for matches that start with the query string:  as in
 grepl(^pattern,x)

 I started writing a function but am not sure how to get it to return the
 dataframe or matrix:


 for (i in 1:length(terms_include)){
 db_new - apply(db,2, grepl,pattern=i)
 }

 Applying this function gives me:

 db_new - structure(c(FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE,
 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), .Dim = c(4L,
 4L), .Dimnames = list(NULL, c(ind, test1, test2, test3
 )))

 So the above is searching the pattern anywhere in the dataframe instead of
 just at the beginning of the string.

 How would I incorporate look for terms to include but don't return the row
 of the data frame if it also includes one of the terms to exclude while
 using partial matching?

 I hope that this makes sense.

 Many thanks,
 Natalie

 -
 Natalie Van Zuydam

 PhD Student
 University of Dundee
 nvanzuy...@dundee.ac.uk
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Subsetting-a-data-frame-tp4160127p4160127.html
 Sent from the R help mailing list archive at Nabble.com.

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



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

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


Re: [R] iterative variable names

2011-12-05 Thread bcdc
Thank you very much, assign was exactly what I needed! For my case, it worked
better than list! :)

Beatriz

--
View this message in context: 
http://r.789695.n4.nabble.com/iterative-variable-names-tp4159888p4160262.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] Dynamic Linear Models for Times Series - Implemented?

2011-12-05 Thread Amsalu Walelign
Dear sir,
As far as my understanding goes, the book “dynamic linear models with
R” does everything based up on the non innovations form.
The problem is that I couldn’t find auxiliary residuals, which can be
used to check for the presence of outliers and structural breaks. R
packages “dlm” and “dlmodeler” use this form of model construction.
Hence I am stuck in the middle of my work.
Is there some R package which performs disturbance smoothing, or use
the innovations form?
Thanks beforehand!
Amsaya

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


Re: [R] Partitioning Around Mediods then rpart to follow

2011-12-05 Thread Terry Therneau
Yes, that seems like a sensible idea to me.

Terry Therneau 
On Sat, 2011-12-03 at 12:00 +0100, r-help-requ...@r-project.org wrote:
 The problem:  There are no a priori groupings to run a classification
 on
 
 My solution:
 
 This is a non-R code question, so I appreciate any thoughts.  I have 
 used pam in the cluster package proceeded by sillohouette to find the 
 optimum number of clusters on scaled and centered data.  I have
 followed 
 this by a classification tree analysis with rpart to discern which 
 variables drive the clustering on the original data.  Is this a
 sensible 
 approach?
 many thanks,
 
 Stephen Sefick


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


Re: [R] problems using the thin plate spline method

2011-12-05 Thread Mintewab Bezabih
Thanks Michael

here is my data

structure(list(x1 = c(409.5, 349, 385.5, 273, 543, 746, 198.75,
262.5, 320.5, 259, 399.5, 595.5, 374, 293, 330, 658, 299, 775,
559.75, 251, 402, 395.5, 345.5, 283.5, 452, 816.5, 266.5, 360.25,
386, 160.25, 360, 337, 326, 758, 342.5, 389, 347.5, 819.25, 355.25,
281, 494.5, 514.5, 263, 439, 263, 373.25, 546, 348, 380.5, 606,
460, 352.5, 737, 275, 520.5, 385.25, 354.5, 383.5, 322.5, 309,
502.5, 517, 276, 400.5, 272.5, NA, 253, 311, 389, 157.75, 520,
499.5, 481, 448.5, 335.5, 231.5, 492.5, 477.5, 650, 540.75, 620.5,
400.5, 331.5, 311, 229, 432.5, 422.75, 493.5, 414.25, 487, 369,
425, 233.5, 254.5, 417.5, NA, 583.25, 492.5, 490, 300.25, NA,
270, 307, 319, 374.5, 562.5, 569.5, 389.75, 341.25, 366, 262.75,
776.25, 379.5, 360, 203.75, 517, 539.5, 418.75, 353.5, 269, 475.5,
472, 342, 189, 492.5, 412, 467.5, 209.75, 340.75, 231.5, 185.5,
358.5, 354, 670.5, 686, 364, 138, 272, 183, 365.25, 188, 229.5,
553.5, 582.5, 469, 359.5, 284.25, 582.5, 287, NA, 455.25, 410.5,
477, 239, 313.5, 294.5, 523, 372.5, 231.5, NA, 365, 269.5, 394.5,
281.5, 418.5, 553.5, 245.75, 304, 423.75, 369.5, 330.5, 278,
257, 416.5, 413.25, 465.5, 877.25, 204, 475, 289, 425.75, 405,
494.25, 332, 552.5, 433.75, 821, 841.5, 226.5, 266.75, 552, 157.5,
528.5, 248.5, 245.5, 303, 444.25, 310, 768.25, 265.5, 98.25,
525, 407.75, 163.5, 374.25, 749, 318.5, 367, 250, 408, 341.5,
266.5, 348.5, 398.5, 429.5, 420, 263.5, 581.5, 509.5, 724.75,
476.5, 249.5, 297.5, 245, 139.5, 360.5, 983.5, 465.5, 263.75,
NA, 510, 325, 122.5, 455.5, 531, 318, 373, 487, 401, 451.75,
561, 364.5, 439.5, 733.5, 455, 376.5, 554, 409.5, 1007.5, 462.5,
183, 342.5, 304, 258.25, 380.5, 373, 683, 577, 430, 324.25, 312,
389, 345, 358.5, 551.75, 317.5, 499, 335.5, 450.5, 363.5, 185,
177.5, 477.75, 644.5, 290.25, 457.5, 295.5, 266.5, 348.5, 357.75,
221.5, 739, 445.5, 416, 261.5, 909, 737.5, 194.5, 438.5, 358,
244, 388.5, 512.5, 315.25, 572, 473.75, 627.5, 507.75, 281, 511.5,
309.25, 308.25, 690, 180, 341.5, 273, 571, 694, 345, 497, 219,
311.5, 458.5, 283, 274, 282.5, 187.5, 332, 281.75, 397.75, 336.5,
392.5, 318, 609.5, 203.5, 144.5, 504.75, 647, 374, 149.5, 319,
306, 304.75, 304.5, 247, 329, 442, 308, 316, 219, 556.5, 643.5,
328.5, 301, 467, 452.5, 351.5, 373, 503.5, 287.5, 393.5, 444,
734, 458.5, 1182, 406, 286.5, 283.5, 642.5, 453.5, 206, 258,
412, 551, 784.75, 316.5, 326.5, 202.25, 336.75, 406, 225.5, 266,
916.5, 387, 496.25, 389, 668.5, 192, 396, 282.5, 414.5, 355,
294.5, 396.5, 348.75, 241.75, 347.5, 250, 473.5, 369, 672, 199.5,
318.25, 219.75, 124, 514.25, 600.5, 256, 574.75, 346.25, 397,
195, 494, 567.5, 431.5, 144.5, 440, 525.5, 375.5, 841.5, 386.25,
490.5, 296.5, 812.25, 385, 232.5, 239.25, 316.5, 312.25, 257.75,
NA, 389, 301.5, 242.25, 400.25, 367.25, 321.5, 301, 223, 360,
662.5, 407.5, 736, 379.5, 852, 355, 397, 527.5, 531.25, 473,
559.75, 344, 379.75, 459, 322, 208.5, 424.25, 342.25, 414.5,
308, 574.5, 635, 449.5, 286, 986.25, 563.5, 596, 492, 265, 826.5,
557, 387.5, 531.5, 464, 582, 354.5, 382.75, 833, 347.25, 615.25,
389, 354.25, 564, 890.5, 168, 467.25, 554.5, 296, 744.5, 387.25,
393.25, 331, 391, 274, 707.75, 467.5, 160.5, 569.5, 340.5, 259,
321.75, 286.25, 416.5, 459.25, 276.5, 280.25, 258.5, 309.5, 424.5,
365, 809, 238.75, 524, 563.5, 419, 354.5, 303, 167.5, 236.25,
268, 330.5, 251.5, 249, 443.5, 411.5, 323.5, 485.25, 356.5, 221.5,
515.5, 462, 322.5, 602.5, 446.25, 489.75, 396.5, NA, 222.5, 365.5,
386, 286, 448, 379.75, 293.5, 410, 335.5, 444.5, 464.75, 364.25,
360, 589, 546.5, 470, 304.5, NA, 501.5, 459.5, 715, 349, 285,
268, 507.5, 441.5, 188.5, 186.5, 679, 249, 200, 419.5, 294.25,
596, 395.75, 314.75, 412.5, 363.75, 218.5, 208.5, 535.5, 309.75,
336, 217, 245.5, 608.75, 375, 555.5, 621, 488.5, 271.5, 331.5,
286, 555, 345, 529.5, 370, 584.25, 208.5, 473.5, 244, 296.25,
598, 456.25, 371, 505.5, 269.5, 284, 420.75, 358.25, 476.75,
363, 485.75, 570, 567.25, 355.5, 444, 629, 367.5, 174.5, 217,
239, 378.5, 179.5, 188, 355, 304.5, 354.5, 207.5, 615, 163.5,
374, 316.5, 79, 409, 218.25, 452, 398, 277.5, 289.25, 491, 515
), x2 = c(673, 335, 1737, 457, 2325, 1255, 388, 104, 786, 516,
542, 916, 1257, 229, 490, 1016, 266, 1139, 1023, 153, 253, 319,
456, 400, 388, 941, 307, 683, 528, 368, 455, 488, 702, 1040,
405, 483, 524, 490, 517, 505, 844, 429, 349, 549, 450, 1212,
546, 485, 378, 598, 838, 519, 624, 185, 632, 696.5, 524, 618,
381, 380, 624, 612, 260, 831, 451, 284, 353, 720, 583, 344, 1175,
761, 694, 606, 239, 273, 394, 899, 721, 730, 1295, 1148, 524,
578, 262, 326, 217, 648, 485, 726, 747, 1663, 269, 488.5, 1137,
310, 434, 536, 486, 1225, 462, 237, 230, 242, 340, 521, 242,
389, 691, 387, 615, 1926, 597, 299, 213, 618, 684, 439, 459,
366, 1098, 384, 488, 181, 5342, 433, 1475, 480, 207, 153, 295,
524, 453, 978, 486, 676, 336, 254, 273, 255, 347, 420, 603, 739,
340, 572, 441, 833, 775, 129, 350, 1445, 328, 585, 412, 446,
679, 519, 372, 1712, 167, 492, 593, 210, 363, 630, 261, 869,
676, 253, 923, 791, 415, 349, 825, 486, 508, 191, 282, 267, 372,
639, 

Re: [R] Project local libraries (reproducible research)

2011-12-05 Thread Hadley Wickham
On Sat, Dec 3, 2011 at 11:16 AM, Jim Lemon j...@bitwrit.com.au wrote:
 On 12/03/2011 06:04 AM, Hadley Wickham wrote:

 Hi all,

 I was wondering if any one had scripts that they could share for
 capturing the current version of R packages used for a project. I'm
 interested in creating a project local library so that you're safe if
 someone (e.g. the ggplot2 author) updates a package you're relying on
 and breaks your code.   I could fairly easily hack together, but I was
 wondering if any one had any neat scripts they'd care to share.

 Hi Hadley,
 This makes quite a few assumptions, but I would build a list of packages
 called in R scripts:

 # get all calls to library or require in a subdirectory of scripts
 packagestrings-c(system(grep library *.R,intern=TRUE),
  system(grep require *.R,intern=TRUE))
 # get the unique package names
 packagenames-unique(sapply(strsplit(packagestrings,[()]),[,2))
 # get the information on all installed packages in the system
 installedpackages-installed.packages()
 # get the indices of the packages used in the subdirectory
 whichpackages-which(match(rownames(installedpackages),packagenames,0)0)
 # get the version information for each used package
 installedpackages[whichpackages,Built]

Thanks Jim.  I was thinking something more like:

rec - dir(file.path(Sys.getenv(R_HOME), library))

pkgs - search()[grepl(package:, search(), fixed = T)]
pkgs - gsub(package:, , pkgs, fixed = TRUE)
pkgs - setdiff(pkgs, rec)

i.e. work from the search path (once you've run your code).  Then the
next step would be find all dependencies of the packages, then copy
them into the current working directory, and give a line to set
.libPaths() correctly.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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


Re: [R] Persp3d freezes when run from within Python

2011-12-05 Thread Duncan Murdoch

On 11-12-04 8:57 PM, wchips wrote:

G'day everyone,

I've been trying to get an interactive OpenGL plot to work from within
Python 2.6 using Rpy2 and the persp3d function. The problem is that the plot
seems to freeze upon activation. All interactivity is lost even though it
works fine when run from within the R console (version 2.11.1). Is this a
known issue? Any ideas as to what might be causing this, or possibly how to
fix it?


Presumably your Python program or Rpy2 is not simulating the event 
handling that the real R console does.  Solution:  use the real R 
console, or fix the bug in your program or Rpy2.


Duncan Murdoch



cheers,
wchips

--
View this message in context: 
http://r.789695.n4.nabble.com/Persp3d-freezes-when-run-from-within-Python-tp4158940p4158940.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] extract cov matrix in summary.rq and use as a matrix.

2011-12-05 Thread R. Michael Weylandt michael.weyla...@gmail.com
No problem, almost all complicated objects that get returned are internally 
lists so you have to use [[ to get at them as [ will just give you a list 
again. Take a look at 

? '[[' # those should be back ticks

for the official documentation. 

Best,
M

On Dec 5, 2011, at 8:09 AM, Julia Lira julia.l...@hotmail.co.uk wrote:

 Dear Michael,
 
 Thank you very much for your suggestion.
 
 It indeed worked!
 
 All the best,
 
 Julia 
 
  CC: r-help@r-project.org
  From: michael.weyla...@gmail.com
  Subject: Re: [R] extract cov matrix in summary.rq and use as a matrix.
  Date: Mon, 5 Dec 2011 07:55:45 -0500
  To: julia.l...@hotmail.co.uk
  
  I'm not at my desk so this is untested, but I'm pretty sure double brackets 
  will do the trick:
  
  qf2_1[[3]]
  
  M 
  
  On Dec 5, 2011, at 7:14 AM, Julia Lira julia.l...@hotmail.co.uk wrote:
  
   
   Dear all,
   
   I need to extract the covariance matrix of my quantile regression 
   estimation to use in a test. My regression is:
   
   qf2_1 - summary(rq(wb2 ~ apv2 + vol2, tau = phi2[1]), cov = TRUE)
   
   I can extract the covaraince matrix by using: qf2_1 [3]. However, if I 
   try to use it in the test, it does not work. I only need to transform 
   qf2_1[3] in a matrix 3x3. I have already tried: matrix(qf2_1[3], nrow=3, 
   ncol=3) but it also does not work. By using the latter, I find:
   [,1] [,2] [,3] 
   [1,] Numeric,9 Numeric,9 Numeric,9
   [2,] Numeric,9 Numeric,9 Numeric,9
   [3,] Numeric,9 Numeric,9 Numeric,9
   
   Is there any other way to do it?
   
   Thanks a lot in advance!
   
   All the best,
   
   Julia
   
   
   
   
   
   
   
   [[alternative HTML version deleted]]
   
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide 
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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


Re: [R] about interpretation of anova results...

2011-12-05 Thread Roger Koenker
If you were to rtfm you'd see that your anova suggests that the slope 
coefficients
are the same for your tau = .15 and tau = .30 models.

url:www.econ.uiuc.edu/~rogerRoger Koenker
emailrkoen...@uiuc.eduDepartment of Economics
vox: 217-333-4558University of Illinois
fax:   217-244-6678Urbana, IL 61801

On Dec 5, 2011, at 1:18 AM, narendarreddy kalam wrote:

 quantreg package is used.
 *fit1 results are*
 Call:
 rq(formula = op ~ inp1 + inp2 + inp3 + inp4 + inp5 + inp6 + inp7 + 
inp8 + inp9, tau = 0.15, data = wbc)
 
 Coefficients:
 (Intercept) inp1 inp2 inp3 inp4
 inp5 
 -0.191528450  0.005276347  0.021414032  0.016034803  0.007510343 
 0.005276347 
inp6 inp7 inp8 inp9 
 0.058708544  0.005224906  0.006804871 -0.003931540 
 
 Degrees of freedom: 673 total; 663 residual
 *fit2 results are*
 Call:
 rq(formula = op ~ inp1 + inp2 + inp3 + inp4 + inp5 + inp6 + inp7 + 
inp8 + inp9, tau = 0.3, data = wbc)
 
 Coefficients:
  (Intercept)  inp1  inp2  inp3  inp4 
 -1.11e-01  5.776765e-19  4.635734e-18  1.874715e-18  2.099872e-18 
 inp5  inp6  inp7  inp8  inp9 
 -4.942052e-19  1.11e-01  2.205289e-18  4.138435e-18  9.300642e-19 
 
 Degrees of freedom: 673 total; 663 residual
 
 anova(fit1,fit2);
 Quantile Regression Analysis of Deviance Table
 
 Model: op ~ inp1 + inp2 + inp3 + inp4 + inp5 + inp6 + inp7 + inp8 + inp9
 Joint Test of Equality of Slopes: tau in {  0.15 0.3  }
 
  Df Resid Df F value Pr(F)
 1  9 1337  0.5256 0.8568
 Warning messages:
 1: In summary.rq(x, se = nid, covariance = TRUE) : 93 non-positive fis
 2: In summary.rq(x, se = nid, covariance = TRUE) : 138 non-positive fis
 how to interpret the above results??
 
 what is the use of anova function??
 will it give the best among fit1  fit2..
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/about-interpretation-of-anova-results-tp4159510p4159510.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.


[R] finding interpolated values along an empirical parametric curve

2011-12-05 Thread Michael Friendly
Given the following data, I am plotting log.det ~ norm.beta, where the 
points depend on a parameter, lambda

(but there is no functional form).
I want to find the (x,y) positions along this curve corresponding to two 
special values of lambda


lambda.HKB - 0.004275357
lambda.LW - 0.03229531

and draw reference lines at ~ -45 degrees (or normal to the curve) thru 
these points.

How can I do this?  A complete example is below

 pd
  lambda   log.det norm.beta
0.000  0.000 -12.92710  3.806801
0.005  0.005 -14.41144  2.819460
0.010  0.010 -15.41069  2.423197
0.020  0.020 -16.82581  2.010924
0.040  0.040 -18.69819  1.611304
0.080  0.080 -21.05065  1.283928


pd -
structure(list(lambda = c(0, 0.005, 0.01, 0.02, 0.04, 0.08),
log.det = c(-12.9270978142337, -14.411442487768, -15.4106886674014,
-16.8258120792945, -18.6981870228698, -21.050646106925),
norm.beta = c(3.8068008759562, 2.81945995964196, 2.42319655878575,
2.01092421747594, 1.6113040561427, 1.28392804825009)), .Names = 
c(lambda,

log.det, norm.beta), class = data.frame, row.names = c(0.000,
0.005, 0.010, 0.020, 0.040, 0.080))

clr - c(black, rainbow(5, start=.6, end=.1))
lambdaf - c(expression(~widehat(beta)^OLS), .005, .01, .02, 
.04, .08)

op - par(mar=c(4, 4, 1, 1) + 0.2, xpd=TRUE)
with(pd, {plot(norm.beta, log.det, type=b,
cex.lab=1.25, pch=16, cex=1.5, col=clr,
  xlab='shrinkage: ||b||',
ylab='variance: log |(Var(b)|)')
text(norm.beta, log.det, lambdaf, cex=1.25, pos=2)
text(min(norm.beta), max(log.det), Variance vs. Shrinkage, 
cex=1.5, pos=4)

})


# How to find the (x,y) positions for these values of lambda along the 
curve of log.det ~ norm.beta ?

lambda.HKB - 0.004275357
lambda.LW - 0.03229531

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [R] iterative variable names

2011-12-05 Thread S Ellison
 

 -Original Message-

 Thank you very much, assign was exactly what I needed! For my 
 case, it worked better than list! :)

If assign(paste('x_', i)) works better for your case than using a list or array 
, you must surely have a very strange case


S Ellison***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 interpolated values along an empirical parametric curve

2011-12-05 Thread John Fox
Hi Michael,

I can get what appears to be a good interpolation with a regression spline
in a multivariate LM, playing around with the tuning parameter to leave 1
residual df. Try this:

library(splines)
mod - lm(cbind(log.det, norm.beta) ~ bs(lambda, df=4), data=pd)
summary(mod)

x - data.frame(lambda=seq(min(pd$lambda), max(pd$lambda), length=100))
fit - predict(mod, newdata=x)
points(fit[, norm.beta], fit[, log.det], pch=16, cex=0.5)

x.2 - data.frame(lambda=c(lambda.HKB, lambda.LW))
fit.2 - predict(mod, x.2)
points(fit.2[, norm.beta], fit.2[, log.det], pch=15, col=green)

That doesn't solve the problem of calculating the normal, however.

I hope this helps,
 John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Michael Friendly
 Sent: December-05-11 9:16 AM
 To: R-help
 Subject: [R] finding interpolated values along an empirical parametric
 curve
 
 Given the following data, I am plotting log.det ~ norm.beta, where the
 points depend on a parameter, lambda (but there is no functional form).
 I want to find the (x,y) positions along this curve corresponding to
 two special values of lambda
 
 lambda.HKB - 0.004275357
 lambda.LW - 0.03229531
 
 and draw reference lines at ~ -45 degrees (or normal to the curve) thru
 these points.
 How can I do this?  A complete example is below
 
   pd
lambda   log.det norm.beta
 0.000  0.000 -12.92710  3.806801
 0.005  0.005 -14.41144  2.819460
 0.010  0.010 -15.41069  2.423197
 0.020  0.020 -16.82581  2.010924
 0.040  0.040 -18.69819  1.611304
 0.080  0.080 -21.05065  1.283928
  
 
 pd -
 structure(list(lambda = c(0, 0.005, 0.01, 0.02, 0.04, 0.08),
  log.det = c(-12.9270978142337, -14.411442487768, -
 15.4106886674014,
  -16.8258120792945, -18.6981870228698, -21.050646106925),
  norm.beta = c(3.8068008759562, 2.81945995964196, 2.42319655878575,
  2.01092421747594, 1.6113040561427, 1.28392804825009)), .Names =
 c(lambda, log.det, norm.beta), class = data.frame, row.names =
 c(0.000, 0.005, 0.010, 0.020, 0.040, 0.080))
 
 clr - c(black, rainbow(5, start=.6, end=.1)) lambdaf -
 c(expression(~widehat(beta)^OLS), .005, .01, .02, .04, .08)
 op - par(mar=c(4, 4, 1, 1) + 0.2, xpd=TRUE) with(pd, {plot(norm.beta,
 log.det, type=b,
  cex.lab=1.25, pch=16, cex=1.5, col=clr,
xlab='shrinkage: ||b||',
  ylab='variance: log |(Var(b)|)')
  text(norm.beta, log.det, lambdaf, cex=1.25, pos=2)
  text(min(norm.beta), max(log.det), Variance vs. Shrinkage,
 cex=1.5, pos=4)
  })
 
 
 # How to find the (x,y) positions for these values of lambda along the
 curve of log.det ~ norm.beta ?
 lambda.HKB - 0.004275357
 lambda.LW - 0.03229531
 
 --
 Michael Friendly Email: friendly AT yorku DOT ca
 Professor, Psychology Dept.
 York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
 4700 Keele StreetWeb:   http://www.datavis.ca
 Toronto, ONT  M3J 1P3 CANADA
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] R 2-14.0 locking up

2011-12-05 Thread Erin Hodgess
Dear R People:

I'm working with R-2.14.0 created from source on a quad core Windows 7 machine.

Starting yesterday, nearly everything I run just sits.  When I hit
escape or Ctrl C, nothing happens.

Has anyone run into this, please?

Any suggestions would be much appreciated.

Thanks,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@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] nipals in the chemometrics package in R

2011-12-05 Thread Pedro Mardones
Perhaps you can try the examples given in
http://www.jstatsoft.org/v18/i02 for getting a better idea about how
the NIPALS algorithm works. BTW, yes,it looks like a homework question
specially when your user name is zz dd void1...@gmail.com so you
can't be recognized.



On Mon, Dec 5, 2011 at 9:27 AM, zz dd void1...@gmail.com wrote:
 Thank you for your brevity you don't have to say more things to show who
 you are.
 Else if you don't understand what we are talking about, you shouldn't  be
 rude and insulting.
 May be you are quite young please take time to read Nonaka and Takeuchi and
 moreover Takanashi to uderstand the way to go from information to knowledge
 to wisdom that's quite useful for IS / IT and should bring you a bit of
 etiquette.
 *I have a dream* *that one day this nation will rise up and live out the
 true meaning of its creed : “We hold these truths to be self-evident : that
 all men are created equal.”*

 Have a nice day.

 2011/12/5 Jeff Newmiller jdnew...@dcn.davis.ca.us

 This is not a homework help list.
 ---
 Jeff Newmiller                        The     .       .  Go Live...
 DCN:jdnew...@dcn.davis.ca.us        Basics: ##.#.       ##.#.  Live
 Go...
                                      Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
 /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
 ---
 Sent from my phone. Please excuse my brevity.

 zz dd void1...@gmail.com wrote:

 Hello
 The solution maybe there but i need to compute it into R if someone can
 help me :
 (Previously store score vector t in score matrix T; store loading
 vector p
 in loading matrix P) that's done by nipals in chemometrics
 After use of nipals function you have T and P matrix
 
 First : Calculate the residual matrix of X. Stop if the elements of
 Xres
 are very small
 because no further PCA components are reasonable :
 Xres= X-u.b(T)
 
 u : improved score vector
 b: loading vector
 X : a mean-centered matrix
 
 Second : Replace X with Xres and continue with step 2 (with nipals
 chemometrics...) for calculation of the next PCA
 component.
 
 If someone can help me ?
 Thank's a lot
 
 
 2011/12/1 zz dd void1...@gmail.com
 
  Hello
  i need some precision about nipals in the chemometrics package in R .
 
  When i use nipals in chemometrics i obtain T and P matrix.
 
  I really don't understand what to do with these two matrix to obtain
  the scores for every the component (like in spss fo example)
 
              Comp1    Comp2   Comp3
  quest1 0,8434      0,54333   0,3466
  quest2 0,665       0,7655      0,433
 
  Thank you very much for your help
  (I know that X=TP+E)... But don't understand else
 
 
        [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



        [[alternative HTML version deleted]]


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


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

2011-12-05 Thread Steve Lianoglou
Hi,

On Mon, Dec 5, 2011 at 10:03 AM, Erin Hodgess erinm.hodg...@gmail.com wrote:
 Dear R People:

 I'm working with R-2.14.0 created from source on a quad core Windows 7 
 machine.

 Starting yesterday, nearly everything I run just sits.  When I hit
 escape or Ctrl C, nothing happens.

 Has anyone run into this, please?

 Any suggestions would be much appreciated.

Does this happen when you run R from the command line?
Are you loading something wonky from a stored workspace (ie, your
~/.RData file)?
Can you start R from terminal with the vanilla switch to see if its
something else, ie:

$ R  --vanilla

(where `$` is the command line prompt you typically see in a *nix
environment,  I'm not sure what the equivalent is in windows -- not
that it matters)

Does any of that work?

And out of curiosity, why did you compile R from source instead of
using the binaries? What were the configure args you used to compile?

-steve

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

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


Re: [R] similarity matrix

2011-12-05 Thread B77S
That really all depends on what you need; and I can't tell you what you need. 



set wrote
 
 I'm sorry, I made a mistake in my example. you're right. I don't really
 know how a similarity alogrithm worksbut I'm willing to try that...are
 there any good examples available?
 Thank you
 


--
View this message in context: 
http://r.789695.n4.nabble.com/similarity-matrix-tp4157576p4160902.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] equating approximate values

2011-12-05 Thread David Winsemius


On Dec 5, 2011, at 8:02 AM, R. Michael Weylandt wrote:

Change which to which.min, but then you won't easily be able to get  
the corresponding x,y indices. Look at the arrayInd() function to  
translate the result to a particular x,y.


The arrayInd help page is shared by the which help and which has an  
arr.ind=TRUE option that let's you encapsulate both steps:


which( abs(outer(x, y, -)) == min(abs(outer(x, y, -))),  
arr.ind=TRUE)




Michael

On Dec 4, 2011, at 7:04 PM, vamshi999 vamshi...@gmail.com wrote:


this is exactly what i wanted.

How to i select only the minimum value from this?.

thank you




My apologies: you need an abs() call as well:

which(abs(outer(x, y, -))  threshold, arr.ind = TRUE)

Michael




--
View this message in context: 
http://r.789695.n4.nabble.com/equating-approximate-values-tp4157551p4158691.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.


David Winsemius, MD
West Hartford, CT

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


[R] using StatEt IDE for Eclipse

2011-12-05 Thread Matteo Richiardi
Hi,
I'm trying to use StatEt IDE for Eclipse as my R editor, but I'm completely
lost. I've read all I could find online, made apparently all I had to do
(installing rj, configuraing StatEt, etc.) but still cannot make R running.
Below is the error log file.
Thank you so much for assistance.
Matteo






!ENTRY de.walware.statet.r.console.ui 1 0 2011-12-05 16:21:51.355
!MESSAGE Launching the R Console was cancelled, because it seems starting
the R engine failed.
Please make sure that R package 'rj' (1.0.0 or compatible) is installed and
that the R library paths are set correctly for the R environment
configuration 'R-2.14.0'.
!SESSION 2011-12-05 16:23:23.552
---
eclipse.buildId=M20110909-1335
java.version=1.6.0_21
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=it_IT
Command-line arguments:  -os win32 -ws win32 -arch x86_64

!ENTRY org.eclipse.osgi 2 1 2011-12-05 16:23:29.901
!MESSAGE NLS unused message: FindReplaceAction_label in:
de.walware.ecommons.ui.SharedMessages

!ENTRY org.eclipse.ui 4 4 2011-12-05 16:23:30.712
!MESSAGE Class load Failure:
'org.eclipse.ecf.docshare.menu.DocShareRosterMenuContributionItem'

!ENTRY org.eclipse.ui 4 0 2011-12-05 16:23:30.714
!MESSAGE Class load Failure:
'org.eclipse.ecf.docshare.menu.DocShareRosterMenuContributionItem'
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in de.walware.ecommons.ltk.ui
was unable to load class
org.eclipse.ecf.docshare.menu.DocShareRosterMenuContributionItem.
 at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.throwException(RegistryStrategyOSGI.java:194)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:176)
 at
org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:905)
at
org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
 at
org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at
org.eclipse.ui.internal.util.Util.safeLoadExecutableExtension(Util.java:879)
 at
org.eclipse.ui.internal.menus.DynamicMenuContributionItem.createContributionItem(DynamicMenuContributionItem.java:222)
at
org.eclipse.ui.internal.menus.DynamicMenuContributionItem.getContributionItem(DynamicMenuContributionItem.java:215)
 at
org.eclipse.ui.internal.menus.DynamicMenuContributionItem.fill(DynamicMenuContributionItem.java:195)
at org.eclipse.jface.action.MenuManager.doItemFill(MenuManager.java:741)
 at org.eclipse.jface.action.MenuManager.update(MenuManager.java:822)
at org.eclipse.jface.action.MenuManager.update(MenuManager.java:682)
 at
org.eclipse.ui.internal.menus.WorkbenchMenuService.updateManagers(WorkbenchMenuService.java:330)
at
org.eclipse.ui.internal.menus.WorkbenchMenuService$4.propertyChange(WorkbenchMenuService.java:316)
 at
org.eclipse.ui.internal.services.EvaluationAuthority$1.run(EvaluationAuthority.java:252)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
 at
org.eclipse.ui.internal.services.EvaluationAuthority.fireServiceChange(EvaluationAuthority.java:246)
at
org.eclipse.ui.internal.services.EvaluationAuthority.endSourceChange(EvaluationAuthority.java:197)
 at
org.eclipse.ui.internal.services.EvaluationAuthority.sourceChanged(EvaluationAuthority.java:135)
at
org.eclipse.ui.internal.services.ExpressionAuthority.sourceChanged(ExpressionAuthority.java:311)
 at
org.eclipse.ui.internal.services.ExpressionAuthority.sourceChanged(ExpressionAuthority.java:290)
at
org.eclipse.ui.AbstractSourceProvider.fireSourceChanged(AbstractSourceProvider.java:99)
 at
org.eclipse.ui.internal.services.WorkbenchSourceProvider.checkActivePart(WorkbenchSourceProvider.java:401)
at
org.eclipse.ui.internal.services.WorkbenchSourceProvider.checkActivePart(WorkbenchSourceProvider.java:300)
 at
org.eclipse.ui.internal.services.WorkbenchSourceProvider.handleCheck(WorkbenchSourceProvider.java:286)
at
org.eclipse.ui.internal.services.WorkbenchSourceProvider.checkOtherSources(WorkbenchSourceProvider.java:855)
 at
org.eclipse.ui.internal.services.WorkbenchSourceProvider$6.handleEvent(WorkbenchSourceProvider.java:839)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
 at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
 at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1058)
 at org.eclipse.swt.widgets.Decorations.WM_ACTIVATE(Decorations.java:1647)
at org.eclipse.swt.widgets.Shell.WM_ACTIVATE(Shell.java:2137)
 at org.eclipse.swt.widgets.Control.windowProc(Control.java:4525)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
 at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1610)
at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2061)
 

[R] barplot ignoring col parameter

2011-12-05 Thread Federico Calboli
Hi All,

I'm having a problem with barplot:

mydata
[1,]  2 108  0  0  0  1  3  0  0  0  0  0  7 18  3  4  8 20 26 20 19  7  1  1

mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2), rep('white', 5), 
rep('orange',3), rep('red',9))

barplot(mydata, col = mycol)

gives me an uniformly yellow barplot. How do I solve this?

bw

Federico 



--
Federico C. F. Calboli
Neuroepidemiology and Ageing Research
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] 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] nipals in the chemometrics package in R

2011-12-05 Thread zz dd
Thank's Pedro Madrones,
you're right that i have removed my name of the email (because of Spam, and
datas that i can't remove on the net).
Ok, i explain a bit more :

X is a centred matrix.
PCA summarise all variation of X into a few new variables called scores
T.These new variables are linearly weighted combinations
of the original X-variables.
The loadings P contain the weights used for each X variable and thus reveal
the influence of individual X-variables.
Is it ok ?

That's what give the nipals function of chemometrics package.

It's just that i don't understand how to use The T and P matrix to have the
component matrix.

i don't need explainations how to obtain P and T But in how to do E = X
– tp.
But maybe it's not there for this kind of questions, i am not from
chemometrics science.

***
Johannes E. S.



2011/12/5 Pedro Mardones mardone...@gmail.com

 Perhaps you can try the examples given in
 http://www.jstatsoft.org/v18/i02 for getting a better idea about how
 the NIPALS algorithm works. BTW, yes,it looks like a homework question
 specially when your user name is zz dd void1...@gmail.com so you
 can't be recognized.



 On Mon, Dec 5, 2011 at 9:27 AM, zz dd void1...@gmail.com wrote:
  Thank you for your brevity you don't have to say more things to show who
  you are.
  Else if you don't understand what we are talking about, you shouldn't  be
  rude and insulting.
  May be you are quite young please take time to read Nonaka and Takeuchi
 and
  moreover Takanashi to uderstand the way to go from information to
 knowledge
  to wisdom that's quite useful for IS / IT and should bring you a bit of
  etiquette.
  *I have a dream* *that one day this nation will rise up and live out the
  true meaning of its creed : “We hold these truths to be self-evident :
 that
  all men are created equal.”*
 
  Have a nice day.
 
  2011/12/5 Jeff Newmiller jdnew...@dcn.davis.ca.us
 
  This is not a homework help list.
 
 ---
  Jeff NewmillerThe .   .  Go
 Live...
  DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live
  Go...
   Live:   OO#.. Dead: OO#..  Playing
  Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
  /Software/Embedded Controllers)   .OO#.   .OO#.
  rocks...1k
 
 ---
  Sent from my phone. Please excuse my brevity.
 
  zz dd void1...@gmail.com wrote:
 
  Hello
  The solution maybe there but i need to compute it into R if someone can
  help me :
  (Previously store score vector t in score matrix T; store loading
  vector p
  in loading matrix P) that's done by nipals in chemometrics
  After use of nipals function you have T and P matrix
  
  First : Calculate the residual matrix of X. Stop if the elements of
  Xres
  are very small
  because no further PCA components are reasonable :
  Xres= X-u.b(T)
  
  u : improved score vector
  b: loading vector
  X : a mean-centered matrix
  
  Second : Replace X with Xres and continue with step 2 (with nipals
  chemometrics...) for calculation of the next PCA
  component.
  
  If someone can help me ?
  Thank's a lot
  
  
  2011/12/1 zz dd void1...@gmail.com
  
   Hello
   i need some precision about nipals in the chemometrics package in R .
  
   When i use nipals in chemometrics i obtain T and P matrix.
  
   I really don't understand what to do with these two matrix to obtain
   the scores for every the component (like in spss fo example)
  
   Comp1Comp2   Comp3
   quest1 0,8434  0,54333   0,3466
   quest2 0,665   0,7655  0,433
  
   Thank you very much for your help
   (I know that X=TP+E)... But don't understand else
  
  
 [[alternative HTML version deleted]]
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 [[alternative HTML version deleted]]
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


[[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] barplot ignoring col parameter

2011-12-05 Thread David Winsemius


On Dec 5, 2011, at 10:44 AM, Federico Calboli wrote:


Hi All,

I'm having a problem with barplot:

mydata
[1,]  2 108  0  0  0  1  3  0  0  0  0  0  7 18  3  4  8 20 26 20  
19  7  1  1


mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2),  
rep('white', 5), rep('orange',3), rep('red',9))


barplot(mydata, col = mycol)

gives me an uniformly yellow barplot. How do I solve this?


Hard to say, since it involves graphics devices and I cannot reproduce  
it.


 mydata - scan()
1:  2 108  0  0  0  1  3  0  0  0  0  0  7 18  3  4  8 20 26 20 19  7   
1  1

25:
Read 24 items
 barplot(mydata)
 ?barplot
 mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2),  
rep('white', 5), rep('orange',3), rep('red',9))


 barplot(mydata, col = mycol)

Gives a multicolored display on my machine:



Rplot.pdf
Description: Adobe PDF document




bw

Federico



--
Federico C. F. Calboli
Neuroepidemiology and Ageing Research
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] 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.


David Winsemius, MD
West Hartford, CT

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


Re: [R] barplot ignoring col parameter

2011-12-05 Thread R. Michael Weylandt
x - c(2L, 108L, 0L, 0L, 0L, 1L, 3L, 0L, 0L, 0L, 0L, 0L, 7L, 18L,
3L, 4L, 8L, 20L, 26L, 20L, 19L, 7L, 1L, 1L)
mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2),
rep('white', 5), rep('orange',3), rep('red',9))
barplot(x, col = mycol)

Produces a multi-colored barplot on my machine so I understand your
confusion. Does the above work for you? It may be something hidden in
your data.

What is your sessionInfo() and str(mydata)? Same problem in a fresh R
session (with --vanilla if necessary)?

Michael

On Mon, Dec 5, 2011 at 10:44 AM, Federico Calboli
f.calb...@imperial.ac.uk wrote:
 Hi All,

 I'm having a problem with barplot:

 mydata
 [1,]  2 108  0  0  0  1  3  0  0  0  0  0  7 18  3  4  8 20 26 20 19  7  1  1

 mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2), rep('white', 
 5), rep('orange',3), rep('red',9))

 barplot(mydata, col = mycol)

 gives me an uniformly yellow barplot. How do I solve this?

 bw

 Federico



 --
 Federico C. F. Calboli
 Neuroepidemiology and Ageing Research
 Imperial College, St. Mary's Campus
 Norfolk Place, London W2 1PG

 Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

 f.calboli [.a.t] imperial.ac.uk
 f.calboli [.a.t] gmail.com

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 interpolated values along an empirical parametric curve

2011-12-05 Thread Michael Friendly

Thanks, John
That's very clever.  I didn't realize that the splines package supports 
multivariate regression
splines and that works well enough for my purposes; plus this solution 
is very transparent.


best,
-Michael


On 12/5/2011 9:50 AM, John Fox wrote:

Hi Michael,

I can get what appears to be a good interpolation with a regression spline
in a multivariate LM, playing around with the tuning parameter to leave 1
residual df. Try this:

library(splines)
mod- lm(cbind(log.det, norm.beta) ~ bs(lambda, df=4), data=pd)
summary(mod)

x- data.frame(lambda=seq(min(pd$lambda), max(pd$lambda), length=100))
fit- predict(mod, newdata=x)
points(fit[, norm.beta], fit[, log.det], pch=16, cex=0.5)

x.2- data.frame(lambda=c(lambda.HKB, lambda.LW))
fit.2- predict(mod, x.2)
points(fit.2[, norm.beta], fit.2[, log.det], pch=15, col=green)

That doesn't solve the problem of calculating the normal, however.

I hope this helps,
  John


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of Michael Friendly
Sent: December-05-11 9:16 AM
To: R-help
Subject: [R] finding interpolated values along an empirical parametric
curve

Given the following data, I am plotting log.det ~ norm.beta, where the
points depend on a parameter, lambda (but there is no functional form).
I want to find the (x,y) positions along this curve corresponding to
two special values of lambda

lambda.HKB- 0.004275357
lambda.LW- 0.03229531

and draw reference lines at ~ -45 degrees (or normal to the curve) thru
these points.
How can I do this?  A complete example is below

pd
lambda   log.det norm.beta
0.000  0.000 -12.92710  3.806801
0.005  0.005 -14.41144  2.819460
0.010  0.010 -15.41069  2.423197
0.020  0.020 -16.82581  2.010924
0.040  0.040 -18.69819  1.611304
0.080  0.080 -21.05065  1.283928
  

pd-
structure(list(lambda = c(0, 0.005, 0.01, 0.02, 0.04, 0.08),
  log.det = c(-12.9270978142337, -14.411442487768, -
15.4106886674014,
  -16.8258120792945, -18.6981870228698, -21.050646106925),
  norm.beta = c(3.8068008759562, 2.81945995964196, 2.42319655878575,
  2.01092421747594, 1.6113040561427, 1.28392804825009)), .Names =
c(lambda, log.det, norm.beta), class = data.frame, row.names =
c(0.000, 0.005, 0.010, 0.020, 0.040, 0.080))

clr- c(black, rainbow(5, start=.6, end=.1)) lambdaf-
c(expression(~widehat(beta)^OLS), .005, .01, .02, .04, .08)
op- par(mar=c(4, 4, 1, 1) + 0.2, xpd=TRUE) with(pd, {plot(norm.beta,
log.det, type=b,
  cex.lab=1.25, pch=16, cex=1.5, col=clr,
xlab='shrinkage: ||b||',
  ylab='variance: log |(Var(b)|)')
  text(norm.beta, log.det, lambdaf, cex=1.25, pos=2)
  text(min(norm.beta), max(log.det), Variance vs. Shrinkage,
cex=1.5, pos=4)
  })


# How to find the (x,y) positions for these values of lambda along the
curve of log.det ~ norm.beta ?
lambda.HKB- 0.004275357
lambda.LW- 0.03229531

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [R] extract cov matrix in summary.rq and use as a matrix.

2011-12-05 Thread Julia Lira

Dear Michael,

Thank you very much for your suggestion.

It indeed worked!

All the best,

Julia 

 CC: r-help@r-project.org
 From: michael.weyla...@gmail.com
 Subject: Re: [R] extract cov matrix in summary.rq and use as a matrix.
 Date: Mon, 5 Dec 2011 07:55:45 -0500
 To: julia.l...@hotmail.co.uk
 
 I'm not at my desk so this is untested, but I'm pretty sure double brackets 
 will do the trick:
 
 qf2_1[[3]]
 
 M 
 
 On Dec 5, 2011, at 7:14 AM, Julia Lira julia.l...@hotmail.co.uk wrote:
 
  
  Dear all,
  
  I need to extract the covariance matrix of my quantile regression 
  estimation to use in a test. My regression is:
  
  qf2_1 - summary(rq(wb2 ~ apv2 + vol2, tau = phi2[1]), cov = TRUE)
  
  I can extract the covaraince matrix by using: qf2_1 [3]. However, if I try 
  to use it in the test, it does not work. I only need to transform qf2_1[3] 
  in a matrix 3x3. I have already tried: matrix(qf2_1[3], nrow=3, ncol=3) but 
  it also does not work. By using the latter, I find:
  [,1]  [,2]  [,3] 
  [1,] Numeric,9 Numeric,9 Numeric,9
  [2,] Numeric,9 Numeric,9 Numeric,9
  [3,] Numeric,9 Numeric,9 Numeric,9
  
  Is there any other way to do it?
  
  Thanks a lot in advance!
  
  All the best,
  
  Julia
  
  
  
  
  
  
  
 [[alternative HTML version deleted]]
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
  
[[alternative HTML version deleted]]

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


[R] Weighting and recodification

2011-12-05 Thread SilvaForever
I have a question that is more statistical than r-specific

I have to recode a variable into quartiles, and I have weighted individuals.
To calculate the quartiles that will serve me to recode the variable, should
I use the weight or not?

--
View this message in context: 
http://r.789695.n4.nabble.com/Weighting-and-recodification-tp4160876p4160876.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] Flexclust package: kcca object's methods and properties?

2011-12-05 Thread Pundurs, Mark
What are all the methods and properties for the flexclust package's kcca object?
Neither http://cran.r-project.org/web/packages/flexclust/flexclust.pdf nor
http://www.stat.uni-muenchen.de/~leisch/papers/Leisch-2006.pdf appear to include
a comprehensive centralized list.

Mark Pundurs
Data Analyst - Traffic
Nokia Location  Commerce

The information contained in this communication may be C...{{dropped:8}}

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


Re: [R] barplot ignoring col parameter

2011-12-05 Thread Federico Calboli

On 5 Dec 2011, at 15:58, R. Michael Weylandt wrote:

 x - c(2L, 108L, 0L, 0L, 0L, 1L, 3L, 0L, 0L, 0L, 0L, 0L, 7L, 18L,
 3L, 4L, 8L, 20L, 26L, 20L, 19L, 7L, 1L, 1L)
 mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2),
 rep('white', 5), rep('orange',3), rep('red',9))
 barplot(x, col = mycol)
 
 Produces a multi-colored barplot on my machine so I understand your
 confusion. Does the above work for you? It may be something hidden in
 your data.

It does work. Might it be that my data is a matrix? I'm using it to give a name 
for each bar.


 
 What is your sessionInfo() and str(mydata)? Same problem in a fresh R
 session (with --vanilla if necessary)?


sessionInfo()
R version 2.14.0 (2011-10-31)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] survival_2.36-10

loaded via a namespace (and not attached):
[1] tools_2.14.0


str(mydata)
num [1, 1:24] 2 108 0 0 0 1 3 0 0 0 ...
- attr(*, dimnames)=List of 2
 ..$ : NULL
 ..$ : chr [1:24] A B C D ...


Basically, using the 'x' object as you created the code works, and I can have a 
workaround. I fail to see why it would not work using mydata.

Cheers

F



 
 Michael
 
 On Mon, Dec 5, 2011 at 10:44 AM, Federico Calboli
 f.calb...@imperial.ac.uk wrote:
 Hi All,
 
 I'm having a problem with barplot:
 
 mydata
 [1,]  2 108  0  0  0  1  3  0  0  0  0  0  7 18  3  4  8 20 26 20 19  7  1  1
 
 mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2), rep('white', 
 5), rep('orange',3), rep('red',9))
 
 barplot(mydata, col = mycol)
 
 gives me an uniformly yellow barplot. How do I solve this?
 
 bw
 
 Federico
 
 
 
 --
 Federico C. F. Calboli
 Neuroepidemiology and Ageing Research
 Imperial College, St. Mary's Campus
 Norfolk Place, London W2 1PG
 
 Tel +44 (0)20 75941602   Fax +44 (0)20 75943193
 
 f.calboli [.a.t] imperial.ac.uk
 f.calboli [.a.t] 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.

--
Federico C. F. Calboli
Neuroepidemiology and Ageing Research
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] 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] Weighting and recodification

2011-12-05 Thread David Winsemius


On Dec 5, 2011, at 10:19 AM, SilvaForever wrote:


I have a question that is more statistical than r-specific

I have to recode a variable into quartiles, and I have weighted  
individuals.
To calculate the quartiles that will serve me to recode the  
variable, should

I use the weight or not?


I would think that an affirmative answer should raise the follow-on  
question of how, and an R-specific answer would be  `wtd.quantile`  
in the Hmisc package.


--

David Winsemius, MD
West Hartford, CT

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


Re: [R] barplot ignoring col parameter

2011-12-05 Thread R. Michael Weylandt
barplot() defaults to stacked bars for matrices and uses the colors
fresh for each bar: e.g.,

layout(1:2)
barplot(matrix(1:6, 2), col = c(red, blue,green))
barplot(matrix(1:6, 3), col = c(red, blue,green))

To get what you are looking for, try something like this:

x = matrix(1:6,1); colnames(x) = LETTERS[1:6]
barplot(as.vector(x), names.arg = colnames(x))

More generally, just turn the matrix into a vector

mat2vec - function(x){
stopifnot(any(dim(x) == 1L))
if(nrow(x) != 1L) x - t(x)
cn - colnames(x)
x - c(x)
names(x) - cn
return(x)
}

and barplot that.

Hope this helps,

Michael

On Mon, Dec 5, 2011 at 11:41 AM, Federico Calboli
f.calb...@imperial.ac.uk wrote:

 On 5 Dec 2011, at 15:58, R. Michael Weylandt wrote:

 x - c(2L, 108L, 0L, 0L, 0L, 1L, 3L, 0L, 0L, 0L, 0L, 0L, 7L, 18L,
 3L, 4L, 8L, 20L, 26L, 20L, 19L, 7L, 1L, 1L)
 mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2),
 rep('white', 5), rep('orange',3), rep('red',9))
 barplot(x, col = mycol)

 Produces a multi-colored barplot on my machine so I understand your
 confusion. Does the above work for you? It may be something hidden in
 your data.

 It does work. Might it be that my data is a matrix? I'm using it to give a 
 name for each bar.



 What is your sessionInfo() and str(mydata)? Same problem in a fresh R
 session (with --vanilla if necessary)?


 sessionInfo()
 R version 2.14.0 (2011-10-31)
 Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

 locale:
 [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

 other attached packages:
 [1] survival_2.36-10

 loaded via a namespace (and not attached):
 [1] tools_2.14.0


 str(mydata)
 num [1, 1:24] 2 108 0 0 0 1 3 0 0 0 ...
 - attr(*, dimnames)=List of 2
  ..$ : NULL
  ..$ : chr [1:24] A B C D ...


 Basically, using the 'x' object as you created the code works, and I can have 
 a workaround. I fail to see why it would not work using mydata.

 Cheers

 F




 Michael

 On Mon, Dec 5, 2011 at 10:44 AM, Federico Calboli
 f.calb...@imperial.ac.uk wrote:
 Hi All,

 I'm having a problem with barplot:

 mydata
 [1,]  2 108  0  0  0  1  3  0  0  0  0  0  7 18  3  4  8 20 26 20 19  7  1  
 1

 mycol = c(rep('yellow', 2), rep('white', 3), rep('orange',2), rep('white', 
 5), rep('orange',3), rep('red',9))

 barplot(mydata, col = mycol)

 gives me an uniformly yellow barplot. How do I solve this?

 bw

 Federico



 --
 Federico C. F. Calboli
 Neuroepidemiology and Ageing Research
 Imperial College, St. Mary's Campus
 Norfolk Place, London W2 1PG

 Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

 f.calboli [.a.t] imperial.ac.uk
 f.calboli [.a.t] 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.

 --
 Federico C. F. Calboli
 Neuroepidemiology and Ageing Research
 Imperial College, St. Mary's Campus
 Norfolk Place, London W2 1PG

 Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

 f.calboli [.a.t] imperial.ac.uk
 f.calboli [.a.t] gmail.com


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


[R] adding hyperlinked text to pdf plot

2011-12-05 Thread Justin Fincher
Howdy,
   I have read that if you put a URL in the text of a plot being saved
into pdf, the result is a functional hyperlink. I am interested in
having text in a plot that is linked to a URL, but I would like the
text to be something other than the URL. Is this possible? Thank you.

- Fincher

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] explanation why RandomForest don't require a transformations (e.g. logarithmic) of variables

2011-12-05 Thread gianni lavaredo
Dear Researches,

sorry for the easy and common question. I am trying to justify the idea of
RandomForest don't require a transformations (e.g. logarithmic) of
variables, comparing this non parametrics method with e.g. the linear
regressions. In leteruature to study my phenomena i need to apply a
logarithmic trasformation to describe my model, but i found RF don't
required this approach. Some people could suggest me text or bibliography
to study?

thanks in advance

Gianni

[[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] adding hyperlinked text to pdf plot

2011-12-05 Thread Ted Harding
On 05-Dec-11 18:39:21, Justin Fincher wrote:
 Howdy,
I have read that if you put a URL in the text of a plot
 being saved into pdf, the result is a functional hyperlink.
 I am interested in having text in a plot that is linked to
 a URL, but I would like the text to be something other than
 the URL. Is this possible? Thank you.
 
 - Fincher

The kosher method of doing this kind of thing (and a host
of other interactive elements in a PDF file) would be to
incorporate a so-called PDFmark into the PDF code. See for
instance:

http://www.pdflib.com/developer/technical-documentation/
books/pdfmark-primer/

There are various ways of doing this in some document-preparation
programs, but I don't know whether it would be easy to do this
when creating a PDF in R. In mt experience, this involves first
passing via PostScript.

Any comments, anyone?

Ted.


E-Mail: (Ted Harding) ted.hard...@wlandres.net
Fax-to-email: +44 (0)870 094 0861
Date: 05-Dec-11   Time: 18:58:53
-- XFMail --

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


Re: [R] explanation why RandomForest don't require a transformations (e.g. logarithmic) of variables

2011-12-05 Thread Liaw, Andy
Tree based models (such as RF) are invriant to monotonic transformations in the 
predictor (x) variables, because they only use the ranks of the variables, not 
their actual values.  More specifically, they look for splits that are at the 
mid-points of unique values.  Thus the resulting trees are basically identical 
regardless of how you transform the x variables.

Of course, the only, probably minor, differences is, e.g., mid-points can be 
different between the original and transformed data.  While this doesn't impact 
the training data, it can impact the prediction on test data (although 
difference should be slight).

Transformation of the response variable is quite another thing.  RF needs it 
just as much as others if the situation calls for it.

Cheers,
Andy
 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of gianni lavaredo
 Sent: Monday, December 05, 2011 1:41 PM
 To: r-help@r-project.org
 Subject: [R] explanation why RandomForest don't require a 
 transformations (e.g. logarithmic) of variables
 
 Dear Researches,
 
 sorry for the easy and common question. I am trying to 
 justify the idea of
 RandomForest don't require a transformations (e.g. logarithmic) of
 variables, comparing this non parametrics method with e.g. the linear
 regressions. In leteruature to study my phenomena i need to apply a
 logarithmic trasformation to describe my model, but i found RF don't
 required this approach. Some people could suggest me text or 
 bibliography
 to study?
 
 thanks in advance
 
 Gianni
 
   [[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.
 
Notice:  This e-mail message, together with any attachme...{{dropped:11}}

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


Re: [R] adding hyperlinked text to pdf plot

2011-12-05 Thread David Winsemius


On Dec 5, 2011, at 1:39 PM, Justin Fincher wrote:


Howdy,
  I have read that if you put a URL in the text of a plot being saved
into pdf, the result is a functional hyperlink.


Don't believe everything you read.

pdf(test.pdf)
 plot(1,1,main=http://test.gov/some.htm;)
 dev.off()

Non-functioning text.


I am interested in
having text in a plot that is linked to a URL, but I would like the
text to be something other than the URL. Is this possible? Thank you.

- Fincher




David Winsemius, MD
West Hartford, CT

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


Re: [R] adding hyperlinked text to pdf plot

2011-12-05 Thread Yihui Xie
It seems I missed the context of this post -- who is you, and what
is something other than the URL?

I feel the tikzDevice package should be an option for the task.

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Mon, Dec 5, 2011 at 12:39 PM, Justin Fincher finc...@cs.fsu.edu wrote:
 Howdy,
   I have read that if you put a URL in the text of a plot being saved
 into pdf, the result is a functional hyperlink. I am interested in
 having text in a plot that is linked to a URL, but I would like the
 text to be something other than the URL. Is this possible? Thank you.

 - Fincher

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] explanation why RandomForest don't require a transformations (e.g. logarithmic) of variables

2011-12-05 Thread gianni lavaredo
about the  because they only use the ranks of the variables. Using a
leave-one-out, in each interaction the the predictor variable ranks change
slightly every time RF builds the model, especially for the variables with
low importance. Is It correct to justify this because there are random
splitting?

Thanks in advance
Gianni


On Mon, Dec 5, 2011 at 7:59 PM, Liaw, Andy andy_l...@merck.com wrote:

 Tree based models (such as RF) are invriant to monotonic transformations
 in the predictor (x) variables, because they only use the ranks of the
 variables, not their actual values.  More specifically, they look for
 splits that are at the mid-points of unique values.  Thus the resulting
 trees are basically identical regardless of how you transform the x
 variables.

 Of course, the only, probably minor, differences is, e.g., mid-points can
 be different between the original and transformed data.  While this doesn't
 impact the training data, it can impact the prediction on test data
 (although difference should be slight).

 Transformation of the response variable is quite another thing.  RF needs
 it just as much as others if the situation calls for it.

 Cheers,
 Andy


  -Original Message-
  From: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] On Behalf Of gianni lavaredo
  Sent: Monday, December 05, 2011 1:41 PM
  To: r-help@r-project.org
  Subject: [R] explanation why RandomForest don't require a
  transformations (e.g. logarithmic) of variables
 
  Dear Researches,
 
  sorry for the easy and common question. I am trying to
  justify the idea of
  RandomForest don't require a transformations (e.g. logarithmic) of
  variables, comparing this non parametrics method with e.g. the linear
  regressions. In leteruature to study my phenomena i need to apply a
  logarithmic trasformation to describe my model, but i found RF don't
  required this approach. Some people could suggest me text or
  bibliography
  to study?
 
  thanks in advance
 
  Gianni
 
[[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.
 
 Notice:  This e-mail message, together with any attach...{{dropped:16}}

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

2011-12-05 Thread Kehl Dániel

Dear list members,

I have a really simple problem.
I connected to a DB and have the following query

adat - dbGetQuery(con, paste(select * from kmdata where SzeAZ=', 
szeazok[i], ' order by datum, sep=))


now I have the data in the adat variable which is a list. In fact the 
elements of the list are lists as well

 is.list(adat)
[1] TRUE
 is.list(adat[10])
[1] TRUE
 is.list(adat[[10]])
[1] FALSE
 is.vector(adat[[10]])
[1] TRUE

I simply want to use a function with sapply on the 13-76th columns of 
the original list.
sapply(data[[13:76]], myfunc) does not work of course. I tried to define 
13:76 in a vector, still no result.

How is it possible?

thanks a lot
d

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


Re: [R] explanation why RandomForest don't require a transformations (e.g. logarithmic) of variables

2011-12-05 Thread Liaw, Andy
You should see no differences beyond what you'd get by running RF a second time 
with a different random number seed.

Best,
Andy


From: gianni lavaredo [mailto:gianni.lavar...@gmail.com]
Sent: Monday, December 05, 2011 2:19 PM
To: Liaw, Andy
Cc: r-help@r-project.org
Subject: Re: [R] explanation why RandomForest don't require a transformations 
(e.g. logarithmic) of variables

about the  because they only use the ranks of the variables. Using a 
leave-one-out, in each interaction the the predictor variable ranks change 
slightly every time RF builds the model, especially for the variables with low 
importance. Is It correct to justify this because there are random splitting?

Thanks in advance
Gianni


On Mon, Dec 5, 2011 at 7:59 PM, Liaw, Andy 
andy_l...@merck.commailto:andy_l...@merck.com wrote:
Tree based models (such as RF) are invriant to monotonic transformations in the 
predictor (x) variables, because they only use the ranks of the variables, not 
their actual values.  More specifically, they look for splits that are at the 
mid-points of unique values.  Thus the resulting trees are basically identical 
regardless of how you transform the x variables.

Of course, the only, probably minor, differences is, e.g., mid-points can be 
different between the original and transformed data.  While this doesn't impact 
the training data, it can impact the prediction on test data (although 
difference should be slight).

Transformation of the response variable is quite another thing.  RF needs it 
just as much as others if the situation calls for it.

Cheers,
Andy


 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org] On 
 Behalf Of gianni lavaredo
 Sent: Monday, December 05, 2011 1:41 PM
 To: r-help@r-project.orgmailto:r-help@r-project.org
 Subject: [R] explanation why RandomForest don't require a
 transformations (e.g. logarithmic) of variables

 Dear Researches,

 sorry for the easy and common question. I am trying to
 justify the idea of
 RandomForest don't require a transformations (e.g. logarithmic) of
 variables, comparing this non parametrics method with e.g. the linear
 regressions. In leteruature to study my phenomena i need to apply a
 logarithmic trasformation to describe my model, but i found RF don't
 required this approach. Some people could suggest me text or
 bibliography
 to study?

 thanks in advance

 Gianni

   [[alternative HTML version deleted]]

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

Notice:  This e-mail message, together with any attachme...{{dropped:26}}

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

2011-12-05 Thread Kehl Dániel

nevermind, typo (and some gray hair)

sorry

12/5/2011 8:21 PM keltezéssel, Kehl Dániel írta:

Dear list members,

I have a really simple problem.
I connected to a DB and have the following query

adat - dbGetQuery(con, paste(select * from kmdata where SzeAZ=', 
szeazok[i], ' order by datum, sep=))


now I have the data in the adat variable which is a list. In fact the 
elements of the list are lists as well

 is.list(adat)
[1] TRUE
 is.list(adat[10])
[1] TRUE
 is.list(adat[[10]])
[1] FALSE
 is.vector(adat[[10]])
[1] TRUE

I simply want to use a function with sapply on the 13-76th columns of 
the original list.
sapply(data[[13:76]], myfunc) does not work of course. I tried to 
define 13:76 in a vector, still no result.

How is it possible?

thanks a lot
d

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] installing several versions of R (2.14 and 2.12.2) on the same system on Ubuntu

2011-12-05 Thread Jannis
Dear R users,


besides the current R 2.14 I would like to install a second version of R 
(2.12.2) on my Ubuntu system. The current version is easily installed as a 
precompiled package from Cran but I am heavily fighting with the older version. 
I tried to follow the instructions here:

http://cran.r-project.org/doc/manuals/R-admin.html

Unfortunately I got totally confused by all the different locations of the 
script, the library and the rest of the program. As I understand these all have 
to be different from the ones of the R 2.14 installation. In case anybody could 
point me to some nice instructions, fell welcome to do so. 


Otherwise we would need to check what went wrong during my try. I finally 
managed to install R.2.12.2 but, as it seems, without Java correctly set up and 
without tcltk support (both are needed). r-base-dev is installed.


This I what I did:

1. downloaded R.2.12.2.tar.gz from Cran
2. tar -xzf R-2.12.2.tar.gz
3. sudo cp R-2.12.2 /usr/lib
4. cd /usr/lib/R.2.12.2
5. mkdir prog
5. sudo ./configure --prefix=/usr/bin
6. sudo make prefix=/usr/lib/R-2.12.2/prog rhome=/usr/lib/R-2.12.2/library

7. sudo mv /usr/bin/R /usr/bin/R-2.12.2


Most probably these two arguments for make are not correct as I did not fully 
understand the instructions here. Additionally I would need to facilitate 
tcl/tk and Java. Both works with R.2.14 so their dependecies should be 
installed but I probably need some more arguments during the build for that. 
Also this renaming of the R script seems arkward to me but I did this to easily 
run R-2.12.2 or R-2.14 from the command line.


Does anybody have any advice on how to fix this stuff? 


Thanks for your help!
Jannis

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


Re: [R] lists everywhere

2011-12-05 Thread William Dunlap
First, some general suggestions:
  To see the structure of an object I would recommend
  the str() function or, for a more concise output,
  the class() function.

  I don't think most ordinary users should be using
  is.list() and, especially, is.vector().

Now for the particulars.
  dbGetQuery probably returns an object of class data.frame.
  data.frames are implemented as lists with certain attributes,
  so if 'dat' is a data.frame then is.list(dat) reports TRUE.
  class(dat) would report data.frame, which is what you want
  to know.  Similarly, dat[1] is a data.frame so is.list(dat[1])
  reports TRUE.  dat[[1]] is a column of a data.frame, not a
  data.frame, and class(dat[[1]]) will tell you its class.

  I haven't come across a case where is.vector is useful.
  is.vector(x) returns TRUE if x has no attributes other than names
  is x is not a language object, environment, or other esoteric
  type.  E.g., is.vector of a factor object returns FALSE and
  is.vector of a numeric object or a list object returns TRUE
  (unless the object has some attributes).
  is.vector has nothing to do with the concept of a vector in linear
  algebra (or aviation or physics or almost anywhere else).

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Kehl Dániel
 Sent: Monday, December 05, 2011 11:21 AM
 To: r-help@r-project.org
 Subject: [R] lists everywhere
 
 Dear list members,
 
 I have a really simple problem.
 I connected to a DB and have the following query
 
 adat - dbGetQuery(con, paste(select * from kmdata where SzeAZ=',
 szeazok[i], ' order by datum, sep=))
 
 now I have the data in the adat variable which is a list. In fact the
 elements of the list are lists as well
   is.list(adat)
 [1] TRUE
   is.list(adat[10])
 [1] TRUE
   is.list(adat[[10]])
 [1] FALSE
   is.vector(adat[[10]])
 [1] TRUE
 
 I simply want to use a function with sapply on the 13-76th columns of
 the original list.
 sapply(data[[13:76]], myfunc) does not work of course. I tried to define
 13:76 in a vector, still no result.
 How is it possible?
 
 thanks a lot
 d
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] adding hyperlinked text to pdf plot

2011-12-05 Thread Justin Fincher
For example, say I am plotting some data that is genomic and therefore
maps to a specific locus on the human genome, like a gene.  I was
hoping to have the title of the plot display the gene name, but have
it be a link so that clicking on it would take you to those
coordinates on a public browser, like USCS's genome browser.  So
basically, I was hoping to have text in a plot generated by R function
as a normal html-style link.

- Fincher


On Mon, Dec 5, 2011 at 14:09, Yihui Xie x...@yihui.name wrote:
 It seems I missed the context of this post -- who is you, and what
 is something other than the URL?

 I feel the tikzDevice package should be an option for the task.

 Regards,
 Yihui
 --
 Yihui Xie xieyi...@gmail.com
 Phone: 515-294-2465 Web: http://yihui.name
 Department of Statistics, Iowa State University
 2215 Snedecor Hall, Ames, IA



 On Mon, Dec 5, 2011 at 12:39 PM, Justin Fincher finc...@cs.fsu.edu wrote:
 Howdy,
   I have read that if you put a URL in the text of a plot being saved
 into pdf, the result is a functional hyperlink. I am interested in
 having text in a plot that is linked to a URL, but I would like the
 text to be something other than the URL. Is this possible? Thank you.

 - Fincher

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

 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.


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


Re: [R] adding hyperlinked text to pdf plot

2011-12-05 Thread Duncan Murdoch

On 05/12/2011 3:10 PM, Justin Fincher wrote:

For example, say I am plotting some data that is genomic and therefore
maps to a specific locus on the human genome, like a gene.  I was
hoping to have the title of the plot display the gene name, but have
it be a link so that clicking on it would take you to those
coordinates on a public browser, like USCS's genome browser.  So
basically, I was hoping to have text in a plot generated by R function
as a normal html-style link.


Just use Sweave, and put the URL in a LaTeX \href{URL}{text} tag, not in 
the R code.  This can be generated in R code in
\Sexp{}.  It's not part of the PDF image, but it's part of the final 
document.


Duncan Murdoch

- Fincher


On Mon, Dec 5, 2011 at 14:09, Yihui Xiex...@yihui.name  wrote:
  It seems I missed the context of this post -- who is you, and what
  is something other than the URL?

  I feel the tikzDevice package should be an option for the task.

  Regards,
  Yihui
  --
  Yihui Xiexieyi...@gmail.com
  Phone: 515-294-2465 Web: http://yihui.name
  Department of Statistics, Iowa State University
  2215 Snedecor Hall, Ames, IA



  On Mon, Dec 5, 2011 at 12:39 PM, Justin Fincherfinc...@cs.fsu.edu  wrote:
  Howdy,
 I have read that if you put a URL in the text of a plot being saved
  into pdf, the result is a functional hyperlink. I am interested in
  having text in a plot that is linked to a URL, but I would like the
  text to be something other than the URL. Is this possible? Thank you.

  - Fincher

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

  --
  This message has been scanned for viruses and
  dangerous content by MailScanner, and is
  believed to be clean.


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

2011-12-05 Thread Yihui Xie
Sorry I experimented with tikzDevice using \href{}{} but failed.

You can probably try the old image hotspot technique in HTML. I
remember someone did this before in R, but I cannot find the link to
the work now. The key is your need to use the two functions grconvertX
and grconvertY.

Regards,
Yihui
--
Yihui Xie xieyi...@gmail.com
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Mon, Dec 5, 2011 at 2:10 PM, Justin Fincher finc...@cs.fsu.edu wrote:
 For example, say I am plotting some data that is genomic and therefore
 maps to a specific locus on the human genome, like a gene.  I was
 hoping to have the title of the plot display the gene name, but have
 it be a link so that clicking on it would take you to those
 coordinates on a public browser, like USCS's genome browser.  So
 basically, I was hoping to have text in a plot generated by R function
 as a normal html-style link.

 - Fincher


 On Mon, Dec 5, 2011 at 14:09, Yihui Xie x...@yihui.name wrote:
 It seems I missed the context of this post -- who is you, and what
 is something other than the URL?

 I feel the tikzDevice package should be an option for the task.

 Regards,
 Yihui
 --
 Yihui Xie xieyi...@gmail.com
 Phone: 515-294-2465 Web: http://yihui.name
 Department of Statistics, Iowa State University
 2215 Snedecor Hall, Ames, IA



 On Mon, Dec 5, 2011 at 12:39 PM, Justin Fincher finc...@cs.fsu.edu wrote:
 Howdy,
   I have read that if you put a URL in the text of a plot being saved
 into pdf, the result is a functional hyperlink. I am interested in
 having text in a plot that is linked to a URL, but I would like the
 text to be something other than the URL. Is this possible? Thank you.

 - Fincher

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

 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.


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


Re: [R] adding hyperlinked text to pdf plot

2011-12-05 Thread Paul Murrell

Hi

On 6/12/2011 9:10 a.m., Justin Fincher wrote:

For example, say I am plotting some data that is genomic and therefore
maps to a specific locus on the human genome, like a gene.  I was
hoping to have the title of the plot display the gene name, but have
it be a link so that clicking on it would take you to those
coordinates on a public browser, like USCS's genome browser.  So
basically, I was hoping to have text in a plot generated by R function
as a normal html-style link.


The 'gridSVG' package will let you associate a hyperlink with text (or 
anything else) and produce SVG that can then be viewed in a web page (as 
long as your plot is a 'lattice' or 'ggplot2' one).


Paul


- Fincher


On Mon, Dec 5, 2011 at 14:09, Yihui Xiex...@yihui.name  wrote:

It seems I missed the context of this post -- who is you, and what
is something other than the URL?

I feel the tikzDevice package should be an option for the task.

Regards,
Yihui
--
Yihui Xiexieyi...@gmail.com
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Mon, Dec 5, 2011 at 12:39 PM, Justin Fincherfinc...@cs.fsu.edu  wrote:

Howdy,
   I have read that if you put a URL in the text of a plot being saved
into pdf, the result is a functional hyperlink. I am interested in
having text in a plot that is linked to a URL, but I would like the
text to be something other than the URL. Is this possible? Thank you.

- Fincher

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


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



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


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Binning the data based on a value

2011-12-05 Thread Diviya Smith
Hello there,

I have a matrix with some data and I want to split this matrix based on the
values in one column. Is there a quick way of doing this? I have looked at
cut but I am not sure how to exactly use it?
for example:

I would like to split the matrix a based on the spending such that the
data is binned groups [0..99],[100..199]...and so on.

a - data.frame(patient=1:7, charges=c(100,500,200,90,400,500,600),
 age=c(0,3,5,7,10,16,19),  spending=c(10, 60, 110, 200, 250, 400, 450))

Expected  output -
bin[1] - c(10, 60)
bin[2] - c(110, 200, 250)
bin[3] - c(400, 450)

NOTE that the number of data points in each bin is not the same and the
empty bins are removed (since there are no points between [199..299],
bin[3] starts at 400.

Any help would be most appreciated. Thank you in advance.

Diviya

[[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] Binning the data based on a value

2011-12-05 Thread R. Michael Weylandt
I'd so something like

split(a, a$spending)

and you can include a round(a$spending, -2) or something similar if
you want to group by the 100's.

Michael

On Mon, Dec 5, 2011 at 3:37 PM, Diviya Smith diviya.sm...@gmail.com wrote:
 Hello there,

 I have a matrix with some data and I want to split this matrix based on the
 values in one column. Is there a quick way of doing this? I have looked at
 cut but I am not sure how to exactly use it?
 for example:

 I would like to split the matrix a based on the spending such that the
 data is binned groups [0..99],[100..199]...and so on.

 a - data.frame(patient=1:7, charges=c(100,500,200,90,400,500,600),
  age=c(0,3,5,7,10,16,19),  spending=c(10, 60, 110, 200, 250, 400, 450))

 Expected  output -
 bin[1] - c(10, 60)
 bin[2] - c(110, 200, 250)
 bin[3] - c(400, 450)

 NOTE that the number of data points in each bin is not the same and the
 empty bins are removed (since there are no points between [199..299],
 bin[3] starts at 400.

 Any help would be most appreciated. Thank you in advance.

 Diviya

        [[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] Binning the data based on a value

2011-12-05 Thread R. Michael Weylandt
Just a clarification: I can't get round to work as I first expected so
if you want to do bins by 100's you'd probably want:

split(a, cut(a$spending, breaks = (0:5)*100))

Michael

On Mon, Dec 5, 2011 at 3:41 PM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
 I'd so something like

 split(a, a$spending)

 and you can include a round(a$spending, -2) or something similar if
 you want to group by the 100's.

 Michael

 On Mon, Dec 5, 2011 at 3:37 PM, Diviya Smith diviya.sm...@gmail.com wrote:
 Hello there,

 I have a matrix with some data and I want to split this matrix based on the
 values in one column. Is there a quick way of doing this? I have looked at
 cut but I am not sure how to exactly use it?
 for example:

 I would like to split the matrix a based on the spending such that the
 data is binned groups [0..99],[100..199]...and so on.

 a - data.frame(patient=1:7, charges=c(100,500,200,90,400,500,600),
  age=c(0,3,5,7,10,16,19),  spending=c(10, 60, 110, 200, 250, 400, 450))

 Expected  output -
 bin[1] - c(10, 60)
 bin[2] - c(110, 200, 250)
 bin[3] - c(400, 450)

 NOTE that the number of data points in each bin is not the same and the
 empty bins are removed (since there are no points between [199..299],
 bin[3] starts at 400.

 Any help would be most appreciated. Thank you in advance.

 Diviya

        [[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] Problem in while loop

2011-12-05 Thread Gyanendra Pokharel
Hi all,
I have the following code,
When I run the code, it never terminate this is because of the while loop i
am using. In general, if you need a loop for which you don't know in
advance how many iterations there will be, you can use the `while'
statement so here too i don't know the number how many iterations are
there. So Can some one suggest me whats going on?
I am using the Metropolis simulated annealing algorithm
Best

[[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] Problem in while loop

2011-12-05 Thread Gyanendra Pokharel
I forgot to upload the R-code in last email, so heare is one

epiann - function(T0 = 1, N=1000, ainit=1, binit=1,rho = 0.99, amean = 3,
bmean=1.6, avar =.1, bvar=.1, f){

moving - 1
count - 0
Temp - T0
aout - ainit
bout - binit
while(moving  0){
moving - 0
for (i in 1:N) {
aprop - rnorm (1,amean, avar)
bprop - rnorm (1,bmean, bvar)
if (aprop  0  bprop  0){
acceptprob - min(1,exp((f(aout, bout) -
f(aprop,bprop))/Temp))
u - runif(1)
if(uacceptprob){
moving - moving +1
aout - aprop
bout - bprop
}
else{aprob - aout
bprob - bout}
}
}
Temp - Temp*rho
count - count +1

}
fmin - f(aout,bout)
return(c(aout, bout,fmin, count) )

}
out- epiann(f = loglikelihood)

On Mon, Dec 5, 2011 at 3:46 PM, Gyanendra Pokharel 
gyanendra.pokha...@gmail.com wrote:

 Hi all,
 I have the following code,
 When I run the code, it never terminate this is because of the while loop
 i am using. In general, if you need a loop for which you don't know in
 advance how many iterations there will be, you can use the `while'
 statement so here too i don't know the number how many iterations are
 there. So Can some one suggest me whats going on?
 I am using the Metropolis simulated annealing algorithm
 Best


[[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] args() function does not list function prototype for locally-produced/installed R package

2011-12-05 Thread Rick Reeves

Greetings:

I have check the 'Building R Extensions' manual and can find no advice 
on this issue,

so I am asking --

I have created an R package consisting entirely of R source code, and 
created an installer
using the R CMD build / R CMD check commands. The package installs 
correctly, using
R CMD install, and the .Rd files for each function (one function per .R 
/ .Rd file) are visible
using the '?function' command. However, the 'args(function)' command 
does not list the

function prototype; instead generating the error:

Error in args(function) : object function not found.

Question: If it is possible, what changes do I make to my package and 
install process to get
args() to display the function prototype(s) for the functions in my 
local package?



Thanks,
Rick Reeves

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


Re: [R] a question on autocorrelation acf

2011-12-05 Thread Bazman76
Hi there,

I am wondering how R calculates the acf too?

I have a data set of approx 1500 returns when I calculate the lag 1
autocorrelation in excel I get a value of -0.4 but in R its approximately
-0.18?

I have cross checked with PC give and PC give agrees with excel?

I'm sure its just some kind of scaling but it would be nice to resolve this
discrepency!

Baz

--
View this message in context: 
http://r.789695.n4.nabble.com/a-question-on-autocorrelation-acf-tp2076280p4161818.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] Summary coefficients give NA values because of singularities

2011-12-05 Thread Gathurst
Hello,

I have a data set which I am using to find a model with the most significant
parameters included and most importantly, the p-values.  The full model is
of the form:
  sad[,1]~b_1 sad[,2]+b_2 sad[,3]+b_3 sad[,4]+b_4 sad[,5]+b_5 sad[,6]+b_6
sad[,7]+b_7 sad[,8]+b_8 sad[,9]+b_9 sad[,10],
where the 9 variables on the right hand side are all indicator variables. 
The thing I don't understand is the line ' sad[, 10] NA NA 
NA   NA ' as a result of 'Coefficients: (1 not defined because of
singularities)'.

I think the output is taking sad[,10] as the intercept, based on previous
attempts at figuring my issue out, which I find a bit wierd considering
sad[,10] is either 0 or 1.  How do I produce the correct output showing all
p-values?

My code and output is as follows:

sad-matrix(1,ncol=11,nrow=486)
sad[,c(1:10)]-d[,2][-357]
sad[,1]-d[,29][-357]
sad[,2][sad[,2]!=1]-0
sad[,3][sad[,3]!=2]-0
sad[,4][sad[,4]!=3]-0
sad[,5][sad[,5]!=4]-0
sad[,6][sad[,6]!=5]-0
sad[,7][sad[,7]!=6]-0
sad[,8][sad[,8]!=7]-0
sad[,9][sad[,9]!=8]-0
sad[,10][sad[,10]!=9]-0
sad[,2][sad[,2]==1]-1
sad[,3][sad[,3]==2]-1
sad[,4][sad[,4]==3]-1
sad[,5][sad[,5]==4]-1
sad[,6][sad[,6]==5]-1
sad[,7][sad[,7]==6]-1
sad[,8][sad[,8]==7]-1
sad[,9][sad[,9]==8]-1
sad[,10][sad[,10]==9]-1
sad

summary(lm(sad[,1]~sad[,2]+sad[,3]
+sad[,4]+sad[,5]+sad[,6]
+sad[,7]+sad[,8]+sad[,9]+sad[,10]))

Call:
lm(formula = sad[, 1] ~ sad[, 2] + sad[, 3] + sad[, 4] + sad[, 
5] + sad[, 6] + sad[, 7] + sad[, 8] + sad[, 9] + sad[, 10])

Residuals:
Min  1Q  Median  3Q Max 
-3.3191 -0.3893  0.0519  0.7436  1.0519 

Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(|t|)
(Intercept)  4.340910.14495  29.947   2e-16 ***
sad[, 2]-0.161420.18128  -0.890   0.3737
sad[, 3]-0.232210.20275  -1.145   0.2527
sad[, 4] 0.178320.19695   0.905   0.3657
sad[, 5] 0.064500.21447   0.301   0.7638
sad[, 6]-0.159090.18713  -0.850   0.3957
sad[, 7]-0.392860.18171  -2.162   0.0311 *  
sad[, 8]-0.084500.21146  -0.400   0.6896
sad[, 9]-0.021760.20170  -0.108   0.9141
sad[, 10] NA NA  NA   NA
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.9615 on 477 degrees of freedom
Multiple R-squared: 0.02984,Adjusted R-squared: 0.01357 
F-statistic: 1.834 on 8 and 477 DF,  p-value: 0.06869 

Thanks in advance.

--
View this message in context: 
http://r.789695.n4.nabble.com/Summary-coefficients-give-NA-values-because-of-singularities-tp4162113p4162113.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] installing several versions of R (2.14 and 2.12.2) on the same system on Ubuntu

2011-12-05 Thread Peter Langfelder
On Mon, Dec 5, 2011 at 11:47 AM, Jannis bt_jan...@yahoo.de wrote:
 Dear R users,


 besides the current R 2.14 I would like to install a second version of R 
 (2.12.2) on my Ubuntu system. The current version is easily installed as a 
 precompiled package from Cran but I am heavily fighting with the older 
 version. I tried to follow the instructions here:

 http://cran.r-project.org/doc/manuals/R-admin.html

 Unfortunately I got totally confused by all the different locations of the 
 script, the library and the rest of the program. As I understand these all 
 have to be different from the ones of the R 2.14 installation. In case 
 anybody could point me to some nice instructions, fell welcome to do so.


 Otherwise we would need to check what went wrong during my try. I finally 
 managed to install R.2.12.2 but, as it seems, without Java correctly set up 
 and without tcltk support (both are needed). r-base-dev is installed.


 This I what I did:

 1. downloaded R.2.12.2.tar.gz from Cran
 2. tar -xzf R-2.12.2.tar.gz
 3. sudo cp R-2.12.2 /usr/lib
 4. cd /usr/lib/R.2.12.2
 5. mkdir prog
 5. sudo ./configure --prefix=/usr/bin
 6. sudo make prefix=/usr/lib/R-2.12.2/prog rhome=/usr/lib/R-2.12.2/library

 7. sudo mv /usr/bin/R /usr/bin/R-2.12.2


 Most probably these two arguments for make are not correct as I did not fully 
 understand the instructions here. Additionally I would need to facilitate 
 tcl/tk and Java. Both works with R.2.14 so their dependecies should be 
 installed but I probably need some more arguments during the build for that. 
 Also this renaming of the R script seems arkward to me but I did this to 
 easily run R-2.12.2 or R-2.14 from the command line.


 Does anybody have any advice on how to fix this stuff?

I think you did basically the right thing. To be able to compile R
with tcl/tk, you have to install the development files for tcl/tk - on
Fedora the files are contained in package tcl-devel (this is a
Fedora/Ubuntu package, not an R package). Then run the entire
compilation process (./configure, make, make install) again. When you
install a pre-compiled R, you don't need the development files, which
is probably why you never needed them in the past.

I'm not sure about Java - you may want to examine the output of
configure (which is usually saved in configure.log) to see what is
missing.

HTH,

Peter

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


Re: [R] Binning the data based on a value

2011-12-05 Thread Diviya Smith
Thank you very much Michael. This is very helpful. However, if there is any
way to exclude zero length bins. Lets imagine that the matrix was as
follows -

a - data.frame(patient=1:7, charges=c(100,500,200,90,400,500,600),
 age=c(0,3,5,7,10,16,19),  spending=c(10, 60, 110, 200, 400, 450, 500))

bins - split(a, cut(a$spending, breaks = (0:5)*100)

then bins[3] =
$`(200,300]`
[1] patient  charges  age  spending
0 rows (or 0-length row.names)

Is there a way to exclude this?

Priya

On Mon, Dec 5, 2011 at 3:43 PM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

 Just a clarification: I can't get round to work as I first expected so
 if you want to do bins by 100's you'd probably want:

 split(a, cut(a$spending, breaks = (0:5)*100))

 Michael

 On Mon, Dec 5, 2011 at 3:41 PM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:
  I'd so something like
 
  split(a, a$spending)
 
  and you can include a round(a$spending, -2) or something similar if
  you want to group by the 100's.
 
  Michael
 
  On Mon, Dec 5, 2011 at 3:37 PM, Diviya Smith diviya.sm...@gmail.com
 wrote:
  Hello there,
 
  I have a matrix with some data and I want to split this matrix based on
 the
  values in one column. Is there a quick way of doing this? I have looked
 at
  cut but I am not sure how to exactly use it?
  for example:
 
  I would like to split the matrix a based on the spending such that the
  data is binned groups [0..99],[100..199]...and so on.
 
  a - data.frame(patient=1:7, charges=c(100,500,200,90,400,500,600),
   age=c(0,3,5,7,10,16,19),  spending=c(10, 60, 110, 200, 250, 400, 450))
 
  Expected  output -
  bin[1] - c(10, 60)
  bin[2] - c(110, 200, 250)
  bin[3] - c(400, 450)
 
  NOTE that the number of data points in each bin is not the same and the
  empty bins are removed (since there are no points between [199..299],
  bin[3] starts at 400.
 
  Any help would be most appreciated. Thank you in advance.
 
  Diviya
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


Re: [R] Binning the data based on a value

2011-12-05 Thread R. Michael Weylandt
Add the drop = TRUE command to split

?split
split(a, cut(a$spending, breaks = (0:5)*100), drop = TRUE)

Michael

On Mon, Dec 5, 2011 at 4:06 PM, Diviya Smith diviya.sm...@gmail.com wrote:
 Thank you very much Michael. This is very helpful. However, if there is any
 way to exclude zero length bins. Lets imagine that the matrix was as follows
 -

 a - data.frame(patient=1:7, charges=c(100,500,200,90,400,500,600),
  age=c(0,3,5,7,10,16,19),  spending=c(10, 60, 110, 200, 400, 450, 500))

 bins - split(a, cut(a$spending, breaks = (0:5)*100)

 then bins[3] =
 $`(200,300]`
 [1] patient  charges  age      spending
 0 rows (or 0-length row.names)

 Is there a way to exclude this?

 Priya

 On Mon, Dec 5, 2011 at 3:43 PM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:

 Just a clarification: I can't get round to work as I first expected so
 if you want to do bins by 100's you'd probably want:

 split(a, cut(a$spending, breaks = (0:5)*100))

 Michael

 On Mon, Dec 5, 2011 at 3:41 PM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:
  I'd so something like
 
  split(a, a$spending)
 
  and you can include a round(a$spending, -2) or something similar if
  you want to group by the 100's.
 
  Michael
 
  On Mon, Dec 5, 2011 at 3:37 PM, Diviya Smith diviya.sm...@gmail.com
  wrote:
  Hello there,
 
  I have a matrix with some data and I want to split this matrix based on
  the
  values in one column. Is there a quick way of doing this? I have looked
  at
  cut but I am not sure how to exactly use it?
  for example:
 
  I would like to split the matrix a based on the spending such that
  the
  data is binned groups [0..99],[100..199]...and so on.
 
  a - data.frame(patient=1:7, charges=c(100,500,200,90,400,500,600),
   age=c(0,3,5,7,10,16,19),  spending=c(10, 60, 110, 200, 250, 400, 450))
 
  Expected  output -
  bin[1] - c(10, 60)
  bin[2] - c(110, 200, 250)
  bin[3] - c(400, 450)
 
  NOTE that the number of data points in each bin is not the same and the
  empty bins are removed (since there are no points between [199..299],
  bin[3] starts at 400.
 
  Any help would be most appreciated. Thank you in advance.
 
  Diviya
 
         [[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] a question on autocorrelation acf

2011-12-05 Thread R. Michael Weylandt
Did you check the MASS reference given above in the thread? If you
want to see the source, it's here:
http://svn.r-project.org/R/trunk/src/library/stats/src/filter.c (best
I can tell)

Michael

On Mon, Dec 5, 2011 at 2:24 PM, Bazman76 h_a_patie...@hotmail.com wrote:
 Hi there,

 I am wondering how R calculates the acf too?

 I have a data set of approx 1500 returns when I calculate the lag 1
 autocorrelation in excel I get a value of -0.4 but in R its approximately
 -0.18?

 I have cross checked with PC give and PC give agrees with excel?

 I'm sure its just some kind of scaling but it would be nice to resolve this
 discrepency!

 Baz

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/a-question-on-autocorrelation-acf-tp2076280p4161818.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] nipals in the chemometrics package in R

2011-12-05 Thread zz dd
That's solved.
Just a cor between X and ti values.

Thank you all.

2011/12/5 zz dd void1...@gmail.com

 Thank's Pedro Madrones,
 you're right that i have removed my name of the email (because of Spam,
 and datas that i can't remove on the net).
 Ok, i explain a bit more :

 X is a centred matrix.
 PCA summarise all variation of X into a few new variables called scores
 T.These new variables are linearly weighted combinations
 of the original X-variables.
 The loadings P contain the weights used for each X variable and thus
 reveal the influence of individual X-variables.
 Is it ok ?

 That's what give the nipals function of chemometrics package.

 It's just that i don't understand how to use The T and P matrix to have
 the component matrix.

 i don't need explainations how to obtain P and T But in how to do E =
 X – tp.
 But maybe it's not there for this kind of questions, i am not from
 chemometrics science.

 ***
 Johannes E. S.




 2011/12/5 Pedro Mardones mardone...@gmail.com

 Perhaps you can try the examples given in
 http://www.jstatsoft.org/v18/i02 for getting a better idea about how
 the NIPALS algorithm works. BTW, yes,it looks like a homework question
 specially when your user name is zz dd void1...@gmail.com so you
 can't be recognized.



 On Mon, Dec 5, 2011 at 9:27 AM, zz dd void1...@gmail.com wrote:
  Thank you for your brevity you don't have to say more things to show who
  you are.
  Else if you don't understand what we are talking about, you shouldn't
  be
  rude and insulting.
  May be you are quite young please take time to read Nonaka and Takeuchi
 and
  moreover Takanashi to uderstand the way to go from information to
 knowledge
  to wisdom that's quite useful for IS / IT and should bring you a bit of
  etiquette.
  *I have a dream* *that one day this nation will rise up and live out the
  true meaning of its creed : “We hold these truths to be self-evident :
 that
  all men are created equal.”*
 
  Have a nice day.
 
  2011/12/5 Jeff Newmiller jdnew...@dcn.davis.ca.us
 
  This is not a homework help list.
 
 ---
  Jeff NewmillerThe .   .  Go
 Live...
  DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live
  Go...
   Live:   OO#.. Dead: OO#..  Playing
  Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
  /Software/Embedded Controllers)   .OO#.   .OO#.
  rocks...1k
 
 ---
  Sent from my phone. Please excuse my brevity.
 
  zz dd void1...@gmail.com wrote:
 
  Hello
  The solution maybe there but i need to compute it into R if someone
 can
  help me :
  (Previously store score vector t in score matrix T; store loading
  vector p
  in loading matrix P) that's done by nipals in chemometrics
  After use of nipals function you have T and P matrix
  
  First : Calculate the residual matrix of X. Stop if the elements of
  Xres
  are very small
  because no further PCA components are reasonable :
  Xres= X-u.b(T)
  
  u : improved score vector
  b: loading vector
  X : a mean-centered matrix
  
  Second : Replace X with Xres and continue with step 2 (with nipals
  chemometrics...) for calculation of the next PCA
  component.
  
  If someone can help me ?
  Thank's a lot
  
  
  2011/12/1 zz dd void1...@gmail.com
  
   Hello
   i need some precision about nipals in the chemometrics package in R
 .
  
   When i use nipals in chemometrics i obtain T and P matrix.
  
   I really don't understand what to do with these two matrix to obtain
   the scores for every the component (like in spss fo example)
  
   Comp1Comp2   Comp3
   quest1 0,8434  0,54333   0,3466
   quest2 0,665   0,7655  0,433
  
   Thank you very much for your help
   (I know that X=TP+E)... But don't understand else
  
  
 [[alternative HTML version deleted]]
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 [[alternative HTML version deleted]]
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 




[[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] Toggle cASE

2011-12-05 Thread Tonio
Thanks a lot Eik!
 
That is exactly what I was looking for.
 
Best
Antonio



Fra: Eik Vettorazzi e.vettora...@uke.de

Cc: r-help@R-project.org r-help@r-project.org 
Sendt: 23:21 mandag den 5. december 2011
Emne: Re: [R] Toggle cASE

Hi Antonio,
how about this:

txt2 - useRs may fly into JFK or laGuardia
chartr(a-zA-Z, A-Za-z, txt2)


Cheers.

Am 05.12.2011 08:11, schrieb Tonio:
 Hello R-help list,
  
 I am looking for way to toggle the case of the characters like a flip-flop; 
 that is from ''Hello'' to hELLO or vice versa.
  
 I know that there are a number of functions like casefold, tolower, toupper, 
 etc. but these functions change the case in an uniform way.
  
 Thanks in advance,
  
 Antonio Rivero Ostoic
  
  
  
  
 Antonio Rivero Ostoic
 PhD Student, Department of Leadership and Strategy
 From 1 Jul until 31 Dec 2011
 Tel.    +61 3 8344 4300
 Fax    +61 3 9347 6618
 Email  j...@sdu.dk
 Addr.  The University of Melbourne, Victoria 3010  Australia
 -
 UNIVERSITY OF SOUTHERN DENMARK
 Sdr. Stationsvej 28 · DK-4200  Slagelse · Denmark · Tel. +45 6550 1000 ·
 www.sdu.dk
 
     [[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

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 
[[alternative HTML version deleted]]

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


Re: [R] problems using the thin plate spline method

2011-12-05 Thread Mintewab Bezabih
Dear Michael and R users,

I generated a more orderly looking data again and below are the data and the 
codes I am trying to run.

many thanks
mintewab

dat - read.table(E:/thin plate/thin plate.csv, header=T, sep=,)
names(dat) - c(x1, x2, y)
library(fidelds)
plot (dat)
plot (dat$x1, dat$x2)
#load the fields package (containing Tps) and fit a thin plate spline
tpsfit - Tps(cbind(dat$x1, dat$x2), dat$y, scale.type=unscaled)



 x1 x2   y
1409.50  673.0 1082.50
2349.00  335.0  684.00
3385.50 1737.0 2122.50
4273.00  457.0  730.00
5543.00 2325.0 2868.00
6746.00 1255.0 2001.00
7198.75  388.0  586.75
8262.50  104.0  366.50
9320.50  786.0 1106.50
10   259.00  516.0  775.00
11   399.50  542.0  941.50
12   595.50  916.0 1511.50
13   374.00 1257.0 1631.00
14   293.00  229.0  522.00
15   330.00  490.0  820.00
16   658.00 1016.0 1674.00
17   299.00  266.0  565.00
18   775.00 1139.0 1914.00
19   559.75 1023.0 1582.75
20   251.00  153.0  404.00
21   402.00  253.0  655.00
22   395.50  319.0  714.50
23   345.50  456.0  801.50
24   283.50  400.0  683.50
25   452.00  388.0  840.00
26   816.50  941.0 1757.50
27   266.50  307.0  573.50
28   360.25  683.0 1043.25
29   386.00  528.0  914.00
30   160.25  368.0  528.25
31   360.00  455.0  815.00
32   337.00  488.0  825.00
33   326.00  702.0 1028.00
34   758.00 1040.0 1798.00
35   342.50  405.0  747.50
36   389.00  483.0  872.00
37   347.50  524.0  871.50
38   819.25  490.0 1309.25
39   355.25  517.0  872.25
40   281.00  505.0  786.00
41   494.50  844.0 1338.50
42   514.50  429.0  943.50
43   263.00  349.0  612.00
44   439.00  549.0  988.00
45   263.00  450.0  713.00
46   373.25 1212.0 1585.25
47   546.00  546.0 1092.00
48   348.00  485.0  833.00
49   380.50  378.0  758.50
50   606.00  598.0 1204.00
51   460.00  838.0 1298.00
52   352.50  519.0  871.50
53   737.00  624.0 1361.00
54   275.00  185.0  460.00
55   520.50  632.0 1152.50
56   385.25  696.5 1081.75
57   354.50  524.0  878.50
58   383.50  618.0 1001.50
59   322.50  381.0  703.50
60   309.00  380.0  689.00
61   502.50  624.0 1126.50
62   517.00  612.0 1129.00
63   276.00  260.0  513.00
64   400.50  831.0 1231.50
65   272.50  451.0  723.50
66   NA  284.0  NA
67   253.00  353.0  606.00
68   311.00  720.0 1031.00
69   389.00  583.0  972.00
70   157.75  344.0  501.75
71   520.00 1175.0 1695.00
72   499.50  761.0 1260.50
73   481.00  694.0 1275.00
74   448.50  606.0 1054.50
75   335.50  239.0  574.50
76   231.50  273.0  504.50
77   492.50  394.0  886.50
78   477.50  899.0 1376.50
79   650.00  721.0 1371.00
80   540.75  730.0 1270.75
81   620.50 1295.0 1915.50
82   400.50 1148.0 1548.50
83   331.50  524.0  855.50
84   311.00  578.0  889.00
85   229.00  262.0  491.00
86   432.50  326.0  758.50
87   422.75  217.0  639.75
88   493.50  648.0 1141.50
89   414.25  485.0  899.25
90   487.00  726.0 1213.00
91   369.00  747.0 1116.00
92   425.00 1663.0 2088.00
93   233.50  269.0  502.50
94   254.50  488.5  743.00
95   417.50 1137.0 1554.50
96   NA  310.0  NA
97   583.25  434.0 1017.25
98   492.50  536.0 1028.50
99   490.00  486.0  976.00
100  300.25 1225.0 1525.25
101  NA  462.0  NA
102  270.00  237.0  507.00
103  307.00  230.0  537.00
104  319.00  242.0  561.00
105  374.50  340.0  714.50
106  562.50  521.0 1083.50
107  569.50  242.0  811.50
108  389.75  389.0  778.75
109  341.25  691.0 1032.25
110  366.00  387.0  753.00
111  262.75  615.0  877.75
112  776.25 1926.0 2702.25
113  379.50  597.0  976.50
114  360.00  299.0  659.00
115  203.75  213.0  416.75
116  517.00  618.0 1135.00
117  539.50  684.0 1223.50
118  418.75  439.0  857.75
119  353.50  459.0  812.50
120  269.00  366.0  635.00
121  475.50 1098.0 1573.50
122  472.00  384.0  856.00
123  342.00  488.0  830.00
124  189.00  181.0  370.00
125  492.50 5342.0 5834.50
126  412.00  433.0  845.00
127  467.50 1475.0 1942.50
128  209.75  480.0  689.75
129  340.75  207.0  547.75
130  231.50  153.0  384.50
131  185.50  295.0  480.50
132  358.50  524.0  882.50
133  354.00  453.0  807.00
134  670.50  978.0 1648.50
135  686.00  486.0 1172.00
136  364.00  676.0 1040.00
137  138.00  336.0  474.00
138  272.00  254.0  526.00
139  183.00  273.0  456.00
140  365.25  255.0  620.25
141  188.00  347.0  535.00
142  229.50  420.0  649.50
143  553.50  603.0 1156.50
144  582.50  739.0 1321.50
145  469.00  340.0  809.00
146  359.50  572.0  931.50
147  284.25  441.0  725.25
148  582.50  833.0 1415.50
149  287.00  775.0 1062.00
150  NA  129.0  NA
151  455.25  350.0  805.25
152  410.50 1445.0 1855.50
153  477.00  328.0  805.00
154  239.00  585.0  824.00
155  313.50  412.0  725.50
156  294.50  446.0  740.50
157  523.00  679.0 1202.00
158  372.50  519.0  891.50
159  231.50  372.0  603.50
160  NA 1712.0  NA
161  365.00  167.0  532.00
162  269.50  492.0  761.50
163  394.50  593.0  987.50
164  281.50  210.0  491.50
165  418.50  363.0  781.50
166  553.50  630.0 1183.50
167  245.75  261.0  506.75
168  304.00  869.0 1173.00
169  

Re: [R] Shading the plot

2011-12-05 Thread R. Michael Weylandt
As David said, your minimal working example is neither minimal nor
working...consider this (admittedly quite clunky) example though:

time - seq(10, 20, length.out = 100)

S1 - 10*exp( cumsum(rnorm(100))/20)
S2 - 10*exp( cumsum(rnorm(100))/20)

plot(time, S1, ylim = range(c(S1,S2)), type = n)
lines(time, S1); lines(time, S2, col = 2)

r - c(1, which(diff(sign(S1-S2)) != 0L), length(time))

for(i in seq_along(r)){
if(i == length(r)){next}

ind1 - r[i]
ind2 - r[i+1]

Xbnds - time[ind1:ind2]
Xbnds - c(Xbnds, rev(Xbnds))

Ybnds - c(S1[ind1:ind2],S2[ind2:ind1])

col = if(median((S1S2)[ind1:ind2])) blue else green

polygon(Xbnds, Ybnds, col = col, border = NA)

}

Best I can figure, this fills green if the red line is on top and blue
otherwise. You may have to run it a few times to see that behavior.

Michael

On Sat, Dec 3, 2011 at 11:37 PM, avinash barnwal
avinashbarnwal...@gmail.com wrote:
 Hi,

 I apologies  for my naive doubts
 I have been trying it from a while. I need the area between the curve based
 on conditions i wrote (whenever red line is above the blue line then area
 between curves to be grey color and whenever blue line is above red line
 then area between curves to be red color )

 x and y are vectors

 Thank you for replying




 On Sun, Dec 4, 2011 at 7:56 AM, David Winsemius dwinsem...@comcast.net
 wrote:


 On Dec 3, 2011, at 5:28 PM, avinash barnwal wrote:

 Hi Weylandt,


 I tried it but i was not successful.

 Here is the full code

 Any help would be great.
 

 time-c(02-Jan-05,09-Jan-05,16-Jan-05,23-Jan-05,30-Jan-05,06-Feb-05,13-Feb-05,20-Feb-05,27-Feb-05,06-Mar-05,13-Mar-05,

 20-Mar-05,27-Mar-05,03-Apr-05,10-Apr-05,17-Apr-05,24-Apr-05,01-May-05,08-May-05,15-May-05)
 time-as.Date(time,%d-%b-%y)

 a2-c(81.96392786,81.96392786,82.16432866,82.56513026,82.76553106,79.96593186,78.16633267,

 75.56713427,74.76753507,72.96793587,70.96793587,45.96793587,83.96793587,84.36873747,

 84.56913828,84.56913828,84.56913828,84.56913828,84.36873747,84.36873747)

 a3-c(81.96392786,81.96392786,81.96392786,70.96392786,68.16432866,66.16432866,

 62.16432866,58.56513026,56.56513026,54.56513026,48.56513026,49.76553106,52.76553106,

 54.76553106,57.96593186,59.36673347,83.36673347,83.36673347,83.36673347,
 83.56713427)
 j-0
 for(i in 1:length(a3))
 {
 if(a2[i]a3[i])
 {
 j-j+1
 x[j]-a2[i]
 y[j]-a3[i]
 temp_time[j]-time[i]
 }
 }
 plot(time,a2,type='l',col='red',ylab='',xlab= ,axes=FALSE)
 lines(time,a3,col='blue',ylab='',xlab= )
 polygon(c(temp_time,rev(temp_time)),c(x,y),col=grey)
 #


 What are the rules that govern requesting outside help in homework at your
 institution?

 Your current code does not recognize  that there is line crossing. Nor do
 you describe what you mean by shading. If you wanted a rectangle within the
 lpot area it would drive one strategy and if you wanted only the area
 between the curves to be shaded it would drive a different strategy.

 AND you never define x or y.

 --
 David.



 On Sun, Dec 4, 2011 at 2:46 AM, R. Michael Weylandt 
 michael.weyla...@gmail.com wrote:

 ? polygon
 example(polygon)

 Michael

 On Sat, Dec 3, 2011 at 4:08 PM, avinash barnwal
 avinashbarnwal...@gmail.com wrote:

 Hi all,

 I have been trying to shade the specific part of the plot

 Part to be shaded

 1. Any color whenever a2a3

 2. Any other color( Not same as 1) whenever a2a3

 Suggest me some code for this task

 PLOT CODE for reference



 ##



 a2-c(81.96392786,81.96392786,82.16432866,82.56513026,82.76553106,79.96593186,78.16633267,



 75.56713427,74.76753507,72.96793587,70.96793587,45.96793587,83.96793587,84.36873747,



 84.56913828,84.56913828,84.56913828,84.56913828,84.36873747,84.36873747)



 a3-c(81.96392786,81.96392786,81.96392786,70.96392786,68.16432866,66.16432866,



 62.16432866,58.56513026,56.56513026,54.56513026,48.56513026,49.76553106,52.76553106,



 54.76553106,57.96593186,59.36673347,83.36673347,83.36673347,83.36673347,

 83.56713427)
 plot(a2,type='l',col='red',ylab='',xlab= ,axes=FALSE)
 lines(a3,col='blue',ylab='',xlab= )


 ##


 Thank you in the advance
 --
 Avinash Barnwal
 Final year undergraduate student
 Statistics and informatics
 Department of Mathematics
 IIT Kharagpur

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

 http://www.R-project.org/posting-guide.html

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





 --
 Avinash Barnwal
 Final year undergraduate student
 Statistics and informatics
 Department of Mathematics
 IIT Kharagpur

        [[alternative HTML 

Re: [R] Problem in while loop

2011-12-05 Thread R. Michael Weylandt
Your code is not reproducible nor minimal, but why don't you put a
command print(acceptprob) in and see if you are getting reasonable
values. If these values are extremely low it shouldn't surprise you
that your loop takes a long time to run.

More generally, read up on the use of print() and browser() as debugging tools.

Michael

On Mon, Dec 5, 2011 at 3:47 PM, Gyanendra Pokharel
gyanendra.pokha...@gmail.com wrote:
 I forgot to upload the R-code in last email, so heare is one

 epiann - function(T0 = 1, N=1000, ainit=1, binit=1,rho = 0.99, amean = 3,
 bmean=1.6, avar =.1, bvar=.1, f){

        moving - 1
        count - 0
        Temp - T0
        aout - ainit
        bout - binit
        while(moving  0){
                moving - 0
                for (i in 1:N) {
                aprop - rnorm (1,amean, avar)
                bprop - rnorm (1,bmean, bvar)
                if (aprop  0  bprop  0){
                acceptprob - min(1,exp((f(aout, bout) -
 f(aprop,bprop))/Temp))
                u - runif(1)
                if(uacceptprob){
                    moving - moving +1
                    aout - aprop
                    bout - bprop
                    }
                    else{aprob - aout
                        bprob - bout}
                }
            }
        Temp - Temp*rho
            count - count +1

    }
    fmin - f(aout,bout)
    return(c(aout, bout,fmin, count) )

 }
 out- epiann(f = loglikelihood)

 On Mon, Dec 5, 2011 at 3:46 PM, Gyanendra Pokharel 
 gyanendra.pokha...@gmail.com wrote:

 Hi all,
 I have the following code,
 When I run the code, it never terminate this is because of the while loop
 i am using. In general, if you need a loop for which you don't know in
 advance how many iterations there will be, you can use the `while'
 statement so here too i don't know the number how many iterations are
 there. So Can some one suggest me whats going on?
 I am using the Metropolis simulated annealing algorithm
 Best


        [[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] Problem in while loop

2011-12-05 Thread Gyanendra Pokharel
Yes, I checked the acceptprob, it is very high but in my view, the while
loop is not stopping, so there is some thing wrong in the use of while
loop. When I removed the while loop, it returned some thing but not the
result what I want. When i run the while loop separately, it never stops.


On Mon, Dec 5, 2011 at 5:18 PM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

 Your code is not reproducible nor minimal, but why don't you put a
 command print(acceptprob) in and see if you are getting reasonable
 values. If these values are extremely low it shouldn't surprise you
 that your loop takes a long time to run.

 More generally, read up on the use of print() and browser() as debugging
 tools.

 Michael

 On Mon, Dec 5, 2011 at 3:47 PM, Gyanendra Pokharel
 gyanendra.pokha...@gmail.com wrote:
  I forgot to upload the R-code in last email, so heare is one
 
  epiann - function(T0 = 1, N=1000, ainit=1, binit=1,rho = 0.99, amean =
 3,
  bmean=1.6, avar =.1, bvar=.1, f){
 
 moving - 1
 count - 0
 Temp - T0
 aout - ainit
 bout - binit
 while(moving  0){
 moving - 0
 for (i in 1:N) {
 aprop - rnorm (1,amean, avar)
 bprop - rnorm (1,bmean, bvar)
 if (aprop  0  bprop  0){
 acceptprob - min(1,exp((f(aout, bout) -
  f(aprop,bprop))/Temp))
 u - runif(1)
 if(uacceptprob){
 moving - moving +1
 aout - aprop
 bout - bprop
 }
 else{aprob - aout
 bprob - bout}
 }
 }
 Temp - Temp*rho
 count - count +1
 
 }
 fmin - f(aout,bout)
 return(c(aout, bout,fmin, count) )
 
  }
  out- epiann(f = loglikelihood)
 
  On Mon, Dec 5, 2011 at 3:46 PM, Gyanendra Pokharel 
  gyanendra.pokha...@gmail.com wrote:
 
  Hi all,
  I have the following code,
  When I run the code, it never terminate this is because of the while
 loop
  i am using. In general, if you need a loop for which you don't know in
  advance how many iterations there will be, you can use the `while'
  statement so here too i don't know the number how many iterations are
  there. So Can some one suggest me whats going on?
  I am using the Metropolis simulated annealing algorithm
  Best
 
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


[R] plot mixed variables

2011-12-05 Thread Juliet Ndukum

 
  
  My data consists of a numeric (yy)
  variable and a categorical (xx) variable, as shown below.
  
 


xx =
c(rep(C, 5), rep(D,5))

yy = rnorm(10, 0, 4)

xx1 =
as.integer(as.factor(xx))

 

plot(xx1, yy, ylim =
c(-13.5, 4), col=blue)

 

I
wish to generate a scatter plot of the data such that instead of 1 it prints C,
and instead of 2, it prints D on the x- axis.

 

Could
someone help me with an R code on how to go about this. Thank you in advance
for your  help,

JN
[[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] args() function does not list function prototype for locally-produced/installed R package

2011-12-05 Thread Duncan Murdoch

On 11-12-05 3:04 PM, Rick Reeves wrote:
 Greetings:

 I have check the 'Building R Extensions' manual and can find no advice
 on this issue,
 so I am asking --

 I have created an R package consisting entirely of R source code, and
 created an installer
 using the R CMD build / R CMD check commands. The package installs
 correctly, using
 R CMD install, and the .Rd files for each function (one function per .R
 / .Rd file) are visible
 using the '?function' command. However, the 'args(function)' command
 does not list the
 function prototype; instead generating the error:

 Error in args(function) : object function not found.

 Question: If it is possible, what changes do I make to my package and
 install process to get
 args() to display the function prototype(s) for the functions in my
 local package?

Is the function visible (e.g., if you type the name of the function, 
does it print)?  I would guess not:  I think you have a NAMESPACE file, 
and you haven't listed this function in it.


If you don't have a NAMESPACE file, or you do have one and you list this 
function, then I think you need to be more forthcoming with accurate 
information.  When I type args(function), I don't get the error you get, 
since function is a reserved word:


 args(function)
Error: unexpected ')' in args(function)

Duncan Murdoch

Duncan Murdoch

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


Re: [R] installing several versions of R (2.14 and 2.12.2) on the same system on Ubuntu

2011-12-05 Thread Duncan Murdoch

On 11-12-05 4:03 PM, Peter Langfelder wrote:

On Mon, Dec 5, 2011 at 11:47 AM, Jannisbt_jan...@yahoo.de  wrote:

Dear R users,


besides the current R 2.14 I would like to install a second version of R 
(2.12.2) on my Ubuntu system. The current version is easily installed as a 
precompiled package from Cran but I am heavily fighting with the older version. 
I tried to follow the instructions here:

http://cran.r-project.org/doc/manuals/R-admin.html

Unfortunately I got totally confused by all the different locations of the 
script, the library and the rest of the program. As I understand these all have 
to be different from the ones of the R 2.14 installation. In case anybody could 
point me to some nice instructions, fell welcome to do so.


Otherwise we would need to check what went wrong during my try. I finally 
managed to install R.2.12.2 but, as it seems, without Java correctly set up and 
without tcltk support (both are needed). r-base-dev is installed.


This I what I did:

1. downloaded R.2.12.2.tar.gz from Cran
2. tar -xzf R-2.12.2.tar.gz
3. sudo cp R-2.12.2 /usr/lib
4. cd /usr/lib/R.2.12.2
5. mkdir prog
5. sudo ./configure --prefix=/usr/bin
6. sudo make prefix=/usr/lib/R-2.12.2/prog rhome=/usr/lib/R-2.12.2/library

7. sudo mv /usr/bin/R /usr/bin/R-2.12.2


Most probably these two arguments for make are not correct as I did not fully understand the 
instructions here. Additionally I would need to facilitate tcl/tk and Java. Both works with R.2.14 
so their dependecies should be installed but I probably need some more arguments during the build 
for that. Also this renaming of the R script seems arkward to me but I did this to easily run 
R-2.12.2 or R-2.14 from the command line.


Does anybody have any advice on how to fix this stuff?


I think you did basically the right thing. To be able to compile R
with tcl/tk, you have to install the development files for tcl/tk - on
Fedora the files are contained in package tcl-devel (this is a
Fedora/Ubuntu package, not an R package). Then run the entire
compilation process (./configure, make, make install) again. When you
install a pre-compiled R, you don't need the development files, which
is probably why you never needed them in the past.

I'm not sure about Java - you may want to examine the output of
configure (which is usually saved in configure.log) to see what is
missing.



Besides what Peter said, I would suggest that you follow the 
instructions for simple compilation in the document you cited.  You 
are doing way too much as a superuser.  You don't need that at all if 
you are the only user who needs this old version of R.  If you need to 
install it for others to use, then follow the instructions for 
installation in that document, and let your users change their path to 
select the R version.


Duncan Murdoch

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


Re: [R] plot mixed variables

2011-12-05 Thread Sarah Goslee
plot(xx1, yy, ylim = c(-13.5, 4), col=blue, xaxt=n)
axis(1, at=c(1, 2), labels=c(C, D))

Defining your own axes with axis() offers a great deal of flexibility.

And thank you for providing a small reproducible example.

Sarah

On Mon, Dec 5, 2011 at 5:43 PM, Juliet Ndukum jpnts...@yahoo.com wrote:



  My data consists of a numeric (yy)
  variable and a categorical (xx) variable, as shown below.




 xx =
 c(rep(C, 5), rep(D,5))

 yy = rnorm(10, 0, 4)

 xx1 =
 as.integer(as.factor(xx))



 plot(xx1, yy, ylim =
 c(-13.5, 4), col=blue)



 I
 wish to generate a scatter plot of the data such that instead of 1 it prints 
 C,
 and instead of 2, it prints D on the x- axis.



 Could
 someone help me with an R code on how to go about this. Thank you in advance
 for your  help,

 JN
        [[alternative HTML version deleted]]




-- 
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] Problem in while loop

2011-12-05 Thread R. Michael Weylandt
If you run

out- epiann(f = function(a,b) log(dnorm(a)*dnorm(b))), N = 10)

It takes less than 0.5 seconds so there's no problem I can see:
perhaps you want to look elsewhere to get better speed (like Rcpp or
general vectorization), or maybe your loglikihood is not what's
desired, but there's no problem with the loop.

Michael

On Mon, Dec 5, 2011 at 5:29 PM, Gyanendra Pokharel
gyanendra.pokha...@gmail.com wrote:
 Yes, I checked the acceptprob, it is very high but in my view, the while
 loop is not stopping, so there is some thing wrong in the use of while loop.
 When I removed the while loop, it returned some thing but not the result
 what I want. When i run the while loop separately, it never stops.



 On Mon, Dec 5, 2011 at 5:18 PM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:

 Your code is not reproducible nor minimal, but why don't you put a
 command print(acceptprob) in and see if you are getting reasonable
 values. If these values are extremely low it shouldn't surprise you
 that your loop takes a long time to run.

 More generally, read up on the use of print() and browser() as debugging
 tools.

 Michael

 On Mon, Dec 5, 2011 at 3:47 PM, Gyanendra Pokharel
 gyanendra.pokha...@gmail.com wrote:
  I forgot to upload the R-code in last email, so heare is one
 
  epiann - function(T0 = 1, N=1000, ainit=1, binit=1,rho = 0.99, amean =
  3,
  bmean=1.6, avar =.1, bvar=.1, f){
 
         moving - 1
         count - 0
         Temp - T0
         aout - ainit
         bout - binit
         while(moving  0){
                 moving - 0
                 for (i in 1:N) {
                 aprop - rnorm (1,amean, avar)
                 bprop - rnorm (1,bmean, bvar)
                 if (aprop  0  bprop  0){
                 acceptprob - min(1,exp((f(aout, bout) -
  f(aprop,bprop))/Temp))
                 u - runif(1)
                 if(uacceptprob){
                     moving - moving +1
                     aout - aprop
                     bout - bprop
                     }
                     else{aprob - aout
                         bprob - bout}
                 }
             }
         Temp - Temp*rho
             count - count +1
 
     }
     fmin - f(aout,bout)
     return(c(aout, bout,fmin, count) )
 
  }
  out- epiann(f = loglikelihood)
 
  On Mon, Dec 5, 2011 at 3:46 PM, Gyanendra Pokharel 
  gyanendra.pokha...@gmail.com wrote:
 
  Hi all,
  I have the following code,
  When I run the code, it never terminate this is because of the while
  loop
  i am using. In general, if you need a loop for which you don't know in
  advance how many iterations there will be, you can use the `while'
  statement so here too i don't know the number how many iterations are
  there. So Can some one suggest me whats going on?
  I am using the Metropolis simulated annealing algorithm
  Best
 
 
         [[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] Plot numeric and categorical variable

2011-12-05 Thread Juliet Ndukum
My data consists of numeric (yy) and categorical (xx) variables, as shown 
below. 
 xx = c(rep(C, 5), rep(D,5)) xx [1] C C C C C D D D D 
 D yy = rnorm(10, 0, 4) yy [1]  2.7219346 -3.7142481  6.8716534 -0.9352463 
  0.4901249  3.8113247 [7] -2.6602041  1.7714471  4.7298233  0.8848188
 xx1 = as.integer(as.factor(xx)) plot(xx1, yy, ylim = c(-13.5, 4), col=blue)
I have attached the plot above  as plot1
I wish to generate a scatter plot of the data such that instead of 1 it prints 
C, and instead of 2, it prints D on the x- axis (see plot1 attached).
How could I possibly go about this, let me know. Any help will be greatly 
appreciated.
Thanks in advance for your help,JN












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


[R] Plotting Time Series Data by Month

2011-12-05 Thread crazedruff
Hi,

I have a dataset which includes monthly data for 17 years. I want to be able
to see the monthly data behavior for the period of all 17 years.

What my data looks like:

http://r.789695.n4.nabble.com/file/n4162534/data.jpg 

I would like to represent the data in a graph such as the one below:

http://r.789695.n4.nabble.com/file/n4162534/Untitled-2.jpg 

Any help would be appreciated.

Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-Time-Series-Data-by-Month-tp4162534p4162534.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] Persp3d freezes when run from within Python

2011-12-05 Thread wchips
Thanks Duncan. The thing is, if you want to display a static R graph using
Rpy2 you need to bring your Python program to a halt immediately after
printing the graph to screen using something like:

raw_input(Press any key to continue ...)

, otherwise it flashes up on the screen for a fraction of a second and then
disappears. I assume this is one and the same issue.. That being, that R is
somehow opened and then _closed_ after each instruction when using Rpy2. So
whilst pausing Python might give you a snapshot of the 3d graph, it
doesn't give you dynamic interactivity. I just need to find a way to keep R
running in the background when I execute that command.

Again, if anyone has had the same problem throw me a line! Or other
suggestions are also welcome.

cheers,
chips

--
View this message in context: 
http://r.789695.n4.nabble.com/Persp3d-freezes-when-run-from-within-Python-tp4158940p4162766.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] Why can't I figure this out? :S

2011-12-05 Thread Jasmine007
Hi, so I don't speak computer and I have no idea what this code is telling
the program to do, but I apparently need to be able to find and isolate
influencial observations. Problem, I have no idea what the error means and
where it may be from in the code.

error I get is below the code

{
## OLS results
NameC- lm(gpanew~female+female:lastinit+agenew+canadian+mom_ed+yearstudy)

## default: choose psamp = quantile
n - length(residuals(NameC))
k - length(coef(NameC))
if(is.null(quantile)) quantile - c(floor((n + k + 1)/2),
floor((n + k)/2))
quantile - rep(quantile, length.out = 2)
if(is.null(psamp)) psamp - quantile[1]

## LTS results with robust residuals
NameC_lts -
lqs(gpanew~female+female:lastinit+agenew+canadian+mom_ed+yearstudy,
quantile = quantile[1], psamp = psamp, nsamp = nsamp)
rr - residuals(NameC_lts)/NameC_lts$scale[2]
rr_nok - abs(rr)  critval[1]
## robust leverage via MCD (or MVE)
X - model.matrix(NameC)[,-1]
cv - cov.rob(X, method = method,
quantile = quantile[2], nsamp = dist_nsamp)
rd - sqrt(mahalanobis(X, cv$center, cv$cov))
rd_nok - rd  critval[2]
## ROBUST results
nok - rr_nok  rd_nok
NameC_rob - lm(formula, data[!nok,])
rval - list(ols = NameC, lts = NameC_lts, robust = NameC_rob,
cov.rob = cv, robresid = rr, robdist = rd,
high_residuals = rr[rr_nok], high_leverage = rd[rd_nok],
bad_leverage = nok, psamp = psamp, method = method,
nsamp = list(lts = nsamp, dist = dist_nsamp),
quantile = list(lts = quantile[1], dist = quantile[2]))
return(rval)
}

Error: object of type 'closure' is not subsettable

Any ideas, In plain non-computer language.. I have a headache from trying to
figure out if this question had been answered before.

Thank you 

--
View this message in context: 
http://r.789695.n4.nabble.com/Why-can-t-I-figure-this-out-S-tp4162826p4162826.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] how to view/edit large matrix/array in R?

2011-12-05 Thread Michael
head, tail and fix commands don't really work well if I have large
matrix/array for which I would like to be able to scroll up and dow, left
and right ...

Could anybody please help me?

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] how to view/edit large matrix/array in R?

2011-12-05 Thread Michael
For example, fix does have scrolling, but could we have a grid based or
cell based viewer/editor just like Excel sheet or like Matlab's object
editor?

For some weird reason, fix can only show numbers a weird format...

On Mon, Dec 5, 2011 at 7:01 PM, Michael comtech@gmail.com wrote:

 head, tail and fix commands don't really work well if I have large
 matrix/array for which I would like to be able to scroll up and dow, left
 and right ...

 Could anybody please help me?

 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] how to view/edit large matrix/array in R?

2011-12-05 Thread Michael
And fix doesn't show the full content...

On Mon, Dec 5, 2011 at 7:07 PM, Michael comtech@gmail.com wrote:

 For example, fix does have scrolling, but could we have a grid based or
 cell based viewer/editor just like Excel sheet or like Matlab's object
 editor?

 For some weird reason, fix can only show numbers a weird format...

  On Mon, Dec 5, 2011 at 7:01 PM, Michael comtech@gmail.com wrote:

 head, tail and fix commands don't really work well if I have large
 matrix/array for which I would like to be able to scroll up and dow, left
 and right ...

 Could anybody please help me?

 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   >