Re: [R] the problem about sample size

2012-02-29 Thread Petr PIKAL
Hi
> 
> Hi, there,
> 
> I run into the same sample size error in JM. Have you found the solution 
for
> the error?

What error?
Petr

> 
> Many thanks,
> Helena
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/the-problem-
> about-sample-size-tp1592855p4434009.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 define a function which includes two functions as arguments such as "plot" and "text"

2012-02-29 Thread Yashwanth M.R
Thank you for the suggestions you have included in the mail. Since this is
my first job and this is the first time I am coordinating with a mailing
list so I was not aware of these formalities. 

 

My objective of writing this function is to produce a personalized report
using "R2HTML". We internally build the predictive models and try to write
the report using R2HTML. There I found this problem and still struggling. I
will again go through the book you suggested and will update you shortly.

 

Regards,

Yashwanth M.R

 

From: Uwe Ligges-3 [via R] [mailto:ml-node+s789695n4432330...@n4.nabble.com]

Sent: Wednesday, February 29, 2012 11:20 PM
To: Yashwanth M.R
Subject: Re: To define a function which includes two functions as arguments
such as "plot" and "text"

 



On 28.02.2012 07:04, Yashwanth M.R wrote: 
> Hi  Mr. Uwe Ligges, 

Yashwanth M.R, 

this is the R-help mailing list, not my personal mail account (and "Mr." 
is inappropriate in any case). 


> 
> 
>  I really thankful for the reply.  I even tried the same, 
> means writing the new function. But the result is same as the last. Here
is 
> the picture below, 
> 
> 
> 
> 
> 
>  Telco.Rpart.PLOT.TEXT.Functn<- 
> function(Telco.Rpart.METHOD.CLASS) 
> 
>  { 
> 
>  Telco.Rpart.PLOT<- 
> plot(Telco.Rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE) 
> 
>  Telco.Rpart.TEXT<- 
> text(Telco.Rpart.METHOD.CLASS,use.n = TRUE, cex = .75) 
> 
>  } 
> 
> 
> 
>Telco.Rpart.PLOT.TEXT<- 
> Telco.Rpart.PLOT.TEXT.Functn(Telco.Rpart.METHOD.CLASS) 
> 
> Telco.Rpart.PLOT.TEXT 
> 
> 
> 
> 
> 
> Again if I solely run the command "Telco.Rpart.PLOT.TEXT", 


That is the value returned from the previous function call, not a 
command nor a function. 


> the output it is 
> displaying as "NULL". Please help me finding out the desired result ASAP. 

Yes, since that ws the result of calling the previous function. 

Your output is not reproducible hence it is hard to help for us, we do 
not really understand what you are going to do with functions, and you 
should start reading "An Introduction to R" in order to get a basic 
sense of R. Finally, this is a mailning list driven by volunteers, and 
sense some rudeness in demanding things "ASAP". 

Best, 
Uwe Ligges 





> 
> 
> 
> 
> Regards, 
> 
> Yashwanth M.R 
> 
> 
> 
> 
> 
> 
> 
> From: Uwe Ligges-3 [via R] [mailto:[hidden email]] 
> 
> Sent: Friday, February 24, 2012 9:16 PM 
> To: Yashwanth M.R 
> Subject: Re: To define a function which includes two functions as
arguments 
> such as "plot" and "text" 
> 
> 
> 
> 
> 
> On 24.02.2012 12:22, Yashwanth M.R wrote: 
> 
> 
>> Here is the two functions which I have used during my practice. 
>> 
>> *plot(Telco.rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE) 
>> 
>> text(Telco.rpart.METHOD.CLASS,use.n = TRUE, cex = .75))* 
>> 
>> "Telco.rpart.METHOD.CLASS" is my "rpart" object of the method "class". 
>> 
>> If I run this, 
>> 
>> *Telco.Rpart.PLOT.TEXT<- 
>> c(plot(Telco.rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE), 
>>  text(Telco.rpart.METHOD.CLASS,use.n = TRUE, cex = 
>> .75)) 
> 
> 
> 
> c() concatenates the returned values of the two functions. If you want 
> to define a sequence of function calls, define them within your own 
> function, calling that new function will produce your desired results, 
> as far as I understand. 
> 
> Uwe Ligges 
> 
> 
>> 
>> http://r.789695.n4.nabble.com/file/n4416881/Rpart.gif
>> 
>> the output is getting generated as shown in the figure. But if I solely 
> run 
>> the same command "Telco.Rpart.PLOT.TEXT" right after the above, the
output 
> 
>> is as below, 
>> 
>> /$x 
>>[1]  4.035156  1.00  7.070312  3.015625  2.00  4.031250 
>>[7]  3.00  5.062500  4.00  6.125000  5.00  7.25 
>> [13]  6.50  6.00  7.00  8.00 11.125000 10.25 
>> [19]  9.50  9.00 10.00 11.00 12.00 
>> 
>> $y 
>>[1] 1.125 1.000 1.000 0.875 0.750 0.750 0.625 0.625 0.500 0.500 0.375 
>> [12] 0.375 0.250 0.125 0.125 0.250 0.875 0.750 0.625 0.500 0.500 0.625 
>> [23] 0.750 
>> / 
>> 
>> 
>> Please help me in getting the output which is there is the Image.. 
>> 
>> Regards, 
>> Yashwanth M,R 
>> 
>> -- 
>> View this message in context: 
>
http://r.789695.n4.nabble.com/To-define-a-function-which-includes-two-functi
> ons-as-arguments-such-as-plot-and-text-tp4416881p4416881.html 
>> Sent from the R help mailing list archive at Nabble.com. 
>> 
>> __ 
>> [hidden email] mailing list 
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code. 
> 
> 
> __ 
> [hidden email] mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do r

[R] User defined link function with extra parameters

2012-02-29 Thread Bernardo Powaga

Hello R users,

I would like to fit a generalized linear model for the binomial family 
with some non standard link functions. For instance, this is the 
Aranda-Ordaz link:


η = ln( ( (1 - π)^-α - 1 )/α)

I know how to define a new link function to use with glm(), but I my 
problem is that I have an extra parameter to estimate and I have no clue 
how to incorporate that. Is there any way to tell glm() to add this 
parameter in the estimation or do I have to write my own estimator with 
optim()?


Thanks,

BP

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

2012-02-29 Thread genomenet
Hi There,

I  don't understand how to order the label in ROCR package in order to
get the correct result. I am wondering whether you can help me.

library(ROCR)
data(ROCR.simple)
pred <- prediction(ROCR.simple$predictions,ROCR.simple$labels)
svm.auc <- performance(pred, 'tpr', 'fpr')
plot(svm.auc)

#label 
ROCR.simple$labels[ROCR.simple$labels=="0"]="tumor"
ROCR.simple$labels[ROCR.simple$labels==1]="normal"

pred <- prediction(ROCR.simple$predictions,ROCR.simple$labels)

svm.auc <- performance(pred, 'tpr', 'fpr')

plot(svm.auc)

The ROC curve is flipped. How do we know which order of labels we should choose?

Is this a bug of ROC?

thank you very much.

Mike

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


[R] ordered lable in ROCR

2012-02-29 Thread genomenet
Hi There,

I  don't understand how to order the label in ROCR package in order to
get the correct result. I am wondering whether you can help me.

library(ROCR)
data(ROCR.simple)
pred <- prediction(ROCR.simple$predictions,ROCR.simple$labels)
svm.auc <- performance(pred, 'tpr', 'fpr')
plot(svm.auc)

#label 
ROCR.simple$labels[ROCR.simple$labels=="0"]="tumor"
ROCR.simple$labels[ROCR.simple$labels==1]="normal"

pred <- prediction(ROCR.simple$predictions,ROCR.simple$labels)

svm.auc <- performance(pred, 'tpr', 'fpr')

plot(svm.auc)

The ROC curve is fliped. How do we know which order of labels we should choose?

Is this a bug of ROC?

thank you very much.

Mike

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


[R] GLM with regularization

2012-02-29 Thread Dmitriy Lyubimov
Hello,

Thank you for probably not so new question, but i am new to R.

Does any of packages have something like glm+regularization? So far i
see probably something close to that as a ridge regression in MASS but
I think i need something like GLM, in particular binomial regularized
versions of polynomial regression.

Also I am not sure how some of the K-fold crossvalidation helpers out
there (cv.glm) could be used to adjust reg rate as there seems to be
no way to apply them over data not used for training (or  i am not
seeing a solution here as training is completely separated from
crossvalidation error computation here) .

The example here in cv.glm doesn't look right to me since it computes
cv error over model trained on 100% of data. (e.g. wikipedia
crossvalidation article lists this as an example of misuse of K-fold
CV).


- doc quote 
# leave-one-out and 6-fold cross-validation prediction error for
# the mammals data set.
data(mammals, package="MASS")
mammals.glm <- glm(log(brain)~log(body),data=mammals)
cv.err <- cv.glm(mammals,mammals.glm)
cv.err.6 <- cv.glm(mammals, mammals.glm, K=6)
 end of quote ---


Those seem to be pretty common techniques, any poniter in the right
direction (package) will be greatly appreciated.

thank you very much.
-Dmitriy

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


Re: [R] the problem about sample size

2012-02-29 Thread hchui
Hi, there,

I run into the same sample size error in JM. Have you found the solution for
the error?

Many thanks,
Helena

--
View this message in context: 
http://r.789695.n4.nabble.com/the-problem-about-sample-size-tp1592855p4434009.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] identifying a column name correctly to use in a formula

2012-02-29 Thread Rui Barradas
Hello,

>
> I have a large matrix (SNPs) that I want to cycle over with logistic
> regression with interaction terms. I have made a loop but I am struggling
> to identify to the formula the name of the column in a way which is
> meaningful to the formula. It errors becasue it is not evaluated proporly. 
> You have must first write the formula in full, using 'paste'.
> 

Try

DF <- data.frame(Resp=rnorm(10), B=rnorm(10), C=rnorm(10),
Interaction=rnorm(10))
#DF

for(i in 2:3){
cname <- colnames(DF)[i]
#
# In 3 steps to be more readable
Regr <- paste(cname, "Interaction", sep="*")
fmlaText <- paste("Resp", Regr, sep="~")
# After step 2 it's already printable
print(fmlaText)
# Step 3: transform it into a formula object
fmla <- as.formula(fmlaText)
model1 <- glm(fmla, data=DF)
print(summary(model1))
}

You have must first write the formula in full, using 'paste'.

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/identifying-a-column-name-correctly-to-use-in-a-formula-tp4433605p4433924.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] Using a FOR LOOP to name objects

2012-02-29 Thread michaelyb
Michael - thank you so much! Just what I needed! 

--
View this message in context: 
http://r.789695.n4.nabble.com/Using-a-FOR-LOOP-to-name-objects-tp4430454p4433903.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to extract numerical values from time series forecast

2012-02-29 Thread R. Michael Weylandt
Perhaps you need the forecast() function?

Michael

On Wed, Feb 29, 2012 at 12:01 PM, ForzaBruta  wrote:
> hi all. i'm busy with some time series data, starting from an earlier period
> until the current day.
>
> i have created a time series forecast taking into account the entire data
> from the earlier date up until 2007, using the "forecast" package for R. i
> am comparing this forecasted data to the actual/ observed data (which starts
> from the earlier date up until the current day).
>
> my question is, how do i extract the estimated data from the forecast as
> actual values so that i can do further analysis with it?
>
> thanking you all in advance
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/How-to-extract-numerical-values-from-time-series-forecast-tp4432165p4432165.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 are the coefficients for the ur.ers, type DF-GLS calculated?

2012-02-29 Thread R. Michael Weylandt
Simply type ur.ers on a line by itself to see how the calculation is
implemented.

Michael

On Wed, Feb 29, 2012 at 11:20 AM, ackbar03  wrote:
> I need some real help on this, really stuck
>
> how are the coefficients for
> ur.ers(y, type = c("DF-GLS", "P-test"), model = c("constant", "trend"),
>       lag.max = 0)
>
> The max lag is set at zero, so the regression should simply be
>
> Diff(zt) = a*z(t-1)
>
> where a is the value i'm trying to find and z(t)'s are the detrended values.
> but through performing my own regression on the two time series I get
> different values. This could only mean
>
> 1) Its not just a simple regression
> or
> 2) I'm detrending my data incorrectly.
>
> However, i've followed the instructions I've seen in research papers and it
> doesn't seem to be right. Basically I take Y*t = Yt-(1-(1-7/T)*Y(t-1) and
> regress that on 1-(1-7/T)  for all t>1 and leave the values at T=1
> unchanged. Then I take Yt and subtract the coefficient of the regression to
> get the detrended value.
>
> I'm really stuck on this and its really frustrating. I think the easiest
> thing would be if someone can tell me exactly how R carries out the
> calculations for the functions. Help will be highly appreciated!!
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/How-are-the-coefficients-for-the-ur-ers-type-DF-GLS-calculated-tp4432015p4432015.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] identifying a column name correctly to use in a formula

2012-02-29 Thread R. Michael Weylandt
Your method of constructing a formula is funny: is there a term called
"interaction" or do you mean an interaction in the statistical sense?
Once you do that, I'd think the easiest way to proceed is to use
as.formula() to construct your formula programmatically and then to
pass that to glm(). Something like

