[R] Reg GARCH+ARIMA

2010-03-17 Thread RAGHAVENDRA PRASAD
Hi,

Although my doubt is pretty,as i m not from stats background i am not sure
how to proceed on this.

Currently i am doing a forecasting.I used ARIMA to forecast and time series
was volatile i used garchFit for residuals.
How to use the output of Garch to correct the forecasted values from ARIMA.

Here is my code:

###delta is the data

fit-arima(delta,order=c(2,,0,1))

fit.res - resid(fit)
##Check for Residuals
acf((fit.res-mean(fit.res))/sd(fit.res))
acf(((fit.res-mean(fit.res))/sd(fit.res))^2)
fit.fore = predict(fit, n.ahead=test)

##Use ARIMA GARCH To fit residuals from ARIMA Model
1.
fitted.gar-garchFit(formula =~arma(2,1)+garch(1,1),data=*fit.res*,cond.dist
= std,trace=FALSE)
sresi=fitted@residuals/fitted@sigma.t   ###Standardised Residuals
acf(sresi)
acf(sresi^2)
fore.res-predict(fitted.ga, n.ahead=test)

OR
2.
fitted.gar-garchFit(formula =~arma(2,1)+garch(1,1),data=*delta*,cond.dist =
std,trace=FALSE)
sresi=fitted@residuals/fitted@sigma.t   ###Standardised Residuals
acf(sresi)
acf(sresi^2)
fore.res-predict(fitted.ga, n.ahead=test)

My Question is
1. How to use fore.res(Result from Garch Model) to change fit.fore
(Forecasted values from ARIMA)
2.Out of 1 and 2 for GARCH which one is correct.Pretty confused.Shud we need
to use the residuals got from ARIMA Model or the series directly ?

Regards,
Raghav

[[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] Effect Size Formaula and Calulations in R

2010-03-17 Thread C.H.
pwr package:

ES.h and ES.w1, ES.w2, cohen.ES



On Wed, Mar 17, 2010 at 1:28 PM, Jim Silverton jim.silver...@gmail.com wrote:
 Hello,
 I would like to find out how to use R to compute the effect size of two
 samples for a two sample t test. Is there a formula for the fisher's exact
 test? Any R code and/or formula would be greatly appreciated.

 Thanks,
 Jim

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




-- 
CH Chan
Research Assistant - KWH
http://www.macgrass.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] Summing daily data for each year

2010-03-17 Thread Santosh.Aryal

Hello there 
  
I have a DAILY data set (as shown below) with Date and 
 Streamflow from April 1995 to Aug 2006.  I want a yearly sum 
the streamflow value (for each year - first and last 
incomplete year).  

Does anyone know how to do this in R?
 
I have tried everything I could think of, e.g. imported the 
streamflow data as time series using:
 
flowdata - ts(ZVo[,2],start = c(1995,4,1), frequency = 7) # 
perhaps frequency = 365 is the better one and tried to 
aggregate using aggregate() without success

ZVo
 V1  V2
 1  1995-04-01 0.002766309
 2  1995-04-02 0.002402973
 3  1995-04-03 0.002254335
 4  1995-04-04 0.002221305
 5  1995-04-05 0.002180017
 6  1995-04-06 0.002031379
 7  1995-04-07 0.001957060
 8  1995-04-08 0.001940545
 9  1995-04-09 0.001924030
 10 1995-04-10 0.001783650
 .
 .
 .
 4156 2006-08-16 0.02861272
 4157 2006-08-17 0.03652353
 4158 2006-08-18 0.05372419
 4159 2006-08-19 0.05630058
 4160 2006-08-20 0.06274154
 4161 2006-08-21 0.06981833
 
 Many thanks 
 
 Santosh 
 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] C# DLL Library

2010-03-17 Thread Romain Francois

The link works fine for me on firefox, chrome and safari.

Other ways to get to it are:
- search rcpp mailing list on google.
- go to r-forge (again google knows where), click on the Rcpp - R/C++ 
interface, click on the Lists tab, click on subscribe, etc ...



Le 17/03/10 04:42, Jeremie Smaga a écrit :

I found the problem for the package that wasn't found... My R version was
2.9.
Sorry about that.

However, I would really appreciate it if you could let me know where I could
find the mailing list...


Thanks,

Jeremie

On Tue, Mar 16, 2010 at 6:56 PM, Romain Francois
rom...@r-enthusiasts.comwrote:


Hello,

disclaimer: I don't know C# at all and how it might connect to c++, etc ...

For an introductory ride about Rcpp, you can consult the Rcpp-introduction
vignette which you can download from the cran page of Rcpp or if you have it
installed, you can just do:


vignette( Rcpp-introduction, package = Rcpp )


For semi-self-explanatory code examples, you can consult our unit tests:


system.file( unitTests, package = Rcpp )


For more questions, we have a dedicated mailing list:
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Romain


Le 16/03/10 11:43, Jeremie Smaga a écrit :



Hello Richard,

Thanks for the tips.

I was aware of the R(D)COM. In the last public version, there is now
splash
screen appearing which is kind of boring so I think I need to buy it or
something.

Anyway, I think the idea was to create a common CORE library that can be
used from C# and from R. So I think I'll have a look at RCPP which looks
to
be the best solution.

Have you tried it already? Do you know any good tutorial for this package?

Thanks,

Jeremie


On Tue, Mar 16, 2010 at 5:23 PM,richard.cot...@hsl.gov.uk   wrote:



  I would like to develop a core library which I will be using both from R



and


from C#.



  - Writing the DLL freely in C# and then create a wrapper?

- Writing it in C++
- Writing it in C, the other options are really not good ideas.



As far as I know, there currently is no way to call .NET code from R.  If
you want a library that can be called from both a .NET environment and
from
R, then writing it in C or C++ is likely your best bet.  Alternatively,
you
can run R code from within .NET using the rcom package.  There's an
example
in F# here (what's true for F# is true for C#).



http://cs.hubfs.net/blogs/thepopeofthehub/archive/2007/11/06/FSharpWithR.aspx

See ?.C for calling C code, and the rcpp package for an interface to C++
code.  Choosing between those two languages mostly depends on whether on
not
your library is especially suited to object oriented programming or not.

Regards,
Richie.

Mathematical Sciences Unit*
**HSL*http://www.hsl.gov.uk/contact-us.htm



r-help-boun...@r-project.org wrote on 16/03/2010 09:04:54:


  Good afternoon everybody,


I am sorry, this question might look trivial to some of you, but I read
quite a lot of stuff about package creation and I would like a bit of
you
advices.





I read that it was possible to import DLL to R.

The thing is, I am not sure that the DLL created with C# will be


compatible.


I still have not implemented anything, so if it is only a matter of


method


signatures, I can make sure everything fits.

Otherwise, I could use a C++ DLL, but I don't know if it is really
recommended. (In fact, I would love to be able to develop it in Visual
Studio because it is where I developed the rest of my platform).

So, what would you advise?





Thanks,

