[R] Problems with large data frames?

2008-12-12 Thread Chris Poliquin

Hi,

I recently added another 1,000 observations to a data frame I have for  
a total of 10,861 observations.  Observations are by row and the frame  
has 15 columns.  R now keeps converting certain columns to factors  
whenever I run regressions and can't seem to figure out the correct  
scaling for the axes of plots on its own.


Are these problems the result of the size of my data frame or  
something else?  I can't see anything wrong with the data itself.  Any  
ideas what might be causing these recent problems and any way to force  
R not to convert variables to factors?


- Chris

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Standard error of mean for aov

2008-12-12 Thread JS . Augustyn
Hi all,

I'm quite new to R and have a very basic question regarding how one gets  
the standard error of the mean for factor levels under aov. I was able to  
get the factor level means using:

summary(print(model.tables(rawfixtimedata.aov,"means"),digits=3)),

where rawfixtimedata.aov is my aov model. It doesn't appear that there is  
an equivalent function to get the standard errors for the factor levels.

I searched through the help archives and documentation but could not find  
anything that would help resolve my problem. I'm sure there is a trivial  
solution, but I would sincerely appreciate having someone more expert  
dispel my ignorance.

Cheers,

Jason Augustyn

[[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] weird pasting of ".value" when list is returned

2008-12-12 Thread markleeds
could someone explain why the name of FPVAL gets " .value" concatenated 
onto it when the code below is run and temp is returned.
I've been trying to figure this out for too long. It doesn't matter when 
I put the FPVAL in the return statement. It happens regardless of

whether it's first or last.   Thanks.

f.lmmultenhanced <-
function(response, pred1, pred2)

{

regmod <- lm(response ~ pred1 + pred2)
lmsum <- summary(regmod)

imbcoef<-lmsum$coefficients[2,1]
retcoef<-lmsum$coefficients[3,1]

imbpval<-lmsum$coefficients[2,4]
retpval<-lmsum$coefficients[3,4]

Fstat<-lmsum$fstatistic[1]

fpval<-pf(Fstat,lmsum$fstatistic[2],lmsum$fstatistic[3],lower=FALSE)


return(list(categrsp=response,pred1=pred1,pred2=pred2,regmod=regmod,

rest=c("FPVAL"=fpval,"IMBCOEF"=imbcoef,"RETCOEF"=retcoef,"IMBPVAL"=imbpval,"RETPVAL"=retpval)
))

 }


x <- 10 + 1:100
y <- 5 +  seq(2,200,by=2)
z <- 2*x + 3*y + rnorm(100)

temp <- f.lmmultenhanced(x,y,z)
print(temp)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 mimic select.list using RGtk2/gWidgetsRGtk2?

2008-12-12 Thread ronggui
Hi, John,

Thanks very much. I have another question about gformlayout().

addSettingGUI <- function(container){
Setting <- list(type = "ggroup",
  horizontal = FALSE,
  children = list(
list(type="fieldset",
 columns = 1,
 label = "Settings",
 label.pos = "top",
 label.font = c(weight="bold"),
 children = list(
   list(name = "owner",
label = "Name of Coder",
type = "gedit",
text = ""
)
)
 )
)
)
SettingFL <- gformlayout(Setting, cont = container, expand=TRUE)

}

g<-gwindow(width=50)
addSettingGUI (g)

## It seems that argument of width in gwindow has no effects on the
resultant widget
## How can can re-scale the width of the resultant widget?
## thanks.

Ronggui

On Sat, Dec 13, 2008 at 1:12 PM, John Verzani  wrote:
> ronggui  gmail.com> writes:
>
>>
>> I want to write a function mimic the function of select.list(), here
>> is my preliminary version.
>>
>> select <- function(x,multiple=TRUE,...){
>> ans<-new.env()
>> g <- gwindow(title=title,wid=200,heigh=500)
>> x1<-ggroup(FALSE,con=g)
>> x2<-gtable(x,multiple=multiple,con=x1,expand=TRUE)
>> gbutton("OK",con=x1,handler=function(h,...){
>> value <- svalue(x2)
>> if (length(value)==0) value=""
>> assign("selected",value,env=h$action$env)
>> dispose(x1)
>> },action=list(env=ans))
>> ans
>> }
>>
>
> Hi,
>
> You can call foo in the handler above or for gWidgetsRGtk2 use gbasicdialog
> which will create a modal dialog:
>
> options(guiToolkit="RGtk2")
> library(gWidgets)
>
> select <- function(x,multiple=TRUE,...){
>  ans<-new.env()
>
>  x1<-ggroup(horizontal=FALSE) # no parent container here
>  x2<-gtable(x,multiple=multiple,con=x1,expand=TRUE)
>  ret <- gbasicdialog(title="select a widget", 
> widget=x1,handler=function(h,...){
>value <- svalue(x2)
>if (length(value)==0) value=""
>assign("selected",value,env=h$action$env)
>dispose(x1)
>  },action=list(env=ans))
>  ans
> }
>
> ans <- select(c("a","b"))
> print(ans$selected)
>
> Hope that helps.
>
>> However, it doesn't behave as what I want.  What I want is that: for
>> {select(c("a","b")); foo()}, foo() only runs after I have clicked the
>> OK button of select(). Any hints?
>>
>> 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.
>



-- 
HUANG Ronggui, Wincent
Tel: (00852) 3442 3832
PhD Candidate, City University of Hong Kong
Website: http://ronggui.huang.googlepages.com/
RQDA project: http://rqda.r-forge.r-project.org/

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


Re: [R] How to mimic select.list using RGtk2/gWidgetsRGtk2?

2008-12-12 Thread John Verzani
ronggui  gmail.com> writes:

> 
> I want to write a function mimic the function of select.list(), here
> is my preliminary version.
> 
> select <- function(x,multiple=TRUE,...){
> ans<-new.env()
> g <- gwindow(title=title,wid=200,heigh=500)
> x1<-ggroup(FALSE,con=g)
> x2<-gtable(x,multiple=multiple,con=x1,expand=TRUE)
> gbutton("OK",con=x1,handler=function(h,...){
> value <- svalue(x2)
> if (length(value)==0) value=""
> assign("selected",value,env=h$action$env)
> dispose(x1)
> },action=list(env=ans))
> ans
> }
> 

Hi,

You can call foo in the handler above or for gWidgetsRGtk2 use gbasicdialog
which will create a modal dialog:

options(guiToolkit="RGtk2")
library(gWidgets)

select <- function(x,multiple=TRUE,...){
  ans<-new.env()

  x1<-ggroup(horizontal=FALSE) # no parent container here
  x2<-gtable(x,multiple=multiple,con=x1,expand=TRUE)
  ret <- gbasicdialog(title="select a widget", 
widget=x1,handler=function(h,...){
value <- svalue(x2)
if (length(value)==0) value=""
assign("selected",value,env=h$action$env)
dispose(x1)
  },action=list(env=ans))
  ans
}

ans <- select(c("a","b"))
print(ans$selected)

Hope that helps.

> However, it doesn't behave as what I want.  What I want is that: for
> {select(c("a","b")); foo()}, foo() only runs after I have clicked the
> OK button of select(). Any hints?
> 
> 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.


Re: [R] sas.get function in Hmsic 3.4-4 vs. 3.0-12

2008-12-12 Thread David Winsemius

Could the R Windows FAQ 2.16 be relevant?

http://cran.r-project.org/bin/windows/base/rw-FAQ.html#R-can_0027t-find-my-file

--  
D Winsemius


On Dec 12, 2008, at 11:34 PM, Larry Ma wrote:


Dear R Users,

I have just installed R 2.8 today and also updated the Hmisc package  
to the latest 3.4-4 version.  However, the sas.get function no  
longer works in the new Hmsic 3.4-4.  Below is a sample code and  
output from the old and new, but the old one worked.


Can someone tell me how sas.get should be used in Hmisc 3.4-4.

Thanks,
Larry


Package Hmisc version 3.0-12

a1 <- sas.get("C:\\Temp", mem="one")

Read 2 records
Read 1 record
Warning message:
C:\Temp/formats.sc? or formats.sas7bcat  not found. Formatting  
ignored.

in: sas.get("C:\\Temp", mem = "one")

a1

 x y
1 1 2


Package Hmisc version 3.4-4

a1 <- sas.get("C:\\Temp", mem="one")

The filename, directory name, or volume label syntax is incorrect.
Error in sas.get("C:\\Temp", mem = "one") : SAS job failed with  
status 1

In addition: Warning messages:
1: In sas.get("C:\\Temp", mem = "one") :
 C:\Temp/formats.sc? or formats.sas7bcat  not found. Formatting  
ignored.

2: In shell(cmd, wait = TRUE, intern = output) :
 '"sas" "C:\DOCUME~1\malarry\LOCALS~1\Temp\Rtmp84GyYh 
\SaS2ea6bb3.3.sas" -log "_temp_.log"' execution failed with error  
code 1

[[alternative HTML version deleted]]

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


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


[R] sas.get function in Hmsic 3.4-4 vs. 3.0-12

2008-12-12 Thread Larry Ma
Dear R Users,

I have just installed R 2.8 today and also updated the Hmisc package to the 
latest 3.4-4 version.  However, the sas.get function no longer works in the new 
Hmsic 3.4-4.  Below is a sample code and output from the old and new, but the 
old one worked.

Can someone tell me how sas.get should be used in Hmisc 3.4-4.

Thanks,
Larry


Package Hmisc version 3.0-12 
> a1 <- sas.get("C:\\Temp", mem="one")
Read 2 records
Read 1 record
Warning message:
C:\Temp/formats.sc? or formats.sas7bcat  not found. Formatting ignored. 
 in: sas.get("C:\\Temp", mem = "one") 
> a1
  x y
1 1 2


Package Hmisc version 3.4-4
> a1 <- sas.get("C:\\Temp", mem="one")
The filename, directory name, or volume label syntax is incorrect.
Error in sas.get("C:\\Temp", mem = "one") : SAS job failed with status 1
In addition: Warning messages:
1: In sas.get("C:\\Temp", mem = "one") :
  C:\Temp/formats.sc? or formats.sas7bcat  not found. Formatting ignored. 
2: In shell(cmd, wait = TRUE, intern = output) :
  '"sas" "C:\DOCUME~1\malarry\LOCALS~1\Temp\Rtmp84GyYh\SaS2ea6bb3.3.sas" -log 
"_temp_.log"' execution failed with error code 1
[[alternative HTML version deleted]]

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


Re: [R] How do I multiply labeled vectors of numbers?

2008-12-12 Thread Gabor Grothendieck
Define nm as the names to be multiplied and then use mapply
on m[-1] and d1[nm] so that the latter's columns are rearranged:

> nm <- names(m)[-1]
> data.frame(m[1], mapply("*", m[-1], d1[nm]))
   class feather jet
1  birds  20  20
2 planes  60  40


On Fri, Dec 12, 2008 at 8:02 PM, Bill McNeill (UW)
 wrote:
> Thanks for the help.  Data frames are gradually starting to make sense to me.
>
> Here's a related question.  I have two data frames, one looks like this:
>
>> m <- data.frame(class = c("birds", "planes"), feather = c(1,3), jet = c(2,4))
>> m
>   class feather jet
> 1  birds   1   2
> 2 planes 3   4
>
> and the other looks like this
>
>> d1 <- data.frame(jet = c(10), feather = c(20))
>> d1
>   jet feather
> 1   10   20
>
> I want to multiply every value in m by the corresponding value in d1.
> I want to do this for both rows, so that I end up with
>
> classfeatherjet
> 1 birds 1*20 = 202*10 = 20
> 2 planes  3*20 = 604*10 = 40
>
> As before, the trick is to align numbers by the data frame labels
> "feather", "jet", etc. where those columns may appear in different
> orders in m and d1.  However, it doesn't seem like merge is
> applicable, because here I'm trying to merge on data frame labels
> instead of on values in a column of a data frame.  In any event, I
> haven't been able to figure out how to do it.
>
> On Wed, Dec 10, 2008 at 6:51 PM, Gabor Grothendieck
>  wrote:
>>
>> You probably want Marc's solution but just in case note that zoo's merge
>> supports zero fill which means that if you represented the two as zoo
>> objects whose "times" are cat, dog, ...  then we would have:
>>
>>
>> File1 <- "typen
>> dog2
>> cat4
>> horse6"
>>
>> File2 <- "typen
>> horse1
>> dog3
>> cat9
>> mouse 11"
>>
>> library(zoo)
>>
>> z1 <- read.zoo(textConnection(File1), header = TRUE, FUN = as.character)
>> z2 <- read.zoo(textConnection(File2), header = TRUE, FUN = as.character)
>>
>> z <- merge(z1, z2, fill = 0)
>> zz <- z[,1] * z[,2]
>>
>> Also note that coredata(zz) and time(zz) extract the data and times
>> respectively.
>>
>>
>> On Wed, Dec 10, 2008 at 6:17 PM, Bill McNeill (UW)
>>  wrote:
>> > I'm an R newbie trying to do an operation that seems like it should be very
>> > simple, but after much playing around with the interface and reading "An
>> > Introduction to R" I can figure out how to do it.
>> >
>> > I have two text files.  File1 contains:
>> >
>> > typen
>> > dog2
>> > cat4
>> > horse6
>> >
>> > File2 contains:
>> >
>> > typen
>> > horse1
>> > dog3
>> > cat9
>> > mouse 11
>> >
>> > I want to read both files into R and multiply corresponding values of n so
>> > that I end up with:
>> >
>> > dog   2*3 = 6
>> > cat4*9 = 36
>> > horse6*1 = 6
>> > mouse  0*11 = 0
>> >
>> > Note that the type rows are not necessarily in the same order in the two
>> > files, and that a missing type gets a default n = 0 value.
>> >
>> > I figure the way to do this is use read.table and do the appropriate
>> > manipulation of the factors, but I can't figure out what those 
>> > manipulations
>> > would be.  Basically I want to use a factor table as a hash table, but I
>> > haven't been able to figure out how to do this, which makes me think I'm 
>> > not
>> > conceptualizing this is the correct R-ish way.
>> >
>> > Thanks.
>> > --
>> > Bill McNeill
>> > http://staff.washington.edu/billmcn/index.shtml
>> >
>> >[[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.
>> >
>
>
>
> --
> Bill McNeill
> http://staff.washington.edu/billmcn/index.shtml
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] simple list question (question withdrawn)

2008-12-12 Thread Barker, Chris

My apology to the list, as it turns out the moment after I hit the send
button, I found that the first element in the list was a null. The error
message reflects that.



> _ 
> From: Barker, Chris  
> Sent: Friday, December 12, 2008 6:30
> To:   'r-help@r-project.org'
> Subject:simple list question
> 
> 
>   I'd appreciate some tips, I'm  making a simple mistake   trying to
> extract elements from a list of fit objects.
> 
>   The following command works,  coef( cph.list[[1]] )  , coef(
> cph.list[[3]] ) and so forth.  These  extract regression coefficients
> from the appropriate list element. 
> 
>   When I try to run this inside  a for loop, or an lapply
> (lapply(cph.list,coef))  I get this error message
> 
> 
>> for (ii in (1:22)){
> +  cat(ii,fill=T) 
> +   print(coef( cph.list[[ii]] ))
> + 
> + }
> 1
> Error in object$coefficients : $ operator is invalid for atomic
> vectors
> 
> Suggestions appreciated. 
> Thanks in advance.
> 
> 
> 
> 
> Chris Barker, Ph.D.
>   Statistical Consultant
> 

[[alternative HTML version deleted]]

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


Re: [R] how to plot implicit functions

2008-12-12 Thread David Winsemius
The answer I have seen before on this list (but cannot find at the  
moment) was a suggestion to solve for one of the variables in terms of  
the other two and then plot with standard 3d plotting routines. I also  
seem to remember that some of the examples in an RGL vignette had  
examples of graphed "implicit functions". I call them parametric  
fucntions, but that term is used in so many other ways that prevent  
effective searching.


Searching on "rgl parametric function" produced this possibly relevant  
hit (among others):

http://finzi.psych.upenn.edu/R/library/misc3d/html/parametric3d.html

--
David Winsemius


On Dec 11, 2008, at 12:57 PM, YIHSU CHEN wrote:


Dear R users --

I think this question was asked before but there was no reply to it.
I would appreciate any suggestion any of you might have.  I am
interested in plotting several "implicit functions" (F(x,y,z)=0) on
the same fig. Is there anyone who has an example code of how to do
this?

Thank you

Yihsu

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

2008-12-12 Thread Ben Bolker



Barker, Chris wrote:
> 
> 
>   I'd appreciate some tips, I'm  making a simple mistake   trying to
> extract elements from a list of fit objects.
> 
>   The following command works,  coef( cph.list[[1]] )  , coef(
> cph.list[[3]] ) and so forth.  These  extract regression coefficients
> from the appropriate list element. 
> 
>   When I try to run this inside  a for loop, or an lapply
> (lapply(cph.list,coef))  I get this error message
> 
> 
>> for (ii in (1:22)){
> +  cat(ii,fill=T) 
> +   print(coef( cph.list[[ii]] ))
> + 
> + }
> 1
> Error in object$coefficients : $ operator is invalid for atomic vectors
> 
> 

No obvious mistake/not reproducible: are you sure that all 22 elements
of the list are really linear model fits?  The following made-up example
works just fine for me.
What are the results of sapply(cph.list,class) ?

x <- 1:100
cph.list <- list()
set.seed(1001)
for (ii in 1:22) {
  y <- rnorm(100,1+2*x,sd=1)
  cph.list[[ii]] <- lm(y~x)
}
  
for (ii in 1:22) {
  cat(ii,fill=TRUE)
  print(coef(cph.list[[ii]]))
}

-- 
View this message in context: 
http://www.nabble.com/simple-list-question-tp20986754p20987041.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] Creating a vector

2008-12-12 Thread PDXRugger

Good day all, 
I am having seom trouble building a simple vector.  Below my sample code
shows what ime trying to do and i have pointed out where the issue is.  What
happens not is that a single "TAZDetermine_FEET" is selected by i need
multiple values, as many as there are "cands".  I am thinking that this
should occur within the for loop and add a "TAZDetermine_FEET" to a new
vector ("TAZDs") each time the loop goes round but i cant seem to make it
work using what i know.  Probably simple so sorry and any help will be much
appreciated, been struggling with this for too long.

Cheers, 
JR

#test location model TAZs
TAZS=101:108
#Builds test Vacant TAZ vector
TAZDEVS=c(125481,174581,556789,14755776,9984275,1324587,12457841,4511475)

#Builds dataframe simulating TAZ_VAC_FEET
TAZ_VAC_FEET=data.frame(TAZS,TAZDEVS)

#Candidate TAZs from location shoice model
cands=c(101,102,107,108)

#Create Object of length of cands
candslength=length(cands)

#Test Location Choice Model selected TAZ 
for(i in i:candslength){

#Renames randomly generated TAZ's object
Loc_Mod_TAZ=cands[i]

#Create test Development in Sq. Ft. 
Dev_Size=50

#Determines vacant square feet by TAZ 
TAZDetermine_FEET=TAZ_VAC_FEET[TAZ_VAC_FEET$TAZS==Loc_Mod_TAZ,2]

#Heres my problem...my attempt below is to build a vector of
length-"candslength" of all of the 
#"TAZDetermine_FEET" values that are less than or equal to Dev_size.

 #heres what i have tried, doesnt get me what i want though
#is.vector(TAZDs)
#TAZDs=list(TAZDetermine_FEET)
#TAZDs=vector(mode = "logical", length = candslength)

}
-- 
View this message in context: 
http://www.nabble.com/Creating-a-vector-tp20985205p20985205.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] simple list question

2008-12-12 Thread Barker, Chris

  I'd appreciate some tips, I'm  making a simple mistake   trying to
extract elements from a list of fit objects.

  The following command works,  coef( cph.list[[1]] )  , coef(
cph.list[[3]] ) and so forth.  These  extract regression coefficients
from the appropriate list element. 

  When I try to run this inside  a for loop, or an lapply
(lapply(cph.list,coef))  I get this error message


   > for (ii in (1:22)){
+  cat(ii,fill=T) 
+   print(coef( cph.list[[ii]] ))
+ 
+ }
1
Error in object$coefficients : $ operator is invalid for atomic vectors

Suggestions appreciated. 
Thanks in advance.




Chris Barker, Ph.D.
  Statistical Consultant


[[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] Testing predictive power of ARIMA model

2008-12-12 Thread Evan DeCorte
I am trying to make estimates of the predictive power of ARIMA models estimated 
by the auto.arima() function. 

I am looping through a large number of time seiries and fitting ARIMA models 
with the following code. 

data1 <- read.csv(file = "case.csv", header = T)
data <- data1

output = c(1:length(data))

for(i in 1:length(data))
{
point_data = unlist(data[i], use.names = FALSE)
x = auto.arima(point_data , max.p = 10, max.q = 10, max.P = 0, max.Q = 
0, approximation = TRUE)

}

However, I would like to find a way to test the out of sample predictive power 
of these models. I can think of a few ways I MIGHT be able to do this but 
nothing clean. I am a recen R user and despite my best efforts (looking on the 
mailing list, reading documentation) I cant figure out the best way to do this. 

I tried including something like this:

output[i] = cor(model_data, real_data)

but with poor results.

Does anyone have any tricks to calculate the R^2 or an ARIMA model. Sample code 
would be apreciated.

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

2008-12-12 Thread markleeds
to the person who just asked about the feather and jet problem: i lost 
your email but below works. there should be a shorter way by
avoiding the last statement and doing everything in the lapply but I've 
had enough of feathers and jets tonight.


m <- data.frame(class = c("birds", "planes"), feather = c(1,3), jet = 
c(2,4))

d1 <- data.frame(jet = c(10), feather = c(20))

result <- lapply(names(m[,-1]), function(.name) {
  m[[.name]]*d1[[.name]]
})

result <- data.frame(m$class,feather=result[[1]],jet=result[[2]])
print(result)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] odd behavior when multiplying data frame by an element

2008-12-12 Thread markleeds
 disregard my last question. i forgot that d1 was a dataframe and was 
thinkiing it was a vector. i think i can fix what i was doing now.





On Fri, Dec 12, 2008 at  8:52 PM, markle...@verizon.net wrote:

could someone explain what is happening below ? I was trying to solve 
a related question on the list and then , as I was solving it,
I was getting strange answers and then I noticed below. It's obviously 
not a bug but I don't get it. Thanks.


m <- data.frame(class = c("birds", "planes"), feather = c(1,3), jet = 
c(2,4))

d1 <- data.frame(jet = c(10), feather = c(20))

print(m)
m[,-1]*2   # THIS IS FINE
m[,"jet"]*2 # THIS IS FINE


print(d1["jet"]) # THIS IS FINE
m[,"jet"]*d1["jet"] # THIS IS ODD

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] odd behavior when multiplying data frame by an element

2008-12-12 Thread markleeds
could someone explain what is happening below ? I was trying to solve a 
related question on the list and then , as I was solving it,
I was getting strange answers and then I noticed below. It's obviously 
not a bug but I don't get it. Thanks.


m <- data.frame(class = c("birds", "planes"), feather = c(1,3), jet = 
c(2,4))

d1 <- data.frame(jet = c(10), feather = c(20))

print(m)
m[,-1]*2   # THIS IS FINE
m[,"jet"]*2 # THIS IS FINE


print(d1["jet"]) # THIS IS FINE
m[,"jet"]*d1["jet"] # THIS IS ODD

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

2008-12-12 Thread David Winsemius


On Dec 10, 2008, at 8:03 AM, Frank E Harrell Jr wrote:


Maithili Shiva wrote:

Hi,
I have the response variable 'Y' and four predictors say X1, X2, X3  
and X4. Assuming all the assmptions like Y follows normal  
distribution etc. hold and I want to run linear multiple  
regression. How do I run the stepwise regression (forward as well  
as the backward regression).
From other software (i.e. minitab), I know only X1 and X2 are  
significant so my regression equation should be Y = constant +  
(b1) X1 + (b2) X2.


Knowing that only X1 and X2 are "insignificant" does not mean you  
know that b3=b4=0, so why are you deleting X3 and X4 from the model?


I think Frank meant to say "knowing that only X1 and X2 are  
"significant" does not mean you know that b3=b4=0'. His point I am  
guessing, is that when there are valid reasons from prior work  
regarding prediction of Y to think that X3 and X4 ought to be in the  
model, that it is not proper to drop them just because your data does  
not happen show them to be "significant".


--
David Winsemius




Frank

I am not sure whether I am using the correct R commands, which are  
as follows -

library (wle)
ONS <- mle.stepwise(Y ~ X1+X2+X3+X4, data=ONS)
summary(ONS)
The output looks something like this
OUTPUT
Forward  selection procedure
F.in:  4 Last  3  iterations:
(Intercept) X1 X2 X3 X4  [1,]   1  0  0  0  1 15.57
[2,]   1  1  0  0  1 14.80
[3,]   1  1  1  0  1 61.56
I am not able to interpret this outcome as well.
Please guide.
With regards
Maithili
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
Frank E Harrell Jr   Professor and Chair   School of Medicine
Department of Biostatistics   Vanderbilt  
University


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


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


Re: [R] How do I multiply labeled vectors of numbers?

2008-12-12 Thread Bill McNeill (UW)
Thanks for the help.  Data frames are gradually starting to make sense to me.

Here's a related question.  I have two data frames, one looks like this:

> m <- data.frame(class = c("birds", "planes"), feather = c(1,3), jet = c(2,4))
> m
   class feather jet
1  birds   1   2
2 planes 3   4

and the other looks like this

> d1 <- data.frame(jet = c(10), feather = c(20))
> d1
   jet feather
1   10   20

I want to multiply every value in m by the corresponding value in d1.
I want to do this for both rows, so that I end up with

classfeatherjet
1 birds 1*20 = 202*10 = 20
2 planes  3*20 = 604*10 = 40

As before, the trick is to align numbers by the data frame labels
"feather", "jet", etc. where those columns may appear in different
orders in m and d1.  However, it doesn't seem like merge is
applicable, because here I'm trying to merge on data frame labels
instead of on values in a column of a data frame.  In any event, I
haven't been able to figure out how to do it.

On Wed, Dec 10, 2008 at 6:51 PM, Gabor Grothendieck
 wrote:
>
> You probably want Marc's solution but just in case note that zoo's merge
> supports zero fill which means that if you represented the two as zoo
> objects whose "times" are cat, dog, ...  then we would have:
>
>
> File1 <- "typen
> dog2
> cat4
> horse6"
>
> File2 <- "typen
> horse1
> dog3
> cat9
> mouse 11"
>
> library(zoo)
>
> z1 <- read.zoo(textConnection(File1), header = TRUE, FUN = as.character)
> z2 <- read.zoo(textConnection(File2), header = TRUE, FUN = as.character)
>
> z <- merge(z1, z2, fill = 0)
> zz <- z[,1] * z[,2]
>
> Also note that coredata(zz) and time(zz) extract the data and times
> respectively.
>
>
> On Wed, Dec 10, 2008 at 6:17 PM, Bill McNeill (UW)
>  wrote:
> > I'm an R newbie trying to do an operation that seems like it should be very
> > simple, but after much playing around with the interface and reading "An
> > Introduction to R" I can figure out how to do it.
> >
> > I have two text files.  File1 contains:
> >
> > typen
> > dog2
> > cat4
> > horse6
> >
> > File2 contains:
> >
> > typen
> > horse1
> > dog3
> > cat9
> > mouse 11
> >
> > I want to read both files into R and multiply corresponding values of n so
> > that I end up with:
> >
> > dog   2*3 = 6
> > cat4*9 = 36
> > horse6*1 = 6
> > mouse  0*11 = 0
> >
> > Note that the type rows are not necessarily in the same order in the two
> > files, and that a missing type gets a default n = 0 value.
> >
> > I figure the way to do this is use read.table and do the appropriate
> > manipulation of the factors, but I can't figure out what those manipulations
> > would be.  Basically I want to use a factor table as a hash table, but I
> > haven't been able to figure out how to do this, which makes me think I'm not
> > conceptualizing this is the correct R-ish way.
> >
> > Thanks.
> > --
> > Bill McNeill
> > http://staff.washington.edu/billmcn/index.shtml
> >
> >[[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.
> >



--
Bill McNeill
http://staff.washington.edu/billmcn/index.shtml

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 can I change the format attribute of POSIXct class

2008-12-12 Thread Fernando Bizuet
Hello,

I have a POSIXct column in a dataframe, but when I change the value
assigment (for instance, VencimientosxDia$fe_ini_ope <-
as.Date(fecha) ) automatically change the format attribute with "2008-12-01
06:00:00".

How can I drop the hh:mm:ss from format attribute?

> str(VencimientosxDia)
'data.frame':   1 obs. of  17 variables:
 $ Id  : int 7471
 $ idSimulacion: int 0
 $ fe_corte: POSIXct, format: "2008-11-30"#  I
want this format
 $ fe_ini_ope  : POSIXct, format: "2008-12-01 06:00:00" # R changes
to "-mm-dd hh:MM:ss"
 $ fe_ven_ope  : POSIXct, format: "2008-12-01"
 $ plazo   : int 1
 $ imp_ope : num 8e+06


Thanks in advance

[[alternative HTML version deleted]]

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


Re: [R] candisc plotting

2008-12-12 Thread Michael Friendly

You might try something like

do.can <- candisc(do.mod, data=do)
plot(do.can)

But, in your example there is only one canonical dimension there are 
only two levels of the

factor.

In any case, do.can$scores has the scores, so you can try to plot them 
however you like.


For a 1-D plot in a case where it makes more sense, try

iris.mod <- lm(cbind(Petal.Length, Sepal.Length, Petal.Width, 
Sepal.Width) ~ Species, data=iris)

iris.can <- candisc(iris.mod, data=iris, ndim=1)
plot(iris.can)


-Michael


Pete Shepard wrote:

Dear Michael,


You haven't told us what your data is, and we can only surmise -- not 
very helpful for you and annoying for those who try to help.


Apologies, I am brand new to R and this mailing list. Will try to be 
more concise.


Here is my data a NEW verion of my data:

  Curvature Diameter   Quality
1  2.95 6.63Passed
2  2.53 7.79Passed
3  3.57 5.65Passed
4  3.16 5.47Passed
5  2.58 4.46 NotPassed
6  2.16 6.22 NotPassed
7  3.27 3.52 NotPassed

What I am trying to get from the candisc method is a 1 dimensional 
scatterplot that separates my two groups Passed and NotPassed


On this data I do a "do.mod <- lm(cbind(Diameter, Curvature) ~ 
Quality, data=do)"


>do.mod produces

Coefficients:
   Diameter  Curvature
(Intercept)4.73332.6700  
QualityPassed  1.65170.3825  


I then run the "candisc" method: "do.can <- candisc(do.mod, data=do)"

this produces:

Canonical Discriminant Analysis for Quality:

   CanRsq Eigenvalue Difference Percent Cumulative
1 0.91354 10.566100100

Test of H0: The canonical correlations in the
current row and all that follow are zero

  LR test stat approx F num Df den Df   Pr(> F)   
10.086   52.831  1  5 0.0007706 ***

---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

What "I think" I would like to plot is the discriminant function of 
each sample 1-7.


Here is an example of what I am trying to do with candisc.

http://people.revoledu.com/kardi/tutorial/LDA/Numerical%20Example.html

Thanks


 




 




On Thu, Dec 11, 2008 at 3:36 PM, Michael Friendly > wrote:


Dear Pete,

You haven't told us what your data is, and we can only surmise --
not very helpful for you and annoying for those who try to help.


Pete Shepard wrote:

Hello,

I have a file with two dependent variables (three and five)
and one
independent variable. I do  i.mod <- lm(cbind(three, five) ~
species,
data=i.txt) and get the following output:


Coefficients:
three   five
(Intercept)   9.949   9.586
species  -1.166  -1.156

From this, it seems that species is numeric variable, not a factor.
If so, canonical discriminant analysis in not appropriate, so
all following bets are off.

That's likely why you end up with only one canonical dimension.



I do a" i.can<-candisc(i.mod,data=i):

Is data=i the same as data=i.txt?


and get the following output:

Canonical Discriminant Analysis for species:

   CanRsq Eigenvalue Difference Percent Cumulative
1 0.0965060.10681100100

Test of H0: The canonical correlations in the
current row and all that follow are zero
LR test stat approx F num Df den Df   Pr(> F)
10.903   63.875  1598 6.859e-15 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

this is different than the output I get with SAS:

What was your SAS code? Was the data the same?


Eigenvalue Difference Proportion Cumulative  Ratio
F Value
Num DF Den DF Pr > F

  1 0.10681. 1. 0.90349416
31.88  2597 <.0001




I am also wondering how to plot the can1*can1 like it is done
in SAS.

proc plot;
   plot can1*can1=species;
   format species spechar.;
   title2 'Plot of Constits_vs_cassettes';
 run;

If you want to compare plots for canonical analysis in SAS and R,
see my macros, canplot and hecan at
http://www.math.yorku.ca/SCS/sasmac/

But in general, if all you have is 1 canonical dimension, a dotplot or
boxplot of the canonical scores would be more useful than a
scatterplot plot of can1 * can1.

The plot method for candisc objects in the candisc package has some
code to handle the 1 can-D case.

hope this helps
-Michael

Thanks

   [[alternative HTML version deleted]]

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

Re: [R] Support vector model?

2008-12-12 Thread Niels Richard Hansen

Dear Celine

If you are considering using support vector machines in R,
you might find it worthwhile to read the paper:

http://www.jstatsoft.org/v15/i09/paper

Best, Niels


Celine Carret wrote:

Dear All,

Apologies for sending this email to both list, but at this point I'm not
sure which one could help me the most.

I have 4 sets of data, 1 test and 3 different sets of controls.
The measurements are binary, with a matrix of 0 and 1
I'm measuring across time (rows, ~815) the behaviour of organelles in
the cell by microscopy in response to different stimuli (several
measurements for each set, 57 columns in total)
Set 1: parasite test
Set 2: no stimulus
Set 3: inert stimulus (beads)
Set 4: different pathogen
Across time, a "zero" means nothing happens around my parasite
introduced in the cell, a "1" means some cytoskeleton dynamics occurring
around my parasite
I want to give some statistical value to my observations in saying that
the cytoskeleton dynamics are specific to my parasite at that frequency
across time.

I thought of comparing profiles, like a smooth profile to summarise all
that is happening in each set and test for distances between 2 smoothed
sets. But the timig when something is happening varies a lot, sometimes
it's few seconds, sometimes minutes, sometimes only once per
measurements, sometimes more for the same parasite..
I'm not sure how to proceed.

I have been looking into e1071 package in R for support vector machine,
but I'm not sure this will give me the right model.

I am very grateful for any help / advice anyone can think of

Thank you very much
Celine






--
Niels Richard Hansen
Associate Professor
Department of Mathematical Sciences
University of Copenhagen
Universitetsparken 5
2100 Copenhagen Ø
Denmark
+45 353 20783

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RODBC and Microsft Visual C++ Runtime Library

2008-12-12 Thread Fernando Bizuet
Hello,
I am using RODBC and some times when I use a sqlSave I recive this message:

  Microsft Visual C++ Runtime Library
  RunTime Error!

  Program C:\Archivo de programa\R\R-2.8.0\bin\Rgui.exe

 This application  has requested the Runtime to terminate it in an
unusual way.
 Please contact the application's support tean for more information.


is it a bug? is there something wrong ?

The sqlSave is:

sqlSave(cnn, VencimientosxDia, tablename = "Copia", append = TRUE, safer =
TRUE, rownames = FALSE, colnames = FALSE)

Thanks

[[alternative HTML version deleted]]

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


Re: [R] mixed exponential distribution

2008-12-12 Thread David Winsemius


On Dec 10, 2008, at 10:36 AM, Fazekas, Jacob wrote:


Good morning,

Is there anyway to do Mixed Exponential Distribution in R?




require(fortunes)
fortune(109)



I am trying
to load some lag-weighted empirical survival distribution into R and  
run

a mixed exponential on that data.


You might want see whether the worked examples on pp 12-13 are helpful:


The actuar package implements much of the classic Loss Models tome.

--
David Winsemius, MD, MPH
Heritage Labs





Thanks,
Jacob Fazekas
Jacob Fazekas
Assistant Actuary
Auto-Owners Insurance Company
517-703-2543
fazekas.ja...@aoins.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [Rd] gregexpr - match overlap mishandled (PR#13391)

2008-12-12 Thread Wacek Kusnierczyk
Greg Snow wrote:
> Where do you get "should" and "expect" from?  All the regular expression 
> tools that I am familiar with only match non-overlapping patterns unless you 
> do extra to specify otherwise.  One of the standard references for regular 
> expressions if you really want to understand what is going on is "Mastering 
> Regular Expressions" by Jeffrey Friedl.  You should really read through that 
> book before passing judgment on the correctness of an implementation.
>
> If you want the overlaps, you need to come up with a regular expression that 
> will match without consuming all of the string.  Here is one way to do it 
> with your example:
>
>  > gregexpr("1122(?=1122)", paste(rep("1122", 10), collapse=""), perl=TRUE)
> [[1]]
> [1]  1  5  9 13 17 21 25 29 33
> attr(,"match.length")
> [1] 4 4 4 4 4 4 4 4 4
>
>   

another option would be to move the anchor backwards after each match,
but i'm not sure if the problem really needs it and if it could be done
from within r.

greg (and another person who answered this post earlier):
while your frustration is understandable, i think reid (and possibly
other users as well) would benefit from a brief explanation instead of
your emotional reactions.  you ought to be more patient and less
arrogant with newbies who will often think there is a bug in r when
there isn't.

reid:
when matching is performed, there is a pointer moved through the
string.  in global matching, after a match is found the pointer is just
behind the matched substring, and further matching proceeds from there. 
for example example, suppose you match "aaa" (the string) with "aa" (the
pattern) globally.  after the first successful match, the position
pointer is *behind the second a* in the string, and no further match can
be found from there.in this context, 'global' does not mean that all
possible matches are found, rather that matching is performed iteratively.

the above is probably a solution to your problem, though the matches
have length 4, not 8.  in perl, you could manually move back the anchor
after each match, e.g.:

$string = "1122" x 10;
$n = length($string)/2;
@matches = ();
$string =~ /11221122(??{push @matches [$-[0], $&]; pos($s) -= $n})/g;

now @matches has 9 elements, each a ref to an array with the starting
position and the content (of length 8) of the respective match:
@matches = ([0, "11221122"], [4, "11221122"], ...)

not sure if you can do this within r.  not sure if you'll ever need it. 
for more complex cases when you need overlapping matches and you need
their content, greg's solution might not do, but in general that's the
solution.

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.


Re: [R] The end of Matlab

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 3:08 PM, Vitalie Spinu  wrote:
> On Fri, 12 Dec 2008 18:27:02 +0100, hadley wickham 
> wrote:
>
>
>>> or may be just
>>> mtcars[cyl>3&last(20)]
>>>
>>> or this is already too far?
>>
>> This would be a considerable extension because then the selector would
>> need to know about all other variables in the dataset, and you'd need
>> someway of combining selectors with logical vectors.
>
> If selector returns a logical vector then I really don't see where is the
> problem. Probably I am mistaken but implementing mtcars[cyl>3] is not such a
> big deal. Just an operator `[.` start searching for "cyl" from inside the
> "x" frame and not from parent.frame as it does now. It is just like putting
> "with" inside '[', or not?

And that's a big change to the current behaviour!

I think there are a few good reasons why this shouldn't be the default:

 * You could no longer do: cyl <- 4;  mtcars[mtcars$cyl == cyl, ]
(which is very useful when writing function)

 * If you want that behaviour, then just use subset

 * It only makes sense for variables of data frames, not for all the
other types of subsets

 * Generally it's better to be explicit than not

> When started with R I was really disappointed that such a natural and
> intuitive subsetting  is not allowed, but instead lengthy and ackward
> mtcars[mtcars$syl>3] is required.
>
> R is an interactive language for 99% of the users and features like that(and
> selectors indeed) would make a tremendous difference.
>
> Regards,
> SV.
>



-- 
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] aggregate and median

2008-12-12 Thread jim holtman
aggregate(x, list(x$y, x$a), FUN=median, na.rm=TRUE)

On Fri, Dec 12, 2008 at 2:13 PM,   wrote:
> Hello R-experts,
>
> I have a simple question: how do I aggregate data using the median
> function with na.rm = TRUE, i.e.
>
> aggregate(x, list(x$y, x$z), FUN = '')
>
> I have tried 'median(x, na.rm = TRUE)' but that doesn't help.
>
> Any suggestions are very much appreciated,
>
>
> Thorsten
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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

2008-12-12 Thread t . raff
Hello R-experts,

I have a simple question: how do I aggregate data using the median
function with na.rm = TRUE, i.e.

aggregate(x, list(x$y, x$z), FUN = '')

I have tried 'median(x, na.rm = TRUE)' but that doesn't help.

Any suggestions are very much appreciated,


Thorsten

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 can we predict differences in a slope, given that the random component was significant?

2008-12-12 Thread Sachi Ito
Dear R users,

Using R lme function, I found that both fixed and random effects of variable
A on variable B are significant.  Now, I'd like to analyze what variables
are predicting differences in the slope.  In other words, I'd like to know
what variables (e.g., variable C) are predicting individual differences in
the effects of A on B.  I have many data points for A and B for each
individual, whereas I have only one data point for C.
I'd appreciate if anyone could answer the question.

Thank you for your attention.

[[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] Trellis margins settings so that they are like a base graphic with no figure region when printed to png file?

2008-12-12 Thread Mark Heckmann
  
Dear R-experts,

I want to produce a very small png file (35 x 18 px) that contains a
histogram without a figure region or margins, only the pure heights. 
In the base graphic this was easy:

  png(filename = "hist.png", res = 72, width=35, height=18)
par(mar=c(0,0,0,0), oma=c(0,0,0,0))
hist(rnorm(100), main="")
  dev.off()

Now I want a grid graphics output as I need the graphic as an object.
I tried several trellis.par settings but I was not able to figure it out
(PROBLEM (1)).
Up to now it looks like this:

myHistogram <- histogram(rnorm(100), xlab="", ylab="", 
 par.settings=list(
axis.line=list(col="transparent"),
 
xlab.text=list(col="transparent"),
 
ylab.text=list(col="transparent"),
 
axis.text=list(col="transparent")   )
)

This looks acceptable although I would like smaller margins, that is to say
no margins at all.

PROBLEM (2) now is, that when it is printed to the png file, the graphic
almost consist of margins only. The main part of the plot shrinks to some
tiny points.

I don't know how to change the settings, so I that I get the same as in the
base system.

Does anyone know?

TIA
Mark

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

2008-12-12 Thread Carlos Cuartas
Hi Ista,
one way could be:

ncharacters<-unlist(lapply(x,function(x)nchar(gsub(' ','',x
ncharacters




From: Ista Zahn 
To: r-help@r-project.org
Sent: Friday, December 12, 2008 10:31:10 AM
Subject: [R] character count

Dear list,
I have a variable that consists of typed responses. I wish to compute
a variable equal to the number of characters in the original variable.
For example:

> x <- c("convert this to 32 because it has 32 characters", "this one has 22 
> characters", "12 characters")

[Some magic function here]

> x
[1] 32 22 12

Any ideas?

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



  
[[alternative HTML version deleted]]

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


[R] Help with a permutation test

2008-12-12 Thread Grant Gillis
Hello List and thanks in advance for all of your help,


I am trying implement a permutation test of a multinomial logistic
regression ('multinom' within the nnet package).  In the end I want to
compare the parameter estimate from my data to the distribution of
randomized parameter estimates.

I have figured out how to permute my dependent variable (MNNUM) x number of
times, apply multinomial logistic regression, to each permutation, and save
the results in a list.  Where I am stuck is figuring out how to take the
mean and SD of the coefficients from my list of regressions.  I know that
the coefficients are stored in the $wts slot of the model.

Below is what I have so far.  I am sure there are nicer ways to do this and
if you feel so inclined please suggest them.



#this is a function to permute the MNNUM column once
rand<- function(DF){
new.DF<-DF
new.DF$MNNUM<-sample(new.DF$MNNUM)
new.DF

}

#this function does one model I am interested in.

modeltree<-function(DF){
MLM.plot <- multinom(MN_fact  ~ Canpy  + mean_dbh  + num_beechoak  +
num_class5  + prop_hard , data=hfdata, trace=FALSE)
MLM.plot
}

# this replicates the 'rand' function and applies a model

resamp.funct<-function(DF,funct, n){
list<-replicate(n,rand(DF), simplify = FALSE)
sapply(list, funct, simplify = FALSE)
}


#So if I paste below:

l<-resamp.funct(hfdata, modeltree, 3)

# I get


> l<-resamp.funct(hfdata, modltree, 3)

> l
[[1]]
Call:
multinom(formula = MN_fact ~ Canpy + mean_dbh + num_beechoak +
num_class5 + prop_hard, data = hfdata, trace = FALSE)

Coefficients:
 (Intercept)   Canpymean_dbh num_beechoak num_class5
prop_hard
none -11.1845028 0.063880939  0.08440340   -0.7050239 -0.0998379
6.894522
sabrinus -10.6848488 0.055157318  0.19276777   -0.6441996  0.1219245
3.325704
volans-0.2481854 0.004410597 -0.02710102   -0.1061700 -0.1858376
2.495856

Residual Deviance: 163.7211
AIC: 199.7211

[[2]]
Call:
multinom(formula = MN_fact ~ Canpy + mean_dbh + num_beechoak +
num_class5 + prop_hard, data = hfdata, trace = FALSE)

Coefficients:
 (Intercept)   Canpymean_dbh num_beechoak num_class5
prop_hard
none -11.1845028 0.063880939  0.08440340   -0.7050239 -0.0998379
6.894522
sabrinus -10.6848488 0.055157318  0.19276777   -0.6441996  0.1219245
3.325704
volans-0.2481854 0.004410597 -0.02710102   -0.1061700 -0.1858376
2.495856

Residual Deviance: 163.7211
AIC: 199.7211

[[3]]
Call:
multinom(formula = MN_fact ~ Canpy + mean_dbh + num_beechoak +
num_class5 + prop_hard, data = hfdata, trace = FALSE)

Coefficients:
 (Intercept)   Canpymean_dbh num_beechoak num_class5
prop_hard
none -11.1845028 0.063880939  0.08440340   -0.7050239 -0.0998379
6.894522
sabrinus -10.6848488 0.055157318  0.19276777   -0.6441996  0.1219245
3.325704
volans-0.2481854 0.004410597 -0.02710102   -0.1061700 -0.1858376
2.495856

Residual Deviance: 163.7211
AIC: 199.7211

[[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] Avoiding multiple outputs using RODBC package

2008-12-12 Thread Brigid Mooney
I am using R as a data manipulation tool for a SQL database.  So in some of
my R scripts I use the RODBC package to retreive data, then run analysis,
and use the sqlSave function in the RODBC package to store the results in a
database.

There are two problems I want to avoid, and they are highly related: (1)
having R rerun analysis which has already been done and saved into output
database table, and (2) ending up with more than one identical row in
my output database table.

-
The analysis I am running allows the user to input a large number of
variables, for example:
date, version, a, b, c, d, e, f, g, ...

After R completes its analysis, I write the results to a database table in
the format:
Value, date, version, a, b, c, d, e, f, g, ...

where Value is the result of the R analysis, and the rest of the columns are
the criteria that was used to get that value.
--

Can anyone think of a way to address these problems?  The only thing I can
think of so far is to run an sqlQuery to get a table of all the variable
combinations that are saved at the start, and then simply avoid computing
and re-outputing those results.  However, my results database table
currently has over 200K rows (and will grow very quickly as I keep going
with this project), so I think that would not be the most expeditious answer
as I think just the SQL query to download 200K rows x 10+ columns is going
to be time consuming in and of itself.

I know this is kindof a weird problem, and am open to all sorts of ideas...

Thanks!

[[alternative HTML version deleted]]

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


Re: [R] mixed model nested ANOVA

2008-12-12 Thread Andrew Robinson
Hi Sebpe,

the analysis of the data that you describe could be a complex and
lengthy process, in which decisions that you are confronted by are
affected by previous decisions that you have made.  I recommend
obtaining the assistance of a statistician, preferably a local one
whose door you can knock on.  If you are unable to do so then I
suggest that you borrow/buy a copy of the Pinheiro and Bates book,
which documents lme() and its friends, and study it carefully,
especially the worked examples.

Good luck!

Andrew

On Fri, Dec 12, 2008 at 03:13:06PM +, Sebpe De Smedt wrote:
> Hi,
> 
> 
> I'm working on leaf characteristics of trees. Each tree is characterised by
> about 10 leaf traits.
> The trees were sampled at 9 different locations (about 20 to 30
> trees/location, NOT balanced), grouped in 3 different climatic zones
> (Sahelian, Soudanian and Guinean) (NOT balanced).
> Further, each tree is characterised by some degree of human pressure
> (mutilation degree), in total 4 different degrees were defined (NOT
> balanced).
> 
> In the dryer zones, the trees are under a much higher human pressure than in
> the more humid climatic zones, "zone" and "mutilation degree" are thus
> strongly correlated.
> 
> I want to know how "zones" (fixed effects, climate interests me) and
> "locations" (nested in "zones", random effects, location doesn't interests
> me) are influencing the leaf traits (say for example "SLA"). Further, also
> human pressure is affecting leaf traits so I want to characterise the
> influence of "mutilation degree" (fixed effects) on "SLA".
> 
> I found some interesting information, but still, I am not be able to analyse
> the data properly. I think I have to use the function lme() or lme().
> 
> Can anyone tell me which function and command I have to use? And how I can
> produce an ANOVA table?
> 
> 
> Thanks in advance,
> Sebpe De Smedt
> 
>   [[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.

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

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

2008-12-12 Thread Vitalie Spinu

On Fri, 12 Dec 2008 18:27:02 +0100, hadley wickham  wrote:



or may be just
mtcars[cyl>3&last(20)]

or this is already too far?


This would be a considerable extension because then the selector would
need to know about all other variables in the dataset, and you'd need
someway of combining selectors with logical vectors. 



If selector returns a logical vector then I really don't see where is the problem. Probably I am mistaken but 
implementing mtcars[cyl>3] is not such a big deal. Just an operator `[.` start searching for "cyl" 
from inside the "x" frame and not from parent.frame as it does now. It is just like putting 
"with" inside '[', or not?

When started with R I was really disappointed that such a natural and intuitive 
subsetting  is not allowed, but instead lengthy and ackward 
mtcars[mtcars$syl>3] is required.

R is an interactive language for 99% of the users and features like that(and 
selectors indeed) would make a tremendous difference.

Regards,
SV.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ANNOUNCE: 2009 John M. Chambers Statistical Software Award

2008-12-12 Thread J.R. Lockwood
John M. Chambers Statistical Software Award - 2009
Statistical Computing Section
American Statistical Association

The Statistical Computing Section of the American Statistical
Association announces the competition for the John M.  Chambers
Statistical Software Award. In 1998 the Association for Computing
Machinery presented its Software System Award to John Chambers for the
design and development of S. Dr. Chambers generously donated his award
to the Statistical Computing Section to endow an annual prize for
statistical software written by an undergraduate or graduate student.
The prize carries with it a cash award of $1000, plus a substantial
allowance for travel to the annual Joint Statistical Meetings where
the award will be presented.

Teams of up to 3 people can participate in the competition, with the
cash award being split among team members. The travel allowance will
be given to just one individual in the team, who will be presented the
award at JSM.  To be eligible, the team must have designed and
implemented a piece of statistical software.  The individual within
the team indicated to receive the travel allowance must have begun the
development while a student, and must either currently be a student,
or have completed all requirements for her/his last degree after
January 1, 2007.  To apply for the award, teams must provide the
following materials:

   Current CV's of all team members.

   A letter from a faculty mentor at the academic institution of the
   individual indicated to receive the travel award.  The letter
   should confirm that the individual had substantial participation in
   the development of the software, certify her/his student status
   when the software began to be developed (and either the current
   student status or the date of degree completion), and briefly
   discuss the importance of the software to statistical practice.

   A brief, one to two page description of the software, summarizing
   what it does, how it does it, and why it is an important
   contribution.  If the team member competing for the travel
   allowance has continued developing the software after finishing
   her/his studies, the description should indicate what was developed
   when the individual was a student and what has been added since.

   Access to the software by the award committee for their use on
   inputs of their choosing.  Access to the software can consist of an
   executable file, Web-based access, macro code, or other appropriate
   form.  Access should be accompanied by enough information to allow
   the judges to effectively use and evaluate the software (including
   its design considerations.)  This information can be provided in a
   variety of ways, including but not limited to a user manual (paper
   or electronic), a paper, a URL, online help to the system, and
   source code.  In particular, the entrant must be prepared to
   provide complete source code for inspection by the committee if
   requested.

All materials must be in English.  We prefer that electronic text be
submitted in Postscript or PDF.  The entries will be judged on a
variety of dimensions, including the importance and relevance for
statistical practice of the tasks performed by the software, ease of
use, clarity of description, elegance and availability for use by the
statistical community. Preference will be given to those entries that
are grounded in software design rather than calculation.  The decision
of the award committee is final.

All application materials must be received by 5:00pm EST, Monday,
February 23, 2009 at the address below.  The winner will be announced
in May and the award will be given at the 2009 Joint Statistical
Meetings.

Information on the competition can also be accessed on the website of
the Statistical Computing Section (www.statcomputing.org or see the
ASA website, www.amstat.org for a pointer), including the names and
contributions of previous winners.  Inquiries and application
materials should be emailed or mailed to:

Chambers Software Award
c/o J.R. Lockwood
The RAND Corporation
4570 Fifth Avenue, Suite 600
Pittsburgh, PA 15213
lockw...@rand.org

__

This email message is for the sole use of the intended r...{{dropped:6}}

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

2008-12-12 Thread Thompson, David (MNR)
Thanks Jorge,
 
I am aware of the method you suggest, however, it's not quite what I was
asking for.
I was attempting to do this change on 56 dataframes, so I attempted to
do so with a list of all rather than each individually.
 
Thanks, DaveT.




From: Jorge Ivan Velez [mailto:jorgeivanve...@gmail.com] 
Sent: December 12, 2008 11:11 AM
To: Thompson, David (MNR)
Subject: Re: [R] assign()ing within apply



Dear David, 

Try this:

ban.ovs.93[,'spp']<-tolower(ban.ovs.93[,'spp'])
ban.ovs.93

pem.ovs.94[,'spp']<-tolower(pem.ovs.94[,'spp'])
pem.ovs.94


HTH,

Jorge



On Fri, Dec 12, 2008 at 9:51 AM, Thompson, David (MNR)
 wrote:


Any tips?

DaveT.

>-Original Message-
>From: Thompson, David (MNR)
>Sent: December 9, 2008 04:03 PM
>To: 'r-help@r-project.org'
>Subject: assign()ing within apply
>
>Hello,
>
>I'm trying to convert a character column in several
dataframes
>to lower case.
>
>###
>#
># Sample data and 'spp' column summaries:
># dput(ban.ovs.1993[sample(row.names(ban.ovs.1993),
20), 1:4])
>ban.ovs.93 <- structure(list(oplt = c(43L, 43L, 38L,
26L, 35L,
>8L, 39L, 1L,
>34L, 50L, 10L, 29L, 31L, 24L, 18L, 12L, 27L, 49L, 28L,
51L),
>rplt = c(NA_integer_, NA_integer_, NA_integer_,
NA_integer_,
>NA_integer_, NA_integer_, NA_integer_, NA_integer_,
NA_integer_,
>NA_integer_, NA_integer_, NA_integer_, NA_integer_,
NA_integer_,
>NA_integer_, NA_integer_, NA_integer_, NA_integer_,
NA_integer_,
>NA_integer_), tree = c(427L, 410L, 639L, 494L,
649L, 166L,
>735L, 163L, 120L, 755L, 612L, 174L, 129L, 331L,
269L, 152L,
>552L, 227L, 243L, 96L), spp = c("MH", "MST", "MH",
"HE",
>"BE", "MH", "MH", "MH", "MH", "Or", "IW", "Or",
"MH", "MH",
>"BY", "MH", "MH", "BE", "MH", "MR")), .Names =
c("oplt",
>"rplt", "tree", "spp"), row.names = c(4587L, 4570L,
3947L, 2761L,
>3653L, 652L, 4136L, 64L, 3567L, 5318L, 838L, 3091L,
3366L, 2423L,
>1775L, 1061L, 2893L, 5161L, 2967L, 5395L), class =
"data.frame")
>
># dput(pem.ovs.1994[sample(row.names(pem.ovs.1994),
20), 1:4])
>pem.ovs.94 <- structure(list(oplt = c(8L, 17L, 36L, 9L,
31L,
>11L, 35L, 51L,
>51L, 49L, 40L, 1L, 9L, 17L, 4L, 42L, 6L, 3L, 39L, 25L),
tree = c(531L,
>557L, 546L, 261L, 592L, 134L, 695L, 933L, 945L, 114L,
34L, 54L,
>549L, 574L, 193L, 96L, 70L, 4L, 546L, 789L), spp =
c("MH", "MH",
>"MH", "BF", "BF", "MH", "IW", "OR", "OR", "BF", "MH",
"IW", "OR",
>"MH", "SM", "BE", "BE", "BE", "OR", "OR"), oaz = c(38L,
205L,
>140L, 277L, 329L, 209L, 222L, 24L, 67L, 187L, 156L,
181L, 174L,
>248L, 42L, 279L, 273L, 357L, 160L, 183L)), .Names =
c("oplt",
>"tree", "spp", "oaz"), row.names = c(1204L, 2943L,
5790L, 1616L,
>5063L, 2013L, 5691L, 8188L, 8200L, 7822L, 6302L, 54L,
1698L,
>2960L, 421L, 6690L, 775L, 245L, 6205L, 4121L), class =
"data.frame")
>
># count per spp
>invisible(lapply(ls(pat='ovs'), function(y) { cat(y,
"\n")  ;
>print(summary.factor(get(y)[,'spp'])) ; cat("\n") } ) )
>ban.ovs.93
>BE  BY  HE  IW  MH  MR MST  Or
> 2   1   1   1  11   1   1   2
>
>pem.ovs.94
>BE BF IW MH OR SM
> 3  3  2  6  5  1
>#
>###
>
>I have tried variants on the following and cannot
remember how
>to have the result assign()ed back to the original
dataframes.
>lapply(ls(pat='ovs'), function(y) { assign(paste(y,
>"[,'spp']", sep=""), tolower(get(y)[,'spp'])) } )
>
>I *do* get the expected results:
>[[1]]
> [1] "mh"  "mst" "mh"  "he"  "be"  "mh"  "mh"  "mh"
"mh"
>"or"  "iw"  "or"  "mh"  "mh"  "by"  "mh"  "mh"  "be"
"mh"  "mr"
>
>[[2]]
> [1] "mh" "mh" "mh" "bf" "bf" "mh" "iw" "or" "or" "bf"
"mh"
>"iw" "or" "mh" "sm" "be" "be" "be" "or" "or"
>
>, I just can't remember ho

Re: [R] loop with dates

2008-12-12 Thread Jagat.K.Sheth
 

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Fernando Bizuet
> Sent: Friday, December 12, 2008 12:55 PM
> To: r-help@r-project.org
> Subject: [R] loop with dates
> 
> Hello,
> 
> I am trying to do a loop with dates, but when I try to use 
> the index is not
> a date.

See ?"for". That help page mentions the following which can clarify what
to expect 

"... The variable 'var' has the same type as 'seq' ..."

Small illustration,

fac  <- gl(5,1,labels=letters[1:5])
fac
[1] a b c d e
Levels: a b c d e

typeof(fac)
[1] "integer"

for(i in fac) print(i)
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5


> 
>Fcorte <-  as.Date('2008/11/30',format = "%Y/%m/%d")
>fini <- Fcorte + 1
>ffin <- seq(fini,by='months',length=2)[2] - 1
> 
>for (i in seq(fini,to = ffin, by='days'))
> print (weekdays(i))  # i doesn't a date

typeof(ffin)
[1] "double"

As your index is no longer of class 'Date', you will get
Error in UseMethod("weekdays") : no applicable method for "weekdays

> 
> How can I do a loop with dates and get the index of each 
> date? are there a
> method to convert the index i to date?

Here's one way 
dd <- seq(fini,to = ffin, by='days')
for (i in seq_along(dd)) print(dd[i])

> 
> 
> Thanks in advance.
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Make installed packages available to new R version

2008-12-12 Thread Prof Brian Ripley

You have not told us your OS (despite the posting guide).

For Windows this is covered in the rw-FAQ.  Similar advice would apply on 
a Unix-alike.


For Mac OS X, see the recent archives of the R-sig-mac list. E.g. the 
strangely titled threads (look in a threaded view) around


https://stat.ethz.ch/pipermail/r-sig-mac/2008-November/005565.html

(probably using the Package Installer).

On Fri, 12 Dec 2008, Roy Robertson wrote:

After installing a new version of R, how do I make the packages that I have 
already installed and use on the old version available to the new version?


Thank you,

Roy Robertson

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



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

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


[R] prevalence ratio and confidence intervals

2008-12-12 Thread Roberta Pereira Niquini
Hi everybody,

I would like to estimate prevalence ratio and confidence intervals. 

I tried to do a log-binomial regression, but there was a failure of 
convergence.
Now, I would like to learn how to do a poisson regression with robust 
variance.
I am trying to estimate coefficients with poisson regression and then get 
standard errors that are adjusted for heteroskedasticity. 

glm22<- svyglm(y~x1+x2+x3+offset(log(x4)), data = banco,  family = poisson, 
design= design_tarv)

# Y has a binomial distribution (0/1)
# X1, X2, X3 e X4 are categorical variables.
#I am using the library(survey) because it is an analysis of Complex Sample 
Survey Data .

summary(glm22)

Call:
svyglm(y~x1+x2+x3+ offset(log(x4)),data = banco, family = poisson, design = 
design_tarv)

Survey design:
svydesign(ids = ~conglomerado, strata = ~estrato, data = banco, 
weights = ~peso)

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -5.612240.07223 -77.699  < 2e-16 ***
x1   0.338470.07428   4.557 0.000155 ***
x2   0.177450.07059   2.514 0.019765 *  
x3   0.335080.09447   3.547 0.001808 ** 
x4   0.243820.08808   2.768 0.011217 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

(Dispersion parameter for poisson family taken to be 0.7535822)

Number of Fisher Scoring iterations: 5

# Using family=quasipoisson, I found the same values.


library(sandwich)

vcovHAC(glm22)

 (Intercept)x1   x2   x3x4
(Intercept)1.060857e-12-1.306035e-13-5.139155e-13 -9.788354e-13 -3.428080e-13
x1 -1.306035e-13  7.237868e-13   -3.263182e-13  -1.620593e-13  1.704392e-13
x2 -5.139155e-13  -3.263182e-13  1.250564e-12   7.207572e-13   -9.350062e-13
x3 -9.788354e-13  -1.620593e-13  7.207572e-13   1.707176e-12   -2.244859e-13
x4 -3.428080e-13   1.704392e-13   -9.350062e-13  -2.244859e-13   2.031640e-12

sqrt(diag(vcovHAC(glm22)))

 (Intercept)   x1x2x3 x4
1.029979e-06 8.507566e-07 1.118286e-06 1.306589e-06 1.425356e-06 


I think these standards errors are very small. 

Is this the correct form to do poisson regression with robust variance?

Thank you for the help, 
Roberta.

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

2008-12-12 Thread Petr PIKAL
Ok, I knew somebody come with regex solution. My regex skills are limited 
so I do not use it very often.

Regards
Petr

r-help-boun...@r-project.org napsal dne 12.12.2008 17:03:38:

> On Fri, Dec 12, 2008 at 11:00 AM, Petr PIKAL  
wrote:
> > Hi
> >
> >
> > r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:
> >
> >> Dear list,
> >> I have a variable that consists of typed responses. I wish to compute
> >> a variable equal to the number of characters in the original 
variable.
> >> For example:
> >>
> >> > x <- c("convert this to 32 because it has 32 characters", "this one
> > has 22
> >> characters", "12 characters")
> >>
> >> [Some magic function here]
> >
> > If you consider space as a character then
> >
> >  nchar(x)
> >
> > gives you the result.
> >
> > If not so such construction can do it
> >
> >  unlist(lapply(lapply(strsplit(x, " "), paste, collapse=""), nchar))
> >
> 
> or perhaps:
> 
> x <- "abc def"
> nchar(gsub(" ", "", x)) # 6
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] loop with dates

2008-12-12 Thread Gabor Grothendieck
Try iterating over the index rather than the value of
each component:

s <- seq(fini,to = ffin, by='days')
for (i in seq_along(s)) print(s[[i]])


On Fri, Dec 12, 2008 at 1:55 PM, Fernando Bizuet  wrote:
> Hello,
>
> I am trying to do a loop with dates, but when I try to use the index is not
> a date.
>
>   Fcorte <-  as.Date('2008/11/30',format = "%Y/%m/%d")
>   fini <- Fcorte + 1
>   ffin <- seq(fini,by='months',length=2)[2] - 1
>
>   for (i in seq(fini,to = ffin, by='days'))
>print (weekdays(i))  # i doesn't a date
>
> How can I do a loop with dates and get the index of each date? are there a
> method to convert the index i to date?
>
>
> Thanks in advance.
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

2008-12-12 Thread Henrique Dallazuanna
Try this:

weekdays(seq(fini,to = ffin, by='days'))

or in a loop:

sapply(as.character(seq(fini,to = ffin, by='days')),
  function(d)weekdays(as.Date(d)))

On Fri, Dec 12, 2008 at 4:55 PM, Fernando Bizuet  wrote:

> Hello,
>
> I am trying to do a loop with dates, but when I try to use the index is not
> a date.
>
>   Fcorte <-  as.Date('2008/11/30',format = "%Y/%m/%d")
>   fini <- Fcorte + 1
>   ffin <- seq(fini,by='months',length=2)[2] - 1
>
>   for (i in seq(fini,to = ffin, by='days'))
>print (weekdays(i))  # i doesn't a date
>
> How can I do a loop with dates and get the index of each date? are there a
> method to convert the index i to date?
>
>
> Thanks in advance.
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

[[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] The end of Matlab

2008-12-12 Thread hadley wickham
> My end would be the output of your end().  If there are no args and no local
> context, I don't see the need for it to be a function call.  It would just
> be defined as something like
>
> end <- structure( function(n) c(rep(FALSE, n-1), TRUE), class="selector")

Oh, I see what you mean.

> I'm not sure what the definition of : should be if one of the args is a
> selector.

Alternatively you could use !first(2), and only use end/last when you
want to select the last n observations.  Of course !first(2) would be
the equivalent to -(1:2) so there's not much savings there.

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.


[R] loop with dates

2008-12-12 Thread Fernando Bizuet
Hello,

I am trying to do a loop with dates, but when I try to use the index is not
a date.

   Fcorte <-  as.Date('2008/11/30',format = "%Y/%m/%d")
   fini <- Fcorte + 1
   ffin <- seq(fini,by='months',length=2)[2] - 1

   for (i in seq(fini,to = ffin, by='days'))
print (weekdays(i))  # i doesn't a date

How can I do a loop with dates and get the index of each date? are there a
method to convert the index i to date?


Thanks in advance.

[[alternative HTML version deleted]]

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


Re: [R] The end of Matlab

2008-12-12 Thread Greg Snow
That depends on what you want evens() & last(5) to mean.  Does that mean the 
last 5 evens (returning 5 values) or the values in the last 5 that are also 
even items (returning either 2 or 3 values depending on if the structure has an 
odd or even number of elements).  It could be interpreted either way.  Your 
subset below does the first, the other examples do the 2nd.

--
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 Claudia Beleites
> Sent: Friday, December 12, 2008 11:38 AM
> To: r-help@r-project.org
> Subject: Re: [R] The end of Matlab
>
> > evens() & last(5)
> wouldn't x[evens()][last(5)] do the & already?
>
> or is different, though.
>
> Claudia
>
> --
> Claudia Beleites
> Dipartimento dei Materiali e delle Risorse Naturali
> Università degli Studi di Trieste
> Via Alfonso Valerio 6/a
> I-34127 Trieste
>
> phone: +39 (0 40) 5 58-34 47
> email: cbelei...@units.it
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Make installed packages available to new R version

2008-12-12 Thread Mike Prager
Roy Robertson  wrote:

> After installing a new version of R, how do I make the packages that I 
> have already installed and use on the old version available to the new 
> version?

Here is my solution. It has worked over many releases of R,
though it will probably require one initial re-installation of
packages.

Set environment variable R_LIBS to some permanent directory
before installing a version of R. (That is, NOT a directory
under the tree of your current R version.) When you subsequently
install packages, they will go into that location and won't need
re-installation with each new version of R. 

It's still necessary to run update.packages() periodically --
such as after installing a new R version -- to keep the
installed packages current.

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

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

2008-12-12 Thread Claudia Beleites
> evens() & last(5)
wouldn't x[evens()][last(5)] do the & already?

or is different, though.

Claudia

-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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


Re: [R] The end of Matlab

2008-12-12 Thread Duncan Murdoch

On 12/12/2008 1:06 PM, hadley wickham wrote:

Oh yes, that's a good point.  But wouldn't the following do the job?

"&.selector" <- function(a, b) {
 function(n) a(n) & b(n)
}

or

"&.selector" <- function(a, b) {
 function(n) intersect(a(n), b(n))
}

depending on whether selectors return logical or numeric vectors.
Writing functions for | and ! would be similarly easy.  Or am I
missing something?


No, I think those definitions would be fine, but I'd be concerned about
speed issues if we start messing with primitives.


Speed or expressiveness: pick one? ;)  People could always use the
regular subsetting mechanisms if they want the best speed - any
changes to support selectors wouldn't affect the speed of the other
methods of subsetting, would they?


While we're at it, we might as well do the same sort of thing for :, and
define a selector named end, and then 3:end would give a selector from 3 to
the end, which brings us back to the original question.  So it's not nearly
as intrusive as I thought it would be.


3:end() do you mean?  Or do you mean extending seq so that it uses
unevaluted input?


My end would be the output of your end().  If there are no args and no 
local context, I don't see the need for it to be a function call.  It 
would just be defined as something like


end <- structure( function(n) c(rep(FALSE, n-1), TRUE), class="selector")

I'm not sure what the definition of : should be if one of the args is a 
selector.


Duncan

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

2008-12-12 Thread Pete Shepard
Dear Michael,


You haven't told us what your data is, and we can only surmise -- not very
helpful for you and annoying for those who try to help.

Apologies, I am brand new to R and this mailing list. Will try to be more
concise.

Here is my data a NEW verion of my data:

  Curvature Diameter   Quality
1  2.95 6.63Passed
2  2.53 7.79Passed
3  3.57 5.65Passed
4  3.16 5.47Passed
5  2.58 4.46 NotPassed
6  2.16 6.22 NotPassed
7  3.27 3.52 NotPassed

What I am trying to get from the candisc method is a 1 dimensional
scatterplot that separates my two groups Passed and NotPassed

On this data I do a "do.mod <- lm(cbind(Diameter, Curvature) ~ Quality,
data=do)"

>do.mod produces

Coefficients:
   Diameter  Curvature
(Intercept)4.73332.6700
QualityPassed  1.65170.3825

I then run the "candisc" method: "do.can <- candisc(do.mod, data=do)"

this produces:

Canonical Discriminant Analysis for Quality:

   CanRsq Eigenvalue Difference Percent Cumulative
1 0.91354 10.566100100

Test of H0: The canonical correlations in the
current row and all that follow are zero

  LR test stat approx F num Df den Df   Pr(> F)
10.086   52.831  1  5 0.0007706 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

What "I think" I would like to plot is the discriminant function of each
sample 1-7.

Here is an example of what I am trying to do with candisc.

http://people.revoledu.com/kardi/tutorial/LDA/Numerical%20Example.html

Thanks










On Thu, Dec 11, 2008 at 3:36 PM, Michael Friendly  wrote:

> Dear Pete,
>
> You haven't told us what your data is, and we can only surmise -- not very
> helpful for you and annoying for those who try to help.
>
> Pete Shepard wrote:
>
>> Hello,
>>
>> I have a file with two dependent variables (three and five) and one
>> independent variable. I do  i.mod <- lm(cbind(three, five) ~ species,
>> data=i.txt) and get the following output:
>>
>>
>> Coefficients:
>> three   five
>> (Intercept)   9.949   9.586
>> species  -1.166  -1.156
>>
> From this, it seems that species is numeric variable, not a factor.
> If so, canonical discriminant analysis in not appropriate, so
> all following bets are off.
>
> That's likely why you end up with only one canonical dimension.
>
>
>  I do a" i.can<-candisc(i.mod,data=i):
>>
> Is data=i the same as data=i.txt?
>
>>
>> and get the following output:
>>
>> Canonical Discriminant Analysis for species:
>>
>>CanRsq Eigenvalue Difference Percent Cumulative
>> 1 0.0965060.10681100100
>>
>> Test of H0: The canonical correlations in the
>> current row and all that follow are zero
>> LR test stat approx F num Df den Df   Pr(> F)
>> 10.903   63.875  1598 6.859e-15 ***
>> ---
>> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>>
>> this is different than the output I get with SAS:
>>
> What was your SAS code? Was the data the same?
>
>>
>> Eigenvalue Difference Proportion Cumulative  Ratio F Value
>> Num DF Den DF Pr > F
>>
>>   1 0.10681. 1. 0.90349416
>> 31.88  2597 <.0001
>>
>
>
>
>> I am also wondering how to plot the can1*can1 like it is done in SAS.
>>
>> proc plot;
>>plot can1*can1=species;
>>format species spechar.;
>>title2 'Plot of Constits_vs_cassettes';
>>  run;
>>
>>  If you want to compare plots for canonical analysis in SAS and R,
> see my macros, canplot and hecan at
> http://www.math.yorku.ca/SCS/sasmac/
>
> But in general, if all you have is 1 canonical dimension, a dotplot or
> boxplot of the canonical scores would be more useful than a scatterplot
> plot of can1 * can1.
>
> The plot method for candisc objects in the candisc package has some
> code to handle the 1 can-D case.
>
> hope this helps
> -Michael
>
>> Thanks
>>
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> --
> Michael Friendly Email: friendly AT yorku DOT ca
> Professor, Psychology Dept.
> York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
> 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
> Toronto, ONT  M3J 1P3 CANADA
>
>

[[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] Make installed packages available to new R version

2008-12-12 Thread Vitalie Spinu

Have a look at this 
http://thread.gmane.org/gmane.comp.lang.r.general/87014/focus=133050
it is safer to have all you packages reinstalled once you have updated R.

HTH.


On Fri, 12 Dec 2008 18:47:33 +0100, Roy Robertson  
wrote:

After installing a new version of R, how do I make the packages that I  
have already installed and use on the old version available to the new  
version?


Thank you,

Roy Robertson

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

2008-12-12 Thread hadley wickham
>> Oh yes, that's a good point.  But wouldn't the following do the job?
>>
>> "&.selector" <- function(a, b) {
>>  function(n) a(n) & b(n)
>> }
>>
>> or
>>
>> "&.selector" <- function(a, b) {
>>  function(n) intersect(a(n), b(n))
>> }
>>
>> depending on whether selectors return logical or numeric vectors.
>> Writing functions for | and ! would be similarly easy.  Or am I
>> missing something?
>
> No, I think those definitions would be fine, but I'd be concerned about
> speed issues if we start messing with primitives.

Speed or expressiveness: pick one? ;)  People could always use the
regular subsetting mechanisms if they want the best speed - any
changes to support selectors wouldn't affect the speed of the other
methods of subsetting, would they?

> While we're at it, we might as well do the same sort of thing for :, and
> define a selector named end, and then 3:end would give a selector from 3 to
> the end, which brings us back to the original question.  So it's not nearly
> as intrusive as I thought it would be.

3:end() do you mean?  Or do you mean extending seq so that it uses
unevaluted input?

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.


[R] Make installed packages available to new R version

2008-12-12 Thread Roy Robertson
After installing a new version of R, how do I make the packages that I 
have already installed and use on the old version available to the new 
version?


Thank you,

Roy Robertson

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

2008-12-12 Thread Duncan Murdoch

On 12/12/2008 12:23 PM, hadley wickham wrote:

On Fri, Dec 12, 2008 at 11:18 AM, Duncan Murdoch  wrote:

On 12/12/2008 11:38 AM, hadley wickham wrote:


On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch 
wrote:


On 12/12/2008 8:25 AM, hadley wickham wrote:


From which you might conclude that I don't like the design of subset,
and
you'd be right.  However, I don't think this is a counterexample to my
general rule.  In the subset function, the select argument is treated
as
an
unevaluated expression, and then there are rules about what to do with
it.
 (I.e. try to look up name `a` in the data frame, if that fails, ...)

For the requested behaviour to similarly fall within the general rule,
we'd
have to treat all indices to all kinds of things (vectors, matrices,
dataframes, etc.) as unevaluated expressions, with special handling for
the
particular symbol `end`.


Except you wouldn't have to necessarily change indexing - you could
change seq instead.  Then 5:end could produce some kind of special
data structure (maybe an iterator) that was recognised by the various
indexing functions.


Ummm, doesn't that require changes to *both* indexing and seq?


Ooops, yes.  I meant it wouldn't require indexing to use unevaluated
expression.


This would still be a lot of work for not a lot
of payoff, but it would be a logically consistent way of adding this
behaviour to indexing, and the basic work would make it possible to
develop other sorts of indexing, eg df[evens(), ], or df[last(5),
last(3)].


I agree:  it would be a nice addition, but a fair bit of work.  I think
it
would be quite doable for the indexable things in the base packages, but
there are a lot of contributed packages that define [ methods, and those
methods would all need to be modified too.


That's true, although I suspect many contributed [.methods eventually
delegate to base methods and might work without further modification.


(Just to be clear, when I say doable, I'm thinking that your iterators
return functions that compute subsets of index ranges.  For example,
evens()
might be implemented as

evens <- function() {
 result <- function(indices) {
  indices[indices %% 2 == 0]
 }
 class(result) <- "iterator"
 return(result)
}

and then `[` in v[evens()] would recognize that it had been passed an
iterator, and would pass 1:length(v) to the iterator to get the subset of
even indices.  Is that what you had in mind?)


Yes, that's exactly what I was thinking, although you'd have to put
some thought into the conventions - would it be better to pass in the
length of the vector instead of a vector of indices?  Should all
iterators return logical vectors?  That way you could do x[evens() &
last(5)] to get the even indices out of the last 5, as opposed to
x[evens()][last(5)] which would return the last 5 even indices.


Actually, I don't think so.  "evens() & last(5)" would fail to evaluate,
because you're trying to do a logical combination of two functions, not of
two logical vectors.  Or are we going to extend the logical operators to
work on iterators/selectors too?


Oh yes, that's a good point.  But wouldn't the following do the job?

"&.selector" <- function(a, b) {
  function(n) a(n) & b(n)
}

or

"&.selector" <- function(a, b) {
  function(n) intersect(a(n), b(n))
}

depending on whether selectors return logical or numeric vectors.
Writing functions for | and ! would be similarly easy.  Or am I
missing something?


No, I think those definitions would be fine, but I'd be concerned about 
speed issues if we start messing with primitives.


While we're at it, we might as well do the same sort of thing for :, and 
define a selector named end, and then 3:end would give a selector from 3 
to the end, which brings us back to the original question.  So it's not 
nearly as intrusive as I thought it would be.


Duncan Murdoch

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


Re: [R] The end of Matlab

2008-12-12 Thread Gabor Grothendieck
On Fri, Dec 12, 2008 at 12:11 PM, Vitalie Spinu  wrote:
> On Fri, 12 Dec 2008 17:38:13 +0100, hadley wickham 
> wrote:
>
>> You could also imagine similar iterators for random sampling, like
>> samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
>> with replacement.  first(n) could also be useful, selecting the first
>> min(n, length(vector)) observations.   An iterator version of rev()
>> would also be handy.
>>
>> Maybe selector would be a better name than iterator though, as these
>> don't have the same feel as iterators in other languages.
>
> That is really something!! Real high level language!!
> "Selectors" could depend on named variables in data frame as well:
>
> mtcars[sel(cyl>3)&last(5)]
> mtcars[sel(cyl>3)&boot(80%)]
>
> or may be just
> mtcars[cyl>3&last(20)]
>

You can do this (and quite a bit more) in data.table:

> library(data.table)
> mtcars.dt <- as.data.table(mtcars)
> tail(mtcars.dt[cyl < 5], 4)
  mpg cyl  disp  hp dratwt qsec vs am gear carb
[1,] 27.3   4  79.0  66 4.08 1.935 18.9  1  141
[2,] 26.0   4 120.3  91 4.43 2.140 16.7  0  152
[3,] 30.4   4  95.1 113 3.77 1.513 16.9  1  152
[4,] 21.4   4 121.0 109 4.11 2.780 18.6  1  142

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

2008-12-12 Thread Roger Bivand
Erin Hodgess  gmail.com> writes:

> 
> Dear R People:
> 
> Are there functions for spatial AR and ARIMA models in R, please?

Would looking at the "Spatial" task view on your CRAN mirror help? If by AR 
you mean simultaneous or conditional autoregressive models using spatial 
weights (or moving average, but not SAR and SMA at the same time), see 
spautolm() in spdep. Note that with corSpatial(), you can fit a selection of
relevant mixed effects models using nlme and similar packages - is this what 
you are looking for?

Roger Bivand 

> 
> Thanks,
> Sincerely,
> Erin
>

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

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 11:11 AM, Vitalie Spinu  wrote:
> On Fri, 12 Dec 2008 17:38:13 +0100, hadley wickham 
> wrote:
>
>> You could also imagine similar iterators for random sampling, like
>> samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
>> with replacement.  first(n) could also be useful, selecting the first
>> min(n, length(vector)) observations.   An iterator version of rev()
>> would also be handy.
>>
>> Maybe selector would be a better name than iterator though, as these
>> don't have the same feel as iterators in other languages.
>
> That is really something!! Real high level language!!
> "Selectors" could depend on named variables in data frame as well:
>
> mtcars[sel(cyl>3)&last(5)]
> mtcars[sel(cyl>3)&boot(80%)]
>
> or may be just
> mtcars[cyl>3&last(20)]
>
> or this is already too far?

This would be a considerable extension because then the selector would
need to know about all other variables in the dataset, and you'd need
someway of combining selectors with logical vectors.  So it would be a
huge increase in complexity for not much gain, given that with just
the interface we have described you could do:

mtcars[mtcars$cyl > 3, ][last(20), ]
# or
subset(mtcars, cyl > 3)[last(20), ]

The main idea of selectors is that they would be independent of the
data structure that they are being used with.

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] The end of Matlab

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 11:18 AM, Duncan Murdoch  wrote:
> On 12/12/2008 11:38 AM, hadley wickham wrote:
>>
>> On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch 
>> wrote:
>>>
>>> On 12/12/2008 8:25 AM, hadley wickham wrote:
>
> From which you might conclude that I don't like the design of subset,
> and
> you'd be right.  However, I don't think this is a counterexample to my
> general rule.  In the subset function, the select argument is treated
> as
> an
> unevaluated expression, and then there are rules about what to do with
> it.
>  (I.e. try to look up name `a` in the data frame, if that fails, ...)
>
> For the requested behaviour to similarly fall within the general rule,
> we'd
> have to treat all indices to all kinds of things (vectors, matrices,
> dataframes, etc.) as unevaluated expressions, with special handling for
> the
> particular symbol `end`.

 Except you wouldn't have to necessarily change indexing - you could
 change seq instead.  Then 5:end could produce some kind of special
 data structure (maybe an iterator) that was recognised by the various
 indexing functions.
>>>
>>> Ummm, doesn't that require changes to *both* indexing and seq?
>>
>> Ooops, yes.  I meant it wouldn't require indexing to use unevaluated
>> expression.
>>
 This would still be a lot of work for not a lot
 of payoff, but it would be a logically consistent way of adding this
 behaviour to indexing, and the basic work would make it possible to
 develop other sorts of indexing, eg df[evens(), ], or df[last(5),
 last(3)].
>>>
>>> I agree:  it would be a nice addition, but a fair bit of work.  I think
>>> it
>>> would be quite doable for the indexable things in the base packages, but
>>> there are a lot of contributed packages that define [ methods, and those
>>> methods would all need to be modified too.
>>
>> That's true, although I suspect many contributed [.methods eventually
>> delegate to base methods and might work without further modification.
>>
>>> (Just to be clear, when I say doable, I'm thinking that your iterators
>>> return functions that compute subsets of index ranges.  For example,
>>> evens()
>>> might be implemented as
>>>
>>> evens <- function() {
>>>  result <- function(indices) {
>>>   indices[indices %% 2 == 0]
>>>  }
>>>  class(result) <- "iterator"
>>>  return(result)
>>> }
>>>
>>> and then `[` in v[evens()] would recognize that it had been passed an
>>> iterator, and would pass 1:length(v) to the iterator to get the subset of
>>> even indices.  Is that what you had in mind?)
>>
>> Yes, that's exactly what I was thinking, although you'd have to put
>> some thought into the conventions - would it be better to pass in the
>> length of the vector instead of a vector of indices?  Should all
>> iterators return logical vectors?  That way you could do x[evens() &
>> last(5)] to get the even indices out of the last 5, as opposed to
>> x[evens()][last(5)] which would return the last 5 even indices.
>
> Actually, I don't think so.  "evens() & last(5)" would fail to evaluate,
> because you're trying to do a logical combination of two functions, not of
> two logical vectors.  Or are we going to extend the logical operators to
> work on iterators/selectors too?

Oh yes, that's a good point.  But wouldn't the following do the job?

"&.selector" <- function(a, b) {
  function(n) a(n) & b(n)
}

or

"&.selector" <- function(a, b) {
  function(n) intersect(a(n), b(n))
}

depending on whether selectors return logical or numeric vectors.
Writing functions for | and ! would be similarly easy.  Or am I
missing something?

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] The end of Matlab

2008-12-12 Thread Duncan Murdoch

On 12/12/2008 11:38 AM, hadley wickham wrote:

On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch  wrote:

On 12/12/2008 8:25 AM, hadley wickham wrote:


From which you might conclude that I don't like the design of subset, and
you'd be right.  However, I don't think this is a counterexample to my
general rule.  In the subset function, the select argument is treated as
an
unevaluated expression, and then there are rules about what to do with
it.
 (I.e. try to look up name `a` in the data frame, if that fails, ...)

For the requested behaviour to similarly fall within the general rule,
we'd
have to treat all indices to all kinds of things (vectors, matrices,
dataframes, etc.) as unevaluated expressions, with special handling for
the
particular symbol `end`.


Except you wouldn't have to necessarily change indexing - you could
change seq instead.  Then 5:end could produce some kind of special
data structure (maybe an iterator) that was recognised by the various
indexing functions.


Ummm, doesn't that require changes to *both* indexing and seq?


Ooops, yes.  I meant it wouldn't require indexing to use unevaluated
expression.


This would still be a lot of work for not a lot
of payoff, but it would be a logically consistent way of adding this
behaviour to indexing, and the basic work would make it possible to
develop other sorts of indexing, eg df[evens(), ], or df[last(5),
last(3)].


I agree:  it would be a nice addition, but a fair bit of work.  I think it
would be quite doable for the indexable things in the base packages, but
there are a lot of contributed packages that define [ methods, and those
methods would all need to be modified too.


That's true, although I suspect many contributed [.methods eventually
delegate to base methods and might work without further modification.


(Just to be clear, when I say doable, I'm thinking that your iterators
return functions that compute subsets of index ranges.  For example, evens()
might be implemented as

evens <- function() {
 result <- function(indices) {
   indices[indices %% 2 == 0]
 }
 class(result) <- "iterator"
 return(result)
}

and then `[` in v[evens()] would recognize that it had been passed an
iterator, and would pass 1:length(v) to the iterator to get the subset of
even indices.  Is that what you had in mind?)


Yes, that's exactly what I was thinking, although you'd have to put
some thought into the conventions - would it be better to pass in the
length of the vector instead of a vector of indices?  Should all
iterators return logical vectors?  That way you could do x[evens() &
last(5)] to get the even indices out of the last 5, as opposed to
x[evens()][last(5)] which would return the last 5 even indices.


Actually, I don't think so.  "evens() & last(5)" would fail to evaluate, 
because you're trying to do a logical combination of two functions, not 
of two logical vectors.  Or are we going to extend the logical operators 
to work on iterators/selectors too?


Duncan Murdoch


You could also imagine similar iterators for random sampling, like
samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
with replacement.  first(n) could also be useful, selecting the first
min(n, length(vector)) observations.   An iterator version of rev()
would also be handy.

Maybe selector would be a better name than iterator though, as these
don't have the same feel as iterators in other languages.

Hadley



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 mimic select.list using RGtk2/gWidgetsRGtk2?

2008-12-12 Thread ronggui
I want to write a function mimic the function of select.list(), here
is my preliminary version.

select <- function(x,multiple=TRUE,...){
ans<-new.env()
g <- gwindow(title=title,wid=200,heigh=500)
x1<-ggroup(FALSE,con=g)
x2<-gtable(x,multiple=multiple,con=x1,expand=TRUE)
gbutton("OK",con=x1,handler=function(h,...){
value <- svalue(x2)
if (length(value)==0) value=""
assign("selected",value,env=h$action$env)
dispose(x1)
},action=list(env=ans))
ans
}

However, it doesn't behave as what I want.  What I want is that: for
{select(c("a","b")); foo()}, foo() only runs after I have clicked the
OK button of select(). Any hints?

Thanks.
-- 
HUANG Ronggui, Wincent
Tel: (00852) 3442 3832
PhD Candidate, City University of Hong Kong
Website: http://ronggui.huang.googlepages.com/
RQDA project: http://rqda.r-forge.r-project.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] T-mode PCA

2008-12-12 Thread Victor Homar

Hi,

We are trying to classify atmospheric patterns using PCA and kmeans. In 
T-mode, the (non-normalized) loadings of the PCs are used as input 
variables for the k-means classification.


As first step we perform PCA using "princomp" but the computed loadings 
produced by princomp are normalized. In order to apply T-mode 
classification, we need the "non-normalized" loadings as they represent 
the correlation between old and new "axis".


How do we get the "non-normalized" loadings for the Principal Components?


Thanks for your help,

Víctor.


--
---
Víctor Homar Santaner
Grup de Meteorologia

Edif. Mateu Orfila  Tel: +34 971 17 1376
Universitat de les Illes BalearsFax: +34 971 17 3426
07122 Palma de Mallorca (SPAIN) Email: victor.ho...@uib.es

 Knowledge is contagious. Infect truth.

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

2008-12-12 Thread Vitalie Spinu

On Fri, 12 Dec 2008 17:38:13 +0100, hadley wickham  wrote:


You could also imagine similar iterators for random sampling, like
samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
with replacement.  first(n) could also be useful, selecting the first
min(n, length(vector)) observations.   An iterator version of rev()
would also be handy.

Maybe selector would be a better name than iterator though, as these
don't have the same feel as iterators in other languages.


That is really something!! Real high level language!!
"Selectors" could depend on named variables in data frame as well:

mtcars[sel(cyl>3)&last(5)]
mtcars[sel(cyl>3)&boot(80%)]

or may be just 


mtcars[cyl>3&last(20)]

or this is already too far?


VS.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] converting multiple columns from POSIX* to Date

2008-12-12 Thread Farrel Buchinsky
I got the whole thing to work, with Hadley Wickham's help.
is.POSIXt <- function(x) inherits(x, "POSIXt")
dates <- sapply(df, is.POSIXt)
df[dates] <-lapply(df[dates], as.Date)


Farrel Buchinsky




On Fri, Dec 12, 2008 at 11:26, Farrel Buchinsky  wrote:
>
> Something strange. The lapply only processed the first row and then wrote 
> that value to every row of the original dataframe. It is as if the lapply is 
> indeed processing every item on the list, namely each column, but the ifelse 
> or the as.Date is getting messed up. Not only is it only processing the first 
> row but it is also returning the value as numbers rather than dates. I am now 
> playing around with Hadley Wickham's plyr package. So far looking good but 
> still need to work out a few things.

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

2008-12-12 Thread hadley wickham
On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch  wrote:
> On 12/12/2008 8:25 AM, hadley wickham wrote:
>>>
>>> From which you might conclude that I don't like the design of subset, and
>>> you'd be right.  However, I don't think this is a counterexample to my
>>> general rule.  In the subset function, the select argument is treated as
>>> an
>>> unevaluated expression, and then there are rules about what to do with
>>> it.
>>>  (I.e. try to look up name `a` in the data frame, if that fails, ...)
>>>
>>> For the requested behaviour to similarly fall within the general rule,
>>> we'd
>>> have to treat all indices to all kinds of things (vectors, matrices,
>>> dataframes, etc.) as unevaluated expressions, with special handling for
>>> the
>>> particular symbol `end`.
>>
>> Except you wouldn't have to necessarily change indexing - you could
>> change seq instead.  Then 5:end could produce some kind of special
>> data structure (maybe an iterator) that was recognised by the various
>> indexing functions.
>
> Ummm, doesn't that require changes to *both* indexing and seq?

Ooops, yes.  I meant it wouldn't require indexing to use unevaluated
expression.

>> This would still be a lot of work for not a lot
>> of payoff, but it would be a logically consistent way of adding this
>> behaviour to indexing, and the basic work would make it possible to
>> develop other sorts of indexing, eg df[evens(), ], or df[last(5),
>> last(3)].
>
> I agree:  it would be a nice addition, but a fair bit of work.  I think it
> would be quite doable for the indexable things in the base packages, but
> there are a lot of contributed packages that define [ methods, and those
> methods would all need to be modified too.

That's true, although I suspect many contributed [.methods eventually
delegate to base methods and might work without further modification.

> (Just to be clear, when I say doable, I'm thinking that your iterators
> return functions that compute subsets of index ranges.  For example, evens()
> might be implemented as
>
> evens <- function() {
>  result <- function(indices) {
>indices[indices %% 2 == 0]
>  }
>  class(result) <- "iterator"
>  return(result)
> }
>
> and then `[` in v[evens()] would recognize that it had been passed an
> iterator, and would pass 1:length(v) to the iterator to get the subset of
> even indices.  Is that what you had in mind?)

Yes, that's exactly what I was thinking, although you'd have to put
some thought into the conventions - would it be better to pass in the
length of the vector instead of a vector of indices?  Should all
iterators return logical vectors?  That way you could do x[evens() &
last(5)] to get the even indices out of the last 5, as opposed to
x[evens()][last(5)] which would return the last 5 even indices.

You could also imagine similar iterators for random sampling, like
samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
with replacement.  first(n) could also be useful, selecting the first
min(n, length(vector)) observations.   An iterator version of rev()
would also be handy.

Maybe selector would be a better name than iterator though, as these
don't have the same feel as iterators in other languages.

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] The end of Matlab

2008-12-12 Thread Greg Snow
Just to muddy the waters a bit further.  Currently we can do things like:

> pascal.tri <- numeric(0)
> class(pascal.tri) <- 'pasctri'
>
> `[.pasctri` <- function(x, ...) {
+ dots <- list(...)
+ n <- dots[[1]]
+ row <- choose(n, 0:n)
+ if(length(dots) > 1) {
+ row <- row[ dots[[2]] ]
+ }
+ row
+ }
>
> pascal.tri[4]
[1] 1 4 6 4 1
> pascal.tri[4,2]
[1] 4

Now whether that is clever or abusive, I'm not sure (probably not clever).

But what would we expect:

> pascal.tri[end]

to return?

Also if we can access the last element of a vector as:

> x[end]

(which I am not opposed to, just don't know if it is worth the effort) then how 
long will it be before someone wants to be able to do:

> x[end+1] <- new.value

and put that in a loop, which would lead to very poor programming practice (but 
so easy it would tempt many).

Just my $0.015 worth,

--
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 Wacek Kusnierczyk
> Sent: Friday, December 12, 2008 8:57 AM
> To: claudia.belei...@gmx.de
> Cc: R help
> Subject: Re: [R] The end of Matlab
>
> Claudia Beleites wrote:
> >>> Wacek:
> >>>
>  x[3:]
>  instead of
>  x[3:length(x)]
>  x[3:end]
> 
> >>> I don't think that would help:
> >>> what to use for end - 3 within the convention that negative values
> mean
> >>> exclusion?
> >>>
> >> might seem tricky, but not impossible:
> >>
> >> x[-2]
> >> # could mean 'all except for 2nd', as it is now
> >>
> >> x[1:-2]
> >> # could mean 'from start to the 2nd backwards from the end'
> >>
> > I know you get thus far. You might even think to decide whether
> exclusion or
> > 'from the end' is meant from ascending ./. descending order of the
> sequence,
> > but this messes around with returning the reverse order.
> >
> >
>
> that's a design issue.  one simple solution is to have this sort of
> indexing return always in ascending order.  thus,
>
> x = 1:5
> x[1:-1]
> # 1 2 3 4 5
> x[5:-5]
> # NULL rather than 5 4 3 2 1 -- as in matlab or python
>
> x[seq(5,1)]
> # 5 4 3 2 1
>
> that is, the ':'-based indexing can be made not to mess with the order.
> for reversing the order, why not use:
>
> x[5:-1:1]
> # 5 4 3 2 1
>
> x[-3:-1:-5]
> # 3 2 1 rather than x[c(-3,-4,-5)], which would be 1 2
>
>
> >> since r disallows mixing positive and negative indexing, the above
> would
> >> not be ambiguous.  worse with
> >>
> >> x[-3:-1]
> >>
> >> which could mean both 'except for 3rd, 2nd, and 1st' and 'from the
> 3rd
> >> to the 1st from the end', and so would be ambiguous.  in this
> context,
> >> indeed, having explicit 'end' could help avoid the ambiguity.
> >>
> > that's the problem.
> > also: how would 'except from the 5th last to the 3rd last' be
> expressed?
> >
>
> for exclusions you'd need to use negative indices anyway:
>
> x[seq(-5,-3)]
>
> now, neither x[-5:-3] nor x[-3:-5] would do the job they do now, but
> the
> above is not particularly longer, while selecting the
> 5th-to3rd-from-the-end columns is simply x[-5:-3] (which could be made
> to fail on out-of-range indices) instead of something like x[length(x)
> -
> 4:2] (which will silently do the wrong thing if length(x) < 4, and thus
> requires extra care).
>
> this is a rather loose idea, and unrealistic in the context of r, but i
> do not see much problem with it on the conceptual level.
>
> 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.


Re: [R] converting multiple columns from POSIX* to Date

2008-12-12 Thread Farrel Buchinsky
Something strange. The lapply only processed the first row and then wrote
that value to every row of the original dataframe. It is as if the lapply is
indeed processing every item on the list, namely each column, but the ifelse
or the as.Date is getting messed up. Not only is it only processing the
first row but it is also returning the value as numbers rather than dates. I
am now playing around with Hadley Wickham's plyr package. So far looking
good but still need to work out a few things.
Farrel Buchinsky
GrandCentral Tel: (412) 567-7870



On Wed, Dec 10, 2008 at 19:08, Marc Schwartz wrote:

> Use inherits() then rather than class():
>
>  DF[] <- lapply(DF, function(x) ifelse(inherits(x, "POSIXt"),
>as.Date(x), x))
>
> That should hopefully work better than my first attempt.
>
> HTH,
>
> Marc Schwartz
>
> on 12/10/2008 05:47 PM Farrel Buchinsky wrote:
> > I will try that but I am somewhat skeptical since when I go
> > class(date.of.birth) I get not just one word but two:  "POSIXt"
> > "POSIXct". Will that not mess up the logical test
> >
> > When I tried the following:
> > lapply(as.list(dataframename),class)=="POSIXt"
> > every item was false
> >
> > Farrel Buchinsky
> > GrandCentral Tel: (412) 567-7870
> >
> >
> >
> >
> >
> >> Dear Farrel,
> >> Determine the class of each column and apply as.Date() just to those
> which
> >> class is POSIX. For more details see ?class. Here is an example assuming
> >> that you're data is named "mydata":
> >> apply(mydata, 2, function(x) ifelse( class(x)=="POSIXt" |
> >>  class(x)=="POSIXlt" , as.Date(x) , x ) )
> >>
> >> HTH,
> >>
> >> Jorge
> >>
> >>
> >>
> >> On Wed, Dec 10, 2008 at 6:26 PM, Farrel Buchinsky 
> wrote:
> >>> converting a POSIX class variable to a date class is easy.
> >>> dates<-as.Date(x) #where X is of class POSIX
> >>> How does one do that to all columns in a data frame that are of POSIX
> >>> class and leave all the other columns (integers, factors) as is.
> >>>
> >>> Feel free to reply with just one or two buzzwords that I could then
> >>> search for to find how to do it.
> >>>
> >>> Farrel Buchinsky
> >>>
> >>> __
> >>> R-help@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/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] character count

2008-12-12 Thread Gabor Grothendieck
On Fri, Dec 12, 2008 at 11:05 AM, Ista Zahn  wrote:
> Thanks to everyone who responded. This turns out to be amazingly easy.
> To count characters including spaces:
> nchar(x)
> To count characters excluding spaces:
> nchar(gsub(" *","",x))

The * is unnecessary.

>
> Thanks!
>
> On Fri, Dec 12, 2008 at 11:00 AM, Petr PIKAL  wrote:
>> Hi
>>
>>
>> r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:
>>
>>> Dear list,
>>> I have a variable that consists of typed responses. I wish to compute
>>> a variable equal to the number of characters in the original variable.
>>> For example:
>>>
>>> > x <- c("convert this to 32 because it has 32 characters", "this one
>> has 22
>>> characters", "12 characters")
>>>
>>> [Some magic function here]
>>
>> If you consider space as a character then
>>
>>  nchar(x)
>>
>> gives you the result.
>>
>> If not so such construction can do it
>>
>>  unlist(lapply(lapply(strsplit(x, " "), paste, collapse=""), nchar))
>>
>> Regards
>> Petr
>>
>>>
>>> > x
>>> [1] 32 22 12
>>>
>>> Any ideas?
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] mixed model nested ANOVA

2008-12-12 Thread Sebpe De Smedt
Hi,


I'm working on leaf characteristics of trees. Each tree is characterised by
about 10 leaf traits.
The trees were sampled at 9 different locations (about 20 to 30
trees/location, NOT balanced), grouped in 3 different climatic zones
(Sahelian, Soudanian and Guinean) (NOT balanced).
Further, each tree is characterised by some degree of human pressure
(mutilation degree), in total 4 different degrees were defined (NOT
balanced).

In the dryer zones, the trees are under a much higher human pressure than in
the more humid climatic zones, "zone" and "mutilation degree" are thus
strongly correlated.

I want to know how "zones" (fixed effects, climate interests me) and
"locations" (nested in "zones", random effects, location doesn't interests
me) are influencing the leaf traits (say for example "SLA"). Further, also
human pressure is affecting leaf traits so I want to characterise the
influence of "mutilation degree" (fixed effects) on "SLA".

I found some interesting information, but still, I am not be able to analyse
the data properly. I think I have to use the function lme() or lme().

Can anyone tell me which function and command I have to use? And how I can
produce an ANOVA table?


Thanks in advance,
Sebpe De Smedt

[[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] Functions in R like lincom and nlcom of Stata

2008-12-12 Thread Marc Marí Dell'Olmo
Hello all,

Does anyone know if there exists any function in R that resembles the
"lincom" and "nlcom" of STATA?. These functions computes point
estimates, standard errors, significance levels, confidence intervals,
etc. for linear and non linear combinations of previous estimated
parameters. Down here you've got links to descriptions of the
functions of STATA

nlcom:
http://www.stata.com/help.cgi?nlcom
lincom:
http://www.stata.com/help.cgi?lincom

Thank you,
Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] What packages have impute method ?

2008-12-12 Thread Daren Tan

Besides the impute package, are there others that have alternative impute 
approaches ? I hope to compare their performances. 
 
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.


Re: [R] character count

2008-12-12 Thread Ista Zahn
Thanks to everyone who responded. This turns out to be amazingly easy.
To count characters including spaces:
nchar(x)
To count characters excluding spaces:
nchar(gsub(" *","",x))

Thanks!

On Fri, Dec 12, 2008 at 11:00 AM, Petr PIKAL  wrote:
> Hi
>
>
> r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:
>
>> Dear list,
>> I have a variable that consists of typed responses. I wish to compute
>> a variable equal to the number of characters in the original variable.
>> For example:
>>
>> > x <- c("convert this to 32 because it has 32 characters", "this one
> has 22
>> characters", "12 characters")
>>
>> [Some magic function here]
>
> If you consider space as a character then
>
>  nchar(x)
>
> gives you the result.
>
> If not so such construction can do it
>
>  unlist(lapply(lapply(strsplit(x, " "), paste, collapse=""), nchar))
>
> Regards
> Petr
>
>>
>> > x
>> [1] 32 22 12
>>
>> Any ideas?
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] Odp: character count

2008-12-12 Thread Henrique Dallazuanna
Or :

 nchar(gsub("[[:space:]]", "", x))

On Fri, Dec 12, 2008 at 2:00 PM, Petr PIKAL  wrote:

> Hi
>
>
> r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:
>
> > Dear list,
> > I have a variable that consists of typed responses. I wish to compute
> > a variable equal to the number of characters in the original variable.
> > For example:
> >
> > > x <- c("convert this to 32 because it has 32 characters", "this one
> has 22
> > characters", "12 characters")
> >
> > [Some magic function here]
>
> If you consider space as a character then
>
>  nchar(x)
>
> gives you the result.
>
> If not so such construction can do it
>
>  unlist(lapply(lapply(strsplit(x, " "), paste, collapse=""), nchar))
>
> Regards
> Petr
>
> >
> > > x
> > [1] 32 22 12
> >
> > Any ideas?
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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.
>



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

[[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] Odp: character count

2008-12-12 Thread Gabor Grothendieck
On Fri, Dec 12, 2008 at 11:00 AM, Petr PIKAL  wrote:
> Hi
>
>
> r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:
>
>> Dear list,
>> I have a variable that consists of typed responses. I wish to compute
>> a variable equal to the number of characters in the original variable.
>> For example:
>>
>> > x <- c("convert this to 32 because it has 32 characters", "this one
> has 22
>> characters", "12 characters")
>>
>> [Some magic function here]
>
> If you consider space as a character then
>
>  nchar(x)
>
> gives you the result.
>
> If not so such construction can do it
>
>  unlist(lapply(lapply(strsplit(x, " "), paste, collapse=""), nchar))
>

or perhaps:

x <- "abc def"
nchar(gsub(" ", "", x)) # 6

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

2008-12-12 Thread Petr PIKAL
Hi


r-help-boun...@r-project.org napsal dne 12.12.2008 16:31:10:

> Dear list,
> I have a variable that consists of typed responses. I wish to compute
> a variable equal to the number of characters in the original variable.
> For example:
> 
> > x <- c("convert this to 32 because it has 32 characters", "this one 
has 22 
> characters", "12 characters")
> 
> [Some magic function here]

If you consider space as a character then

 nchar(x)

gives you the result.

If not so such construction can do it

 unlist(lapply(lapply(strsplit(x, " "), paste, collapse=""), nchar))

Regards
Petr

> 
> > x
> [1] 32 22 12
> 
> Any ideas?
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] The end of Matlab

2008-12-12 Thread Wacek Kusnierczyk
Claudia Beleites wrote:
>>> Wacek:
>>>   
 x[3:]
 instead of
 x[3:length(x)]
 x[3:end]
 
>>> I don't think that would help:
>>> what to use for end - 3 within the convention that negative values mean
>>> exclusion?
>>>   
>> might seem tricky, but not impossible:
>>
>> x[-2]
>> # could mean 'all except for 2nd', as it is now
>>
>> x[1:-2]
>> # could mean 'from start to the 2nd backwards from the end'
>> 
> I know you get thus far. You might even think to decide whether exclusion or 
> 'from the end' is meant from ascending ./. descending order of the sequence, 
> but this messes around with returning the reverse order.
>
>   

that's a design issue.  one simple solution is to have this sort of
indexing return always in ascending order.  thus,

x = 1:5
x[1:-1]
# 1 2 3 4 5
x[5:-5]
# NULL rather than 5 4 3 2 1 -- as in matlab or python

x[seq(5,1)]
# 5 4 3 2 1

that is, the ':'-based indexing can be made not to mess with the order. 
for reversing the order, why not use:

x[5:-1:1]
# 5 4 3 2 1

x[-3:-1:-5]
# 3 2 1 rather than x[c(-3,-4,-5)], which would be 1 2


>> since r disallows mixing positive and negative indexing, the above would
>> not be ambiguous.  worse with
>>
>> x[-3:-1]
>>
>> which could mean both 'except for 3rd, 2nd, and 1st' and 'from the 3rd
>> to the 1st from the end', and so would be ambiguous.  in this context,
>> indeed, having explicit 'end' could help avoid the ambiguity.
>> 
> that's the problem.
> also: how would 'except from the 5th last to the 3rd last' be expressed?
>   

for exclusions you'd need to use negative indices anyway:

x[seq(-5,-3)]

now, neither x[-5:-3] nor x[-3:-5] would do the job they do now, but the
above is not particularly longer, while selecting the
5th-to3rd-from-the-end columns is simply x[-5:-3] (which could be made
to fail on out-of-range indices) instead of something like x[length(x) -
4:2] (which will silently do the wrong thing if length(x) < 4, and thus
requires extra care).

this is a rather loose idea, and unrealistic in the context of r, but i
do not see much problem with it on the conceptual level.

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.


Re: [R] character count

2008-12-12 Thread Claudia Beleites

nchar (c("convert this to 47 because it has 47 characters", "this one has 26 
characters", "13 characters"))

HTH Claudia
-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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


Re: [R] ref card for data manipulation?

2008-12-12 Thread Vitalie Spinu

On Fri, 12 Dec 2008 12:43:17 +0100, Liviu Andronic  
wrote:



I'm not sure whether this can (partially) fill the gap, but Quick-R
[1] has a decent overview of data manipulation, and is essentially a
reference card. The maintainer of the Web site is open to
improvements, so it might make sense to contribute relevant
documentation to those pages.



Oh, well, I've completely forgotten about that beautiful site. Indeed, Robert has done an amazing job by creating that site. 
Anyway, we started something here http://wiki.r-project.org/rwiki/doku.php?id=guides:toolbox-data-manip and here http://wiki.r-project.org/rwiki/doku.php?id=guides:overview-data-manip


Hopefully something useful will emerge out of it. 
Feel free to contribute.


Vitalie.

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

2008-12-12 Thread Claudia Beleites
I just realized that my idea of doing something without going into the 
extraction functions itself won't work 
:-( it was a nice dream, though.

The reason is that there is no general way to find out what the needed length 
is: At least I'm just writing a class where 2 kinds of columns are involved. I 
don't give a dim attribute, though. But I could, and then: how to know how it 
should be interpreted?

> on the other hand, another possible solution would be to have ':' mean,
> inside range selection expressions, not the usual sequence generation,
> but rather specification of start and end indices:
...
> this is daydreaming, of course, because such modifications would break
> much old code,
nothing would break if some other sign instead of : would be used. Maybe 
something like "end"...

> and the benefit may not outweigh the effort.
This might be true in any case.

If I only think of how many lines of nrow, ncol, length & Co I could have 
written instead of posting wrong proposals

Claudia

-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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


[R] character count

2008-12-12 Thread Ista Zahn
Dear list,
I have a variable that consists of typed responses. I wish to compute
a variable equal to the number of characters in the original variable.
For example:

> x <- c("convert this to 32 because it has 32 characters", "this one has 22 
> characters", "12 characters")

[Some magic function here]

> x
[1] 32 22 12

Any ideas?

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

2008-12-12 Thread Gabor Grothendieck
Here is how to emulate matlab end in R in the case of matrices.

Rather than redefine the matrix class (which would be a bit intrusive) we
just define a subclass of matrix called matrix2.  Note in the examples that
matrix2 survives some operations such as + but not others such as crossprod
so in those one would have to coerce back to matrix2 using as.matrix2.


as.matrix2 <- function(x, ...) UseMethod("as.matrix2")

as.matrix2.default <- function(x, ...) {
   do.call(structure, list(x, ...,
   class = c("matrix2", setdiff(class(x), "matrix2"
}

matrix2 <- function(data, ...) as.matrix2(matrix(data, ...))

"[.matrix2" <- function(x, i, j, ...) {
i <- if (missing(i)) TRUE
else eval.parent(do.call(substitute, list(substitute(i), list(end = 
nrow(x)
j <- if (missing(j)) TRUE
else eval.parent(do.call(substitute, list(substitute(j), list(end = 
ncol(x)
.subset(x, i, j, ...)
}


> # test
> m <- matrix2(1:12, 3, 4)
> # matrix2 survives the + operation
> class(m+2)
[1] "matrix2" "matrix"

> # but not crossprod
> class(crossprod(m))
[1] "matrix"

> # coercing back
> as.matrix2(crossprod(m))
 [,1] [,2] [,3] [,4]
[1,]   14   32   50   68
[2,]   32   77  122  167
[3,]   50  122  194  266
[4,]   68  167  266  365
attr(,"class")
[1] "matrix2" "matrix"
>
> # example of using end
> m[2:end, 2:end]
 [,1] [,2] [,3]
[1,]58   11
[2,]69   12



On Thu, Dec 11, 2008 at 9:45 PM, Mike Rowe  wrote:
> Greetings!
>
> I come to R by way of Matlab.  One feature in Matlab I miss is its
> "end" keyword.  When you put "end" inside an indexing expression, it
> is interpreted as the length of the variable along the dimension being
> indexed.  For example, if the same feature were implemented in R:
>
> my.vector[5:end]
>
> would be equivalent to:
>
> my.vector[5:length(my.vector)]
>
> or:
>
> this.matrix[3:end,end]
>
> would be equivalent to:
>
> this.matrix[3:nrow(this.matrix),ncol(this.matrix)]   # or
> this.matrix[3:dim(this.matrix)[1],dim(this.matrix)[2]]
>
> As you can see, the R version requires more typing, and I am a lousy
> typist.
>
> With this in mind, I wanted to try to implement something like this in
> R.  It seems like that in order to be able to do this, I would have to
> be able to access the parse tree of the expression currently being
> evaluated by the interpreter from within my End function-- is this
> possible?  Since the "[" and "[[" operators are primitive I can't see
> their arguments via the call stack functions...
>
> Anyone got a workaround?  Would anybody else like to see this feature
> added to R?
>
> Thanks,
> Mike
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Eror handling with R

2008-12-12 Thread Sarah Goslee
Is try() what you're looking for?

Sarah

On Fri, Dec 12, 2008 at 5:43 AM,   wrote:
> Is there any way to handle errors retuened by R functions ... something like 
> the exception handling in C++ ?
>
> Thank you so much,
> Maura
>
> Alice Messenger ;-) chatti anche con gli amici di Windows Live Messenger e 
> tutti i telefonini TIM!
> Vai su http://maileservizi.alice.it/alice_messenger/index.html?pmk=footer
>


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

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


Re: [R] The end of Matlab

2008-12-12 Thread Claudia Beleites
> > Wacek:
> >> x[3:]
> >> instead of
> >> x[3:length(x)]
> >> x[3:end]
> >
> > I don't think that would help:
> > what to use for end - 3 within the convention that negative values mean
> > exclusion?
>
> might seem tricky, but not impossible:
>
> x[-2]
> # could mean 'all except for 2nd', as it is now
>
> x[1:-2]
> # could mean 'from start to the 2nd backwards from the end'
I know you get thus far. You might even think to decide whether exclusion or 
'from the end' is meant from ascending ./. descending order of the sequence, 
but this messes around with returning the reverse order.

> since r disallows mixing positive and negative indexing, the above would
> not be ambiguous.  worse with
>
> x[-3:-1]
>
> which could mean both 'except for 3rd, 2nd, and 1st' and 'from the 3rd
> to the 1st from the end', and so would be ambiguous.  in this context,
> indeed, having explicit 'end' could help avoid the ambiguity.
that's the problem.
also: how would 'except from the 5th last to the 3rd last' be expressed?

You won't get 2 independent things into one sign without trouble. 

Claudia

-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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


[R] DSC 2009: Now open for registration and abstract submission

2008-12-12 Thread Peter Dalgaard
Re. Workshop on Directions in Statistical Computing, Copenhagen 13-14
July 2009.

http://www.r-project.org/dsc-2009

The web interface for registration and submission of abstracts is now open.

(The site is still under construction in a number of respects. In
particular, we haven't negotiated discounts with any of the hotels yet.)


-- 
   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-annou...@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Extracting the name of an object into a character string and vice versa

2008-12-12 Thread Simon Pickett

paste()
?paste


- Original Message - 
From: "Philip Whittall" 

To: 
Sent: Friday, December 12, 2008 1:30 PM
Subject: Re: [R] Extracting the name of an object into a character string 
and vice versa





I am still struggling to map a character string to an object name and
vice versa in R.
I thought the as.name() function might work, but observe the following
behaviour ...


attach(warpbreaks)
levels(tension)

[1] "L" "M" "H"

levels(as.name("tension"))

NULL

objectname<-as.name("tension")
objectname

tension

levels(objectname)

NULL

So even though it sets up a symbol, this symbol isn't recognised as an
object name by functions such as levels().

I need 2 functions, call them A and B such that A("tension") yields the
object name tension which is recognised by functions and
B(tension) yields the character result "tension".

Any suggestions would be greatly appreciated,

Philip









This message should be regarded as confidential. If you have received this 
email in error please notify the sender and destroy it immediately.
Statements of intent shall only become binding when confirmed in hard copy 
by an authorised signatory.  The contents of this email may relate to 
dealings with other companies within the Detica Group plc group of 
companies.


Detica Limited is registered in England under No: 1337451.

Registered offices: Surrey Research Park, Guildford, Surrey, GU2 7YP, 
England.




[[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] setting the R_Libs gives warning message from Rgui.exe

2008-12-12 Thread Daren Tan

I have managed to get rid the two warning messages simply by uninstalling and 
installing again R. Very likely that I disrupted the installation of a large 
package. 

> Date: Fri, 12 Dec 2008 15:07:38 +0100
> From: lig...@statistik.tu-dortmund.de
> To: dare...@hotmail.com
> CC: r-h...@stat.math.ethz.ch
> Subject: Re: [R] setting the R_Libs gives warning message from Rgui.exe
> 
> 
> 
> Daren Tan wrote:
>> Hi, 
>> 
>> I keep getting the error message and a pop-up window for selecting CRAN 
>> mirror server from Rgui.exe after setting the R_Libs
>> 
>> Warning in install.packages(necessary[!installed], dep = T) :
>> argument 'lib' is missing: using 'D:/Program Files/R/R-2.8.0.libs'
> 
> This is a warning that R chooses the first library in the current list, 
> and this is obviously the one you intended, isn't it?
> 
>> --- Please select a CRAN mirror for use in this session ---
>> Error in contrib.url(repos, type) : 
> 
> This is the more interesting error. What is the whole message?
> You may have chosen a non-working mirror or your internet connectrion is 
> broken, or ...or... or
> ...
> 
> 
> Uwe Ligges
> 
> 
> 
>> 
>> I set the command for Rgui.exe to be 
>> "D:\Program Files\R\R-2.8.0\bin\Rgui.exe" --no-restore --no-save 
>> --max-mem-size 2000MB R_LIBS="D:/Program Files/R/R-2.8.0.libs"
>> 
>>> sessionInfo()
>> R version 2.8.0 (2008-10-20) 
>> i386-pc-mingw32 
>> locale:
>> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
>> States.1252;LC_MONETARY=English_United 
>> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>> attached base packages:
>> [1] stats graphics grDevices datasets utils methods base 
>> other attached packages:
>> [1] qvalue_1.1
>> loaded via a namespace (and not attached):
>> [1] tools_2.8.0
>> 
>> 
>> 
>> _
>> [[elided Hotmail spam]]
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] How to generate a prediction equation for a stratified survival model that was fitted by cph() in Design package

2008-12-12 Thread Yu, Changhong
Dear Dr. Harrell,

Thanks for response so quickly. Here is example code to illustrate the
problem.

> n <- 1000
> set.seed(731)
> age <- 50 + 12*rnorm(n)
> label(age) <- "Age"
> sex <- factor(sample(c('Male','Female'), n,
+   rep=TRUE, prob=c(.6, .4)))
> cens <- 15*runif(n)
> h <- .02*exp(.04*(age-50)+.8*(sex=='Female'))
> dt <- -log(runif(n))/h
> label(dt) <- 'Follow-up Time'
> e <- ifelse(dt <= cens,1,0)
> dt <- pmin(dt, cens)
> units(dt) <- "Year"
> dat <- data.frame(dt,e,age,sex)
> dd <- datadist(dat)
> options(datadist='dd')
> f1 <- cph( Surv(dt,e) ~ rcs(age,4) + sex, data=dat,x=TRUE, y=TRUE,
surv=TRUE)
> f2 <- cph( Surv(dt,e)~ age + strat(sex), data=dat, x=TRUE,
y=TRUE,surv=TRUE)
> Function(f1) # works well
function(age = 48.800654,sex = "Male") {0.28612987-0.017321951*
age+0.00012586581*pmax(age-29.600456,0)^3-0.00046285671*pmax(age-44.2731
98,0)^3+0.00042111763*pmax(age-53.769262,0)^3-8.4126731e-05*pmax(age-69.
855597,0)^3-0.64448916*(sex=="Male") }

> Function(f2)
Error in Nam[[i]] : subscript out of bounds

I am using Windows R ( version 2.6.0 2007-10-03).

Best regards,

Changhong Yu

-Original Message-
From: Frank E Harrell Jr [mailto:f.harr...@vanderbilt.edu] 
Sent: Thursday, December 11, 2008 6:58 PM
To: Yu, Changhong
Cc: r-help@r-project.org
Subject: Re: [R] How to generate a prediction equation for a stratified
survival model that was fitted by cph() in Design package

Yu, Changhong wrote:
> Dear all,
> 
> I used cph() function from Frank harrell's Design package to create a
> survival model, then used functions 'Function' and 'sascode' to
generate
> prediction equation based on the saved survival model. But it failed.
I
> included a stratified variable in the model. If I removed the
> stratification, they were working well. Does that mean that function
> 'Function' doesn't accept a stratified model?

It is supposed to work for that case.  Please send trivial example code 
with data defined in the code that replicates the problem you are 
seeing, and I'll debug.

Frank

> 
> Any thoughts on this will be appreciated. Thanks.
> 
> 
> Changhong
> 
> ===
> 
> P Please consider the environment before printing this e-mail
> 
> Cleveland Clinic is ranked one of the top hospitals
> in America by U.S. News & World Report (2008).  
> Visit us online at http://www.clevelandclinic.org for
> a complete listing of our services, staff and
> locations.
> 
> 
> Confidentiality Note:  This message is intended for
use\...{{dropped:13}}
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt
University



P Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2008).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use\...{{dropped:13}}

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

2008-12-12 Thread Celine Carret

Dear All,

Apologies for sending this email to both list, but at this point I'm not
sure which one could help me the most.

I have 4 sets of data, 1 test and 3 different sets of controls.
The measurements are binary, with a matrix of 0 and 1
I'm measuring across time (rows, ~815) the behaviour of organelles in
the cell by microscopy in response to different stimuli (several
measurements for each set, 57 columns in total)
Set 1: parasite test
Set 2: no stimulus
Set 3: inert stimulus (beads)
Set 4: different pathogen
Across time, a "zero" means nothing happens around my parasite
introduced in the cell, a "1" means some cytoskeleton dynamics occurring
around my parasite
I want to give some statistical value to my observations in saying that
the cytoskeleton dynamics are specific to my parasite at that frequency
across time.

I thought of comparing profiles, like a smooth profile to summarise all
that is happening in each set and test for distances between 2 smoothed
sets. But the timig when something is happening varies a lot, sometimes
it's few seconds, sometimes minutes, sometimes only once per
measurements, sometimes more for the same parasite..
I'm not sure how to proceed.

I have been looking into e1071 package in R for support vector machine,
but I'm not sure this will give me the right model.

I am very grateful for any help / advice anyone can think of

Thank you very much
Celine




-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE.

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

2008-12-12 Thread mauede
Is there any way to handle errors retuened by R functions ... something like 
the exception handling in C++ ?

Thank you so much,
Maura 

Alice Messenger ;-) chatti anche con gli amici di Windows Live Messenger e 
tutti i telefonini TIM!
Vai su http://maileservizi.alice.it/alice_messenger/index.html?pmk=footer

[[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] preprocessCore

2008-12-12 Thread irene . vicari


Bonjour!
Je suis en train de faire un projet utilisant Affymatrix mais j'ai un problème à
télécharger un package depuis R: une fois que je télécharge le package et je
demande de faire "rma" ca sort l'erreur suivante et je n'ai aucune idée de
comment je pourrais faire.

> library(preprocessCore)
> plac.rma <- rma(plac.new)
Background correcting
Normalizing
Calculating Expression
Errore in rma(plac.new) :
  function 'R_subColSummarize_medianpolish_log' not provided by package
'preprocessCore'

Est-ce que vous avez un conseil à me donner? J'ai un projet à finir et je suis
complètement bloquée :(

Merci d'avance,
Irene Vicari

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

2008-12-12 Thread qroberts

Thanks very much for the replies.

Both suggestions worked perfectly.

That's one more step towards understanding R.

Thanks again.


-- 
View this message in context: 
http://www.nabble.com/Row-order-in-plot-tp20962774p20974800.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How-To capture and handle errors with R

2008-12-12 Thread mauede
The following error occurs every now and then by calling a function of wmTSA 
package:

Error in `row.names<-.data.frame`(`*tmp*`, value = c("1", "0")) : 
  invalid 'row.names' length

I would greatly appreciate some guidelines about how to catch such an error 
upon its occurrence and have it handled by my own routine 
rather than letting R stop the currently run script.
I had a look a the R on-line documentation about errors handler and also ran 
some provided examples that confused my mind.
The error is in textual form. I do not know whether I have to pass the whole 
message to the handler.
When such an exception occurs the execution control is not transferred to my 
routine.
I would like to see a working example.

Thank you so much,
Maura 


Alice Messenger ;-) chatti anche con gli amici di Windows Live Messenger e 
tutti i telefonini TIM!
Vai su http://maileservizi.alice.it/alice_messenger/index.html?pmk=footer

[[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] Please help me in Converting this from C# to R [C1]

2008-12-12 Thread Taoufik NADIFI
Please, can you tell me if you know how can i use the library Igraph in C# 
?

Thanks
Nadifi Taoufik
*
This message and any attachments (the "message") are con...{{dropped:15}}

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

2008-12-12 Thread Wacek Kusnierczyk

>> Wacek:
>>   
>> 
>>> x[3:]
>>> instead of
>>> x[3:length(x)]
>>> x[3:end]
>>> 
>>>   
>> I don't think that would help: 
>> what to use for end - 3 within the convention that negative values mean 
>> exclusion?
>>
>>
>>   
>> 
>
> might seem tricky, but not impossible:
>
> x[-2]
> # could mean 'all except for 2nd', as it is now
>
> x[1:-2]
> # could mean 'from start to the 2nd backwards from the end'
>
> since r disallows mixing positive and negative indexing, the above would
> not be ambiguous.  worse with
>
> x[-3:-1]
>
> which could mean both 'except for 3rd, 2nd, and 1st' and 'from the 3rd
> to the 1st from the end', and so would be ambiguous.  in this context,
> indeed, having explicit 'end' could help avoid the ambiguity.
>
>   

on the other hand, another possible solution would be to have ':' mean,
inside range selection expressions, not the usual sequence generation,
but rather specification of start and end indices:

x[1:2]
# from 1st to 2nd, inclusive

x[seq(1,2)]
# same as above

x[c(1,2)]
# same as above

x[1:-2]
# from 1st to 2nd from the end, not x[c(1,0,-1,-2)]

x[seq(1,-2)]
# no way, mixed indices

x[-2:-1]
# from 2nd to 1st, both from the end, not x[c(-2,-1)]

x[length(x) + -1:0]
# same as above

x[seq(-2,-1)]
# except for 2nd and 1st

x[c(-2,-1)]
# same as above

x[2:]
# from 2nd up

x[seq(2, max(2, length(x)))]
# same as above (would not be without max)

x[:3]
# up to 3rd

x[seq(1,3)]
# same as above

x[:-3]
# up to 3rd from the end

x[seq(1, length(x)-2)]
# same as above

with additional specifications for the behaviour in case of invalid
indices and decreasing indices:

x[2:1]
# from the 2nd to the 1st, in reverse order
# or nothing, invalid indexing

which can be easily done with the unambiguous x[seq(2,1)] or x[c(2,1)]

this is daydreaming, of course, because such modifications would break
much old code, and the benefit may not outweigh the effort.

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.


Re: [R] assign()ing within apply

2008-12-12 Thread Thompson, David (MNR)
Any tips?
 
DaveT.
>-Original Message-
>From: Thompson, David (MNR) 
>Sent: December 9, 2008 04:03 PM
>To: 'r-help@r-project.org'
>Subject: assign()ing within apply
>
>Hello,
>
>I'm trying to convert a character column in several dataframes 
>to lower case.
>
>###
>#
># Sample data and 'spp' column summaries:
># dput(ban.ovs.1993[sample(row.names(ban.ovs.1993), 20), 1:4])
>ban.ovs.93 <- structure(list(oplt = c(43L, 43L, 38L, 26L, 35L, 
>8L, 39L, 1L, 
>34L, 50L, 10L, 29L, 31L, 24L, 18L, 12L, 27L, 49L, 28L, 51L), 
>rplt = c(NA_integer_, NA_integer_, NA_integer_, NA_integer_, 
>NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, 
>NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, 
>NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, 
>NA_integer_), tree = c(427L, 410L, 639L, 494L, 649L, 166L, 
>735L, 163L, 120L, 755L, 612L, 174L, 129L, 331L, 269L, 152L, 
>552L, 227L, 243L, 96L), spp = c("MH", "MST", "MH", "HE", 
>"BE", "MH", "MH", "MH", "MH", "Or", "IW", "Or", "MH", "MH", 
>"BY", "MH", "MH", "BE", "MH", "MR")), .Names = c("oplt", 
>"rplt", "tree", "spp"), row.names = c(4587L, 4570L, 3947L, 2761L, 
>3653L, 652L, 4136L, 64L, 3567L, 5318L, 838L, 3091L, 3366L, 2423L, 
>1775L, 1061L, 2893L, 5161L, 2967L, 5395L), class = "data.frame")
>
># dput(pem.ovs.1994[sample(row.names(pem.ovs.1994), 20), 1:4])
>pem.ovs.94 <- structure(list(oplt = c(8L, 17L, 36L, 9L, 31L, 
>11L, 35L, 51L, 
>51L, 49L, 40L, 1L, 9L, 17L, 4L, 42L, 6L, 3L, 39L, 25L), tree = c(531L, 
>557L, 546L, 261L, 592L, 134L, 695L, 933L, 945L, 114L, 34L, 54L, 
>549L, 574L, 193L, 96L, 70L, 4L, 546L, 789L), spp = c("MH", "MH", 
>"MH", "BF", "BF", "MH", "IW", "OR", "OR", "BF", "MH", "IW", "OR", 
>"MH", "SM", "BE", "BE", "BE", "OR", "OR"), oaz = c(38L, 205L, 
>140L, 277L, 329L, 209L, 222L, 24L, 67L, 187L, 156L, 181L, 174L, 
>248L, 42L, 279L, 273L, 357L, 160L, 183L)), .Names = c("oplt", 
>"tree", "spp", "oaz"), row.names = c(1204L, 2943L, 5790L, 1616L, 
>5063L, 2013L, 5691L, 8188L, 8200L, 7822L, 6302L, 54L, 1698L, 
>2960L, 421L, 6690L, 775L, 245L, 6205L, 4121L), class = "data.frame")
>
># count per spp
>invisible(lapply(ls(pat='ovs'), function(y) { cat(y, "\n")  ; 
>print(summary.factor(get(y)[,'spp'])) ; cat("\n") } ) )
>ban.ovs.93 
>BE  BY  HE  IW  MH  MR MST  Or 
> 2   1   1   1  11   1   1   2 
>
>pem.ovs.94 
>BE BF IW MH OR SM 
> 3  3  2  6  5  1 
>#
>###
>
>I have tried variants on the following and cannot remember how 
>to have the result assign()ed back to the original dataframes.
>lapply(ls(pat='ovs'), function(y) { assign(paste(y, 
>"[,'spp']", sep=""), tolower(get(y)[,'spp'])) } )
>
>I *do* get the expected results:
>[[1]]
> [1] "mh"  "mst" "mh"  "he"  "be"  "mh"  "mh"  "mh"  "mh"  
>"or"  "iw"  "or"  "mh"  "mh"  "by"  "mh"  "mh"  "be"  "mh"  "mr" 
>
>[[2]]
> [1] "mh" "mh" "mh" "bf" "bf" "mh" "iw" "or" "or" "bf" "mh" 
>"iw" "or" "mh" "sm" "be" "be" "be" "or" "or"
>
>, I just can't remember how to get them back into the original 
>dataframe objects. Suggestions?
>
>Thanx, DaveT.
>*
>Silviculture Data Analyst
>Ontario Forest Research Institute
>Ontario Ministry of Natural Resources
>david.john.thomp...@ontario.ca
>http://ontario.ca/ofri
>*

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

2008-12-12 Thread Duncan Murdoch

On 12/12/2008 8:25 AM, hadley wickham wrote:

From which you might conclude that I don't like the design of subset, and
you'd be right.  However, I don't think this is a counterexample to my
general rule.  In the subset function, the select argument is treated as an
unevaluated expression, and then there are rules about what to do with it.
 (I.e. try to look up name `a` in the data frame, if that fails, ...)

For the requested behaviour to similarly fall within the general rule, we'd
have to treat all indices to all kinds of things (vectors, matrices,
dataframes, etc.) as unevaluated expressions, with special handling for the
particular symbol `end`.


Except you wouldn't have to necessarily change indexing - you could
change seq instead.  Then 5:end could produce some kind of special
data structure (maybe an iterator) that was recognised by the various
indexing functions. 


Ummm, doesn't that require changes to *both* indexing and seq?


This would still be a lot of work for not a lot
of payoff, but it would be a logically consistent way of adding this
behaviour to indexing, and the basic work would make it possible to
develop other sorts of indexing, eg df[evens(), ], or df[last(5),
last(3)].


I agree:  it would be a nice addition, but a fair bit of work.  I think 
it would be quite doable for the indexable things in the base packages, 
but there are a lot of contributed packages that define [ methods, and 
those methods would all need to be modified too.


(Just to be clear, when I say doable, I'm thinking that your iterators 
return functions that compute subsets of index ranges.  For example, 
evens() might be implemented as


evens <- function() {
  result <- function(indices) {
indices[indices %% 2 == 0]
  }
  class(result) <- "iterator"
  return(result)
}

and then `[` in v[evens()] would recognize that it had been passed an 
iterator, and would pass 1:length(v) to the iterator to get the subset 
of even indices.  Is that what you had in mind?)


Duncan

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

2008-12-12 Thread Richardson, Patrick
I have asked the maintainer for a fix and didn't get a reply, which is why I 
posted to the list to see if there were any other ideas.

Sorry to bother. . . with my warning message.

Patrick


-Original Message-
From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
Sent: Friday, December 12, 2008 9:34 AM
To: Richardson, Patrick
Cc: 'r-help@r-project.org'
Subject: Re: [R] Error message when starting TINN-R

And the *Error* message was (that was a warning)?

The warning comes from some contributed code, probably in Tinn-R.  Please
find out where it is and ask the maintainer for a fix.  But it looks
harmless enough.

On Fri, 12 Dec 2008, Richardson, Patrick wrote:

> When R starts I get the following error message
>
> Warning message:
> In grep(paste("[{]TclEval ", topic, "[}]", sep = ""), tclvalue(.Tcl("dde 
> services TclEval {}")), :
> argument 'useBytes = TRUE' will be ignored
>
> Has anyone else run into this issue and is there any way to can fix this?
>
> Thanks,
>
> Patrick
>
>
>
> This email message, including any attachments, is for ...{{dropped:27}}

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

2008-12-12 Thread Wacek Kusnierczyk
Claudia Beleites wrote:
> Am Freitag 12 Dezember 2008 13:10:20 schrieb Patrick Burns:
>   
>> How about:
>>
>> x[, -seq(to=ncol(x), length=n)]
>> 
> Doing it is not my problem. I just agree with Mike in that I would like if I 
> could do shorter than: 
>
> x[, 1 : (ncol(x) - n)] 
>
> which I btw prefer to your solution.
>
> Also, I don't have a problem writing generalized versions of head and tail to 
> work along other/more dimensions. Or a combined function, taking first and 
> last 
> arguments. 
>
> Still, they would not be as convenient to use as matlab's:
> 3 : end - 4
> which btw. also does not need parentheses.
>
> I guess the general problem is that there is only one thing with integers 
> that 
> can easily be (ab)used as a flag: the negative sign. 
>
> But there are (at least) 2 possibly useful special ways of indexing: 
> - exclusion (as in R)
> - using -n for end - n (as in perl)
>
> Now we enjoy having a shortcut for exclusion (at least I do), but still feel 
> that marking "from the end" would be useful.
>
> As no other signs (in the sense of flag) are available for integers, we won't 
> be able to stop typing somewhat more in R.
>
> Wacek:
>   
>> x[3:]
>> instead of
>> x[3:length(x)]
>> x[3:end]
>> 
> I don't think that would help: 
> what to use for end - 3 within the convention that negative values mean 
> exclusion?
>
>
>   

might seem tricky, but not impossible:

x[-2]
# could mean 'all except for 2nd', as it is now

x[1:-2]
# could mean 'from start to the 2nd backwards from the end'

since r disallows mixing positive and negative indexing, the above would
not be ambiguous.  worse with

x[-3:-1]

which could mean both 'except for 3rd, 2nd, and 1st' and 'from the 3rd
to the 1st from the end', and so would be ambiguous.  in this context,
indeed, having explicit 'end' could help avoid the ambiguity.


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.


Re: [R] Error message when starting TINN-R

2008-12-12 Thread Prof Brian Ripley

And the *Error* message was (that was a warning)?

The warning comes from some contributed code, probably in Tinn-R.  Please 
find out where it is and ask the maintainer for a fix.  But it looks 
harmless enough.


On Fri, 12 Dec 2008, Richardson, Patrick wrote:


When R starts I get the following error message

Warning message:
In grep(paste("[{]TclEval ", topic, "[}]", sep = ""), tclvalue(.Tcl("dde services 
TclEval {}")), :
argument 'useBytes = TRUE' will be ignored

Has anyone else run into this issue and is there any way to can fix this?

Thanks,

Patrick



This email message, including any attachments, is for ...{{dropped:19}}


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

2008-12-12 Thread Richardson, Patrick
When R starts I get the following error message

Warning message:
In grep(paste("[{]TclEval ", topic, "[}]", sep = ""), tclvalue(.Tcl("dde 
services TclEval {}")), :
argument 'useBytes = TRUE' will be ignored

Has anyone else run into this issue and is there any way to can fix this?

Thanks,

Patrick



This email message, including any attachments, is for th...{{dropped:9}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fwd: Re: The end of Matlab (sorry, I messed up a sentence)

2008-12-12 Thread Claudia Beleites
--  Weitergeleitete Nachricht  --

Betreff: Re: [R] The end of Matlab
Datum: Freitag 12 Dezember 2008
Von: Claudia Beleites 
An: r-help@r-project.org

Am Freitag 12 Dezember 2008 13:10:20 schrieb Patrick Burns:
> How about:
>
> x[, -seq(to=ncol(x), length=n)]
Doing it is not my problem. I just agree with Mike in that I would like if I 
could do shorter than: 

x[, 1 : (ncol(x) - n)] 

which I btw prefer to your solution.

Also, I don't have a problem writing generalized versions of head and tail to 
work along other/more dimensions. Or a combined function, taking "head-n" and 
"tail-n" arguments. 

Still, they would not be as convenient to use as matlab's:
3 : end - 4
which btw. also does not need parentheses.

I guess the general problem is that there is only one thing with integers that 
can easily be (ab)used as a flag: the negative sign. 

But there are (at least) 2 possibly useful special ways of indexing: 
- exclusion (as in R)
- using -n for end - n (as in perl)

Now we enjoy having a shortcut for exclusion (at least I do), but still feel 
that marking "from the end" would be useful.

As no other signs (in the sense of flag) are available for integers, we won't 
be able to stop typing somewhat more in R.

Wacek:
> x[3:]
> instead of
> x[3:length(x)]
> x[3:end]
I don't think that would help: 
what to use for end - 3 within the convention that negative values mean 
exclusion?




--- now I start "dreaming" ---

However, it is possible to define new binary operators (operators are great for 
lazy typing...).

Let's say %:% should be a new operator to generate proper indexing sequences 
to be used inside "[" :
e.g. an.array [ 1:3, -2 %:% -5, ...]

If we now find an.array which is x inside "[" (and also inside "[[") - which is 
possible but maybe a bit fiddly

and if we can also find out which of the indices is actually evaluated (which I 
don't know how to do)

then we could use something* as a flag for "from the end" and calculate the 
proper sequence.

something* could e.g. be 
either an attribute to the operators (convenient if we can define an unary 
operator that allows setting it, e.g. § 3 [§ is the easy-to-type sign on my 
keyboard that is not yet used...])

or i (the imaginary one) if there is no other convenient unary operator e.g. 
3i

=> 
easy part of the solution:
make.index <- function (x, along.dim = 1, from, to){
if (is.null (dim (x)))
   dim <- length (x)
else 
  dim <- dim (x)[along.dim]

if (is.complex (from)){
from <- dim - from # 0i means end
## warning if re (from) != 0 ?
}
if (is.complex (to)){
to <- dim - to # 0i means end
## warning if re (to) != 0 ?
}
   
from : to
}

"%:%" <- function (e1, e2)  ## using a new operator does not mess up ":"
make.index (x = find.x (), along.dim = find.dim (), e1, e2)

now, the heavy part are the still missing find.x () and find.dim () functions...

I'm not sure whether this would be worth the work, but maybe someone is around 
who just knows how to do this.


Claudia

-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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

---
-- 
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 (0 40) 5 58-34 47
email: cbelei...@units.it

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


  1   2   >