[R] Unable to compile & install rggobi

2012-04-27 Thread Indrajit Sengupta
I am currently using R 2.15.0 with R Tools 2.15 (in Windows XP). I downloaded 
the source for RGgobi and extracted it to a folder.
 
Then I tried compiling and installing with the following command and got an 
error message:
--
D:\Work\tmp>R CMD INSTALL --build "D:\\DPF\\Rggobi\\rggobi"
* installing to library 'C:/Program Files/R/R-2.15.0/library'
* installing *source* package 'rggobi' ...
** libs
cygwin warning:
  MS-DOS style path detected: C:/PROGRA~1/R/R-215~1.0/etc/i386/Makeconf
  Preferred POSIX equivalent is: 
/cygdrive/c/PROGRA~1/R/R-215~1.0/etc/i386/Makeconf
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gcc  -I"C:/PROGRA~1/R/R-215~1.0/include" -DNDEBUG -D_R_=1 -DUSE_R=1 
-mms-bitfields -I/include/gtk-2.0 -I/include/gdk-pixbuf-2.0 
-I/../lib/gtk-2.0/include -
I/include/atk-1.0 -I/include/cairo -I/include/pango-1.0 -I/include/glib-2.0 
-I/../lib/glib-2.0/include -I/include/libxml2 -I/include -I/include/ggobi -IC:/
PROGRA~1/R/R-215~1.0/include -I/include/libxml -O3 -Wall  -std=gnu99 
-mtune=core2 -c RSEval.c -o RSEval.o
In file included from RSEval.c:6:0:
RSGGobi.h:5:22: fatal error: GGobiAPI.h: No such file or directory
compilation terminated.
make: *** [RSEval.o] Error 1
ERROR: compilation failed for package 'rggobi'
* removing 'C:/Program Files/R/R-2.15.0/library/rggobi'
--
 
Can anybody help in figuring out what is the problem? I have installed GGobi & 
RGtk2 previously.
 
Regards,
Indrajit
[[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] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-27 Thread Martin Maechler
> David Winsemius 
> on Mon, 23 Apr 2012 12:16:39 -0400 writes:

> On Apr 23, 2012, at 12:10 PM, Paul Miller wrote:

>> Hello All,
>> 
>> Started out awhile ago trying to select columns in a
>> dataframe whose names contain some variation of the word
>> "mutant" using code like:
>> 
>> names(KRASyn)[grep("muta", names(KRASyn))]
>> 
>> The idea then would be to add together the various
>> columns using code like:
>> 
>> KRASyn$Mutant_comb <- rowSums(KRASyn[grep("muta",
>> names(KRASyn))])
>> 
>> What I discovered though, is that this selects columns
>> like "nonmutated" and "unmutated" as well as columns like
>> "mutated", "mutation", and "mutational".
>> 
>> So I'd like to know how to select columns that have some
>> variation of the word "mutant" without the "non" or the
>> "un". I've been looking around for an example of how to
>> do that but haven't found anything yet.
>> 
>> Can anyone show me how to select the columns I need?

> If you want only columns whose names _begin_ with "muta"
> then add the "^" character at the beginning of your
> pattern:

> names(KRASyn)[grep("^muta", names(KRASyn))]

> (This should be explained on the ?regex page.)

It *is* !Search for "beginning" and you're there.
Martin

> David Winsemius, MD West Hartford, CT

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


Re: [R] print table on plot

2012-04-27 Thread Jim Lemon

On 04/26/2012 11:26 PM, statquant2 wrote:

Hello,
I would like to be able to plot an array on a plot, something like:
 |arg1  | arg2 | arg3
val1| 0.9| 1.1| 2.4
val2| 0.33  | 0.23 | -1.4
val3| hello| stop | test
I know Rwave is good to report but don't want to use it.

? Is there a package that allow quick and dirty plot of dataframes like this
?


Hi statquant2,
Well, there is:

tablemat<-matrix(c(0.9,1.1,2.4,0.33,0.23,-1.4,"hello","stop","test"),
 ncol=3)
rownames(tablemat)<-c("val1","val2","val3")
colnames(tablemat)<-c("arg1","arg2","arg3")
plot(5:1)
library(plotrix)
addtable2plot(3,4,tablemat,vlines=TRUE,display.rownames=TRUE)

Jim

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


Re: [R] Unable to compile & install rggobi

2012-04-27 Thread Prof Brian Ripley

On 27/04/2012 08:56, Indrajit Sengupta wrote:

I am currently using R 2.15.0 with R Tools 2.15 (in Windows XP). I downloaded 
the source for RGgobi and extracted it to a folder.

Then I tried compiling and installing with the following command and got an 
error message:
--
D:\Work\tmp>R CMD INSTALL --build "D:\\DPF\\Rggobi\\rggobi"
* installing to library 'C:/Program Files/R/R-2.15.0/library'
* installing *source* package 'rggobi' ...
** libs
cygwin warning:
   MS-DOS style path detected: C:/PROGRA~1/R/R-215~1.0/etc/i386/Makeconf
   Preferred POSIX equivalent is: 
/cygdrive/c/PROGRA~1/R/R-215~1.0/etc/i386/Makeconf
   CYGWIN environment variable option "nodosfilewarning" turns off this warning.
   Consult the user's guide for more details about POSIX paths:
 http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gcc  -I"C:/PROGRA~1/R/R-215~1.0/include" -DNDEBUG -D_R_=1 -DUSE_R=1 
-mms-bitfields -I/include/gtk-2.0 -I/include/gdk-pixbuf-2.0 -I/../lib/gtk-2.0/include -
I/include/atk-1.0 -I/include/cairo -I/include/pango-1.0 -I/include/glib-2.0 
-I/../lib/glib-2.0/include -I/include/libxml2 -I/include -I/include/ggobi -IC:/
PROGRA~1/R/R-215~1.0/include -I/include/libxml -O3 -Wall  -std=gnu99 
-mtune=core2 -c RSEval.c -o RSEval.o
In file included from RSEval.c:6:0:
RSGGobi.h:5:22: fatal error: GGobiAPI.h: No such file or directory
compilation terminated.
make: *** [RSEval.o] Error 1
ERROR: compilation failed for package 'rggobi'
* removing 'C:/Program Files/R/R-2.15.0/library/rggobi'
--

Can anybody help in figuring out what is the problem? I have installed GGobi&  
RGtk2 previously.


You need to set some environment variables: study the rggobi sources for 
what. E.g. I bet GGobi is not installed in the root, so -I/include/ggobi 
will not work.



Regards,
Indrajit
[[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.


Please do as you were asked: no HTML, programming questions to R-devel, 
questions about packages to the maintainer 


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

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


Re: [R] random effects in library mgcv

2012-04-27 Thread Mabille, Geraldine
Thanks Simon for your help again on those points. Just a last thing, regarding 
the third question:
If the gm1 model has a lower AIC than the gm model, does that mean that we 
should "select" for it?? As you said, I think both these models are doing the 
same job (i.e. testing that the three smooth are different from zero), so the 
part of deviance explain by both should be similar, and the difference in AIC 
we obtained is only due to the fact that creating a smooth of the difference to 
the reference model needs less degrees of freedom than creating a totally "new" 
smooth???
Am I interpreting those things right???
Cheers,
Geraldine 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Simon Wood
Sent: 26. april 2012 19:28
To: r-help@r-project.org
Subject: Re: [R] random effects in library mgcv

On 25/04/12 14:02, Mabille, Geraldine wrote:
> Hi, I am working with gam models in the mgcv library. My response 
> variable (Y) is binary (0/1), and my dataset contains repeated 
> measures over 110 individuals (same number of 0/1 within a given
> individual: e.g. 345-zero and 345-one for individual A, 226-zero and 
> 226-one for individual B, etc.). The variable Factor is separating the 
> individuals in three groups according to mass (group 0,1,2),
> Factor1 is a binary variable coding for individuals of group1,
> Factor2 is a binary variable for individuals of group 2 I use gam 
> models of this sort with random effects coded using a s( ...,
> bs="re") term: gm<-gam(Y~Factor+te(x1,x2,by=Factor)
> )+s(Individual,bs="re"),dat=Data,family=binomial(link=logit),method="R
> EML")
>
>
>
gm1<-gam(Y~Factor+te(x1,x2)+ te(x1,x2,by=Factor1)+
te(x1,x2,by=Factor2)+s(Individual,bs="re"),dat=Data,family=binomial(link=logit),method="REML")
>
> 1)First question: is it OK to use gam() to model a binary variable 
> with random effects coded as a "bs="re" term"?? I have read that the
> gamm4() function gives better performance than gamm() to deal with 
> binary variables when random effects are coded as:
> random=~(1|Individual) but does that mean that binary variables should 
> not be used as response variable in gam() with random effects coded as 
> bs="re"???
-- It's fine to use 'gam'. The problem with gamm, is that it uses PQL, which 
can perform poorly in the binary case (mostly related to estimating the scale 
parameter rather than treating it as fixed). Both gam and gamm4 use a Laplace 
approximation that behaves much better that PQL in the binary case.


> 2)Second question: For some models, I obtain a p-value=NA and
> Chi-square=0 for the s(Individual) term, and for some other models a
> p-value=1 and high Chi-square. The difference between one model that 
> can estimate a p-value and one that cannot is very slight: for example 
> if I use a variable x3 instead of x2 in a model, it can change from 
> p-value=NA to p-value=1. Does anyone know what can be happening?
>
-- basically both cases are providing the same information --- that the 
corresponding term is not need in the model. In the first case the term is 
estimated to be so close to zero that it makes no sense to compute a p-value, 
while in the second case the term has been estimated to be non-zero, but not 
*significantly* different from zero at any level.


> 3)Third question: Not linked to random effects but rather to what the 
> two models gm and gm1 are actually testing. From my understanding, the 
> first model creates a 2d-smooth for each level of my factor variable 
> and test whether those smooth are significantly different from a 
> straight line.
-- from zero, if I understand the model right.


> The second model, also creates 3
> smooth: one for the reference level of my Factor variable (group0), 
> one showing the difference between the reference smooth and the smooth 
> for group1, one showing the difference between the reference smooth 
> and the smooth for group 2. The summary(gm1) gives p-values associated 
> with each of those three smooths and which determine:  if the 
> reference smooth is different from 0, if the smooth for group1 is 
> different from the reference smooth and  if the smooth for group2 is 
> different from the reference smooth. Do I understand well what the 
> models are testing?
-- sounds right to me.

>The number of "edf" estimated for
> te(x1,x2):Factor2 in the gm1 model is 3,013 while it is 19,57 in the  
>gm model. Does that mean that the difference between the reference
> smooth: te(x1,x2) and the smooth for group 2: te(x1,x2, by=Factor2)  
>is "small" so it can be modeled with only 3 degrees of freedom?
-- "smooth", rather than "small". The difference could be very large, but vary 
smoothly with x1, x2.

> Still, the associated p-value is highly significant?
... since the terms is significantly different from zero.


> When comparing
> AIC between the gm and gm1 models, I find sometimes that gm1 has a 
> lower AIC than gm.  How can that be interpreted??
-- th

Re: [R] print table on plot

2012-04-27 Thread statquant2
Thank you all.
addtable2plot seem to be the best solution visually speaking.

++

--
View this message in context: 
http://r.789695.n4.nabble.com/print-table-on-plot-tp4589804p4591958.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] Subsetting dataframe with missing values

2012-04-27 Thread Petr PIKAL
Hi


> 
> Dear R-community, 
> 
> I am using R (V 2.14.1) on Windows 7. I have a dataset which consists of 
19
> variables for 91 individuals or rows. Two of my variables are Age
> (adult/chick, with no NA values) and Sex (0 for females/1 for females, 
with
> quite a few NA values). The sex of many adult birds is unknown (entered 
as
> NA in dataframe). At some point of my analyses, I happen to need to need 
to
> work with only male adults, so I tried subsetting the dataframe as 
follows
> (see code below) but I get a new dataframe containing all the males but 
also
> a lot of unneeded information such as data in rows 1-7 (NAs), 13, 14, 19 
and
> 21-30. I suspect this is caused by NAs in the variable Sex because
> everything goes fine (I get a dataframe containing adults) if I run the 
same
> code but without the "& Data$Sex == 1" part. 
> 
> How can I fix this problem? I there a straightforward way of subsetting
> efficiently when NAs are present in the original dataset? 
> Thank you so much!

I usually do it in 2 lines

selection<- which(Data$Category == "Adult" & Data$Sex == 1)
Data[selection, ]

could be what you want.

Or you can do

adult.males <- adult.males[!is.na(adult.males$Sex),]

Regards
Petr


> 
> Luciano 
> 
> adult.males <- Data[Data$Category == "Adult" & Data$Sex == 1,] 
> adult.males
> 
>  ID Category Sex  Beak   Head 
> NANANA NA 
> NA.1  NANA NA 
> NA.2  NANA NA 
> NA.3  NANA NA 
> NA.4  NANA NA 
> NA.5  NANA NA 
> NA.6  NANA NA 
> 9 LAA10Adult   1 57.40 121.95 
> 10LAA11Adult   1 56.40 113.00 
> 11LAA12Adult   1 52.00 111.85 
> 13LAA14Adult   1 56.55 124.85 
> 15LAA16Adult   1 57.15 120.10 
> NA.7  NANA NA 
> NA.8  NANA NA 
> 21LAA22Adult   1 56.85 117.35 
> 22LAA23Adult   1 54.80 117.45 
> 27LAA28Adult   1 59.00 116.75 
> 28LAA29Adult   1 55.95 124.25 
> NA.9  NANA NA 
> 30LAA31Adult   1 57.70 112.80 
> NA.10 NANA NA 
> NA.11 NANA NA 
> NA.12 NANA NA 
> NA.13 NANA NA 
> NA.14 NANA NA 
> NA.15 NANA NA 
> NA.16 NANA NA 
> NA.17 NANA NA 
> NA.18 NANA NA 
> NA.19 NANA NA
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] phone number extraction

2012-04-27 Thread R. Michael Weylandt
What is a "verbatim"?

This came up three days ago on this very list:
https://stat.ethz.ch/pipermail/r-help/2012-April/310815.html

The short answer is that you need this regex: pat <- "[-0-9]{10,12}"

Michael

On Fri, Apr 27, 2012 at 1:23 AM, antony  wrote:
> Hi,
>
> How can I extract the phone numbers( consecutive 10 digits or in a pattern
> like 3digits-3digits-4digits) from a verbatim?
> Thanks in advance for any help...
>
> Antony
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/phone-number-extraction-tp4591802p4591802.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] random effects in library mgcv

2012-04-27 Thread Simon Wood

Geraldine,

I think that you are interpreting correctly. Since fewer effective 
degrees of freedom for essentially the same fit should lead to slightly 
improved precision, then you might expect slightly better prediction 
error performance for the model with fewer degrees of freedom, which is 
what the AIC score is picking up on.


best,
Simon

On 27/04/12 09:46, Mabille, Geraldine wrote:

Thanks Simon for your help again on those points. Just a last thing, regarding 
the third question:
If the gm1 model has a lower AIC than the gm model, does that mean that we should 
"select" for it?? As you said, I think both these models are doing the same job (i.e. 
testing that the three smooth are different from zero), so the part of deviance explain by both 
should be similar, and the difference in AIC we obtained is only due to the fact that creating a 
smooth of the difference to the reference model needs less degrees of freedom than creating a 
totally "new" smooth???
Am I interpreting those things right???
Cheers,
Geraldine

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Simon Wood
Sent: 26. april 2012 19:28
To: r-help@r-project.org
Subject: Re: [R] random effects in library mgcv

On 25/04/12 14:02, Mabille, Geraldine wrote:

Hi, I am working with gam models in the mgcv library. My response
variable (Y) is binary (0/1), and my dataset contains repeated
measures over 110 individuals (same number of 0/1 within a given
individual: e.g. 345-zero and 345-one for individual A, 226-zero and
226-one for individual B, etc.). The variable Factor is separating the
individuals in three groups according to mass (group 0,1,2),
Factor1 is a binary variable coding for individuals of group1,
Factor2 is a binary variable for individuals of group 2 I use gam
models of this sort with random effects coded using a s( ...,
bs="re") term: gm<-gam(Y~Factor+te(x1,x2,by=Factor)
)+s(Individual,bs="re"),dat=Data,family=binomial(link=logit),method="R
EML")




gm1<-gam(Y~Factor+te(x1,x2)+ te(x1,x2,by=Factor1)+
te(x1,x2,by=Factor2)+s(Individual,bs="re"),dat=Data,family=binomial(link=logit),method="REML")


1)First question: is it OK to use gam() to model a binary variable
with random effects coded as a "bs="re" term"?? I have read that the
gamm4() function gives better performance than gamm() to deal with
binary variables when random effects are coded as:
random=~(1|Individual) but does that mean that binary variables should
not be used as response variable in gam() with random effects coded as
bs="re"???

-- It's fine to use 'gam'. The problem with gamm, is that it uses PQL, which 
can perform poorly in the binary case (mostly related to estimating the scale 
parameter rather than treating it as fixed). Both gam and gamm4 use a Laplace 
approximation that behaves much better that PQL in the binary case.



2)Second question: For some models, I obtain a p-value=NA and
Chi-square=0 for the s(Individual) term, and for some other models a
p-value=1 and high Chi-square. The difference between one model that
can estimate a p-value and one that cannot is very slight: for example
if I use a variable x3 instead of x2 in a model, it can change from
p-value=NA to p-value=1. Does anyone know what can be happening?


-- basically both cases are providing the same information --- that the 
corresponding term is not need in the model. In the first case the term is 
estimated to be so close to zero that it makes no sense to compute a p-value, 
while in the second case the term has been estimated to be non-zero, but not 
*significantly* different from zero at any level.



3)Third question: Not linked to random effects but rather to what the
two models gm and gm1 are actually testing. From my understanding, the
first model creates a 2d-smooth for each level of my factor variable
and test whether those smooth are significantly different from a
straight line.

-- from zero, if I understand the model right.



The second model, also creates 3
smooth: one for the reference level of my Factor variable (group0),
one showing the difference between the reference smooth and the smooth
for group1, one showing the difference between the reference smooth
and the smooth for group 2. The summary(gm1) gives p-values associated
with each of those three smooths and which determine:  if the
reference smooth is different from 0, if the smooth for group1 is
different from the reference smooth and  if the smooth for group2 is
different from the reference smooth. Do I understand well what the
models are testing?

-- sounds right to me.


The number of "edf" estimated for
te(x1,x2):Factor2 in the gm1 model is 3,013 while it is 19,57 in the
gm model. Does that mean that the difference between the reference
smooth: te(x1,x2) and the smooth for group 2: te(x1,x2, by=Factor2)
is "small" so it can be modeled with only 3 degrees of freedom?

-- "smooth", rather than "small". The difference could be very large, but var

[R] Where would i put feature requests for a library?