form <- as.formula(paste("AS ~ ", colnames(n)[i], sep = ""))
glm(form, data = n, framily = bonimial("logit")

Michael

On Wed, Feb 29, 2012 at 7:42 PM, Philip Robinson
 wrote:
> Hi,
>
> I have a large matrix (SNPs) that I want to cycle over with logistic
> regression with interaction terms. I have made a loop but I am struggling
> to identify to the formula the name of the column in a way which is
> meaningful to the formula. It errors becasue it is not evaluated proporly.
>
> (below is a pilot with only 7 to 33 columns, my actual has 200,000 columns)
>
> My attempts:
>
>
> for (i in 7:33) {
>  label <- colnames(n)[i]
> model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
>    X <- summary(model1)$coefficients[2,1]
> Y <- c(label,X)
> vector <- rbind(vector,Y)
> } #variable lengths differ
>
> Error in model.frame.default(formula = AS ~ label, data = n,
> drop.unused.levels = TRUE) :
>  variable lengths differ (found for 'label')
>
> #This is because it is trying to do logistic regression on a character
> string
>
> for (i in 7:33) {
>  label <- eval(colnames(n)[i])
> model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
>    X <- summary(model1)$coefficients[2,1]
> Y <- c(label,X)
> vector <- rbind(vector,Y)
> } #variable lengths differ
>
> Error in model.frame.default(formula = AS ~ label, data = n,
> drop.unused.levels = TRUE) :
>  variable lengths differ (found for 'label')
>
> #same as above
>
> for (i in 7:33) {
>  label <- as.name(colnames(n)[i])
> model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
>    X <- summary(model1)$coefficients[2,1]
> Y <- c(label,X)
> vector <- rbind(vector,Y)
> }
>
> Error in model.frame.default(formula = AS ~ label, data = n,
> drop.unused.levels = TRUE) :
>  invalid type (symbol) for variable 'label
> #not sure what this error is
>
> for (i in 7:33) {
>  label <- eval(as.name(colnames(n)[i]))
> model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
>    X <- summary(model1)$coefficients[2,1]
> Y <- c(label,X)
> vector <- rbind(vector,Y)
> }
>
> # Error in eval(expr, envir, enclos) : object 'B1' not found
> B1 is the name of the first column - this isn't an object and that seems to
> be why it is causing an error
>
> for (i in 7:33) {
>  label <- as.formula(colnames(n)[i])
> model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
>    X <- summary(model1)$coefficients[2,1]
> Y <- c(label,X)
> vector <- rbind(vector,Y)
> }
> Error in eval(expr, envir, enclos) : object 'B1' not found
>
> #same as above
>
> for (i in 7:33) {
>  label <- eval(as.formula(colnames(n)[i]))
> model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
>    X <- summary(model1)$coefficients[2,1]
> Y <- c(label,X)
> vector <- rbind(vector,Y)
> }
>
> Error in eval(expr, envir, enclos) : object 'B1' not found
> #same as above
>
> Any help would be appreciated.
>
> Thanks
> Philip
>
>        [[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] Plotting a registered sign

2012-02-29 Thread Marc Schwartz
On Feb 29, 2012, at 7:41 PM, Dennis Fisher wrote:

> R 2.14.0
> OS X
> 
> Colleagues
> 
> Probably a simple question but it alludes me at the moment.  I want to embed 
> a registered sign in the text in a legend.  The text would look like:
>   SOMETEXT® 
> with ® superscripted.  
> 
> Thanks in advance.
> 
> Dennis


Dennis,

Depending upon some additional fine tuning, here is a generic example:

  plot(1)
  legend("topright", pch = 1, legend = expression(SOMETEXT ^ symbol("\342")))


See ?plotmath for more information. The above works on my MBP running Lion.

HTH,

Marc Schwartz

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


[R] Re : Create a function "automatically" from lm formula and coefficients?

2012-02-29 Thread Pascal Oettli
Hi Keith,

Do you mean as "predict.lm" can do?

Regards,
Pascal



De : Keith Weintraub 
À : r-help@r-project.org 
Envoyé le : Jeudi 1 mars 2012 11h41
Objet : [R] Create a function "automatically" from lm formula and coefficients?

I hope the subject says it all.

I want to be able to use an lm object and the associated coefficients to 
create  function that can produce "expected" "y" values given inputs.

Thanks,
KW

--


    [[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] Simulate values from VAR

2012-02-29 Thread Keith Weintraub
Folks,
  What is the best way to simulate values from a fitted "VAR {vars}" model.

Also I have tried to use SVAR for a cointegration fit of y~x (just two 
univariate time-series) but I can't figure out how to set up the "A" matrix so 
that x_t can be used as a contemporaneous predictor of y_t.

Thanks much for your time,
KW

--


[[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] Create a function "automatically" from lm formula and coefficients?

2012-02-29 Thread Frank Harrell
require(rms)
f <- ols(y ~ rcs(age,4)*sex + blood.pressure + rcs(height,5))
latex(f)   # typeset algebraic form of model
Function(f)   # create an R function that computes Y hat

Frank


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/Create-a-function-automatically-from-lm-formula-and-coefficients-tp4433854p4433870.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] Create a function "automatically" from lm formula and coefficients?

2012-02-29 Thread Keith Weintraub
I hope the subject says it all.

I want to be able to use an lm object and the associated coefficients to create 
 function that can produce "expected" "y" values given inputs.

Thanks,
KW

--


[[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] Plotting a registered sign

2012-02-29 Thread Dennis Fisher
R 2.14.0
OS X

Colleagues

Probably a simple question but it alludes me at the moment.  I want to embed a 
registered sign in the text in a legend.  The text would look like:
SOMETEXT® 
with ® superscripted.  

Thanks in advance.

Dennis

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.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] Binning continuous data

2012-02-29 Thread David Winsemius


On Feb 29, 2012, at 5:01 PM, Faryabi, Robert (NIH/NCI) [F] wrote:


Hi there,

Here is the scenario:

I have a measurement of some sort for two variables, I would like to  
figure out a rough pattern between them. Let say if the values of  
the first variable are low, middle, high, and extremely high, then  
what would be the corresponding pattern of the second variable. The  
idea is not to find the 2d distribution, but plot a conditional  
distribution of the second variable based on the binning of the the  
first variable and then present it in a boxplot.


I got the breakpoints for binning the first variables by a bi-modal  
density estimation. Now I need to bin the first variable accordingly  
and map them to a categorical value.


Is there an R command that does the binning?


It sounds as though you want `cut` and `table`. Whether that is the  
best use of the data is more questionable. Generally the  
categorization process removes quite a bit of the information content  
and may either introduce significant biases or lower power  when the  
cuts are chosen after looking at the data or lower power when any  
inferential test is used. You _should_ also look at 2d density  
estimation as a method that is less susceptible to these distortions.


help( kde2d, package=MASS)

help( bkde2D , package=KernSmooth)

help( s.kde2d , package=ade4)

--
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] Cannot use negative argument in function

2012-02-29 Thread David Winsemius


On Feb 29, 2012, at 7:05 PM, lidaky wrote:

the "*" character in front of the Temp variable is there because i  
just
wanted to bold the variable in the threade that you can see where it  
is

used.

I just restart my computer and R. Now the function is working great.  
No clue

what was happening, but now everything works.
Sorry for the false notice, and thanks so much for this quick  
support by all

of you. Next time i'll restart R before posting on the forum...


AND don't use bold on Nabble, infact don't use Nabble.
AND don't highjack existing threads.



Sent from the R help mailing list archive at Nabble.com.


Which is neither an archive nor is it the R help mailing list.

--

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] Contour plot- repost message

2012-02-29 Thread David Winsemius


On Feb 29, 2012, at 7:08 PM, Leong Keat Chan wrote:

Hi, I would like to make a contour plot using R with the following  
information (data at the end): x-axis= arranged according to day  
(from 1 to 365, labels= use


I am really getting tired of seeing this message. This must be the  
fourth duplicate today. There is clearly insufficient data offered to  
allow plotting such as that offered as the desired output. I saw no  
reason to do any coding to attempt the impossible.


--

David Winsemius, MD
West Hartford, CT

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


[R] identifying a column name correctly to use in a formula

2012-02-29 Thread Philip Robinson
Hi,

I have a large matrix (SNPs) that I want to cycle over with logistic
regression with interaction terms. I have made a loop but I am struggling
to identify to the formula the name of the column in a way which is
meaningful to the formula. It errors becasue it is not evaluated proporly.

(below is a pilot with only 7 to 33 columns, my actual has 200,000 columns)

My attempts:


for (i in 7:33) {
  label <- colnames(n)[i]
model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
X <- summary(model1)$coefficients[2,1]
Y <- c(label,X)
vector <- rbind(vector,Y)
} #variable lengths differ

Error in model.frame.default(formula = AS ~ label, data = n,
drop.unused.levels = TRUE) :
  variable lengths differ (found for 'label')

#This is because it is trying to do logistic regression on a character
string

for (i in 7:33) {
  label <- eval(colnames(n)[i])
model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
X <- summary(model1)$coefficients[2,1]
Y <- c(label,X)
vector <- rbind(vector,Y)
} #variable lengths differ

Error in model.frame.default(formula = AS ~ label, data = n,
drop.unused.levels = TRUE) :
  variable lengths differ (found for 'label')

#same as above

for (i in 7:33) {
  label <- as.name(colnames(n)[i])
model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
X <- summary(model1)$coefficients[2,1]
Y <- c(label,X)
vector <- rbind(vector,Y)
}

Error in model.frame.default(formula = AS ~ label, data = n,
drop.unused.levels = TRUE) :
  invalid type (symbol) for variable 'label
#not sure what this error is

for (i in 7:33) {
  label <- eval(as.name(colnames(n)[i]))
model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
X <- summary(model1)$coefficients[2,1]
Y <- c(label,X)
vector <- rbind(vector,Y)
}

# Error in eval(expr, envir, enclos) : object 'B1' not found
B1 is the name of the first column - this isn't an object and that seems to
be why it is causing an error

for (i in 7:33) {
  label <- as.formula(colnames(n)[i])
model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
X <- summary(model1)$coefficients[2,1]
Y <- c(label,X)
vector <- rbind(vector,Y)
}
Error in eval(expr, envir, enclos) : object 'B1' not found

#same as above

for (i in 7:33) {
  label <- eval(as.formula(colnames(n)[i]))
model1 <- glm(AS~label*interaction,family=binomial("logit"),data=n)
X <- summary(model1)$coefficients[2,1]
Y <- c(label,X)
vector <- rbind(vector,Y)
}

Error in eval(expr, envir, enclos) : object 'B1' not found
#same as above

Any help would be appreciated.

Thanks
Philip

[[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] linear regression by column

2012-02-29 Thread Peter Ehlers

On 2012-02-29 15:45, David Winsemius wrote:


On Feb 29, 2012, at 6:39 PM, David Winsemius wrote:



On Feb 29, 2012, at 1:53 PM, Filoche wrote:


Hi everyone.

I have a DF with the first column being my independant variable and
all
other columns the dependent variables.

Something like:

x   y1  y2  y3
... ... ... ...
... ... ... ...

What I'm trying to do is to perform a linear model for each of my
"y". It is
pretty simple with loops, but I'm trying to vectorize it using
*apply*.

For instance, I tried something like:

apply(DF, 1, function(DF){lm(DF[,1] ~ Band1[,2:5])})


apply( DF[2:5], 2, function(x){lm(DF[,1] ~ x)})

You need to use the variable name that you created in the function
call and loop over columns, not rows.


I read the request wrong. It would be:

apply( DF[2:5], 2, function(y){y ~ DF$x)})


Another possibility: from ?lm:

"If response is a matrix a linear model is fitted separately by
 least-squares to each column of the matrix."

Peter Ehlers








But apparently it does not work.


For about four or five reasons.


.


David Winsemius, MD
West Hartford, CT

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


David Winsemius, MD
West Hartford, CT

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


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


Re: [R] TM reader with text

2012-02-29 Thread Mickael R problem
my computer run under windows vista 64 sp2. The question about encoding, I
don't understand it, sorry ?


--
View this message in context: 
http://r.789695.n4.nabble.com/TM-reader-with-text-tp4433394p4433526.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] Cannot use negative argument in function

2012-02-29 Thread lidaky
the "*" character in front of the Temp variable is there because i just
wanted to bold the variable in the threade that you can see where it is
used.

I just restart my computer and R. Now the function is working great. No clue
what was happening, but now everything works.
Sorry for the false notice, and thanks so much for this quick support by all
of you. Next time i'll restart R before posting on the forum...
Simon

--
View this message in context: 
http://r.789695.n4.nabble.com/Cannot-use-negative-argument-in-function-tp4430667p4433537.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] Contour plot- repost message

2012-02-29 Thread Leong Keat Chan
Hi, I would like to make a contour plot using R with the following information 
(data at the end): x-axis= arranged according to day (from 1 to 365, labels= 
use months; up to 365 days in one year), y-axis= depth (labels from 0 at the 
top to 7 at the bottom; this is a water depth profile), and z-axis= pH. So, 
this would be a pH contour plot of different dates throughout a year, with pH 
measured at different depths (0 meter to 7 meters). I tried to use various 
contour plot packages, but always have trouble with y axis data that are not 
arranged in ascending order thus failed to make a matrix for data in the z-axis 
(pH). So, I used akima to make a matrix 
(data.interp<-interp(x,y,z,duplicate="mean")) but the results is a square 
matrix- Not sure if the data is correct. So, any help/suggestion would be 
great! An example image that I would like to make is here: 
http://neuer.lab.asu.edu/images/10_data/roosevelt_temp.JPG

Thanks so much!

Leo


Data:
Day Month   Depth   pH
23  Jan 0   4.9
23  Jan 3   4.93
23  Jan 7   5.05
52  Feb 0   4.93
52  Feb 3   4.92
52  Feb 7   5.54
86  Mar 0   4.93
86  Mar 3   5.09
86  Mar 7   5.32
115 Apr 0   4.92
115 Apr 3   4.88
115 Apr 7   5.385
142 May 0   4.99
142 May 2   4.805
142 May 5   5.31
142 May 7   5.41
169 Jun 0   4.935
169 Jun 2   4.66
169 Jun 3   4.96
169 Jun 7   5.55
198 Jul 0   5.19
198 Jul 3   5.1
198 Jul 5   5.59
198 Jul 7   5.8
225 Aug 0   5.05
225 Aug 2   4.88
225 Aug 5   5.31
225 Aug 7   5.53
225 Sep 0   4.78
225 Sep 2   4.76
225 Sep 5   5.22
225 Sep 6   5.4
282 Oct 0   4.8
282 Oct 3   4.91
282 Oct 5   5.185
282 Oct 6   5.32
319 Nov 0   5.06
319 Nov 3   5.05
319 Nov 7   5.11


[[alternative HTML version deleted]]

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


Re: [R] R can't load a large dataset

2012-02-29 Thread David Winsemius


On Feb 29, 2012, at 7:00 PM, Francesco Sarracino wrote:


Dear R listers,

I have a silly problem. I am trying to load a dta (Stata) file in R.
The dta is about 650 MB and contains the integrated World Values
Survey/ European Value Study data-set.
My problem is that I don't manage to load the file. After almost 1
hour I issued the following command:
data <- read.dta("http://www.stata-press.com/data/kkd/data1.dta";,
 convert.dates = TRUE, convert.factors = TRUE,
 missing.type = FALSE,
 convert.underscore = FALSE, warn.missing.labels = TRUE)


I get MUCH smaller data.frame;

require(foreign)
...then your code:

(Almost instantaneous return to console prompt.)

> str(data)
'data.frame':   3340 obs. of  47 variables:
 $ persnr  : int  2229 3994 6326 8660 10622 13277 15241 17852 19635  
21501 ...
 $ intnr   : int  145700 256862 166979 120826 154849 138118 13277  
160539 194697 150495 ...
 $ state   : Factor w/ 16 levels "Berlin","Schl.Hst",..: 6 15 2 6 6  
10 6 6 10 9 ...
 $ gender  : Factor w/ 2 levels "Maenner","Frauen": 1 1 2 1 1 1 1 1 2  
2 ...

Snipped a few pages...


The column names don't really look like what you describe:

>  names(data)
 [1] "persnr"   "intnr""state""gender"   "ybirth"   "ymove"
 [7] "ybuild"   "hcond""sqm"  "rooms""fseval"   "kitchen"
[13] "shower"   "wc"   "heating"  "cellar"   "balcony"  "garden"
[19] "phone""renttype" "rent" "renteval" "hhtype"   "htype"
[25] "area" "np11701"  "np0105"   "np9401"   "np9402"   "np9403"
[31] "np9501"   "np9502"   "np9503"   "np9504"   "np9506"   "np9507"
[37] "hhpos""hhsize"   "marital"  "edu"  "voc"  "yedu"
[43] "emp"  "occ"  "hhinc""income"   "egph"

>  sessionInfo()
R version 2.14.0 Patched (2011-11-13 r57650)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] foreign_0.8-47 sos_1.3-1  brew_1.0-6 lattice_0.20-0

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




I still don't have my data loaded. Moreover, my system becomes very
slow and not responsive.
I can't figure out what is going on.
Here you are my specs:
Ubuntu Linux 11.10 x86_64-pc-linux-gnu (64-bit)
Intel Core i7, 4 GB RAM, 367 GB Free HD, 8 GB swap memory
R:
R version 2.14.1 (2011-12-22)

Can you please help me figuring out what's wrong? I think it's
impossible that R can't handle files of similar sizes.
Thanks a lot,
f.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] The joys of Nabble: Re: Cannot use negative argument in function

2012-02-29 Thread Duncan Murdoch

On 12-02-29 6:28 PM, Sarah Goslee wrote:

This is yet another problem with the Nabble interface to
the list.

On Wed, Feb 29, 2012 at 6:21 PM, Richard M. Heiberger  wrote:

This line

  TT<- *Temp*+273.15
makes it unexecutable.  that is not the error you mentioned.


On nabble, that variable is in bold. When it's reformatted for
the plain-text email list, the formatting is converted to ** surrounding
that bit of text.

This is not helpful.

Please note, this is an argument for NOT using nabble, rather
than for converting the list to HTML. The latter would cause
many more problems.

Another problem with nabble is that there is no context in this
post. What error? What reproducible example? What are we
trying to solve? With the erroneous formatting codes removed,
the function runs, as far as I can tell.


No need to complain about nabble, just filter them out.  Look for a 
"Message-ID" header containing "nabble.com".


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] TM reader with text

2012-02-29 Thread Richard M. Heiberger
Most, maybe all, of the example words you posted include ligatures,
With "financier" for example, the leading "fi" is rendered in PDF and in
most typesetting
situations as a ligature with the a single complex character representing
the "fi' combination.

fi fl

I pasted the "fi" and "fl" ligatures in this email. I hope they get through.

I don't know the package you are using, I hope it has arguments that tell
it about ligatures.

Rich



On Wed, Feb 29, 2012

at 6:49 PM, David Winsemius  wrote:

