Re: [R] SQL like function?

2007-09-08 Thread Takatsugu Kobayashi
Hi Gabor,

Wow, this is awesome although I eventually should learn MySQL for 
integrating it on web-based DB management using PHP or Perl, this is a 
very helpful tool for me to start with!

Thank you very much

Gabor Grothendieck wrote:
 Others have already pointed out %in% but regarding your comment about
 SQL, you can use SQL to manipulate R data frames using the sqldf package
 which provides an interface to lower level RSQLite (and RMySQL in the future)
 routines.  The following examples use SQLite underneath:

 DF - data.frame(observation = c(1,2,3,4,5))
 ID - data.frame(ID = c(1, 3, 4))

 library(sqldf)
 sqldf(select observation, observation in (select * from ID) `ID?` from DF)

 # or

 sqldf(select observation, observation in (1, 3, 4) `ID?` from DF)

 See home page at:

 http://sqldf.googlecode.com


 On 9/7/07, Takatsugu Kobayashi [EMAIL PROTECTED] wrote:
   
 Hi RUsers,

 I am wonder if I can search observations whose IDs matches any of the
 values in another vector, such as in MySQL. While I am learing MySQL for
 future database management, I appreciate if anyone could give me a hint.

 Suppose I have one 5*1 vector containing observation IDs and
 frequencies, and one 3*1 vector containing observation IDs.

 observation-c(1,2,3,4,5)
 ID-c(1,3,4)

 Then, I would like to program a code that returns a results showing
 matched observations like

 result: TRUE FALSE TRUE TRUE FALSE

 I am reading S programming, but I cannot find a way to do this.

 Thank you very much.

 Taka

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



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


Re: [R] SQL like function?

2007-09-08 Thread Gabor Grothendieck
Great.  Regarding the web, note that there are actually quite a few R
web projects as well:

http://www.lmbe.seu.edu.cn/CRAN/doc/FAQ/R-FAQ.html#R-Web-Interfaces

I have used rpad (www.rpad.org) which has an integrated web server right
in the R package making setup a non-issue.

On 9/8/07, Takatsugu Kobayashi [EMAIL PROTECTED] wrote:
 Hi Gabor,

 Wow, this is awesome although I eventually should learn MySQL for
 integrating it on web-based DB management using PHP or Perl, this is a
 very helpful tool for me to start with!

 Thank you very much

 Gabor Grothendieck wrote:
  Others have already pointed out %in% but regarding your comment about
  SQL, you can use SQL to manipulate R data frames using the sqldf package
  which provides an interface to lower level RSQLite (and RMySQL in the 
  future)
  routines.  The following examples use SQLite underneath:
 
  DF - data.frame(observation = c(1,2,3,4,5))
  ID - data.frame(ID = c(1, 3, 4))
 
  library(sqldf)
  sqldf(select observation, observation in (select * from ID) `ID?` from DF)
 
  # or
 
  sqldf(select observation, observation in (1, 3, 4) `ID?` from DF)
 
  See home page at:
 
  http://sqldf.googlecode.com
 
 
  On 9/7/07, Takatsugu Kobayashi [EMAIL PROTECTED] wrote:
 
  Hi RUsers,
 
  I am wonder if I can search observations whose IDs matches any of the
  values in another vector, such as in MySQL. While I am learing MySQL for
  future database management, I appreciate if anyone could give me a hint.
 
  Suppose I have one 5*1 vector containing observation IDs and
  frequencies, and one 3*1 vector containing observation IDs.
 
  observation-c(1,2,3,4,5)
  ID-c(1,3,4)
 
  Then, I would like to program a code that returns a results showing
  matched observations like
 
  result: TRUE FALSE TRUE TRUE FALSE
 
  I am reading S programming, but I cannot find a way to do this.
 
  Thank you very much.
 
  Taka
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 



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


Re: [R] Lisp-like primitives in R

2007-09-08 Thread Peter Dalgaard
François Pinard wrote:
 [Roland Rau]
   
 [François Pinard]
 

   
 I wonder what happened, for R to hide the underlying Scheme so fully, 
 at least at the level of the surface language (despite there are 
 hints).  
   

   
 To further foster portability, we chose to write R in ANSI C
 

 Yes, of course.  Scheme is also (often) implemented in C.  I meant that 
 R might have implemented a Scheme engine (or part of a Scheme engine, 
 extended with appropriate data types) with a surface language (nearly 
 the S language) which is purposely not Scheme, but could have been.

 If the gap is not extreme, one could dare dreaming that the Scheme 
 engine in R be completed, and Scheme offered as an alternate extension 
 language.  If you allow me to continue dreaming awake -- they told me 
 they will let me free as long as I do not get dangerous! :-) -- part 
 of the interest lies in the fact there are excellent Scheme compilers.  
 If we could only find or devise some kind of marriage between a mature 
 Scheme and R, so to speed up the non-vectorisable parts of R scripts...

   
Well, depending on what you want, this is either trivial or 
impossible... The internal storage of R is still pretty much equivalent 
to scheme. E.g. try this:

  r2scheme - function(e) if (!is.recursive(e))
  deparse(e) else c((, unlist(lapply(as.list(e), r2scheme)), ))
  paste(r2scheme(quote(for(i in 1:4)print(i))), collapse= )
[1] ( for i ( : 1 4 ) ( print i ) )

and a parser that parses a similar language to R internal format is  not 
a very hard exercise (some care needed in places). However, replacing 
the front-end is not going to make anything faster, and the evaluation 
engine in R does a couple of tricks which are not done in Scheme, 
notably lazy evaluation, and other forms of non-local evaluation, which 
drives optimizers crazy. Look up the writings of Luke Tierney on the 
matter to learn more.

 If we are lucky and one of the original authors reads this thread they 
 might explain the situation further and better [...].
 

 In r-devel, maybe!  We would be lucky if the authors really had time to 
 read r-help. :-)

   


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


[R] Using clustering functions

2007-09-08 Thread uv

Hi. I need to use a few different clustering functions. I managed to run the
kmeans() one which is in my stats library, but I can't use any function,
such as agnes(), that is in my cluster library. Any idea how to access
other libraries? 
Thanks!
-- 
View this message in context: 
http://www.nabble.com/Using-clustering-functions-tf4401159.html#a12554686
Sent from the R help mailing list archive at Nabble.com.

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


[R] Covariates and clustering of extremes