2012-04-27 Thread Jessica Streicher
Hi!

If i found a problem with the code of one of the libraries (not core), or, in 
my current case, would wish something minor changed for convenience, where can 
i get contact? Can i put it in the "official" bug repository?

(Problem discription for anyone interested:
Why call the default function kpca for a matrix with kpar=list(sigma=0.2), 
instead of putting this default sigma into the rbfkernel and using kpar=list()? 
Anytime i call kpca with a kernel without sigma, i have to supply kpar=list() 
or get an error. 
)

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


Re: [R] Using the R predict function to forecast a model fit with auto.arima function

2012-04-27 Thread R. Michael Weylandt
Hmmm can you provide the result of dput(paulfit)?

Otherwise, I'm not really sure what might have happened:

library(forecast)
example(auto.arima) # Makes an Arima object "fit" available
predict(fit, n.ahead = 36) # Works fine
forecast(fit, 36) # As does this

Michael

On Thu, Apr 26, 2012 at 12:40 PM, PaulJr  wrote:
> Hello R users,
>
> Hope everyone is doing great.
>
> I have a dataset that is in .csv format and consists of two columns: one
> named Period (which contains dates in the format _mm) and goes from
> 1995_10 to 2007_09 and the second column named pcumsdry which is a
> volumetric measure and has been formatted as numeric without any commas or
> decimals.
>
> I imported the dataset as pauldataset and made use of the auto.arima
> function which is great when you want R to suggest an appropriate arima
> model to fit to your data.
>
> I successfully got the arima fit by coding:
>
>> paulfit<-auto.arima(pauldataset$pcumsdry)
>> paulfit
>
> which produced the following results:
> Series: pauldataset$pcumsdry
> ARIMA(2,1,1) with drift
>
> Coefficients:
>         ar1    ar2      ma1       drift
>      0.2684  0.109  -0.8906  -15265.776
> s.e.  0.1145  0.102   0.0798    8047.169
>
> sigma^2 estimated as 2.869e+11:  log likelihood=-2265.02
> AIC=4540.03   AICc=4540.43   BIC=4555.25
>
> After this, I wanted to make some predictions based on the model suggested
> by the auto.arima function. I tried to use the following code to get the
> predictions:
>
> variableA.pred<-predict(paulfit, n.ahead=36)
> *Error in predict.Arima(paulfit, n.ahead = 36) :
>  'xreg' and 'newxreg' have different numbers of columns: 1 != 0*>
>
> Now, I have understood, and, according to my research the xreg comes into
> play if you add external regressors to your arima fit, but since I am just
> working with a univariate time series, I really do not understand the reason
> for that error message.
>
> Can anybody help me or tell me how could I do to be able to generate the
> predictions?
>
> Best regards,
>
> Paul
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Using-the-R-predict-function-to-forecast-a-model-fit-with-auto-arima-function-tp4590335p4590335.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] Where would i put feature requests for a library?

2012-04-27 Thread R. Michael Weylandt
The first step should be to contact the _package_ maintainer: use the
maintainer() function to get a contact email.

Michael

On Fri, Apr 27, 2012 at 7:04 AM, Jessica Streicher
 wrote:
> Hi!
>
> If i found a problem with the code of one of the libraries (not core), or, in 
> my current case, would wish something minor changed for convenience, where 
> can i get contact? Can i put it in the "official" bug repository?
>
> (Problem discription for anyone interested:
> Why call the default function kpca for a matrix with kpar=list(sigma=0.2), 
> instead of putting this default sigma into the rbfkernel and using 
> kpar=list()? Anytime i call kpca with a kernel without sigma, i have to 
> supply kpar=list() or get an error.
> )
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Where would i put feature requests for a library?

2012-04-27 Thread Duncan Murdoch

On 12-04-27 7:04 AM, Jessica Streicher wrote:

Hi!

If i found a problem with the code of one of the libraries (not core), or, in my current 
case, would wish something minor changed for convenience, where can i get contact? Can i 
put it in the "official" bug repository?

(Problem discription for anyone interested:
Why call the default function kpca for a matrix with kpar=list(sigma=0.2), 
instead of putting this default sigma into the rbfkernel and using kpar=list()? 
Anytime i call kpca with a kernel without sigma, i have to supply kpar=list() 
or get an error.
)



If it's a bug report, you can use bug.report(package="foo"); it will 
either print a message saying where to send your report, or will take 
you to the right place, depending on your system and the package.


If you just want to know who is currently responsible for the package, 
you can use


library(help="foo")

Duncan Murdoch

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


Re: [R] creating a package?

2012-04-27 Thread R. Michael Weylandt
Do you want to create a function or something like a function or a package?

Creating a function is easy:

doAThing <- function(a, b, c){
print("The cow jumped over the moon")
return(a + b^c)
}

Something like a function is somewhat ambiguous.

To create a package, start with the package.skeleton() function.

If it's a single function you want to distribute and it has no
compiled code or external dependencies, the package structure might be
overkill (though best practice) but you'll learn a fair bit by doing
it. If you just want to distribute a single function, you could also
put it in a text file that others could source().

Michael

On Thu, Apr 26, 2012 at 3:26 PM, Jose Bustos Melo  wrote:
> Dear R users.
>
>   I'm trying to know how to create a function. I have developed a big code 
> that use a file and makes many process and then creates a table that is 
> exported as txt.
> The point is to make something like a function.  I need to make it easy for 
> others, so they can run it. This has a particular name?
>
> I will be very gratefull and placed if any of you can provide some lights.
>
> Saludos,
> José Bustos
> www.aespro.cl
> Asesorias Estadisticas
> Celular 95939144
>
>        [[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] random effects in library mgcv

2012-04-27 Thread Mabille, Geraldine
Thanks Simon...it's always clearer when you say it!!!
Geraldine

-Original Message-
From: Simon Wood [mailto:s.w...@bath.ac.uk] 
Sent: 27. april 2012 12:41
To: Mabille, Geraldine
Cc: r-help@r-project.org
Subject: Re: [R] random effects in library mgcv

Geraldine,

I think that you are interpreting correctly. Since fewer effective degrees of 
freedom for essentially the same fit should lead to slightly improved 
precision, then you might expect slightly better prediction error performance 
for the model with fewer degrees of freedom, which is what the AIC score is 
picking up on.

best,
Simon

On 27/04/12 09:46, Mabille, Geraldine wrote:
> Thanks Simon for your help again on those points. Just a last thing, 
> regarding the third question:
> If the gm1 model has a lower AIC than the gm model, does that mean that we 
> should "select" for it?? As you said, I think both these models are doing the 
> same job (i.e. testing that the three smooth are different from zero), so the 
> part of deviance explain by both should be similar, and the difference in AIC 
> we obtained is only due to the fact that creating a smooth of the difference 
> to the reference model needs less degrees of freedom than creating a totally 
> "new" smooth???
> Am I interpreting those things right???
> Cheers,
> Geraldine
>
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Simon Wood
> Sent: 26. april 2012 19:28
> To: r-help@r-project.org
> Subject: Re: [R] random effects in library mgcv
>
> On 25/04/12 14:02, Mabille, Geraldine wrote:
>> Hi, I am working with gam models in the mgcv library. My response 
>> variable (Y) is binary (0/1), and my dataset contains repeated 
>> measures over 110 individuals (same number of 0/1 within a given
>> individual: e.g. 345-zero and 345-one for individual A, 226-zero and 
>> 226-one for individual B, etc.). The variable Factor is separating 
>> the individuals in three groups according to mass (group 0,1,2),
>> Factor1 is a binary variable coding for individuals of group1,
>> Factor2 is a binary variable for individuals of group 2 I use gam 
>> models of this sort with random effects coded using a s( ...,
>> bs="re") term: gm<-gam(Y~Factor+te(x1,x2,by=Factor)
>> )+s(Individual,bs="re"),dat=Data,family=binomial(link=logit),method="
>> R
>> EML")
>>
>>
>>
> gm1<-gam(Y~Factor+te(x1,x2)+ te(x1,x2,by=Factor1)+
> te(x1,x2,by=Factor2)+s(Individual,bs="re"),dat=Data,family=binomial(li
> nk=logit),method="REML")
>>
>> 1)First question: is it OK to use gam() to model a binary variable 
>> with random effects coded as a "bs="re" term"?? I have read that the
>> gamm4() function gives better performance than gamm() to deal with 
>> binary variables when random effects are coded as:
>> random=~(1|Individual) but does that mean that binary variables 
>> should not be used as response variable in gam() with random effects 
>> coded as bs="re"???
> -- It's fine to use 'gam'. The problem with gamm, is that it uses PQL, which 
> can perform poorly in the binary case (mostly related to estimating the scale 
> parameter rather than treating it as fixed). Both gam and gamm4 use a Laplace 
> approximation that behaves much better that PQL in the binary case.
>
>
>> 2)Second question: For some models, I obtain a p-value=NA and
>> Chi-square=0 for the s(Individual) term, and for some other models a
>> p-value=1 and high Chi-square. The difference between one model that 
>> can estimate a p-value and one that cannot is very slight: for 
>> example if I use a variable x3 instead of x2 in a model, it can 
>> change from p-value=NA to p-value=1. Does anyone know what can be happening?
>>
> -- basically both cases are providing the same information --- that the 
> corresponding term is not need in the model. In the first case the term is 
> estimated to be so close to zero that it makes no sense to compute a p-value, 
> while in the second case the term has been estimated to be non-zero, but not 
> *significantly* different from zero at any level.
>
>
>> 3)Third question: Not linked to random effects but rather to what the 
>> two models gm and gm1 are actually testing. From my understanding, 
>> the first model creates a 2d-smooth for each level of my factor 
>> variable and test whether those smooth are significantly different 
>> from a straight line.
> -- from zero, if I understand the model right.
>
>
>> The second model, also creates 3
>> smooth: one for the reference level of my Factor variable (group0), 
>> one showing the difference between the reference smooth and the 
>> smooth for group1, one showing the difference between the reference 
>> smooth and the smooth for group 2. The summary(gm1) gives p-values 
>> associated with each of those three smooths and which determine:  if 
>> the reference smooth is different from 0, if the smooth for group1 is 
>> different from the reference smooth and  if the smooth for group2 is 
>> different from t

Re: [R] Unable to compile & install rggobi

2012-04-27 Thread Indrajit Sengupta
I am sorry, but I didn't understand what you are trying to say here. Can you be 
a bit more explicit?
 
Indrajit
 



From: Prof Brian Ripley 

Cc: R Help  
Sent: Friday, April 27, 2012 2:21 PM
Subject: Re: [R] Unable to compile & install rggobi


You need to set some environment variables: study the rggobi sources for 
what. E.g. I bet GGobi is not installed in the root, so -I/include/ggobi 
will not work.


-- 
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,            Tel:  +44 1865 272861 (self)
1 South Parks Road,                    +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595
[[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] HoltWinters() fitted values

2012-04-27 Thread R. Michael Weylandt
HoltWinters doesn't give fitted values for the entire time series
since, like most time series models, there's a "recursive" element to
it. I.e., if a very simple model is X_t = 1/2*(X_{t-1} + X_{t-2}) +
epsilon, you need to take X_0, X_1 as is to "start" the series.

If you run example(HoltWinters) you'll note that the red lines have
roughly one period's (I think that's the right term) less points
because those are needed to set up seasonality.

You can change the model to something simpler to get earlier fits, but
to the best of my understanding, you can't get them all the way to the
beginning with HoltWinters smoothing.

Michael

On Thu, Apr 26, 2012 at 5:57 PM, slipkid90515
 wrote:
> Hi everyone,
>
> I'm using the HoltWinters() function to do a time series analysis.  The
> function only returns the back fitted values ($fitted) after the first year
> of data, which is my case, is a little more than half.  However, when I use
> the plot() function, it plots the back fit for almost the entire data set.
>
> Any ideas on how to extract the fitted values going all the way back to the
> start of the data set?
>
> Thanks,
> Jess
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/HoltWinters-fitted-values-tp4591103p4591103.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] Rconsole file fails to remember GUI settings, and script window text colour option is missing

2012-04-27 Thread geotheory
Am encountering two related problems since the 2.15 release.  Apologies in
advance for a mundane non code-related post, but you know how it is.  I'm
using the basic R GUI.

1: I use a black environment for no glare, so pre-version 2.15 I've had
black backgrounds and white text.  Since the 2.15 release my script window
text has colour turned itself black (so is now invisible) and now I cannot
find any setting in the options list that changes it.  Anyone know which one
its supposed to be?

2: I initially changed the script window to mid grey (so I could see the
text) and saving to the standard 'Rconsole' file, but now R fails to
remember that setting when it reloads.  So I've tried resetting the GUI
settings by deleting all 'Rconsole' files (found 1 on C drive and the one in
my personal R folder) but to no avail. It just doesn't remember new
settings, and its unclear where R is getting its current GUI settings from.
R!

More generally, can't someone behind this otherwise great project please
update the GUI settings to make them more comprehensive.  And user-friendly
- the 'console and pager colours' section is abysmal.

--
View this message in context: 
http://r.789695.n4.nabble.com/Rconsole-file-fails-to-remember-GUI-settings-and-script-window-text-colour-option-is-missing-tp4592349p4592349.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] Rconsole file fails to remember GUI settings, and script window text colour option is missing

2012-04-27 Thread R. Michael Weylandt
The GUI's are OS specific -- which is yours?

You might also want to check out RStudio -- also open source -- which
provides a very nice cross-platform IDE: http://rstudio.org/

There are nice coloration options (both customizable and by default)
-- I quite like the cobalt theme

Michael

On Fri, Apr 27, 2012 at 7:04 AM, geotheory  wrote:
> Am encountering two related problems since the 2.15 release.  Apologies in
> advance for a mundane non code-related post, but you know how it is.  I'm
> using the basic R GUI.
>
> 1: I use a black environment for no glare, so pre-version 2.15 I've had
> black backgrounds and white text.  Since the 2.15 release my script window
> text has colour turned itself black (so is now invisible) and now I cannot
> find any setting in the options list that changes it.  Anyone know which one
> its supposed to be?
>
> 2: I initially changed the script window to mid grey (so I could see the
> text) and saving to the standard 'Rconsole' file, but now R fails to
> remember that setting when it reloads.  So I've tried resetting the GUI
> settings by deleting all 'Rconsole' files (found 1 on C drive and the one in
> my personal R folder) but to no avail. It just doesn't remember new
> settings, and its unclear where R is getting its current GUI settings from.
> R!
>
> More generally, can't someone behind this otherwise great project please
> update the GUI settings to make them more comprehensive.  And user-friendly
> - the 'console and pager colours' section is abysmal.
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Rconsole-file-fails-to-remember-GUI-settings-and-script-window-text-colour-option-is-missing-tp4592349p4592349.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] Lambert (1992) simulation

2012-04-27 Thread Christopher Desjardins
On Fri, Apr 27, 2012 at 1:53 AM, Achim Zeileis wrote:

> On Thu, 26 Apr 2012, Christopher Desjardins wrote:
>
>  Hi,
>> I am trying to replicate Lambert (1992)'s simulation with zero-inflated
>> Poisson models. The citation is here:
>>
>> @article{lambert1992zero,
>> Author = {Lambert, D.},
>> Journal = {Technometrics},
>> Pages = {1--14},
>> Publisher = {JSTOR},
>> Title = {Zero-inflated {P}oisson regression, with an application to
>> defects
>> in manufacturing},
>> Year = {1992}}
>>
>> Specifically I am trying to recreate Table 2. But my estimates for Gamma
>> are not working out. Any ideas why?
>>
>
> Your implementation of the inverse logit link is wrong, it should be
> exp(x)/(1 + exp(x)) and not exp(x)/exp(1 + x). In R I never code this by
> hand but either use qlogis()/plogis() or make.link("logit").
>


Doh! So obvious. I really should have noticed that. Thanks! I'll have a
look at the rest of your code too.
Cheers,
Chris


