Re: [R] (no subject)

2009-07-30 Thread Stein, Luba (AIM SE)
The error message is: "Error in library(lattice) : there is no package called 
'lattice'"
 
I have installed it twice because it did not work the first time, so I was not 
sure if the installation worked out.
The strange thing is that the folder lattice is in the folder library. 

Luba


> library(lattice)
>

It loads just fine.

On Thu, Jul 30, 2009 at 11:08 AM, Stein, Luba (AIM
SE) wrote:
> I try to load the package lattice by library(lattice).
>
> Although I have installed it through CRAN by internet as well as from a local 
> directory using the zip-file, it can't be loaded into the editor.
>
> Can anyone give advice, please.
>
> I am using R 2.9.1 on Widows XP.
>
> Thanks a lot,
>
> Luba
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] package lattice can't be loeaded

2009-07-30 Thread Stein, Luba (AIM SE)
The error message is: "Error in library(lattice) : there is no package called 
'lattice'"

I have installed it twice because it did not work the first time, so I was not 
sure if it worked.
And YES, the folder lattice is in the folder library.

What's the error message? Why do you have to install twice? Did you check if 
the package is actually in the R library folder?

On Thu, Jul 30, 2009 at 10:02 AM, Stein, Luba (AIM SE) 
mailto:luba.st...@allianz.com>> wrote:
I try to load the package lattice by library(lattice).
Although I have installed it through CRAN by internet as well as from a local 
directory using the zip-file, it can't be loaded into the editor.

Can anyone give advice, please.
I am using R 2.9.1 on Widows XP.

Thanks a lot,
Luba





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



--
Jun Shen PhD
PK/PD Scientist
BioPharma Services
Millipore Corporation
15 Research Park Dr.
St Charles, MO 63304
Direct: 636-720-1589


[[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] adjusting grid on Xaxis ticks

2009-07-30 Thread wapita wapita

Thank you j, its perfect!!
Wapita

> Date: Fri, 24 Jul 2009 06:41:16 -0400
> Subject: Re: [R] adjusting grid on Xaxis ticks
> From: jholt...@gmail.com
> To: wap...@hotmail.com
> CC: r-help-boun...@r-project.org; r-help@r-project.org
> 
> is this what you want:
> 
> plot(0, xlim=as.POSIXct(c('2009-01-01', '2009-12-31')), xaxt='n')
> x <- seq(as.POSIXct('2009-01-01'), as.POSIXct('2009-12-13'), by='1 month')
> axis(1, at=x, labels=format(x, "%b"))
> abline(v=x, lty=2)
> 
> 
> On Thu, Jul 23, 2009 at 11:37 PM, wapita wapita wrote:
> >
> > Hello,
> > I have been trying to plot correctly a graph for 2 month now, with no 
> > success.I want to put a grid, adjusted on the X axis tickers.
> > Here is the way I build my X-Axis and my grid:
> >
> >
> > grid(11, NULL, col="grey40")
> > axis(2)
> >
> > # build the tickers on the beginning of each monthticks.at <- 
> > seq(ISOdatetime(lastYear, 01, 01, hour=0, min=0, sec=0, tz="GMT"), 
> > ISOdatetime(lastYear, 12, 31, hour=0, min=0, sec=0, tz="GMT"), by = 
> > "months")
> > ticks.lab <- format(ticks.at, format = "%b")
> > Axis(ISOdatetime(lastYear, substr(index(xts1),6,7), 
> > substr(index(xts1),9,10), hour=0, min=0, sec=0, tz="GMT"), at = ticks.at, 
> > side = 1, labels = ticks.lab, las = 2)
> > box()
> >
> >
> > If anyone can help me, I would be very grateful.
> > Xavier
> > _
> >
> > [[elided Hotmail spam]]
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
> 
> What is the problem that you are trying to solve?

_

[[elided Hotmail spam]]

[[alternative HTML version deleted]]

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


Re: [R] how use the subset?

2009-07-30 Thread Steve Lianoglou

Hi,

On Jul 31, 2009, at 12:02 AM, Jie TANG wrote:


hi ,everyone

I  want subtract some dataset by subset.

From the help running  help(subset),  ths information is  
"*subset(airquality,

Day == 1, select = -Temp)* "



while  I running my script written as "*g1data<-subset(errdata,  
fac>12) *"

,it is wrong with the error information "*subset.default(newerrdata,
fac>12),can not find fac*"


and g1 in read from the file as shown below
*errdata<-scan("err.dat",what = list(mon=0,day=0,err=0,fac=0))*

While I changed to *g1data<-subset(errdata, errdata$fac>12)*, there  
is no

error message any more  but it seems that *g1data* dooes be selected.

who can help me to subset the dataset?


As per the posting guide, please post a small/simple example of a  
data.frame you are trying to subset and show us the queries you are  
using and what you expect to get out of it.


We'll show you where you're going wrong ;-)

-steve

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

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


Re: [R] Forecasting - Croston Method Error

2009-07-30 Thread Rob Hyndman
Pedro Souto  gmail.com> writes:
> 
> Hi,
> I tried to use the Croston function from the forecasting package
> 1.24 with
> the code below, but I get in return this message "*Error in
> decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) :  time
> series has no or less than 2 periods*".
> 
> histValues <-ts(c(5,5,0,0,3,0,1,3,0,3,0,2,7,3,2,2,3,2,3,2,2,3,1,1,3,
>0,1,0,2,1,0,4,1,1,3,0,1),f=12,s=c(1998,1))
> forecastValues <- croston(histValues, h=4, alpha=0.1)
> 
> Does anyone know the causes and how to fix this problem?
> 
> Thanks,
> Pedro Souto

This bug was in a beta version of forecast v1.24 on my website. 
The bug was corrected in v1.24 of the package uploaded to CRAN last April.

Rob Hyndman

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

2009-07-30 Thread Jie TANG
hi ,everyone

I  want subtract some dataset by subset.

>From the help running  help(subset),  ths information is "*subset(airquality,
Day == 1, select = -Temp)* "



while  I running my script written as "*g1data<-subset(errdata, fac>12) *"
,it is wrong with the error information "*subset.default(newerrdata,
fac>12),can not find fac*"


and g1 in read from the file as shown below
*errdata<-scan("err.dat",what = list(mon=0,day=0,err=0,fac=0))*

While I changed to *g1data<-subset(errdata, errdata$fac>12)*, there is no
error message any more  but it seems that *g1data* dooes be selected.

who can help me to subset the dataset?

thank you .:)

-- 
TANG Jie
Email: totang...@gmail.com
Tel: 0086-2154896104
Shanghai Typhoon Institute,China

[[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] write matrix M including names(dimnames(M))

2009-07-30 Thread Steve Jaffe

I can do this by writing (and reading) the file according to some format of
my own devising, but I'm wondering if there is a built-in way to write and
then restore a matrix with not only the dimnames (which
write.table/read.table can preserve) but also the names(dimnames)?

Example:
> M <- matrix(1:4, 2, 2)
> dimnames(M) <- list(xdim=c("a", "b"), ydim=c("u", "v"))
> M
ydim
xdim u v
   a 1 3
   b 2 4


-- 
View this message in context: 
http://www.nabble.com/write-matrix-M-including-names%28dimnames%28M%29%29-tp24750637p24750637.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] truncating values into separate categories

2009-07-30 Thread Bill.Venables
Here is a suggestion:

> Per <- c("NA", "1", "2", "3","4")
> NP <- c(1,  1,  2,  1, 1,  2,  2,  1,  4,  1,  0,  5,  
+ 3,  3,  1,  5,  3, 5, 1, 6, 1, 2, 2, 2,
+ 4, 4, 1, 2, 1, 3, 3, 1,  2,  2,  1,  2, 1, 2,
+ 2, 3, 1, 1, 4, 4, 1, 1, 1, 2, 2, 2)
> Person_CAT <- cut(NP, breaks = c(0:4, Inf)-0.5, labels = Per)
> table(Person_CAT)
Person_CAT
NA  1  2  3  4 
 1 19 15  6  9 
>  

You should be aware, though, that items corresponding to the level "NA" will 
NOT be treated as missing.


Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of PDXRugger
Sent: Friday, 31 July 2009 9:54 AM
To: r-help@r-project.org
Subject: [R] truncating values into separate categories


Hi all, 
  Simple question which i thought i had the answer but it isnt so simple for
some reason.  I am sure someone can easily help.  I would like to categorize
the values in NP into 1 of the five values in "Per", with the last
category("4") representing values >=4(hence 4:max(NP)).  The problem is that
R is reading max(NP) as multiple values instead of range so the lengths of
the labels and the breaks are not matching.  Suggestions?

Per <- c("NA", "1", "2", "3","4")

NP=c(1 ,1 ,2 ,1, 1 ,2 ,2 ,1 ,4 ,1 ,0 ,5 ,3 ,3 ,1 ,5 ,3, 5, 1, 6, 1, 2, 2, 2,
4, 4, 1, 2, 1, 3, 3, 1 ,2 ,2 ,1 ,2, 1, 2,
2, 3, 1, 1, 4, 4, 1, 1, 1, 2, 2, 2)

Person_CAT <- cut(NP, breaks=c(0,1,2,3,4:max(NP)), labels=Per)

-- 
View this message in context: 
http://www.nabble.com/truncating-values-into-separate-categories-tp24749046p24749046.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] concatenating multiple columns from files

2009-07-30 Thread Bill.Venables
Here is a suggestion:

rawdata <- list.files("./data")
mat <- list()

for(i in rawdata) 
mat[[i]] <- read.table(file.path("./data", i))

mat <- data.frame(mat)

  


Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of ferreirafm
Sent: Friday, 31 July 2009 8:46 AM
To: r-help@r-project.org
Subject: [R] concatenating multiple columns from files


R-users,
I want to concatenate columns from different files in a  single object. 
I'm doing bad. My peace of code is as follow:

rawdata <- list.files("./data")

for (i in rawdata) {
  mat <- read.table(paste(i ,sep=""))
}

At the end of the loop I have just one column. What I'm doing wrong?
Thanks,


-- 
View this message in context: 
http://www.nabble.com/concatenating-multiple-columns-from-files-tp24748542p24748542.html
Sent from the R help mailing list archive at Nabble.com.

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

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


[R] truncating values into separate categories

2009-07-30 Thread PDXRugger

Hi all, 
  Simple question which i thought i had the answer but it isnt so simple for
some reason.  I am sure someone can easily help.  I would like to categorize
the values in NP into 1 of the five values in "Per", with the last
category("4") representing values >=4(hence 4:max(NP)).  The problem is that
R is reading max(NP) as multiple values instead of range so the lengths of
the labels and the breaks are not matching.  Suggestions?

Per <- c("NA", "1", "2", "3","4")

NP=c(1 ,1 ,2 ,1, 1 ,2 ,2 ,1 ,4 ,1 ,0 ,5 ,3 ,3 ,1 ,5 ,3, 5, 1, 6, 1, 2, 2, 2,
4, 4, 1, 2, 1, 3, 3, 1 ,2 ,2 ,1 ,2, 1, 2,
2, 3, 1, 1, 4, 4, 1, 1, 1, 2, 2, 2)

Person_CAT <- cut(NP, breaks=c(0,1,2,3,4:max(NP)), labels=Per)

-- 
View this message in context: 
http://www.nabble.com/truncating-values-into-separate-categories-tp24749046p24749046.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] concatenating multiple columns from files

2009-07-30 Thread ferreirafm

R-users,
I want to concatenate columns from different files in a  single object. 
I'm doing bad. My peace of code is as follow:

rawdata <- list.files("./data")

for (i in rawdata) {
  mat <- read.table(paste(i ,sep=""))
}

At the end of the loop I have just one column. What I'm doing wrong?
Thanks,
Fred

-- 
View this message in context: 
http://www.nabble.com/concatenating-multiple-columns-from-files-tp24748542p24748542.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] Logistic regression and R

2009-07-30 Thread G. Jay Kerns
Dear Carlos,

On Thu, Jul 30, 2009 at 6:11 PM, Carlos López wrote:
> Hello everybody :-)
>
> I have some data that I want to model with a logistic regression, most of
> the independent variables are numeric and the only dependent is categorical,
> I was thinking that I could apply a logistic regression using glm but I
> wanted to deepen my knowledge of this so I tried to do some reading and
> found the "iris" dataset, now I would like to ask two things, first if you
> know of any bibliography to read more about the logistic regression and R so
> I could understand and interpret better the output,


See the following

https://home.comcast.net/~lthompson221/

and the following specific link on that page:

https://home.comcast.net/~lthompson221/Splusdiscrete2.pdf

which is a manual to accompany Agresti's _Categorical Data Analysis_.
In particular, you may want to check out Chapter 5 (and also some of
4).


>and second, what could I
> do when I have some independent variables that are not only numerical but
> categorical too, i.e. mixed (categorical and numerical), can I still use a
> logistic regression?

Easy peasy, lemon squeezy.  See page 78.

Hope this helps,
Jay












***
G. Jay Kerns, Ph.D.
Associate Professor
Department of Mathematics & Statistics
Youngstown State University
Youngstown, OH 44555-0002 USA
Office: 1035 Cushwa Hall
Phone: (330) 941-3310 Office (voice mail)
-3302 Department
-3170 FAX
VoIP: gjke...@ekiga.net
E-mail: gke...@ysu.edu
http://www.cc.ysu.edu/~gjkerns/

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


Re: [R] Question regarding sqldf

2009-07-30 Thread Gabor Grothendieck
I just answered essentially the same question from another person offline
within the last day.  Anyways:

"Date" class variables are stored as numbers, i.e. days since
the Epoch, in R and when transferred to sqlite get transferred
as numbers.  Try this:

> library(sqldf)
> DF <- data.frame(a = Sys.Date() + 1:5, b = 1:5)
> DF
  a b
1 2009-07-31 1
2 2009-08-01 2
3 2009-08-02 3
4 2009-08-03 4
5 2009-08-04 5
> Sys.Date() + 2
[1] "2009-08-01"
> s <- sprintf("select * from DF where a >= %d", Sys.Date() + 2)
> s
[1] "select * from DF where a >= 14457"
> sqldf(s)
  a b
1 2009-08-01 2
2 2009-08-02 3
3 2009-08-03 4
4 2009-08-04 5

> # to compare against character string store a as character
> DF2 <- transform(DF, a = as.character(a))
> sqldf("select * from DF2 where a >= '2009-08-01'")
  a b
1 2009-08-01 2
2 2009-08-02 3
3 2009-08-03 4
4 2009-08-04 5

On Thu, Jul 30, 2009 at 1:46 PM,  wrote:
>
> Hello,
>
> I am having a problem using sqldf.  I'm trying to choose a subset of
> observations from a data set based on the date and maximum value of a
> variable by date.
>
> Here is the code I am using:
>
> test<-sqldf("select distinct * from bextuse group by sdate having
> bext=max(bext)",method="raw");
>
> The result I get back is a data frame with 0 rows and 0 columns.  I have
> tried the code in another program that utilizes SQL, and I retrieve the
> 14 rows I was expecting to get.
> I looked at the SQLite information on the web, and it mentions that the
> "having" clause can be used to select observations from grouped data
> using aggregating functions.
>
> Any help or advice is greatly appreciated.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] r and ocx

2009-07-30 Thread Applejus

Hello dear community,

I have written scripts in r that involve 3d plots (rgl library).
I would like to know if there is a possibility of creating an OCX object
that contains my code and plot?
The reason is I need to embed my r script into another application that only
accepts OCX 
This application would feed the OCX with the input ( a string in my case)
and the OCX should output back the final 3d plot . I should be able to
rotate that plot too...

Sounds a bit impossible, but I know nothing is impossible...I hope!

-- 
View this message in context: 
http://www.nabble.com/r-and-ocx-tp24748981p24748981.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] wireframe color

2009-07-30 Thread Marlin Keith Cox
Hello, hopefully simple question, but I cannot find the answer.  I need to
change the color from the standard default.  Still want the scaled colors,
but need different colors for different graphs.

Code is:

wireframe(z ~ y*x, mat.df,
  drape = TRUE,
  zlab = list("Water mass error (%)",rot=92), zlim=c(-50,180),
  xlab = list("Resistance error (%)",rot=16),
  ylab = list("Length error (%)",rot=118),
  scales = list(arrows = FALSE),
 screen = list(z = 20, x = -57, y = 5))


Thanks ahead of time.

-- 
M. Keith Cox, Ph.D.
Alaska NOAA Fisheries, National Marine Fisheries Service
Auke Bay Laboratories
17109 Pt. Lena Loop Rd.
Juneau, AK 99801
keith@noaa.gov
marlink...@gmail.com
U.S. (907) 789-6603