2007-09-08 Thread Dag J. Steinskog

I am looking at some extremes, and I want to implement covariates in my
analysis. My work is on daily datasets, and I use the cluster of exceedences
approach in fpot (evd-package) to estimate the parameters in the General
Pareto Distribution. How to include covariates like e.g. time is my question
then.  

In advance, thanks for all help!


-- 
View this message in context: 
http://www.nabble.com/Covariates-and-clustering-of-extremes-tf4396856.html#a12538022
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Plotting lines to sets of points

2007-09-08 Thread Jim Price

# Create a matrix of ball locations
# You'd do this using the calls within your points function
balls - matrix(c(0,50,25,-150,-100,-50), ncol=2, byrow=F)


# Draw a line from the origin to each ball location
apply(balls, 1, function(x) lines(c(125, x[1]), c(-210, x[2]), col='red'))



A more complete example might loop over all the unique elements of
framename$hit_traj, and then run this procedure for each value with a
different colour, plotting both ball points and trajectories.



lawnboy34 wrote:
 
 I am using R to plot baseball spray charts from play-by-play data. I have
 used the following command to plot the diamond:
 
 plot (0:250, -250:0, type=n, bg=white)
   lines(c(125,150,125,100,125),c(-210,-180,-150,-180,-210), 
 col=c(black))
 
 I have also plotted different hit locations using commands such as the
 following:
 
 points(subset(framename$hit_x, framename$hit_traj==line_drive),
 subset(-framename$hit_y, framename$hit_traj==line_drive), pch=20,
 col=c(red))
 
 My question: Is there any easy way to plot a line from the origin (home
 plate) to each point on the graph? Preferably the line would share the
 same color as the dot that denotes where the ball landed. I have tried
 searching Google and these forums, and most graphing questions have to do
 with scatterplots or other varieties of graphs I am not using. Thanks very
 much in advance.
 
 -Jason
 

-- 
View this message in context: 
http://www.nabble.com/Plotting-lines-to-sets-of-points-tf4404235.html#a12564959
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] enable object name to be called as object (a dataset)

2007-09-08 Thread Jim Price

a - 1:3
b - 11:13
c - 21:23

names - c('a','b','c')

