Re: [R] legend problem [with ggplot[12]]

2009-06-04 Thread Uwe Ligges
IF you provide us with the reproducible code that is requested in the 
posting guide, you may get some valuable help. I gues sthe is from ggplot2?


Uwe Ligges


Felipe Carrillo wrote:

Hi: See the attached pdf graphic. The legend overlaps a little bit with the 
strip. Is there a way to move it over half a cm?

Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish  Wildlife Service  
California, USA



  





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


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


Re: [R] 'beside' option for boxplots

2009-06-04 Thread Uwe Ligges

Example:

boxplot(d1$b ~ d1$a, pars = list(boxwex = 0.15), at=c(1:3 - 0.1), xaxt=n)
boxplot(d2$b ~ d2$a, add=T, pars = list(boxwex = 0.15), at=c(1:3 + 0.1), 
xaxt=n)

axis(1, at=1:3)

Uwe

Malcolm Ryan wrote:
Is there any way to get a boxplot of several data sets beside one 
another on the same graph, as there is for barplot?


If I do:

d1 - data.frame(a = c(rep(1:3, each = 3)), b = c(1:9))
d2 - data.frame(a = c(rep(1:3, each = 3)), b = c(9:1))
boxplot(d1$b ~ d1$a)
boxplot(d2$b ~ d2$a, add=T)

It will show the two datasets on the one graph, but the middle point 
will overlap.


What I want is a layout more like:

barplot(t(matrix(c(d1$b, d2$b), ncol=2)), beside=T)

only showing the boxes from the plot above instead of bars.

Can this be done?

Malcolm

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

2009-06-04 Thread Jason Rupert

Thank you again for all the R help folks who responded.  I again appreciate all 
the help and insight and will investigate the options suggested. 

I guess I still doing a little head scratching at how the division occurred:

It looks like the default hist(...) behavior is doing the following:
HouseHist-hist(as.numeric(HouseYear_array)) 
HouseHist$counts
[1] 2 1 4 4 8 8

That would equate to the following grouping of the years:
[90, 91] (91, 92] (92, 93] (93, 94] (94, 95] (95, 96] 


However, the true division is something like the following:
table(as.numeric(HouseYear_array))
1990 1991 1992 1993 1994 1995 1996 
   1114488 

Seems like hist behavior could have been:
(89, 90] (90, 91] (91, 92] (92, 93] (93, 94] (94, 95] (95, 96]

Of course, I haven't had any coffee yet...

This goes with the following example:
http://n2.nabble.com/What-is-going-on-with-Histogram-Plots-td3022645.htm


--- On Thu, 6/4/09, ted.hard...@manchester.ac.uk ted.hard...@manchester.ac.uk 
wrote:

 From: ted.hard...@manchester.ac.uk ted.hard...@manchester.ac.uk
 Subject: RE: [R] Understanding R Hist() Results...
 To: R-help@r-project.org
 Cc: Jason Rupert jasonkrup...@yahoo.com
 Date: Thursday, June 4, 2009, 5:13 AM
 On 04-Jun-09 04:00:11, Jason Rupert
 wrote:
  
  Think I'm missing something to understand what is
 going on with
  hist(...)
  
  http://n2.nabble.com/What-is-going-on-with-Histogram-Plots-td3022645.htm
  l
  
  For my example I count 7 unique years, however, on the
 histogram there
  only 6.  It looks like the bin to the left of the
 tic mark on the
  x-axis represents the number of entries for that year,
 i.e. Frequency. 
  
  I guess it looks like the bin for 1990 is
 missing.  Is there a better
  way or a different histogram R command to use in order
 to see all the
  age bins and them for them to be aligned directly over
 the year tic
  mark on the x-axis?  
  
  Thanks again for any insights that can be provided.
 
 It's doing what it's supposed to -- which admitredly could
 be confusing
 when all your data lie on the exact boundaries between
 bins.
 
 From ?hist, by default include.lowest = TRUE, right =
 TRUE, and:
 
   If 'right = TRUE' (default), the histogram cells are
 intervals of
   the form '(a, b]', i.e., they include their
 right-hand endpoint,
   but not their left one, with the exception of the
 first cell when
   'include.lowest' is 'TRUE'.
 
 In your data:
 
  sort(HouseYear_array)
  [1] 1990 1991 1992 1993 1993 1993 1993
 1994 1994
 [10] 1994 1994 1995 1995 1995 1995 1995
 1995 1995
 [20] 1995 1996 1996 1996 1996 1996 1996
 1996 1996
 
 and, with
 
   H-hist(as.numeric(HouseYear_array))
   H$breaks
   # [1] 1990 1991 1992 1993 1994 1995 1996
 
 so you get 2 (1990,1991) in the [1990-1] bin, 1 in the
 [1991-2] bin,
 4 in [1992-3], and so on, exactly as observed.
 
 You can get what you're expecting to see by setting the
 'breaks'
 parameter explicitly, and making sure the breakpoints do
 not
 coincide with data (which ensures that there is no
 confusion about
 what goes in which bin):
 
  
 hist(as.numeric(HouseYear_array),breaks=0.5+(1989:1996))
 
 Ted.
 
 
 E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
 Fax-to-email: +44 (0)870 094 0861
 Date: 04-Jun-09           
                
            Time:
 11:13:22
 -- 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] Adding a method to a generic in another package

2009-06-04 Thread Gabor Grothendieck
The zoo package has lattice methods and does not use require
and it puts lattice in Imports in the DESCRIPTION file.  If a user
wants to the use the zoo lattice functions then they must issue
a library(lattice) call.  As a result users do not have to load
lattice but if they want to use it they must do it themselves.

library(zoo)
z - zoo(1:4)
xyplot(z) # wrong

library(lattice)
xyplot(z) # yes!

On Tue, Jun 2, 2009 at 5:14 PM, Jeffrey J. Hallman jhall...@frb.gov wrote:
 I am the maintainer of the 'tis' package.  One of the functions in my package
 is 'nberShade'.  A user wants to make nberShade generic, with the old version
 renamed as nberShade.default, all of which is fine with me.  And he wants to
 add a new method, nberShade.ggplot, which works for objects of class ggplot.
 He also wants to add a method fortify.tis for the generic fortify defined in
 ggplot2.

 The nberShade.ggplot method uses a bunch of other functions from the ggplot2
 package, and it's first line is

 require(ggplot2)

 From what he tells me, this function works.

 Where I'm having trouble is figuring out what I have to do to get the tis
 package to pass R CMD check.  I really don't want to force users of the tis
 package to have to install ggplot2.  What can I do?  Is it enough to have

 Imports: ggplot2

 in the DESCRIPTION file and

 import(ggplot2)

 in the NAMESPACE file?  I've done that, but I still get this warning from R
 CMD check:

 * checking for unstated dependencies in R code ... WARNING
 'library' or 'require' calls not declared from:
  ggplot2
 See the information on DESCRIPTION files in the chapter 'Creating R
 packages' of the 'Writing R Extensions' manual.

 Well, I did read the manual, and it seems to say that what I'm doing is OK. So
 why am I getting the warning?

 --
 Jeff

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

2009-06-04 Thread spencerg
 It looks to me like you need to add x to the arguments in your 
call to constrOptim, something like the following: 


constrOptim(beta_i, myFunction, NULL, ui, ci, mu = 1e-04, control = list(),
method = Nelder-Mead,outer.iterations = 100, outer.eps = 1e-05, x=x)


 The first x in x=x tells constrOptim that this is a named 
argument.  Since it's NOT the name of an argument for constrOptim, it 
must be part of the ... argument, which is offered to f, which in 
this case is myFunction.  The second x in x=x tells constrOptim 
to pass your global variable x for this purpose. 



 If this does not work, please submit another post, providing a 
simpler, self contained example.  Define myFunction as something 
simple to define that still generates your error.  Then someone can copy 
your code into R, run it and see your error.  That will tend on average 
to increase the probability of a response as well as its speed and 
utility. 



 Hope this helps,
 Spencer


Ali Mahani wrote:

I have a function myFunction(beta,x) where beta is a vector of coefficients
and x is a data frame (think of it as a matrix). I want to optimize the
function myFunction() by ONLY changing beta, i.e. x stays constant, with 4
constraints. I have the following code (with a separate source file for the
function):

rm(list=ls())
source('mySourceFile')
x=read.csv(myFile.csv,head=TRUE,sep=,)
beta_i=c(1,1,1,1,1,1,-1)
ui=rbind(c(1,0,0,0,0,0,0),c(0,1,0,0,0,0,0),c(0,0,1,0,0,0,0),c(0,0,0,0,0,0,-1))
ci=c(0,0,0,0)
constrOptim(beta_i, myFunction, NULL, ui, ci, mu = 1e-04, control = list(),
method = Nelder-Mead,outer.iterations = 100, outer.eps = 1e-05)

I am getting this error:

Error in f(theta, ...) : argument x is missing, with no default

If I replace myFunction with myFunction(beta,x) I get this error:

Error in beta * feature_1[i, ] : non-numeric argument to binary operator

If I try myFunction(beta_i,x) I get:

Error in constrOptim(beta_i, mirror_lf(beta_i, x), NULL, ui, ci, mu = 1e-04, 
: 
  could not find function f


Clearly, I don;t have a good understanding of how to use constrOptim() or
optim() for that matter. Any guidance? Thank you!



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Getting a column of values from a list - think I'm doing it thehard way

2009-06-04 Thread Gabor Grothendieck
Or even:

 library(chron)

 ch - chron(HouseDates)
 years(ch)
[1] 1990 1991 1992 1993 1994 1995 1996
Levels: 1990  1991  1992  1993  1994  1995  1996

 # or
 with(month.day.year(ch), year)
[1] 1990 1991 1992 1993 1994 1995 1996


On Thu, Jun 4, 2009 at 4:02 AM, ONKELINX, Thierry
thierry.onkel...@inbo.be wrote:
 Dear Jason,

 Have a look at years() from the chron package.

 library(chron)
 HouseDates - c(02/27/90, 02/27/91, 01/14/92, 02/28/93,
 02/01/94, 02/01/95, 02/01/96)
 HouseDatesFormatted-as.Date(HouseDates, %m/%d/%y)
 years(HouseDates)

 HTH,

 Thierry
 
 
 ir. Thierry Onkelinx
 Instituut voor natuur- en bosonderzoek / Research Institute for Nature
 and Forest
 Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
 methodology and quality assurance
 Gaverstraat 4
 9500 Geraardsbergen
 Belgium
 tel. + 32 54/436 185
 thierry.onkel...@inbo.be
 www.inbo.be

 To call in the statistician after the experiment is done may be no more
 than asking him to perform a post-mortem examination: he may be able to
 say what the experiment died of.
 ~ Sir Ronald Aylmer Fisher

 The plural of anecdote is not data.
 ~ Roger Brinner

 The combination of some data and an aching desire for an answer does not
 ensure that a reasonable answer can be extracted from a given body of
 data.
 ~ John Tukey

 -Oorspronkelijk bericht-
 Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 Namens Jason Rupert
 Verzonden: donderdag 4 juni 2009 4:45
 Aan: R-help@r-project.org
 Onderwerp: [R] Getting a column of values from a list - think I'm doing
 it thehard way


 Example code it shown below.

 I think I am doing this the hard way.  I'm just trying to get the full
 year value from an array of dates.  An example array is shown below.
 Right now, I'm using a for loop to pull the year out of a list where
 the dates were split up into their individual components.

 This seems to work, but just wondering if there is an easier way.

 Thanks for any insights.

 #*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
 HouseDates - c(02/27/90, 02/27/91, 01/14/92, 02/28/93,
 02/01/94, 02/01/95, 02/01/96)

 # ?as.Date
 HouseDatesFormatted-as.Date(HouseDates, %m/%d/%y)

 HouseDatesFormatted

 HouseDatesList-strsplit(as.character(HouseDatesFormatted), -,
 fixed=TRUE)

 HouseYear_array-NULL
 length_array-length(HouseDatesList)
 for(ii in 1:length_array)
 {
        HouseYear-HouseDatesList[[ii]][1]

        HouseYear_array-c(HouseYear_array, HouseYear) }

 as.character(HouseYear_array)

 # Desired:
 # [1] 1990 1991 1992 1993 1994 1995 1996

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

 Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer
 en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd 
 is
 door een geldig ondertekend document. The views expressed in  this message
 and any annex are purely those of the writer and may not be regarded as 
 stating
 an official position of INBO, as long as the message is not confirmed by a 
 duly
 signed document.

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

2009-06-04 Thread Peter Dalgaard
edw...@web.de wrote:
 Hi,
 
 
 Unfortunately, they can't handle NA. Any suggestion? Some row for Ip
 don't have ip address. This cause an error/ wrong result.

A quick fix could be to substitute ... or 0.0.0.0 for the NA
entries. (Use something like

ipch - as.character(df$ip)
ipch[is.na(df$ip)] - ...
connection - textConnection(ipch)

)

 
 Eddie
 
 
 
 library(gsubfn)
 library(gtools)
 library(rbenchmark)

 n - 1
 df - data.frame(
 a = rnorm(n),
 b = rnorm(n),
 c = rnorm(n),
 ip = replicate(n, paste(sample(255, 4), collapse='.'), simplify=TRUE)
 )

 res - benchmark(columns=c('test', 'elapsed'), replications=10,
 order=NULL,
 peda = {
 connection - textConnection(as.character(df$ip))
 o - do.call(order, read.table(connection, sep='.'))
 close(connection)
 df[o, ]
 },

 peda2 = {
 connection - textConnection(as.character(df$ip))
 dfT - read.table(connection, sep='.', colClasses=rep(integer,
 4), quote=, na.strings=NULL, blank.lines.skip=FALSE)
 close(connection)
 o - do.call(order, dfT)
 df[o, ]
 },

 hb = {
 ip - strsplit(as.character(df$ip), split=., fixed=TRUE)
 ip - unlist(ip, use.names=FALSE)
 ip - as.integer(ip)
 dim(ip) - c(4, nrow(df))
 ip - 256^3*ip[1,] + 256^2*ip[2,] + 256*ip[3,] + ip[4,]
 o - order(ip)
 df[o, ]
 },

 hb2 = {
 ip - strsplit(as.character(df$ip), split=., fixed=TRUE)
 ip - unlist(ip, use.names=FALSE)
 ip - as.integer(ip);
 dim(ip) - c(4, nrow(df))
 o - sort.list(ip[4,], method=radix, na.last=TRUE)
 for (kk in 3:1) {
 o - o[sort.list(ip[kk,o], method=radix, na.last=TRUE)]
 }
 df[o, ]
 }
 )

 print(res)

 test elapsed
 1 peda 4.12
 2 peda2 4.08
 3 hb 0.28
 4 hb2 0.25


 On Sun, May 31, 2009 at 12:42 AM, Wacek Kusnierczyk

 waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
  edwin Sendjaja wrote:
  Hi VQ,
 
  Thank you. It works like charm. But I think Peter's code is faster.
 What
  is the difference?
 
  i think peter's code is more r-elegant, though less generic.  here's a
  quick test, with not so surprising results.  gsubfn is implemented in r,
  not c, and it is painfully slow in this test. i also added gabor's
  suggestion.
 
 library(gsubfn)
 library(gtools)
 library(rbenchmark)
 
 n = 1000
 df = data.frame(
a=rnorm(n),
b = rnorm(n),
c = rnorm(n),
ip = replicate(n, paste(sample(255, 4), collapse='.'),
  simplify=TRUE))
 benchmark(columns=c('test', 'elapsed'), replications=10, order=NULL,
peda={
   connection = textConnection(as.character(df$ip))
   o = do.call(order, read.table(connection, sep='.'))
   close(connection)
   df[o, ] },
waku=df[order(gsubfn(perl=TRUE,
   '[0-9]+',
   ~ sprintf('%03d', as.integer(x)),
   as.character(df$ip))), ],
gagr=df[mixedorder(df$ip), ] )
 
 # peda 0.070
 # waku 7.070
 # gagr 4.710
 
 
  vQ
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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.
 
 
 


-- 
   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
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

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

2009-06-04 Thread jlfmssm
Does anyone know which package include the computation of Cochran’s Q
statistic in R?

 jlfmssm

[[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] 'beside' option for boxplots

2009-06-04 Thread ONKELINX, Thierry
Dear Malcom,

Another option is to merge both dataset to one big dataset and then plot
the big dataset.

d1 - data.frame(a = c(rep(1:3, each = 3)), b = c(1:9), d = A)
d2 - data.frame(a = c(rep(1:3, each = 3)), b = c(9:1), d = B)
Dataset - rbind(d1, d2)
library(ggplot2)
Dataset$a - factor(Dataset$a)
ggplot(Dataset, aes(x = a, y = b, colour = d)) + geom_boxplot()

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Uwe Ligges
Verzonden: donderdag 4 juni 2009 13:45
Aan: Malcolm Ryan
CC: r-help@r-project.org
Onderwerp: Re: [R] 'beside' option for boxplots

Example:

boxplot(d1$b ~ d1$a, pars = list(boxwex = 0.15), at=c(1:3 - 0.1),
xaxt=n) boxplot(d2$b ~ d2$a, add=T, pars = list(boxwex = 0.15),
at=c(1:3 + 0.1),
xaxt=n)
axis(1, at=1:3)

Uwe

Malcolm Ryan wrote:
 Is there any way to get a boxplot of several data sets beside one 
 another on the same graph, as there is for barplot?
 
 If I do:
 
 d1 - data.frame(a = c(rep(1:3, each = 3)), b = c(1:9))
 d2 - data.frame(a = c(rep(1:3, each = 3)), b = c(9:1)) boxplot(d1$b ~

 d1$a) boxplot(d2$b ~ d2$a, add=T)
 
 It will show the two datasets on the one graph, but the middle point 
 will overlap.
 
 What I want is a layout more like:
 
 barplot(t(matrix(c(d1$b, d2$b), ncol=2)), beside=T)
 
 only showing the boxes from the plot above instead of bars.
 
 Can this be done?
 
 Malcolm
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

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

2009-06-04 Thread Gabor Grothendieck
Suggest you be more specific.  The solution I posted does handle missing values
sorting them to the beginning:

 Lines - id rank color status ip
+ 138 29746 yellow no 162.131.58.26
+ 138 29746 red  yes  162.131.58.16
+ 138 29746 blue yes  162.131.58.10
+ 138 29746 red no  162.131.58.17
+ 138 29746 yellow no 162.131.58.14
+ 138 29746 red no  162.131.58.13
+ 138 29746 yellow  no 162.132.58.15
+ 139 29746 green no  162.252.20.69
+ 140 29746 red yes  162.254.20.71
+ 141 29746 yellow no  163.253.7.153
+ 142 31804 green yes  163.253.20.114
+ 142 31804 green yes
+ 144 32360 black yes  161.138.45.226

 DF - read.table(textConnection(Lines), header = TRUE, fill = TRUE)
 library(gtools)
 DF[mixedorder(DF$ip), ]
id  rank  color status ip
12 142 31804  greenyes
13 144 32360  blackyes 161.138.45.226
3  138 29746   blueyes  162.131.58.10
6  138 29746red no  162.131.58.13
5  138 29746 yellow no  162.131.58.14
2  138 29746redyes  162.131.58.16
4  138 29746red no  162.131.58.17
1  138 29746 yellow no  162.131.58.26
7  138 29746 yellow no  162.132.58.15
8  139 29746  green no  162.252.20.69
9  140 29746redyes  162.254.20.71
11 142 31804  greenyes 163.253.20.114
10 141 29746 yellow no  163.253.7.153


On Thu, Jun 4, 2009 at 6:39 AM,  edw...@web.de wrote:
 Hi,

 Unfortunately, they can't handle NA. Any suggestion? Some row for Ip don't 
 have ip address. This cause an error/ wrong result.

 Eddie


 library(gsubfn)
 library(gtools)
 library(rbenchmark)

 n - 1
 df - data.frame(
   a = rnorm(n),
   b = rnorm(n),
   c = rnorm(n),
   ip = replicate(n, paste(sample(255, 4), collapse='.'), simplify=TRUE)
 )

 res - benchmark(columns=c('test', 'elapsed'), replications=10, order=NULL,
   peda = {
     connection - textConnection(as.character(df$ip))
     o - do.call(order, read.table(connection, sep='.'))
     close(connection)
     df[o, ]
   },

   peda2 = {
     connection - textConnection(as.character(df$ip))
     dfT - read.table(connection, sep='.', colClasses=rep(integer,
 4), quote=, na.strings=NULL, blank.lines.skip=FALSE)
     close(connection)
     o - do.call(order, dfT)
     df[o, ]
   },

   hb = {
     ip - strsplit(as.character(df$ip), split=., fixed=TRUE)
     ip - unlist(ip, use.names=FALSE)
     ip - as.integer(ip)
     dim(ip) - c(4, nrow(df))
     ip - 256^3*ip[1,] + 256^2*ip[2,] + 256*ip[3,] + ip[4,]
     o - order(ip)
     df[o, ]
   },

   hb2 = {
     ip - strsplit(as.character(df$ip), split=., fixed=TRUE)
     ip - unlist(ip, use.names=FALSE)
     ip - as.integer(ip);
     dim(ip) - c(4, nrow(df))
     o - sort.list(ip[4,], method=radix, na.last=TRUE)
     for (kk in 3:1) {
       o - o[sort.list(ip[kk,o], method=radix, na.last=TRUE)]
     }
     df[o, ]
   }
 )

 print(res)

    test elapsed
 1  peda    4.12
 2 peda2    4.08
 3    hb    0.28
 4   hb2    0.25


 On Sun, May 31, 2009 at 12:42 AM, Wacek Kusnierczyk

 waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
  edwin Sendjaja wrote:
  Hi VQ,
 
  Thank you. It works like charm. But I think Peter's code is faster. What
  is the difference?
 
  i think peter's code is more r-elegant, though less generic.  here's a
  quick test, with not so surprising results.  gsubfn is implemented in r,
  not c, and it is painfully slow in this test. i also added gabor's
  suggestion.
 
     library(gsubfn)
     library(gtools)
     library(rbenchmark)
 
     n = 1000
     df = data.frame(
        a=rnorm(n),
        b = rnorm(n),
        c = rnorm(n),
        ip = replicate(n, paste(sample(255, 4), collapse='.'),
  simplify=TRUE))
     benchmark(columns=c('test', 'elapsed'), replications=10, order=NULL,
        peda={
           connection = textConnection(as.character(df$ip))
           o = do.call(order, read.table(connection, sep='.'))
           close(connection)
           df[o, ] },
        waku=df[order(gsubfn(perl=TRUE,
           '[0-9]+',
           ~ sprintf('%03d', as.integer(x)),
           as.character(df$ip))), ],
        gagr=df[mixedorder(df$ip), ] )
 
     # peda 0.070
     # waku 7.070
     # gagr 4.710
 
 
  vQ
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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.



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

[R] visible code

2009-06-04 Thread Karin Martijn
Hello,

Can anyone help me with the following:
if one enters a function name in the R console then usually one sees the code 
of that function. But there are functions that one cannot see. For example I 
want to see the code of print.htest or t.test.default. These functions are 
non-visible. Is it possible to see the code anyway?

Thanks in advance,

Karin Groothuis-Oudshoorn
[[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] Create a time interval from a single time variable

2009-06-04 Thread Terry Therneau
-- begin included message --
I am trying to set up a data set for a survival analysis with time-varying  
covariates. The data is already in a long format, but does not have a variable 
to signify the stopping point for the interval. The variable DaysEnrolled is 
the 
variable I would like to use to form this interval. This is what I have now:

...
 end inclusion

 I would have expected a dozen solutions from the list - data manipulation 
problems usually get a large following.  It can be done in 4 lines, assuming 
that the parent data set is sorted by subject and time within subject.
 
newdata$start - olddata$DaysEnrolled   #start time = the current variable
temp - olddata$DaysEnrolled[-1]# shift column up by one position
temp[diff(olddata$id) !=0] - NA# NA for last line of each subject
newdata$stop - c(temp, NA) # add the NA for the last subject

   I will leave it to others to compress this into a 1-line application of one 
of the apply functions.  (Unreadable perhaps, but definitely more elegant :-)
   
Terry T.

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

2009-06-04 Thread jlfmssm
which package have Hedges g statistic calculation in R?

[[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] Cochran’s Q statistic

2009-06-04 Thread Allan Engelhardt

jlfmssm wrote:

Does anyone know which package include the computation of Cochran’s Q
statistic in R?
  

install.packages(outliers)

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

2009-06-04 Thread Marc Schwartz

On Jun 4, 2009, at 7:48 AM, jlfmssm wrote:


Does anyone know which package include the computation of Cochran’s Q
statistic in R?

jlfmssm


See this thread:

  https://stat.ethz.ch/pipermail/r-help/2006-September/113139.html

HTH,

Marc Schwartz

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


Re: [R] visible code

2009-06-04 Thread David Winsemius


Yes. Uwe Ligges' R Help Desk article in this Rnews should answer your  
questions:


www.r-project.org/doc/Rnews/Rnews_2006-4.pdf

On Jun 4, 2009, at 9:08 AM, Karin  Martijn wrote:


Hello,

Can anyone help me with the following:
if one enters a function name in the R console then usually one sees  
the code of that function. But there are functions that one cannot  
see. For example I want to see the code of print.htest or  
t.test.default. These functions are non-visible. Is it possible to  
see the code anyway?


Thanks in advance,

Karin Groothuis-Oudshoorn


David Winsemius, MD
Heritage Laboratories
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] Morlet wavelet analysis

2009-06-04 Thread Irina Foss
Dear,

I am using cwt function from Rwave package to perform Morlet wavelet analysis.

d1-c(1.31673209591515, -0.171333455797346, -1.67618546079420, 
-0.931604651010362, -0.954614183224057, -1.19821794547758, 0.516096363353144, 
-0.0432811977638559, 0.737764943619919, 0.438046629673177, -0.208607167908743, 
-0.3091308821262, -1.42473112931594, 0.234125312118165, -0.307047554490597, 
0.686201101422384, 1.40104418156371, -0.722985280679127, -1.47295298153946, 
-1.49070808616222, -0.294899345331949, -0.623882988251866, 0.95580872220543, 
0.159226599747532, 0.258592921036826, -0.893605825950617, -1.48090318423471, 
-0.599454337019121, -0.315308442503905, 1.48221661623468, 1.07313149452230, 
0.0330503877044541, 1.07332650281700, -1.37121080562242, -0.181568897416963, 
1.55169357402125, -0.502404116831855, 2.19007041840759, 0.177374817139349, 
1.37270541339308, 0.179612250662539, 1.33781757389541)

d1-ts(d1deltat=1,start=c(1960,1))
 library(Rwave)
D1-cwt(d1,noctave=8,nvoice=1)

After I did Morlet wavelet analysis by using function wavelet from dplR 
package.

 library(dplR)

D2-wavelet(d1,Dt=1)

But the wavelets from two tests are very different. What is the reason??

Thank you,

Irina




Irina Foss
Environmental Research Institute
North Highland College
UHI Millennium Institute
Castle Street
Thurso, Caithness
Scotland
KW14 7JD
United Kingdom

Tel:  +44 (0) 1847 889 587
Fax: +44 (0) 1847 890 014
http://www.eri.ac.uk/sub/staff.php?id=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] Cochran's Q statistic

2009-06-04 Thread Weiss, Bernd

jlfmssm schrieb:

Does anyone know which package include the computation of Cochran?s Q
statistic in R?

 jlfmssm

[[alternative HTML version deleted]]



I might be wrong but the packages rmeta and meta report a Q-statistic.

For an example, see

library(meta)
meta1
metagen(meta1$TE, meta1$seTE, sm=RR)


Bernd

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] order() with randomised order in ties?

2009-06-04 Thread Rainer M Krug
On Thu, Jun 4, 2009 at 12:36 PM, Patrick Burns pbu...@pburns.seanet.com wrote:
 How about:

 order(x, runif(length(x)))

Thanks - that is really elegant.

Rainer




 Patrick Burns
 patr...@burns-stat.com
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of The R Inferno and A Guide for the Unwilling S User)

 Rainer M Krug wrote:

 Sorry for replying to my own post, but I found a solution. Still, a
 more elegant solution would be preferred.

 On Thu, Jun 4, 2009 at 12:02 PM, Rainer M Krug r.m.k...@gmail.com wrote:

 Hi

 I want to use order() to get the order of a vector.

 But I would need a different behavior when ties occur: similar to the
 parameter  ties.method = random in the rank() function, I would need
 to randomise the ties. Is this possible?

 The solution is to randomize the vector before submitting to order():

 x - rep(1:10, 2)

 iS - sample( length(x) )
 o - order( x[iS], na.last=NA, decreasing=TRUE)
 o
  [1]  8 16 12 17  2  9  7 15 10 11  4 14  3  5 13 20  1  6 18 19
 x[iS][o]
  [1] 10 10  9  9  8  8  7  7  6  6  5  5  4  4  3  3  2  2  1  1

 iS - sample( length(x) )
 o - order( x[iS], na.last=NA, decreasing=TRUE)
 o
  [1] 14 19 13 20  2 18  3 10  1 15  4  9 11 12  6  7  8 16  5 17

 x[iS][o]

  [1] 10 10  9  9  8  8  7  7  6  6  5  5  4  4  3  3  2  2  1  1


 Thanks

 Rainer

 Example:

 x - rep(1:10, 2)
 order(x)
  [1]  1 11  2 12  3 13  4 14  5 15  6 16  7 17  8 18  9 19 10 20
 order(x)
  [1]  1 11  2 12  3 13  4 14  5 15  6 16  7 17  8 18  9 19 10 20

 ## I would need different order for the ties, as below in rank()
 example:

 rank(x, ties.method=random)
  [1]  1  4  6  7 10 12 13 15 18 19  2  3  5  8  9 11 14 16 17 20

 rank(x, ties.method=random)

  [1]  2  4  5  7  9 12 14 15 18 19  1  3  6  8 10 11 13 16 17 20


 Thanks

 Rainer

 --
 Rainer M. Krug, Centre of Excellence for Invasion Biology,
 Stellenbosch University, South Africa








-- 
Rainer M. Krug, Centre of Excellence for Invasion Biology,
Stellenbosch University, South Africa

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Dropping terms from regression w/ poly()

2009-06-04 Thread Joshua Stults
Hello r-help,

I'm fitting a model with lm() and using the orthogonal polynomials
from poly() as my basis:

dat - read.csv(ConsolidatedData.csv, header=TRUE)
attach(dat)
nrows - 1925
Rad - poly(Radius, 2)
ntheta - 14
Theta - poly(T.Angle..deg., ntheta)
nbeta - 4
Beta - poly(B.Beta..deg., nbeta)

model.1 - lm( Measurement ~ Block + Rad + Theta + Beta + Rad:Theta +
  Rad:Beta + Theta:Beta)

Which works splendidly, and for my data set shows that the odd orders
in Theta and Beta are not significant (expected because it is a
symmetric measurement that I'm fitting). Now I want to simplify my
model by dropping all the odd-order terms.  I couldn't figure out a
way to do that without defining new design matrices like this:

T2 - matrix(0,nrows,ntheta)
for(i in 1:ntheta){
  T2[,i] - Theta[,i]
}
B2 - matrix(0,nrows,nbeta)
for(i in 1:nbeta){
  B2[,i] - Beta[,i]
}
R2 -matrix(0,nrows,2)
R2[,1] - Rad[,1]
R2[,2] - Rad[,2]

And then fitting a model using the individual columns of T2, R2 and
B2.  That lets me drop all the odd terms, but it is very cumbersome:

model.2 - lm( Measurement ~ Block + (R2[,1] + R2[,2]) + (T2[,1] +
  T2[,2] + T2[,3] + T2[,4] + T2[,5] + T2[,6] + T2[,7] +
  T2[,8] + T2[,9] + T2[,10] + T2[,11]+ T2[,12] + T2[,13] +
  T2[,14]) + (B2[,1] + B2[,2] + B2[,3] + B2[,4]) + (R2[,1]
  + R2[,2]) : (T2[,1] + T2[,2] + T2[,3] + T2[,4] + T2[,5]
  + T2[,6] + T2[,7] + T2[,8] + T2[,9] + T2[,10] + T2[,11]+
  T2[,12] + T2[,13] + T2[,14]) + (R2[,1] + R2[,2]) :
  (B2[,1] + B2[,2] + B2[,3] + B2[,4]) + (T2[,1] + T2[,2] +
  T2[,3] + T2[,4] + T2[,5] + T2[,6] + T2[,7] + T2[,8] +
  T2[,9] + T2[,10] + T2[,11]+ T2[,12] + T2[,13] + T2[,14])
  : (B2[,1] + B2[,2] + B2[,3] + B2[,4]))

because I have to call out each column explicitly.  I'm new to R so I
have a suspicion that there is a much better way to accomplish this
(dropping odd terms from a model based on poly), but I haven't figured
it out.  Any hints / suggestions?  Thanks.


-- 
Joshua Stults
Website: http://j-stults.blogspot.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] Plot and lm

2009-06-04 Thread Par Leijonhufvud
I want to make a log-log plot with a regression line, but I can't figure
out what I'm doing wrong. What I'm trying is:

plot(mass,area, log=xy, pch=as.numeric(food))
abline(lm(mass~area))

or

plot(mass,area, log=xy, pch=as.numeric(food))
islands$logmass - log(mass)
islands$logarea - log(area)
attach(islands)
abline(lm(logmass~logarea))


But that does not show a line. Where am I going wrong?

data: 
island, area,species,food,mass
Ibiza , 577 ,  Anser n. sp., herb,  2.0
Ibiza , 577 ,Haliaeetus albicilla, carn, 4.8
Mauritius , 1874 ,  Raphus cucullatus, herb,  19 
Mauritius , 1874 ,  Circus alphonsi, carn, 0.63
Mallorca , 3667 , Myotragus balearicus, herb,  40 
Mallorca , 3667 , Aquila chrysaetos, carn, 4.2
Kreta , 8259 , Elephas creutzburgi, herb,  3200 
...

/Par

-- 
Par Leijonhufvud   p...@hunter-gatherer.org
I don't believe in reincarnation.  I used to,
but that was in another life.

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

2009-06-04 Thread Daniel Mail




Hello,
  
I need to know how to import ARIMA coefficients. I already determined the 
coefficients of the model with other software, but now i need to do the 
forecast in R.

 

For Example:  I have a time series named x

 

and i have fitted an ARIMA(1,0,1) (with other software)

AR coef = -.172295

MA coef = .960043

 

(i know that this is not a good model, it's just an example)


I try to import the coefficients doing this:

 

 fit - arima(x, order=c(1, 0, 1), fixed=c(-.172295, .960043, 0)) 
 fit

Call:
arima(x = x, order = c(1, 0, 1), fixed = c(-0.172295, 0.960043, 0))

Coefficients:
Error in se  nrow(x$var.coef) : invalid 'y' type in 'x  y'

 

 

I will be very pleased if someone help me.

_
Mais do que mensagens – conheça todo o Windows Live™.
http://www.microsoft.com/windows/windowslive/
[[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] RGtk2 help: Show list of column names from dataset and categorize as factor or numeric

2009-06-04 Thread Harsh
Hi UseRs,
I recently started working with the RGtk2 library. The documentation
is comprehensive and I've tried learning from the examples in most Gtk
tutorials (which have C code). This is a little problematic, but has
helped quite a bit in getting me started.

I would like to create a GUI for file selection, which then displays
the column names from the selected file, and provides the user with
checkboxes with each column name for the user to select. Two columns
of check boxes (Factor Type, Numeric Type) and one column of names is
what I would like to display.

Moreover, I am planning to create a GUI tool that would have tabs in a
notebook layout, each tab providing a certain functionality, beginning
from basic charting of data, and going on to applying regression
models and such on the data.

This requires extensive knowledge in components that RGtk2 provides
which could be implemented for the task outlined above. I have looked
at the omegahat.org examples, but would like to see examples for such
simple tasks as to how one could create a drop down list of column
names to choose for x axis and another drop down allowing the choice
of y axis, etc.

Having made the choice to use RGtk2, I would  appreciate if users
could share their RGtk experience with me.

Regards
Harsh Singhal

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RGtk2 help: Show list of column names from dataset and categorize as factor or numeric

2009-06-04 Thread Ronggui Huang
I use gWidgetsRGtk2, which provides widgets such as notebook etc. You
can start with gWidgetsRGtk2, and if you want to tailor the GUI
according to your needs, you can modified them with RGtk2 package.

Ronggui

2009/6/4 Harsh singhal...@gmail.com:
 Hi UseRs,
 I recently started working with the RGtk2 library. The documentation
 is comprehensive and I've tried learning from the examples in most Gtk
 tutorials (which have C code). This is a little problematic, but has
 helped quite a bit in getting me started.

 I would like to create a GUI for file selection, which then displays
 the column names from the selected file, and provides the user with
 checkboxes with each column name for the user to select. Two columns
 of check boxes (Factor Type, Numeric Type) and one column of names is
 what I would like to display.

 Moreover, I am planning to create a GUI tool that would have tabs in a
 notebook layout, each tab providing a certain functionality, beginning
 from basic charting of data, and going on to applying regression
 models and such on the data.

 This requires extensive knowledge in components that RGtk2 provides
 which could be implemented for the task outlined above. I have looked
 at the omegahat.org examples, but would like to see examples for such
 simple tasks as to how one could create a drop down list of column
 names to choose for x axis and another drop down allowing the choice
 of y axis, etc.

 Having made the choice to use RGtk2, I would  appreciate if users
 could share their RGtk experience with me.

 Regards
 Harsh Singhal

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




-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

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

2009-06-04 Thread Glen Sargeant



alamoboy wrote:
 
 Newbie here.  Many apologies in advance for using the incorrect lingo. 
 I'm new to statistics and VERY new to R.
 
 I'm attempting to group or bin data together in order to analyze them
 as a combined group rather than as discrete set.  I'll provide a simple
 example of the data for illustrative purposes.
 
 Patient ID  |  Charges   |Age  |   Race
 1  |  100  |0 |   Black
 2  |  500  |3 |   White
 3  |  200  |5 |   Hispanic
 4  |   90   |7 |   Asian
 5  |400|   10 |   Hispanic 
 6  |500|   16 |   Black
 
 I'm trying to create three age categories--0 to 4, 5 to 11 and 12 to
 17--and analyze their Charges by their Race.  How do I go abouts to
 doing this?  
 
 Thanks for any assistance!
 
 
 Sam
 
 
 

Sam,

In addition to functions mentioned by other respondents, you may wish to
investigate findInterval(), which returns indices of bins.  The resulting
indices are very useful for subscripting as well as grouping.

 id
[1] 1 2 3 4 5 6

 age
[1]  0  3  5  7 10 16

 group - findInterval(age,breaks)

 group
[1] 1 1 3 3 3 5

 data.frame(id,age,group)
  id age group
1  1   0 1
2  2   3 1
3  3   5 3
4  4   7 3
5  5  10 3
6  6  16 5

Glen


-- 
View this message in context: 
http://www.nabble.com/Binning-or-grouping-data-tp23864555p23872151.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] hist returning density larger than 1

2009-06-04 Thread Steven Matthew Anderson
The following code is giving me problems.  I want to export densities  
of a distribution to a csv file.  At the bottom of the code I use the  
hist function to generate the densities.  But hist is returning values  
greater than 1.  I don't understand, why.  Any help you can supply is  
greatly appreciated.


# Set word path
dir-~/Research/MR Distribution Analysis/
setwd(dir)
getwd()

# Define Objects
Max.Shots=3
Max.Groups=5000
hist.brks - pretty(range(c(0,4)), 200)

for(sim in (2:Max.Shots)){
  x.Data-matrix(nrow=Max.Groups,ncol=sim,byrow=TRUE)
  y.Data-matrix(nrow=Max.Groups,ncol=sim,byrow=TRUE)
  shot2mean.x-matrix(nrow=Max.Groups,ncol=sim,byrow=TRUE)
  shot2mean.y-matrix(nrow=Max.Groups,ncol=sim,byrow=TRUE)
  Euclid.Dist-matrix(nrow=Max.Groups,ncol=sim,byrow=TRUE)
  mean.radius-vector(mode=numeric,length=Max.Groups)
  # Generate the Simulation Data
  ###
  # Number of Groups
  for(Groups in (1:Max.Groups)) {
# Number of Shots per Group
for(Shots in (1:sim)) {
  # Populate the Simulation Data
  x.Data[Groups,Shots]-rnorm(n=1,mean=0,sd=1)
  y.Data[Groups,Shots]-rnorm(n=1,mean=0,sd=1)
}
  }
  # Calculate the Component Distances from the Shots to the Group Mean
  # Calculate the Euclidean Distance from the Shots to the Group Mean
  # Calculate the Group Mean Radius
  ###
  # Number of Groups
  for(Groups in (1:Max.Groups)){
# Number of Shots per Group
for(Shots in (1:sim)){
  shot2mean.x[Groups,Shots]-(x.Data[Groups,Shots]- 
mean(x.Data[Groups,]))^2
  shot2mean.y[Groups,Shots]-(y.Data[Groups,Shots]- 
mean(y.Data[Groups,]))^2
  	  Euclid.Dist[Groups,Shots]-sqrt(shot2mean.x[Groups,Shots] 
+shot2mean.y[Groups,Shots])

}
mean.radius[Groups]-mean(Euclid.Dist[Groups,])
  }

  f-hist(mean.radius,breaks=hist.brks,plot=FALSE)
  density.data-cbind(sim,f$mids,f$density)
  colnames(density.data)-c(Simulation,MidPoint,Density)
  if (sim==2) {Simulation.Data-density.data} else {Simulation.Data- 
rbind(Simulation.Data,density.data)}


  rm(x.Data)
  rm(y.Data)
  rm(shot2mean.x)
  rm(shot2mean.y)
  rm(Euclid.Dist)
  rm(mean.radius)

}

write.table(
  Simulation.Data,
  file=paste(dir,/DATA/Simulation_Data.csv,sep=''),
  sep=,,
  quote=FALSE,
  row.names=FALSE,
  qmethod=double)



Steven Matthew Anderson

Anderson Research, LLC
Statistical Programming and Analysis
SAS (R) Certified Professional
adastr...@mac.com

Ad Astra per Aspera

שָׁלוֹם

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


[R] error installing RCurl in SUSE SLES10-SP2

2009-06-04 Thread Robert Castelo
dear list,

i'm trying to install the package RCurl into a linux system running SUSE
Linux Enterprise Server 10 SP2 but i get compilation errors which i
guess should be due to some missing additional software. i've been
searching about the R-help archives without success so i hope somebody
can point me out to this missing piece.

in principle, i have the necessary curl software installed:

$ rpm -qa | grep curl
curl-7.15.1-19.11
curl-devel-7.15.1-19.11
curl-32bit-7.15.1-19.11

however as you'll see below, when i try to install it from R the
compilation breaks. i've included at the end also the sessionInfo()
output (it's R-2.9.0). i've also tried to install a newer version of
RCurl (0.98) which i found in http://www.omegahat.org/RCurl but it gives
the same errors.

thanks!
robert.

 install.packages(RCurl, repos=http://cran.r-project.org;)
trying URL 'http://cran.r-project.org/src/contrib/RCurl_0.97-3.tar.gz'
Content type 'application/x-gzip' length 1437829 bytes (1.4 Mb)
opened URL
==
downloaded 1.4 Mb

* Installing *source* package 'RCurl' ...
checking for curl-config... /usr/bin/curl-config
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
Version has a libidn field
Version has CURLOPT_URL
No CURLOPT_NOPROXY enumeration value.
No CURLINFO_CONDITION_UNMET enumeration value.
No CURLINFO_REDIRECT_URL enumeration value.
No CURLINFO_CERTINFO enumeration value.
No CURLINFO_PRIMARY_IP enumeration value.
No CURLINFO_APPCONNECT_TIME enumeration value.
No CURLOPT_KEYPASSWD enumeration value.
No CURLOPT_DIRLISTONLY enumeration value.
No CURLOPT_APPEND enumeration value.
No CURLOPT_KRBLEVEL enumeration value.
No CURLOPT_USE_SSL enumeration value.
No CURLOPT_TIMEOUT_MS enumeration value.
No CURLOPT_CONNECTTIMEOUT_MS enumeration value.
No CURLOPT_HTTP_TRANSFER_DECODING enumeration value.
No CURLOPT_HTTP_CONTENT_DECODING enumeration value.
No CURLOPT_NEW_FILE_PERMS enumeration value.
No CURLOPT_NEW_DIRECTORY_PERMS enumeration value.
No CURLOPT_POSTREDIR enumeration value.
No CURLOPT_SSH_HOST_PUBLIC_KEY_MD enumeration value.
No CURLOPT_OPENSOCKETFUNCTION enumeration value.
No CURLOPT_OPENSOCKETDATA enumeration value.
No CURLOPT_COPYPOSTFIELDS enumeration value.
No CURLOPT_PROXY_TRANSFER_MODE enumeration value.
No CURLOPT_SEEKFUNCTION enumeration value.
No CURLOPT_SEEKDATA enumeration value.
No CURLOPT_CRLFILE enumeration value.
No CURLOPT_ISSUERCERT enumeration value.
No CURLOPT_ADDRESS_SCOPE enumeration value.
No CURLOPT_CERTINFO enumeration value.
No CURLOPT_USERNAME enumeration value.
No CURLOPT_PASSWORD enumeration value.
No CURLOPT_PROXYUSERNAME enumeration value.
No CURLOPT_PROXYPASSWORD enumeration value.
No CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 enumeration value.
No CURLOPT_NOPROXY enumeration value.
No CURLOPT_TFTP_BLKSIZE enumeration value.
No CURLOPT_SOCKS5_GSSAPI_SERVICE enumeration value.
No CURLOPT_SOCKS5_GSSAPI_NEC enumeration value.
Version has CURLOPT_PROTOCOLS
Version has CURLOPT_REDIR_PROTOCOLS
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/cursos/MBI/soft/R/R-2.9.0/lib64/R/include
-DHAVE_LIBIDN_FIELD=1 -DHAVE_CURLOPT_URL=1 -DHAVE_CURLOPT_PROTOCOLS=1
-DHAVE_CURLOPT_REDIR_PROTOCOLS=1 -I/usr/local/include-fpic  -g -O2
-c base64.c -o base64.o
gcc -std=gnu99 -I/cursos/MBI/soft/R/R-2.9.0/lib64/R/include
-DHAVE_LIBIDN_FIELD=1 -DHAVE_CURLOPT_URL=1 -DHAVE_CURLOPT_PROTOCOLS=1
-DHAVE_CURLOPT_REDIR_PROTOCOLS=1 -I/usr/local/include-fpic  -g -O2
-c curl.c -o curl.o
curl.c:553: warning: 'struct curl_certinfo' declared inside parameter
list
curl.c:553: warning: its scope is only this definition or declaration,
which is probably not what you want
gcc -std=gnu99 -I/cursos/MBI/soft/R/R-2.9.0/lib64/R/include
-DHAVE_LIBIDN_FIELD=1 -DHAVE_CURLOPT_URL=1 -DHAVE_CURLOPT_PROTOCOLS=1
-DHAVE_CURLOPT_REDIR_PROTOCOLS=1 -I/usr/local/include-fpic  -g -O2
-c curlInit.c -o curlInit.o
gcc -std=gnu99 -I/cursos/MBI/soft/R/R-2.9.0/lib64/R/include
-DHAVE_LIBIDN_FIELD=1 -DHAVE_CURLOPT_URL=1 -DHAVE_CURLOPT_PROTOCOLS=1
-DHAVE_CURLOPT_REDIR_PROTOCOLS=1 -I/usr/local/include-fpic  -g -O2
-c curl_base64.c -o curl_base64.o
gcc -std=gnu99 -I/cursos/MBI/soft/R/R-2.9.0/lib64/R/include
-DHAVE_LIBIDN_FIELD=1 -DHAVE_CURLOPT_URL=1 -DHAVE_CURLOPT_PROTOCOLS=1
-DHAVE_CURLOPT_REDIR_PROTOCOLS=1 -I/usr/local/include-fpic  -g -O2
-c enums.c -o enums.o
In file included from CurlOptEnums.h:10,
 from enums.c:79:
CURLOptTable.h:136: error: 'CURLOPT_LOCALPORT' undeclared here (not in a
function)
CURLOptTable.h:137: error: 

Re: [R] order() with randomised order in ties?

2009-06-04 Thread Rainer M Krug
On Thu, Jun 4, 2009 at 12:45 PM, Rainer M Krug r.m.k...@gmail.com wrote:
 On Thu, Jun 4, 2009 at 12:36 PM, Patrick Burns pbu...@pburns.seanet.com 
 wrote:
 How about:

 order(x, runif(length(x)))

 Thanks - that is really elegant.

One thing:
it is saver to use sample(length(x)) instead of runif(length(x)), as
runif() might also produce ties. It is quite unlikely that those
result in ties for both vectors, but not impossible. That problem is
avoided with sample(length(x))

Rainer



 Rainer




 Patrick Burns
 patr...@burns-stat.com
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of The R Inferno and A Guide for the Unwilling S User)

 Rainer M Krug wrote:

 Sorry for replying to my own post, but I found a solution. Still, a
 more elegant solution would be preferred.

 On Thu, Jun 4, 2009 at 12:02 PM, Rainer M Krug r.m.k...@gmail.com wrote:

 Hi

 I want to use order() to get the order of a vector.

 But I would need a different behavior when ties occur: similar to the
 parameter  ties.method = random in the rank() function, I would need
 to randomise the ties. Is this possible?

 The solution is to randomize the vector before submitting to order():

 x - rep(1:10, 2)

 iS - sample( length(x) )
 o - order( x[iS], na.last=NA, decreasing=TRUE)
 o
  [1]  8 16 12 17  2  9  7 15 10 11  4 14  3  5 13 20  1  6 18 19
 x[iS][o]
  [1] 10 10  9  9  8  8  7  7  6  6  5  5  4  4  3  3  2  2  1  1

 iS - sample( length(x) )
 o - order( x[iS], na.last=NA, decreasing=TRUE)
 o
  [1] 14 19 13 20  2 18  3 10  1 15  4  9 11 12  6  7  8 16  5 17

 x[iS][o]

  [1] 10 10  9  9  8  8  7  7  6  6  5  5  4  4  3  3  2  2  1  1


 Thanks

 Rainer

 Example:

 x - rep(1:10, 2)
 order(x)
  [1]  1 11  2 12  3 13  4 14  5 15  6 16  7 17  8 18  9 19 10 20
 order(x)
  [1]  1 11  2 12  3 13  4 14  5 15  6 16  7 17  8 18  9 19 10 20

 ## I would need different order for the ties, as below in rank()
 example:

 rank(x, ties.method=random)
  [1]  1  4  6  7 10 12 13 15 18 19  2  3  5  8  9 11 14 16 17 20

 rank(x, ties.method=random)

  [1]  2  4  5  7  9 12 14 15 18 19  1  3  6  8 10 11 13 16 17 20


 Thanks

 Rainer

 --
 Rainer M. Krug, Centre of Excellence for Invasion Biology,
 Stellenbosch University, South Africa








 --
 Rainer M. Krug, Centre of Excellence for Invasion Biology,
 Stellenbosch University, South Africa




-- 
Rainer M. Krug, Centre of Excellence for Invasion Biology,
Stellenbosch University, South Africa

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ordered Twoing criterion in classification trees

2009-06-04 Thread Paolo Radaelli

Dear R users,
I'm using the rpart package to build classification trees. I'm interested in 
implementing the ordered Twoing as a splitting criterion.

Does anyone have experience with this task ?

Thank you for your help

Paolo

Paolo Radaelli
Dipartimento di Metodi Quantitativi per le Scienze Economiche ed Aziendali
Facoltà di Economia
Università degli Studi di Milano-Bicocca
Via Bicocca degli Arcimboldi, 8
20126 Milano
Italy
e-mail paolo.radae...@unimib.it
Tel +39 02 6448 3163
Fax +39 02 6448 3105

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] hist returning density larger than 1

2009-06-04 Thread Sarah Goslee
Hi,

If I understand your problem correctly, you didn't need to send us
your entire code.
A simple reproducible example that showed just your problem would have been
sufficient.

Take a look at this, and reread the help for hist().

 testdata - runif(1000)
 testdata.hist - hist(testdata)
 testdata.hist$density
 [1] 1.19 1.01 0.89 0.79 0.92 1.04 1.13 0.93
 [9] 1.02 1.08


# See the help for the actual definition of density (admittedly not as clear as
# one might want).
 sum(testdata.hist$density * diff(testdata.hist$breaks))
[1] 1

# What you appear to actually want:
 testdata.hist$counts/1000
 [1] 0.119 0.101 0.089 0.079 0.092 0.104 0.113 0.093 0.102 0.108

Sarah

On Thu, Jun 4, 2009 at 11:23 AM, Steven Matthew Anderson
adastr...@mac.com wrote:
 The following code is giving me problems.  I want to export densities of a
 distribution to a csv file.  At the bottom of the code I use the hist
 function to generate the densities.  But hist is returning values greater
 than 1.  I don't understand, why.  Any help you can supply is greatly
 appreciated.

-- 
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] Small mystery : passing a subset= argument to lme|lm through ...

2009-06-04 Thread Emmanuel Charpentier
Dear list,

I have problems involving passing a subset= argument through 
I'm trying to augment the set of defined analyses for mice (homonymous
package) with a call to lme. This package create multiple imputations of
missing data in a mids object, each completed data set may be obtained
through the complete(data, set) function.

 sessionInfo()
R version 2.9.0 (2009-04-17) 
x86_64-pc-linux-gnu 

locale:
LC_CTYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;LC_MONETARY=C;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
[1] odfWeave_0.7.10 XML_2.3-0   lattice_0.17-25

loaded via a namespace (and not attached):
[1] grid_2.9.0   MASS_7.2-47  nlme_3.1-92  rpart_3.1-44
 

# First attempt : 
foo-function(formula, data, ...) {
  library(nlme)
  call - match.call()
  if (!is.mids(data))
stop(The data must have class mids)
  analyses-lapply(1:data$m, function(i) lme(formula,
 data=complete(data,i),
 ...))
  object - list(call = call, call1 = data$call, nmis = data$nmis, 
 analyses = analyses)
  oldClass(object) - c(mira, oldClass(object))
  return(object)
}
 bar1-foo(ttotal~nbpradio, data=Data1.Imp, random=~1|ctr)
 class(bar1$analyses[[1]])
[1] lme # Fine : the random= argument *HAS BEEN* passed to lme()
# through ... ; therefore it's (usually) possible.
# Further tests (not shown) show that results are reasonable (i. e. 
# compliant with expectations...).
 bar2-foo(log(ttotal)~log(nbpradio), data=Data1.Imp, random=~1|ctr,
subset=nbpradio0)
Erreur dans eval(expr, envir, enclos) : 
  ..2 utilisé dans un mauvais contexte, aucun ... où chercher
 

Further exploration show that a subset= argument *DOES NOT GET PASSED*
to lme(), which complaints furthermore not to find a ... argument.
Since lme is a method private to the nlme package, I can't trace the
source of error.

[Later : Same observation with lm() instead of lme()...]

Now, ISTR that an analogous problem *has already been discussed* on this
list, but even a prolonged use of RSiteSearch() did not retrieve it.
http://finzi.psych.upenn.edu/R/Rhelp02/archive/10139.html hints that
Modelling and graphics functions with formulas all have slightly 
different nonstandard evaluation rules, and it turns out that lme() 
doesn't evaluate extra arguments like subset in the parent environment,
but this does not tell me why a ... argument is *not* found. Different
frame of evaluation ?

May some kind soul point me to the right direction ? (He may even
further my shame by telling me how he retrieved the relevant
information...).

Sincerely,

Emmanuel Charpentier

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

2009-06-04 Thread Glen Sargeant



alamoboy wrote:
 
 Newbie here.  Many apologies in advance for using the incorrect lingo. 
 I'm new to statistics and VERY new to R.
 
 I'm attempting to group or bin data together in order to analyze them
 as a combined group rather than as discrete set.  I'll provide a simple
 example of the data for illustrative purposes.
 
 Patient ID  |  Charges   |Age  |   Race
 1  |  100  |0 |   Black
 2  |  500  |3 |   White
 3  |  200  |5 |   Hispanic
 4  |   90   |7 |   Asian
 5  |400|   10 |   Hispanic 
 6  |500|   16 |   Black
 
 I'm trying to create three age categories--0 to 4, 5 to 11 and 12 to
 17--and analyze their Charges by their Race.  How do I go abouts to
 doing this?  
 
 Thanks for any assistance!
 
 
 Sam
 
 
 

Oops!

My use of bins other than you described was not part of some obscure
strategy.  Should have been as shown below:

 id
[1] 1 2 3 4 5 6

 age
[1]  0  3  5  7 10 16

 breaks
[1]  0  5 12 17

 group - findInterval(age,breaks)

 data.frame(id,age,group)
  id age group
1  1   0 1
2  2   3 1
3  3   5 2
4  4   7 2
5  5  10 2
6  6  16 3



-- 
View this message in context: 
http://www.nabble.com/Binning-or-grouping-data-tp23864555p23872705.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] Need help understanding output from aov and from anova

2009-06-04 Thread Suman Sundaresh
Hi Steve,

Thanks for your response and also for the useful information about the
latest version warning.

On the earlier version that I was using (2.6.2 Win), I was expecting
at least an error or warning in response to submitting an obviously
corner case condition that should result in NaN, but it does not
yield any. The t-test does so. Actually, when the groups have two
samples each (and all values are identical), the P-value results in an
NaN which is what one would expect.

It is great to know that it has been corrected at least through a
warning in the latest version.

R version 2.6.2 (2008-02-08)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

snip

#No warning/error provided when there are 2 samples in 1 group, and 1
in the other
 vtot=c(200,200,200)
 fac=as.factor(c(1,1,2))
 anova(lm(vtot~fac))
Analysis of Variance Table

Response: vtot
  Df Sum SqMean Sq F value Pr(F)
fac1 1.4722e-27 1.4722e-27  0. 0.6667
Residuals  1 4.4166e-27 4.4166e-27


 T-test works as expected with an error
 t.test(vtot~fac,var.equal=TRUE)
Error in t.test.default(x = c(200, 200), y = 200, var.equal = TRUE) :
  data are essentially constant


# P-value is NaN when we have at least two samples in each group
 vtot=c(200,200,200,200)
 fac=as.factor(c(1,1,2,2))
 anova(lm(vtot~fac))
Analysis of Variance Table

Response: vtot
  Df Sum Sq Mean Sq F value Pr(F)
fac1  0   0
Residuals  2  0   0

 anova(lm(vtot~fac))[1,5]
[1] NaN


Best,
Suman.


On Wed, Jun 3, 2009 at 9:24 PM, Steven McKinney smckin...@bccrc.ca wrote:
 Hi Suman,

 What version of R are you running?

 In R 2.9.0 running your first example yields a warning

  Warning message:
  In anova.lm(lm(vtot ~ fac)) :
   ANOVA F-tests on an essentially perfect fit are unreliable

 so some adept R developer has taken the time to figure
 out how to warn you about such a problem.

 Perhaps someone will add this to aov() at some point as well.

 The only variability in this problem is that introduced
 by machine precision rounding errors.

 The exercise of submitting data with no variability to
 a program designed to assess variability cannot be expected
 to produce meaningful output, so there's nothing to
 understand except the issue of machine precision.
 Machine roundoff error is an important topic, so I'd
 recommend learning about that issue, which will do most
 to help understand these examples.

 Best

 SteveM


 R version 2.9.0 (2009-04-17)
 Copyright (C) 2009 The R Foundation for Statistical Computing
 ISBN 3-900051-07-0

 R is free software and comes with ABSOLUTELY NO WARRANTY.
 You are welcome to redistribute it under certain conditions.
 Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

 R is a collaborative project with many contributors.
 Type 'contributors()' for more information and
 'citation()' on how to cite R or R packages in publications.

 Type 'demo()' for some demos, 'help()' for on-line help, or
 'help.start()' for an HTML browser interface to help.
 Type 'q()' to quit R.

 vtot=c(7.29917, 7.29917, 7.29917)  #identical values
 fac=as.factor(c(1,1,2))   #group 1 has first two elements, group 2 has
 anova(lm(vtot~fac))
 Analysis of Variance Table

 Response: vtot
          Df     Sum Sq    Mean Sq F value Pr(F)
 fac        1 1.6818e-30 1.6818e-30  0. 0.6667
 Residuals  1 5.0455e-30 5.0455e-30
 Warning message:
 In anova.lm(lm(vtot ~ fac)) :
  ANOVA F-tests on an essentially perfect fit are unreliable

 summary(aov(vtot~fac))
            Df     Sum Sq    Mean Sq F value Pr(F)
 fac          1 1.6818e-30 1.6818e-30  0. 0.6667
 Residuals    1 5.0455e-30 5.0455e-30

 fac=as.factor(c(1,2,2))
 anova(lm(vtot~fac))
 Analysis of Variance Table

 Response: vtot
          Df     Sum Sq    Mean Sq    F value    Pr(F)
 fac        1 6.7274e-30 6.7274e-30 1.3340e+32  2.2e-16 ***
 Residuals  1  5.043e-62  5.043e-62
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
 Warning message:
 In anova.lm(lm(vtot ~ fac)) :
  ANOVA F-tests on an essentially perfect fit are unreliable






 Steven McKinney, Ph.D.

 Statistician
 Molecular Oncology and Breast Cancer Program
 British Columbia Cancer Research Centre

 email: smckin...@bccrc.ca
 tel: 604-675-8000 x7561

 BCCRC
 Molecular Oncology
 675 West 10th Ave, Floor 4
 Vancouver B.C.
 V5Z 1L3

 Canada







 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Suman Sundaresh
 Sent: Wednesday, June 03, 2009 3:55 PM
 To: r-help@r-project.org
 Subject: [R] Need help understanding output from aov and from anova

 Hi all,

 I noticed something strange when I ran aov and anova.

 vtot=c(7.29917, 7.29917, 7.29917)  #identical values
 fac=as.factor(c(1,1,2))   #group 1 has first two elements, group 2 has
 the 3rd element

 When I run:
  anova(lm(vtot~fac))
 Analysis of Variance Table

 

Re: [R] Getting a column of values from a list - think I'm doing it the hard way

2009-06-04 Thread Greg Snow
If you want to play R golf then:

 sapply(HouseDatesList, '[[', 1)
[1] 1990 1991 1992 1993 1994 1995 1996

Does the same thing in fewer keystrokes, but Ronggui's solution is more 
readable.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Ronggui Huang
 Sent: Wednesday, June 03, 2009 8:57 PM
 To: Jason Rupert
 Cc: R-help@r-project.org
 Subject: Re: [R] Getting a column of values from a list - think I'm
 doing it the hard way
 
 2009/6/4 Jason Rupert jasonkrup...@yahoo.com:
 
  Example code it shown below.
 
  I think I am doing this the hard way.  I'm just trying to get the
 full year value from an array of dates.  An example array is shown
 below.  Right now, I'm using a for loop to pull the year out of a
 list where the dates were split up into their individual components.
 
  This seems to work, but just wondering if there is an easier way.
 
  Thanks for any insights.
 
  #*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
  HouseDates - c(02/27/90, 02/27/91, 01/14/92, 02/28/93,
 02/01/94, 02/01/95, 02/01/96)
 
  # ?as.Date
  HouseDatesFormatted-as.Date(HouseDates, %m/%d/%y)
 
  HouseDatesFormatted
 
  HouseDatesList-strsplit(as.character(HouseDatesFormatted), -,
 fixed=TRUE)
 
  sapply(HouseDatesList,function(x) x[[1]])
 [1] 1990 1991 1992 1993 1994 1995 1996
 
 
  HouseYear_array-NULL
  length_array-length(HouseDatesList)
  for(ii in 1:length_array)
  {
         HouseYear-HouseDatesList[[ii]][1]
 
         HouseYear_array-c(HouseYear_array, HouseYear)
  }
 
  as.character(HouseYear_array)
 
  # Desired:
  # [1] 1990 1991 1992 1993 1994 1995 1996
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 --
 HUANG Ronggui, Wincent
 PhD Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Least Squares Method

2009-06-04 Thread aledanda

Dear Helpers,

I need to fit a gamma function on a distribution. I want to use the Method
of the Least Squares for minimizing the sum of squared residuals (SSE). I
don't know how to do this. I guess I need to calculate the best fit
parameter values and then somehow comparing my empirical distribution with
the theorical one (in this case gamma). This is what I've done so far:

rate is the name of my distribution (12000 data point)

mean- mean(rate)   # mean of the empirical distribution
var -var(rate)# variance of the empirical distribution
l.est - mean/var# lambda estimate (scale param.)
a.est - (mean^2)/var  # alfa estimate (shape param.)

should I create a random gamma distribution and then comparing it with my
data? But how?
And then Is there a way to visualize in a graph the fitting with gamma?

Thanks a lot for your help!!

Alessandra



-- 
View this message in context: 
http://www.nabble.com/Least-Squares-Method-tp23872037p23872037.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] loglilelihood

2009-06-04 Thread Subha P. T.




Hi,

 I tried fitting
loglinear model using the glm(catspec). The data used is FHtab. . An
independence model was fitted. Here summary() and fitmacro( ) give different
values for AIC. 

 

I understand that fitmacro( ) takes the likelilhood ratio L2(deviance)
to calculate AIC and uses the formula AIC= L2-
d.f(deviance)*2 and this AIC is used in nested models. (Am I right?)

 

The value given by loglik( ) is used by summary to
calculate AIC using the formula 

AIC= -2 logL + K* e.d.f. Can anybody tell me how this  log L is calculated? 

It is not logL=Sum(ni* log (pi)), where
pi= fitted frequency / total no. of observations. The help available at extract
AIC( ) also is not giving the answer.  

Please help
regards
Subha





  
[[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] wrong labels and colors of points in graph/plot

2009-06-04 Thread Katharina May
Hi there,

I trying to solve this problem for the whole day not going anywhere,
so I  really hope maybe somebody can help
me in this community...
I've got an object coefficient2 which I want to plot in differerent
ways, with colors and labels added to the points,
but somehow there seems to be a problem if a value is NA within the
independent variable, resulting in false labels and false colors for
the points.

plot(coefficient2$intercept ~ coefficient2$average_height,
main=intercepts ::: height, ylab=intercepts, xlab=average height
per site [cm], xlim=c(20,3020), ylim=c(-2,5), col=coefficient2$color)
highlight(coefficient2$intercept ~ coefficient2$average_height,
lbls=coefficient2$site_no,col=Red, cex = .6)

plot(coefficient2$intercept ~ coefficient2$average_dbh,
main=intercepts ::: dbh, ylab=intercepts, xlab=average dbh per
site [mm], xlim=c(-10,360), ylim=c(-2,5),col=coefficient2$color )
highlight(coefficient2$intercept ~ coefficient2$average_dbh,
lbls=coefficient2$site_no,col=Red, cex = .6


If I create a temporary object for each plot excluding any NA values
for the x axis variable, somehow all points are displayed and the
labels are correct except for the color (I have e.g. no clue why some
points are red which I do not define at all and no ones are yellow
which I use several times).

#create temp container for all coefficients with average heights for plotting
coef_avheight - coefficient2[which(!is.na(coefficient2$average_height)),]
plot(coef_avheight$intercept ~ coef_avheight$average_height,
main=intercepts ::: height, ylab=intercepts, xlab=average height
per site [cm], xlim=c(20,3020), ylim=c(-2,5),
col=coef_avheight$color)
highlight(coef_avheight$intercept ~ coef_avheight$average_height,
lbls=coef_avheight$site_no,col=Red, cex = .6)

#create temp container for all coefficients with average dbh for plotting
coef_avdbh- coefficient2[which(!is.na(coefficient2$average_dbh)),]
plot(coef_avdbh$intercept ~ coef_avdbh$average_dbh,  main=intercepts
::: dbh, ylab=intercepts, xlab=average dbh per site [mm],
xlim=c(-10,360), ylim=c(-2,5),col=coef_avdbh$color )
highlight(coef_avdbh$intercept ~ coef_avdbh$average_dbh,
lbls=coef_avdbh$site_no,col=Red, cex = .6)


Maybe someone can explain me the color issue and the problem with the
NA values which results in a wrong labeling and to few
points being displayed? I'm new to R as you can guess and my code
isn't really elegant but I really cannot get faults within it...


Attached you can find the referred R object (coefficient2).
highlight requires library(NCStats)...

Thank you very, very much,

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

2009-06-04 Thread Stefan Grosse
On Thu, 4 Jun 2009 15:21:52 +0100 Daniel Mail d20...@live.com.pt
wrote:

DM I need to know how to import ARIMA coefficients. I already
DM determined the coefficients of the model with other software, but
DM now i need to do the forecast in R.

So why then don't you fit the model then in R Would be much more
convenient...

Stefan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 needed with ridge regression and choice of lambda with lm.ridge!!!

2009-06-04 Thread Giulio Di Giovanni

Hi,

I'm a beginner in the field, I have to perform the ridge regression with 
lm.ridge for many datasets, and I wanted to do it in an automatic way.
In which way I can automatically choose lambda ?
As said, right now I'm using lm.ridge MASS function, which I found quite simple 
and fast, and I've seen that among the returned values there are HKB estimate 
of the ridge constant and L-W estimate of the ridge constant, together with GCV 
values.

I found on the web other studies where people simply choose among one of these 
quantities. It will be perfect to me to do the same, but how? Which are the 
decisional criteria, if there are criteria? HKB, L-W or none of these ?

Another (for me) important question: Aren't the lambda in general supposed to 
increase with the increasing of the number of predictors ? Isn't the ridge 
regression supposed to work fine even with number of predictors  number of 
observations? At least I was said so...
But if I have a dataset of 16 observations and 34 predictors I get:

 fmr-lm.ridge(y~0+ .+., data=x, lambda = seq(0,10,0.01))
select(fmr)
modified HKB estimator is -1.850770e-28 
modified L-W estimator is -2.012264e-28 
smallest value of GCV  at 0.01 

and similar values if I reduce the number of predictor in the dataset, all 
numbars between 17and 34.
but if I build a dataset with only 16 predictors (euqal to the number of rows) 
I get:

 select(fmr)
modified HKB estimator is 0.1511719 
modified L-W estimator is 3.322775 
smallest value of GCV  at 0.51 

And at the same way, other accettable values for any smaller dataset...
Please, could anybody help me? 

Thanks in advance

Giulio

 
_
[[elided Hotmail spam]]

[[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] 5-D density? was Re: R help

2009-06-04 Thread David Winsemius
(copy of earlier reply which was not addressed to r-help. Also added  
informative Subject:)

yes .. is not responsive to the question of how you propose to  
display or examine such a mathematical object. My signature was  
perhaps a lame (certainly an ineffective) effort at getting you to  
acknowledge that there might, just might, be some conceptual  
difficulties in viewing a 5+1 = 6 dimensional object.

Can you point to any examples of such a procedure being applied in a  
manner that you find helpful? It is certainly feasible to calculate  
distances in 5-space, but the next step, displaying the  
concentration of those distances as a function of the coordinates,  
would be the tough nut.

(1000 data points is not a problem. That amount of data should easily  
fit in any device that can run R.)

-- 
David


On Jun 4, 2009, at 12:06 AM, arijit kumar debnath wrote:

 yes..
 I want a density estimator for 5 dimensional data.I want it to be  
 efficient since I don't have access to a fast computer.My data set  
 is quite large(about 1000 data points) and I have only a pentium 4  
 1.7 Ghz (512 Mb RAM)computer.

 On Thu, Jun 4, 2009 at 7:25 AM, David Winsemius dwinsem...@comcast.net 
  wrote:
 We can get you a kde2d but you really want a kde5d? What sort of  
 display are you proposing?

 -- 
 David Earthling Winsemius

 On Jun 3, 2009, at 9:26 PM, arijit kumar debnath wrote:

 I want to fit a kernel density to a data-set of size 1000 and each
 data point being of dimension 5. The default density function does'nt
 work for me. Is there any other function available which can do the
 job efficiently.?
 I don't have access to a very fast computer.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT


[[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] wrong labels and colors of points in graph/plot

2009-06-04 Thread David Winsemius
No attachment came through the mailserver. Did you follow the  
directions in the posting guide regarding acceptable types of  
attachments? I also do not see any code that would let us reproduce an  
input process.


One method that might work is to offer the results of  
dput(coefficients) as text within your message.


--
David
On Jun 4, 2009, at 12:22 PM, Katharina May wrote:


Hi there,

I trying to solve this problem for the whole day not going anywhere,
so I  really hope maybe somebody can help
me in this community...
I've got an object coefficient2 which I want to plot in differerent
ways, with colors and labels added to the points,
but somehow there seems to be a problem if a value is NA within the
independent variable, resulting in false labels and false colors for
the points.

plot(coefficient2$intercept ~ coefficient2$average_height,
main=intercepts ::: height, ylab=intercepts, xlab=average height
per site [cm], xlim=c(20,3020), ylim=c(-2,5), col=coefficient2$color)
highlight(coefficient2$intercept ~ coefficient2$average_height,
lbls=coefficient2$site_no,col=Red, cex = .6)

plot(coefficient2$intercept ~ coefficient2$average_dbh,
main=intercepts ::: dbh, ylab=intercepts, xlab=average dbh per
site [mm], xlim=c(-10,360), ylim=c(-2,5),col=coefficient2$color )
highlight(coefficient2$intercept ~ coefficient2$average_dbh,
lbls=coefficient2$site_no,col=Red, cex = .6


If I create a temporary object for each plot excluding any NA values
for the x axis variable, somehow all points are displayed and the
labels are correct except for the color (I have e.g. no clue why some
points are red which I do not define at all and no ones are yellow
which I use several times).

#create temp container for all coefficients with average heights for  
plotting
coef_avheight - coefficient2[which(! 
is.na(coefficient2$average_height)),]

plot(coef_avheight$intercept ~ coef_avheight$average_height,
main=intercepts ::: height, ylab=intercepts, xlab=average height
per site [cm], xlim=c(20,3020), ylim=c(-2,5),
col=coef_avheight$color)
highlight(coef_avheight$intercept ~ coef_avheight$average_height,
lbls=coef_avheight$site_no,col=Red, cex = .6)

#create temp container for all coefficients with average dbh for  
plotting

coef_avdbh- coefficient2[which(!is.na(coefficient2$average_dbh)),]
plot(coef_avdbh$intercept ~ coef_avdbh$average_dbh,  main=intercepts
::: dbh, ylab=intercepts, xlab=average dbh per site [mm],
xlim=c(-10,360), ylim=c(-2,5),col=coef_avdbh$color )
highlight(coef_avdbh$intercept ~ coef_avdbh$average_dbh,
lbls=coef_avdbh$site_no,col=Red, cex = .6)


Maybe someone can explain me the color issue and the problem with the
NA values which results in a wrong labeling and to few
points being displayed? I'm new to R as you can guess and my code
isn't really elegant but I really cannot get faults within it...


Attached you can find the referred R object (coefficient2).
highlight requires library(NCStats)...

Thank you very, very much,

  Katharina
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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
Heritage Laboratories
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] Return variable assignments from a function

2009-06-04 Thread Greg Snow
I still think that fortune(181) applies here.  Someday you (or another user 
that you give your function to) will run this, then realize that you/they had 
an A, B, or c variable that has just been overwritten that you/they wanted to 
keep.  (also 'c' is one of the variable names recommended against, there is a 
very often used function 'c').

You are also still breaking the association between A, B, and c.  Keeping 
things grouped into a single object is one of the powerful concepts in R/S.

If you know that one function (funcA) is only going to be called by another 
function (funcB) and you want funcB to have access to things computed in funcA, 
then the easiest/most straight forward is to return the values from funcA to 
funcB and use the ret$A type syntax.  Using '-' to have funcA assign values 
in funcB is safer (and often simpler) than using 'assign', but you still need 
to be careful.

If you want to use the return values at the command line and just want to avoid 
all the typing of object$... then use the 'with' and 'within' functions (or 
other functions that take a list of objects as the data to operate on).

If you tell us more about what you are trying to accomplish, maybe we can show 
you a way to use the power of the R way of thinking to make your task easier 
rather than trying to work around it.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: hydeb...@gmail.com [mailto:hydeb...@gmail.com] On Behalf Of Scott
 Hyde
 Sent: Wednesday, June 03, 2009 9:30 PM
 To: r-help@r-project.org
 Subject: Re: Return variable assignments from a function
 
 As a followup to my question yesterday, what if I were to return the
 argument as a list, and then unwrap the list with the function I've
 written called objects.  Is there any problems with doing it?  It
 works to use it inside other functions.  For example:
 
 =
 
  objects - function(alist) {
   for (vars in names(alist))
 assign(vars,alist[[vars]],pos=sys.frame(-1))
 }
 
  simple - function(m,n) {
   A=matrix(c(3,3,2,3),2,2)
   B=m
   c=1:n
   list(A=A,B=B,c=c)
 }
  rm(A,B,c)  #just in case they exist
  stuff=simple(2,3)
  objects(stuff)
  A
  [,1] [,2]
 [1,]32
 [2,]33
  B
 [1] 2
  c
 [1] 1 2 3
 
 
 =
 
 -Scott
 
 
 *
 Scott K. Hyde
 Assistant Professor of Statistics and Mathematics
 College of Math and Sciences
 Brigham Young University -- Hawaii
 Laie, HI  96762
 
 
 
 On Tue, Jun 2, 2009 at 5:30 PM, Scott Hyde hy...@byuh.edu wrote:
 
  I'd like to perform return variable assignments like matlab.  For
 example, the following function would return A, B, and c to the script
 that called it.
 
  =
  function  [A,B,c] = simple(m,n)
  A=[ 3 2; 3 3]
  B=m
  c=1:n
  =
 
  I'd like to do similar assignments in R, but I seem to be able to
 only return one variable.  I tried to use a list to return all the
 arguments, but then each has to be referred to using the list.  For
 example:
 
  =
  simple - function(m,n) {
    A=matrix(c(3,3,2,3),2,2)
    B=m
    c=1:n
    list(A=A,B=B,c=c)
  }
 
   stuff=simple(2,3)
   stuff
  $A
   [,1] [,2]
  [1,]    3    2
  [2,]    3    3
 
  $B
  [1] 2
 
  $c
  [1] 1 2 3
  =
 
  Then I could assign each variable like this (which is what I'd like
 to avoid):
 
  =
  A=stuff$A
  B=stuff$B
  c=stuff$c
  rm(stuff)   #stuff isn't needed anymore.
  =
 
 
  I've even toyed with the superassignment operator, which also works,
 but I think it doesn't work for functions of functions.  The following
 example works.
 
  =
  simple2 - function(m,n) {
    A - matrix(c(3,3,2,3),2,2)
    B - m
    c - 1:n
  }
 
   stuff2=simple2(2,3)
   stuff2
  [1] 1 2 3
   A
   [,1] [,2]
  [1,]    3    2
  [2,]    3    3
   B
  [1] 2
   c
  [1] 1 2 3
  =
 
  In the example below, I call the function ten inside the function
 nine.  I'm expecting that the variable b should change only in the
 function nine (and not in the global environment).  In other words, I
 think the line (nine) b= 9 should be (nine) b= 10.
 
  Can someone help me know how to do this correctly?
 
  -Scott
 
  =
  nine = function(a) {
    b - 9
    ten(a)
    print(paste((nine) b=,b))
  }
 
  ten = function(d) {
    b - 10
    print(paste((ten) b=,b))
    print(paste((ten) d=,d))
    d
  }
 
   nine(5)
  [1] (ten) b= 10
  [1] (ten) d= 5
  [1] (nine) b= 9
   b
  [1] 10
  =
 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the 

Re: [R] Using WinBUGS from R: A Multi-Way Array Problem

2009-06-04 Thread Greg Snow
Your output example below looks the same as the input.  But I think the 'aperm' 
function may be what you are looking for, read its help page and run the 
example to see if that will work for you.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Khurram Nadeem
 Sent: Wednesday, June 03, 2009 11:37 PM
 To: r-help@r-project.org
 Subject: [R] Using WinBUGS from R: A Multi-Way Array Problem
 
 Please suggest a way out to the following problem.
 
 I have a T by n data matrix (say Y) where coulmns are time series of
 length
 T.
 To do some analysis in WinBUGS I need to construct my data as follows.
 
 yy-rep(Y,k) ## this will be a vector
 Yk-array(yy,dim=c(T,n,k)) ## data array
 
 Here the definition of dim indices is
 
 first index: T rows
 second index: n columns
 third index: for kth T by n array
 
 EXAMPLE
 T=3
 n=2
 k=2
 Y-matrix(c(1,2,3,4,5,6), ncol=n) ## my data matrix
 yy-rep(Y,k)
 Yk-array(yy,dim=c(T,n,k))
 Yk  # this produces the following R output.
 
 , , 1
  [,1] [,2]
 [1,]14
 [2,]25
 [3,]36
 , , 2
  [,1] [,2]
 [1,]14
 [2,]25
 [3,]36
 
 That is, I have copied the orignal data k=2 times. WinBUGS will be
 supplied
 the following data
 
 d-list(Yk=Yk, T=T,n=n,k=k).
 
 Now in WinBUGS I have to define a multivariate stochastic node as as
 follows
 
 e[i,1:n,kk]~dmnorm(   ,   ) ## i= 1,2,...,T ; kk = 1,2,...,k
 
 But Winbugs accepts only something like
 
 e[ , , 1:n]~dmnorm(   ,   ).
 
 That is 1:n has to be given at the leftmost position.
 
 This means that I need to change the definition of dim indices in R as
 follows.
 
 first index: for kth T by n array
 second index: T rows
 third index: n columns.
 
 Specifically, I want the above output as
 
  1, ,
  [,1] [,2]
 [1,]14
 [2,]25
 [3,]36
 
 2, ,
  [,1] [,2]
 [1,]14
 [2,]25
 [3,]36
 
 I would appriciate any help in this regard.
 
 
 Khurram Nadeem
 PhD Student
 Department of Math.  Stat. Sciences
 University of Alberta
 
   [[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] wrong labels and colors of points in graph/plot

2009-06-04 Thread katharina

sorry, the attachment can be found here for download:
http://www.wzw.tum.de/waldinventur/fileadmin/coefficient2.RData



katharina wrote:
 
 Hi there,
 
 I trying to solve this problem for the whole day not going anywhere,
 so I  really hope maybe somebody can help
 me in this community...
 I've got an object coefficient2 which I want to plot in differerent
 ways, with colors and labels added to the points,
 but somehow there seems to be a problem if a value is NA within the
 independent variable, resulting in false labels and false colors for
 the points.
 
 plot(coefficient2$intercept ~ coefficient2$average_height,
 main=intercepts ::: height, ylab=intercepts, xlab=average height
 per site [cm], xlim=c(20,3020), ylim=c(-2,5), col=coefficient2$color)
 highlight(coefficient2$intercept ~ coefficient2$average_height,
 lbls=coefficient2$site_no,col=Red, cex = .6)
 
 plot(coefficient2$intercept ~ coefficient2$average_dbh,
 main=intercepts ::: dbh, ylab=intercepts, xlab=average dbh per
 site [mm], xlim=c(-10,360), ylim=c(-2,5),col=coefficient2$color )
 highlight(coefficient2$intercept ~ coefficient2$average_dbh,
 lbls=coefficient2$site_no,col=Red, cex = .6
 
 
 If I create a temporary object for each plot excluding any NA values
 for the x axis variable, somehow all points are displayed and the
 labels are correct except for the color (I have e.g. no clue why some
 points are red which I do not define at all and no ones are yellow
 which I use several times).
 
 #create temp container for all coefficients with average heights for
 plotting
 coef_avheight - coefficient2[which(!is.na(coefficient2$average_height)),]
 plot(coef_avheight$intercept ~ coef_avheight$average_height,
 main=intercepts ::: height, ylab=intercepts, xlab=average height
 per site [cm], xlim=c(20,3020), ylim=c(-2,5),
 col=coef_avheight$color)
 highlight(coef_avheight$intercept ~ coef_avheight$average_height,
 lbls=coef_avheight$site_no,col=Red, cex = .6)
 
 #create temp container for all coefficients with average dbh for plotting
 coef_avdbh- coefficient2[which(!is.na(coefficient2$average_dbh)),]
 plot(coef_avdbh$intercept ~ coef_avdbh$average_dbh,  main=intercepts
 ::: dbh, ylab=intercepts, xlab=average dbh per site [mm],
 xlim=c(-10,360), ylim=c(-2,5),col=coef_avdbh$color )
 highlight(coef_avdbh$intercept ~ coef_avdbh$average_dbh,
 lbls=coef_avdbh$site_no,col=Red, cex = .6)
 
 
 Maybe someone can explain me the color issue and the problem with the
 NA values which results in a wrong labeling and to few
 points being displayed? I'm new to R as you can guess and my code
 isn't really elegant but I really cannot get faults within it...
 
 
 Attached you can find the referred R object (coefficient2).
 highlight requires library(NCStats)...
 
 Thank you very, very much,
 
Katharina
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/wrong-labels-and-colors-of-points-in-graph-plot-tp23873337p23873849.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] Excel Export in a beauty way

2009-06-04 Thread Kevin W
Also see this post at
https://stat.ethz.ch/pipermail/r-help/2008-July/169149.html

The same idea is discussed in a SAS proceedings paper (but it is NOT
specific to SAS)
www.lexjansen.com/wuss/2005/data_presentation/dp_using_*sas*_with_xml.pdfhttp://www.lexjansen.com/wuss/2005/data_presentation/dp_using_sas_with_xml.pdf

As Marc indicated, the autofit column widths is a bit confusing.  It would
be better called set the column width to a number large enough to show all
current contents.

Kevin


On Thu, Jun 4, 2009 at 12:37 AM, Patrick Connolly 
p_conno...@slingshot.co.nz wrote:

 On Wed, 03-Jun-2009 at 08:54AM -0500, Marc Schwartz wrote:

 [...]

  For example, using the Perl package that I do for the WriteXLS
  package, it is not possible to use the AutoFit capability to
  easily set all column widths wide enough to visually allow for the
  data contained within each. From the available Perl package
  documentation, this appears to be a run time only feature, which
  means that it would require Excel to be available and running and
  the user either going through the column formatting menu, or
  creating a macro to automate the process.

 I've used that Perl script for some time and find it very useful
 (thanks Marc).  I can't see a lot of point in trying to get the column
 widths done by it.  In Excel, it's very easy to highlight every column
 and then double click on the line separating any two column names and
 that will set ALL the widths to their optimum in one go.
 (Just in case anyone didn't know.)

 If that's not sufficient, one of those other methods might suit.

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

 ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


[[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] documentation / An Intro to R / list manipulation

2009-06-04 Thread Robbie Morrison

Hello R users

  http://cran.r-project.org/doc/manuals/R-intro.html
  An Introduction to R
  6.2 Constructing and modifying lists

After a short but successful struggle with nested
associative arrays (using named lists), I think the
following documentation change might be beneficial.

The existing description and example (see below)
implies that the given statement would transfer the
component name as well (not so):

 Lst[5] - list(matrix=Mat)

-
 new text for section 6.2
-

Lists, like any subscripted object, can be extended by
specifying additional components. For example

 Lst[5] - list(Mat)

This new component can also be named, using either a
character string (as shown) or suitable string variable

 names(Lst)[5] - matrix

-
 test code
-

  Mat - matrix()
  Lst - list()
  Lst[1] - list(matrix = Mat)
  str(Lst)
  # List of 1
  #  $ : logi [1, 1] NA
  names(Lst)[1] - matrix
  str(Lst)
  # List of 1
  #  $ matrix: logi [1, 1] NA


many thanks to the R team in general
Robbie

ps: I'm using R for visualizing data, including
directed graphs (via adjacency lists) and timeseries,
and for summarizing relatively diverse but consistent
datasets
---
Robbie Morrison
PhD student -- policy-oriented energy system simulation
Technical University of Berlin (TU-Berlin), Germany
University email (redirected) : morri...@iet.tu-berlin.de
Webmail (preferred)   : rob...@actrix.co.nz
[from IMAP client]

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

2009-06-04 Thread stephen sefick
Could you provide a reproducible example even with fake data would be
fine or dput() yours.

On Thu, Jun 4, 2009 at 10:11 AM, Par Leijonhufvud
p...@hunter-gatherer.org wrote:
 I want to make a log-log plot with a regression line, but I can't figure
 out what I'm doing wrong. What I'm trying is:

 plot(mass,area, log=xy, pch=as.numeric(food))
 abline(lm(mass~area))

 or

 plot(mass,area, log=xy, pch=as.numeric(food))
 islands$logmass - log(mass)
 islands$logarea - log(area)
 attach(islands)
 abline(lm(logmass~logarea))


 But that does not show a line. Where am I going wrong?

 data:
 island, area,species,food,mass
 Ibiza , 577 ,  Anser n. sp., herb,  2.0
 Ibiza , 577 ,    Haliaeetus albicilla, carn, 4.8
 Mauritius , 1874 ,  Raphus cucullatus, herb,  19
 Mauritius , 1874 ,  Circus alphonsi, carn, 0.63
 Mallorca , 3667 , Myotragus balearicus, herb,  40
 Mallorca , 3667 , Aquila chrysaetos, carn, 4.2
 Kreta , 8259 , Elephas creutzburgi, herb,  3200
 ...

 /Par

 --
 Par Leijonhufvud                               p...@hunter-gatherer.org
 I don't believe in reincarnation.  I used to,
 but that was in another life.

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




-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fast way of finding top-n values of a long vector

2009-06-04 Thread Greg Snow
Try adding a version that uses sort with the partial argument, that should be 
faster than regular sort (for long enough test vectors) and possibly faster 
than the max solutions when finding more than just the largest 2.

Also, for your max solutions, what happens when the 2 largest values are 
identical?

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Allan Engelhardt
 Sent: Thursday, June 04, 2009 2:18 AM
 To: r-help@r-project.org
 Subject: [R] Fast way of finding top-n values of a long vector
 
 If x is a (long) vector and n  length(x), what is a fast way of
 finding the top-n values of x?
 
 Some suggestions (calculating the ratio of the two top values):
 
 
 library(rbenchmark)
 set.seed(1); x - runif(1e6, max=1e7); x[1] - NA;
 benchmark(
  replications=20,
  columns=c(test,elapsed),
  order=elapsed
  , sort = {a-sort(x, decreasing=TRUE, na.last=NA)[1:2]; a[1]/a[2];}
  , max  = {m-max(x, na.rm=TRUE); w-which(x==m)[1]; m/max(x[-w],
 na.rm=TRUE);}
  , max2 = {w-which.max(x); max(x, na.rm=TRUE)/max(x[-w], na.rm=TRUE);}
 )
 #   test elapsed
 # 3 max2   0.772
 # 2  max   1.732
 # 1 sort   4.958
 
 
 I want to apply this code to a few tens of thousands of vectors so
 speed
 does matter.  In C or similar I would of course calculate the result
 with a single pass through x, and not with three passes as in 'max2'.
 
 
 Allan.
 
 PS: I know na.last=NA is the default for sort, but there is no harm in
 being explicit in how you want NA's handled.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] wrong labels and colors of points in graph/plot

2009-06-04 Thread David Winsemius
Was not able to find NCStats on CRAN or BioConductor repositories. You  
are wasting our (or mine at any rate) time by giving us dead ends.


You have been bitten by the factor snake in the grass. Color should  
be text rather than a factor if you want the desired results.


See if this is illuminating and eventually helpful:
 str(coefficient2)
'data.frame':   26 obs. of  11 variables:
 $ site_no  : num  29 10 17 18 19 25 9 33 37 41 ...
 $ intercept: num  0.603 2.767 3.6 1.86 2.753 ...
 $ slope: num  0.912 0.867 0.841 0.99 0.911 ...
 $ average_height   : num  90.4 2096.2 990 1950 2184 ...
 $ average_crown_length : num  NA 1066 592 645 795 ...
 $ average_dbh  : num  11.8 271.2 105.1 169.2 220.9 ...
 $ average_age  : num  NA 80.3 19.3 50.9 68.2 ...
 $ average_BM_branches  : num  NA 66649 12679 11246 38049 ...
 $ average_BM_leaves_needles: num  2.28 31051.41 7727.07 9322.6  
27112.2 ...
 $ average_BM_total : num  36.7 538194.3 62332.9 163137.2  
339177.5 ...
 $ color: Factor w/ 4 levels  
violet,yellow,..: 1 2 2 2 2 2 1 3 1 1 ...

  as.character(coefficient2$color)
 [1] violet yellow yellow yellow yellow yellow violet  
black  violet violet black
[12] yellow violet yellow violet violet violet yellow  
violet violet black  green

[23] green  green  green  green
  coefficient2$color - as.character(coefficient2$color)

Now do your plots

--
David

On Jun 4, 2009, at 12:54 PM, katharina wrote:



sorry, the attachment can be found here for download:
http://www.wzw.tum.de/waldinventur/fileadmin/coefficient2.RData



katharina wrote:


Hi there,

I trying to solve this problem for the whole day not going anywhere,
so I  really hope maybe somebody can help
me in this community...
I've got an object coefficient2 which I want to plot in differerent
ways, with colors and labels added to the points,
but somehow there seems to be a problem if a value is NA within the
independent variable, resulting in false labels and false colors for
the points.

plot(coefficient2$intercept ~ coefficient2$average_height,
main=intercepts ::: height, ylab=intercepts, xlab=average height
per site [cm], xlim=c(20,3020), ylim=c(-2,5),  
col=coefficient2$color)

highlight(coefficient2$intercept ~ coefficient2$average_height,
lbls=coefficient2$site_no,col=Red, cex = .6)

plot(coefficient2$intercept ~ coefficient2$average_dbh,
main=intercepts ::: dbh, ylab=intercepts, xlab=average dbh per
site [mm], xlim=c(-10,360), ylim=c(-2,5),col=coefficient2$color )
highlight(coefficient2$intercept ~ coefficient2$average_dbh,
lbls=coefficient2$site_no,col=Red, cex = .6


If I create a temporary object for each plot excluding any NA values
for the x axis variable, somehow all points are displayed and the
labels are correct except for the color (I have e.g. no clue why some
points are red which I do not define at all and no ones are yellow
which I use several times).

#create temp container for all coefficients with average heights for
plotting
coef_avheight - coefficient2[which(! 
is.na(coefficient2$average_height)),]

plot(coef_avheight$intercept ~ coef_avheight$average_height,
main=intercepts ::: height, ylab=intercepts, xlab=average height
per site [cm], xlim=c(20,3020), ylim=c(-2,5),
col=coef_avheight$color)
highlight(coef_avheight$intercept ~ coef_avheight$average_height,
lbls=coef_avheight$site_no,col=Red, cex = .6)

#create temp container for all coefficients with average dbh for  
plotting

coef_avdbh- coefficient2[which(!is.na(coefficient2$average_dbh)),]
plot(coef_avdbh$intercept ~ coef_avdbh$average_dbh,  main=intercepts
::: dbh, ylab=intercepts, xlab=average dbh per site [mm],
xlim=c(-10,360), ylim=c(-2,5),col=coef_avdbh$color )
highlight(coef_avdbh$intercept ~ coef_avdbh$average_dbh,
lbls=coef_avdbh$site_no,col=Red, cex = .6)


Maybe someone can explain me the color issue and the problem with the
NA values which results in a wrong labeling and to few
points being displayed? I'm new to R as you can guess and my code
isn't really elegant but I really cannot get faults within it...


Attached you can find the referred R object (coefficient2).
highlight requires library(NCStats)...

Thank you very, very much,

  Katharina

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




--
View this message in context: 
http://www.nabble.com/wrong-labels-and-colors-of-points-in-graph-plot-tp23873337p23873849.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, 

Re: [R] Plot and lm

2009-06-04 Thread Par Leijonhufvud
stephen sefick ssef...@gmail.com [2009.06.04] wrote:
 Could you provide a reproducible example even with fake data would be
 fine or dput() yours.

Sorry, I don't understand what you mean. Im my post was the first 8 lines of
my data, imported into R with

islands - read.table(islands.csv, sep=,, h=T)

and the code was a cut-and-past from my .Rhistory. When I run it I get a
nice graph, but no line from abline (unless it is vertical or horizontal
and superimposed uppon one of the axes)... Which turns out ot be the
case: 

Just running lm I get

 lm(mass~area)

Call:
lm(formula = mass ~ area)

Coefficients:
(Intercept) area  
  3.615e+025.967e-05  

 lm(logmass~logarea)

Call:
lm(formula = logmass ~ logarea)

Coefficients:
(Intercept)  logarea  
-1.3480   0.4747  


Forcing the graph with ylim=c(0,001,1) I see a line from the latter,
but (no surprise) none from the former. Now I just need to fix my
assumptions such that I produce a line that is an actual regession
line...

Thanks for making me think it through!

/Par

-- 
Par Leijonhufvud   p...@hunter-gatherer.org
The best comment I heard about Starship Troopers was Based on the back cover
of a book by RAH.
-- Paul Tomblin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] wrong labels and colors of points in graph/plot

2009-06-04 Thread katharina

Sorry for the problem with NCStats, I used it from this page not realizing
that this is not 'official':
http://www.rforge.net/NCStats/files/

Thank you for helping me with the color issue, I finally know now what has
happened with the
colors of the points my plots.



David Winsemius wrote:
 
 Was not able to find NCStats on CRAN or BioConductor repositories. You  
 are wasting our (or mine at any rate) time by giving us dead ends.
 
 You have been bitten by the factor snake in the grass. Color should  
 be text rather than a factor if you want the desired results.
 
 See if this is illuminating and eventually helpful:
   str(coefficient2)
 'data.frame': 26 obs. of  11 variables:
   $ site_no  : num  29 10 17 18 19 25 9 33 37 41 ...
   $ intercept: num  0.603 2.767 3.6 1.86 2.753 ...
   $ slope: num  0.912 0.867 0.841 0.99 0.911 ...
   $ average_height   : num  90.4 2096.2 990 1950 2184 ...
   $ average_crown_length : num  NA 1066 592 645 795 ...
   $ average_dbh  : num  11.8 271.2 105.1 169.2 220.9 ...
   $ average_age  : num  NA 80.3 19.3 50.9 68.2 ...
   $ average_BM_branches  : num  NA 66649 12679 11246 38049 ...
   $ average_BM_leaves_needles: num  2.28 31051.41 7727.07 9322.6  
 27112.2 ...
   $ average_BM_total : num  36.7 538194.3 62332.9 163137.2  
 339177.5 ...
   $ color: Factor w/ 4 levels  
 violet,yellow,..: 1 2 2 2 2 2 1 3 1 1 ...
as.character(coefficient2$color)
   [1] violet yellow yellow yellow yellow yellow violet  
 black  violet violet black
 [12] yellow violet yellow violet violet violet yellow  
 violet violet black  green
 [23] green  green  green  green
coefficient2$color - as.character(coefficient2$color)
 
 Now do your plots
 
 -- 
 David
 
 On Jun 4, 2009, at 12:54 PM, katharina wrote:
 

 sorry, the attachment can be found here for download:
 http://www.wzw.tum.de/waldinventur/fileadmin/coefficient2.RData



 katharina wrote:

 Hi there,

 I trying to solve this problem for the whole day not going anywhere,
 so I  really hope maybe somebody can help
 me in this community...
 I've got an object coefficient2 which I want to plot in differerent
 ways, with colors and labels added to the points,
 but somehow there seems to be a problem if a value is NA within the
 independent variable, resulting in false labels and false colors for
 the points.

 plot(coefficient2$intercept ~ coefficient2$average_height,
 main=intercepts ::: height, ylab=intercepts, xlab=average height
 per site [cm], xlim=c(20,3020), ylim=c(-2,5),  
 col=coefficient2$color)
 highlight(coefficient2$intercept ~ coefficient2$average_height,
 lbls=coefficient2$site_no,col=Red, cex = .6)

 plot(coefficient2$intercept ~ coefficient2$average_dbh,
 main=intercepts ::: dbh, ylab=intercepts, xlab=average dbh per
 site [mm], xlim=c(-10,360), ylim=c(-2,5),col=coefficient2$color )
 highlight(coefficient2$intercept ~ coefficient2$average_dbh,
 lbls=coefficient2$site_no,col=Red, cex = .6


 If I create a temporary object for each plot excluding any NA values
 for the x axis variable, somehow all points are displayed and the
 labels are correct except for the color (I have e.g. no clue why some
 points are red which I do not define at all and no ones are yellow
 which I use several times).

 #create temp container for all coefficients with average heights for
 plotting
 coef_avheight - coefficient2[which(! 
 is.na(coefficient2$average_height)),]
 plot(coef_avheight$intercept ~ coef_avheight$average_height,
 main=intercepts ::: height, ylab=intercepts, xlab=average height
 per site [cm], xlim=c(20,3020), ylim=c(-2,5),
 col=coef_avheight$color)
 highlight(coef_avheight$intercept ~ coef_avheight$average_height,
 lbls=coef_avheight$site_no,col=Red, cex = .6)

 #create temp container for all coefficients with average dbh for  
 plotting
 coef_avdbh- coefficient2[which(!is.na(coefficient2$average_dbh)),]
 plot(coef_avdbh$intercept ~ coef_avdbh$average_dbh,  main=intercepts
 ::: dbh, ylab=intercepts, xlab=average dbh per site [mm],
 xlim=c(-10,360), ylim=c(-2,5),col=coef_avdbh$color )
 highlight(coef_avdbh$intercept ~ coef_avdbh$average_dbh,
 lbls=coef_avdbh$site_no,col=Red, cex = .6)


 Maybe someone can explain me the color issue and the problem with the
 NA values which results in a wrong labeling and to few
 points being displayed? I'm new to R as you can guess and my code
 isn't really elegant but I really cannot get faults within it...


 Attached you can find the referred R object (coefficient2).
 highlight requires library(NCStats)...

 Thank you very, very much,

   Katharina

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



 -- 
 View this message in 

[R] Error Catching?

2009-06-04 Thread Brigid Mooney
Hi,

Is there an easy way to catch errors, in order to arrange for
r-scripts to exit gracefully?

I'm thinking of something along the lines of using is.na with an
if/else statement, but for errors.

Thanks!

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


[R] how to tell if as.numeric succeeds?

2009-06-04 Thread Steve Jaffe

Suppose I have a vector of strings. I'd like to convert this to a vector of
numbers if possible. How can I tell if it is possible? 

as.numeric() will issue a warning if it fails. Do I need to trap this
warning? If so, how?

In other words, my end goal is a function that takes a vector of strings and
returns either a numeric vector or the original vector. Assuming this
doesn't already exist, then to write it I'd need a function that returns
true if its input can be converted to numeric and false otherwise.

Any suggestions will be appreciated.
-- 
View this message in context: 
http://www.nabble.com/how-to-tell-if-as.numeric-succeeds--tp23874936p23874936.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] Error Catching?

2009-06-04 Thread Barry Rowlingson
On Thu, Jun 4, 2009 at 6:56 PM, Brigid Mooney bkmoo...@gmail.com wrote:
 Hi,

 Is there an easy way to catch errors, in order to arrange for
 r-scripts to exit gracefully?

 I'm thinking of something along the lines of using is.na with an
 if/else statement, but for errors.


 Try 'try'.

Barry

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


Re: [R] Error Catching?

2009-06-04 Thread Marc Schwartz

On Jun 4, 2009, at 12:56 PM, Brigid Mooney wrote:


Hi,

Is there an easy way to catch errors, in order to arrange for
r-scripts to exit gracefully?

I'm thinking of something along the lines of using is.na with an
if/else statement, but for errors.

Thanks!


See ?try and ?tryCatch

HTH,

Marc Schwartz

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


Re: [R] Plot and lm

2009-06-04 Thread stephen sefick
I can't copy and paste your example right out of you email and into an
R session.
?dput

and then see if you can copy and paste it into an R session and make
it work.  That way it is easier for everyone and you have a better
chance of getting helpful responses.
HTH

Stephen Sefick

On Thu, Jun 4, 2009 at 1:47 PM, Par Leijonhufvud
p...@hunter-gatherer.org wrote:
 stephen sefick ssef...@gmail.com [2009.06.04] wrote:
 Could you provide a reproducible example even with fake data would be
 fine or dput() yours.

 Sorry, I don't understand what you mean. Im my post was the first 8 lines of
 my data, imported into R with

 islands - read.table(islands.csv, sep=,, h=T)

 and the code was a cut-and-past from my .Rhistory. When I run it I get a
 nice graph, but no line from abline (unless it is vertical or horizontal
 and superimposed uppon one of the axes)... Which turns out ot be the
 case:

 Just running lm I get

 lm(mass~area)

 Call:
 lm(formula = mass ~ area)

 Coefficients:
 (Intercept)         area
  3.615e+02    5.967e-05

 lm(logmass~logarea)

 Call:
 lm(formula = logmass ~ logarea)

 Coefficients:
 (Intercept)      logarea
    -1.3480       0.4747


 Forcing the graph with ylim=c(0,001,1) I see a line from the latter,
 but (no surprise) none from the former. Now I just need to fix my
 assumptions such that I produce a line that is an actual regession
 line...

 Thanks for making me think it through!

 /Par

 --
 Par Leijonhufvud                               p...@hunter-gatherer.org
 The best comment I heard about Starship Troopers was Based on the back cover
 of a book by RAH.
                -- Paul Tomblin

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




-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 tell if as.numeric succeeds?

2009-06-04 Thread Marc Schwartz

On Jun 4, 2009, at 1:01 PM, Steve Jaffe wrote:



Suppose I have a vector of strings. I'd like to convert this to a  
vector of

numbers if possible. How can I tell if it is possible?

as.numeric() will issue a warning if it fails. Do I need to trap this
warning? If so, how?

In other words, my end goal is a function that takes a vector of  
strings and

returns either a numeric vector or the original vector. Assuming this
doesn't already exist, then to write it I'd need a function that  
returns

true if its input can be converted to numeric and false otherwise.

Any suggestions will be appreciated.




In the case of as.numeric(), it will return NA for any elements in the  
vector that cannot be coerced to numeric:


 as.numeric(c(a, 1, c, 2))
[1] NA  1 NA  2
Warning message:
NAs introduced by coercion


So there are at least three scenarios:

1. All of the elements can be coerced

2. Some of the elements can be coerced

3. None of the elements can be coerced


You could feasibly do something like this, which will suppress the  
warning, so there is no textual output in the case of a warning:


 suppressWarnings(as.numeric(c(a, 1, c, 2)))
[1] NA  1 NA  2


Then you just need to check to see if any() of the elements are not  
NAs, which means that at least one value was successfully coerced:


NumCheck - function(x)
{
  Result - suppressWarnings(as.numeric(x))
  if (any(!is.na(Result))) TRUE else FALSE
}


 NumCheck(c(a, 1, c, 2))
[1] TRUE

 NumCheck(letters[1:4])
[1] FALSE

 NumCheck(c(1, 2, 3, 4))
[1] TRUE


Alter the internal logic in the function relative to NA checking  
depending up what you may need.


HTH,

Marc Schwartz

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


Re: [R] Newton method again

2009-06-04 Thread Berend Hasselman


Roslina Zakaria wrote:
 
 Hi Ravi,
 I did ask you some question regarding newton method sometime ago..  Now I
 have fixed the problem and I also wrote 2 looping code (ff1 and ff2) to
 evaluate the modified Bessel function of the first kind and call them in
 the newton code.  But I dont't understand why it gives the error message
 but still give the result but it is incorrect(too big and too small).
  
 ff1 - function(bb,eta,z){
 r - length(z)
 for (i in 1:r) {
 sm - sum(besselI(z[i]*bb,eta)/besselI(z[i]*bb,eta+1))*z[i]}
 sm
 }
 ff1(bb,eta,z)
 ff2 - function(bb,eta,z,k){
 r - length(z)
 for (i in 1:r) {
 sm1 -
 sum((z[i]*bb/2)*(psigamma((0:k)+eta+1,deriv=0)/(factorial(0:k)*gamma((0:k)+eta+1
 sm2 - sum((besselI(z[i]*bb,eta)*log(z[i]*bb/2) -
 sm1)/besselI(z[i]*bb,eta))}
 sm2
 }
 ff2(bb,eta,z,10)
  
 newton.input3 - function(pars)
 {  ##  parameters to be approximated , note: eta - alpha3-0.5
    eta   - pars[1]
    bt3   - pars[2]
    bt4   - pars[3]
    rho   - pars[4]
    b1    - (pars[2]-pars[3])^2+4*pars[2]*pars[3]*pars[4]
    b2    - sqrt(b1)
    bb    - b2/(2*pars[2]*pars[3]*(1-pars[4]))
    bf2   -
 (pars[3]+2*pars[2]*pars[4]-pars[2])/(2*pars[2]^2*(pars[4]-1)*b2)
    bf3   -
 (pars[2]+2*pars[3]*pars[4]-pars[3])/(2*pars[3]^2*(pars[4]-1)*b2)
    bf4   -
 (2*pars[2]*pars[3]*pars[4]+pars[2]^2+pars[3]^2)/(2*pars[2]*pars[3]*(pars[4]-1)^2*b2)
    zsm   - sum(z)
    psigm - psigamma(pars[1]+0.5,deriv=0) 
    pdz   - log(prod(z))
    erh   - (1+2*pars[1])*(pars[4]-1)
    brh1  - 2*pars[2]*pars[3]*pars[4]+pars[2]^2+pars[3]^2 
    brh2  - 2*pars[2]*pars[3]*(pars[4]-1)^2 
    k - 1000
    ## function
    fn1a  - pdz -r*(2*psigm + log(b1))/2
    fn2a  - (pars[2]*r*erh+zsm)/(2*pars[2]^2*(1-pars[4]))
    fn3a  - (pars[3]*r*erh+zsm)/(2*pars[3]^2*(1-pars[4]))
    fn4a  -
 (pars[2]*pars[3]*r*erh+(pars[2]+pars[3])*zsm)/(-2*pars[2]*pars[3]*(pars[4]-1)^2)
    
    ## function that involve modified Bessel function of 1st kind 
    fn1b  - ff2(bb,eta,z,k)
    fn2b  - bf2*ff1(bb,eta,z)
    fn3b  - bf3*ff1(bb,eta,z)
    fn4b  -  bf4*ff1(bb,eta,z)
    
    ##  final function
    fn1   - fn1a + fn1b
    fn2   - fn2a + fn2b
    fn3   - fn3a + fn3b
    fn4   -  fn4a + fn4b
    fval  - c(fn1,fn2,fn3,fn4)
    ## output
    list(fval=fval)
 }
 library(BB)
 start - c(0.7,0.8,0.6,0.4)
 dfsane(pars=start,fn=newton.input3)
 newton.input3(start)
 
 library(BB)
 start - c(0.7,0.8,0.6,0.4)
 dfsane(pars=start,fn=newton.input3)
 Error in dfsane(pars = start, fn = newton.input3) : element 1 is empty;
    the part of the args list of 'length' being evaluated was:
    (par)
 newton.input3(start)
 $fval
 [1]   103.0642   452.5835   823.6637 -1484.3209
 There were 50 or more warnings (use warnings() to see the first 50)

  
 Here is my data:
 z
  [1]  4.2 11.2  0.8 20.4 16.6  3.8  1.2  4.0 10.8 10.2  6.6 25.6 18.2  4.6
 15.0  1.2 12.0 25.4  6.4  1.6  4.8 10.0  3.0
 [24]  7.0  1.8 15.0  8.6 11.2  5.4  1.8 23.2 10.8 25.4  6.0  6.0  5.0  1.4
 11.0  8.4  7.4  6.4  2.6  8.6 15.8

 
 

You could also try package nleqslv which implements Newton and Broyden
methods for solving systems of equations.

I have tried to run your problem but you are not providing all the
information required.
Moreover your example contains errors: for example where are the arguments
defined in the call of ff1  on the line ff1(bb,eta,z)  right after the
definition of ff1?

Where is the variable r used in the lines calculating fn1a, fn2a etc. in
function newton.input3?
Is it the same as in ff1 and ff2? length(z)?

When I insert r-length(z) in newton.input3() I get the results shown in
your post for $fval.

The warnings are being given by factorial(0:k):  In factorial(0:k) : value
out of range in 'gammafn'

Why are you assigning pars[1], pars[2] etc to scalars and then afterwards
not or hardly using them?

You code is inefficient since you are calling ff1 in newton.input3  three
times with exactly the same input.

I have tried to run your code in nleqslv but it appears to run very slowly
so I can't help you any further at this point in time.

What is the purpose of the loop in function ff1

for (i in 1:r) { 
sm - sum(besselI(z[i]*bb,eta)/besselI(z[i]*bb,eta+1))*z[i]} 

(on returning from the function sm will contain the value obtained for i=r)
?

Given the presentation of your problem, I cannot make head or tail of what
you are trying to do so I can't help you any further.

Berend Hasselman



-- 
View this message in context: 
http://www.nabble.com/newton-method-tp22653758p23875467.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] Fast way of finding top-n values of a long vector

2009-06-04 Thread Allan Engelhardt

Greg Snow wrote:

Try adding a version that uses sort with the partial argument, that should be 
faster than regular sort (for long enough test vectors) and possibly faster 
than the max solutions when finding more than just the largest 2.


I find the documentation for the partial argument in sort very difficult 
to understand, but it seems to be something like this:



library(rbenchmark)
set.seed(1); x - runif(1e6, max=1e7); x[1] - NA;
benchmark(
replications=20,
columns=c(test,elapsed),
order=elapsed
, sort = {a-sort(x, decreasing=TRUE, na.last=NA)[1:2]; a[1]/a[2];}
, qsrt = {a-sort(x, decreasing=TRUE, na.last=NA, method=quick)[1:2]; 
a[1]/a[2];}

, part = {a-sort.int(-x, partial=1:2, na.last=NA)[1:2]; a[1]/a[2];}
, max1 = {m-max(x, na.rm=TRUE); w-which(x==m)[1]; 
m/max(x[-w],na.rm=TRUE);}

, max2 = {w-which.max(x); max(x, na.rm=TRUE)/max(x[-w], na.rm=TRUE);}
)
#   test elapsed
# 5 max2   0.846
# 4 max1   1.957
# 3 part   2.752
# 2 qsrt   4.561
# 1 sort   5.577


Completely agree on your point about partial sort being faster for 
larger values of n and certainly giving more scalable code which was 
also what I was looking for so thanks for that tip!



Also, for your max solutions, what happens when the 2 largest values are 
identical?


It returns those two values, just like the sort solution:

x - c(999,NA,1:10,NA,999)
m-max(x, na.rm=TRUE); w-which(x==m)[1]; c(m, max(x[-w],na.rm=TRUE))
# [1] 999 999
sort(x, decreasing=TRUE, na.last=NA)[1:2]
# [1] 999 999


Allan.

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

2009-06-04 Thread William Dunlap
I think the problem is that plot's log axes are to the base 10
so the lm() call needs to use log10, not log.  E.g.,

   x-101:200
   y-sqrt(x)+1+runif(100)
   plot(x,y,log=xy)
   abline(col=red, lm(log(y)~log(x))) # nothing plotted
   abline(col=blue, lm(log10(y)~log10(x))) # passes through points

Expand the y axis a bit and you can see where the base-e line went:

   plot(x,y,log=xy, ylim=c(1,100))
   abline(col=red, lm(log(y)~log(x))) # plotted well above the points
   abline(col=blue, lm(log10(y)~log10(x))) # passes through points

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com  

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of stephen sefick
 Sent: Thursday, June 04, 2009 10:04 AM
 To: Par Leijonhufvud
 Cc: R-help
 Subject: Re: [R] Plot and lm
 
 Could you provide a reproducible example even with fake data would be
 fine or dput() yours.
 
 On Thu, Jun 4, 2009 at 10:11 AM, Par Leijonhufvud
 p...@hunter-gatherer.org wrote:
  I want to make a log-log plot with a regression line, but I 
 can't figure
  out what I'm doing wrong. What I'm trying is:
 
  plot(mass,area, log=xy, pch=as.numeric(food))
  abline(lm(mass~area))
 
  or
 
  plot(mass,area, log=xy, pch=as.numeric(food))
  islands$logmass - log(mass)
  islands$logarea - log(area)
  attach(islands)
  abline(lm(logmass~logarea))
 
 
  But that does not show a line. Where am I going wrong?
 
  data:
  island, area,species,food,mass
  Ibiza , 577 ,  Anser n. sp., herb,  2.0
  Ibiza , 577 ,    Haliaeetus albicilla, carn, 4.8
  Mauritius , 1874 ,  Raphus cucullatus, herb,  19
  Mauritius , 1874 ,  Circus alphonsi, carn, 0.63
  Mallorca , 3667 , Myotragus balearicus, herb,  40
  Mallorca , 3667 , Aquila chrysaetos, carn, 4.2
  Kreta , 8259 , Elephas creutzburgi, herb,  3200
  ...
 
  /Par
 
  --
  Par Leijonhufvud                               
 p...@hunter-gatherer.org
  I don't believe in reincarnation.  I used to,
  but that was in another life.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 -- 
 Stephen Sefick
 
 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods.  We are mammals, and have not exhausted the
 annoying little problems of being mammals.
 
   
 -K. Mullis
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] logical indexing multidimensional arrays

2009-06-04 Thread Steve Jaffe

Suppose I have an n-dimensional array and a logical vector as long as the
first dimension. I can extract an n-dimensional subarray with 
  a[ i, , , , .. ,] where there are n-1 commas (ie empty indices)

Is there an alternative notation that would better lend itself to more
generic use, e.g. to write a function that takes 'a' and 'i' and returns
a[i, , , .. ,]?

-- 
View this message in context: 
http://www.nabble.com/logical-indexing-multidimensional-arrays-tp23875985p23875985.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] type = 'b' with Grid

2009-06-04 Thread baptiste auguie

Dear all,

I feel like I've been reinventing the wheel with this code (implementing 
type = 'b' for Grid graphics),


http://econum.umh.ac.be/rwiki/doku.php?id=tips:graphics-grid:linesandpointsgrob

Has anyone here attempted this with success before? I found suggestions 
of overlapping large white points to mask the lines but it's not ideal.


I welcome any comments on the code. (e.g., should it perhaps use 
polylines rather than segments?, is there an obvious optimization to 
make?, ...)


Regards,

baptiste



# code reproduced below,

barbedGrob - function( x = 1:10/12,
   y = sin(1:10)/3+0.5,
   size=1, shape=21, space=1,
   colour=red, fill=blue,
   linetype=1, linewidth=1){


n - length(x)

dx - diff(x)
dy - diff(y)

# duplicate the points to make split segments
new.x - rep(x, each=2)[-c(1, 2*length(x))]
new.y - rep(y, each=2)[-c(1, 2*length(y))]
new.size - rep(size, each=2, length=2*n)[-c(1, 2*n)]

length - sqrt(dx^2 + dy^2) # length of initial segments
exclusion - 0.5*space*convertX(unit(new.size, char), npc, TRUE)

scaling - exclusion / rep(length, each=2) # exclusion factor around 
each point


start - seq(1, by=2, length(new.x)) # starting points
end - seq(2, by=2, length(new.x)) # end points

x.start - scaling[start] * dx[(start+1)/2] + new.x[start] # shift the 
points
y.start - scaling[start] * dy[(start+1)/2] + new.y[start] # keeping the 
direction of the initial segments


x.end - new.x[end] - scaling[end] * dx[end/2]
y.end - new.y[end] - scaling[end] * dy[end/2]

grob.lines - segmentsGrob(
   x0 = x.start, y0 = y.start,
   x1 = x.end, y1=y.end,
default.units=native,
gp = gpar(
  col = colour,
  lex = linewidth, lty = linetype, lineend = butt
)
)

grob.points - pointsGrob(x, y, pch=shape, size=unit(size, char),
   gp = gpar(
 col = colour,
 fill = fill,
 lex = linewidth, linejoin = mitre
   )
)

  gTree(children = gList(grob.lines,grob.points))

}



# example of use
g -
barbedGrob(size=sample(1:3, 10, repl=T),
   fill=alpha(white, 0.3),
   col=alpha(cadetblue4, 0.8),
   linewidth=5, space=1.2)
pushViewport(vp=viewport(width=1, height=1))
grid.rect(gp=gpar(fill=thistle2))
grid.grill(gp=gpar(col=lavenderblush1, lwd=3, lty=3))
grid.draw(g)



--
_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] For Social Network Analysis-Graph Analysis - How to convert 2 mode data to 1 mode data?

2009-06-04 Thread S. Messing

All, 

There is a simple solution to this problem using R's matrix algebra
commands.  I describe in detail at 
http://www.stanford.edu/~messing/Affiliation%20Data.html
http://www.stanford.edu/~messing/Affiliation%20Data.html .  

Best wishes,

-Solomon
-- 
View this message in context: 
http://www.nabble.com/For-Social-Network-Analysis-Graph-Analysis---How-to-convert-2-mode-data-to-1-mode-data--tp17157380p23875403.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] IP-Address

2009-06-04 Thread edwin
Thank you Peter,

This solved the problem.


 edw...@web.de wrote:
  Hi,
 
 
  Unfortunately, they can't handle NA. Any suggestion? Some row for Ip
  don't have ip address. This cause an error/ wrong result.

 A quick fix could be to substitute ... or 0.0.0.0 for the NA
 entries. (Use something like

 ipch - as.character(df$ip)
 ipch[is.na(df$ip)] - ...
 connection - textConnection(ipch)

 )

  Eddie
 
  library(gsubfn)
  library(gtools)
  library(rbenchmark)
 
  n - 1
  df - data.frame(
  a = rnorm(n),
  b = rnorm(n),
  c = rnorm(n),
  ip = replicate(n, paste(sample(255, 4), collapse='.'), simplify=TRUE)
  )
 
  res - benchmark(columns=c('test', 'elapsed'), replications=10,
 
  order=NULL,
 
  peda = {
  connection - textConnection(as.character(df$ip))
  o - do.call(order, read.table(connection, sep='.'))
  close(connection)
  df[o, ]
  },
 
  peda2 = {
  connection - textConnection(as.character(df$ip))
  dfT - read.table(connection, sep='.', colClasses=rep(integer,
  4), quote=, na.strings=NULL, blank.lines.skip=FALSE)
  close(connection)
  o - do.call(order, dfT)
  df[o, ]
  },
 
  hb = {
  ip - strsplit(as.character(df$ip), split=., fixed=TRUE)
  ip - unlist(ip, use.names=FALSE)
  ip - as.integer(ip)
  dim(ip) - c(4, nrow(df))
  ip - 256^3*ip[1,] + 256^2*ip[2,] + 256*ip[3,] + ip[4,]
  o - order(ip)
  df[o, ]
  },
 
  hb2 = {
  ip - strsplit(as.character(df$ip), split=., fixed=TRUE)
  ip - unlist(ip, use.names=FALSE)
  ip - as.integer(ip);
  dim(ip) - c(4, nrow(df))
  o - sort.list(ip[4,], method=radix, na.last=TRUE)
  for (kk in 3:1) {
  o - o[sort.list(ip[kk,o], method=radix, na.last=TRUE)]
  }
  df[o, ]
  }
  )
 
  print(res)
 
  test elapsed
  1 peda 4.12
  2 peda2 4.08
  3 hb 0.28
  4 hb2 0.25
 
 
  On Sun, May 31, 2009 at 12:42 AM, Wacek Kusnierczyk
 
  waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
   edwin Sendjaja wrote:
   Hi VQ,
  
   Thank you. It works like charm. But I think Peter's code is faster.
 
  What
 
   is the difference?
  
   i think peter's code is more r-elegant, though less generic.  here's a
   quick test, with not so surprising results.  gsubfn is implemented in
   r, not c, and it is painfully slow in this test. i also added gabor's
   suggestion.
  
  library(gsubfn)
  library(gtools)
  library(rbenchmark)
  
  n = 1000
  df = data.frame(
 a=rnorm(n),
 b = rnorm(n),
 c = rnorm(n),
 ip = replicate(n, paste(sample(255, 4), collapse='.'),
   simplify=TRUE))
  benchmark(columns=c('test', 'elapsed'), replications=10,
   order=NULL, peda={
connection = textConnection(as.character(df$ip))
o = do.call(order, read.table(connection, sep='.'))
close(connection)
df[o, ] },
 waku=df[order(gsubfn(perl=TRUE,
'[0-9]+',
~ sprintf('%03d', as.integer(x)),
as.character(df$ip))), ],
 gagr=df[mixedorder(df$ip), ] )
  
  # peda 0.070
  # waku 7.070
  # gagr 4.710
  
  
   vQ
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/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.



[[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] 5-D density? was Re: R help

2009-06-04 Thread arijit kumar debnath
I don't want to plot or visualize the plot. I just want to clculate the
density at certain prespecified points.For that,knowin the funcional form is
enough.I just want a function that returns me back the estimate of density
at some point

On Thu, Jun 4, 2009 at 10:04 PM, David Winsemius dwinsem...@comcast.netwrote:

 (copy of earlier reply which was not addressed to r-help. Also added
 informative Subject:)

 yes .. is not responsive to the question of how you propose to
 display or examine such a mathematical object. My signature was perhaps a
 lame (certainly an ineffective) effort at getting you to acknowledge that
 there might, just might, be some conceptual difficulties in viewing a 5+1
 = 6 dimensional object.
 Can you point to any examples of such a procedure being applied in a manner
 that you find helpful? It is certainly feasible to calculate distances in
 5-space, but the next step, displaying the concentration of those
 distances as a function of the coordinates, would be the tough nut.
 (1000 data points is not a problem. That amount of data should easily fit
 in any device that can run R.)

 --
 David


 On Jun 4, 2009, at 12:06 AM, arijit kumar debnath wrote:

 yes..
 I want a density estimator for 5 dimensional data.I want it to be efficient
 since I don't have access to a fast computer.My data set is quite
 large(about 1000 data points) and I have only a pentium 4 1.7 Ghz (512 Mb
 RAM)computer.

 On Thu, Jun 4, 2009 at 7:25 AM, David Winsemius dwinsem...@comcast.netwrote:

 We can get you a kde2d but you really want a kde5d? What sort of display
 are you proposing?

 --
 David Earthling Winsemius

 On Jun 3, 2009, at 9:26 PM, arijit kumar debnath wrote:

  I want to fit a kernel density to a data-set of size 1000 and each
 data point being of dimension 5. The default density function does'nt
 work for me. Is there any other function available which can do the
 job efficiently.?
 I don't have access to a very fast computer.


 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT



[[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] 5-D density? was Re: R help

2009-06-04 Thread David Winsemius

To address the creation of a 5-D density object:

http://finzi.psych.upenn.edu/R/library/ks/html/kda.kde.html

http://finzi.psych.upenn.edu/R/library/ks/html/kde.html

http://finzi.psych.upenn.edu/R/library/locfit/html/locfit.raw.html

--
David Winsemius

On Jun 4, 2009, at 12:34 PM, David Winsemius wrote:


(copy of earlier reply which was not addressed to r-help. Also added
informative Subject:)

yes .. is not responsive to the question of how you propose to
display or examine such a mathematical object. My signature was
perhaps a lame (certainly an ineffective) effort at getting you to
acknowledge that there might, just might, be some conceptual
difficulties in viewing a 5+1 = 6 dimensional object.

Can you point to any examples of such a procedure being applied in a
manner that you find helpful? It is certainly feasible to calculate
distances in 5-space, but the next step, displaying the
concentration of those distances as a function of the coordinates,
would be the tough nut.

(1000 data points is not a problem. That amount of data should easily
fit in any device that can run R.)

--
David


On Jun 4, 2009, at 12:06 AM, arijit kumar debnath wrote:


yes..
I want a density estimator for 5 dimensional data.I want it to be
efficient since I don't have access to a fast computer.My data set
is quite large(about 1000 data points) and I have only a pentium 4
1.7 Ghz (512 Mb RAM)computer.

On Thu, Jun 4, 2009 at 7:25 AM, David Winsemius dwinsem...@comcast.net

wrote:

We can get you a kde2d but you really want a kde5d? What sort of
display are you proposing?

--
David Earthling Winsemius

On Jun 3, 2009, at 9:26 PM, arijit kumar debnath wrote:

I want to fit a kernel density to a data-set of size 1000 and each
data point being of dimension 5. The default density function does'nt
work for me. Is there any other function available which can do the
job efficiently.?
I don't have access to a very fast computer.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT


[[alternative HTML version deleted]]

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


David Winsemius, MD
Heritage Laboratories
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] Minor tick marks for date/time ggplot2 (this is better, but not exactly what I want)

2009-06-04 Thread hadley wickham
On Mon, Jun 1, 2009 at 2:18 PM, stephen sefick ssef...@gmail.com wrote:
 library(ggplot2)

 melt.updn - (structure(list(date = structure(c(11808, 11869, 11961, 11992,
 12084, 12173, 12265, 12418, 12600, 12631, 12753, 12996, 13057,
 13149, 11808, 11869, 11961, 11992, 12084, 12173, 12265, 12418,
 12600, 12631, 12753, 12996, 13057, 13149), class = Date), site =
 structure(c(1L,
 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(unrestored,
 restored), class = factor), value = c(1.10799962473684, 0.732152347032395,
 0.410438861475827, 0.458941230025228, 0.429883166858706, 0.831083728521569,
 0.601942073736539, 0.81855597155132, 1.12612228239269, 0.246006569972335,
 0.940239233910111, 0.98645360143702, 0.291191536260016, 0.346271105079473,
 1.36216149279675, 0.878585508942967, 0.525184260519839, 0.803247305232454,
 1.08086182748669, 1.24915815325761, 0.971046497346528, 0.936835411801682,
 1.26957337598606, 0.337691543740682, 0.90931142298893, 0.950891472223867,
 0.290354002109368, 0.426509990013021)), .Names = c(date, site,
 value), row.names = c(NA, -28L), class = data.frame))

 #I would also like to add tick marks to this graph is possible with no
 label for the months in between the years
 qplot(date, value, data=melt.updn, shape=site, ylab=Distance
 ,main=Euclidean Distances Time Series, xlim=c(as.Date(2002-1-1),
 as.Date(2006-3-1)))+geom_line()+theme_bw()+geom_vline(x=as.numeric(as.Date(2002-11-01)))
 + opts(panel.grid.major = theme_line(colour=grey, size=0.75),
 panel.grid.minor=theme_line(colour=grey, size=0.25))

Unfortunately that's currently not possible - tick marks are always
associated with major grid lines, and more importantly currently
scale_date only lets you specify the time between ticks, not their
labels.  Are the minor monthly grid lines not good enough?

Hadley

-- 
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] 5-D density? was Re: R help

2009-06-04 Thread arijit kumar debnath
thank you.
This is just what I was looking for.

On Fri, Jun 5, 2009 at 3:16 AM, David Winsemius dwinsem...@comcast.netwrote:

 To address the creation of a 5-D density object:

 http://finzi.psych.upenn.edu/R/library/ks/html/kda.kde.html

 http://finzi.psych.upenn.edu/R/library/ks/html/kde.html

 http://finzi.psych.upenn.edu/R/library/locfit/html/locfit.raw.html

 --
 David Winsemius

 On Jun 4, 2009, at 12:34 PM, David Winsemius wrote:

  (copy of earlier reply which was not addressed to r-help. Also added
 informative Subject:)

 yes .. is not responsive to the question of how you propose to
 display or examine such a mathematical object. My signature was
 perhaps a lame (certainly an ineffective) effort at getting you to
 acknowledge that there might, just might, be some conceptual
 difficulties in viewing a 5+1 = 6 dimensional object.

 Can you point to any examples of such a procedure being applied in a
 manner that you find helpful? It is certainly feasible to calculate
 distances in 5-space, but the next step, displaying the
 concentration of those distances as a function of the coordinates,
 would be the tough nut.

 (1000 data points is not a problem. That amount of data should easily
 fit in any device that can run R.)

 --
 David


 On Jun 4, 2009, at 12:06 AM, arijit kumar debnath wrote:

  yes..
 I want a density estimator for 5 dimensional data.I want it to be
 efficient since I don't have access to a fast computer.My data set
 is quite large(about 1000 data points) and I have only a pentium 4
 1.7 Ghz (512 Mb RAM)computer.

 On Thu, Jun 4, 2009 at 7:25 AM, David Winsemius dwinsem...@comcast.net

 wrote:

 We can get you a kde2d but you really want a kde5d? What sort of
 display are you proposing?

 --
 David Earthling Winsemius

 On Jun 3, 2009, at 9:26 PM, arijit kumar debnath wrote:

 I want to fit a kernel density to a data-set of size 1000 and each
 data point being of dimension 5. The default density function does'nt
 work for me. Is there any other function available which can do the
 job efficiently.?
 I don't have access to a very fast computer.


 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT


[[alternative HTML version deleted]]

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


 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT



[[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] RPostgreSQL segfault with LEFT JOIN

2009-06-04 Thread Dylan Beaudette
Hi,

I recently upgraded to R 2.9.0 on linux x86. After doing so, I switched to the 
RPostgreSQL package for interfacing with a postgresql database. I am using 
postgresql  8.3.7.

A query that works from the postgresql terminal is causing a segfault when 
executed from R.

My sessionInfo, the error message, and the R code used to generate the error 
are listed below.

I have noticed that a trivial query (SELECT 1 as value) or other queries seem 
to work fine. It is only when I enable the LEFT JOIN (see below) that I get a 
segfault. Could this be related to the treatment of null values?

Any ideas?
Thanks!
Dylan

Here is the code that caused the error

# libs
library(RPostgreSQL)

## query DB
q - 
SELECT deb_lab_data.*
-- matrix_wet_color_hue as hue, matrix_wet_color_value as value, 
matrix_wet_color_chroma as chroma
FROM deb_lab_data
-- LEFT JOIN horizon USING (pedon_id, hz_number)
WHERE deb_lab_data.pedon_id ~~ '%SJER%'
ORDER BY deb_lab_data.pedon_id, deb_lab_data.top ASC 

# create an PostgreSQL instance and create one connection.
drv - dbDriver(PostgreSQL)
conn - dbConnect(drv, host=localhost, dbname=XXX, user=XXX)
query - dbSendQuery(conn, q)
x - fetch(query, n = -1) # extract all rows


Here is the error message in R:

row number 0 is out of range 0..-1

 *** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
 1: .Call(RS_PostgreSQL_exec, conId, statement, PACKAGE 
= .PostgreSQLPkgName)
 2: postgresqlExecStatement(conn, statement, ...)
 3: is(object, Cl)
 4: is(object, Cl)
 
5: .valueClassTest(standardGeneric(dbSendQuery), DBIResult, 
dbSendQuery)
 6: dbSendQuery(conn, q)




Here are the details on my R install:

R version 2.9.0 (2009-04-17) 
i686-pc-linux-gnu 

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
[1] RPostgreSQL_0.1-4 DBI_0.2-4




-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

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

2009-06-04 Thread Dirk Eddelbuettel

On 4 June 2009 at 16:17, Dylan Beaudette wrote:
| Hi,
| 
| I recently upgraded to R 2.9.0 on linux x86. After doing so, I switched to 
the 
| RPostgreSQL package for interfacing with a postgresql database. I am using 
| postgresql  8.3.7.
| 
| A query that works from the postgresql terminal is causing a segfault when 
| executed from R.
| 
| My sessionInfo, the error message, and the R code used to generate the error 
| are listed below.
| 
| I have noticed that a trivial query (SELECT 1 as value) or other queries seem 
| to work fine. It is only when I enable the LEFT JOIN (see below) that I get a 
| segfault. Could this be related to the treatment of null values?

As per some recent messages on the r-sig-db list, I think that the error is
due to a bug in the handling of 'schema.table' queries.  If you just use
'select ... from table' you're fine.

Not sure if this helps you -- someone has to go in and fix the bug.

Dirk

| 
| Any ideas?
| Thanks!
| Dylan
| 
| Here is the code that caused the error
| 

| # libs
| library(RPostgreSQL)
| 
| ## query DB
| q - 
| SELECT deb_lab_data.*
| -- matrix_wet_color_hue as hue, matrix_wet_color_value as value, 
| matrix_wet_color_chroma as chroma
| FROM deb_lab_data
| -- LEFT JOIN horizon USING (pedon_id, hz_number)
| WHERE deb_lab_data.pedon_id ~~ '%SJER%'
| ORDER BY deb_lab_data.pedon_id, deb_lab_data.top ASC 
| 
| # create an PostgreSQL instance and create one connection.
| drv - dbDriver(PostgreSQL)
| conn - dbConnect(drv, host=localhost, dbname=XXX, user=XXX)
| query - dbSendQuery(conn, q)
| x - fetch(query, n = -1) # extract all rows
| 

| 
| Here is the error message in R:
| 

| row number 0 is out of range 0..-1
| 
|  *** caught segfault ***
| address (nil), cause 'memory not mapped'
| 
| Traceback:
|  1: .Call(RS_PostgreSQL_exec, conId, statement, PACKAGE 
| = .PostgreSQLPkgName)
|  2: postgresqlExecStatement(conn, statement, ...)
|  3: is(object, Cl)
|  4: is(object, Cl)
|  
| 5: .valueClassTest(standardGeneric(dbSendQuery), DBIResult, 
dbSendQuery)
|  6: dbSendQuery(conn, q)
| 

| 
| 
| 
| Here are the details on my R install:
| 

| R version 2.9.0 (2009-04-17) 
| i686-pc-linux-gnu 
| 
| locale:
| 
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
| 
| attached base packages:
| [1] stats graphics  grDevices utils datasets  methods   base 
| 
| other attached packages:
| [1] RPostgreSQL_0.1-4 DBI_0.2-4
| 

| 
| 
| 
| -- 
| Dylan Beaudette
| Soil Resource Laboratory
| http://casoilresource.lawr.ucdavis.edu/
| University of California at Davis
| 530.754.7341
| 
| __
| R-help@r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-help
| PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
| and provide commented, minimal, self-contained, reproducible code.

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

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

2009-06-04 Thread Dylan Beaudette
On Thursday 04 June 2009, Dirk Eddelbuettel wrote:
 On 4 June 2009 at 16:17, Dylan Beaudette wrote:
 | Hi,
 |
 | I recently upgraded to R 2.9.0 on linux x86. After doing so, I switched
 | to the RPostgreSQL package for interfacing with a postgresql database. I
 | am using postgresql  8.3.7.
 |
 | A query that works from the postgresql terminal is causing a segfault
 | when executed from R.
 |
 | My sessionInfo, the error message, and the R code used to generate the
 | error are listed below.
 |
 | I have noticed that a trivial query (SELECT 1 as value) or other queries
 | seem to work fine. It is only when I enable the LEFT JOIN (see below)
 | that I get a segfault. Could this be related to the treatment of null
 | values?

 As per some recent messages on the r-sig-db list, I think that the error is
 due to a bug in the handling of 'schema.table' queries.  If you just use
 'select ... from table' you're fine.

 Not sure if this helps you -- someone has to go in and fix the bug.

 Dirk

Thanks Dirk,

After some further investigation, I see that the query works fine if I *do not 
use column aliases* :

# segfaults:
q - 
SELECT deb_lab_data.* ,
matrix_wet_color_hue as hue, matrix_wet_color_value as value, 
matrix_wet_color_chroma as chroma
FROM deb_lab_data
LEFT JOIN horizon USING (pedon_id, hz_number)
WHERE deb_lab_data.pedon_id ~~ '%SJER%'
ORDER BY deb_lab_data.pedon_id, deb_lab_data.top ASC 


# works fine:
q - 
SELECT deb_lab_data.* ,
matrix_wet_color_hue, matrix_wet_color_value, 
matrix_wet_color_chroma
FROM deb_lab_data
LEFT JOIN horizon USING (pedon_id, hz_number)
WHERE deb_lab_data.pedon_id ~~ '%SJER%'
ORDER BY deb_lab_data.pedon_id, deb_lab_data.top ASC 


Very strange...

Dylan



 | Any ideas?
 | Thanks!
 | Dylan
 |
 | Here is the code that caused the error
 | -
 |--- # libs
 | library(RPostgreSQL)
 |
 | ## query DB
 | q - 
 | SELECT deb_lab_data.*
 | -- matrix_wet_color_hue as hue, matrix_wet_color_value as value,
 | matrix_wet_color_chroma as chroma
 | FROM deb_lab_data
 | -- LEFT JOIN horizon USING (pedon_id, hz_number)
 | WHERE deb_lab_data.pedon_id ~~ '%SJER%'
 | ORDER BY deb_lab_data.pedon_id, deb_lab_data.top ASC 
 |
 | # create an PostgreSQL instance and create one connection.
 | drv - dbDriver(PostgreSQL)
 | conn - dbConnect(drv, host=localhost, dbname=XXX, user=XXX)
 | query - dbSendQuery(conn, q)
 | x - fetch(query, n = -1) # extract all rows
 | -
 |---
 |
 | Here is the error message in R:
 | -
 |--- row number 0 is out of range 0..-1
 |
 |  *** caught segfault ***
 | address (nil), cause 'memory not mapped'
 |
 | Traceback:
 |  1: .Call(RS_PostgreSQL_exec, conId, statement, PACKAGE
 | = .PostgreSQLPkgName)
 |  2: postgresqlExecStatement(conn, statement, ...)
 |  3: is(object, Cl)
 |  4: is(object, Cl)
 |
 | 5: .valueClassTest(standardGeneric(dbSendQuery), DBIResult,
 | dbSendQuery) 6: dbSendQuery(conn, q)
 | -
 |---
 |
 |
 |
 | Here are the details on my R install:
 | -
 |--- R version 2.9.0 (2009-04-17)
 | i686-pc-linux-gnu
 |
 | locale:
 | LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UT
 |F-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;L
 |C_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
 |
 | attached base packages:
 | [1] stats graphics  grDevices utils datasets  methods   base
 |
 | other attached packages:
 | [1] RPostgreSQL_0.1-4 DBI_0.2-4
 | -
 |---
 |
 |
 |
 | --
 | Dylan Beaudette
 | Soil Resource Laboratory
 | http://casoilresource.lawr.ucdavis.edu/
 | University of California at Davis
 | 530.754.7341
 |
 | __
 | R-help@r-project.org mailing list
 | https://stat.ethz.ch/mailman/listinfo/r-help
 | PLEASE do read the posting guide
 | http://www.R-project.org/posting-guide.html and provide commented,
 | minimal, self-contained, reproducible code.



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

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

2009-06-04 Thread Angshuman Bagchi
HI,
I am Angshuman a postdoc in Buck Institute, Novato, CA. I am using random 
forest in R. I have a problem.  I have a training file and a test file. I need 
to generate model file to classify a set of data of the test file. I need to 
know the command for that. Please let me know. 
Thank you.
Angshuman

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

2009-06-04 Thread jc
Hi all,
I've been playing with ROracle (0.5-9) for a few days
and I can't wrap my mind around this one.
Here's a sample of my R (2.4.0) session.

my.df-data.frame(prd_id=c(123,456),vol_factor=c(.123,.456))
 my.df
prd_id vol_factor
1123  0.123
2456  0.456
 library(ROracle)
Loading required package: DBI
 conn-dbConnect(Oracle,***/*...@***)
 dbGetQuery(conn,create table mytable (prd_id number, vol_factor number))
 dbGetQuery(conn,insert into mytable (prd_id,vol_factor) values(123,.123))
 dbGetQuery(conn,insert into mytable (prd_id,vol_factor) values(456,.456))
 dbGetQuery(conn,select * from mytable)
  PRD_ID VOL_FACTOR
0123  0.123
1456  0.456

the above works as expected. Now let's try to insert new rows into
mytable
using a prepared statement and bind variables:

 ps-dbPrepareStatement(conn,insert into mytable (prd_id,vol_factor) values 
 (:1,:2),bind=c(rep(numeric,2)))
 res-dbExecStatement(ps,my.df)
 dbCommit(conn)
[1] TRUE
 dbGetQuery(conn,select * from jdomenge_test)
  PRD_ID VOL_FACTOR
0123  0.123
1456  0.456
2123 NA
3456 NA

so the 2 new rows were appended, except the values in the second
column were seemingly not read...
the same happens with dbWriteTable:

 dbWriteTable(conn,mytable,df,append=T,row.names=F)
[1] TRUE
 dbGetQuery(conn,select * from mytable)
  PRD_ID VOL_FACTOR
0123  0.123
1456  0.456
2123 NA
3456 NA
4123 NA
5456 NA


I'm clueless at this point, could find no answer in the help files or
on the web... for a while now.

Any help would be *greatly* appreciated.

Thanks in advance,

Jean-Christophe

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

2009-06-04 Thread Jorge Cornejo

Thanks... This will be very usefull.


Warren Young wrote:
 
 Jorge Cornejo wrote:
 Hi, I am  looking any way to communicant with Arduino
 (http://www.arduino.cc/) Wiring (http://www.wiring.org.co) boards and
 read data generate with sensor on these.
 
 On Linux you can simply open the file /dev/ttyS0 in read/write mode to 
 talk on the first serial port on the PC.  (ttyS1 for the second port, 
 etc.)
 
 If your PC doesn't have serial ports, you can get a cheap USB to serial 
 adapter, most of which are based on common chips like the PL2303, which 
 will also work, though with a different /dev node, ttyUSB0 or something 
 like that.  Type dmesg | tail after plugging the adapter in to see 
 what /dev/ node it was assigned.
 
 Avoid the expensive adapters.  They often use special chips, requiring 
 drivers that aren't built into the OS.  The cheaper ones are actually 
 better, because the chances are better that they're using some generic 
 chip which your OS already knows how to talk to.
 
 All of that also applies to Mac OS X and other Unixy type systems.
 
 If you're on Windows, you may be screwed.  But, you can always install 
 Linux on another partition, or in a virtual machine system. :)
 
 It doesn't appear that R has a built-in way to control the bit rate and 
 such.  You can do that from the command line with setserial on Linux, 
 but it's probably easier to just stick with the defaults -- 115200 bps, 
 8N1 -- and make your Arduino use that.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Wiring-or-Arduino-package-scripts-tp23846389p23879858.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] Antialiasing plots and text on different devices

2009-06-04 Thread Winston Chang
I have a question about antialiasing when R generates bitmaps. (This follows
a thread on the ggplot2 mailing list.)

I mostly use R on Linux, although I sometimes use it in Mac and Windows as
well. On Linux, I've found that plotting shapes 15-18 via cairo results in
bad-looking output. The points are not antialiased, and they are jagged and
misshapen. Plots generated in Windows also aren't antialiased, but at least
the vector shapes seem to be aligned to pixel boundaries so that the raster
images look consistent.

You can see this in the scatterplots I've posted here:
http://stdout.org/~winston/X/r-antialias/pch.html

Also on that page are pch symbol charts from a modified version of pchShow()
from the pch help page. I rendered PNG's of the chart on Mac, Linux, and
Windows, using png() and setting type to Xlib, cairo, quartz, if available
on the given platform. In Windows, I did it without the type argument (in
Windows, the flag wasn't available). Finally, I also installed the Cairo
package and used CairoPNG. Please note the distinction between cairo,
which is built-in, and Cairo, which is an installed package.

(Side note: there's no Mac-Xlib image, but only because I had some X server
issues on that computer.)

Here are some observations and questions that hopefully someone can answer:
- With cairo, all shapes are antialiased except 15-18. Why do cairo and
Cairo give different results for shapes 15-18?
- With CairoPNG, all shapes are antialiased. Title text looks different
between the platforms, though. On Mac, it's normal text; on Linux, it's
bold; and on Windows, it's italic. I believe that font.main was set to 2, so
it should be bold. Why does Cairo render text so differently on different
platforms?


It would be nice not to have to tailor scripts to fit the quirks of whatever
platform I happen to be at. For example, to have the title render properly
in bold and have all shapes be anti-aliased, here's what I would need to do:
- Mac: png(type=quartz)
- Linux: CairoPNG()
- Windows: not possible

Ideally, I would like to use the same command on all platforms to generate
good antialiased graphs with similar-looking fonts. Is such a thing
possible?

-Winston



This is the code that I used to generate all the images for each platform:

pchShow -
   function(extras = c(*,., o,O,0,+,-,|,%,#),
cex = 3, ## good for both .Device==postscript and x11
col = red3, bg = gold, coltext = brown, cextext = 1.2,
main = paste(plot symbols :  points (...  pch = *, cex =,
 cex,)))
   {
 nex - length(extras)
 np  - 26 + nex
 ipch - 0:(np-1)
 k - floor(sqrt(np))
 dd - c(-1,1)/2
 rx - dd + range(ix - ipch %/% k)
 ry - dd + range(iy - 3 + (k-1)- ipch %% k)
 pch - as.list(ipch) # list with integers  strings
 if(nex  0) pch[26+ 1:nex] - as.list(extras)
 plot(rx, ry, type=n, axes = FALSE,
  xlab = x-axis label, ylab = y-axis label,
  main = main)
 abline(v = ix, h = iy, col = lightgray, lty = dotted)
 for(i in 1:np) {
   pc - pch[[i]]
   ## 'col' symbols with a 'bg'-colored interior (where available) :
   points(ix[i], iy[i], pch = pc, col = col, bg = bg, cex = cex)
   if(cextext  0)
   text(ix[i] - 0.3, iy[i], pc, col = coltext, cex = cextext)
 }
   }


sysname - paste(version$platform, _, version$major, ., version$minor,
sep=)

# Make the scatterplot
set.seed(123)
png(paste(sysname, -default_png_scatterplot.png, sep=), width=300,
height=300)
plot(rnorm(20),rnorm(20), pch=16, main=paste(sysname,pch=16))
dev.off()


# Get the possible types on this computer (cairo, Xlib, etc)
types - NULL
if (capabilities()[cairo])types - c(types, cairo)
if (capabilities()[X11])  types - c(types, Xlib)
if (capabilities()[aqua]) types - c(types, quartz)


# Generate the images
if (is.null(types)) {
# If no types available
png(paste(sysname, -default_png.png, sep=), width=300,
height=300)
pchShow(cex=.9, cextext=.8, main=paste(sysname, default PNG
output))
dev.off()

} else {
 for (i in 1:length(types)) {
# If types are available, use them
png(paste(sysname, -, types[i], .png, sep=), width=300,
height=300,
type=types[i])
pchShow(cex=.9, cextext=.8, main=paste(sysname,types[i]))
dev.off()
}
}

# Make the CairoPNG version
library(Cairo)
CairoPNG(paste(sysname, -, CairoPNG, .png, sep=), width=300,
height=300)
pchShow(cex=.8, cextext=.8, main=paste(sysname, CairoPNG))
dev.off()

[[alternative HTML version deleted]]

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


Re: [R] RGtk2 help: Show list of column names from dataset and categorize as factor or numeric

2009-06-04 Thread Michael Lawrence
On Thu, Jun 4, 2009 at 7:53 AM, Harsh singhal...@gmail.com wrote:

 Hi UseRs,
 I recently started working with the RGtk2 library. The documentation
 is comprehensive and I've tried learning from the examples in most Gtk
 tutorials (which have C code). This is a little problematic, but has
 helped quite a bit in getting me started.

 I would like to create a GUI for file selection, which then displays
 the column names from the selected file, and provides the user with
 checkboxes with each column name for the user to select. Two columns
 of check boxes (Factor Type, Numeric Type) and one column of names is
 what I would like to display.


This would use what is known as a GtkTreeView widget. There is RGtkDataFrame
object that will tie an R data frame directly to a GtkTreeView as its
GtkTreeModel. See help(RGtkDataFrame). Using a GtkTreeView is pretty
complicated, but powerful. Basically, you create your RGtkDataFrame from an
R data.frame and pass it as the model to the gtkTreeView constructor. You
then need to add columns to the tree view to map the data to the view. Your
best bet is to check out the demos included with RGtk2, like editableCells
and treeStore.



 Moreover, I am planning to create a GUI tool that would have tabs in a
 notebook layout, each tab providing a certain functionality, beginning
 from basic charting of data, and going on to applying regression
 models and such on the data.


help(GtkNotebook)



 This requires extensive knowledge in components that RGtk2 provides
 which could be implemented for the task outlined above. I have looked
 at the omegahat.org examples, but would like to see examples for such
 simple tasks as to how one could create a drop down list of column
 names to choose for x axis and another drop down allowing the choice
 of y axis, etc.


See help(GtkComboBox) and gtkComboBoxNewText().



 Having made the choice to use RGtk2, I would  appreciate if users
 could share their RGtk experience with me.


I wrote a paper on RGtk2, but for some reason it has never been published.
Probably time to write a book.



 Regards
 Harsh Singhal

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] R FAQ - web interfaces section very out of date.

2009-06-04 Thread Christian Gunning
I just checked every project in the Web interfaces section of the FAQ
(http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Web-Interfaces ).

There are many dead links in this section.  Of the links that work,
many projects themselves contain links that don't work, appear to have
not been maintained in many years, and/or use deprecated versions of
R.

Perhaps this section could be broken into subsections of Active or
Working Projects and Historical Interest?  The R FAQ serves at the
public face of R to some extent, and it seems that improving this
section would be *very* helpful to the R community.

-christian
graduate student
University of New Mexico Biology

-- 
Far better an approximate answer to the right question, which is often
vague, than the exact answer to the wrong question, which can always
be made precise -- j.w. tukey

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

2009-06-04 Thread heyi xiao








Hello all,

I had both curl and curl-devel
(both 7.15) installed on my x86_64/CentOS machine. However, I still got problem
when I do

R CMD INSTALL RCurl

 

Error message below,
since library and/or include path is missing. I tried

R CMD INSTALL RCurl
--configure-args='--libdir=/usr/lib64/ 
--includedir=/usr/include/'

Same result. Any
hint/suggestion would be appreciated.

...

No CURLOPT_NOPROXY
enumeration value.

No
CURLINFO_CONDITION_UNMET enumeration value.

No
CURLINFO_REDIRECT_URL enumeration value.

No CURLINFO_CERTINFO
enumeration value.

No
CURLINFO_PRIMARY_IP enumeration value.

No
CURLINFO_APPCONNECT_TIME enumeration value.

No CURLOPT_KEYPASSWD
enumeration value.

No
CURLOPT_DIRLISTONLY enumeration value.

No CURLOPT_APPEND
enumeration value.

No CURLOPT_KRBLEVEL
enumeration value.

...

Version has
CURLOPT_PROTOCOLS

Version has
CURLOPT_REDIR_PROTOCOLS

configure: creating
./config.status

config.status:
creating src/Makevars

** libs

gcc -std=gnu99
-I/usr/local/lib64/R/include 
-DHAVE_LIBIDN_FIELD=1 -DHAVE_CURLOPT_URL=1 -DHAVE_CURLOPT_PROTOCOLS=1
-DHAVE_CURLOPT_REDIR_PROTOCOLS=1 -I/usr/local/include    -fpic 
-g -O2 -c enums.c -o enums.o

In file included
from CurlOptEnums.h:10,

                 from enums.c:79:

CURLOptTable.h:145:
error: âCURLOPT_SOCKOPTFUNCTIONâ undeclared here (not in a function)

CURLOptTable.h:146:
error: âCURLOPT_SOCKOPTDATAâ undeclared here (not in a function)

CURLOptTable.h:147:
error: âCURLOPT_SSL_SESSIONID_CACHEâ undeclared here (not in a function)

CURLOptTable.h:148:
error: âCURLOPT_SSH_AUTH_TYPESâ undeclared here (not in a function)

CURLOptTable.h:149:
error: âCURLOPT_SSH_PUBLIC_KEYFILEâ undeclared here (not in a function)

CURLOptTable.h:150:
error: âCURLOPT_SSH_PRIVATE_KEYFILEâ undeclared here (not in a function)

CURLOptTable.h:151:
error: âCURLOPT_FTP_SSL_CCCâ undeclared here (not in a function)

make: *** [enums.o]
Error 1

ERROR: compilation
failed for package âRCurlâ

* Removing
â/usr/local/lib64/R/library/RCurlâ




  
[[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] OT: Inference for R - Interview

2009-06-04 Thread Ajay ohri
Dear All,

Slightly off -non technical topic ( but hey it is Friday)

Following last week's interview with REvolution Computing which makes
enterprise  versions of R,  here is another interview with the rapidly
growing company Blue Reference CEOPaul van Eikeren at
http://www.decisionstats.com/2009/06/04/interview-inference-for-r/
http://www.decisionstats.com/2009/06/04/interview-inference-for-r/

Paul talks on his product, Inference for R- a add on plugin which makes a R
GUI within Office Excel available for 199$ a year ( and *separate
academic*program as well) for enhanced analytics as well as graphical
capabilities.


Best Regards,

Ajay Ohri

www.decisionstats.com

[[alternative HTML version deleted]]

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


[R] problem with using subset from two different tables

2009-06-04 Thread venkata kirankumar
Hi all,

I am new to R-project my problem is I tried to get subset from two different
tables its giving error
but if i m tring for  geting results from one table its working

actually i have to take values from two tables with applying different
conditions on two tables like


kk- is an object of one table and
fk- is an object of another table

here i have to get values  from these tables like

subset(kk  fk,kk$Rmaxtgavcg  1.256  fk$rmaxtgavcg 
3.25,select=c(uniqueid))

my doubt is, that if any thing like this expression is there in R-project or
i have to go for two different subsets and then adding those two one after
another with checking the common uniqueid's


any help is more precious to me

Thanks in advance

kiran.

[[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] OT: Inference for R - Interview

2009-06-04 Thread hadley wickham
Is it really necessary to further advertise this company which already
spams R-help subscribers?
Hadley

On Thu, Jun 4, 2009 at 10:41 PM, Ajay ohri ohri2...@gmail.com wrote:
 Dear All,

 Slightly off -non technical topic ( but hey it is Friday)

 Following last week's interview with REvolution Computing which makes
 enterprise  versions of R,  here is another interview with the rapidly
 growing company Blue Reference CEOPaul van Eikeren at
 http://www.decisionstats.com/2009/06/04/interview-inference-for-r/
 http://www.decisionstats.com/2009/06/04/interview-inference-for-r/

 Paul talks on his product, Inference for R- a add on plugin which makes a R
 GUI within Office Excel available for 199$ a year ( and *separate
 academic*program as well) for enhanced analytics as well as graphical
 capabilities.


 Best Regards,

 Ajay Ohri

 www.decisionstats.com

        [[alternative HTML version deleted]]

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




-- 
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] Install RCurl in Linux

2009-06-04 Thread Prof Brian Ripley
It seems you need a later curl -- 7.15 is rather old (and I think 
incomplete as a version number) and 7.19.5 is current.


It is helpful to tell us what version of packages (here RCurl) you are 
trying to use, as well as your precise OS.


On Thu, 4 Jun 2009, heyi xiao wrote:










Hello all,

I had both curl and curl-devel
(both 7.15) installed on my x86_64/CentOS machine. However, I still got problem
when I do

R CMD INSTALL RCurl

??

Error message below,
since library and/or include path is missing. I tried

R CMD INSTALL RCurl
--configure-args='--libdir=/usr/lib64/??
--includedir=/usr/include/'


That should be part of the default paths.


Same result. Any
hint/suggestion would be appreciated.

...

No CURLOPT_NOPROXY
enumeration value.

No
CURLINFO_CONDITION_UNMET enumeration value.

No
CURLINFO_REDIRECT_URL enumeration value.

No CURLINFO_CERTINFO
enumeration value.

No
CURLINFO_PRIMARY_IP enumeration value.

No
CURLINFO_APPCONNECT_TIME enumeration value.

No CURLOPT_KEYPASSWD
enumeration value.

No
CURLOPT_DIRLISTONLY enumeration value.

No CURLOPT_APPEND
enumeration value.

No CURLOPT_KRBLEVEL
enumeration value.

...

Version has
CURLOPT_PROTOCOLS

Version has
CURLOPT_REDIR_PROTOCOLS

configure: creating
./config.status

config.status:
creating src/Makevars

** libs

gcc -std=gnu99
-I/usr/local/lib64/R/include??
-DHAVE_LIBIDN_FIELD=1 -DHAVE_CURLOPT_URL=1 -DHAVE_CURLOPT_PROTOCOLS=1
-DHAVE_CURLOPT_REDIR_PROTOCOLS=1 -I/usr/local/include?? -fpic??
-g -O2 -c enums.c -o enums.o

In file included
from CurlOptEnums.h:10,

 from enums.c:79:

CURLOptTable.h:145:
error: ??CURLOPT_SOCKOPTFUNCTION?? undeclared here (not in a function)

CURLOptTable.h:146:
error: ??CURLOPT_SOCKOPTDATA?? undeclared here (not in a function)

CURLOptTable.h:147:
error: ??CURLOPT_SSL_SESSIONID_CACHE?? undeclared here (not in a function)

CURLOptTable.h:148:
error: ??CURLOPT_SSH_AUTH_TYPES?? undeclared here (not in a function)

CURLOptTable.h:149:
error: ??CURLOPT_SSH_PUBLIC_KEYFILE?? undeclared here (not in a function)

CURLOptTable.h:150:
error: ??CURLOPT_SSH_PRIVATE_KEYFILE?? undeclared here (not in a function)

CURLOptTable.h:151:
error: ??CURLOPT_FTP_SSL_CCC?? undeclared here (not in a function)

make: *** [enums.o]
Error 1

ERROR: compilation
failed for package ??RCurl??

* Removing
??/usr/local/lib64/R/library/RCurl??





[[alternative HTML version deleted]]




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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