>
> Your setting resulting in an almost constant probability of zero inflation
> and hence gamma was completely off.
>
> Below is my cleaned up code which nicely replicates the results for n =
> 100. The other two would require additional work because one would need to
> catch non-convergence etc.
>
> hth,
> Z
>
> ## data-generating process
> dgp <- function(nobs = 100) {
>  gamma <- c(-1.5, 2)
>  beta <- c(1.5, -2)
>  x <- seq(0, 1, length.out = nobs)
>  lambda <- exp(beta[1] + beta[2] * x)
>  p <- plogis(gamma[1] + gamma[2] * x)
>  y <- ifelse(runif(nobs) <= p, 0, rpois(nobs, lambda = lambda))
>  data.frame(y = y, x = x)
> }
>
> ## simulation of coefficients and standard errors
> sim <- function(nrep = 2000, ...) {
>  onesim <- function(i) {
>d <- dgp(...)
>m <- zeroinfl(y ~ x, data = d)
>c(coef(m), sqrt(diag(vcov(m
>  }
>  t(sapply(1:nrep, onesim))
> }
>
> ## run simulation #3
> library("pscl")
> set.seed(1)
> cfse <- sim(nobs = 100)
>
> ## mean coefficient estimates
> apply(cfse[, 1:4], 2, mean)
>
> ## median coefficient estimates
> apply(cfse[, 1:4], 2, median)
>
> ## sd of coefficient estimates
> apply(cfse[, 1:4], 2, sd)
>
> ## mean of the standard deviation estimates from observed information
> apply(cfse[, 5:8], 2, mean)
>
>
>
>  Please cc me on a reply!
>> Thanks,
>> Chris
>>
>> ## ZIP simulations based on Lambert (1992)'s conditions
>>
>> # Empty workspace
>> rm(list=ls())
>>
>> # Load zero-inflation package
>> library(pscl)
>>
>> # Simulation conditions #3
>> NumSimulations=2000
>> X=seq(from=0,to=1,length.out=**N)
>> Model.Matrix=cbind(rep(1,**length(X)),X)
>> Gamma=c(-1.5,2)
>> Beta=c(1.5,-2)
>> P=exp(Model.Matrix%*%Gamma)/**exp(1+Model.Matrix%*%Gamma)
>> Lambda=exp(Model.Matrix%*%**Beta)
>> CoefSimulations=matrix(nrow=**NumSimulations,ncol=2*dim(**
>> Model.Matrix)[2])
>>
>> for(i in 1 : NumSimulations){
>> Lambda.Draw=rpois(N,Lambda)
>> U=runif(N)
>> Y=ifelse(U<=P,0,Lambda.Draw)
>> CoefSimulations[i,]=coef(**zeroinfl(Y~X|X))
>> }
>>
>> # What were the estimates?
>> colMeans(CoefSimulations) # My gamma estimates aren't even close ...
>>
>>[[alternative HTML version deleted]]
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html 
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>

[[alternative HTML version deleted]]

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


Re: [R] Unable to compile & install rggobi

2012-04-27 Thread Indrajit Sengupta
I am able to compile it. However, when I try to check it - there is error:
 
D:\DPF\Rggobi\rggobi>R CMD check "D:\\Work\\tmp\\rggobi_2.1.17.tar.gz"
* using log directory 'D:/Work/tmp/rggobi.Rcheck'
* using R version 2.15.0 (2012-03-30)
* using platform: i386-pc-mingw32 (32-bit)
* using session charset: ISO8859-1
* checking for file 'rggobi/DESCRIPTION' ... OK
* this is package 'rggobi' version '2.1.17'
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking whether package 'rggobi' can be installed ... ERROR
Installation failed.
 
Regards,
Indrajit
 
 




To: Prof Brian Ripley  
Cc: R Help  
Sent: Friday, April 27, 2012 5:12 PM
Subject: Re: [R] Unable to compile & install rggobi

I am sorry, but I didn't understand what you are trying to say here. Can you be 
a bit more explicit?
 
Indrajit
 



From: Prof Brian Ripley 

Cc: R Help  
Sent: Friday, April 27, 2012 2:21 PM
Subject: Re: [R] Unable to compile & install rggobi


You need to set some environment variables: study the rggobi sources for 
what. E.g. I bet GGobi is not installed in the root, so -I/include/ggobi 
will not work.


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


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

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


Re: [R] Rconsole file fails to remember GUI settings, and script

2012-04-27 Thread R. Michael Weylandt
Sorry, I don't use Windows... can't help there.

It's customary to keep cc'ing the list on these sorts of things so
someone with a more similar platform/ more expertise can take the
issue up if needed. Maybe someone else will be able to help you out.

Michael

On Fri, Apr 27, 2012 at 9:05 AM, geo theory  wrote:
> Hi there
>
> Window 7. Sorry should've mentioned that.
>
> On Fri Apr 27, 2012 at some time, Michael Weylandt wrote:
> The GUI's are OS specific -- which is yours?
>
> You might also want to check out RStudio -- also open source -- which
> provides a very nice cross-platform IDE: http://rstudio.org/
>
> There are nice coloration options (both customizable and by default)
> -- I quite like the cobalt theme
>
> Michael
>
> On Fri, Apr 27, 2012 at 7:04 AM, geotheory  wrote:
>> Am encountering two related problems since the 2.15 release. =C2=A0Apolog=
> ies in
>> advance for a mundane non code-related post, but you know how it is. =C2=
> =A0I'm
>> using the basic R GUI.
>>
>> 1: I use a black environment for no glare, so pre-version 2.15 I've had
>> black backgrounds and white text. =C2=A0Since the 2.15 release my script =
> window
>> text has colour turned itself black (so is now invisible) and now I canno=
> t
>> find any setting in the options list that changes it. =C2=A0Anyone know w=
> hich one
>> its supposed to be?
>>
>> 2: I initially changed the script window to mid grey (so I could see the
>> text) and saving to the standard 'Rconsole' file, but now R fails to
>> remember that setting when it reloads. =C2=A0So I've tried resetting the =
> GUI
>> settings by deleting all 'Rconsole' files (found 1 on C drive and the one=
>  in
>> my personal R folder) but to no avail. It just doesn't remember new
>> settings, and its unclear where R is getting its current GUI settings fro=
> m.
>> R!
>>
>> More generally, can't someone behind this otherwise great project please
>> update the GUI settings to make them more comprehensive. =C2=A0And user-f=
> riendly
>> - the 'console and pager colours' section is abysmal.
>>
>> --
>> View this message in context: http://r.789695.n4.nabble.com/Rconsole-file=
> -fails-to-remember-GUI-settings-and-script-window-text-colour-option-is-mis=
> sing-tp4592349p4592349.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.h=
> tml
>> 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] Rconsole file fails to remember GUI settings, and script

2012-04-27 Thread Petr PIKAL
Hi

Isn't possible just to change values in etc/Rconsole file?

## Colours for console and pager(s)
# (see rw/etc/rgb.txt for the known colours).
background = White
normaltext = NavyBlue
usertext = Red
highlight = DarkRed

You can customise it and keep your setting somewhere. With each new 
installation just copy appropriate part aof Rconsole file and save it.

Regards
Petr

> 
> Sorry, I don't use Windows... can't help there.
> 
> It's customary to keep cc'ing the list on these sorts of things so
> someone with a more similar platform/ more expertise can take the
> issue up if needed. Maybe someone else will be able to help you out.
> 
> Michael
> 
> On Fri, Apr 27, 2012 at 9:05 AM, geo theory  
wrote:
> > Hi there
> >
> > Window 7. Sorry should've mentioned that.
> >
> > On Fri Apr 27, 2012 at some time, Michael Weylandt wrote:
> > The GUI's are OS specific -- which is yours?
> >
> > You might also want to check out RStudio -- also open source -- which
> > provides a very nice cross-platform IDE: http://rstudio.org/
> >
> > There are nice coloration options (both customizable and by default)
> > -- I quite like the cobalt theme
> >
> > Michael
> >
> > On Fri, Apr 27, 2012 at 7:04 AM, geotheory  
wrote:
> >> Am encountering two related problems since the 2.15 release. 
=C2=A0Apolog=
> > ies in
> >> advance for a mundane non code-related post, but you know how it is. 
=C2=
> > =A0I'm
> >> using the basic R GUI.
> >>
> >> 1: I use a black environment for no glare, so pre-version 2.15 I've 
had
> >> black backgrounds and white text. =C2=A0Since the 2.15 release my 
script =
> > window
> >> text has colour turned itself black (so is now invisible) and now I 
canno=
> > t
> >> find any setting in the options list that changes it. =C2=A0Anyone 
know w=
> > hich one
> >> its supposed to be?
> >>
> >> 2: I initially changed the script window to mid grey (so I could see 
the
> >> text) and saving to the standard 'Rconsole' file, but now R fails to
> >> remember that setting when it reloads. =C2=A0So I've tried resetting 
the =
> > GUI
> >> settings by deleting all 'Rconsole' files (found 1 on C drive and the 
one=
> >  in
> >> my personal R folder) but to no avail. It just doesn't remember new
> >> settings, and its unclear where R is getting its current GUI settings 
fro=
> > m.
> >> R!
> >>
> >> More generally, can't someone behind this otherwise great project 
please
> >> update the GUI settings to make them more comprehensive. =C2=A0And 
user-f=
> > riendly
> >> - the 'console and pager colours' section is abysmal.
> >>
> >> --
> >> View this message in context: 
http://r.789695.n4.nabble.com/Rconsole-file=
> > 
-fails-to-remember-GUI-settings-and-script-window-text-colour-option-is-mis=
> > sing-tp4592349p4592349.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.h=
> > tml
> >> and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] PLM package PGGLS strange behavior

2012-04-27 Thread Millo Giovanni
Hello. No "strange behaviour" here, just a warning.

There is a difference between an "error" and a "warning", and between an
argument and a model. In this specific case, the warning is just there
to remind you that, as stated, 'the "random" **argument** has been
renamed to "pooling" ' (emphasis mine). 

Both still work, but the former is deprecated. The estimator you get is
the same (a GGLS, or "Parks estimator"), everything works the way it
should and you can trust the numbers that come out, provided the
specification is clear to you and it is what you wanted (which for
instance is not entirely clear from your email). 

The model underlying the General Feasible GLS estimator (GGLS) does not
really have "random effects"; therefore, after having initially named
the model without FEs "random" by contrast to the Fixed Effects GLS a la
Kiefer (1980), we later considered the denomination as inappropriate and
changed it to "pooling" which in effect it is: a pooled model with no
proper individual effects but a general error covariance structure. You
can get a better understanding of the specification if you read the
cited reference carefully (or even better, Wooldridge as referenced
therein).

Lastly, it is not clear what you mean by "the right estimates": the
numbers I get by using either 'model="pooling"' or ' model="random"' on
the given example are exactly those in the JSS paper. If on your system
you get anything else, I'll be grateful for a reproducible report, as
asked for in the posting guide.

PS if by chance you are just mistaking "General Feasible GLS" with
"Random Effects by GLS", then you should use 'plm(yourformula, yourdata,
model="random")' instead, and you'll get the standard RE model.

Best wishes,
Giovanni

Giovanni Millo, PhD
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4,
34132 Trieste (Italy)
tel. +39 040 671184
fax  +39 040 671160

--- original message ---

Message: 18
Date: Thu, 26 Apr 2012 14:07:16 +0200
From: Ruben de Bliek 
To: r-help@r-project.org
Subject: [R] PLM package PGGLS strange behavior
Message-ID:


Content-Type: text/plain

When using the PLM package (version 1.2-8), I encounter the probem that
calling the FGLS estimator evokes strange behavior, when choosing the
"random" effects model. After calling the PGGLS function to estimate
FGLS,
PLM gives me a warning, stating that the "random" model has been
replaced
with the "pooling" model. I would, however, really like to estimate the
random model instead. For me, the problem is reproducable using one of
the
examples from the PLM Jstatsoft article "Panel Data Econometrics in R:
The
plm package" (pp.19-20):

data("EmplUK", package="plm")
zz <- pggls(log(emp)~log(wage)+log(capital),data=EmplUK, model="random")
summary(zz)

Which for me results in the following warning:

WARNING: Warning: 'random' argument to pggls() has been renamed as
'pooling'

It then proceeds with estimating a pooled model. I've checked if PLM by
any
chance does produce the right coefficient estimates, but the numbers do
not
add up when compared to the estimates in the article. This problem
perists
for any dataset I use. Any thoughts?

-- end original message -

 
Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{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.


Re: [R] PLM package PGGLS strange behavior

2012-04-27 Thread Ruben de Bliek
Thank you Millo. I was a little confused by the random versus pooling
nomenclature used in PLM, thank you for clearing that up. I still have the
issue of not receiving the proper coefficient estimates for the example in
the paper though. My output is posted below; the estimates are
substantially different from the ones posted on page 20. My R version is
2.14.2.

library(plm)
> data("EmplUK", package="plm")
> zz <- pggls(log(emp)~log(wage)+log(capital),data=EmplUK, model="random")
Warning message:
'random' argument to pggls() has been renamed as 'pooling'
> summary(zz)
 Random effects model
Call:
pggls(formula = log(emp) ~ log(wage) + log(capital), data = EmplUK,
model = "random")
Unbalanced Panel: n=140, T=7-9, N=1031
Residuals
Min.  1st Qu.   Median Mean  3rd Qu. Max.
-1.80700 -0.36550  0.06181  0.03230  0.44280  1.58700
Coefficients
  Estimate Std. Error z-value  Pr(>|z|)
(Intercept)   2.023480   0.158468 12.7690 < 2.2e-16 ***
log(wage)-0.232329   0.048001 -4.8401 1.298e-06 ***
log(capital)  0.610484   0.017434 35.0174 < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Total Sum of Squares: 1853.6
Residual Sum of Squares: 402.55
Multiple R-squared: 0.78283
2012/4/27 Millo Giovanni 

> Hello. No "strange behaviour" here, just a warning.
>
> There is a difference between an "error" and a "warning", and between an
> argument and a model. In this specific case, the warning is just there
> to remind you that, as stated, 'the "random" **argument** has been
> renamed to "pooling" ' (emphasis mine).
>
> Both still work, but the former is deprecated. The estimator you get is
> the same (a GGLS, or "Parks estimator"), everything works the way it
> should and you can trust the numbers that come out, provided the
> specification is clear to you and it is what you wanted (which for
> instance is not entirely clear from your email).
>
> The model underlying the General Feasible GLS estimator (GGLS) does not
> really have "random effects"; therefore, after having initially named
> the model without FEs "random" by contrast to the Fixed Effects GLS a la
> Kiefer (1980), we later considered the denomination as inappropriate and
> changed it to "pooling" which in effect it is: a pooled model with no
> proper individual effects but a general error covariance structure. You
> can get a better understanding of the specification if you read the
> cited reference carefully (or even better, Wooldridge as referenced
> therein).
>
> Lastly, it is not clear what you mean by "the right estimates": the
> numbers I get by using either 'model="pooling"' or ' model="random"' on
> the given example are exactly those in the JSS paper. If on your system
> you get anything else, I'll be grateful for a reproducible report, as
> asked for in the posting guide.
>
> PS if by chance you are just mistaking "General Feasible GLS" with
> "Random Effects by GLS", then you should use 'plm(yourformula, yourdata,
> model="random")' instead, and you'll get the standard RE model.
>
> Best wishes,
> Giovanni
>
> Giovanni Millo, PhD
> Research Dept.,
> Assicurazioni Generali SpA
> Via Machiavelli 4,
> 34132 Trieste (Italy)
> tel. +39 040 671184
> fax  +39 040 671160
>
> --- original message ---
>
> Message: 18
> Date: Thu, 26 Apr 2012 14:07:16 +0200
> From: Ruben de Bliek 
> To: r-help@r-project.org
> Subject: [R] PLM package PGGLS strange behavior
> Message-ID:
>
> 
> Content-Type: text/plain
>
> When using the PLM package (version 1.2-8), I encounter the probem that
> calling the FGLS estimator evokes strange behavior, when choosing the
> "random" effects model. After calling the PGGLS function to estimate
> FGLS,
> PLM gives me a warning, stating that the "random" model has been
> replaced
> with the "pooling" model. I would, however, really like to estimate the
> random model instead. For me, the problem is reproducable using one of
> the
> examples from the PLM Jstatsoft article "Panel Data Econometrics in R:
> The
> plm package" (pp.19-20):
>
> data("EmplUK", package="plm")
> zz <- pggls(log(emp)~log(wage)+log(capital),data=EmplUK, model="random")
> summary(zz)
>
> Which for me results in the following warning:
>
> WARNING: Warning: 'random' argument to pggls() has been renamed as
> 'pooling'
>
> It then proceeds with estimating a pooled model. I've checked if PLM by
> any
> chance does produce the right coefficient estimates, but the numbers do
> not
> add up when compared to the estimates in the article. This problem
> perists
> for any dataset I use. Any thoughts?
>
> -- end original message -
>
>
> Ai sensi del D.Lgs. 196/2003 si precisa che le informazioni contenute in
> questo messaggio sono riservate ed a uso esclusivo del destinatario.
> Qualora il messaggio in parola Le fosse pervenuto per errore, La invitiamo
> ad eliminarlo senza copiarlo e a non inoltrarlo a terzi, dandocene
> gentilmente comunicazione. Grazie.
>
> Pu

[R] R: PLM package PGGLS strange behavior

2012-04-27 Thread Millo Giovanni
Hello again.
This is really strange: I actually get the right numbers all the time. I tried 
now and got 
 
> data("EmplUK", package="plm")
> zz <- pggls(log(emp)~log(wage)+log(capital),data=EmplUK, model="random")
Warning message:
'random' argument to pggls() has been renamed as 'pooling' 
> summary(zz)
 Random effects model
 
Call:
pggls(formula = log(emp) ~ log(wage) + log(capital), data = EmplUK, 
model = "random")
 
Unbalanced Panel: n=140, T=7-9, N=1031
 
Residuals
  Min.1st Qu. Median   Mean3rd Qu.   Max. 
-1.844 -0.3908000  0.0388700  0.0005525  0.4153000  1.492 
 
Coefficients
  Estimate Std. Error z-value Pr(>|z|)
(Intercept)   1.751448   0.180100  9.7249  < 2e-16 ***
log(wage)-0.132986   0.054292 -2.4495  0.01431 *  
log(capital)  0.629621   0.018483 34.0648  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
Total Sum of Squares: 1853.6
Residual Sum of Squares: 386
Multiple R-squared: 0.79176

exactly as expected.
Which is your system? (please post the output of Sys.info)  although I'd be 
surprised if this were system dependent!
 
You might also update the package to the last version if it isn't yet, although 
I can't remember bugs in this function since a very long time.
Thx for feedback
Best,
G.



Da: Ruben de Bliek [mailto:rubendebl...@gmail.com] 
Inviato: venerdì 27 aprile 2012 16.28
A: Millo Giovanni
Cc: r-help@r-project.org
Oggetto: Re: [R] PLM package PGGLS strange behavior


Thank you Millo. I was a little confused by the random versus pooling 
nomenclature used in PLM, thank you for clearing that up. I still have the 
issue of not receiving the proper coefficient estimates for the example in the 
paper though. My output is posted below; the estimates are substantially 
different from the ones posted on page 20. My R version is 2.14.2.

library(plm)
> data("EmplUK", package="plm")
> zz <- pggls(log(emp)~log(wage)+log(capital),data=EmplUK, model="random")
Warning message:
'random' argument to pggls() has been renamed as 'pooling' 
> summary(zz)
 Random effects model
Call:
pggls(formula = log(emp) ~ log(wage) + log(capital), data = EmplUK, 
model = "random")
Unbalanced Panel: n=140, T=7-9, N=1031
Residuals
Min.  1st Qu.   Median Mean  3rd Qu. Max. 
-1.80700 -0.36550  0.06181  0.03230  0.44280  1.58700 
Coefficients
  Estimate Std. Error z-value  Pr(>|z|)
(Intercept)   2.023480   0.158468 12.7690 < 2.2e-16 ***
log(wage)-0.232329   0.048001 -4.8401 1.298e-06 ***
log(capital)  0.610484   0.017434 35.0174 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
Total Sum of Squares: 1853.6
Residual Sum of Squares: 402.55
Multiple R-squared: 0.78283

2012/4/27 Millo Giovanni 


Hello. No "strange behaviour" here, just a warning.

There is a difference between an "error" and a "warning", and between an
argument and a model. In this specific case, the warning is just there
to remind you that, as stated, 'the "random" **argument** has been
renamed to "pooling" ' (emphasis mine).

Both still work, but the former is deprecated. The estimator you get is
the same (a GGLS, or "Parks estimator"), everything works the way it
should and you can trust the numbers that come out, provided the
specification is clear to you and it is what you wanted (which for
instance is not entirely clear from your email).

The model underlying the General Feasible GLS estimator (GGLS) does not
really have "random effects"; therefore, after having initially named
the model without FEs "random" by contrast to the Fixed Effects GLS a la
Kiefer (1980), we later considered the denomination as inappropriate and
changed it to "pooling" which in effect it is: a pooled model with no
proper individual effects but a general error covariance structure. You
can get a better understanding of the specification if you read the
cited reference carefully (or even better, Wooldridge as referenced
therein).

Lastly, it is not clear what you mean by "the right estimates": the
numbers I get by using either 'model="pooling"' or ' model="random"' on
the given example are exactly those in the JSS paper. If on your system
you get anything else, I'll be grateful for a reproducible report, as
asked for in the posting guide.

PS if by chance you are just mistaking "General Feasible GLS" with
"Random Effects by GLS", then you should use 'plm(yourformula, yourdata,
model="random")' instead, and you'll get the standard RE model.

Best wishes,
Giovanni

Giovanni Millo, PhD
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4,
34132 Trieste (Ital

Re: [R] Rconsole file fails to remember GUI settings, and script

2012-04-27 Thread Duncan Murdoch

On 27/04/2012 9:58 AM, Petr PIKAL wrote:

Hi

Isn't possible just to change values in etc/Rconsole file?

## Colours for console and pager(s)
# (see rw/etc/rgb.txt for the known colours).
background = White
normaltext = NavyBlue
usertext = Red
highlight = DarkRed

You can customise it and keep your setting somewhere. With each new
installation just copy appropriate part aof Rconsole file and save it.


That's not necessarily the right place to look:  see ?Rconsole.   It 
will look in R_USER/Rconsole first.  You can suppress

the lookup by putting --no-Rconsole on the command line.

If the original poster is finding the colours aren't working when he's 
sure he's got the right file, please post details.


Duncan Murdoch


Regards
Petr

>
>  Sorry, I don't use Windows... can't help there.
>
>  It's customary to keep cc'ing the list on these sorts of things so
>  someone with a more similar platform/ more expertise can take the
>  issue up if needed. Maybe someone else will be able to help you out.
>
>  Michael
>
>  On Fri, Apr 27, 2012 at 9:05 AM, geo theory
wrote:
>  >  Hi there
>  >
>  >  Window 7. Sorry should've mentioned that.
>  >
>  >  On Fri Apr 27, 2012 at some time, Michael Weylandt wrote:
>  >  The GUI's are OS specific -- which is yours?
>  >
>  >  You might also want to check out RStudio -- also open source -- which
>  >  provides a very nice cross-platform IDE: http://rstudio.org/
>  >
>  >  There are nice coloration options (both customizable and by default)
>  >  -- I quite like the cobalt theme
>  >
>  >  Michael
>  >
>  >  On Fri, Apr 27, 2012 at 7:04 AM, geotheory
wrote:
>  >>  Am encountering two related problems since the 2.15 release.
=C2=A0Apolog=
>  >  ies in
>  >>  advance for a mundane non code-related post, but you know how it is.
=C2=
>  >  =A0I'm
>  >>  using the basic R GUI.
>  >>
>  >>  1: I use a black environment for no glare, so pre-version 2.15 I've
had
>  >>  black backgrounds and white text. =C2=A0Since the 2.15 release my
script =
>  >  window
>  >>  text has colour turned itself black (so is now invisible) and now I
canno=
>  >  t
>  >>  find any setting in the options list that changes it. =C2=A0Anyone
know w=
>  >  hich one
>  >>  its supposed to be?
>  >>
>  >>  2: I initially changed the script window to mid grey (so I could see
the
>  >>  text) and saving to the standard 'Rconsole' file, but now R fails to
>  >>  remember that setting when it reloads. =C2=A0So I've tried resetting
the =
>  >  GUI
>  >>  settings by deleting all 'Rconsole' files (found 1 on C drive and the
one=
>  >   in
>  >>  my personal R folder) but to no avail. It just doesn't remember new
>  >>  settings, and its unclear where R is getting its current GUI settings
fro=
>  >  m.
>  >>  R!
>  >>
>  >>  More generally, can't someone behind this otherwise great project
please
>  >>  update the GUI settings to make them more comprehensive. =C2=A0And
user-f=
>  >  riendly
>  >>  - the 'console and pager colours' section is abysmal.
>  >>
>  >>  --
>  >>  View this message in context:
http://r.789695.n4.nabble.com/Rconsole-file=
>  >
-fails-to-remember-GUI-settings-and-script-window-text-colour-option-is-mis=
>  >  sing-tp4592349p4592349.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.h=
>  >  tml
>  >>  and provide commented, minimal, self-contained, reproducible code.
>
>  __
>  R-help@r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-help
>  PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
>  and provide commented, minimal, self-contained, reproducible code.

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


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

2012-04-27 Thread Ben quant
Hello,

Does anyone know how to get the rounding method used for the axis tick
numbers/values in plot()?

I'm using mtext() to plot the values used to plot vertical and horizontal
lines (using abline()) and I'd like these vertical and horizontal line
values to be rounded like the axis tick values are rounded.

In other words, I want numbers plotted with mtext() to be rounded in the
same fashion as the axis values given by default by plot().

thank you very much for your help!

ben

[[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] get plot axis rounding method

2012-04-27 Thread Duncan Murdoch

On 27/04/2012 10:55 AM, Ben quant wrote:

Hello,

Does anyone know how to get the rounding method used for the axis tick
numbers/values in plot()?

I'm using mtext() to plot the values used to plot vertical and horizontal
lines (using abline()) and I'd like these vertical and horizontal line
values to be rounded like the axis tick values are rounded.

In other words, I want numbers plotted with mtext() to be rounded in the
same fashion as the axis values given by default by plot().

thank you very much for your help!


See ?axTicks or ?pretty.

Duncan Murdoch

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


Re: [R] Merge function - Return NON matches

2012-04-27 Thread RHelpPlease
Hi there,
I've tried the noted solutions:

"If you do `no <- unlist(hrc_78_clm_no`, do you get a character vector 
of claim numbers you want to exclude? If so, then `subset(whatever, 
!CLAIM_NO %in% no)` should work."

I converted the CLAIM_NO list to a character, with

> hrc78_clmno_char <- format(as.character(hrc78_clm_no))
> is.character(hrc78_clmno_char)
[1] TRUE

Then I applied your code (above), which didn't work.  Thanks though!

Thanks for the dput() help.  Here is truncated output of the list (its class
is data.frame, I call it a list for communication sake) & data.frame. 
Again, your help is most appreciated!

Goal: merge the list & data.frame together.  Output the data.frame, but with
rows where the CLAIM_NO variable between the list & data.frame *do not
match*.

*The List*
truncated_list <- hrc78_clm_no[1:100,] #So you can see consistency in
previously-mentioned variables
truncated_list <- structure(list(CLAIM_NO = c(20L, 83L, 1440L, 4439L, 7002L,
9562L, 10463L, 12503L, 16195L, 
22987L, 30760L, 32108L, 32640L, 33045L, 36241L, 37091L, 37934L, 
38663L, 39456L, 40544L, 40630L, 40679L, 40734L, 43054L, 53483L, 
54155L, 56151L, 58113L, 61050L, 62056L, 63014L, 68486L, 68541L, 
69298L, 69983L, 73379L, 76810L, 79975L, 91124L, 97697L, 100524L, 
105808L, 112659L, 112955L, 113422L, 114522L, 124159L, 133566L, 
135167L, 137387L, 137954L, 138186L, 144574L, 148573L, 150013L, 
152193L, 154680L, 155414L, 165954L, 171223L, 175077L, 176359L, 
177656L, 178155L, 182250L, 182393L, 182832L, 184245L, 185542L, 
186038L, 186087L, 186098L, 186294L, 186550L, 186897L, 187025L, 
190180L, 191472L, 192593L, 196207L, 196689L, 197372L, 197537L, 
197590L, 197730L, 197874L, 198294L, 198750L, 198823L, 199076L, 
199233L, 199284L, 199468L, 199661L, 199913L, 200150L, 200279L, 
200473L, 200927L, 202407L), .Names = c("CLAIM_NO"), class = "data.frame"))

*The (multi-column) data.frame, but greatly truncated*
truncated_dataframe <- bestPartAreadmin[1:25, 1:4]
truncated_dataframe <- structure(list(DESY_SORT_KEY = c(10193L,
10193L, 10193L, 
10574L, 10574L, 19213L, 19213L, 19213L, 100026636L, 
100040718L, 100055111L, 100060558L, 100060558L, 100060558L, 100072978L, 
100096346L, 100130451L, 100168782L, 100168782L, 100168782L, 100168782L, 
100168782L, 100168782L, 100174887L, 100177905L), PRVDR_NUM =
structure(c(1368L, 
1353L, 1406L, 149L, 149L, 1362L, 1393L, 1367L, 1557L, 1370L, 
1360L, 1362L, 1362L, 1362L, 1372L, 1358L, 193L, 196L, 196L, 61L, 
166L, 196L, 196L, 311L, 1363L), .Label = c("010001", "010006", 
"010015", "010016", "010029", "010033", "010034", "010035", "010039", 
"010040", "010046", "010049", "010083", "010092", "010108", "010131", 
"010149", "01S001", "01S033", "01S046", "01S145", "020001", "020006", 
"020012", "020017", "021306", "021311", "030002", "030006", "030007", 
"030010", "030011", "030012", "030013", "030014", "030016", "030023", 
"030024", "030030", "030033", "030036", "030037", "030038", "030043", 
"030055", "030061", "030062", "030064", "030065", "030067", "030069", 
"030078", "030083", "030085", "030087", "030088", "030089", "030092", 
"030093", "030100", "030101", "030102", "030103", "030105", "030108", 
"030110", "030111", "030114", "030115", "030117", "030118", "030119", 
"030120", "030121", "030122", "030123", "030126", "030128", "031300", 
"031305", "031311", "032000", "032001", "032002", "032006", "033025", 
"033028", "033029", "033032", "033034", "033036", "034004", "034013", 
"034020", "034024", "03S002", "03S006", "03S007", "03S016", "03S022", 
"03S023", "03S089", "03T002", "03T055", "03T061", "03T069", "03T093", 
"03T103", "03T114", "03T117", "03T126", "040004", "040007", "040010", 
"040011", "040016", "040022", "040026", "040027", "040029", "040036", 
"040041", "040047", "040055", "040062", "040072", "040080", "040084", 
"040088", "040091", "040114", "040118", "040119", "043028", "044005", 
"04S027", "04S084", "04T041", "04T062", "04T119", "050002", "050006", 
"050007", "050008", "050009", "050013", "050014", "050016", "050017", 
"050018", "050022", "050024", "050025", "050026", "050030", "050036", 
"050038", "050039", "050040", "050042", "050043", "050045", "050046", 
"050047", "050055", "050056", "050057", "050058", "050060", "050063", 
"050069", "050070", "050071", "050073", "050075", "050076", "050077", 
"050078", "050079", "050082", "050084", "050089", "050090", "050091", 
"050093", "050099", "050100", "050101", "050102", "050103", "050104", 
"050107", "050108", "050110", "050111", "050112", "050113", "050115", 
"050116", "050118", "050121", "050122", "050124", "050125", "050126", 
"050128", "050129", "050131", "050132", "050133", "050135", "050136", 
"050137", "050138", "050139", "050140", "050145", "050146", "050149", 
"050150", "050152", "050153", "050158", "050159", "050168", "050169", 
"050174", "050179", "050180", "050188", "050191", "050193", "050195", 
"050196", "050197", "050204", "050211", "050219", "050222", "050224", 
"050225", "050226", "050228", "050230",

Re: [R] get plot axis rounding method

2012-04-27 Thread Sarah Goslee
The help for axis() talks about it some, and provides the suggestion
to see ?pretty - since you're not looking for a regular sequence of
numbers, you may need to dig into the code itself. Or something in
?axis may offer the clue you need.

But surely it's more appropriate to use the correct number of
significant figures for those data than it is to simply make them
match the axis labels?

Sarah

On Fri, Apr 27, 2012 at 10:55 AM, Ben quant  wrote:
> Hello,
>
> Does anyone know how to get the rounding method used for the axis tick
> numbers/values in plot()?
>
> I'm using mtext() to plot the values used to plot vertical and horizontal
> lines (using abline()) and I'd like these vertical and horizontal line
> values to be rounded like the axis tick values are rounded.
>
> In other words, I want numbers plotted with mtext() to be rounded in the
> same fashion as the axis values given by default by plot().
>
> thank you very much for your help!
>
> ben
>


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

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


Re: [R] Merge function - Return NON matches

2012-04-27 Thread Petr PIKAL
Hi

If you used shorter names for your objects you will get probably more 
readable advice

Is this what you wanted?

truncated_dataframe[truncated_dataframe$CLAIM_NO %in% 
setdiff(truncated_dataframe$CLAIM_NO, truncated_list$CLAIM_NO),]

Regards
Petr

 
> Hi there,
> I've tried the noted solutions:
> 
> "If you do `no <- unlist(hrc_78_clm_no`, do you get a character vector 
> of claim numbers you want to exclude? If so, then `subset(whatever, 
> !CLAIM_NO %in% no)` should work."
> 
> I converted the CLAIM_NO list to a character, with
> 
> > hrc78_clmno_char <- format(as.character(hrc78_clm_no))
> > is.character(hrc78_clmno_char)
> [1] TRUE
> 
> Then I applied your code (above), which didn't work.  Thanks though!
> 
> Thanks for the dput() help.  Here is truncated output of the list (its 
class
> is data.frame, I call it a list for communication sake) & data.frame. 
> Again, your help is most appreciated!
> 
> Goal: merge the list & data.frame together.  Output the data.frame, but 
with
> rows where the CLAIM_NO variable between the list & data.frame *do not
> match*.
> 
> *The List*
> truncated_list <- hrc78_clm_no[1:100,] #So you can see consistency in
> previously-mentioned variables
> truncated_list <- structure(list(CLAIM_NO = c(20L, 83L, 1440L, 4439L, 
7002L,
> 9562L, 10463L, 12503L, 16195L, 
> 22987L, 30760L, 32108L, 32640L, 33045L, 36241L, 37091L, 37934L, 
> 38663L, 39456L, 40544L, 40630L, 40679L, 40734L, 43054L, 53483L, 
> 54155L, 56151L, 58113L, 61050L, 62056L, 63014L, 68486L, 68541L, 
> 69298L, 69983L, 73379L, 76810L, 79975L, 91124L, 97697L, 100524L, 
> 105808L, 112659L, 112955L, 113422L, 114522L, 124159L, 133566L, 
> 135167L, 137387L, 137954L, 138186L, 144574L, 148573L, 150013L, 
> 152193L, 154680L, 155414L, 165954L, 171223L, 175077L, 176359L, 
> 177656L, 178155L, 182250L, 182393L, 182832L, 184245L, 185542L, 
> 186038L, 186087L, 186098L, 186294L, 186550L, 186897L, 187025L, 
> 190180L, 191472L, 192593L, 196207L, 196689L, 197372L, 197537L, 
> 197590L, 197730L, 197874L, 198294L, 198750L, 198823L, 199076L, 
> 199233L, 199284L, 199468L, 199661L, 199913L, 200150L, 200279L, 
> 200473L, 200927L, 202407L), .Names = c("CLAIM_NO"), class = 
"data.frame"))
> 
> *The (multi-column) data.frame, but greatly truncated*
> truncated_dataframe <- bestPartAreadmin[1:25, 1:4]
> truncated_dataframe <- structure(list(DESY_SORT_KEY = c(10193L,
> 10193L, 10193L, 
> 10574L, 10574L, 19213L, 19213L, 19213L, 100026636L, 
> 100040718L, 100055111L, 100060558L, 100060558L, 100060558L, 100072978L, 
> 100096346L, 100130451L, 100168782L, 100168782L, 100168782L, 100168782L, 
> 100168782L, 100168782L, 100174887L, 100177905L), PRVDR_NUM =
> structure(c(1368L, 
> 1353L, 1406L, 149L, 149L, 1362L, 1393L, 1367L, 1557L, 1370L, 
> 1360L, 1362L, 1362L, 1362L, 1372L, 1358L, 193L, 196L, 196L, 61L, 
> 166L, 196L, 196L, 311L, 1363L), .Label = c("010001", "010006", 
> "010015", "010016", "010029", "010033", "010034", "010035", "010039", 
> "010040", "010046", "010049", "010083", "010092", "010108", "010131", 
> "010149", "01S001", "01S033", "01S046", "01S145", "020001", "020006", 
> "020012", "020017", "021306", "021311", "030002", "030006", "030007", 
> "030010", "030011", "030012", "030013", "030014", "030016", "030023", 
> "030024", "030030", "030033", "030036", "030037", "030038", "030043", 
> "030055", "030061", "030062", "030064", "030065", "030067", "030069", 
> "030078", "030083", "030085", "030087", "030088", "030089", "030092", 
> "030093", "030100", "030101", "030102", "030103", "030105", "030108", 
> "030110", "030111", "030114", "030115", "030117", "030118", "030119", 
> "030120", "030121", "030122", "030123", "030126", "030128", "031300", 
> "031305", "031311", "032000", "032001", "032002", "032006", "033025", 
> "033028", "033029", "033032", "033034", "033036", "034004", "034013", 
> "034020", "034024", "03S002", "03S006", "03S007", "03S016", "03S022", 
> "03S023", "03S089", "03T002", "03T055", "03T061", "03T069", "03T093", 
> "03T103", "03T114", "03T117", "03T126", "040004", "040007", "040010", 
> "040011", "040016", "040022", "040026", "040027", "040029", "040036", 
> "040041", "040047", "040055", "040062", "040072", "040080", "040084", 
> "040088", "040091", "040114", "040118", "040119", "043028", "044005", 
> "04S027", "04S084", "04T041", "04T062", "04T119", "050002", "050006", 
> "050007", "050008", "050009", "050013", "050014", "050016", "050017", 
> "050018", "050022", "050024", "050025", "050026", "050030", "050036", 
> "050038", "050039", "050040", "050042", "050043", "050045", "050046", 
> "050047", "050055", "050056", "050057", "050058", "050060", "050063", 
> "050069", "050070", "050071", "050073", "050075", "050076", "050077", 
> "050078", "050079", "050082", "050084", "050089", "050090", "050091", 
> "050093", "050099", "050100", "050101", "050102", "050103", "050104", 
> "050107", "050108", "050110", "050111", "050112", "050113", "050115", 
> "050116", "050118", "050121", "050122", 

[R] Min , Max

2012-04-27 Thread Jonsson
Hellow everyone,
This code bellow will calculate average daily wind speed(measurements are
taken every three hours).Any ideas how to take the Min and Max instead of
average.

library(Matrix)
setwd("C:\\Users\\aalyaari\\Desktop\\img")
listfile<-dir()
long <- file("C:\\Users\\aalyaari\\Desktop\\New folder (5)\\inra.bin", "rb")
 A=readBin(long, integer(), size=2,n=67420*1, signed=F)
 ta<-t(A)
 lot <- file("C:\\Users\\aalyaari\\Desktop\\New folder (5)\\lat.img", "rb")
 B=readBin(lot, integer(), size=2,n=67420*1, signed=F)
 tb<-t(B)

for (n in 1:length(listfile))
{

#h[n]=listfile[n]
h=listfile[n]
#b[n]=file.info(h[n])$size/67420/4
b=file.info(h[n])$size/67420/4

wind <- file(h, "rb")
C=readBin(wind, double(), size=4,n=67420*b, signed=TRUE)
 
D<-matrix(C,nrow=b,ncol=67420)
 
for(d in 1:b)
{
M <- Matrix(-, 360, 720)
tm<-t(M)
for(i in 1:67420)
{
tm[ta[i],tb[i]]= round(10 * ((D[(d-1)*8+1,i] + 
D[(d-1)*8+2,i]
+D[(d-1)*8+3,i] +D[(d-1)*8+4,i] +D[(d-1)*8+5,i] +D[(d-1)*8+6,i]
+D[(d-1)*8+7,i] +D[(d-1)*8+8,i] ) / 8))

}
to.write <- sprintf("C:\\Users\\aalyaari\\Desktop\\New folder
(6)\\Yar_%00d.bin", d)
writeBin(as.integer(tm@x), size=2,to.write)
}
}


--
View this message in context: 
http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593065.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] check if excel file is

2012-04-27 Thread Ben quant
Hello again,

I'd like to determine if an Excel file is open or writable. Can anyone help
me with that?

I write some stats to an .xlsx Excel file using the xlsx package. I can't
write to the file unless its closed. How do I determine if the .xlsx file
is open or closed so I can write to it?

I've looked at file.info and file.access and I couldn't get those to work
for me.

Any help would be great!
ben

[[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] Merge function - Return NON matches

2012-04-27 Thread RHelpPlease
Hi again,
Petr, your solution worked!

Thanks everyone for your input.  I'll look more into "setdiff."

Cheers!

--
View this message in context: 
http://r.789695.n4.nabble.com/Merge-function-Return-NON-matches-tp4590755p4593101.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] check if excel file is

2012-04-27 Thread Ben quant
Forgot this: the solution doesn't have to come from the xlsx package...

thanks

ben

On Fri, Apr 27, 2012 at 10:08 AM, Ben quant  wrote:

> Hello again,
>
> I'd like to determine if an Excel file is open or writable. Can anyone
> help me with that?
>
> I write some stats to an .xlsx Excel file using the xlsx package. I can't
> write to the file unless its closed. How do I determine if the .xlsx file
> is open or closed so I can write to it?
>
> I've looked at file.info and file.access and I couldn't get those to work
> for me.
>
> Any help would be great!
> ben
>
>
>

[[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] Memoize and vectorize a custom function

2012-04-27 Thread Henrik Bengtsson
On Thu, Apr 26, 2012 at 3:21 PM, Kamil Slowikowski
 wrote:
> My goal is simple: calcuate GC content of each sequence in a list of
> nucleotide
> sequences. I have figured out how to vectorize, but all my attempts at
> memoization failed.
>
> Can you show me how to properly memoize my function?
>
> There is a StackOverflow post on the subject of memoization, but it does not
> help me:
> http://stackoverflow.com/questions/7262485/options-for-caching-memoization-hashing-in-r
>
> I haven't been able to find any other discussions on this subject. Searching
> for "memoise" or "memoize" on r-bloggers.com returns zero results. Searching
> for those keywords at http://r-project.markmail.org/ does not return helpful
> discussions.
>
> Here's my data:
>
>    seqs <- c("","G","C","CCC","T","","TTCCT","","C","CTC")
>
> Some sequences are missing, so they're blank `""`.
>
> I have a function for calculating GC content:
>
>    > GC <- function(s) {
>        if (!is.character(s)) return(NA)
>        n <- nchar(s)
>        if (n == 0) return(NA)
>        m <- gregexpr('[GCSgcs]', s)[[1]]
>        if (m[1] < 1) return(0)
>        return(100.0 * length(m) / n)
>    }
>
> It works:
>
>    > GC('')
>    [1] NA
>    > GC('G')
>    [1] 100
>    > GC('GAG')
>    [1] 66.7
>    > sapply(seqs, GC)
>                      G         C       CCC         T               TTCCT
>                C
>           NA 100.0 100.0 100.0   0.0        NA  40.0
>     NA 100.0
>          CTC
>     66.7
>
> I want to memoize it. Then, I want to vectorize it. Should be easy, right?
>
> Apparently, I must have the wrong mindset for using the `memoise` or
> `R.cache`
> R packages:
>
>    > system.time(dummy <- sapply(rep(seqs,100), GC))
>       user  system elapsed
>      0.044   0.000   0.054
>    >
>    > library(memoise)
>    > GCm1 <- memoise(GC)
>    > system.time(dummy <- sapply(rep(seqs,100), GCm1))
>       user  system elapsed
>      0.164   0.000   0.173
>    >
>    > library(R.cache)
>    > GCm2 <- addMemoization(GC)
>    > system.time(dummy <- sapply(rep(seqs,100), GCm2))
>       user  system elapsed
>     10.601   0.252  10.926
>
> Notice that the memoized functions are several orders of magnitude slower.

About R.cache: All memoization by R.cache is currently done toward the
file system.  In other words, it is designed for larger objects (so
you cannot hold all of the cache in memory) and more computationally
expensive tasks.

/Henrik

>
> I tried the `hash` package, but things seem to be happening behind the
> scenes
> and I don't understand the output:
>
>    > cache <- hash()
>    > GCc <- function(s) {
>        if (!is.character(s) || nchar(s) == 0) {
>            return(NA)
>        }
>        if(exists(s, cache)) {
>            return(cache[[s]])
>        }
>        result <- GC(s)
>        cache[[s]] <<- result
>        return(result)
>    }
>    > sapply(seqs,GCc)
>    [[1]]
>    [1] NA
>
>    $G
>    [1] 100
>
>    $C
>    NULL
>
>    $CCC
>    [1] 100
>
>    $T
>    NULL
>
>    [[6]]
>    [1] NA
>
>    $TTCCT
>    [1] 40
>
>    [[8]]
>    [1] NA
>
>    $C
>    NULL
>
>    $CTC
>    [1] 66.7
>
> At least I figured out how to vectorize:
>
>    > GCv <- Vectorize(GC)
>    > GCv(seqs)
>                      G         C       CCC         T               TTCCT
>                C
>      0.0 100.0 100.0 100.0   0.0   0.0  40.0
> 0.0 100.0
>          CTC
>     66.7
>
>        [[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] check if excel file is

2012-04-27 Thread Ben quant
To get around the issue below, I just wrapped it with try(), but would like
to know how to know the question below.

Thanks!

ben

On Fri, Apr 27, 2012 at 10:13 AM, Ben quant  wrote:

> Forgot this: the solution doesn't have to come from the xlsx package...
>
> thanks
>
> ben
>
>
> On Fri, Apr 27, 2012 at 10:08 AM, Ben quant  wrote:
>
>> Hello again,
>>
>> I'd like to determine if an Excel file is open or writable. Can anyone
>> help me with that?
>>
>> I write some stats to an .xlsx Excel file using the xlsx package. I can't
>> write to the file unless its closed. How do I determine if the .xlsx file
>> is open or closed so I can write to it?
>>
>> I've looked at file.info and file.access and I couldn't get those to
>> work for me.
>>
>> Any help would be great!
>> ben
>>
>>
>>
>

[[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] check if excel file is

2012-04-27 Thread Duncan Murdoch

On 27/04/2012 12:08 PM, Ben quant wrote:

Hello again,

I'd like to determine if an Excel file is open or writable. Can anyone help
me with that?
Try to write to it.  If you fail, it wasn't writable.  (You can wrap 
your attempt in try() so that it doesn't abort your program.)


If you're not ready to write to it, then open it as a connection in 
write mode.  I think that will also fail if it's not writable.  You have 
to keep it open until you're finished writing; otherwise some other 
process could grab it after your test but before you write.


Duncan Murdoch


I write some stats to an .xlsx Excel file using the xlsx package. I can't
write to the file unless its closed. How do I determine if the .xlsx file
is open or closed so I can write to it?

I've looked at file.info and file.access and I couldn't get those to work
for me.

Any help would be great!
ben

[[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] Min , Max

2012-04-27 Thread Jonsson
Dear Rui,

I really appreciate your help. This is exactly what I was looking for.I know
there is simpler way than mine but I couldn't figure it out.So, many many
thanks.

I wonder what is the difference between 

This:tm[ta[i],tb[i]]= round(mean(D[(d-1)*8 + 1:8, i])) 
 and This:  (Why not use the parameter 'digits'?) 
tm[ta[i],tb[i]]= round(mean(D[(d-1)*8 + 1:8, i]), 1) 



--
View this message in context: 
http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593159.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] Min , Max

2012-04-27 Thread R. Michael Weylandt
You might want to look into the caTools package: it provides runmean,
runmin, and runmax functions -- if you set those for a window of
length 8 and then take every 8th element, you should get what you're
looking for (much cleaner and faster too!) A good way to do that
subset is something like:

x <- 1:100
y <- x^2 - 3*x + 5
n <- 8

y[!(seq_along(x) %% n)]

Though I'm pretty sure I've seen a cleaner version elsewhere

Michael

On Fri, Apr 27, 2012 at 11:46 AM, Jonsson  wrote:
> Hellow everyone,
> This code bellow will calculate average daily wind speed(measurements are
> taken every three hours).Any ideas how to take the Min and Max instead of
> average.
>
> library(Matrix)
> setwd("C:\\Users\\aalyaari\\Desktop\\img")
> listfile<-dir()
> long <- file("C:\\Users\\aalyaari\\Desktop\\New folder (5)\\inra.bin", "rb")
>  A=readBin(long, integer(), size=2,n=67420*1, signed=F)
>  ta<-t(A)
>  lot <- file("C:\\Users\\aalyaari\\Desktop\\New folder (5)\\lat.img", "rb")
>  B=readBin(lot, integer(), size=2,n=67420*1, signed=F)
>  tb<-t(B)
>
> for (n in 1:length(listfile))
> {
>
>        #h[n]=listfile[n]
>        h=listfile[n]
>        #b[n]=file.info(h[n])$size/67420/4
>        b=file.info(h[n])$size/67420/4
>
>        wind <- file(h, "rb")
>        C=readBin(wind, double(), size=4,n=67420*b, signed=TRUE)
>
>        D<-matrix(C,nrow=b,ncol=67420)
>
>        for(d in 1:b)
>        {
>                M <- Matrix(-, 360, 720)
>        tm<-t(M)
>                for(i in 1:67420)
>                {
>                        tm[ta[i],tb[i]]= round(10 * ((D[(d-1)*8+1,i] + 
> D[(d-1)*8+2,i]
> +D[(d-1)*8+3,i] +D[(d-1)*8+4,i] +D[(d-1)*8+5,i] +D[(d-1)*8+6,i]
> +D[(d-1)*8+7,i] +D[(d-1)*8+8,i] ) / 8))
>
>                }
>                to.write <- sprintf("C:\\Users\\aalyaari\\Desktop\\New folder
> (6)\\Yar_%00d.bin", d)
>                writeBin(as.integer(tm@x), size=2,to.write)
>        }
> }
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593065.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] How to display data values for points in a plot?

2012-04-27 Thread daltieri
See 

?text

Hope it works for you.

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-display-data-values-for-points-in-a-plot-tp2197796p4592822.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] HoltWinters() fitted values

2012-04-27 Thread slipkid90515
Yeah, I was pretty sure that it needed one period to begin estimating, but it
just seemed odd to me that the plot function was able to interpolate all the
way back to the beginning (well, nearly the beginning), but the fitted
values only began after the first period.

Thanks for your response!
Jess

--
View this message in context: 
http://r.789695.n4.nabble.com/HoltWinters-fitted-values-tp4591103p4593025.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] expression() and font.lab ?

2012-04-27 Thread aparna15
Hi..

I managed to use expression() for superscripting and subscripting values in
my axis labels. However, I notice that the font and style that I had passed
through par() are ignored. 

I used :
par(font.lab=2, font=2, family="sans")

but when I employ expression() for my xlab, the styling given above is
completely ignored.

I would greatly appreciate it if someone knew of a method of maintaing the
style while superscripting or subscripting in an axis label.

Regards,
Aparna.


--
View this message in context: 
http://r.789695.n4.nabble.com/expression-and-font-lab-tp4592991p4592991.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] comparison of bivariate normal distributions

2012-04-27 Thread Fabian Roger
Hello Petr and thanks for your help! Thanks also for the correction on the 
code, of cause it is better to use the real mean and covariance than those 
estimated by mean() and cov(). What I am after is that if I have the two 
two-dimensional probability density functions of the distribution of my 
parameters, these functions should have an intersect. And if I know the 
intersect I should be able to say that a certain "volume" under both functions 
is shared by both comparable to the surface shared by two one-dimensional 
normal distributions.  From there on I was hoping to be able to say something 
about how high the probability is that my samples come from two different 
populations (in the logic of a t-test).

Would this be possible or reasonable at all?

Thank again, I really appreciate your help!

best

Fabian

Would it be possible, too to
On 26 Apr 2012, at 10:56, Petr Savicky wrote:

On Wed, Apr 25, 2012 at 08:43:34PM +, Fabian Roger wrote:
sorry for cross-posting

Dear all,

I have tow (several) bivariate distributions with a known mean and 
variance-covariance structure (hence a known density function) that I would 
like to compare in order to get an intersect that tells me something about "how 
different" these distributions are (as t-statistics for univariate 
distributions).

In order to visualize what I mean hear a little code example:


library(mvtnorm)

c<-data.frame(rnorm(1000,5,sd=1),rnorm(1000,6,sd=1))
c2<-data.frame(rnorm(1000,10,sd=2),rnorm(1000,7,sd=1))

xx=seq(0,20,0.1)
yy=seq(0,20,0.1)
xmult=cbind(rep(yy,201),rep(xx,each=201))
dens=dmvnorm(xmult,mean(c),cov(c))
dmat=matrix(dens,ncol=length(yy),nrow=length(xx),byrow=F)

dens2=dmvnorm(xmult,mean(c2),cov(c2))
dmat2=matrix(dens2,ncol=length(yy),nrow=length(xx),byrow=F)
contour(xx,yy,dmat,lwd=2)
contour(xx,yy,dmat2,lwd=2,add=T)
##

Is their an easy way to do this (maybe with dmvnorm()?) and could I interpret 
the intersect ("shared volume") in the sense of a t-statistic?

Hello:

I am not sure, what is exactly the question. The parameters
of a bivariate normal distribution are the covariance matrix and
the mean vector. For the distributions above, these are

 mean1 <- c(5, 6)
 cov1 <- diag(c(1, 1))

 mean2 <- c(10, 7)
 cov2 <- diag(c(2, 1)^2)

These parameters may be used in the code above instead of mean(c), cov(c)
and mean(c2), cov(c2).

The curves of equal density are ellipses, whose equations may be derived
from the mean vector mu and covariance matrix Sigma using the formula for
the exponent in the bivariate density of normal distribution. For any
fixed value of the density, the formula has the form

 (x - mu)' Sigma^(-1) (x - mu) = const

where (x - mu)' is the transpose of (x - mu), (x - mu) is a column
vector and const is some constant. The value of const may be derived
using the full formula for the bivariate density, which is at

 http://en.wikipedia.org/wiki/Multivariate_normal_distribution

In order to compute the area of this ellipse, we have to specify a required
density, more exactly a lower bound on the density. The area of an ellipse
is \pi a b, where a, b, are its axes. If we have two such ellipses, it is
possible to compute the area of their intersection, but again, for each
ellipse, a lower bound on the density is needed.

Is the area of the intersection of two ellipses for some specified lower
bounds on the density, what you want to compute?

Petr Savicky.

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

Fabian Roger, Ph.D. student
Dept of Biological and Environmental Sciences
University of Gothenburg
Box 461
SE-405 30 Göteborg
Sweden
Tel. +46 31 786 2933




[[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] Batch importing data

2012-04-27 Thread jiangxijixzy
I want to import data from about 2000 text files, and hope to create a data
frame to make it easy to quote the data.
For example, the files like this
Oil_20030801.txt, Oil_20030804.txt, Oil_20030805.txt … Oil_20120427.txt
The dates aren’t continuous. I want to create the data frame called “Oil”,
like that
Oil20030801<-read.table(“E:/Oil/ Oil_20030801.txt”)
Oil20030804<-read.table(“E:/Oil/ Oil_20030804.txt”)
Oil20030805<-read.table(“E:/Oil/ Oil_20030805.txt”)
…
Oil20120427<-read.table(“E:/Oil/ Oil_20120427.txt”)
It is a time consuming way. How can I perform a convenient way? Thank you!


--
View this message in context: 
http://r.789695.n4.nabble.com/Batch-importing-data-tp4592997p4592997.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] To make a graph for 4 functions

2012-04-27 Thread quantum
lets say I have these function and I want to have a graph on them

y0=x^2
y1=x^3

Then I say this

x=seq(0,10,length.out=100)
plot(x,y0,y1,type="l")

but R does not give me a graph. How would you do it?

--
View this message in context: 
http://r.789695.n4.nabble.com/To-make-a-graph-for-4-functions-tp4592941p4592941.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] multivariate xts merge question

2012-04-27 Thread Soo Sun Park
Hi,

I have an xts starting with a number of columns (currency pairs see below),
then I add new ones which are derived from existing ones (like adding the
moving average of a column) by merging the new columns one by one. These
get the name of the column they are calculated from concatenated with ".1".
All done by merge.xts, easy.

Now, I have a function (procState below) which generates n columns looking
at rows of the xts and the column names.
I understand that an xts cannot contain vectors, lists and matrices, so I
am happy with adding n new columns from the returned data frame (vector).

Unfortunately, I have been unable to accomplish this.

apply(x,1,function(y,ns) procState(y,ns), colnames(x))

gives me a list, where a non-intrinsic attribute contains the timestamp.

$`2012-03-16 16:04:00`
  aud cad chf eur gbp jpy nzd usd
1  -3  -5   7   5   1  -1   3  -7

$`2012-03-16 16:05:00`
  aud cad chf eur gbp jpy nzd usd
1  -3  -5   7   5  -1   1   3  -7

How do I merge this with the original xts?
I tried merge(x,unlist(y)) to flatten it, but instead of getting n new
columns I get the timestamps repeated n times.
I do need to stick to merge.xts because there are 10 years of minute data
and the naive merge on data frames runs out of memory.

It might be that my approach isn't the Right one, I appreciate any guidance
from seasoned users.

I'm sorry for the long winded question, but tried to follow the posting
guide to the word.

Thanks,ssp

pairs<-c("audcad", "audchf", "audjpy", "audnzd", "audusd", "cadchf",
"cadjpy", "chfjpy", "euraud", "eurcad", "eurchf", "eurgbp", "eurjpy",
"eurnzd", "eurusd", "gbpaud", "gbpcad", "gbpchf", "gbpjpy", "gbpnzd",
"gbpusd", "nzdcad", "nzdchf", "nzdjpy", "nzdusd", "usdcad", "usdchf",
"usdjpy")

procState <- function(r, nams)
# r: row
# nams: column names
{
  d<-data.frame(aud=0,cad=0,chf=0,eur=0,gbp=0,jpy=0,nzd=0,usd=0)

  st<-head(grep(".1", nams, fixed=TRUE), n=1)
  for (i in grep(".1", nams, fixed=TRUE))
  {
# first and second currency

fc<-substring(pairs[[i-st+1]],1,3)
sc<-substring(pairs[[i-st+1]],4,6)

d[[fc]] <- d[[fc]]+r[i]
d[[sc]] <- d[[sc]]+(-1*r[i])
  }
 # as.matrix(d)
 as.vector(d)
}


x<-structure(c(1.04932739130435, 1.04916, 0.9695133, 0.96952,
88.161, 88.141, 1.28334615384615, 1.2832350877193, 1.058053,
1.05801, 0.923845, 0.923921428571429, 84.01278, 84.00367,
90.92867, 90.909, 1.24416368421053, 1.24423, 1.30570214285714,
1.30553, 1.20644257575758, 1.20643348484848, 0.831628, 0.831781428571429,
109.7156, 109.685, 1.596928, 1.59683, 1.31658928571429, 1.31648,
1.49588142857143, 1.49558736842105, 1.56994, 1.569414, 1.450548,
1.45026, 131.9072, 131.854, 1.9200925, 1.91961195121951, 1.583044,
1.58268, 0.8174425, 0.81738, 0.7552675, 0.755292857142857,
68.6788571428571,
68.66633, 0.8242475, 0.82426, 0.991685, 0.9915767,
0.916344615384615, 0.916331428571429, 83.3262857142857, 83.312,
1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, 1,
1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1,
1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1,
-1, -1), class = c("xts", "zoo"), .indexCLASS = c("POSIXct",
"POSIXt"), .indexTZ = "GMT", tclass = c("POSIXct", "POSIXt"), tzone =
"GMT", index = structure(c(1331913840,
1331913900), tzone = "GMT", tclass = c("POSIXct", "POSIXt")), .Dim = c(2L,
56L), .Dimnames = list(NULL, c("audcad", "audchf", "audjpy",
"audnzd", "audusd", "cadchf", "cadjpy", "chfjpy", "euraud", "eurcad",
"eurchf", "eurgbp", "eurjpy", "eurnzd", "eurusd", "gbpaud", "gbpcad",
"gbpchf", "gbpjpy", "gbpnzd", "gbpusd", "nzdcad", "nzdchf", "nzdjpy",
"nzdusd", "usdcad", "usdchf", "usdjpy", "audcad.1", "audchf.1",
"audjpy.1", "audnzd.1", "audusd.1", "cadchf.1", "cadjpy.1", "chfjpy.1",
"euraud.1", "eurcad.1", "eurchf.1", "eurgbp.1", "eurjpy.1", "eurnzd.1",
"eurusd.1", "gbpaud.1", "gbpcad.1", "gbpchf.1", "gbpjpy.1", "gbpnzd.1",
"gbpusd.1", "nzdcad.1", "nzdchf.1", "nzdjpy.1", "nzdusd.1", "usdcad.1",
"usdchf.1", "usdjpy.1")))
>

[[alternative HTML version deleted]]

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


Re: [R] Rconsole file fails to remember GUI settings, and script window text colour option is missing

2012-04-27 Thread geotheory
Hi there, its Windows 7 (32 bit) platform.

Yes, I used R Studio when I started learning, but now prefer the simpler
basic GUI.  Maybe I'll have to go back to it, although that would seem like
such a pointlessly ridiculous defeat by poor GUI design!

--
View this message in context: 
http://r.789695.n4.nabble.com/Rconsole-file-fails-to-remember-GUI-settings-and-script-window-text-colour-option-is-missing-tp4592349p4593012.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] To make a graph for 4 functions

2012-04-27 Thread Rui Barradas
Hello,


quantum wrote
> 
> lets say I have these function and I want to have a graph on them
> 
> y0=x^2
> y1=x^3
> 
> Then I say this
> 
> x=seq(0,10,length.out=100)
> plot(x,y0,y1,type="l")
> 
> but R does not give me a graph. How would you do it?
> 

First of all, try your own code:

> y0=x^2
Error: object 'x' not found

Unlike you've said, y0=x^2 is not a function. Functions in R look like this:

y0 <- function(x) x^2
y1 <- function(x) x^3

This is chapter 10 of R-intro.pdf, "Writing your own functions".

Also, use the help system.
?plot

It will tell you that 'plot' plot x against y, not against two variables.

plot(x, y0(x), type="l")
lines(x, y1(x))

Or, use function 'curve'.

curve(x^2, from=0, to=10, col="red")
curve(x^3, from=0, to=10, col="blue", add=TRUE)

And, please, read the manual above. It WILL save you time.

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/To-make-a-graph-for-4-functions-tp4592941p4593083.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] Package for endemic channels in epidemiology

2012-04-27 Thread rafitoariaz
Does anybody knows if there is a special R package for making endemic
channels graphics in epidemiology? Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/Package-for-endemic-channels-in-epidemiology-tp4593029p4593029.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] find the eigenvector corresponding to the largest eigenvalue

2012-04-27 Thread Rebecca
Hi,
If I use the eigen() function to find the eigenvalues of a matrix, how can I 
find the eigenvector corresponding to the largest eigen value?
Thanks!
[[alternative HTML version deleted]]

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


Re: [R] Min , Max

2012-04-27 Thread Rui Barradas
Hello,


Jonsson wrote
> 
> Hellow everyone,
> This code bellow will calculate average daily wind speed(measurements are
> taken every three hours).Any ideas how to take the Min and Max instead of
> average.
> 
> library(Matrix)
> setwd("C:\\Users\\aalyaari\\Desktop\\img")
> listfile<-dir()
> long <- file("C:\\Users\\aalyaari\\Desktop\\New folder (5)\\inra.bin",
> "rb")
>  A=readBin(long, integer(), size=2,n=67420*1, signed=F)
>  ta<-t(A)
>  lot <- file("C:\\Users\\aalyaari\\Desktop\\New folder (5)\\lat.img",
> "rb")
>  B=readBin(lot, integer(), size=2,n=67420*1, signed=F)
>  tb<-t(B)
> 
> for (n in 1:length(listfile))
> {
> 
>   #h[n]=listfile[n]
>   h=listfile[n]
>   #b[n]=file.info(h[n])$size/67420/4
>   b=file.info(h[n])$size/67420/4
> 
>   wind <- file(h, "rb")
>   C=readBin(wind, double(), size=4,n=67420*b, signed=TRUE)
>  
>   D<-matrix(C,nrow=b,ncol=67420)
>  
>   for(d in 1:b)
>   {
>   M <- Matrix(-, 360, 720)
>   tm<-t(M)
>   for(i in 1:67420)
>   {
>   tm[ta[i],tb[i]]= round(10 * ((D[(d-1)*8+1,i] + 
> D[(d-1)*8+2,i]
> +D[(d-1)*8+3,i] +D[(d-1)*8+4,i] +D[(d-1)*8+5,i] +D[(d-1)*8+6,i]
> +D[(d-1)*8+7,i] +D[(d-1)*8+8,i] ) / 8))
>   
>   }
>   to.write <- sprintf("C:\\Users\\aalyaari\\Desktop\\New folder
> (6)\\Yar_%00d.bin", d)
>   writeBin(as.integer(tm@x), size=2,to.write)
>   }
> }
> 

Your code line with 'round', near the bottom, is equivalent to this simpler
line:

tm[ta[i],tb[i]]= round(10 * sum(D[(d-1)*8 + 1:8, i]) / 8)

Note that this doesn't give the average, but the average multiplied by 10.
For the average, with and without the factor 10, use

tm[ta[i],tb[i]]= round(10 * mean(D[(d-1)*8 + 1:8, i]))
tm[ta[i],tb[i]]= round(mean(D[(d-1)*8 + 1:8, i]))

(Why not use the parameter 'digits'?)
tm[ta[i],tb[i]]= round(mean(D[(d-1)*8 + 1:8, i]), 1)

Now just substitute min or max for mean.

Hope this helps,

Rui Barradas



--
View this message in context: 
http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593118.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] Error in .Call("X" ... X not in DLLS for package G

2012-04-27 Thread stat curio
Hello,

I'm calling function X as

.Call("X",a,b,PACKAGE="G")

the function X has been registered as

R_CallMethodDef callMethods [] = {
  {"X",(DL_FUNC) myfun,2},
  {NULL, NULL, 0}
};
...
R_registerRoutines(info, NULL, callMethods, NULL, NULL);

yet, I (sometimes, not all the time) get this error:

Error in .Call("X", a,b, PACKAGE = "G") :
  C symbol name "X" not in DLL for package "G"

Any idea why this might occur?

Thanks and Regards

H

[[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] find the eigenvector corresponding to the largest eigenvalue

2012-04-27 Thread Berend Hasselman

On 27-04-2012, at 17:41, Rebecca wrote:

> Hi,
> If I use the eigen() function to find the eigenvalues of a matrix, how can I 
> find the eigenvector corresponding to the largest eigen value?


What does the documentation of eigen() say in the Value section for values?

Sorted in decreasing order.
So the first item of ..$values is the largest eigenvalue and thus the first 
column of ..$vectors is the corresponding eigenvector.

Example

n <- 3
A  <- matrix(round(runif(n*n),2),nrow=n)
A
evv.A <- eigen(A)
evv.A

k <- which(abs(evv.A$values)==max(abs(evv.A$values)))
evv.A$vectors[,k]
k

Berend

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


Re: [R] Min , Max

2012-04-27 Thread Jonsson
The piece of R code given above is meant to perform calculations for many
files(12) in one folder.But I am getting this error:Error: subscript out of
bounds.It finished reading the first file(successfully) but the error arose
when it started to read the next file. Any suggestions why?. I think the
problem is in this first loop: for (n in 1:length(listfile)) { h=listfile[n]
   b=file.info(h[n])$size/67420/4

--
View this message in context: 
http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593279.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] Batch importing data

2012-04-27 Thread R. Michael Weylandt
list.files() will give you all the file names in your working
directory (you can also give it a pattern argument) then can loop over
those with something like:

lapply(list.files(), read.table)

which will put all your files in a list object. This is generally
considered much more convenient than trying to create a whole bunch of
objects with different names programmatically.

Michael

On Fri, Apr 27, 2012 at 11:23 AM, jiangxijixzy  wrote:
> I want to import data from about 2000 text files, and hope to create a data
> frame to make it easy to quote the data.
> For example, the files like this
> Oil_20030801.txt, Oil_20030804.txt, Oil_20030805.txt … Oil_20120427.txt
> The dates aren’t continuous. I want to create the data frame called “Oil”,
> like that
> Oil20030801<-read.table(“E:/Oil/ Oil_20030801.txt”)
> Oil20030804<-read.table(“E:/Oil/ Oil_20030804.txt”)
> Oil20030805<-read.table(“E:/Oil/ Oil_20030805.txt”)
> …
> Oil20120427<-read.table(“E:/Oil/ Oil_20120427.txt”)
> It is a time consuming way. How can I perform a convenient way? Thank you!
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Batch-importing-data-tp4592997p4592997.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] Min , Max

2012-04-27 Thread R. Michael Weylandt
Just a total guess but if h is the n-th element of listfile, do you
really mean to be taking the n-th element of h as well? It could be
that when you get to the second element h[n] becomes h[2] which
doesn't exist (h[1] obviously did)

If you do mean this, listfile is probably a list (possibly of lists)
so you want listfile[[n]] to get the n-th element (rather than a
sublist)

Hope this helps,
Michael

On Fri, Apr 27, 2012 at 1:28 PM, Jonsson  wrote:
> The piece of R code given above is meant to perform calculations for many
> files(12) in one folder.But I am getting this error:Error: subscript out of
> bounds.It finished reading the first file(successfully) but the error arose
> when it started to read the next file. Any suggestions why?. I think the
> problem is in this first loop: for (n in 1:length(listfile)) { h=listfile[n]
>       b=file.info(h[n])$size/67420/4
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593279.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] Min , Max

2012-04-27 Thread Rui Barradas
Hello,


Jonsson wrote
> 
> Dear Rui,
> 
> I really appreciate your help. This is exactly what I was looking for.I
> know there is simpler way than mine but I couldn't figure it out.So, many
> many thanks.
> 
> I wonder what is the difference between 
> 
> This:tm[ta[i],tb[i]]= round(mean(D[(d-1)*8 + 1:8, i])) 
>  and This:  (Why not use the parameter 'digits'?) 
> tm[ta[i],tb[i]]= round(mean(D[(d-1)*8 + 1:8, i]), 1)
> 

round defaults to 0 decimal places. The second version uses 1, just as an
example.
>From the help page:
"round rounds the values in its first argument to the specified number of
decimal places (default 0). "

See
?round

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593253.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] find the eigenvector corresponding to the largest eigenvalue

2012-04-27 Thread David Winsemius


On Apr 27, 2012, at 11:41 AM, Rebecca wrote:


Hi,
If I use the eigen() function to find the eigenvalues of a matrix,  
how can I find the eigenvector corresponding to the largest eigen  
value?


After reading the help page, I would have assumed that since the  
eigenvalues are sorted, that the eigenvectors would be sorted in the  
same order. Do you have reasons to doubt that they are not?


--

David Winsemius, MD
West Hartford, CT

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


Re: [R] PLM package PGGLS strange behavior

2012-04-27 Thread Ruben de Bliek
Hi. I can confirm my version of R to be of number 2.14.2, PLM 1.2-8. My
system:

X86 Pentium dualc. t2390 32bit, 3gb internal memory. Windows 7 build 7601,
Service Pack 1. This machine has actually just received a clean Windows 7
install. The estimated estimates do not match the correct ones.
Furthermore, I can confirm the coefficient estimates are also off using R
at my office, which also has R 2.14.2 alongside PLM 1.2-8 installed. This
is a similar machine to the one above, the only difference being the cpu
(amd).

Update: I have just downloaded and installed the latest version of R, 2.15,
on the above machine, just to see if that would fix the problem. The
wrongly estimated coefficients remain, unfortunately. I've also checked
some other examples from the JSS paper. It would appear, that the examples
using a different dataset than the EmplUK data, such as the Grunfeld
dataset, are all correctly estimated on my machine. However, I can also
reproduce the GMM results on page 18,  using the EmplUK data. The FGLS
estimator example is the only one that is not consistent with the paper,
for me. It would appear that the total sum of squares is correct, but the
residual is not.
2012/4/27 Millo Giovanni 

> **
> Hello again.
> This is really strange: I actually get the right numbers all the time. I
> tried now and got
>
> > data("EmplUK", package="plm")
> > zz <- pggls(log(emp)~log(wage)+log(capital),data=EmplUK, model="random")
> Warning message:
> 'random' argument to pggls() has been renamed as 'pooling'
> > summary(zz)
>  Random effects model
>
> Call:
> pggls(formula = log(emp) ~ log(wage) + log(capital), data = EmplUK,
> model = "random")
>
> Unbalanced Panel: n=140, T=7-9, N=1031
>
>  Residuals
>   Min.1st Qu. Median   Mean3rd Qu.   Max.
> -1.844 -0.3908000  0.0388700  0.0005525  0.4153000  1.492
>
>  Coefficients
>   Estimate Std. Error z-value Pr(>|z|)
> (Intercept)   1.751448   0.180100  9.7249  < 2e-16 ***
> log(wage)-0.132986   0.054292 -2.4495  0.01431 *
> log(capital)  0.629621   0.018483 34.0648  < 2e-16 ***
>
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> Total Sum of Squares: 1853.6
> Residual Sum of Squares: 386
> Multiple R-squared: 0.79176
> exactly as expected.
> Which is your system? (please post the output of Sys.info)  although
> I'd be surprised if this were system dependent!
>
> You might also update the package to the last version if it isn't yet,
> although I can't remember bugs in this function since a very long time.
> Thx for feedback
> Best,
> G.
>  --
> *Da:* Ruben de Bliek [mailto:rubendebl...@gmail.com]
> *Inviato:* venerdì 27 aprile 2012 16.28
> *A:* Millo Giovanni
> *Cc:* r-help@r-project.org
> *Oggetto:* Re: [R] PLM package PGGLS strange behavior
>
>   Thank you Millo. I was a little confused by the random versus pooling
> nomenclature used in PLM, thank you for clearing that up. I still have the
> issue of not receiving the proper coefficient estimates for the example in
> the paper though. My output is posted below; the estimates are
> substantially different from the ones posted on page 20. My R version is
> 2.14.2.
>
> library(plm)
> > data("EmplUK", package="plm")
> > zz <- pggls(log(emp)~log(wage)+log(capital),data=EmplUK, model="random")
> Warning message:
> 'random' argument to pggls() has been renamed as 'pooling'
> > summary(zz)
>  Random effects model
> Call:
> pggls(formula = log(emp) ~ log(wage) + log(capital), data = EmplUK,
> model = "random")
> Unbalanced Panel: n=140, T=7-9, N=1031
> Residuals
> Min.  1st Qu.   Median Mean  3rd Qu. Max.
> -1.80700 -0.36550  0.06181  0.03230  0.44280  1.58700
> Coefficients
>   Estimate Std. Error z-value  Pr(>|z|)
> (Intercept)   2.023480   0.158468 12.7690 < 2.2e-16 ***
> log(wage)-0.232329   0.048001 -4.8401 1.298e-06 ***
> log(capital)  0.610484   0.017434 35.0174 < 2.2e-16 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> Total Sum of Squares: 1853.6
> Residual Sum of Squares: 402.55
> Multiple R-squared: 0.78283
> 2012/4/27 Millo Giovanni 
>
>> Hello. No "strange behaviour" here, just a warning.
>>
>> There is a difference between an "error" and a "warning", and between an
>> argument and a model. In this specific case, the warning is just there
>> to remind you that, as stated, 'the "random" **argument** has been
>> renamed to "pooling" ' (emphasis mine).
>>
>> Both still work, but the former is deprecated. The estimator you get is
>> the same (a GGLS, or "Parks estimator"), everything works the way it
>> should and you can trust the numbers that come out, provided the
>> specification is clear to you and it is what you wanted (which for
>> instance is not entirely clear from your email).
>>
>> The model underlying the General Feasible GLS estimator (GGLS) does not
>> really have "random effects"; therefore, after having initially named
>> the model with

Re: [R] One main title and One legend for multiple lattice plots

2012-04-27 Thread Elliot
How would I do something like

xyplot(y + z + w ~ x | v, groups = n, data = dat, main = "My Title",
auto.key = TRUE)

I want the output to be an array of panels, with a column for each value of
v, a row for each of y, z, and w, and with each row having a different
y-axis scale (but the same scale within each row).

Thanks.

- Elliot

--
View this message in context: 
http://r.789695.n4.nabble.com/One-main-title-and-One-legend-for-multiple-lattice-plots-tp1598894p4593320.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] Batch importing data

2012-04-27 Thread David Winsemius


On Apr 27, 2012, at 1:30 PM, R. Michael Weylandt wrote:


list.files() will give you all the file names in your working
directory (you can also give it a pattern argument) then can loop over
those with something like:

lapply(list.files(), read.table)

which will put all your files in a list object. This is generally
considered much more convenient than trying to create a whole bunch of
objects with different names programmatically.


And if you wanted to have them named, then something like:

inputfils <- lapply(list.files(patt=".txt"), read.table)
names(inputfils)  <- sub("\\.txt", "", list.files(patt=.txt) )

Then this will let you access a particular file by name:

inputfils[["Oil_20030801"]]

--  
David.




Michael

On Fri, Apr 27, 2012 at 11:23 AM, jiangxijixzy  
 wrote:
I want to import data from about 2000 text files, and hope to  
create a data

frame to make it easy to quote the data.
For example, the files like this
Oil_20030801.txt, Oil_20030804.txt, Oil_20030805.txt …  
Oil_20120427.txt
The dates aren’t continuous. I want to create the data frame called  
“Oil”,

like that
Oil20030801<-read.table(“E:/Oil/ Oil_20030801.txt”)
Oil20030804<-read.table(“E:/Oil/ Oil_20030804.txt”)
Oil20030805<-read.table(“E:/Oil/ Oil_20030805.txt”)
…
Oil20120427<-read.table(“E:/Oil/ Oil_20120427.txt”)
It is a time consuming way. How can I perform a convenient way?  
Thank you!



--
View this message in context: 
http://r.789695.n4.nabble.com/Batch-importing-data-tp4592997p4592997.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.


David Winsemius, MD
West Hartford, CT

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


Re: [R] Min , Max

2012-04-27 Thread Jonsson
Yes this what I meant.  I think no need for  this line h=listfile[[n]],if I
can just put it directly in the other line to do the calculations for every
file in my list.they are not really elements.they are files.
  what I need is just this:get the size of each file in my list then
/67420/4,to get the number of rows and assign that to b . so  now b will be
used later as a loop.
 
I tried this also:
for (n in 1:length(listfile)).{  
 h=listfile[[n]]
 b=file.info(h[[n]])$size/67420/4
 }
then I got this :Error in h[[n]] : subscript out of bounds

--
View this message in context: 
http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593326.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] Min , Max

2012-04-27 Thread Jonsson
this is what happened with me:that when I get to the second element h[n]
becomes h[2] which 
doesn't exist (h[1] obviously did).
Any suggestions 

--
View this message in context: 
http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593401.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] Min , Max

2012-04-27 Thread Jonsson
this is what happened with me:that when I get to the second element h[n]
becomes h[2] which 
doesn't exist (h[1] obviously did).
Any suggestions 

--
View this message in context: 
http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593402.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] Wrap names.arg text in barplot

2012-04-27 Thread Kyle.
Hello!

Does anyone know of a handy way to wrap the names.arg text in a barplot?
I'm creating a bar plot with rather long labels; I can adjust the margins,
but I'd also like to have the text wrap to about 4cm. Thanks!


Kyle H. Ambert
Doctoral Candidate, Bioinformatics
Oregon Health & Science University
ambe...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] Min , Max

2012-04-27 Thread Jeff Newmiller
a) don't double post
b) provide context... the majority of R-helpers do not use nabble
c) read and believe the error message... don't subscript on a vector known to 
have one element.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Jonsson  wrote:

>this is what happened with me:that when I get to the second element
>h[n]
>becomes h[2] which 
>doesn't exist (h[1] obviously did).
>Any suggestions 
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593402.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] expression() and font.lab ?

2012-04-27 Thread David Winsemius


On Apr 27, 2012, at 11:22 AM, aparna15 wrote:


Hi..

I managed to use expression() for superscripting and subscripting  
values in

my axis labels.


What's missing here is your plotting code and your machine and R  
installation details. You may want to review the Posting Guide for  
what is requested. Plotting issues are more machine dependent than  
other aspects. Since the ?plotmath page does have details that include:


"The fonts used are taken from the current font family, and so can be  
set by par(family=) in base graphics, and gpar(fontfamily=) in package  
grid.


Note that bold, italic and bolditalic do not apply to symbols, and  
hence not to the Greek symbols such as mu which are displayed in the  
symbol font. They also do not apply to numeric constants."


... my speculation is that you may not be using base graphics or you  
may have excessive expectations regarding how symbols are displayed.  
You can sometimes get around that last limitation by using character  
values where you want numeric values in bold or italic. Again, we need  
full details. Put together a reproducible example and repost.


--
David



However, I notice that the font and style that I had passed
through par() are ignored.

I used :
par(font.lab=2, font=2, family="sans")

but when I employ expression() for my xlab, the styling given above is
completely ignored.

I would greatly appreciate it if someone knew of a method of  
maintaing the

style while superscripting or subscripting in an axis label.

Regards,
Aparna.


--
View this message in context: 
http://r.789695.n4.nabble.com/expression-and-font-lab-tp4592991p4592991.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] Min , Max

2012-04-27 Thread R. Michael Weylandt
Yes, like I said, you don't need to be subsetting h:

h = listoffiles[n]

then later just use h

Michael

On Fri, Apr 27, 2012 at 2:22 PM, Jonsson  wrote:
> this is what happened with me:that when I get to the second element h[n]
> becomes h[2] which
> doesn't exist (h[1] obviously did).
> Any suggestions
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Min-Max-tp4593065p4593402.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] To make a graph for 4 functions

2012-04-27 Thread quantum
Thanks for your response.

Now I have 3 functions for example 

y0<-function(x) x^2
y1<-function(x) x^3
y2<-function(x) x^5

t<-function(x) c(y0(x),y1(x),y2(x))

I want to plot this so I get 3 graphs in a diagram.

How can I do this?

plot(x,t(x),type="l") doesnt work.

--
View this message in context: 
http://r.789695.n4.nabble.com/To-make-a-graph-for-4-functions-tp4592941p4593316.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] kiteChart to show real values with scalebar

2012-04-27 Thread bodiless
Dear R-users

I hope someone could help me on this problem.

I want to create a multiple kiteChart showing the real values with a
scalebar on each indicating  the scale .
Here are some sample data to show what I want to achieve.

Y <- read.table(textConnection("Sample1 Sample2
   60 20
   150 50
   300 100"),header=TRUE)
X <- read.table(textConnection("Sample1 Sample2
   6 2
   15 5
   30 10"),header=TRUE)
par(las=1,mfrow=c(2,1))
kiteChart(t(Y),xlim=c(-400,400),timelabels=c("2-3cm","1-2cm","0-1cm"),
  normalize=FALSE,shownorm=FALSE,timex=FALSE)
kiteChart(t(X),xlim=c(-400,400),timelabels=c("2-3cm","1-2cm","0-1cm"),
  normalize=FALSE,shownorm=FALSE,timex=FALSE)

My first problem with the above approach is that the kites in both graphs
are overlapping. If I take out the xlim switch then the kites are too large
and you can't see anything. If I use the xlim switch then they are not
plotted next to each other as they should. Please note that I could use
normalize=TRUE and then they are plotted ok but I don't want to normalize
them.

My second problem is that I have data which are way too smaller that the
values shown in data.frame X. So, if the first graph has large values and
the second very small values then on the second graph you see only a thin
line. Therefore I want to multiply the small values of data.frame X by a
factor to make the kites visible but then I need to place a scalebar on each
graph showing e.g. that for the 0-1cm the top graph is 0-300 and the lower
graph is 0-30.

Hope that my post is not very confusing.

Thanks in advance.





--
View this message in context: 
http://r.789695.n4.nabble.com/kiteChart-to-show-real-values-with-scalebar-tp4593386p4593386.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] panel cointegration

2012-04-27 Thread phillen
Hi - i am looking for a package with which I can perform panel cointegration
tests. Old threads suggest plm and urca package, but I don't find suitable
tests in these packs. Somebody knows more?
best regards, Philipp

--
View this message in context: 
http://r.789695.n4.nabble.com/panel-cointegration-tp4593443p4593443.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] RODBC 1.3-5 under cygwin 1.7.12-1

2012-04-27 Thread Dario Buttari
I am using R 2.14.2-1 under cygwin 1.7.12-1 in Windows 7 Professional
Service Pack 1.

In the past I found very desirable to modify the RODBC package to
access the Windows ODBC connections in R under cygwin:
http://sourceforge.net/mailarchive/forum.php?thread_name=CAPCJcd5K7-9TdK6AqEzy9XpBVw68QeOYz9CY-Bo6%2BoqRu_UsGA%40mail.gmail.com&forum_name=cygwin-ports-general

This enables NTLM authenticated connections to Oracle and sql server
databases using the Windows ODBC drivers.
I would like to propose the patch below to the RODBC 1.3-5 package maintainers.
The patch is pretty much an exact copy of an old patch present in
cygwin-ports: 
http://cygwin-ports.git.sourceforge.net/git/gitweb.cgi?p=cygwin-ports/R-RODBC;a=summary

I would like to point out that R is now part of the std cygwin
packages: http://cygwin.com/packages/
In using R under cygwin just because I found that combining R to the
unix command line is quite powerful and convenient.
Thanks, Dario

Modify RODBC\src\RODBC.c in RODBC_1.3-5.tar as follows:
--
--- RODBC.c_bk  2012-03-08 22:01:02.0 -0800
+++ RODBC.c 2012-04-22 09:14:54.353868700 -0700
@@ -41,6 +41,12 @@
 #include 
 #include  /* for INT_MAX */

+#ifdef __CYGWIN__
+#define WIN32_LEAN_AND_MEAN
+#include 
+#undef WIN32
+#endif
+
 #define MAX_CHANNELS 1000
 #include 
 #include 
--

Installation procedure under Cygwin to access the windows ODBC DNSs:
export ac_cv_search_SQLTables="-lodbc32"
R CMD INSTALL RODBC_1.3-5.tar.gz

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


Re: [R] To make a graph for 4 functions

2012-04-27 Thread R. Michael Weylandt
Use curve() like Rui said.

Michael

On Fri, Apr 27, 2012 at 1:48 PM, quantum  wrote:
> Thanks for your response.
>
> Now I have 3 functions for example
>
> y0<-function(x) x^2
> y1<-function(x) x^3
> y2<-function(x) x^5
>
> t<-function(x) c(y0(x),y1(x),y2(x))
>
> I want to plot this so I get 3 graphs in a diagram.
>
> How can I do this?
>
> plot(x,t(x),type="l") doesnt work.
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/To-make-a-graph-for-4-functions-tp4592941p4593316.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] panel cointegration

2012-04-27 Thread David Winsemius


On Apr 27, 2012, at 2:38 PM, phillen wrote:

Hi - i am looking for a package with which I can perform panel  
cointegration
tests. Old threads suggest plm and urca package, but I don't find  
suitable

tests in these packs. Somebody knows more?
best regards, Philipp


http://cran.r-project.org/web/views/Econometrics.html




--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Wrap names.arg text in barplot

2012-04-27 Thread William Dunlap
You can use strwrap  and paste to insert newlines into your labels.  E.g.,

> wrapped <- function(strings, width) vapply(strings, 
> function(s)paste(collapse="\n", strwrap(s, width)), FUN.VALUE="", 
> USE.NAMES=FALSE)
> par(mfrow=c(2,1))
> barplot(structure(11:15, names=wrapped(state.name[31:35], 6)))
> barplot(structure(11:15, names=state.name[31:35]))
> wrapped(state.name[31:35], 6)
[1] "New\nMexico" "New\nYork"   "North\nCarolina" "North\nDakota"  
[5] "Ohio"   

strwrap, hence the above wrapped, uses units of characters, not cm.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Kyle.
> Sent: Friday, April 27, 2012 11:35 AM
> To: RHelp
> Subject: [R] Wrap names.arg text in barplot
> 
> Hello!
> 
> Does anyone know of a handy way to wrap the names.arg text in a barplot?
> I'm creating a bar plot with rather long labels; I can adjust the margins,
> but I'd also like to have the text wrap to about 4cm. Thanks!
> 
> 
> Kyle H. Ambert
> Doctoral Candidate, Bioinformatics
> Oregon Health & Science University
> ambe...@gmail.com
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Wrap names.arg text in barplot

2012-04-27 Thread Kyle.
Oh! Great idea. I'll give that a try.


---Kyle.

On Fri, Apr 27, 2012 at 12:00 PM, William Dunlap  wrote:

> You can use strwrap  and paste to insert newlines into your labels.  E.g.,
>
> > wrapped <- function(strings, width) vapply(strings,
> function(s)paste(collapse="\n", strwrap(s, width)), FUN.VALUE="",
> USE.NAMES=FALSE)
> > par(mfrow=c(2,1))
> > barplot(structure(11:15, names=wrapped(state.name[31:35], 6)))
> > barplot(structure(11:15, names=state.name[31:35]))
> > wrapped(state.name[31:35], 6)
> [1] "New\nMexico" "New\nYork"   "North\nCarolina" "North\nDakota"
> [5] "Ohio"
>
> strwrap, hence the above wrapped, uses units of characters, not cm.
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf
> > Of Kyle.
> > Sent: Friday, April 27, 2012 11:35 AM
> > To: RHelp
> > Subject: [R] Wrap names.arg text in barplot
> >
> > Hello!
> >
> > Does anyone know of a handy way to wrap the names.arg text in a barplot?
> > I'm creating a bar plot with rather long labels; I can adjust the
> margins,
> > but I'd also like to have the text wrap to about 4cm. Thanks!
> >
> >
> > Kyle H. Ambert
> > Doctoral Candidate, Bioinformatics
> > Oregon Health & Science University
> > ambe...@gmail.com
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

[[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] R2HTML output shows NULL

2012-04-27 Thread Erin Hodgess
Hello R People:

I am using the R2HTML program for the first time (actually yesterday),
and I have a question, please:

I am getting NULL in the webpage in several places, presumably where
NULL would appear on the screen.

How would I go about fixing that, please?

Thanks,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

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


Re: [R] R2HTML output shows NULL

2012-04-27 Thread Jeff Newmiller
Haven't you been asked to provide an example of code that illustrates your 
problem often enough by now to anticipate the request in your first post?
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Erin Hodgess  wrote:

>Hello R People:
>
>I am using the R2HTML program for the first time (actually yesterday),
>and I have a question, please:
>
>I am getting NULL in the webpage in several places, presumably where
>NULL would appear on the screen.
>
>How would I go about fixing that, please?
>
>Thanks,
>Erin
>
>
>-- 
>Erin Hodgess
>Associate Professor
>Department of Computer and Mathematical Sciences
>University of Houston - Downtown
>mailto: erinm.hodg...@gmail.com
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Deleting observations from baseline that don't appear in follow up

2012-04-27 Thread justin jarvis
Hello all,
I'm almost embarrassed to post this , it seems so easy.  Suppose I have a
baseline and follow up survey but some people are missing in the follow up:

> baseline<-data.frame(id=c(3,5,7,9,12), data= runif(5))
> follow.up<-data.frame(id=c(3,7,9,12), data= runif(4))
> baseline
  id   data
1  3 0.66771988
2  5 0.28794744
3  7 0.01892821
4  9 0.64863175
5 12 0.86485882
> follow.up
  id  data
1  3 0.8237210
2  7 0.8140544
3  9 0.8803674
4 12 0.8031520

Here, in follow up we are missing person #5.  I need to delete him from the
baseline, so that I have an equal number of rows once again.  Obviously

baseline<-baseline[-2,] won't cut it here, since in my data set I have
thousands of people.

Thanks in advance

Justin

[[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] Deleting observations from baseline that don't appear in follow up

2012-04-27 Thread Sarah Goslee
What about

baseline[baseline$id %in% follow.up$id, ]

or the same thing but using subset().

Sarah

On Fri, Apr 27, 2012 at 4:36 PM, justin jarvis
 wrote:
> Hello all,
> I'm almost embarrassed to post this , it seems so easy.  Suppose I have a
> baseline and follow up survey but some people are missing in the follow up:
>
>> baseline<-data.frame(id=c(3,5,7,9,12), data= runif(5))
>> follow.up<-data.frame(id=c(3,7,9,12), data= runif(4))
>> baseline
>  id       data
> 1 3 0.66771988
> 2  5 0.28794744
> 3  7 0.01892821
> 4  9 0.64863175
> 5 12 0.86485882
>> follow.up
>  id      data
> 1  3 0.8237210
> 2 7 0.8140544
> 3  9 0.8803674
> 4 12 0.8031520
>
> Here, in follow up we are missing person #5.  I need to delete him from the
> baseline, so that I have an equal number of rows once again.  Obviously
>
> baseline<-baseline[-2,] won't cut it here, since in my data set I have
> thousands of people.
>
> Thanks in advance
>
> Justin

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

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


Re: [R] Deleting observations from baseline that don't appear in follow up

2012-04-27 Thread Jeff Newmiller
Read ?merge
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

justin jarvis  wrote:

>Hello all,
>I'm almost embarrassed to post this , it seems so easy.  Suppose I have
>a
>baseline and follow up survey but some people are missing in the follow
>up:
>
>> baseline<-data.frame(id=c(3,5,7,9,12), data= runif(5))
>> follow.up<-data.frame(id=c(3,7,9,12), data= runif(4))
>> baseline
>  id   data
>1  3 0.66771988
>2  5 0.28794744
>3  7 0.01892821
>4  9 0.64863175
>5 12 0.86485882
>> follow.up
>  id  data
>1  3 0.8237210
>2  7 0.8140544
>3  9 0.8803674
>4 12 0.8031520
>
>Here, in follow up we are missing person #5.  I need to delete him from
>the
>baseline, so that I have an equal number of rows once again.  Obviously
>
>baseline<-baseline[-2,] won't cut it here, since in my data set I have
>thousands of people.
>
>Thanks in advance
>
>Justin
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


[R] determining if a function exists in a particular package

2012-04-27 Thread Erin Hodgess
Hello R People:

Is there a way to determine if a function exists in a particular
package, please?

I looked at exists and objects, but they seem to refer to an
environment rather than a package.

I was thinking of something like:

ifelse(exists(functiona) in MASS, print(1:10), print(5))

Thanks,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

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


Re: [R] determining if a function exists in a particular package

2012-04-27 Thread Erin Hodgess
I found the solution in an old post:

It's
lsf.str("package:ts")

for functions.

Cool!

On Fri, Apr 27, 2012 at 4:12 PM, Mark Leeds  wrote:
> Hi Erin: I don't know how to do it programatically but it might be quicker
> to just
> go to the vignette and click on it. All the functions should be in the right
> column of
> the pdf. Of course, you may have reason for needing it programatically in
> which
> case, my apologies for the noise !
>
> On Fri, Apr 27, 2012 at 5:07 PM, Erin Hodgess 
> wrote:
>>
>> Hello R People:
>>
>> Is there a way to determine if a function exists in a particular
>> package, please?
>>
>> I looked at exists and objects, but they seem to refer to an
>> environment rather than a package.
>>
>> I was thinking of something like:
>>
>> ifelse(exists(functiona) in MASS, print(1:10), print(5))
>>
>> Thanks,
>> Erin
>>
>>
>> --
>> Erin Hodgess
>> Associate Professor
>> Department of Computer and Mathematical Sciences
>> University of Houston - Downtown
>> mailto: erinm.hodg...@gmail.com
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

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


Re: [R] determining if a function exists in a particular package

2012-04-27 Thread Sarah Goslee
You can also use exists():
> library(MASS)
> exists("loglm", where=search()[grepl("MASS", search())])
[1] TRUE
> exists("loglmx", where=search()[grepl("MASS", search())])
[1] FALSE

As for lsf.str(), this only works for loaded packages. You didn't
specify whether you needed to be able to search loaded packages,
installed packages, or packages that exist on CRAN.

Package sos might be helpful for the last of those; you can use
help.search and grep to search for functions within installed but
unloaded packages.

Since you didn't tell us anything about your objectives, it's
impossible to know what you are really looking for.

Sarah


On Fri, Apr 27, 2012 at 5:13 PM, Erin Hodgess  wrote:
> I found the solution in an old post:
>
> It's
> lsf.str("package:ts")
>
> for functions.
>
> Cool!
>
> On Fri, Apr 27, 2012 at 4:12 PM, Mark Leeds  wrote:
>> Hi Erin: I don't know how to do it programatically but it might be quicker
>> to just
>> go to the vignette and click on it. All the functions should be in the right
>> column of
>> the pdf. Of course, you may have reason for needing it programatically in
>> which
>> case, my apologies for the noise !
>>
>> On Fri, Apr 27, 2012 at 5:07 PM, Erin Hodgess 
>> wrote:
>>>
>>> Hello R People:
>>>
>>> Is there a way to determine if a function exists in a particular
>>> package, please?
>>>
>>> I looked at exists and objects, but they seem to refer to an
>>> environment rather than a package.
>>>
>>> I was thinking of something like:
>>>
>>> ifelse(exists(functiona) in MASS, print(1:10), print(5))
>>>
>>> Thanks,
>>> Erin
>>>

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

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


Re: [R] panel cointegration

2012-04-27 Thread phillen
I found the unit root test function /purtest/ in the plm package but nothing
spefifical about cointegration. I really would be grateful if anyone knew
about a package for panel cointegration tests.
best regards, Philipp

--
View this message in context: 
http://r.789695.n4.nabble.com/panel-cointegration-tp4593443p4593525.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] expression() and font.lab ?

2012-04-27 Thread Aparna Radhakrishnan
Hi...sorry that my question seemed incomplete.

The plotting code :
par(cex.axis=0.8,las=1,font.lab=2,font.axis=2,family="sans",mgp=c(2,1,0),mar=c(3,
 3, 4, 2)+0.1)
plot(A$pos,-log(A$GPVI_frequentist_add_Batch_expected_pvalue,10),col=A$R2class,pch=A$pch,xlim=c(161160087,161214038),ylim=c(0,7),xlab="Genomic
 position",ylab=expression(-log[10]~(P-value)))

I am using a MacBook Pro and I have the R 2.15.0 . I have used only the 
base-graphics and not loaded any other libraries.

Hope that completes the question.

Please also find the plot attached here. Note the y-axis label is not in bold 
face or in "sans" font.

Regards,
Aparna.


On 27 Apr 2012, at 19:36, David Winsemius wrote:

> 
> On Apr 27, 2012, at 11:22 AM, aparna15 wrote:
> 
>> Hi..
>> 
>> I managed to use expression() for superscripting and subscripting values in
>> my axis labels.
> 
> What's missing here is your plotting code and your machine and R installation 
> details. You may want to review the Posting Guide for what is requested. 
> Plotting issues are more machine dependent than other aspects. Since the 
> ?plotmath page does have details that include:
> 
> "The fonts used are taken from the current font family, and so can be set by 
> par(family=) in base graphics, and gpar(fontfamily=) in package grid.
> 
> Note that bold, italic and bolditalic do not apply to symbols, and hence not 
> to the Greek symbols such as mu which are displayed in the symbol font. They 
> also do not apply to numeric constants."
> 
> ... my speculation is that you may not be using base graphics or you may have 
> excessive expectations regarding how symbols are displayed. You can sometimes 
> get around that last limitation by using character values where you want 
> numeric values in bold or italic. Again, we need full details. Put together a 
> reproducible example and repost.
> 
> -- 
> David
> 
> 
>> However, I notice that the font and style that I had passed
>> through par() are ignored.
>> 
>> I used :
>> par(font.lab=2, font=2, family="sans")
>> 
>> but when I employ expression() for my xlab, the styling given above is
>> completely ignored.
>> 
>> I would greatly appreciate it if someone knew of a method of maintaing the
>> style while superscripting or subscripting in an axis label.
>> 
>> Regards,
>> Aparna.
>> 
>> 
>> --
>> View this message in context: 
>> http://r.789695.n4.nabble.com/expression-and-font-lab-tp4592991p4592991.html
>> Sent from the R help mailing list archive at Nabble.com.
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> David Winsemius, MD
> West Hartford, CT
> 

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


Re: [R] Selecting columns whose names contain "mutated" except when they also contain "non" or "un"

2012-04-27 Thread Paul Miller
Hi Greg,

This is very helpful. Thanks for explaining it. I'm clearly going to need to 
improve my understanding of regular expressions. Currently busy trying to 
figure out Sweave and knitr though.

Paul

--- On Thu, 4/26/12, Greg Snow <538...@gmail.com> wrote:

> From: Greg Snow <538...@gmail.com>
> Subject: Re: [R] Selecting columns whose names contain "mutated" except when 
> they also contain "non" or "un"
> To: "Paul Miller" 
> Cc: r-help@r-project.org
> Received: Thursday, April 26, 2012, 1:55 PM
> Sorry I took so long getting back to
> this, but the paying job needs to
> take priority.
> 
> The regular expression "(? looks for a string that
> matches "muta" then looks at the characters immediately
> before it to
> see if they match either "un" or "non" in which case it
> makes it a not
> match.  More specifically the regular expression engine
> steps through
> the string and at each point tries the match, so at a given
> point it
> will first see if "un" is before that point, if it is then
> this point
> can't match and it moves the checking point, if it is not
> "un" then it
> moves to the next negative look behind and sees if "non" is
> just
> before the point.  If neither "un" or "non" are just
> before the point
> then it starts matching characters after the point to see if
> they
> match "muta".
> 
> So the next pattern is "(?!muta)non|un", the (?!muta) is a
> negative
> look ahead which starts at the point and checks forward to
> see that
> the next characters are not "muta" (but does not include
> them in the
> match), in this case it is a no-op because you are saying
> that you
> want to match at a point where the next characters are not
> "muta" but
> are "non"  and since the next set of characters cannot
> be both this is
> the same as just matching "non", also you need to be aware
> of the
> operator precedence, in that pattern the (?!muta) part only
> applied to
> the "non", not the "un".
> 
> To match "nonmuta" or "unmuta" a simple pattern would just
> be
> "(non|un)muta" or "(no|u)nmuta".  You could use the
> positive
> lookbehind (you would still need an "or"), but it would be
> overkill
> for a grep command.  The difference in the positive
> look ahead/behind
> is more important for replacing where the look ahead/behind
> is needed
> for the match to happen, but is not captured as part of the
> match to
> be replaced.
> 
> 
> 
> On Tue, Apr 24, 2012 at 7:40 AM, Paul Miller 
> wrote:
> > Hi Greg,
> >
> > This is quite helpful. Not so good yet with regular
> expressions in general or Perl-like regular expressions.
> Found the help page though, and think I was able to
> determine how the code works as well as how I would select
> only instances where "muta" is preceeded by either "non" or
> "un".
> >
> >> (tmp <-
> c('mutation','nonmutated','unmutated','verymutated','other'))
> > [1] "mutation"    "nonmutated"  "unmutated"  
> "verymutated" "other"
> >
> >> grep("(? > [1] 1 4
> >
> >> grep("(?!muta)non|un", tmp, perl=TRUE)
> > [1] 2 3
> >
> > Did I get the second grep right?
> >
> > If so, do you have any sense of why it seems to fail
> when I apply it to my data?
> >
> >> KRASyn$NonMutant_comb <-
> rowSums(KRASyn[grep("(?!muta)non|un", names(KRASyn),
> perl=TRUE)])
> >
> > Error in rowSums(KRASyn[grep("(?!muta)non|un",
> names(KRASyn), perl = TRUE)]) :
> >  'x' must be numeric
> >
> > Thanks,
> >
> > Paul
> >
> 
> 
> 
> -- 
> Gregory (Greg) L. Snow Ph.D.
> 538...@gmail.com
>

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


[R] Returning the coef from two coordinates

2012-04-27 Thread Hans Thompson
Thank you to everyone in this forum that has been helping me with the basic R
skills while I learn to apply them.  

I would like to take the coefficient of two coordinates.  One of them comes
from two different columns in a table:


>A
 x   y  
a  1   3
b  2   2
c  3   1

the other is set and for this question I'll just call it (1,1)

I've been trying to find a way to return the coefficient values for a,b, and
c through (1,1). 

 Also, it looks like my questions are very basic compared to the others
being asked on this forum so please let me know if I am out of place.  :)



--
View this message in context: 
http://r.789695.n4.nabble.com/Returning-the-coef-from-two-coordinates-tp4593504p4593504.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] To make a graph for 4 functions

2012-04-27 Thread quantum
How can I use the curve when I have a vector? How should the R code look
like?

--
View this message in context: 
http://r.789695.n4.nabble.com/To-make-a-graph-for-4-functions-tp4592941p4593672.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] determining if a function exists in a particular package

2012-04-27 Thread Gabor Grothendieck
On Fri, Apr 27, 2012 at 5:13 PM, Erin Hodgess  wrote:
> I found the solution in an old post:
>
> It's
> lsf.str("package:ts")
>
> for functions.
>
> Cool!
>

Note that that gives exported functions.  If you also want internal
functions in addition to the exported ones then try this:

library(ts)
lsf.str(asNamespace("ts"))

Also note that these not give functions whose name starts with dot
unnless all.names=TRUE is added as an argument.

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

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


[R] Hyperspec package: need to change spectra names in a stacked plot

2012-04-27 Thread Roberto
Hi all,
I need to insert the name of spectra in a stacked plot obtained with
hyperspec.

I use this command
plot(spectra [c(-1:-4, -6:-8, -10:-12, -14:-16)], stacked = T)

but, in this way R draw  nameless spectra on the Y axis.

How can I solve the problem?

Thank you for any suggestion.
Best regards,
Roberto



--
View this message in context: 
http://r.789695.n4.nabble.com/Hyperspec-package-need-to-change-spectra-names-in-a-stacked-plot-tp4593690p4593690.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] To make a graph for 4 functions

2012-04-27 Thread Rui Barradas
Hello,


quantum wrote
> 
> How can I use the curve when I have a vector? How should the R code look
> like?
> 

You can't. From the manual:

"expr   The name of a function, or a call or an expression written as a
function of x which will evaluate to an object of the same length as x."

Your function does not return an object of the same length as x. It triples
it's length.
You are complicating what is simple and was already answered.

Your latest function, t, has that problem.
A second problem is that it returns a vector when to make some sense it
should return a matrix.
?cbind

A third problem is the name 't', it is the name of R's matrix transpose
function.

Tip: Plot each curve one at a time like said before.

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/To-make-a-graph-for-4-functions-tp4592941p4593708.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] Returning the coef from two coordinates

2012-04-27 Thread Rui Barradas
Hello,


Hans Thompson wrote
> 
> Thank you to everyone in this forum that has been helping me with the
> basic R skills while I learn to apply them.  
> 
> I would like to take the coefficient of two coordinates.  One of them
> comes from two different columns in a table:
> 
> 
>>A
>  x   y  
> a  1   3
> b  2   2
> c  3   1
> 
> the other is set and for this question I'll just call it (1,1)
> 
> I've been trying to find a way to return the coefficient values for a,b,
> and c through (1,1). 
> 
>  Also, it looks like my questions are very basic compared to the others
> being asked on this forum so please let me know if I am out of place.  :)
> 

Sorry, but I'm not understanding what (1, 1) is. Are those the matrix A
coordinates, (row, col)?
If so, use an index matrix, with two columns. Here is an example.

elm1 <- c(1, 1)
elm2 <- c(2, 1)
inx <- matrix(c(elm1, elm2), ncol=2, byrow=TRUE)
colnames(inx) <- c("Row", "Col")
inx

A[inx]

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/Returning-the-coef-from-two-coordinates-tp4593504p4593723.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] Returning the coef from two coordinates

2012-04-27 Thread Hans Thompson
I meant (1,1) as an (x,y) coordinate.  I am trying to find the function to
return the coefficient of the line running through:

>B
x  y
a  1  1

and all the points in:

>A
 x   y  
a  1   3
b  2   2
c  3   1

hope that is more clear.  Thanks again Rui.

--
View this message in context: 
http://r.789695.n4.nabble.com/Returning-the-coef-from-two-coordinates-tp4593504p4593754.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] Returning the coef from two coordinates

2012-04-27 Thread Bert Gunter
Have you read "An Introduction to R" or other basic R tutorial? I
don't completely understand what you're asking (I was unable to
decipher"coefficients of two coordinates") , but it seems shockingly
basic. Before posting to this list, you should at least make some
effort to learn basic skills on your own.

... and when you do post, please follow the posting guide and frame
your questions more clearly (although maybe it's just me here...).

-- Bert

On Fri, Apr 27, 2012 at 12:04 PM, Hans Thompson
 wrote:
> Thank you to everyone in this forum that has been helping me with the basic R
> skills while I learn to apply them.
>
> I would like to take the coefficient of two coordinates.  One of them comes
> from two different columns in a table:
>
>
>>A
>     x   y
> a  1   3
> b  2   2
> c  3   1
>
> the other is set and for this question I'll just call it (1,1)
>
> I've been trying to find a way to return the coefficient values for a,b, and
> c through (1,1).
>
>  Also, it looks like my questions are very basic compared to the others
> being asked on this forum so please let me know if I am out of place.  :)
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Returning-the-coef-from-two-coordinates-tp4593504p4593504.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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] Returning the coef from two coordinates

2012-04-27 Thread Sarah Goslee
You mean like a linear regression?
?lm

You might benefit from reading at the very least An Introduction to R
and the posting guide to this list.

Sarah


On Fri, Apr 27, 2012 at 5:08 PM, Hans Thompson  wrote:
> I meant (1,1) as an (x,y) coordinate.  I am trying to find the function to
> return the coefficient of the line running through:
>
>>B
>    x  y
> a  1  1
>
> and all the points in:
>
>>A
>     x   y
> a  1   3
> b  2   2
> c  3   1
>
> hope that is more clear.  Thanks again Rui.
>
-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] expression() and font.lab ?

2012-04-27 Thread David Winsemius

converted formated text to plain text.
On Apr 27, 2012, at 3:52 PM, Aparna Radhakrishnan wrote:


Hi...sorry that my question seemed incomplete.

The plotting code :
par
(cex
.axis
=
0.8,las=1,font.lab=2,font.axis=2,family="sans",mgp=c(2,1,0),mar=c(3,  
3, 4, 2)+0.1)
plot(A$pos,-log(A$GPVI_frequentist_add_Batch_expected_pvalue, 
10),col=A$R2class,pch=A 
$pch,xlim=c(161160087,161214038),ylim=c(0,7),xlab="Genomic  
position",ylab=expression(-log[10]~(P-value)))




Well, since you didn't give the data, most of that plot argument is  
superfluous. Lets just use plot(1,1) as out staring point.  Plotmath  
expression interpetation of the font choices among plain, bold and  
italic are controlled by plotmath functions, so:


plot(1,1, ylab=expression( bold(-log[10]~(P-value) ) ) )

Now, thinking as the plotmath interpreter which considers "-" to be  
meaningful and then back as a human interpreter, I would suggest that  
you also consider whether this is what you really wanted:


plot(1,1, ylab=expression(bold(-log[10]~(P*"-"*value))) ) # no spaces  
fore and aft of the minus sign


Noting that one needs to quote the minus sing to prevent its  
interpretation as as minus sign. Or perhaps (thinking now as a human- 
plotmath hybrid):


plot(1,1, ylab=expression(bold(-log[bold("10")]~(P*"-"*value))) )


(Note that I suggested earlier that there _was_ a way to get numbers  
bold()-ed.)


--
David.

I am using a MacBook Pro and I have the R 2.15.0 . I have used only  
the base-graphics and not loaded any other libraries.


Hope that completes the question.

Please also find the plot attached here. Note the y-axis label is  
not in bold face or in "sans" font.


Regards,
Aparna.


On 27 Apr 2012, at 19:36, David Winsemius wrote:



On Apr 27, 2012, at 11:22 AM, aparna15 wrote:


Hi..

I managed to use expression() for superscripting and subscripting  
values in

my axis labels.


What's missing here is your plotting code and your machine and R  
installation details. You may want to review the Posting Guide for  
what is requested. Plotting issues are more machine dependent than  
other aspects. Since the ?plotmath page does have details that  
include:


"The fonts used are taken from the current font family, and so can  
be set by par(family=) in base graphics, and gpar(fontfamily=) in  
package grid.


Note that bold, italic and bolditalic do not apply to symbols, and  
hence not to the Greek symbols such as mu which are displayed in  
the symbol font. They also do not apply to numeric constants."


... my speculation is that you may not be using base graphics or  
you may have excessive expectations regarding how symbols are  
displayed. You can sometimes get around that last limitation by  
using character values where you want numeric values in bold or  
italic. Again, we need full details. Put together a reproducible  
example and repost.


--
David



However, I notice that the font and style that I had passed
through par() are ignored.

I used :
par(font.lab=2, font=2, family="sans")

but when I employ expression() for my xlab, the styling given  
above is

completely ignored.

I would greatly appreciate it if someone knew of a method of  
maintaing the

style while superscripting or subscripting in an axis label.

Regards,
Aparna.








David Winsemius, MD
West Hartford, CT

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


Re: [R] determining if a function exists in a particular package

2012-04-27 Thread William Dunlap
> I looked at exists and objects, but they seem to refer to an
> environment rather than a package.

Those functions work with the names of attached packages, but you have
know that the name of an attached package has "package:" prefixed to
the package's usual name.  E.g.,
  > exists("lm", "package:stats")
  [1] TRUE
  > objects("package:stats", pattern="iso")
  [1] "isoreg"
If you leave off the "package:" you might be misled into thinking an
environment is required:
  > objects("stats", pattern="iso")
  Error in as.environment(pos) : no item called "stats" on the search list

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Erin Hodgess
> Sent: Friday, April 27, 2012 2:08 PM
> To: R help
> Subject: [R] determining if a function exists in a particular package
> 
> Hello R People:
> 
> Is there a way to determine if a function exists in a particular
> package, please?
> 
> I looked at exists and objects, but they seem to refer to an
> environment rather than a package.
> 
> I was thinking of something like:
> 
> ifelse(exists(functiona) in MASS, print(1:10), print(5))
> 
> Thanks,
> Erin
> 
> 
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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