do.call(data.frame, list(sapply(names, function(x) get(x



runner wrote:
 
 What I am trying to do is as follows:
 
 - I have listed names of all wanted objects (datasets A,B,C... ) in
 current workspace as a vector: 
 
 obj - c('A','B','C')
 
 - then i need to use these objects, say to extract all the 1st columns and
 bind to an existing dataset ('data'): 
  
 for ( i in 1:3){
 newdata - obj[i] 
 data - cbind(data,newdata [[1]] )
 }
 
 Obviously, it doesn't work since obj[i] is just a string of dataset name.
 Here is my question: how to call it as a original dataset? Thanks.
 

-- 
View this message in context: 
http://www.nabble.com/enable-object-name-to-be-called-as-object-%28a-dataset%29-tf4403933.html#a12564175
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] FW: variable format

2007-09-08 Thread Martin Becker
Frank E Harrell Jr wrote:
 Martin Becker wrote:
 Dear Cory,

 I am not familiar with SAS, but is this what you are looking for?

 divisionTable - matrix(c(1, New England,
   2, Middle Atlantic,
   3, East North Central,
   4, West North Central,
   5, South Atlantic,
   6, East South Central,
   7, West South Central,
   8, Mountain,
   9, Pacific),
 ncol=2, byrow=T)

 How about just divisionTable - c('New England', 'Middle Atlantic', 
 ...) then factor(old, 1:9, divisionTable) ?

 Frank


Of course, this solution is more elegant, but my intention was
1. to provide a solution which makes use of the exisiting object 
divisionTable
2. to reproduce the output from the working example (-conversion to 
character)
Maybe I should have emphasized that I was quoting the existing 
definition of divisionTable from the original email (for the sake of 
providing self-contained code) and not introducing a unnecessarily 
complicated new definition of divisionTable.

Regards,

 Martin

 a - NULL
 a$divisionOld - c(0,1,2,3,4,5)
 a$divisionNew - 
 as.character(factor(a$divisionOld,levels=divisionTable[,1],labels=divisionTable[,2]))
  

 a$divisionNew

 [1] NA   New EnglandMiddle Atlantic  [4] 
 East North Central West North Central South Atlantic

 Kind regards,

   Martin


 Cory Nissen schrieb:
 
 Anybody? 

 

 From: Cory Nissen
 Sent: Tue 9/4/2007 9:30 AM
 To: r-help@stat.math.ethz.ch
 Subject: variable format


 Okay, I want to do something similar to SAS proc format.

 I usually do this...

 a - NULL
 a$divisionOld - c(1,2,3,4,5)
 divisionTable - matrix(c(1, New England,
   2, Middle Atlantic,
   3, East North Central,
   4, West North Central,
   5, South Atlantic),
 ncol=2, byrow=T)
 a$divisionNew[match(a$divisionOld, divisionTable[,1])] - 
 divisionTable[,2]

 But how do I handle the case where...
 a$divisionOld - c(0,1,2,3,4,5)   #no format available for 0, this 
 throws an error.
 OR
 divisionTable - matrix(c(1, New England,
   2, Middle Atlantic,
   3, East North Central,
   4, West North Central,
   5, South Atlantic,
   6, East South Central,
   7, West South Central,
   8, Mountain,
   9, Pacific),
 ncol=2, byrow=T)   There are extra formats 
 available... this throws a warning.

 Thanks

 Cory

 [[alternative HTML version deleted]]

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


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




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


Re: [R] Matlab's lsqnonlin

2007-09-08 Thread Martin Maechler
 KateM == Katharine Mullen [EMAIL PROTECTED]
 on Fri, 7 Sep 2007 20:07:41 +0200 (CEST) writes:

KateM The thread you linked to regarding Levenberg-Marquardt's supposed 
lack of
KateM availability is from 2001; it has been possible to get
KateM to the MINPACK implementation of Levenberg-Marquardt within R via the
KateM package minpack.lm
KateM (http://cran.r-project.org/src/contrib/Descriptions/minpack.lm.html) 
since
KateM 2005.

Thanks a lot, Kate.

I'm wondering about experiences:
Do you know of cases where  minpack.lm's  nls.lm() solved a
(real) problem that nls() would have a problem with ?

Beware however -- one of the main things I learned about this
field from Doug Bates, co-author of Bates_and_Watts and
prinicipal author of S's and R's nls() :
It's a *feature* that nls() does not converge sometimes when
other methods do falsely claim convergence!

Martin Maechler, ETH Zurich

KateM 
KateM Katharine Mullen
KateM mail: Department of Physics and Astronomy, Faculty of Sciences
KateM Vrije Universiteit Amsterdam, de Boelelaan 1081
KateM 1081 HV Amsterdam, The Netherlands
KateM room: T.1.06
KateM tel: +31 205987870
KateM fax: +31 205987992
KateM e-mail: [EMAIL PROTECTED]
KateM homepage: http://www.nat.vu.nl/~kate/


KateM On Fri, 7 Sep 2007, Jose Luis Aznarte M. wrote:

 Hi! I'm translating some code from Matlab to R and I found a problem.
 I need to translate Matlab's function 'lsqnonlin'
 (http://www-ccs.ucsd.edu/matlab/toolbox/optim/lsqnonlin.html) into R,
 and at the beginning I  thought it would be the same as R's 'optim'. But
 then I looked at the definition of 'lsqnonlin' and I don't quite see how
 to make 'optim' to do the same thing. Does anyone have an idea?
 This is apart from the fact that I would like to use the Levenberg
 Marquardt algorithm which is not implemented in R (some discussion about
 this: http://tolstoy.newcastle.edu.au/R/help/00b/2492.html).
 Thank you! All the best,
 
 
 --  --
 Jose Luis Aznarte M.   http://decsai.ugr.es/~jlaznarte
 Department of Computer Science and Artificial Intelligence
 Universidad de Granada   Tel. +34 - 958 - 24 04 67
 GRANADA (Spain)  Fax: +34 - 958 - 24 00 79
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

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


[R] argument 'lib' is missing: using '/usr/lib/R/library'

2007-09-08 Thread Paul Smith
Dear All,

When installing packages, I get the following warning:

 install.packages(sqldf)
Warning in install.packages(sqldf) : argument 'lib' is missing:
using '/usr/lib/R/library'

Any ideas?

The details of my R installation are:

 version
   _
platform   i386-redhat-linux-gnu
arch   i386
os linux-gnu
system i386, linux-gnu
status
major  2
minor  5.1
year   2007
month  06
day27
svn rev42083
language   R
version.string R version 2.5.1 (2007-06-27)


R is here installed on Fedora 7.

Thanks in advance,

Paul

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


Re: [R] argument 'lib' is missing: using '/usr/lib/R/library'

2007-09-08 Thread Gabor Csardi
Paul, what is the question? If the question is why you get this 
warning message, the reason is that the 'lib' argument is missing
and install.packages is using '/usr/lib/R/library'.

If you want to get rid of the warning supply the 'lib' argument.

Gabor

On Sat, Sep 08, 2007 at 11:26:44AM +0100, Paul Smith wrote:
 Dear All,
 
 When installing packages, I get the following warning:
 
  install.packages(sqldf)
 Warning in install.packages(sqldf) : argument 'lib' is missing:
 using '/usr/lib/R/library'
 
 Any ideas?
 
 The details of my R installation are:
 
  version
_
 platform   i386-redhat-linux-gnu
 arch   i386
 os linux-gnu
 system i386, linux-gnu
 status
 major  2
 minor  5.1
 year   2007
 month  06
 day27
 svn rev42083
 language   R
 version.string R version 2.5.1 (2007-06-27)
 
 
 R is here installed on Fedora 7.
 
 Thanks in advance,
 
 Paul
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK

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


Re: [R] R survey package again

2007-09-08 Thread James Reilly

On 7/9/07 11:42 PM, eugen pircalabelu wrote:
I have a sample from a survey where household were interviewed. The 
sample has 4 criteria on which the stratification was based: REGION, 
SIZE OF HOUSEHOLD, SIZE OF LOCALITY, AGE OF HEAD OF HOUSEHOLD. Since i 
don't have the whole information in each cell of the cross 
region*sizehh*sizeloc*age i can't use the postStratify function from 
Survey package. Is that correct? (I think so but i need a competent answer)
 
The only additional info that i have is the size of a cell from a 
2*2 crossing (eg: I know the population size for all the strata defined 
by region*sizehh, region*sizeloc, sizeloc*age) so i have the 
behaviour of the population but in a 2 by 2 cross for each of these 
criteria.


You're right, poststratification can't work from two-way marginal 
distributions, but raking or calibration can.

However it seems odd that you only have this much information, since the 
full joint distribution would have been needed for stratification. 
Usually these details would be documented as part of the sample design. 
Can you get this information from those responsible for the sample 
design? It would also be good to check your understanding of the design. 
A sampling frame listing details of household size and age of household 
head would have been needed to do the four-way stratification you 
mention, but in my experience such frames aren't very common.

James
-- 
James Reilly
Department of Statistics, University of Auckland
Private Bag 92019, Auckland, New Zealand

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


Re: [R] Matlab's lsqnonlin

2007-09-08 Thread Katharine Mullen

 I'm wondering about experiences:
 Do you know of cases where  minpack.lm's  nls.lm() solved a
 (real) problem that nls() would have a problem with ?


In short, no.  However, I looked at this question in the limited context
of fitting the parameters of a linear superposition of 2 exponentials with
Gaussian noise.  A simulation study showed nearly identical performance
for the range of parameter values/noise levels that are of practical
interest to us.

Are there problems for which steepest descent gets you in the neighborhood
of a solution whereas GN does not?  If such problems exist then there
would be reason to apply LM instead of GN, but I don't know of any.

 Beware however -- one of the main things I learned about this
 field from Doug Bates, co-author of Bates_and_Watts and
 prinicipal author of S's and R's nls() :
 It's a *feature* that nls() does not converge sometimes when
 other methods do falsely claim convergence!

 Martin Maechler, ETH Zurich

 KateM 
 KateM Katharine Mullen
 KateM mail: Department of Physics and Astronomy, Faculty of Sciences
 KateM Vrije Universiteit Amsterdam, de Boelelaan 1081
 KateM 1081 HV Amsterdam, The Netherlands
 KateM room: T.1.06
 KateM tel: +31 205987870
 KateM fax: +31 205987992
 KateM e-mail: [EMAIL PROTECTED]
 KateM homepage: http://www.nat.vu.nl/~kate/


 KateM On Fri, 7 Sep 2007, Jose Luis Aznarte M. wrote:

  Hi! I'm translating some code from Matlab to R and I found a problem.
  I need to translate Matlab's function 'lsqnonlin'
  (http://www-ccs.ucsd.edu/matlab/toolbox/optim/lsqnonlin.html) into R,
  and at the beginning I  thought it would be the same as R's 'optim'. 
 But
  then I looked at the definition of 'lsqnonlin' and I don't quite see 
 how
  to make 'optim' to do the same thing. Does anyone have an idea?
  This is apart from the fact that I would like to use the Levenberg
  Marquardt algorithm which is not implemented in R (some discussion 
 about
  this: http://tolstoy.newcastle.edu.au/R/help/00b/2492.html).
  Thank you! All the best,
 
 
  --  --
  Jose Luis Aznarte M.   http://decsai.ugr.es/~jlaznarte
  Department of Computer Science and Artificial Intelligence
  Universidad de Granada   Tel. +34 - 958 - 24 04 67
  GRANADA (Spain)  Fax: +34 - 958 - 24 00 79
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

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


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


Re: [R] Help with color coded bar graph

2007-09-08 Thread Jim Lemon
Luis Naver wrote:
 I have a list of observations that are -1, 1 or 0.  I would like to  
 represent them in a horizontal bar color coded based on value like a  
 stacked bar graph. I can achieve this in the form of a png with the  
 following code:
 
 A = floor(runif(10)*3) - 1
 
 png(width=100, height=10)
 par(mar=c(0,0,0,0))
 image(matrix(A), col=grey(c(0.1, 0.5, 0.9)))
 dev.off()
 
 However I would like to do this with one of the standard plotting  
 tools (i.e. barplot) to take advantage of labels and multiple  
 series.  Any help would be appreciated.
 
Hi Luis,
I understood your request as wanting a single horizontal bar with 10 
segments, each colored according to the value of A. If this is correct, 
you might want:

library(plotrix)
plot(1,xlim=c(-1,1),ylim=c(-1,1),xlab=,ylab=,type=n,axes=FALSE)
gradient.rect(-1,-0.1,1,0.1,col=grey(c(0.1,0.5,0.9))[A+2])

Jim

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


Re: [R] argument 'lib' is missing: using '/usr/lib/R/library'

2007-09-08 Thread Paul Smith
On 9/8/07, Gabor Csardi [EMAIL PROTECTED] wrote:
 Paul, what is the question? If the question is why you get this
 warning message, the reason is that the 'lib' argument is missing
 and install.packages is using '/usr/lib/R/library'.

 If you want to get rid of the warning supply the 'lib' argument.

Thanks, Gabor. Yes, I want to get rid of the warning message. Since
the warning did not appear before, even without supplying the 'lib'
argument, I thought that something was wrong here.

Paul





 On Sat, Sep 08, 2007 at 11:26:44AM +0100, Paul Smith wrote:
  Dear All,
 
  When installing packages, I get the following warning:
 
   install.packages(sqldf)
  Warning in install.packages(sqldf) : argument 'lib' is missing:
  using '/usr/lib/R/library'
 
  Any ideas?
 
  The details of my R installation are:
 
   version
 _
  platform   i386-redhat-linux-gnu
  arch   i386
  os linux-gnu
  system i386, linux-gnu
  status
  major  2
  minor  5.1
  year   2007
  month  06
  day27
  svn rev42083
  language   R
  version.string R version 2.5.1 (2007-06-27)
  
 
  R is here installed on Fedora 7.
 
  Thanks in advance,
 
  Paul
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 --
 Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK


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


Re: [R] genoud problem

2007-09-08 Thread Jasjeet Singh Sekhon

Hi Shubha,

genoud does not return the initial fit value.  But you could easily
obtain it by passing your starting values to your function directly.
Alternatively, one can have genoud print out the entire initial
population (or the entire population as is evolves), and one can then
decide to report whatever summary of this one would like.  Note that
the best fit in generation zero is printed by default.  See the
project.path and print.level options for details.

Cheers,
Jas.

===
Jasjeet S. Sekhon 
  
Associate Professor 
Travers Department of Political Science
Survey Research Center  
UC Berkeley 

http://sekhon.berkeley.edu/
V: 510-642-9974  F: 617-507-5524
===


Shubha Vishwanath Karanth writes:
  Hi R users,
  
   
  
  genoud function of rgenoud package will optimize my function. If 
  
   
  
  opt = genoud(fn,2,max=TRUE,starting.value=c(1,10),)
  
   
  
  opt$value will give the optimized value of the function, fn. My
  problem is from the same opt, can I get the value of the function at the
  initial parameter values? I need the initial value of the function for
  reporting purposes.
  
   
  
   
  
   
  
  BR, Shubha
  
  
   [[alternative HTML version deleted]]
  
 

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


Re: [R] Running a PERL script from R

2007-09-08 Thread Paul Hiemstra
Dear Ken.

You could also try and use RSPerl (http://www.omegahat.org/RSPerl/). It 
allows one to use R commands in Perl and vice-versa.

regards,

Paul

Pierce, Ken schreef:
 Is there a way to run a simple perl script from R?
  

 Kenneth B. Pierce Jr.

 Research Ecologist

 Landscape Ecology, Modeling, Mapping and Analysis Team 

 PNW Research Station - USDA-FS 

 3200 SW Jefferson Way,  Corvallis,  OR 97331 

 [EMAIL PROTECTED]

 541 750-7393 

 http://www.fsl.orst.edu/lemma/gnnfire

 http://www.fsl.orst.edu/R_users/index.php

  

   [[alternative HTML version deleted]]

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


-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone: +31302535773
Fax:+31302531145
http://intamap.geo.uu.nl/~paul

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


Re: [R] Lisp-like primitives in R

2007-09-08 Thread Gabor Grothendieck
On 9/8/07, Peter Dalgaard [EMAIL PROTECTED] wrote:
 François Pinard wrote:
  [Roland Rau]
 
  [François Pinard]
 
 
 
  I wonder what happened, for R to hide the underlying Scheme so fully,
  at least at the level of the surface language (despite there are
  hints).
 
 
 
  To further foster portability, we chose to write R in ANSI C
 
 
  Yes, of course.  Scheme is also (often) implemented in C.  I meant that
  R might have implemented a Scheme engine (or part of a Scheme engine,
  extended with appropriate data types) with a surface language (nearly
  the S language) which is purposely not Scheme, but could have been.
 
  If the gap is not extreme, one could dare dreaming that the Scheme
  engine in R be completed, and Scheme offered as an alternate extension
  language.  If you allow me to continue dreaming awake -- they told me
  they will let me free as long as I do not get dangerous! :-) -- part
  of the interest lies in the fact there are excellent Scheme compilers.
  If we could only find or devise some kind of marriage between a mature
  Scheme and R, so to speed up the non-vectorisable parts of R scripts...
 
 
 Well, depending on what you want, this is either trivial or
 impossible... The internal storage of R is still pretty much equivalent
 to scheme. E.g. try this:

   r2scheme - function(e) if (!is.recursive(e))
  deparse(e) else c((, unlist(lapply(as.list(e), r2scheme)), ))
   paste(r2scheme(quote(for(i in 1:4)print(i))), collapse= )
 [1] ( for i ( : 1 4 ) ( print i ) )


Also see showTree in codetools:

 library(codetools)
 showTree(quote(for(i in 1:4)print(i)))
(for i (: 1 4) (print i))

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


Re: [R] Running a PERL script from R

2007-09-08 Thread Dirk Eddelbuettel

On 7 September 2007 at 14:04, Pierce, Ken wrote:
| I've tried various configurations of .script, system and shell to no
| avail. It seems to pause and run something but then no output is
| created. 

Make sure you read the help page for system, and understand the options. Esp
on Windows, you will need them to display/capture what is happening.

Dirk


| -Original Message-
| From: Dirk Eddelbuettel [mailto:[EMAIL PROTECTED] 
| Sent: Friday, September 07, 2007 1:11 PM
| To: Pierce, Ken
| Cc: r-help
| Subject: Re: [R] Running a PERL script from R
| 
| On Fri, Sep 07, 2007 at 12:15:51PM -0700, Pierce, Ken wrote:
|  Is there a way to run a simple perl script from R?
| 
| ?system
| 
| Hth, Dirk
| 
| --
| Three out of two people have difficulties with fractions.

-- 
Three out of two people have difficulties with fractions.

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


Re: [R] confusion matrix - better code?

2007-09-08 Thread Monica Pisica

Michael,
 
Thank you very much. My code is certainly put to shame by yours. I promise to 
read about factor to see how you use it and why ;-))
 
I really appreciate your help.
 
Monica
 Subject: RE: [R] confusion matrix - better code? Date: Fri, 7 Sep 2007 
 15:36:00 -0500 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED]  How about 
 this?   
 tab-table(factor(tr,levels=unique(tr)),factor(pr,levels=unique(tr)))  
 tab-rbind(tab,colSums(tab))  tab-cbind(tab,rowSums(tab))  tab 1 2 3 4 
  1 2 1 0 0 3 2 2 1 0 0 3 3 0 0 3 0 3 4 0 1 0 0 1 4 3 3 0 10   Of 
 course you can add some dimnames for the 5th row and 5th column if you 
 want.  dimnames(tab)[[1]][5]-Total dimnames(tab)[[2]][5]-Total  
 tab 1 2 3 4 Total 1 2 1 0 0 3 2 2 1 0 0 3 3 0 0 3 0 3 4 0 1 0 0 1 Total 
 4 3 3 0 10  Michael Conklin  Chief Methodologist - Advanced Analytics  
   MarketTools, Inc.  6465 Wayzata Blvd. Suite 170  Minneapolis, MN 
 55426   Tel: 952.417.4719 | Mobile:612.201.8978  [EMAIL PROTECTED]
 MarketTools(r) http://www.markettools.comThis e-mail and any 
 attachments may contain privileged, confidential or proprietary information. 
 If you are not the intended recipient, be aware that any review, copying, or 
 distribution of this e-mail or any attachment is strictly prohibited. If you 
 have received this e-mail in error, please return it to the sender 
 immediately, and permanently delete the original and any copies from your 
 system. Thank you for your cooperation.-Original Message- 
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Monica 
 Pisica Sent: Friday, September 07, 2007 2:53 PM To: 
 r-help@stat.math.ethz.ch Subject: [R] confusion matrix - better code? 
 Importance: High   Hi,  I've written some code to obtain a confusion 
 matrix when the true classification and the predicted classification are 
 known. Suppose true classification is called tr and predicted 
 classification is pr. I have 4 classes in tr, but only 3 classes out of 4 
 are predicted in pr. Following is my code, but looks quite clunky to me. 
 I wonder if you have any suggestions to improve it.  Thanks,  Monica  
 -  tr - c(1,2,2,3,3,3,2,4,1,1) 
 pr-c(1,2,1,3,3,3,1,2,1,2) dat - data.frame(tr, pr) class - 
 c(1:length(tr)) m - max(c(length(unique(tr)), length(unique(pr for(i 
 in 1:length(class)) { class[i] - sub(' ','',paste(dat[i,1],dat[i,2])) } 
 dat - data.frame(dat, class) mat - matrix(0, nrow=m, ncol=m) for (i in 
 1:m){ for (j in 1:m){ mat[i,j] - sub(' ','',paste(i,j)) }} cat - 
 matrix(0, nrow=(m+1), ncol=(m+1)) for (i in 1:m){ for(j in 1:m){ 
 cat[i,j]- nrow(dat[dat$class==mat[i,j],]) }} for (i in 1:m){ 
 cat[(m+1),i]-sum(cat[1:m,i]) cat[i,(m+1)]- sum(cat[i,1:m]) 
 cat[(m+1),(m+1)] - sum(cat[1:m,(m+1)]) } cat [,1] [,2] [,3] [,4] [,5] 
 [1,] 2 1 0 0 3 [2,] 2 1 0 0 3 [3,] 0 0 3 0 3 [4,] 0 1 0 0 1 [5,] 4 3 3 0 
 10  The 5th row / col represents the sum on each row / col respectively. 
 _ Gear up 
 for Halo(r) 3 with free downloads and an exclusive offer. It's our way of 
 saying thanks for using Windows Live(tm).  [[alternative HTML version 
 deleted]] 
_

é.

[[alternative HTML version deleted]]

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


Re: [R] Lisp-like primitives in R

2007-09-08 Thread François Pinard
[Peter Dalgaard]
[François Pinard]

I meant that R might have implemented a Scheme engine [...] with 
a surface language [...] which is purposely not Scheme, but could have 
been.  [...] one could dare dreaming that the Scheme engine in R be 
completed, and Scheme offered as an alternate extension language.  
[...] there are excellent Scheme compilers.  [...]

Well, depending on what you want, this is either trivial or 
impossible...

I'm more leaning on the impossible side :-).

The internal storage of R is still pretty much equivalent to scheme.

R needs a few supplementary data types, and it motivated the R authors 
into re-implementing their own Scheme engine instead of relying on an 
existing implementation of a Scheme system.

  r2scheme - function(e) [...]

Nice exercise! :-)

a parser that parses a similar language to R internal format is  not 
a very hard exercise (some care needed in places). However, replacing 
the front-end is not going to make anything faster,

Of course.  The idea is nothing more than to please people starving to 
use Scheme instead of S as a surface language, here and there in 
scripts.  I merely thought that if the gap is small enough (so to not 
require an extraordinary effort), it would be worth the leap.  One 
immediate difficulty to foresee is the name clashes between R and RnRS.
There might also be missing things in R (like continuations, say).

To make anything faster, and this is a totally different idea, one might 
consider replacing the back-end, not the front-end.  Writing good 
optimizing Scheme compilers is quite an undertaking, and if one only 
considers type inference (as a subproblem), this still is an active 
research area.  The Scheme engine in R was written as to quickly get 
a working S (non-obstant lexical scoping and some library issues).
My ramble was about switching this quick base of R to some solid Scheme 
implementation, than to re-address separately compiling issues for R.

and the evaluation engine in R does a couple of tricks which are not 
done in Scheme, notably lazy evaluation,

Promises?  Aren't they already part of Scheme?  The main difference 
I saw is their systematic use in R argument passing.  All aspects of 
mere argument passing would require a lot of thought.  As you wrote, 
variable scope is another difficulty.  Offering a compatible C API, and 
library interface in general, might be a frightening but necessary 
challenge.  It's all more of a dream than a thought, actually... :-)

Look up the writings of Luke Tierney on the matter to learn more.

Thanks for this interesting reference.

-- 
François Pinard   http://pinard.progiciels-bpi.ca

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


Re: [R] R first.id last.id function error

2007-09-08 Thread Gerard Smits
Hi Jim,

Thanks for going to the trouble of writing the function. I'll copy and try it.

Gerard



At 06:30 PM 9/7/2007, jim holtman wrote:
This function should do it for you:


  file1 - read.table(textConnection(   id rx week dv1
+ 1   1  11   1
+ 2   1  12   1
+ 3   1  13   2
+ 4   2  11   3
+ 5   2  12   4
+ 6   2  13   1
+ 7   3  11   2
+ 8   3  12   3
+ 9   3  13   4
+ 10  4  11   2
+ 11  4  12   6
+ 12  4  13   5
+ 13  5  21   7
+ 14  5  22   8
+ 15  5  23   5
+ 16  6  21   2
+ 17  6  22   4
+ 18  6  23   6
+ 19  7  21   7
+ 20  7  22   8
+ 21  8  21   9
+ 22  9  21   4
+ 23  9  22   5), header=TRUE)
 
  mark.function -
+ function(df){
+ df - df[order(df$id, df$week),]
+ # create 'diff' of 'id' to determine where the breaks are
+ breaks - diff(df$id)
+ # the first entry will be TRUE, and then every occurance of
non-zero in breaks
+ df$first.id - c(TRUE, breaks != 0)
+ # the last entry is TRUE and every non-zero breaks
+ df$last.id - c(breaks != 0, TRUE)
+ df
+ }
 
  mark.function(file1)
id rx week dv1 first.id last.id
1   1  11   1 TRUE   FALSE
2   1  12   1FALSE   FALSE
3   1  13   2FALSETRUE
4   2  11   3 TRUE   FALSE
5   2  12   4FALSE   FALSE
6   2  13   1FALSETRUE
7   3  11   2 TRUE   FALSE
8   3  12   3FALSE   FALSE
9   3  13   4FALSETRUE
10  4  11   2 TRUE   FALSE
11  4  12   6FALSE   FALSE
12  4  13   5FALSETRUE
13  5  21   7 TRUE   FALSE
14  5  22   8FALSE   FALSE
15  5  23   5FALSETRUE
16  6  21   2 TRUE   FALSE
17  6  22   4FALSE   FALSE
18  6  23   6FALSETRUE
19  7  21   7 TRUE   FALSE
20  7  22   8FALSETRUE
21  8  21   9 TRUETRUE
22  9  21   4 TRUE   FALSE
23  9  22   5FALSETRUE
 
 


On 9/7/07, Gerard Smits [EMAIL PROTECTED] wrote:
  Hi R users,
 
  I have a test dataframe (file1, shown below) for which I am trying
  to create a flag for the first and last ID record (equivalent to SAS
  first.id and last.id variables.
 
  Dump of file1:
 
file1
 id rx week dv1
  1   1  11   1
  2   1  12   1
  3   1  13   2
  4   2  11   3
  5   2  12   4
  6   2  13   1
  7   3  11   2
  8   3  12   3
  9   3  13   4
  10  4  11   2
  11  4  12   6
  12  4  13   5
  13  5  21   7
  14  5  22   8
  15  5  23   5
  16  6  21   2
  17  6  22   4
  18  6  23   6
  19  7  21   7
  20  7  22   8
  21  8  21   9
  22  9  21   4
  23  9  22   5
 
  I have written code that correctly assigns the first.id and 
 last.id variabes:
 
  require(Hmisc)  #for Lags
  #ascending order to define first dot
  file1- file1[order(file1$id, file1$week),]
  file1$first.id - (Lag(file1$id) != file1$id)
  file1$first.id[1]-TRUE  #force NA to TRUE
 
  #descending order to define last dot
  file1- file1[order(-file1$id,-file1$week),]
  file1$last.id  - (Lag(file1$id) != file1$id)
  file1$last.id[1]-TRUE   #force NA to TRUE
 
  #resort to original order
  file1- file1[order(file1$id,file1$week),]
 
 
 
  I am now trying to get the above code to work as a function, and am
  clearly doing something wrong:
 
first.last - function (df, idvar, sortvars1, sortvars2)
  +   {
  +   #sort in ascending order to define first dot
  +   df- df[order(sortvars1),]
  +   df$first.idvar - (Lag(df$idvar) != df$idvar)
  +   #force first record NA to TRUE
  +   df$first.idvar[1]-TRUE
  +
  +   #sort in descending order to define last dot
  +   df- df[order(-sortvars2),]
  +   df$last.idvar  - (Lag(df$idvar) != df$idvar)
  +   #force last record NA to TRUE
  +   df$last.idvar[1]-TRUE
  +
  +   #resort to original order
  +   df- df[order(sortvars1),]
  +   }
   
 
  Function call:
 
first.last(df=file1, idvar=file1$id,
  sortvars1=c(file1$id,file1$week), sortvars2=c(-file1$id,-file1$week))
 
  R Error:
 
  Error in as.vector(x, mode) : invalid argument 'mode'
   
 
  I am not sure about the passing of the sort strings.  Perhaps this is
  were things are off.  Any help greatly appreciated.
 
  Thanks,
 
  Gerard
 [[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


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

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

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

[R] Suppress 'x' when appending to a csv file

2007-09-08 Thread John Kane
Is there any convenient way to supress the x that
appears in csv export files?  I would like to be able
to export a file and add a comment to it yet still be
able to read it back into R.  I don't see any way to
get rid of the x that seperates the different appended
parts.

Thanks

EXAMPLE

x
1
2
3
4
5
x
#Results from file SSS.r

R.2.5.1 Windows XP

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


Re: [R] Suppress 'x' when appending to a csv file

2007-09-08 Thread Marc Schwartz
On Sat, 2007-09-08 at 11:41 -0400, John Kane wrote:
 Is there any convenient way to supress the x that
 appears in csv export files?  I would like to be able
 to export a file and add a comment to it yet still be
 able to read it back into R.  I don't see any way to
 get rid of the x that seperates the different appended
 parts.
 
 Thanks
 
 EXAMPLE
 
 x
 1
 2
 3
 4
 5
 x
 #Results from file SSS.r
 
 R.2.5.1 Windows XP

John,

Try this:

 write.table(head(iris), sep = ,, 
  row.names = FALSE, col.names = FALSE)
5.1,3.5,1.4,0.2,setosa
4.9,3,1.4,0.2,setosa
4.7,3.2,1.3,0.2,setosa
4.6,3.1,1.5,0.2,setosa
5,3.6,1.4,0.2,setosa
5.4,3.9,1.7,0.4,setosa


You may need to explicitly adjust other arguments that are otherwise set
to defaults when using write.csv().

HTH,

Marc Schwartz

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


Re: [R] Using clustering functions

2007-09-08 Thread Uwe Ligges


uv wrote:
 Hi. I need to use a few different clustering functions. I managed to run the
 kmeans() one which is in my stats library, but I can't use any function,
 such as agnes(), that is in my cluster library. Any idea how to access
 other libraries? 
 Thanks!


Both stats and cluster are packages, not libraries.
You need to call library(cluster) in order to load package cluster 
from your library before using agnes() and her friends.


Uwe Ligges

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


Re: [R] Problem in installing packages on linux machine...

2007-09-08 Thread tkobayas
Hi,

I am trying to install RSQLite package on my Fedora workstation. I 
tried to install other packages as well, but each time I got the same 
error messages saying compilation error and non zero exit status. 
Do I have to specify lib=? I never specified the library path before 
when I was using Fedora Core 6.


Warning in install.packages(RSQLite) : argument 'lib' is missing: 
using '/usr/lib/R/library'
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/RSQLite_0.5-6.tar.gz'
Content type 'application/x-gzip' length 710241 bytes
opened URL
==
downloaded 693Kb

gcc -std=gnu99 -shared -L/usr/local/lib -o RSQLite.so RS-DBI.o 
RS-SQLite.o sqlite-all.o   -L/usr/lib/R/lib -lR
/usr/bin/ld: skipping incompatible /usr/lib/R/lib/libR.so when 
searching for -lR
/usr/bin/ld: cannot find -lR
collect2: ld returned 1 exit status
make: *** [RSQLite.so] Error 1
chmod: cannot access `/usr/lib/R/library/RSQLite/libs/*': No such file 
or directory
ERROR: compilation failed for package 'RSQLite'
** Removing '/usr/lib/R/library/RSQLite'

The downloaded packages are in
/tmp/RtmpHQ5Y7C/downloaded_packages
Warning message:
installation of package 'RSQLite' had non-zero exit status in: 
install.packages(RSQLite)

I appreciate your help.

Thank you very much

Taka

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


Re: [R] Problem in installing packages on linux machine...

2007-09-08 Thread Henrique Dallazuanna
Hi, try install packages whit 'sudo'.

$sudo R

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

On 08/09/2007, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Hi,

 I am trying to install RSQLite package on my Fedora workstation. I
 tried to install other packages as well, but each time I got the same
 error messages saying compilation error and non zero exit status.
 Do I have to specify lib=? I never specified the library path before
 when I was using Fedora Core 6.


 Warning in install.packages(RSQLite) : argument 'lib' is missing:
 using '/usr/lib/R/library'
 --- Please select a CRAN mirror for use in this session ---
 Loading Tcl/Tk interface ... done
 trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/RSQLite_0.5-6.tar.gz'
 Content type 'application/x-gzip' length 710241 bytes
 opened URL
 ==
 downloaded 693Kb

 gcc -std=gnu99 -shared -L/usr/local/lib -o RSQLite.so RS-DBI.o
 RS-SQLite.o sqlite-all.o   -L/usr/lib/R/lib -lR
 /usr/bin/ld: skipping incompatible /usr/lib/R/lib/libR.so when
 searching for -lR
 /usr/bin/ld: cannot find -lR
 collect2: ld returned 1 exit status
 make: *** [RSQLite.so] Error 1
 chmod: cannot access `/usr/lib/R/library/RSQLite/libs/*': No such file
 or directory
 ERROR: compilation failed for package 'RSQLite'
 ** Removing '/usr/lib/R/library/RSQLite'

 The downloaded packages are in
 /tmp/RtmpHQ5Y7C/downloaded_packages
 Warning message:
 installation of package 'RSQLite' had non-zero exit status in:
 install.packages(RSQLite)

 I appreciate your help.

 Thank you very much

 Taka

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


[[alternative HTML version deleted]]

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


Re: [R] Problem in installing packages on linux machine...

2007-09-08 Thread tkobayas
Hi,

Still got the same error message. I did su R when I got the error 
message for the first time. I have never seen this error message. I 
will be googling for solutions as well...

Thank you.

Quoting Henrique Dallazuanna [EMAIL PROTECTED]:

 Hi, try install packages whit 'sudo'.

 $sudo R

 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O

 On 08/09/2007, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Hi,

 I am trying to install RSQLite package on my Fedora workstation. I
 tried to install other packages as well, but each time I got the same
 error messages saying compilation error and non zero exit status.
 Do I have to specify lib=? I never specified the library path before
 when I was using Fedora Core 6.


 Warning in install.packages(RSQLite) : argument 'lib' is missing:
 using '/usr/lib/R/library'
 --- Please select a CRAN mirror for use in this session ---
 Loading Tcl/Tk interface ... done
 trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/RSQLite_0.5-6.tar.gz'
 Content type 'application/x-gzip' length 710241 bytes
 opened URL
 ==
 downloaded 693Kb

 gcc -std=gnu99 -shared -L/usr/local/lib -o RSQLite.so RS-DBI.o
 RS-SQLite.o sqlite-all.o   -L/usr/lib/R/lib -lR
 /usr/bin/ld: skipping incompatible /usr/lib/R/lib/libR.so when
 searching for -lR
 /usr/bin/ld: cannot find -lR
 collect2: ld returned 1 exit status
 make: *** [RSQLite.so] Error 1
 chmod: cannot access `/usr/lib/R/library/RSQLite/libs/*': No such file
 or directory
 ERROR: compilation failed for package 'RSQLite'
 ** Removing '/usr/lib/R/library/RSQLite'

 The downloaded packages are in
 /tmp/RtmpHQ5Y7C/downloaded_packages
 Warning message:
 installation of package 'RSQLite' had non-zero exit status in:
 install.packages(RSQLite)

 I appreciate your help.

 Thank you very much

 Taka

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






Takatsugu Kobayashi
PhD Student
Indiana University, Dept. Geography

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


Re: [R] Suppress 'x' when appending to a csv file

2007-09-08 Thread John Kane
Thanks Marc. It works.  I had not thought of using
col.names = FALSE as I wanted to keep the colnames. I
see that I will just have to do another write.table
command to do this.  Humm, actually it took a a bit of
juggling to do the names but it's looking fine now.



--- Marc Schwartz [EMAIL PROTECTED] wrote:

 On Sat, 2007-09-08 at 11:41 -0400, John Kane wrote:
  Is there any convenient way to supress the x that
  appears in csv export files?  I would like to be
 able
  to export a file and add a comment to it yet still
 be
  able to read it back into R.  I don't see any way
 to
  get rid of the x that seperates the different
 appended
  parts.
  
  Thanks
  
  EXAMPLE
  
  x
  1
  2
  3
  4
  5
  x
  #Results from file SSS.r
  
  R.2.5.1 Windows XP
 
 John,
 
 Try this:
 
  write.table(head(iris), sep = ,, 
   row.names = FALSE, col.names = FALSE)
 5.1,3.5,1.4,0.2,setosa
 4.9,3,1.4,0.2,setosa
 4.7,3.2,1.3,0.2,setosa
 4.6,3.1,1.5,0.2,setosa
 5,3.6,1.4,0.2,setosa
 5.4,3.9,1.7,0.4,setosa
 
 
 You may need to explicitly adjust other arguments
 that are otherwise set
 to defaults when using write.csv().
 
 HTH,
 
 Marc Schwartz
 
 


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


[R] statistical tests under serial dependence

2007-09-08 Thread Rosa Trancoso
Hello!

I would like to know if there are already programmed statistical tests 
for data under serial dependence, for example, considering the variance 
inflation factor?


Thank you very much
Best regards
Rosa

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


[R] predict.arima

2007-09-08 Thread shao ran

Hi *,

Firstly, thank you so much for your time to read my email.

I am currently interested in how to use R to predict time series from
models fitted by ARIMA. The package I used is basic stats package, and the
method I used is predict.Arima.

What I know is that ARIMA parameters are estimated by Kalman Filter, but I
have difficulty in understanding how exactly maximum likelihood (ML)
estimator can be computed based on Kalman Filter, i.e. given a time series
and an ARIMA model, how can I compute the ARIMA parameters for prediction.

Could you please give me some help or provide some materials for it?

Thank you so much!


will

_
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com

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


Re: [R] 'initial value not feasible' in constrOptim

2007-09-08 Thread Ingmar Visser
Hi,

On Sep 7, 2007, at 11:00 PM, Yuchen Luo wrote:
 constrOptim(c(0.5,0.3,0.5), fit.error, fit.error.grr,  
 ui=-1*ui,ci=-1*ci)

 and I am confronted with error message initial value not feasible

 I plug in the initial value of (0.5,0.3,0.5) to function fit.error and
 fit.error.grr and have pretty reasonable result.

That doesn't mean the constraint is satisfied, which depends on the  
values of ui and ci
but they are not provided so it's hard to tell where the problem is.

hth, Ingmar

 I inequality ui %*% theta
 - ci = 0 as suggested in the R manual and it is satisfied. In  
 case that
 this is a typo of the manual, I let ui=-ui and ci=-ci and try  
 constrOptim
 again but the same warning message pops up.
 Could you please point me a way out of this?

 I am actually trying to translate a fortran code to R and the  
 function I
 want to replace is DBCPOL, which used 'the complex method  
 described in
 Nelder and Mead (1965) and Gill et al. (1981). I believe contrOptim is
 better than it because it is newer, is it?

 Best Wishes
 Yuchen Luo

   [[alternative HTML version deleted]]

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

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


[R] writing complex outputs to table

2007-09-08 Thread Steve Powers
So I've come across a few cases where complex outputs from functions 
will not write to tables. The most recent case involves the TukeyHSD 
function in the stats package. If I save the TukeyHSD call and print it, 
that obviously goes fine, but when I try writing to a table, I get an 
error message that says cannot coerce class \multicomp\ into 
dataframe. What does this mean, and how do I work around it? Is there a 
more fail-safe general method of writing complex outputs to a table? 
The story here is I want to be able to call certain values from the 
TukeyHSD results to produce custom summaries.

Using R version 2.4 on Windows XP.---steve

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