Re: [R] Print plot to pdf, jpg or any other format when using scatter3d error

2011-01-04 Thread Uwe Ligges



On 04.01.2011 08:37, David Winsemius wrote:


On Jan 3, 2011, at 8:17 PM, Jurica Seva wrote:


Hi,

I have been trying to output my graphs to a file (jpeg, pdf, ps, it
doesnt matter) but i cant seem to be able to get it to output. I tried
a few things but none of them worked and am lost as what to do now. I
am using the scatter3d function, and it prints out the graphs on tot
he screen without any problems, but when it comes to writing them to a
file i cant make it work. Is there any other way of producing
3dimensional graphs (they dont have to be rotatable/interactive after
the print out)?

The code is fairly simple and is listed down :

#libraries
library(RMySQL)
library(rgl)
library(scatterplot3d)
library(Rcmdr)

##

#database connection
mycon - dbConnect(MySQL(),
user='root',dbname='test',host='localhost',password='')
#distinct sessions
rsSessionsU01 - dbSendQuery(mycon, select distinct sessionID from
actiontimes where userID = 'ID01')
sessionU01 -fetch(rsSessionsU01)
sessionU01[2,]

#user01 data
mycon - dbConnect(MySQL(),
user='root',dbname='test',host='localhost',password='')
rsUser01 - dbSendQuery(mycon, select
a.userID,a.sessionID,a.actionTaken,a.timelineMSEC,a.durationMSEC,b.X,b.Y,b.Rel__dist_,b.Total_dist_
from `actiontimes` as a , `ulogdata` as b where a.originalRECNO =
b.RECNO and a.userID='ID01')
user01 - fetch(rsUser01, n= -1)
user01[1,1]

#plot loop

for (i in 1:10){

userSubset-subset(user01,sessionID ==
sessionU01[i,],select=c(timelineMSEC,X,Y))
userSubset
x-as.numeric(userSubset$X)
y-as.numeric(userSubset$Y)
scatter3d(

#??? I thought the function was scatterplot3d()


scatter3d() is provided by Rcmdr and an interface to the rgl package.



x,y,userSubset$timeline,xlim = c(0,1280), ylim = c(0,1024),
zlim=c(0,180),type=h,main=sessionU01[i,],sub=sessionU01[i,])
tmp6=rep(.ps)


Why name it .ps when you are using pdf.dev()?



Actually he is not using it (at least it is in comments).



tmp7=paste(sessionU01[i,],tmp6,sep=)
tmp7
rgl.postscript(tmp7,ps,drawText=FALSE)



That should be correct code, according to the rgl documentation.



When you want to get output to the file device, you need to surround
the plotting commands. the pdf call goes at the beginning of the loop
and the dev.odd at the end. It seems dangerous to specify the number to
dev.off since there might be no or more than one device already open. If
you just use dev.off() you will close the last device that was opened,'


Using R standard devices will not work for rgl graphics.

Best wishes,
Uwe





#pdf(file=tmp7) # Move before the scatterplot3d call



#dev.print(file=tmp7, device=pdf, width=600)


# you should also make sure you created a valid file string. We cannot
check since you have not offered a reproducible example.




#dev.off(2)
}




David Winsemius, MD
West Hartford, CT

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


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


[R] Odp: how to subset unique factor combinations from a data frame.

2011-01-04 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 04.01.2011 05:21:25:

 Hi All
 
 I have these questions and request members expert view on this. 
 
 a) I have a dataframe (df) with five factors (identity variables) and 
value
 (measured value). The id variables are Year, Country, Commodity, 
Attribute,
 Unit. Value is a value for each combination of this.
 
 I would like to get just the unique combination of Commodity, Attribute 
and
 Unit. I just need the unique factor combination into a dataframe or a 
table.
 I know aggregate and subset but dont how to use them in this context. 

aggregate(Value, list(Comoditiy, Atribute, Unit), function)

 
 b) Is it possible to inclue non- aggregate columns with aggregate 
function
 
 say in the above case  aggregate(Value ~ Commodity + Attribute, data = 
df,
 FUN = count). The use of count(Value) is just a round about to return 
the
 combinations of Commodity  Attribute, and I would like to include 
'Unit'
 column in the returned data frame?

Hm. Maybe xtabs? But without any example it is only a guess.

 
 c) Is it possible to subset based on unique combination, some thing like
 this.
 
  subset(df, unique(Commodity), select = c(Commodity, Attribute, Unit)). 
I
 know this is not correct as it returns an error 'subset needs a logical
 evaluation'. Trying various ways to accomplish the task. 
 

Probably sqldf package has tools for doing it but I do not use it so you 
have to try yourself.

df[Comodity==something, c(Commodity, Attribute, Unit)]

can be other way.

Anyway your explanation is ambiguous. Let say you have three rows with the 
same Commodity. Which row do you want to select?

Regards
Petr


 will be grateful for any ideas and help 
 
 Regards,
 
 SNVK 
 