>
> On Feb 29, 2012, at 6:00 PM, Mickael R problem wrote:
>
> Hello everybody,
>> I work, I try, with TM but I have a problem with some special words in
>> french. I think this is due to the manner to transform PDF to text, but
>> I'm
>> not perfectly sure.
>> Let's see to the example :
>>
>> findFreqTerms(tdm1,30)
>>   [33] """n"   "nancement"
>> "nancier" "nancière""nancières"
>> "nanciers""xe"
>>
>> Some french words are not well reading by TM with the reader readPlain. I
>> try to use reader= reader PDF. But it doesn't work so I must transformed
>> PDF
>> text to text. And some words are not understand so when I use
>> TermDocumentMatrix a word like inflation diseappear. It's a big probleme
>> for
>> me. I spend lot of time on this problem, any idea ? Thank's for you time.
>>
>
> You included no information about your platform, locale settings, or
> encoding of the text.
>
> ?Encoding
> ?sessionInfo
>
> --
>
> 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.
>

[[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] ggplot2 dot chart-start at zero

2012-02-29 Thread Robert Baer

Not sure I'm interpreting what you want to do correctly, but how about:

p2 <- pa + scale_x_continuous(limits=c(0,80))
p2



-Original Message- 
From: John Kane

Sent: Wednesday, February 29, 2012 2:32 PM
To: r-help@r-project.org
Subject: [R] ggplot2 dot chart-start at zero

I am trying to create a simple dot-plot in ggplot2  with a solid line from 
the y-axis to the dot, something I first saw in Cleveland's 1984 book


What I would like is to have the graph start at zero on the x-axis but leave 
some space on the right side of the plot area.


I assumed that I should be able to do this with expand() in 
scale_x_continuous() but either I'm wrong or just don't understand what 
expand() is doing. So far, I see that scale_x_continuous(expand=c(0,0)) 
removes the space on the right and left. but I don't understand how to just 
get the left only to disappear.


Any help would be appreciated

Code below
#
library(ggplot2)
xx<- structure(list(Food = c("Milk", "Bread", "Potatoes", "Rice"),
   Expense = c(25L, 49L, 34L, 15L)), .Names = c("Food", "Expense"
), class = "data.frame", row.names = c(NA, -4L))


p <- ggplot(xx, aes(Expense, Food))

pa <- p + geom_point(aes(Expense, Food, colour=Food)) +
  geom_segment(aes(x = 0, xend = Expense,
  y = Food, yend = Food,colour=Food)) +
  opts(legend.position = "none")

pa  # so far so good

p1 <- pa + scale_x_continuous(expand=c(0,0))
#===

R version 2.13.1 (2011-07-08)
Platform: i686-pc-linux-gnu (32-bit)

locale:
[1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8   LC_NAME=C
[9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4 plyr_1.7


John Kane
Kingston ON Canada


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your 
desktop!


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


--
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501
660-626-2322
FAX 660-626-2965

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


Re: [R] Contour plot

2012-02-29 Thread Leong Keat Chan
Hi, I would like to make a contour plot using R with the following information 
(data at the end): x-axis= arranged according to day (from 1 to 365, labels= 
use months; up to 365 days in one year), y-axis= depth (labels from 0 at the 
top to 7 at the bottom; this is a water depth profile), and z-axis= pH. So, 
this would be a pH contour plot of different dates throughout a year, with pH 
measured at different depths (0 meter to 7 meters). I tried to use various 
contour plot packages, but always have trouble with y axis data that are not 
arranged in ascending order thus failed to make a matrix for data in the z-axis 
(pH). So, I used akima to make a matrix 
(data.interp<-interp(x,y,z,duplicate="mean")) but the results is a square 
matrix- Not sure if the data is correct. So, any help/suggestion would be 
great! An example image that I would like to make is here: 
http://neuer.lab.asu.edu/images/10_data/roosevelt_temp.JPG

Thanks so much!

Leo


Data:
Day Month   Depth   pH
23  Jan 0   4.9
23  Jan 3   4.93
23  Jan 7   5.05
52  Feb 0   4.93
52  Feb 3   4.92
52  Feb 7   5.54
86  Mar 0   4.93
86  Mar 3   5.09
86  Mar 7   5.32
115 Apr 0   4.92
115 Apr 3   4.88
115 Apr 7   5.385
142 May 0   4.99
142 May 2   4.805
142 May 5   5.31
142 May 7   5.41
169 Jun 0   4.935
169 Jun 2   4.66
169 Jun 3   4.96
169 Jun 7   5.55
198 Jul 0   5.19
198 Jul 3   5.1
198 Jul 5   5.59
198 Jul 7   5.8
225 Aug 0   5.05
225 Aug 2   4.88
225 Aug 5   5.31
225 Aug 7   5.53
225 Sep 0   4.78
225 Sep 2   4.76
225 Sep 5   5.22
225 Sep 6   5.4
282 Oct 0   4.8
282 Oct 3   4.91
282 Oct 5   5.185
282 Oct 6   5.32
319 Nov 0   5.06
319 Nov 3   5.05
319 Nov 7   5.11



[[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] R can't load a large dataset

2012-02-29 Thread Francesco Sarracino
Dear R listers,

I have a silly problem. I am trying to load a dta (Stata) file in R.
The dta is about 650 MB and contains the integrated World Values
Survey/ European Value Study data-set.
My problem is that I don't manage to load the file. After almost 1
hour I issued the following command:
data <- read.dta("http://www.stata-press.com/data/kkd/data1.dta";,
  convert.dates = TRUE, convert.factors = TRUE,
  missing.type = FALSE,
  convert.underscore = FALSE, warn.missing.labels = TRUE)

I still don't have my data loaded. Moreover, my system becomes very
slow and not responsive.
I can't figure out what is going on.
Here you are my specs:
Ubuntu Linux 11.10 x86_64-pc-linux-gnu (64-bit)
Intel Core i7, 4 GB RAM, 367 GB Free HD, 8 GB swap memory
R:
R version 2.14.1 (2011-12-22)

Can you please help me figuring out what's wrong? I think it's
impossible that R can't handle files of similar sizes.
Thanks a lot,
f.

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


Re: [R] puzzling results from logistic regression

2012-02-29 Thread Peter Ehlers

Michael (OP),

Not that it's necessary, but you might also find
 confint(aa)
to be instructive.

Peter Ehlers

On 2012-02-29 07:20, R. Michael Weylandt wrote:

Formally, look at Pr(>|z|). Informally, look at the null and residual
deviances from print(aa).

Michael

On Wed, Feb 29, 2012 at 10:14 AM, Michael  wrote:

How did you see it's non-significant?

Thanks!

On Wed, Feb 29, 2012 at 9:10 AM, Sarah Gosleewrote:


On Wed, Feb 29, 2012 at 10:02 AM, Michael  wrote:

Hi all,

As you can see from below, the result is strange...


Not really.


I would imagined that the bb result should be much higher and close to 1,
any way to improve the fit?

Any other classification methods?

Thank you!

data=data.frame(y=rep(c(0, 1), times=100), x=1:200)
aa=glm(y~x, data=data, family=binomial(link="logit"))

newdata=data.frame(x=6, y=100)
bb=predict(aa, newdata=newdata, type="response")
bb



bb


1

0.4929125



What did you expect? Your model is completely nonsignificant; there's no
way to predict y from x, and that's what your predicted value tells you.


summary(aa)


Call:
glm(formula = y ~ x, family = binomial(link = "logit"), data = data)

Deviance Residuals:
   Min  1Q  Median  3Q Max
-1.190  -1.177   0.000   1.177   1.190

Coefficients:
 Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.030152   0.283924  -0.1060.915
x0.000300   0.002450   0.1220.903

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 277.26  on 199  degrees of freedom
Residual deviance: 277.24  on 198  degrees of freedom
AIC: 281.24

Number of Fisher Scoring iterations: 3


I can only assume that you didn't construct the data frame that
you intended to test.

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



[[alternative HTML version deleted]]

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


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


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


Re: [R] TM reader with text

2012-02-29 Thread David Winsemius


On Feb 29, 2012, at 6:00 PM, Mickael R problem wrote:


Hello everybody,
I work, I try, with TM but I have a problem with some special words in
french. I think this is due to the manner to transform PDF to text,  
but I'm

not perfectly sure.
Let's see to the example :

findFreqTerms(tdm1,30)
   [33] """n"   "+FB01>nancement"

"nancier" "nancière""nancières"
"nanciers""xe"

Some french words are not well reading by TM with the reader  
readPlain. I
try to use reader= reader PDF. But it doesn't work so I must  
transformed PDF

text to text. And some words are not understand so when I use
TermDocumentMatrix a word like inflation diseappear. It's a big  
probleme for
me. I spend lot of time on this problem, any idea ? Thank's for you  
time.


You included no information about your platform, locale settings, or  
encoding of the text.


?Encoding
?sessionInfo

--

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] linear regression by column

2012-02-29 Thread David Winsemius


On Feb 29, 2012, at 6:39 PM, David Winsemius wrote:



On Feb 29, 2012, at 1:53 PM, Filoche wrote:


Hi everyone.

I have a DF with the first column being my independant variable and  
all

other columns the dependent variables.

Something like:

x   y1  y2  y3
... ... ... ...
... ... ... ...

What I'm trying to do is to perform a linear model for each of my  
"y". It is
pretty simple with loops, but I'm trying to vectorize it using  
*apply*.


For instance, I tried something like:

apply(DF, 1, function(DF){lm(DF[,1] ~ Band1[,2:5])})


apply( DF[2:5], 2, function(x){lm(DF[,1] ~ x)})

You need to use the variable name that you created in the function  
call and loop over columns, not rows.


I read the request wrong. It would be:

apply( DF[2:5], 2, function(y){y ~ DF$x)})






But apparently it does not work.


For about four or five reasons.


.


David Winsemius, MD
West Hartford, CT

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] Cannot use negative argument in function

2012-02-29 Thread David Winsemius


On Feb 29, 2012, at 2:14 PM, lidaky wrote:


index.refraction <- function(Temp,Press, RH, CO2)
{
 #define constant
 lambda  <-  531 #nm
 Co  <- 299792458 #m/s
 ww <- c(295.235,2.6422,-0.03238,0.004028)
 kk  <- c( 238.0185 ,5792105 ,57.362 ,167917)
 aa  <- c( 1.58123 * 10^(-6) , -2.9331 * 10^(-8) , 1.1043 * 10^(-10))
 bb  <- c( 5.707 * 10^(-6) , -2.051 * 10^(-8))
 cc  <-  c(1.9898 * 10^(-4) , -2.376 * 10^(-6))
 dd  <- 1.83 * 10^(-11)
 ee  <-  -0.765 * 10^(-8)
 pp <- 101325
 tt <- 288.15
 zz <- 0.9995922115
 ro <- 0.00985938
 R <- 8.314472
 M <- 0.018015

 S <- 1/(lambda*10^-3)^2
 ras <- 10^-8*((kk[2]/(kk[1]-S))+(kk[4]/(kk[3]-S)))
 rvs  <- 1.022*10^-8*(ww[1]+S*ww[2]+ww[3]*S^2+ww[4]*S^3)
 Ma  <-  0.0289635 + 1.2011 * 10^(-8) * (CO2 - 400)
 raxs  <- ras*(1+5.34*10^-7*(CO2-450))
 TT <- *Temp*+273.15


That was the first line with an error. Why are you using "*"'s in that  
manner?




#Saturation vapor pressure over ice
# A1 <- -13.928169
# A2 <- 34.7078238
# Theta <- (*Temp*+273.15)/273.16
# Y  <-  A1 * (1 - Theta^(-1.5)) + A2 * (1 - Theta^(-1.25))
# Psv <- 611.657*exp(Y)

 #Saturation vapor pressure over water
 Tc  <-  647.096   # K   : Temperature at the critical point
 Pc  <-  22.064 * 10^4 # hPa : Vapor pressure at the critical point
 nu  <-  (1-TT/Tc)
 a1  <-  -7.85951783
 a2  <-  1.84408259
 a3  <-  -11.7866497
 a4  <-  22.6807411
 a5  <-  -15.9618719
 a6  <-  1.80122502
 Psv  <-  Pc * exp(Tc/TT * (a1*nu + a2*nu^1.5 + a3*nu^3. + a4*nu^3.5 +
a5*nu^4. + a6*nu^7.5))

Alpha  <-  1.00062
Beta  <-  3.14 * 10^(-8)
Gamma  <-  5.60 * 10^(-7)
fpt <- Alpha+Beta*Press+Gamma**Temp*^2
Xv <- (RH/100)*fpt*Psv/Press

 Zm <- 1-(Press/TT)*(aa[1]+aa[2]**Temp*+aa[3]**Temp*^2
 +(bb[1]+bb[2]*Temp)*Xv+(cc[1]+cc[2]**Temp*)*Xv^2)
+(Press/TT)^2*(dd+ee*Xv^2)
Roaxs <- pp*Ma/(zz*R*tt)
Rov <- Xv*Press*M/(Zm*R*TT)
Roa <- (1-Xv)*Press*Ma/(Zm*R*TT)
n <- 1+(Roa/Roaxs)*raxs+(Rov/ro)*rvs
return(n)
}


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] linear regression by column

2012-02-29 Thread David Winsemius


On Feb 29, 2012, at 1:53 PM, Filoche wrote:


Hi everyone.

I have a DF with the first column being my independant variable and  
all

other columns the dependent variables.

Something like:

x   y1  y2  y3
... ... ... ...
... ... ... ...

What I'm trying to do is to perform a linear model for each of my  
"y". It is
pretty simple with loops, but I'm trying to vectorize it using  
*apply*.


For instance, I tried something like:

apply(DF, 1, function(DF){lm(DF[,1] ~ Band1[,2:5])})


apply( DF[2:5], 2, function(x){lm(DF[,1] ~ x)})

You need to use the variable name that you created in the function  
call and loop over columns, not rows.




But apparently it does not work.


For about four or five reasons.


.


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] regular expression

2012-02-29 Thread Justin Haynes
gsub('.+; (.+);.+','\\1',x)

or if you just want the value out:

gsub('.+; Surv\\(months\\): ([0-9]+);.+','\\1',x)

You can also look at strsplit:
> strsplit(x,';')
[[1]]
[1] "99-625: Cell type: S"" Surv(months): 21"   "
STATUS(0=alive, 1=dead): 1"

> lapply(strsplit(x,';'),'[',2)
[[1]]
[1] " Surv(months): 21"

But i would follow David's second suggestion and just read them in with
sep=';' instead.


Justin

On Wed, Feb 29, 2012 at 11:24 AM, Fred G  wrote:

> Computer Friends,
>
> with the following example lines:
>
> [107] "98-610: Cell type: S; Surv(months): 6; STATUS(0=alive, 1=dead): 1"
>
> [108] "99-625: Cell type: S; Surv(months): 21; STATUS(0=alive, 1=dead): 1"
>
> i want to be able to isolate the number of months of survival for each row.
>
> is there a regular expression that can find the first instance of a ";",
> delete everything in front of it-- and find the second instance of an ";"
> and delete everything behind it? in python there is a function line.find(),
> would be grateful to hear the R equiv; or, any other better alternatives to
> get the number of months of survival stored as a variable.
>
> Much Thank You!
>
>[[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] regular expression

2012-02-29 Thread Gabor Grothendieck
On Wed, Feb 29, 2012 at 2:24 PM, Fred G  wrote:
> Computer Friends,
>
> with the following example lines:
>
> [107] "98-610: Cell type: S; Surv(months): 6; STATUS(0=alive, 1=dead): 1"
>
> [108] "99-625: Cell type: S; Surv(months): 21; STATUS(0=alive, 1=dead): 1"
>
> i want to be able to isolate the number of months of survival for each row.
>
> is there a regular expression that can find the first instance of a ";",
> delete everything in front of it-- and find the second instance of an ";"
> and delete everything behind it? in python there is a function line.find(),
> would be grateful to hear the R equiv; or, any other better alternatives to
> get the number of months of survival stored as a variable.
>

This extracts all the numeric fields:

# sample data
Lines <- c("98-610: Cell type: S; Surv(months): 6; STATUS(0=alive, 1=dead): 1",
"99-625: Cell type: S; Surv(months): 21; STATUS(0=alive, 1=dead): 1")

library(gsubfn)
strapply(Lines, "(\\d+);", as.numeric, simplify = TRUE)


# We can also get all numeric fields in case that is of interest:

strapply(Lines, "\\d+", as.numeric, simplify = rbind)


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

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


Re: [R] regular expression

2012-02-29 Thread David Winsemius


On Feb 29, 2012, at 2:24 PM, Fred G wrote:


Computer Friends,

with the following example lines:


Modified to be correct R code. Please emulate my example in the future.

inp <-c( "98-610: Cell type: S; Surv(months): 6; STATUS(0=alive,  
1=dead): 1",

"99-625: Cell type: S; Surv(months): 21; STATUS(0=alive, 1=dead): 1")



i want to be able to isolate the number of months of survival for  
each row.


is there a regular expression that can find the first instance of a  
";",
delete everything in front of it-- and find the second instance of  
an ";"
and delete everything behind it? in python there is a function  
line.find(),
would be grateful to hear the R equiv; or, any other better  
alternatives to

get the number of months of survival stored as a variable.