[[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] What is the best method to produce means by categorical factors?

2009-07-30 Thread John Kane

The most common would be aggregate. You can change mean for other functions ( 
e.g. sum or length, median, or one you write yourself)

You probably would find Bob Munechen's book http://rforsasandspssusers.com/ 
very useful and there is a shorter pdf available on that page.

Example: 

dd <- data.frame(factor1= rep(letters[1:10], 2), factor2=rep(LETTERS[1:5],4), 
   var1=rnorm(20, 10,2), var2=rnorm(20, 25,5))

aggregate(dd[,3:4], by=list(dd[,1],dd[,2]), mean)

aggregate(dd[,3:4], by=list(dd[,1],dd[,2]), sum)


--- On Thu, 7/30/09, Pat Schmitz  wrote:

> From: Pat Schmitz 
> Subject: [R] What is the best method to produce means by categorical factors?
> To: r-help@r-project.org
> Received: Thursday, July 30, 2009, 4:19 AM
> I am attempting to replicate some of
> my experience from SAS in R and assume
> there are best methods for using a combination of
> summary(), subset, and
> which() to produce a subset of mean values by categorical
> or ordinal
> factors.
> 
> within sas I would write
> 
> proc means mean data=dataset;
> class factor1 factor2
> var variable1 variable2;
> RUN;
> 
> producing an output with means for each variable by factor
> groupings as
> below:
> 
> *factor1        factor2   
>       obs   
>    variable    mean*
> Level A        treatmentA   
>     3        variable1 
>   10
>                
>                
>           variable2   
> 22
> 
>            
>    treatmentB       
> 3        variable1    12
>                
>                
>           variable2   
> 30
> 
> Level B        treatmentA   
>     3        variable1 
>   10
>                
>                
>           variable2   
> 22
> 
>            
>    treatmentB       
> 3        variable1    12
>                
>                
>           variable2   
> 30
> 
> What is the best way to go about this in R?
> 
> 
> 
> 
> 
> 
> -- 
> Patrick Schmitz
> Graduate Student
> Plant Biology
> 1206 West Gregory Drive
> RM 1500
> 
>     [[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.
> 


  __
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now
http://ca.toolbar.yahoo.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] Testing year effects in lm()

2009-07-30 Thread Achim Zeileis

On Thu, 30 Jul 2009, Mark Na wrote:


Dear R-helpers,

I have a linear model with a year effect (year is coded as a factor), i.e.
the parameter estimates for each level of my year variable have significant
P values (see some output below) and I am interested in testing:

a) the overall effect of year;


Fit the model without the "year" effect and compare both fits with 
anova().



b) the significance of each year vis-a-vis every other year (the model
output only tests each year against the baseline year).


If you want to compare every year with the next year, you can use 
successive difference contrasts for year. These are available as 
contr.sdif() in MASS.


If you want to perform all possible pairwise comparisons, i.e., Tukey 
contrasts, you can use glht() from package "multcomp". See the package 
documentation and vignette for further examples.


hth,
Z


I'd appreciate any help with how to perform these post-hoc tests in R.

Many thanks,

Mark Na




Call:

lm(formula = data$SR.obs ~ log(data$AREA, 10) + data$YEAR,

   subset = (data$AREA >= 14.5))



Residuals:

   Min  1Q  Median  3Q Max

-5.3412 -1.3140  0.1108  1.1972  4.3126



Coefficients:

  Estimate Std. Error t value Pr(>|t|)

(Intercept) -9.4606 0.6144 -15.399  < 2e-16 ***

log(data$AREA, 10)   3.9261 0.1734  22.644  < 2e-16 ***

data$YEAR20081.0750 0.2854   3.767 0.000211 ***

data$YEAR20091.5884 0.3073   5.169 5.18e-07 ***

---

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1



Residual standard error: 1.822 on 226 degrees of freedom

Multiple R-squared: 0.6945, Adjusted R-squared: 0.6905

F-statistic: 171.3 on 3 and 226 DF,  p-value: < 2.2e-16



[1] "AIC=  934.557"

[[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] Looping through R objects with $ operator and tags

2009-07-30 Thread Vivek Ayer
I figured it out. I understand that R isn't really meant to do this.
Essentially, I want to have an object per read csv file which contains
columns. But I'm dealing with hundreds of files in a folder and I
wanted to automate the importing into R and process stuff without
entering the shell and using lists, lapply, and sapply.

I realized there's an more convenient indexing symbol for these kind
of functions, namely "[[ , ]]"

So I did something like this:

for (i in c(1:num)) {
tempobj <- get(paste(id,i,sep=""));
TotLogDist <- c(TotLogDist,tempobj[["LogDist"]])
}

where num is now ~100 or 1000.

Thanks for the tips! I'm still a newbie in R, and hopefully I can
learn to be more efficient next time.

Thanks again,
Vivek

On Thu, Jul 30, 2009 at 3:01 PM, Phil Spector wrote:
> Vivek -
>   In R, you shouldn't be storing related objects in
> individual vectors or data frames, you should put them in
> a list.  Frankly, I don't know what you're trying to
> acheive with the code fragment you sent, so I don't really
> know what to tell you, but it's usually not a good idea in R to have to
> paste together strings to access a variable.
>                                               - Phil
>
>
> On Thu, 30 Jul 2009, Vivek Ayer wrote:
>
>> How I loop object placement into a list?
>>
>> for (i in c(1:10))
>> list(paste("object",i,sep=""))
>> ??
>>
>> Kind of confused. This would be useful for functions like c() as well.
>>
>> Thanks,
>> Vivek
>>
>> btw...I stop by 5th floor Evans every once in a while!
>>
>> On Thu, Jul 30, 2009 at 9:33 AM, Phil Spector
>> wrote:
>>>
>>> Vivek -
>>>   First, put your objects in a list where they belong:
>>>
>>> myobjects = list(object1,object2,object3)
>>>
>>> Now you can use the power of R to do your work:
>>>
>>> myobjects = lapply(myobjects,transform,logDist = log10(Distance))
>>>
>>>                                       - Phil Spector
>>>                                         Statistical Computing Facility
>>>                                         Department of Statistics
>>>                                         UC Berkeley
>>>                                         spec...@stat.berkeley.edu
>>>
>>> P.S. -  If you really want to do things with loops, get, assign, etc.
>>> you could do something like this:
>>>
>>> for(i in 1:10){
>>>    objname = paste('object',i,sep='')
>>>    now = get(objname)
>>>    assign(objname,transform(now,logDist = log10(distance)))
>>> }
>>>
>>> But please try to remember that R provides lists and functions like
>>> lapply and sapply for a reason.
>>>
>>> On Thu, 30 Jul 2009, Vivek Ayer wrote:
>>>
 Hi all,

 Suppose I want to set the values in a column to the log of the values
 of another column like so:

 object$LogDist <- log10(object$Distance)

 How do I loop through the objects if I have object1, object2, etc to
 perform this function?

 object1$LogDist <- log10(object1$Distance)
 object2$LogDist <- log10(object2$Distance)
 object3$LogDist <- log10(object3$Distance)

 I was trying to use the assign and paste functions like so:

 for (i in c(1:10))


 assign(paste("object",i,"$LogDist"),log10(as.name(paste("object",i,"$LogDist")))

 but that didn't work out. It creates objects with whole name
 object1$LogDist instead of just manipulating the column that's part of
 that object.

 Help appreciated,
 Vivek

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 change the thickness of the lines of the boxplot outliers

2009-07-30 Thread Paul Murrell

Hi


Waverley wrote:

Thanks Paul.

I reproduced my problem using the example of the ?boxplot which is
also at 
http://stat.ethz.ch/R-manual/R-patched/library/graphics/html/boxplot.html

The sample code is as following:
boxplot(count ~ spray, data = InsectSprays, col = "lightgray", lwd=40)

lwd = 40 is kind of exaggerating but does show the case: the circles
of outliers maintain the original length while the box becomes a black
bulb.

BTW: I am using linux redhat ES3.0 64 bit. R is 2.9.0 version.



Thanks for the code.  I can confirm that this problem has been fixed in 
the development version of R.


Paul



Thanks.




Hi




Waverley wrote:
Hi,

I tried to use boxplot function. I am following the ?boxplot and can
change the whisker box width using lwd parameter.  However, when
outline=TRUE, the thickness of the circle of the outliers is not
proportionally changed when I change the line width of the whisker
box.  There must be another parameter for that.  Unfortunately I don't
know.



This sounds like a problem that was recently fixed in the development
version.  It would be useful if you could send me (directly if you
like) a sample of code that produces the problem.

Paul



please help and thanks much in advance.

--
Waverley @ Palo Alto

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


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/


--
Waverley @ Palo Alto


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

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


[R] Testing year effect in lm() ***failed first time, sending again

2009-07-30 Thread Mark Na
Dear R-helpers,

I have a linear model with a year effect (year is coded as a factor), i.e.
the parameter estimates for each level of my year variable have significant
P values (see some output below) and I am interested in testing:

a) the overall effect of year;
b) the significance of each year vis-a-vis every other year (the model
output only tests each year against the baseline year).

I'd appreciate any help with how to perform these post-hoc tests in R.

Many thanks,

Mark Na



Call:

lm(formula = data$SR.obs ~ log(data$AREA, 10) + data$YEAR,

subset = (data$AREA >= 14.5))



Residuals:

Min  1Q  Median  3Q Max

-5.3412 -1.3140  0.1108  1.1972  4.3126



Coefficients:

   Estimate Std. Error t value Pr(>|t|)

(Intercept) -9.4606 0.6144 -15.399  < 2e-16 ***

log(data$AREA, 10)   3.9261 0.1734  22.644  < 2e-16 ***

data$YEAR20081.0750 0.2854   3.767 0.000211 ***

data$YEAR20091.5884 0.3073   5.169 5.18e-07 ***

---

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1



Residual standard error: 1.822 on 226 degrees of freedom

Multiple R-squared: 0.6945, Adjusted R-squared: 0.6905

F-statistic: 171.3 on 3 and 226 DF,  p-value: < 2.2e-16



[1] "AIC=  934.557"

[[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] Summarising Data for Forrest Plots

2009-07-30 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)

>Ah, I think I see what you want. Try this on each pair of exclusive sets:


>Then under65row and over65row should be the first two rows of your result.
>Can't test this at the moment, but I don't think it's too far wrong.
>
I knew this shouldn't need so much work ;-)

Not cracked it yet - because as I see it I need a 2 x 4 table and at the moment 
I only cracked a 2 x 2 table.  ( Or really I need something like a 10 x 4 - but 
the 4 is the bit that I haven't cracked)

First option is something like this:
with(mydataset,  table(Sex, Dose))

I can get:
Dose
Sex  FD RD
  F615
  M  1623

For non catagorical data its slightly trickier... but quite achievable in two 
lines (for the 2 x 2 table)

factor(cut(mydatasetl$Age, breaks = c(0,65,100))) -> AgeBands
table (AgeBands, mydataset$Dose)

Which gives:

AgeBands  FD RD
 (0,65]156
 (65,100]1326

Although - I'm not yet sure if I can actually call that data back by column 
names.  ie

x <- table (AgeBands, mydataset$Dose)
x$FD

produces an error. :-(

But getting there.
















This message may contain confidential information. If yo...{{dropped:21}}

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


Re: [R] ask help about boxplot , different list variation into the tick of x-axis?

2009-07-30 Thread John Kane

Replying to my own post, it occurred to me that there is a simple solution 
using the reshape package. Here's an example using some made-up data.
#=
years  <- 1997:2008
set.seed <- 1234
(mydata <- data.frame(matrix(rnorm(60, 25, 5),ncol=5), years))

library(reshape)
newdata  <- (melt(mydata, id=c("years")))
boxplot(value~years, data=newdata)

#==

--- On Thu, 7/30/09, John Kane  wrote:

> From: John Kane 
> Subject: Re: [R] ask help about boxplot , different list variation into the 
> tick of  x-axis?
> To: r-help@r-project.org, "Jie TANG" 
> Received: Thursday, July 30, 2009, 6:18 PM
> 
> You are trying to apply a funtion to a data.frame that is
> intended to work on a vector that is indexed on another
> vector.   
> 
> Try pasting this into R to see what I mean
> 
> boxplot(len ~ dose, data = ToothGrowth)
> ToothGrowth
>  
> 
> --- On Thu, 7/30/09, Jie TANG 
> wrote:
> 
> > From: Jie TANG 
> > Subject: [R] ask help about boxplot , different list
> variation into the tick of  x-axis?
> > To: r-help@r-project.org
> > Received: Thursday, July 30, 2009, 5:54 PM
> >  Hi ,everyone.
> > 
> > I want to draw a boxplot figure, main script shown as
> > below. when I
> > run the command "boxplot(bjavee~yearname)",it is wrong
> with
> > the error
> > information " model.frame.default(formula = bjavee ~
> > yearname) :
> >   variation 'bjavee' list is wrong".
> > 
> > I want to add the yearname as the x-axis tick. And
> yearname
> > is a array
> > with the length 12,while bjavee is a 5*12 matrix. How
> could
> > I get what
> > I want? thanks.
> > 
> > bjerr1<-bjerrdata$tyerr[1:bjyearnum[2]]
> >
> bjerr2<-bjerrdata$tyerr[(bjyearnum[2]+1):bjyearnum[3]]
> >
> bjerr3<-bjerrdata$tyerr[(bjyearnum[3]+1):bjyearnum[4]]
> >
> bjerr4<-bjerrdata$tyerr[(bjyearnum[4]+1):bjyearnum[5]]
> >
> bjerr5<-bjerrdata$tyerr[(bjyearnum[5]+1):bjyearnum[6]]
> >
> bjerr6<-bjerrdata$tyerr[(bjyearnum[6]+1):bjyearnum[7]]
> >
> bjerr7<-bjerrdata$tyerr[(bjyearnum[7]+1):bjyearnum[8]]
> >
> bjerr8<-bjerrdata$tyerr[(bjyearnum[8]+1):bjyearnum[9]]
> >
> bjerr9<-bjerrdata$tyerr[(bjyearnum[9]+1):bjyearnum[10]]
> >
> bjerr10<-bjerrdata$tyerr[(bjyearnum[10]+1):bjyearnum[11]]
> >
> bjerr11<-bjerrdata$tyerr[(bjyearnum[11]+1):bjyearnum[12]]
> >
> bjerr12<-bjerrdata$tyerr[(bjyearnum[12]+1):length(bjerryear)]
> > 
> > bjavee<-data.frame(5,12)
> > cprob=c(0.05,0.25,0.5,0.75,0.95)
> > bjavee[1:5,1]<-quantile(bjerr1,prob=cprob)
> > bjavee[1:5,2]<-quantile(bjerr2,prob=cprob)
> > bjavee[1:5,3]<-quantile(bjerr3,prob=cprob)
> > bjavee[1:5,4]<-quantile(bjerr4,prob=cprob)
> > bjavee[1:5,5]<-quantile(bjerr5,prob=cprob)
> > bjavee[1:5,6]<-quantile(bjerr6,prob=cprob)
> > bjavee[1:5,7]<-quantile(bjerr7,prob=cprob)
> > bjavee[1:5,8]<-quantile(bjerr8,prob=cprob)
> > bjavee[1:5,9]<-quantile(bjerr9,prob=cprob)
> > bjavee[1:5,10]<-quantile(bjerr10,prob=cprob)
> > bjavee[1:5,11]<-quantile(bjerr11,prob=cprob)
> > bjavee[1:5,12]<-quantile(bjerr12,prob=cprob)
> > 
> > 
> > yearname<-(1997:2008)
> > 
> > png(file=".\\png\\jptrkfivenum24.png",
> bg="transparent")
> > 
> >
> bjbox<-data.frame(bjavee[1:5,1],bjavee[1:5,2],bjavee[1:5,3],bjavee[1:5,4],bjavee[1:5,5],bjavee[1:5,6],bjavee[1:5,7],bjavee[1:5,8],bjavee[1:5,9],bjavee[1:5,10],bjavee[1:5,11],bjavee[1:5,12])
> > boxplot(bjavee~yearname)
> > 
> > __
> > R-help@r-project.org
> > mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> > reproducible code.
> > 
> 
> 
>      
> __
> Looking for the perfect gift? Give the gift of Flickr! 
> 
> http://www.flickr.com/gift/
> 
> __
> R-help@r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 


  __
Get the name you've always wanted @ymail.com or @rocketmail.com! Go to 
http://ca.promos.yahoo.com/jacko/

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


[R] Testing year effects in lm()

2009-07-30 Thread Mark Na
Dear R-helpers,

I have a linear model with a year effect (year is coded as a factor), i.e.
the parameter estimates for each level of my year variable have significant
P values (see some output below) and I am interested in testing:

a) the overall effect of year;
b) the significance of each year vis-a-vis every other year (the model
output only tests each year against the baseline year).

I'd appreciate any help with how to perform these post-hoc tests in R.

Many thanks,

Mark Na




Call:

lm(formula = data$SR.obs ~ log(data$AREA, 10) + data$YEAR,

subset = (data$AREA >= 14.5))



Residuals:

Min  1Q  Median  3Q Max

-5.3412 -1.3140  0.1108  1.1972  4.3126



Coefficients:

   Estimate Std. Error t value Pr(>|t|)

(Intercept) -9.4606 0.6144 -15.399  < 2e-16 ***

log(data$AREA, 10)   3.9261 0.1734  22.644  < 2e-16 ***

data$YEAR20081.0750 0.2854   3.767 0.000211 ***

data$YEAR20091.5884 0.3073   5.169 5.18e-07 ***

---

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1



Residual standard error: 1.822 on 226 degrees of freedom

Multiple R-squared: 0.6945, Adjusted R-squared: 0.6905

F-statistic: 171.3 on 3 and 226 DF,  p-value: < 2.2e-16



[1] "AIC=  934.557"

