Re: [R] xts dates spacings

2009-10-02 Thread devol

Please also find below an example of what I meant (and sorry that I forgot to
do it before)

> class(thedata)
[1] "xts" "zoo"
> thedata
 thecolumn
2009-09-24 18:44:00  -60.34653
2009-09-24 18:45:00  -70.34653
2009-09-24 19:10:00  389.65347
2009-09-24 19:13:00  526.18462
2009-09-24 19:20:00  595.88177
2009-09-24 19:23:00  391.21376
2009-09-24 19:24:00  129.44164
2009-09-24 19:26:00  487.51082
2009-09-24 19:28:00  548.75286
2009-09-24 19:30:00  738.88320
2009-09-24 19:38:00  296.21436
2009-09-24 19:47:00  505.88466
2009-09-24 19:48:00  394.64898
2009-09-24 19:50:00  441.44369
2009-09-24 20:11:00  456.95179
2009-09-25 10:31:00 -483.92521
2009-09-25 10:32:00 -821.79402
2009-09-25 10:33:00 -382.56616
2009-09-25 10:34:00  121.78882
2009-09-25 10:35:00 -138.87696
2009-09-25 10:36:00 -319.00630
2009-09-25 10:37:00 -352.86793
2009-09-25 10:38:00 -180.49100
2009-09-25 10:39:00  -98.86423
2009-09-25 10:40:00 -158.06193
2009-09-25 10:41:00 -132.81620
> 

And it look in my R in the following way

http://www.nabble.com/file/p25725969/spacespicture.png 

The question is how to remove the space btw the dates.

Thanks!


devol wrote:
> 
> Hello!
> 
>   Please help - can't find any options how to remove very big spaces
> between two dates containing intraday prices plotted by plot.xts. It looks
> like the following: on the left side of the plot window is the first bunch
> of points, the same is for the right hand side and a long line connecting
> them in the middle. I would want to merge them (cut spaces) somehow.
> 
> In any case thanks for help.
> 
> Alex
> 

-- 
View this message in context: 
http://www.nabble.com/xts-dates-spacings-tp25721103p25725969.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] Time Series

2009-10-02 Thread Kon Knafelman

Hi,

Im trying to perform a time series analysis on financial data. Im going on the 
assumption that it follows the random walk, and therefore am fitting an ARIMA 
process via the following code fit<-arima(exchange,order=c(0,1,0)), and then 
analysing the tsdiag.

Is there a more efficient way of doing this? or can i get R to automatically 
give the most efficient p,d,q values for the model itself?

Thanks a lot, any point in the right direction would be greatly appreciated.


  
_