You can use either regex methods (noting that the "?" is necessary to  
defeat the default greedy nature of regex match.



> sub( ";.+$", "", sub("^.+?;", "", inp) )
[1] " Surv(months): 6"  " Surv(months): 21"

...  or you can read these as lines and pass the results to read.table  
with sep =";".


> read.table(text=inp, sep=";", stringsAsFactors=FALSE)[ ,2]
[1] " Surv(months): 6"  " Surv(months): 21"



[[alternative HTML version deleted]]


Please learn to post in palin text.

--

David Winsemius, MD
West Hartford, CT

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


[R] The joys of Nabble: Re: Cannot use negative argument in function

2012-02-29 Thread Sarah Goslee
This is yet another problem with the Nabble interface to
the list.

On Wed, Feb 29, 2012 at 6:21 PM, Richard M. Heiberger  wrote:
> This line
>
>  TT <- *Temp*+273.15
> makes it unexecutable.  that is not the error you mentioned.

On nabble, that variable is in bold. When it's reformatted for
the plain-text email list, the formatting is converted to ** surrounding
that bit of text.

This is not helpful.

Please note, this is an argument for NOT using nabble, rather
than for converting the list to HTML. The latter would cause
many more problems.

Another problem with nabble is that there is no context in this
post. What error? What reproducible example? What are we
trying to solve? With the erroneous formatting codes removed,
the function runs, as far as I can tell.

Sarah

> should that be
>
>  TT <- "Temp"+273.15
> or
>  TT <- Temp+273.15
> or something else?
>
> On Wed, Feb 29, 2012 at 2:14 PM, lidaky  wrote:
>
>> here is the code:
>>
>> index.refraction <- function(Temp,Press, RH, CO2)
>> {
>>  #define constant
>>  lambda  <-  531 #nm
>>  Co  <- 299792458 #m/s
>>  ww <- c(295.235,2.6422,-0.03238,0.004028)
>>  kk  <- c( 238.0185 ,5792105 ,57.362 ,167917)
>>  aa  <- c( 1.58123 * 10^(-6) , -2.9331 * 10^(-8) , 1.1043 * 10^(-10))
>>  bb  <- c( 5.707 * 10^(-6) , -2.051 * 10^(-8))
>>  cc  <-  c(1.9898 * 10^(-4) , -2.376 * 10^(-6))
>>  dd  <- 1.83 * 10^(-11)
>>  ee  <-  -0.765 * 10^(-8)
>>  pp <- 101325
>>  tt <- 288.15
>>  zz <- 0.9995922115
>>  ro <- 0.00985938
>>  R <- 8.314472
>>  M <- 0.018015
>>
>>  S <- 1/(lambda*10^-3)^2
>>  ras <- 10^-8*((kk[2]/(kk[1]-S))+(kk[4]/(kk[3]-S)))
>>  rvs  <- 1.022*10^-8*(ww[1]+S*ww[2]+ww[3]*S^2+ww[4]*S^3)
>>  Ma  <-  0.0289635 + 1.2011 * 10^(-8) * (CO2 - 400)
>>  raxs  <- ras*(1+5.34*10^-7*(CO2-450))
>>  TT <- *Temp*+273.15
>>
>> #Saturation vapor pressure over ice
>> # A1 <- -13.928169
>> # A2 <- 34.7078238
>> # Theta <- (*Temp*+273.15)/273.16
>> # Y  <-  A1 * (1 - Theta^(-1.5)) + A2 * (1 - Theta^(-1.25))
>> # Psv <- 611.657*exp(Y)
>>
>>  #Saturation vapor pressure over water
>>  Tc  <-  647.096       # K   : Temperature at the critical point
>>  Pc  <-  22.064 * 10^4 # hPa : Vapor pressure at the critical point
>>  nu  <-  (1-TT/Tc)
>>  a1  <-  -7.85951783
>>  a2  <-  1.84408259
>>  a3  <-  -11.7866497
>>  a4  <-  22.6807411
>>  a5  <-  -15.9618719
>>  a6  <-  1.80122502
>>  Psv  <-  Pc * exp(Tc/TT * (a1*nu + a2*nu^1.5 + a3*nu^3. + a4*nu^3.5 +
>> a5*nu^4. + a6*nu^7.5))
>>
>> Alpha  <-  1.00062
>> Beta  <-  3.14 * 10^(-8)
>> Gamma  <-  5.60 * 10^(-7)
>> fpt <- Alpha+Beta*Press+Gamma**Temp*^2
>> Xv <- (RH/100)*fpt*Psv/Press
>>
>>  Zm <- 1-(Press/TT)*(aa[1]+aa[2]**Temp*+aa[3]**Temp*^2
>>                      +(bb[1]+bb[2]*Temp)*Xv+(cc[1]+cc[2]**Temp*)*Xv^2)
>> +(Press/TT)^2*(dd+ee*Xv^2)
>> Roaxs <- pp*Ma/(zz*R*tt)
>> Rov <- Xv*Press*M/(Zm*R*TT)
>> Roa <- (1-Xv)*Press*Ma/(Zm*R*TT)
>> n <- 1+(Roa/Roaxs)*raxs+(Rov/ro)*rvs
>> return(n)
>> }
>>
>>
>> Basically, this is just a function to calculate index of refraction in air.
>> The function is just dealing with numbers.
>> So i am quite surprise getting this error.
>> Simon
>>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/Cannot-use-negative-argument-in-function-tp4430667p4432628.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>>  __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
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] Contour plot

2012-02-29 Thread Leong Keat Chan
Hi, I would like to make a contour plot using R with the following information 
(data at the end): x-axis= arranged according to day (from 1 to 365, labels= 
use months; up to 365 days in one year), y-axis= depth (labels from 0 at the 
top to 7 at the bottom; this is a water depth profile), and z-axis= pH. So, 
this would be a pH contour plot of different dates throughout a year, with pH 
measured at different depths (0 meter to 7 meters). I tried to use various 
contour plot packages, but always have trouble with y axis data that are not 
arranged in ascending order thus failed to make a matrix for data in the z-axis 
(pH). So, I used akima to make a matrix 
(data.interp<-interp(x,y,z,duplicate="mean")) but the results is a square 
matrix- Not sure if the data is correct. So, any help/suggestion would be 
great! An example image that I would like to make is here: 
http://neuer.lab.asu.edu/images/10_data/roosevelt_temp.JPG

Thanks so much!

Leo


Data:
Day Month   Depth   pH
23  Jan 0   4.9
23  Jan 3   4.93
23  Jan 7   5.05
52  Feb 0   4.93
52  Feb 3   4.92
52  Feb 7   5.54
86  Mar 0   4.93
86  Mar 3   5.09
86  Mar 7   5.32
115 Apr 0   4.92
115 Apr 3   4.88
115 Apr 7   5.385
142 May 0   4.99
142 May 2   4.805
142 May 5   5.31
142 May 7   5.41
169 Jun 0   4.935
169 Jun 2   4.66
169 Jun 3   4.96
169 Jun 7   5.55
198 Jul 0   5.19
198 Jul 3   5.1
198 Jul 5   5.59
198 Jul 7   5.8
225 Aug 0   5.05
225 Aug 2   4.88
225 Aug 5   5.31
225 Aug 7   5.53
225 Sep 0   4.78
225 Sep 2   4.76
225 Sep 5   5.22
225 Sep 6   5.4
282 Oct 0   4.8
282 Oct 3   4.91
282 Oct 5   5.185
282 Oct 6   5.32
319 Nov 0   5.06
319 Nov 3   5.05
319 Nov 7   5.11

[[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] Cannot use negative argument in function

2012-02-29 Thread Richard M. Heiberger
This line

 TT <- *Temp*+273.15
makes it unexecutable.  that is not the error you mentioned.

should that be

 TT <- "Temp"+273.15
or
 TT <- Temp+273.15
or something else?

On Wed, Feb 29, 2012 at 2:14 PM, lidaky  wrote:

> here is the code:
>
> index.refraction <- function(Temp,Press, RH, CO2)
> {
>  #define constant
>  lambda  <-  531 #nm
>  Co  <- 299792458 #m/s
>  ww <- c(295.235,2.6422,-0.03238,0.004028)
>  kk  <- c( 238.0185 ,5792105 ,57.362 ,167917)
>  aa  <- c( 1.58123 * 10^(-6) , -2.9331 * 10^(-8) , 1.1043 * 10^(-10))
>  bb  <- c( 5.707 * 10^(-6) , -2.051 * 10^(-8))
>  cc  <-  c(1.9898 * 10^(-4) , -2.376 * 10^(-6))
>  dd  <- 1.83 * 10^(-11)
>  ee  <-  -0.765 * 10^(-8)
>  pp <- 101325
>  tt <- 288.15
>  zz <- 0.9995922115
>  ro <- 0.00985938
>  R <- 8.314472
>  M <- 0.018015
>
>  S <- 1/(lambda*10^-3)^2
>  ras <- 10^-8*((kk[2]/(kk[1]-S))+(kk[4]/(kk[3]-S)))
>  rvs  <- 1.022*10^-8*(ww[1]+S*ww[2]+ww[3]*S^2+ww[4]*S^3)
>  Ma  <-  0.0289635 + 1.2011 * 10^(-8) * (CO2 - 400)
>  raxs  <- ras*(1+5.34*10^-7*(CO2-450))
>  TT <- *Temp*+273.15
>
> #Saturation vapor pressure over ice
> # A1 <- -13.928169
> # A2 <- 34.7078238
> # Theta <- (*Temp*+273.15)/273.16
> # Y  <-  A1 * (1 - Theta^(-1.5)) + A2 * (1 - Theta^(-1.25))
> # Psv <- 611.657*exp(Y)
>
>  #Saturation vapor pressure over water
>  Tc  <-  647.096   # K   : Temperature at the critical point
>  Pc  <-  22.064 * 10^4 # hPa : Vapor pressure at the critical point
>  nu  <-  (1-TT/Tc)
>  a1  <-  -7.85951783
>  a2  <-  1.84408259
>  a3  <-  -11.7866497
>  a4  <-  22.6807411
>  a5  <-  -15.9618719
>  a6  <-  1.80122502
>  Psv  <-  Pc * exp(Tc/TT * (a1*nu + a2*nu^1.5 + a3*nu^3. + a4*nu^3.5 +
> a5*nu^4. + a6*nu^7.5))
>
> Alpha  <-  1.00062
> Beta  <-  3.14 * 10^(-8)
> Gamma  <-  5.60 * 10^(-7)
> fpt <- Alpha+Beta*Press+Gamma**Temp*^2
> Xv <- (RH/100)*fpt*Psv/Press
>
>  Zm <- 1-(Press/TT)*(aa[1]+aa[2]**Temp*+aa[3]**Temp*^2
>  +(bb[1]+bb[2]*Temp)*Xv+(cc[1]+cc[2]**Temp*)*Xv^2)
> +(Press/TT)^2*(dd+ee*Xv^2)
> Roaxs <- pp*Ma/(zz*R*tt)
> Rov <- Xv*Press*M/(Zm*R*TT)
> Roa <- (1-Xv)*Press*Ma/(Zm*R*TT)
> n <- 1+(Roa/Roaxs)*raxs+(Rov/ro)*rvs
> return(n)
> }
>
>
> Basically, this is just a function to calculate index of refraction in air.
> The function is just dealing with numbers.
> So i am quite surprise getting this error.
> Simon
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Cannot-use-negative-argument-in-function-tp4430667p4432628.html
> Sent from the R help mailing list archive at Nabble.com.
>
>  __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] TM reader with text

2012-02-29 Thread Mickael R problem
Hello everybody,
I work, I try, with TM but I have a problem with some special words in
french. I think this is due to the manner to transform PDF to text, but I'm
not perfectly sure. 
Let's see to the example :