[[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] ask help about boxplot , different list variation into the tick of x-axis?

2009-07-30 Thread John Kane

You are trying to apply a funtion to a data.frame that is intended to work on a 
vector that is indexed on another vector.   

Try pasting this into R to see what I mean

boxplot(len ~ dose, data = ToothGrowth)
ToothGrowth
 

--- On Thu, 7/30/09, Jie TANG  wrote:

> From: Jie TANG 
> Subject: [R] ask help about boxplot , different list variation into the tick 
> of  x-axis?
> To: r-help@r-project.org
> Received: Thursday, July 30, 2009, 5:54 PM
>  Hi ,everyone.
> 
> I want to draw a boxplot figure, main script shown as
> below. when I
> run the command "boxplot(bjavee~yearname)",it is wrong with
> the error
> information " model.frame.default(formula = bjavee ~
> yearname) :
>   variation 'bjavee' list is wrong".
> 
> I want to add the yearname as the x-axis tick. And yearname
> is a array
> with the length 12,while bjavee is a 5*12 matrix. How could
> I get what
> I want? thanks.
> 
> bjerr1<-bjerrdata$tyerr[1:bjyearnum[2]]
> bjerr2<-bjerrdata$tyerr[(bjyearnum[2]+1):bjyearnum[3]]
> bjerr3<-bjerrdata$tyerr[(bjyearnum[3]+1):bjyearnum[4]]
> bjerr4<-bjerrdata$tyerr[(bjyearnum[4]+1):bjyearnum[5]]
> bjerr5<-bjerrdata$tyerr[(bjyearnum[5]+1):bjyearnum[6]]
> bjerr6<-bjerrdata$tyerr[(bjyearnum[6]+1):bjyearnum[7]]
> bjerr7<-bjerrdata$tyerr[(bjyearnum[7]+1):bjyearnum[8]]
> bjerr8<-bjerrdata$tyerr[(bjyearnum[8]+1):bjyearnum[9]]
> bjerr9<-bjerrdata$tyerr[(bjyearnum[9]+1):bjyearnum[10]]
> bjerr10<-bjerrdata$tyerr[(bjyearnum[10]+1):bjyearnum[11]]
> bjerr11<-bjerrdata$tyerr[(bjyearnum[11]+1):bjyearnum[12]]
> bjerr12<-bjerrdata$tyerr[(bjyearnum[12]+1):length(bjerryear)]
> 
> bjavee<-data.frame(5,12)
> cprob=c(0.05,0.25,0.5,0.75,0.95)
> bjavee[1:5,1]<-quantile(bjerr1,prob=cprob)
> bjavee[1:5,2]<-quantile(bjerr2,prob=cprob)
> bjavee[1:5,3]<-quantile(bjerr3,prob=cprob)
> bjavee[1:5,4]<-quantile(bjerr4,prob=cprob)
> bjavee[1:5,5]<-quantile(bjerr5,prob=cprob)
> bjavee[1:5,6]<-quantile(bjerr6,prob=cprob)
> bjavee[1:5,7]<-quantile(bjerr7,prob=cprob)
> bjavee[1:5,8]<-quantile(bjerr8,prob=cprob)
> bjavee[1:5,9]<-quantile(bjerr9,prob=cprob)
> bjavee[1:5,10]<-quantile(bjerr10,prob=cprob)
> bjavee[1:5,11]<-quantile(bjerr11,prob=cprob)
> bjavee[1:5,12]<-quantile(bjerr12,prob=cprob)
> 
> 
> yearname<-(1997:2008)
> 
> png(file=".\\png\\jptrkfivenum24.png", bg="transparent")
> 
> bjbox<-data.frame(bjavee[1:5,1],bjavee[1:5,2],bjavee[1:5,3],bjavee[1:5,4],bjavee[1:5,5],bjavee[1:5,6],bjavee[1:5,7],bjavee[1:5,8],bjavee[1:5,9],bjavee[1:5,10],bjavee[1:5,11],bjavee[1:5,12])
> boxplot(bjavee~yearname)
> 
> __
> R-help@r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 


  __
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 change the thickness of the lines of the boxplot outliers

2009-07-30 Thread Waverley
Thanks Paul.

I reproduced my problem using the example of the ?boxplot which is
also at 
http://stat.ethz.ch/R-manual/R-patched/library/graphics/html/boxplot.html

The sample code is as following:
boxplot(count ~ spray, data = InsectSprays, col = "lightgray", lwd=40)

lwd = 40 is kind of exaggerating but does show the case: the circles
of outliers maintain the original length while the box becomes a black
bulb.

BTW: I am using linux redhat ES3.0 64 bit. R is 2.9.0 version.

Thanks.



>Hi


>Waverley wrote:
> Hi,
>
> I tried to use boxplot function. I am following the ?boxplot and can
> change the whisker box width using lwd parameter.  However, when
> outline=TRUE, the thickness of the circle of the outliers is not
> proportionally changed when I change the line width of the whisker
> box.  There must be another parameter for that.  Unfortunately I don't
> know.


This sounds like a problem that was recently fixed in the development
version.  It would be useful if you could send me (directly if you
like) a sample of code that produces the problem.

Paul


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

--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/


-- 
Waverley @ Palo Alto

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

2009-07-30 Thread Carlos López

Hello everybody :-)

I have some data that I want to model with a logistic regression, most 
of the independent variables are numeric and the only dependent is 
categorical, I was thinking that I could apply a logistic regression 
using glm but I wanted to deepen my knowledge of this so I tried to do 
some reading and found the "iris" dataset, now I would like to ask two 
things, first if you know of any bibliography to read more about the 
logistic regression and R so I could understand and interpret better the 
output, and second, what could I do when I have some independent 
variables that are not only numerical but categorical too, i.e. mixed 
(categorical and numerical), can I still use a logistic regression?


Thank you very much!!! :-D

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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

2009-07-30 Thread jimdare

Dear R Users,

I have a dataset that I have split by group.  For each group I plot a figure
using:

for (i in splitdf){
plot<-xyplot()
print(plot)
savePlot(filename=paste(i$Group[1]),type="pdf")
}

This gives me X pdf files where X is the number of groups.
Does anyone know a simple way to get the name of the plot [plot<-xyplot()]
to differ for each rin of the loop so I can merge them into a single pdf
files using.

pdf(filename="mergedplots")
plot1

plotX
dev.off()

Thanks in advance,
James



-- 
View this message in context: 
http://www.nabble.com/Defining-different-objects-within-a-loop-tp24748164p24748164.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] Question regarding sqldf

2009-07-30 Thread milton ruser
How about update R/sqldf?

> require(sqlf)
Loading required package: sqlf
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return
= TRUE,  :
  there is no package called 'sqlf'
>
> testframe<-data.frame(sdate=rep(paste
+ ("day",1:5,sep=""),each=5),bext=runif(25,1,100),otherstuff=runif
+ (25,45,60),stuff=runif(25,3,25))
>
>
> maxdays<-sqldf("select distinct * from testframe group by sdate having
bext=max(bext)")
> maxdays
  sdate bext otherstuff stuff
1  day1 77.20252   51.77503 12.045835
2  day2 91.37352   50.07259  4.468679
3  day5 74.29047   58.58456 10.027444

[[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] Superscripts and rounding

2009-07-30 Thread ehux

WORKS!!

Thank you for all your help!


plot (
  decade[['date']],
  decade[['value']],

  type = 'l',
  col = 'lightsteelblue4',
  ylab = 'Discharge [cms]',
  main = sprintf('%s [%s]', stn[['metadata']][['name']],
stn[['metadata']][['id']]),
  sub = sprintf('Seasonal station with natural streamflow - Lat: %s Lon: %s
Gross Area %s\km\UB2 - Effective Area
%s\km\UB2',round(stn[['metadata']][['latitude']],
digits=5),stn[['metadata']][['longitude']],stn[['metadata']][['grossarea']],
stn[['metadata']][['effectivearea']]), 
  cex.sub = 1, font.sub = 3, col.sub = "black"
  )
-- 
View this message in context: 
http://www.nabble.com/Superscripts-and-rounding-tp24682319p24747812.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] ask help about boxplot , different list variation into the tick of x-axis?

2009-07-30 Thread Jie TANG
 Hi ,everyone.

I want to draw a boxplot figure, main script shown as below. when I
run the command "boxplot(bjavee~yearname)",it is wrong with the error
information " model.frame.default(formula = bjavee ~ yearname) :
  variation 'bjavee' list is wrong".

I want to add the yearname as the x-axis tick. And yearname is a array
with the length 12,while bjavee is a 5*12 matrix. How could I get what
I want? thanks.

bjerr1<-bjerrdata$tyerr[1:bjyearnum[2]]
bjerr2<-bjerrdata$tyerr[(bjyearnum[2]+1):bjyearnum[3]]
bjerr3<-bjerrdata$tyerr[(bjyearnum[3]+1):bjyearnum[4]]
bjerr4<-bjerrdata$tyerr[(bjyearnum[4]+1):bjyearnum[5]]
bjerr5<-bjerrdata$tyerr[(bjyearnum[5]+1):bjyearnum[6]]
bjerr6<-bjerrdata$tyerr[(bjyearnum[6]+1):bjyearnum[7]]
bjerr7<-bjerrdata$tyerr[(bjyearnum[7]+1):bjyearnum[8]]
bjerr8<-bjerrdata$tyerr[(bjyearnum[8]+1):bjyearnum[9]]
bjerr9<-bjerrdata$tyerr[(bjyearnum[9]+1):bjyearnum[10]]
bjerr10<-bjerrdata$tyerr[(bjyearnum[10]+1):bjyearnum[11]]
bjerr11<-bjerrdata$tyerr[(bjyearnum[11]+1):bjyearnum[12]]
bjerr12<-bjerrdata$tyerr[(bjyearnum[12]+1):length(bjerryear)]

bjavee<-data.frame(5,12)
cprob=c(0.05,0.25,0.5,0.75,0.95)
bjavee[1:5,1]<-quantile(bjerr1,prob=cprob)
bjavee[1:5,2]<-quantile(bjerr2,prob=cprob)
bjavee[1:5,3]<-quantile(bjerr3,prob=cprob)
bjavee[1:5,4]<-quantile(bjerr4,prob=cprob)
bjavee[1:5,5]<-quantile(bjerr5,prob=cprob)
bjavee[1:5,6]<-quantile(bjerr6,prob=cprob)
bjavee[1:5,7]<-quantile(bjerr7,prob=cprob)
bjavee[1:5,8]<-quantile(bjerr8,prob=cprob)
bjavee[1:5,9]<-quantile(bjerr9,prob=cprob)
bjavee[1:5,10]<-quantile(bjerr10,prob=cprob)
bjavee[1:5,11]<-quantile(bjerr11,prob=cprob)
bjavee[1:5,12]<-quantile(bjerr12,prob=cprob)


yearname<-(1997:2008)

png(file=".\\png\\jptrkfivenum24.png", bg="transparent")

bjbox<-data.frame(bjavee[1:5,1],bjavee[1:5,2],bjavee[1:5,3],bjavee[1:5,4],bjavee[1:5,5],bjavee[1:5,6],bjavee[1:5,7],bjavee[1:5,8],bjavee[1:5,9],bjavee[1:5,10],bjavee[1:5,11],bjavee[1:5,12])
boxplot(bjavee~yearname)

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


Re: [R] Superscripts and rounding

2009-07-30 Thread ehux

This code WORKS  but i can not get it to work when i add the rest of
the sub-title. I have tried three different ways.

# WORKS
plot (
  decade[['date']],
  decade[['value']],

  type = 'l',
  col = 'lightsteelblue4',
  ylab = 'Discharge [cms]',
  main = sprintf('%s [%s]', stn[['metadata']][['name']],
stn[['metadata']][['id']]),
  sub = sprintf('Seasonal station with natural streamflow - Lat: %s',round
(stn[['metadata']][['latitude']], digits=5)), 
  cex.sub = 1, font.sub = 3, col.sub = "black"
  )


#does not work
plot (
  decade[['date']],
  decade[['value']],

  type = 'l',
  col = 'lightsteelblue4',
  ylab = 'Discharge [cms]',
  main = sprintf('%s [%s]', stn[['metadata']][['name']],
stn[['metadata']][['id']]),
  sub = sprintf('Seasonal station with natural streamflow - Lat: %s',round
(stn[['metadata']][['latitude']], digits=5)),'Lon: %s
Gross Area %s\km\UB2 - Effective Area
%s\km\UB2',stn[['metadata']][['longitude']],stn[['metadata']][['grossarea']],
stn[['metadata']][['effectivearea']]), 
  cex.sub = 1, font.sub = 3, col.sub = "black"
  )


#does not work
plot (
  decade[['date']],
  decade[['value']],

  type = 'l',
  col = 'lightsteelblue4',
  ylab = 'Discharge [cms]',
  main = sprintf('%s [%s]', stn[['metadata']][['name']],
stn[['metadata']][['id']]),
  sub = sprintf('Seasonal station with natural streamflow - Lat: %s Lon: %s
Gross Area %s\km\UB2 - Effective Area %s\km\UB2',round
(stn[['metadata']][['latitude']],
digits=5)),stn[['metadata']][['longitude']],stn[['metadata']][['grossarea']],
stn[['metadata']][['effectivearea']]), 
  cex.sub = 1, font.sub = 3, col.sub = "black"
  )

#plot works but does not round number
plot (
  decade[['date']],
  decade[['value']],

  type = 'l',
  col = 'lightsteelblue4',
  ylab = 'Discharge [cms]',
  main = sprintf('%s [%s]', stn[['metadata']][['name']],
stn[['metadata']][['id']]),
  sub = sprintf('Seasonal station with natural streamflow - Lat: %s Lon: %s
Gross Area %s\km\UB2 - Effective Area
%s\km\UB2',round(stn[['metadata']][['latitude']],
digits=5),stn[['metadata']][['longitude']],stn[['metadata']][['grossarea']],
stn[['metadata']][['effectivearea']]), 
  cex.sub = 1, font.sub = 3, col.sub = "black"
  )
-- 
View this message in context: 
http://www.nabble.com/Superscripts-and-rounding-tp24682319p24747802.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] Looping through R objects with $ operator and tags

2009-07-30 Thread Vivek Ayer
Got that work! Thanks.

However, now I need to know how to dump tag values into an object, e.g.,

TotLogDist <- c(object1$LogDist,object2$LogDist,object3$LogDist ...)
[for how many ever objects you provided]

Is there a way to loop that?

TotLogDist <- NULL
for (i in c(1:10))
TotLogDist <- c(TotLogDist,objecti$LogDist)

After this, I don't need to do anymore loops etc. I promise I'll use
lists, lapply, and sapply from then on.

Thanks,
Vivek