[[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] Please, need help with a plot

2011-01-04 Thread Uwe Ligges



On 03.01.2011 14:25, Victor F Seabra wrote:


although the code somehow didn't work on my Vista / R 2.8,
it did work perfectly on a XP machine / R 2.10


An when you update both machines to a recent R-2.12.1 you will find how 
much more will work in the end!


Uwe Ligges




I've been trying to fix this for days,
Thank you very much for your help!


__

02/01/2011 19:30, David Winsemius  dwinsem...@comcast.net  wrote:

On Jan 2, 2011, at 1:15 PM, Ben Bolker wrote:


This is a little bit more 'magic' than I would like, but seems
to work. Perhaps someone else can suggest a cleaner solution.


Here's the best I could come up with but will admit that there were
many failed attempts before success:

expr.vec- as.expression(parse(text=table1$var1))
plot(x=table1$var2 ,y=1:11, xlim=c(0,20), pch=20)
text(x=table1$var2, y=1:11, labels=expr.vec, pos=4)
title(x=15, y=5, expression(Yet another way to process strings with
operators like '=' )

(The title expression works on my machine, but perhaps not on the OP's
machine, given differences in encoding that have so far been exhibited.)



ages- gsub([^0-9]+,,table1$var1)
rel- gsub(age\\s*([=]+)\\s*[0-9]+,\\1,table1$var1,perl=TRUE)

with(table1,plot(var2,1:11,xlim=c(0,20),pch=20))
invisible(with(table1,
mapply(function(x,y,a,r) {
text(x=x,y=y,
switch(r,
`=`=bquote(age= .(a)),
``=bquote(age  .(a)),
`=`=bquote(age= .(a))),
pos=4)},
var2,1:11,ages,rel)))

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


David Winsemius, MD
West Hartford, CT

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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Default Working directory on windows 7?

2011-01-04 Thread W Eryk Wolski
Hi,

Just installed R on a new Windows 7 machine (as admin).


I feel quite uncomfortable knowing that the default WD when starting R is:

 getwd()
[1] C:/Windows/system32



I guess I did something wrong when installing R... How to change R's
default working directory?

regards

Eryk

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


Re: [R] Default Working directory on windows 7?

2011-01-04 Thread Michael Sumner
Change the Start in: property on the shortcut you used to start R
with. Right-click on the R icon and click Properties (you may need to
right click once, then again if you are using the pinned start menu
icon in Windows 7). Then when you start R again with that shortcut it
will use the directory you choose.

I'm not sure if you can control this during the install, but mine is
set to use the Documents folder in my user account.

Cheers, Mike.

On Tue, Jan 4, 2011 at 8:35 PM, W Eryk Wolski wewol...@gmail.com wrote:
 Hi,

 Just installed R on a new Windows 7 machine (as admin).


 I feel quite uncomfortable knowing that the default WD when starting R is:

 getwd()
 [1] C:/Windows/system32



 I guess I did something wrong when installing R... How to change R's
 default working directory?

 regards

 Eryk

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




-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@gmail.com

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


[R] Fw: Re: Default Working directory on windows 7?

2011-01-04 Thread Amy Milano

Suppose your working R directory is

C:\My Working Directory

I hope now that you have installed the R, you must be having R ICON on your 
desktop.

Right click on this icon, then click on Properties. Once that box is opened, 
you will find a tab called Start in. There within the   type C:\My Working 
Directory. So it should look like C:\My Working Directory

Then click on OK.

So whenever you execute R henceforth, this will remain your working directory 
till the time you change it using above process.


I hope I have addressed your query. Of course others may be having different 
efficient methods to do it.

HTH

Amy



--- On Tue, 1/4/11, W Eryk Wolski wewol...@gmail.com wrote:

From: W Eryk Wolski wewol...@gmail.com
Subject: [R] Default Working directory on windows 7?
To: r-help@r-project.org
Date: Tuesday, January 4, 2011, 9:35 AM

Hi,

Just installed R on a new Windows 7 machine (as admin).


I feel quite uncomfortable knowing that the default WD when starting R is:

 getwd()
[1] C:/Windows/system32



I guess I did something wrong when installing R... How to change R's
default working directory?

regards

Eryk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lattice: how to center a title?

2011-01-04 Thread Marius Hofert
Dear expeRts,

As you can see from this example...

trellis.device(pdf, width = 5, height = 5)
  print(xyplot(0 ~ 0, main = This title is not 'centered' for the human's 
eye, scales = list(alternating = c(1,1), tck = c(1,0
dev.off()

... the title does not seem to be centered for the human's eye [although it 
is centered when the plot (width) is considered with the y-axis label]. 
I could not easily (via trellis.par.get()) find a way to adjust this. Of course 
one could include more spaces in the title string, but is there a more elegant 
way to slightly shift the title to the right? 

Cheers,

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


[R] Odp: Default Working directory on windows 7?

2011-01-04 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 04.01.2011 10:35:23:

 Hi,
 
 Just installed R on a new Windows 7 machine (as admin).
 
 
 I feel quite uncomfortable knowing that the default WD when starting R 
is:
 
  getwd()
 [1] C:/Windows/system32

Something was set incorrectly. I believe that with default setting R shall 
be somewhere in Program Files directory (but you can install it to any 
directory without problems). Try to remove it and reinstall if it is in 
some inconvenient place.

There is one file .RData which is used as starting workspace. So make any 
directory, copy this file to it, start R by double click on it and now the 
new directory is working directory.

Quite useful when working on several projects.

Regards
Petr


 
 
 
 I guess I did something wrong when installing R... How to change R's
 default working directory?
 
 regards
 
 Eryk
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 subset unique factor combinations from a data frame.

2011-01-04 Thread SNV Krishna
Hi,

Sorry that my example is not clear. I will give an example of what each
variable holds. I hope this clearly explains the case.

Names of the dataframe (df) and description

Year :- Year is calendar year, from 1980 to 2010

Country :- is the country name, total no. (levels) of countries is ~ 190 

Commodity :- Crude oil, Sugar, Rubber, Coffee  No. (levels) of
commodities is 20

Attribute: - Production, Consumption, Stock, Import, Export... Levels ~ 20

Unit :- this is actually not a factor. It describes the unit of Attribute.
Say the unit for Coffee (commodity) - Production (attribute) is 60 kgs.
While the unit for Crude oil - Production is 1000 barrels

Value :-  value 

 tail(df, n = 10) // example data//

YearCountry Commodity   Attribute   Unit
Value
1991United Kingdom  Wheat, DurumTotal Supply(1000 MT)   70
1991United Kingdom  Wheat, DurumTY Exports  (1000 MT)   0
1991United Kingdom  Wheat, DurumTY Imp. from U  (1000 MT)   0
1991United Kingdom  Wheat, DurumTY Imports  (1000 MT)   60
1991United Kingdom  Wheat, DurumYield   (MT/HA) 5

Wish this is clear. Any suggestion

Regards,

SNVK

-Original Message-
From: Petr PIKAL [mailto:petr.pi...@precheza.cz] 
Sent: Tuesday, January 04, 2011 4:06 PM
To: SNV Krishna
Cc: r-help@r-project.org
Subject: Odp: [R] how to subset unique factor combinations from a data
frame.

Hi

r-help-boun...@r-project.org napsal dne 04.01.2011 05:21:25:

 Hi All
 
 I have these questions and request members expert view on this. 
 
 a) I have a dataframe (df) with five factors (identity variables) and
value
 (measured value). The id variables are Year, Country, Commodity,
Attribute,
 Unit. Value is a value for each combination of this.
 
 I would like to get just the unique combination of Commodity, 
 Attribute
and
 Unit. I just need the unique factor combination into a dataframe or a
table.
 I know aggregate and subset but dont how to use them in this context. 

aggregate(Value, list(Comoditiy, Atribute, Unit), function)

 
 b) Is it possible to inclue non- aggregate columns with aggregate
function
 
 say in the above case  aggregate(Value ~ Commodity + Attribute, data 
 =
df,
 FUN = count). The use of count(Value) is just a round about to return
the
 combinations of Commodity  Attribute, and I would like to include
'Unit'
 column in the returned data frame?

Hm. Maybe xtabs? But without any example it is only a guess.

 
 c) Is it possible to subset based on unique combination, some thing 
 like this.
 
  subset(df, unique(Commodity), select = c(Commodity, Attribute, Unit)). 
I
 know this is not correct as it returns an error 'subset needs a 
 logical evaluation'. Trying various ways to accomplish the task.
 

Probably sqldf package has tools for doing it but I do not use it so you
have to try yourself.

df[Comodity==something, c(Commodity, Attribute, Unit)]

can be other way.

Anyway your explanation is ambiguous. Let say you have three rows with the
same Commodity. Which row do you want to select?

Regards
Petr


 will be grateful for any ideas and help
 
 Regards,
 
 SNVK
 
[[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] Writing do and resample functions

2011-01-04 Thread Ben Ward

Hi,

I'm trying to take a function from a workspace download provided in a 
stats textbook book, so I have it in my workspace to use all the time.


I opened the workspace and typed the names of the two functions to get 
the code that makes them up:

-
 resample
function(d, size, replace=TRUE,prob=NULL,within=NULL) {
  if (!is.null(within)) return( resample.within(d, 
within,replace=replace) )

  if (is.null(dim(d))) {
 # it's just a vector
 if (missing(size)) size=length(d)
return( d[ sample(1:length(d),size, replace=replace, prob=prob)])
  }
  else {
 if (missing(size)) size = dim(d)[1];
 inds = sample(1:(dim(d))[1], size, replace=replace, prob=prob)
 if (is.data.frame(d) | is.matrix(d)) {
return(d[inds,]);
 } else {
return(d[inds]);
 }
  }
}
-
 do
function(n=10){
  as.repeater(n)
}
-
 as.repeater
function(n=5){
  foo = list(n=n)
  class(foo) = 'repeater'
  return(foo)
}

Then I made the functions in my workspace by choosing the name (same 
name), and then = and then copied and pasted the function, beginning 
with function( and ending with the final }'s.


But when I try to do the following in my workspace afterwards:

samps = do(500)* coef(lm(MIC.~1+Challenge+Cleaner+Replicate, 
data=resample(ecoli)))

sd(samps)

I get an error:
Error in do(500) * coef(lm(MIC. ~ 1 + Challenge + Cleaner + Replicate,  :
non-numeric argument to binary operator.

But in the workspace that comes with that book, I get a decent output:

sd(samps)
(Intercept)   Challenge   CleanerGarlic  ReplicateFirst 
ReplicateFourth
  3.9455401   0.7178385   1.6830641   5.4564926   
5.4320998

ReplicateSecond  ReplicateThird
  5.3895562   5.5422622

Is there anybody out there who know a lot more about programming 
functions in R than I do, that might know why this is giving me the 
error? I don't understand why one workspace would accept the model 
formula, when the other give me the non-numeric argument to binary 
vector, the only vector that's not numerical is Replicate, but I don't 
that's what the error is talking about.


Thanks,
Ben Ward.

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

2011-01-04 Thread Amy Milano
Dear r helpers,

At first, I apologize for raising a query which seems to be a stupid 
interpretation on my part. I am trying to learn SQLite.



Following is an example given in the RSQLite.zip file (Page # 4)

drv - dbDriver(SQLite)
tfile - tempfile()
con - dbConnect(drv, dbname = tfile)
data(USArrests)
dbWriteTable(con, arrests, USArrests)


On the similar line I am trying to read my data.

Suppose I have a dataframe as given below.

DF = data.frame(X = c(US, UK, Canada, Australia, Newzealand), Y = 
c(52, 36, 74, 10, 98))

drv - dbDriver(SQLite)
tfile - tempfile()
con - dbConnect(drv, dbname = tfile)
data(DF)
dbWriteTable(con, ..., ...) # Didn't know what to write here.

I understand I have raised a query in a stupid manner. I need to understand is 
there any way I can use SQLite to read
 dataframe or for that matter any csv file say e.g. 'DF.csv'.

Please enlighten me.

Amy


  
[[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 invert the axes in the wireframe() plot

2011-01-04 Thread Simone Gabbriellini
thank you very much, I am now closer to the result I would like to achieve. 

Still, I have to figure out how to invert the n axes, see figure:

http://www.digitaldust.it/materiali/mine2.pdf

is panel.3dwire the function I have to study for this last step?

thanks,
simone

Il giorno 04/gen/2011, alle ore 01.26, David Winsemius ha scritto:

 
 On Jan 3, 2011, at 7:07 PM, Simone Gabbriellini wrote:
 
 I am trying to reproduce this graph:
 
 http://www.digitaldust.it/materiali/their.png
 
 the default axes orientation of wireframe gives me this:
 
 http://www.digitaldust.it/materiali/mine.pdf
 
 I am trying to understand if I can reproduce the axes orientation of the 
 first figure.
 
 Well, there is more to reproducing that figure than just rotating around the 
 z axis by 180, which is what I now take your question to be:
 
 ?panel.3dwire
 
 Run  the 2nd example in ?wireframe and then compare to this minor 
 modification of the screen arguments:
 
 wireframe(z ~ x * y, data = g, groups = gr,
   scales = list(arrows = FALSE),
   drape = TRUE, colorkey = TRUE,
   screen = list(z = 30+180, x = -60), )
 
 (Rotated 180 around the z-axis.)
 
 -- 
 Best;
 David.
 
 
 many thanks,
 simone
 
 Il giorno 03/gen/2011, alle ore 23.45, David Winsemius ha scritto:
 
 
 On Jan 3, 2011, at 5:06 PM, Simone Gabbriellini wrote:
 
 Dear List,
 
 I am using the wireframe function in the lattice package, and I am 
 wondering if it is possible to invert the default axes orientation for x 
 and y axes... what parameter should I look for?
 
 Perhaps you should define invert.
 
 
 
 -- 
 
 David Winsemius, MD
 West Hartford, CT
 
 
 
 David Winsemius, MD
 West Hartford, CT
 

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


[R] lattice: par.settings with standard.theme() + additional arguments?

2011-01-04 Thread Marius Hofert
Dear expeRts,

I usually use par.settings = standard.theme(color = FALSE) to create lattice 
graphics
without colors, so something like

library(lattice)
x - runif(10)
xyplot(x ~ 1:10, type = l, par.settings = standard.theme(color = FALSE))

Now I would like to use an additional component in par.settings. I tried 
several things
like

xyplot(x ~ 1:10, type = l, par.settings = c(standard.theme(color = FALSE), 
list(par.xlab.text = list(cex = 5, col = blue

but it doesn't work. I know I could use lattice.options() but is there a way to 
get it
right (locally) with par.settings?

Cheers,

Marius
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 subset unique factor combinations from a data frame.

2011-01-04 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 04.01.2011 11:19:02:

 Hi,
 
 Sorry that my example is not clear. I will give an example of what each
 variable holds. I hope this clearly explains the case.
 
 Names of the dataframe (df) and description
 
 Year :- Year is calendar year, from 1980 to 2010
 
 Country :- is the country name, total no. (levels) of countries is ~ 190 

 
 Commodity :- Crude oil, Sugar, Rubber, Coffee  No. (levels) of
 commodities is 20
 
 Attribute: - Production, Consumption, Stock, Import, Export... Levels ~ 
20
 
 Unit :- this is actually not a factor. It describes the unit of 
Attribute.
 Say the unit for Coffee (commodity) - Production (attribute) is 60 kgs.
 While the unit for Crude oil - Production is 1000 barrels
 
 Value :-  value 
 
  tail(df, n = 10) // example data//
 
 Year   Country  Commodity   Attribute   Unit
 Value
 1991   United Kingdom   Wheat, Durum   Total Supply   (1000 MT)   70
 1991   United Kingdom   Wheat, Durum   TY Exports   (1000 MT)   0
 1991   United Kingdom   Wheat, Durum   TY Imp. from U   (1000 MT)   0
 1991   United Kingdom   Wheat, Durum   TY Imports   (1000 MT)   60
 1991   United Kingdom   Wheat, Durum   Yield  (MT/HA)   5
 
 Wish this is clear. Any suggestion

suggestion is still the same, use aggregate on any other similar function 
maybe from plyr package. No matter how exactly you will describe your data 
if you fail to show any code you used and how this code failed in 
delivering desired result you will get only vague responses.

Regards
Petr


 
 Regards,
 
 SNVK
 
 -Original Message-
 From: Petr PIKAL [mailto:petr.pi...@precheza.cz] 
 Sent: Tuesday, January 04, 2011 4:06 PM
 To: SNV Krishna
 Cc: r-help@r-project.org
 Subject: Odp: [R] how to subset unique factor combinations from a data
 frame.
 
 Hi
 
 r-help-boun...@r-project.org napsal dne 04.01.2011 05:21:25:
 
  Hi All
  
  I have these questions and request members expert view on this. 
  
  a) I have a dataframe (df) with five factors (identity variables) and
 value
  (measured value). The id variables are Year, Country, Commodity,
 Attribute,
  Unit. Value is a value for each combination of this.
  
  I would like to get just the unique combination of Commodity, 
  Attribute
 and
  Unit. I just need the unique factor combination into a dataframe or a
 table.
  I know aggregate and subset but dont how to use them in this context. 
 
 aggregate(Value, list(Comoditiy, Atribute, Unit), function)
 
  
  b) Is it possible to inclue non- aggregate columns with aggregate
 function
  
  say in the above case  aggregate(Value ~ Commodity + Attribute, data 
  =
 df,
  FUN = count). The use of count(Value) is just a round about to return
 the
  combinations of Commodity  Attribute, and I would like to include
 'Unit'
  column in the returned data frame?
 
 Hm. Maybe xtabs? But without any example it is only a guess.
 
  
  c) Is it possible to subset based on unique combination, some thing 
  like this.
  
   subset(df, unique(Commodity), select = c(Commodity, Attribute, 
Unit)). 
 I
  know this is not correct as it returns an error 'subset needs a 
  logical evaluation'. Trying various ways to accomplish the task.
  
 
 Probably sqldf package has tools for doing it but I do not use it so you
 have to try yourself.
 
 df[Comodity==something, c(Commodity, Attribute, Unit)]
 
 can be other way.
 
 Anyway your explanation is ambiguous. Let say you have three rows with 
the
 same Commodity. Which row do you want to select?
 
 Regards
 Petr
 
 
  will be grateful for any ideas and help
  
  Regards,
  
  SNVK
  
 [[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.


[R] 95% CI of the Predicted values from the GLS Model

2011-01-04 Thread Mangalani Peter Makananisa
 

Dear all,

 

I have just constructed  the GLS model in R . How do I print the 95%
confidence intervals for the vector of predicted values R code/s for
GLS CI?

 

See the model below:

 

Please advice 

 

Regards

 

Peter

 

South Africa

+2712 422 7357

+2782 456 4669

 

Generalized least squares fit by maximum likelihood

  Model: log(y) ~ log(x) + d1 + d3 

  Data: NULL 

AIC   BIC   logLik

  -166.2344 -147.8469   92.1172

 

Correlation Structure: ARMA(2,2)

 Formula: ~1 

 Parameter estimate(s):

   Phi1Phi2  Theta1  Theta2 

 0.65960193   0.26221313 -0.02561896 -0.37995110 

 

Coefficients:

  Value Std.Errort-valuep-value

(Intercept)  -2.4304969 0.8078837   -3.0084740.004

log(x)1.0558775 0.068438915.428027   0.000

d10.2105713 0.011025019.099466   0.000

d30.1012744 0.01095029.2485960.000

 

 Correlation: 

 (Intr)  lg(cm) d1

log(x)   -0.999  

d1   -0.208   0.204   

d3   -0.094   0.093 -0.323

 

Standardized residuals:

   Min Q1Med Q3Max 

-1.6668631 -0.9549670 -0.1153022   0.7962635   2.0764581 

 

Residual standard error: 0.07542025 

Degrees of freedom: 57 total; 53 residual

 


Please Note: This email and its contents are subject to our email legal notice 
which can be viewed at http://www.sars.gov.za/Email_Disclaimer.pdf 

[[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] RSQLite to input dataframe

2011-01-04 Thread Michael Bedward
Hi Amy,

I'm not sure if I understand your question correctly so let me know if
the following is off track.

Starting with your example, here is how to create a data.frame and
write it to a new table in a new database file...

my.data = data.frame(X = c(US, UK, Canada, Australia,
Newzealand), Y = c(52, 36, 74, 10, 98))

drv - dbDriver(SQLite)
con - dbConnect(drv, myfilename.db)
dbWriteTable(con, sometablename, my.data)

To verify that the table is now in the file...

dbListTables(con)

To check the fields in the table (should match the colnames in your
data.frame)...

dbListFields(con, sometablename)

To read the whole table into the workspace as a new data.frame

my.data.copy - dbReadTable(con, sometablename)

If you have data in a CSV file, and the contents are small enough to
read in one go, you would use the read.csv function to read the
contents of the file into a data.frame and then use dbWriteTable to
transfer this to your database.

Hope this helps,

Michael


On 4 January 2011 21:43, Amy Milano milano_...@yahoo.com wrote:
 Dear r helpers,

 At first, I apologize for raising a query which seems to be a stupid 
 interpretation on my part. I am trying to learn SQLite.



 Following is an example given in the RSQLite.zip file (Page # 4)

 drv - dbDriver(SQLite)
 tfile - tempfile()
 con - dbConnect(drv, dbname = tfile)
 data(USArrests)
 dbWriteTable(con, arrests, USArrests)


 On the similar line I am trying to read my data.

 Suppose I have a dataframe as given below.

 DF = data.frame(X = c(US, UK, Canada, Australia, Newzealand), Y = 
 c(52, 36, 74, 10, 98))

 drv - dbDriver(SQLite)
 tfile - tempfile()
 con - dbConnect(drv, dbname = tfile)
 data(DF)
 dbWriteTable(con, ..., ...) # Didn't know what to write here.

 I understand I have raised a query in a stupid manner. I need to understand 
 is there any way I can use SQLite to read
  dataframe or for that matter any csv file say e.g. 'DF.csv'.

 Please enlighten me.

 Amy



        [[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] Saving objects inside a list

2011-01-04 Thread Olivier ETERRADOSSI

Message: 42
Date: Mon, 3 Jan 2011 18:58:04 -0200
From: Eduardo de Oliveira Hortaeduardo.oliveiraho...@gmail.com
To: r-helpr-help@r-project.org
Subject: Re: [R] Saving objects inside a list
Message-ID:
aanlktimbxmr0rusiws1grorhjh=wstofzqdoc-90z...@mail.gmail.com
Content-Type: text/plain

sapply(ls(),get) works fine. Thanks.

ps: the as.list and the eapply suggestions didn't work.

Hi Eduardo (and all the best for this new year),

are you sure the as.list and eapply solutions didn't work ? On my 
machine they produce a list but in reverse order compared to the 
result of ls(),...maybe it's the same with you :


names(as.list(.GlobalEnv))[6] is the name of the 6th variable FROM THE 
END of ls().


Regards. Olivier

--
Olivier ETERRADOSSI
Maître-Assistant
animateur du groupe Sensomines (Institut Carnot M.I.N.E.S)
-
CMGD
Pôle Matériaux Polymères Avancés
axe Propriétés Psycho-Sensorielles des Matériaux
-
Ecole des Mines d'Alès
Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9
tel std: +33 (0)5.59.30.54.25
tel direct: +33 (0)5.59.30.90.35
fax: +33 (0)5.59.30.63.68
http://www.mines-ales.fr
e-mail : olivier.eterrado...@mines-ales.fr

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

2011-01-04 Thread Sébastien Bihorel
Dear R-users,

Is there a easy way to access to a complete listing of available functions
from a R session? The help.start() and ? functions are great, but I feel
like they require the user to know the answer in advance (especially with
respect to function names)... I could not find a easy way to simply browse
through a list of functions and randomly pick one function to see what is
does.

Is there such a possibility in R?

Thanks

PS: I apologize if this question appears trivial.

[[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] Writing do and resample functions

2011-01-04 Thread Erich Neuwirth
It seems that the textbook workspace you are using as a method
definition for * for class repeater. Load the workspace and try
methods(`*`)
If you get something like '*.repeater' this suspicion is confirmed


On 1/4/2011 11:36 AM, Ben Ward wrote:
 Hi,
 
 I'm trying to take a function from a workspace download provided in a
 stats textbook book, so I have it in my workspace to use all the time.
 
 I opened the workspace and typed the names of the two functions to get
 the code that makes them up:
 -
 
 resample
 function(d, size, replace=TRUE,prob=NULL,within=NULL) {
   if (!is.null(within)) return( resample.within(d,
 within,replace=replace) )
   if (is.null(dim(d))) {
  # it's just a vector
  if (missing(size)) size=length(d)
 return( d[ sample(1:length(d),size, replace=replace, prob=prob)])
   }
   else {
  if (missing(size)) size = dim(d)[1];
  inds = sample(1:(dim(d))[1], size, replace=replace, prob=prob)
  if (is.data.frame(d) | is.matrix(d)) {
 return(d[inds,]);
  } else {
 return(d[inds]);
  }
   }
 }
 -
 
 do
 function(n=10){
   as.repeater(n)
 }
 -
 
 as.repeater
 function(n=5){
   foo = list(n=n)
   class(foo) = 'repeater'
   return(foo)
 }
 
 Then I made the functions in my workspace by choosing the name (same
 name), and then = and then copied and pasted the function, beginning
 with function( and ending with the final }'s.
 
 But when I try to do the following in my workspace afterwards:
 
 samps = do(500)* coef(lm(MIC.~1+Challenge+Cleaner+Replicate,
 data=resample(ecoli)))
 sd(samps)
 
 I get an error:
 Error in do(500) * coef(lm(MIC. ~ 1 + Challenge + Cleaner + Replicate,  :
 non-numeric argument to binary operator.
 
 But in the workspace that comes with that book, I get a decent output:
 
 sd(samps)
 (Intercept)   Challenge   CleanerGarlic  ReplicateFirst
 ReplicateFourth
   3.9455401   0.7178385   1.6830641   5.4564926  
 5.4320998
 ReplicateSecond  ReplicateThird
   5.3895562   5.5422622
 
 Is there anybody out there who know a lot more about programming
 functions in R than I do, that might know why this is giving me the
 error? I don't understand why one workspace would accept the model
 formula, when the other give me the non-numeric argument to binary
 vector, the only vector that's not numerical is Replicate, but I don't
 that's what the error is talking about.
 
 Thanks,
 Ben Ward.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] RSQLite to input dataframe

2011-01-04 Thread Andreas Borg


Hi Amy,

Suppose I have a dataframe as given below.

DF = data.frame(X = c(US, UK, Canada, Australia, Newzealand), Y = 
c(52, 36, 74, 10, 98))

drv - dbDriver(SQLite)
tfile - tempfile()
con - dbConnect(drv, dbname = tfile)
data(DF)
dbWriteTable(con, ..., ...) # Didn't know what to write here.
  


data() loads data sets which ship with R or an extension package. Your 
data frame DF is already in the working environment, hence it is neither 
possible nor necessary to load it, the expression


data(DF)

is an error. The command to write DF to a database would be something like

dbWriteTable(con, DF, DF)

where the second argument is the name of the database table to write to, the 
third argument the data frame you want to write (please have a look at the 
documentation).


I understand I have raised a query in a stupid manner. I need to understand is 
there any way I can use SQLite to read
 dataframe or for that matter any csv file say e.g. 'DF.csv'.


To copy a CSV file to SQLite, read it via read.table() or read.csv() first, 
then copy the result with dbWriteTable. There might be a way to read files 
directly from SQLite, but I don't know about that.

Best regards,

Andreas






  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


Re: [R] Listing of available functions

2011-01-04 Thread Matthew Dowle
Try :
objects(package:base)

Also, as it happens, a new package called unknownR is in
development on R-Forge.

It's description says :
  Do you know how many functions there are in base R?
  How many of them do you know you don't know?
  Run unk() to discover your unknown unknowns.
  It's fast and it's fun !

It's not ready to try yet (and may not live up to it's promises)
but hopefully should be ready soon.

Matthew


Sébastien Bihorel pomc...@free.fr wrote in message 
news:aanlktinfpmthb2osgjckeo3jwsqhw+-zdyd0xtdmk...@mail.gmail.com...
 Dear R-users,

 Is there a easy way to access to a complete listing of available functions
 from a R session? The help.start() and ? functions are great, but I feel
 like they require the user to know the answer in advance (especially with
 respect to function names)... I could not find a easy way to simply browse
 through a list of functions and randomly pick one function to see what is
 does.

 Is there such a possibility in R?

 Thanks

 PS: I apologize if this question appears trivial.

 [[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] Listing of available functions

2011-01-04 Thread Henrique Dallazuanna
Try this:

sapply(search(), ls, all.names = TRUE)

This show all the functions in the search() path

On Tue, Jan 4, 2011 at 10:13 AM, Sébastien Bihorel pomc...@free.fr wrote:

 Dear R-users,

 Is there a easy way to access to a complete listing of available functions
 from a R session? The help.start() and ? functions are great, but I feel
 like they require the user to know the answer in advance (especially with
 respect to function names)... I could not find a easy way to simply browse
 through a list of functions and randomly pick one function to see what is
 does.

 Is there such a possibility in R?

 Thanks

 PS: I apologize if this question appears trivial.

[[alternative HTML version deleted]]

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




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

[[alternative HTML version deleted]]

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


Re: [R] Writing do and resample functions

2011-01-04 Thread Ben Ward

I've just loaded the workspace and done

 methods('*')
And got the ouptut
[1] *.difftime *.repeater

I'm not entirely sure on what this repeater and as.repeater is. From my 
reading when one want to repeat stuff for say bootstrapping, you have to 
use repeat as part of a function and put in some sort of qualification 
that end the repetitions. Coding functions is a bit beyond what is 
taught on my BSc Biology course. However, I do know that if I do the 
same in a new R session:


 methods('*')
[1] *.difftime

*.repeater is missing. So to clarify my understanding, the * is the 
problem because it hasn't got this .repeater value attributed to it?


Thanks,
Ben Ward.


On 04/01/2011 12:30, Erich Neuwirth wrote:

It seems that the textbook workspace you are using as a method
definition for * for class repeater. Load the workspace and try
methods(`*`)
If you get something like '*.repeater' this suspicion is confirmed


On 1/4/2011 11:36 AM, Ben Ward wrote:

Hi,

I'm trying to take a function from a workspace download provided in a
stats textbook book, so I have it in my workspace to use all the time.

I opened the workspace and typed the names of the two functions to get
the code that makes them up:
-


resample

function(d, size, replace=TRUE,prob=NULL,within=NULL) {
   if (!is.null(within)) return( resample.within(d,
within,replace=replace) )
   if (is.null(dim(d))) {
  # it's just a vector
  if (missing(size)) size=length(d)
 return( d[ sample(1:length(d),size, replace=replace, prob=prob)])
   }
   else {
  if (missing(size)) size = dim(d)[1];
  inds = sample(1:(dim(d))[1], size, replace=replace, prob=prob)
  if (is.data.frame(d) | is.matrix(d)) {
 return(d[inds,]);
  } else {
 return(d[inds]);
  }
   }
}
-


do

function(n=10){
   as.repeater(n)
}
-


as.repeater

function(n=5){
   foo = list(n=n)
   class(foo) = 'repeater'
   return(foo)
}

Then I made the functions in my workspace by choosing the name (same
name), and then = and then copied and pasted the function, beginning
with function( and ending with the final }'s.

But when I try to do the following in my workspace afterwards:

samps = do(500)* coef(lm(MIC.~1+Challenge+Cleaner+Replicate,
data=resample(ecoli)))
sd(samps)

I get an error:
Error in do(500) * coef(lm(MIC. ~ 1 + Challenge + Cleaner + Replicate,  :
non-numeric argument to binary operator.

But in the workspace that comes with that book, I get a decent output:

sd(samps)
 (Intercept)   Challenge   CleanerGarlic  ReplicateFirst
ReplicateFourth
   3.9455401   0.7178385   1.6830641   5.4564926
5.4320998
ReplicateSecond  ReplicateThird
   5.3895562   5.5422622

Is there anybody out there who know a lot more about programming
functions in R than I do, that might know why this is giving me the
error? I don't understand why one workspace would accept the model
formula, when the other give me the non-numeric argument to binary
vector, the only vector that's not numerical is Replicate, but I don't
that's what the error is talking about.

Thanks,
Ben Ward.

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

2011-01-04 Thread ADias

Hi

thank you all. I think I have what I need to solve my problem.

Regards,
A.Dias
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Help-with-For-instruction-tp3173074p3173386.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] Inverse Gaussian Distribution

2011-01-04 Thread Louisa

Thank you!

But i'm wondering: 

if you run
 
area - factor(area, levels=c(C, A,B,D,E,F) ) 

then you are transforming only 'area',  aren't you? 

isn't it possible to transform the whole data like i did for agecat 
but now for area and area C as baseline, 

or are you doing so when you run 

 area - factor(area, levels=c(C, A,B,D,E,F) ) 
 attach(data)

and then run the model with area as predictorvariable:

  model - glm(Y~ agecat+gender+area,...)

My question is if i can run it as follows and still have a right solution :

 data -transform(data, area=(factor(area, levels=c(C,
 A,B,D,E,F) ) )

I'll be very grateful for any help you can provide!

Kind regards, 

Louisa


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Inverse-Gaussian-Distribution-tp3172533p3173468.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] S4 plot function (Package)...

2011-01-04 Thread Daniel Kosztyla

Hello,

I have a problem programming 2 plot methods for 2 classes.
1. I have 2 classes. Each class has its own plot method. !!! How the 
plot,xxx-method.R -files have to look like,
so that the plot method for class 1 und plot methods for class 2 can act 
for each belonging class. Prob


My example for plot_class1.R for class labeled class1 (class2 
equivalent):


if (!isGeneric(plot)) {
  setGeneric(plot, function(x=class1, y=ANY, ...) 
standardGeneric(plot), package=the_package_name);

}

setMethod(plot, signature(x=class1, y=ANY),
  function(x, y, type=xy, method = names(x...@misclass), anno=symbol, 
...)

  {
... #code
  }
}

#DOCS
\name{plot,class1-method}
\docType{methods}
\alias{plot}
\alias{plot,class1-method}
...


Looks it correct?
thx so far.
Dan

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


Re: [R] RSQLite to input dataframe

2011-01-04 Thread Amy Milano
Dear sir,

When I was going through RSQLite.pdf file, I was just wondering if at all I 
will understand this. But you have explained it in such a simple and lucid 
manner, that although I am yet to go thoroughly through the mail, I am filled 
with confidence that yes now i can do it and I am going to circulate your mail 
through my office so that all will be benefited. 

Thanks a lot sir once again. Must say that was The Guidnace.

Regards

Amy

  

--- On Tue, 1/4/11, Michael Bedward michael.bedw...@gmail.com wrote:

From: Michael Bedward michael.bedw...@gmail.com
Subject: Re: [R] RSQLite to input dataframe
To: Amy Milano milano_...@yahoo.com, Rhelp r-help@r-project.org
Date: Tuesday, January 4, 2011, 11:32 AM

Hi Amy,

I'm not sure if I understand your question correctly so let me know if
the following is off track.

Starting with your example, here is how to create a data.frame and
write it to a new table in a new database file...

my.data = data.frame(X = c(US, UK, Canada, Australia,
Newzealand), Y = c(52, 36, 74, 10, 98))

drv - dbDriver(SQLite)
con - dbConnect(drv, myfilename.db)
dbWriteTable(con, sometablename, my.data)

To verify that the table is now in the file...

dbListTables(con)

To check the fields in the table (should match the colnames in your
data.frame)...

dbListFields(con, sometablename)

To read the whole table into the workspace as a new data.frame

my.data.copy - dbReadTable(con, sometablename)

If you have data in a CSV file, and the contents are small enough to
read in one go, you would use the read.csv function to read the
contents of the file into a data.frame and then use dbWriteTable to
transfer this to your database.

Hope this helps,

Michael


On 4 January 2011 21:43, Amy Milano milano_...@yahoo.com wrote:
 Dear r helpers,

 At first, I apologize for raising a query which seems to be a stupid 
 interpretation on my part. I am trying to learn SQLite.



 Following is an example given in the RSQLite.zip file (Page # 4)

 drv - dbDriver(SQLite)
 tfile - tempfile()
 con - dbConnect(drv, dbname = tfile)
 data(USArrests)
 dbWriteTable(con, arrests, USArrests)


 On the similar line I am trying to read my data.

 Suppose I have a dataframe as given below.

 DF = data.frame(X = c(US, UK, Canada, Australia, Newzealand), Y = 
 c(52, 36, 74, 10, 98))

 drv - dbDriver(SQLite)
 tfile - tempfile()
 con - dbConnect(drv, dbname = tfile)
 data(DF)
 dbWriteTable(con, ..., ...) # Didn't know what to write here.

 I understand I have raised a query in a stupid manner. I need to understand 
 is there any way I can use SQLite to read
  dataframe or for that matter any csv file say e.g. 'DF.csv'.

 Please enlighten me.

 Amy



        [[alternative HTML version deleted]]

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




  
[[alternative HTML version deleted]]

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


Re: [R] ARIMA simulation including a constant

2011-01-04 Thread Prof Brian Ripley
That output is not from arima(), which is the function paired with 
arima.sim().  Nor is it from arima0(), so I don't believe it is 
'ouptut from R' (perhaps from a contributed package you have not 
mentioned?).


With arima(), the intercept is 'm' in the notation on the help page 
and not 'a' in your personal re-definition.  You can easily go from 
one to the other by some trivial algebra ( a = m*(1-sum(ar)) ), but 
you do need to be sure what the unstated function you use is using.


On Mon, 3 Jan 2011, Paolo Rossi wrote:


Sorry I am not really sure I have been taht clear.
 
I meant ARMA which is not bound to have zero mean. More precisely, suppose I
estimate y(t) = a + by(t-1)  + e(t) + ce(t-1) , i.e. and ARMA(1,1). My
question is how do I simulate values for yt given the values for a, b and c?
My problem with arima.sim is that I cannot find a way to pass the value for
the constant a.
 
Output from  R is:
 
Coefficient(s):
   Estimate  Std. Error  t value Pr(|t|)   
ar1 0.82978 0.01033   80.297   2e-16 ***
ma1 0.46347 0.01548   29.942   2e-16 ***
intercept  -0.02666 0.01012   -2.635  0.00841 **
---
Intercept is significant and I suppose it should be used if I want simulate
values from this ARMA(1,1)
 
 
Thanks and Apologies for not being clear
 
Paolo
 


 
On 3 January 2011 16:46, Prof Brian Ripley rip...@stats.ox.ac.uk wrote:
On Mon, 3 Jan 2011, Paolo Rossi wrote:

  Hi,

  I have been looking at arima.sim to simulate the output
  from an ARMA model
  fed with a normal and uncorrelated input series but I
  cannot find a way to
  pass an intercept / constant into the model. In other
  words, the model input
  in the function allows only for the AR and MA components
  but I need to pass
  a constant.

  Can anyone help?


Well, an ARIMA model by definition has zero mean (as the link on the
help page for arima.sim to the exact definition tells you).  Perhaps
you mean that (X-m) = Z follows an ARIMA model, in which case simulate
Z and add m.  For a differenced ARIMA model it is not clear if you
meant that you wanted an intercept for the original or differenced
series: for the latter simply simulate the differenced series, add the
intercept and use diffinv().

  Thanks

  Paolo

         [[alternative HTML version deleted]]


Please do as we asked in the posting guide and not send HTML.

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






--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to subset unique factor combinations from a data frame.

2011-01-04 Thread Dennis Murphy
Hi:

Did you try something like

summdf - as.data.frame(with(df, table(Commodity, Attribute,
Unit)))

?
The rows of the table should represent the unique combinations of the three
variables

Here's a simple toy example to illustrate:
 x - sample(LETTERS[1:6], 1000, replace = TRUE)
 xx - sample(letters[1:6], 1000, replace = TRUE)
 u - as.data.frame(table(x, xx))
 dim(u)
[1] 36  3
 head(u)
  x xx Freq
1 A  a   26
2 B  a   29
3 C  a   25
4 D  a   25
5 E  a   27
6 F  a   29

HTH,
Dennis

On Tue, Jan 4, 2011 at 2:19 AM, SNV Krishna kris...@primps.com.sg wrote:

 Hi,

 Sorry that my example is not clear. I will give an example of what each
 variable holds. I hope this clearly explains the case.

 Names of the dataframe (df) and description

 Year :- Year is calendar year, from 1980 to 2010

 Country :- is the country name, total no. (levels) of countries is ~ 190

 Commodity :- Crude oil, Sugar, Rubber, Coffee  No. (levels) of
 commodities is 20

 Attribute: - Production, Consumption, Stock, Import, Export... Levels ~ 20

 Unit :- this is actually not a factor. It describes the unit of Attribute.
 Say the unit for Coffee (commodity) - Production (attribute) is 60 kgs.
 While the unit for Crude oil - Production is 1000 barrels

 Value :-  value

  tail(df, n = 10) // example data//

 YearCountry Commodity   Attribute   Unit
 Value
 1991United Kingdom  Wheat, DurumTotal Supply(1000 MT)   70
 1991United Kingdom  Wheat, DurumTY Exports  (1000 MT)   0
 1991United Kingdom  Wheat, DurumTY Imp. from U  (1000 MT)   0
 1991United Kingdom  Wheat, DurumTY Imports  (1000 MT)   60
 1991United Kingdom  Wheat, DurumYield   (MT/HA) 5

 Wish this is clear. Any suggestion

 Regards,

 SNVK

 -Original Message-
 From: Petr PIKAL [mailto:petr.pi...@precheza.cz]
 Sent: Tuesday, January 04, 2011 4:06 PM
 To: SNV Krishna
 Cc: r-help@r-project.org
 Subject: Odp: [R] how to subset unique factor combinations from a data
 frame.

 Hi

 r-help-boun...@r-project.org napsal dne 04.01.2011 05:21:25:

  Hi All
 
  I have these questions and request members expert view on this.
 
  a) I have a dataframe (df) with five factors (identity variables) and
 value
  (measured value). The id variables are Year, Country, Commodity,
 Attribute,
  Unit. Value is a value for each combination of this.
 
  I would like to get just the unique combination of Commodity,
  Attribute
 and
  Unit. I just need the unique factor combination into a dataframe or a
 table.
  I know aggregate and subset but dont how to use them in this context.

 aggregate(Value, list(Comoditiy, Atribute, Unit), function)

 
  b) Is it possible to inclue non- aggregate columns with aggregate
 function
 
  say in the above case  aggregate(Value ~ Commodity + Attribute, data
  =
 df,
  FUN = count). The use of count(Value) is just a round about to return
 the
  combinations of Commodity  Attribute, and I would like to include
 'Unit'
  column in the returned data frame?

 Hm. Maybe xtabs? But without any example it is only a guess.

 
  c) Is it possible to subset based on unique combination, some thing
  like this.
 
   subset(df, unique(Commodity), select = c(Commodity, Attribute, Unit)).
 I
  know this is not correct as it returns an error 'subset needs a
  logical evaluation'. Trying various ways to accomplish the task.
 

 Probably sqldf package has tools for doing it but I do not use it so you
 have to try yourself.

 df[Comodity==something, c(Commodity, Attribute, Unit)]

 can be other way.

 Anyway your explanation is ambiguous. Let say you have three rows with the
 same Commodity. Which row do you want to select?

 Regards
 Petr


  will be grateful for any ideas and help
 
  Regards,
 
  SNVK
 
 [[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.


[[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 keep keep matching column in output of merge

2011-01-04 Thread Nevil Amos

How do I keep the linking column[s] in a merge()?
 I need to use the values again in a further merge.

thanks

Nevil Amos

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


Re: [R] Print plot to pdf, jpg or any other format when using scatter3d error

2011-01-04 Thread Duncan Murdoch

On 03/01/2011 8:17 PM, Jurica Seva wrote:

Hi,

I have been trying to output my graphs to a file (jpeg, pdf, ps, it
doesnt matter) but i cant seem to be able to get it to output.



As Uwe said, you are using rgl graphics, not base graphics.  So none of 
the standard devices work, you need to use the tools built into rgl.  
Attach that package, and then read ?rgl.postscript (for graphics in 
various vector formats, not just Postscript) and ?rgl.snapshot (for 
bitmapped graphics).


Some notes:
 - For a while rgl.snapshot wasn't working in the Windows builds with R 
2.12.1; that is now fixed, so you should update rgl before getting 
frustrated.
 - rgl.snapshot just takes a copy of the graphics buffer that is 
showing on screen, so it is limited to the size you can display
 - rgl.postscript does a better job for the parts of an image that it 
can handle, but it is not a perfect OpenGL emulator, so it doesn't 
always include all components of a graph properly.


Duncan Murdoch


  I tried a
few things but none of them worked and am lost as what to do now. I am
using the scatter3d function, and it prints out the graphs on tot he
screen without any problems, but when it comes to writing them to a file
i cant make it work. Is there any other way of producing 3dimensional
graphs (they dont have to be rotatable/interactive after the print out)?

The code is fairly simple and is listed down :

#libraries
library(RMySQL)
library(rgl)
library(scatterplot3d)
library(Rcmdr)

##
#database connection
mycon- dbConnect(MySQL(),
user='root',dbname='test',host='localhost',password='')
#distinct sessions
rsSessionsU01- dbSendQuery(mycon, select distinct sessionID from
actiontimes where userID = 'ID01')
sessionU01-fetch(rsSessionsU01)
sessionU01[2,]

#user01 data
mycon- dbConnect(MySQL(),
user='root',dbname='test',host='localhost',password='')
rsUser01- dbSendQuery(mycon, select
a.userID,a.sessionID,a.actionTaken,a.timelineMSEC,a.durationMSEC,b.X,b.Y,b.Rel__dist_,b.Total_dist_
from `actiontimes` as a , `ulogdata` as b where a.originalRECNO =
b.RECNO and a.userID='ID01')
user01- fetch(rsUser01, n= -1)
user01[1,1]

#plot loop

for (i in 1:10){

  userSubset-subset(user01,sessionID ==
sessionU01[i,],select=c(timelineMSEC,X,Y))
  userSubset
  x-as.numeric(userSubset$X)
  y-as.numeric(userSubset$Y)
  scatter3d(x,y,userSubset$timeline,xlim = c(0,1280), ylim =
c(0,1024),
zlim=c(0,180),type=h,main=sessionU01[i,],sub=sessionU01[i,])
  tmp6=rep(.ps)
  tmp7=paste(sessionU01[i,],tmp6,sep=)
  tmp7
  rgl.postscript(tmp7,ps,drawText=FALSE)
  #pdf(file=tmp7)
  #dev.print(file=tmp7, device=pdf, width=600)
  #dev.off(2)
}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lattice: par.settings with standard.theme() + additional arguments?

2011-01-04 Thread David Winsemius


On Jan 4, 2011, at 5:57 AM, Marius Hofert wrote:


Dear expeRts,

I usually use par.settings = standard.theme(color = FALSE) to create  
lattice graphics

without colors, so something like

library(lattice)
x - runif(10)
xyplot(x ~ 1:10, type = l, par.settings = standard.theme(color =  
FALSE))


Now I would like to use an additional component in par.settings. I  
tried several things

like

xyplot(x ~ 1:10, type = l, par.settings = c(standard.theme(color =  
FALSE), list(par.xlab.text = list(cex = 5, col = blue


but it doesn't work. I know I could use lattice.options() but is  
there a way to get it

right (locally) with par.settings?


Add it as a list element:

xyplot(x ~ 1:10, type = l, par.settings = list(standard.theme(color  
= FALSE), par.xlab.text = list(cex = 5, col = blue)))


--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Listing of available functions

2011-01-04 Thread Duncan Murdoch

On 04/01/2011 7:13 AM, Sébastien Bihorel wrote:

Dear R-users,

Is there a easy way to access to a complete listing of available functions
from a R session? The help.start() and ? functions are great, but I feel
like they require the user to know the answer in advance (especially with
respect to function names)... I could not find a easy way to simply browse
through a list of functions and randomly pick one function to see what is
does.

Is there such a possibility in R?

Thanks

PS: I apologize if this question appears trivial.



This requires a two level search, but is probably more useful than just 
a list of function names:


Run help.start() to get into the main help page.

Click on Packages.  Now you'll see a list of all installed packages 
and their titles.


Choose an interesting package, and click on its name.  Now you'll see a 
list of most help aliases (generally all functions, plus some other 
things) and the title of the associated help page.


You don't see all help aliases:  S4 method documentation tends to have a 
lot of aliases, and some of those are suppressed.  But you should see 
all help pages at least once.


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] Listing of available functions

2011-01-04 Thread David Winsemius
You can also search for a cheatsheet. There are several out there  
searching on cheatsheet r


This one at Oregon State is presented as a web page

http://www.science.oregonstate.edu/~shenr/Rhelp/00cheat.htm

Others are available as pdf's.


On Jan 4, 2011, at 7:13 AM, Sébastien Bihorel wrote:


Dear R-users,

Is there a easy way to access to a complete listing of available  
functions
from a R session? The help.start() and ? functions are great, but I  
feel
like they require the user to know the answer in advance (especially  
with
respect to function names)... I could not find a easy way to simply  
browse
through a list of functions and randomly pick one function to see  
what is

does.

Is there such a possibility in R?

Thanks

PS: I apologize if this question appears trivial.

[[alternative HTML version deleted]]

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] lattice: par.settings with standard.theme() + additional arguments?

2011-01-04 Thread Marius Hofert
Dear David,

this I already tried. But as you can see, the plot itself *is* colored. 
However, I want to have color = FALSE, so, unfortunately, this approach does 
not work...

Cheers,

Marius 
 
On 2011-01-04, at 14:32 , David Winsemius wrote:

 
 On Jan 4, 2011, at 5:57 AM, Marius Hofert wrote:
 
 Dear expeRts,
 
 I usually use par.settings = standard.theme(color = FALSE) to create lattice 
 graphics
 without colors, so something like
 
 library(lattice)
 x - runif(10)
 xyplot(x ~ 1:10, type = l, par.settings = standard.theme(color = FALSE))
 
 Now I would like to use an additional component in par.settings. I tried 
 several things
 like
 
 xyplot(x ~ 1:10, type = l, par.settings = c(standard.theme(color = FALSE), 
 list(par.xlab.text = list(cex = 5, col = blue
 
 but it doesn't work. I know I could use lattice.options() but is there a way 
 to get it
 right (locally) with par.settings?
 
 Add it as a list element:
 
 xyplot(x ~ 1:10, type = l, par.settings = list(standard.theme(color = 
 FALSE), par.xlab.text = list(cex = 5, col = blue)))
 
 -- 
 
 David Winsemius, MD
 West Hartford, CT
 

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


Re: [R] Inverse Gaussian Distribution

2011-01-04 Thread David Winsemius


On Jan 4, 2011, at 7:50 AM, Louisa wrote:



Thank you!

But i'm wondering:

if you run

area - factor(area, levels=c(C, A,B,D,E,F) )

then you are transforming only 'area',  aren't you?

isn't it possible to transform the whole data like i did for agecat
but now for area and area C as baseline,


Of course, but may I point out that you did no earlier say that you  
may have attached a dataframe containing area. There are many  
confusing situations that arise when using attached dataframes and  
this may be one of them. Many experienced R users avoid attaching data  
objects like the plague.




or are you doing so when you run


area - factor(area, levels=c(C, A,B,D,E,F) )
attach(data)


and then run the model with area as predictorvariable:


model - glm(Y~ agecat+gender+area,...)




My question is if i can run it as follows and still have a right  
solution :



data -transform(data, area=(factor(area, levels=c(C,
A,B,D,E,F) ) )


Is there any reason that you suspect this will not work? Why not try  
it ... now assumimg that you failed to tell us that area was a column  
in a dataframe that is. (One set of parentheses appear extraneous.)


data -transform(data, area = factor(area, levels=c(C,  
A,B,D,E,F) )


(Untested in the absence of reproducible example ,,, but it looks as  
though it might work.)




I'll be very grateful for any help you can provide!

Kind regards,

Louisa


--
View this message in context: 
http://r.789695.n4.nabble.com/Inverse-Gaussian-Distribution-tp3172533p3173468.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.


David Winsemius, MD
West Hartford, CT

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


Re: [R] lasso/lars error

2011-01-04 Thread F1Tim

I'm having the same error too, but it's very rare though... (especially when
using datasets with many variables, say 25). A somewhat odd, but seemingly
effective, way to solve this, is by writing try(lars(x,y),silent = T). The
try-command in this shape will not generate an error on the console and
therefore, any running programs are not aborted. When there is no error, you
simply get the LARS object. When there is an error, you get a character
string (can be checked by 'is.character()'). I suggest to perturb the data a
little to get it to work...

Best Regards,

Timmie Smet

B.A.P. Operations Research and Business Statistics
University of Leuven, Belgium
-- 
View this message in context: 
http://r.789695.n4.nabble.com/lasso-lars-error-tp831400p3173480.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 keep keep matching column in output of merge

2011-01-04 Thread Ben Bolker
Nevil Amos nevil.amos at gmail.com writes:

 How do I keep the linking column[s] in a merge()?
   I need to use the values again in a further merge.

  simple reproducible example please?
(e.g. make up a couple of 4-row datasets that show what you
want, what you are trying, and what you are getting instead).

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 keep keep matching column in output of merge

2011-01-04 Thread Sarah Goslee
Hi Nevil,

We really need an example here of what you're doing, since
merge() does keep the id column by default.


 x - data.frame(id = c(a, b, c, d), x=c(1,2,3,4))
 y - data.frame(id = c(b, a, d, c), y=c(101, 102, 103, 104))
 merge(x, y)
  id x   y
1  a 1 102
2  b 2 101
3  c 3 104
4  d 4 103

Sarah

On Tue, Jan 4, 2011 at 8:31 AM, Nevil Amos nevil.a...@gmail.com wrote:
 How do I keep the linking column[s] in a merge()?
  I need to use the values again in a further merge.

 thanks

 Nevil Amos


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

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


Re: [R] Saving objects inside a list

2011-01-04 Thread Eduardo de Oliveira Horta
Hello, (and a happy new year for you too!)

Apparently the problem is happening only within my RKWard sessions:
 B = 1000
 oblist = as.list(.GlobalEnv)
 str(oblist)
List of 1
 $ B:function (value)
 oblist$B
function (value)
{
if (!missing(value)) {
assign(k, value, envir = .rk.watched.symbols)
.rk.do.call(ws, k)
invisible(value)
}
else {
get(k, envir = .rk.watched.symbols)
}
}
environment: 0x08cc9eec

Now the same code in a regular Rgui session:
 B = 1000
 oblist = as.list(.GlobalEnv)
 str(oblist)
List of 1
 $ B: num 1000
 oblist$B
[1] 1000

Problem solved?

Best regards,

Eduardo Horta

On Tue, Jan 4, 2011 at 9:41 AM, Olivier ETERRADOSSI 
olivier.eterrado...@mines-ales.fr wrote:

 Message: 42
 Date: Mon, 3 Jan 2011 18:58:04 -0200
 From: Eduardo de Oliveira Hortaeduardo.oliveiraho...@gmail.com

 To: r-helpr-help@r-project.org
 Subject: Re: [R] Saving objects inside a list
 Message-ID:
aanlktimbxmr0rusiws1grorhjh=wstofzqdoc-90z...@mail.gmail.com
 Content-Type: text/plain


 sapply(ls(),get) works fine. Thanks.

 ps: the as.list and the eapply suggestions didn't work.

 Hi Eduardo (and all the best for this new year),

 are you sure the as.list and eapply solutions didn't work ? On my machine
 they produce a list but in reverse order compared to the result of
 ls(),...maybe it's the same with you :

 names(as.list(.GlobalEnv))[6] is the name of the 6th variable FROM THE END
 of ls().

 Regards. Olivier

 --
 Olivier ETERRADOSSI
 Maître-Assistant
 animateur du groupe Sensomines (Institut Carnot M.I.N.E.S)
 -
 CMGD
 Pôle Matériaux Polymères Avancés
 axe Propriétés Psycho-Sensorielles des Matériaux
 -
 Ecole des Mines d'Alès
 Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9
 tel std: +33 (0)5.59.30.54.25
 tel direct: +33 (0)5.59.30.90.35
 fax: +33 (0)5.59.30.63.68
 http://www.mines-ales.fr
 e-mail : olivier.eterrado...@mines-ales.fr




[[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 make a Cluster of Clusters

2011-01-04 Thread Diego Pujoni
Dear R-help,

In my Master thesis I measured 10 variables from 18 lakes. These
measurements were taken 4 times a year in 3 depths, so I have 12
samples from each lake. I know that 12 samples can not be treated as
replications, since they don't correspond to the same environmental
characteristics and are not statistically independent, but I want to
use these 12 samples as an estimate of an annual range the 18 lakes
have of the 10 variables.

I want to make a cluster analysis of the 18 lakes and my known
possibilities were:
1- Make an average of the 12 samples from each lake and make the
cluster (Using ward's method);
2- Use all 216 samples (18*12) to make the cluster (Which yields a mess).

But I thought I could begin the cluster algorithm already with 18
clusters (Lakes) each with 12 individuals (samples) and normally
proceed with the calculations (using ward's method). So I will obtain
a cluster of the 18 lakes, but using the 12 samples.

I got the cluster Fortran algorithm and I'm trying to translate it to
the R language to see how it works and maybe implement this kind of
cluster of cluster analysis.

Does anyone knows if there is an algorithm that does this? Actually I
did it by hand and got very good and meaningful results, but I want to
implement it to try another merging criterias.

Thanks

Diego Pujoni
Zooplankton Ecology Laboratory
Biological Sciences Institute
Federal University of Minas Gerais
Brazil

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

2011-01-04 Thread LOON88

Hey.
I have to do calendar in program R. I was looking for examples on this forum
but havent found it. Can someone help me in this thing ? I would be really
appreciate for that. Calendar should be the same as we have in Windows but I
really dont know how to begin it. Hope u can show me the best way to do it.
Cheers
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Calendar-in-R-program-tp3173566p3173566.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] [R-pkgs] plyr 1.4

2011-01-04 Thread Hadley Wickham
# plyr

plyr is a set of tools for a common set of problems: you need to
__split__ up a big data structure into homogeneous pieces, __apply__ a
function to each piece and then __combine__ all the results back
together. For example, you might want to:

  * fit the same model each patient subsets of a data frame
  * quickly calculate summary statistics for each group
  * perform group-wise transformations like scaling or standardising

It's already possible to do this with base R functions (like split and
the apply family of functions), but plyr makes it all a bit easier
with:

  * totally consistent names, arguments and outputs
  * convenient parallelisation through the foreach package
  * input from and output to data.frames, matrices and lists
  * progress bars to keep track of long running operations
  * built-in error recovery, and informative error messages
  * labels that are maintained across all transformations

Considerable effort has been put into making plyr fast and memory
efficient, and in many cases plyr is as fast as, or faster than, the
built-in functions.

You can find out more at http://had.co.nz/plyr/, including a 20 page
introductory guide, http://had.co.nz/plyr/plyr-intro.pdf.  You can ask
questions about plyr (and data-manipulation in general) on the plyr
mailing list. Sign up at http://groups.google.com/group/manipulatr

Version 1.4 (2011-01-03)
--

* `count` now takes an additional parameter `wt_var` which allows you to
  compute weighted sums. This is as fast, or faster than, `tapply` or `xtabs`.

* Really fix bug in `names.quoted`

* `.` now captures the environment in which it was evaluated. This should fix
  an esoteric class of bugs which no-one probably ever encountered, but will
  form the basis for an improved version of `ggplot2::aes`.

Version 1.3.1 (2010-12-30)
--

* Fix bug in `names.quoted` that interfered with ggplot2

Version 1.3 (2010-12-28)
--

NEW FEATURES

* new function `mutate` that works like transform to add new columns or
  overwrite existing columns, but computes new columns iteratively so later
  transformations can use columns created by earlier transformations. (It's
  also about 10x faster) (Fixes #21)

BUG FIXES

* split column names are no longer coerced to valid R names.

* `quickdf` now adds names if missing

* `summarise` preserves variable names if explicit names not provided (Fixes
  #17)

* `arrays` with names should be sorted correctly once again (also fixed a bug
  in the test case that prevented me from catching this automatically)

* `m_ply` no longer possesses .parallel argument (mistakenly added)

* `ldply` (and hence `adply` and `ddply`) now correctly passes on .parallel
  argument (Fixes #16)

* `id` uses a better strategy for converting to integers, making it possible
  to use for cases with larger potential numbers of combinations


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

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

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


[R] [R-pkgs] reshape2 1.1

2011-01-04 Thread Hadley Wickham
Reshape2 is a reboot of the reshape package. It's been over five years
since the first release of the package, and in that time I've learned
a tremendous amount about R programming, and how to work with data in
R. Reshape2 uses that knowledge to make a new package for reshaping
data that is much more focussed and much much faster.

This version improves speed at the cost of functionality, so I have
renamed it to `reshape2` to avoid causing problems for existing users.
 Based on user feedback I may reintroduce some of these features.

What's new in `reshape2`:

 * considerably faster and more memory efficient thanks to a much better
   underlying algorithm that uses the power and speed of subsetting to the
   fullest extent, in most cases only making a single copy of the data.

 * cast is replaced by two functions depending on the output type: `dcast`
   produces data frames, and `acast` produces matrices/arrays.

 * multidimensional margins are now possible: `grand_row` and `grand_col` have
   been dropped: now the name of the margin refers to the variable that has
   its value set to (all).

 * some features have been removed such as the `|` cast operator, and the
   ability to return multiple values from an aggregation function. I'm
   reasonably sure both these operations are better performed by plyr.

 * a new cast syntax which allows you to reshape based on functions
   of variables (based on the same underlying syntax as plyr):

 * better development practices like namespaces and tests.

Initial benchmarking has shown `melt` to be up to 10x faster, pure
reshaping `cast` up to 100x faster, and aggregating `cast()` up to 10x
faster.

This work has been generously supported by BD (Becton Dickinson).

Version 1.1
---

* `melt.data.frame` no longer turns characters into factors

* All melt methods gain a `na.rm` and `value.name` arguments - these
  previously were only possessed by `melt.data.frame` (Fixes #5)

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

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

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

2011-01-04 Thread John Sorkin
(1) I know that \n when used in cat, e.g. cat(\n) produces a line feed (i.e. 
skips to the next line). Is there any escape sequence that will go to the top 
of the next page?
(2) I know that control L will clear the console. Is there an equivalent 
function or other means that can be used in R code to clear the console?

Thanks,
John  


John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

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


Re: [R] Inverse Gaussian Distribution

2011-01-04 Thread Louisa

Thank you again David! 

I did not try it yet, cause neither the dataset nor R is on this computer.
I'll try it in a few hours, as soon as possible, when I'm on my personal
computer. 

I'll let you know if it works. I'm really curious!

Thank you for your time!

Best Wishes, 
Louisa
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Inverse-Gaussian-Distribution-tp3172533p3173579.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] uroot Package and R 2.12.1

2011-01-04 Thread CALEF ALEJANDRO RODRIGUEZ CUEVAS
Hello friends.

I'm wondering what happened to package uroot.  I worked quite well with
older versions of R, however with 2.12.1 version it simply doesn't work.

The worst thing is that I look for it in the contributed packages and it
simply doesn't appear.

I want to develop ADF test with seasonal (centered) dummies, is there any
other possible package that contains this test?

Thanks a lot.

Regards

[[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] uroot Package and R 2.12.1

2011-01-04 Thread Uwe Ligges



On 04.01.2011 16:15, CALEF ALEJANDRO RODRIGUEZ CUEVAS wrote:

Hello friends.

I'm wondering what happened to package uroot.  I worked quite well with
older versions of R, however with 2.12.1 version it simply doesn't work.

The worst thing is that I look for it in the contributed packages and it
simply doesn't appear.



It was removed from the main repository since it did not work and was 
not fixed by its maintainer.
Given the compatible license: Feel free to get it from the archives, fix 
it, and re-upload a new version to CRAN.


Best,
Uwe Ligges






I want to develop ADF test with seasonal (centered) dummies, is there any
other possible package that contains this test?

Thanks a lot.

Regards

[[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] an error about JRI

2011-01-04 Thread ying zhang
Hi everyone, I try to run my R script in Java, thus I installed JRI. and run
the example, I am using Eclipse on 64 bits windows 7.  part of the example
code is as follows:

 

public static void main(String[] args) {

System.out.println(Creating Rengine (with arguments));

Rengine re=new Rengine(args, false, null);

System.out.println(Rengine created, waiting for R);

if (!re.waitForR()) {

System.out.println(Cannot load R);

return;

}

However, everytime I run it. it teminated after print out Creating Rengine
(with arguments) never successfully print out Rengine created, waiting for
R

 

I do not know what is right argument to input, I have tried to add
--no-save under the Program arguments of eclipse run configuration, but
still does not help.

 

any suggestions? Many thanks

 

 

Ying

 


[[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] lattice: how to center a title?

2011-01-04 Thread Dieter Menne


mhofert wrote:
 
 trellis.device(pdf, width = 5, height = 5)
   print(xyplot(0 ~ 0, main = This title is not 'centered' for the human's
 eye, scales = list(alternating = c(1,1), tck = c(1,0
 dev.off()
 
 ... the title does not seem to be centered for the human's eye [although
 it is centered when the plot (width) is considered with the y-axis label]. 
 

This is because there is a y label, and centering is on the page (as you
noted). One way around this would be to add a similar padding at the right
side. See the example below, where I have exaggerated the effect. Try a
padding of 5 instead.

Dieter


library(lattice)
trellis.device(pdf, width = 5, height = 5)
trellis.par.set(layout.widths = list(right.padding = 10))
  print(xyplot(0 ~ 0, main = This title is not 'centered' for the human's
eye, scales = list(alternating = c(1,1), tck = c(1,0
dev.off()


-- 
View this message in context: 
http://r.789695.n4.nabble.com/lattice-how-to-center-a-title-tp3173271p3173800.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] lattice: par.settings with standard.theme() + additional arguments?

2011-01-04 Thread David Winsemius


On Jan 4, 2011, at 8:39 AM, Marius Hofert wrote:


Dear David,

this I already tried. But as you can see, the plot itself *is*  
colored. However, I want to have color = FALSE, so, unfortunately,  
this approach does not work...


Quite right. I didn't see that until you pointed it out. I had many  
failed attempts at a solution and then searched for prior positngs  
using par.settings and standard.theme and found one by Ehlers earlier  
this year that seems to work when modified to your ends:


xyplot(x ~ 1:10, type = l, par.settings =  
modifyList(standard.theme(color = FALSE),

  list(par.xlab.text = list(cex = 5) )))

I had tried various constructions that I thought would be equivalent,  
but I think I was getting the levels of the list structure wrong. This  
also works:


xyplot(x ~ 1:10, type = l, par.setting=c(list(par.xlab.text =  
list(cex = 5), standard.theme(color = FALSE))  )


Notice the use of c() rather than list() to bind them together. When I  
looked at the output of standard.theme(color=FALSE), there was no  
par.xlab.text element so it seemed as though there should be no  
conflict and in fact there wasn't (except for the asynchrony between  
my brain and the R interpreter.)


best;
David.


Cheers,

Marius

On 2011-01-04, at 14:32 , David Winsemius wrote:



On Jan 4, 2011, at 5:57 AM, Marius Hofert wrote:


Dear expeRts,

I usually use par.settings = standard.theme(color = FALSE) to  
create lattice graphics

without colors, so something like

library(lattice)
x - runif(10)
xyplot(x ~ 1:10, type = l, par.settings = standard.theme(color =  
FALSE))


Now I would like to use an additional component in par.settings. I  
tried several things

like

xyplot(x ~ 1:10, type = l, par.settings = c(standard.theme(color  
= FALSE), list(par.xlab.text = list(cex = 5, col = blue


but it doesn't work. I know I could use lattice.options() but is  
there a way to get it

right (locally) with par.settings?


Add it as a list element:

xyplot(x ~ 1:10, type = l, par.settings =  
list(standard.theme(color = FALSE), par.xlab.text = list(cex = 5,  
col = blue)))


--

David Winsemius, MD
West Hartford, CT





David Winsemius, MD
West Hartford, CT

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


Re: [R] Resampling to find Confidence intervals

2011-01-04 Thread Dieter Menne


Axolotl9250 wrote:
 
 ...
 resampled_ecoli = sample(ecoli, 500, replace=T)
 coefs = (coef(lm(MIC. ~ 1 + Challenge + Cleaner + Replicate, 
 data=resampled_ecoli)))
 sd(coefs)
 
 ...
 
Below a simplified and self-consistent version of your code, and some
changes

Dieter

# resample
d = data.frame(x=rnorm(10))
d$y = d$x*3+rnorm(10,0.01)

# if you do this, you only get ONE bootstrap sample
d1 = d[sample(1:nrow(d),10,TRUE),]
d1.coef = coef(lm(y~x,data=d1))
d1.coef
# No error below, because you compute the sd of (Intercept) and slope
# but result is wrong!
sd(d1.coef)

# We have to do this over and over
# Check ?replicate for a more R-ish approach
nsamples = 1000
allboot = NULL
for (i in 1:1000) {
  d1 = d[sample(1:nrow(d),10,TRUE),]
  d1.coef = coef(lm(y~x,data=d1))
  allboot = rbind(allboot,d1.coef) # Not very efficient, preallocate!
}
head(allboot) # display first of nsamples lines
apply(allboot,2,mean) # Compute mean
apply(allboot,2,sd) # compute sd
# After you are sure you understood the above, you might try package boot.





-- 
View this message in context: 
http://r.789695.n4.nabble.com/Resampling-to-find-Confidence-intervals-tp3172867p3173846.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] randomForest speed improvements

2011-01-04 Thread Liaw, Andy
If you have multiple cores, one poor man's solution is to run separate
forests in different R sessions, save the RF objects, load them into the
same session and combine() them.  You can do this less clumsily if you
use things like Rmpi or other distributed computing packages.

Another consideration is to increase nodesize (which reduces the sizes
of trees).  The problem with numeric predictors for tree-based
algorithms is that the number of computations to find the best splitting
point increases by that much _at each node_.  Some algorithms try to
save on this by using only certain quantiles.  The current RF code
doesn't do this.

Andy

 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of apresley
 Sent: Monday, January 03, 2011 6:28 PM
 To: r-help@r-project.org
 Subject: Re: [R] randomForest speed improvements
 
 
 I haven't tried changing the mtry or ntree at all ... though 
 I suppose with
 only 6 variables, and tens-of-thousands of rows, we can 
 probably do less
 than 500 tree's (the default?).
 
 Although tossing the forest does speed things up a bit, seems 
 to be about 15
 - 20% faster in some cases, I need to keep the forest to do 
 the prediction,
 otherwise, it complains that there is no forest component in 
 the object.
 
 --
 Anthony
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/randomForest-speed-improvements-
 tp3172523p3172834.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.
 
Notice:  This e-mail message, together with any attachme...{{dropped:11}}

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


[R] Cost-benefit/value for money analysis

2011-01-04 Thread Graham Smith
I assume this has a proper name, but I don't know what it is and wondered
if anyone knew of a package that might do the following, or something
similar.

As an example, assume I have borrowed and read 10 books on R , and  I have
subjectively given each of them a value score in terms of how useful I
think they are. I also know how much each costs in terms of money.

What I would like to do is to calculate the costs of every possible
combination of the 10 books, and plot the total monetary value for each of
these possible combination  with their associated subjective value totals,
to help decide which combination of books represents the best value for
money.

I know that some specialist decision analysis software does this sort of
thing, but was hoping R might have an appropriate package.

Many thanks,

Graham

[[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] an error about JRI

2011-01-04 Thread Prof Brian Ripley
AFAIK JRI is part of rJava (and you installed rJava), which has its 
own mailing list: plasea use it. (http://rosuda.org/lists.shtml, I 
believe).


There are tricky things with JRI on multi-architecture platforms, so 
you do need to be sure you are using the right versions (and rJava 
0.8-8 is needed for 64-bit Windows R, for example).


On Tue, 4 Jan 2011, ying zhang wrote:


Hi everyone, I try to run my R script in Java, thus I installed JRI. and run
the example, I am using Eclipse on 64 bits windows 7.  part of the example
code is as follows:



   public static void main(String[] args) {

   System.out.println(Creating Rengine (with arguments));

   Rengine re=new Rengine(args, false, null);

   System.out.println(Rengine created, waiting for R);

   if (!re.waitForR()) {

   System.out.println(Cannot load R);

   return;

   }

However, everytime I run it. it teminated after print out Creating Rengine
(with arguments) never successfully print out Rengine created, waiting for
R



I do not know what is right argument to input, I have tried to add
--no-save under the Program arguments of eclipse run configuration, but
still does not help.



any suggestions? Many thanks





Ying




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



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

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


Re: [R] lattice: par.settings with standard.theme() + additional arguments?

2011-01-04 Thread David Winsemius


On Jan 4, 2011, at 11:08 AM, David Winsemius wrote:



On Jan 4, 2011, at 8:39 AM, Marius Hofert wrote:


Dear David,

this I already tried. But as you can see, the plot itself *is*  
colored. However, I want to have color = FALSE, so, unfortunately,  
this approach does not work...


Quite right. I didn't see that until you pointed it out. I had many  
failed attempts at a solution and then searched for prior positngs  
using par.settings and standard.theme and found one by Ehlers  
earlier this year that seems to work when modified to your ends:


xyplot(x ~ 1:10, type = l, par.settings =  
modifyList(standard.theme(color = FALSE),

 list(par.xlab.text = list(cex = 5) )))

I had tried various constructions that I thought would be  
equivalent, but I think I was getting the levels of the list  
structure wrong. This also works:
### NO,  it doesn't. I failed to notice that the command was  
incomplete so was looking at my prior plot.


xyplot(x ~ 1:10, type = l, par.setting=c(list(par.xlab.text =  
list(cex = 5), standard.theme(color = FALSE))  )


Proving that I still do not really understand why the modifyList  
approach works and what seemed to be equivalents do not. (Next  
paragraph is wrong.)


Notice the use of c() rather than list() to bind them together. When  
I looked at the output of standard.theme(color=FALSE), there was no  
par.xlab.text element so it seemed as though there should be no  
conflict and in fact there wasn't (except for the asynchrony between  
my brain and the R interpreter.)


best;
David.


Cheers,

Marius

On 2011-01-04, at 14:32 , David Winsemius wrote:



On Jan 4, 2011, at 5:57 AM, Marius Hofert wrote:


Dear expeRts,

I usually use par.settings = standard.theme(color = FALSE) to  
create lattice graphics

without colors, so something like

library(lattice)
x - runif(10)
xyplot(x ~ 1:10, type = l, par.settings = standard.theme(color  
= FALSE))


Now I would like to use an additional component in par.settings.  
I tried several things

like

xyplot(x ~ 1:10, type = l, par.settings =  
c(standard.theme(color = FALSE), list(par.xlab.text = list(cex =  
5, col = blue


but it doesn't work. I know I could use lattice.options() but is  
there a way to get it

right (locally) with par.settings?


Add it as a list element:

xyplot(x ~ 1:10, type = l, par.settings =  
list(standard.theme(color = FALSE), par.xlab.text = list(cex = 5,  
col = blue)))


--

David Winsemius, MD
West Hartford, CT





David Winsemius, MD
West Hartford, CT

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


David Winsemius, MD
West Hartford, CT

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


[R] plot without points overlap

2011-01-04 Thread joonR

Hi,

I'm trying to plot a grid of points of different dimensions using the simple
plot() function.
I want to plot the points such that they DO NOT overlap,
I guess there should be a way to set a maximum distance between the points,
but I cannot find it.

Can you help?
Thanks a lot!

g

PS: Is it possible to produce device regions of different dimensions?
(i.e. a rectangular one with height  width)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/plot-without-points-overlap-tp3173894p3173894.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] lattice: par.settings with standard.theme() + additional arguments?

2011-01-04 Thread Marius Hofert
Dear David,

that's funny to read. I guess we did pretty much the same. I also thought I got 
the list structure wrong and I also tried c()... (since I recently learned from 
Gabor that a list is only a vector of mode list) and I also searched for 
posts with exactly the same words [but wasn't as successful as you :-)].

Thanks for the modifyList()-trick!

Cheers,

Marius

On 2011-01-04, at 17:37 , David Winsemius wrote:

 
 On Jan 4, 2011, at 11:08 AM, David Winsemius wrote:
 
 
 On Jan 4, 2011, at 8:39 AM, Marius Hofert wrote:
 
 Dear David,
 
 this I already tried. But as you can see, the plot itself *is* colored. 
 However, I want to have color = FALSE, so, unfortunately, this approach 
 does not work...
 
 Quite right. I didn't see that until you pointed it out. I had many failed 
 attempts at a solution and then searched for prior positngs using 
 par.settings and standard.theme and found one by Ehlers earlier this year 
 that seems to work when modified to your ends:
 
 xyplot(x ~ 1:10, type = l, par.settings = modifyList(standard.theme(color 
 = FALSE),
 list(par.xlab.text = list(cex = 5) )))
 
 I had tried various constructions that I thought would be equivalent, but I 
 think I was getting the levels of the list structure wrong. This also works:
 ### NO,  it doesn't. I failed to notice that the command was incomplete so 
 was looking at my prior plot.
 
 xyplot(x ~ 1:10, type = l, par.setting=c(list(par.xlab.text = list(cex = 
 5), standard.theme(color = FALSE))  )
 
 Proving that I still do not really understand why the modifyList approach 
 works and what seemed to be equivalents do not. (Next paragraph is wrong.)
 
 Notice the use of c() rather than list() to bind them together. When I 
 looked at the output of standard.theme(color=FALSE), there was no 
 par.xlab.text element so it seemed as though there should be no conflict and 
 in fact there wasn't (except for the asynchrony between my brain and the R 
 interpreter.)
 
 best;
 David.
 
 Cheers,
 
 Marius
 
 On 2011-01-04, at 14:32 , David Winsemius wrote:
 
 
 On Jan 4, 2011, at 5:57 AM, Marius Hofert wrote:
 
 Dear expeRts,
 
 I usually use par.settings = standard.theme(color = FALSE) to create 
 lattice graphics
 without colors, so something like
 
 library(lattice)
 x - runif(10)
 xyplot(x ~ 1:10, type = l, par.settings = standard.theme(color = FALSE))
 
 Now I would like to use an additional component in par.settings. I tried 
 several things
 like
 
 xyplot(x ~ 1:10, type = l, par.settings = c(standard.theme(color = 
 FALSE), list(par.xlab.text = list(cex = 5, col = blue
 
 but it doesn't work. I know I could use lattice.options() but is there a 
 way to get it
 right (locally) with par.settings?
 
 Add it as a list element:
 
 xyplot(x ~ 1:10, type = l, par.settings = list(standard.theme(color = 
 FALSE), par.xlab.text = list(cex = 5, col = blue)))
 
 -- 
 
 David Winsemius, MD
 West Hartford, CT
 
 
 
 David Winsemius, MD
 West Hartford, CT
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 David Winsemius, MD
 West Hartford, CT
 

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


[R] Page eject and clearing the console

2011-01-04 Thread John Sorkin
(1) I know that \n when used in cat, e.g. cat(\n) produces a line feed (i.e. 
skips to the next line). Is there any escape sequence that will go to the top 
of the next page?
(2) I know that control L will clear the console. Is there an equivalent 
function or other means that can be used in R code to clear the console?

Thanks,
John  


John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

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


Re: [R] Page eject and clearing the console

2011-01-04 Thread Henrique Dallazuanna
Take a look on:
http://tolstoy.newcastle.edu.au/R/e11/help/10/09/8463.html

On Tue, Jan 4, 2011 at 2:54 PM, John Sorkin jsor...@grecc.umaryland.eduwrote:

 (1) I know that \n when used in cat, e.g. cat(\n) produces a line feed
 (i.e. skips to the next line). Is there any escape sequence that will go to
 the top of the next page?
 (2) I know that control L will clear the console. Is there an equivalent
 function or other means that can be used in R code to clear the console?

 Thanks,
 John


 John David Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:20}}

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


Re: [R] Page eject and clearing the console

2011-01-04 Thread Sarah Goslee
Hi John,

I don't understand what you mean by top of the next page, or rather,
how that differs from clearing the screen.

And for the latter, that is dependent on OS, and on GUI/console usage,
and has been discussed several times on the list. The easiest solution
is to invoke the system command if running in a console. For linux,
that would be:
system(clear)

A Google search using the exact words from your question found several
more options, including a discussion of doing this in Windows.
http://www.google.com/search?q=R+code+to+clear+the+console

I can't test them for you, but since I don't know if you're using Windows
or not it may not matter.

Sarah


On Tue, Jan 4, 2011 at 11:54 AM, John Sorkin
jsor...@grecc.umaryland.edu wrote:
 (1) I know that \n when used in cat, e.g. cat(\n) produces a line feed 
 (i.e. skips to the next line). Is there any escape sequence that will go to 
 the top of the next page?
 (2) I know that control L will clear the console. Is there an equivalent 
 function or other means that can be used in R code to clear the console?

 Thanks,
 John


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

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


Re: [R] Help with For instruction

2011-01-04 Thread ADias

Hi,

Still with the above problem:

But for instance, i have a data base with 30 variables and I created an
object each with one varibale missing:

DataBase - has 30 variables
DataBase1 has 29 variables with the 1st variable gone
DataBase2 has 29 variables with the 2nd variable gone

for(i in 1:length(database)) assign(paste(database,i,sep=),database[-i])


Now, I wish to create the 30 distance matrix:

for (i in 1:length(database))
assign(paste(distancematrix,i,sep=),
dist(database[i]))

But doing like this - database[i] - I am just refering to the 1st value on
the object database and not to the entire database i.

How do I do this?

thanks
Regards,
A.Dias
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Help-with-For-instruction-tp3173074p3173914.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] Saving objects inside a list

2011-01-04 Thread Eduardo de Oliveira Horta
Hello,

I've contacted the guys from RKWard. Below I paste the answer Thomas
Friedrichsmeier gave me.

---

Hi,

the problem appears to be our use of active bindings (see
?makeActiveBinding). Internally, RKWard replaces all objects inside
.GlobalEnv
by active bindings. This allows us to find out, when the objects get
modified.
For almost all purposes, these active bindings behave just like the regular
object, but apparently, as.list() copies the accessor functions, instead. I
do
wonder whether that is the expected behavior of as.list()...

Either way, RKWard will probably switch to a different strategy for
detecting
when objects get modified, in the not-too-distant future. The problem should
go
away, then. Meanwhile, perhaps you can work around the problem using code
like
this:

oblist - sapply (ls (all.names=TRUE), function (x) get (x), simplify=FALSE)

Regards
Thomas

On Tue, Jan 4, 2011 at 2:54 PM, William Dunlap wdun...@tibco.com wrote:

 Under RKWard, do you get (at the command line)
   environment()
  environment: R_GlobalEnv
 If environment() doesn't evaluate to .GlobalEnv's
 value then
   as.list(environment())
 may show the B=1000.  It may be that RKWard doesn't
 use .GlobalEnv in the usual way.

 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com


  -Original Message-
  From: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] On Behalf Of Eduardo de
  Oliveira Horta
  Sent: Tuesday, January 04, 2011 6:25 AM
  To: r-help@r-project.org
  Subject: Re: [R] Saving objects inside a list
 
  Hello, (and a happy new year for you too!)
 
  Apparently the problem is happening only within my RKWard sessions:
   B = 1000
   oblist = as.list(.GlobalEnv)
   str(oblist)
  List of 1
   $ B:function (value)
   oblist$B
  function (value)
  {
  if (!missing(value)) {
  assign(k, value, envir = .rk.watched.symbols)
  .rk.do.call(ws, k)
  invisible(value)
  }
  else {
  get(k, envir = .rk.watched.symbols)
  }
  }
  environment: 0x08cc9eec
 
  Now the same code in a regular Rgui session:
   B = 1000
   oblist = as.list(.GlobalEnv)
   str(oblist)
  List of 1
   $ B: num 1000
   oblist$B
  [1] 1000
 
  Problem solved?
 
  Best regards,
 
  Eduardo Horta
 
  On Tue, Jan 4, 2011 at 9:41 AM, Olivier ETERRADOSSI 
  olivier.eterrado...@mines-ales.fr wrote:
 
   Message: 42
   Date: Mon, 3 Jan 2011 18:58:04 -0200
   From: Eduardo de Oliveira Hortaeduardo.oliveiraho...@gmail.com
  
   To: r-helpr-help@r-project.org
   Subject: Re: [R] Saving objects inside a list
   Message-ID:
  
  aanlktimbxmr0rusiws1grorhjh=wstofzqdoc-90z...@mail.gmail.com
   Content-Type: text/plain
  
  
   sapply(ls(),get) works fine. Thanks.
  
   ps: the as.list and the eapply suggestions didn't work.
  
   Hi Eduardo (and all the best for this new year),
  
   are you sure the as.list and eapply solutions didn't work ?
  On my machine
   they produce a list but in reverse order compared to the result of
   ls(),...maybe it's the same with you :
  
   names(as.list(.GlobalEnv))[6] is the name of the 6th
  variable FROM THE END
   of ls().
  
   Regards. Olivier
  
   --
   Olivier ETERRADOSSI
   Maître-Assistant
   animateur du groupe Sensomines (Institut Carnot M.I.N.E.S)
   -
   CMGD
   Pôle Matériaux Polymères Avancés
   axe Propriétés Psycho-Sensorielles des Matériaux
   -
   Ecole des Mines d'Alès
   Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9
   tel std: +33 (0)5.59.30.54.25
   tel direct: +33 (0)5.59.30.90.35
   fax: +33 (0)5.59.30.63.68
   http://www.mines-ales.fr
   e-mail : olivier.eterrado...@mines-ales.fr
  
  
  
 
[[alternative HTML version deleted]]
 
 


[[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] Page eject and clearing the console

2011-01-04 Thread Gabor Grothendieck
On Tue, Jan 4, 2011 at 9:48 AM, John Sorkin jsor...@grecc.umaryland.edu wrote:
 (1) I know that \n when used in cat, e.g. cat(\n) produces a line feed 
 (i.e. skips to the next line). Is there any escape sequence that will go to 
 the top of the next page?
 (2) I know that control L will clear the console. Is there an equivalent 
 function or other means that can be used in R code to clear the console?


Its always a good idea to look through the archives before posting.  I
had posted this 5 years ago.  It uses RDCOMClient:

http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg57802.html

and also posted a second version using rcom in the same thread.

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] plot without points overlap

2011-01-04 Thread Joshua Wiley
Hi,

You can set the device region in inches using the pin argument (see
?par maybe halfway down or so).  You can also set the aspect ratio in
plot(), but I am not sure that is really what you want (see
?plot.window for that).

Two Examples
###
par(pin = c(2, 4))
plot(1:10)
dev.off()

plot(1:10, asp = 2)
###

Hope that helps,

Josh


On Tue, Jan 4, 2011 at 8:46 AM, joonR joon...@gmail.com wrote:

 Hi,

 I'm trying to plot a grid of points of different dimensions using the simple
 plot() function.
 I want to plot the points such that they DO NOT overlap,
 I guess there should be a way to set a maximum distance between the points,
 but I cannot find it.

 Can you help?
 Thanks a lot!

 g

 PS: Is it possible to produce device regions of different dimensions?
 (i.e. a rectangular one with height  width)
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/plot-without-points-overlap-tp3173894p3173894.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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] lattice: how to center a title?

2011-01-04 Thread mhofert

Dear Dieter,

many thanks, exactly what I was looking for.

Cheers,

Marius
-- 
View this message in context: 
http://r.789695.n4.nabble.com/lattice-how-to-center-a-title-tp3173271p3173931.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] Calendar in R-program

2011-01-04 Thread Mark Sharp
Look at the lubridate package from Hadley Wickham for great basic routines for 
handling date objects.

Mark
R. Mark Sharp, Ph.D.
msh...@sfbr.orgmailto:msh...@sfbr.org




On Jan 4, 2011, at 8:02 AM, LOON88 wrote:


Hey.
I have to do calendar in program R. I was looking for examples on this forum
but havent found it. Can someone help me in this thing ? I would be really
appreciate for that. Calendar should be the same as we have in Windows but I
really dont know how to begin it. Hope u can show me the best way to do it.
Cheers
--
View this message in context: 
http://r.789695.n4.nabble.com/Calendar-in-R-program-tp3173566p3173566.html
Sent from the R help mailing list archive at Nabble.comhttp://Nabble.com.

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


[[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] packagename:::functionname vs. importFrom

2011-01-04 Thread Frank Harrell

Thanks Luke.  By the namespace from which you import is loaded when your 
package is I take it that you are saying that all such referenced packages
are loaded up front, which is not what I hoped.  And it's too bad you can't
import unexported objects, as that rather defeats the purpose of importFrom.

Frank


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
-- 
View this message in context: 
http://r.789695.n4.nabble.com/packagename-functionname-vs-importFrom-tp3172684p3174003.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] packagename:::functionname vs. importFrom

2011-01-04 Thread Frank Harrell

Thanks Hadley, Luke, Martin, and Bill.  Bill captured the essence of my
reasons for needing an unexported function.  Other reasons include
occasional overrides of dispatching rules, and providing parallel versions
of some functions that exist in other packages to make them easier to use in
some sense.  I could ask the package creator to export those functions but
it would not make sense to him to do so.

Frank


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
-- 
View this message in context: 
http://r.789695.n4.nabble.com/packagename-functionname-vs-importFrom-tp3172684p3174011.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] Help with For instruction

2011-01-04 Thread André Dias
hi

how do I exactly use the get(). I am reading the help for get() but the way
I am using it causes an error/

thanks
ADias

2011/1/4 Sarah Goslee sarah.gos...@gmail.com

 With get().

 On Tue, Jan 4, 2011 at 11:58 AM, ADias diasan...@gmail.com wrote:
 
  Hi,
 
  Still with the above problem:
 
  But for instance, i have a data base with 30 variables and I created an
  object each with one varibale missing:
 
  DataBase - has 30 variables
  DataBase1 has 29 variables with the 1st variable gone
  DataBase2 has 29 variables with the 2nd variable gone
 
  for(i in 1:length(database))
 assign(paste(database,i,sep=),database[-i])
 
 
  Now, I wish to create the 30 distance matrix:
 
  for (i in 1:length(database))
  assign(paste(distancematrix,i,sep=),
  dist(database[i]))
 
  But doing like this - database[i] - I am just refering to the 1st value
 on
  the object database and not to the entire database i.
 
  How do I do this?
 
  thanks
  Regards,
  A.Dias
  --
 --
 Sarah Goslee
 http://www.functionaldiversity.org


[[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] Resampling to find Confidence intervals

2011-01-04 Thread Ben Ward

Ok I'll check I understand:
So it's using sample, to resample d once, 10 values, because the rnorm 
has 10 values, with replacement (I assume thats the TRUE part).
Then a for loop has this to resample the data - in the loop's case its 
1000 times. Then it does a lm to get the coefficients and add them to 
d1.coef. I'm guessing that the allboot bit with rbind, which is null at 
the start of the loop, is the collection of d1.coef values, as I think 
that without it, every cycle of the loop the d1.coef from the previous 
cycle round the loop would be gone?


On 04/01/2011 16:24, Dieter Menne wrote:

Axolotl9250 wrote:


...
resampled_ecoli = sample(ecoli, 500, replace=T)
coefs = (coef(lm(MIC. ~ 1 + Challenge + Cleaner + Replicate,
data=resampled_ecoli)))
sd(coefs)

...


Below a simplified and self-consistent version of your code, and some
changes

Dieter

# resample
d = data.frame(x=rnorm(10))
d$y = d$x*3+rnorm(10,0.01)

# if you do this, you only get ONE bootstrap sample
d1 = d[sample(1:nrow(d),10,TRUE),]
d1.coef = coef(lm(y~x,data=d1))
d1.coef
# No error below, because you compute the sd of (Intercept) and slope
# but result is wrong!
sd(d1.coef)

# We have to do this over and over
# Check ?replicate for a more R-ish approach
nsamples = 1000
allboot = NULL
for (i in 1:1000) {
   d1 = d[sample(1:nrow(d),10,TRUE),]
   d1.coef = coef(lm(y~x,data=d1))
   allboot = rbind(allboot,d1.coef) # Not very efficient, preallocate!
}
head(allboot) # display first of nsamples lines
apply(allboot,2,mean) # Compute mean
apply(allboot,2,sd) # compute sd
# After you are sure you understood the above, you might try package boot.







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

2011-01-04 Thread Sarah Goslee
2011/1/4 André Dias diasan...@gmail.com:
 hi

 how do I exactly use the get(). I am reading the help for get() but the way
 I am using it causes an error/


So how are you using it? It's so much easier to explain what you're doing
wrong if I know what you're doing.

Without a reproducible example I can't show you exactly, but
something like:

 for (i in 1:length(database))
assign(paste(distancematrix,i,sep=), dist(get(paste(database, i,
sep=

get() is the counterpart of assign(), though there are better (more R-ish)
ways of doing what you want.

Sarah


 thanks
 ADias

 2011/1/4 Sarah Goslee sarah.gos...@gmail.com

 With get().

 On Tue, Jan 4, 2011 at 11:58 AM, ADias diasan...@gmail.com wrote:
 
  Hi,
 
  Still with the above problem:
 
  But for instance, i have a data base with 30 variables and I created an
  object each with one varibale missing:
 
  DataBase - has 30 variables
  DataBase1 has 29 variables with the 1st variable gone
  DataBase2 has 29 variables with the 2nd variable gone
 
  for(i in 1:length(database))
  assign(paste(database,i,sep=),database[-i])
 
 
  Now, I wish to create the 30 distance matrix:
 
  for (i in 1:length(database))
  assign(paste(distancematrix,i,sep=),
  dist(database[i]))
 
  But doing like this - database[i] - I am just refering to the 1st value
  on
  the object database and not to the entire database i.
 
  How do I do this?
 
  thanks
  Regards,
  A.Dias
  --
 --

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

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


Re: [R] Inverse Gaussian Distribution

2011-01-04 Thread Louisa

Dear David, 
It works! 
Thank you so much for your help!
Louisa 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Inverse-Gaussian-Distribution-tp3172533p3174015.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] Help with For instruction

2011-01-04 Thread Greg Snow
If you had followed David's advice and put everything into a list or other 
structure instead of using the assign function (see fortune(236)) then you 
could just access the list element instead of needing get.  In the long run (or 
even medium and short run) life will be much easier for you if you learn to use 
proper data structures and not programmatically create global variables.

-- 
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 André Dias
 Sent: Tuesday, January 04, 2011 10:55 AM
 To: Sarah Goslee
 Cc: r-help@r-project.org
 Subject: Re: [R] Help with For instruction
 
 hi
 
 how do I exactly use the get(). I am reading the help for get() but the
 way
 I am using it causes an error/
 
 thanks
 ADias
 
 2011/1/4 Sarah Goslee sarah.gos...@gmail.com
 
  With get().
 
  On Tue, Jan 4, 2011 at 11:58 AM, ADias diasan...@gmail.com wrote:
  
   Hi,
  
   Still with the above problem:
  
   But for instance, i have a data base with 30 variables and I
 created an
   object each with one varibale missing:
  
   DataBase - has 30 variables
   DataBase1 has 29 variables with the 1st variable gone
   DataBase2 has 29 variables with the 2nd variable gone
  
   for(i in 1:length(database))
  assign(paste(database,i,sep=),database[-i])
  
  
   Now, I wish to create the 30 distance matrix:
  
   for (i in 1:length(database))
   assign(paste(distancematrix,i,sep=),
   dist(database[i]))
  
   But doing like this - database[i] - I am just refering to the 1st
 value
  on
   the object database and not to the entire database i.
  
   How do I do this?
  
   thanks
   Regards,
   A.Dias
   --
  --
  Sarah Goslee
  http://www.functionaldiversity.org
 
 
   [[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] Help with For instruction

2011-01-04 Thread André Dias
Hi

I was doing

for (i in 1:length(database))
assign(paste(distancematrix,i,sep=), dist(paste(get(database, i,
sep=)

but i really did not know what I was doing. I will try your way. But I still
don't understnad how the get function works.

What woud be more r-ish then get() ?

thanks
ADias



No dia 4 de Janeiro de 2011 17:58, Sarah Goslee
sarah.gos...@gmail.comescreveu:

 2011/1/4 André Dias diasan...@gmail.com:
  hi
 
  how do I exactly use the get(). I am reading the help for get() but the
 way
  I am using it causes an error/
 

 So how are you using it? It's so much easier to explain what you're doing
 wrong if I know what you're doing.

 Without a reproducible example I can't show you exactly, but
 something like:

  for (i in 1:length(database))
 assign(paste(distancematrix,i,sep=), dist(get(paste(database, i,
 sep=

 get() is the counterpart of assign(), though there are better (more R-ish)
 ways of doing what you want.

 Sarah


  thanks
  ADias
 
  2011/1/4 Sarah Goslee sarah.gos...@gmail.com
 
  With get().
 
  On Tue, Jan 4, 2011 at 11:58 AM, ADias diasan...@gmail.com wrote:
  
   Hi,
  
   Still with the above problem:
  
   But for instance, i have a data base with 30 variables and I created
 an
   object each with one varibale missing:
  
   DataBase - has 30 variables
   DataBase1 has 29 variables with the 1st variable gone
   DataBase2 has 29 variables with the 2nd variable gone
  
   for(i in 1:length(database))
   assign(paste(database,i,sep=),database[-i])
  
  
   Now, I wish to create the 30 distance matrix:
  
   for (i in 1:length(database))
   assign(paste(distancematrix,i,sep=),
   dist(database[i]))
  
   But doing like this - database[i] - I am just refering to the 1st
 value
   on
   the object database and not to the entire database i.
  
   How do I do this?
  
   thanks
   Regards,
   A.Dias
   --
  --

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


[[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] Help with For instruction

2011-01-04 Thread Sarah Goslee
You need to swap the get and paste commands -
paste() creates the string filename that get() acts on.

As already explained, using a list is much nicer.

Sarah

2011/1/4 André Dias diasan...@gmail.com:
 Hi

 I was doing

 for (i in 1:length(database))
 assign(paste(distancematrix,i,sep=), dist(paste(get(database, i,
 sep=)

 but i really did not know what I was doing. I will try your way. But I still
 don't understnad how the get function works.

 What woud be more r-ish then get() ?

 thanks
 ADias

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

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


Re: [R] Calendar in R-program

2011-01-04 Thread Spencer Graves
  If all you want is a calendar Date, the simplest may be the 
Date class in the base package.  Try help('as.Date').



  Dates and times can be extremely difficult to use for many 
reasons.  For example, some months have 30 days, others have 31, and 
February usually has 28 days, but every 4th year, it has 29, except if 
the year is a century year, except ... .  Times involve arithmetic to 
multiple bases.  In addition, there are occasional leap seconds 
introduced by irregularities in the rotation of the earth.  Then don't 
forget timezones and holidays, which vary between countries and 
sometimes between regions within a country.  Holidays further depend on 
the occupation.  Financial markets have their own rules.



  This complexity is met by a wide range of alternative systems in 
R for coding dates and times.  A great overview of the options appeared 
in R News a few years ago.  To find it,
go to r-project.org - The R Journal - Archive - Table of 
Contents (all issues) - Search for date.  The second match should be 
Gabor Grothendieck and Thomas Petzoldt. R Help Desk: Date and time 
classes in R. R News, 4(1):29-32, June 2004.



  There have been many additions since 2004.  Probably the quickest 
way to find other options is to use the sos package.



library(sos)
(cndr - ???calendar)
#found 238 matches;  retrieving 12 pages
# This will open a table in a web browser showing the 238 matches
# sorted by package.
# A function from the lubridate package is match # 229 on this list.


  The sos package also has a vignette, which provides examples of 
how to combine searches, write results to an Excel file with the first 
sheet being a summary by package, etc.



  Hope this helps.
  Spencer


On 1/4/2011 9:32 AM, Mark Sharp wrote:

Look at the lubridate package from Hadley Wickham for great basic routines for 
handling date objects.

Mark
R. Mark Sharp, Ph.D.
msh...@sfbr.orgmailto:msh...@sfbr.org




On Jan 4, 2011, at 8:02 AM, LOON88 wrote:


Hey.
I have to do calendar in program R. I was looking for examples on this forum
but havent found it. Can someone help me in this thing ? I would be really
appreciate for that. Calendar should be the same as we have in Windows but I
really dont know how to begin it. Hope u can show me the best way to do it.
Cheers
--
View this message in context: 
http://r.789695.n4.nabble.com/Calendar-in-R-program-tp3173566p3173566.html
Sent from the R help mailing list archive at Nabble.comhttp://Nabble.com.

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


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





--
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] Page eject and clearing the console

2011-01-04 Thread John Sorkin
I have received help on one of my questions (thank you Henrique Jorge
and ), viz. how I can clear the console from an R program. 
I have not yet received help on how I can skip to the top of the next
page, i.e. cat(\n) skips to the next line, is there an equivalent way
to skip to the top of the next page?
Thanks,
John




John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
Henrique Dallazuanna www...@gmail.com 1/4/2011 11:58 AM 
Take a look on:
http://tolstoy.newcastle.edu.au/R/e11/help/10/09/8463.html 

On Tue, Jan 4, 2011 at 2:54 PM, John Sorkin
jsor...@grecc.umaryland.eduwrote:

 (1) I know that \n when used in cat, e.g. cat(\n) produces a line
feed
 (i.e. skips to the next line). Is there any escape sequence that will
go to
 the top of the next page?
 (2) I know that control L will clear the console. Is there an
equivalent
 function or other means that can be used in R code to clear the
console?

 Thanks,
 John


 John David Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Confidentiality Statement:
 This email message, including any attachments, is for\...{{dropped:25}}

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


Re: [R] Page eject and clearing the console

2011-01-04 Thread David Winsemius


On Jan 4, 2011, at 1:19 PM, John Sorkin wrote:


I have received help on one of my questions (thank you Henrique Jorge
and ), viz. how I can clear the console from an R program.
I have not yet received help on how I can skip to the top of the next
page, i.e. cat(\n) skips to the next line, is there an equivalent  
way

to skip to the top of the next page?


\n does NOT skip to the next line. It is a character and it is  
interpreted by some sort of program, say a a plotting program or a  
word-processor as a line feed. You need to specify what sort of  
program you intend to do this skipping-to-next-page action and also  
provide the character sequence that that program uses to signal that  
action. (There are not any pages in R except perhaps multi-page plots  
but you seem to be in character mode at the moment.)


--
David.



Thanks,
John




John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
Henrique Dallazuanna www...@gmail.com 1/4/2011 11:58 AM 
Take a look on:
http://tolstoy.newcastle.edu.au/R/e11/help/10/09/8463.html

On Tue, Jan 4, 2011 at 2:54 PM, John Sorkin
jsor...@grecc.umaryland.eduwrote:


(1) I know that \n when used in cat, e.g. cat(\n) produces a line

feed

(i.e. skips to the next line). Is there any escape sequence that will

go to

the top of the next page?
(2) I know that control L will clear the console. Is there an

equivalent

function or other means that can be used in R code to clear the

console?


Thanks,
John


John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for\...{{dropped: 
25}}


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


David Winsemius, MD
West Hartford, CT

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


Re: [R] Page eject and clearing the console

2011-01-04 Thread David Winsemius


On Jan 4, 2011, at 1:27 PM, David Winsemius wrote:



On Jan 4, 2011, at 1:19 PM, John Sorkin wrote:


I have received help on one of my questions (thank you Henrique Jorge
and ), viz. how I can clear the console from an R program.
I have not yet received help on how I can skip to the top of the next
page, i.e. cat(\n) skips to the next line, is there an equivalent  
way

to skip to the top of the next page?


\n does NOT skip to the next line. It is a character and it is  
interpreted by some sort of program, say a a plotting program or a  
word-processor as a line feed. You need to specify what sort of  
program you intend to do this skipping-to-next-page action and  
also provide the character sequence that that program uses to signal  
that action. (There are not any pages in R except perhaps multi-page  
plots but you seem to be in character mode at the moment.)




It has occurred to me that you may be asking for something that will  
give the illusion of clearing the screen but will in fact be just  
printing a page of blank space on a console display, scrolling would  
ahve been the name I would have given it. In which case:


scroll - function(lines=40) cat(rep(\n, lines))
scroll()


--
David.



Thanks,
John




John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to  
faxing)

Henrique Dallazuanna www...@gmail.com 1/4/2011 11:58 AM 
Take a look on:
http://tolstoy.newcastle.edu.au/R/e11/help/10/09/8463.html

On Tue, Jan 4, 2011 at 2:54 PM, John Sorkin
jsor...@grecc.umaryland.eduwrote:


(1) I know that \n when used in cat, e.g. cat(\n) produces a line

feed
(i.e. skips to the next line). Is there any escape sequence that  
will

go to

the top of the next page?
(2) I know that control L will clear the console. Is there an

equivalent

function or other means that can be used in R code to clear the

console?


Thanks,
John


John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for\...{{dropped: 
25}}


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


David Winsemius, MD
West Hartford, CT

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] Page eject and clearing the console

2011-01-04 Thread Bert Gunter
Perhaps merely rephrasing David's comments,

page is not a meaningful physical entity -- it depends on font size,
line spacing, etc. and the physical size of the output surface,
which has no meaning for an infinitely (or at least up to tyhe
screen buffer's limit) scrollable screen viewing area.

But maybe David's scroll function is what you had in mind.

-- Bert

On Tue, Jan 4, 2011 at 10:55 AM, David Winsemius dwinsem...@comcast.net wrote:

 On Jan 4, 2011, at 1:27 PM, David Winsemius wrote:


 On Jan 4, 2011, at 1:19 PM, John Sorkin wrote:

 I have received help on one of my questions (thank you Henrique Jorge
 and ), viz. how I can clear the console from an R program.
 I have not yet received help on how I can skip to the top of the next
 page, i.e. cat(\n) skips to the next line, is there an equivalent way
 to skip to the top of the next page?

 \n does NOT skip to the next line. It is a character and it is
 interpreted by some sort of program, say a a plotting program or a
 word-processor as a line feed. You need to specify what sort of program you
 intend to do this skipping-to-next-page action and also provide the
 character sequence that that program uses to signal that action. (There are
 not any pages in R except perhaps multi-page plots but you seem to be in
 character mode at the moment.)


 It has occurred to me that you may be asking for something that will give
 the illusion of clearing the screen but will in fact be just printing a
 page of blank space on a console display, scrolling would ahve been the name
 I would have given it. In which case:

 scroll - function(lines=40) cat(rep(\n, lines))
 scroll()

 --
 David.


 Thanks,
 John




 John David Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 Henrique Dallazuanna www...@gmail.com 1/4/2011 11:58 AM 
 Take a look on:
 http://tolstoy.newcastle.edu.au/R/e11/help/10/09/8463.html

 On Tue, Jan 4, 2011 at 2:54 PM, John Sorkin
 jsor...@grecc.umaryland.eduwrote:

 (1) I know that \n when used in cat, e.g. cat(\n) produces a line

 feed

 (i.e. skips to the next line). Is there any escape sequence that will

 go to

 the top of the next page?
 (2) I know that control L will clear the console. Is there an

 equivalent

 function or other means that can be used in R code to clear the

 console?

 Thanks,
 John


 John David Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Confidentiality Statement:
 This email message, including any attachments, is for\...{{dropped:25}}

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

 David Winsemius, MD
 West Hartford, CT

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

 David Winsemius, MD
 West Hartford, CT

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




-- 
Bert Gunter
Genentech Nonclinical Biostatistics

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 : merge.xts seems to have problem with character vectors

2011-01-04 Thread rivercode

Hi,

Please can you tell me what I am doing wrong.  When trying to merge two xts
objects, one of which has multiple character vectors for columns...I am just
getting NAs.

 str(t)
 POSIXct[1:1], format: 2011-01-04 11:45:37

 y2 = xts(matrix(c(letters[1:10]),5), order.by=as.POSIXct(c(t + 1:5)))
 names(y2) = c(1,2)
 y2
1   2  
2011-01-04 11:45:38 a f
2011-01-04 11:45:39 b g
2011-01-04 11:45:40 c h
2011-01-04 11:45:41 d i
2011-01-04 11:45:42 e j

 y1 = xts(c(1:5), order.by=as.POSIXct(c(t + 1:5)))
 y1
[,1]
2011-01-04 11:45:381
2011-01-04 11:45:392
2011-01-04 11:45:403
2011-01-04 11:45:414
2011-01-04 11:45:425

 merge(y1, y2)
y1 X1 X2
2011-01-04 11:45:38  1 NA NA
2011-01-04 11:45:39  2 NA NA
2011-01-04 11:45:40  3 NA NA
2011-01-04 11:45:41  4 NA NA
2011-01-04 11:45:42  5 NA NA

Warning message:
In merge.xts(y1, y2) : NAs introduced by coercion

Why do I lose the character columns ?

Cheers,
Chris
-- 
View this message in context: 
http://r.789695.n4.nabble.com/XTS-merge-xts-seems-to-have-problem-with-character-vectors-tp3174125p3174125.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] Navigating web pages using R

2011-01-04 Thread Erik Gregory
R-Help,

I'm trying to obtain some data from a webpage which masks the URL from the 
user, 
so an explicit URL will not work.  For example, when one navigates to the web 
page the URL looks something like:
http://137.113.141.205/rpt34s.php?flags=1 (changed for privacy, but i'm not 
sure 
you could access it anyways since it's internal to the agency I work for).
The site has three drop-down menus for Site, Month, and Year.  When a 
combination is selected of these, the resulting URL is 
always http://137.113.141.205/rpt34s (nothing changes, except flags=1 is 
dropped, so what I need to be able to do is write something that will navigate 
to the original URL, then select some combination of Site, Month, and 
Year, and then submit the query to the site to navigate to the page with the 
data. 
Is this a capability that R has as a language?  Unfortunately, I'm unfamiliar 
with html or php programming, so if this question belongs in a forum on that I 
apologize.  I'm trying to centralize all of my code for my analysis in R!

Thank you,
-Erik Gregory
Student Assistant, California EPA
CSU Sacramento, Mathematics

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


Re: [R] XTS : merge.xts seems to have problem with character vectors

2011-01-04 Thread Joshua Ulrich
On Tue, Jan 4, 2011 at 12:42 PM, rivercode aqua...@gmail.com wrote:

 Hi,

 Please can you tell me what I am doing wrong.  When trying to merge two xts
 objects, one of which has multiple character vectors for columns...I am just
 getting NAs.

 str(t)
  POSIXct[1:1], format: 2011-01-04 11:45:37

 y2 = xts(matrix(c(letters[1:10]),5), order.by=as.POSIXct(c(t + 1:5)))
 names(y2) = c(1,2)
 y2
                    1   2
 2011-01-04 11:45:38 a f
 2011-01-04 11:45:39 b g
 2011-01-04 11:45:40 c h
 2011-01-04 11:45:41 d i
 2011-01-04 11:45:42 e j

 y1 = xts(c(1:5), order.by=as.POSIXct(c(t + 1:5)))
 y1
                    [,1]
 2011-01-04 11:45:38    1
 2011-01-04 11:45:39    2
 2011-01-04 11:45:40    3
 2011-01-04 11:45:41    4
 2011-01-04 11:45:42    5

 merge(y1, y2)
                    y1 X1 X2
 2011-01-04 11:45:38  1 NA NA
 2011-01-04 11:45:39  2 NA NA
 2011-01-04 11:45:40  3 NA NA
 2011-01-04 11:45:41  4 NA NA
 2011-01-04 11:45:42  5 NA NA

 Warning message:
 In merge.xts(y1, y2) : NAs introduced by coercion

 Why do I lose the character columns ?


Because zoo / xts objects are matrices with an ordered index (a time
index in the case of xts).  You can't mix types in a matrix.

--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com


 Cheers,
 Chris
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/XTS-merge-xts-seems-to-have-problem-with-character-vectors-tp3174125p3174125.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] Page eject and clearing the console

2011-01-04 Thread John Sorkin
I am looking for something which will emulate the following:
Back in the old days, when printing to a line printer, the first two characters 
in a line controlled printing. For example, a line starting with 
1h1 starts printing at the top of the next page.
1h+ indicates overprinting
1h0 results in double 
In R \n skips to the next line. Is there some escape sequence that will start 
printing at the top of the next page?
Thanks,
John





John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) Bert 
Gunter gunter.ber...@gene.com 1/4/2011 2:05 PM 
Perhaps merely rephrasing David's comments,

page is not a meaningful physical entity -- it depends on font size,
line spacing, etc. and the physical size of the output surface,
which has no meaning for an infinitely (or at least up to tyhe
screen buffer's limit) scrollable screen viewing area.

But maybe David's scroll function is what you had in mind.

-- Bert

On Tue, Jan 4, 2011 at 10:55 AM, David Winsemius dwinsem...@comcast.net wrote:

 On Jan 4, 2011, at 1:27 PM, David Winsemius wrote:


 On Jan 4, 2011, at 1:19 PM, John Sorkin wrote:

 I have received help on one of my questions (thank you Henrique Jorge
 and ), viz. how I can clear the console from an R program.
 I have not yet received help on how I can skip to the top of the next
 page, i.e. cat(\n) skips to the next line, is there an equivalent way
 to skip to the top of the next page?

 \n does NOT skip to the next line. It is a character and it is
 interpreted by some sort of program, say a a plotting program or a
 word-processor as a line feed. You need to specify what sort of program you
 intend to do this skipping-to-next-page action and also provide the
 character sequence that that program uses to signal that action. (There are
 not any pages in R except perhaps multi-page plots but you seem to be in
 character mode at the moment.)


 It has occurred to me that you may be asking for something that will give
 the illusion of clearing the screen but will in fact be just printing a
 page of blank space on a console display, scrolling would ahve been the name
 I would have given it. In which case:

 scroll - function(lines=40) cat(rep(\n, lines))
 scroll()

 --
 David.


 Thanks,
 John




 John David Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 Henrique Dallazuanna www...@gmail.com 1/4/2011 11:58 AM 
 Take a look on:
 http://tolstoy.newcastle.edu.au/R/e11/help/10/09/8463.html 

 On Tue, Jan 4, 2011 at 2:54 PM, John Sorkin
 jsor...@grecc.umaryland.eduwrote:

 (1) I know that \n when used in cat, e.g. cat(\n) produces a line

 feed

 (i.e. skips to the next line). Is there any escape sequence that will

 go to

 the top of the next page?
 (2) I know that control L will clear the console. Is there an

 equivalent

 function or other means that can be used in R code to clear the

 console?

 Thanks,
 John


 John David Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

 Confidentiality Statement:
 This email message, including any attachments, is for\...{{dropped:25}}

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

 David Winsemius, MD
 West Hartford, CT

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

 David Winsemius, MD
 West Hartford, CT

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




-- 
Bert Gunter
Genentech Nonclinical Biostatistics

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

[R] R implementation of S-distribution

2011-01-04 Thread Seth W Bigelow
I'm working with data that can exhibit either strong right- or left-skew. 
I understand the S-distribution is useful in such cases
(e.g., Voit and Schwacke, 2000. Random Number Generation from 
Right-Skewed, Symmetric, and Left-Skewed Distributions. Risk Analysis 20 
(1): 59-71).
Does anyone know of any R implementation of this distribution?


Dr. Seth  W. Bigelow
Biologist, USDA-FS Pacific Southwest Research Station
1731 Research Park Drive, Davis California
sbige...@fs.fed.us /  ph. 530 759 1718
[[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] Non-uniformly distributed plot

2011-01-04 Thread Eric Hu
Hi Dennise, David and Jorge,

I hope you all had a great holiday season. Thank you so much for the good 
comments. I think all your suggestions are sufficient for my current needs. I 
guess it is safe to say that there is no easy way to plot the data according to 
the x-axis range. By the way, spotfire can achieve this beautifully.

Eric


From: Dennis Murphy [mailto:djmu...@gmail.com]
Sent: Friday, December 24, 2010 12:43 PM
To: Eric Hu
Cc: r-help@r-project.org
Subject: Re: [R] Non-uniformly distributed plot

Hi:

One way to combine Jorge's and David's solutions is to visualize the data in 
ggplot2 and/or lattice:

library(ggplot2)
x - c(0.349763, 3.39489, 1.52249, 0.269066, 0.107872, 0.0451689,
0.590268, 0.275755, 0.751845, 1.00599, 0.652409, 2.80664, 0.0269933,
0.137307, 0.282939, 1.23008, 0.436429, 0.0555626, 1.10624, 53,
1.30411, 1.29749, 53, 3.2552, 1.189, 2.23616, 1.13259, 0.505039,
1.05812, 1.18238, 0.500926, 1.0314, 0.733468, 3.13292, 1.26685,
3.10882, 1.01719, 0.13096, 0.0529692, 0.418408, 0.213299, 0.536631,
1.82336, 1.15287, 0.192519, 0.961295, 51, 0.470511, 4.05688,
1.78098, 0.364686, 1.24533)
y - c(0.423279, 0.473681, 0.629478, 1.09712, 0.396239, 0.273577,
0.303214, 0.628386, 0.465841, 0.687251, 0.544569, 0.635805, 0.358983,
0.16519, 0.366217, 1.08421, 0.668939, 0.181861, 0.782656, 13.3816,
1.15256, 0.965943, 20, 2.86051, 0.304939, 1.94654, 0.967576,
0.647599, 0.520811, 1.27434, 0.363666, 0.93621, 0.544573, 0.696733,
1.0031, 3.78895, 0.694053, 0.289111, 0.178439, 0.746576, 0.391725,
0.363901, 1.20297, 0.461934, 0.364011, 0.691368, 20, 0.81947,
1.69594, 1.56381, 0.900398, 0.960948)

d - data.frame(x, y)

g - ggplot(d, aes(log(x), log(y))
g + geom_point() + geom_smooth(colour = 'red', size = 1) +
  geom_smooth(method = 'lm', colour = 'blue', size = 1)

The default smooth is a loess curve, which shows the curvature present in the 
residual  vs. fitted plot from Jorge's solution. The predicted values from the 
linear model in the log-log scale lie along the blue line. (To get rid of the 
confidence curves, add se = FALSE to both geom_smooth() calls above.) If you 
were to fit a model to these data in the log-log scale, the plot indicates that 
a quadratic polynomial would be a reasonable next step.

This is pretty easy to do in lattice as well (sans the confidence curves):

library(lattice)
xyplot(log(y) ~ log(x), data = d, type = c('p', 'r', 'smooth'),
pch = 16, col = 'black',
panel = function(x, y, ...) {
   panel.xyplot(x, y, ..., col.line = 'blue')
   panel.loess(x, y, col.line = 'red')
   }
)

I needed to write a small panel function to get separate colors for the least 
squares line and loess curves, but maybe there's an easier way (col.line = 
c('blue', 'red') by itself doesn't work - I tried that - and it makes sense to 
me why it doesn't).

Dennis

On Thu, Dec 23, 2010 at 3:50 PM, David Winsemius 
dwinsem...@comcast.netmailto:dwinsem...@comcast.net wrote:

On Dec 23, 2010, at 6:41 PM, David Winsemius wrote:

On Dec 23, 2010, at 5:55 PM, Eric Hu wrote:
Thanks David. I am reposting the data here.

Jorge has already responded masterfully. He's apparently less lazy that I and 
did all the editing. A log transformation as he illustrated can be very useful 
with bivariate skewed distributions. The only variation I would have suggested 
would be to record the default par settings and restore them at the end.

You could also repeat the plot an use abline to look at the predicted values

plot(x,y, log=xy)
lines( log(x), fit$predicted)

It's complementary to the residual plot and the QQ plot in the plot.lm display 
for consideration of the possibility that this may not be a truly 
log-log-linear relationship.



--
David

Eric

Hi,

I would like to plot a linear relationship between variable x and y.
Can anyone help me with scaled plotting and axes so that all data
points can be visualized somehow evenly? Plaint plot(x,y) will
generate condensed points near (0,0) due to several large data
points. Thank you.

Eric


dput(x)
c(0.349763, 3.39489, 1.52249, 0.269066, 0.107872, 0.0451689,
0.590268, 0.275755, 0.751845, 1.00599, 0.652409, 2.80664, 0.0269933,
0.137307, 0.282939, 1.23008, 0.436429, 0.0555626, 1.10624, 53,
1.30411, 1.29749, 53, 3.2552, 1.189, 2.23616, 1.13259, 0.505039,
1.05812, 1.18238, 0.500926, 1.0314, 0.733468, 3.13292, 1.26685,
3.10882, 1.01719, 0.13096, 0.0529692, 0.418408, 0.213299, 0.536631,
1.82336, 1.15287, 0.192519, 0.961295, 51, 0.470511, 4.05688,
1.78098, 0.364686, 1.24533)
dput(y)
c(0.423279, 0.473681, 0.629478, 1.09712, 0.396239, 0.273577,
0.303214, 0.628386, 0.465841, 0.687251, 0.544569, 0.635805, 0.358983,
0.16519, 0.366217, 1.08421, 0.668939, 0.181861, 0.782656, 13.3816,
1.15256, 0.965943, 20, 2.86051, 0.304939, 1.94654, 0.967576,
0.647599, 0.520811, 1.27434, 0.363666, 0.93621, 0.544573, 0.696733,
1.0031, 3.78895, 0.694053, 0.289111, 0.178439, 0.746576, 0.391725,
0.363901, 

[R] R command execution from shell

2011-01-04 Thread Sebastien Bihorel

Dear R-users,

Is there a way I can ask R to execute the write(hello 
world,file=hello.txt) command directly from the UNIX shell, instead 
of having to save this command to a .R file and execute this file with R 
CMD BATCH?


Thank you

Sebastien

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


Re: [R] Listing of available functions

2011-01-04 Thread Sébastien Bihorel
Thank you David, Duncan, and Henrique.

This is going to be useful.

Sebastien

On Tue, Jan 4, 2011 at 8:38 AM, David Winsemius dwinsem...@comcast.netwrote:

 You can also search for a cheatsheet. There are several out there
 searching on cheatsheet r

 This one at Oregon State is presented as a web page

 http://www.science.oregonstate.edu/~shenr/Rhelp/00cheat.htmhttp://www.science.oregonstate.edu/%7Eshenr/Rhelp/00cheat.htm

 Others are available as pdf's.



 On Jan 4, 2011, at 7:13 AM, Sébastien Bihorel wrote:

  Dear R-users,

 Is there a easy way to access to a complete listing of available functions
 from a R session? The help.start() and ? functions are great, but I feel
 like they require the user to know the answer in advance (especially with
 respect to function names)... I could not find a easy way to simply browse
 through a list of functions and randomly pick one function to see what is
 does.

 Is there such a possibility in R?

 Thanks

 PS: I apologize if this question appears trivial.

[[alternative HTML version deleted]]

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


 David Winsemius, MD
 West Hartford, CT



[[alternative HTML version deleted]]

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


Re: [R] Page eject and clearing the console

2011-01-04 Thread Greg Snow
Well the things most like cat('\n') for starting a new page would be 
cat('\013') or cat('\014') (vertical tab and form feed), however on all the 
terminals I tried they don't do anything since page is not a concept on a 
terminal.  However if you outputted one of those into a file and interpreted 
the file in a context with pages, then they may do what you want.

The next closest idea to what you are saying that I can find is the wdPageBreak 
function in the R2wd package.  This will insert a page break into a word 
document that is being created from R, there pages make sense and this will 
start the next part on a new page.

To be any more help we need to know what context you are using this in and what 
you mean by page.  Are you preparing stuff to be printed on paper (or at 
least to a pdf doc where pages make sense?) or is there some behavior in the 
terminal that you want to see?  For the last we need to know OS and possibly 
how you are running R within that OS (gui vs. terminal, etc.).

-- 
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 John Sorkin
 Sent: Tuesday, January 04, 2011 12:52 PM
 To: David Winsemius; Bert Gunter
 Cc: r-help@r-project.org
 Subject: Re: [R] Page eject and clearing the console
 
 I am looking for something which will emulate the following:
 Back in the old days, when printing to a line printer, the first two
 characters in a line controlled printing. For example, a line starting
 with
 1h1 starts printing at the top of the next page.
 1h+ indicates overprinting
 1h0 results in double
 In R \n skips to the next line. Is there some escape sequence that
 will start printing at the top of the next page?
 Thanks,
 John
 
 
 
 
 
 John David Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 Bert Gunter gunter.ber...@gene.com 1/4/2011 2:05 PM 
 Perhaps merely rephrasing David's comments,
 
 page is not a meaningful physical entity -- it depends on font size,
 line spacing, etc. and the physical size of the output surface,
 which has no meaning for an infinitely (or at least up to tyhe
 screen buffer's limit) scrollable screen viewing area.
 
 But maybe David's scroll function is what you had in mind.
 
 -- Bert
 
 On Tue, Jan 4, 2011 at 10:55 AM, David Winsemius
 dwinsem...@comcast.net wrote:
 
  On Jan 4, 2011, at 1:27 PM, David Winsemius wrote:
 
 
  On Jan 4, 2011, at 1:19 PM, John Sorkin wrote:
 
  I have received help on one of my questions (thank you Henrique
 Jorge
  and ), viz. how I can clear the console from an R program.
  I have not yet received help on how I can skip to the top of the
 next
  page, i.e. cat(\n) skips to the next line, is there an equivalent
 way
  to skip to the top of the next page?
 
  \n does NOT skip to the next line. It is a character and it is
  interpreted by some sort of program, say a a plotting program or a
  word-processor as a line feed. You need to specify what sort of
 program you
  intend to do this skipping-to-next-page action and also provide
 the
  character sequence that that program uses to signal that action.
 (There are
  not any pages in R except perhaps multi-page plots but you seem to
 be in
  character mode at the moment.)
 
 
  It has occurred to me that you may be asking for something that will
 give
  the illusion of clearing the screen but will in fact be just
 printing a
  page of blank space on a console display, scrolling would ahve been
 the name
  I would have given it. In which case:
 
  scroll - function(lines=40) cat(rep(\n, lines))
  scroll()
 
  --
  David.
 
 
  Thanks,
  John
 
 
 
 
  John David Sorkin M.D., Ph.D.
  Chief, Biostatistics and Informatics
  University of Maryland School of Medicine Division of Gerontology
  Baltimore VA Medical Center
  10 North Greene Street
  GRECC (BT/18/GR)
  Baltimore, MD 21201-1524
  (Phone) 410-605-7119
  (Fax) 410-605-7913 (Please call phone number above prior to
 faxing)
  Henrique Dallazuanna www...@gmail.com 1/4/2011 11:58 AM 
  Take a look on:
  http://tolstoy.newcastle.edu.au/R/e11/help/10/09/8463.html
 
  On Tue, Jan 4, 2011 at 2:54 PM, John Sorkin
  jsor...@grecc.umaryland.eduwrote:
 
  (1) I know that \n when used in cat, e.g. cat(\n) produces a
 line
 
  feed
 
  (i.e. skips to the next line). Is there any escape sequence that
 will
 
  go to
 
  the top of the next page?
  (2) I know that control L will clear the console. Is there an
 
  equivalent
 
  function or other means that can be used in R code to clear the
 
  console?
 
  Thanks,
  John
 
 
  John David Sorkin M.D., Ph.D.
  Chief, Biostatistics and Informatics
  

Re: [R] R command execution from shell

2011-01-04 Thread Duncan Murdoch

On 04/01/2011 3:21 PM, Sebastien Bihorel wrote:

Dear R-users,

Is there a way I can ask R to execute the write(hello
world,file=hello.txt) command directly from the UNIX shell, instead
of having to save this command to a .R file and execute this file with R
CMD BATCH?


Yes.  Some versions of R support the -e option on the command line to 
execute a particular command.  It's not always easy to work out the 
escapes so your shell passes all the quotes through...  An alternative 
is to echo the command into the shell, e.g.


echo 'cat(hello)' | R --slave

(where the outer ' ' are just for bash).

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] Resampling to find Confidence intervals

2011-01-04 Thread Ben Ward
You mentioned the boot package, I've just stumbled across a package 
called simpleboot, with a function lm.boot. Would this be suitable - it 
says I can sample cases from the origional dataset, as well as from the 
residuals of a model. Not all the options I understand but I assume the 
defaults might be suitable for what I'm doing?


On 04/01/2011 17:56, Ben Ward wrote:

Ok I'll check I understand:
So it's using sample, to resample d once, 10 values, because the rnorm 
has 10 values, with replacement (I assume thats the TRUE part).
Then a for loop has this to resample the data - in the loop's case its 
1000 times. Then it does a lm to get the coefficients and add them to 
d1.coef. I'm guessing that the allboot bit with rbind, which is null 
at the start of the loop, is the collection of d1.coef values, as I 
think that without it, every cycle of the loop the d1.coef from the 
previous cycle round the loop would be gone?


On 04/01/2011 16:24, Dieter Menne wrote:

Axolotl9250 wrote:


...
resampled_ecoli = sample(ecoli, 500, replace=T)
coefs = (coef(lm(MIC. ~ 1 + Challenge + Cleaner + Replicate,
data=resampled_ecoli)))
sd(coefs)

...


Below a simplified and self-consistent version of your code, and some
changes

Dieter

# resample
d = data.frame(x=rnorm(10))
d$y = d$x*3+rnorm(10,0.01)

# if you do this, you only get ONE bootstrap sample
d1 = d[sample(1:nrow(d),10,TRUE),]
d1.coef = coef(lm(y~x,data=d1))
d1.coef
# No error below, because you compute the sd of (Intercept) and slope
# but result is wrong!
sd(d1.coef)

# We have to do this over and over
# Check ?replicate for a more R-ish approach
nsamples = 1000
allboot = NULL
for (i in 1:1000) {
   d1 = d[sample(1:nrow(d),10,TRUE),]
   d1.coef = coef(lm(y~x,data=d1))
   allboot = rbind(allboot,d1.coef) # Not very efficient, preallocate!
}
head(allboot) # display first of nsamples lines
apply(allboot,2,mean) # Compute mean
apply(allboot,2,sd) # compute sd
# After you are sure you understood the above, you might try package 
boot.








__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] error in calling source(): invalid multibyte character in parser

2011-01-04 Thread Luca Meyer
It works fine, thanks. 
I was just wondering is there is anyway to include automatically the command 
you suggest as a default when I open R.
Thanks,
Luca

Il giorno 03/gen/2011, alle ore 08.36, Phil Spector ha scritto:

 Luca -
   What happens why you type
 
 Sys.setlocale('LC_ALL','C')
 
   before issuing the source command?
 
   - Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
 
 
 On Mon, 3 Jan 2011, Luca Meyer wrote:
 
 Being italians when writing comments/instructions we use accented letters - 
 like à, ò, è, etc when running R scripts using such characters I get and 
 error saying:
 
 invalid multibyte character in parser
 
 I have been looking at the help and searched the r-help archives but I 
 haven't find anything that I could intelligibly apply to my case.
 
 Can anyone suggest a fix for this error?
 
 Thanks,
 Luca
 
 Mr. Luca Meyer
 www.lucameyer.com
 IBM SPSS Statistics release 19.0.0
 R version 2.12.1 (2010-12-16)
 Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


Re: [R] R command execution from shell

2011-01-04 Thread Sebastien Bihorel

Thank you

That is exactly what I was looking for.

Sebastien

Duncan Murdoch wrote:

On 04/01/2011 3:21 PM, Sebastien Bihorel wrote:

Dear R-users,

Is there a way I can ask R to execute the write(hello
world,file=hello.txt) command directly from the UNIX shell, instead
of having to save this command to a .R file and execute this file with R
CMD BATCH?


Yes.  Some versions of R support the -e option on the command line to 
execute a particular command.  It's not always easy to work out the 
escapes so your shell passes all the quotes through...  An alternative 
is to echo the command into the shell, e.g.


echo 'cat(hello)' | R --slave

(where the outer ' ' are just for bash).

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] error in calling source(): invalid multibyte character in parser

2011-01-04 Thread Prof Brian Ripley

On Tue, 4 Jan 2011, Luca Meyer wrote:


How would I go by doing that? I have tried with:

source(file.R, encoding=it_IT.UTF-8)

But I get

Error in file(file, r, encoding = encoding) :
 unsupported conversion from 'it_IT.UTF-8' to ''


Well, that is not the value I suggested -- so what not simply follow 
what you were asked to try?




Thanks,
Luca

PS:  it_IT.UTF-8 is what I get under locale when I run sessionInfo()

Il giorno 03/gen/2011, alle ore 09.48, Prof Brian Ripley ha scritto:


On Mon, 3 Jan 2011, peter dalgaard wrote:



On Jan 3, 2011, at 08:32 , Luca Meyer wrote:


Being italians when writing comments/instructions we use accented letters - 
like à, ò, è, etc when running R scripts using such characters I get and 
error saying:

invalid multibyte character in parser

I have been looking at the help and searched the r-help archives but I haven't 
find anything that I could intelligibly apply to my case.

Can anyone suggest a fix for this error?


The most likely cause is that your scripts are written in an 8 bit ASCII 
encoding (Latin-1 or -9, most likely), while R is running in a UTF8 locale. If that is 
the cause, the fix is to standardize things to use the same locale. You can convert the 
encoding of your source file using the iconv utility (in a Terminal window).


Or use the 'encoding' argument of source() to tell R what the 
encoding is, e.g. encoding=latin1 or latin-9 (the inconsistency 
being in the iconv used on Macs, not in R).




-pd



Thanks,
Luca

Mr. Luca Meyer
www.lucameyer.com
IBM SPSS Statistics release 19.0.0
R version 2.12.1 (2010-12-16)
Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0

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


--
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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



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





--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R command execution from shell

2011-01-04 Thread Prof Brian Ripley

On Tue, 4 Jan 2011, Duncan Murdoch wrote:


On 04/01/2011 3:21 PM, Sebastien Bihorel wrote:

Dear R-users,

Is there a way I can ask R to execute the write(hello
world,file=hello.txt) command directly from the UNIX shell, instead
of having to save this command to a .R file and execute this file with R
CMD BATCH?


Yes.  Some versions of R support the -e option on the command line to execute 
a particular command.  It's not always easy to work out the escapes so your 
shell passes all the quotes through...  An alternative is to echo the command 
into the shell, e.g.


echo 'cat(hello)' | R --slave

(where the outer ' ' are just for bash).


It is marginally preferable to use Rscript in place of 'R --slave'.
I think in all known shells

Rscript -e write('hello world', file = 'hello.txt')

will work.  (If not, shQuote() will not work for that shell, but this 
does work in sh+clones, csh+clones, zsh and Windows' cmd.exe.)


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

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


[R] [R-pkgs] ENmisc_1.0

2011-01-04 Thread Erich Neuwirth
ENmisc contains two utility function

mtapply is a hybrid of mapply and tapply. It evaluates summary function
for each cell of data defined by a fixed set of factor values.
The reason I wrote it was to be able to compute weighted means
(using wtd.mean from Hmisc) to groups of data defined by factors,
but it accepts any multivariate function as the function argument

wtd.boxplot does what the name makes you expect, it computes and draws
boxplots for weighted data. It behaves like boxplot, but accepts an
additional argument, weights.

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

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


[R] [R-pkgs] Package animation update (v2.0-0)

2011-01-04 Thread Yihui Xie
Hi,

The animation package 2.0-0 is on CRAN now. This version is a
milestone of the animation package. It includes a new function
saveHTML() which uses a much more elegant interface and is consistent
in syntax with other save*() functions such as saveMovie(), saveSWF()
and saveLatex(). Lots of demos have been added to demonstrate the
flexibility of this package, e.g. now we can get the snapshots of rgl
3D plots and insert them into LaTeX with a single call to saveLatex(),
or even into Sweave documents.

There are some funny demos in this version too, e.g. demo('fireworks')
to set fireworks, or demo('CLEvsLAL') which is a replay of an NBA
game between Cavaliers and Lakers on 2009.

Have fun!


                 CHANGES IN animation VERSION 2.0-0


NEW FEATURES

   o a new demo 'Xmas2': Merry Christmas with snowflakes (see
 demo('Xmas2', 'animation'); thanks, Jing Jiao)

   o a new function saveHTML() to insert animations into HTML pages
 (this was designed to replace the old ani.start() and ani.stop();
 the output is much more appealing; the JavaScript is based on the
 SciAnimator library and jQuery)

   o ani.options() gained a new option 'autoplay' to indicate whether
 to autoplay the animation in the HTML page created by saveHTML()

   o in fact ani.options() was rewritten, but this should not have
 any influence on users; the usage is the same

   o ani.options() gained a new option 'use.dev' to decide whether to
 use the graphics device provided in ani.options('ani.dev') when
 calling saveHTML(), saveLatex(), saveMovie() and saveSWF()

   o ani.options() has a couple of hidden options ('convert',
 'swftools', 'img.fmt') which can be useful too; see ?ani.options for
 details

   o a new function ani.pause(): it is a wrapper to
 Sys.sleep(interval) but it will not pause when called in a
 non-interactive graphics device (usually the off-screen devices);
 this is the recommended way to specify the pause in the animation
 now -- all the functions in this package have been adjusted to use
 ani.pause()

   o a new demo('pollen') to show the hidden 'structure' in a large
 data (requires the rgl package)

   o a new demo('CLEvsLAL') to `replay' the NBA game between CLE and
 LAL on 2009 Christmas (with a new dataset 'CLELAL09')

   o a new demo('fireworks') to set fireworks using R (thanks,
 Weicheng Zhu)

   o saveLatex() can work with the rgl package to produce 3D animations
 in a PDF document now; see demo('rgl_animation')

   o a new demo('rgl_animation') to demonstrate how to insert rgl 3D
 animations into a LaTeX document and compile to PDF

   o a new demo('use_Cairo') to show how to use the Cairo device in
 this package to obtain high-quality output

   o a new demo('Sweave_animation') to show how to insert animations
 into Sweave documents

   o a new demo('game_of_life') to demonstrate the (amusing) Game of
 Life (thanks, Linlin Yan)


SIGNIFICANT CHANGES

   o the documentation of this package has been tremendously revised;
 hopefully it is more clear to read now

   o several arguments in saveMovie(), im.convert(), saveSWF() and
 saveLatex() were removed, because they can be specified by
 ani.options(); this can simplify the usage of these functions


MINOR CHANGES

   o the argument 'para' in saveMovie() was removed; the argument
 'ani.first' was also removed from all the save*() functions, because
 this can be written in 'expr' and there is no need to provide an
 additional argument

   o the path of the output in im.convert() and gm.convert() will be
 quoted, because sometimes users might supply a path containing
 spaces (thanks, Phalkun Chheng)

   o the option 'filename' in ani.options() was renamed to 'htmlfile'
 so that the meaning of this option is more clear; 'footer' was
 renamed to 'verbose' too

   o ani.options() can accept any arguments now

   o im.convert() and gm.convert() will no longer stop() when the
 convert utility cannot be found; instead, they only issue warnings;
 a hidden option ani.options('convert') can be used to specify the
 location of convert.exe in ImageMagick

   o saveMovie(), saveHTML(), saveSWF() and saveLatex() will try to
 open the output if ani.options('autobrowse') is TRUE; and they will
 keep the current working directory untouched when evaluating 'expr'
 (i.e.  'expr' will be evaluated under getwd())


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

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] randomForest speed improvements

2011-01-04 Thread apresley

Andy,

Thanks for the reply.  I had no idea I could combine them back ... that
actually will work pretty well.  We can have several worker threads load
up the RF's on different machines and/or cores, and then re-assemble them. 
RMPI might be an option down the road, but would be a bit of overhead for us
now.

Using the method of combine() ... I was able to drastically reduce the
amount of time to build randomForest objects.  IE, using about 25,000 rows
(6 columns), it takes maybe 5 minutes on my laptop.  Using 5 randomForest
objects (each with 5k rows), and then combining them, takes  1 minute.

--
Anthony
-- 
View this message in context: 
http://r.789695.n4.nabble.com/randomForest-speed-improvements-tp3172523p3174621.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 keep keep matching column in output of merge

2011-01-04 Thread Nevil Amos

Apologies,  it is there!

On 5/01/2011 1:26 AM, Sarah Goslee wrote:

Hi Nevil,

We really need an example here of what you're doing, since
merge() does keep the id column by default.



x- data.frame(id = c(a, b, c, NA), x=c(1,2,3,4))
y- data.frame(id1 = c(NA, a, d, c), y=c(101, 102, 103, 104))
merge(x, y)

   id x   y
1  a 1 102
2  b 2 101
3  c 3 104
4  d 4 103

Sarah

On Tue, Jan 4, 2011 at 8:31 AM, Nevil Amosnevil.a...@gmail.com  wrote:

How do I keep the linking column[s] in a merge()?
  I need to use the values again in a further merge.

thanks

Nevil Amos



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