--
Jeremie Smaga



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7
`- http://tr.im/O1wO : highlight 0.1-5

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


Re: [R] Summing daily data for each year

2010-03-17 Thread Tal Galili
HI Santosh,

The simplest way I can think of is (after you import the data) to do:
tapply(Zvo$V2, YEAR, sum)

The question is how to get YEAR.

You could do that if you know how to play with date objects.
Another option is to do something like:

YEAR - as.data.frame(strsplit(Zvo$V2, -))[1,]

For example:
as.data.frame(strsplit(c( 1995-04-01 ,1995-04-02), -))[1,]

I am sure others can think of better ways.

Tal



Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Wed, Mar 17, 2010 at 8:20 AM, santosh.ar...@csiro.au wrote:


 Hello there

 I have a DAILY data set (as shown below) with Date and
  Streamflow from April 1995 to Aug 2006.  I want a yearly sum
 the streamflow value (for each year - first and last
 incomplete year).

 Does anyone know how to do this in R?

 I have tried everything I could think of, e.g. imported the
 streamflow data as time series using:

 flowdata - ts(ZVo[,2],start = c(1995,4,1), frequency = 7) #
 perhaps frequency = 365 is the better one and tried to
 aggregate using aggregate() without success

 ZVo
 V1  V2
  1  1995-04-01 0.002766309
  2  1995-04-02 0.002402973
  3  1995-04-03 0.002254335
  4  1995-04-04 0.002221305
  5  1995-04-05 0.002180017
  6  1995-04-06 0.002031379
  7  1995-04-07 0.001957060
  8  1995-04-08 0.001940545
  9  1995-04-09 0.001924030
  10 1995-04-10 0.001783650
  .
  .
  .
  4156 2006-08-16 0.02861272
  4157 2006-08-17 0.03652353
  4158 2006-08-18 0.05372419
  4159 2006-08-19 0.05630058
  4160 2006-08-20 0.06274154
  4161 2006-08-21 0.06981833

  Many thanks

  Santosh

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Summing daily data for each year

2010-03-17 Thread Santosh.Aryal
Hello there
 
I have a DAILY data set (as shown below) with Date and Streamflow from April 
1995
to Aug 2006.  I want a yearly sum the streamflow value (for each year - first 
and last incomplete year).  
Does anyone know how to do this in R?
 
I have tried everything I could think of, e.g. imported the streamflow
data as time series using:
 
flowdata - ts(ZVo[,2],start = c(1995,4,1), frequency = 7) # perhaps frequency 
= 365 is the better one
and tried to aggregate using aggregate() without success

ZVo
V1  V2
1  1995-04-01 0.002766309
2  1995-04-02 0.002402973
3  1995-04-03 0.002254335
4  1995-04-04 0.002221305
5  1995-04-05 0.002180017
6  1995-04-06 0.002031379
7  1995-04-07 0.001957060
8  1995-04-08 0.001940545
9  1995-04-09 0.001924030
10 1995-04-10 0.001783650
.
.
.
4156 2006-08-16 0.02861272
4157 2006-08-17 0.03652353
4158 2006-08-18 0.05372419
4159 2006-08-19 0.05630058
4160 2006-08-20 0.06274154
4161 2006-08-21 0.06981833

Many thanks 

Santosh 

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


Re: [R] Summing daily data for each year

2010-03-17 Thread Bill.Venables
You might try something like this:

ZVo1 - with(ZVo, {
Year - substring(as.character(V1), 1, 4)
Count - table(Year) ## for a count of days
TFlow - tapply(V2, Year, sum) ## total flow
data.frame(Year=Year, No=Count, TotalFlow=TFlow)
})
 


Bill Venables
CSIRO/CMIS Cleveland Laboratories


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of santosh.ar...@csiro.au
Sent: Wednesday, 17 March 2010 3:22 PM
To: r-help@r-project.org
Subject: [ExternalEmail] [R] Summing daily data for each year

Hello there
 
I have a DAILY data set (as shown below) with Date and Streamflow from April 
1995
to Aug 2006.  I want a yearly sum the streamflow value (for each year - first 
and last incomplete year).  
Does anyone know how to do this in R?
 
I have tried everything I could think of, e.g. imported the streamflow
data as time series using:
 
flowdata - ts(ZVo[,2],start = c(1995,4,1), frequency = 7) # perhaps frequency 
= 365 is the better one
and tried to aggregate using aggregate() without success

ZVo
V1  V2
1  1995-04-01 0.002766309
2  1995-04-02 0.002402973
3  1995-04-03 0.002254335
4  1995-04-04 0.002221305
5  1995-04-05 0.002180017
6  1995-04-06 0.002031379
7  1995-04-07 0.001957060
8  1995-04-08 0.001940545
9  1995-04-09 0.001924030
10 1995-04-10 0.001783650
.
.
.
4156 2006-08-16 0.02861272
4157 2006-08-17 0.03652353
4158 2006-08-18 0.05372419
4159 2006-08-19 0.05630058
4160 2006-08-20 0.06274154
4161 2006-08-21 0.06981833

Many thanks 

Santosh 

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

2010-03-17 Thread lith
 I am following an example from online and am getting the following error:
 .Error unizipping fileunzip not found.

Are zip and unzip in your path? If not you could use odfWeaveControl.

Example:

odfctrl - odfWeaveControl(
zipCmd = c(h:/bin/zip.exe -r $$file$$ ., h:/bin/unzip.exe -o $
$file$$),
)
odfWeave(template, outfile, control = odfctrl)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Why eval(parse(text=var(vec))) return a matrix but NOT a number?

2010-03-17 Thread Yong Wang
Dear List

I am getting a problem when using eval(parse).
Code below sketchs what I am trying to do:

For each row of a N*K dataframe (I use a 2*2 dataframe in the example below),
applying a number of functions and get the outputs (two functions,
sum and var are used in the example below).

The problem is  eval(parse(text=sum(para))) works fine but not when
sum is replaced by var.
in the later case, a matrix instead of a number is returned.

Any suggestion highly appreciated.

Thank you

#===The function
myloop  -function(datfra,funs) {

rows-dim(datfra)[1];
totfunnum-length(funs);

for (i in 1:rows)   {
vec-datfra[i,];

for(k in 1:totfunnum)   {   
print(funs[k]);
x-eval(parse(text=funs[k]));
print(x);   
}

}
}


#Experiemental run
workport-data.frame(matrix(1:4,2,2))
funs-c(sum(vec,na.rm=T),var(vec,na.rm=T))  

myloop(workport,funs)

# Outputs of the
Experimental run

[1] sum(vec,na.rm=T)
[1] 4
[1] var(vec,na.rm=T)
   X1 X2
X1 NA NA
X2 NA NA
[1] sum(vec,na.rm=T)
[1] 6
[1] var(vec,na.rm=T)
   X1 X2
X1 NA NA
X2 NA NA

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


Re: [R] C# DLL Library

2010-03-17 Thread Dieter Menne


JSmaga wrote:
 
 I was aware of the R(D)COM. In the last public version, there is now
 splash
 screen appearing which is kind of boring so I think I need to buy it or
 something.
 
 

I would pay for RDCOM, but it requires that you explain the details of you
application spread (which is mostly 1 in my case, since I only work on
request), and that's unacceptable to me. I think there is a way to get
around that using the Rcommander (?) version, but I found a better solution:

I have moved to using RServe with c# recently; it has nice support for all
types of structures, and works under Linux (at server side) or Windows.

While RServe is Java, you can use IKVM to make it accessible to c#, and it
works out of the box. Getting this translation to work within an hour was
one of the biggest miracles in my 40-year programmer's life; kudos to the
IKVM (and to rserve, clearly).

You can download my simple test application (no support, and it may not even
work) for Visual Studio from http://www.menne-biomed.de/uni/rserve.zip. You
can use it with a local, Windows rserve, or, more reliably, with a virtual
linux box running under VMWare. The latter works great as a development
environment, and I can create complex installations, for example with
NONMEM, and provide my colleagues the virtual machine as a no-brainer.

Dieter 




-- 
View this message in context: 
http://n4.nabble.com/C-DLL-Library-tp1594583p1596029.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] C# DLL Library

2010-03-17 Thread Philippe Grosjean

Hello,

Also, if you go for socket connection, you could give a try to svSocket.
Best,

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

On 17/03/10 09:16, Dieter Menne wrote:



JSmaga wrote:


I was aware of the R(D)COM. In the last public version, there is now
splash
screen appearing which is kind of boring so I think I need to buy it or
something.




I would pay for RDCOM, but it requires that you explain the details of you
application spread (which is mostly 1 in my case, since I only work on
request), and that's unacceptable to me. I think there is a way to get
around that using the Rcommander (?) version, but I found a better solution:

I have moved to using RServe with c# recently; it has nice support for all
types of structures, and works under Linux (at server side) or Windows.

While RServe is Java, you can use IKVM to make it accessible to c#, and it
works out of the box. Getting this translation to work within an hour was
one of the biggest miracles in my 40-year programmer's life; kudos to the
IKVM (and to rserve, clearly).

You can download my simple test application (no support, and it may not even
work) for Visual Studio from http://www.menne-biomed.de/uni/rserve.zip. You
can use it with a local, Windows rserve, or, more reliably, with a virtual
linux box running under VMWare. The latter works great as a development
environment, and I can create complex installations, for example with
NONMEM, and provide my colleagues the virtual machine as a no-brainer.

Dieter






__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] define F-ratio computations with aov

2010-03-17 Thread Galanidis Alexandros
Greetings to all,

This is my model: aov.fit-aov(Y~A+B+C+D+E+A:C+A:E)

In summary(aov.fit) all F values are comptuted by eg MS(A)/MS(Residuals). This 
is not correct (or what I want), except for F(B) and F(A:E). I suppose P values 
are not correct either.

Is it possible with aov to define the way F computations will be done? I 'd 
like them to be like this: F(A)=MS(A)/MS(E), F(C)=MS(C)/MS(E), 
F(D)=MS(D)/MS(E), F(E)=MS(E)/MS(A:E), F(A:C)=MS(A:C)/MS(A:E)

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


Re: [R] C# DLL Library

2010-03-17 Thread Jeremie Smaga
Hi guys,

Correct me if I am wrong, but R(D)COM (and hence RServe and so on) allow you
to run R code from C# but is useless to use C(# or ++) code in R right?

Because it is in fact what I am trying to find out in this post.

Thanks for the tips though, I was also looking for some information about
alternative to R(D)COM.

Best,

Jeremie


On Wed, Mar 17, 2010 at 4:26 PM, Philippe Grosjean
phgrosj...@sciviews.orgwrote:

 Hello,

 Also, if you go for socket connection, you could give a try to svSocket.
 Best,

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


 On 17/03/10 09:16, Dieter Menne wrote:



 JSmaga wrote:


 I was aware of the R(D)COM. In the last public version, there is now
 splash
 screen appearing which is kind of boring so I think I need to buy it or
 something.



 I would pay for RDCOM, but it requires that you explain the details of you
 application spread (which is mostly 1 in my case, since I only work on
 request), and that's unacceptable to me. I think there is a way to get
 around that using the Rcommander (?) version, but I found a better
 solution:

 I have moved to using RServe with c# recently; it has nice support for all
 types of structures, and works under Linux (at server side) or Windows.

 While RServe is Java, you can use IKVM to make it accessible to c#, and it
 works out of the box. Getting this translation to work within an hour was
 one of the biggest miracles in my 40-year programmer's life; kudos to the
 IKVM (and to rserve, clearly).

 You can download my simple test application (no support, and it may not
 even
 work) for Visual Studio from http://www.menne-biomed.de/uni/rserve.zip.
 You
 can use it with a local, Windows rserve, or, more reliably, with a virtual
 linux box running under VMWare. The latter works great as a development
 environment, and I can create complex installations, for example with
 NONMEM, and provide my colleagues the virtual machine as a no-brainer.

 Dieter





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




-- 
Jeremie Smaga

[[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] PCA - blank loadings

2010-03-17 Thread S Ellison
Which principal component function are you using?

Check the documentation for that and look for the part of the object
that provides the PC's. Those are your loadings.

 Xanthe Walker xanthe.wal...@gmail.com 16/03/2010 23:16:47 
Hi,

I have successfully completed a PCA and printed the loadings, however,
numerous values are blank. I know that this means the values are just
very
small but not equal to zero.

Is there a way to print out the loadings, including the very small
values, I
need them for graphing purposes.

Thanks,
Xan

[[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 email and any attachments are confidential. Any use...{{dropped:8}}

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


Re: [R] C# DLL Library

2010-03-17 Thread Dieter Menne


JSmaga wrote:
 
 
 Correct me if I am wrong, but R(D)COM (and hence RServe and so on) allow
 you
 to run R code from C# but is useless to use C(# or ++) code in R right?
 

Correct. I use a c wrapper if I want to run c# code from R similar, but it
can get nasty to cross the marshalling barrier.

Dieter


-- 
View this message in context: 
http://n4.nabble.com/C-DLL-Library-tp1594583p1596092.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 parse a string (by a new markup) with R ?

2010-03-17 Thread Tal Galili
Wow, Thank you very much Andrej!

Tal

Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




2010/3/17 Andrej Blejec andrej.ble...@nib.si

 A version using regular expressions, lot of regexpr() and substr()
 functions is attached.
 Finally everything is packed into splitSeq() function

 Andrej

 --
 Andrej Blejec
 National Institute of Biology
 Vecna pot 111 POB 141
 SI-1000 Ljubljana
 SLOVENIA
 e-mail: andrej.ble...@nib.si
 URL: http://ablejec.nib.si
 tel: + 386 (0)59 232 789
 fax: + 386 1 241 29 80
 --
 Local Organizer of ICOTS-8
 International Conference on Teaching Statistics
 http://icots8.org



  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
  project.org] On Behalf Of Gabor Grothendieck
  Sent: Tuesday, March 16, 2010 3:24 PM
  To: Tal Galili
  Cc: r-help@r-project.org; seqinr-fo...@r-forge.wu-wien.ac.at
  Subject: Re: [R] How to parse a string (by a new markup) with R ?
 
  We show how to use the gsubfn package to parse this.
 
  The rules are not entirely clear so we will assume the following:
 
  - there is a fixed template for the output which is the same as your
  output but possibly with different character strings filled in.  This
  implies, for example, that there are exactly Stem0, Stem1, Stem2 and
  Stem3 and no fewer or more stems.
 
  - the sequence always starts with the open of Stem0, at least one dot
  and the open of Stem1.  There are no dots prior to the open of Stem0.
  This seems to be implicit in your sample output since there is no zero
  length string in your sample output corresponding to dots prior to
  Stem0.
 
  - Stem0 closes with the same number of  as there are  to open it
 
  You can modify this yourself to take into account the actual rules
  whatever they are.
 
  We first calculate, k, the number of leading 's using strapply.
 
  Then we replace the leading k 's with }'s and the trailing k 's with
  {'s giving us Str3:
 
 
  }}}..{
  {{.
 
  We again use strapply, this time to get the lengths of the runs.  Note
  that
  zero length runs are possible so we cannot, for example, use rle for
  this.  For
  example there is a zero length run of dots between the last  and the
  first {.
  read.fwf is used to actually parse out the strings using the lengths we
  just
  calculated.
 
  Finally we fill in the template using relist.
 
  # inputs
 
  Seq -
  GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCGGG
  GCA
  Str -
  ..
  .
  template -
list(
  Stem 0 opening = ,
  before Stem 1 = ,
  Stem 1 = list(opening = ,
  inside = ,
  closing = 
  ),
  between Stem 1 and 2 = ,
  Stem 2 = list(opening = ,
  inside = ,
  closing = 
  ),
  between Stem 2 and 3 = ,
  Stem 3 = list(opening = ,
  inside = ,
  closing = 
  ),
  After Stem 3 = ,
  Stem 0 closing = 
 )
 
  # processing
 
  # create string made by repeating string s k times followed by more
  reps - function(s, k, more = ) {
paste(paste(rep(s, k), collapse = ), more, sep = )
  }
 
  library(gsubfn)
  k - nchar(strapply(Str, ^+, c)[[1]])
  Str2 - sub(^+, reps(}, k), Str)
  Str3 - sub(reps(, k, ([^]*)$), reps({, k, \\1), Str2)
 
  pat -
  ^(}*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*)(*)([.]*
  )({*)([.]*)$
  lens - sapply(strapply(Str3, pat, c)[[1]], nchar)
  tokens - unlist(read.fwf(textConnection(Seq), lens, as.is = TRUE))
  closeAllConnections()
  tokens[is.na(tokens)] - 
  out - relist(tokens, template)
  out
 
 
  Here is the str of the output for your sample input:
 
   str(out)
  List of 9
   $ Stem 0 opening  : chr GCCTCGA
   $ before Stem 1   : chr TA
   $ Stem 1  :List of 3
..$ opening: chr GCTC
..$ inside : chr AGTTGGGA
..$ closing: chr GAGC
   $ between Stem 1 and 2: chr G
   $ Stem 2  :List of 3
..$ opening: chr TACGA
..$ inside : chr CTGAAGA
..$ closing: chr TCGTA
   $ between Stem 2 and 3: chr AGGtC
   $ Stem 3  :List of 3
..$ opening: chr ACCAG
..$ inside : chr TTCGATC
..$ closing: chr CTGGT
   $ After Stem 3: chr 
   $ Stem 0 closing  : chr TCC
 
 
 
  On Tue, Mar 16, 2010 at 6:10 AM, Tal Galili tal.gal...@gmail.com
  wrote:
   Hello all,
  
   For some work I am doing on RNA, I want to use R to do string parsing
  that
   (I think) is like a simplistic HTML parsing.
  
  
   For example, let's say we have the following two variables:
  
  Seq -
  
  GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCGGG
  GCA
  Str -
  
  ..
  .
  
 

[R] Transform contingency table into data.frame ?

2010-03-17 Thread Carlos Petti
Dear list,

I have a contingency table :

a - letters[1:3]
t - table(a)

I'm looking for a way to transform this table into data frame, as follows :

 Freq
a1
b1
c1

I used :

df - as.data.frame(t, row.names = names(t))

But, this function do not remove the duplicated column. Do you know the
solution ?

Thanks in advance,
Carlos

[[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] cut out single lines out of matrix

2010-03-17 Thread Petr PIKAL
Hi

I am a bit curious why one shall do such a twisted construction. Accessing 
list is basically the same as accessing corresponding matrix row, you only 
need to remember drop=FALSE option.

Regards
Petr

r-help-boun...@r-project.org napsal dne 17.03.2010 00:58:54:

 Here is a way of creating a list of the matrices:
 
  x - matrix(1:(12*30), nrow=30)
  # create a list of single row matrices
  x.l - lapply(seq(nrow(x)), function(a) x[a,, drop=FALSE])
 
  x.l
 [[1]]
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
 [1,]1   31   61   91  121  151  181  211  241   271   301   331
 [[2]]
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
 [1,]2   32   62   92  122  152  182  212  242   272   302   332
 [[3]]
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
 [1,]3   33   63   93  123  153  183  213  243   273   303   333
 
  # access the 5th element
  x.l[[5]]
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
 [1,]5   35   65   95  125  155  185  215  245   275   305   335
 
 
 
 On Tue, Mar 16, 2010 at 6:20 PM, Schmidt Martin 
m.schm...@students.unibe.ch
  wrote:
 
  Hey dear users
 
 
  I'm trying to kind of split my matrix which looks as follows:
 
  dim(out)
 
  [1] 30 12
 
  What I finally want is each line as it's own matrix which I can handle 
then
  separately.
  Like, say:
  out1- [1,]
  out2-[2,]
  ..
  Would you do that with a for() loop or does exist an other appropriate
  solution? I unfortunately couldn't find any solution!
 
  Thanks for help
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/
 posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem that you are trying to solve?
 
[[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] Transform contingency table into data.frame ?

2010-03-17 Thread Ivan Calandra

Hi,

I don't really understand what the problem is... There is no duplicated 
column... Maybe you mean the row names? If it is so, then just don't use 
row names.


Ivan

Le 3/17/2010 10:45, Carlos Petti a écrit :

Dear list,

I have a contingency table :

a- letters[1:3]
t- table(a)

I'm looking for a way to transform this table into data frame, as follows :

  Freq
a1
b1
c1

I used :

df- as.data.frame(t, row.names = names(t))

But, this function do not remove the duplicated column. Do you know the
solution ?

Thanks in advance,
Carlos

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

   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


[R] Odp: Transform contingency table into data.frame ?

2010-03-17 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 17.03.2010 10:45:48:

 Dear list,
 
 I have a contingency table :
 
 a - letters[1:3]
 t - table(a)
 
 I'm looking for a way to transform this table into data frame, as 
follows :
 
  Freq
 a1
 b1
 c1
 
 I used :
 
 df - as.data.frame(t, row.names = names(t))
 
 But, this function do not remove the duplicated column. Do you know the
 solution ?

You probably do not distinct between columns of data frame and row names 
of data frame. From what you told us it is not clear which one you want to 
keep

if row names use

as.data.frame(as.matrix(t, row.names = names(t)))

if you want to keep column

as.data.frame(t)

shall suffice. 

Row names is not a data frame column.

Regards
Petr


 
 Thanks in advance,
 Carlos
 
[[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] Constrained non linear regression using ML

2010-03-17 Thread Corrado

Dear Gabor, dear R users,

I had already read the betareg documentation. As far as I can understand 
from the help, it does not allow for constrained regression.


Regards


Gabor Grothendieck wrote:

Check out the betareg package.

On Tue, Mar 16, 2010 at 2:58 PM, Corrado ct...@york.ac.uk wrote:
  

Dear R users,

I have to fit the non linear regression:

y~1-exp(-(k0+k1*p1+k2*p2+  +kn*pn))

where ki=0 for each i in [1  n] and pi are on R+.

I am using, at the moment, nls, but I would rather use a Maximum Likelhood
based algorithm. The error is not necessarily normally distributed.

y is approximately beta distributed, and the volume of data is medium to
large (the y,pi may have ~ 40,000 elements).

I have studied the packages in the task views Optimisation and Robust
Statistical Methods, but I did look like what I was looking for was there.
Maybe I am wrong.

The nearest thing was nlrob, but even that does not allow for constraints,
as far as I can understand.

Any suggestion?

Regards

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

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





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

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


Re: [R] Transform contingency table into data.frame ?

2010-03-17 Thread Carlos Petti
Dear list,

Sorry, I did not explain myself very well.

I want to obtain a data.frame like this :

Freq
a1
b1
c1

This data.frame contains just one column (Freq) and each row is named.

But when I use this code :

df - as.data.frame(t)

or this code :

df - as.data.frame(t, row.names(t))

The a column remains.

Thanks,
Carlos

2010/3/17 Petr PIKAL petr.pi...@precheza.cz

 Hi

 r-help-boun...@r-project.org napsal dne 17.03.2010 10:45:48:

  Dear list,
 
  I have a contingency table :
 
  a - letters[1:3]
  t - table(a)
 
  I'm looking for a way to transform this table into data frame, as
 follows :
 
   Freq
  a1
  b1
  c1
 
  I used :
 
  df - as.data.frame(t, row.names = names(t))
 
  But, this function do not remove the duplicated column. Do you know the
  solution ?

 You probably do not distinct between columns of data frame and row names
 of data frame. From what you told us it is not clear which one you want to
 keep

 if row names use

 as.data.frame(as.matrix(t, row.names = names(t)))

 if you want to keep column

 as.data.frame(t)

 shall suffice.

 Row names is not a data frame column.

 Regards
 Petr


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



[[alternative HTML version deleted]]

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


[R] Odp: Missing index in vector assignment

2010-03-17 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 17.03.2010 00:03:21:

 Dear r-helpers,
 
 I am getting a mismatch error between two variables:
 
   svp - ksvm(x, y, type=nu-svc)
   Error in .local(x, ...) : x and y don't match.
 
 and I suspect that it might be due to missing index in the y variable 
which

Why suspect? It is probably better to read the docs. Try

?ksvm

and see how x or y shall be defined. 

Besides why do you expect everybody knows what ksvm is

I get

 ??ksvm
No help files found with alias or concept or title matching ‘ksvm’
using regular expression matching.

therefore I the function is not a part of my installed packages.

 I defined as:
 
   y - (LVvar[,1])
 
 I tried various methods to make the y assignment in the same format as 
x,
 which is a dataframe
   x - (LVvar[,-1])
 
 and looks like
  x
rCoordCap rKnowGrow rGoalcom rSupport  rOpcomm rT2Cadap
 1   4.979167  4.50 5.812500 6.145833 5.979167 5.031250
 ...
 
 but I still get y without the indexes as a vector:
  y
  [1] -1. -6.91193182 -1.  0.74431818 -6.91193182
 
 
 Why are the results different for x and y, even though the assignment is 
the
 same
 except I exclude the columns for y?

LVvar is probably data frame. So x is data frame too but y lost dimension 
so it is a vector.

Help page for subsetting is a bit complicated as it has to cover various 
object types.

?[

Basically if you want to keep dimensions = you has to use drop=FALSE 
option in subsetting. Default is FALSE so whenever result is only one 
column of data frame it is coerced to vector.

drop: logical.  If ‘TRUE’ the result is coerced to the lowest
  possible dimension.  The default is to drop if only one
  column is left, but *not* to drop if only one row is left.

Regards
Petr

 
 Cheers,
 Chaehan
 
[[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] Transform contingency table into data.frame ?

2010-03-17 Thread Petr PIKAL
Hi

and did you try my suggestion?

as.data.frame(as.matrix(t, row.names = names(t)))

Regards
Petr

r-help-boun...@r-project.org napsal dne 17.03.2010 11:16:43:

 Dear list,
 
 Sorry, I did not explain myself very well.
 
 I want to obtain a data.frame like this :
 
 Freq
 a1
 b1
 c1
 
 This data.frame contains just one column (Freq) and each row is named.
 
 But when I use this code :
 
 df - as.data.frame(t)
 
 or this code :
 
 df - as.data.frame(t, row.names(t))
 
 The a column remains.
 
 Thanks,
 Carlos
 
 2010/3/17 Petr PIKAL petr.pi...@precheza.cz
 
  Hi
 
  r-help-boun...@r-project.org napsal dne 17.03.2010 10:45:48:
 
   Dear list,
  
   I have a contingency table :
  
   a - letters[1:3]
   t - table(a)
  
   I'm looking for a way to transform this table into data frame, as
  follows :
  
Freq
   a1
   b1
   c1
  
   I used :
  
   df - as.data.frame(t, row.names = names(t))
  
   But, this function do not remove the duplicated column. Do you know 
the
   solution ?
 
  You probably do not distinct between columns of data frame and row 
names
  of data frame. From what you told us it is not clear which one you 
want to
  keep
 
  if row names use
 
  as.data.frame(as.matrix(t, row.names = names(t)))
 
  if you want to keep column
 
  as.data.frame(t)
 
  shall suffice.
 
  Row names is not a data frame column.
 
  Regards
  Petr
 
 
  
   Thanks in advance,
   Carlos
  
  [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
 
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Transform contingency table into data.frame ?

2010-03-17 Thread Eik Vettorazzi

Hi Carlos,
try
as.data.frame.table(t)
hth.

Carlos Petti schrieb:

Dear list,

I have a contingency table :

a - letters[1:3]
t - table(a)

I'm looking for a way to transform this table into data frame, as follows :

 Freq
a1
b1
c1

I used :

df - as.data.frame(t, row.names = names(t))

But, this function do not remove the duplicated column. Do you know the
solution ?

Thanks in advance,
Carlos

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


--
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

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


Re: [R] Transform contingency table into data.frame ?

2010-03-17 Thread Ivan Calandra

I would then just change it using names()
For example:
 names(df) - c(letter, Freq)
 df
  letter Freq
a  a1
b  b1
c  c1

If you prefer having nothing, I don't really know how to do it because I 
couldn't use my dataframes without column names!


HTH
Ivan


Le 3/17/2010 11:16, Carlos Petti a écrit :

Dear list,

Sorry, I did not explain myself very well.

I want to obtain a data.frame like this :

Freq
a1
b1
c1

This data.frame contains just one column (Freq) and each row is named.

But when I use this code :

df- as.data.frame(t)

or this code :

df- as.data.frame(t, row.names(t))

The a column remains.

Thanks,
Carlos

2010/3/17 Petr PIKALpetr.pi...@precheza.cz

   

Hi

r-help-boun...@r-project.org napsal dne 17.03.2010 10:45:48:

 

Dear list,

I have a contingency table :

a- letters[1:3]
t- table(a)

I'm looking for a way to transform this table into data frame, as
   

follows :
 

  Freq
a1
b1
c1

I used :

df- as.data.frame(t, row.names = names(t))

But, this function do not remove the duplicated column. Do you know the
solution ?
   

You probably do not distinct between columns of data frame and row names
of data frame. From what you told us it is not clear which one you want to
keep

if row names use

as.data.frame(as.matrix(t, row.names = names(t)))

if you want to keep column

as.data.frame(t)

shall suffice.

Row names is not a data frame column.

Regards
Petr


 

Thanks in advance,
Carlos

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

   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


Re: [R] Transform contingency table into data.frame ?

2010-03-17 Thread Ivan Calandra
Now I get it, I was still thinking you wanted two columns. I was 
confused by the print example.

Petr's suggestion works well then
Ivan

Le 3/17/2010 11:27, Petr PIKAL a écrit :

Hi

and did you try my suggestion?

as.data.frame(as.matrix(t, row.names = names(t)))

Regards
Petr

r-help-boun...@r-project.org napsal dne 17.03.2010 11:16:43:

   

Dear list,

Sorry, I did not explain myself very well.

I want to obtain a data.frame like this :

Freq
a1
b1
c1

This data.frame contains just one column (Freq) and each row is named.

But when I use this code :

df- as.data.frame(t)

or this code :

df- as.data.frame(t, row.names(t))

The a column remains.

Thanks,
Carlos

2010/3/17 Petr PIKALpetr.pi...@precheza.cz

 

Hi

r-help-boun...@r-project.org napsal dne 17.03.2010 10:45:48:

   

Dear list,

I have a contingency table :

a- letters[1:3]
t- table(a)

I'm looking for a way to transform this table into data frame, as
 

follows :
   

  Freq
a1
b1
c1

I used :

df- as.data.frame(t, row.names = names(t))

But, this function do not remove the duplicated column. Do you know
 

the
   

solution ?
 

You probably do not distinct between columns of data frame and row
   

names
   

of data frame. From what you told us it is not clear which one you
   

want to
   

keep

if row names use

as.data.frame(as.matrix(t, row.names = names(t)))

if you want to keep column

as.data.frame(t)

shall suffice.

Row names is not a data frame column.

Regards
Petr


   

Thanks in advance,
Carlos

[[alternative HTML version deleted]]

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

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

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


   

[[alternative HTML version deleted]]

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

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

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

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

   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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

2010-03-17 Thread Hadassa Brunschwig
Hi

I would like to produce a red shading I figured the easiest way
to do that would be to use rgb in the following way:

a- seq(0,0.9,by=0.1)
redshade - rgb(red=1,green=a, blue=a)

However, I don't really know how to plot things using
hexadecimal colors. I used a function which tries to
find the closest color to the rgb shades but it didn't
work very well.

Any comments would be appreciated.
Thanks,
Hadassa

[[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] save data to an R object

2010-03-17 Thread cheba meier
Dear R people,

Is it possible to save three data sets in an R object and to call each data
from this object independently!

Regards,
Cheba

[[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] hexadecimal colors

2010-03-17 Thread jim holtman
To plot, just use 'redshade'

plot(1:10, col=redshade, cex=4,pch=16)



On Wed, Mar 17, 2010 at 6:55 AM, Hadassa Brunschwig 
hadassa.brunsch...@mail.huji.ac.il wrote:

 Hi

 I would like to produce a red shading I figured the easiest way
 to do that would be to use rgb in the following way:

 a- seq(0,0.9,by=0.1)
 redshade - rgb(red=1,green=a, blue=a)

 However, I don't really know how to plot things using
 hexadecimal colors. I used a function which tries to
 find the closest color to the rgb shades but it didn't
 work very well.

 Any comments would be appreciated.
 Thanks,
 Hadassa

[[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

What is the problem that you are trying to solve?

[[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] save data to an R object

2010-03-17 Thread Ivan Calandra

Hi,

Here is one option:
#some sample dataframes
df1 - data.frame(letter=letters[1:3], number=1:3)
df1 - data.frame(letter=letters[4:6], number=4:6)

#save the dataframes
save(df1, df2, file=test.Rda)
#load them in another session
load(test.Rda)
 df1
  letter number
1  a  1
2  b  2
3  c  3
 df2
  letter number
1  d  4
2  e  5
3  f  6

Is that what you're looking for?
Ivan



Le 3/17/2010 11:56, cheba meier a écrit :

Dear R people,

Is it possible to save three data sets in an R object and to call each data
from this object independently!

Regards,
Cheba

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

   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


Re: [R] save data to an R object

2010-03-17 Thread jim holtman
?list
Intro to R

That is what a list is for.

On Wed, Mar 17, 2010 at 6:56 AM, cheba meier cheba.me...@googlemail.comwrote:

 Dear R people,

 Is it possible to save three data sets in an R object and to call each data
 from this object independently!

 Regards,
 Cheba

[[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] Help running a Fortran subroutine from R

2010-03-17 Thread Berend Hasselman


dc896148 wrote:
 
 Then I pass the parameters according to the order they are specified in
 the filter:
 array - data.matrix(read.table(time702.txt,header=F))
 array1 - array
 nx - 60
 ny - 120
 halfintx - 3
 halfinty - 3
 mask - matrix(array(rep(1.0,25)),5,5)
 subarray - matrix(0,5,5)
 subarray1 - matrix(0,5,5)
 
 Then I run the Fortran subroutine...
 out - .Fortran(filter2d,
   as.single(array),
 as.single(array),
   as.integer(nx),
   as.integer(ny),
   as.integer(halfintx),
   as.integer(halfinty),
   as.single(mask),
   as.single(subarray),
   as.single(subarray1))
 
 The smoothed output is 'array1', which I just passed as 'array' in the
 specification.  It can be any matrix, but must be the same dimension as
 'array', which is given as nx by ny.
 Missing values in time702.txt are denoted by 999.00, and are defined that
 way in the subroutine.
 
 Can anyone see where I may be doing something wrong?  I am not good with
 fortran, as this code was previously written and now I am trying to adapt
 it to R on the fly.
 

First of all, if array1 is the output array of the fortran subroutine, then
you should do as.single(array1) instead of as.single(array) as the second
argument in the call of filter2d.

Furthermore you have set both halfintx and halfinty to 3.

Looking in the fortran code this means that subarray and subarray1 are
fortran arrays with dimension (7,7).

You should parametrize the definition of these arrays in the R code:

subarray - matrix(0, 2*halfintx+1,2*halfinty+1)
subarray1 - matrix(0, 2*halfintx+1,2*halfinty+1)

Similar for mask since it is indexed in fortran with indices -halfintx :
halfintx which means 2*halfintx+1 elements.

mask -
matrix(array(rep(1.0,(2*halfintx+1)*(2*halfinty+1))),2*halfintx+1,2*halfinty+1)

(Hopefully no typos here; I haven't tested this).

Finally, I am not sure whether you can get array1 returned by the fortran as
a single precision real array.

I would consider using R numeric doubles. You would only have to change the
real in the Fortran with double precision and the 999 with 999D0.

And make a small example with required output to make testing easier.

Good luck

Berend

-- 
View this message in context: 
http://n4.nabble.com/Help-running-a-Fortran-subroutine-from-R-tp1595641p1596231.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] Transform contingency table into data.frame ?

2010-03-17 Thread Carlos Petti
Dear list,

Thank you for your answers.

Petr, your solution works great :-)

Peter's solution too.

Carlos

2010/3/17 Ivan Calandra ivan.calan...@uni-hamburg.de

 Now I get it, I was still thinking you wanted two columns. I was confused
 by the print example.
 Petr's suggestion works well then
 Ivan

 Le 3/17/2010 11:27, Petr PIKAL a écrit :

  Hi

 and did you try my suggestion?

 as.data.frame(as.matrix(t, row.names = names(t)))

 Regards
 Petr

 r-help-boun...@r-project.org napsal dne 17.03.2010 11:16:43:



 Dear list,

 Sorry, I did not explain myself very well.

 I want to obtain a data.frame like this :

 Freq
 a1
 b1
 c1

 This data.frame contains just one column (Freq) and each row is named.

 But when I use this code :

 df- as.data.frame(t)

 or this code :

 df- as.data.frame(t, row.names(t))

 The a column remains.

 Thanks,
 Carlos

 2010/3/17 Petr PIKALpetr.pi...@precheza.cz



 Hi

 r-help-boun...@r-project.org napsal dne 17.03.2010 10:45:48:



 Dear list,

 I have a contingency table :

 a- letters[1:3]
 t- table(a)

 I'm looking for a way to transform this table into data frame, as


 follows :


  Freq
 a1
 b1
 c1

 I used :

 df- as.data.frame(t, row.names = names(t))

 But, this function do not remove the duplicated column. Do you know


 the


 solution ?


 You probably do not distinct between columns of data frame and row


 names


 of data frame. From what you told us it is not clear which one you


 want to


 keep

 if row names use

 as.data.frame(as.matrix(t, row.names = names(t)))

 if you want to keep column

 as.data.frame(t)

 shall suffice.

 Row names is not a data frame column.

 Regards
 Petr




 Thanks in advance,
 Carlos

[[alternative HTML version deleted]]

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


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


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





[[alternative HTML version deleted]]

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


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


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


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




 --
 Ivan CALANDRA
 PhD Student
 University of Hamburg
 Biozentrum Grindel und Zoologisches Museum
 Abt. Säugetiere
 Martin-Luther-King-Platz 3
 D-20146 Hamburg, GERMANY
 +49(0)40 42838 6231
 ivan.calan...@uni-hamburg.de

 **
 http://www.for771.uni-bonn.de
 http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] testing parallelism of does-response curves using package drc

2010-03-17 Thread Walmes Zeviani

Using just nls() you can set the complete model and the alternative model in
this way

da - expand.grid(x=20:50, trat=c(0.9,1))
da$y - 10*da$trat*da$x/(12+da$x)+rnorm(da$x,0,0.1)
plot(y~x, da)
da$trat - as.factor(da$trat)

n0 - nls(y~A[trat]*x/(B[trat]+x), data=da,
  start=list(A=c(9,10), B=c(12,12)))
n1 - nls(y~A*x/(B[trat]+x), data=da,
  start=list(A=c(9.5), B=c(12,12)))
anova(n1,n0)

Look at gnls() function in the nlme package for a easier way to specify the
model.

Walmes Zeviani.

-
..ooo0
...
..()... 0ooo...  Walmes Zeviani
...\..(.(.)... Master in Statistics and Agricultural
Experimentation
\_). )../   walmeszevi...@hotmail.com, Lavras - MG, Brasil

(_/
-- 
View this message in context: 
http://n4.nabble.com/testing-parallelism-of-does-response-curves-using-nls-tp1591356p1596256.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] Odp: save data to an R object

2010-03-17 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 17.03.2010 11:56:45:

 Dear R people,
 
 Is it possible to save three data sets in an R object and to call each 
data
 from this object independently!

?list

Regards
Petr




 
 Regards,
 Cheba
 
[[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] mmap error-12, macbook pro

2010-03-17 Thread Mamun

Dear List,

I am trying to read some files using read.csv and total size of those files
are 3.99 GB. I am using MacBook Pro with 4GB RAM(snow leopard). I also tried
to run a chunk from those files and altogether the size was 1.33 GB. But
every time I was getting the following error

R(1200) malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

I managed to run smaller chunks (400MB) and I also saved the object. But
problem is when I try to load some of those objects(which is not more than
1.5 GB altogether), I get same error again. Can someone please help? why am
I getting this error? does R need more space than the actual file size? I
may buy new machine if its something related to RAM size. but if it is some
R problem then it will be very useless to buy new machine. So, I really need
to know why this is happening.

Any help is appreciated.

Thanks in advance. 

regards,
Mamun
-- 
View this message in context: 
http://n4.nabble.com/mmap-error-12-macbook-pro-tp1596234p1596234.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] mmap error-12, macbook pro

2010-03-17 Thread Mamun

Hi,
I am trying to read some files using read.csv and total size of those files
are 3.99 GB. I am using MacBook Pro with 4GB RAM(snow leopard). I also tried
to run a chunk from those files and altogether the size was 1.33 GB. But
every time I was getting the following error

R(1200) malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

I managed to run smaller chunks (400MB) and I also saved the object. But
problem is when I try to load some of those objects(which is not more than
1.5 GB altogether), I get same error again. Can someone please help? why am
I getting this error? does R need more space than the actual file size? I
may buy new machine if its something related to RAM size. but if it is some
R problem then it will be very useless to buy new machine. So, I really need
to know why this is happening.

Thanks.
-- 
View this message in context: 
http://n4.nabble.com/mmap-error-12-macbook-pro-tp1596208p1596208.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] mmap error, macbook pro

2010-03-17 Thread shyama

Hi,
I am trying to read some files using read.csv and total size of those files
are 3.99 GB. I am using MacBook Pro with 4GB RAM(snow leopard). I also tried
to run a chunk from those files and altogether the size was 1.33 GB. But
every time I was getting the following error 

R(1200) malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

I managed to run smaller chunks (400MB) and I also saved the object. But
problem is when I try to load some of those objects(which is not more than
1.5 GB altogether), I get same error again. Can someone please help? why am
I getting this error? does R need more space than the actual file size? I
may buy new machine if its something related to RAM size. but if it is some
R problem then it will be very useless to buy new machine. So, I really need
to know why this is happening. 

Thanks.

Shyama
-- 
View this message in context: 
http://n4.nabble.com/mmap-error-macbook-pro-tp1596091p1596091.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] accessing info in object slots from listed objects using loops

2010-03-17 Thread torgrims

Hey,

I have stacked a couple of garchFit objects in a list with names $fit1,
$fit2, ..., $fiti assigning objects names using a loop, i.e. after running
the loop modelStack = list($fit1, $fit2,...,$fiti).

Thus the following apply;
a = modelStack$fit2, then a is the second garchFit object of formal class
'fGarch' with 11 slots, @call, @formula... etc.

I then want to extract information in the 11 slots using another for loop,
say i want to access the slot a...@fit$coef. In order for this to happen I need
to combine modelStack$fit2, where the $fit2 object name must be constructed
in the loop, with the slot name @fit$coef.

In order to construct the proper list names one could use the following in
the for loop;
name = paste(modelStack$fit,i,@fit$coef,sep=)  #
modelstack$f...@fit$coef for i = 2, 

and then use something like 
get(name) 

But this returns; Error in get(name) : object 'modelstack$f...@fit$coef' not
found

If I just type modelstack$f...@fit$coef in the command window it returns the
proper info from the object list. I figure this is because R somehow
interpret $ and @ in get() differently than $ and @ as list
separators.

Does anyone know how to extract information in slots of listed objects using
a loop and on the run generated variable/object names?

JT

sample code
nAssets = length(modelStack)

for(i in 1:nAssets){
name = paste(modelStack[,i,]...@name$series$h,sep=)   
 
a = get(name)
  t = length(a)
} # end for loop

-- 
View this message in context: 
http://n4.nabble.com/accessing-info-in-object-slots-from-listed-objects-using-loops-tp1596135p1596135.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] Missing index in vector assignment

2010-03-17 Thread Chaehan So
Jim  Petr,
Thank you for your hint - I am really grateful, because they helped me to
get one step further,
and although now the problem lies somewhere else, you encouraged that we can
find the
solution soon!

1. To Petr's comments

Petr, your hint to define y:
  y - LVvar[,1, drop=FALSE]
did solve the problem, so I got a data.frame with the indexes.

Yet, then I turned to the call
  svp - ksvm(x, y, type=nu-svc)
  Error in .local(x, ...) : y must be a vector or a factor.

So then I followed your second advice, looking up the additional information
from help file:
==
x is defined as:
 a symbolic description of the model to be fit. When not using a formula x
can be a matrix or vector containing the training data or a kernel matrix of
class kernelMatrix of the training data or a list of character vectors (for
use with the string kernel). Note, that the intercept is always excluded,
whether given in the formula or not.

y is defined as
a response vector with one label for each row/component of x. Can be either
a factor (for classification tasks) or a numeric vector (for regression).
==

So I tried to convert LVvar into a matrix via as.matrix() but didn't make a
difference.


2. To Jim's comments

On Wed, Mar 17, 2010 at 1:10 AM, jim holtman jholt...@gmail.com wrote:

 Please provide what LVvar is.


LVvar is a dataframe


 At least provide str(LVvar), or preferably a 'dput' of the object.


str(LVvar) returns:

'data.frame':   55 obs. of  7 variables:
 $ rPerform : num  0.0682 -0.0682 -0.7443 0.7443 0.2619 ...
 $ rCoordCap: num  4.98 6.08 5.73 5.92 4.96 ...
 $ rKnowGrow: num  4.5 5.92 5.23 6.08 4.38 ...
 $ rGoalcom : num  5.81 6.58 6 5.75 5.29 ...
 $ rSupport : num  6.15 6.92 6.6 4.92 6 ...
 $ rOpcomm  : num  5.98 6.25 6.33 6.5 5.29 ...
 $ rT2Cadap : num  5.03 6.12 4.9 6.25 5.12 ...
 - attr(*, na.action)=Class 'omit'  Named int 40
  .. ..- attr(*, names)= chr 40

==

dput(LVvar) returns (abbreviated with ...):

structure(list(rPerform = c(0.0681818181818183, -0.0681818181818183,
-0.744318181818182, 0.744318181818182, 0.261931818181818,
-0.900568181818182,
...
 rCoordCap = c(4.979167,
6.08, 5.73, 5.916667, 4.958333,
...
.Names = c(rPerform, rCoordCap, rKnowGrow,
rGoalcom, rSupport, rOpcomm, rT2Cadap), row.names = c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 41L, 42L,
43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L,
56L), na.action = structure(40L, .Names = 40, class = omit), class =
data.frame)




 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



Here's my try (please have mercy for a complete R beginner):

library(kernlab)
library(methods)

# Data Definitions
LV - c(rPerform,rCoordCap, rKnowGrow, rGoalcom, rSupport,
rOpcomm, rT2Cadap )

# creates a dataframe
LVvar - na.omit(loopLV_IndexScores(LV, u_proj))

x - (LVvar[,-1])
y - (LVvar[,1])
svp - ksvm(x, y, type=nu-svc)
svp

===

Thanks so much for not giving up.

Cheers,
Chaehan




 On Tue, Mar 16, 2010 at 6:03 PM, Chaehan So chaehan...@gmail.com wrote:

 Dear r-helpers,

 I am getting a mismatch error between two variables:

  svp - ksvm(x, y, type=nu-svc)
  Error in .local(x, ...) : x and y don't match.

 and I suspect that it might be due to missing index in the y variable
 which
 I defined as:

  y - (LVvar[,1])

 I tried various methods to make the y assignment in the same format as x,
 which is a dataframe
  x - (LVvar[,-1])

 and looks like
  x
   rCoordCap rKnowGrow rGoalcom rSupport  rOpcomm rT2Cadap
 1   4.979167  4.50 5.812500 6.145833 5.979167 5.031250
 ...

 but I still get y without the indexes as a vector:
  y
  [1] -1. -6.91193182 -1.  0.74431818 -6.91193182


 Why are the results different for x and y, even though the assignment is
 the
 same
 except I exclude the columns for y?

 Cheers,
 Chaehan

[[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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




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

 What is the problem that you are trying to solve?




-- 
Humboldt University Berlin, Germany
Institute of Psychology
Rudower Chaussee 18, Room 1221
12489 Berlin
Germany
Office: +49 30 2093 - 9337
Mobile: +49 171- 626 9373

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the 

Re: [R] Constrained non linear regression using ML

2010-03-17 Thread Gabor Grothendieck
Try it anyways -- maybe none of your constraints are active.

On Wed, Mar 17, 2010 at 6:01 AM, Corrado ct...@york.ac.uk wrote:
 Dear Gabor, dear R users,

 I had already read the betareg documentation. As far as I can understand
 from the help, it does not allow for constrained regression.

 Regards


 Gabor Grothendieck wrote:

 Check out the betareg package.

 On Tue, Mar 16, 2010 at 2:58 PM, Corrado ct...@york.ac.uk wrote:


 Dear R users,

 I have to fit the non linear regression:

 y~1-exp(-(k0+k1*p1+k2*p2+  +kn*pn))

 where ki=0 for each i in [1  n] and pi are on R+.

 I am using, at the moment, nls, but I would rather use a Maximum
 Likelhood
 based algorithm. The error is not necessarily normally distributed.

 y is approximately beta distributed, and the volume of data is medium to
 large (the y,pi may have ~ 40,000 elements).

 I have studied the packages in the task views Optimisation and Robust
 Statistical Methods, but I did look like what I was looking for was
 there.
 Maybe I am wrong.

 The nearest thing was nlrob, but even that does not allow for
 constraints,
 as far as I can understand.

 Any suggestion?

 Regards

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

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




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



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


[R] Antw: odfWeave Error

2010-03-17 Thread Frank Bloos
Hi,
 
I am using 7-zip for unzipping (http://www.7-zip.org/). Then
odfWeaveControl needs to be set to
 
odfWeaveControl(zipCmd=c(c:/programme/7-zip/7z a -tzip
$$file$$,c:/programme/7-zip/7z x $$file$$ -aoa)) - control 
where 'c:/programme/7-zip/' is the path to my 7-zip installation.
 
You can then use control to set the control-parameter in odfWeave.
 
Frank
 Btibert3 btibe...@gmail.com 17.03.2010 03:02 

Hi All,

This is probably basic, but I am just starting with R and very
interested in
learning how to automate my reports.  I am just learning about Sweave
and
LaTex.  

I am following an example from online and am getting the following
error:
.Error unizipping fileunzip not found.

I am not a programmer by any stretch, but I realize that the package
is
either not recognizing my  native unzip utility, have to configure one
in
the package, or both.  

Additionally, I saw in the tutorial that they recommend a zip program. 
I
tried to install it, but I couldn't figure out what to do.

Any help you can provide will be greatly appreciated.

Brock
-- 
View this message in context:
http://n4.nabble.com/odfWeave-Error-tp1595848p1595848.html 
Sent from the R help mailing list archive at Nabble.com.



  
Universitätsklinikum Jena
Körperschaft des öffentlichen Rechts und Teilkörperschaft der
Friedrich-Schiller-Universität
Jena Bachstraße 18, 07743 Jena
Verwaltungsratsvorsitzender: Prof. Dr. Thomas Deufel; Medizinischer
Vorstand: Prof. Dr. Klaus Höffken;
Wissenschaftlicher Vorstand: Prof. Dr. Klaus Benndorf; Kaufmännischer
Vorstand und Sprecher des Klinikumsvorstandes Rudolf Kruse
Bankverbindung: Sparkasse Jena; BLZ: 830 530 30; Kto.: 221;
Gerichtsstand Jena
Steuernummer: 161/144/02978; USt.-IdNr. : DE 150545777 

[[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] Are loops handled differently in newer versions of R?

2010-03-17 Thread Michael Rennie


Thanks everyone for your assistance with this! Very much appreciated, 
and the students of my statistics course will also be pleased to have a 
fix ;)


Mike

Don MacQueen wrote:
Joshua's explanation of rownames makes a lot more sense than my 
speculation about conversion to numeric. Rownames of dataframes is an 
area in which there have definitely been changes in R in the last year 
or two, give or take. (I don't recall details or timing)


Therefore, I find it very plausible that in R 2.8.x the rownames of 
your dataframe were different than they are now in R 2.10.x, given how 
you constructed the dataframe. This then would be the explanation of 
why the script worked in 2.8.x and not in 2.10.x.


-Don

At 8:57 PM -0700 3/16/10, Joshua Wiley wrote:

Michael,

I have to agree with Don that using a factor as a loop index seems
like a risky choice.  At any rate, part of the problem is that you are
referencing a nonexistant part of your dataframe.  i is an index of
characters, but your rownames are 1:5, not LETTERS[1:5].  If you give
your dataframe rownames, you can then use your loop, see below.


locn-c(A, B, C, D, E)
n-c(28, 14, 21, 52, 35)
corr.r-c(0.40, 0.63, 0.38, 0.44, 0.35)

lab8.dat-data.frame(locn, n, corr.r)
lab8.dat

calc.prob.t-function(n, r)
   {
   df-n-2
   t-(r-0)/(sqrt((1-r^2)/df)) # I'm assuming you mean r^2 here not r2
   probt-2*(pt(t, df, lower.tail=FALSE))
   probt
   }

p_unadj-NULL # since you assign it to null anyways, there's not real
point in the other assignment
p_unadj

for ( i in lab8.dat[,1] )
   p_unadj[i] - calc.prob.t(lab8.dat[i,2], lab8.dat[i,3])

p_unadj # all NAs as you noticed

rownames(lab8.dat) - lab8.dat$locn

for ( i in lab8.dat[,1] )
   p_unadj[i] - calc.prob.t(lab8.dat[i,2], lab8.dat[i,3])

p_unadj # now lab8.dat[A,2] etc. means something, and it works

##




On Tue, Mar 16, 2010 at 7:53 PM, Michael Rennie mdren...@gmail.com 
wrote:


 Hi gang,

 I'm perplexed- I have some code that uses for() loops that works 
fine in R
 version 2.8 on my mac, worked fine in version 2.8 on my old windows 
machine,

 but doesn't work in version 2.10 on windows.

 The loop implements a function over a data frame (code is included 
below).


 In Mac (running version 2.8), the results of the loop are what I 
expect:



 p_unadj

 [1] 0.034939481 0.015743706 0.089287030 0.001098538 0.039290594

 But in Windows (running version 2.10.1), I get a bunch of NA's...


 p_unadj

  A   B  CDE
 NA NA NA NA NA

 If I had to guess, I'd say that R v. 2.10 is handling the i in 
lab8.dat[,1]

 differently, given that it's keeping the row names in the output for
 p_unadj... but why would that stop it from applying the function?

 Any thoughts or suggestions are welcome.

 Cheers,

 Mike

 Here's the code...


 #build the dataset

 locn-c(A, B, C, D, E)
 n-c(28, 14, 21, 52, 35)
 corr.r-c(0.40, 0.63, 0.38, 0.44, 0.35)

 lab8.dat-data.frame(locn, n, corr.r)
 lab8.dat

 attach(lab8.dat)

 #write the function

 calc.prob.t-function(n, r)
 #given a sample size (n) and correlation coefficient (r), returns the
 probability for that test
{
df-n-2
t-(r-0)/(sqrt((1-r2)/df))
probt-2*(pt(t, df, lower.tail=FALSE))
probt
}

 #try out the function...
 calc.prob.t(lab8.dat$n[1], lab8.dat$corr.r[1])
 #it works.

 #write a loop to implement that function for every correlation in your
 dataset...


 p_unadj-numeric(length(lab8.dat[,1]))
 p_unadj-NULL
 p_unadj

 #all this just built an empty vector to store the results of our 
loop...


 for ( i in lab8.dat[,1] )
p_unadj[i]-calc.prob.t(lab8.dat[i,2], lab8.dat[i,3])

 p_unadj

 #if executed on my Mac, running R v.2.8, this works (and did using 
2.8 on my

 old windows machine). Running v. 2.10 in Windows, I get NAs.

 --
 Michael D. Rennie, Ph.D.
 Postdoctoral Fellow, Environmental and Life Sciences Program
 Trent University

 2140 East Bank Drive, DNA Building (2nd Floor)

 Peterborough, Ontario K9J 7B8
 Vox:705.755.2287 Fax:705.755.1559
 www.*people.trentu.ca/michaelrennie

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

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





--
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://*www.*joshuawiley.com/

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

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





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

[R] Is there any R package that can find the maxima of a 1-D time series

2010-03-17 Thread mauede
Is there any R package that can help me with digging out the maxima of a 1-D 
trajectory ?

I have 975 1-D  curves. They are only known as time series. That is a set of 
points ordered with respect 
to time. Some curves exhibit one only peak. Others have two peaks of different 
height.
We wish to find the number of peaks and their position along the time axis.
Apparently it's a trivial problem solved looking at the zeros and the change of 
sign of the 1st derivative.
In practice it is necessary to apply some criteria (which ones ?) to 
discriminate between real peaks
 and noise oscillations.
Presumably I ought to define the noise level with respect to peaks  height in 
this application ...
Maybe wavelets can help ?
Thank you in advance,
Maura



tutti i telefonini TIM!


[[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] define F-ratio computations with aov

2010-03-17 Thread Michael Rennie


Howdy,

In the past, I've just run the ANOVA as normal, and then just grabbed 
the appropriate MS for the estimation of F ratios. Eg, this will get you 
the MS in your anova object:


summary(obj.aov)[[1]][3]

or

summary(obj.aov)$Mean

And if you want a specific MS,

summary(obj.aov)[[1]][[1,3]]

or

summary(obj.aov)[[1]]$Mean[1]


Then you can just put whichever MS over whichever other MS, estimate 
your F-ratios, with something like:


Ffact- summary(obj.aov)[[1]]$Mean[1]/summary(obj.aov)[[1]]$Mean[3]

estimate the p-values with:

pFfact-1-pf(Ffact, summary(obj.aov)[[1]]$Df[1], 
summary(obj.aov)[[1]]$Df[3])


 and you're off to the races.

You can also specify error strata in the aov() model, but then all you 
get is the MS and you have to estimate your F-ratios anyway (though the 
indexing is a little different). E.g., if you had a nested anova, you 
could specify it as:


ex.aov-aov(Fixed ~ Nested + Error(Nested/Fixed))

At least this way, the summary() doesn't give you the wrong F-ratios, so 
you aren't temped to interpret them incorrectly (as you would in the 
previous example).


HTH,

Mike

Galanidis Alexandros wrote:

Greetings to all,

This is my model: aov.fit-aov(Y~A+B+C+D+E+A:C+A:E)

In summary(aov.fit) all F values are comptuted by eg MS(A)/MS(Residuals). This 
is not correct (or what I want), except for F(B) and F(A:E). I suppose P values 
are not correct either.

Is it possible with aov to define the way F computations will be done? I 'd 
like them to be like this: F(A)=MS(A)/MS(E), F(C)=MS(C)/MS(E), 
F(D)=MS(D)/MS(E), F(E)=MS(E)/MS(A:E), F(A:C)=MS(A:C)/MS(A:E)

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




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


Re: [R] accessing info in object slots from listed objects using loops

2010-03-17 Thread Henrique Dallazuanna
Try this:

sapply(modelStack, slot, 'fit')['coef',]

On Wed, Mar 17, 2010 at 7:11 AM, torgrims torgr...@stud.ntnu.no wrote:

 Hey,

 I have stacked a couple of garchFit objects in a list with names $fit1,
 $fit2, ..., $fiti assigning objects names using a loop, i.e. after running
 the loop modelStack = list($fit1, $fit2,...,$fiti).

 Thus the following apply;
 a = modelStack$fit2, then a is the second garchFit object of formal class
 'fGarch' with 11 slots, @call, @formula... etc.

 I then want to extract information in the 11 slots using another for loop,
 say i want to access the slot a...@fit$coef. In order for this to happen I 
 need
 to combine modelStack$fit2, where the $fit2 object name must be constructed
 in the loop, with the slot name @fit$coef.

 In order to construct the proper list names one could use the following in
 the for loop;
 name = paste(modelStack$fit,i,@fit$coef,sep=)  #
 modelstack$f...@fit$coef for i = 2,

 and then use something like
 get(name)

 But this returns; Error in get(name) : object 'modelstack$f...@fit$coef' not
 found

 If I just type modelstack$f...@fit$coef in the command window it returns the
 proper info from the object list. I figure this is because R somehow
 interpret $ and @ in get() differently than $ and @ as list
 separators.

 Does anyone know how to extract information in slots of listed objects using
 a loop and on the run generated variable/object names?

 JT

 sample code
        nAssets = length(modelStack)

        for(i in 1:nAssets){
                name = paste(modelStack[,i,]...@name$series$h,sep=)
                a = get(name)
                      t = length(a)
        } # end for loop

 --
 View this message in context: 
 http://n4.nabble.com/accessing-info-in-object-slots-from-listed-objects-using-loops-tp1596135p1596135.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

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


Re: [R] Constrained non linear regression using ML

2010-03-17 Thread Corrado

Dear Gabor,

1) The constraints are active, at least from a formal point view.
3) I have tried several times to run betareg.fit on the data, and the 
only thing I can obtain is the very strange error:


Error in dimnames(x) - dn :  length of 'dimnames' [2] not equal to 
array extent


The error is strange because, because the function dimnames is not 
called anywhere.  


Regards

Gabor Grothendieck wrote:

Try it anyways -- maybe none of your constraints are active.

On Wed, Mar 17, 2010 at 6:01 AM, Corrado ct...@york.ac.uk wrote:
  

Dear Gabor, dear R users,

I had already read the betareg documentation. As far as I can understand
from the help, it does not allow for constrained regression.

Regards


Gabor Grothendieck wrote:


Check out the betareg package.

On Tue, Mar 16, 2010 at 2:58 PM, Corrado ct...@york.ac.uk wrote:

  

Dear R users,

I have to fit the non linear regression:

y~1-exp(-(k0+k1*p1+k2*p2+  +kn*pn))

where ki=0 for each i in [1  n] and pi are on R+.

I am using, at the moment, nls, but I would rather use a Maximum
Likelhood
based algorithm. The error is not necessarily normally distributed.

y is approximately beta distributed, and the volume of data is medium to
large (the y,pi may have ~ 40,000 elements).

I have studied the packages in the task views Optimisation and Robust
Statistical Methods, but I did look like what I was looking for was
there.
Maybe I am wrong.

The nearest thing was nlrob, but even that does not allow for
constraints,
as far as I can understand.

Any suggestion?

Regards

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

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




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






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

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


Re: [R] Summing daily data for each year

2010-03-17 Thread Gabor Grothendieck
Try this.  We read in the data using read.zoo and then aggregate it.
read.zoo assumes Date class unless you indicate otherwise.
Then we compute the year and aggregate over that.

as.numeric(format(time(z), %Y)) would be an alternate way to compute the year.

Lines - 1995-04-01 0.002766309
1995-04-02 0.002402973
1995-04-03 0.002254335
1995-04-04 0.002221305
1995-04-05 0.002180017
1995-04-06 0.002031379
1995-04-07 0.001957060
1995-04-08 0.001940545
1995-04-09 0.001924030
1995-04-10 0.001783650

library(zoo)
# z - read.zoo(myfile.dat)
z - read.zoo(textConnection(Lines))
aggregate(z, as.numeric(floor(as.yearmon(time(z, sum)

The result of the last statement is (since our test data above only
has one year):

  1995
0.02146160

See ?read.zoo and ?aggregate.zoo in the zoo package and also the three
vignettes (pdf documents) that come with the package.




On Wed, Mar 17, 2010 at 2:20 AM,  santosh.ar...@csiro.au wrote:

 Hello there

 I have a DAILY data set (as shown below) with Date and
  Streamflow from April 1995 to Aug 2006.  I want a yearly sum
 the streamflow value (for each year - first and last
 incomplete year).

 Does anyone know how to do this in R?

 I have tried everything I could think of, e.g. imported the
 streamflow data as time series using:

 flowdata - ts(ZVo[,2],start = c(1995,4,1), frequency = 7) #
 perhaps frequency = 365 is the better one and tried to
 aggregate using aggregate() without success

ZVo
             V1      V2
  1  1995-04-01 0.002766309
  2  1995-04-02 0.002402973
  3  1995-04-03 0.002254335
  4  1995-04-04 0.002221305
  5  1995-04-05 0.002180017
  6  1995-04-06 0.002031379
  7  1995-04-07 0.001957060
  8  1995-04-08 0.001940545
  9  1995-04-09 0.001924030
  10 1995-04-10 0.001783650
  .
  .
  .
  4156 2006-08-16 0.02861272
  4157 2006-08-17 0.03652353
  4158 2006-08-18 0.05372419
  4159 2006-08-19 0.05630058
  4160 2006-08-20 0.06274154
  4161 2006-08-21 0.06981833

  Many thanks

  Santosh

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

2010-03-17 Thread Gabor Grothendieck
Contact the maintainer regarding problems with the package.  Not sure
if this is acceptable but if you get it to run you could consider just
dropping the variables from your model that correspond to active
constraints.

Also try the maxLik package.  You will have to define the likelihood
yourself but it does support constraints.

On Wed, Mar 17, 2010 at 9:07 AM, Corrado ct...@york.ac.uk wrote:
 Dear Gabor,

 1) The constraints are active, at least from a formal point view.
 3) I have tried several times to run betareg.fit on the data, and the only
 thing I can obtain is the very strange error:

 Error in dimnames(x) - dn :  length of 'dimnames' [2] not equal to array
 extent

 The error is strange because, because the function dimnames is not called
 anywhere.
 Regards

 Gabor Grothendieck wrote:

 Try it anyways -- maybe none of your constraints are active.

 On Wed, Mar 17, 2010 at 6:01 AM, Corrado ct...@york.ac.uk wrote:


 Dear Gabor, dear R users,

 I had already read the betareg documentation. As far as I can understand
 from the help, it does not allow for constrained regression.

 Regards


 Gabor Grothendieck wrote:


 Check out the betareg package.

 On Tue, Mar 16, 2010 at 2:58 PM, Corrado ct...@york.ac.uk wrote:



 Dear R users,

 I have to fit the non linear regression:

 y~1-exp(-(k0+k1*p1+k2*p2+  +kn*pn))

 where ki=0 for each i in [1  n] and pi are on R+.

 I am using, at the moment, nls, but I would rather use a Maximum
 Likelhood
 based algorithm. The error is not necessarily normally distributed.

 y is approximately beta distributed, and the volume of data is medium
 to
 large (the y,pi may have ~ 40,000 elements).

 I have studied the packages in the task views Optimisation and Robust
 Statistical Methods, but I did look like what I was looking for was
 there.
 Maybe I am wrong.

 The nearest thing was nlrob, but even that does not allow for
 constraints,
 as far as I can understand.

 Any suggestion?

 Regards

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

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




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





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



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


Re: [R] How can I save the result for goodness of fit test

2010-03-17 Thread Michael Friendly

pinusan wrote:

Dear All,
I run the goodness of fit test using goodfit() in vcd package.
The result is as follow: 


Goodness-of-fit test for poisson distribution

 X^2 df  P( X^2)
Pearson 1.053348  2 0.5905661
Warning message:
In summary.goodfit(gf) : Chi-squared approximation may be incorrect

I want to save the the test statistics(X^2), df, and p-value. How can I save
the result. Actually, I want to make a table.


The usual general answer to this question is to read the documentation, 
and look for the Value section.  ?goodfit gives


Value
A list of class goodfit with elements:

observed observed frequencies.
countcorresponding counts.
fitted   expected frequencies (fitted by ML).
type a character string indicating the distribution fitted.
method   a character string indicating the fitting method (can be either 
 ML, MinChisq or fixed if the parameters were specified).

df   degrees of freedom.
par  a named list of the (estimated) distribution parameters.

So, the quantities you want are not returned in the resulting object. 
But, they *are* returned from the summary method that you used to print 
the result. [That isn't documented, so perhaps that could be added.]


So, the 2nd general answer to your question is to use str() on the
result of the summary() function.

 ## Simulated data examples:
 dummy - rnbinom(200, size = 1.5, prob = 0.8)
 gf - goodfit(dummy, type = nbinomial, method = MinChisq)
 summary(gf)

 Goodness-of-fit test for nbinomial distribution

  X^2 df  P( X^2)
Pearson 0.5865029  1 0.4437746
Warning message:
In summary.goodfit(gf) : Chi-squared approximation may be incorrect
 result - summary(gf)

 Goodness-of-fit test for nbinomial distribution

  X^2 df  P( X^2)
Pearson 0.5865029  1 0.4437746
Warning message:
In summary.goodfit(gf) : Chi-squared approximation may be incorrect
 str(result)
 num [1, 1:3] 0.587 1 0.444
 - attr(*, dimnames)=List of 2
  ..$ : chr Pearson
  ..$ : chr [1:3] X^2 df P( X^2)

 result
  X^2 df  P( X^2)
Pearson 0.5865029  1 0.4437746

So, there you go!



In addition, there is warning message In summary.goodfit(gf) : Chi-squared
approximation may be incorrect.
How can I interpret this result. 


Read the Details section

Have a nice day.




--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA

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


Re: [R] Missing index in vector assignment

2010-03-17 Thread Petr PIKAL
Hi


r-help-boun...@r-project.org napsal dne 17.03.2010 13:04:05:

 Jim  Petr,
 Thank you for your hint - I am really grateful, because they helped me 
to
 get one step further,
 and although now the problem lies somewhere else, you encouraged that we 
can
 find the
 solution soon!
 
 1. To Petr's comments
 
 Petr, your hint to define y:
   y - LVvar[,1, drop=FALSE]
 did solve the problem, so I got a data.frame with the indexes.

Going through help page

y - as.matrix(LVvar[,1, drop=FALSE])
x - as.matrix(LVvar[,-1]
svp - ksvm(x, y, type=nu-svc)

shall work. However as I never used this package and function I am not 
sure if it is used correctly.

Regards
Petr


 
 Yet, then I turned to the call
   svp - ksvm(x, y, type=nu-svc)
   Error in .local(x, ...) : y must be a vector or a factor.
 
 So then I followed your second advice, looking up the additional 
information
 from help file:
 ==
 x is defined as:
  a symbolic description of the model to be fit. When not using a formula 
x
 can be a matrix or vector containing the training data or a kernel 
matrix of
 class kernelMatrix of the training data or a list of character vectors 
(for
 use with the string kernel). Note, that the intercept is always 
excluded,
 whether given in the formula or not.
 
 y is defined as
 a response vector with one label for each row/component of x. Can be 
either
 a factor (for classification tasks) or a numeric vector (for 
regression).
 ==
 
 So I tried to convert LVvar into a matrix via as.matrix() but didn't 
make a
 difference.
 
 
 2. To Jim's comments
 
 On Wed, Mar 17, 2010 at 1:10 AM, jim holtman jholt...@gmail.com wrote:
 
  Please provide what LVvar is.
 
 
 LVvar is a dataframe
 
 
  At least provide str(LVvar), or preferably a 'dput' of the object.
 
 
 str(LVvar) returns:
 
 'data.frame':   55 obs. of  7 variables:
  $ rPerform : num  0.0682 -0.0682 -0.7443 0.7443 0.2619 ...
  $ rCoordCap: num  4.98 6.08 5.73 5.92 4.96 ...
  $ rKnowGrow: num  4.5 5.92 5.23 6.08 4.38 ...
  $ rGoalcom : num  5.81 6.58 6 5.75 5.29 ...
  $ rSupport : num  6.15 6.92 6.6 4.92 6 ...
  $ rOpcomm  : num  5.98 6.25 6.33 6.5 5.29 ...
  $ rT2Cadap : num  5.03 6.12 4.9 6.25 5.12 ...
  - attr(*, na.action)=Class 'omit'  Named int 40
   .. ..- attr(*, names)= chr 40
 
 ==
 
 dput(LVvar) returns (abbreviated with ...):
 
 structure(list(rPerform = c(0.0681818181818183, -0.0681818181818183,
 -0.744318181818182, 0.744318181818182, 0.261931818181818,
 -0.900568181818182,
 ...
  rCoordCap = c(4.979167,
 6.08, 5.73, 5.916667, 4.958333,
 ...
 .Names = c(rPerform, rCoordCap, rKnowGrow,
 rGoalcom, rSupport, rOpcomm, rT2Cadap), row.names = c(1L,
 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 41L, 42L,
 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L,
 56L), na.action = structure(40L, .Names = 40, class = omit), class =
 data.frame)
 
 
 
 
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/
 posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 Here's my try (please have mercy for a complete R beginner):
 
 library(kernlab)
 library(methods)
 
 # Data Definitions
 LV - c(rPerform,rCoordCap, rKnowGrow, rGoalcom, rSupport,
 rOpcomm, rT2Cadap )
 
 # creates a dataframe
 LVvar - na.omit(loopLV_IndexScores(LV, u_proj))
 
 x - (LVvar[,-1])
 y - (LVvar[,1])
 svp - ksvm(x, y, type=nu-svc)
 svp
 
 ===
 
 Thanks so much for not giving up.
 
 Cheers,
 Chaehan
 
 
 
 
  On Tue, Mar 16, 2010 at 6:03 PM, Chaehan So chaehan...@gmail.com 
wrote:
 
  Dear r-helpers,
 
  I am getting a mismatch error between two variables:
 
   svp - ksvm(x, y, type=nu-svc)
   Error in .local(x, ...) : x and y don't match.
 
  and I suspect that it might be due to missing index in the y variable
  which
  I defined as:
 
   y - (LVvar[,1])
 
  I tried various methods to make the y assignment in the same format 
as x,
  which is a dataframe
   x - (LVvar[,-1])
 
  and looks like
   x
rCoordCap rKnowGrow rGoalcom rSupport  rOpcomm rT2Cadap
  1   4.979167  4.50 5.812500 6.145833 5.979167 5.031250
  ...
 
  but I still get y without the indexes as a vector:
   y
   [1] -1. -6.91193182 -1.  0.74431818 -6.91193182
 
 
  Why are the results different for x and y, even though the assignment 
is
  the
  same
  except I exclude the columns for y?
 
  Cheers,
  Chaehan
 
 [[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.htmlhttp://www.r-project.org/
 posting-guide.html
  and provide commented, minimal, self-contained, 

Re: [R] Constrained non linear regression using ML

2010-03-17 Thread Arne Henningsen
On 17 March 2010 14:22, Gabor Grothendieck ggrothendi...@gmail.com wrote:
 Contact the maintainer regarding problems with the package.  Not sure
 if this is acceptable but if you get it to run you could consider just
 dropping the variables from your model that correspond to active
 constraints.

 Also try the maxLik package.  You will have to define the likelihood
 yourself but it does support constraints.

Yes. And specifying the likelihood function is probably (depending on
your distributional assumptions) not too complicated.

BTW: Even if your y follows a beta distribution, it does not mean that
your error term also follows a beta distribution. And it the
distribution of the error term which is crucial for specifying the
likelihood function.

/Arne

 On Wed, Mar 17, 2010 at 9:07 AM, Corrado ct...@york.ac.uk wrote:
 Dear Gabor,

 1) The constraints are active, at least from a formal point view.
 3) I have tried several times to run betareg.fit on the data, and the only
 thing I can obtain is the very strange error:

 Error in dimnames(x) - dn :  length of 'dimnames' [2] not equal to array
 extent

 The error is strange because, because the function dimnames is not called
 anywhere.
 Regards

 Gabor Grothendieck wrote:

 Try it anyways -- maybe none of your constraints are active.

 On Wed, Mar 17, 2010 at 6:01 AM, Corrado ct...@york.ac.uk wrote:


 Dear Gabor, dear R users,

 I had already read the betareg documentation. As far as I can understand
 from the help, it does not allow for constrained regression.

 Regards


 Gabor Grothendieck wrote:


 Check out the betareg package.

 On Tue, Mar 16, 2010 at 2:58 PM, Corrado ct...@york.ac.uk wrote:



 Dear R users,

 I have to fit the non linear regression:

 y~1-exp(-(k0+k1*p1+k2*p2+  +kn*pn))

 where ki=0 for each i in [1  n] and pi are on R+.

 I am using, at the moment, nls, but I would rather use a Maximum
 Likelhood
 based algorithm. The error is not necessarily normally distributed.

 y is approximately beta distributed, and the volume of data is medium
 to
 large (the y,pi may have ~ 40,000 elements).

 I have studied the packages in the task views Optimisation and Robust
 Statistical Methods, but I did look like what I was looking for was
 there.
 Maybe I am wrong.

 The nearest thing was nlrob, but even that does not allow for
 constraints,
 as far as I can understand.

 Any suggestion?

 Regards

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

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




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





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



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




-- 
Arne Henningsen
http://www.arne-henningsen.name

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


Re: [R] plm within models: is the correct F-statistic reported?

2010-03-17 Thread Liviu Andronic
Dear Achim

On 3/16/10, Achim Zeileis achim.zeil...@uibk.ac.at wrote:
  Hence, when saying summary() different models with no effects are
 assumed. For gr_fe the model without effects just omits value/capital but
 keeps the firm-specific interecepts. For gr_lm not even the intercept is
 kept in the model. Thus:

  gr_fe_null - lm(invest ~ 0 + firm, data = pgr)
  gr_lm_null - lm(invest ~ 0, data = pgr)

What would be the more useful no effects model in the plm(...,
effect=twoways) case? Considering the same setting,
library(AER)
data(Grunfeld, package = AER)
library(plm)
gr - subset(Grunfeld, firm %in% c(General Electric, General Motors, IBM))
pgr - plm.data(gr, index = c(firm, year))

I am fitting a twoways model and an individual with manually
specified time effects.
 gr_fe1 - plm(invest ~ value + capital, data = pgr,
+model = within, effect=twoways)
 summary(gr_fe1)
Twoways effects Within Model

Call:
plm(formula = invest ~ value + capital, data = pgr, effect = twoways,
model = within)

Balanced Panel: n=3, T=20, N=60

Residuals :
   Min. 1st Qu.  Median 3rd Qu.Max.
-153.00  -29.102.23   34.80  125.00

Coefficients :
Estimate Std. Error t-value Pr(|t|)
value 0.1295 0.02245.77  1.4e-06 ***
capital   0.4184 0.0353   11.85  5.5e-14 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares:957000
Residual Sum of Squares: 138000
F-statistic: 107.246 on 2 and 36 DF, p-value: 6.84e-16

  gr_fe2 - plm(invest ~ value + capital + year, data = pgr,
+model = within, effect=individual)
  summary(gr_fe2)
Oneway (individual) effect Within Model

Call:
plm(formula = invest ~ value + capital + year, data = pgr, effect =
individual,
model = within)

Balanced Panel: n=3, T=20, N=60

Residuals :
   Min. 1st Qu.  Median 3rd Qu.Max.
-153.00  -29.102.23   34.80  125.00

Coefficients :
  Estimate Std. Error t-value Pr(|t|)
value   0.1295 0.02245.77  1.4e-06 ***
capital 0.4184 0.0353   11.85  5.5e-14 ***
year1936  -83.962553.6143   -1.57   0.1261
year1937 -150.920658.3282   -2.59   0.0139 *
year1938  -81.234350.7175   -1.60   0.1180
year1939 -137.457953.4385   -2.57   0.0144 *
year1940  -96.358453.9837   -1.78   0.0827 .
year1941  -56.558753.0089   -1.07   0.2931
year1942  -36.653950.9966   -0.72   0.4769
year1943  -78.079452.0249   -1.50   0.1421
year1944  -66.472552.5047   -1.27   0.2136
year1945  -89.556254.2876   -1.65   0.1077
year1946  -59.114755.3115   -1.07   0.2923
year1947  -87.544452.6530   -1.66   0.1051
year1948 -119.912553.3167   -2.25   0.0307 *
year1949 -167.955254.1999   -3.10   0.0038 **
year1950 -172.767655.0212   -3.14   0.0034 **
year1951 -191.136957.6114   -3.32   0.0021 **
year1952 -195.450359.6377   -3.28   0.0023 **
year1953 -174.663966.3451   -2.63   0.0124 *
year1954 -181.127368.5794   -2.64   0.0121 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares:189
Residual Sum of Squares: 138000
F-statistic: 21.8327 on 21 and 36 DF, p-value: 1.32e-14


Following the reasoning in your previous e-mail, I assume that the
(more useful) no effects model used in the twoways case is
 gr_fe1_null - lm(invest ~ 0 + firm + year, data = pgr)

However I cannot replicate the F-statistic: 107.246.
 anova(gr_fe1_null, gr_fe1)
Analysis of Variance Table

Response: invest
  Df  Sum Sq Mean Sq F value Pr(F)
firm   3 7664439 2554813  101.46 2e-16 ***
year  19  932060   490561.95  0.040 *
Residuals 38  956886   25181
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Warning message:
In anova.lmlist(object, ...) :
  models with response NULL removed because response differs from model 1
 anova(gr_fe1_null, gr_fe2)
Analysis of Variance Table

Response: invest
  Df  Sum Sq Mean Sq F value Pr(F)
firm   3 7664439 2554813  101.46 2e-16 ***
year  19  932060   490561.95  0.040 *
Residuals 38  956886   25181
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Warning message:
In anova.lmlist(object, ...) :
  models with response NULL removed because response differs from model 1


In the case of individual with manually introduced time effects, I
assume the following null is used:
 gr_fe2_null - lm(invest ~ 0 + firm, data = pgr)

But even here I cannot replicate the F-statistic: 21.8327.
 anova(gr_fe2_null, gr_fe2)
Analysis of Variance Table

Response: invest
  Df  Sum Sq Mean Sq F value Pr(F)
firm   3 7664439 255481377.1 2e-16 ***
Residuals 57 1888946   33139
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Warning message:
In anova.lmlist(object, ...) :
  models with response NULL removed because response differs from model 1


Am I doing something wrong?
Liviu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] Is there any R package that can find the maxima of a 1-D

2010-03-17 Thread Ted Harding
On 17-Mar-10 12:31:43, mau...@alice.it wrote:
 Is there any R package that can help me with digging out the
 maxima of a 1-D trajectory ?
 
 I have 975 1-D  curves. They are only known as time series.
 That is a set of points ordered with respect to time. Some
 curves exhibit one only peak.
 We wish to find the number of peaks and their position along
 the time axis.
 Apparently it's a trivial problem solved looking at the zeros
 and the change of sign of the 1st derivative.
 In practice it is necessary to apply some criteria (which ones?)
 to discriminate between real peaks  and noise oscillations.
 Presumably I ought to define the noise level with respect to
 peaks height in this application ...
 Maybe wavelets can help ?
 Thank you in advance,
 Maura

Precisely. You need to define what you wish peak to mean.
Then you can implement your wish in code.

The most inclusive definition:
  (X[n] = X[n-1])(X[n] = X[n+1])
will of course catch everything, including noisy fluctuations
(and as a result may hide real (underlying) peaks hidden by
the noise).

You might extend the above:
(X[n]=X[n-1])(X[n-1]=X[n-2])(X[n]=X[n+1])(X[n+1]=X[n+2])

or you might apply a smoother (possibly wavelets) to reduce the
noise and then find the peaks of that. And so on ... Apparently
you already have some notion of what you want peak to mean,
since you say Others have two peaks of different height,
and you also recognise an effect of noise.

But the possibilities are endless!

Sir Hector Munro's classic Tables of the 3000-feet Mountains
of Scotland (first published 1891) did not give a formal
definition owing to the impossibility of deciding what should
be considered separate mountains. On the other hand, J. Rooke
Corbett's later Scottish Mountains 2500 Feet And Under 3000 Feet
In Height With Re-Ascent Of 500 Feet On All Sides did use
the re-ascent definition given in the title: it is a separate
mountain if you have to climb at least 500 feet from any other
peak to reach its summit.

However, a single mountain may have more than one peak. For
example, the mountain of Lochnagar (overlooking the Balmoral
Estate and the theme of a novel by Prince Charles) is held to
have two separate peaks, marked on the Ordnance Survey Map as
Cac Carn Beag and Cac Carn Mor (don't ask ... ), at 3789 feet
and 3768 feet respectively, separated by a ridge of about 1/4
mile which dips by about 100 feet.

They can be seen at the right-hand end of the photo of Lochnagar
shown in
  http://en.wikipedia.org/wiki/Lochnagar
(to the right of the notch just right of centre)

On the other hand, look at the photo of part of Cairngorm mountain
at
  http://www.scotclimb.org.uk/gallery.php?id=200
and ask: Is there a peak here, or is it all noise?

However, here:
  http://www.scotclimb.org.uk/gallery.php?id=126
you can rather clearly distinguish between peak and noise!

So we can (more or less) make the distinction when we look.
But how to define this sort of thing so that R can understand?
Up to you!

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 17-Mar-10   Time: 14:02:13
-- XFMail --

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


Re: [R] Constrained non linear regression using ML

2010-03-17 Thread Corrado

Dear Arne, Gabor,

I solved the problem with betareg (downloaded the package). I run it on 
my data, and unfortunately the  constraint is definitively active, if I 
remove the active variables, I then remove the most significant variables!


Of course the error is important, not the distribution of the variable.

In this case, one of the assumptions is that the error may be 
distributed ~ beta. I think that betareg makes this assumption, am I right?


I am finding it difficult to solve two problems:

1) write the maximum likelihood function (what do you suggest?)
2) deal with the fact that a few factors actually have values of y (the 
response) at the extremes: that is 0 and 1. But that mean that the link 
function returns Infinite values in that case 

3) the error is dependent on E(y).

PS: Additional silly question: what is the discrete equivalent of beta? 
binomial?


Arne Henningsen wrote:

On 17 March 2010 14:22, Gabor Grothendieck ggrothendi...@gmail.com wrote:
  

Contact the maintainer regarding problems with the package.  Not sure
if this is acceptable but if you get it to run you could consider just
dropping the variables from your model that correspond to active
constraints.

Also try the maxLik package.  You will have to define the likelihood
yourself but it does support constraints.



Yes. And specifying the likelihood function is probably (depending on
your distributional assumptions) not too complicated.

BTW: Even if your y follows a beta distribution, it does not mean that
your error term also follows a beta distribution. And it the
distribution of the error term which is crucial for specifying the
likelihood function.

/Arne
  

--

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

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


Re: [R] define F-ratio computations with aov

2010-03-17 Thread RICHARD M. HEIBERGER
Please look at the Error term in ?aov

On Wed, Mar 17, 2010 at 4:25 AM, Galanidis Alexandros a...@env.aegean.grwrote:

 Greetings to all,

 This is my model: aov.fit-aov(Y~A+B+C+D+E+A:C+A:E)

 In summary(aov.fit) all F values are comptuted by eg MS(A)/MS(Residuals).
 This is not correct (or what I want), except for F(B) and F(A:E). I suppose
 P values are not correct either.

 Is it possible with aov to define the way F computations will be done? I 'd
 like them to be like this: F(A)=MS(A)/MS(E), F(C)=MS(C)/MS(E),
 F(D)=MS(D)/MS(E), F(E)=MS(E)/MS(A:E), F(A:C)=MS(A:C)/MS(A:E)


For your example, it looks like

mydata.aov - aov(Y ~ A+B+C+D + Error(E/A), data=mydata)

might be what you need.  It isn't possible to be sure of the correct
statement
for your example without seeing the actual treatment plan.

The standard split-plot design is specified with

splplot - data.frame(y=rnorm(72),
  blocks=factor(rep(1:6, each=12)),
  plots=factor(rep(rep(1:3, each=4), 6)),
  subplots=factor(rep(1:4, 18)),
  A=factor(rep(c(3,1,2, 3,1,2, 2,3,1, 3,2,1, 2,1,3,
1,2,3), each=4)),
  B=factor(
c(4, 3, 2, 1, 1, 2, 4, 3, 1, 2, 3, 4,
  3, 1, 2, 4, 4, 1, 2, 3, 2, 1, 3, 4,
  2, 3, 4, 1, 4, 2, 3, 1, 1, 4, 2, 3,
  3, 4, 1, 2, 1, 3, 4, 2, 2, 3, 4, 1,
  4, 1, 3, 2, 3, 4, 1, 2, 3, 4, 2, 1,
  3, 1, 4, 2, 4, 3, 1, 2, 1, 2, 3, 4)))

splplot.aov - aov(y ~ A*B +  Error(blocks/plots/subplots), data=splplot)
summary(splplot.aov)
 summary(splplot.aov)
Error: blocks
  Df Sum Sq Mean Sq F value Pr(F)
Residuals  5 2.0231 0.40463
Error: blocks:plots
  Df  Sum Sq Mean Sq F value Pr(F)
A  2  0.2876  0.1438  0.1135 0.8938
Residuals 10 12.6646  1.2665
Error: blocks:plots:subplots
  Df Sum Sq Mean Sq F value Pr(F)
B  3  2.814 0.93797  0.8987 0.4493
A:B6  3.358 0.55964  0.5362 0.7778
Residuals 45 46.965 1.04367


As you see, the correct F tests are automatically determined and displayed.

Rich

[[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] Odp: Adding minutes to 24 hour time

2010-03-17 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 17.03.2010 14:57:32:

 Hi,
 
 Does anyone know how to add minutes (up to 100 min) to a 24 hour time, 
to 
 create a new 24 hour time? I can't seem to find any documentation or 
examples 
 explaining how to do this. The variables of interest are 
'ARRIVE','WAIT', and 
 'DEPART' in the attached partial dataframe. I want 'DEPART' to be the 
sum of
 'ARRIVE' and 'WAIT' in 24 hour format. Also, can anyone direct me to 
some 
 relevant documentation?

You can make a date/time object from

YEAR, WEEK, ARRIVE

by 

mydate - strptime(paste())

see
?strptime

then you can add ARRIVE just by

mydate+ARRIVE*60

(You did not say explicitly what values are ARRIVE so assume minutes)

You shall probably also consult zoo library, especially na.locf function.

Regards
Petr

 
 Thank you,
 
 Mike
 [příloha Dataframe.pdf odstraněna uživatelem Petr PIKAL/CTCAP] 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Adding minutes to 24 hour time

2010-03-17 Thread Gustaf Rydevik
On Wed, Mar 17, 2010 at 2:57 PM, Hosack, Michael mhos...@state.pa.us wrote:
 Hi,

 Does anyone know how to add minutes (up to 100 min) to a 24 hour time, to 
 create a new 24 hour time? I can't seem to find any documentation or examples 
 explaining how to do this. The variables of interest are 'ARRIVE','WAIT', and 
 'DEPART' in the attached partial dataframe. I want 'DEPART' to be the sum 
 of 'ARRIVE' and 'WAIT' in 24 hour format. Also, can anyone direct me to some 
 relevant documentation?

 Thank you,

 Mike


If you convert all data to a date-and-time ?POSIXlt object, you can
just convert the minutes to seconds and add together with +.
Another way would be the something like this:

addTime-function(timeTxt,mins){
  start.time-strsplit(timeTxt,:)
  start.time-do.call(rbind,start.time)
  storage.mode(start.time)-numeric
  hours-mins%/%60
  mins.left-mins%%60
  end.mins-(start.time[,2]+mins.left)%%60
  end.hours-(start.time[,1]+hours+(start.time[,2]+mins.left)%/%60)%%24
  end.time-paste(end.hours,end.mins,sep=:)
 return(end.time)
}
addTime(c(15:23,7:00),c(70,100))

or this:

addTime2-function(timeTxt,mins){
orig.date-as.POSIXct(paste(2001-01-01,timeTxt))
new.Date-orig.date+mins*60
new.Date-strsplit(as.character(new.Date), )
new.Time-(sapply(new.Date,[,2))
return(new.Time)
}
addTime2(c(15:23,7:00),c(70,100))


Regards,
Gustaf
-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

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


Re: [R] Missing index in vector assignment

2010-03-17 Thread Chaehan So
Petr -
your suggestion WORKS!

Thank you so much, really!

happy-Chaehan

On Wed, Mar 17, 2010 at 2:22 PM, Petr PIKAL petr.pi...@precheza.cz wrote:

 Hi


 r-help-boun...@r-project.org napsal dne 17.03.2010 13:04:05:

  Jim  Petr,
  Thank you for your hint - I am really grateful, because they helped me
 to
  get one step further,
  and although now the problem lies somewhere else, you encouraged that we
 can
  find the
  solution soon!
 
  1. To Petr's comments
 
  Petr, your hint to define y:
y - LVvar[,1, drop=FALSE]
  did solve the problem, so I got a data.frame with the indexes.

 Going through help page

 y - as.matrix(LVvar[,1, drop=FALSE])
 x - as.matrix(LVvar[,-1]
 svp - ksvm(x, y, type=nu-svc)

 shall work. However as I never used this package and function I am not
 sure if it is used correctly.

 Regards
 Petr


 
  Yet, then I turned to the call
svp - ksvm(x, y, type=nu-svc)
Error in .local(x, ...) : y must be a vector or a factor.
 
  So then I followed your second advice, looking up the additional
 information
  from help file:
  ==
  x is defined as:
   a symbolic description of the model to be fit. When not using a formula
 x
  can be a matrix or vector containing the training data or a kernel
 matrix of
  class kernelMatrix of the training data or a list of character vectors
 (for
  use with the string kernel). Note, that the intercept is always
 excluded,
  whether given in the formula or not.
 
  y is defined as
  a response vector with one label for each row/component of x. Can be
 either
  a factor (for classification tasks) or a numeric vector (for
 regression).
  ==
 
  So I tried to convert LVvar into a matrix via as.matrix() but didn't
 make a
  difference.
  
 
  2. To Jim's comments
 
  On Wed, Mar 17, 2010 at 1:10 AM, jim holtman jholt...@gmail.com wrote:
 
   Please provide what LVvar is.
  
 
  LVvar is a dataframe
 
 
   At least provide str(LVvar), or preferably a 'dput' of the object.
  
 
  str(LVvar) returns:
 
  'data.frame':   55 obs. of  7 variables:
   $ rPerform : num  0.0682 -0.0682 -0.7443 0.7443 0.2619 ...
   $ rCoordCap: num  4.98 6.08 5.73 5.92 4.96 ...
   $ rKnowGrow: num  4.5 5.92 5.23 6.08 4.38 ...
   $ rGoalcom : num  5.81 6.58 6 5.75 5.29 ...
   $ rSupport : num  6.15 6.92 6.6 4.92 6 ...
   $ rOpcomm  : num  5.98 6.25 6.33 6.5 5.29 ...
   $ rT2Cadap : num  5.03 6.12 4.9 6.25 5.12 ...
   - attr(*, na.action)=Class 'omit'  Named int 40
.. ..- attr(*, names)= chr 40
 
  ==
 
  dput(LVvar) returns (abbreviated with ...):
 
  structure(list(rPerform = c(0.0681818181818183, -0.0681818181818183,
  -0.744318181818182, 0.744318181818182, 0.261931818181818,
  -0.900568181818182,
  ...
   rCoordCap = c(4.979167,
  6.08, 5.73, 5.916667, 4.958333,
  ...
  .Names = c(rPerform, rCoordCap, rKnowGrow,
  rGoalcom, rSupport, rOpcomm, rT2Cadap), row.names = c(1L,
  2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
  16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
  29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 41L, 42L,
  43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L,
  56L), na.action = structure(40L, .Names = 40, class = omit), class =
  data.frame)
 
 
 
  
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/
  posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
  
 
  Here's my try (please have mercy for a complete R beginner):
 
  library(kernlab)
  library(methods)
 
  # Data Definitions
  LV - c(rPerform,rCoordCap, rKnowGrow, rGoalcom, rSupport,
  rOpcomm, rT2Cadap )
 
  # creates a dataframe
  LVvar - na.omit(loopLV_IndexScores(LV, u_proj))
 
  x - (LVvar[,-1])
  y - (LVvar[,1])
  svp - ksvm(x, y, type=nu-svc)
  svp
 
  ===
 
  Thanks so much for not giving up.
 
  Cheers,
  Chaehan
 
 
 
 
   On Tue, Mar 16, 2010 at 6:03 PM, Chaehan So chaehan...@gmail.com
 wrote:
  
   Dear r-helpers,
  
   I am getting a mismatch error between two variables:
  
svp - ksvm(x, y, type=nu-svc)
Error in .local(x, ...) : x and y don't match.
  
   and I suspect that it might be due to missing index in the y variable
   which
   I defined as:
  
y - (LVvar[,1])
  
   I tried various methods to make the y assignment in the same format
 as x,
   which is a dataframe
x - (LVvar[,-1])
  
   and looks like
x
 rCoordCap rKnowGrow rGoalcom rSupport  rOpcomm rT2Cadap
   1   4.979167  4.50 5.812500 6.145833 5.979167 5.031250
   ...
  
   but I still get y without the indexes as a vector:
y
[1] -1. -6.91193182 -1.  0.74431818 -6.91193182
  
  
   Why are the results different for x and y, even though the assignment
 is
   the
   same
   except I exclude the columns for y?
  
   Cheers,
   Chaehan
  
  [[alternative HTML version deleted]]
  
   

Re: [R] Constrained non linear regression using ML

2010-03-17 Thread Gabor Grothendieck
For specific questions on the betareg package contact the maintainer.
If the likelihood based approaches are giving too much difficulty try
moving to a Bayesian framework (WinBUGS/R2WinBUGS, JAGS/r2jags, etc.)

On Wed, Mar 17, 2010 at 10:03 AM, Corrado ct...@york.ac.uk wrote:
 Dear Arne, Gabor,

 I solved the problem with betareg (downloaded the package). I run it on my
 data, and unfortunately the  constraint is definitively active, if I remove
 the active variables, I then remove the most significant variables!

 Of course the error is important, not the distribution of the variable.

 In this case, one of the assumptions is that the error may be distributed ~
 beta. I think that betareg makes this assumption, am I right?

 I am finding it difficult to solve two problems:

 1) write the maximum likelihood function (what do you suggest?)
 2) deal with the fact that a few factors actually have values of y (the
 response) at the extremes: that is 0 and 1. But that mean that the link
 function returns Infinite values in that case 
 3) the error is dependent on E(y).

 PS: Additional silly question: what is the discrete equivalent of beta?
 binomial?

 Arne Henningsen wrote:

 On 17 March 2010 14:22, Gabor Grothendieck ggrothendi...@gmail.com
 wrote:


 Contact the maintainer regarding problems with the package.  Not sure
 if this is acceptable but if you get it to run you could consider just
 dropping the variables from your model that correspond to active
 constraints.

 Also try the maxLik package.  You will have to define the likelihood
 yourself but it does support constraints.


 Yes. And specifying the likelihood function is probably (depending on
 your distributional assumptions) not too complicated.

 BTW: Even if your y follows a beta distribution, it does not mean that
 your error term also follows a beta distribution. And it the
 distribution of the error term which is crucial for specifying the
 likelihood function.

 /Arne


 --

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



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


[R] [R-pkgs] haarfisz

2010-03-17 Thread Guy Nason
Dear all,

The package haarfisz, for computing Haar-Fisz variance stabilization transforms 
for Poisson-like data has just been submitted to CRAN.

This was previously bundled with wavethresh, but has now been unbundled.

Best wishes,
Guy Nason

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

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


Re: [R] odfWeave Error

2010-03-17 Thread Btibert3

Thanks for your help!

Here is what I tried with no luck. I use 7-zip on my machine. Just in case
it helps, I am running XP Pro 32 at the office.

odfctrl - odfWeaveControl(zipCmd = c(C:/Program Files/7-Zip/7zG.exe -r
$$file$$ ., C:/Program Files/7-Zip/7zG.exe -o $$file$$))

odfWeave(example01_in.odt, example01.odt, control = odfctrl)


I even tried to use 7z.exe, as well as 7zFM.exe.  Essentially, I attempted
to use all 3 exectuable files that are located in the install directory.

Any ideas?

Thanks again!
-- 
View this message in context: 
http://n4.nabble.com/odfWeave-Error-tp1595848p1596418.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] Converting factors to numeric in a dataframe

2010-03-17 Thread Michael Glanville
I am currently trying to write a program that minimises the amount of work
required for “auditable” qPCR data. At the moment I am using an Excel (.csv)
spreadsheet as source data that has been transposed to the column format
required for R to read. Unfortunately, this means I have* *to manually
confirm the whole data set prior to doing any analysis, which is taking a
considerable amount of time! My idea now is to read the raw data in directly
and get R to do the transformation prior to analysis. The problem I now have
is that, upon transposition, the data are converted to “character” in a
matrix, rather than “factor” and “numeric” in a dataframe. I have succeeded
in changing the matrix to a dataframe (via as.data.frame(object)), but this
then converts all the data to “factor” which I can’t use for my analysis
since, other than the column headings, I need the data to be numeric. I have
tried coercing the data to numeric using the as() and as.numeric() commands,
but this has no effect on the data format. I have no experience in
programming and so am at a loss as to what to do: am I making a basic error
in my programming or missing something essential (or both!)?



I am using R version 2.9.0 at the moment, but this will change as soon as I
have sorted this issue out. Below is the code I have put together, as you
can see it is VERY brief but essential to allow my analysis to proceed:



pcrdata-read.csv(File_path,header=FALSE)

pcrdata-as.data.frame(t(pcrdata))

pcrdata[2:51]-as.numeric(as.character(pcrdata))



Any help would be gratefully appreciated,



Mike Glanville

[[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-pkgs] waveband

2010-03-17 Thread Guy Nason
Dear all,

The package waveband, for computing wavelet shrinkage credible intervals, has 
been uploaded to CRAN.

This was previously bundled with wavethresh, but has now been unbundled.

Best wishes,
Guy Nason



--
Professor Guy Nason
Head of Department
Department of Mathematics  
University of Bristol
http://www.stats.bris.ac.uk/~magpn


PA: Helen Craven
helen.cra...@bristol.ac.uk, +44 (0) 117 928 7978




[[alternative HTML version deleted]]

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

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


[R] mmap error on macbook pro

2010-03-17 Thread Shyamasree Saha [shs]
Dear List,

I am trying to read some files using read.csv and total size of those files are 
3.99 GB. I am using MacBook Pro with 4GB RAM(snow leopard). I also tried to run 
a chunk from those files and altogether the size was 1.33 GB. But every time I 
was getting the following error

R(1200) malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

I managed to run smaller chunks (400MB) and I also saved the object. But 
problem is when I try to load some of those objects(which is not more than 1.5 
GB altogether), I get same error again. Can someone please help? why am I 
getting this error? does R need more space than the actual file size? I may buy 
new machine if its something related to RAM size. but if it is some R problem 
then it will be very useless to buy new machine. So, I really need to know why 
this is happening.

Any help is appreciated.

Thanks in advance.

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


[R] [R-pkgs] wavethresh

2010-03-17 Thread Guy Nason
Dear all,

A new version of wavethresh has just been submitted to CRAN.

This is version 4.5

All best wishes,
Guy Nason

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

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


[R] How good is R at making publication quality tables?

2010-03-17 Thread Paul Miller
Hello Everyone,
 
I have just started learning R and am in the process of figuring out what it 
can and can't do. I must say I am very impressed with R so far and am amazed 
that something this good can actually be free. 
 
Recently, I finished reading R for SAS and SPSS Users and have begun reading 
SAS and R and Data Manipulation with R. Based on what I've read in these books 
and elsewhere, I get the impression that R is very good at drawing high quality 
graphs but maybe not so good at creating nice looking tables of the sort I'm 
used to getting through SAS ODS.
 
Am I right or wrong about this? If I am wrong, can anyone show me some examples 
of how R can be used to create really nice looking tables? I often make tables 
of adverse events in clinical trials that have n(%) values in the cells. I'd 
love to see an example that does a nice job of making that sort of table but 
would be happy to see any examples that someone might be willing to send to me.
 
Thanks,
 
Paul
 


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


[[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] odfWeave Error

2010-03-17 Thread Max Kuhn
Can you use 7zG to unzip an odt file from a dos prompt?

Max


On Wed, Mar 17, 2010 at 9:46 AM, Btibert3 btibe...@gmail.com wrote:

 Thanks for your help!

 Here is what I tried with no luck. I use 7-zip on my machine. Just in case
 it helps, I am running XP Pro 32 at the office.

 odfctrl - odfWeaveControl(zipCmd = c(C:/Program Files/7-Zip/7zG.exe -r
 $$file$$ ., C:/Program Files/7-Zip/7zG.exe -o $$file$$))

 odfWeave(example01_in.odt, example01.odt, control = odfctrl)


 I even tried to use 7z.exe, as well as 7zFM.exe.  Essentially, I attempted
 to use all 3 exectuable files that are located in the install directory.

 Any ideas?

 Thanks again!
 --
 View this message in context: 
 http://n4.nabble.com/odfWeave-Error-tp1595848p1596418.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.




-- 

Max

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

2010-03-17 Thread Ivan Calandra
Hi!

I don't really understand why you do pcrdata-as.data.frame(t(pcrdata))
Do you need to transpose the dataset? Because read.csv() creates a 
dataframe already.

Something I found really useful recently is the package xlsReadWrite 
where the function read.xls() has an argument colClasses (read.table() 
and read.csv() have it too, but it never worked fine for me) which would 
allow you to specify the class of each column at reading.

Is this what you were looking for or am I completely wrong?

By the way, you could send us the output from str(pcrdata), I mean just 
after reading in the data

Ivan


Le 3/17/2010 15:23, Michael Glanville a écrit :
 I am currently trying to write a program that minimises the amount of work
 required for auditable qPCR data. At the moment I am using an Excel (.csv)
 spreadsheet as source data that has been transposed to the column format
 required for R to read. Unfortunately, this means I have* *to manually
 confirm the whole data set prior to doing any analysis, which is taking a
 considerable amount of time! My idea now is to read the raw data in directly
 and get R to do the transformation prior to analysis. The problem I now have
 is that, upon transposition, the data are converted to character in a
 matrix, rather than factor and numeric in a dataframe. I have succeeded
 in changing the matrix to a dataframe (via as.data.frame(object)), but this
 then converts all the data to factor which I can't use for my analysis
 since, other than the column headings, I need the data to be numeric. I have
 tried coercing the data to numeric using the as() and as.numeric() commands,
 but this has no effect on the data format. I have no experience in
 programming and so am at a loss as to what to do: am I making a basic error
 in my programming or missing something essential (or both!)?



 I am using R version 2.9.0 at the moment, but this will change as soon as I
 have sorted this issue out. Below is the code I have put together, as you
 can see it is VERY brief but essential to allow my analysis to proceed:



 pcrdata-read.csv(File_path,header=FALSE)

 pcrdata-as.data.frame(t(pcrdata))

 pcrdata[2:51]-as.numeric(as.character(pcrdata))



 Any help would be gratefully appreciated,



 Mike Glanville

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


-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php


[[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] email id

2010-03-17 Thread makhdoomi
this is my mail id

abraufs...@gmail.com

[[alternative HTML version deleted]]

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


[R] question about multinom function (nnet)

2010-03-17 Thread Sergii Ivakhno
Dear All.

I have the following table that I want to analyze using multinom
function 

  freq segments sample

4271 Seg1 tumour

4311 Seg2 tumour

3515 Seg1 normal

3561 Seg2 normal

 

I want to compare model with both factors to the one where only sample
is present.

model1=multinom(freq~segments+sample,data=table)

model2=multinom(freq~ sample,data=table)

 

anova(model2,model1)

Likelihood ratio tests of Multinomial Models

 

Response: freq

  Model Resid. df   Resid. Dev   TestDf LR stat.
Pr(Chi)

1sample 6 5.5452609828

2 segments + sample 3 0.0001600513 1 vs 2 3 5.545101
0.1359658

 

What I do not understand is where df of 6 and 3 come from? Shouldn't
they be 2 and 1?

Many thanks for your help in advance

Sincerely

Sergii 

 
  
--
Sergii Ivakhno

PhD student

Computational Biology Group
Cancer Research UK Cambridge Research Institute
Li Ka Shing Centre
Robinson Way
Cambridge CB2 0RE
England

+44 (0)1223 404293 (O)
+44 (0)1223 404128 (F)

http://www.compbio.group.cam.ac.uk http://www.compbio.group.cam.ac.uk/
/


This communication is from Cancer Research UK. Our website is at 
www.cancerresearchuk.org. We are a charity registered under number 1089464 and 
a company limited by guarantee registered in England  Wales under number 
4325234. Our registered address is 61 Lincoln's Inn Fields, London WC2A 3PX. 
Our central telephone number is 020 7242 0200.

This communication and any attachments contain information which is 
confidential and may also be privileged.   It is for the exclusive use of the 
intended recipient(s).  If you are not the intended recipient(s) please note 
that any form of disclosure, distribution, copying or use of this communication 
or the information in it or in any attachments is strictly prohibited and may 
be unlawful.  If you have received this communication in error, please notify 
the sender and delete the email and destroy any copies of it.

E-mail communications cannot be guaranteed to be secure or error free, as 
information could be intercepted, corrupted, amended, lost, destroyed, arrive 
late or incomplete, or contain viruses.  We do not accept liability for any 
such matters or their consequences.  Anyone who communicates with us by e-mail 
is taken to accept the risks in doing so.
[[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] Odp: boxplot, vertical position of x-axis labels

2010-03-17 Thread Kay Cichini

thanks a lot!

both ways work.

greetings - 
kay
-- 
View this message in context: 
http://n4.nabble.com/boxplot-vertical-position-of-x-axis-labels-tp1594857p1596456.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 good is R at making publication quality tables?

2010-03-17 Thread RICHARD M. HEIBERGER
Please look at the latex function in the Hmisc package.
The default display is very good.  And there are many optional
arguments that give you very fine control over the appearance of
the table.

Rich

[[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] Converting factors to numeric in a dataframe

2010-03-17 Thread RICHARD M. HEIBERGER
Why use a csv dataset as an intermediary?  Use RExcel and get
the dataset directly from your Excel source.

See http://rcom.univie.ac.at for full details.
You can download the RExcelInstaller package from CRAN with

install.packages(RExcelInstaller)
library(RExcelInstaller)
installRExcel()

Rich

[[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] Odp: Converting factors to numeric in a dataframe

2010-03-17 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 17.03.2010 15:23:34:

 I am currently trying to write a program that minimises the amount of 
work
 required for “auditable” qPCR data. At the moment I am using an Excel 
(.csv)
 spreadsheet as source data that has been transposed to the column format
 required for R to read. Unfortunately, this means I have* *to manually
 confirm the whole data set prior to doing any analysis, which is taking 
a
 considerable amount of time! My idea now is to read the raw data in 
directly
 and get R to do the transformation prior to analysis. The problem I now 
have
 is that, upon transposition, the data are converted to “character” in a
 matrix, rather than “factor” and “numeric” in a dataframe. I have 
succeeded
 in changing the matrix to a dataframe (via as.data.frame(object)), but 
this
 then converts all the data to “factor” which I can’t use for my analysis
 since, other than the column headings, I need the data to be numeric. I 
have
 tried coercing the data to numeric using the as() and as.numeric() 
commands,
 but this has no effect on the data format. I have no experience in
 programming and so am at a loss as to what to do: am I making a basic 
error
 in my programming or missing something essential (or both!)?
 
 
 
 I am using R version 2.9.0 at the moment, but this will change as soon 
as I
 have sorted this issue out. Below is the code I have put together, as 
you
 can see it is VERY brief but essential to allow my analysis to proceed:
 
 
 
 pcrdata-read.csv(File_path,header=FALSE)


This is supposed to be data frame already. As you did not show us any of 
possible clues of data type like

str(pcrdata)

it is difficult to say.

However from your description your original data are in columns which have 
numeric and character data together which is not possible. I believe that 
there are options for reading such data.

 
 pcrdata-as.data.frame(t(pcrdata))

OK. Here you say you get data in columns but they are all character.

 
 pcrdata[2:51]-as.numeric(as.character(pcrdata))
 

Here it depends whether they are all numeric or if some of them shall be 
character (factor). Functions like those above can not be used directly on 
data frames. You need to use apply.

apply(pcrdata, 1, as.character)

Exact sequence of required functions is impossible to guess without 
knowing structure of your objects.

You shall also consult R intro and R data manuals.

Regards
Petr


 
 
 Any help would be gratefully appreciated,
 
 
 
 Mike Glanville
 
[[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] Using nrow with summaryBy

2010-03-17 Thread Tony Laidig
Hello Everyone-
I'm calculating summary statistics on a dataset (~4000 records, 
observations are not uniformly distributed) using summaryBy and trying 
to add a column with the number of observations to the output as well. 
What occurs to me is to use nrow(), but this doesn't appear to be working

I'm able to replicate the same results with an example from the 
summaryBy docs:

data(dietox)
dietox12- subset(dietox,Time==12)
library(doBy)
#this one works
summaryBy(Weight+Feed~Evit+Cu,data=dietox12,FUN=c(mean,var,length))
#adding nrow doesn't give the number of rows
summaryBy(Weight+Feed~Evit+Cu,data=dietox12,FUN=c(mean,var,length,nrow))


There must be a way to do this, but I can't figure it out. I suspect 
there is another function that would be compatible with summaryBy.

Thanks in advance.
-Tony




[[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 good is R at making publication quality tables?

2010-03-17 Thread Erik Iverson



Paul Miller wrote:

Hello Everyone,

I have just started learning R and am in the process of figuring out
what it can and can't do. I must say I am very impressed with R so
far and am amazed that something this good can actually be free.

Recently, I finished reading R for SAS and SPSS Users and have begun
reading SAS and R and Data Manipulation with R. Based on what I've
read in these books and elsewhere, I get the impression that R is
very good at drawing high quality graphs but maybe not so good at
creating nice looking tables of the sort I'm used to getting through
SAS ODS.


You're really only limited by your imagination here.  I have written 
several custom table functions to output LaTeX, but you can output 
whatever you like (HTML, plain-text, org-mode files...), you're in 
complete control with R.


I can second the Hmisc package though.  I often use a combination of 
summary.formula and the latex function to output really nice looking 
tables that get put into a long PDF report for a study.


I can say that both of these functions, summary.formula and latex, in 
Hmisc have a LOT of arguments, and almost every time I said I wish it 
looked a little different, there was an option to control it.


Specifically, I found the options:

exclude1, long, longtable, combine, test,

do be very useful.  I often make tables by some treatment group, so all 
these are using method = reverse to accomplish that.


And if you don't like the output, latex.summary.formula.reverse is a 
good function to make your own version of, to output exactly what you 
want.  I have a local copy that augments the tables that contain 
unadjusted p-values with adjusted p-values from a model.


But apart from Hmisc, just realize that with R you have a nice 
programming language to produce any type of output you want, you're not 
limited to what someone else gave you.


--Erik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Adding minutes to 24 hour time

2010-03-17 Thread Hosack, Michael
Thank you Gustaf for your help! It worked perfectly. Now I just need to figure 
out how you did it.
Petr, thank you for assisting me, but I could not get your approach to work. 

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.


Re: [R] save data to an R object

2010-03-17 Thread cheba meier
Yes, that was very useful, thank you, Cheba

2010/3/17 Ivan Calandra ivan.calan...@uni-hamburg.de

 Hi,

 Here is one option:
 #some sample dataframes
 df1 - data.frame(letter=letters[1:3], number=1:3)
 df1 - data.frame(letter=letters[4:6], number=4:6)

 #save the dataframes
 save(df1, df2, file=test.Rda)
 #load them in another session
 load(test.Rda)
  df1
  letter number
 1  a  1
 2  b  2
 3  c  3
  df2
  letter number
 1  d  4
 2  e  5
 3  f  6

 Is that what you're looking for?
 Ivan



 Le 3/17/2010 11:56, cheba meier a écrit :

 Dear R people,

 Is it possible to save three data sets in an R object and to call each
 data
 from this object independently!

 Regards,
 Cheba

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




 --
 Ivan CALANDRA
 PhD Student
 University of Hamburg
 Biozentrum Grindel und Zoologisches Museum
 Abt. Säugetiere
 Martin-Luther-King-Platz 3
 D-20146 Hamburg, GERMANY
 +49(0)40 42838 6231
 ivan.calan...@uni-hamburg.de

 **
 http://www.for771.uni-bonn.de
 http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 good is R at making publication quality tables?

2010-03-17 Thread Ista Zahn
Hi Paul,
For instructions and examples using the Hmisc latex() function you
might want to take a look at
http://lib.stat.cmu.edu/S/Harrell/doc/summary.pdf.

-Best,
Ista

On Wed, Mar 17, 2010 at 10:51 AM, Paul Miller pjmiller...@yahoo.com wrote:
 Hello Everyone,

 I have just started learning R and am in the process of figuring out what it 
 can and can't do. I must say I am very impressed with R so far and am amazed 
 that something this good can actually be free.

 Recently, I finished reading R for SAS and SPSS Users and have begun reading 
 SAS and R and Data Manipulation with R. Based on what I've read in these 
 books and elsewhere, I get the impression that R is very good at drawing high 
 quality graphs but maybe not so good at creating nice looking tables of the 
 sort I'm used to getting through SAS ODS.

 Am I right or wrong about this? If I am wrong, can anyone show me some 
 examples of how R can be used to create really nice looking tables? I often 
 make tables of adverse events in clinical trials that have n(%) values in the 
 cells. I'd love to see an example that does a nice job of making that sort of 
 table but would be happy to see any examples that someone might be willing to 
 send to me.

 Thanks,

 Paul



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


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





-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.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 good is R at making publication quality tables?

2010-03-17 Thread Douglas Bates
On Wed, Mar 17, 2010 at 10:25 AM, Erik Iverson er...@ccbr.umn.edu wrote:


 Paul Miller wrote:

 Hello Everyone,

 I have just started learning R and am in the process of figuring out
 what it can and can't do. I must say I am very impressed with R so
 far and am amazed that something this good can actually be free.

 Recently, I finished reading R for SAS and SPSS Users and have begun
 reading SAS and R and Data Manipulation with R. Based on what I've
 read in these books and elsewhere, I get the impression that R is
 very good at drawing high quality graphs but maybe not so good at
 creating nice looking tables of the sort I'm used to getting through
 SAS ODS.

 You're really only limited by your imagination here.  I have written several
 custom table functions to output LaTeX, but you can output whatever you like
 (HTML, plain-text, org-mode files...), you're in complete control with R.

 I can second the Hmisc package though.  I often use a combination of
 summary.formula and the latex function to output really nice looking tables
 that get put into a long PDF report for a study.

 I can say that both of these functions, summary.formula and latex, in Hmisc
 have a LOT of arguments, and almost every time I said I wish it looked a
 little different, there was an option to control it.

 Specifically, I found the options:

 exclude1, long, longtable, combine, test,

 do be very useful.  I often make tables by some treatment group, so all
 these are using method = reverse to accomplish that.

 And if you don't like the output, latex.summary.formula.reverse is a good
 function to make your own version of, to output exactly what you want.  I
 have a local copy that augments the tables that contain unadjusted p-values
 with adjusted p-values from a model.

 But apart from Hmisc, just realize that with R you have a nice programming
 language to produce any type of output you want, you're not limited to what
 someone else gave you.

Another option to consider is the xtable 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] Using nrow with summaryBy

2010-03-17 Thread David Winsemius


On Mar 17, 2010, at 11:23 AM, Tony Laidig wrote:


Hello Everyone-
I'm calculating summary statistics on a dataset (~4000 records,
observations are not uniformly distributed) using summaryBy and trying
to add a column with the number of observations to the output as well.
What occurs to me is to use nrow(), but this doesn't appear to be  
working


I'm able to replicate the same results with an example from the
summaryBy docs:

data(dietox)
dietox12- subset(dietox,Time==12)
library(doBy)
#this one works
summaryBy(Weight+Feed~Evit+Cu,data=dietox12,FUN=c(mean,var,length))
#adding nrow doesn't give the number of rows
summaryBy(Weight+Feed~Evit 
+Cu,data=dietox12,FUN=c(mean,var,length,nrow))




I'm a bit puzzled. One of my many newbie mistakes was to assume that  
length() applied to dataframes would tell me how many rows it had. It  
appears that the authors of summaryBy have figured out how to get  
length() to tell you the number of observations, presumably on a  
subsetted vector where length would make sense.  So ...  it's not  
clear why you also want nrow (which would not make sense for a  
subsetted vector).





There must be a way to do this, but I can't figure it out. I suspect
there is another function that would be compatible with summaryBy.

Thanks in advance.
-Tony



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] How good is R at making publication quality tables?

2010-03-17 Thread Liviu Andronic
On Wed, Mar 17, 2010 at 2:51 PM, Paul Miller pjmiller...@yahoo.com wrote:
 Am I right or wrong about this? If I am wrong, can anyone show me some 
 examples of how R can be used to create really nice looking tables? I often 
 make tables of adverse events in clinical trials that have n(%) values in the 
 cells. I'd love to see an example that does a nice job of making that sort of 
 table but would be happy to see any examples that someone might be willing to 
 send to me.

To complement all said up to now, see this documentation [1]. For
clinical trials you might also want to check rreport [2]. There was
also a recent thread [3] on the topic.
Liviu

[1] 
http://cran.r-project.org/web/packages/RcmdrPlugin.Export/RcmdrPlugin.Export.pdf
[2] http://biostat.mc.vanderbilt.edu/wiki/Main/Rreport
[3] [R] Use of R in clinical trials

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


Re: [R] Why eval(parse(text=var(vec))) return a matrix but NOT a number?

2010-03-17 Thread Charles C. Berry

On Wed, 17 Mar 2010, Yong Wang wrote:


Dear List

I am getting a problem when using eval(parse).
Code below sketchs what I am trying to do:

For each row of a N*K dataframe (I use a 2*2 dataframe in the example below),
applying a number of functions and get the outputs (two functions,
sum and var are used in the example below).

The problem is  eval(parse(text=sum(para))) works fine but not when
sum is replaced by var.
in the later case, a matrix instead of a number is returned.

Any suggestion highly appreciated.

Thank you

#===The function
myloop  -function(datfra,funs)  {

rows-dim(datfra)[1];
totfunnum-length(funs);

for (i in 1:rows)   {
vec-datfra[i,];

# I suggest:
browser()
# Now try print(vec), str(vec), etc till you understand
#why the results do not agree with your expectation

# HTH,
# Chuck


for(k in 1:totfunnum)   {
print(funs[k]);
x-eval(parse(text=funs[k]));
print(x);
}

}
}


#Experiemental run
workport-data.frame(matrix(1:4,2,2))
funs-c(sum(vec,na.rm=T),var(vec,na.rm=T))
myloop(workport,funs)

# Outputs of the
Experimental run

[1] sum(vec,na.rm=T)
[1] 4
[1] var(vec,na.rm=T)
  X1 X2
X1 NA NA
X2 NA NA
[1] sum(vec,na.rm=T)
[1] 6
[1] var(vec,na.rm=T)
  X1 X2
X1 NA NA
X2 NA NA

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



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

2010-03-17 Thread Ivan Calandra

Hi David,

I have probably 2 stupid questions regarding what you said but it might 
be important to understand:


- why nrow() would not make sens for a subsetted vector?
On the help page of nrow(), it's written that we can apply it on a 
vector, array or dataframe (basically everything...?). So what's the 
difference between a normal vector (for which it would make sense and 
work) and a subsetted vector?


- why assuming that length() applied to dataframes would tell me how 
many rows it had would be a mistake? I mean in this case, length() is 
calculated for each numerical variable (which are vectors, aren't they?).


I think these questions concern the way R handle the data and that's why 
I think it might be important for me to understand these issues.


Thanks for your input.
Regards,
Ivan

Le 3/17/2010 16:39, David Winsemius a écrit :


On Mar 17, 2010, at 11:23 AM, Tony Laidig wrote:


Hello Everyone-
I'm calculating summary statistics on a dataset (~4000 records,
observations are not uniformly distributed) using summaryBy and trying
to add a column with the number of observations to the output as well.
What occurs to me is to use nrow(), but this doesn't appear to be 
working


I'm able to replicate the same results with an example from the
summaryBy docs:

data(dietox)
dietox12- subset(dietox,Time==12)
library(doBy)
#this one works
summaryBy(Weight+Feed~Evit+Cu,data=dietox12,FUN=c(mean,var,length))
#adding nrow doesn't give the number of rows
summaryBy(Weight+Feed~Evit+Cu,data=dietox12,FUN=c(mean,var,length,nrow))



I'm a bit puzzled. One of my many newbie mistakes was to assume that 
length() applied to dataframes would tell me how many rows it had. It 
appears that the authors of summaryBy have figured out how to get 
length() to tell you the number of observations, presumably on a 
subsetted vector where length would make sense.  So ...  it's not 
clear why you also want nrow (which would not make sense for a 
subsetted vector).





There must be a way to do this, but I can't figure it out. I suspect
there is another function that would be compatible with summaryBy.

Thanks in advance.
-Tony



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.



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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

2010-03-17 Thread David Winsemius


On Mar 17, 2010, at 12:10 PM, Ivan Calandra wrote:


Hi David,

I have probably 2 stupid questions regarding what you said but it  
might be important to understand:


- why nrow() would not make sens for a subsetted vector?
On the help page of nrow(), it's written that we can apply it on a  
vector, array or dataframe (basically everything...?). So what's the  
difference between a normal vector (for which it would make sense  
and work) and a subsetted vector?


 nrow(c(0,1,3,4))
NULL
 nrow(1:12)
NULL

(It did not throw an error but the help page does say the value could  
be NULL.)


 length(1:12)
[1] 12



- why assuming that length() applied to dataframes would tell me  
how many rows it had would be a mistake? I mean in this case,  
length() is calculated for each numerical variable (which are  
vectors, aren't they?).


length applied to any list is the number of elements at the first  
level. Dataframes are lists of vectors so length applied to  
data.frames gives you the number of columns, not the length of an  
individual vector in the dataframe.




I think these questions concern the way R handle the data and that's  
why I think it might be important for me to understand these issues.


It's important, fur sure.



Thanks for your input.
Regards,
Ivan

Le 3/17/2010 16:39, David Winsemius a écrit :


On Mar 17, 2010, at 11:23 AM, Tony Laidig wrote:


Hello Everyone-
I'm calculating summary statistics on a dataset (~4000 records,
observations are not uniformly distributed) using summaryBy and  
trying
to add a column with the number of observations to the output as  
well.
What occurs to me is to use nrow(), but this doesn't appear to be  
working


I'm able to replicate the same results with an example from the
summaryBy docs:

data(dietox)
dietox12- subset(dietox,Time==12)
library(doBy)
#this one works
summaryBy(Weight+Feed~Evit+Cu,data=dietox12,FUN=c(mean,var,length))
#adding nrow doesn't give the number of rows
summaryBy(Weight+Feed~Evit 
+Cu,data=dietox12,FUN=c(mean,var,length,nrow))




I'm a bit puzzled. One of my many newbie mistakes was to assume  
that length() applied to dataframes would tell me how many rows it  
had. It appears that the authors of summaryBy have figured out how  
to get length() to tell you the number of observations, presumably  
on a subsetted vector where length would make sense.  So ...  it's  
not clear why you also want nrow (which would not make sense for a  
subsetted vector).





There must be a way to do this, but I can't figure it out. I suspect
there is another function that would be compatible with summaryBy.

Thanks in advance.
-Tony



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.



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Writing dataframes to SAS XPT format

2010-03-17 Thread Dennis Fisher
Colleagues,

On occasion, I need to output an R dataframe to a file in SAS XPT format.  
Although the foreign package supports reading of XPT files and writing to a 
format that SAS can read, it does not support writing to XPT format (confirmed 
with Thomas Lumley, the author of write.foreign).

Has anyone developed such a function?  If so, would you be willing to share it? 
 Better yet, post it to CRAN so that it is available to all users.

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] mmap error-12, macbook pro

2010-03-17 Thread Thomas Lumley



There seem to have been three almost identical reports of this from three 
different email addresses, including two widely-separate UK academic 
institutions, and two user names, which is a bit weird.

However:  R  will need more than 4GB memory to handle a 3.99GB file, and 
probably more than 4GB memory to handle a 1.33GB file.

On 32-bit R I think the recommendation is that the data should occupy no more 
than 10% of the address space, ie, about 400MB.  For 64-bit R, you are likely 
to still find R very slow if the data set is more than about 1/3 of physical 
memory.   For a 4GB data file I would recommend a computer with at least 16GB 
memory.

Now, it is often possible to load only a small fraction of the data at one time 
and so to analyse large data sets on smaller computers.  Three examples that I 
have worked on
- analysing data from a survey data set about the same size as your data, 
by keeping most of the data in a SQLite database and just loading a
   few variables at a time.
- fitting linear regression models to large data sets with the biglm 
package, by keeping the data in a SQLite database and just loading a few rows
   at a time
- analysing whole-genome genetic data (40GB or so) by storing the data in a 
netCDF file and reading appropriate chunks with the ncdf package.

  -thomas


On Wed, 17 Mar 2010, Mamun wrote:



Dear List,

I am trying to read some files using read.csv and total size of those files
are 3.99 GB. I am using MacBook Pro with 4GB RAM(snow leopard). I also tried
to run a chunk from those files and altogether the size was 1.33 GB. But
every time I was getting the following error

R(1200) malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

I managed to run smaller chunks (400MB) and I also saved the object. But
problem is when I try to load some of those objects(which is not more than
1.5 GB altogether), I get same error again. Can someone please help? why am
I getting this error? does R need more space than the actual file size? I
may buy new machine if its something related to RAM size. but if it is some
R problem then it will be very useless to buy new machine. So, I really need
to know why this is happening.

Any help is appreciated.

Thanks in advance.

regards,
Mamun
--
View this message in context: 
http://n4.nabble.com/mmap-error-12-macbook-pro-tp1596234p1596234.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.



Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

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


Re: [R] Retrieving latitude and longitude via Google Maps API

2010-03-17 Thread Greg Snow
You may want to look at http://www.openstreetmap.org/ or 
http://maps.cloudmade.com/ instead of google maps.  I don't know if they give 
the same detail/searches, but open source sites tend to be easier to work with 
and have fewer restrictions on use.  While I like the google maps, I tend to 
not use them for anything other than personal browsing since I am not sure 
about the legal/copyright issues.

Hope this helps, 

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Nutter, Benjamin
 Sent: Tuesday, March 16, 2010 1:42 PM
 To: r-help@r-project.org
 Subject: [R] Retrieving latitude and longitude via Google Maps API
 
 Does anyone have any experience retrieving latitutde and longitude for
 an address from the Google Maps API?
 
 I'd like to have an R script that submits a street address, city,
 state,
 and zip code and returns the coordinates.  So far, I've been submitting
 the coordinates from another program, then loading the coordinates in R
 and merging them back into the data frame I want to use.  It'd be nice
 to be able to do it all in one script, but I'm not comprehending the
 API
 thing very well.
 
 I'm using R 2.9.1 on Windows XP.  Any suggestions or pointers?
 
 Benjamin
 
 
 
   Benjamin Nutter |  Biostatistician  |  Quantitative Health Sciences
   Cleveland Clinic  |  9500 Euclid Ave.   |  Cleveland, OH 44195  |
 (216) 445-1365
 
 
 ===
 
 P Please consider the environment before printing this e-mail
 
 Cleveland Clinic is ranked one of the top hospitals
 in America by U.S.News  World Report (2009).
 Visit us online at http://www.clevelandclinic.org for
 a complete listing of our services, staff and
 locations.
 
 
 Confidentiality Note:  This message is intended for
 use\...{{dropped:13}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] plm within models: is the correct F-statistic reported?

2010-03-17 Thread Achim Zeileis

On Wed, 17 Mar 2010, Liviu Andronic wrote:


Dear Achim

On 3/16/10, Achim Zeileis achim.zeil...@uibk.ac.at wrote:

 Hence, when saying summary() different models with no effects are
assumed. For gr_fe the model without effects just omits value/capital but
keeps the firm-specific interecepts. For gr_lm not even the intercept is
kept in the model. Thus:

 gr_fe_null - lm(invest ~ 0 + firm, data = pgr)
 gr_lm_null - lm(invest ~ 0, data = pgr)


What would be the more useful no effects model in the plm(...,
effect=twoways) case? Considering the same setting,
library(AER)
data(Grunfeld, package = AER)
library(plm)
gr - subset(Grunfeld, firm %in% c(General Electric, General Motors, IBM))
pgr - plm.data(gr, index = c(firm, year))

I am fitting a twoways model and an individual with manually
specified time effects.

gr_fe1 - plm(invest ~ value + capital, data = pgr,

+model = within, effect=twoways)


[snip]


Following the reasoning in your previous e-mail, I assume that the
(more useful) no effects model used in the twoways case is

gr_fe1_null - lm(invest ~ 0 + firm + year, data = pgr)


Yes.


However I cannot replicate the F-statistic: 107.246.

anova(gr_fe1_null, gr_fe1)


Here, you compare apples and oranges. gr_fe1 is of class plm and 
gr_fe1_null is of class lm. This does not fly.


gr_fe1_lm - lm(invest ~ 0 + value + capital + firm + year, data = pgr)
anova(gr_fe1_lm, gr_fe1_null)

which does the job.

In short:
  - plm(..., model = within) offers a convenient approach of what
is usually done in this kind of analysis.
  - You can replicate everything by hand using lm() but have to take
care of everything yourself. But you do get the same results.
  - Don't mix the two approaches.

Best,
Z

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


Re: [R] Writing dataframes to SAS XPT format

2010-03-17 Thread Tobias Verbeke

Dennis Fisher wrote:

Colleagues,

On occasion, I need to output an R dataframe to a file in SAS XPT format.  
Although the foreign package supports reading of XPT files and writing to a 
format that SAS can read, it does not support writing to XPT format (confirmed 
with Thomas Lumley, the author of write.foreign).

Has anyone developed such a function?  If so, would you be willing to share it? 
 Better yet, post it to CRAN so that it is available to all users.


http://cran.r-project.org/web/packages/SASxport/index.html

HTH,
Tobias

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


Re: [R] replace NA value with 0

2010-03-17 Thread ehux

Building on the question how to replace NA with 0.

My data set below has date, station 1, flags for station 1, station 2, flags
for station 2, etc...

I would like to make the values in the station columns equal to 1 and the NA
in the station columns equal to 0 and then sum each row for the number of 1
present in the row.

head(data.matrix, n=10)
 date 05AE005 flg_05AE005 05AF010 flg_05AF010 05BM014 flg_05BM014
1  1900-01-01  NANA  NANA  NANA
2  1900-01-02  NANA  NANA  .23NA
3  1900-01-03  NANA  NANA  .45NA
4  1900-01-04  NANA  NANA  NANA
5  1900-01-05  NANA  NANA  NANA
6  1900-01-06  NANA  NANA  NANA
7  1900-01-07  0.75  NA  .09NA  NANA
8  1900-01-08  0.87  NA  .23NA  NANA
9  1900-01-09  0.26  NA  .78NA  NANA
10 1900-01-10  0.23  NA  NANA  NANA

# figure out which columns the data are in
colpos - seq(2, by = 2, length.out = n)

# make value 1 and NA 0
colpos[!is.na(colpos)] - 1.0
colpos[is.na(colpos)] - 0.0

# sum number of values on a given day
rowsum(colpos, )


The above script is what i have tried - and does not work. The values are
not being replaced with 1s and the NAs with 0s and the rows are not being
summed.

any help would be greatly appreciated.

E

-- 
View this message in context: 
http://n4.nabble.com/replace-NA-value-with-0-tp834446p1596779.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 good is R at making publication quality tables?

2010-03-17 Thread Erich Neuwirth
If you are working in Windows and want Word output,
it might be worthwhile to have a look at SWord
available from the download section on rcom.univie.ac.at.

Warning: the program is free for noncommercial use,
but NOT licensed under GPL or LGPL.


On 3/17/2010 3:51 PM, Paul Miller wrote:
 Hello Everyone,
  
 I have just started learning R and am in the process of figuring out what it 
 can and can't do. I must say I am very impressed with R so far and am amazed 
 that something this good can actually be free. 
  
 Recently, I finished reading R for SAS and SPSS Users and have begun reading 
 SAS and R and Data Manipulation with R. Based on what I've read in these 
 books and elsewhere, I get the impression that R is very good at drawing high 
 quality graphs but maybe not so good at creating nice looking tables of the 
 sort I'm used to getting through SAS ODS.
  
 Am I right or wrong about this? If I am wrong, can anyone show me some 
 examples of how R can be used to create really nice looking tables? I often 
 make tables of adverse events in clinical trials that have n(%) values in the 
 cells. I'd love to see an example that does a nice job of making that sort of 
 table but would be happy to see any examples that someone might be willing to 
 send to me.
  
 Thanks,
  
 Paul
  
 
 
   __
 Looking for the perfect gift? Give the gift of Flickr! 
 
 
   [[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.

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

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


Re: [R] Odp: Loop overwrite and data output problems

2010-03-17 Thread RCulloch

Hi Petr,

Thanks again!!! model is a list. So your suggestion:

mod - matrix(NA, 1000, ncols) doesn't work.

I thought that do.call and rbind would be the best for these data?

Cheers,

Ross
-- 
View this message in context: 
http://n4.nabble.com/Loop-overwrite-and-data-output-problems-tp1570593p1596889.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 nrow with summaryBy

2010-03-17 Thread Gabor Grothendieck
Use NROW rather than nrow.

On Wed, Mar 17, 2010 at 11:23 AM, Tony Laidig c...@mit.edu wrote:
 Hello Everyone-
 I'm calculating summary statistics on a dataset (~4000 records,
 observations are not uniformly distributed) using summaryBy and trying
 to add a column with the number of observations to the output as well.
 What occurs to me is to use nrow(), but this doesn't appear to be working

 I'm able to replicate the same results with an example from the
 summaryBy docs:

 data(dietox)
 dietox12- subset(dietox,Time==12)
 library(doBy)
 #this one works
 summaryBy(Weight+Feed~Evit+Cu,data=dietox12,FUN=c(mean,var,length))
 #adding nrow doesn't give the number of rows
 summaryBy(Weight+Feed~Evit+Cu,data=dietox12,FUN=c(mean,var,length,nrow))


 There must be a way to do this, but I can't figure it out. I suspect
 there is another function that would be compatible with summaryBy.

 Thanks in advance.
 -Tony




        [[alternative HTML version deleted]]

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


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


Re: [R] How good is R at making publication quality tables?

2010-03-17 Thread Muenchen, Robert A (Bob)
Hi Paul,

Sorry I didn't get to that subject in the first edition of R for SAS and SPSS 
Users. Several of the options people have mentioned will be in the second 
edition, although that's about a year off. I did get them added to R for Stata 
Users, due out in early April.

Cheers,
Bob


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Paul Miller
Sent: Wednesday, March 17, 2010 10:51 AM
To: r-help@r-project.org
Subject: [R] How good is R at making publication quality tables?

Hello Everyone,

I have just started learning R and am in the process of figuring out
what it can and can't do. I must say I am very impressed with R so far
and am amazed that something this good can actually be free.

Recently, I finished reading R for SAS and SPSS Users and have begun
reading SAS and R and Data Manipulation with R. Based on what I've read
in these books and elsewhere, I get the impression that R is very good
at drawing high quality graphs but maybe not so good at creating nice
looking tables of the sort I'm used to getting through SAS ODS.

Am I right or wrong about this? If I am wrong, can anyone show me some
examples of how R can be used to create really nice looking tables? I
often make tables of adverse events in clinical trials that have n(%)
values in the cells. I'd love to see an example that does a nice job of
making that sort of table but would be happy to see any examples that
someone might be willing to send to me.

Thanks,

Paul



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


   [[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] plm within models: is the correct F-statistic reported?

2010-03-17 Thread Liviu Andronic
On 3/17/10, Achim Zeileis achim.zeil...@uibk.ac.at wrote:
  Here, you compare apples and oranges. gr_fe1 is of class plm and
 gr_fe1_null is of class lm. This does not fly.

  gr_fe1_lm - lm(invest ~ 0 + value + capital + firm + year, data = pgr)
  anova(gr_fe1_lm, gr_fe1_null)

  which does the job.

Indeed, I see.


  In short:
   - plm(..., model = within) offers a convenient approach of what
 is usually done in this kind of analysis.

Unfortunately plm(..., effect=twoways, model = within) fails on my
particular unbalanced panel data (100% CPU and the task never
finishes); there are no such issues with individual or time. Worse
is that I cannot replicate the issue on dummy data.


   - You can replicate everything by hand using lm() but have to take
 care of everything yourself. But you do get the same results.

   - Don't mix the two approaches.

I wanted to avoid displaying 2000 individuals in the regression
coefficients, the reason for trying the mix-up. I also tried to do the
trick using a plm() model for the null, too, but there is no anova
method for these.

 gr_fe1 - plm(invest ~ value + capital, data = pgr,
+model = within, effect=twoways)
 gr_fe1_null - plm(invest ~ 0 + firm + year, data = pgr, model = pooling)
 anova(gr_fe1_null, gr_fe1)
Error in UseMethod(anova) :
  no applicable method for 'anova' applied to an object of class
c('plm', 'panelmodel')

And having checked the source, I wouldn't venture to implement one.
I'm still a bit stuck on how to proceed. Thank you
Liviu

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

2010-03-17 Thread AC Del Re
Hi All,

Im interested in creating a function that will convert a variable within a
data.frame to a factor while retaining the original name (yes, I know that I
can just:  var -factor(var) but I need it as a  function for other
purposes). e.g.:

# this was an attempt but fails.

facts - function(meta, mod, modname = spec) {
  meta$mod - factor(meta$mod)
  colnames(meta)['mod'] - modname
  return(meta)
}

# ideally, would like to just specify the data.frame (=meta) and
# variable to convert to factor (=mod) (similar to function input below).
But am
# also interested in having the option to create a new variable and
# name (similar to the function input above).

facts - function(meta, mod) {
  meta$mod - factor(meta$mod)
  return(meta)
}

Thanks for any help!

AC

[[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] Retaining variable name in a function

2010-03-17 Thread Sarah Goslee
How about this? It changes a column to a factor, and
optionally renames it.

facts - function(meta, mod, newmodname) {
   meta[,mod] - factor(meta[,mod])
   if(!missing(newmodname)) {
  colnames(meta)[colnames(meta) == mod] - newmodname
   }
   meta
}

 testdata - data.frame(a=c(1,2,3), b=c(1,1,2))
 str(testdata)
'data.frame':   3 obs. of  2 variables:
 $ a: num  1 2 3
 $ b: num  1 1 2

 test1 - facts(testdata, a)
 str(test1)
'data.frame':   3 obs. of  2 variables:
 $ a: Factor w/ 3 levels 1,2,3: 1 2 3
 $ b: num  1 1 2

 test2 - facts(testdata, b, newb)
 str(test2)
'data.frame':   3 obs. of  2 variables:
 $ a   : num  1 2 3
 $ newb: Factor w/ 2 levels 1,2: 1 1 2

Sarah

On Wed, Mar 17, 2010 at 3:06 PM, AC Del Re de...@wisc.edu wrote:
 Hi All,

 Im interested in creating a function that will convert a variable within a
 data.frame to a factor while retaining the original name (yes, I know that I
 can just:  var -factor(var) but I need it as a  function for other
 purposes). e.g.:

 # this was an attempt but fails.

 facts - function(meta, mod, modname = spec) {
  meta$mod - factor(meta$mod)
  colnames(meta)['mod'] - modname
  return(meta)
 }

 # ideally, would like to just specify the data.frame (=meta) and
 # variable to convert to factor (=mod) (similar to function input below).
 But am
 # also interested in having the option to create a new variable and
 # name (similar to the function input above).

 facts - function(meta, mod) {
  meta$mod - factor(meta$mod)
  return(meta)
 }

 Thanks for any help!

 AC


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


  1   2   >