On Thu, Jul 30, 2009 at 9:04 AM, Vivek Ayer wrote:
> Hi all,
>
> Suppose I want to set the values in a column to the log of the values
> of another column like so:
>
> object$LogDist <- log10(object$Distance)
>
> How do I loop through the objects if I have object1, object2, etc to
> perform this function?
>
> object1$LogDist <- log10(object1$Distance)
> object2$LogDist <- log10(object2$Distance)
> object3$LogDist <- log10(object3$Distance)
>
> I was trying to use the assign and paste functions like so:
>
> for (i in c(1:10))
> assign(paste("object",i,"$LogDist"),log10(as.name(paste("object",i,"$LogDist")))
>
> but that didn't work out. It creates objects with whole name
> object1$LogDist instead of just manipulating the column that's part of
> that object.
>
> Help appreciated,
> Vivek
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lmer() and "$ operator is invalid for atomic vectors"

2009-07-30 Thread Angela Radulescu

Hi all,

I am a bit mystified by this error message that I get when I try to apply
lmer() to a simple dataset with one between factor (age) and one within
factor (item): "$ operator is invalid for atomic vectors"

I'll just provide the code, because I don't see where the problem is: 


library(lme4)
options(contrasts=c("contr.helmert","contr.poly"))


data =
read.csv("C:/Users/Angela/Desktop/Summer_at_CDS/aging_JDM_Martine/datasets/lamda.data_07.27.09.csv",
header=TRUE) 
attach(data)

new<-data.frame(lamda, age.o_1, Item.l2_2,Subject)
new

Subject <- factor(Subject)
Age <- factor(age.o_1,levels=c("0","1"),labels=c("young","old"))
Item <- factor(Item.l2_2,levels=c("1","2"),labels=c("lamda1","lamda2"))

new2<-data.frame(lamda, Subject, Age, Item)
new2

new3 <- na.omit(new2)
new3
new4=as.data.frame(new3)


> (lmer.lamda <- lmer(lamda ~ Age*Item + ( 1 | Subject), lamda, data=new4))
Error in family$family : $ operator is invalid for atomic vectors


Here are the first 25 values of the dataframe lmer() should operate on: 

 lamda Subject   Age   Item
1 1.600   1   old lamda1
2 1.0434783   2   old lamda1
3 0.960   3   old lamda1
4 3.4285714   4   old lamda1
5 1.1428571   5   old lamda1
6 2.1818182   6   old lamda1
7 0.960   7   old lamda1
8 1.8461538   8   old lamda1
9 2.1818182   9   old lamda1
101.8461538  10   old lamda1
111.8461538  11   old lamda1
121.8461538  12   old lamda1
132.667  13   old lamda1
142.667  14   old lamda1
151.8461538  15   old lamda1
161.0434783  16   old lamda1
171.8461538  17   old lamda1
182.667  18   old lamda1
192.667  19   old lamda1
208.000  20   old lamda1
211.8461538  21   old lamda1
228.000  22   old lamda1
231.8461538  23   old lamda1
242.667  24   old lamda1
252.1818182  25   old lamda1


Any help would be much appreciated this one. I am in the dark and tried
pretty much everything... 

Many thanks,
Angela 

-- 
View this message in context: 
http://www.nabble.com/lmer%28%29-and-%22%24-operator-is-invalid-for-atomic-vectors%22-tp24747770p24747770.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] Question regarding sqldf

2009-07-30 Thread Rizzo . Michael
Here is a test data frame:

> testframe<-data.frame(sdate=rep(paste
("day",1:5,sep=""),each=5),bext=runif(25,1,100),otherstuff=runif
(25,45,60),stuff=runif(25,3,25))
> testframe
   sdate  bext otherstuff stuff
1   day1 37.863859   49.19816 10.036211
2   day1 58.557049   59.23145 21.793954
3   day1 70.345462   48.82313 24.630742
4   day1  1.245913   57.70718 14.131270
5   day1 40.170634   50.38963 21.420328
6   day2 36.126846   51.97043 22.815169
7   day2 95.801896   53.30061 13.540535
8   day2 19.959486   50.46775  9.403084
9   day2  5.772996   55.14082 17.137113
10  day2 77.956966   51.44969 13.448527
11  day3  6.743810   54.49836 17.650795
12  day3 60.758896   55.35407  5.005359
13  day3 86.924873   57.74122  8.691572
14  day3 91.933544   48.17538  8.559737
15  day3 23.627126   59.28906  4.766172
16  day4 76.200158   55.78072 19.493428
17  day4 67.809049   51.06784  7.116428
18  day4 70.309643   54.38067 10.736461
19  day4 91.152166   58.39768 23.199943
20  day4 30.358417   54.16645 24.153823
21  day5 64.064953   58.31813 19.856882
22  day5 49.220106   48.49721 16.615940
23  day5 21.554696   47.03421  3.585458
24  day5 30.227874   55.51724 14.435731
25  day5 51.518716   54.31445 20.837326

If I run the following sqldf statement:

 maxdays<-sqldf("select distinct * from testframe group by sdate having
bext=max(bext)")

I get:

> maxdays
data frame with 0 columns and 0 rows

I want to get the entire observation for each day where "bext" is the
maximum for the day.



|>
| From:  |
|>
  
>|
  |milton ruser 
   |
  
>|
|>
| To:|
|>
  
>|
  |Michael Rizzo/RTP/USEPA/u...@epa 
 |
  
>|
|>
| Cc:|
|>
  
>|
  |r-help@r-project.org 
   |
  
>|
|>
| Date:  |
|>
  
>|
  |07/30/2009 03:03 PM  
   |
  
>|
|>
| Subject:   |
|>
  
>|
  |Re: [R] Question regarding sqldf 
   |
  
>|





Hi Rizzi,

how about a reproducible example/data.frame?

:-)
milton

On Thu, Jul 30, 2009 at 1:46 PM,  wrote:

  Hello,

  I am having a problem using sqldf.  I'm trying to choose a subset of
  observations from a data set based on the date and maximum value of a
  variable by date.

  Here is the code I am using:

  test<-sqldf("select distinct * from bextuse group by sdate having
  bext=max(bext)",method="raw");

  The result I get back is a data frame with 0 rows and 0 columns.  I
  have
  tried the code in another program that utilizes SQL, and I retrieve
  the
  14 rows I was expecting to get.
  I looked at the SQLite information on the web, and it mentions that
  the
  "having" clause can be used to select observations from grouped data
  using aggregating functions.

  Any help or advice is greatly appreciated.

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

[R] how to add the x-axis information

2009-07-30 Thread Jie TANG
Hi ,everyone.

I want to draw a boxplot figure, main script shown as below. when I run the
command "boxplot(bjavee~yearname)",it is wrong with the error information "
model.frame.default(formula = bjavee ~ yearname) :
  variation 'bjavee' list is wrong".

I want to add the yearname as the x-axis tick. And yearname is a array with
the length 12,while bjavee is a 5*12 matrix. How could I get what I want?
thanks.

bjerr1<-bjerrdata$tyerr[1:bjyearnum[2]]
bjerr2<-bjerrdata$tyerr[(bjyearnum[2]+1):bjyearnum[3]]
bjerr3<-bjerrdata$tyerr[(bjyearnum[3]+1):bjyearnum[4]]
bjerr4<-bjerrdata$tyerr[(bjyearnum[4]+1):bjyearnum[5]]
bjerr5<-bjerrdata$tyerr[(bjyearnum[5]+1):bjyearnum[6]]
bjerr6<-bjerrdata$tyerr[(bjyearnum[6]+1):bjyearnum[7]]
bjerr7<-bjerrdata$tyerr[(bjyearnum[7]+1):bjyearnum[8]]
bjerr8<-bjerrdata$tyerr[(bjyearnum[8]+1):bjyearnum[9]]
bjerr9<-bjerrdata$tyerr[(bjyearnum[9]+1):bjyearnum[10]]
bjerr10<-bjerrdata$tyerr[(bjyearnum[10]+1):bjyearnum[11]]
bjerr11<-bjerrdata$tyerr[(bjyearnum[11]+1):bjyearnum[12]]
bjerr12<-bjerrdata$tyerr[(bjyearnum[12]+1):length(bjerryear)]

bjavee<-data.frame(5,12)
cprob=c(0.05,0.25,0.5,0.75,0.95)
bjavee[1:5,1]<-quantile(bjerr1,prob=cprob)
bjavee[1:5,2]<-quantile(bjerr2,prob=cprob)
bjavee[1:5,3]<-quantile(bjerr3,prob=cprob)
bjavee[1:5,4]<-quantile(bjerr4,prob=cprob)
bjavee[1:5,5]<-quantile(bjerr5,prob=cprob)
bjavee[1:5,6]<-quantile(bjerr6,prob=cprob)
bjavee[1:5,7]<-quantile(bjerr7,prob=cprob)
bjavee[1:5,8]<-quantile(bjerr8,prob=cprob)
bjavee[1:5,9]<-quantile(bjerr9,prob=cprob)
bjavee[1:5,10]<-quantile(bjerr10,prob=cprob)
bjavee[1:5,11]<-quantile(bjerr11,prob=cprob)
bjavee[1:5,12]<-quantile(bjerr12,prob=cprob)


yearname<-(1997:2008)

png(file=".\\png\\jptrkfivenum24.png", bg="transparent")

bjbox<-data.frame(bjavee[1:5,1],bjavee[1:5,2],bjavee[1:5,3],bjavee[1:5,4],bjavee[1:5,5],bjavee[1:5,6],bjavee[1:5,7],bjavee[1:5,8],bjavee[1:5,9],bjavee[1:5,10],bjavee[1:5,11],bjavee[1:5,12])
boxplot(bjavee~yearname)




-- 
TANG Jie
Email: totang...@gmail.com
Tel: 0086-2154896104
Shanghai Typhoon Institute,China

[[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] wireframe color change from default

2009-07-30 Thread Marlin Keith Cox
Hello, hopefully simple question, but I cannot find the answer.  I need to
change the color from the standard default.  Still want the scaled colors,
but need different colors for different graphs.

Code is:

wireframe(z ~ y*x, mat.df,
  drape = TRUE,
  zlab = list("Water mass error (%)",rot=92), zlim=c(-50,180),
  xlab = list("Resistance error (%)",rot=16),
  ylab = list("Length error (%)",rot=118),
  scales = list(arrows = FALSE),
 screen = list(z = 20, x = -57, y = 5))

Thanks ahead of time.

-- 
M. Keith Cox, Ph.D.
Alaska NOAA Fisheries, National Marine Fisheries Service
Auke Bay Laboratories
17109 Pt. Lena Loop Rd.
Juneau, AK 99801
keith@noaa.gov
marlink...@gmail.com
U.S. (907) 789-6603

[[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] weight median by count for multiple records

2009-07-30 Thread John Kane

This may do it but I have not verified the figures.

library(cwhmisc)
 by(xx[,3:4],xx[,2],function(x,y) weighted.mean(x,y))

--- On Thu, 7/30/09, Kirsten Beyer  wrote:

> From: Kirsten Beyer 
> Subject: [R] weight median by count for multiple records
> To: r-help@r-project.org
> Received: Thursday, July 30, 2009, 1:58 PM
> Hello everyone,
> 
> I have a .csv file with the following format:
> 
> uniqueID     SubjectID   
>   Distance_miles     Tag
> 1               
>   1001             
>       5.5         
>      3
> 2               
>   1001             
>       7         
>         1
> 3               
>   1001             
>       6.5         
>      1
> 4               
>   1001             
>       5         
>         1
> 5               
>   1002             
>       2         
>         2
> 6               
>   1002             
>       2         
>         2
> 7               
>   1002             
>       1.5         
>      2
> 8               
>   1003             
>       15         
>       2
> 9               
>   1003             
>       17         
>       2
> 10               
> 1003               
>     18           
>     2
> 
> 
> For each SubjectID, I want to calculate the median
> distance, where the
> Tag variable indicates the number of times that distance
> was recorded.
>  My final output table would be...
> 
> SubjectID   Median Distance
> 1001               
> 5.5
> 1002               
> 2
> 1003               
> 17
> 
> I have used the following script to calculate the median
> for a data
> frame where each recorded distance has its own row, and
> where temp is
> a dataframe containing each unique SubjectID and routes is
> the file I
> describe above.
> 
> for(i in 1:nrow(temp)){
> temp$mediandistance[i] <-
> median(routes$Distance_miles[routes$Subject_ID==temp$Subject_ID[i]])
> }
> 
> I am interested to know...
> (1) Is there a way to incorporate a weighted median into
> this script,
> where the weights are the number of times each distance is
> recorded?
> (2) Can I transform my current matrix into one that gives
> each
> distance its own row?
> 
> Help is much appreciated,
> Kirsten Beyer
> 
> __
> R-help@r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 


  __
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now
http://ca.toolbar.yahoo.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] Superscripts and rounding

2009-07-30 Thread ehux

could it be that the values accessed in the database are not integers or
numeric??? 
-- 
View this message in context: 
http://www.nabble.com/Superscripts-and-rounding-tp24682319p24747282.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] Object equality for S4 objects

2009-07-30 Thread Stavros Macrakis
On Thu, Jul 30, 2009 at 4:03 PM, Martin Morgan wrote:
> S4 objects are mutable in the sense that one can write replacement methods 
> for them

Understood, but I don't think that's the usual meaning of 'mutable'.

-s

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


Re: [R] for loop for file names

2009-07-30 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of waltzmiester
> Sent: Thursday, July 30, 2009 1:29 PM
> To: r-help@r-project.org
> Subject: Re: [R] for loop for file names
> 
> 
> Thanks very much for these two solutions, but they are still printing
> "Pred_pres_[i]_indpdt" on the screen and not executing the function load
> 
> Chris
> 
> 
> 
> baptiste auguie-5 wrote:
> >
> > Try this,
> >
> > files = paste('pred/Pred_pres_', letters[1:6], '_indpdt',sep="")
> >
> > lapply(files, load)
> >
> >
> > HTH,
> >
> > baptiste
> > 2009/7/30 waltzmiester :
> >>
> >> I am trying to load binary files in the following fashion
> >>
> >> load("pred/Pred_pres_a_indpdt")
> >> load("pred/Pred_pres_b_indpdt")
> >> load("pred/Pred_pres_c_indpdt")
> >> load("pred/Pred_pres_d_indpdt")
> >> load("pred/Pred_pres_e_indpdt")
> >> load("pred/Pred_pres_f_indpdt")
> >>
> >> but I would like to set up a for loop to replace the letters a:f
> >>
> >> Here is what I have so far:
> >>
> >> letter=c("a","b","c","d","e","f")
> >>
> >> for(l in letter){
> >>
> >>        cat("load('pred/Pred_pres_",l,"_indpdt')",sep="",collapse="","\n")
> >>
> >> }
> >>
> >> That will print the above commands to the console but it will not
> >> actually
> >> enter the commands.
> >>
> >> Any ideas?
> >>
> >> Thanks
> >>
> >> Chris
> >> --
> >> View this message in context:
> >> http://www.nabble.com/for-loop-for-file-names-tp24746012p24746012.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.
> >>
> >
> >
> >
> > --
> > _
> >
> > Baptiste Auguié
> >
> > School of Physics
> > University of Exeter
> > Stocker Road,
> > Exeter, Devon,
> > EX4 4QL, UK
> >
> > http://newton.ex.ac.uk/research/emag
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> 
How about

files = paste('pred/Pred_pres_', letters[1:6], '_indpdt',sep="")
for(i in files){load(i)}

Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204
 

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


Re: [R] for loop for file names

2009-07-30 Thread John Kane

I'm just guessing but what about

letters  <- letters[1:6]
mynames <- paste("pred/Pred_pres_",letters,"_indpdt")
for(i in 1:6) load(mynames[i])

--- On Thu, 7/30/09, waltzmiester  wrote:

> From: waltzmiester 
> Subject: Re: [R] for loop for file names
> To: r-help@r-project.org
> Received: Thursday, July 30, 2009, 4:29 PM
> 
> Thanks very much for these two solutions, but they are
> still printing
> "Pred_pres_[i]_indpdt" on the screen and not executing the
> function load
> 
> Chris
> 
> 
> 
> baptiste auguie-5 wrote:
> > 
> > Try this,
> > 
> > files = paste('pred/Pred_pres_', letters[1:6],
> '_indpdt',sep="")
> > 
> > lapply(files, load)
> > 
> > 
> > HTH,
> > 
> > baptiste
> > 2009/7/30 waltzmiester :
> >>
> >> I am trying to load binary files in the following
> fashion
> >>
> >> load("pred/Pred_pres_a_indpdt")
> >> load("pred/Pred_pres_b_indpdt")
> >> load("pred/Pred_pres_c_indpdt")
> >> load("pred/Pred_pres_d_indpdt")
> >> load("pred/Pred_pres_e_indpdt")
> >> load("pred/Pred_pres_f_indpdt")
> >>
> >> but I would like to set up a for loop to replace
> the letters a:f
> >>
> >> Here is what I have so far:
> >>
> >> letter=c("a","b","c","d","e","f")
> >>
> >> for(l in letter){
> >>
> >>      
>  cat("load('pred/Pred_pres_",l,"_indpdt')",sep="",collapse="","\n")
> >>
> >> }
> >>
> >> That will print the above commands to the console
> but it will not
> >> actually
> >> enter the commands.
> >>
> >> Any ideas?
> >>
> >> Thanks
> >>
> >> Chris
> >> --
> >> View this message in context:
> >> http://www.nabble.com/for-loop-for-file-names-tp24746012p24746012.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.
> >>
> > 
> > 
> > 
> > -- 
> > _
> > 
> > Baptiste Auguié
> > 
> > School of Physics
> > University of Exeter
> > Stocker Road,
> > Exeter, Devon,
> > EX4 4QL, UK
> > 
> > http://newton.ex.ac.uk/research/emag
> > 
> > __
> > R-help@r-project.org
> mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> reproducible code.
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/for-loop-for-file-names-tp24746012p24746775.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.
> 


  __
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now
http://ca.toolbar.yahoo.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] Superscripts and rounding

2009-07-30 Thread ehux

Good one!! Although i think it is stn - none the less neither works.





Polwart Calum (County Durham and Darlington NHS Foundation Trust) wrote:
> 
> Duh! did it again! the variables need str in front of them don't they!!
> 
> sub = sprintf('Seasonal station with natural streamflow - Lat: %s Lon: %s
> Gross Area %s km\UB2 - Effective Area %s km\UB2 ',
> round( str[['metadata']][['latitude']], digits=4 ),
> round( str[['metadata']][['longitude']], digits = 4),
> round( str[['metadata']][['grossarea']], digits = 4),
> round( str[['metadata']][['effectivearea']], digits = 4))
> 
> 
> Let me know if that works.
> 
> 
> 
> This message may contain confidential information. If yo...{{dropped:21}}
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Superscripts-and-rounding-tp24682319p24747066.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] Summarising Data for Forrest Plots

2009-07-30 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)

>Ah, I think I see what you want. Try this on each pair of exclusive sets:
>
n_total<-dim(mydataset)[1]
under65<-mydataset$age <= 65
n_under65<-sum(under65)
under65row<-c(sum(mydataset$dose[under65] == "FD"),
 sum(mydataset$dose[under65] == "RD"),
 sum(mydataset$vitalstatus[under65] == "dead" &
  mydataset$dose[under65] == "FD"),
 sum(mydataset$vitalstatus[under65] == "dead" &
  mydataset$dose[under65] == "RD"))
over65row<-c(sum(mydataset$dose[!under65] == "FD"),
 sum(mydataset$dose[!under65] == "RD"),
 sum(mydataset$vitalstatus[!under65] == "dead" &
  mydataset$dose[!under65] == "FD"),
 sum(mydataset$vitalstatus[!under65] == "dead" &
  mydataset$dose[!under65] == "RD"))
>
>Then under65row and over65row should be the first two rows of your result.
>Can't test this at the moment, but I don't think it's too far wrong.

Thanks Jim.

Yes it looks like that code should do the job.  I was really hoping for a code 
like "SummariseForSubsetAnalysis(mydataset, by=mydatatset$dose, subsets=c(age, 
renal, sex, toxicity), event=survival )" which would magically do it for me ;-)

I guess if this is something I start having to do lots I might have to write 
one.

Surprised one doesn't seem to exist - perhaps the number of variations in what 
people want would be too complex.

Calum




This message may contain confidential information. If yo...{{dropped:21}}

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


Re: [R] Problem with RGtk2 & Rattle

2009-07-30 Thread Graham Williams
Hi Wayne - but what version of the other tools have you installed?

Regards,
Graham


2009/7/30 Wayne Murray 

>
> HI Graham
>
> Thanks for responding so promptly - unfortunately downloading and running
> this new version of Rattle did not alter the outcome - I am however running
> on Windows XP
>
> Regards
>
> Wayne
>
>
>
> Wayne Murray wrote:
> >
> > HI
> >
> > Apologies for previously trying to post this question onto the Dev forum.
> >
> > I have recently update my versions of R and related packages. When I try
> > to use rattle the following message appears
> >
> > "Error in .RGtkCall("R_setGObjectProps", obj, value, PACKAGE = "RGtk2") :
> >   Invalid property tooltip-text!"
> >
> > I have downloaded and installed the latest available version of RGtk2, so
> > I am at a loss to explain this error, or more importantly what I need to
> > do to overcome it
> >
> > Thanks for any suggestions
> >
> > Regards
> >
> > Wayne
> >
>
>
> -
> Dr D. W. Murray
> Canberra, Australia
> --
> View this message in context:
> http://www.nabble.com/Problem-with-RGtk2---Rattle-tp24734447p24736985.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] how to change the thickness of the lines of the boxplot outliers

2009-07-30 Thread Paul Murrell

Hi


Waverley wrote:

Hi,

I tried to use boxplot function. I am following the ?boxplot and can
change the whisker box width using lwd parameter.  However, when
outline=TRUE, the thickness of the circle of the outliers is not
proportionally changed when I change the line width of the whisker
box.  There must be another parameter for that.  Unfortunately I don't
know.



This sounds like a problem that was recently fixed in the development 
version.  It would be useful if you could send me (directly if you like) 
a sample of code that produces the problem.


Paul



please help and thanks much in advance.

--
Waverley @ Palo Alto

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


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

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


Re: [R] Scatter Plot

2009-07-30 Thread John Kane