[[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] getting variables based on name

2009-10-02 Thread William Doane

This turns out to be quite easy...

Given:


> head(data)
  inst a1 a2 a3 a4 a5 a6 a7 a8 escore
11  1  1  0  1  1  0  0  0  4
21  0  1  0  0  0  0  0  0  1
31  1  0  0  1  0  1  1  1  2
41  0  1  0  0  0  1  0  0  1

You can use grep on the names of the columns in data


> # returns the column numbers of cols that begin with "a"
> grep("^a", names(data)) 
[1] 2 3 4 5 6 7 8 9

> data[,grep("^a", names(data))]
a1 a2 a3 a4 a5 a6 a7 a8
11  1  0  1  1  0  0  0
20  1  0  0  0  0  0  0
31  0  0  1  0  1  1  1
40  1  0  0  0  1  0  0
50  0  0  0  0  1  0  0

and, of course, you can use any regular expression you like.

-Wil

-- 
View this message in context: 
http://www.nabble.com/getting-variables-based-on-name-tp25725837p25725951.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


Re: [R] Multiple time series and their names

2009-10-02 Thread Gabor Grothendieck
zoo objects can have one column with a heading and convert back
faithfully to ts:

> library(zoo)
> as.zoo(x)[, 1, drop = FALSE]
Juan
1(1) -0.37415224
1(2) -0.30875111
1(3) -0.02617545
1(4) -0.45053564
2(1)  0.15173749
2(2)  1.38545761
2(3)  2.11594058
2(4) -0.84970010
3(1) -0.05944844
3(2)  1.27543030
> tsp(x)
[1] 1.00 3.25 4.00
> tsp(as.ts(as.zoo(x)))
[1] 1.00 3.25 4.00


On Fri, Oct 2, 2009 at 11:15 PM, David Stoffer  wrote:
>
> Suppose I have multiple time series with names for each one, for example,
>
> x <- ts(matrix(rnorm(30,0,1),10,3), names=c("Juan", "Tuey", "Trey"),
> frequency=4)
>
> So now, as I start to explore these series, if I do everything at once, the
> names
> stay attached to the series.  For example,
> plot(x) # gives a plot of the series with their names
> acf(x)  # gives the ACFs & CCFs with names attached
>
> But if I want to explore what's going on with Juan, from what I can gather,
> I have to do something like this
> plot(x[,1])
> (or acf(x[,1])... or similar things) but this doesn't keep the name Juan.
>
> My question: Is there a way, without making a data frame [which seems to
> destroy the
> time series attributes(??) - this seems to be the only answer I can find on
> Rhelp]
> that allows me to keep track of the names?  That way, for example, I don't
> have to
> remember that the 18th series is Martha.
>
> x$Juan, x$Tuey, x$Trey, would be nice ... but that doesn't work.
>
> Thanks in advance.
>
>
> -
> The power of accurate observation is commonly called cynicism
> by those who have not got it.  George Bernard Shaw
> --
> View this message in context: 
> http://www.nabble.com/Multiple-time-series-and-their-names-tp25725411p25725411.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] Multiple time series and their names

2009-10-02 Thread David Stoffer

Suppose I have multiple time series with names for each one, for example,

x <- ts(matrix(rnorm(30,0,1),10,3), names=c("Juan", "Tuey", "Trey"),
frequency=4)

So now, as I start to explore these series, if I do everything at once, the
names
stay attached to the series.  For example,
plot(x) # gives a plot of the series with their names
acf(x)  # gives the ACFs & CCFs with names attached

But if I want to explore what's going on with Juan, from what I can gather, 
I have to do something like this
plot(x[,1])
(or acf(x[,1])... or similar things) but this doesn't keep the name Juan.

My question: Is there a way, without making a data frame [which seems to
destroy the
time series attributes(??) - this seems to be the only answer I can find on
Rhelp] 
that allows me to keep track of the names?  That way, for example, I don't
have to 
remember that the 18th series is Martha.  

x$Juan, x$Tuey, x$Trey, would be nice ... but that doesn't work.

Thanks in advance.


-
The power of accurate observation is commonly called cynicism 
by those who have not got it.  George Bernard Shaw
-- 
View this message in context: 
http://www.nabble.com/Multiple-time-series-and-their-names-tp25725411p25725411.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] Problem using with panel.average in Lattice package

2009-10-02 Thread Mark Dalphin

Hi,

I'm having a problem getting the panel.average function to work as I
expect it to in a lattice plot. I wish to draw lines between the
averages of groups of y-values at specific x-values. I have created a
dataset below which is similar to my real data. I also show an example
of using panel.loess in place of panel.average; it performs in a
manner similar to what I want panel.average to do except it shows a
loess line rather than a straight line connecting the means of the
groups.

Please see my coded examples, below.

Regards,
Mark Dalphin

=
My system information:


library(lattice)
print(sessionInfo())
R version 2.9.1 (2009-06-26) 
i686-pc-linux-gnu 


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

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


other attached packages:
[1] lattice_0.17-25

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

##--
## This dataset is too complicated, but it does show the type of plot I want.
##
## Create a fake qPCR dataset: Eight 96-well plates over 4 days (2 per day),
## 2 genes per plate (multiplexed), and 4 "Hi" positive control and
## 4 "Lo" positive controls per plate.
## Create the experimental data; by rights it is all identical, expect for
## experimental errors with in days and between days.
## For this simulation, each gene will be given a base value.
## In qPCR the higher the "Ct" value, the lower the concentration.
library(lattice)  # Add for ease of cut-n-paste of this code
date  <- c('2009-09-07', '2009-09-08', '2009-09-10', '2009-09-14')
probe <- c('Gene.A1', 'Gene.A2', 'Gene.B1', 'Gene.B2')
conc  <- c('Lo', 'Hi')
base.lo <- c(Gene.A1=29, Gene.A2=25, Gene.B1=28, Gene.B2=31)
base.hi <- base.lo - 8
day.err <- c(Day.1=0, Day.2=1, Day.3=1.5, Day.4=1.0)

d <- data.frame()
for(i in seq(along=date)) {
   for(j in seq(along=probe)) {
   for(k in seq(along=conc)) {
d <- rbind(d, data.frame(Date=rep(date[i], length=4),
Probe=rep(probe[j], length=4),
Conc=rep(conc[k], length=4),
Ct=rnorm(4, sd=0.5) + (k-1)*8 + base.hi[j] 
+ day.err[i]
))
   }
   }
}
d$Date <- as.POSIXct(d$Date)

##--
## Example 1
## Print with LOESS line showing the 'means' for the groups.
## This is close, but I don't want a loess line; I want straight lines
## between mean values.
print(xyplot(Ct ~ Date|Probe, group=Conc, data=d,
panel="panel.superpose",	  
panel.groups=function(x, y, ...) {

panel.loess(x, y, ...)
panel.xyplot(x, y, ...)
},
auto.key=TRUE))

##--
## Example 2
## Parallel construction to the loess example, above.
## Note the loss of the lines. The 'horizontal' default
## is different between 'panel.loess' and 'panel.average'.
print(xyplot(Ct ~ Date|Probe, group=Conc, data=d,
panel="panel.superpose",
panel.groups=function(x, y, ...) {
panel.average(x, y, horizontal=FALSE, ...)
panel.xyplot(x, y, ...)
},
auto.key=TRUE))

##--
## Example 3
## Don't pass along the '...' to the panel.average. Now I
## get lines, but not matching colours to the points.
print(xyplot(Ct ~ Date|Probe, group=Conc, data=d,
panel="panel.superpose",
panel.groups=function(x, y, ...) {
panel.average(x, y, horizontal=FALSE)
panel.xyplot(x, y, ...)
},
auto.key=TRUE))

##**
Main question:

I want to create a plot that looks like Example 3, but with the
coloured lines of Example 1. Suggestions? I've looked in RSiteSearch()
for both "panel.average" and "panel.linejoin" but found nothing addressing
this.

Side question:

I also read the source code to panel.average, panel.loess and
panel.superpose.  Which leads to a side question; how do I determine
what parameters are being passed within '...'? I tried recreating my
panel.groups function above as an explicit (non-anonymous) function
and using debug() on it, but running formals() within that debugging session
didn't seem to show me the huge list of arguments from
panel.superpose, "do.call(panel.groups, args)", coming into my panel
function. Is there some way to "see" these arguments?

##**


___

Re: [R] loop problem

2009-10-02 Thread David Winsemius


On Oct 2, 2009, at 7:34 AM, crenial30 wrote:



Thanks a lot David for your answer. I am sorry for being so minimal.

I wanted to produce a list/vector/table consisting each vector  
produced from

this code

len<-20
for (n1 in seq(0,(len-1),by=1)){

f <- R_event[R_event > (rx[1]+ n1*300)& R_event <= (rx[1] +  
300*(n1+1))]

//create list for each values of n1


That throws an error:
f <- R_event[R_event > (rx[1]+ n1*300)& R_event <= (rx[1] + 300*(n1+1))]
+ //create list for each values of n1
Error: syntax error

Plus... even if it were syntactically correct, we are not going to  
know what R_event is.


Try posting code that creates a data situation and then express in  
English (not mangled R) what you want to happen.





R_ev_char <- as.character(f)

lis01 <- c(length(R_ev_char)) // here I want to store the values of  
lengths

of R_ev_char vector for successive values of n1(0,1,2,3,...20)

I already tried with vector notation but no help.

I just want to store Lengths on each successive  integer so that I  
can draw

the list on 300(secs) interval.

Any suggestion would be very much helpful.
crenial


crenial30 wrote:


I have the following code which I wanted to convert using for loop

previous code:
R_ev1 <- R_event[R_event > (rx[1] + 300*0)& R_event <= (rx[1] +  
300*1)]
R_ev2 <- R_event[R_event > (rx[1] + 300*1)& R_event <= (rx[1] +  
300*2)]
R_ev3 <- R_event[R_event > (rx[1] + 300*2)& R_event <= (rx[1] +  
300*3)]
R_ev4 <- R_event[R_event > (rx[1] + 300*3)& R_event <= (rx[1] +  
300*4)]


R_ev5 <- R_event[R_event > (rx[1] + 300*4)& R_event <= (rx[1] +  
300*5)]
R_ev6 <- R_event[R_event > (rx[1] + 300*5)& R_event <= (rx[1] +  
300*6)]
R_ev7 <- R_event[R_event > (rx[1] + 300*6)& R_event <= (rx[1] +  
300*7)]
R_ev8 <- R_event[R_event > (rx[1] + 300*7)& R_event <= (rx[1] +  
300*8)]


R_ev9 <- R_event[R_event  > (rx[1] + 300*8)& R_event <= (rx[1] +  
300*9)]
R_ev10 <- R_event[R_event > (rx[1] + 300*9)& R_event <= (rx[1] +  
300*10)]
R_ev11 <- R_event[R_event > (rx[1] + 300*10)& R_event <= (rx[1] +  
300*11)]
R_ev12 <- R_event[R_event > (rx[1] + 300*11)& R_event <= (rx[1] +  
300*12)]


R_ev13 <- R_event[R_event > (rx[1] + 300*12)& R_event <= (rx[1] +  
300*13)]
R_ev14 <- R_event[R_event > (rx[1] + 300*13)& R_event <= (rx[1] +  
300*14)]
R_ev15 <- R_event[R_event > (rx[1] + 300*14)& R_event <= (rx[1] +  
300*15)]
R_ev16 <- R_event[R_event > (rx[1] + 300*15)& R_event <= (rx[1] +  
300*16)]



R_ev1c <- as.character(R_ev1)
R_ev2c <- as.character(R_ev2)
R_ev3c <- as.character(R_ev3)
R_ev4c <- as.character(R_ev4)
R_ev5c <- as.character(R_ev5)
R_ev6c <- as.character(R_ev6)
R_ev7c <- as.character(R_ev7)
R_ev8c <- as.character(R_ev8)

R_ev9c  <- as.character(R_ev9)
R_ev10c <- as.character(R_ev10)
R_ev11c <- as.character(R_ev11)
R_ev12c <- as.character(R_ev12)
R_ev13c <- as.character(R_ev13)
R_ev14c <- as.character(R_ev14)
R_ev15c <- as.character(R_ev15)
R_ev16c <- as.character(R_ev16)




lis1 <- c(
length(R_ev1c),
length(R_ev2c),
length(R_ev3c),
length(R_ev4c),
length(R_ev5c),
length(R_ev6c),
length(R_ev7c),
length(R_ev8c),
length(R_ev9c),
length(R_ev10c),
length(R_ev11c),
length(R_ev12c),
length(R_ev13c),
length(R_ev14c),
length(R_ev15c),
length(R_ev16c)
)


# R_ev1_mat <- matrix(unlist(R_ev1),nrow=T)


barplot(lis1, angle = 15+10*1:5, density = 20, col = "black",
  legend = rownames(lis1))
title(main = list("Number of Occurred Received events in every 5  
mins",

font = 4))

# dev.off()


New code:

f1<- seq(rx[1],rx[2],by=300)
f<- as.character(f1)
len <- length(f)

for (n1 in 0:(len-1)){
for(n2 in 1:len){
# R_ev_01 <- R_event[R_event <= (rx[1] + 300)]

R_ev[n1] <- R_event[R_event > (rx[1]+ n1*300)& R_event <= (rx[1] +
300*n2)]
R_ev_char <- as.character(R_ev)

lis01 <- list(length(R_ev_char))
barplot(lis01, angle = 15+10*1:5, density = 20, col = "blue",
  legend = rownames(lis01))
title(main = list("Number of Occurred Received Events in every 5  
mins",

font = 4))
}
}

Somehow it is not working and giving an error saying "Fehler in  
-0.01 *

height : nicht-numerisches Argument für binären Operator".

Any help would be really appreciated.

Thanks
Crenial



--
View this message in context: 
http://www.nabble.com/loop-problem-tp25665329p25714305.html
Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] How to deal with this :" object ' obs' not found.

2009-10-02 Thread P Ehlers

Oops, missed a square bracket:

ttx1[order(-ttx1[,"obs"]),]

-Peter Ehlers

P Ehlers wrote:

You don't need to attach. But you do need to mention what kind of
object ttx1 is. I had (foolishly) assumed that it was dataframe,
but I see that it's a matrix. So try this:

 ttx1[order(-ttx1[,"obs"),]

-Peter Ehlers

Hyo Lee wrote:

Ok. I just figured out what the problem was.
I had to attach() the data.
**
x1=data1[,,2]
tx1=t(x1)
*ttx1 *= cbind(tx1 , obs=1:nrow(tx1))
--> this is how ttx1 was made; and of course, in ttx1, there is a 
variable

called 'obs'.

I had to attach(ttx1) first before I use this: 
*sortedx1=ttx1[order(-obs),]*


But it seems that, I cannot attach ttx1.
*> attach(ttx1)
Error in attach(ttx1) :
  'attach' only works for lists, data frames and environments*

Of course, this is one of the ways I can do. But I just don't think I 
can do

it for 1916 times.
 

write.csv(ttx1,"c:/i.csv")
m=read.table("c:/i.csv", header=T, sep=",")
attach(m)
sortedx1=m[order(-obs),]


Do you know what I should do?
Thanks.

-Hyo
On Fri, Oct 2, 2009 at 8:50 PM, jim holtman  wrote:

 

It is clear that 'obs' does not exist.

On Fri, Oct 2, 2009 at 8:48 PM, Hyo Lee  wrote:
   

It says...

 

str(obs)


Error in str(obs) : object 'obs' not found
 

ls(obs)


Error in try(name) : object 'obs' not found
Error in as.environment(pos) : no item called "obs" on the search list

On Fri, Oct 2, 2009 at 8:26 PM, jim holtman  
wrote:
 

Are you really sure you have 'obs'?  What does 'str(obs)' show?  What
about 'ls()'?

On Fri, Oct 2, 2009 at 8:19 PM, Hyo Lee  wrote:
   

Hi guys,
I need your help.
I'm trying to sort the data by the variable "obs".
This is how I tried to sort the data below.

The problem is, I have a variable name "obs"; this is.. a counter
variable.
something like _n_ in SAS.
I do not know why it is not working.
I even tried a similar example in UCLA webpage:
http://www.ats.ucla.edu/stat/R/faq/sort.htm  :it also does not seem
  

to
   

work.
"*sort1.hsb2 <- hsb2[order(read) , ]"*
Do you have any idea how to deal with this problem??  Thank you so
  

much.
   

-Hyo

 

colnames(ttx1)


 [1] "longitude 1"  "longitude 2"  "longitude 3"  "longitude 4"
 "longitude
5"
 [6] "longitude 6"  "longitude 7"  "longitude 8"  "longitude 9"
 "longitude
10"
[11] "longitude 11" "longitude 12" "longitude 13" "longitude 14"
"longitude
15"
[16] "longitude 16" "longitude 17" "longitude 18" "longitude 19"
"longitude
20"
[21] "longitude 21" "longitude 22" "longitude 23" "longitude 24"
"longitude
25"
[26] "longitude 26" "longitude 27" "longitude 28" "longitude 29"
"longitude
30"
[31] "longitude 31" "longitude 32" "longitude 33" "longitude 34"
"longitude
35"
[36] "longitude 36" "longitude 37" "longitude 38" "longitude 39"
"longitude
40"
[41] "longitude 41" "longitude 42" "longitude 43" "longitude 44"
"longitude
45"
[46] "longitude 46" "longitude 47" "longitude 48" "longitude 49"
"longitude
50"
[51] "longitude 51" "longitude 52" "longitude 53" "longitude 54"
"longitude
55"
[56] "longitude 56" "longitude 57" "longitude 58" "longitude 59"
"longitude
60"
[61] "longitude 61" "longitude 62" "longitude 63" "longitude 64"
"longitude
65"
[66] "longitude 66" "longitude 67" "longitude 68" "longitude 69"
"longitude
70"
[71] "longitude 71" "longitude 72" "obs"
 

sortedx1=ttx1[order(-obs),]


Error in order(-obs) : object 'obs' not found

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

  


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

What is the problem that you are trying to solve?

  


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

What is the problem that you are trying to solve?




[[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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 deal with this :" object ' obs' not found.

2009-10-02 Thread P Ehlers

You don't need to attach. But you do need to mention what kind of
object ttx1 is. I had (foolishly) assumed that it was dataframe,
but I see that it's a matrix. So try this:

 ttx1[order(-ttx1[,"obs"),]

-Peter Ehlers

Hyo Lee wrote:

Ok. I just figured out what the problem was.
I had to attach() the data.
**
x1=data1[,,2]
tx1=t(x1)
*ttx1 *= cbind(tx1 , obs=1:nrow(tx1))
--> this is how ttx1 was made; and of course, in ttx1, there is a variable
called 'obs'.

I had to attach(ttx1) first before I use this: *sortedx1=ttx1[order(-obs),]*

But it seems that, I cannot attach ttx1.
*> attach(ttx1)
Error in attach(ttx1) :
  'attach' only works for lists, data frames and environments*

Of course, this is one of the ways I can do. But I just don't think I can do
it for 1916 times.
  

write.csv(ttx1,"c:/i.csv")
m=read.table("c:/i.csv", header=T, sep=",")
attach(m)
sortedx1=m[order(-obs),]


Do you know what I should do?
Thanks.

-Hyo
On Fri, Oct 2, 2009 at 8:50 PM, jim holtman  wrote:

  

It is clear that 'obs' does not exist.

On Fri, Oct 2, 2009 at 8:48 PM, Hyo Lee  wrote:


It says...

  

str(obs)


Error in str(obs) : object 'obs' not found
  

ls(obs)


Error in try(name) : object 'obs' not found
Error in as.environment(pos) : no item called "obs" on the search list

On Fri, Oct 2, 2009 at 8:26 PM, jim holtman  wrote:
  

Are you really sure you have 'obs'?  What does 'str(obs)' show?  What
about 'ls()'?

On Fri, Oct 2, 2009 at 8:19 PM, Hyo Lee  wrote:


Hi guys,
I need your help.
I'm trying to sort the data by the variable "obs".
This is how I tried to sort the data below.

The problem is, I have a variable name "obs"; this is.. a counter
variable.
something like _n_ in SAS.
I do not know why it is not working.
I even tried a similar example in UCLA webpage:
http://www.ats.ucla.edu/stat/R/faq/sort.htm  :it also does not seem
  

to


work.
"*sort1.hsb2 <- hsb2[order(read) , ]"*
Do you have any idea how to deal with this problem??  Thank you so
  

much.


-Hyo

  

colnames(ttx1)


 [1] "longitude 1"  "longitude 2"  "longitude 3"  "longitude 4"
 "longitude
5"
 [6] "longitude 6"  "longitude 7"  "longitude 8"  "longitude 9"
 "longitude
10"
[11] "longitude 11" "longitude 12" "longitude 13" "longitude 14"
"longitude
15"
[16] "longitude 16" "longitude 17" "longitude 18" "longitude 19"
"longitude
20"
[21] "longitude 21" "longitude 22" "longitude 23" "longitude 24"
"longitude
25"
[26] "longitude 26" "longitude 27" "longitude 28" "longitude 29"
"longitude
30"
[31] "longitude 31" "longitude 32" "longitude 33" "longitude 34"
"longitude
35"
[36] "longitude 36" "longitude 37" "longitude 38" "longitude 39"
"longitude
40"
[41] "longitude 41" "longitude 42" "longitude 43" "longitude 44"
"longitude
45"
[46] "longitude 46" "longitude 47" "longitude 48" "longitude 49"
"longitude
50"
[51] "longitude 51" "longitude 52" "longitude 53" "longitude 54"
"longitude
55"
[56] "longitude 56" "longitude 57" "longitude 58" "longitude 59"
"longitude
60"
[61] "longitude 61" "longitude 62" "longitude 63" "longitude 64"
"longitude
65"
[66] "longitude 66" "longitude 67" "longitude 68" "longitude 69"
"longitude
70"
[71] "longitude 71" "longitude 72" "obs"
  

sortedx1=ttx1[order(-obs),]


Error in order(-obs) : object 'obs' not found

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

  


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

What is the problem that you are trying to solve?

  


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

What is the problem that you are trying to solve?




[[alternative HTML version deleted]]

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





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


Re: [R] How to deal with this :" object ' obs' not found.

2009-10-02 Thread jim holtman
You probably need to read a little more about R and learn the
difference between matrix and dataframes.  You need to do the
following since ttx1 is a matrix:

sortedx1=ttx1[order(-ttx1[, 'obs']),]

On Fri, Oct 2, 2009 at 9:37 PM, Hyo Lee  wrote:
> Ok. I just figured out what the problem was.
> I had to attach() the data.
>
> x1=data1[,,2]
> tx1=t(x1)
> ttx1 = cbind(tx1 , obs=1:nrow(tx1))
> --> this is how ttx1 was made; and of course, in ttx1, there is a variable
> called 'obs'.
>
> I had to attach(ttx1) first before I use this: sortedx1=ttx1[order(-obs),]
>
> But it seems that, I cannot attach ttx1.
>> attach(ttx1)
> Error in attach(ttx1) :
>   'attach' only works for lists, data frames and environments
>
> Of course, this is one of the ways I can do. But I just don't think I can do
> it for 1916 times.
>> write.csv(ttx1,"c:/i.csv")
>> m=read.table("c:/i.csv", header=T, sep=",")
>> attach(m)
>> sortedx1=m[order(-obs),]
> Do you know what I should do?
> Thanks.
>
> -Hyo
> On Fri, Oct 2, 2009 at 8:50 PM, jim holtman  wrote:
>>
>> It is clear that 'obs' does not exist.
>>
>> On Fri, Oct 2, 2009 at 8:48 PM, Hyo Lee  wrote:
>> > It says...
>> >
>> >> str(obs)
>> > Error in str(obs) : object 'obs' not found
>> >> ls(obs)
>> > Error in try(name) : object 'obs' not found
>> > Error in as.environment(pos) : no item called "obs" on the search list
>> >
>> > On Fri, Oct 2, 2009 at 8:26 PM, jim holtman  wrote:
>> >>
>> >> Are you really sure you have 'obs'?  What does 'str(obs)' show?  What
>> >> about 'ls()'?
>> >>
>> >> On Fri, Oct 2, 2009 at 8:19 PM, Hyo Lee  wrote:
>> >> > Hi guys,
>> >> > I need your help.
>> >> > I'm trying to sort the data by the variable "obs".
>> >> > This is how I tried to sort the data below.
>> >> >
>> >> > The problem is, I have a variable name "obs"; this is.. a counter
>> >> > variable.
>> >> > something like _n_ in SAS.
>> >> > I do not know why it is not working.
>> >> > I even tried a similar example in UCLA webpage:
>> >> > http://www.ats.ucla.edu/stat/R/faq/sort.htm  :it also does not seem
>> >> > to
>> >> > work.
>> >> > "*sort1.hsb2 <- hsb2[order(read) , ]"*
>> >> > Do you have any idea how to deal with this problem??  Thank you so
>> >> > much.
>> >> > -Hyo
>> >> >
>> >> >> colnames(ttx1)
>> >> >  [1] "longitude 1"  "longitude 2"  "longitude 3"  "longitude 4"
>> >> >  "longitude
>> >> > 5"
>> >> >  [6] "longitude 6"  "longitude 7"  "longitude 8"  "longitude 9"
>> >> >  "longitude
>> >> > 10"
>> >> > [11] "longitude 11" "longitude 12" "longitude 13" "longitude 14"
>> >> > "longitude
>> >> > 15"
>> >> > [16] "longitude 16" "longitude 17" "longitude 18" "longitude 19"
>> >> > "longitude
>> >> > 20"
>> >> > [21] "longitude 21" "longitude 22" "longitude 23" "longitude 24"
>> >> > "longitude
>> >> > 25"
>> >> > [26] "longitude 26" "longitude 27" "longitude 28" "longitude 29"
>> >> > "longitude
>> >> > 30"
>> >> > [31] "longitude 31" "longitude 32" "longitude 33" "longitude 34"
>> >> > "longitude
>> >> > 35"
>> >> > [36] "longitude 36" "longitude 37" "longitude 38" "longitude 39"
>> >> > "longitude
>> >> > 40"
>> >> > [41] "longitude 41" "longitude 42" "longitude 43" "longitude 44"
>> >> > "longitude
>> >> > 45"
>> >> > [46] "longitude 46" "longitude 47" "longitude 48" "longitude 49"
>> >> > "longitude
>> >> > 50"
>> >> > [51] "longitude 51" "longitude 52" "longitude 53" "longitude 54"
>> >> > "longitude
>> >> > 55"
>> >> > [56] "longitude 56" "longitude 57" "longitude 58" "longitude 59"
>> >> > "longitude
>> >> > 60"
>> >> > [61] "longitude 61" "longitude 62" "longitude 63" "longitude 64"
>> >> > "longitude
>> >> > 65"
>> >> > [66] "longitude 66" "longitude 67" "longitude 68" "longitude 69"
>> >> > "longitude
>> >> > 70"
>> >> > [71] "longitude 71" "longitude 72" "obs"
>> >> >>
>> >> >> sortedx1=ttx1[order(-obs),]
>> >> > Error in order(-obs) : object 'obs' not found
>> >> >
>> >> >        [[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.
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Jim Holtman
>> >> Cincinnati, OH
>> >> +1 513 646 9390
>> >>
>> >> What is the problem that you are trying to solve?
>> >
>> >
>>
>>
>>
>> --
>> Jim Holtman
>> Cincinnati, OH
>> +1 513 646 9390
>>
>> What is the problem that you are trying to solve?
>
>



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


Re: [R] How to deal with this :" object ' obs' not found.

2009-10-02 Thread Hyo Lee
Ok. I just figured out what the problem was.
I had to attach() the data.
**
x1=data1[,,2]
tx1=t(x1)
*ttx1 *= cbind(tx1 , obs=1:nrow(tx1))
--> this is how ttx1 was made; and of course, in ttx1, there is a variable
called 'obs'.

I had to attach(ttx1) first before I use this: *sortedx1=ttx1[order(-obs),]*

But it seems that, I cannot attach ttx1.
*> attach(ttx1)
Error in attach(ttx1) :
  'attach' only works for lists, data frames and environments*

Of course, this is one of the ways I can do. But I just don't think I can do
it for 1916 times.
> write.csv(ttx1,"c:/i.csv")
> m=read.table("c:/i.csv", header=T, sep=",")
> attach(m)
> sortedx1=m[order(-obs),]
Do you know what I should do?
Thanks.

-Hyo
On Fri, Oct 2, 2009 at 8:50 PM, jim holtman  wrote:

> It is clear that 'obs' does not exist.
>
> On Fri, Oct 2, 2009 at 8:48 PM, Hyo Lee  wrote:
> > It says...
> >
> >> str(obs)
> > Error in str(obs) : object 'obs' not found
> >> ls(obs)
> > Error in try(name) : object 'obs' not found
> > Error in as.environment(pos) : no item called "obs" on the search list
> >
> > On Fri, Oct 2, 2009 at 8:26 PM, jim holtman  wrote:
> >>
> >> Are you really sure you have 'obs'?  What does 'str(obs)' show?  What
> >> about 'ls()'?
> >>
> >> On Fri, Oct 2, 2009 at 8:19 PM, Hyo Lee  wrote:
> >> > Hi guys,
> >> > I need your help.
> >> > I'm trying to sort the data by the variable "obs".
> >> > This is how I tried to sort the data below.
> >> >
> >> > The problem is, I have a variable name "obs"; this is.. a counter
> >> > variable.
> >> > something like _n_ in SAS.
> >> > I do not know why it is not working.
> >> > I even tried a similar example in UCLA webpage:
> >> > http://www.ats.ucla.edu/stat/R/faq/sort.htm  :it also does not seem
> to
> >> > work.
> >> > "*sort1.hsb2 <- hsb2[order(read) , ]"*
> >> > Do you have any idea how to deal with this problem??  Thank you so
> much.
> >> > -Hyo
> >> >
> >> >> colnames(ttx1)
> >> >  [1] "longitude 1"  "longitude 2"  "longitude 3"  "longitude 4"
> >> >  "longitude
> >> > 5"
> >> >  [6] "longitude 6"  "longitude 7"  "longitude 8"  "longitude 9"
> >> >  "longitude
> >> > 10"
> >> > [11] "longitude 11" "longitude 12" "longitude 13" "longitude 14"
> >> > "longitude
> >> > 15"
> >> > [16] "longitude 16" "longitude 17" "longitude 18" "longitude 19"
> >> > "longitude
> >> > 20"
> >> > [21] "longitude 21" "longitude 22" "longitude 23" "longitude 24"
> >> > "longitude
> >> > 25"
> >> > [26] "longitude 26" "longitude 27" "longitude 28" "longitude 29"
> >> > "longitude
> >> > 30"
> >> > [31] "longitude 31" "longitude 32" "longitude 33" "longitude 34"
> >> > "longitude
> >> > 35"
> >> > [36] "longitude 36" "longitude 37" "longitude 38" "longitude 39"
> >> > "longitude
> >> > 40"
> >> > [41] "longitude 41" "longitude 42" "longitude 43" "longitude 44"
> >> > "longitude
> >> > 45"
> >> > [46] "longitude 46" "longitude 47" "longitude 48" "longitude 49"
> >> > "longitude
> >> > 50"
> >> > [51] "longitude 51" "longitude 52" "longitude 53" "longitude 54"
> >> > "longitude
> >> > 55"
> >> > [56] "longitude 56" "longitude 57" "longitude 58" "longitude 59"
> >> > "longitude
> >> > 60"
> >> > [61] "longitude 61" "longitude 62" "longitude 63" "longitude 64"
> >> > "longitude
> >> > 65"
> >> > [66] "longitude 66" "longitude 67" "longitude 68" "longitude 69"
> >> > "longitude
> >> > 70"
> >> > [71] "longitude 71" "longitude 72" "obs"
> >> >>
> >> >> sortedx1=ttx1[order(-obs),]
> >> > Error in order(-obs) : object 'obs' not found
> >> >
> >> >[[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.
> >> >
> >>
> >>
> >>
> >> --
> >> Jim Holtman
> >> Cincinnati, OH
> >> +1 513 646 9390
> >>
> >> What is the problem that you are trying to solve?
> >
> >
>
>
>
> --
>  Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>

[[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] caret package for time series applications

2009-10-02 Thread zubin
Max, thx for the reply, i am amazed at the caret package.. very nice

okay, for time series, i think i can include a dummy variable for each 
time period and try to remove the time effect, less 1 dummy, like one 
does for seasonality.  maybe that will work, if anyone has any 
suggestions on how to use the present caret package with time series, 
please share..







Max Kuhn wrote:
> Zubin,
>
>   
>> Hello, I have some time series applications, where i have a large set of X
>> variables (hundreds) and thousands of time data points (sampling every
>> minute).
>> I like to use the caret package to support the analysis, variable selection
>> and model selection.  However, reading the documentation, it looks like
>> caret uses resampling methods.  Not sure if these methods work with time
>> series, as you need  a block bootstrap or such.
>> My question:  Does the caret package support the usage of time series data?
>> 
>
> I don't know much about resampling with time series. If regular
> resampling methods are not appropriate, you can use the index argument
> of trainControl to specify the indices of the samples that you want in
> the training set. We can always add resampling options that are
> specific to time series.
>
> It also assumes that the predictors are in the form of a data frame or
> matrix, so I'm not sure that passing an object of some other class
> would work right now. I'd be happy to add new methods for train that
> are specific to certain data types.
>
>   

[[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] Tabulating using arbitrary numbers of factors

2009-10-02 Thread jim holtman
try 'reshape':

> require(reshape)
> # add a column to accumulate on
> tmp$inc <- 1
> recast(tmp, f1 + f2 + f3 ~ ., sum)
Using f1, f2, f3 as id variables
   f1   f2f3 (all)
1MaleWhite  0-20 3
2MaleWhite 21-40 4
3MaleWhite 41-60 2
4MaleWhite 61-80 3
5MaleBlack  0-20 3
6MaleBlack 21-40 4
7MaleBlack 41-60 2
8MaleBlack 61-80 3
9Male Hispanic  0-20 4
10   Male Hispanic 21-40 4
11   Male Hispanic 41-60 4
12   Male Hispanic 61-80 3
13   MaleOther  0-20 3
14   MaleOther 21-40 2
15   MaleOther 41-60 2
16   MaleOther 61-80 4
17 FemaleWhite  0-20 2
18 FemaleWhite 21-40 4
19 FemaleWhite 41-60 4
20 FemaleWhite 61-80 3
21 FemaleBlack  0-20 5
22 FemaleBlack 21-40 3
23 FemaleBlack 41-60 4
24 FemaleBlack 61-80 1
25 Female Hispanic  0-20 1
26 Female Hispanic 21-40 2
27 Female Hispanic 41-60 4
28 Female Hispanic 61-80 3
29 FemaleOther  0-20 4
30 FemaleOther 21-40 2
31 FemaleOther 41-60 3
32 FemaleOther 61-80 5
>
>


On Fri, Oct 2, 2009 at 2:15 PM, Andrew Spence  wrote:
> Dear R-help,
>
>
>
> First of all, thank you VERY much for any help you have time to offer. I
> greatly appreciate it.
>
>
>
> I would like to write a function that, given an arbitrary number of factors
> from a data frame, tabulates the number of occurrences of each unique
> combination of the factors. Cleary, this works:
>
>
>
>> table(horse,date,surface)
>
> 
>
> , , surface = TURF
>
>
>
>                   date
>
> horse               20080404 20080514 20081015 20081025 20081120 20081203
> 20090319
>
>  Bedevil                  0        0        0        0        0        0
> 0
>
>  Cut To The Point       227        0        0        0        0        0
> 0
>
> 
>
>
>
> But I would prefer output that skips all the zeros, flattens any dimensions
> greater than 2, and gives the level names rather than codes. I can write
> code specifically for n factors like this: (here 2 levels):
>
>
>
> ft <- function(x,y) {cbind(
> levels(x)[unique(cbind(x,y))[,1]],levels(y)[unique(cbind(x,y))[,2]],
> table(x,y)[unique(cbind(x,y))])}
>
>
>
> which gives the lovely output I'm looking for:
>
>
>
> #      [,1]                [,2]       [,3]
>
> # [1,] "Cut To The Point"  "20080404" "227"
>
> # [2,] "Prairie Wolf"      "20080404" "364"
>
> # [3,] "Bedevil"           "20080514" "319"
>
> # [4,] "Prairie Wolf"      "20080514" "330"
>
>
>
> But my attempts to make this into a function that handles arbitrary numbers
> of factors as separate input arguments has failed. The closest I can get is:
>
>
>
> ft2 <- function (...) { cbind( unique(cbind(...)),
> table(...)[unique(cbind(...))] )
>
>
>
> giving:
>
>> ft2(horse,date)
>
>      horse date
>
>  [1,]     2    1 227
>
>  [2,]     9    1 364
>
>  [3,]     1    2 319
>
>  [4,]     9    2 330
>
>  [5,]     9    3 291
>
>  [6,]    12    3 249
>
>  [7,]    10    3 286
>
>  [8,]     5    4 217
>
>  [9,]     3    4 426
>
> [10,]     8    4 468
>
> [11,]     9    5 319
>
> [12,]    13    5 328
>
> [13,]    12    5 138
>
> [14,]     7    6 375
>
> [15,]    11    6 366
>
> [16,]     4    7 255
>
> [17,]     6    7 517
>
>
>
> I would be greatly in debt to anyone willing to show me how to make the
> above function take arbitrary inputs and still produce output displaying
> factor level names instead of the underlying coded numbers.
>
>
>
> Cheers and thanks for your time!
>
>
>
> Andrew Spence
> RCUK Academic Research Fellow
> Structure and Motion Laboratory
> Royal Veterinary College
> Hawkshead Lane
> North Mymms, Hatfield
> Hertfordshire AL9 7TA
> +44 (0) 1707 666988
>
> mailto:aspe...@rvc.ac.uk
>
> http://www.rvc.ac.uk/sml/People/andrewspence.cfm
>
>
>
>
>
>
>        [[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.
>



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


Re: [R] How to deal with this :" object ' obs' not found.

2009-10-02 Thread Hyo Lee
Thanks.. but not working...

> sortedx1=ttx1[order(-ttx1$obs),]
Error in ttx1$obs : $ operator is invalid for atomic vectors


On Fri, Oct 2, 2009 at 8:47 PM, P Ehlers  wrote:

> Try
>
>  sortedx1=ttx1[order(-ttx1$obs),]
>
> (and ask yourself where obs lives)
>
> -Peter Ehlers
>
> Hyo Lee wrote:
>
>>  Hi guys,
>> I need your help.
>> I'm trying to sort the data by the variable "obs".
>> This is how I tried to sort the data below.
>>
>> The problem is, I have a variable name "obs"; this is.. a counter
>> variable.
>> something like _n_ in SAS.
>> I do not know why it is not working.
>> I even tried a similar example in UCLA webpage:
>> http://www.ats.ucla.edu/stat/R/faq/sort.htm  :it also does not seem to
>> work.
>> "*sort1.hsb2 <- hsb2[order(read) , ]"*
>> Do you have any idea how to deal with this problem??  Thank you so much.
>> -Hyo
>>
>>
>>
>>> colnames(ttx1)
>>>
>>>
>>  [1] "longitude 1"  "longitude 2"  "longitude 3"  "longitude 4"
>>  "longitude
>> 5"
>>  [6] "longitude 6"  "longitude 7"  "longitude 8"  "longitude 9"
>>  "longitude
>> 10"
>> [11] "longitude 11" "longitude 12" "longitude 13" "longitude 14"
>> "longitude
>> 15"
>> [16] "longitude 16" "longitude 17" "longitude 18" "longitude 19"
>> "longitude
>> 20"
>> [21] "longitude 21" "longitude 22" "longitude 23" "longitude 24"
>> "longitude
>> 25"
>> [26] "longitude 26" "longitude 27" "longitude 28" "longitude 29"
>> "longitude
>> 30"
>> [31] "longitude 31" "longitude 32" "longitude 33" "longitude 34"
>> "longitude
>> 35"
>> [36] "longitude 36" "longitude 37" "longitude 38" "longitude 39"
>> "longitude
>> 40"
>> [41] "longitude 41" "longitude 42" "longitude 43" "longitude 44"
>> "longitude
>> 45"
>> [46] "longitude 46" "longitude 47" "longitude 48" "longitude 49"
>> "longitude
>> 50"
>> [51] "longitude 51" "longitude 52" "longitude 53" "longitude 54"
>> "longitude
>> 55"
>> [56] "longitude 56" "longitude 57" "longitude 58" "longitude 59"
>> "longitude
>> 60"
>> [61] "longitude 61" "longitude 62" "longitude 63" "longitude 64"
>> "longitude
>> 65"
>> [66] "longitude 66" "longitude 67" "longitude 68" "longitude 69"
>> "longitude
>> 70"
>> [71] "longitude 71" "longitude 72" "obs"
>>
>>
>>> sortedx1=ttx1[order(-obs),]
>>>
>>>
>> Error in order(-obs) : object 'obs' not found
>>
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>>
>>
>

[[alternative HTML version deleted]]

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


[R] posting contrib documentation

2009-10-02 Thread Sharma, Dhruv
Hi, 
  how do i post a document to contrib documentation in R?  is there an email i 
can send the document as an attachment to?


thanks
DS

[[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 deal with this :" object ' obs' not found.

2009-10-02 Thread P Ehlers

Try

 sortedx1=ttx1[order(-ttx1$obs),]

(and ask yourself where obs lives)

-Peter Ehlers

Hyo Lee wrote:

Hi guys,
I need your help.
I'm trying to sort the data by the variable "obs".
This is how I tried to sort the data below.

The problem is, I have a variable name "obs"; this is.. a counter variable.
something like _n_ in SAS.
I do not know why it is not working.
I even tried a similar example in UCLA webpage:
http://www.ats.ucla.edu/stat/R/faq/sort.htm  :it also does not seem to work.
"*sort1.hsb2 <- hsb2[order(read) , ]"*
Do you have any idea how to deal with this problem??  Thank you so much.
-Hyo

  

colnames(ttx1)


 [1] "longitude 1"  "longitude 2"  "longitude 3"  "longitude 4"  "longitude
5"
 [6] "longitude 6"  "longitude 7"  "longitude 8"  "longitude 9"  "longitude
10"
[11] "longitude 11" "longitude 12" "longitude 13" "longitude 14" "longitude
15"
[16] "longitude 16" "longitude 17" "longitude 18" "longitude 19" "longitude
20"
[21] "longitude 21" "longitude 22" "longitude 23" "longitude 24" "longitude
25"
[26] "longitude 26" "longitude 27" "longitude 28" "longitude 29" "longitude
30"
[31] "longitude 31" "longitude 32" "longitude 33" "longitude 34" "longitude
35"
[36] "longitude 36" "longitude 37" "longitude 38" "longitude 39" "longitude
40"
[41] "longitude 41" "longitude 42" "longitude 43" "longitude 44" "longitude
45"
[46] "longitude 46" "longitude 47" "longitude 48" "longitude 49" "longitude
50"
[51] "longitude 51" "longitude 52" "longitude 53" "longitude 54" "longitude
55"
[56] "longitude 56" "longitude 57" "longitude 58" "longitude 59" "longitude
60"
[61] "longitude 61" "longitude 62" "longitude 63" "longitude 64" "longitude
65"
[66] "longitude 66" "longitude 67" "longitude 68" "longitude 69" "longitude
70"
[71] "longitude 71" "longitude 72" "obs"
  

sortedx1=ttx1[order(-obs),]


Error in order(-obs) : object 'obs' not found

[[alternative HTML version deleted]]

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





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


Re: [R] How to deal with this :" object ' obs' not found.

2009-10-02 Thread jim holtman
Are you really sure you have 'obs'?  What does 'str(obs)' show?  What
about 'ls()'?

On Fri, Oct 2, 2009 at 8:19 PM, Hyo Lee  wrote:
> Hi guys,
> I need your help.
> I'm trying to sort the data by the variable "obs".
> This is how I tried to sort the data below.
>
> The problem is, I have a variable name "obs"; this is.. a counter variable.
> something like _n_ in SAS.
> I do not know why it is not working.
> I even tried a similar example in UCLA webpage:
> http://www.ats.ucla.edu/stat/R/faq/sort.htm  :it also does not seem to work.
> "*sort1.hsb2 <- hsb2[order(read) , ]"*
> Do you have any idea how to deal with this problem??  Thank you so much.
> -Hyo
>
>> colnames(ttx1)
>  [1] "longitude 1"  "longitude 2"  "longitude 3"  "longitude 4"  "longitude
> 5"
>  [6] "longitude 6"  "longitude 7"  "longitude 8"  "longitude 9"  "longitude
> 10"
> [11] "longitude 11" "longitude 12" "longitude 13" "longitude 14" "longitude
> 15"
> [16] "longitude 16" "longitude 17" "longitude 18" "longitude 19" "longitude
> 20"
> [21] "longitude 21" "longitude 22" "longitude 23" "longitude 24" "longitude
> 25"
> [26] "longitude 26" "longitude 27" "longitude 28" "longitude 29" "longitude
> 30"
> [31] "longitude 31" "longitude 32" "longitude 33" "longitude 34" "longitude
> 35"
> [36] "longitude 36" "longitude 37" "longitude 38" "longitude 39" "longitude
> 40"
> [41] "longitude 41" "longitude 42" "longitude 43" "longitude 44" "longitude
> 45"
> [46] "longitude 46" "longitude 47" "longitude 48" "longitude 49" "longitude
> 50"
> [51] "longitude 51" "longitude 52" "longitude 53" "longitude 54" "longitude
> 55"
> [56] "longitude 56" "longitude 57" "longitude 58" "longitude 59" "longitude
> 60"
> [61] "longitude 61" "longitude 62" "longitude 63" "longitude 64" "longitude
> 65"
> [66] "longitude 66" "longitude 67" "longitude 68" "longitude 69" "longitude
> 70"
> [71] "longitude 71" "longitude 72" "obs"
>>
>> sortedx1=ttx1[order(-obs),]
> Error in order(-obs) : object 'obs' not found
>
>        [[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.
>



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


Re: [R] how to fill out the empty spots when using rbind or cbind?

2009-10-02 Thread jim holtman
I will take a guess at what you want since you did not program an
example of your data or output desired:

> a <- 1:4
> b <- 1:6
> # get error message
> cbind(a,b)
 a b
[1,] 1 1
[2,] 2 2
[3,] 3 3
[4,] 4 4
[5,] 1 5
[6,] 2 6
Warning message:
In cbind(a, b) :
  number of rows of result is not a multiple of vector length (arg 1)
> # now combine them filling out with NAs
> combine <- list(a, b)  # create a list of vectors to be bound
> max.length <- max(sapply(combine, length))
> do.call(cbind, lapply(combine, function(.vec){
+ c(.vec, rep(NA, max.length - length(.vec)))
+ }))
 [,1] [,2]
[1,]11
[2,]22
[3,]33
[4,]44
[5,]   NA5
[6,]   NA6


On Fri, Oct 2, 2009 at 6:12 PM,   wrote:
>
> I have uneven vectors I want to use cbind or rbind to combine them into a 
> matrix. Is there a way to make it so that R would not return error msg saying 
> they're uneven?
> Thanks.
>
> Edward Chen
> Email: tke...@msn.com
> Cell Phone: 510-371-4717
>
>
>
>        [[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.
>



-- 
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] How to deal with this :" object ' obs' not found.

2009-10-02 Thread Hyo Lee
Hi guys,
I need your help.
I'm trying to sort the data by the variable "obs".
This is how I tried to sort the data below.

The problem is, I have a variable name "obs"; this is.. a counter variable.
something like _n_ in SAS.
I do not know why it is not working.
I even tried a similar example in UCLA webpage:
http://www.ats.ucla.edu/stat/R/faq/sort.htm  :it also does not seem to work.
"*sort1.hsb2 <- hsb2[order(read) , ]"*
Do you have any idea how to deal with this problem??  Thank you so much.
-Hyo

> colnames(ttx1)
 [1] "longitude 1"  "longitude 2"  "longitude 3"  "longitude 4"  "longitude
5"
 [6] "longitude 6"  "longitude 7"  "longitude 8"  "longitude 9"  "longitude
10"
[11] "longitude 11" "longitude 12" "longitude 13" "longitude 14" "longitude
15"
[16] "longitude 16" "longitude 17" "longitude 18" "longitude 19" "longitude
20"
[21] "longitude 21" "longitude 22" "longitude 23" "longitude 24" "longitude
25"
[26] "longitude 26" "longitude 27" "longitude 28" "longitude 29" "longitude
30"
[31] "longitude 31" "longitude 32" "longitude 33" "longitude 34" "longitude
35"
[36] "longitude 36" "longitude 37" "longitude 38" "longitude 39" "longitude
40"
[41] "longitude 41" "longitude 42" "longitude 43" "longitude 44" "longitude
45"
[46] "longitude 46" "longitude 47" "longitude 48" "longitude 49" "longitude
50"
[51] "longitude 51" "longitude 52" "longitude 53" "longitude 54" "longitude
55"
[56] "longitude 56" "longitude 57" "longitude 58" "longitude 59" "longitude
60"
[61] "longitude 61" "longitude 62" "longitude 63" "longitude 64" "longitude
65"
[66] "longitude 66" "longitude 67" "longitude 68" "longitude 69" "longitude
70"
[71] "longitude 71" "longitude 72" "obs"
>
> sortedx1=ttx1[order(-obs),]
Error in order(-obs) : object 'obs' not found

[[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 fill out the empty spots when using rbind or cbind?

2009-10-02 Thread Daniel Malter
Fill the respective "empty" spots in the vectors with NAs.  

Daniel


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von tke...@msn.com
Gesendet: Friday, October 02, 2009 6:13 PM
An: R help
Betreff: [R] how to fill out the empty spots when using rbind or cbind?


I have uneven vectors I want to use cbind or rbind to combine them into a
matrix. Is there a way to make it so that R would not return error msg
saying they're uneven? 
Thanks. 

Edward Chen
Email: tke...@msn.com
Cell Phone: 510-371-4717


  
[[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] randomizing groups

2009-10-02 Thread Jason Priem
Duh.  I just figured out that though I was getting a warning, it was 
still doing the split anyway.  Sorry for the dumb question.

-jason

Jason Priem wrote:
I have a list of participants in a study, identified by number.  I 
want to randomly sort them into an arbitrary number of groups. 
split(sample(1:96, 96), 1:16)

almost does it, but it only works where the division is even.  Any ideas?
Thanks!

Jason Priem,
Doctoral Student,
School of Information and Library Science
University of North Carolina-Chapel Hill



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 fill out the empty spots when using rbind or cbind?

2009-10-02 Thread tkedch

I have uneven vectors I want to use cbind or rbind to combine them into a 
matrix. Is there a way to make it so that R would not return error msg saying 
they're uneven? 
Thanks. 

Edward Chen
Email: tke...@msn.com
Cell Phone: 510-371-4717


  
[[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] Re cursive regression

2009-10-02 Thread spencerg
 There is a huge literature on time series analysis with many 
functions and contributed packages in R, including many different ways 
"to estimate a recursive model". 



 If you are working with "asset returns", I suggest you start with 
Diethelm Würtz, Yohan Chalabi, William Chen, Andrew Ellis (2009) 
Portfolio Optimization with R/Rmetrics (www.rmetrics.org/ebook.htm) and 
the companion Rmetrics bundle documented in that book.  You may also be 
interested in Ruey Tsay (2005) Analysis of Financial Time Series (Wiley) 
and the companion "FinTS" package on CRAN.  For recursive regression, I 
suggest you consider Giovanni Petris, Sonia Petrone, and Patrizia 
Campagnoli (2009) Dynamic Linear Models with R (Springer) and the 
companion "dlm" package. 



 There are many other books discussing time series mentioned on 
"http://www.r-project.org/doc/bib/R-books.html";. 



 Beyond that, I suggest you acquaint yourself with the 
"RSiteSearch" function an the "sos" package to help search capabilities 
available in R. 



 Hope this helps. 
 Spencer Graves



manta wrote:

Hi there, I'm in desperate need to figure out how to solve this issue.
I need to estimate a recursive model for a time series data of asset
returns. The dependent variable is the asset return and then I have a set of
k variables, a lagged value of the dependent variable (plus an intercept) as
regressors. My sample period (monthly observations) starts on Jan 1972. What
I need to do is the following:

1)use a moving window regression (window of 60 observations, i.e. 5 years)
2)estimate all the possible model (Jan 1972 Dec 1977) using a subset of the
k variables (intercept and lagged values always present) and choose the best
model according to thee AIC criterion
3)once the best model is chosen, make one-step ahead prediction with that
model
4)go back to step 2 shifting the sample period one month ahead (i.e. Feb
1972, Jan 1978) and then repeat step 2 and 3
5)keep going until the end of the sample (May 2009)

Hope it helps
  



--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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

2009-10-02 Thread David Winsemius


On Oct 2, 2009, at 2:39 PM, KABELI MEFANE wrote:


Dear Mr Winsemius

I am sorry to have offended any of you by the mistakes i made. The  
package i loaded is sampling and there was an unwanted comma between  
size c(20, )and the bracket. What i wanted was to calculate the sum  
of H in a sample not in the original dataframe. If i do

sum(H) i get the sum value of H's in the original dataframe.


Yes, and that would be expected, would it not?



Load package sampling

H <- matrix(rnorm(100, mean=5, sd=5000))
sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe
 sum(H)

str=strata(sampleframe,c("type"),size=c(20), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat


Seems to me that you should be getting descriptive statisics on the  
sample.strat object rather than on H.

> summary(sample.strat)
 value   type  ID_unit   ProbStratum
 Min.   :37931   H:20   Min.   : 1.00   Min.   :0.2   Min.   :1
 1st Qu.:46547  1st Qu.:20.75   1st Qu.:0.2   1st Qu.:1
 Median :48848  Median :44.50   Median :0.2   Median :1
 Mean   :49193  Mean   :50.45   Mean   :0.2   Mean   :1
 3rd Qu.:51311  3rd Qu.:78.75   3rd Qu.:0.2   3rd Qu.:1
 Max.   :58523  Max.   :98.00   Max.   :0.2   Max.   :1
>



Thanks for the input. Once again sorry for wasting your time.

Best Regards




--- On Fri, 2/10/09, David Winsemius  wrote:

From: David Winsemius 
Subject: Re: [R] How to use Subpopulation data?
To: "KABELI MEFANE" 
Cc: R-help@r-project.org
Date: Friday, 2 October, 2009, 3:38 PM


On Oct 1, 2009, at 6:06 AM, KABELI MEFANE wrote:

> Dear Helpers
>
> I have a sample frame and i have sampled from it using three  
methods and now i want to calculate the statistics but i only get  
the population parameters.

>
> H <- matrix(rnorm(100, mean=5, sd=5000))
> sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
> sampleframe
>
> str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
> sample.strat<-getdata(sampleframe,str)
> sample.strat

If you want the number of rows in sample.strat then length(H) is the  
wrong approach since that is the original (unsampled) object.


> length(H)
> i get:
>
> length(H)
> [1] 100
>
> Desire to get:
> length(H)
> [1] 20

I cannot tell what packages you have loaded and strata is not in the  
sampling package which I guessed (wrongly) was where you were  
getting "getdata". When you post code you should precede that code  
with calls that load any non-base packages.


In later posting you ask for ways to calculate "the sum" but you do  
not say what it is that you want the sum of . Our abilities to  
read minds is extremely limited.


--David Winsemius



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


Re: [R] randomizing groups

2009-10-02 Thread David Winsemius


On Oct 2, 2009, at 4:36 PM, Jason Priem wrote:

I have a list of participants in a study, identified by number.  I  
want to randomly sort them into an arbitrary number of groups.  
split(sample(1:96, 96), 1:16)
almost does it, but it only works where the division is even.  Any  
ideas?

Thanks!


See if this gives you some ideas:

> idx <- sample(1:96, 96)
> cut(idx,  breaks=quantile(idx, prob=c(0, 0.25, 0.5, 0.75, 1),  
include.lowest=TRUE))
 [1] (48.5,72.2] (24.8,48.5] (24.8,48.5] (48.5,72.2] (1,24.8] 
(24.8,48.5] (24.8,48.5] (24.8,48.5] (48.5,72.2]
[10] (48.5,72.2] (1,24.8](48.5,72.2] (72.2,96]   (1,24.8] 
(1,24.8](24.8,48.5] (1,24.8](1,24.8]
[19] (72.2,96]   (72.2,96]   (24.8,48.5] (1,24.8](24.8,48.5]  
(24.8,48.5] (24.8,48.5] (72.2,96]   (72.2,96]
[28] (24.8,48.5] (48.5,72.2] (1,24.8](48.5,72.2] (48.5,72.2]  
(72.2,96]   (72.2,96]   (1,24.8](48.5,72.2]
[37] (48.5,72.2] (48.5,72.2] (24.8,48.5] (48.5,72.2] (1,24.8] 
(1,24.8](1,24.8](24.8,48.5] (1,24.8]
[46] (24.8,48.5] (72.2,96]   (24.8,48.5] (24.8,48.5] (1,24.8] 
(1,24.8](1,24.8](1,24.8](72.2,96]
[55] (48.5,72.2] (72.2,96]   (1,24.8](48.5,72.2] (48.5,72.2]  
(72.2,96]   (48.5,72.2] (48.5,72.2] (24.8,48.5]
[64] (72.2,96]   (48.5,72.2] (1,24.8](48.5,72.2] (24.8,48.5]  
(72.2,96]   (48.5,72.2] (48.5,72.2]
[73] (48.5,72.2] (1,24.8](24.8,48.5] (72.2,96]   (1,24.8] 
(24.8,48.5] (24.8,48.5] (1,24.8](72.2,96]
[82] (24.8,48.5] (24.8,48.5] (1,24.8](72.2,96]   (48.5,72.2]  
(72.2,96]   (72.2,96]   (72.2,96]   (24.8,48.5]
[91] (72.2,96]   (72.2,96]   (48.5,72.2] (72.2,96]   (72.2,96]
(72.2,96]

Levels: (1,24.8] (24.8,48.5] (48.5,72.2] (72.2,96]
> idx.grp <-as.numeric(cut(idx,  breaks=quantile(idx, prob=c(0, 0.25,  
0.5, 0.75, 1), include.lowest=TRUE)))

> tapply(idx, idx.grp, I)
$`1`
 [1]  6 21  4 14  8  7 20 23 18 22 24 13 17 10  3  2  5 11 19 16  9  
12 15


$`2`
 [1] 38 46 33 34 40 44 27 29 39 28 42 26 47 35 31 45 32 36 37 48 43  
30 41 25


$`3`
 [1] 61 62 70 50 67 69 52 55 51 68 56 54 57 60 53 59 65 66 49 63 72  
64 58 71


$`4`
 [1] 89 86 77 94 93 82 81 80 90 91 76 78 73 88 85 75 96 74 79 95 87  
83 84 92



--
David

Jason Priem,
Doctoral Student,
School of Information and Library Science
University of North Carolina-Chapel Hill

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

2009-10-02 Thread Jason Priem
Duh. I just figured out that though I was getting a warning, it was 
still doing the split anyway. Sorry for the dumb question.


-jason

Jason Priem wrote:
I have a list of participants in a study, identified by number.  I 
want to randomly sort them into an arbitrary number of groups. 
split(sample(1:96, 96), 1:16)

almost does it, but it only works where the division is even.  Any ideas?
Thanks!

Jason Priem,
Doctoral Student,
School of Information and Library Science
University of North Carolina-Chapel Hill



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

2009-10-02 Thread C. Maranto

Dear R Community,

I am running GLM's within the "MASS" library.  My data are overdispersed and 
I am accounting for the overdispersion by using an ANOVA 'F' test instead of 
ANOVA 'Chisq'.  You will have to forgive me because I am new at this, but I 
am not sure if R is conducting an ANOVA 'F' test appropriately.  I was 
hoping to explain this using my data results below:



anova(glm.model,test="F")

Analysis of Deviance Table
Model:binomial,link:logit
Response: ytrips

Terms added squentially (first to last)

   DFDeviance 
Resid. DfResid. Dev. FPr(>F)
NULL 
1251008.55
WaterLevel10.14 
1241008.420.13650.7118
RiverFlowObserved   113.34 
123995.07  13.3427  0.0002594
WSBacklog   112.47 
122982.61  12.4675  0.0004141
factor(WDEW)  183.13 
121899.48  83.1258  <2.2e-16
ChickDays 1   157.22 
120742.26 157.2225 <2.2e-16
Salmon  16.91 
119735.34  6.91430.0085509
factor(Year)   3370.31 
116365.03  123.4375<2.2e-16
WSBacklog:factor(WDEW)  19.06 
115355.97  9.0644 0.0026063



I think the F-values in the results are over-inflated for an F-test.

For an F-test,

F-observed = (Deviance/Df numerator)/("MSE"=Residual Deviance/Residual Df)

When I calculate F-observed for one of my main effects, such as 
'WSBacklogfactor(WDEW)' above I get:


F-observed = (9.06/1)/(355.97/115)=2.92  NOT 9.0644(as shown in the results 
above)


It seems that the F-test in 'R' is not dividing by the "MSE".

Does anyone have any thoughts on this? Or can let me know where I am going 
wrong?


Thank you!


~Christina




Christina J. Maranto
University of Washington
Department of Zoology
Box 351800
Seattle, WA 98195
(206) 618-2956

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


Re: [R] Re gression line w/ residuals - tuning the plot

2009-10-02 Thread Primoz PETERLIN
Many thanks to both who replied, Ulrike and Petr. Indeed, some playing
with the margin-sizing options solved my problem.

All the best, Primož

2009/9/29 Ulrike Groemping :
>
> Hello Primoz,
>
> with traditional graphics, you may want to use par (?par), options like mar,
> mai, oma etc. may be interesting for you. And for the relation between
> y-axis and x-axis, the option asp to function plot (?plot.default) will
> help.
>
> Regards, Ulrike
>
>
>
> Primoz PETERLIN-2 wrote:
>>
>> Hello everybody,
>>
>> I am sure this is a beginners' problem which is being asked
>> recurrently every few months, but nevertheless I wasn't able to find
>> the answer searching through the r-help list.
>>
>> So here is my problem: I would like to plot a set of points (y vs. x),
>> a (linear) regression line through them, and on the second graph
>> underneath the first one I would want to plot residuals vs. x. I came
>> up with two solutions, unfortunately neither of them is fully
>> satisfactory.
>>
>> First I tried with what I later learned is called traditional graphics
>> (file norris.R). Here, the white space margins around the plots are
>> too wide, meaning that the data in the plot are crammed. Probably I
>> would be quite happy if I could somehow define a rectangular plotting
>> area with its height being ~150% of its width, but I cannot prevent R
>> from offering me a square plotting area.
>>
>> Next I tried a lattice package (file norris.lattice.R). Here, the
>> margins are smaller, but the lower plot does not fit exactly under the
>> upper one (the x-axes should match).
>>
>> Most likely I am not using the correct terminology (if I would have
>> known it, I could have looked in the help pages myself, thank you :),
>> but I hope that the attached files make more sense of what I am trying
>> to do.
>>
>> Thanks in advance.
>>
>> All the best,
>> Primoz
>>
>> --
>> Primož Peterlin,   Inštitut za biofiziko, Med. fakulteta, Univerza v
>> Ljubljani
>> Lipičeva 2, SI-1000 Ljubljana, Slovenija.
>> primoz.peter...@mf.uni-lj.si
>> Tel +386-1-5437612, fax +386-1-4315127,
>> http://biofiz.mf.uni-lj.si/~peterlin/
>> F8021D69 OpenPGP fingerprint: CB 6F F1 EE D9 67 E0 2F  0B 59 AF 0D 79 56
>> 19 0F
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/Regression-line-w--residuals---tuning-the-plot-tp25647458p25670483.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.
>



-- 
Primož Peterlin,   Inštitut za biofiziko, Med. fakulteta, Univerza v Ljubljani
Lipičeva 2, SI-1000 Ljubljana, Slovenija.primoz.peter...@mf.uni-lj.si
Tel +386-1-5437612, fax +386-1-4315127,  http://biofiz.mf.uni-lj.si/~peterlin/
F8021D69 OpenPGP fingerprint: CB 6F F1 EE D9 67 E0 2F  0B 59 AF 0D 79 56 19 0F

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

2009-10-02 Thread Juliane Struve
Dear list,
 
I would like to aggregate CVTimeDiff by Fish_ID and Trip and put the result 
into myarray,i.e. for the example below Trip 1,9 and Fish_ID 1646 I would like 
to obtain mean= (0.8104876+1.3676631)/2 and put it into myarray[1] .

 
mydataframe
 
 Trip Fish_ID CVTimeDiff
1    1,9 1646  0.8104876
2    1,9 1646  1.3676631
3  11,13    1647 NA

 
myarray
 
  1646 1647 1648 1649 1650 1654 1656 1662
1,9   NA   NA   NA   NA   NA   NA   NA   NA
10,11    NA   NA   NA   NA   NA   NA   NA   NA
11,13    NA   NA   NA   NA   NA   NA   NA   NA
 
Could somebody help me with this ?
 
Many thanks,
 
Juliane 




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

2009-10-02 Thread Jason Priem
I have a list of participants in a study, identified by number.  I want 
to randomly sort them into an arbitrary number of groups. 
split(sample(1:96, 96), 1:16)

almost does it, but it only works where the division is even.  Any ideas?
Thanks!

Jason Priem,
Doctoral Student,
School of Information and Library Science
University of North Carolina-Chapel Hill

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

2009-10-02 Thread Peter Ehlers

Kabeli,

You seem to be doing your best to avoid working
your way through some introductory documentation
like An Introduction to R, which is sitting
right there on your computer.

So let's try to take it slowly, one step at a time.

#1. generate a vector of values to work with.
(forget the matrix() bit and the data.frame() bit
for now and forget about the sampling package
for now)

 x <- rnorm(100, mean=5, sd=5000)

#2. in order to select a random sample of values
from x, we'll randomly select 20 numbers from
the set {1, 2, 3, ..., 99, 100}. Those 20 numbers
will tell us which x-values get into our sample.

 idx <- sample(100, 20, replace = FALSE)

Here's what I got (you'll get different numbers):

> idx
 [1] 91 51 97 50 67 31 29 75 89 78 63 77
[13] 38 85 16 74 53 40 54  2

#3. now select x[91], x[51], etc as the elements
of x to be your sample:

 xsample <- x[idx]

#4. now do whatever you want with xsample;

 sum(xsample)
 mean(xsample)
 sd(xsample)

#5. in order to use something like the function
strata() in pkg:sampling, you will first have
to understand how to read its help page and
understand what's in the object returned by strata().

I do hope that this helps at least somewhat,
Peter Ehlers


KABELI MEFANE wrote:

Dear Mr Winsemius
 
I am sorry to have offended any of you by the mistakes i made. The package i loaded is sampling and there was an unwanted comma between size c(20, )and the bracket. What i wanted was to calculate the sum of H in a sample not in the original dataframe. If i do 
sum(H) i get the sum value of H's in the original dataframe.
 
 
Load package sampling
 
H <- matrix(rnorm(100, mean=5, sd=5000))

sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe
 sum(H)

str=strata(sampleframe,c("type"),size=c(20), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat
 
Thanks for the input. Once again sorry for wasting your time.
 
Best Regards 
 
 



--- On Fri, 2/10/09, David Winsemius  wrote:


From: David Winsemius 
Subject: Re: [R] How to use Subpopulation data?
To: "KABELI MEFANE" 
Cc: R-help@r-project.org
Date: Friday, 2 October, 2009, 3:38 PM



On Oct 1, 2009, at 6:06 AM, KABELI MEFANE wrote:


Dear Helpers

I have a sample frame and i have sampled from it using three methods and now i 
want to calculate the statistics but i only get the population parameters.

H <- matrix(rnorm(100, mean=5, sd=5000))
sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe

str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat


If you want the number of rows in sample.strat then length(H) is the wrong 
approach since that is the original (unsampled) object.


length(H)
i get:

length(H)
[1] 100

Desire to get:
length(H)
[1] 20


I cannot tell what packages you have loaded and strata is not in the sampling package 
which I guessed (wrongly) was where you were getting "getdata". When you post 
code you should precede that code with calls that load any non-base packages.

In later posting you ask for ways to calculate "the sum" but you do not say 
what it is that you want the sum of . Our abilities to read minds is extremely 
limited.

--David Winsemius



  
	[[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] Tabulating using arbitrary numbers of factors

2009-10-02 Thread Erik Iverson
Andrew, 

Is this what you're looking for?  Most likely a more elegant solution exists... 
but maybe this is good enough. 

## BEGIN R SAMPLE CODE
## sample data frame, 3 factors
tmp <- data.frame(f1 = sample(gl(2, 50, labels = c("Male", "Female"))),
  f2 = sample(gl(4, 25, labels =
c("White", "Black", "Hispanic", "Other"))),
  f3 = sample(gl(4, 25, labels =
c("0-20", "21-40", "41-60", "61-80"

summary(tmp)

## the function
test <- function(...) {
  tbl <- table(interaction(..., sep = "!"))
  tbl.nozero <- tbl[tbl > 0]
  
  nms <- strsplit(names(tbl.nozero), "!")
  
  cb <- cbind(t(do.call(data.frame, nms)), tbl.nozero)
  dimnames(cb) <- NULL
  cb
}

## test calling the function, does this produce what you want? 
with(tmp, test(f1, f2, f3))

## END R SAMPLE CODE 

Best Regards,
Erik Iverson

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Andrew Spence
> Sent: Friday, October 02, 2009 1:15 PM
> To: r-help@r-project.org
> Subject: [R] Tabulating using arbitrary numbers of factors
> 
> Dear R-help,
> 
> 
> 
> First of all, thank you VERY much for any help you have time to offer. I
> greatly appreciate it.
> 
> 
> 
> I would like to write a function that, given an arbitrary number of
> factors
> from a data frame, tabulates the number of occurrences of each unique
> combination of the factors. Cleary, this works:
> 
> 
> 
> > table(horse,date,surface)
> 
> 
> 
> , , surface = TURF
> 
> 
> 
>date
> 
> horse   20080404 20080514 20081015 20081025 20081120 20081203
> 20090319
> 
>   Bedevil  000000
> 0
> 
>   Cut To The Point   22700000
> 0
> 
> 
> 
> 
> 
> But I would prefer output that skips all the zeros, flattens any
> dimensions
> greater than 2, and gives the level names rather than codes. I can write
> code specifically for n factors like this: (here 2 levels):
> 
> 
> 
> ft <- function(x,y) {cbind(
> levels(x)[unique(cbind(x,y))[,1]],levels(y)[unique(cbind(x,y))[,2]],
> table(x,y)[unique(cbind(x,y))])}
> 
> 
> 
> which gives the lovely output I'm looking for:
> 
> 
> 
> #  [,1][,2]   [,3]
> 
> # [1,] "Cut To The Point"  "20080404" "227"
> 
> # [2,] "Prairie Wolf"  "20080404" "364"
> 
> # [3,] "Bedevil"   "20080514" "319"
> 
> # [4,] "Prairie Wolf"  "20080514" "330"
> 
> 
> 
> But my attempts to make this into a function that handles arbitrary
> numbers
> of factors as separate input arguments has failed. The closest I can get
> is:
> 
> 
> 
> ft2 <- function (...) { cbind( unique(cbind(...)),
> table(...)[unique(cbind(...))] )
> 
> 
> 
> giving:
> 
> > ft2(horse,date)
> 
>   horse date
> 
>  [1,] 21 227
> 
>  [2,] 91 364
> 
>  [3,] 12 319
> 
>  [4,] 92 330
> 
>  [5,] 93 291
> 
>  [6,]123 249
> 
>  [7,]103 286
> 
>  [8,] 54 217
> 
>  [9,] 34 426
> 
> [10,] 84 468
> 
> [11,] 95 319
> 
> [12,]135 328
> 
> [13,]125 138
> 
> [14,] 76 375
> 
> [15,]116 366
> 
> [16,] 47 255
> 
> [17,] 67 517
> 
> 
> 
> I would be greatly in debt to anyone willing to show me how to make the
> above function take arbitrary inputs and still produce output displaying
> factor level names instead of the underlying coded numbers.
> 
> 
> 
> Cheers and thanks for your time!
> 
> 
> 
> Andrew Spence
> RCUK Academic Research Fellow
> Structure and Motion Laboratory
> Royal Veterinary College
> Hawkshead Lane
> North Mymms, Hatfield
> Hertfordshire AL9 7TA
> +44 (0) 1707 666988
> 
> mailto:aspe...@rvc.ac.uk
> 
> http://www.rvc.ac.uk/sml/People/andrewspence.cfm
> 
> 
> 
> 
> 
> 
>   [[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] trouble with html() in Hmisc

2009-10-02 Thread Liviu Andronic
Dear all
On my system html() conversion of a `latex()' object fails. Follows a
dummy example:
> require(Hmisc)
> data(Angell)
> .object <- cor(Angell[,1:2], use="complete.obs")
> tmp <- latex(.object, cdec=c(2,2), title="")
> class(tmp)
[1] "latex"
> html(tmp)
/tmp/RtmprfPwzw/file7e72f7a7.tex:9: Warning: Command not found: \tabularnewline
Giving up command: \...@hevea@amper
/tmp/RtmprfPwzw/file7e72f7a7.tex:11: Error while reading LaTeX:
This array/tabular column has no specification
Adios


I have hevea-1.10 installed on Debian (according to the help page, it
performs the conversion). Attached is teh produced .tex file. Is this
a bug or would there be a way to work around this behaviour?
Thank you
Liviu


> sessionInfo()
R version 2.9.2 (2009-08-24)
x86_64-pc-linux-gnu

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

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

other attached packages:
 [1] fortunes_1.3-6   RcmdrPlugin.Export_0.3-0 Rcmdr_1.5-2
 [4] car_1.2-15   hints_1.0.1-1boot_1.2-39
 [7] relimp_1.0-1 xtable_1.5-5 Hmisc_3.7-0
[10] survival_2.35-7

loaded via a namespace (and not attached):
[1] cluster_1.12.0  grid_2.9.2  lattice_0.17-25 tools_2.9.2
> system("uname -a")
Linux debian-liv 2.6.30-1-amd64 #1 SMP Sat Aug 15 18:09:19 UTC 2009
x86_64 GNU/Linux





-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Tabulating using arbitrary numbers of factors

2009-10-02 Thread Andrew Spence
Dear R-help,

 

First of all, thank you VERY much for any help you have time to offer. I
greatly appreciate it.

 

I would like to write a function that, given an arbitrary number of factors
from a data frame, tabulates the number of occurrences of each unique
combination of the factors. Cleary, this works:

 

> table(horse,date,surface)



, , surface = TURF

 

   date

horse   20080404 20080514 20081015 20081025 20081120 20081203
20090319

  Bedevil  000000
0

  Cut To The Point   22700000
0



 

But I would prefer output that skips all the zeros, flattens any dimensions
greater than 2, and gives the level names rather than codes. I can write
code specifically for n factors like this: (here 2 levels):

 

ft <- function(x,y) {cbind(
levels(x)[unique(cbind(x,y))[,1]],levels(y)[unique(cbind(x,y))[,2]],
table(x,y)[unique(cbind(x,y))])}

 

which gives the lovely output I'm looking for:

 

#  [,1][,2]   [,3]

# [1,] "Cut To The Point"  "20080404" "227"

# [2,] "Prairie Wolf"  "20080404" "364"

# [3,] "Bedevil"   "20080514" "319"

# [4,] "Prairie Wolf"  "20080514" "330"

 

But my attempts to make this into a function that handles arbitrary numbers
of factors as separate input arguments has failed. The closest I can get is:

 

ft2 <- function (...) { cbind( unique(cbind(...)),
table(...)[unique(cbind(...))] )

 

giving:

> ft2(horse,date)

  horse date

 [1,] 21 227

 [2,] 91 364

 [3,] 12 319

 [4,] 92 330

 [5,] 93 291

 [6,]123 249

 [7,]103 286

 [8,] 54 217

 [9,] 34 426

[10,] 84 468

[11,] 95 319

[12,]135 328

[13,]125 138

[14,] 76 375

[15,]116 366

[16,] 47 255

[17,] 67 517

 

I would be greatly in debt to anyone willing to show me how to make the
above function take arbitrary inputs and still produce output displaying
factor level names instead of the underlying coded numbers.

 

Cheers and thanks for your time!

 

Andrew Spence
RCUK Academic Research Fellow
Structure and Motion Laboratory
Royal Veterinary College
Hawkshead Lane
North Mymms, Hatfield
Hertfordshire AL9 7TA
+44 (0) 1707 666988

mailto:aspe...@rvc.ac.uk

http://www.rvc.ac.uk/sml/People/andrewspence.cfm

 

 


[[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] error using frailty term

2009-10-02 Thread Mary Slaughter
Trying to fit a model using the Surv() with a frailty term but get the
following cryptic error message:
--
Error in frailty.brent(sqrt(x), y, lower = 0) :
  Ties for max(y), I surrender
Calls: runplots ... coxpenal.fit -> eval -> eval ->  -> frailty.brent
--
When I remove the frailty term from the model it runs just fine. Does
anyone know what this error message means?

Thanks,
M.

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


Re: [R] plot scale

2009-10-02 Thread Greg Snow
Here is a different approach:
This example uses the default plotting device, but should work the same with 
postscript or any other device.  Just set the size of the paper to a standard 
size, or a large enough size to fit your largest plot:

dev.new()
tmp <- par('plt')

scale <- 5
x <- runif(100, 0, 20)
y <- rnorm(100, x)

dx <- diff(range(x))*1.08
wx <- grconvertX(dx/scale, from='inches', to='ndc')

dy <- diff(range(y))*1.08
wy <- grconvertY(dy/scale, from='inches', to='ndc')

par(plt = c(tmp[1], tmp[1]+wx, tmp[3], tmp[3]+wy) )
plot(x,y)

dev.new()

x2 <- runif(100, 0,5)
y2 <- rnorm(100, x2)

dx <- diff(range(x2))*1.08
wx <- grconvertX(dx/scale, from='inches', to='ndc')

dy <- diff(range(y2))*1.08
wy <- grconvertY(dy/scale, from='inches', to='ndc')

par(plt = c(tmp[1], tmp[1]+wx, tmp[3], tmp[3]+wy) )
plot(x2,y2)


The above only works for 1 plot per page (no layout or par(mfrow=... ) ).

This keeps the lower left corner of the plot in the same place (so change the 
margins before the call to par('plt') if you want them different). Then sets 
the top and right parts of the plotting region leaving white space on the top 
and right to get the scaling correct (you will have problems if your desired 
scale does not fit in the window/on the page).  This example uses a "scale" of 
5 plot units per inch, change as appropriate.  The *1.08 is to account for the 
extra area that is added to the plot by default, change this for the other axis 
type.

Hope this helps,



-- 
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 Ben Kenward
> Sent: Friday, October 02, 2009 2:08 AM
> To: r-help@r-project.org
> Subject: [R] plot scale
> 
> Hi,
> 
> Is there a way to set the scale of a plot (i.e. number of axis units
> per centimeter) when you output it to postscript? If not, how am I
> supposed to plot graphs with different axis limits to the same scale?
> They just get resized to fit the paper so that graphs which show a
> smaller number of axis units end up with a larger scale.
> 
> Cheers,
> 
> Ben
> 
> --
> Dr. Ben Kenward
> Department of Psychology, Uppsala University, Sweden
> http://www.benkenward.com
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] xts dates spacings

2009-10-02 Thread devol

Hello!

  Please help - can't find any options how to remove very big spaces between
two dates containing intraday prices plotted by plot.xts. It looks like the
following: on the left side of the plot window is the first bunch of points,
the same is for the right hand side and a long line connecting them in the
middle. I would want to merge them (cut spaces) somehow.

In any case thanks for help.

Alex
-- 
View this message in context: 
http://www.nabble.com/xts-dates-spacings-tp25721103p25721103.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] RE xcel foreground and background server

2009-10-02 Thread ryusuke

I have installed, its workable in frontground mode while but background mode,
may I know how do I activate background mode? Thanks


Irina Ursachi wrote:
> 
> Dear all,
> 
> I have a question regarding background and foreground server in RExcel:
> Can somebody explain the main difference between them? As far as I
> understood from the RExcel webpage, for both of them one  needs rights
> for access to Windows registries. The only difference that I can see so
> far is that for the installation of the background server, one needs the
> R(D)COM package, whereas for the foreground server installation, the
> rcom package is required.
> 
> Further more, does anyone know, how Excel proccesses and R processes
> communicate? Is it possible for more than one Excel-process to
> communicate with more than one R process?
> 
> Thank you in advance!
> 
> Best regards,
> Irina Ursachi.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/RExcel-foreground-and-background-server-tp21668224p25720937.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] text mining

2009-10-02 Thread Corey Dow-Hygelund
Your problem lies in the use of system.file.  This command looks in the
folder location of tm for specific folders.  See ?system.files.

Basically, for the document example, it assigning txt to the directory
string like "C:/Program Files (x86)/R/R-2.9.0/library/tm/texts/txt"
Then the DirSource(txt) constructs a directory source from directory string
txt.
Finally Corpus constructs a tm corpus from the DirSource object (with some
extra arguments to boot).

So, to solve your problem, replace txt with the directory containing your
files:
txt<-"C://docs"

and then run the subsequent command
 ovid <- Corpus(DirSource(txt),
 readerControl = list(reader = readPlain,
language = "la",
 load = TRUE))

(though you may want to change the object name "ovid" to something more
descriptive)

C






On Fri, Oct 2, 2009 at 10:15 AM, PDXRugger  wrote:

>
> The following code is derived from a paper titled "Text Mining
> Infrastructure
> in R" (http://www.jstatsoft.org/v25/i05/paper).  The example below seems
> to
> load some default documents for analysis, some sort of latin document.  I
> cannot for the life of me figure out to load my own document let alone an
> entire corpus.  I have searched the above documenet as well as related
> documentation.  Any leads or help would be appreciated.  Thanks everyone
>
> from document
>
> txt <- system.file("texts", "txt", package = "tm")
>  (ovid <- Corpus(DirSource(txt),
>  readerControl = list(reader = readPlain,
> language = "la",
>  load = TRUE)))
>
> my attempt
> txt <- system.file("Speeches/speech", "txt", package = "tm")
>  (ovid <- Corpus(DirSource(txt),
>  readerControl = list(reader = readPlain,
> language = "la",
>  load = TRUE)))
>
>
> --
> View this message in context:
> http://www.nabble.com/text-mining-tp25717142p25717142.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] How to use Subpopulation data?

2009-10-02 Thread KABELI MEFANE
Dear Mr Winsemius
 
I am sorry to have offended any of you by the mistakes i made. The package i 
loaded is sampling and there was an unwanted comma between size c(20, )and the 
bracket. What i wanted was to calculate the sum of H in a sample not in the 
original dataframe. If i do 
sum(H) i get the sum value of H's in the original dataframe.
 
 
Load package sampling
 
H <- matrix(rnorm(100, mean=5, sd=5000))
sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe
 sum(H)

str=strata(sampleframe,c("type"),size=c(20), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat
 
Thanks for the input. Once again sorry for wasting your time.
 
Best Regards 
 
 


--- On Fri, 2/10/09, David Winsemius  wrote:


From: David Winsemius 
Subject: Re: [R] How to use Subpopulation data?
To: "KABELI MEFANE" 
Cc: R-help@r-project.org
Date: Friday, 2 October, 2009, 3:38 PM



On Oct 1, 2009, at 6:06 AM, KABELI MEFANE wrote:

> Dear Helpers
> 
> I have a sample frame and i have sampled from it using three methods and now 
> i want to calculate the statistics but i only get the population parameters.
> 
> H <- matrix(rnorm(100, mean=5, sd=5000))
> sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
> sampleframe
> 
> str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
> sample.strat<-getdata(sampleframe,str)
> sample.strat

If you want the number of rows in sample.strat then length(H) is the wrong 
approach since that is the original (unsampled) object.

> length(H)
> i get:
> 
> length(H)
> [1] 100
> 
> Desire to get:
> length(H)
> [1] 20

I cannot tell what packages you have loaded and strata is not in the sampling 
package which I guessed (wrongly) was where you were getting "getdata". When 
you post code you should precede that code with calls that load any non-base 
packages.

In later posting you ask for ways to calculate "the sum" but you do not say 
what it is that you want the sum of . Our abilities to read minds is 
extremely limited.

--David Winsemius



  
[[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] plot scale

2009-10-02 Thread Ryan
> 
> Hi,
> 
> Is there a way to set the scale of a plot (i.e. number of axis units
> per centimeter) when you output it to postscript? If not, how am I
> supposed to plot graphs with different axis limits to the same scale?
> They just get resized to fit the paper so that graphs which show a
> smaller number of axis units end up with a larger scale.
> 
> Cheers,
> 
> Ben
> 

If I understand you correctly, you want the units on each axis to 
be physically represented equally on the same scale.  If this is right, 
try using the lattice package (xyplot, etc.) with aspect="iso".

Lattice lets you adjust the aspect ratio of the plot to whatever you 
like and constrains the dimensions of the plot accordingly.  Base 
graphics also allow for control of the aspect ratio using "asp=", but 
extend the limits of the plot to fill whatever region you are plotting 
in.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Weibull survival regression model with different shape parameters

2009-10-02 Thread Nicolas RODE
Dear R users,

I'm trying to fit a parametric survival model using the survreg function
with a Weibull distribution.
I'm studying the time to death of individuals from different families
and I would like to fit different shape parameters (ie 1/scale in R) for
each of the families. I looked it up in the help pdf and on the
internet, but I couldn't find anything.
Would it be possible to do such a thing ?

Thanks in advance,

Best regards,

Nicolas


N. Rode
PhD student
CEFE (Centre d'Ecologie Fonctionnelle et Evolutive)
34293 Montpellier, France



-- 
passerelle antivirus du campus CNRS de Montpellier
--



[[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] .Rprofile file

2009-10-02 Thread Marianne Promberger
> I want to use the .RProfile to set defaults such as text editor.  Is  
> this a file I need to create?  Also, where should I put it?  I tend to  
> create .RData files for different projects, putting each in a different  
> Windows (Vista) folder.  Is one .Rprofile file created  that any   
> instance of R can access  (I would imagine so)?

I'm just trying to find that out myself for XP -- on Linux it is very
easy, you just create ~/.Rprofile in your home directory.

I think this thread might help, but I haven't had time to pursue this
yet:

http://tolstoy.newcastle.edu.au/R/devel/05/12/3454.html

Marianne


-- 
Marianne Promberger PhD
King's College London
London SE1 9RT
Phone: 020 7188 2590
GnuPG/PGP public key ID 80AD9916
.tex .bib .R .Rnw files welcome

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

2009-10-02 Thread crenial30

Thanks a lot David for your answer. I am sorry for being so minimal.

I wanted to produce a list/vector/table consisting each vector produced from
this code

len<-20
for (n1 in seq(0,(len-1),by=1)){

f <- R_event[R_event > (rx[1]+ n1*300)& R_event <= (rx[1] + 300*(n1+1))]
//create list for each values of n1

R_ev_char <- as.character(f)

lis01 <- c(length(R_ev_char)) // here I want to store the values of lengths
of R_ev_char vector for successive values of n1(0,1,2,3,...20)

I already tried with vector notation but no help.

I just want to store Lengths on each successive  integer so that I can draw
the list on 300(secs) interval.

Any suggestion would be very much helpful.
crenial


crenial30 wrote:
> 
> I have the following code which I wanted to convert using for loop
> 
> previous code:
> R_ev1 <- R_event[R_event > (rx[1] + 300*0)& R_event <= (rx[1] + 300*1)]
> R_ev2 <- R_event[R_event > (rx[1] + 300*1)& R_event <= (rx[1] + 300*2)]
> R_ev3 <- R_event[R_event > (rx[1] + 300*2)& R_event <= (rx[1] + 300*3)]
> R_ev4 <- R_event[R_event > (rx[1] + 300*3)& R_event <= (rx[1] + 300*4)]
> 
> R_ev5 <- R_event[R_event > (rx[1] + 300*4)& R_event <= (rx[1] + 300*5)]
> R_ev6 <- R_event[R_event > (rx[1] + 300*5)& R_event <= (rx[1] + 300*6)]
> R_ev7 <- R_event[R_event > (rx[1] + 300*6)& R_event <= (rx[1] + 300*7)]
> R_ev8 <- R_event[R_event > (rx[1] + 300*7)& R_event <= (rx[1] + 300*8)]
> 
> R_ev9 <- R_event[R_event  > (rx[1] + 300*8)& R_event <= (rx[1] + 300*9)]
> R_ev10 <- R_event[R_event > (rx[1] + 300*9)& R_event <= (rx[1] + 300*10)]
> R_ev11 <- R_event[R_event > (rx[1] + 300*10)& R_event <= (rx[1] + 300*11)]
> R_ev12 <- R_event[R_event > (rx[1] + 300*11)& R_event <= (rx[1] + 300*12)]
> 
> R_ev13 <- R_event[R_event > (rx[1] + 300*12)& R_event <= (rx[1] + 300*13)]
> R_ev14 <- R_event[R_event > (rx[1] + 300*13)& R_event <= (rx[1] + 300*14)]
> R_ev15 <- R_event[R_event > (rx[1] + 300*14)& R_event <= (rx[1] + 300*15)]
> R_ev16 <- R_event[R_event > (rx[1] + 300*15)& R_event <= (rx[1] + 300*16)]
> 
> 
> R_ev1c <- as.character(R_ev1)
> R_ev2c <- as.character(R_ev2)
> R_ev3c <- as.character(R_ev3)
> R_ev4c <- as.character(R_ev4)
> R_ev5c <- as.character(R_ev5)
> R_ev6c <- as.character(R_ev6)
> R_ev7c <- as.character(R_ev7)
> R_ev8c <- as.character(R_ev8)
> 
> R_ev9c  <- as.character(R_ev9)
> R_ev10c <- as.character(R_ev10)
> R_ev11c <- as.character(R_ev11)
> R_ev12c <- as.character(R_ev12)
> R_ev13c <- as.character(R_ev13)
> R_ev14c <- as.character(R_ev14)
> R_ev15c <- as.character(R_ev15)
> R_ev16c <- as.character(R_ev16)
> 
> 
> 
> 
> lis1 <- c(
> length(R_ev1c),
> length(R_ev2c),
> length(R_ev3c),
> length(R_ev4c),
> length(R_ev5c),
> length(R_ev6c),
> length(R_ev7c),
> length(R_ev8c),
> length(R_ev9c),
> length(R_ev10c),
> length(R_ev11c),
> length(R_ev12c),
> length(R_ev13c),
> length(R_ev14c),
> length(R_ev15c),
> length(R_ev16c)
> )
> 
> 
> # R_ev1_mat <- matrix(unlist(R_ev1),nrow=T)
> 
> 
> barplot(lis1, angle = 15+10*1:5, density = 20, col = "black",
>legend = rownames(lis1))
>  title(main = list("Number of Occurred Received events in every 5 mins",
> font = 4))
> 
> # dev.off()
> 
> 
> New code:
> 
> f1<- seq(rx[1],rx[2],by=300)
> f<- as.character(f1)
> len <- length(f)
> 
> for (n1 in 0:(len-1)){
> for(n2 in 1:len){
> # R_ev_01 <- R_event[R_event <= (rx[1] + 300)]
> 
> R_ev[n1] <- R_event[R_event > (rx[1]+ n1*300)& R_event <= (rx[1] +
> 300*n2)]
> R_ev_char <- as.character(R_ev)
> 
> lis01 <- list(length(R_ev_char))
> barplot(lis01, angle = 15+10*1:5, density = 20, col = "blue",
>legend = rownames(lis01))
>  title(main = list("Number of Occurred Received Events in every 5 mins",
> font = 4))
> }
> }
> 
> Somehow it is not working and giving an error saying "Fehler in -0.01 *
> height : nicht-numerisches Argument für binären Operator".
> 
> Any help would be really appreciated.
> 
> Thanks
> Crenial
> 

-- 
View this message in context: 
http://www.nabble.com/loop-problem-tp25665329p25714305.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] text mining

2009-10-02 Thread PDXRugger

The following code is derived from a paper titled "Text Mining Infrastructure
in R" (http://www.jstatsoft.org/v25/i05/paper).  The example below seems to
load some default documents for analysis, some sort of latin document.  I
cannot for the life of me figure out to load my own document let alone an
entire corpus.  I have searched the above documenet as well as related
documentation.  Any leads or help would be appreciated.  Thanks everyone

from document

txt <- system.file("texts", "txt", package = "tm")
 (ovid <- Corpus(DirSource(txt),
 readerControl = list(reader = readPlain,
language = "la",
 load = TRUE)))

my attempt
txt <- system.file("Speeches/speech", "txt", package = "tm")
 (ovid <- Corpus(DirSource(txt),
 readerControl = list(reader = readPlain,
language = "la",
 load = TRUE)))


-- 
View this message in context: 
http://www.nabble.com/text-mining-tp25717142p25717142.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] split-apply question

2009-10-02 Thread William Dunlap

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of hadley wickham
> Sent: Friday, October 02, 2009 6:07 AM
> To: jim holtman
> Cc: r-help@r-project.org; Kavitha Venkatesan
> Subject: Re: [R] split-apply question
> 
> On Fri, Oct 2, 2009 at 4:24 AM, jim holtman 
>  wrote:
> > try this:
> >
> >> x <- read.table(textConnection("x1  x2  x3
> > + A   1    1.5
> > + B   2    0.9
> > + B   3    2.7
> > + C   7    1.8
> > + D   7    1.3"), header=TRUE)
> >> closeAllConnections()
> >> do.call(rbind, lapply(split(seq(nrow(x)), x$x1), function(.row){
> > +     x[.row[which.min(x$x2[.row])],]
> > + }))
> >  x1 x2  x3
> > A  A  1 1.5
> > B  B  2 0.9
> > C  C  7 1.8
> > D  D  7 1.3
> >>
> 
> Or, using plyr and subset
> 
> library(plyr)
> ddply(x, "x1", subset, x2 == min(x2))
> 
> Hadley

Since we are using min() we can use sorting tricks

f3 <- function(x) {
   x <- x[with(x, order(x1,x2)),]
   isFirstInRun <- function(z)c(TRUE, z[-1] != z[-length(z)])
   x[isFirstInRun(x$x1),]
}

This has the advantage that it keeps the original row names intact.
It is quick even when there are lots of unique values in x1.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  
> -- 
> 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] nls not accepting control parameter?

2009-10-02 Thread Peter Ehlers

Hello Rainer,

I think that your problem is with trying to fit a logistic model to
data that don't support that model. Removing the first two points
from your data will work (but of course it may not represent reality).
The logistic function does not exhibit the kind of minimum that
your data suggest.

 -Peter Ehlers

Rainer M Krug wrote:

Hi

I want to change a control parameter for an nls () as I am getting an error
message  "step factor 0.000488281 reduced below 'minFactor' of 0.000976562".
Despite all tries, it seems that the control parameter of the nls, does not
seem to get handed down to the function itself, or the error message is
using a different one.

Below system info and an example highlighting the problem.

Thanks,

Rainer



version   _

platform   i486-pc-linux-gnu
arch   i486
os linux-gnu
system i486, linux-gnu
status
major  2
minor  9.2
year   2009
month  08
day24
svn rev49384
language   R
version.string R version 2.9.2 (2009-08-24)


sessionInfo()

R version 2.9.2 (2009-08-24)
i486-pc-linux-gnu

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

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

other attached packages:
[1] R.utils_1.2.0 R.oo_1.5.0R.methodsS3_1.0.3 maptools_0.7-26
[5] sp_0.9-44 foreign_0.8-37

loaded via a namespace (and not attached):
[1] grid_2.9.2  lattice_0.17-25


#

EXAMPLE:

dat <- data.frame(
  x = 2006:2037,
  y = c(143088, 140218, 137964,
138313, 140005, 141483, 142365,
144114, 145335, 146958, 148584,
149398, 151074, 152241, 153919,
155580, 157258, 158981, 160591,
162126, 163743, 165213, 166695,
168023, 169522, 170746, 172057,
173287, 173977, 175232, 176308,
177484)
  )

nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, trace=TRUE)

(newMinFactor <- 1/(4*1024))
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=nls.control(minFactor=newMinFactor), trace=TRUE)
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=c(minFactor=newMinFactor), trace=TRUE)


(newMinFactor <- 4/1024)
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=nls.control(minFactor=newMinFactor), trace=TRUE)
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=c(minFactor=newMinFactor), trace=TRUE)





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


Re: [R] confint fails in quasibinomial glm: dims do not match

2009-10-02 Thread Peter Ehlers

Chad,

(inline below)

joris meys wrote:

Confint doesn't work if you have a multi-dimensional dependent variable.


Well, it will work, but not for the quasibinomial family.

The simple solution would seem to be to change your response from
the matrix cbind(,) to the vector alive/sum(alive+red) and use
the weights=sum(alive+red) argument.

 -Peter Ehlers



Kind regards
Joris

On Fri, Oct 2, 2009 at 4:29 AM, smith_cc  wrote:

I am unable to calculate confidence intervals for the slope estimate in a
quasibinomial glm using confint(). Below is the output and the package info
for MASS. Thanks in advance!

R 2.9.2
MASS 7.2-48


confint(glm.palive.0.str)

Waiting for profiling to be done...
Error: dims [product 37] do not match the length of object [74]

glm.palive.0.str

Call:  glm(formula = cbind(alive, red) ~ str, family = quasibinomial,
data = subset(master.palive, vtime == 0))

Coefficients:
(Intercept) strs
  1.05 1.01

Degrees of Freedom: 36 Total (i.e. Null);  35 Residual
Null Deviance:  20800
Residual Deviance: 16200AIC: NA


packageDescription("MASS")

Bundle: VR
Contains: MASS class nnet spatial
Priority: recommended
Version: 7.2-48
Date: 2009-07-29
Depends: R (>= 2.5.0), grDevices, graphics, stats, utils
Suggests: lattice, nlme, survival
Author: S original by Venables & Ripley. R port by Brian Ripley
, following earlier work by Kurt Hornik and Albrecht
   Gebhardt.
Maintainer: Brian Ripley 
BundleDescription: Functions and datasets to support Venables and Ripley,
'Modern Applied Statistics with S' (4th edition).
License: GPL-2 | GPL-3
URL: http://www.stats.ox.ac.uk/pub/MASS4/
Packaged: 2009-07-31 13:56:57 UTC; ripley
Repository: CRAN
Date/Publication: 2009-08-05 11:20:53
Package: MASS
Description: The main library and the datasets
Title: Main Package of Venables and Ripley's MASS
LazyLoad: yes
LazyData: yes
Built: R 2.9.2; i686-pc-linux-gnu; 2009-08-25 10:52:10 UTC; unix

Cheers,
Chad
--
View this message in context: 
http://www.nabble.com/confint-fails-in-quasibinomial-glm%3A-dims-do-not-match-tp25709756p25709756.html
Sent from the R help mailing list archive at Nabble.com.

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



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




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


Re: [R] Normal distribution

2009-10-02 Thread Greg Snow
See fortune(234)

-- 
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 Noela Sánchez
> Sent: Thursday, October 01, 2009 10:47 AM
> To: r-help@r-project.org
> Subject: [R] Normal distribution
> 
> Hi,
> 
> I am dealing with how to check in R if some data that I have belongs to
> a
> normal distribution or not. I am not interested in obtaining the
> theoreticall frequencies. I am only interested in determing if (by
> means of
> a test as Kolmogorov, or whatever), if my data are normal or not.
> 
> But I have tried with ks.test() and I have not got it.
> 
> 
> --
> Noela
> Grupo de Recursos Marinos y Pesquerías
> Universidad de A Coruña
> 
>   [[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] break up a string into strings with a fixed length

2009-10-02 Thread Gabor Grothendieck
Here is a slightly simpler version of the strapply solution with a
short string at the end:

> strapply("abcdefghijk", ".{1,3}")[[1]]
[1] "abc" "def" "ghi" "jk"

On Fri, Oct 2, 2009 at 8:20 AM, Gabor Grothendieck
 wrote:
> That part wasn't specified so we can't say what the required behavior
> is in that case; however, if a non-multiple of 3 were possible and if
> the short string is to be emitted at the end then we can just add to
> the regular expression:
>
>> library(gsubfn)
>> s <- paste(letters, collapse = "")
>
>> strapply(s, "...|..$|.$", c)[[1]]
> [1] "abc" "def" "ghi" "jkl" "mno" "pqr" "stu" "vwx" "yz"
>
> On Fri, Oct 2, 2009 at 8:08 AM, jim holtman  wrote:
>> But it misses the last set if not a multiple of the subset length:
>>
>>> library(gsubfn)
>>> s <- "abcdefghijklm"
>>>
>>> # no 'm'
>>> strapply(s, "...")[[1]]
>> [1] "abc" "def" "ghi" "jkl"
>>>
>>
>>
>> On Fri, Oct 2, 2009 at 7:58 AM, Gabor Grothendieck
>>  wrote:
>>> Try this:
>>>
 library(gsubfn)
 s <- "abcdefghijkl"
>>>
 strapply(s, "...")[[1]]
>>> [1] "abc" "def" "ghi" "jkl"
>>>
>>>
>>> On Fri, Oct 2, 2009 at 5:36 AM, J Chen  wrote:

 dear all,

 I have some very long strings and would like to break up each long string
 into multiple strings with a fixed length, e.g. to break up

 abcdefghijkl

 into

 abc, def, ghi, jkl

 I tried a couple of commands but was not successful. Any help will be
 appreciated.

 Best,
 Jimmy
 --
 View this message in context: 
 http://www.nabble.com/break-up-a-string-into-strings-with-a-fixed-length-tp25712955p25712955.html
 Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] break up a string into strings with a fixed length

2009-10-02 Thread Stefan Th. Gries
This should do what you want:

x<-"abcdefghijkl"
strsplit(x, "(?<=...)", perl=T)

HTH,
STG
--
Stefan Th. Gries
---
University of California, Santa Barbara
http://www.linguistics.ucsb.edu/faculty/stgries

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 speed up R with version 2.9.2?

2009-10-02 Thread Gabor Grothendieck
I was thinking of startup code in your C:\Program
Files\R\R-2.9.2\etc\Rprofile.site file or other startup R file that
you provided.  See ?Startup

On Fri, Oct 2, 2009 at 12:01 PM, FMH  wrote:
> Yes, i noticed there are few Windows start up programs, shown by the 
> EasyCleaner software.
>
> Cheers
>
>
>
>
> - Original Message 
> From: Gabor Grothendieck 
> To: FMH 
> Cc: stephen sefick ;
> Sent: Fri, October 2, 2009 4:50:52 PM
> Subject: Re: [R] How to speed up R with version 2.9.2?
>
> Its under 5 seconds on my Vista laptop.  Do you have any startup files?  If
>   Rgui --vanilla
> is much faster then your startup files are the problem.
>
> On Fri, Oct 2, 2009 at 11:45 AM, FMH  wrote:
>> Thank you for your answer. I'm using Win XP with 2GB RAM in memory.
>>
>> Cheers
>> Fir
>>
>>
>>
>> - Original Message 
>> From: stephen sefick 
>> To: FMH 
>> Cc: r-help@r-project.org
>> Sent: Fri, October 2, 2009 4:38:10 PM
>> Subject: Re: [R] How to speed up R with version 2.9.2?
>>
>> You're fine, but please do read the posting guide.  What OS etc.
>> Where you doing anything else on the computer?  Is this a RAM
>> limitation?  I have 2.9.2 running on two flavours of linux, mac os x
>> and windows all 2.9.2 and there doesn't seem to be a problem.
>> regards,
>>
>> Stephen
>>
>> On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
>>> Dear All,
>>>
>>> I'm sorry if my question does not suit with this R group.
>>>
>>> I have recently installed R software with version 2.9.2, but i found the 
>>> program took almost 1 minute as soon as it was opened, before it can be 
>>> used. However, the previous version 2.9.1 only take few seconds after the 
>>> menu bar was clicked. This circumstance has caused me to wait for couple of 
>>> minutes as several R windows were opened simultaneously.
>>>
>>> Are there any ways to speed up on this 2.9.2 version? Could someone give 
>>> some hints, please?
>>>
>>> Thank you
>>> Fir
>>>
>>>
>>>
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>>
>> --
>> Stephen Sefick
>>
>> Let's not spend our time and resources thinking about things that are
>> so little or so large that all they really do for us is puff us up and
>> make us feel like gods.  We are mammals, and have not exhausted the
>> annoying little problems of being mammals.
>>
>>                                 -K. Mullis
>>
>>
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
>
>

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


Re: [R] How to speed up R with version 2.9.2?

2009-10-02 Thread FMH
Yes, i noticed there are few Windows start up programs, shown by the 
EasyCleaner software.

Cheers

 


- Original Message 
From: Gabor Grothendieck 
To: FMH 
Cc: stephen sefick ;
Sent: Fri, October 2, 2009 4:50:52 PM
Subject: Re: [R] How to speed up R with version 2.9.2?

Its under 5 seconds on my Vista laptop.  Do you have any startup files?  If
  Rgui --vanilla
is much faster then your startup files are the problem.

On Fri, Oct 2, 2009 at 11:45 AM, FMH  wrote:
> Thank you for your answer. I'm using Win XP with 2GB RAM in memory.
>
> Cheers
> Fir
>
>
>
> - Original Message 
> From: stephen sefick 
> To: FMH 
> Cc: r-help@r-project.org
> Sent: Fri, October 2, 2009 4:38:10 PM
> Subject: Re: [R] How to speed up R with version 2.9.2?
>
> You're fine, but please do read the posting guide.  What OS etc.
> Where you doing anything else on the computer?  Is this a RAM
> limitation?  I have 2.9.2 running on two flavours of linux, mac os x
> and windows all 2.9.2 and there doesn't seem to be a problem.
> regards,
>
> Stephen
>
> On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
>> Dear All,
>>
>> I'm sorry if my question does not suit with this R group.
>>
>> I have recently installed R software with version 2.9.2, but i found the 
>> program took almost 1 minute as soon as it was opened, before it can be 
>> used. However, the previous version 2.9.1 only take few seconds after the 
>> menu bar was clicked. This circumstance has caused me to wait for couple of 
>> minutes as several R windows were opened simultaneously.
>>
>> Are there any ways to speed up on this 2.9.2 version? Could someone give 
>> some hints, please?
>>
>> Thank you
>> Fir
>>
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Stephen Sefick
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>                                 -K. Mullis
>
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>





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


Re: [R] How to speed up R with version 2.9.2?

2009-10-02 Thread Sundar Dorai-Raj
Another possibility is a very large .RData file in the directory where
you're starting R. You can try

Rgui --no-restore

(I don't have windows, so I'm not sure if this an option with RGui,
though I know it is with R.)

--sundar

On Fri, Oct 2, 2009 at 8:50 AM, Gabor Grothendieck
 wrote:
> Its under 5 seconds on my Vista laptop.  Do you have any startup files?  If
>  Rgui --vanilla
> is much faster then your startup files are the problem.
>
> On Fri, Oct 2, 2009 at 11:45 AM, FMH  wrote:
>> Thank you for your answer. I'm using Win XP with 2GB RAM in memory.
>>
>> Cheers
>> Fir
>>
>>
>>
>> - Original Message 
>> From: stephen sefick 
>> To: FMH 
>> Cc: r-help@r-project.org
>> Sent: Fri, October 2, 2009 4:38:10 PM
>> Subject: Re: [R] How to speed up R with version 2.9.2?
>>
>> You're fine, but please do read the posting guide.  What OS etc.
>> Where you doing anything else on the computer?  Is this a RAM
>> limitation?  I have 2.9.2 running on two flavours of linux, mac os x
>> and windows all 2.9.2 and there doesn't seem to be a problem.
>> regards,
>>
>> Stephen
>>
>> On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
>>> Dear All,
>>>
>>> I'm sorry if my question does not suit with this R group.
>>>
>>> I have recently installed R software with version 2.9.2, but i found the 
>>> program took almost 1 minute as soon as it was opened, before it can be 
>>> used. However, the previous version 2.9.1 only take few seconds after the 
>>> menu bar was clicked. This circumstance has caused me to wait for couple of 
>>> minutes as several R windows were opened simultaneously.
>>>
>>> Are there any ways to speed up on this 2.9.2 version? Could someone give 
>>> some hints, please?
>>>
>>> Thank you
>>> Fir
>>>
>>>
>>>
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>>
>> --
>> Stephen Sefick
>>
>> Let's not spend our time and resources thinking about things that are
>> so little or so large that all they really do for us is puff us up and
>> make us feel like gods.  We are mammals, and have not exhausted the
>> annoying little problems of being mammals.
>>
>>                                 -K. Mullis
>>
>>
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 speed up R with version 2.9.2?

2009-10-02 Thread Gabor Grothendieck
Its under 5 seconds on my Vista laptop.  Do you have any startup files?  If
  Rgui --vanilla
is much faster then your startup files are the problem.

On Fri, Oct 2, 2009 at 11:45 AM, FMH  wrote:
> Thank you for your answer. I'm using Win XP with 2GB RAM in memory.
>
> Cheers
> Fir
>
>
>
> - Original Message 
> From: stephen sefick 
> To: FMH 
> Cc: r-help@r-project.org
> Sent: Fri, October 2, 2009 4:38:10 PM
> Subject: Re: [R] How to speed up R with version 2.9.2?
>
> You're fine, but please do read the posting guide.  What OS etc.
> Where you doing anything else on the computer?  Is this a RAM
> limitation?  I have 2.9.2 running on two flavours of linux, mac os x
> and windows all 2.9.2 and there doesn't seem to be a problem.
> regards,
>
> Stephen
>
> On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
>> Dear All,
>>
>> I'm sorry if my question does not suit with this R group.
>>
>> I have recently installed R software with version 2.9.2, but i found the 
>> program took almost 1 minute as soon as it was opened, before it can be 
>> used. However, the previous version 2.9.1 only take few seconds after the 
>> menu bar was clicked. This circumstance has caused me to wait for couple of 
>> minutes as several R windows were opened simultaneously.
>>
>> Are there any ways to speed up on this 2.9.2 version? Could someone give 
>> some hints, please?
>>
>> Thank you
>> Fir
>>
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Stephen Sefick
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>                                 -K. Mullis
>
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] How to speed up R with version 2.9.2?

2009-10-02 Thread Erik Iverson
Sorry, original replied to wrong post... 

Do you happen to have a large .Rdata file that is being loaded, or something in 
your .Rprofile?  Try searching for a file with that name.  Or start R with a 
--vanilla and see if that helps...

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of FMH
> Sent: Friday, October 02, 2009 10:35 AM
> To: r-help@r-project.org
> Subject: [R] How to speed up R with version 2.9.2?
> 
> Dear All,
> 
> I'm sorry if my question does not suit with this R group.
> 
> I have recently installed R software with version 2.9.2, but i found the
> program took almost 1 minute as soon as it was opened, before it can be
> used. However, the previous version 2.9.1 only take few seconds after the
> menu bar was clicked. This circumstance has caused me to wait for couple
> of minutes as several R windows were opened simultaneously.
> 
> Are there any ways to speed up on this 2.9.2 version? Could someone give
> some hints, please?
> 
> Thank you
> Fir
> 
> 
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 speed up R with version 2.9.2?

2009-10-02 Thread FMH
Thank you for your answer. I'm using Win XP with 2GB RAM in memory.

Cheers
Fir



- Original Message 
From: stephen sefick 
To: FMH 
Cc: r-help@r-project.org
Sent: Fri, October 2, 2009 4:38:10 PM
Subject: Re: [R] How to speed up R with version 2.9.2?

You're fine, but please do read the posting guide.  What OS etc.
Where you doing anything else on the computer?  Is this a RAM
limitation?  I have 2.9.2 running on two flavours of linux, mac os x
and windows all 2.9.2 and there doesn't seem to be a problem.
regards,

Stephen

On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
> Dear All,
>
> I'm sorry if my question does not suit with this R group.
>
> I have recently installed R software with version 2.9.2, but i found the 
> program took almost 1 minute as soon as it was opened, before it can be used. 
> However, the previous version 2.9.1 only take few seconds after the menu bar 
> was clicked. This circumstance has caused me to wait for couple of minutes as 
> several R windows were opened simultaneously.
>
> Are there any ways to speed up on this 2.9.2 version? Could someone give some 
> hints, please?
>
> Thank you
> Fir
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick

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

                                -K. Mullis





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


Re: [R] decision trees using the Hellinger distance rather than

2009-10-02 Thread Erik Iverson
Do you happen to have a large .Rdata file that is being loaded, or something in 
your .Rprofile?  Try searching for a file with that name.  Or start R with a 
--vanilla and see if that helps... 

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Rajarshi Guha
> Sent: Friday, October 02, 2009 10:33 AM
> To: R
> Subject: [R] decision trees using the Hellinger distance rather than
> 
> Hi, while working with decision trees and unbalanced data, I came across
> the
> use of the Hellinger distance as an alternative to information gain [1,2],
> when dealing with skewed data. Does anybody know of R implementations of
> this approach to decision trees?
> 
> Thanks,
> 
> [1] http://www.cse.nd.edu/Reports/2008/TR-2008-06.pdf
> [2] http://csmr.ca.sandia.gov/~wpk/slides/wdmda-sem.pdf
> --
> Rajarshi Guha
> NIH Chemical Genomics Center
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] How to speed up R with version 2.9.2?

2009-10-02 Thread stephen sefick
You're fine, but please do read the posting guide.  What OS etc.
Where you doing anything else on the computer?  Is this a RAM
limitation?  I have 2.9.2 running on two flavours of linux, mac os x
and windows all 2.9.2 and there doesn't seem to be a problem.
regards,

Stephen

On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
> Dear All,
>
> I'm sorry if my question does not suit with this R group.
>
> I have recently installed R software with version 2.9.2, but i found the 
> program took almost 1 minute as soon as it was opened, before it can be used. 
> However, the previous version 2.9.1 only take few seconds after the menu bar 
> was clicked. This circumstance has caused me to wait for couple of minutes as 
> several R windows were opened simultaneously.
>
> Are there any ways to speed up on this 2.9.2 version? Could someone give some 
> hints, please?
>
> Thank you
> Fir
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick

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

-K. Mullis

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


[R] decision trees using the Hellinger distance rather than

2009-10-02 Thread Rajarshi Guha
Hi, while working with decision trees and unbalanced data, I came across the
use of the Hellinger distance as an alternative to information gain [1,2],
when dealing with skewed data. Does anybody know of R implementations of
this approach to decision trees?

Thanks,

[1] http://www.cse.nd.edu/Reports/2008/TR-2008-06.pdf
[2] http://csmr.ca.sandia.gov/~wpk/slides/wdmda-sem.pdf
-- 
Rajarshi Guha
NIH Chemical Genomics Center

[[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] How to speed up R with version 2.9.2?

2009-10-02 Thread FMH
Dear All,

I'm sorry if my question does not suit with this R group.

I have recently installed R software with version 2.9.2, but i found the 
program took almost 1 minute as soon as it was opened, before it can be used. 
However, the previous version 2.9.1 only take few seconds after the menu bar 
was clicked. This circumstance has caused me to wait for couple of minutes as 
several R windows were opened simultaneously.

Are there any ways to speed up on this 2.9.2 version? Could someone give some 
hints, please?

Thank you
Fir




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ggplot2: proper use of facet_grid inside a function

2009-10-02 Thread Bryan Hanson
Hello Again R Folk:

I have found items about this in the archives, but I’m still not getting
it right.  I want to use ggplot2 with facet_grid inside a function with
user specified variables, for instance:

p <- ggplot(data, aes_string(x = fac1, y = res)) + facet_grid(. ~
fac2)

Where data, fac1, fac2 and res are arguments to the function.  I have
tried

p <- ggplot(data, aes_string(x = fac1, y = res)) + facet_grid(. ~
as.name(fac2))

and 

p <- ggplot(data, aes_string(x = fac1, y = res)) + facet_grid(“. ~
fac2”)

But all of these produce the same error:

Error in `[.data.frame`(plot$data, , setdiff(cond, names(df)), drop =
FALSE) : 
  undefined columns selected

If I hardwire the true identity of fac2 into the function, it works as
desired, so I know this is a problem of connecting the name with the
proper value.

I'm up to date on everything:

R version 2.9.2 (2009-08-24) 
i386-apple-darwin8.11.1 

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] Hmisc_3.6-0ggplot2_0.8.3  reshape_0.8.3 
proto_0.3-8   
 [5] mvbutils_2.2.0 ChemoSpec_1.1  lattice_0.17-25   
mvoutlier_1.4 
 [9] plyr_0.1.8 RColorBrewer_1.0-2 chemometrics_0.4   som_0.3-4 
   
[13] robustbase_0.4-5   rpart_3.1-45   pls_2.1-0  pcaPP_1.7 
   
[17] mvtnorm_0.9-7  nnet_7.2-48mclust_3.2
MASS_7.2-48   
[21] lars_0.9-7 e1071_1.5-19   class_7.2-48  

loaded via a namespace (and not attached):
[1] cluster_1.12.0

Thanks for any help!  Bryan
*
Bryan Hanson
Professor of Chemistry & Biochemistry
DePauw University, Greencastle IN USA

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


Re: [R] Robust ANOVA with variance heterogeneity

2009-10-02 Thread Kjetil Halvorsen
On Fri, Oct 2, 2009 at 8:45 AM, David Winsemius  wrote:
> There are multiple routes to "robust" statistics, but the quick answer to
> this question is probably friedman.test

I don't think friedman.test is robust to variance heterogeneity. It is
only robust to
non-normality.

Kjetil



>
> I seem to remember a CRAN Task View on the area of Robust Statistics.
>
> --
> David Winsemius
>
>
> On Oct 2, 2009, at 3:05 AM, Maike Luhmann wrote:
>
>> Dear list members,
>>
>> I am looking for an alternative function for a two-way ANOVA in the case
>> of
>> variance heterogeneity. For one-way ANOVA, I found oneway.test(), but I
>> didn't find anything alike for two-way ANOVA. Does anyone have a
>> suggestion?
>>
>> Thank you!
>>
>> Maike Luhmann
>> Freie Universität Berlin
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 files, \itemize in \value

2009-10-02 Thread Duncan Murdoch

On 10/2/2009 9:05 AM, Gábor Csárdi wrote:

Dear All,

how can I create a list in the \value{} section of an Rd file? The
things I have tried:

1.

\value{
text text
\item more text
\item even more
}

*** Syntax error: \item in
/-
\item more text
\item even more\-

2.

\value{
text text
\item{more text}
\item{even more}
}

This gives no error or warning, but the manual page looks as


The value section is like the \arguments section, there's an implicit 
\describe around everything.




Value:
 text text

more text: Numeric scalar giving the minimum correlation for
  convergence.

even more: Numeric scalar giving the minimum correlation for
  convergence.


That looks like a bug:  you should have got nothing for the second arg 
(or an error/warning that it was missing).





The "Numeric..." text is coming from the last \item{} in arguments{}...

3.

\value{
text text
\itemize{
\item{more text}
\item{even more}
}
}

Gives the same result as 2, but with a warning


The itemize style of list has zero-arguments on \item.  So that's really 
a bug if "Numeric scalar..." is showing up here.



Is there a proper way?


If you want a \describe style of list, just enter items as

\item{name}{description}

If you want an itemize style of list, enter it as

\itemize{
  \item content
  \item more content
}

Thanks for the report...

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] break up a string into strings with a fixed length

2009-10-02 Thread William Dunlap

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of jim holtman
> Sent: Friday, October 02, 2009 5:09 AM
> To: Gabor Grothendieck
> Cc: r-help@r-project.org; J Chen
> Subject: Re: [R] break up a string into strings with a fixed length
> 
> But it misses the last set if not a multiple of the subset length:
> 
> > library(gsubfn)
> > s <- "abcdefghijklm"
> >
> > # no 'm'
> > strapply(s, "...")[[1]]
> [1] "abc" "def" "ghi" "jkl"
> >

Perhaps the pattern ".{1,3}" would do it.

S+'s strapply has a keep=FALSE/TRUE argument.  If FALSE,
the default, it omits that parts of string that match the pattern
as R's strapply does.  If TRUE it keeps the parts of the string
that match the pattern and omits the parts that do not.  I added
it to make it easier to pull all the numbers out of a string that
might include commas, spaces, and words but it works in this
case also:

  > s<-sapply(1:10, function(i)substring("abcdefghij",1,i))
  > strsplit(s, ".{1,3}", keep=TRUE)[c(1,3,4,9,10)]
  [[1]]:
  [1] "a"

  [[2]]:
  [1] "abc"

  [[3]]:
  [1] "abc" "d"  

  [[4]]:
  [1] "abc" "def" "ghi"

  [[5]]:
  [1] "abc" "def" "ghi" "j"  

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
> 
> 
> On Fri, Oct 2, 2009 at 7:58 AM, Gabor Grothendieck
>  wrote:
> > Try this:
> >
> >> library(gsubfn)
> >> s <- "abcdefghijkl"
> >
> >> strapply(s, "...")[[1]]
> > [1] "abc" "def" "ghi" "jkl"
> >
> >
> > On Fri, Oct 2, 2009 at 5:36 AM, J Chen 
>  wrote:
> >>
> >> dear all,
> >>
> >> I have some very long strings and would like to break up 
> each long string
> >> into multiple strings with a fixed length, e.g. to break up
> >>
> >> abcdefghijkl
> >>
> >> into
> >>
> >> abc, def, ghi, jkl
> >>
> >> I tried a couple of commands but was not successful. Any 
> help will be
> >> appreciated.
> >>
> >> Best,
> >> Jimmy
> >> --
> >> View this message in context: 
> http://www.nabble.com/break-up-a-string-into-strings-with-a-fi
> xed-length-tp25712955p25712955.html
> >> Sent from the R help mailing list archive at Nabble.com.
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> -- 
> 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 select a subset

2009-10-02 Thread Steve Lianoglou

Hi,

On Oct 2, 2009, at 10:47 AM, Hyo Lee wrote:


Hi guys,
I need your help.

I would like to select a subset from a dataset.
This is the dimension of the dataset.


dim(data1)

[1]   72   36 1916

so, it's like.. there are 1916 of  72 * 36 matrix. ==> looks like 72  
* (

36*1916 )
**
*1)*
And I would like to select the first 72*36 matrix. This is how I did:


two=data1[,1:36]

Error in data1[, 1:36] : incorrect number of dimensions


You have an object with three dimensions, but only passing in two dims  
to "slice" with.


Do you have any idea how I should fix this?


This is a similar array : think of it as 5 10x2 matrices

R> m <- array(1:100, dim=c(10,2,5))

I can get the first 10x2 matrix like so:

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

The second would be: m[,,2]

Does answering the first question take care of the rest?

-steve




*2) *I thought about another way to deal with this problem.
Firstly, I name the each column variable:


colnames(data1)=paste('lati',1:36)


and then select:


one=subset(data1,subset=TRUE, select = lati1:lati36)


but the problem is that, although I tried to select only 36 columns,  
above

command selects the all columns. (36*1916  =68976)
I think if I can name all the variables at one time, say ,
colnames(data1)=paste('lati',1:68976) ,then it wouldn't have been a  
problem.

(but obviously, <---this command does not work)
Do you have any idea how to deal with this??


*3)* After all, what I would really like to do is to transpose the  
data:
The dataset I have above is 72*68976. (hard to export to csv; since  
max

column# is 18000 something.)
I have to transpose the data.. obviously.
But, the problem is,  after I transpose the data and export it to  
csv, I

can't really see the data.
Besides, I think tranpose thing does not seem work as I want,

bbb=t(as.matrix(data1))
write.csv(bbb,"c:/oo.csv")


Please help me,
Thanks.

-Hyo

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


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

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


Re: [R] svDialogs

2009-10-02 Thread Tubin

Download the package to your hard drive from here:
http://cran.r-project.org/web/packages/svDialogs/ 

Then install directly using install.packages (for instructions on doing
this, type ?install.packages)

Just tried it, worked fine for me.


Hi there,

I was using Open/Save-dialogs from the package svDialogs (SciViews). But now 
the package has dissapeared? How do I have to set up my R-installation to 
further use these dialogs??? (beside copying my old packages to the new 
installation).

Ciao,
Antje

-- 
View this message in context: 
http://www.nabble.com/svDialogs-tp22539778p25716506.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 select a subset

2009-10-02 Thread Hyo Lee
Hi guys,
I need your help.

I would like to select a subset from a dataset.
This is the dimension of the dataset.

> dim(data1)
[1]   72   36 1916

so, it's like.. there are 1916 of  72 * 36 matrix. ==> looks like 72 * (
36*1916 )
**
*1)*
And I would like to select the first 72*36 matrix. This is how I did:

> two=data1[,1:36]
Error in data1[, 1:36] : incorrect number of dimensions

Do you have any idea how I should fix this?


*2) *I thought about another way to deal with this problem.
Firstly, I name the each column variable:

>colnames(data1)=paste('lati',1:36)

and then select:

>one=subset(data1,subset=TRUE, select = lati1:lati36)

but the problem is that, although I tried to select only 36 columns, above
command selects the all columns. (36*1916  =68976)
I think if I can name all the variables at one time, say ,
colnames(data1)=paste('lati',1:68976) ,then it wouldn't have been a problem.
(but obviously, <---this command does not work)
Do you have any idea how to deal with this??


*3)* After all, what I would really like to do is to transpose the data:
The dataset I have above is 72*68976. (hard to export to csv; since max
column# is 18000 something.)
I have to transpose the data.. obviously.
But, the problem is,  after I transpose the data and export it to csv, I
can't really see the data.
Besides, I think tranpose thing does not seem work as I want,
>bbb=t(as.matrix(data1))
>write.csv(bbb,"c:/oo.csv")

Please help me,
Thanks.

-Hyo

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

2009-10-02 Thread Philippe Grosjean

Hello,

Now, the *bundle* SciViews has disappeared from CRAN, but the *package* 
svDialogs is still there.

Best,

Philippe
..<°}))><
 ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
 ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
 ) ) ) ) )   Mons University, Belgium
( ( ( ( (
..

Tubin wrote:

Did you ever get a response on this?  I have been having a similar problem.

Thanks,
Sarah


antje-4 wrote:

Hi there,

I was using Open/Save-dialogs from the package svDialogs (SciViews). But
now 
the package has dissapeared? How do I have to set up my R-installation to 
further use these dialogs??? (beside copying my old packages to the new 
installation).


Ciao,
Antje

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

2009-10-02 Thread David Winsemius


On Oct 1, 2009, at 6:06 AM, KABELI MEFANE wrote:


Dear Helpers

I have a sample frame and i have sampled from it using three methods  
and now i want to calculate the statistics but i only get the  
population parameters.


H <- matrix(rnorm(100, mean=5, sd=5000))
sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe

str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat


If you want the number of rows in sample.strat then length(H) is the  
wrong approach since that is the original (unsampled) object.



length(H)
i get:

length(H)
[1] 100

Desire to get:
length(H)
[1] 20


I cannot tell what packages you have loaded and strata is not in the  
sampling package which I guessed (wrongly) was where you were getting  
"getdata". When you post code you should precede that code with calls  
that load any non-base packages.


In later posting you ask for ways to calculate "the sum" but you do  
not say what it is that you want the sum of . Our abilities to  
read minds is extremely limited.


--
David Winsemius

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


Re: [R] svDialogs

2009-10-02 Thread Tubin

Did you ever get a response on this?  I have been having a similar problem.

Thanks,
Sarah


antje-4 wrote:
> 
> Hi there,
> 
> I was using Open/Save-dialogs from the package svDialogs (SciViews). But
> now 
> the package has dissapeared? How do I have to set up my R-installation to 
> further use these dialogs??? (beside copying my old packages to the new 
> installation).
> 
> Ciao,
> Antje
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

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

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


Re: [R] How to use Subpopulation data?

2009-10-02 Thread KABELI MEFANE
Thank you very much!!
 
To trouble you again: I cannot do the sum and i have looked at several package 
since startng with this problem. I have a very large code just to do simple 
random, normal stratified sampling with proportional allocation and Dollar 
stratification with Neyman allocation using that dataframe i created. Now the 
code its becoming very large i just wish i could just call everything by the 
same name it was called in the original data frame, i tried usiing attach with 
no success. Therefore if you can just help me calculate the sum and mean then i 
will learn how to shorten this code. 
 
Thanks once again you really helped a lot.Thanks 

--- On Fri, 2/10/09, Bernardo Rangel Tura  wrote:


From: Bernardo Rangel Tura 
Subject: Re: [R] How to use Subpopulation data?
To: "KABELI MEFANE" 
Cc: R-help@r-project.org
Date: Friday, 2 October, 2009, 10:08 AM


On Fri, 2009-10-02 at 00:42 +, KABELI MEFANE wrote:
> Thanks
> 
> But it seems like you don't get my problem.Do you mean that there is 
> something wrong with the code as it seems like what you are doing is 
> suggesting different ways to write a code. 
> 
> Will i get to use the variable that have been name previously like if i want 
> to calculate the standard deviation of stratum hypermarket in a sample not 
> population, the first start is to check if it would help me is to check the 
> length() of different levels if it is not same as that of the original data
> 
> Best Regards
> 
> I rest my case, i might dream it

Sorry

I don't understand your problem early.

In your case you have 2 data.frames: sampleframe and sample.strat so you
need show to R where calculate sd or length or summary


set.seed(1)# only to make this example don't use in your code
stra<-strata(sampleframe,c("type"),size=c(20,80,200,300,400),method="srswor")
sample.strat<-getdata(sampleframe,stra)

length of value in sampleframe where type is Hypermarket:
> length(sampleframet$value[sampleframe$type=="Hypermarket"]) 
[1] 100

SD of value in sampleframe where type is Hypermarket:
> sd(sampleframe$value[sampleframet$type=="Hypermarket"])
[1] 4586.854

length of value in sample.strat where type is Hypermarket:
> length(sample.strat$value[sample.strat$type=="Hypermarket"] )
[1] 20

SD of value in sample.strat where type is Hypermarket:
> sd(sample.strat$value[sample.strat$type=="Hypermarket"] )
[1] 4679.336


-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil




  
[[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] Fetch large sized file from SQL

2009-10-02 Thread Corrado
I think you can specify the number of rows to be loaded at a time.  It was 
quite a while ago. Try reading

?sqlQuery
?odbcConnect

I have loaded quite large tables.

On Friday 02 October 2009 14:59:59 Dr. Alireza Zolfaghari wrote:
> But the problem is that the dataframe size in sql is large, therefore odbc
> can sqlQuery() can not handel it.
>
> On Fri, Oct 2, 2009 at 2:14 PM, Corrado  wrote:
> > You can try using RODBC, it allows you to connect to databases using the
> > ODBC
> > driver.
> >
> > I had some difficulties using it with the postgresSQL driver in the past,
> > because of some apparent incompatibility with the native postrgesSQL ODBC
> > driver. I think the problem where solved by the new ODBC driver for
> > postgresSQL and the new revision for RODBC.
> >
> > On Friday 02 October 2009 13:56:02 Dr. Alireza Zolfaghari wrote:
> > > Hi List,
> > > Does any one know what package I need to use in order to fetch/get a
> >
> > large
> >
> > > sized dataframe from SQL? I have already used sqldf package which is
> > > good for fetching large sized csv files.
> > >
> > > Thanks
> > > Alireza
> > >
> > >   [[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 > >sting-guide.html>and provide commented, minimal, self-contained,
> > > reproducible code.
> >
> > --
> > Corrado Topi
> >
> > Global Climate Change & Biodiversity Indicators
> > Area 18,Department of Biology
> > University of York, York, YO10 5YW, UK
> > Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk



-- 
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] confint fails in quasibinomial glm: dims do not match

2009-10-02 Thread joris meys
Confint doesn't work if you have a multi-dimensional dependent variable.

Kind regards
Joris

On Fri, Oct 2, 2009 at 4:29 AM, smith_cc  wrote:
>
> I am unable to calculate confidence intervals for the slope estimate in a
> quasibinomial glm using confint(). Below is the output and the package info
> for MASS. Thanks in advance!
>
> R 2.9.2
> MASS 7.2-48
>
>> confint(glm.palive.0.str)
> Waiting for profiling to be done...
> Error: dims [product 37] do not match the length of object [74]
>> glm.palive.0.str
>
> Call:  glm(formula = cbind(alive, red) ~ str, family = quasibinomial,
> data = subset(master.palive, vtime == 0))
>
> Coefficients:
> (Intercept)         strs
>       1.05         1.01
>
> Degrees of Freedom: 36 Total (i.e. Null);  35 Residual
> Null Deviance:      20800
> Residual Deviance: 16200        AIC: NA
>
>> packageDescription("MASS")
> Bundle: VR
> Contains: MASS class nnet spatial
> Priority: recommended
> Version: 7.2-48
> Date: 2009-07-29
> Depends: R (>= 2.5.0), grDevices, graphics, stats, utils
> Suggests: lattice, nlme, survival
> Author: S original by Venables & Ripley. R port by Brian Ripley
> , following earlier work by Kurt Hornik and Albrecht
>                Gebhardt.
> Maintainer: Brian Ripley 
> BundleDescription: Functions and datasets to support Venables and Ripley,
> 'Modern Applied Statistics with S' (4th edition).
> License: GPL-2 | GPL-3
> URL: http://www.stats.ox.ac.uk/pub/MASS4/
> Packaged: 2009-07-31 13:56:57 UTC; ripley
> Repository: CRAN
> Date/Publication: 2009-08-05 11:20:53
> Package: MASS
> Description: The main library and the datasets
> Title: Main Package of Venables and Ripley's MASS
> LazyLoad: yes
> LazyData: yes
> Built: R 2.9.2; i686-pc-linux-gnu; 2009-08-25 10:52:10 UTC; unix
>
> Cheers,
> Chad
> --
> View this message in context: 
> http://www.nabble.com/confint-fails-in-quasibinomial-glm%3A-dims-do-not-match-tp25709756p25709756.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Fetch large sized file from SQL

2009-10-02 Thread Dr. Alireza Zolfaghari
But the problem is that the dataframe size in sql is large, therefore odbc
can sqlQuery() can not handel it.

On Fri, Oct 2, 2009 at 2:14 PM, Corrado  wrote:

> You can try using RODBC, it allows you to connect to databases using the
> ODBC
> driver.
>
> I had some difficulties using it with the postgresSQL driver in the past,
> because of some apparent incompatibility with the native postrgesSQL ODBC
> driver. I think the problem where solved by the new ODBC driver for
> postgresSQL and the new revision for RODBC.
>
> On Friday 02 October 2009 13:56:02 Dr. Alireza Zolfaghari wrote:
> > Hi List,
> > Does any one know what package I need to use in order to fetch/get a
> large
> > sized dataframe from SQL? I have already used sqldf package which is good
> > for fetching large sized csv files.
> >
> > Thanks
> > Alireza
> >
> >   [[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.htmland
> >  provide commented, minimal,
> > self-contained, reproducible code.
>
>
>
> --
> Corrado Topi
>
> Global Climate Change & Biodiversity Indicators
> Area 18,Department of Biology
> University of York, York, YO10 5YW, UK
> Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk
>
>

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

2009-10-02 Thread David Winsemius


On Oct 2, 2009, at 9:46 AM, Ashta wrote:

I have more than three lines in one  and I want to add a legend  for  
each

line

abline( m1, col = 'red' )
ablime( m2, col = 'blue' )
abline( m3, col = 'purple' )

How can I add a legend? . Is it also possible to increase the  
thickness of

the lines?


?abline and this time pay closer attention to the lwd parameter.

The answer to the legend question may depend on the details of the  
plot call, but I am unclear why you have not yet tried:


?legend

I am getting the impression that you are not taking advantage of R's  
help system.


--
David Winsemius

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


Re: [R] Legend

2009-10-02 Thread Gábor Csárdi
On Fri, Oct 2, 2009 at 3:46 PM, Ashta  wrote:
> I have more than three lines in one  and I want to add a legend  for each
> line
>
> abline( m1, col = 'red' )
> ablime( m2, col = 'blue' )
> abline( m3, col = 'purple' )
>
> How can I add a legend? .

Surprisingly, it is the legend() function. See ?legend.

>  Is it also possible to increase the thickness of
> the lines?

It is, see the 'lwd' parameter in ?par.

Best,
Gabor

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



-- 
Gabor Csardi  UNIL DGM

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

2009-10-02 Thread Ashta
I have more than three lines in one  and I want to add a legend  for each
line

abline( m1, col = 'red' )
ablime( m2, col = 'blue' )
abline( m3, col = 'purple' )

How can I add a legend? . Is it also possible to increase the thickness of
the lines?

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] Fetch large sized file from SQL

2009-10-02 Thread Corrado
You can try using RODBC, it allows you to connect to databases using the ODBC 
driver. 

I had some difficulties using it with the postgresSQL driver in the past, 
because of some apparent incompatibility with the native postrgesSQL ODBC 
driver. I think the problem where solved by the new ODBC driver for 
postgresSQL and the new revision for RODBC.

On Friday 02 October 2009 13:56:02 Dr. Alireza Zolfaghari wrote:
> Hi List,
> Does any one know what package I need to use in order to fetch/get a large
> sized dataframe from SQL? I have already used sqldf package which is good
> for fetching large sized csv files.
>
> Thanks
> Alireza
>
>   [[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.



-- 
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] Problem with dist (bug?)

2009-10-02 Thread Corrado
Dear list,

here is the code that generates the problem:

library(proxy)
scot<-read.csv("scot.csv",header=TRUE)
scot24_climate<-scot24[,1105:1109]

# Scotland
dist_scot24_climate<-
dist(scot24_climate,method="correlation",diag=TRUE,upper=TRUE)

max(dist_scot24_climate)  

is 1.9. I do not think it should be, because the value is usually the cos() of 
the angle between the 2 vectors. If you use method="cosine" you have  1.8, 
which I think it should not be.

Is there a problem with the way I use it, or is there a bug?

I have been able to reduce the scot.csv to under 200MB, but I thought of not 
posting it to the list 

> We need to see the data and the script that produced the error.
>
> On Fri, Oct 2, 2009 at 5:06 AM, Corrado  wrote:
> > Dear list,
> >
> > using package "proxy".
> >


> > In one situation, the dissimilarity between two vectors based on
> > method=correlation returns a value of 1.9. That should not happen, should
> > it?
> >
> > The correlation is normally the cos() of the angle between the two
> > vectors 
> >
> > Any clue?
> >
> > Package dist 0.4-3 on R 2.9.2 on Kubuntu 904 64 bit.
> >
> > Regards
> > --
> > Corrado Topi
> >
> > Global Climate Change & Biodiversity Indicators
> > Area 18,Department of Biology
> > University of York, York, YO10 5YW, UK
> > Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html and provide commented,
> > minimal, self-contained, reproducible code.



-- 
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] split-apply question

2009-10-02 Thread hadley wickham
On Fri, Oct 2, 2009 at 4:24 AM, jim holtman  wrote:
> try this:
>
>> x <- read.table(textConnection("x1  x2  x3
> + A   1    1.5
> + B   2    0.9
> + B   3    2.7
> + C   7    1.8
> + D   7    1.3"), header=TRUE)
>> closeAllConnections()
>> do.call(rbind, lapply(split(seq(nrow(x)), x$x1), function(.row){
> +     x[.row[which.min(x$x2[.row])],]
> + }))
>  x1 x2  x3
> A  A  1 1.5
> B  B  2 0.9
> C  C  7 1.8
> D  D  7 1.3
>>

Or, using plyr and subset

library(plyr)
ddply(x, "x1", subset, x2 == min(x2))

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] Rd files, \itemize in \value

2009-10-02 Thread Gábor Csárdi
Dear All,

how can I create a list in the \value{} section of an Rd file? The
things I have tried:

1.

\value{
text text
\item more text
\item even more
}

*** Syntax error: \item in
/-
\item more text
\item even more\-

2.

\value{
text text
\item{more text}
\item{even more}
}

This gives no error or warning, but the manual page looks as

Value:
 text text

more text: Numeric scalar giving the minimum correlation for
  convergence.

even more: Numeric scalar giving the minimum correlation for
  convergence.


The "Numeric..." text is coming from the last \item{} in arguments{}...

3.

\value{
text text
\itemize{
\item{more text}
\item{even more}
}
}

Gives the same result as 2, but with a warning

Is there a proper way?

Thanks,
Gabor

-- 
Gabor Csardi  UNIL DGM

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


Re: [R] inverse currying

2009-10-02 Thread baptiste auguie
After some more digging (grep "alist" R-devel/ ), I've come up with this,

tools:::as.alist.symbol("x")

sugar = function(fun, id = "id"){
 ff <- formals(fun)
 if( id %in% names(ff))
   stop(paste(id, "is part of args(fun)"))

 new.arg <- tools:::as.alist.symbol(id)

 formals(fun) <- c(unlist(ff), new.arg)
 fun

}

foo = function(x, a=1){
 x
}

sugar(foo)
sugar(foo, 'a')
sugar(sugar(foo))

sugar(foo, 'my.new.arg')


Best,

baptiste



2009/10/1 baptiste auguie :
> Dear list,
>
> I have the following function,
>
> sugar = function(fun, id = "id"){
>  ff <- formals(fun)
>  if( id %in% names(ff))
>    stop("id is part of args(fun)")
>  formals(fun) <- c(unlist(ff), alist(id=))
>  fun
> }
>
> which one may use on a function foo,
>
> foo = function(x){
>  x
> }
>
> sugar(foo) # results in the extended closure,
>
> function (x, id)
> {
>    x
> }
>
> Its limitation (other than not working with .Primitives) is the 'id'
> tag that I add in the formals of fun(). I don't know how to create a
> alist(id=) pairlist where id can be changed. I tried the usual bquote
> and substitute approach but they don't seem to work here. I suppose I
> could do something like,
>
> parse(text = paste("alist(",id, "=)", sep=""))
>
> but this is usually not recommended.
>
> Any ideas?
>
> Best regards,
>
> baptiste
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fetch large sized file from SQL

2009-10-02 Thread Dr. Alireza Zolfaghari
Hi List,
Does any one know what package I need to use in order to fetch/get a large
sized dataframe from SQL? I have already used sqldf package which is good
for fetching large sized csv files.

Thanks
Alireza

[[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] split-apply question

2009-10-02 Thread Henrique Dallazuanna
You can use aggregate:

aggregate(x[,c('x2','x3')], x['x1'], min)

On Fri, Oct 2, 2009 at 12:43 AM, Kavitha Venkatesan
 wrote:
> Hi,
>
> I have a data frame that looks like this:
>
>>x
>
> x1  x2  x3
> A   1    1.5
> B   2    0.9
> B   3    2.7
> C   7    1.8
> D   7    1.3
>
> I want to "group" by the x1 column and in the case of multiple x$x1 values
> (e.g., "B")d, return rows that have the smallest values of x2. In the case
> of rows with only one value of x1 (e.g., "A"), return the row as is. How can
> I do that?  For example, in the above case, the output I want would be:
>
> x1  x2  x3
> A   1    1.5
> B   2    0.9
> C   7    1.8
> D   7    1.3
>
>
> 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.
>



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

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


Re: [R] Robust ANOVA with variance heterogeneity

2009-10-02 Thread David Winsemius
There are multiple routes to "robust" statistics, but the quick answer  
to this question is probably friedman.test


I seem to remember a CRAN Task View on the area of Robust Statistics.

--
David Winsemius


On Oct 2, 2009, at 3:05 AM, Maike Luhmann wrote:


Dear list members,

I am looking for an alternative function for a two-way ANOVA in the  
case of
variance heterogeneity. For one-way ANOVA, I found oneway.test(),  
but I
didn't find anything alike for two-way ANOVA. Does anyone have a  
suggestion?


Thank you!

Maike Luhmann
Freie Universität Berlin


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


Re: [R] split-apply question

2009-10-02 Thread David Winsemius
As is typical with R there are often other ways. Here is another  
approach that determines the rows of interest with tapply and min,  
converts those minimums into logical "targets" with %in%, and extracts  
them from "x" using indexing:


x[x$x2 %in% tapply(x$x2, x$x1, min), ]


  x1 x2  x3
1  A  1 1.5
2  B  2 0.9
4  C  7 1.8
5  D  7 1.3

You might want to determine whether both would return all rows if  
there were multiple instances of a minimum. I think the above solution  
would return multiples while the one below would not. You choose based  
on the nature of the problem.


--
David


On Oct 2, 2009, at 5:24 AM, jim holtman wrote:


try this:


x <- read.table(textConnection("x1  x2  x3

+ A   11.5
+ B   20.9
+ B   32.7
+ C   71.8
+ D   71.3"), header=TRUE)

closeAllConnections()
do.call(rbind, lapply(split(seq(nrow(x)), x$x1), function(.row){

+ x[.row[which.min(x$x2[.row])],]
+ }))
 x1 x2  x3
A  A  1 1.5
B  B  2 0.9
C  C  7 1.8
D  D  7 1.3





On Thu, Oct 1, 2009 at 11:43 PM, Kavitha Venkatesan
 wrote:

Hi,

I have a data frame that looks like this:


x


x1  x2  x3
A   11.5
B   20.9
B   32.7
C   71.8
D   71.3

I want to "group" by the x1 column and in the case of multiple x$x1  
values
(e.g., "B")d, return rows that have the smallest values of x2. In  
the case
of rows with only one value of x1 (e.g., "A"), return the row as  
is. How can
I do that?  For example, in the above case, the output I want would  
be:


x1  x2  x3
A   11.5
B   20.9
C   71.8
D   71.3


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.





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


Re: [R] break up a string into strings with a fixed length

2009-10-02 Thread Gabor Grothendieck
That part wasn't specified so we can't say what the required behavior
is in that case; however, if a non-multiple of 3 were possible and if
the short string is to be emitted at the end then we can just add to
the regular expression:

> library(gsubfn)
> s <- paste(letters, collapse = "")

> strapply(s, "...|..$|.$", c)[[1]]
[1] "abc" "def" "ghi" "jkl" "mno" "pqr" "stu" "vwx" "yz"

On Fri, Oct 2, 2009 at 8:08 AM, jim holtman  wrote:
> But it misses the last set if not a multiple of the subset length:
>
>> library(gsubfn)
>> s <- "abcdefghijklm"
>>
>> # no 'm'
>> strapply(s, "...")[[1]]
> [1] "abc" "def" "ghi" "jkl"
>>
>
>
> On Fri, Oct 2, 2009 at 7:58 AM, Gabor Grothendieck
>  wrote:
>> Try this:
>>
>>> library(gsubfn)
>>> s <- "abcdefghijkl"
>>
>>> strapply(s, "...")[[1]]
>> [1] "abc" "def" "ghi" "jkl"
>>
>>
>> On Fri, Oct 2, 2009 at 5:36 AM, J Chen  wrote:
>>>
>>> dear all,
>>>
>>> I have some very long strings and would like to break up each long string
>>> into multiple strings with a fixed length, e.g. to break up
>>>
>>> abcdefghijkl
>>>
>>> into
>>>
>>> abc, def, ghi, jkl
>>>
>>> I tried a couple of commands but was not successful. Any help will be
>>> appreciated.
>>>
>>> Best,
>>> Jimmy
>>> --
>>> View this message in context: 
>>> http://www.nabble.com/break-up-a-string-into-strings-with-a-fixed-length-tp25712955p25712955.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> 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.


Re: [R] help with regexp mass substitution

2009-10-02 Thread Gabor Grothendieck
dot (.) matches anything so be sure to escape it so that it only
matches a literal dot in your regular expression.

On Fri, Oct 2, 2009 at 5:39 AM, Luca Braglia  wrote:
> Hello *
>
> i have to rename a lot of variables, and, given that they have regular name 
> constructs, I would like to use regexps.
>
> Here's a dump of my head(names(df))
>
> varnames <- c("id.quest", "txt.1.3", "col1.1.3", "col2.1.3", "col3.1.3",
> "col4.1.3", "col5.1.3", "txt.2.3", "col1.2.3", "col2.2.3", "col3.2.3",
> "col4.2.3", "col5.2.3", "txt.3.3", "col1.3.3", "col2.3.3", "col3.3.3",
> "col4.3.3", "col5.3.3", "txt.4.3", "col1.4.3", "col2.4.3", "col3.4.3",
> "col4.4.3", "col5.4.3", "txt.5.3", "col1.5.3", "col2.5.3", "col3.5.3",
> "col4.5.3", "col5.5.3", "txt.6.3", "col1.6.3", "col2.6.3", "col3.6.3",
> "col4.6.3", "col5.6.3", "txt.7.3", "col1.7.3", "col2.7.3", "col3.7.3",
> "col4.7.3", "col5.7.3", "txt.8.3", "col1.8.3", "col2.8.3", "col3.8.3",
> "col4.8.3", "col5.8.3", "txt.9.3", "col1.9.3", "col2.9.3", "col3.9.3",
> "col4.9.3", "col5.9.3", "txt.10.3", "col1.10.3", "col2.10.3",
> "col3.10.3", "col4.10.3", "col5.10.3", "txt.11.3", "col1.11.3",
> "col2.11.3", "col3.11.3", "col4.11.3", "col5.11.3", "txt.12.3",
> "col1.12.3", "col2.12.3", "col3.12.3", "col4.12.3", "col5.12.3",
> "txt.13.3", "col1.13.3", "col2.13.3", "col3.13.3", "col4.13.3",
> "col5.13.3", "txt.14.3", "col1.14.3", "col2.14.3", "col3.14.3",
> "col4.14.3", "col5.14.3", "txt.15.3", "col1.15.3", "col2.15.3",
> "col3.15.3", "col4.15.3", "col5.15.3", "txt.16.3", "col1.16.3",
> "col2.16.3", "col3.16.3", "col4.16.3", "col5.16.3", "txt.17.3",
> "col1.17.3", "col2.17.3")
>
> I'd like to convert only ^col variables to have eg
>
> >From "col4.1.3" --> To "dom3.rig1.col4"
>
> to test the matching regex I've tryied
>
> grep("^col\\d{1,2}.\\d{1,2}.\\d{1,2}$",varnames, perl=T, value=T)
>
> to substitute the ^col variables, I've tryied
>
> gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", varnames)
>
> I'm a newbie with regexps and I got the starting vector (==varnames)
>
> all(gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", 
> varnames) == varnames )
>
> How can I do?
>
> Many thanks and have a nice weekend.
>
> Luca
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] help with regexp mass substitution

2009-10-02 Thread jim holtman
You need perl=TRUE:

gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1",
varnames, perl=TRUE)
  [1] "id.quest""txt.1.3" "dom3.rig1.col1"
"dom3.rig1.col2"  "dom3.rig1.col3"  "dom3.rig1.col4"  "dom3.rig1.col5"
  [8] "txt.2.3" "dom3.rig2.col1"  "dom3.rig2.col2"
"dom3.rig2.col3"  "dom3.rig2.col4"  "dom3.rig2.col5"  "txt.3.3"
 [15] "dom3.rig3.col1"  "dom3.rig3.col2"  "dom3.rig3.col3"
"dom3.rig3.col4"  "dom3.rig3.col5"  "txt.4.3" "dom3.rig4.col1"
 [22] "dom3.rig4.col2"  "dom3.rig4.col3"  "dom3.rig4.col4"
"dom3.rig4.col5"  "txt.5.3" "dom3.rig5.col1"  "dom3.rig5.col2"
 [29] "dom3.rig5.col3"  "dom3.rig5.col4"  "dom3.rig5.col5"  "txt.6.3"
   "dom3.rig6.col1"  "dom3.rig6.col2"  "dom3.rig6.col3"
 [36] "dom3.rig6.col4"  "dom3.rig6.col5"  "txt.7.3"
"dom3.rig7.col1"  "dom3.rig7.col2"  "dom3.rig7.col3"  "dom3.rig7.col4"
 [43] "dom3.rig7.col5"  "txt.8.3" "dom3.rig8.col1"
"dom3.rig8.col2"  "dom3.rig8.col3"  "dom3.rig8.col4"  "dom3.rig8.col5"
 [50] "txt.9.3" "dom3.rig9.col1"  "dom3.rig9.col2"
"dom3.rig9.col3"  "dom3.rig9.col4"  "dom3.rig9.col5"  "txt.10.3"
 [57] "dom3.rig10.col1" "dom3.rig10.col2" "dom3.rig10.col3"
"dom3.rig10.col4" "dom3.rig10.col5" "txt.11.3"
"dom3.rig11.col1"
 [64] "dom3.rig11.col2" "dom3.rig11.col3" "dom3.rig11.col4"
"dom3.rig11.col5" "txt.12.3""dom3.rig12.col1"
"dom3.rig12.col2"
 [71] "dom3.rig12.col3" "dom3.rig12.col4" "dom3.rig12.col5" "txt.13.3"
   "dom3.rig13.col1" "dom3.rig13.col2" "dom3.rig13.col3"
 [78] "dom3.rig13.col4" "dom3.rig13.col5" "txt.14.3"
"dom3.rig14.col1" "dom3.rig14.col2" "dom3.rig14.col3"
"dom3.rig14.col4"
 [85] "dom3.rig14.col5" "txt.15.3""dom3.rig15.col1"
"dom3.rig15.col2" "dom3.rig15.col3" "dom3.rig15.col4"
"dom3.rig15.col5"
 [92] "txt.16.3""dom3.rig16.col1" "dom3.rig16.col2"
"dom3.rig16.col3" "dom3.rig16.col4" "dom3.rig16.col5" "txt.17.3"
 [99] "dom3.rig17.col1" "dom3.rig17.col2"
>


On Fri, Oct 2, 2009 at 5:39 AM, Luca Braglia  wrote:
> Hello *
>
> i have to rename a lot of variables, and, given that they have regular name 
> constructs, I would like to use regexps.
>
> Here's a dump of my head(names(df))
>
> varnames <- c("id.quest", "txt.1.3", "col1.1.3", "col2.1.3", "col3.1.3",
> "col4.1.3", "col5.1.3", "txt.2.3", "col1.2.3", "col2.2.3", "col3.2.3",
> "col4.2.3", "col5.2.3", "txt.3.3", "col1.3.3", "col2.3.3", "col3.3.3",
> "col4.3.3", "col5.3.3", "txt.4.3", "col1.4.3", "col2.4.3", "col3.4.3",
> "col4.4.3", "col5.4.3", "txt.5.3", "col1.5.3", "col2.5.3", "col3.5.3",
> "col4.5.3", "col5.5.3", "txt.6.3", "col1.6.3", "col2.6.3", "col3.6.3",
> "col4.6.3", "col5.6.3", "txt.7.3", "col1.7.3", "col2.7.3", "col3.7.3",
> "col4.7.3", "col5.7.3", "txt.8.3", "col1.8.3", "col2.8.3", "col3.8.3",
> "col4.8.3", "col5.8.3", "txt.9.3", "col1.9.3", "col2.9.3", "col3.9.3",
> "col4.9.3", "col5.9.3", "txt.10.3", "col1.10.3", "col2.10.3",
> "col3.10.3", "col4.10.3", "col5.10.3", "txt.11.3", "col1.11.3",
> "col2.11.3", "col3.11.3", "col4.11.3", "col5.11.3", "txt.12.3",
> "col1.12.3", "col2.12.3", "col3.12.3", "col4.12.3", "col5.12.3",
> "txt.13.3", "col1.13.3", "col2.13.3", "col3.13.3", "col4.13.3",
> "col5.13.3", "txt.14.3", "col1.14.3", "col2.14.3", "col3.14.3",
> "col4.14.3", "col5.14.3", "txt.15.3", "col1.15.3", "col2.15.3",
> "col3.15.3", "col4.15.3", "col5.15.3", "txt.16.3", "col1.16.3",
> "col2.16.3", "col3.16.3", "col4.16.3", "col5.16.3", "txt.17.3",
> "col1.17.3", "col2.17.3")
>
> I'd like to convert only ^col variables to have eg
>
> >From "col4.1.3" --> To "dom3.rig1.col4"
>
> to test the matching regex I've tryied
>
> grep("^col\\d{1,2}.\\d{1,2}.\\d{1,2}$",varnames, perl=T, value=T)
>
> to substitute the ^col variables, I've tryied
>
> gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", varnames)
>
> I'm a newbie with regexps and I got the starting vector (==varnames)
>
> all(gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", 
> varnames) == varnames )
>
> How can I do?
>
> Many thanks and have a nice weekend.
>
> Luca
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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.


Re: [R] plot subscript text and percentage symbol in graph label axis

2009-10-02 Thread baptiste auguie
try this,

plot(x~y,ylab=expression(~degree~C),xlab=expression(x[2]~"%"))


baptiste

2009/10/2 e-letter :
> Readers,
>
> I am unable to plot a label consisting of both subscript text and
> percentage (%) symbol:
>
> x<-(1:10)
> y<-(200:191)
> plot(x~y,ylab=expression(~degree~C),xlab=expression(x[2]~%))
> Error: syntax error, unexpected ERROR in
> "plot(x~y,ylab=expression(~degree~C),xlab=expression(x~%)"
>
> It seems that % is a special character in R? I have looked in the
> introductory manual but can see no reference to reserved characters.
>
> Yours,
>
> rhelpatconference.jabber.org
> r251
> mandriva2008
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] break up a string into strings with a fixed length

2009-10-02 Thread jim holtman
But it misses the last set if not a multiple of the subset length:

> library(gsubfn)
> s <- "abcdefghijklm"
>
> # no 'm'
> strapply(s, "...")[[1]]
[1] "abc" "def" "ghi" "jkl"
>


On Fri, Oct 2, 2009 at 7:58 AM, Gabor Grothendieck
 wrote:
> Try this:
>
>> library(gsubfn)
>> s <- "abcdefghijkl"
>
>> strapply(s, "...")[[1]]
> [1] "abc" "def" "ghi" "jkl"
>
>
> On Fri, Oct 2, 2009 at 5:36 AM, J Chen  wrote:
>>
>> dear all,
>>
>> I have some very long strings and would like to break up each long string
>> into multiple strings with a fixed length, e.g. to break up
>>
>> abcdefghijkl
>>
>> into
>>
>> abc, def, ghi, jkl
>>
>> I tried a couple of commands but was not successful. Any help will be
>> appreciated.
>>
>> Best,
>> Jimmy
>> --
>> View this message in context: 
>> http://www.nabble.com/break-up-a-string-into-strings-with-a-fixed-length-tp25712955p25712955.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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


Re: [R] break up a string into strings with a fixed length

2009-10-02 Thread Gabor Grothendieck
Try this:

> library(gsubfn)
> s <- "abcdefghijkl"

> strapply(s, "...")[[1]]
[1] "abc" "def" "ghi" "jkl"


On Fri, Oct 2, 2009 at 5:36 AM, J Chen  wrote:
>
> dear all,
>
> I have some very long strings and would like to break up each long string
> into multiple strings with a fixed length, e.g. to break up
>
> abcdefghijkl
>
> into
>
> abc, def, ghi, jkl
>
> I tried a couple of commands but was not successful. Any help will be
> appreciated.
>
> Best,
> Jimmy
> --
> View this message in context: 
> http://www.nabble.com/break-up-a-string-into-strings-with-a-fixed-length-tp25712955p25712955.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] How to get duplicated items in a vector?

2009-10-02 Thread jim holtman
Try this:

>  x=c(rep(1,3),rep(3,2))
> x
[1] 1 1 1 3 3
> duplicated(x) | duplicated(x, fromLast=TRUE)
[1] TRUE TRUE TRUE TRUE TRUE
>


On Thu, Oct 1, 2009 at 10:42 PM, Peng Yu  wrote:
> Hi,
>
>> x=c(rep(1,3),rep(3,2))
>> x
> [1] 1 1 1 3 3
>> duplicated(x)
> [1] FALSE  TRUE  TRUE FALSE  TRUE
>>
>
> As shown in the above code, 'duplicated' doesn't return 'F' for the
> first '1' and first '3' in 'x'. I am wondering if there is a function
> that can return an indicator for any element whether it appears in a
> vector twice or more.
>
> Regards,
> Peng
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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.


Re: [R] Robust ANOVA with variance heterogeneity

2009-10-02 Thread John Fox
Dear Maike,

You could use the Anova() function in the car package with a
heteroscedasticity-consistent coefficient covariance matrix (via the
argument white.adjust=TRUE).

Regards,
 John


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
> Behalf Of Maike Luhmann
> Sent: October-02-09 3:05 AM
> To: r-help@r-project.org
> Subject: [R] Robust ANOVA with variance heterogeneity
> 
> Dear list members,
> 
> I am looking for an alternative function for a two-way ANOVA in the case
of
> variance heterogeneity. For one-way ANOVA, I found oneway.test(), but I
> didn't find anything alike for two-way ANOVA. Does anyone have a
suggestion?
> 
> Thank you!
> 
> Maike Luhmann
> Freie Universität Berlin
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Please Help me!

2009-10-02 Thread jim holtman
try this:  (?try)

name_c<-Sys.glob("C:/Documents and Settings/lma/My
Documents/habitdata/*/calllog/*")

for (i in 1:length(name_c)){

log1<-try(readLines(name_c[i]))
if (inherits(log1, 'try-error')) next  # skip if error


write.table(Temps, file=paste("C:/Documents and Settings/lma/My
Documents/habitdata1",pname,lname,basename(name_c[i]),sep="/"))

}

On Fri, Oct 2, 2009 at 7:04 AM, Tammy Ma  wrote:
>
> Hi, R-users,
>
>
> I have a problem: Because there are few files which can't be readed
> into R completely, so on the following subsequence programme, I use
> write.table, which creates the "NA" files for those incomplete files
> autimatically.
> I don't want those NA files.
>
> My programes formats looks like:
>
>
>
> name_c<-Sys.glob("C:/Documents and Settings/lma/My 
> Documents/habitdata/*/calllog/*")
>
> for (i in 1:length(name_c)){
>
> log1<-readLines(name_c[i])
> 
>
> write.table(Temps, file=paste("C:/Documents and Settings/lma/My 
> Documents/habitdata1",pname,lname,basename(name_c[i]),sep="/"))
>
> }
>
>
> Error Information:
> Error in file(file, ifelse(append, "a", "w")) :
>  cannot open the connection
>
>  In file(file, ifelse(append, "a", "w")) :
>  cannot open file 'C:/Documents and Settings/lma/My 
> Documents/habitdata1/NA/NA/NA': Permission denied
>
>
> I have checked why the error appears, because  when I use "readLines" to read 
> data, but when processing the large data set, there are few files which can 
> not be readed in completely:
>
> 48: In readLines(name_c[i]) ... :
>
> incomplete final line found on 'C:/Documents and Settings/lma/My
> Documents/habitdata/244052900243997/calllog/calllog_log-20050505T121611.txt'
> ...
>
>
> So it create the "NA" file when implementing the subsequence procedure by 
> write.table.How can I do: whenever readLines can't completely read one file, 
> then autimatically doesn't implement the subsequence programmes?
>
> Thanks.
> Tammy
> _
> More than messages–check out the rest of the Windows Live™.
> http://www.microsoft.com/windows/windowslive/
>        [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



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


Re: [R] break up a string into strings with a fixed length

2009-10-02 Thread jim holtman
try this:

> a <- paste(letters, collapse='')
> # partitions into lengths of 4
> indx <- seq(1, nchar(a), 4)
> a.p <- sapply(indx, function(x) substring(a, x, x+3))
>
> a.p
[1] "abcd" "efgh" "ijkl" "mnop" "qrst" "uvwx" "yz"
>


On Fri, Oct 2, 2009 at 5:36 AM, J Chen  wrote:
>
> dear all,
>
> I have some very long strings and would like to break up each long string
> into multiple strings with a fixed length, e.g. to break up
>
> abcdefghijkl
>
> into
>
> abc, def, ghi, jkl
>
> I tried a couple of commands but was not successful. Any help will be
> appreciated.
>
> Best,
> Jimmy
> --
> View this message in context: 
> http://www.nabble.com/break-up-a-string-into-strings-with-a-fixed-length-tp25712955p25712955.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
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] plot subscript text and percentage symbol in graph label axis

2009-10-02 Thread e-letter
Readers,

I am unable to plot a label consisting of both subscript text and
percentage (%) symbol:

x<-(1:10)
y<-(200:191)
plot(x~y,ylab=expression(~degree~C),xlab=expression(x[2]~%))
Error: syntax error, unexpected ERROR in
"plot(x~y,ylab=expression(~degree~C),xlab=expression(x~%)"

It seems that % is a special character in R? I have looked in the
introductory manual but can see no reference to reserved characters.

Yours,

rhelpatconference.jabber.org
r251
mandriva2008

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

2009-10-02 Thread Tammy Ma

Hi, R-users,


I have a problem: Because there are few files which can't be readed
into R completely, so on the following subsequence programme, I use
write.table, which creates the "NA" files for those incomplete files
autimatically. 
I don't want those NA files.

My programes formats looks like:



name_c<-Sys.glob("C:/Documents and Settings/lma/My 
Documents/habitdata/*/calllog/*")

for (i in 1:length(name_c)){

log1<-readLines(name_c[i])


write.table(Temps, file=paste("C:/Documents and Settings/lma/My 
Documents/habitdata1",pname,lname,basename(name_c[i]),sep="/"))

}


Error Information:
Error in file(file, ifelse(append, "a", "w")) : 
  cannot open the connection

 In file(file, ifelse(append, "a", "w")) :
  cannot open file 'C:/Documents and Settings/lma/My 
Documents/habitdata1/NA/NA/NA': Permission denied


I have checked why the error appears, because  when I use "readLines" to read 
data, but when processing the large data set, there are few files which can not 
be readed in completely:

48: In readLines(name_c[i]) ... :
 
incomplete final line found on 'C:/Documents and Settings/lma/My
Documents/habitdata/244052900243997/calllog/calllog_log-20050505T121611.txt'
...


So it create the "NA" file when implementing the subsequence procedure by 
write.table.How can I do: whenever readLines can't completely read one file, 
then autimatically doesn't implement the subsequence programmes?

Thanks.
Tammy 
_
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/
[[alternative HTML version deleted]]

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


[R] help with regexp mass substitution

2009-10-02 Thread Luca Braglia
Hello *

i have to rename a lot of variables, and, given that they have regular name 
constructs, I would like to use regexps.

Here's a dump of my head(names(df))

varnames <- c("id.quest", "txt.1.3", "col1.1.3", "col2.1.3", "col3.1.3", 
"col4.1.3", "col5.1.3", "txt.2.3", "col1.2.3", "col2.2.3", "col3.2.3", 
"col4.2.3", "col5.2.3", "txt.3.3", "col1.3.3", "col2.3.3", "col3.3.3", 
"col4.3.3", "col5.3.3", "txt.4.3", "col1.4.3", "col2.4.3", "col3.4.3", 
"col4.4.3", "col5.4.3", "txt.5.3", "col1.5.3", "col2.5.3", "col3.5.3", 
"col4.5.3", "col5.5.3", "txt.6.3", "col1.6.3", "col2.6.3", "col3.6.3", 
"col4.6.3", "col5.6.3", "txt.7.3", "col1.7.3", "col2.7.3", "col3.7.3", 
"col4.7.3", "col5.7.3", "txt.8.3", "col1.8.3", "col2.8.3", "col3.8.3", 
"col4.8.3", "col5.8.3", "txt.9.3", "col1.9.3", "col2.9.3", "col3.9.3", 
"col4.9.3", "col5.9.3", "txt.10.3", "col1.10.3", "col2.10.3", 
"col3.10.3", "col4.10.3", "col5.10.3", "txt.11.3", "col1.11.3", 
"col2.11.3", "col3.11.3", "col4.11.3", "col5.11.3", "txt.12.3", 
"col1.12.3", "col2.12.3", "col3.12.3", "col4.12.3", "col5.12.3", 
"txt.13.3", "col1.13.3", "col2.13.3", "col3.13.3", "col4.13.3", 
"col5.13.3", "txt.14.3", "col1.14.3", "col2.14.3", "col3.14.3", 
"col4.14.3", "col5.14.3", "txt.15.3", "col1.15.3", "col2.15.3", 
"col3.15.3", "col4.15.3", "col5.15.3", "txt.16.3", "col1.16.3", 
"col2.16.3", "col3.16.3", "col4.16.3", "col5.16.3", "txt.17.3", 
"col1.17.3", "col2.17.3")

I'd like to convert only ^col variables to have eg

>From "col4.1.3" --> To "dom3.rig1.col4"

to test the matching regex I've tryied

grep("^col\\d{1,2}.\\d{1,2}.\\d{1,2}$",varnames, perl=T, value=T)

to substitute the ^col variables, I've tryied

gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", varnames)

I'm a newbie with regexps and I got the starting vector (==varnames)

all(gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", 
varnames) == varnames )

How can I do?

Many thanks and have a nice weekend.

Luca

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