findFreqTerms(tdm1,30)
[33] """n"   "nancement"  
"nancier" "nancière""nancières"  
"nanciers""xe" 

Some french words are not well reading by TM with the reader readPlain. I
try to use reader= reader PDF. But it doesn't work so I must transformed PDF
text to text. And some words are not understand so when I use 
TermDocumentMatrix a word like inflation diseappear. It's a big probleme for
me. I spend lot of time on this problem, any idea ? Thank's for you time.
Best regard"s
Mickaël


--
View this message in context: 
http://r.789695.n4.nabble.com/TM-reader-with-text-tp4433394p4433394.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] NaN in nlminb

2012-02-29 Thread Alexandr
Good day everybody!

Please help me with NaN result in nlminb function.
I use the following:

The function that present weighted maximum likelihood:
garchLLH<-
function(parm) {
mu = parm[1]; omega = parm[2]; alpha = parm[3]; beta = parm[4]
z = (x-mu); Mean = mean(z^2)
# Use Filter Representation:
e = omega + alpha * c(Mean, z[-length(x)]^2)
h = filter(e, beta, "r", init = Mean)
hh = sqrt(abs(h))
llh = -sum(y*log(garchDist(z, hh)))
llh }

Where,
y<-rep(0,length(x))
len<-length(x)
for (i in 1:len) {
y[i]<-0.5^(len-i+1)}}
Mean = mean(x); Var = var(x); S = 1e-6
params = c(mu = Mean, omega = 0.1*Var, alpha = 0.1, beta = 0.8)
lowerBounds = c(mu = -10*abs(Mean), omega = S^2, alpha = S, beta = S)
 upperBounds = c(mu = 10*abs(Mean), omega = 100*Var, alpha = 1-2*S, beta =
1-2*S)
garchDist = function(z, hh) { dnorm(x = z/hh)/hh }

Also I use scaling in optimization:
 parscale = rep(1, length = length(params))
parscale[2] = var(x)
 parscale[1] = abs(mean(x))

And finally optoimization function:
fit = nlminb(start = params, objective = garchLLH, lower = lowerBounds,
upper = upperBounds,
scale = 1/parscale, control = list(eval.max = 2000, iter.max = 1500, rel.tol
= 1e-14, x.tol = 1e-14))

For calculating as x I use the lorarithmic yield of the share "Gazprom"
quotes.
The code for yield is following:
 logyield<-
function(range1) {
len<-length(range1)
log(range1[2:len]/range1[1:(len-1)],base=exp(1))}

Running the nlminb results the NaN at the 37th step of iteration.

Please help how to overcome the problem. If you want to try the calculation
I can send you the share "Gazprom" quotes 


--
View this message in context: 
http://r.789695.n4.nabble.com/NaN-in-nlminb-tp4432939p4432939.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] Contour plot

2012-02-29 Thread lkchan
Hi, I would like to make a contour plot with the data below, x-axis= Day
(increasing order, day number is out of 365 days of a year), y-axis= Depth
(varies), and z=pH. I tried to use filled.contour function, but not sure the
proper way to ordinate my z results into a matrix with different x and y
length. After that, if I attempted to plot the data, the x and y values are
not in ascending order...so a filled contour plot cannot be made. Any help
is appreciated!

Thanks!

Leo 

Day Month   Depth   pH
23  Jan 0   4.9
23  Jan 3   4.93
23  Jan 7   5.05
52  Feb 0   4.93
52  Feb 3   4.92
52  Feb 7   5.54
86  Mar 0   4.93
86  Mar 3   5.09
86  Mar 7   5.32
115 Apr 0   4.92
115 Apr 3   4.88
115 Apr 7   5.385
142 May 0   4.99
142 May 2   4.805
142 May 5   5.31
142 May 7   5.41
169 Jun 0   4.935
169 Jun 2   4.66
169 Jun 3   4.96
169 Jun 7   5.55
198 Jul 0   5.19
198 Jul 3   5.1
198 Jul 5   5.59
198 Jul 7   5.8
225 Aug 0   5.05
225 Aug 2   4.88
225 Aug 5   5.31
225 Aug 7   5.53
225 Sep 0   4.78
225 Sep 2   4.76
225 Sep 5   5.22
225 Sep 6   5.4
282 Oct 0   4.8
282 Oct 3   4.91
282 Oct 5   5.185
282 Oct 6   5.32
319 Nov 0   5.06
319 Nov 3   5.05
319 Nov 7   5.11

--
View this message in context: 
http://r.789695.n4.nabble.com/RE-Contour-plot-tp4433128p4433128.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] regular expression

2012-02-29 Thread Fred G
Computer Friends,

with the following example lines:

[107] "98-610: Cell type: S; Surv(months): 6; STATUS(0=alive, 1=dead): 1"

[108] "99-625: Cell type: S; Surv(months): 21; STATUS(0=alive, 1=dead): 1"

i want to be able to isolate the number of months of survival for each row.

is there a regular expression that can find the first instance of a ";",
delete everything in front of it-- and find the second instance of an ";"
and delete everything behind it? in python there is a function line.find(),
would be grateful to hear the R equiv; or, any other better alternatives to
get the number of months of survival stored as a variable.

Much Thank You!

[[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] function for filtering and deleting vector entries

2012-02-29 Thread Rui Barradas
Hello,


babyluck wrote
> 
> Dear helpers
> 
> I have two data sets saved as vectors (temperature and velocity). Now I
> need to "take out" a span of temperature and its corresponding velocity in
> the other vector. How can I achieve that? 
> 
> I tried to write a function,which takes a vector entry and then decides
> wether to delete the temperature entry or not and  simultaneously doing so
> with same entry in the velocity vector..
> But somehow it's not working...could somebody please help me? 
> Thanks a lot..
> 
> 
> norm = function(Temp,v){
>   for (i in 1:length(Temp)){
>   
>   if (Temp[i]<=16 || Temp[i] >= 38.5)
>{Temp[-i];v[-i]}
> 
>   return(Temp,v)
>   }
> }
> 

Your function is not changing 'Temp' nor 'v', just choosing subsets of them.
And you 'return' at the end of the first iteration...
(And you can only return one value)

Try


fun <- function(Temp, v){
unwanted <- Temp <= 16 | Temp >= 38.5
Temp <- Temp[!unwanted]
v <- v[!unwanted]
list(Temp=Temp, v=v)
}

(tt <- seq(10, 40, by=0.5))
(vv <- 1:length(tt))
fun(tt, vv)

I've changed the name because 'norm' is a  R function name. See ?norm

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/function-for-filtering-and-deleting-vector-entries-tp4432410p4432772.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] linear regression by column

2012-02-29 Thread Filoche
Hi everyone.

I have a DF with the first column being my independant variable and all
other columns the dependent variables.

Something like:

x   y1  y2  y3
... ... ... ...
... ... ... ...

What I'm trying to do is to perform a linear model for each of my "y". It is
pretty simple with loops, but I'm trying to vectorize it using *apply*.

For instance, I tried something like:

apply(DF, 1, function(DF){lm(DF[,1] ~ Band1[,2:5])})

But apparently it does not work.

Any help would be greatly appreciated.


Phil 

--
View this message in context: 
http://r.789695.n4.nabble.com/linear-regression-by-column-tp4432564p4432564.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] Cannot use negative argument in function

2012-02-29 Thread lidaky
here is the code:

index.refraction <- function(Temp,Press, RH, CO2)
{
  #define constant
  lambda  <-  531 #nm
  Co  <- 299792458 #m/s
  ww <- c(295.235,2.6422,-0.03238,0.004028)
  kk  <- c( 238.0185 ,5792105 ,57.362 ,167917)
  aa  <- c( 1.58123 * 10^(-6) , -2.9331 * 10^(-8) , 1.1043 * 10^(-10))
  bb  <- c( 5.707 * 10^(-6) , -2.051 * 10^(-8))
  cc  <-  c(1.9898 * 10^(-4) , -2.376 * 10^(-6))
  dd  <- 1.83 * 10^(-11) 
  ee  <-  -0.765 * 10^(-8)
  pp <- 101325
  tt <- 288.15
  zz <- 0.9995922115
  ro <- 0.00985938
  R <- 8.314472
  M <- 0.018015
  
  S <- 1/(lambda*10^-3)^2
  ras <- 10^-8*((kk[2]/(kk[1]-S))+(kk[4]/(kk[3]-S)))
  rvs  <- 1.022*10^-8*(ww[1]+S*ww[2]+ww[3]*S^2+ww[4]*S^3)
  Ma  <-  0.0289635 + 1.2011 * 10^(-8) * (CO2 - 400)
  raxs  <- ras*(1+5.34*10^-7*(CO2-450))
  TT <- *Temp*+273.15 

#Saturation vapor pressure over ice
# A1 <- -13.928169
# A2 <- 34.7078238
# Theta <- (*Temp*+273.15)/273.16
# Y  <-  A1 * (1 - Theta^(-1.5)) + A2 * (1 - Theta^(-1.25))
# Psv <- 611.657*exp(Y)

  #Saturation vapor pressure over water
  Tc  <-  647.096   # K   : Temperature at the critical point
  Pc  <-  22.064 * 10^4 # hPa : Vapor pressure at the critical point
  nu  <-  (1-TT/Tc)
  a1  <-  -7.85951783
  a2  <-  1.84408259
  a3  <-  -11.7866497
  a4  <-  22.6807411
  a5  <-  -15.9618719
  a6  <-  1.80122502
  Psv  <-  Pc * exp(Tc/TT * (a1*nu + a2*nu^1.5 + a3*nu^3. + a4*nu^3.5 +
a5*nu^4. + a6*nu^7.5))
  
Alpha  <-  1.00062 
Beta  <-  3.14 * 10^(-8) 
Gamma  <-  5.60 * 10^(-7)
fpt <- Alpha+Beta*Press+Gamma**Temp*^2
Xv <- (RH/100)*fpt*Psv/Press

  Zm <- 1-(Press/TT)*(aa[1]+aa[2]**Temp*+aa[3]**Temp*^2
  +(bb[1]+bb[2]*Temp)*Xv+(cc[1]+cc[2]**Temp*)*Xv^2)
+(Press/TT)^2*(dd+ee*Xv^2)
Roaxs <- pp*Ma/(zz*R*tt)
Rov <- Xv*Press*M/(Zm*R*TT)
Roa <- (1-Xv)*Press*Ma/(Zm*R*TT)
n <- 1+(Roa/Roaxs)*raxs+(Rov/ro)*rvs
return(n)
}


Basically, this is just a function to calculate index of refraction in air.
The function is just dealing with numbers.
So i am quite surprise getting this error.
Simon

--
View this message in context: 
http://r.789695.n4.nabble.com/Cannot-use-negative-argument-in-function-tp4430667p4432628.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] Binning continuous data

2012-02-29 Thread Faryabi, Robert (NIH/NCI) [F]
Hi there,

Here is the scenario:

I have a measurement of some sort for two variables, I would like to figure out 
a rough pattern between them. Let say if the values of the first variable are 
low, middle, high, and extremely high, then what would be the corresponding 
pattern of the second variable. The idea is not to find the 2d distribution, 
but plot a conditional distribution of the second variable based on the binning 
of the the first variable and then present it in a boxplot.

I got the breakpoints for binning the first variables by a bi-modal density 
estimation. Now I need to bin the first variable accordingly and map them to a 
categorical value.

Is there an R command that does the binning?

Thanks,
Robert

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


Re: [R] Quantile scores as dependent variables.. an R and general method question

2012-02-29 Thread Doran, Harold
Typically this list doesn't support general statistical questions and 
unfortunately I don't have a better recommendation. It may be more helpful for 
you to work with a statistician than seek help here. 

My point is simply that quantile regression is not for modeling outcomes that 
are quantiles. The fact that you have a dependent variables expressed as a 
percentile doesn't mean that quantile regression is the appropriate approach.

From: ila...@gmail.com [ila...@gmail.com] On Behalf Of ilai 
[ke...@math.montana.edu]
Sent: Wednesday, February 29, 2012 5:52 PM
To: Doran, Harold
Cc: Rob James; r-help@r-project.org
Subject: Re: [R] Quantile scores as dependent variables.. an R and general 
method question

On Wed, Feb 29, 2012 at 1:23 PM, Doran, Harold  wrote:
>
> The OP is looking for a way to deal with outcomes scores that are quantiles, 
> not a method that models different quantiles of the conditional distribution 
> where an outcome is a continuous variable. So, I don't think QR methods is 
> what is needed.

Huhh?
First, "deal with" is rather vague, does it mean summary? plot?
delete? as the OP is worried about independence, some modelling
exercise is more likely. Second, where do you think the OP quantiles
come from if not from the conditional distribution of some continuous
RV ? hint: not France.
So for "...leads to theory, texts or R code.." on the distributional
properties of quantiles/order statistics, do you have a better
suggestion for a starting point than QR methods?

Cheers

> 
> From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf 
> Of ilai [ke...@math.montana.edu]
> Sent: Wednesday, February 29, 2012 1:30 PM
> To: Rob James
> Cc: r-help@r-project.org
> Subject: Re: [R] Quantile scores as dependent variables.. an R and general 
> method question
>
> On Tue, Feb 28, 2012 at 3:54 PM, Rob James  wrote:
>> I have a dataset that does not include native scores, but only serial
>> quantile rankings for a set of units.
>>
>> Clearly these observations are dependent (in that you can't alter one
>> observation without also altering others).
>>
>> Are there methods for dealing with quantile dependent variables. My atempt
>> to find such methods has not bee successful.
>>
>
> Really? because google found 227k hits for "R quantile regression" -
> none of them lead anywhere ?
>
>
>> Any leads to theory, texts or R code would be most appeciated.
>>
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Quantile scores as dependent variables.. an R and general method question

2012-02-29 Thread ilai
On Wed, Feb 29, 2012 at 1:23 PM, Doran, Harold  wrote:
>
> The OP is looking for a way to deal with outcomes scores that are quantiles, 
> not a method that models different quantiles of the conditional distribution 
> where an outcome is a continuous variable. So, I don't think QR methods is 
> what is needed.

Huhh?
First, "deal with" is rather vague, does it mean summary? plot?
delete? as the OP is worried about independence, some modelling
exercise is more likely. Second, where do you think the OP quantiles
come from if not from the conditional distribution of some continuous
RV ? hint: not France.
So for "...leads to theory, texts or R code.." on the distributional
properties of quantiles/order statistics, do you have a better
suggestion for a starting point than QR methods?

Cheers

> 
> From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf 
> Of ilai [ke...@math.montana.edu]
> Sent: Wednesday, February 29, 2012 1:30 PM
> To: Rob James
> Cc: r-help@r-project.org
> Subject: Re: [R] Quantile scores as dependent variables.. an R and general 
> method question
>
> On Tue, Feb 28, 2012 at 3:54 PM, Rob James  wrote:
>> I have a dataset that does not include native scores, but only serial
>> quantile rankings for a set of units.
>>
>> Clearly these observations are dependent (in that you can't alter one
>> observation without also altering others).
>>
>> Are there methods for dealing with quantile dependent variables. My atempt
>> to find such methods has not bee successful.
>>
>
> Really? because google found 227k hits for "R quantile regression" -
> none of them lead anywhere ?
>
>
>> Any leads to theory, texts or R code would be most appeciated.
>>
>>        [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] function for filtering and deleting vector entries

2012-02-29 Thread andrija djurovic
Hi.

Maybe this will help you:

set.seed(1)
temp <- 1:100
v <- rnorm(100)

temp[temp<16 | temp>38]
v[temp<16 | temp>38]

Andrija

On Wed, Feb 29, 2012 at 7:09 PM, babyluck  wrote:
> Dear helpers
>
> I have two data sets saved as vectors (temperature and velocity). Now I need
> to "take out" a span of temperature and its corresponding velocity in the
> other vector. How can I achieve that?
>
> I tried to write a function,which takes a vector entry and then decides
> wether to delete the temperature entry or not and  simultaneously doing so
> with same entry in the velocity vector..
> But somehow it's not working...could somebody please help me?
> Thanks a lot..
>
>
> norm = function(Temp,v){
>        for (i in 1:length(Temp)){
>
>                if (Temp[i]<=16 || Temp[i] >= 38.5)
>                 {Temp[-i];v[-i]}
>
>                return(Temp,v)
>        }
> }
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/function-for-filtering-and-deleting-vector-entries-tp4432410p4432410.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] Trying to eliminate a for loop

2012-02-29 Thread Steven Wolf
Yes!  That works.  

Thank you so much!

-Steve

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Petr Savicky
Sent: Wednesday, February 29, 2012 4:41 PM
To: r-help@r-project.org
Subject: Re: [R] Trying to eliminate a for loop

On Wed, Feb 29, 2012 at 03:52:15PM -0500, Steven Wolf wrote:
> I keep trying to eliminate for loops when I arrive at them, but this 
> one is stumping me.  What is the nifty way to do this?
> 
> My object data.cca is the output of the cancor function (for some two 
> datasets X and Y) (data.cca is a numeric vector)
> 
> data.cca <- cancor(X,Y)
> 
> Xcen=0*X
> for(i in 1:dim(X)[1]){
>   Xcen[i,]=data.cca$xcenter
>   }
> Xc = X - Xcen

Hi.

Is the following, what you are looking for?

  Xc <- sweep(X, 2, data.cca$xcenter)

Hope this helps.

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.

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


Re: [R] memory management

2012-02-29 Thread Sam Steingold
> *   [2012-02-29 13:55:25 -0600]:
> On Wed, 29 Feb 2012, Sam Steingold wrote:
>> compacting garbage collector is our best friend!
>
> Which R does not use because of the problems it would create for
> external C/Fortran code on which R heavily relies.

Well, you know better, of course.

However, I cannot stop wondering if this really is absolutely necessary.
If you do not call GC while the external C/Fortran code is running, you
should be fine with a compacting garbage collector.
If you access the C/Fortran data (managed by the C/Fortran code), then
it should live in a separate universe from the one managed by R GC.

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://www.childpsy.net/ http://dhimmi.com http://camera.org
http://iris.org.il http://truepeace.org http://mideasttruth.com
Lisp: it's here to save your butt.

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


Re: [R] Cleaning up messy Excel data

2012-02-29 Thread Rolf Turner

On 01/03/12 04:43, John Kane wrote:

(mydata<- as.factor(c("1","2","3", ">2", "5", ">2")))
str(mydata)

newdata<- as.character(mydata)

newdata[newdata==">2"]<- 0
newdata<- as.numeric(newdata)
str(newdata)

We really need to keep Excel (and other spreadsheets) out of peoples hands.


Amen, bro'!!!

cheers,

Rolf Turner

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


Re: [R] Trying to eliminate a for loop

2012-02-29 Thread Petr Savicky
On Wed, Feb 29, 2012 at 03:52:15PM -0500, Steven Wolf wrote:
> I keep trying to eliminate for loops when I arrive at them, but this one is
> stumping me.  What is the nifty way to do this?
> 
> My object data.cca is the output of the cancor function (for some two
> datasets X and Y) (data.cca is a numeric vector)
> 
> data.cca <- cancor(X,Y)
> 
> Xcen=0*X
> for(i in 1:dim(X)[1]){
>   Xcen[i,]=data.cca$xcenter
>   }
> Xc = X - Xcen

Hi.

Is the following, what you are looking for?

  Xc <- sweep(X, 2, data.cca$xcenter)

Hope this helps.

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.


Re: [R] Frequencies from x/y data into a 2d table (for 3d histogram or heatmap)

2012-02-29 Thread Marcio Pupin Mello

Hi David,
   thanks a lot! Actually, I was looking for the graph since I still 
have obtained the table... but It can help...

   Best,

Marcio
www.dsr.inpe.br/~mello


On 2/29/12 5:34 PM, David L Carlson wrote:

Something like this?

x<- round(runif(100, 0, 40), 0)
y<- round(runif(100, 0, 40), 0)
xgroup<- cut(x, seq(0, 40, 10), include.lowest=TRUE)
ygroup<- cut(y, seq(0, 40, 10), include.lowest=TRUE)
xy<- table(xgroup, ygroup)
image(xy)

You'll still have to work with the plot commands to label it properly.

--
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Marcio Pupin Mello
Sent: Wednesday, February 29, 2012 12:49 PM
To: r-h...@stat.math.ethz.ch
Subject: Re: [R] Frequencies from x/y data into a 2d table (for 3d histogram
or heatmap)

Hi Ralf,
have you solved your problem?! If so, could you share? I have the same
problem...
Best,

Marcio


On 3/25/10 6:03 PM, Ralf B wrote:

Hi all,

I have simple x/y data from screen recording in a sequence:

number,x,y

1,10,30
1,20,
1,43,110
1,74,18
1,88,112

and would like to create a 3d histogram data structure that i can use
to create a 3d histogram or, more likely a heatmap. The unterlying
data structure therefore needs to look like this:

0-1011-20 21-3031-40
0-10
11-20
21-30
31-40

where the values in the cells represent counts of datapoints fitting
respective ranges for x and y. Can somebody point me to a procedure in
R that can make such a transformation for different range sizes (i.e.
10 in my example)? I came across the following method:



https://stat.ethz.ch/pipermail/r-help/attachments/20070425/fcb92205/attachme
nt.pl



which seems (at least close) but did not get it running (could not
find clear3d()). I also dont' need the 3d histogram plot as I will be
using the table to create a heatmap. I might be thinking to
complicated here. To me, it seems like this should be possible with a
few lines of code. Perhaps one of you has them lying around somewhere
or knows a script that does the trick.

Thanks in advance!

Ralf



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 print km square in the form of km2

2012-02-29 Thread Rolf Turner

On 01/03/12 10:27, Elaine Kuo wrote:

Hello Rolf,

Thank you for the response.

I tried your command but it did not work.
 plot(1:10,ylab="y",xlab=expression(plain(km)^2))

Please kindly advise any other method to make "2" in km2 become a 
uppercase number.

Thanks again.


The expression ``uppercase number'' makes no sense.

DO YOU MEAN ``superscript''?

If so, say so.  I.e. use the correct terminology or no-one can help 
you.


Anyway the command works for me.  I.e. it gives me the "2" as a 
***superscript***.


If you indeed want a superscript, then you must be doing something 
strange, or there is

something strange about your setup.

Can you tell/show me *exactly* what you did?

If you don't want a superscript please make it clear what you *do* want.
As I said "uppercase number" makes no sense at all.

cheers,

Rolf

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 print km square in the form of km2

2012-02-29 Thread Sarah Goslee
Try
plot(1:10,ylab="y",xlab=expression(km^2))
and if that fails, you'll need to tell us what you mean by "did not
work."

Sarah

On Wed, Feb 29, 2012 at 4:27 PM, Elaine Kuo  wrote:
> Hello Rolf,
>
> Thank you for the response.
>
> I tried your command but it did not work.
>  plot(1:10,ylab="y",xlab=**expression(plain(km)^2))
>
> Please kindly advise any other method to make "2" in km2 become a uppercase
> number.
> Thanks again.
>
> Elaine
>
>
> On Tue, Feb 21, 2012 at 8:24 AM, Rolf Turner  wrote:
>
>> On 21/02/12 12:54, Elaine Kuo wrote:
>>
>>> Hello,
>>>
>>> This is Elaine.
>>>
>>> I am drawing a plot with x-axis label with "km square" as the unit.
>>> Now I want to print km square in the form of km2 and output "2" as the
>>> uppercase.
>>> Please kindly help suggest command to show the uppercase.
>>>
>>
>> When you say "as [the] uppercase" I *think* you mean "as a
>> superscript".  Assuming that I am correct in my supposition,
>> you can achieve what you want via the syntax shown in the
>> following example:
>>
>>    plot(1:10,ylab="y",xlab=**expression(plain(km)^2))
>>
>> For details on how you do this sort of thing in general see:
>>
>>    ?plotmath
>>
>> Be warned --- it's tricky!  I find that I always need to experiment
>> quite a lot before I get it right.  Experimentation is cheap, but.
>>
>> HTH
>>
>>    cheers,
>>

-- 
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] how to print km square in the form of km2

2012-02-29 Thread Elaine Kuo
Hello Rolf,

Thank you for the response.

I tried your command but it did not work.
 plot(1:10,ylab="y",xlab=**expression(plain(km)^2))

Please kindly advise any other method to make "2" in km2 become a uppercase
number.
Thanks again.

Elaine


On Tue, Feb 21, 2012 at 8:24 AM, Rolf Turner  wrote:

> On 21/02/12 12:54, Elaine Kuo wrote:
>
>> Hello,
>>
>> This is Elaine.
>>
>> I am drawing a plot with x-axis label with "km square" as the unit.
>> Now I want to print km square in the form of km2 and output "2" as the
>> uppercase.
>> Please kindly help suggest command to show the uppercase.
>>
>
> When you say "as [the] uppercase" I *think* you mean "as a
> superscript".  Assuming that I am correct in my supposition,
> you can achieve what you want via the syntax shown in the
> following example:
>
>plot(1:10,ylab="y",xlab=**expression(plain(km)^2))
>
> For details on how you do this sort of thing in general see:
>
>?plotmath
>
> Be warned --- it's tricky!  I find that I always need to experiment
> quite a lot before I get it right.  Experimentation is cheap, but.
>
> HTH
>
>cheers,
>
>Rolf Turner
>

[[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] Trying to eliminate a for loop

2012-02-29 Thread Steven Wolf
I keep trying to eliminate for loops when I arrive at them, but this one is
stumping me.  What is the nifty way to do this?

My object data.cca is the output of the cancor function (for some two
datasets X and Y) (data.cca is a numeric vector)

data.cca <- cancor(X,Y)

Xcen=0*X
for(i in 1:dim(X)[1]){
Xcen[i,]=data.cca$xcenter
}
Xc = X - Xcen

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


Re: [R] Frequencies from x/y data into a 2d table (for 3d histogram or heatmap)

2012-02-29 Thread David L Carlson
Something like this?

x <- round(runif(100, 0, 40), 0)
y <- round(runif(100, 0, 40), 0)
xgroup <- cut(x, seq(0, 40, 10), include.lowest=TRUE)
ygroup <- cut(y, seq(0, 40, 10), include.lowest=TRUE)
xy <- table(xgroup, ygroup)
image(xy)

You'll still have to work with the plot commands to label it properly.

--
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Marcio Pupin Mello
Sent: Wednesday, February 29, 2012 12:49 PM
To: r-h...@stat.math.ethz.ch
Subject: Re: [R] Frequencies from x/y data into a 2d table (for 3d histogram
or heatmap)

Hi Ralf,
have you solved your problem?! If so, could you share? I have the same 
problem...
Best,

Marcio


On 3/25/10 6:03 PM, Ralf B wrote:
> Hi all,
>
> I have simple x/y data from screen recording in a sequence:
>
> number,x,y
> 
> 1,10,30
> 1,20,
> 1,43,110
> 1,74,18
> 1,88,112
>
> and would like to create a 3d histogram data structure that i can use
> to create a 3d histogram or, more likely a heatmap. The unterlying
> data structure therefore needs to look like this:
>
>0-1011-20 21-3031-40
> 0-10
> 11-20
> 21-30
> 31-40
>
> where the values in the cells represent counts of datapoints fitting
> respective ranges for x and y. Can somebody point me to a procedure in
> R that can make such a transformation for different range sizes (i.e.
> 10 in my example)? I came across the following method:
>
>
https://stat.ethz.ch/pipermail/r-help/attachments/20070425/fcb92205/attachme
nt.pl
>
>
> which seems (at least close) but did not get it running (could not
> find clear3d()). I also dont' need the 3d histogram plot as I will be
> using the table to create a heatmap. I might be thinking to
> complicated here. To me, it seems like this should be possible with a
> few lines of code. Perhaps one of you has them lying around somewhere
> or knows a script that does the trick.
>
> Thanks in advance!
>
> Ralf
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ggplot2 dot chart-start at zero

2012-02-29 Thread John Kane
I am trying to create a simple dot-plot in ggplot2  with a solid line from the 
y-axis to the dot, something I first saw in Cleveland's 1984 book

What I would like is to have the graph start at zero on the x-axis but leave 
some space on the right side of the plot area.

I assumed that I should be able to do this with expand() in 
scale_x_continuous() but either I'm wrong or just don't understand what  
expand() is doing. So far, I see that scale_x_continuous(expand=c(0,0)) removes 
the space on the right and left. but I don't understand how to just get the 
left only to disappear.

Any help would be appreciated

Code below
 #
library(ggplot2)
xx<- structure(list(Food = c("Milk", "Bread", "Potatoes", "Rice"), 
Expense = c(25L, 49L, 34L, 15L)), .Names = c("Food", "Expense"
), class = "data.frame", row.names = c(NA, -4L))


p <- ggplot(xx, aes(Expense, Food))

pa <- p + geom_point(aes(Expense, Food, colour=Food)) +
   geom_segment(aes(x = 0, xend = Expense,  
   y = Food, yend = Food,colour=Food)) +
   opts(legend.position = "none")

pa  # so far so good

p1 <- pa + scale_x_continuous(expand=c(0,0))  
#===

R version 2.13.1 (2011-07-08)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   

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

other attached packages:
[1] ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4 plyr_1.7   


John Kane
Kingston ON Canada


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your 
desktop!

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


Re: [R] puzzling results from logistic regression

2012-02-29 Thread Ben Bolker
Michael  gmail.com> writes:

> 
> Hi all,
> 
> As you can see from below, the result is strange...
> 
> I would imagined that the bb result should be much higher and close to 1,
> any way to improve the fit?
> 
> Any other classification methods?
> 
> Thank you!
> 
> data=data.frame(y=rep(c(0, 1), times=100), x=1:200)
> aa=glm(y~x, data=data, family=binomial(link="logit"))
> 
> newdata=data.frame(x=6, y=100)
> bb=predict(aa, newdata=newdata, type="response")
> bb
> 
> > bb
> 
> 1
> 
> 0.4929125
> 

  I have a feeling you meant to say

data <- data.frame(y=rep(c(0,1), each=100), x=1:200)

instead. 

Try 

with(data,plot(y~x))

for each data set to see what you actually got as opposed to
what you thought you were getting it.

You may still have a little bit of a problem fitting such an
extreme data set -- this is what is called "complete separation",
and leads to an infinite estimate of the slope -- if you want
to pursue this, take a look at the brglm package.

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


Re: [R] Quantile scores as dependent variables.. an R and general method question

2012-02-29 Thread Doran, Harold
Rob

The OP is looking for a way to deal with outcomes scores that are quantiles, 
not a method that models different quantiles of the conditional distribution 
where an outcome is a continuous variable. So, I don't think QR methods is what 
is needed. 

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
ilai [ke...@math.montana.edu]
Sent: Wednesday, February 29, 2012 1:30 PM
To: Rob James
Cc: r-help@r-project.org
Subject: Re: [R] Quantile scores as dependent variables.. an R and general 
method question

On Tue, Feb 28, 2012 at 3:54 PM, Rob James  wrote:
> I have a dataset that does not include native scores, but only serial
> quantile rankings for a set of units.
>
> Clearly these observations are dependent (in that you can't alter one
> observation without also altering others).
>
> Are there methods for dealing with quantile dependent variables. My atempt
> to find such methods has not bee successful.
>

Really? because google found 227k hits for "R quantile regression" -
none of them lead anywhere ?


> Any leads to theory, texts or R code would be most appeciated.
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] How can I avoid the warning messages when calling DAAG package?

2012-02-29 Thread Uwe Ligges



On 29.02.2012 15:19, Jason Love wrote:

Dear R users,
I'm a newbie for R and want to ask some basic questions.
So, after I open the R software, I typed library(DAAG). Then, I get massive
warning messages as shown below.
  Why does it happen?
  Also, here are few specific questions regarding each message.

   1) Loading required package: MASS ->  Does this mean that the MASS package
is not included in DAAG?


Yes.


   2) Attaching package: 'survival' ->Does this also mean that the package
'survival' is attached because it is not included in DAAG?


Yes.


   3) Why are so many objects masked even after I open up the fresh R and
type library (DAAG) first time?


Because you loaded lots of packages and you have, e.g., a fossilfuel in 
your workspace and another object with the same name is in the package. 
Next, DAAG is masking some objects from the other packages. Since we 
have NAMESPACES nowadays, it is not too serious to mask objects unless 
you want to use them directly (and the information is given to notify 
you about that).


Uwe Ligges





  Any help would be appreciated,
  Jason




library(DAAG)

Loading required package: MASS
Loading required package: rpart
Loading required package: randomForest
randomForest 4.6-6
Type rfNews() to see new features/changes/bug fixes.
Loading required package: boot
Loading required package: survival
Loading required package: splines

Attaching package: ‘survival’

The following object(s) are masked from ‘package:boot’:

 aml


Attaching package: ‘DAAG’

The following object(s) are masked _by_ ‘.GlobalEnv’:

 fossilfuel

The following object(s) are masked from ‘package:survival’:

 lung

The following object(s) are masked from ‘package:MASS’:

 hills

[[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] memory management

2012-02-29 Thread luke-tierney

On Wed, 29 Feb 2012, Sam Steingold wrote:


* Milan Bouchet-Valat  [2012-02-29 18:18:50 +0100]:

I think you're simply hitting a (terrible) OS limitation. Linux is
very often not able to reclaim the memory R has used because it's
fragmented.  The OS can only get the pages back if nothing is above
them, and most of the time there is data after the object you
remove. I'm not able to give you a more precise explanation, but
that's apparently a known problem and that's hard to fix.


compacting garbage collector is our best friend!


Which R does not use because of the problems it would create for
external C/Fortran code on which R heavily relies.


--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 319-335-3386
Department of Statistics andFax:   319-335-3017
   Actuarial Science
241 Schaeffer Hall  email:   luke-tier...@uiowa.edu
Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu

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


Re: [R] orthogonal distance regression package?

2012-02-29 Thread Adam Waytz

Thanks all.  This is tremendously helpful.

Best,
Adam

On Feb 29, 2012, at 12:58 PM, David Reiner wrote:

> My understanding is that TLS, EIV, and orthogonal regression are closely 
> related but separate concepts.
> If you read the  'Talk' at the Wikipedia page referenced below, you will see 
> that many people have
> terminology problems as well.
> My take is that TLS is a special case of EIV and orthogonal linear regression 
> is a special case of TLS.
> ** If your data is centered, then the orthogonal regression slope is just the 
> ratio of the standard deviations of the two variables. **
> You can get the same thing from PCA if you first scale by the SD's and then 
> restore them after finding the first eigenvector.
> The TLS and EIV approaches are more general, but assuming that the relative 
> errors in the variables are equal, and things are 'nice' gives the simple 
> result above.
> 
> The page Mark refers to from Sabine van Huffel's book on TLS is visible in 
> Google books.
> 
> HTH,
> -- David
> 
> 
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf Of Mark Leeds
> Sent: Wednesday, February 29, 2012 12:37 PM
> To: Adam Waytz
> Cc: ; Bert Gunter
> Subject: Re: [R] orthogonal distance regression package?
> 
> Hi: I can't find it anywhere on the internet but I have a book that shows 
> that, as long as the SVD of the X matrix can be obtained, then the 
> coefficient solution to TLS ( least angle regression )  is only a function of 
> the eigenvectors.
> Therefore, principal components can be used to obtain the coefficients in TLS 
> which could be why there may not be an R package out there.
> 
> The book is titled "The Total Least Squares Problem" Huffel and Vandewalle.
> 
> Paul Teetor's paper ( see link below ) has an example of using principal 
> components to calculate the coefficients in a univariate TLS.
> 
> Disclaimer: I've never used TLS regression and never studied it so there 
> could be subtlleties where the result doesn't hold. The result is on page
> 37 of the book and the book is almost 300 pages so the SVD approach must not 
> work all the time.
> 
> https://docs.google.com/viewer?a=v&q=cache:h5YT7w7fQXkJ:quanttrader.info/public/betterHedgeRatios.pdf+&hl=en&gl=us&pid=bl&srcid=ADGEESjbXq-o_3J148Ex376HqUTLCTbDyuH921wEkyze_uT8wlwhvpK8ywgp9ZBNPFTe9p7TbxTgHdNhD3BwjFSPD6H9ln1mIKDN1y0yKXOb9c3zHYhQnAuCtVx3aptuL7P2FtvIrl-0&sig=AHIEtbRl0WGG4c551EHnuOYP3cQ1RaEsBA&pli=1
> ''
> 
> 
> 
> 
> 
> 
> 
> On Wed, Feb 29, 2012 at 1:19 PM, Adam Waytz < 
> a-wa...@kellogg.northwestern.edu> wrote:
> 
>> 
>> In the age of google, I have found that concepts such as these are
>> more complex than what Wikipedia provides. Going far beyond a cursory
>> search, it appeared to me there are subtle differences between these
>> terms. I was hoping this knowledgeable community could provide insight
>> on an R package to perform ODR. Thank you.
>> 
>> On Feb 29, 2012, at 12:07 PM, "Bert Gunter" 
>> wrote:
>> 
>>> On Wed, Feb 29, 2012 at 7:53 AM, Adam Waytz
>>>  wrote:
 
 Hello,
 
 I am extremely new to R and have found some leads to this question
 in
>> the archives, but I am still a bit uncertain.
 I am looking for an R package to carry out orthogonal distance
>> regression.  I found some answers regarding Deming
 regression and Total Least Squares regression, but I was unclear if
>> these are identical terms.
>>> 
>>> In the age of Google?!
>>> 
>>> Searching on "orthogonal regression" brought up:
>>> 
>>> http://en.wikipedia.org/wiki/Total_least_squares
>>> 
>>> which provides info. Sheesh!
>>> 
>>> I suggest you also check the ChemPhys and Econometrics task views on
>>> CRAN to see what they have to offer.
>>> 
>>> Incidentally, my very limited understanding is that orthogonal
>>> regression (for errors in variables) can be problematic. The
>>> wikipedia article provides more details.
>>> 
>>> -- Bert
>>> 
>>> Please let me know if
 a package is available.
 
 Thank you,
 Adam
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.
>> 
> 
>[[alternative HTML version deleted]]
> 
> ___

[R] Question about tables in bigtabulate

2012-02-29 Thread steven mosher
I have a large file backed big. matrix, with millions of rows and 20
columns.

The columns contain data that I simply need to tabulate. There are a few
dozen unique
values. and I just want a frequency count

Test code with a small "big" matrix.

library(bigmemory)
library(bigtabulate)

  test <- big.matrix(nrow = 100, ncol = 10)
  test[,1:3]<- sample(150)
  test[,4:6]<- sample(100)
  test[,7:10]<- sample(100)

##so we have  sample big memory matrix. Its not file backed but will do
for testing.
##the result we want is one that you would get if you could run table()
 on the bigmatrix
##thats emulated in this example by coercing the bigmatrix to a matrix.
##in the real application that is not possible, because of RAM limits
  P <- table(as.matrix(test))

##  the package big tabulate has a version of table called  bigtable.
##  you can run table on an individual column.
## I want to run it on all the columns. basically combine the results of
running it on individual columns
## if you try to specify multiple columns, you get a contingency table, and
if you use too many
## columns you will hang your system hard .. so dont try the line below .
Well at least I hung my system

#  Ouch <- bigtable(test, ccols = seq(1,10))

So, is there a simple way to  get the answer as emulated by
 P<-table(as.matrix(test))
without coercing to a matrix.

TIA

[[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] orthogonal distance regression package?

2012-02-29 Thread David Reiner
My understanding is that TLS, EIV, and orthogonal regression are closely 
related but separate concepts.
If you read the  'Talk' at the Wikipedia page referenced below, you will see 
that many people have
terminology problems as well.
My take is that TLS is a special case of EIV and orthogonal linear regression 
is a special case of TLS.
** If your data is centered, then the orthogonal regression slope is just the 
ratio of the standard deviations of the two variables. **
You can get the same thing from PCA if you first scale by the SD's and then 
restore them after finding the first eigenvector.
The TLS and EIV approaches are more general, but assuming that the relative 
errors in the variables are equal, and things are 'nice' gives the simple 
result above.

The page Mark refers to from Sabine van Huffel's book on TLS is visible in 
Google books.

HTH,
-- David


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Mark Leeds
Sent: Wednesday, February 29, 2012 12:37 PM
To: Adam Waytz
Cc: ; Bert Gunter
Subject: Re: [R] orthogonal distance regression package?

Hi: I can't find it anywhere on the internet but I have a book that shows that, 
as long as the SVD of the X matrix can be obtained, then the coefficient 
solution to TLS ( least angle regression )  is only a function of the 
eigenvectors.
Therefore, principal components can be used to obtain the coefficients in TLS 
which could be why there may not be an R package out there.

The book is titled "The Total Least Squares Problem" Huffel and Vandewalle.

Paul Teetor's paper ( see link below ) has an example of using principal 
components to calculate the coefficients in a univariate TLS.

Disclaimer: I've never used TLS regression and never studied it so there could 
be subtlleties where the result doesn't hold. The result is on page
37 of the book and the book is almost 300 pages so the SVD approach must not 
work all the time.

https://docs.google.com/viewer?a=v&q=cache:h5YT7w7fQXkJ:quanttrader.info/public/betterHedgeRatios.pdf+&hl=en&gl=us&pid=bl&srcid=ADGEESjbXq-o_3J148Ex376HqUTLCTbDyuH921wEkyze_uT8wlwhvpK8ywgp9ZBNPFTe9p7TbxTgHdNhD3BwjFSPD6H9ln1mIKDN1y0yKXOb9c3zHYhQnAuCtVx3aptuL7P2FtvIrl-0&sig=AHIEtbRl0WGG4c551EHnuOYP3cQ1RaEsBA&pli=1
''







On Wed, Feb 29, 2012 at 1:19 PM, Adam Waytz < a-wa...@kellogg.northwestern.edu> 
wrote:

>
> In the age of google, I have found that concepts such as these are
> more complex than what Wikipedia provides. Going far beyond a cursory
> search, it appeared to me there are subtle differences between these
> terms. I was hoping this knowledgeable community could provide insight
> on an R package to perform ODR. Thank you.
>
> On Feb 29, 2012, at 12:07 PM, "Bert Gunter" 
> wrote:
>
> > On Wed, Feb 29, 2012 at 7:53 AM, Adam Waytz
> >  wrote:
> >>
> >> Hello,
> >>
> >> I am extremely new to R and have found some leads to this question
> >> in
> the archives, but I am still a bit uncertain.
> >> I am looking for an R package to carry out orthogonal distance
> regression.  I found some answers regarding Deming
> >> regression and Total Least Squares regression, but I was unclear if
> these are identical terms.
> >
> > In the age of Google?!
> >
> > Searching on "orthogonal regression" brought up:
> >
> > http://en.wikipedia.org/wiki/Total_least_squares
> >
> > which provides info. Sheesh!
> >
> > I suggest you also check the ChemPhys and Econometrics task views on
> > CRAN to see what they have to offer.
> >
> > Incidentally, my very limited understanding is that orthogonal
> > regression (for errors in variables) can be problematic. The
> > wikipedia article provides more details.
> >
> > -- Bert
> >
> >  Please let me know if
> >> a package is available.
> >>
> >> Thank you,
> >> Adam
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/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.
>

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


This e-mail and any materials atta

Re: [R] Frequencies from x/y data into a 2d table (for 3d histogram or heatmap)

2012-02-29 Thread Marcio Pupin Mello

Hi Ralf,
have you solved your problem?! If so, could you share? I have the same 
problem...

Best,

Marcio


On 3/25/10 6:03 PM, Ralf B wrote:

Hi all,

I have simple x/y data from screen recording in a sequence:

number,x,y

1,10,30
1,20,
1,43,110
1,74,18
1,88,112

and would like to create a 3d histogram data structure that i can use
to create a 3d histogram or, more likely a heatmap. The unterlying
data structure therefore needs to look like this:

   0-1011-20 21-3031-40
0-10
11-20
21-30
31-40

where the values in the cells represent counts of datapoints fitting
respective ranges for x and y. Can somebody point me to a procedure in
R that can make such a transformation for different range sizes (i.e.
10 in my example)? I came across the following method:

https://stat.ethz.ch/pipermail/r-help/attachments/20070425/fcb92205/attachment.pl


which seems (at least close) but did not get it running (could not
find clear3d()). I also dont' need the 3d histogram plot as I will be
using the table to create a heatmap. I might be thinking to
complicated here. To me, it seems like this should be possible with a
few lines of code. Perhaps one of you has them lying around somewhere
or knows a script that does the trick.

Thanks in advance!

Ralf



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


Re: [R] Volcano Plot

2012-02-29 Thread Martin Morgan

On 02/28/2012 08:13 AM, aishsk wrote:

Hi I am using the ggplot2 package for the volcano plot and I am using the
following code for the same:

g = ggplot(data=data, aes(x=data[11], y=-log10(data[12]), colour=threshold))
+
+   geom_point(alpha=0.4, size=1.75) +
+   opts(legend.position = "none") +
+   xlim(c(-10, 10)) + ylim(c(0, 15)) +
+   xlab("log2 fold change") + ylab("-log10 p-value")

data[11] is a column of the fold change values and data[12] contains the P
values and I am getting a following error:

Error: geom_point requires the following missing aesthetics: x, y
  What can be done for the same ?
And if not what other package may I use for the same in which I don't have
to use a lmfit model?


Have you tried, if 'data' is a data.frame, simply plot(data[[1]], 
-log10(data[[12]])) ?


Martin


Thanks

--
View this message in context: 
http://r.789695.n4.nabble.com/Volcano-Plot-tp4428622p4428622.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.



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

Location: M1-B861
Telephone: 206 667-2793

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


Re: [R] orthogonal distance regression package?

2012-02-29 Thread Mark Leeds
Hi: I can't find it anywhere on the internet but I have a book that shows
that, as long
as the SVD of the X matrix can be obtained, then the coefficient solution
to TLS ( least angle regression )  is only a function of the eigenvectors.
Therefore, principal components can be used to obtain the coefficients in
TLS which could be why there may not be an R package out there.

The book is titled "The Total Least Squares Problem" Huffel and Vandewalle.

Paul Teetor's paper ( see link below ) has an example of using principal
components to calculate the coefficients in a univariate TLS.

Disclaimer: I've never used TLS regression and never studied it so there
could be subtlleties where the result doesn't hold. The result is on page
37 of the book and the book is almost 300 pages so the SVD approach must
not work all the time.

https://docs.google.com/viewer?a=v&q=cache:h5YT7w7fQXkJ:quanttrader.info/public/betterHedgeRatios.pdf+&hl=en&gl=us&pid=bl&srcid=ADGEESjbXq-o_3J148Ex376HqUTLCTbDyuH921wEkyze_uT8wlwhvpK8ywgp9ZBNPFTe9p7TbxTgHdNhD3BwjFSPD6H9ln1mIKDN1y0yKXOb9c3zHYhQnAuCtVx3aptuL7P2FtvIrl-0&sig=AHIEtbRl0WGG4c551EHnuOYP3cQ1RaEsBA&pli=1
''







On Wed, Feb 29, 2012 at 1:19 PM, Adam Waytz <
a-wa...@kellogg.northwestern.edu> wrote:

>
> In the age of google, I have found that concepts such as these are more
> complex than what Wikipedia provides. Going far beyond a cursory search, it
> appeared to me there are subtle differences between these terms. I was
> hoping this knowledgeable community could provide insight on an R package
> to perform ODR. Thank you.
>
> On Feb 29, 2012, at 12:07 PM, "Bert Gunter" 
> wrote:
>
> > On Wed, Feb 29, 2012 at 7:53 AM, Adam Waytz
> >  wrote:
> >>
> >> Hello,
> >>
> >> I am extremely new to R and have found some leads to this question in
> the archives, but I am still a bit uncertain.
> >> I am looking for an R package to carry out orthogonal distance
> regression.  I found some answers regarding Deming
> >> regression and Total Least Squares regression, but I was unclear if
> these are identical terms.
> >
> > In the age of Google?!
> >
> > Searching on "orthogonal regression" brought up:
> >
> > http://en.wikipedia.org/wiki/Total_least_squares
> >
> > which provides info. Sheesh!
> >
> > I suggest you also check the ChemPhys and Econometrics task views on
> > CRAN to see what they have to offer.
> >
> > Incidentally, my very limited understanding is that orthogonal
> > regression (for errors in variables) can be problematic. The wikipedia
> > article provides more details.
> >
> > -- Bert
> >
> >  Please let me know if
> >> a package is available.
> >>
> >> Thank you,
> >> Adam
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/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.
>

[[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] Quantile scores as dependent variables.. an R and general method question

2012-02-29 Thread ilai
On Tue, Feb 28, 2012 at 3:54 PM, Rob James  wrote:
> I have a dataset that does not include native scores, but only serial
> quantile rankings for a set of units.
>
> Clearly these observations are dependent (in that you can't alter one
> observation without also altering others).
>
> Are there methods for dealing with quantile dependent variables. My atempt
> to find such methods has not bee successful.
>

Really? because google found 227k hits for "R quantile regression" -
none of them lead anywhere ?


> Any leads to theory, texts or R code would be most appeciated.
>
>        [[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] Computing line= for mtext

2012-02-29 Thread Richard M. Heiberger
Frank,

This can be done directly with a variant of the panel.axis function.
See function panel.axis.right in the HH package.  This was provided for me
by David Winsemius in response to my query on this list in October 2011
https://stat.ethz.ch/pipermail/r-help/2011-October/292806.html

The email thread also includes comments by Deepayan Sarkar and Paul Murrell.

Rich

On Wed, Feb 29, 2012 at 8:48 AM, Frank Harrell wrote:

> I want to right-justify a vector of numbers in the right margin of a
> low-level plot.  For this I need to compute the line parameter to give to
> mtext.  Is this the correct scalable calculation?
>
> par(mar=c(4,3,1,5)); plot(1:20)
> s <- 'abcde'; w=strwidth(s, units='inches')/par('cin')[1]
> mtext(s, side=4, las=1, at=5, adj=1, line=w-.5, cex=1)
> mtext(s, side=4, las=1, at=7, adj=1, line=2*(w-.5), cex=2)
>
> Thanks
> Frank
>
> -
> Frank Harrell
> Department of Biostatistics, Vanderbilt University
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Computing-line-for-mtext-tp4431554p4431554.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Coding help

2012-02-29 Thread Petr Savicky
On Wed, Feb 29, 2012 at 11:58:04AM -0500, Ayyappa Chaturvedula wrote:
> Dear Group,
> 
> I have the following dataset:
>ID REPI DV CONC SS
> 11 156.84  116  0
> 1   2 146.56  116  0
>13 115.13  116  0
>14 207.81  116  0
>   15 129.53  116  0
>   16 151.48  116  0
>   17 158.95  116  0
>   18 192.37  116  0
>   19  32.97  116  0
>   1   10 151.66  116  0
> 
> I want to calculate the percentile of each CONC within ID=i and add as a
> column "Percentile".  I got some help from R-tutorial on percentile but I
> am not able loop the function to calculate percentile/individual.  So, I
> want the calculation to include only the ID=1 DVs to calculate the
> pecentile of conc=116.

Hi.

Can you provide a numerical example? This may require some
more data, where the column CONC has more than one value.

Another question is, what do you mean by computing percentile
for data. I would expect that you specify a number P, such
that 0 \le P < 100 and compute P-th percentile in some data.

Do you want to compute the inverse operation? This would
mean to compute P for each value in the data. For your
column DV, this would be

  DV <- c(156.84,146.56,115.13,207.81,129.53,151.48,158.95,192.37,32.97,151.66)
  p <- 100*(rank(DV)-1)/length(DV)
  cbind(DV, p)

DV  p
   [1,] 156.84 60
   [2,] 146.56 30
   [3,] 115.13 10
   [4,] 207.81 90
   [5,] 129.53 20
   [6,] 151.48 40
   [7,] 158.95 70
   [8,] 192.37 80
   [9,]  32.97  0
  [10,] 151.66 50

This need not be, what you want. In this case, provide a numerical
example.

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.


[R] function for filtering and deleting vector entries

2012-02-29 Thread babyluck
Dear helpers

I have two data sets saved as vectors (temperature and velocity). Now I need
to "take out" a span of temperature and its corresponding velocity in the
other vector. How can I achieve that? 

I tried to write a function,which takes a vector entry and then decides
wether to delete the temperature entry or not and  simultaneously doing so
with same entry in the velocity vector..
But somehow it's not working...could somebody please help me? 
Thanks a lot..


norm = function(Temp,v){
for (i in 1:length(Temp)){

if (Temp[i]<=16 || Temp[i] >= 38.5)
 {Temp[-i];v[-i]}

return(Temp,v)
}
}


--
View this message in context: 
http://r.789695.n4.nabble.com/function-for-filtering-and-deleting-vector-entries-tp4432410p4432410.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] orthogonal distance regression package?

2012-02-29 Thread Adam Waytz

In the age of google, I have found that concepts such as these are more complex 
than what Wikipedia provides. Going far beyond a cursory search, it appeared to 
me there are subtle differences between these terms. I was hoping this 
knowledgeable community could provide insight on an R package to perform ODR. 
Thank you. 

On Feb 29, 2012, at 12:07 PM, "Bert Gunter"  wrote:

> On Wed, Feb 29, 2012 at 7:53 AM, Adam Waytz
>  wrote:
>> 
>> Hello,
>> 
>> I am extremely new to R and have found some leads to this question in the 
>> archives, but I am still a bit uncertain.
>> I am looking for an R package to carry out orthogonal distance regression.  
>> I found some answers regarding Deming
>> regression and Total Least Squares regression, but I was unclear if these 
>> are identical terms.
> 
> In the age of Google?!
> 
> Searching on "orthogonal regression" brought up:
> 
> http://en.wikipedia.org/wiki/Total_least_squares
> 
> which provides info. Sheesh!
> 
> I suggest you also check the ChemPhys and Econometrics task views on
> CRAN to see what they have to offer.
> 
> Incidentally, my very limited understanding is that orthogonal
> regression (for errors in variables) can be problematic. The wikipedia
> article provides more details.
> 
> -- Bert
> 
>  Please let me know if
>> a package is available.
>> 
>> Thank you,
>> Adam
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] orthogonal distance regression package?

2012-02-29 Thread Bert Gunter
On Wed, Feb 29, 2012 at 7:53 AM, Adam Waytz
 wrote:
>
> Hello,
>
> I am extremely new to R and have found some leads to this question in the 
> archives, but I am still a bit uncertain.
> I am looking for an R package to carry out orthogonal distance regression.  I 
> found some answers regarding Deming
> regression and Total Least Squares regression, but I was unclear if these are 
> identical terms.

In the age of Google?!

Searching on "orthogonal regression" brought up:

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

which provides info. Sheesh!

I suggest you also check the ChemPhys and Econometrics task views on
CRAN to see what they have to offer.

Incidentally, my very limited understanding is that orthogonal
regression (for errors in variables) can be problematic. The wikipedia
article provides more details.

-- Bert

 Please let me know if
> a package is available.
>
> Thank you,
> Adam
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] equivalent from gladder and ladder from stata

2012-02-29 Thread Richard M. Heiberger
>From your description, I believe the ladder function in the HH package is
what you are looking for.

## install.packages("HH")  ## if  necessary
library(HH)
data(tv)
ladder(life.exp ~ ppl.per.phys, data=tv, scales=list(relation="free"))

Rich
On Wed, Feb 29, 2012 at 6:21 AM, agent dunham  wrote:

> Dear community,
>
> Apologies, I'm still pretty newbie. Anyway, I am performing linar
> regression
> analysis. As a common cause of non-normally distributed residuals is
> non-normally predictor variables, i'm interested in achieving the best
> transformation of the predictors.
>
> I've seen some commands at R, but I would like to know if it exists a
> command equivalent to gladder (graphic display) , and another one
> equivalent
> to ladder (numeric results,  look for the transformation with the smallest
> chi-square)
>
> Thanks in advance, show u...@host.com as u...@host.com
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/equivalent-from-gladder-and-ladder-from-stata-tp4431216p4431216.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] How to simulate demographic (specifically, sub-group) data?

2012-02-29 Thread Chris Campbell
Hi Alok

See ?createCovariates in MSToolkit.

Best wishes

Chris
 
Chris Campbell
MANGO SOLUTIONS
Data Analysis that Delivers
+44 1249 705450

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Bhupatkar, Alok
Sent: 29 February 2012 16:30
To: r-help@r-project.org
Subject: [R] How to simulate demographic (specifically, sub-group) data?

I am a relatively new R user and have recently built a multivariate dataset 
without the demographic information.

Is there any package or code to simulate subgroup dataset (race, sex, age) 
using R?

Any help would be appreciated.

Thanks,
Alok

[[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.
LEGAL NOTICE
This message is intended for the use o...{{dropped:10}}

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


Re: [R] memory management

2012-02-29 Thread Sam Steingold
> * Milan Bouchet-Valat  [2012-02-29 18:18:50 +0100]:
>
> I think you're simply hitting a (terrible) OS limitation. Linux is
> very often not able to reclaim the memory R has used because it's
> fragmented.  The OS can only get the pages back if nothing is above
> them, and most of the time there is data after the object you
> remove. I'm not able to give you a more precise explanation, but
> that's apparently a known problem and that's hard to fix.

compacting garbage collector is our best friend!

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000
http://www.childpsy.net/ http://iris.org.il http://www.memritv.org
http://ffii.org http://honestreporting.com http://jihadwatch.org
To a Lisp hacker, XML is S-expressions with extra cruft.

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


Re: [R] R newbie: Installation of package reshape exit status not 0

2012-02-29 Thread David Winsemius


On Feb 29, 2012, at 12:34 PM, ibid...@gmx.at wrote:


Hello,
sorry i'm an R newbie and wan't to install
ggplot2 on my ubuntu system.
during installation i got the error warning:

Warnmeldung:
In install.packages("reshape") :
 Installation des Pakets 'reshape' hatte Exit-Status ungleich 0

Please, give me a idea, how can i fix this error/warning


You might want to try installing reshape first. Sometimes packages do  
not list all of their dependencies properly. Before  you follow-up  
please first read the Posting Guide more thoroughly than you have so  
far.


--

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] R newbie: Installation of package reshape exit status not 0

2012-02-29 Thread Uwe Ligges



On 29.02.2012 18:34, ibid...@gmx.at wrote:

Hello,
sorry i'm an R newbie and wan't to install
ggplot2 on my ubuntu system.
during installation i got the error warning:

Warnmeldung:
In install.packages("reshape") :
   Installation des Pakets 'reshape' hatte Exit-Status ungleich 0

Please, give me a idea, how can i fix this error/warning




Read the posting guide and find that we really need some relevant 
information in order to be able to help!


Uwe Ligges

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 define a function which includes two functions as arguments such as "plot" and "text"

2012-02-29 Thread Uwe Ligges



On 28.02.2012 07:04, Yashwanth M.R wrote:

Hi  Mr. Uwe Ligges,


Yashwanth M.R,

this is the R-help mailing list, not my personal mail account (and "Mr." 
is inappropriate in any case).






 I really thankful for the reply.  I even tried the same,
means writing the new function. But the result is same as the last. Here is
the picture below,





 Telco.Rpart.PLOT.TEXT.Functn<-
function(Telco.Rpart.METHOD.CLASS)

 {

 Telco.Rpart.PLOT<-
plot(Telco.Rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE)

 Telco.Rpart.TEXT<-
text(Telco.Rpart.METHOD.CLASS,use.n = TRUE, cex = .75)

 }



   Telco.Rpart.PLOT.TEXT<-
Telco.Rpart.PLOT.TEXT.Functn(Telco.Rpart.METHOD.CLASS)

Telco.Rpart.PLOT.TEXT





Again if I solely run the command "Telco.Rpart.PLOT.TEXT",


That is the value returned from the previous function call, not a 
command nor a function.




the output it is
displaying as "NULL". Please help me finding out the desired result ASAP.


Yes, since that ws the result of calling the previous function.

Your output is not reproducible hence it is hard to help for us, we do 
not really understand what you are going to do with functions, and you 
should start reading "An Introduction to R" in order to get a basic 
sense of R. Finally, this is a mailning list driven by volunteers, and 
sense some rudeness in demanding things "ASAP".


Best,
Uwe Ligges









Regards,

Yashwanth M.R







From: Uwe Ligges-3 [via R] [mailto:ml-node+s789695n4417618...@n4.nabble.com]

Sent: Friday, February 24, 2012 9:16 PM
To: Yashwanth M.R
Subject: Re: To define a function which includes two functions as arguments
such as "plot" and "text"





On 24.02.2012 12:22, Yashwanth M.R wrote:



Here is the two functions which I have used during my practice.

*plot(Telco.rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE)

text(Telco.rpart.METHOD.CLASS,use.n = TRUE, cex = .75))*

"Telco.rpart.METHOD.CLASS" is my "rpart" object of the method "class".

If I run this,

*Telco.Rpart.PLOT.TEXT<-
c(plot(Telco.rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE),
 text(Telco.rpart.METHOD.CLASS,use.n = TRUE, cex =
.75))




c() concatenates the returned values of the two functions. If you want
to define a sequence of function calls, define them within your own
function, calling that new function will produce your desired results,
as far as I understand.

Uwe Ligges




http://r.789695.n4.nabble.com/file/n4416881/Rpart.gif

the output is getting generated as shown in the figure. But if I solely

run

the same command "Telco.Rpart.PLOT.TEXT" right after the above, the output



is as below,

/$x
   [1]  4.035156  1.00  7.070312  3.015625  2.00  4.031250
   [7]  3.00  5.062500  4.00  6.125000  5.00  7.25
[13]  6.50  6.00  7.00  8.00 11.125000 10.25
[19]  9.50  9.00 10.00 11.00 12.00

$y
   [1] 1.125 1.000 1.000 0.875 0.750 0.750 0.625 0.625 0.500 0.500 0.375
[12] 0.375 0.250 0.125 0.125 0.250 0.875 0.750 0.625 0.500 0.500 0.625
[23] 0.750
/


Please help me in getting the output which is there is the Image..

Regards,
Yashwanth M,R

--
View this message in context:

http://r.789695.n4.nabble.com/To-define-a-function-which-includes-two-functi
ons-as-arguments-such-as-plot-and-text-tp4416881p4416881.html

Sent from the R help mailing list archive at Nabble.com.

__
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.



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



   _

If you reply to this email, your message will be added to the discussion
below:

http://r.789695.n4.nabble.com/To-define-a-function-which-includes-two-functi
ons-as-arguments-such-as-plot-and-text-tp4416881p4417618.html

To unsubscribe from To define a function which includes two functions as
arguments such as "plot" and "text", click here
  .

  NAML



--
View this message in context: 
http://r.789695.n4.nabble.com/To-define-a-fun

Re: [R] Help please

2012-02-29 Thread Uwe Ligges



On 29.02.2012 17:36, Raúl Fernández Naranjo wrote:










Hi everyone, I was using rattle. I used a database with 4 individuals and 
50 variables. Reading the database was OK and that was made by rattle but when 
y was trying to draw the tree, rattle shows the image attached.



And have you followed the advice and contacted the e-mail address given 
there?


Uwe Ligges




Please help me.

Raúl Fernández



graf.png




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


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


Re: [R] Converting a function from Splus to R

2012-02-29 Thread William Dunlap
1.0d+0 is Fortran (not C) for a double precision value,
1.0 * 10^0.

1.0e+0 is Fortran for a single precision value, 1.0 * 10^0
and C for a double precision value.

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 Prof Brian
> Ripley
> Sent: Wednesday, February 29, 2012 5:41 AM
> To: R. Michael Weylandt
> Cc: r-help@r-project.org; Freddy Hernández
> Subject: Re: [R] Converting a function from Splus to R
> 
> On 29/02/2012 13:24, R. Michael Weylandt wrote:
> > Change the name to something syntactically valid? The problem is that
> > you can't (well, you can, but it's ill advised) have variable names
> > beginning with numbers.  They don't seem to be used much so there
> > won't be much trouble in that.
> 
> I think that 2.0d0 is someone translating C into R. Just use 2 .  In R,
> 2 is a double precision floating-point constant: in C and (recent
> S-PLUS) it is integer and you need to use 2.0 .
> 
> > Michael
> >
> > 2012/2/29 Freddy Hernández:
> >> I have a function written for Splus, when I run it in R I obtain get an 
> >> error
> >> because the function has the elements "0.d0" and "2.d0". How can I change 
> >> it
> >> to run in R?
> >>
> >> The function can be found in page 230 from
> >>   http://www.stat.wisc.edu/~mchung/teaching/stat471/stat_computing.pdf
> >>
> >> Function is as follows:
> >>
> >> gauher<- function(n) {# Gauss-Hermite: returns x,w so that
> >> #\int_-\infty^\infty exp(-x^2) f(x) dx \doteq \sum w_i f(x_i)
> >> EPS<- 3.e-14
> >> PIM4<- .7511255444649425D0
> >> MAXIT<- 10
> >> m<- trunc((n+1)/2)
> >> x<- w<- rep(-1,n)
> >> for (i in 1:m) {
> >> if (i==1) {
> >> z<- sqrt(2*n+1)-1.85575*(2*n+1)^(-.16667)
> >> } else if(i==2) {
> >> z<- z-1.14*n^.426/z
> >> } else if (i==3) {
> >> z<- 1.86*z-.86*x[1]
> >> } else if (i==4) {
> >> z<- 1.91*z-.91*x[2]
> >> } else {
> >> z<- 2.*z-x[i-2]
> >> }
> >> for (its in 1:MAXIT) {
> >> p1<- PIM4
> >> p2<- 0.d0
> >> for (j in 1:n) {
> >> p3<- p2
> >> p2<- p1
> >> p1<- z*sqrt(2.d0/j)*p2-sqrt((j-1)/j)*p3
> >> }
> >> pp<- sqrt(2.d0*n)*p2
> >> z1<- z
> >> z<- z1-p1/pp
> >> if(abs(z-z1)<= EPS) break
> >> }
> >> x[i]<- z
> >> x[n+1-i]<- -z
> >> w[i]<- 2/(pp*pp)
> >> w[n+1-i]<- w[i]
> >> }
> >> list(x=x,w=w)
> >> }
> >>
> >> --
> >> View this message in context: 
> >> http://r.789695.n4.nabble.com/Converting-a-function-from-Splus-to-R-
> tp4431416p4431416.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.
> 
> 
> --
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] R newbie: Installation of package reshape exit status not 0

2012-02-29 Thread ibidrin
Hello,
sorry i'm an R newbie and wan't to install 
ggplot2 on my ubuntu system. 
during installation i got the error warning:

Warnmeldung:
In install.packages("reshape") :
  Installation des Pakets 'reshape' hatte Exit-Status ungleich 0

Please, give me a idea, how can i fix this error/warning


-- 

Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

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


[R] How to extract numerical values from time series forecast

2012-02-29 Thread ForzaBruta
hi all. i'm busy with some time series data, starting from an earlier period
until the current day.

i have created a time series forecast taking into account the entire data
from the earlier date up until 2007, using the "forecast" package for R. i
am comparing this forecasted data to the actual/ observed data (which starts
from the earlier date up until the current day).

my question is, how do i extract the estimated data from the forecast as
actual values so that i can do further analysis with it?

thanking you all in advance

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-extract-numerical-values-from-time-series-forecast-tp4432165p4432165.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to simulate demographic (specifically, sub-group) data?

2012-02-29 Thread Bhupatkar, Alok
I am a relatively new R user and have recently built a multivariate dataset 
without the demographic information.

Is there any package or code to simulate subgroup dataset (race, sex, age) 
using R?

Any help would be appreciated.

Thanks,
Alok

[[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] orthogonal distance regression package?

2012-02-29 Thread Adam Waytz

Hello,

I am extremely new to R and have found some leads to this question in the 
archives, but I am still a bit uncertain.
I am looking for an R package to carry out orthogonal distance regression.  I 
found some answers regarding Deming
regression and Total Least Squares regression, but I was unclear if these are 
identical terms.  Please let me know if
a package is available.

Thank you,
Adam

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

2012-02-29 Thread Raúl Fernández Naranjo









Hi everyone, I was using rattle. I used a database with 4 individuals and 
50 variables. Reading the database was OK and that was made by rattle but when 
y was trying to draw the tree, rattle shows the image attached.

Please help me.

Raúl Fernández

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


Re: [R] Error: could not find function "hier.part"

2012-02-29 Thread Amay
Thank you Michael.
I also wrote to the author of this program, Palph, he suggested the same
thing. It worked!!
It is a very useful tool. In case for someone who is interested, I found the
package here:
http://cran.r-project.org/web/packages/hier.part/





--
View this message in context: 
http://r.789695.n4.nabble.com/Error-could-not-find-function-hier-part-tp4429644p4431998.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] Installing package QRMlib

2012-02-29 Thread DT54321
That worked!

Thanks a lot Jeremy. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-package-QRMlib-tp4425269p4431895.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to replace the values in a column

2012-02-29 Thread Rui Barradas
Hello,

Try the following.
(In Andrija's code I've changed 'df' to 'DF', 'df' is a R function name)

DF <- read.table( ... etc ...

tc <- textConnection("
Column1(Gen)Column2(Name)
A_1   Wynda
A_2 A_2
B_1 B_1
B_3 Wynda
OP1_1   Wynda
OP1_5OP1_5 
")
TransTable <- read.table(tc, header=TRUE, stringsAsFactors=FALSE)
close(tc)

nrTrans <- nrow(TransTable)

for(iTrans in 1:nrTrans){
i <- DF$Gen == TransTable[iTrans, 1]
DF$Gen[i] <- TransTable[iTrans, 2]
}
# See first 6 lines of result
head(DF)

That's it.

Hope this helps,

Rui Barradas



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-replace-the-values-in-a-column-tp4430448p4431983.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] use of subset in lme function

2012-02-29 Thread amace
Dear all,

I have an issue concerning the lme function and I couldn't find the solution 
elsewhere.

I have a data frame with id, Ages, Parameter1 and Parameter2.
The Ages can belong to one of two categories "early" or "late". 

Then for example an id can have several values of Parameter1 at different ages 
in the "early" category (but only one value per age)

What I want to know is if Parameter1 at early Age "predict" Parameter2 at late 
Age, but I don't know how to create two subsets one for parameter1 and one for 
parameter2.
I would like something like:

lme(Parameter2_late ~ I + Parameter1_early, data = dataset, random = ~1|id, 
correlation = corAR1(0.2, form = ~Ages|id)

I hope I made myself clear.

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


[R] How are the coefficients for the ur.ers, type DF-GLS calculated?

2012-02-29 Thread ackbar03
I need some real help on this, really stuck

how are the coefficients for
ur.ers(y, type = c("DF-GLS", "P-test"), model = c("constant", "trend"),
   lag.max = 0)

The max lag is set at zero, so the regression should simply be

Diff(zt) = a*z(t-1)

where a is the value i'm trying to find and z(t)'s are the detrended values.
but through performing my own regression on the two time series I get
different values. This could only mean

1) Its not just a simple regression
or
2) I'm detrending my data incorrectly.

However, i've followed the instructions I've seen in research papers and it
doesn't seem to be right. Basically I take Y*t = Yt-(1-(1-7/T)*Y(t-1) and
regress that on 1-(1-7/T)  for all t>1 and leave the values at T=1
unchanged. Then I take Yt and subtract the coefficient of the regression to
get the detrended value.

I'm really stuck on this and its really frustrating. I think the easiest
thing would be if someone can tell me exactly how R carries out the
calculations for the functions. Help will be highly appreciated!!


--
View this message in context: 
http://r.789695.n4.nabble.com/How-are-the-coefficients-for-the-ur-ers-type-DF-GLS-calculated-tp4432015p4432015.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] memory management

2012-02-29 Thread Milan Bouchet-Valat
Le mercredi 29 février 2012 à 11:42 -0500, Sam Steingold a écrit :
> > * William Dunlap  [2012-02-28 23:06:54 +]:
> >
> > You need to walk through the objects, checking for environments on
> > each component or attribute of an object.
> 
> so why doesn't object.size do that?
> 
> >   > f <- function(n) {
> >   +   d <- data.frame(y = rnorm(n), x = rnorm(n))
> >   +   lm(y ~ poly(x, 4), data=d)
> >   + }
> 
> I am not doing any modeling. No "~". No formulas.
> The whole thing is just a bunch of data frames.
> I do a lot of strsplit, unlist, & subsetting, so I could imagine why
> the RSS is triple the total size of my data if all the intermediate
> results are not released.
I think you're simply hitting a (terrible) OS limitation. Linux is very
often not able to reclaim the memory R has used because it's fragmented.
The OS can only get the pages back if nothing is above them, and most of
the time there is data after the object you remove. I'm not able to give
you a more precise explanation, but that's apparently a known problem
and that's hard to fix.

At least, I can confirm that after doing a lot of merges on big data
frames, R can keep using 3GB of shared memory on my box even if gc()
only reports 500MB currently used. Restarting R makes memory use go down
to the normal expectations.


Regards

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