x <- 1:10
y <- 1:10
plot("", xlim=c(1,10),ylim=c(0,10)
text(x,y, labels=x)

--- On Thu, 7/30/09, amna khan  wrote:

> From: amna khan 
> Subject: [R] Scatter Plot
> To: r-help@r-project.org
> Received: Thursday, July 30, 2009, 12:14 PM
> Dear Sir
> 
> I want to write the numbers 1,2,3,on a scatter plot
> instead of points,
> like 1 corresponding to first point on plot, 2
> corresponding second point
> etc.
> Help in this regard.
> 
> Regards
> 
> -- 
> AMINA SHAHZADI
> Department of Statistics
> GC University Lahore, Pakistan.
> 
>     [[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.
> 


  __
Be smarter than spam. See how smart Sp
ck on Options in Mail and switch to New Mail today or register for free at 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Superscripts and rounding

2009-07-30 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
Duh! did it again! the variables need str in front of them don't they!!

sub = sprintf('Seasonal station with natural streamflow - Lat: %s Lon: %s
Gross Area %s km\UB2 - Effective Area %s km\UB2 ',
round( str[['metadata']][['latitude']], digits=4 ),
round( str[['metadata']][['longitude']], digits = 4),
round( str[['metadata']][['grossarea']], digits = 4),
round( str[['metadata']][['effectivearea']], digits = 4))


Let me know if that works.



This message may contain confidential information. If yo...{{dropped:21}}

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


Re: [R] for loop for file names

2009-07-30 Thread waltzmiester

Thanks very much for these two solutions, but they are still printing
"Pred_pres_[i]_indpdt" on the screen and not executing the function load

Chris



baptiste auguie-5 wrote:
> 
> Try this,
> 
> files = paste('pred/Pred_pres_', letters[1:6], '_indpdt',sep="")
> 
> lapply(files, load)
> 
> 
> HTH,
> 
> baptiste
> 2009/7/30 waltzmiester :
>>
>> I am trying to load binary files in the following fashion
>>
>> load("pred/Pred_pres_a_indpdt")
>> load("pred/Pred_pres_b_indpdt")
>> load("pred/Pred_pres_c_indpdt")
>> load("pred/Pred_pres_d_indpdt")
>> load("pred/Pred_pres_e_indpdt")
>> load("pred/Pred_pres_f_indpdt")
>>
>> but I would like to set up a for loop to replace the letters a:f
>>
>> Here is what I have so far:
>>
>> letter=c("a","b","c","d","e","f")
>>
>> for(l in letter){
>>
>>        cat("load('pred/Pred_pres_",l,"_indpdt')",sep="",collapse="","\n")
>>
>> }
>>
>> That will print the above commands to the console but it will not
>> actually
>> enter the commands.
>>
>> Any ideas?
>>
>> Thanks
>>
>> Chris
>> --
>> View this message in context:
>> http://www.nabble.com/for-loop-for-file-names-tp24746012p24746012.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.
>>
> 
> 
> 
> -- 
> _
> 
> Baptiste Auguié
> 
> School of Physics
> University of Exeter
> Stocker Road,
> Exeter, Devon,
> EX4 4QL, UK
> 
> http://newton.ex.ac.uk/research/emag
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/for-loop-for-file-names-tp24746012p24746775.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] for loop for file names

2009-07-30 Thread Henrique Dallazuanna
Try this:
sapply(sprintf("pred/Pred_pres_%s_indpt", x), load, envir = .GlobalEnv)

You need set the envir argument to global environment inside the sapply.

On Thu, Jul 30, 2009 at 5:06 PM, waltzmiester  wrote:

>
> I am trying to load binary files in the following fashion
>
> load("pred/Pred_pres_a_indpdt")
> load("pred/Pred_pres_b_indpdt")
> load("pred/Pred_pres_c_indpdt")
> load("pred/Pred_pres_d_indpdt")
> load("pred/Pred_pres_e_indpdt")
> load("pred/Pred_pres_f_indpdt")
>
> but I would like to set up a for loop to replace the letters a:f
>
> Here is what I have so far:
>
> letter=c("a","b","c","d","e","f")
>
> for(l in letter){
>
>cat("load('pred/Pred_pres_",l,"_indpdt')",sep="",collapse="","\n")
>
> }
>
> That will print the above commands to the console but it will not actually
> enter the commands.
>
> Any ideas?
>
> Thanks
>
> Chris
> --
> View this message in context:
> http://www.nabble.com/for-loop-for-file-names-tp24746012p24746012.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.
>



-- 
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] for loop for file names

2009-07-30 Thread baptiste auguie
Try this,

files = paste('pred/Pred_pres_', letters[1:6], '_indpdt',sep="")

lapply(files, load)


HTH,

baptiste
2009/7/30 waltzmiester :
>
> I am trying to load binary files in the following fashion
>
> load("pred/Pred_pres_a_indpdt")
> load("pred/Pred_pres_b_indpdt")
> load("pred/Pred_pres_c_indpdt")
> load("pred/Pred_pres_d_indpdt")
> load("pred/Pred_pres_e_indpdt")
> load("pred/Pred_pres_f_indpdt")
>
> but I would like to set up a for loop to replace the letters a:f
>
> Here is what I have so far:
>
> letter=c("a","b","c","d","e","f")
>
> for(l in letter){
>
>        cat("load('pred/Pred_pres_",l,"_indpdt')",sep="",collapse="","\n")
>
> }
>
> That will print the above commands to the console but it will not actually
> enter the commands.
>
> Any ideas?
>
> Thanks
>
> Chris
> --
> View this message in context: 
> http://www.nabble.com/for-loop-for-file-names-tp24746012p24746012.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.
>



-- 
_

Baptiste Auguié

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

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

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


[R] constrained input for optimization algorithm

2009-07-30 Thread Zhi Xie
Hi all,

It seems that optimization algorithm, optim, tries to find optimized
parameters within defined lower and upper bounds. In my problem, all
the parameters are integers. My question is that if there is any means
that I can let "optim" only tries mutual exclusive integers. To be
specific, I am giving an example here.

I tried to find a set parameters with five elements with the lowest
value for the cost function. The parameter set that "optim" returned
is "5, 5, 49, 51, 51". However, I only wanted to search unique
parameter values, such as "5, 6, 49, 50, 51".

Many thanks,

Zhi Xie

Johns Hopkins School of Medicine
Baltimore, MD

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 change the thickness of the lines of the boxplot outliers

2009-07-30 Thread Waverley
Hi,

I tried to use boxplot function. I am following the ?boxplot and can
change the whisker box width using lwd parameter.  However, when
outline=TRUE, the thickness of the circle of the outliers is not
proportionally changed when I change the line width of the whisker
box.  There must be another parameter for that.  Unfortunately I don't
know.

please help and thanks much in advance.

-- 
Waverley @ Palo Alto

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


Re: [R] for loop for file names

2009-07-30 Thread Jorge Ivan Velez
Dear Chris,
Try this:

x <- c("a","b","c","d","e","f")

sapply(x, function(i){
 i <- paste("pred/Pred_pres_",i,"_indpdt", sep ="")
 load(i)
}
   )

HTH,

Jorge



On Thu, Jul 30, 2009 at 4:06 PM, waltzmiester  wrote:

>
> I am trying to load binary files in the following fashion
>
> load("pred/Pred_pres_a_indpdt")
> load("pred/Pred_pres_b_indpdt")
> load("pred/Pred_pres_c_indpdt")
> load("pred/Pred_pres_d_indpdt")
> load("pred/Pred_pres_e_indpdt")
> load("pred/Pred_pres_f_indpdt")
>
> but I would like to set up a for loop to replace the letters a:f
>
> Here is what I have so far:
>
> letter=c("a","b","c","d","e","f")
>
> for(l in letter){
>
>cat("load('pred/Pred_pres_",l,"_indpdt')",sep="",collapse="","\n")
>
> }
>
> That will print the above commands to the console but it will not actually
> enter the commands.
>
> Any ideas?
>
> Thanks
>
> Chris
> --
> View this message in context:
> http://www.nabble.com/for-loop-for-file-names-tp24746012p24746012.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] for loop for file names

2009-07-30 Thread waltzmiester

I am trying to load binary files in the following fashion

load("pred/Pred_pres_a_indpdt")
load("pred/Pred_pres_b_indpdt")
load("pred/Pred_pres_c_indpdt")
load("pred/Pred_pres_d_indpdt")
load("pred/Pred_pres_e_indpdt")
load("pred/Pred_pres_f_indpdt")

but I would like to set up a for loop to replace the letters a:f

Here is what I have so far:

letter=c("a","b","c","d","e","f")

for(l in letter){

cat("load('pred/Pred_pres_",l,"_indpdt')",sep="",collapse="","\n")

}

That will print the above commands to the console but it will not actually
enter the commands.

Any ideas?

Thanks

Chris
-- 
View this message in context: 
http://www.nabble.com/for-loop-for-file-names-tp24746012p24746012.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] Object equality for S4 objects

2009-07-30 Thread Martin Morgan

Stavros Macrakis wrote:

On Thu, Jul 30, 2009 at 12:01 PM, Martin Morgan wrote:

S4 objects do not have the semantics of environments, but of lists (or of most 
other R objects), so it is as meaningful to ask why identical(s1, s2) returns 
TRUE as it is to ask why identical(list(x=1), list(x=1)) returns TRUE.


Thanks for the clarification.

For some reason, I thought that S4 objects (unlike S3 objects) were
objects in the conventional computer science sense, that is, mutable.


S4 objects are mutable in the sense that one can write replacement 
methods for them



  setClass("A", representation=representation(aValue="logical"))
  setGeneric("aValue<-",
 function(object, value) standardGeneric("aValue<-"))
  setReplaceMethod("aValue", "A", function(object, value) {
  slot(object, "aValue") <- value
  object
  })

> a <- b <- new("A", aValue=FALSE)
> aValue(a) <- TRUE
> a
An object of class "A"
Slot "aValue":
[1] TRUE

while preserving copy-on-change

> b
An object of class "A"
Slot "aValue":
[1] FALSE

Martin


Compare proto objects, which *are* objects in the usual sense:


proto1 <- proto(expr= {x=23})
proto2 <- proto1
proto1$x <- 45
proto2$x

[1] 45# proto1 and proto2 are the same object


setClass("test",representation(a="logical"))

[1] "test"

s41 <- new("test")
s42 <- s41
s...@a <- TRUE
s...@a  # s41 and s42 are different objects

logical(0)

It would thus perhaps be clearer to speak of S4 "values" rather than
S4 "objects".

-s



--
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

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


Re: [R] Scatter Plot

2009-07-30 Thread Felipe Carrillo

Tri this for both, points and text..
library(ggplot2)
qplot(x=1:5,y=1:5) + geom_text(label=1:5)


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


--- On Thu, 7/30/09, amna khan  wrote:

> From: amna khan 
> Subject: [R] Scatter Plot
> To: r-help@r-project.org
> Date: Thursday, July 30, 2009, 9:14 AM
> Dear Sir
> 
> I want to write the numbers 1,2,3,on a scatter plot
> instead of points,
> like 1 corresponding to first point on plot, 2
> corresponding second point
> etc.
> Help in this regard.
> 
> Regards
> 
> -- 
> AMINA SHAHZADI
> Department of Statistics
> GC University Lahore, Pakistan.
> 
>     [[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] edit.row.names taking row names from the edited dataframe

2009-07-30 Thread Ross Culloch

Hi Chuck,

Thank you too for your help and quick reply - that has worked perfectly. I
think as Erik pointed out i was going down the wrong road with my attempts
to identify the root of the problem. Yet another handy command i'm now aware
of!

Thanks again, I really appreciate the help!


-- 
View this message in context: 
http://www.nabble.com/edit.row.names-taking-row-names-from-the-edited-dataframe-tp24744741p24745661.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] edit.row.names taking row names from the edited dataframe

2009-07-30 Thread Ross Culloch

Hello Erik,

Thanks very much, that works perfectly - thanks also for the link - it seems
that i was going down the wrong road with regards to solving this problem! 

Thanks also for your quick reply!

-- 
View this message in context: 
http://www.nabble.com/edit.row.names-taking-row-names-from-the-edited-dataframe-tp24744741p24745624.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] Retrieving original data frame after repetition

2009-07-30 Thread Marc Schwartz

On Jul 30, 2009, at 11:15 AM, Jose Iparraguirre D'Elia wrote:


Dear R users,

Consider the first two columns of a data frame like this:

z[,1:2]

x y

1 1 1

2 2 2

3 3 3

4 1 4



Imagine that y represents the times that the value x happens in a  
population. But z is not exactly a frequency table, because in z we  
have x=1 twice. So, the x=1 in the first line and the x=1 in the  
fourth are not the same, differing according to a third variable in  
the data frame.


Now, I use the function rep() in order to obtain a vector of values  
of x in the population:


x.pop <- rep(x,y)


x.pop


[1] 1 2 2 3 3 3 1 1 1 1

How can I go from x.pop back to z? If I use table(x.pop), I obtain a  
frequency table like the one below, but not z.


table(x.pop)

x.pop

1 2 3

5 2 3


(I know I haven't deleted z, obviously, but I need to write a piece  
of code to do something very similar).


Just in case anyone is wondering by now whether this is an  
assignment for college, etc.,-it is not. The real world problem I'm  
working on at the moment has to do with income distribution in  
Northern Ireland. I want to see how many people would leave poverty  
if the income of those currently below 60% median income increases  
by, say, £20 a week. I am working with the Family Resources Survey  
sample for Northern Ireland (n=2,263), which I have to gross up  
before increasing the incomes (grossed up n=1,712,886). Once I  
increased the income figures for those individuals in poverty, I  
need to 'un-gross' the data to get back to  n=2,263 -and table()  
simply does not do the trick, because of exactly the same situation  
in the example above.


So, please, how can I retrieve z?

Many thanks,

Jose


Presuming that your larger case is similar in structure to 'x.pop',  
which is to say that each unique value is in sequential runs, you can  
use:


z <- do.call(data.frame, rle(x.pop))[, c(2, 1)]

colnames(z) <- c("x", "y")

> z
x y
1 1 1
2 2 2
3 3 3
4 1 4


See ?rle for more information on summarizing runs of values. The core  
of the first step above yields:


> rle(x.pop)
Run Length Encoding
lengths: int [1:4] 1 2 3 4
values : num [1:4] 1 2 3 1

which is a list of two elements, that we coerce to a data frame using  
do.call(), reversing the two columns to match your original order.


HTH,

Marc Schwartz

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


Re: [R] edit.row.names taking row names from the edited dataframe

2009-07-30 Thread Erik Iverson
I didn't test what I wrote, but I see that "id" should be "ID" in the first 
line of R code; the one with the %in% operator, sorry!

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Erik Iverson
Sent: Thursday, July 30, 2009 1:56 PM
To: Ross Culloch; r-help@r-project.org
Subject: Re: [R] edit.row.names taking row names from the edited dataframe

Hello, 

Try the following instead of your many separate assignments (I do not like to 
give objects the name "data", since that is the name of a built-in function). 

> ids <- subset(mumpup, id %in% c("A1", "B1", ... , "G1")) 
#in above line, fill in ... with other IDs you want

> ids$ID <- factor(ids$ID)
#remove extra factor levels, this would also work after the rbind
#if you called your object "ids" instead of "data". 

This really has nothing to do with the "row names" issue you mention, as far as 
I can tell.  It has to do with this: 

http://stackoverflow.com/questions/1195826/dropping-factor-levels-in-a-subsetted-data-frame-in-r

Best,
Erik Iverson 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Ross Culloch
Sent: Thursday, July 30, 2009 1:46 PM
To: r-help@r-project.org
Subject: [R] edit.row.names taking row names from the edited dataframe


Hi all,

I am struggling to work out how to use the rownames from an edited dataframe
rather than the row names from the original dataframe. In my data set i'm
trying to extract several rows of data on particular individuals, i don't
doubt i'm using the long way round but what i have in the way of a script is
this:


##selecting the IDs from the dataframe individually
A1<-mumpup[ID=="A1",]
B1<-mumpup[ID=="B1",]
B2<-mumpup[ID=="B2",]
B3<-mumpup[ID=="B3",]
B4<-mumpup[ID=="B4",]
B6<-mumpup[ID=="B6",]
B7<-mumpup[ID=="B7",]
B8<-mumpup[ID=="B8",]
B9<-mumpup[ID=="B9",]
B13<-mumpup[ID=="B13",]
C1<-mumpup[ID=="C1",]
G1<-mumpup[ID=="G1",]

data<-rbind(A1,B1,B2,B3,B4,B6,B7,B8,B9,B13,C1,G1)

It works fine to a certain extent, the only problem being that i get are all
the IDs in the original dataframe so if i use

summary(data$ID)

I get:

 A1  B1 B10 B13  B2  B3  B4  B6  B7  B8  B9  C1  G1  G3  H2  H9  J1  J2  J3 
K1 
354 354   0 354 354 354 354 354 354 354 354 246 210   0   0   0   0   0   0  
0 

So it does take the data out of the dataframe but it keeps the IDs for some
reason.

I have looked at the edit.data.frame help and i understand why it is
happening, it is taking the rownames from the original dataframe and not the
edit and it seems i should use edit.row.names=T in my script, but i can't
get that to work.

Does anyone have any suggestions at all? Any help is much appreciated,

Best wishes,

Ross

-- 
View this message in context: 
http://www.nabble.com/edit.row.names-taking-row-names-from-the-edited-dataframe-tp24744741p24744741.html
Sent from the R help mailing list archive at Nabble.com.

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

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

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


Re: [R] Question regarding sqldf

2009-07-30 Thread milton ruser
Hi Rizzi,

how about a reproducible example/data.frame?

:-)
milton

On Thu, Jul 30, 2009 at 1:46 PM,  wrote:

>
> Hello,
>
> I am having a problem using sqldf.  I'm trying to choose a subset of
> observations from a data set based on the date and maximum value of a
> variable by date.
>
> Here is the code I am using:
>
> test<-sqldf("select distinct * from bextuse group by sdate having
> bext=max(bext)",method="raw");
>
> The result I get back is a data frame with 0 rows and 0 columns.  I have
> tried the code in another program that utilizes SQL, and I retrieve the
> 14 rows I was expecting to get.
> I looked at the SQLite information on the web, and it mentions that the
> "having" clause can be used to select observations from grouped data
> using aggregating functions.
>
> Any help or advice is greatly appreciated.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] edit.row.names taking row names from the edited dataframe

2009-07-30 Thread Chuck Cleland
On 7/30/2009 2:46 PM, Ross Culloch wrote:
> Hi all,
> 
> I am struggling to work out how to use the rownames from an edited dataframe
> rather than the row names from the original dataframe. In my data set i'm
> trying to extract several rows of data on particular individuals, i don't
> doubt i'm using the long way round but what i have in the way of a script is
> this:
> 
> 
> ##selecting the IDs from the dataframe individually
> A1<-mumpup[ID=="A1",]
> B1<-mumpup[ID=="B1",]
> B2<-mumpup[ID=="B2",]
> B3<-mumpup[ID=="B3",]
> B4<-mumpup[ID=="B4",]
> B6<-mumpup[ID=="B6",]
> B7<-mumpup[ID=="B7",]
> B8<-mumpup[ID=="B8",]
> B9<-mumpup[ID=="B9",]
> B13<-mumpup[ID=="B13",]
> C1<-mumpup[ID=="C1",]
> G1<-mumpup[ID=="G1",]
> 
> data<-rbind(A1,B1,B2,B3,B4,B6,B7,B8,B9,B13,C1,G1)
> 
> It works fine to a certain extent, the only problem being that i get are all
> the IDs in the original dataframe so if i use
> 
> summary(data$ID)
> 
> I get:
> 
>  A1  B1 B10 B13  B2  B3  B4  B6  B7  B8  B9  C1  G1  G3  H2  H9  J1  J2  J3 
> K1 
> 354 354   0 354 354 354 354 354 354 354 354 246 210   0   0   0   0   0   0  
> 0 
> 
> So it does take the data out of the dataframe but it keeps the IDs for some
> reason.
> 
> I have looked at the edit.data.frame help and i understand why it is
> happening, it is taking the rownames from the original dataframe and not the
> edit and it seems i should use edit.row.names=T in my script, but i can't
> get that to work.
> 
> Does anyone have any suggestions at all? Any help is much appreciated,

  If I understand, you may want something like this:

myIDs <- c('A1','B1','B2','B3','B4','B6','B7','B8','B9','B13','C1','G1')

subset(mumpup, ID %in% myIDs)

> Best wishes,
> 
> Ross 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

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


Re: [R] Scatter Plot

2009-07-30 Thread baptiste auguie
Hi,

Try this,

plot(1:5,1:5, t='p', pch=paste(1:5))

baptiste


2009/7/30 amna khan :
> Dear Sir
>
> I want to write the numbers 1,2,3,on a scatter plot instead of points,
> like 1 corresponding to first point on plot, 2 corresponding second point
> etc.
> Help in this regard.
>
> Regards
>
> --
> AMINA SHAHZADI
> Department of Statistics
> GC University Lahore, Pakistan.
>
>        [[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] edit.row.names taking row names from the edited dataframe

2009-07-30 Thread Erik Iverson
Hello, 

Try the following instead of your many separate assignments (I do not like to 
give objects the name "data", since that is the name of a built-in function). 

> ids <- subset(mumpup, id %in% c("A1", "B1", ... , "G1")) 
#in above line, fill in ... with other IDs you want

> ids$ID <- factor(ids$ID)
#remove extra factor levels, this would also work after the rbind
#if you called your object "ids" instead of "data". 

This really has nothing to do with the "row names" issue you mention, as far as 
I can tell.  It has to do with this: 

http://stackoverflow.com/questions/1195826/dropping-factor-levels-in-a-subsetted-data-frame-in-r

Best,
Erik Iverson 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Ross Culloch
Sent: Thursday, July 30, 2009 1:46 PM
To: r-help@r-project.org
Subject: [R] edit.row.names taking row names from the edited dataframe


Hi all,

I am struggling to work out how to use the rownames from an edited dataframe
rather than the row names from the original dataframe. In my data set i'm
trying to extract several rows of data on particular individuals, i don't
doubt i'm using the long way round but what i have in the way of a script is
this:


##selecting the IDs from the dataframe individually
A1<-mumpup[ID=="A1",]
B1<-mumpup[ID=="B1",]
B2<-mumpup[ID=="B2",]
B3<-mumpup[ID=="B3",]
B4<-mumpup[ID=="B4",]
B6<-mumpup[ID=="B6",]
B7<-mumpup[ID=="B7",]
B8<-mumpup[ID=="B8",]
B9<-mumpup[ID=="B9",]
B13<-mumpup[ID=="B13",]
C1<-mumpup[ID=="C1",]
G1<-mumpup[ID=="G1",]

data<-rbind(A1,B1,B2,B3,B4,B6,B7,B8,B9,B13,C1,G1)

It works fine to a certain extent, the only problem being that i get are all
the IDs in the original dataframe so if i use

summary(data$ID)

I get:

 A1  B1 B10 B13  B2  B3  B4  B6  B7  B8  B9  C1  G1  G3  H2  H9  J1  J2  J3 
K1 
354 354   0 354 354 354 354 354 354 354 354 246 210   0   0   0   0   0   0  
0 

So it does take the data out of the dataframe but it keeps the IDs for some
reason.

I have looked at the edit.data.frame help and i understand why it is
happening, it is taking the rownames from the original dataframe and not the
edit and it seems i should use edit.row.names=T in my script, but i can't
get that to work.

Does anyone have any suggestions at all? Any help is much appreciated,

Best wishes,

Ross

-- 
View this message in context: 
http://www.nabble.com/edit.row.names-taking-row-names-from-the-edited-dataframe-tp24744741p24744741.html
Sent from the R help mailing list archive at Nabble.com.

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

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


[R] edit.row.names taking row names from the edited dataframe

2009-07-30 Thread Ross Culloch

Hi all,

I am struggling to work out how to use the rownames from an edited dataframe
rather than the row names from the original dataframe. In my data set i'm
trying to extract several rows of data on particular individuals, i don't
doubt i'm using the long way round but what i have in the way of a script is
this:


##selecting the IDs from the dataframe individually
A1<-mumpup[ID=="A1",]
B1<-mumpup[ID=="B1",]
B2<-mumpup[ID=="B2",]
B3<-mumpup[ID=="B3",]
B4<-mumpup[ID=="B4",]
B6<-mumpup[ID=="B6",]
B7<-mumpup[ID=="B7",]
B8<-mumpup[ID=="B8",]
B9<-mumpup[ID=="B9",]
B13<-mumpup[ID=="B13",]
C1<-mumpup[ID=="C1",]
G1<-mumpup[ID=="G1",]

data<-rbind(A1,B1,B2,B3,B4,B6,B7,B8,B9,B13,C1,G1)

It works fine to a certain extent, the only problem being that i get are all
the IDs in the original dataframe so if i use

summary(data$ID)

I get:

 A1  B1 B10 B13  B2  B3  B4  B6  B7  B8  B9  C1  G1  G3  H2  H9  J1  J2  J3 
K1 
354 354   0 354 354 354 354 354 354 354 354 246 210   0   0   0   0   0   0  
0 

So it does take the data out of the dataframe but it keeps the IDs for some
reason.

I have looked at the edit.data.frame help and i understand why it is
happening, it is taking the rownames from the original dataframe and not the
edit and it seems i should use edit.row.names=T in my script, but i can't
get that to work.

Does anyone have any suggestions at all? Any help is much appreciated,

Best wishes,

Ross

-- 
View this message in context: 
http://www.nabble.com/edit.row.names-taking-row-names-from-the-edited-dataframe-tp24744741p24744741.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] Constrained MLE of fixed mean Singh-Maddala distribution

2009-07-30 Thread Josh Parcel
INTRODUCTION TO THE PROBLEM

 

I am trying to fit a distribution to a dataset. The distribution that I
am currently considering is the (3-parameter) Singh-Maddala (Burr)
distribution. The final model will fix the mean of the distribution to a
given value and estimate the remaining parameters accordingly; however,
the code provided below ignores this. For this distribution the three
parameters ('a': corresponding to 'a' in the function 'dsinmad' under
the package 'VGAM'; 'b': corresponding to 'scale'; and 'q':
corresponding to 'q.arg') are constrained to be strictly positive. For
this I estimate parameters, first using 'optim' (and later 'nlm'),
defined over the set of real numbers and then use the exponential
function to convert them to positive values. For these constraints and
the additional constraint: 'q-1/a>0' the expected value is given as (as
reported on the help page for the function 'sinmad'):

E(Y) = b gamma(1 + 1/a) gamma(q - 1/a) / gamma(q).

THE PROBLEM

 

The problem I am having is constraining the search to the region where
'q-1/a>0'. I was hoping not to just set the value of the negative log
likelihood to 'Inf' (unless suggested otherwise) when 'optim' set the
parameter at values that violated the constraint. I do not have much
experience with simulated annealing so am not sure if the method 'SANN'
would address this issue. I was also hoping to avoid using 'optim'
recursively to solve this problem (unless otherwise suggested).

 

Does 'R' have a function that can address the issue of the mentioned
constraint in solving the maximum likelihood problem (that is applicable
when the mean is fixed and other parameters estimated accordingly)? 

 

I have included code below to provide a better understanding of the
problem (the dataset for 'y' is not included).

 

Thanks,

Josh Parcel

 

 

 

 

 

 

 

###

R CODE

###



library(VGAM)





#Fit a Singh-Maddala distribution to 'y'.





#Singh-Maddala Distribution

#Parameters: a:shape ; b: scale; q: shape.

#a>0, b>0, q>0. To use given mean require -a<10'.

z<-(-sum(log(dsinmad(y, a=a_iter, scale=b_iter,
q.arg=q_iter, log=FALSE

}



#Set values for initial guess of the parameters.



a_guess<-2

b_guess<-3

q_guess<-7



q_guess-1/a_guess



p0<-c(log(a_guess), log(b_guess), log(q_guess)) 



#Optimize to find minimum of the negative likelihood function 



est_p_A<-optim(par=p0, fn=neg.LL_sinmad, y=y)



est_p_A$par

a_hat1<-exp(est_p_A$par[1])

b_hat1<-exp(est_p_A$par[2])

q_hat1<-exp(est_p_A$par[3])



q_hat1-1/a_hat1



est_p_B<-nlm(f=neg.LL_sinmad, p=c(est_p_A$par[1], est_p_A$par[2],

est_p_A$par[3]), print.level=1, y=y)



a_hat<-exp(est_p_A$par[1])

b_hat<-exp(est_p_A$par[2])

q_hat<-exp(est_p_A$par[3])



q_hat-1/a_hat




CONFIDENTIALITY NOTICE: This email, and any attachments ...{{dropped:12}}

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

2009-07-30 Thread joaodaniel

Hello!

I've been studying the Rserve for the last few days, and achieved to connect
it to a Java plattaform. I also could run some simple commands in R, and
plot some graphics.

But I did this just using the examples files as a template. Now I'm looking
for discover what does all those Java classes means, and how is the correct
way to write the code.

Where is the best place to learn more about this? I've been trought the
Rserve documentation, but I still don't know when should I use each "eval"
command, and what is that REXP class.

Do you guys know some good documentation?

Thanks

J Daniel
-- 
View this message in context: 
http://www.nabble.com/Help-in-Rserve-tp24744155p24744155.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] Retrieving original data frame after repetition

2009-07-30 Thread Jose Iparraguirre D'Elia
Dear R users,

 

Consider the first two columns of a data frame like this:

 

> z[,1:2]

  x y

1 1 1

2 2 2

3 3 3

4 1 4

 

Imagine that y represents the times that the value x happens in a population. 
But z is not exactly a frequency table, because in z we have x=1 twice. So, the 
x=1 in the first line and the x=1 in the fourth are not the same, differing 
according to a third variable in the data frame.

 

Now, I use the function rep() in order to obtain a vector of values of x in the 
population:

 

> x.pop <- rep(x,y)

> x.pop

 [1] 1 2 2 3 3 3 1 1 1 1

 

How can I go from x.pop back to z? If I use table(x.pop), I obtain a frequency 
table like the one below, but not z.

 

> table(x.pop)

x.pop

1 2 3 

5 2 3

 

(I know I haven't deleted z, obviously, but I need to write a piece of code to 
do something very similar).

 

Just in case anyone is wondering by now whether this is an assignment for 
college, etc.,-it is not. The real world problem I'm working on at the moment 
has to do with income distribution in Northern Ireland. I want to see how many 
people would leave poverty if the income of those currently below 60% median 
income increases by, say, £20 a week. I am working with the Family Resources 
Survey sample for Northern Ireland (n=2,263), which I have to gross up before 
increasing the incomes (grossed up n=1,712,886). Once I increased the income 
figures for those individuals in poverty, I need to 'un-gross' the data to get 
back to  n=2,263 -and table() simply does not do the trick, because of exactly 
the same situation in the example above.

 

So, please, how can I retrieve z? 

 

Many thanks,

 

Jose

 

Mr José Luis Iparraguirre

Senior Research Economist

Economic Research Institute of Northern Ireland

2 -14 East Bridge Street

Belfast BT1 3NQ

Northern Ireland

United Kingdom

 

Tel: +44 (0)28 9072 7365

 


[[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] Scatter Plot

2009-07-30 Thread amna khan
Dear Sir

I want to write the numbers 1,2,3,on a scatter plot instead of points,
like 1 corresponding to first point on plot, 2 corresponding second point
etc.
Help in this regard.

Regards

-- 
AMINA SHAHZADI
Department of Statistics
GC University Lahore, Pakistan.

[[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] Object equality for S4 objects

2009-07-30 Thread Stavros Macrakis
On Thu, Jul 30, 2009 at 12:01 PM, Martin Morgan wrote:
> S4 objects do not have the semantics of environments, but of lists (or of 
> most other R objects), so it is as meaningful to ask why identical(s1, s2) 
> returns TRUE as it is to ask why identical(list(x=1), list(x=1)) returns TRUE.

Thanks for the clarification.

For some reason, I thought that S4 objects (unlike S3 objects) were
objects in the conventional computer science sense, that is, mutable.
Compare proto objects, which *are* objects in the usual sense:

> proto1 <- proto(expr= {x=23})
> proto2 <- proto1
> proto1$x <- 45
> proto2$x
[1] 45# proto1 and proto2 are the same object

> setClass("test",representation(a="logical"))
[1] "test"
> s41 <- new("test")
> s42 <- s41
> s...@a <- TRUE
> s...@a  # s41 and s42 are different objects
logical(0)

It would thus perhaps be clearer to speak of S4 "values" rather than
S4 "objects".

-s

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


Re: [R] Selecting Bootstrap Method for Quantile Regression

2009-07-30 Thread Mark Difford

Hi Tom,

>> For example, if I want to use the "xy-pair bootstrap" how do I indicate
>> this in summary.rq?

The general approach is documented under summary.rq (sub se option 5).
Shorter route is boot.rq, where examples are given.

## ?boot.rq
y <- rnorm(50)
x <- matrix(rnorm(100),50)
fit <- rq(y~x,tau = .4)
summary(fit,se = "boot", bsmethod= "xy")

Regards, Mark.


Tom La Bone wrote:
> 
> The help page and vignette for summary.rq(quantreg) mention that there are
> three different bootstrap methods available for the se="bootstrap"
> argument, but I can't figure out how to select a particular method. For
> example, if I want to use the "xy-pair bootstrap" how do I indicate this
> in summary.rq?
> 
> Tom
> 

-- 
View this message in context: 
http://www.nabble.com/Selecting-Bootstrap-Method-for-Quantile-Regression-tp24737299p24744179.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] Continue to finish for loop even there is an error in one of rounds.

2009-07-30 Thread Scott Sherrill-Mix
You probably want to wrap the nls(...) in a 'try' or 'tryCatch' function.

Scott



Scott Sherrill-Mix
Department of Microbiology
University of Pennsylvania
402B Johnson Pavilion
3610 Hamilton Walk
Philadelphia, PA  19104-6076
Phone: 215-573-3141



On Thu, Jul 30, 2009 at 1:14 PM, Liao, Hongsheng wrote:
> I am trying to fit a logistic model to my 10 year data (1999-2008) by year.  
> Codes like below:
>
> Year <- c(1999: 2008)
> for(y in 1:length(year)) {
>        file.input <- paste("C:\\", year[y], "\\data.csv", sep="")
> table <- read.csv(file=fileinput, header=TRUE, as.is=TRUE, na.strings=c(""))
>        initial <- getInitial(percent ~ SSlogis(age, Asym, xmid, scal), data = 
> table)
> fm1 <- nls(percent ~ SSlogis(age, Asym, xmid, scal), data = table)
>        summary <- summary(fm1)
>        parameters <- summary$parameters
>        file.output <- paste("C:\\", year[y], "\\parameters.csv", sep="")
>        write.csv(parameters, file=file.output, row.names=FALSE)
> }
>
> However, when one of 10 years can't be converged, such as 2000, the loop 
> stops in that year (2000) even though the rest years (2001 to 2008) can be 
> converged. I would really appreciate if someone helps me on how to force the 
> loop function to finish all 10 rounds even when errors occur due to no 
> convergences for some of years.
>
>
> Hongsheng (Hank) Liao
> Lab Manager
> Center for Quantitative Fisheries Ecology
> Old Dominion University
> Phone: 757-683-4571
>
>
>
>
>        [[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] weight median by count for multiple records

2009-07-30 Thread Dimitris Rizopoulos

one approach is:

sp <- split(dat[-1], dat$SubjectID)
t(sapply(sp, function (d)
c(d$SubjectID[1], median(rep(d$Distance_miles, d$Tag)

where 'dat' is the name of your data.frame.

I hope this helps.

Best,
Dimitris


Kirsten Beyer wrote:

Hello everyone,

I have a .csv file with the following format:

uniqueID SubjectID  Distance_miles Tag
1  10015.5   3
2  10017  1
3  10016.5   1
4  10015  1
5  10022  2
6  10022  2
7  10021.5   2
8  1003152
9  1003172
101003182


For each SubjectID, I want to calculate the median distance, where the
Tag variable indicates the number of times that distance was recorded.
 My final output table would be...

SubjectID   Median Distance
10015.5
10022
100317

I have used the following script to calculate the median for a data
frame where each recorded distance has its own row, and where temp is
a dataframe containing each unique SubjectID and routes is the file I
describe above.

for(i in 1:nrow(temp)){
temp$mediandistance[i] <-
median(routes$Distance_miles[routes$Subject_ID==temp$Subject_ID[i]])
}

I am interested to know...
(1) Is there a way to incorporate a weighted median into this script,
where the weights are the number of times each distance is recorded?
(2) Can I transform my current matrix into one that gives each
distance its own row?

Help is much appreciated,
Kirsten Beyer

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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

2009-07-30 Thread Kirsten Beyer
Hello everyone,

I have a .csv file with the following format:

uniqueID SubjectID  Distance_miles Tag
1  10015.5   3
2  10017  1
3  10016.5   1
4  10015  1
5  10022  2
6  10022  2
7  10021.5   2
8  1003152
9  1003172
101003182


For each SubjectID, I want to calculate the median distance, where the
Tag variable indicates the number of times that distance was recorded.
 My final output table would be...

SubjectID   Median Distance
10015.5
10022
100317

I have used the following script to calculate the median for a data
frame where each recorded distance has its own row, and where temp is
a dataframe containing each unique SubjectID and routes is the file I
describe above.

for(i in 1:nrow(temp)){
temp$mediandistance[i] <-
median(routes$Distance_miles[routes$Subject_ID==temp$Subject_ID[i]])
}

I am interested to know...
(1) Is there a way to incorporate a weighted median into this script,
where the weights are the number of times each distance is recorded?
(2) Can I transform my current matrix into one that gives each
distance its own row?

Help is much appreciated,
Kirsten Beyer

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

2009-07-30 Thread Rizzo . Michael

Hello,

I am having a problem using sqldf.  I'm trying to choose a subset of
observations from a data set based on the date and maximum value of a
variable by date.

Here is the code I am using:

test<-sqldf("select distinct * from bextuse group by sdate having
bext=max(bext)",method="raw");

The result I get back is a data frame with 0 rows and 0 columns.  I have
tried the code in another program that utilizes SQL, and I retrieve the
14 rows I was expecting to get.
I looked at the SQLite information on the web, and it mentions that the
"having" clause can be used to select observations from grouped data
using aggregating functions.

Any help or advice is greatly appreciated.

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

2009-07-30 Thread David M Smith
I've also been maintaining a list at:

http://blog.revolution-computing.com/local-r-groups.html

The most recent addition is the user group in Japan.

# David Smith

On Thu, Jul 30, 2009 at 5:33 AM, Prof. John C Nash  wrote:
>
> There are now several R geographic user groups, and a few have mailing lists 
> on the R mailing list system. Thanks to Martin M, there's also a pointer to a 
> page I'm maintaining to list/describe the groups. The page is at
>
> http://macnash.telfer.uottawa.ca/RUG.html
>
>
> Contact me if you have a listing. I'm prepared to wikify it if there is 
> sufficient interest.
>
> John Nash

--
David M Smith 
Director of Community, REvolution Computing www.revolution-computing.com
Tel: +1 (206) 577-4778 x3203 (San Francisco, USA)

Check out our upcoming events schedule at www.revolution-computing.com/events

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

2009-07-30 Thread baptiste auguie
Hi,

Chapter 8 of the lattice book has some examples (you can see the code
and figures on r-forge). Perhaps you could try something like this,


d = data.frame(x=1:10,y=1:10,f=sample(letters[1:2],10,repl=T))

axis.custom = function(side, ...){

if(side == "bottom")
switch(panel.number(),
'1' = panel.axis(side="bottom",outside=TRUE, at = c(4,6)),
'2' = panel.axis(side="bottom",outside=TRUE, at = c(2,8),
labels=letters[1:2], rot=rep(0,2)))
}

xyplot(y~x|f, d, axis=axis.custom)


HTH,

baptiste

2009/7/30 Armin Goralczyk :
> Hello (R-)Experts
>
> I hope someone can help with this problem concerning axis annotation
> of a lattice shingle plot. I want a plot with three shingles to
> display some laboratory value over time. In the first panel over the
> first few days, then in the next panel some months, and in the last
> panel some years. In the following minimal example the axis annotation
> will be in days, but I'd like to have days in the fisrt panel, months
> in the second panel and years in the third panel. Is it possible?
>
> pod <- seq(1, 5000, 5)
> test <- data.frame(pod=pod,
>                   val=rep(c(1,2,4,8), length=length(pod)),
>                   g=rep(c('A', 'B'), length=length(pod)))
> shingle.pod <- shingle(test$pod, intervals = rbind(c(0, 20), c(20, 180),
>                                c(220, 6000)))
> test.plot <- xyplot(val ~ pod | shingle.pod,
>                    data = test,
>                    groups = test$g,
>                    scales = list(x = "free",
>                    y = list(relation = "same", log = 2)),
>                    between = list(x = 0.5),
>                    panel = function(x, y, ...) {
>                        panel.grid(h = -1, v = -1, lwd = 1)
>                        panel.superpose(x, y, ...)
>                    },
>                    type = c('b')
>                    )
> plot(test.plot)
>
> (this plot doesn't look good, I know, it's just and example)
> Thank you
> --
> Armin Goralczyk
> --
> http://www.gwdg.de/~agoralc
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
_

Baptiste Auguié

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

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

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


[R] Continue to finish for loop even there is an error in one of rounds.

2009-07-30 Thread Liao, Hongsheng
I am trying to fit a logistic model to my 10 year data (1999-2008) by year.  
Codes like below:

Year <- c(1999: 2008)
for(y in 1:length(year)) {
file.input <- paste("C:\\", year[y], "\\data.csv", sep="")
table <- read.csv(file=fileinput, header=TRUE, as.is=TRUE, na.strings=c(""))
initial <- getInitial(percent ~ SSlogis(age, Asym, xmid, scal), data = 
table)
fm1 <- nls(percent ~ SSlogis(age, Asym, xmid, scal), data = table)
summary <- summary(fm1)
parameters <- summary$parameters
file.output <- paste("C:\\", year[y], "\\parameters.csv", sep="")
write.csv(parameters, file=file.output, row.names=FALSE)
}

However, when one of 10 years can't be converged, such as 2000, the loop stops 
in that year (2000) even though the rest years (2001 to 2008) can be converged. 
I would really appreciate if someone helps me on how to force the loop function 
to finish all 10 rounds even when errors occur due to no convergences for some 
of years.


Hongsheng (Hank) Liao
Lab Manager
Center for Quantitative Fisheries Ecology
Old Dominion University
Phone: 757-683-4571




[[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] saving only part of a computation in integrate

2009-07-30 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of Mary A. Marion
> Sent: Thursday, July 30, 2009 12:56 PM
> To: r-help@r-project.org
> Subject: [R] saving only part of a computation in integrate
> 
> Hello,
> 
> I am using
> Beta <-integrate(dnorm,mean=0,sd=1,-Inf,2.3552)
>  > Beta
> 0.9907436 with absolute error < 4.2e-06
> 
> 1-Beta results in an error
> How can I store into Beta only .9907436?
> 
> Thank you.
> 
> Sincerely,
> Mary A. Marion
> 

Take a look at the results of 

str(Beta)

List of 5
 $ value   : num 0.99
 $ abs.error   : num 4.22e-06
 $ subdivisions: int 4
 $ message : chr "OK"
 $ call: language integrate(f = dnorm, lower = -Inf, upper = 2.3552, 
mean = 0,  sd = 1)
 - attr(*, "class")= chr "integrate"

So it would appear that you could do

Beta <-integrate(dnorm,mean=0,sd=1,-Inf,2.3552)$value

Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 only part of a computation in integrate

2009-07-30 Thread Erik Iverson
See ?str

> str(Beta)
List of 5
 $ value   : num 0.99
 $ abs.error   : num 4.22e-06
 $ subdivisions: int 4
 $ message : chr "OK"
 $ call: language integrate(f = dnorm, lower = -Inf, upper = 2.3552, 
mean = 0,  sd = 1)
 - attr(*, "class")= chr "integrate"

> Beta$value
[1] 0.9907436

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Mary A. Marion
Sent: Thursday, July 30, 2009 2:56 PM
To: r-help@r-project.org
Subject: [R] saving only part of a computation in integrate

Hello,

I am using
Beta <-integrate(dnorm,mean=0,sd=1,-Inf,2.3552)
 > Beta
0.9907436 with absolute error < 4.2e-06

1-Beta results in an error
How can I store into Beta only .9907436?

Thank you.

Sincerely,
Mary A. Marion

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] saving only part of a computation in integrate

2009-07-30 Thread Mary A. Marion

Hello,

I am using
Beta <-integrate(dnorm,mean=0,sd=1,-Inf,2.3552)
> Beta
0.9907436 with absolute error < 4.2e-06

1-Beta results in an error
How can I store into Beta only .9907436?

Thank you.

Sincerely,
Mary A. Marion

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


Re: [R] Re lative paths in R?

2009-07-30 Thread Glen Sargeant

See also file.path() and create.dir(). You can use them with getwd() and
setwd() to specify and/or create subdirectories, relative to your current
working directory.  Handy because they allow you to create paths and
directories with names derived within functions.

For example, I have used them to create output directories that reflect
dates when successive data summaries were prepared.

> #Current working directory is "c:\temp"
 
> #Creates a subdirectory, "data," relative
> #to current working directory
> wd <- getwd()
> sub <- file.path(wd,"data")
> dir.create(sub)
 
> #Changes working directory
> setwd(sub)
> getwd()
[1] "C:/temp/data"

> #Changes back
> setwd(wd)
> getwd()
[1] "C:/temp"
 


julien cuisinier wrote:
> 
> 
> 
> 
> 
> Dear list,
>  
>  
>  
> What I would like to achieve is to make this "PathUpload" relative to were
> R is at the time I launch it using the R CMD BATCH command
>  
> so I would end up with something like "PathUpload <- './uploads'" (as in
> php in this example)
>  
>  
> 
> 
> 
>   [[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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Relative-paths-in-R--tp24738390p24742361.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] Looping through R objects with $ operator and tags

2009-07-30 Thread baptiste auguie
essentially the same,

object1 = object2 = object3 = data.frame(Distance = 1:10)

foo = function(o){
within(get(o), LogDist <- log10(Distance))
}

my.objects = paste("object", 1:3,sep="")
lapply(my.objects, foo) 


It is however advisable to group the initial objects in a list, or in
a long format data.frame.

HTH,

baptiste

2009/7/30 jim holtman :
> I would first put the objects in a 'list' since it is easier to work
> with and then use 'lapply':
>
>> obj1 <- obj2 <- obj3 <- data.frame(Distance=1:10)
>> # create a list - earier to work with
>> list.obj <- list(obj1, obj2, obj3)
>>
>> list.obj <- lapply(list.obj, function(x){
> +     x$LogDist <- log(x$Distance)
> +     x   # return the modified value
> + })
>>
>> list.obj
> [[1]]
>   Distance   LogDist
> 1         1 0.000
> 2         2 0.6931472
> 3         3 1.0986123
> 4         4 1.3862944
> 5         5 1.6094379
> 6         6 1.7917595
> 7         7 1.9459101
> 8         8 2.0794415
> 9         9 2.1972246
> 10       10 2.3025851
>
> [[2]]
>   Distance   LogDist
> 1         1 0.000
> 2         2 0.6931472
> 3         3 1.0986123
> 4         4 1.3862944
> 5         5 1.6094379
> 6         6 1.7917595
> 7         7 1.9459101
> 8         8 2.0794415
> 9         9 2.1972246
> 10       10 2.3025851
>
> [[3]]
>   Distance   LogDist
> 1         1 0.000
> 2         2 0.6931472
> 3         3 1.0986123
> 4         4 1.3862944
> 5         5 1.6094379
> 6         6 1.7917595
> 7         7 1.9459101
> 8         8 2.0794415
> 9         9 2.1972246
> 10       10 2.3025851
>
>
>
> On Thu, Jul 30, 2009 at 12:04 PM, Vivek Ayer wrote:
>> Hi all,
>>
>> Suppose I want to set the values in a column to the log of the values
>> of another column like so:
>>
>> object$LogDist <- log10(object$Distance)
>>
>> How do I loop through the objects if I have object1, object2, etc to
>> perform this function?
>>
>> object1$LogDist <- log10(object1$Distance)
>> object2$LogDist <- log10(object2$Distance)
>> object3$LogDist <- log10(object3$Distance)
>>
>> I was trying to use the assign and paste functions like so:
>>
>> for (i in c(1:10))
>> assign(paste("object",i,"$LogDist"),log10(as.name(paste("object",i,"$LogDist")))
>>
>> but that didn't work out. It creates objects with whole name
>> object1$LogDist instead of just manipulating the column that's part of
>> that object.
>>
>> Help appreciated,
>> Vivek
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
_

Baptiste Auguié

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

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

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


[R] CRAN + geography = Cranography

2009-07-30 Thread Barry Rowlingson
In response to an earlier discussion about finding the
fastest/best/nearest CRAN site, I geocoded (using my geonames package)
the locations of the CRAN sites returned by getCRANmirrors. I've
mapped them here:

http://www.maths.lancs.ac.uk/~rowlings/R/Cranography/

The geocoding may have got it wrong, so if CRAN site maintainers want
to send me a real lat-long (in WGS 84 aka EPSG:4326) I'll update my
map. Maybe eventually lat-long can go in the CRAN csv file distributed
with R.

Note this is just for fun. No warranties. Maybe I should use a little
'R' as a marker. Maybe I should get a life.

Barry

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


Re: [R] (no subject)

2009-07-30 Thread jim holtman
Exactly why are you trying to load it into the editor?  What happens
when you execute 'library(lattice)' at the command line?  Is there an
error message associated with it?  Here is what I get:

> library(lattice)
>

It loads just fine.

On Thu, Jul 30, 2009 at 11:08 AM, Stein, Luba (AIM
SE) wrote:
> I try to load the package lattice by library(lattice).
>
> Although I have installed it through CRAN by internet as well as from a local 
> directory using the zip-file, it can't be loaded into the editor.
>
> Can anyone give advice, please.
>
> I am using R 2.9.1 on Widows XP.
>
> Thanks a lot,
>
> Luba
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] Looping through R objects with $ operator and tags

2009-07-30 Thread jim holtman
I would first put the objects in a 'list' since it is easier to work
with and then use 'lapply':

> obj1 <- obj2 <- obj3 <- data.frame(Distance=1:10)
> # create a list - earier to work with
> list.obj <- list(obj1, obj2, obj3)
>
> list.obj <- lapply(list.obj, function(x){
+ x$LogDist <- log(x$Distance)
+ x   # return the modified value
+ })
>
> list.obj
[[1]]
   Distance   LogDist
1 1 0.000
2 2 0.6931472
3 3 1.0986123
4 4 1.3862944
5 5 1.6094379
6 6 1.7917595
7 7 1.9459101
8 8 2.0794415
9 9 2.1972246
10   10 2.3025851

[[2]]
   Distance   LogDist
1 1 0.000
2 2 0.6931472
3 3 1.0986123
4 4 1.3862944
5 5 1.6094379
6 6 1.7917595
7 7 1.9459101
8 8 2.0794415
9 9 2.1972246
10   10 2.3025851

[[3]]
   Distance   LogDist
1 1 0.000
2 2 0.6931472
3 3 1.0986123
4 4 1.3862944
5 5 1.6094379
6 6 1.7917595
7 7 1.9459101
8 8 2.0794415
9 9 2.1972246
10   10 2.3025851



On Thu, Jul 30, 2009 at 12:04 PM, Vivek Ayer wrote:
> Hi all,
>
> Suppose I want to set the values in a column to the log of the values
> of another column like so:
>
> object$LogDist <- log10(object$Distance)
>
> How do I loop through the objects if I have object1, object2, etc to
> perform this function?
>
> object1$LogDist <- log10(object1$Distance)
> object2$LogDist <- log10(object2$Distance)
> object3$LogDist <- log10(object3$Distance)
>
> I was trying to use the assign and paste functions like so:
>
> for (i in c(1:10))
> assign(paste("object",i,"$LogDist"),log10(as.name(paste("object",i,"$LogDist")))
>
> but that didn't work out. It creates objects with whole name
> object1$LogDist instead of just manipulating the column that's part of
> that object.
>
> Help appreciated,
> Vivek
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] USGS stream flow data automatic download R

2009-07-30 Thread Felipe Carrillo

An Excel Web query will also do what you want. From an Excel Workbook create a 
web query and link it to the USGS website. You can schedule downloads or the 
query will download data up-to-date everytime the workbook is open.


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


--- On Wed, 7/29/09, stephen sefick  wrote:

> From: stephen sefick 
> Subject: Re: [R] USGS stream flow data automatic download R
> To: thomas.ad...@noaa.gov
> Cc: r-help@r-project.org
> Date: Wednesday, July 29, 2009, 6:23 PM
> Instantaneous Data, mean flow data
> could be a start.  That would be
> wonderful if you would send it to me.
> 
> Stephen Sefick
> 
> On Wed, Jul 29, 2009 at 8:20 PM, 
> wrote:
> > Stephen,
> >
> > I don't have anything or know of anything in R to do
> this. But, we download USGS streamflow data routinely. I
> have a Perl script that will reformat the downloaded data
> into a R-importable format (basically two columns date/time
> flow value). Are you interested in mean daily or
> instantaneous streamflow data?
> >
> > Regards,
> > Tom
> >
> > - Original Message -
> > From: stephen sefick 
> > Date: Wednesday, July 29, 2009 9:03 pm
> > Subject: [R] USGS stream flow data automatic download
> R
> >
> >> I don't even know if this is the right place to
> ask this question.  I
> >> would like to download USGS stream gauging data
> for a couple of gauges
> >> on a daily basis- save the files to .csv files and
> append the nest
> >> days time series to this.  Is there a way to do
> this automatically in
> >> R?
> >> thanks,
> >>
> >> --
> >> Stephen Sefick
> >>
> >> Let's not spend our time and resources thinking
> about things that are
> >> so little or so large that all they really do for
> us is puff us up and
> >> make us feel like gods.  We are mammals, and have
> not exhausted the
> >> annoying little problems of being mammals.
> >>
> >>                                  
>                             -K. Mullis
> >>
> >> __
> >> R-help@r-project.org
> mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide http://www.R-project.org/posting-
> >> guide.htmland provide commented, minimal,
> self-contained,
> >> reproducible code.
> >>
> >
> 
> 
> 
> -- 
> Stephen Sefick
> 
> Let's not spend our time and resources thinking about
> things that are
> so little or so large that all they really do for us is
> puff us up and
> make us feel like gods.  We are mammals, and have not
> exhausted the
> annoying little problems of being mammals.
> 
>            
>            
>         -K. Mullis
> 
> __
> R-help@r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 




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


[R] Looping through R objects with $ operator and tags

2009-07-30 Thread Vivek Ayer
Hi all,

Suppose I want to set the values in a column to the log of the values
of another column like so:

object$LogDist <- log10(object$Distance)

How do I loop through the objects if I have object1, object2, etc to
perform this function?

object1$LogDist <- log10(object1$Distance)
object2$LogDist <- log10(object2$Distance)
object3$LogDist <- log10(object3$Distance)

I was trying to use the assign and paste functions like so:

for (i in c(1:10))
assign(paste("object",i,"$LogDist"),log10(as.name(paste("object",i,"$LogDist")))

but that didn't work out. It creates objects with whole name
object1$LogDist instead of just manipulating the column that's part of
that object.

Help appreciated,
Vivek

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


Re: [R] Object equality for S4 objects

2009-07-30 Thread Martin Morgan
Hi Stavros --

Stavros Macrakis  writes:

> To test two environments for object equality (Lisp EQ), I can use 'identity':
>
>> e1 <- environment(local(function()x))
>> e2 <- environment(local(function()x))
>> identical(e1,e2)  # compares object identity
> [1] FALSE
>> identical(as.list(e1),as.list(e2))# compares values as name->value 
>> mapping
> [1] TRUE# (is there a better way to do this?)
>
> What is the corresponding function for testing whether two S4 objects
> are the same object?  It appears that 'identity' for S4 objects
> compares the *value*, not the *object identity*:

Hi Stavros

S4 objects do not have the semantics of environments, but of lists (or
of most other R objects), so it is as meaningful to ask why
identical(s1, s2) returns TRUE as it is to ask why
identical(list(x=1), list(x=1)) returns TRUE.

Martin

>> setClass("simple",representation(a="logical"))
> [1] "simple"
>> s1 <- new("simple"); s2 <- new("simple")
>> identical(s1,s1)
> [1] TRUE   # not surprising
>> identical(s1,s2)
> [1] TRUE   # ? not comparing object identity
>> s...@a <- TRUE
>> s...@a <- TRUE
>> identical(s1,s2)
> [1] TRUE
>> s...@a <- TRUE
>> s...@a <- FALSE
>> identical(s1,s2)
> [1] FALSE
>
> Thanks,
>
>   -s
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

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


Re: [R] Plotting two overlapping curves

2009-07-30 Thread Dimitris Rizopoulos

one way is the following:

x <- seq(-2, 2, len = 11)
y1 <- 2*x^2 + 3*x + 1
y2 <- - 2*x^2 - 3*x + 1

plot(x, y1, type = "l", col = "red", ylim = range(y1, y2))
lines(x, y2, col = "blue")


I hope it helps.

Best,
Dimitris


njhuang86 wrote:

Hi. Sorry if this question might have already been asked... I'm trying to
plot two curves on the same X-Y coordinate. The par(mfrow) command allows me
to plot the two curves on the same window however on different coordinate
systems. Is there a way to force the two curves into the same coordinate
system? Anyways, thanks in advance!


--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

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

2009-07-30 Thread njhuang86

Hi. Sorry if this question might have already been asked... I'm trying to
plot two curves on the same X-Y coordinate. The par(mfrow) command allows me
to plot the two curves on the same window however on different coordinate
systems. Is there a way to force the two curves into the same coordinate
system? Anyways, thanks in advance!
-- 
View this message in context: 
http://www.nabble.com/Plotting-two-overlapping-curves-tp24740989p24740989.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] Superscripts and rounding

2009-07-30 Thread ehux



I'd need access to the whole data file.  I tried exporting some data from
the website for it but it got too complex for me!  (oh right you need the
HYDAT package - sorry about that) =)

However, it seems to me you have two chunks of data: you got it!!! 

stn[flow] - which has daily flow data in it? Correct
stn[metadata] which i guess is a header for the whole dataset -describing
what it is. Correct


Below is a small section of the data. I tried copying and pasting your new
sub = code but i still get the same error. It is so weird it should work the
logic is there!!! 

> str(Lyons)
List of 3
 $ metadata:List of 7
  ..$ id   : chr "11AB075"
  ..$ name : chr "LYONS CREEK AT INTERNATIONAL BOUNDARY"
  ..$ latitude : num 49
  ..$ longitude: num -109
  ..$ provstate: chr "SK"
  ..$ grossarea: num 174
  ..$ effectivearea: num 136
 $ flow:List of 7
  ..$ daily   :'data.frame':28124 obs. of  3 variables:
  .. ..$ date :Class 'Date'  num [1:28124] -15706 -15705 -15704 -15703
-15702 ...
  .. ..$ value: num [1:28124] NA NA NA NA NA NA NA NA NA NA ...
  .. ..$ flag : Factor w/ 4 levels "","B","E","A": 1 1 1 1 1 1 1 1 1 1 ...
  ..$ monthly :'data.frame':924 obs. of  4 variables:
  .. ..$ year : int [1:924] 1927 1927 1927 1927 1927 1927 1927 1927 1927
1927 ...
  .. ..$ month: int [1:924] 1 2 3 4 5 6 7 8 9 10 ...
  .. ..$ value: num [1:924] NA NA 0.466 2.49 1.46 ...
  .. ..$ flag : Factor w/ 1 level "": 1 1 1 1 1 1 1 1 1 1 ...
  ..$ annual  :'data.frame':19 obs. of  3 variables:
  .. ..$ year : num [1:19] 1930 1931 1932 1933 1934 ...
  .. ..$ value: num [1:19] 0.167 0 0.004 0 0.04 ...
  .. ..$ flag : chr [1:19] "" "" "" "" ...
  ..$ annual.maxima   :'data.frame':77 obs. of  3 variables:
  .. ..$ date :Class 'Date'  num [1:77] -15564 -15249 -14821 -14519 -14245
...
  .. ..$ value: num [1:77] 14.3 10.7 0.603 10.7 0 ...
  .. ..$ flag : chr [1:77] "" "B" "" "B" ...
  ..$ annual.minima   :'data.frame':77 obs. of  3 variables:
  .. ..$ date :Class 'Date'  num [1:77] -15647 -15281 -14916 -14610 -14245
...
  .. ..$ value: num [1:77] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ flag : chr [1:77] "" "B" "" "" ...
  ..$ instantaneous.maxima:'data.frame':62 obs. of  4 variables:
  .. ..$ date: chr [1:62] "1927-04-03 19:00:00" "1928-04-02 00:00:00"
"1929-06-11 00:00:00" "1930-04-02 07:00:00" ...
  .. ..$ timezone: chr [1:62] "MS" "  " "  " "MS" ...
  .. ..$ value   : num [1:62] 18.9 15.8 0.796 12.4 0.708 ...
  .. ..$ flag: chr [1:62] "" "B" "" "B" ...
  ..$ daily.flag.summary  :List of 2
  .. ..$ by.year  :'data.frame':77 obs. of  6 variables:
  .. .. ..$ year   : num [1:77] 1927 1928 1929 1930 1931 ...
  .. .. ..$ A  : int [1:77] 0 0 0 0 0 0 0 0 0 0 ...
  .. .. ..$ B  : int [1:77] 12 40 0 61 0 0 0 51 0 0 ...
  .. .. ..$ E  : int [1:77] 0 2 1 3 0 0 0 0 0 0 ...
  .. .. ..$ MISSING: int [1:77] 120 118 59 0 0 0 0 0 0 0 ...
  .. .. ..$ NOFLAG : int [1:77] 233 206 305 301 365 366 365 314 365 366 ...
  .. ..$ by.month.year:'data.frame':924 obs. of  7 variables:
  .. .. ..$ year   : num [1:924] 1927 1927 1927 1927 1927 ...
  .. .. ..$ month  : num [1:924] 1 2 3 4 5 6 7 8 9 10 ...
  .. .. ..$ A  : int [1:924] 0 0 0 0 0 0 0 0 0 0 ...
  .. .. ..$ B  : int [1:924] 0 0 0 12 0 0 0 0 0 0 ...
  .. .. ..$ E  : int [1:924] 0 0 0 0 0 0 0 0 0 0 ...
  .. .. ..$ MISSING: int [1:924] 31 28 0 0 0 0 0 0 0 0 ...
  .. .. ..$ NOFLAG : int [1:924] 0 0 31 18 31 30 31 31 30 31 ...
 $ level   : NULL
>  
 
$flow$daily
   date value flag
22536 1988-09-12  0.000 
22537 1988-09-13  0.000 
22538 1988-09-14  0.000 
22539 1988-09-15  0.000 
22540 1988-09-16  0.000 
22541 1988-09-17  0.000 
22542 1988-09-18  0.000 
22543 1988-09-19  0.000 
22544 1988-09-20  0.000 
22545 1988-09-21  0.000 
22546 1988-09-22  0.000 
22547 1988-09-23  0.000 
22548 1988-09-24  0.000 

$flow$monthly
year month value flag
1   1927 1NA 
2   1927 2NA 
3   1927 3 0.466 
4   1927 4 2.490 
5   1927 5 1.460 
6   1927 6 0.042 
7   1927 7 0.318 
8   1927 8 0.020 
9   1927 9 0.000 
10  192710 0.000 
11  192711NA 
12  192712NA 
13  1928 1NA 
14  1928 2NA 
15  1928 3 0.184 
16  1928 4 1.200 
17  1928 5 0.008 
18  1928 6 0.000 
19  1928 7 0.000 

$flow$annual
   year value flag
1  1930 0.167 
2  1931 0.000 
3  1932 0.004 
4  1933 0.000 
5  1934 0.040 
6  1935 0.072 
7  1936 0.061 
9  1937NA 
10 1938NA 
11 1939NA 
12 1940NA 

$flow$annual.maxima
 date  value flag
1  1927-05-23 14.300 
2  1928-04-02 10.700B
3  1929-06-04  0.603 
4  1930-04-02 10.700B
5  1931-01-01  0.000 
6  1932-06-11  0.362 
7  1933-01-01  0.000 
8  1934-03-03

Re: [R] PDF Compression

2009-07-30 Thread Stephen Tucker

There was a previous post about this also:
http://tolstoy.newcastle.edu.au/R/e2/help/07/05/17475.html

I was able to use bitmap(,type="pdfwrite") on Ubuntu Linux but had trouble 
getting it to work on Windows. 
For now, it's kind of kludgey but I have in my .Rprofle (or .Rprofile.site on 
Windows):

compressPDF <- function(x) {
  system(paste("pdftk",x,"output",sub("\\.pdf","c.pdf",x),
   "compress dont_ask"))
  unlink(x)
}

so after I plot something I would call compressPDF() on the same pdf file
pdf("plot.pdf"); plot(1:10); dev.off()
compressPDF("plot.pdf")

which renames it from 'plot.pdf' to 'plotc.pdf' to remind myself that I already 
compressed it...

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


[R] (no subject)

2009-07-30 Thread Stein, Luba (AIM SE)
I try to load the package lattice by library(lattice).

Although I have installed it through CRAN by internet as well as from a local 
directory using the zip-file, it can't be loaded into the editor.

Can anyone give advice, please.

I am using R 2.9.1 on Widows XP.

Thanks a lot,

Luba





[[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] R User Group listings

2009-07-30 Thread Armin Goralczyk
On Thu, Jul 30, 2009 at 2:33 PM, Prof. John C Nash wrote:
> There are now several R geographic user groups, and a few have mailing lists
> on the R mailing list system. Thanks to Martin M, there's also a pointer to
> a page I'm maintaining to list/describe the groups. The page is at
>
> http://macnash.telfer.uottawa.ca/RUG.html
>
>
> Contact me if you have a listing. I'm prepared to wikify it if there is
> sufficient interest.
>
> John Nash

Does anybody know if there is an R geographic user group in germany?
(found none by ggogle search)

-- 
Armin Goralczyk
--
http://www.gwdg.de/~agoralc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] package lattice can't be loeaded

2009-07-30 Thread Stein, Luba (AIM SE)
I try to load the package lattice by library(lattice).
Although I have installed it through CRAN by internet as well as from a local 
directory using the zip-file, it can't be loaded into the editor.

Can anyone give advice, please.
I am using R 2.9.1 on Widows XP.

Thanks a lot,
Luba





[[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] dynamic network analysis

2009-07-30 Thread cir p

Dear group,
I am browsing the web to find suitable software for dynamic network analysis. I 
came across the sna-package under R, but this seems to do static analysis only. 
Is this right? Or is there a separate package for dynamic network analysis?
Thanks

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


Re: [R] PDF Compression

2009-07-30 Thread Frank E Harrell Jr

Eduardo Leoni wrote:

PDF created by R is in vector format. If you really want smaller files
you can try creating PNGs instead. With a high enough resolution (e.g.
dpi=600) there won't be much difference in the printed version of your
document.

-eduardo
  


Eduardo,

It is not a good idea in general to use a non-scalable graphics 
solution.  In general png can be larger than pdf but other disadvantages 
are more important.


When I have created curves in R that are composed of thousands of data 
points, the compression of pdf I've achieved with pdftk has been amazing.


Frank




On Thu, Jul 30, 2009 at 7:55 AM, Benno Pütz wrote:
  

Thanks for this advice - and to second Gabor's experience: I just
tried it on a couple of my files and achieved reductions on the order
of 90% (28.6MB to 4.4MB and 1.5GB to 170MB)!

This file contains lots of small plots but also many scattersmooth()-
images ...

So I think it does quite well in my case.

   Benno

Am 30.Jul.2009 um 12:21 schrieb Gabor Grothendieck:



I just tried it with a recent pdf that was generated from R on
Windows Vista
with "R version 2.9.1 Patched (2009-07-16 r48939)".  This particular
one
was laden with many graphs and was reduced to 25% of the original
size so my experience with that one was that it made a huge
difference.

On Thu, Jul 30, 2009 at 5:59 AM, David
Keegan wrote:
  

Gabor,

Thanks for the suggestion. I tried pdftk but it made very
little difference.

Regards,
David.
--
[David Keegan david.kee...@shenick.com 353 1 2710818]
Gabor Grothendieck writes:
 > After generating the pdf try this using the free pdftk utilty:
 >
 >pdftk infile.pdf output outfile.pdf compress
 >
 > On Thu, Jul 30, 2009 at 5:13 AM, David Keegan

wrote:
  

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

  



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

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


[R] R 2.9.1: Error building target 'front'

2009-07-30 Thread Loris Bennett
Hi,

I am getting the following error

   # (R-2.9.1/src/library/methods): gmake front

   /bin/sh: 0403-057 Syntax error at line 1 : `;' is not expected.
   gmake: *** [front] Error 2

However, I am not sure what script sh is trying to execute at this
point. I am building on AIX 5.3.

Cheers,

Loris

-- 
Dr. Loris Bennett
Computer Centre
Freie Universität Berlin
Berlin, Germany

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


Re: [R] PDF Compression

2009-07-30 Thread Eduardo Leoni
PDF created by R is in vector format. If you really want smaller files
you can try creating PNGs instead. With a high enough resolution (e.g.
dpi=600) there won't be much difference in the printed version of your
document.

-eduardo



On Thu, Jul 30, 2009 at 7:55 AM, Benno Pütz wrote:
> Thanks for this advice - and to second Gabor's experience: I just
> tried it on a couple of my files and achieved reductions on the order
> of 90% (28.6MB to 4.4MB and 1.5GB to 170MB)!
>
> This file contains lots of small plots but also many scattersmooth()-
> images ...
>
> So I think it does quite well in my case.
>
>        Benno
>
> Am 30.Jul.2009 um 12:21 schrieb Gabor Grothendieck:
>
>> I just tried it with a recent pdf that was generated from R on
>> Windows Vista
>> with "R version 2.9.1 Patched (2009-07-16 r48939)".  This particular
>> one
>> was laden with many graphs and was reduced to 25% of the original
>> size so my experience with that one was that it made a huge
>> difference.
>>
>> On Thu, Jul 30, 2009 at 5:59 AM, David
>> Keegan wrote:
>>> Gabor,
>>>
>>> Thanks for the suggestion. I tried pdftk but it made very
>>> little difference.
>>>
>>> Regards,
>>> David.
>>> --
>>> [David Keegan david.kee...@shenick.com 353 1 2710818]
>>> Gabor Grothendieck writes:
>>>  > After generating the pdf try this using the free pdftk utilty:
>>>  >
>>>  >    pdftk infile.pdf output outfile.pdf compress
>>>  >
>>>  > On Thu, Jul 30, 2009 at 5:13 AM, David Keegan>> > wrote:
>>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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