Re: [R] Writing R package that call Fortran codes

2016-06-16 Thread Eduardo M. A. M.Mendes

> On Jun 16, 2016, at 3:50 PM, Berend Hasselman <b...@xs4all.nl> wrote:
> 
> 
>> On 16 Jun 2016, at 20:02, Eduardo M. A. M.Mendes <emammen...@gmail.com> 
>> wrote:
>> 
>> Thanks  Bill for pointing this out.  I haven’t noticed it.
>> 
>> Vineetha, try as.double(rep(0,n)) or as.matrix(rep(0,n)),
>> 
> 
> Why not simply numeric(n)?
> 
> Berend Hasselman
> 

as.numeric(rep(0,n)) works too. Please remember that he wants a vector nor a 
scalar.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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 R package that call Fortran codes

2016-06-16 Thread Eduardo M. A. M.Mendes
Thanks  Bill for pointing this out.  I haven’t noticed it.

Vineetha, try as.double(rep(0,n)) or as.matrix(rep(0,n)),

Ed

> On Jun 16, 2016, at 2:54 PM, William Dunlap <wdun...@tibco.com> wrote:
> 
> >  1: .Fortran("dataxy", n = as.integer(n), tmax = as.integer(tmax), 
> > alpha = as.double(alpha), beta = as.double(beta), x = as.double(0, 
> > length = n), y = as.double(0, length = n), tau = as.integer(0, 
> > length = n))
> 
> Are you expecting that
> as.integer(0, length=n)
> and
> as.double(0, length = n)
> will produce vectors of length 'n'?  They do not and short inputs will usually
> cause memory misuse and crashes in the Fortran code.
> 
> 
> 
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com <http://tibco.com/>
> On Thu, Jun 16, 2016 at 10:03 AM, Kodalore Vijayan, Vineetha W <vwk...@mun.ca 
> <mailto:vwk...@mun.ca>> wrote:
> Hi Eduardo,
> 
>  Thanks for your comments. I haven't tried the way you told me. Now when I
> tried, got the following error:
> 
> *** caught segfault ***
> address 0x0, cause 'memory not mapped'
> 
> Traceback:
>  1: .Fortran("dataxy", n = as.integer(n), tmax = as.integer(tmax),
> alpha = as.double(alpha), beta = as.double(beta), x = as.double(0,
> length = n), y = as.double(0, length = n), tau = as.integer(0,
> length = n))
>  2: out(NULL, NULL, NULL, NULL)
> 
> Possible actions:
> 1: abort (with core dump, if enabled)
> 2: normal R exit
> 3: exit R without saving workspace
> 4: exit R saving workspace
> Selection:
> 
> Any suggestions?
> 
> Thanks,
> Vineetha
> 
> On Wed, Jun 15, 2016 at 3:55 PM, Eduardo M. A. M.Mendes <
> emammen...@gmail.com <mailto:emammen...@gmail.com>> wrote:
> 
> > Hi
> >
> > Have you tried to load and run the fortran code using just a wrapper
> > function in R?   I do that as the first step in order to build a package.
> >
> > Example:   fortran sources -> rk4_mod_r.f90 ,derive_henonheilles.f90,
> > poincare_section.f90
> >
> > a) I use R CMD SHLIB rk4_mod_r.f90 ,derive_henonheilles.f90,
> > poincare_section.f90 - o poincare_section_henonheilles_rk4.so
> > b) Then I write a wrapper function in R, poinc_section_henonheilles.R
> > ...
> >  dyn.load("poincare_section_henonheilles_rk4.so")
> >
> >   out<-.Fortran("section_crossing",
> > h=as.numeric(h),
> > nphas=as.integer(nphas),..
> > ...
> > c) and call the function as usual.
> >
> > Please note that the function called by .Fortran is the name of the
> > subroutine within poincare_section.f90 and not the filename.
> >
> > I take the opportunity to thank R-developers for making the calling of C
> > and Fortran in R very easy.
> >
> > I hope this helps.
> >
> > regards
> >
> > Ed
> >
> > PS.  If you need an example of a package using Fortran90, please check
> > https://github.com/emammendes/mittagleffler 
> > <https://github.com/emammendes/mittagleffler>
> >
> >
> >
> > On Jun 15, 2016, at 5:20 PM, Kodalore Vijayan, Vineetha W <vwk...@mun.ca 
> > <mailto:vwk...@mun.ca>>
> > wrote:
> >
> > Hi,
> >
> > I'm trying to write an R package that calls a Fortran subroutine on my  Mac
> > os x El Capitan with Xcode 7 and gfortran 6.1, R 3.3.0.   I can build and
> > load the library but when I try to use it in R I get this error:
> >
> > library(NEpidemic)
> > random_epi(variable_names)
> >
> >
> > Error in .Fortran("random_epi", : "random_pi" not resolved from current
> > namespace (NEpidemic).
> >
> > Then I  tried adding useDynLib(random_epi.f95) in the NAMESPACE file,
> > additional to useDynLib(NEpidemic). After doing that I couldn't build the
> > package and it gave me another error:
> >
> > Error in library.dynam(lib, package, package.lib) :
> >  shared object ‘random_epi.so’ not found
> > Error: loading failed
> > Execution halted
> > ERROR: loading failed
> >
> > When I checked my src folder, there is only random_epi.o file.  How can I
> > fix this issue? Any help would be much appreciated. I'm vey new to both R
> > and Fortran coding, especially in package building.
> >
> > Thanks in advance!
> > Vineetha
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- To 
> > UNSUBSCRIBE and mor

Re: [R] Writing R package that call Fortran codes

2016-06-16 Thread Eduardo M. A. M.Mendes
Hi Vineetha

It seems that there are some problems in the Fortran code as far as allocating 
memory is concerned.  If you have statements such as double preciosion :: y(n)  
 you will need to allocate memory for the vector within the Fortran code or in 
the R wrapper-function.  It is hard to pinpoint the error without seeing the 
source files.

Cheers

Ed



> On Jun 16, 2016, at 2:03 PM, Kodalore Vijayan, Vineetha W <vwk...@mun.ca> 
> wrote:
> 
> Hi Eduardo,
> 
>  Thanks for your comments. I haven't tried the way you told me. Now when I 
> tried, got the following error:
> 
> *** caught segfault ***
> address 0x0, cause 'memory not mapped'
> 
> Traceback:
>  1: .Fortran("dataxy", n = as.integer(n), tmax = as.integer(tmax), alpha 
> = as.double(alpha), beta = as.double(beta), x = as.double(0, length = 
> n), y = as.double(0, length = n), tau = as.integer(0, length = n))
>  2: out(NULL, NULL, NULL, NULL)
> 
> Possible actions:
> 1: abort (with core dump, if enabled)
> 2: normal R exit
> 3: exit R without saving workspace
> 4: exit R saving workspace
> Selection: 
> 
> Any suggestions?
> 
> Thanks,
> Vineetha
> 
> On Wed, Jun 15, 2016 at 3:55 PM, Eduardo M. A. M.Mendes <emammen...@gmail.com 
> <mailto:emammen...@gmail.com>> wrote:
> Hi
> 
> Have you tried to load and run the fortran code using just a wrapper function 
> in R?   I do that as the first step in order to build a package.  
> 
> Example:   fortran sources -> rk4_mod_r.f90 ,derive_henonheilles.f90, 
> poincare_section.f90
> 
> a) I use R CMD SHLIB rk4_mod_r.f90 ,derive_henonheilles.f90, 
> poincare_section.f90 - o poincare_section_henonheilles_rk4.so 
> b) Then I write a wrapper function in R, poinc_section_henonheilles.R
> ...
>  dyn.load("poincare_section_henonheilles_rk4.so")
>   
>   out<-.Fortran("section_crossing",
> h=as.numeric(h),
> nphas=as.integer(nphas),..
> ...
> c) and call the function as usual.
> 
> Please note that the function called by .Fortran is the name of the 
> subroutine within poincare_section.f90 and not the filename.
> 
> I take the opportunity to thank R-developers for making the calling of C and 
> Fortran in R very easy.   
> 
> I hope this helps.
> 
> regards
> 
> Ed
> 
> PS.  If you need an example of a package using Fortran90, please check 
> https://github.com/emammendes/mittagleffler 
> <https://github.com/emammendes/mittagleffler>
> 
> 
> 
>> On Jun 15, 2016, at 5:20 PM, Kodalore Vijayan, Vineetha W <vwk...@mun.ca 
>> <mailto:vwk...@mun.ca>> wrote:
>> 
>> Hi,
>> 
>> I'm trying to write an R package that calls a Fortran subroutine on my  Mac
>> os x El Capitan with Xcode 7 and gfortran 6.1, R 3.3.0.   I can build and
>> load the library but when I try to use it in R I get this error:
>>> library(NEpidemic)
>>> random_epi(variable_names)
>> 
>> Error in .Fortran("random_epi", : "random_pi" not resolved from current
>> namespace (NEpidemic).
>> 
>> Then I  tried adding useDynLib(random_epi.f95) in the NAMESPACE file,
>> additional to useDynLib(NEpidemic). After doing that I couldn't build the
>> package and it gave me another error:
>> 
>> Error in library.dynam(lib, package, package.lib) :
>>  shared object ‘random_epi.so’ not found
>> Error: loading failed
>> Execution halted
>> ERROR: loading failed
>> 
>> When I checked my src folder, there is only random_epi.o file.  How can I
>> fix this issue? Any help would be much appreciated. I'm vey new to both R
>> and Fortran coding, especially in package building.
>> 
>> Thanks in advance!
>> Vineetha
>> 
>>  
>> [[alternative HTML version deleted]]
>> 
>> __
>> R-help@r-project.org <mailto:R-help@r-project.org> mailing list -- To 
>> UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help 
>> <https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 
>> <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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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 R package that call Fortran codes

2016-06-15 Thread Eduardo M. A. M.Mendes
Hi

Have you tried to load and run the fortran code using just a wrapper function 
in R?   I do that as the first step in order to build a package.  

Example:   fortran sources -> rk4_mod_r.f90 ,derive_henonheilles.f90, 
poincare_section.f90

a) I use R CMD SHLIB rk4_mod_r.f90 ,derive_henonheilles.f90, 
poincare_section.f90 - o poincare_section_henonheilles_rk4.so 
b) Then I write a wrapper function in R, poinc_section_henonheilles.R
...
 dyn.load("poincare_section_henonheilles_rk4.so")
  
  out<-.Fortran("section_crossing",
h=as.numeric(h),
nphas=as.integer(nphas),..
...
c) and call the function as usual.

Please note that the function called by .Fortran is the name of the subroutine 
within poincare_section.f90 and not the filename.

I take the opportunity to thank R-developers for making the calling of C and 
Fortran in R very easy.   

I hope this helps.

regards

Ed

PS.  If you need an example of a package using Fortran90, please check 
https://github.com/emammendes/mittagleffler 




> On Jun 15, 2016, at 5:20 PM, Kodalore Vijayan, Vineetha W  
> wrote:
> 
> Hi,
> 
> I'm trying to write an R package that calls a Fortran subroutine on my  Mac
> os x El Capitan with Xcode 7 and gfortran 6.1, R 3.3.0.   I can build and
> load the library but when I try to use it in R I get this error:
>> library(NEpidemic)
>> random_epi(variable_names)
> 
> Error in .Fortran("random_epi", : "random_pi" not resolved from current
> namespace (NEpidemic).
> 
> Then I  tried adding useDynLib(random_epi.f95) in the NAMESPACE file,
> additional to useDynLib(NEpidemic). After doing that I couldn't build the
> package and it gave me another error:
> 
> Error in library.dynam(lib, package, package.lib) :
>  shared object ‘random_epi.so’ not found
> Error: loading failed
> Execution halted
> ERROR: loading failed
> 
> When I checked my src folder, there is only random_epi.o file.  How can I
> fix this issue? Any help would be much appreciated. I'm vey new to both R
> and Fortran coding, especially in package building.
> 
> Thanks in advance!
> Vineetha
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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 Fortran with R

2015-11-06 Thread Eduardo M. A. M.Mendes
Dear Erin

I have written some packages using my old fortran source codes.   Nothing fancy 
as the ones in CRAN but they do what they suppose to do.  If you are interested 
in checking a very simple package using a fortran code, please look at 
https://github.com/emammendes/mittagleffler 
 , an R-package to deal with 
Mittag-Leffler functions (fractional differential equations). 

Cheers

Ed



> On Nov 6, 2015, at 3:17 PM, Erin Hodgess  wrote:
> 
> Great..thanks for the package names.  I was going to use the "Writing R
> Extensions" but wanted some more material as well.  Looking at the other
> packages might just do the trick.
> 
> Thanks,
> Erin
> 
> 
> On Fri, Nov 6, 2015 at 10:59 AM, Berend Hasselman  > wrote:
> 
>> 
>>> On 6 Nov 2015, at 17:23, Erin Hodgess  wrote:
>>> 
>>> Hello everyone!
>>> 
>>> Could someone recommend a good reference for Fortran with R, please?  I
>>> know that Dirk has an excellent book for C/C++, but I feel more
>> comfortable
>>> with Fortran (I'm old school, maybe just old!)
>>> 
>> 
>> I don't know about a book.
>> The best you can do is read Writing R Extensions.
>> And have a look at packages using Fortran:  nleqslv, geigen, QZ, deSolve,
>> minpack.lm, PEIP
>> That should give you a good idea how to use Fortran.
>> There are surely more but these are the ones I know about.
>> 
>> Berend
>> 
>>> Thank you very much in advance,
>>> Sincerely,
>>> Erin
>>> 
>>> 
>>> --
>>> Erin Hodgess
>>> Associate Professor
>>> Department of Mathematical and Statistics
>>> University of Houston - Downtown
>>> mailto: erinm.hodg...@gmail.com
>>> 
>>>  [[alternative HTML version deleted]]
>>> 
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>> 
>> 
> 
> 
> -- 
> Erin Hodgess
> Associate Professor
> Department of Mathematical and Statistics
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org  mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Minor Ticks on ggplot2

2015-07-27 Thread Eduardo M. A. M.Mendes
Hi

Although I could find some answers on how to add minor ticks on a ggplot on 
stack overflow, I could not figure to how to add them to the following example:

library(ggplot2)

x - data.frame(V1=runif(1000, -6.0, 6.0),V2=runif(1000, -6.0, 6.0));

   
g-ggplot(x,aes(V1,V2))+geom_point(size=1.5)+theme_bw()
g-g+scale_y_continuous(name=y(t))+scale_x_continuous(name=x(t))
g-g+theme(axis.title.x = element_text(face=italic, size=20),axis.title.y = 
element_text(face=italic, size=20))
g-g+theme(axis.text.x  = element_text(angle=0, vjust=0.5, size=16),axis.text.y 
 = element_text(angle=0, vjust=0.5, size=16))
g-g+coord_cartesian(xlim=c(min(x[,1]),max(x[,1])), 
ylim=c(min(x[,2]),max(x[,2])))
print(g)

How to add gridlines (or points) to the minor ticks?

Many thanks

Ed

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Date as numeric

2015-03-23 Thread Eduardo M. A. M.Mendes
Hello

I wonder what the formula behind as.numeric(2012-11-11 19:05:00 UTC”) is.

Many thanks

Ed

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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 remove latex message from a resulting rmarkdown pdf?

2014-08-03 Thread Eduardo M. A. M.Mendes
Many thanks.  I was checking print options instead of print.xtable.

Ed


On Aug 3, 2014, at 4:44 AM, Uwe Ligges lig...@statistik.tu-dortmund.de wrote:

 
 
 On 03.08.2014 02:58, Eduardo M. A. M.Mendes wrote:
 Hello
 
 I am using rmarkdown to write the partial results of my research project.  
 Both html and pdf files are used. In the resulting pdf xtable writes the 
 following msg:
 
 % latex table generated in R 3.1.1 by xtable 1.7-3 package % Sat Aug 2 
 21:42:16 2014
 
 
 How can I remove such a msg?
 
 Read ?print.xtable, there is some argument (comment?) to switch it off.
 
 
 Best,
 Uwe Ligges
 
 
 Many thanks
 
 Ed
 
 
 Below you will find the info on my system and a rmakrdown example to 
 reproduce the msg.
 
 R version 3.1.1 (2014-07-10)
 Platform: x86_64-apple-darwin13.1.0 (64-bit)
 
 locale:
 [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
 
 
 loaded via a namespace (and not attached):
  [1] cluster_1.15.2
  [2] colorspace_1.2-4
  [3] digest_0.6.4
  [4] evaluate_0.5.5
  [5] formatR_0.10
  [6] gtable_0.1.2
  [7] htmltools_0.2.4
  [8] knitr_1.6
  [9] labeling_0.2
 [10] latticeExtra_0.6-26
 [11] MASS_7.3-33
 [12] munsell_0.4.2
 [13] plyr_1.8.1
 [14] proto_0.3-10
 [15] RColorBrewer_1.0-5
 [16] Rcpp_0.11.2
 [17] reshape2_1.4
 [18] rmarkdown_0.2.53
 [19] scales_0.2.4
 [20] stringr_0.6.2
 [21] tools_3.1.1
 [22] yaml_2.1.13
 
 RStudio - Version 0.98.987
 
 and ExampleA.Rmd
 
 ---
 title: Example - Latex message on the resulting pdf
 output: pdf_document
 ---
 
 ```{r r princ, echo=FALSE, warning=FALSE, results='asis', message=FALSE}
 library(xtable,quietly = TRUE,warn.conflicts = FALSE, verbose = FALSE)
 exampleAinfo=data.frame(matrix(runif(84),21,4))
 names(exampleAinfo)=c(Column 1,Column 2,Column 3,Column 4)
 ```
 
 
 # Example
 
 ```{r exampleA, results='asis', echo=FALSE, tidy=FALSE}
 exampleAinfo.table - xtable(exampleAinfo, caption=Example A, digits=6)
 print(exampleAinfo.table, include.rownames = FALSE, floating=FALSE)
 ```
 
 
 
  [[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] How to remove latex message from a resulting rmarkdown pdf?

2014-08-02 Thread Eduardo M. A. M.Mendes
Hello

I am using rmarkdown to write the partial results of my research project.  Both 
html and pdf files are used. In the resulting pdf xtable writes the following 
msg:

% latex table generated in R 3.1.1 by xtable 1.7-3 package % Sat Aug 2 21:42:16 
2014 


How can I remove such a msg?

Many thanks

Ed


Below you will find the info on my system and a rmakrdown example to reproduce 
the msg.

R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

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


loaded via a namespace (and not attached):
 [1] cluster_1.15.2 
 [2] colorspace_1.2-4   
 [3] digest_0.6.4   
 [4] evaluate_0.5.5 
 [5] formatR_0.10   
 [6] gtable_0.1.2   
 [7] htmltools_0.2.4
 [8] knitr_1.6  
 [9] labeling_0.2   
[10] latticeExtra_0.6-26
[11] MASS_7.3-33
[12] munsell_0.4.2  
[13] plyr_1.8.1 
[14] proto_0.3-10   
[15] RColorBrewer_1.0-5 
[16] Rcpp_0.11.2
[17] reshape2_1.4   
[18] rmarkdown_0.2.53   
[19] scales_0.2.4   
[20] stringr_0.6.2  
[21] tools_3.1.1
[22] yaml_2.1.13

RStudio - Version 0.98.987

and ExampleA.Rmd

---
title: Example - Latex message on the resulting pdf
output: pdf_document
---

```{r r princ, echo=FALSE, warning=FALSE, results='asis', message=FALSE}
library(xtable,quietly = TRUE,warn.conflicts = FALSE, verbose = FALSE)
exampleAinfo=data.frame(matrix(runif(84),21,4))
names(exampleAinfo)=c(Column 1,Column 2,Column 3,Column 4)
```

  
# Example
  
```{r exampleA, results='asis', echo=FALSE, tidy=FALSE}
exampleAinfo.table - xtable(exampleAinfo, caption=Example A, digits=6)
print(exampleAinfo.table, include.rownames = FALSE, floating=FALSE)
```



  
[[alternative HTML version deleted]]

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


[R] How to change print behaviour within a markdown document

2014-08-01 Thread Eduardo M. A. M.Mendes
Hello

I have the following chunk of code within a rmarkdown document:

```{r infoA, echo=FALSE, tidy=FALSE}
print(pAinfo,quote=FALSE,justify=center)
```
pAinfo is data.frame with 21 rows and 4 columns. Unfortunately the resulting 
html (or pdf) file does not show all the four columns together (the fourth 
column is placed below the first three columns) even though there is plenty of 
room to accommodate the last column.

Is there a way to control how print or rmarkdown breaks the data.frame in order 
to get all four columns together? Can I somehow control the font size too?

Many thanks

Ed

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

2014-07-24 Thread Eduardo M. A. M.Mendes
Hello

I have recently upgraded R to the newest version.  Unfortunately my old 
(fortran and C) R-package cannot be installed anymore (was built before R 
3.0.0: please re-install it). 

I have tried R CMD INSTALL package_name but I noticed that R requests gcc-4.8.2 
and specific locations for the libraries (gcc and gfortran).   Can someone 
point me to the documentation on how to install  gcc as R requires, please?

Please note that I have used brew install gcc on another mac and soft linked 
all the necessary libraries so that gcc-4.9.1 can be used as 4.8 (as R 
requires). However I would like a clean installation.

Many thanks

Ed

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


Re: [R] R-3.1.1 - R CMD INSTALL problem

2014-07-24 Thread Eduardo M. A. M.Mendes
Many thanks.

With 4.9.1 (as I did) no need to modify Depends.

Ed

PS. I have posted the question to R-devel mailing list. Many thanks.


On Jul 24, 2014, at 8:52 PM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote:

 You need to rebuild it with an appropriate Depends entry (version of R 
 greater than 3) in the DESCRIPTION file.
 
 Further discussion about how to fix packages belongs on the R-devel mailing 
 list.
 ---
 Jeff NewmillerThe .   .  Go Live...
 DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
 /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
 --- 
 Sent from my phone. Please excuse my brevity.
 
 On July 24, 2014 3:52:26 PM PDT, Eduardo M. A. M.Mendes 
 emammen...@gmail.com wrote:
 Hello
 
 I have recently upgraded R to the newest version.  Unfortunately my old
 (fortran and C) R-package cannot be installed anymore (was built before
 R 3.0.0: please re-install it). 
 
 I have tried R CMD INSTALL package_name but I noticed that R requests
 gcc-4.8.2 and specific locations for the libraries (gcc and gfortran). 
 Can someone point me to the documentation on how to install  gcc as R
 requires, please?
 
 Please note that I have used brew install gcc on another mac and soft
 linked all the necessary libraries so that gcc-4.9.1 can be used as 4.8
 (as R requires). However I would like a clean installation.
 
 Many thanks
 
 Ed
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] What am I missing when using zoo on version 2.15?

2012-11-29 Thread Eduardo M. A. M.Mendes
Hello

 

I am running R versions 2.13 and 2.15.  One of my codes run ok on 2.13 but
on 2.15.   I have tried to understand what is wrong but come up with
nothing.

 

Here is the code

 

rm(list=ls())

graphics.off()

 

library(R.matlab)

library(zoo);

library(xts);

library(lattice);

library(hydroGOF);

 

a=readMat(exemplo_narmax_Aimores_MISO.mat)

 

predicoes=zoo(cbind(a$predicoes[,,1]$Real,a$predicoes[,,1]$Predito),as.Date(
a$predicoes[,,1]$data))

names(predicoes)=c(Real,Predito)

ggof(obs=predicoes$Real,sim=predicoes$Predito,main=Predicao Vazao - NARMAX
MISO,

 legend=c(Predito,Real))

 

ggof is a function on the hydroGOF available on  CRAN.

 

Predicoes looks like

 

 predicoes

   Real   Predito

2008-12-20  921  921.

2008-12-21 1002 1002.

2008-12-22  870  870.

2008-12-23  695  695.

2008-12-24  751  751.

2008-12-25  650  650.

2008-12-26  443  443.

..

 

which looks ok to me.

 

The  error msg on version 2.15  is

 

 ggof(obs=predicoes$Real,sim=predicoes$Predito,main=Predicao Vazao -
NARMAX MISO,
+  legend=c(Predito,Real))
Error in try.xts(x, error = 'x' needs to be timeBased or xtsible) : 
  'x' needs to be timeBased or xtsible

 

Just a remainder - there is no error whatsoever on version 2.13.

 

What am I missing?

 

Many thanks

 

Ed

 

 


[[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] Problems loading package hydroTSM

2011-10-04 Thread Eduardo M. A. M.Mendes
Hello

 

I have the following problem when loading the package hydroGOF on Windows 7
running R.12.2

 

library(hydroGOF)

Error : package 'hydroTSM' does not have a name space

Error: package/namespace load failed for 'hydroGOF'

 

The same command does not result in error on R.13.1 at  my Mac running Lion.

 

Have I done something wrong?

 

Many thanks

 

Ed

 

 

 


[[alternative HTML version deleted]]

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


[R] How to keep the same class?

2011-09-02 Thread Eduardo M. A. M.Mendes
Hello

 

Please see the example below

 

 class(testX)

[1] matrix

 class(testX[1,])

[1] numeric

 

Why not matrix?   What am I missing here?   Is there a way to keep the same
class?   

 

The reason for the question is that I want to implement a k-step ahead
prediction for my own routines and R wrecks does not seem to like [1,] as
shown below.

 

 predict(fit10,testX[1,])
Error in knnregTrain(train = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  : 
  dims of 'test' and 'train differ
 predict(fit10,testX[1:2,])
[1] 81.00 76.36

 

Many thanks

 

Ed

 


[[alternative HTML version deleted]]

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


Re: [R] How to keep the same class?

2011-09-02 Thread Eduardo M. A. M.Mendes
Many thanks to all for the reply.

I do apologize for bothering the list with a FAQ but I have to confess that,
although I read Faq in the past, I did not remember to do it again.

Cheers

Ed


-Original Message-
From: Marc Schwartz [mailto:marc_schwa...@me.com] 
Sent: Friday, September 02, 2011 5:16 PM
To: Eduardo M. A. M.Mendes
Cc: r-help@r-project.org
Subject: Re: [R] How to keep the same class?

On Sep 2, 2011, at 3:05 PM, Eduardo M. A. M.Mendes wrote:

 Hello
 
 
 
 Please see the example below
 
 
 
 class(testX)
 
 [1] matrix
 
 class(testX[1,])
 
 [1] numeric
 
 
 
 Why not matrix?   What am I missing here?   Is there a way to keep the
same
 class?   
 
 
 
 The reason for the question is that I want to implement a k-step ahead 
 prediction for my own routines and R wrecks does not seem to like [1,] 
 as shown below.
 
 
 
 predict(fit10,testX[1,])
 Error in knnregTrain(train = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  : 
  dims of 'test' and 'train differ
 predict(fit10,testX[1:2,])
 [1] 81.00 76.36
 
 
 
 Many thanks
 
 
 
 Ed


Ed,

See:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-my-matrices-lose-dimensi
ons_003f

and then use:

  predict(fit10, testX[1, , drop = FALSE])

HTH,

Marc Schwartz

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


Re: [R] Build a package - check error

2011-08-20 Thread Eduardo M. A. M.Mendes
Hi there

Many thanks.

Just to be clear I did read the manual (section 5 and all) and  have even
looked at the package expm which has a src dir with codes in fortran and C
to understand what it is going on.  

I have also read the help for .First.lib.  

Cheers

Ed


-Original Message-
From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
Sent: Saturday, August 20, 2011 10:38 AM
To: Eduardo Mendes
Cc: r-help@r-project.org
Subject: Re: [R] Build a package - check error



On 20.08.2011 00:41, Eduardo Mendes wrote:
 Hi

 I have modified the path to

 dyn.load(paste(Sys.getenv(R_LIBS_USER),/fortran/src/fortran.so,sep
 =))


Hmmm, looks like you never took a look into the relevant manual Writing R
Extensions nor in the help files I cited below.

?.First.lib has an example:

## Suppose a package needs to call a DLL named 'fooEXT', ## where 'EXT' is
the system-specific extension.  Then you should use .First.lib -
function(lib, pkg)
   library.dynam(foo, pkg, lib)


You cannot know that the package is in Sys.getenv(R_LIBS_USER)

Note also that the .so file won't be in the path /src/... but in
.../lib/... once you install the package in the recommended way using R CMD
INSTALL.

Really, please do read manual!!!





 and the package could installed, loaded and the lines with dyn.load
worked.
 It does not look like a pretty solution but works on my linux (I am 
 not sure if it works on my mac or windows).

 I am not sure if this is what you meant but as I have no clue what 
 .First.lib does or NAMESPACES means this is the best I come up with.

So again time to read the manual and the help pages.

Best,
Uwe Ligges



 Please correct me if I am wrong.

 Many thanks

 Ed



 On Fri, Aug 19, 2011 at 6:03 PM, Uwe 
 Liggeslig...@statistik.tu-dortmund.de
 wrote:



 On 19.08.2011 22:53, Eduardo Mendes wrote:

 Dear R-users

 I am slowly migrating my mex files (MATLAB - Fortran and C) to R.  
 To get my own functions available on R section I have decided to 
 learn how to build
   a
 R package. I choose a simple example with a few Fortran and R 
 functions (wrapper).

 The fortran sources are located at src and the R functions at R (as 
 recommended).  The building process went ok but R CMD check did not. 
 The error mgs was

 Error in dyn.load(fortran.so) :
unable to load shared object
 '/home/eduardo/R_packages/**test.Rcheck/fortran.so':

 Although I can see that R cannot find the compiled fortran code I do not
 know what to do.   I believe it is something to do with the following
 lines
 in  the R-wrapper file

 if (!is.loaded('calnpr'))
 dyn.load(fortran.so)



 1. If the package is called calnpr, the shared library is also called 
 that way.
 2. you have to provide the path to the shared library.

 See ?.First.lib for how to do it in a package without NAMESPACE (and 
 note that NAMESPACES are forced for the next R release).

 Best,
 Uwe Ligges


   How to add the path so that once the package is installed the 
 compiled
 fortran code can be found?

 Many thanks

 Cheers

 Ed

 [[alternative HTML version deleted]]

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



   [[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] Build a package - check error

2011-08-20 Thread Eduardo M. A. M.Mendes
Hello

I managed to find what was wrong and it has nothing to do with .First.lib.
The clue was in NAMESPACE and in the way the fortran was called (don't use
dyn.load).

I thank the author of the package digest where I found the lines that help
me to crack what was wrong and Uwe Ligges for pushing me hard.

Cheers

Ed


-Original Message-
From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] 
Sent: Saturday, August 20, 2011 10:38 AM
To: Eduardo Mendes
Cc: r-help@r-project.org
Subject: Re: [R] Build a package - check error



On 20.08.2011 00:41, Eduardo Mendes wrote:
 Hi

 I have modified the path to

 dyn.load(paste(Sys.getenv(R_LIBS_USER),/fortran/src/fortran.so,sep
 =))


Hmmm, looks like you never took a look into the relevant manual Writing R
Extensions nor in the help files I cited below.

?.First.lib has an example:

## Suppose a package needs to call a DLL named 'fooEXT', ## where 'EXT' is
the system-specific extension.  Then you should use .First.lib -
function(lib, pkg)
   library.dynam(foo, pkg, lib)


You cannot know that the package is in Sys.getenv(R_LIBS_USER)

Note also that the .so file won't be in the path /src/... but in
.../lib/... once you install the package in the recommended way using R CMD
INSTALL.

Really, please do read manual!!!





 and the package could installed, loaded and the lines with dyn.load
worked.
 It does not look like a pretty solution but works on my linux (I am 
 not sure if it works on my mac or windows).

 I am not sure if this is what you meant but as I have no clue what 
 .First.lib does or NAMESPACES means this is the best I come up with.

So again time to read the manual and the help pages.

Best,
Uwe Ligges



 Please correct me if I am wrong.

 Many thanks

 Ed



 On Fri, Aug 19, 2011 at 6:03 PM, Uwe 
 Liggeslig...@statistik.tu-dortmund.de
 wrote:



 On 19.08.2011 22:53, Eduardo Mendes wrote:

 Dear R-users

 I am slowly migrating my mex files (MATLAB - Fortran and C) to R.  
 To get my own functions available on R section I have decided to 
 learn how to build
   a
 R package. I choose a simple example with a few Fortran and R 
 functions (wrapper).

 The fortran sources are located at src and the R functions at R (as 
 recommended).  The building process went ok but R CMD check did not. 
 The error mgs was

 Error in dyn.load(fortran.so) :
unable to load shared object
 '/home/eduardo/R_packages/**test.Rcheck/fortran.so':

 Although I can see that R cannot find the compiled fortran code I do not
 know what to do.   I believe it is something to do with the following
 lines
 in  the R-wrapper file

 if (!is.loaded('calnpr'))
 dyn.load(fortran.so)



 1. If the package is called calnpr, the shared library is also called 
 that way.
 2. you have to provide the path to the shared library.

 See ?.First.lib for how to do it in a package without NAMESPACE (and 
 note that NAMESPACES are forced for the next R release).

 Best,
 Uwe Ligges


   How to add the path so that once the package is installed the 
 compiled
 fortran code can be found?

 Many thanks

 Cheers

 Ed

 [[alternative HTML version deleted]]

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



   [[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] Sweave and graphics

2011-08-16 Thread Eduardo M. A. M.Mendes
Dear R-Users

 

I think I am getting the hang of how sweave works.  However there is one
thing I am struggling with - nice small size graphics.

 

Here is the piece of the Rnw file that creates the figures.

 

pl1,fig=TRUE,include=FALSE,echo=false=

#pdf(file=datapl1.pdf,paper=a4,width=0,height=0);

plot(yt,ypred,xlab=Data,ylab=Predicted
Value,ylim=c(0,3),xlim=c(0,3),main=PL 1);

#invisible(dev.off());

@

 

pl2,fig=TRUE,include=FALSE,echo=false=

#pdf(file=datapl2.pdf,paper=a4,width=0,height=0);

plot(yt,ypredmean,xlab=Data,ylab=Predicted
Value,ylim=c(0,3),xlim=c(0,3),main=PL 2);

#invisible(dev.off());

@

 

pl3,fig=TRUE,include=FALSE,echo=false=

#pdf(file=datapl3.pdf,paper=a4,width=0,height=0);

plot(yt,ypredr,xlab=Data,ylab=Predicted
Value,ylim=c(0,3),xlim=c(0,3),main=PL 3);

#invisible(dev.off());

@

 

\begin{figure}[htbp]

\centering{

\begin{tabular}{cc}

\includegraphics[width=0.4\textwidth,height=0.3\textheight]{report-pl1} 

\includegraphics[width=0.4\textwidth,height=0.3\textheight]{report-pl2} \\

(a)  (b)

\end{tabular}

\begin{tabular}{c}

\includegraphics[width=0.4\textwidth,height=0.3\textheight]{report-pl3} \\

(c)

\end{tabular}

}

\caption{\label{fig:pl1})}

\end{figure}

 

With the comments (#) the axis labels and the tick labels seem a bit fuzzy.
Why did I do wrong?  Is there a way to increase the font size?  

 

If I  change the code and include what is in the comments (#), the output
result is terrible.  The whole figure seems fuzzy; font size is so small
that one cannot read (I have used cex.lab=1.3 but part of the label is
lost).  

 

Any tips?

 

Many thanks again

 

Ed

 


[[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 on how to use predict

2011-08-15 Thread Eduardo M. A. M.Mendes
Dear R-Users

 

My problem is quite simple: I need to use a fitted model to predict the next
point (that is, just one single point in a curve).

 

The data was divided in two parts:  identification (x and y - class matrix)
and validation (xt and yt  - class matrix).  I don't use all values in x and
y but only the 10 nearest points (x[b,] and y[b,]) for each regression (b is
a vector with the indexes).

 

 fit.a=lm(y[b] ~ x[b,],method=qr)

 summary(fit.a)

 

Call:

lm(formula = y[b] ~ x[b, ], method = qr)

 

Residuals:

 1  2  3  4  5  6  7


 6.939e-18 -2.393e-02 -3.912e-02  1.344e-02 -5.926e-02 -1.821e-02 -4.075e-02


 8  9 10 

 4.075e-02  3.938e-02  8.769e-02 

 

Coefficients:

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

(Intercept)  1.852793   0.842459   2.1990.115

x[b, ]1 -0.086324   0.056841  -1.5190.226

x[b, ]2  0.001114   0.001666   0.6680.552

x[b, ]3  0.002501   0.004376   0.5710.608

x[b, ]4 -0.003589   0.009041  -0.3970.718

x[b, ]5 -0.276498   0.119545  -2.3130.104

x[b, ]6 -0.003010   0.003574  -0.8420.462

 

Residual standard error: 0.07893 on 3 degrees of freedom

Multiple R-squared: 0.7932,   Adjusted R-squared: 0.3795 

F-statistic: 1.917 on 6 and 3 DF,  p-value: 0.3169

 

Once the fiited model is found (it does not matter how bad it is - the
variables are poorly correlated), I need to predict the next value 

 

 predict(fit.a,xt[j,])

Error in eval(predvars, data, env) : 

  numeric 'envir' arg not of length one

 

It seems that predict needs a dataframe class but even if I change xt[b,] to
as.data.frame(xt[b,]) the result is not what I expect.

 

 predict(fit.a,as.data.frame(t(xt[j,])))

1 2 3 4 5 6 7
8 

0.7834919 0.8243357 0.7780093 0.7810451 0.8084342 0.8057823 1.0304123
0.9729126 

910 

0.7708979 0.8464298 

Warning message:

'newdata' had 1 rows but variable(s) found have 10 rows

 

My feeling is that I did not understand how to enter the formula in lm in
the first place.

 

Many thanks

 

Ed

 


[[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 on how to use predict

2011-08-15 Thread Eduardo M. A. M.Mendes
Hi there

Many thanks.   I will try to follow what you two said.  

Meanwhile I use the dirty solution that I have just come across.

Cheers

Ed


-Original Message-
From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] 
Sent: Monday, August 15, 2011 1:36 PM
To: David Winsemius
Cc: Eduardo M. A. M.Mendes; r-help@r-project.org
Subject: Re: [R] Help on how to use predict

On 11-08-15 12:21 PM, David Winsemius wrote:
 Eduardo;

 I think you would be more successful if you put your data in a 
 dataframe, offered it to lm with column names only in the formula, and 
 then used the newdata argument with predict with the column names 
 matching the column names in the original data.


I agree.  You can use the subset argument to lm to choose your local
window.

Duncan Murdoch

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


[R] Regression - how to deal with past values?

2011-08-15 Thread Eduardo M. A. M.Mendes
Dear R-users

 

I need to fit a nonlinear model to a piece of data. The model to be fitted
uses past values of the input and the ouput - something like

y(k) ~ f(y(k-1),y(k-2),u(k),u(k-1) ) (k is time index).  As far as I
know I could use earth(MARS), nnet and etc but I am not sure how to deal
with the past values since most, if not all, examples I saw formula does not
take in account past values of any input (let alone output).

 

Is there any package available that deals with this type of regression?  (ar
(linear) is not what I am looking for).

 

Is there any example out there that I can follow?  I have searched the web
using words such as fitting and past values but I could not find what I
want.

 

Many thanks

 

Ed

 


[[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] Regression - how to deal with past values?

2011-08-15 Thread Eduardo M. A. M.Mendes
Many thanks but I am not  looking for a remote consulting.

Actually it is not difficult but unfortunately I am a newbie as far as
writing functions on R.  

Can I gather from your email that there is nothing available on R that deals
with dynamic models (k-step ahead and free-run)?

Cheers

Ed


-Original Message-
From: Bert Gunter [mailto:gunter.ber...@gene.com] 
Sent: Monday, August 15, 2011 7:42 PM
To: Eduardo M. A. M.Mendes
Cc: r-help@r-project.org
Subject: Re: [R] Regression - how to deal with past values?

This may not be helpful, but this sounds difficult enough that you should
work with a local statistician rather than trying to get remote consulting
here.

-- Bert

On Mon, Aug 15, 2011 at 3:00 PM, Eduardo M. A. M.Mendes
emammen...@gmail.com wrote:
 Dear R-users



 I need to fit a nonlinear model to a piece of data. The model to be 
 fitted uses past values of the input and the ouput - something like

 y(k) ~ f(y(k-1),y(k-2),u(k),u(k-1) ) (k is time index).  As far as 
 I know I could use earth(MARS), nnet and etc but I am not sure how to 
 deal with the past values since most, if not all, examples I saw 
 formula does not take in account past values of any input (let alone
output).



 Is there any package available that deals with this type of 
 regression?  (ar
 (linear) is not what I am looking for).



 Is there any example out there that I can follow?  I have searched the 
 web using words such as fitting and past values but I could not find 
 what I want.



 Many thanks



 Ed




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




--
Men by nature long to get on to the ultimate truths, and will often be
impatient with elementary studies or fight shy of them. If it were possible
to reach the ultimate truths without the elementary studies usually prefixed
to them, these would not be preparatory studies but superfluous diversions.

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics
467-7374

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


[R] Plot.xts - how to change the x-axis labels to show weekly labels.

2011-07-30 Thread Eduardo M. A. M.Mendes
Dear R-users

 

I am new to R and struggling not to bother the list with silly questions.

 

I read the documentation on xts and searched for some examples over the
internet on how to use plot.xts.  

 

The xts object is as follows

 

dataxts : An 'xts' object from 2010-06-27 to 2010-08-05 containing:

  Data: num [1:56161, 1:14] 74 74.2 74.2 74.1 73.9 ...

  Indexed by objects of class: [POSIXct,POSIXt] TZ: 

  xts Attributes:  

 NULL

 

The time index goes from 2010-06-27 to 2010-08-05 hourly, that is, there are
56151 time stamps.  If I issue plot.xts(dataxts[,1]) a graphics window comes
out with the following x labels:

 

Jun 27 00:00, Jul 11 21:00, Jul 25 21:00, Aug 05  00:00

 

I could not figure out how to change the number of ticks so that the time
stamps (major ticks) are shown weekly and the minor ticks daily.  Besides, I
wonder whether the labels could be show as follows:

 

Jun 27   Jul 11   Jul 25  Aug 05 (just as example)

00:00 21:00   21:00  00:00

 

Thanks for your help and patience.

 

Cheers

 

Ed

 


[[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] Plot.xts - how to change the x-axis labels to show weekly labels.

2011-07-30 Thread Eduardo M. A. M.Mendes
Hi Joshua

Many thanks.

library(Hmisc);
 plot.xts(x,major.ticks=weeks,major.format=%b/%d %H:%M:%S);
 minor.tick(nx=7);

The above  commands give me almost what I need. I just need to figure out
how to split the labels in two lines (without using ggplot2)

Cheers

Ed



-Original Message-
From: Joshua Ulrich [mailto:josh.m.ulr...@gmail.com] 
Sent: Saturday, July 30, 2011 1:09 PM
To: Eduardo M. A. M.Mendes
Cc: r-help@r-project.org
Subject: Re: [R] Plot.xts - how to change the x-axis labels to show weekly
labels.

Hi Eduardo,

I'm not too familiar with plot.xts, but this answers 2/3 of your requests.
R plot(x, major.ticks=weeks, major.format=%b %d)

plot.zoo is quite a bit more flexible and has a lot of examples in
?plot.zoo.  Combining plot.zoo with endpoints should be able to give you
what you want.

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



On Sat, Jul 30, 2011 at 9:10 AM, Eduardo M. A. M.Mendes
emammen...@gmail.com wrote:
 Dear R-users



 I am new to R and struggling not to bother the list with silly questions.



 I read the documentation on xts and searched for some examples over 
 the internet on how to use plot.xts.



 The xts object is as follows



 dataxts : An 'xts' object from 2010-06-27 to 2010-08-05 containing:

  Data: num [1:56161, 1:14] 74 74.2 74.2 74.1 73.9 ...

  Indexed by objects of class: [POSIXct,POSIXt] TZ:

  xts Attributes:

  NULL



 The time index goes from 2010-06-27 to 2010-08-05 hourly, that is, 
 there are
 56151 time stamps.  If I issue plot.xts(dataxts[,1]) a graphics window 
 comes out with the following x labels:



 Jun 27 00:00, Jul 11 21:00, Jul 25 21:00, Aug 05  00:00



 I could not figure out how to change the number of ticks so that the 
 time stamps (major ticks) are shown weekly and the minor ticks daily.  
 Besides, I wonder whether the labels could be show as follows:



 Jun 27       Jul 11   Jul 25  Aug 05 (just as example)

 00:00         21:00   21:00  00:00



 Thanks for your help and patience.



 Cheers



 Ed




        [[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 to use as.Date (or something else) with 31-Jul-2010 23:59:00

2011-07-28 Thread Eduardo M. A. M.Mendes
Hello

Many thanks.

Sorry for not replying earlier but I have followed advice and read as much
documentation as I could.

I managed to get a zoo object the way I want

dadoszoo : 'zoo' series from 2010-06-27 to 2010-08-05
  Data: num [1:56161, 1:14] 74 74.2 74.2 74.1 73.9 ...
  Index:  POSIXct[1:56161], format: 2010-06-27 00:00:00 2010-06-27
00:01:00 ...

I did not manage to get  plot.zoo to give x-axis a nice format (I only got
Jun 30 Jul10 Jul 20 Jul 30).  I guess the way to change it is the
documentation too but I am yet to find it.

Many thanks

Ed


-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] 
Sent: Tuesday, July 26, 2011 8:31 PM
To: Eduardo Mendes
Cc: r-help@r-project.org
Subject: Re: [R] How to use as.Date (or something else) with 31-Jul-2010
23:59:00

On Tue, Jul 26, 2011 at 7:18 PM, Eduardo Mendes emammen...@gmail.com
wrote:
 Hello  again

 I do apologize for the previous email without any useful information 
 that can lead to an answer.  To those who felt offended by to no 
 avail, I do apologize again.  I guess I will be always a newbie as 
 far as R is concerned.


 The date format was wrong and although I have tried to use different 
 formats I could not get the result I wanted.  So I went back to the 
 file and changed to a format that R can understand (Please understand 
 that R is very likely to have package that I might be unaware of).  
 Now all dates are

 class(data$TempDate)
 [1] POSIXct POSIXt
 data$TempDate[1:2]
 [1] 2010-06-27 00:00:00 BRT 2010-06-27 00:01:00 BRT

 If I issue the command as.Date(data$TempDate[2]), the information on 
 hour, minute and second is lost

 as.Date(data$TempDate[2])
 [1] 2010-06-27

 If I use data$TempDate in a zoo object, I got the following msg

 some methods for zoo objects do not work if the index entries in
'order.by'
 are not unique

 If I issue plot(zoo object), the result is a mess since many values do 
 not have an unique entry (as expected).

 How can I use the information on data$TempDate to create unique 
 indexes for zoo objects and the like?


Read R News 4/1 and its references to find out about R's date time classes
and then read the 5 vignettes (PDF documents) that come with zoo for many
examples.

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

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


[R] How to use as.Date (or something else) with 31-Jul-2010 23:59:00

2011-07-26 Thread Eduardo M. A. M.Mendes
Hello

I have a huge file (not an R-file) in which the first column is a string
with date, hour, minutes and seconds (For instance, 31-Jul-2010 23:59:00).

I tried as.Date but the error msg was Error in charToDate(x) : 
  character string is not in a standard unambiguous format.   

I have checked the help for the function as well as date but to no avail.

How can that sort of string be transformed to something useful in R?

Many thanks

Ed

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


[R] Testing two independent samples for null of same skewness and kurtosis?

2011-07-23 Thread Eduardo M. A. M.Mendes
Hello

 

I wonder whether there is an r tool or package available for testing for the
null of same skewness or kurtosis of two independent samples.

 

It semes that nsRFA package uses L-moments for soothing similar but I could
not get how to use the package for the above test.

 

Any pointers, help, example and etc.  will be most welcome.

 

Many thanks

 

Ed

 

 

 


[[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] Using package amelia

2011-07-22 Thread Eduardo M. A. M.Mendes
Hello

 

I do not think I have fully grasped how to use Amelia to deal with missing
data.

 

For instance, suppose I have a data.frame variable with 4 columns (year,
mon, ssn, dev) = (year, month, measurements, standard deviation of the
measurement).  Of course, there are some  random missing values on columns 3
and 4.  The measurements are an almost periodic time-series contaminated by
noise.

 

I did some tests such as:

 

a.out - amelia(x, m = 5, ts = YEAR, p2s = 0, idvars=c(DEV));

 a.out - amelia(x, m = 5, ts = YEAR, p2s = 0, idvars=c(MON,DEV));

Error in matrix(1, AMn, 1) : non-numeric matrix extent

 

a.out - amelia(x, m = 5, ts = YEAR, p2s = 0);

 

a.out - amelia(x, m = 5, p2s = 0, idvars=c(MON,DEV));

 

If I got it right, idvars removes the columns from the imputation process.
Is that right?  

 

There is an option called cs (cross-section) but I have no idea what it
does. 

 

How can I use the information on column 4 to limit the values of the
estimates of the missing values?  Some of the results are extremely high.

 

Any pointers that help me to understand what is going on will be most
appreciated.

 

Many thanks

 

Ed

 


[[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] Inverse noncentral Beta

2011-04-03 Thread Eduardo M. A. M.Mendes
Hello

 

I could not find whether there is any R-function that implements the inverse
of a noncentral Beta. Could someone out there tell me where I can find it?
Or how to implement it?

 

Many thanks

 

Ed

 


[[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] An example of using neuralnet to predict infinite steps ahead

2011-03-13 Thread Eduardo M. A. M.Mendes
Hello

I am new to R and wonder whether someone out there could send me an example
on how to use the package neuralnet to fit a model to data, following the
usual procedure, that is, fitting the model using the training set and then
using the validation set to check the model.   Moreover, the neural net
model is recursive (uses its own output values)- infinite steps ahead
prediction. 

Many thanks

Ed

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
Hello

I have a matlab MAT file that contains one single variable: a.  The
structure of a is as follows:

a.river1.flow (flow values)
a.river1.date_flow (date)
a.river1.precip (precipitation values)
a.river1.date_precip
a.river2.flow
a.river2.date_flow
a.river2.precip
a.river2.date_precip

I have used readMat to load the variable a in R, however I have no idea how
readMat translates a.  I managed to get some values out of
data=readMat(matfile.mat)

data$a[,,1]$river1[,,1]$flow  - Why do I need [,,1]?  Why not
data$a$river1$flow?

Many thanks

Ed

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


Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
Hi Joshua

Many thanks for the prompt reply.

I have saved a short version of the matlab file and the output on R is

 b=readMat(testr.mat)
 b
$a
, , 1

   [,1]  
river1 List,2
river2 List,2


attr(,header)
attr(,header)$description
[1] MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13 18:51:54 2011 
 

attr(,header)$version
[1] 5

attr(,header)$endian
[1] little

When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow values.

Unfortunately the data is confidential.

Many thanks

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] 
Sent: Sunday, March 13, 2011 6:30 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

Hi Ed,

Can you please provide *at least* the R output from running:

str(data)

where data is the variable name you stored the results of readMat() in.  If 
it is reasonably small and can be sent as plaintext (I do not know Matlabs file 
format off hand), you could send us the actual data so we can try to read it 
in, but at the least str() will let us see how R is storing your data and give 
you some explanation.

Side note, as data() is a function, it might be worthwhile to call your actual 
data something else (say, mydata, dat, etc.).  For anyone else interested, 
readMat() is in package R.matlab.

Cheers,

Josh

On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes emammen...@gmail.com 
wrote:
 Hello

 I have a matlab MAT file that contains one single variable: a.  The 
 structure of a is as follows:

 a.river1.flow (flow values)
 a.river1.date_flow (date)
 a.river1.precip (precipitation values) a.river1.date_precip 
 a.river2.flow a.river2.date_flow a.river2.precip a.river2.date_precip

 I have used readMat to load the variable a in R, however I have no 
 idea how readMat translates a.  I managed to get some values out of
 data=readMat(matfile.mat)

 data$a[,,1]$river1[,,1]$flow  - Why do I need [,,1]?  Why not 
 data$a$river1$flow?

 Many thanks

 Ed

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




--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes

Hi Joshua

Many thanks.  

The values of flow can be accessed in a weird way and we can used them for some 
calculations.  Since I am a newbie as far as using R is concerned I wonder 
whether you could tell me how to create a structure in R that looks like the 
one I have in matlab (that is, a variable a that contains river1 and river2 
that contains flow and precipitation).

Cheers

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] 
Sent: Sunday, March 13, 2011 7:20 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes emammen...@gmail.com 
wrote:
 Hi Joshua

 Many thanks for the prompt reply.

 I have saved a short version of the matlab file and the output on R is

 b=readMat(testr.mat)
 b
 $a
 , , 1

   [,1]
 river1 List,2
 river2 List,2

It looks like you are dealing with a special series of lists nested within 
three dimensional arrays within lists.  My suggestion would be to double check 
that the matlab file has reasonable data (whatever that means) and try to 
double check your use of readmat (do you meet all the requirements for 
versions, etc.).  That is not a common R structure so the extraction is 
similarly uncommon.  Perhaps Henrik will be along with more helpful answers.

Good luck,

Josh


 attr(,header)
 attr(,header)$description
 [1] MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13 18:51:54 
 2011  

 attr(,header)$version
 [1] 5

 attr(,header)$endian
 [1] little

 When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow values.

 Unfortunately the data is confidential.

 Many thanks

 Ed


 -Original Message-
 From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
 Sent: Sunday, March 13, 2011 6:30 PM
 To: Eduardo M. A. M.Mendes
 Cc: R-help@r-project.org
 Subject: Re: [R] readMat - how to retrieve the variables

 Hi Ed,

 Can you please provide *at least* the R output from running:

 str(data)

 where data is the variable name you stored the results of readMat() in.  If 
 it is reasonably small and can be sent as plaintext (I do not know Matlabs 
 file format off hand), you could send us the actual data so we can try to 
 read it in, but at the least str() will let us see how R is storing your data 
 and give you some explanation.

 Side note, as data() is a function, it might be worthwhile to call your 
 actual data something else (say, mydata, dat, etc.).  For anyone else 
 interested, readMat() is in package R.matlab.

 Cheers,

 Josh

 On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes 
 emammen...@gmail.com wrote:
 Hello

 I have a matlab MAT file that contains one single variable: a.  The 
 structure of a is as follows:

 a.river1.flow (flow values)
 a.river1.date_flow (date)
 a.river1.precip (precipitation values) a.river1.date_precip 
 a.river2.flow a.river2.date_flow a.river2.precip a.river2.date_precip

 I have used readMat to load the variable a in R, however I have no 
 idea how readMat translates a.  I managed to get some values out of
 data=readMat(matfile.mat)

 data$a[,,1]$river1[,,1]$flow  - Why do I need [,,1]?  Why not 
 data$a$river1$flow?

 Many thanks

 Ed

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

--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
Hi Joshua

Many many thanks.

Cheers

Ed


-Original Message-
From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] 
Sent: Sunday, March 13, 2011 8:00 PM
To: Eduardo M. A. M.Mendes
Cc: R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables

Hi Ed,

Here are some different ways of structuring and storing data in R as well as 
how to access them.

Hope this helps,

Josh

#

set.seed(10)
## Option 1a (closest to what you want?) a1a - list(river1 = data.frame(flow = 
1:10, precipitation = runif(10)),
  river2 = data.frame(flow = 11:20, precipitation = runif(10)))

set.seed(10)
## Option 1b (a slight variant), lists + named vectors a1b - list(river1 = 
list(flow = 1:10, precipitation = runif(10)),
  river2 = list(flow = 11:20, precipitation = runif(10)))

set.seed(10)
## Option 2 (a.k.a. 'long' format)
a2 - data.frame(flow = 1:20, precipitation = runif(20),
  river = factor(rep(1:2, each = 10)))

set.seed(10)
## Option 3 (a.k.a. 'wide' format)
a3 - data.frame(r1.flow = 1:10, r2.flow = 11:20,
  r1.precipitation = runif(10), r2.precipitation = runif(10))

## compare the str()uctures of all four objects

str(a1a)
str(a1b)
str(a2)
str(a3)

## Access flow from river1 in option 1a ## four equivalent options 
a1a$river1$flow a1a[[river1]][,flow] a1a[[1]][, 1] a1a[[c(1, 1)]]

## Option 1b
a1b$river1$flow ## works
a1b[[1]][, 1] ## does not work, used vectors not a dataframe a1b[[c(1, 1)]] ## 
works

## Option 2
a2$flow ## both rivers' flow, useful for plotting a2[, 1] a2[, flow] ## for 
example:
require(lattice)
xyplot(flow ~ precipitation | river, data = a2)

## Option 3
a3$r1.flow
a3[, 1]
a3[, r1.flow]

##

On Sun, Mar 13, 2011 at 3:42 PM, Eduardo M. A. M.Mendes emammen...@gmail.com 
wrote:

 Hi Joshua

 Many thanks.

 The values of flow can be accessed in a weird way and we can used them for 
 some calculations.  Since I am a newbie as far as using R is concerned I 
 wonder whether you could tell me how to create a structure in R that looks 
 like the one I have in matlab (that is, a variable a that contains river1 and 
 river2 that contains flow and precipitation).

 Cheers

 Ed


 -Original Message-
 From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
 Sent: Sunday, March 13, 2011 7:20 PM
 To: Eduardo M. A. M.Mendes
 Cc: R-help@r-project.org
 Subject: Re: [R] readMat - how to retrieve the variables

 On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes 
 emammen...@gmail.com wrote:
 Hi Joshua

 Many thanks for the prompt reply.

 I have saved a short version of the matlab file and the output on R 
 is

 b=readMat(testr.mat)
 b
 $a
 , , 1

   [,1]
 river1 List,2
 river2 List,2

 It looks like you are dealing with a special series of lists nested within 
 three dimensional arrays within lists.  My suggestion would be to double 
 check that the matlab file has reasonable data (whatever that means) and try 
 to double check your use of readmat (do you meet all the requirements for 
 versions, etc.).  That is not a common R structure so the extraction is 
 similarly uncommon.  Perhaps Henrik will be along with more helpful answers.

 Good luck,

 Josh


 attr(,header)
 attr(,header)$description
 [1] MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13 18:51:54 
 2011  

 attr(,header)$version
 [1] 5

 attr(,header)$endian
 [1] little

 When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow values.

 Unfortunately the data is confidential.

 Many thanks

 Ed


 -Original Message-
 From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
 Sent: Sunday, March 13, 2011 6:30 PM
 To: Eduardo M. A. M.Mendes
 Cc: R-help@r-project.org
 Subject: Re: [R] readMat - how to retrieve the variables

 Hi Ed,

 Can you please provide *at least* the R output from running:

 str(data)

 where data is the variable name you stored the results of readMat() in.  
 If it is reasonably small and can be sent as plaintext (I do not know 
 Matlabs file format off hand), you could send us the actual data so we can 
 try to read it in, but at the least str() will let us see how R is storing 
 your data and give you some explanation.

 Side note, as data() is a function, it might be worthwhile to call your 
 actual data something else (say, mydata, dat, etc.).  For anyone else 
 interested, readMat() is in package R.matlab.

 Cheers,

 Josh

 On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes 
 emammen...@gmail.com wrote:
 Hello

 I have a matlab MAT file that contains one single variable: a.  The 
 structure of a is as follows:

 a.river1.flow (flow values)
 a.river1.date_flow (date)
 a.river1.precip (precipitation values) a.river1.date_precip 
 a.river2.flow a.river2.date_flow a.river2.precip 
 a.river2.date_precip

 I have used readMat to load the variable a in R, however I have no 
 idea how

Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
Hello there

Here is the output of the command

structure(list(a =
structure(list(structure(list(structure(c(16.259746877453, 
17.7125316239611, 17.7801266531401, 18.7370886410339, 18.5622784910323, 
19. 

), .Dim = c(3683L, 1L)), structure(c(0, 0, 6.7, 46.1, 2, 0, 29.5, 
93.7, 4.5, 39.6, 1.4, 5.5, 9, 12.2, 5.7, 0, 0, 0, 0, 8, 0, 19.5, 
30 

), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = list(
c(flow, precip), NULL, NULL)), structure(list(structure(c(42, 
42, 44, 60, 84, 97, 113, 357, 613, 495, 401, 295, 250, 228, 202, 
174 

12, 36, 0, 2, 0, 6, 13, 0, 1, 0, 12, 0, 0, 32, 0, 0, 1, 36, 7, 
36, 48, 27, 7), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames =
list(
c(flow, precip), NULL, NULL))), .Dim = c(2L, 1L, 1L), .Dimnames =
list(
c(river1, river2), NULL, NULL))), .Names = a, header =
structure(list(
description = MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar
13 18:51:54 2011  , 
version = 5, endian = little), .Names = c(description, 
version, endian)))

Cheers

Ed


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Sunday, March 13, 2011 8:01 PM
To: Eduardo M. A. M.Mendes
Cc: 'Joshua Wiley'; R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables


On Mar 13, 2011, at 6:42 PM, Eduardo M. A. M.Mendes wrote:


 Hi Joshua

 Many thanks.

 The values of flow can be accessed in a weird way and we can used them 
 for some calculations.  Since I am a newbie as far as using R is 
 concerned I wonder whether you could tell me how to create a structure 
 in R that looks like the one I have in matlab (that is, a variable a 
 that contains river1 and river2 that contains flow and precipitation).

If you posted the results of dput(a) ,  we might be able to test our pet
theories, but here is my hapless first guess:

mat.R.struc - with(b$a[,,1],   #looks like it was a matrix that had  
lists as elements
  cbind(as.data.frame(river1), as.data.frame(river2) )
 )

It's not so much that it will look like your Matlab structure, but it
could be something that you can work with. This will create a long- format
structure which is a typical one for plotting ans regression.  
Another option would be an R array which, unlike matrices, can have more
than 2 dimensions.



 Cheers

 Ed


 -Original Message-
 From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
 Sent: Sunday, March 13, 2011 7:20 PM
 To: Eduardo M. A. M.Mendes
 Cc: R-help@r-project.org
 Subject: Re: [R] readMat - how to retrieve the variables

 On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes 
 emammen...@gmail.com
  wrote:
 Hi Joshua

 Many thanks for the prompt reply.

 I have saved a short version of the matlab file and the output on R 
 is

 b=readMat(testr.mat)
 b
 $a
 , , 1

  [,1]
 river1 List,2
 river2 List,2

 It looks like you are dealing with a special series of lists nested 
 within three dimensional arrays within lists.  My suggestion would be 
 to double check that the matlab file has reasonable data (whatever 
 that means) and try to double check your use of readmat (do you meet 
 all the requirements for versions, etc.).  That is not
 a common R structure so the extraction is similarly uncommon.   
 Perhaps Henrik will be along with more helpful answers.

 Good luck,

 Josh


 attr(,header)
 attr(,header)$description
 [1] MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13  
 18:51:54 2011  

 attr(,header)$version
 [1] 5

 attr(,header)$endian
 [1] little

 When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow 
 values.

 Unfortunately the data is confidential.

 Many thanks

 Ed


 -Original Message-
 From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
 Sent: Sunday, March 13, 2011 6:30 PM
 To: Eduardo M. A. M.Mendes
 Cc: R-help@r-project.org
 Subject: Re: [R] readMat - how to retrieve the variables

 Hi Ed,

 Can you please provide *at least* the R output from running:

 str(data)

 where data is the variable name you stored the results of
 readMat() in.  If it is reasonably small and can be sent as plaintext 
 (I do not know Matlabs file format off hand), you could send us the 
 actual data so we can try to read it in, but at the least str() will 
 let us see how R is storing your data and give you some explanation.

 Side note, as data() is a function, it might be worthwhile to call 
 your actual data something else (say, mydata, dat, etc.).  For anyone 
 else interested, readMat() is in package R.matlab.

 Cheers,

 Josh

 On Sun, Mar 13, 2011 at 2:07 PM, Eduardo M. A. M.Mendes 
 emammen...@gmail.com
  wrote:
 Hello

 I have a matlab MAT file that contains one single variable: a.  The 
 structure of a is as follows:

 a.river1.flow (flow values)
 a.river1.date_flow (date)
 a.river1.precip (precipitation values) a.river1.date_precip 
 a.river2.flow

Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
Hi there

...   means that I have not copied all the data that R showed on the screen.

Cheers

Ed


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Sunday, March 13, 2011 8:37 PM
To: Eduardo M. A. M.Mendes
Cc: 'Joshua Wiley'; R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables


On Mar 13, 2011, at 7:27 PM, Eduardo M. A. M.Mendes wrote:

 Hello there

 Here is the output of the command

 structure(list(a =
 structure(list(structure(list(structure(c(16.259746877453,
 17.7125316239611, 17.7801266531401, 18.7370886410339, 
 18.5622784910323, 19. 

That seems pretty unlikely. All of those  are not in the output from
dput are they? The dimension of 3683 implies otherwise.

 
 ), .Dim = c(3683L, 1L)), structure(c(0, 0, 6.7, 46.1, 2, 0, 29.5, 
 93.7, 4.5, 39.6, 1.4, 5.5, 9, 12.2, 5.7, 0, 0, 0, 0, 8, 0, 19.5,
 30 
 
 ), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = list(
c(flow, precip), NULL, NULL)), structure(list(structure(c(42, 
 42, 44, 60, 84, 97, 113, 357, 613, 495, 401, 295, 250, 228, 202,
 174 
 
 12, 36, 0, 2, 0, 6, 13, 0, 1, 0, 12, 0, 0, 32, 0, 0, 1, 36, 7, 36, 48, 
 27, 7), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = list(
c(flow, precip), NULL, NULL))), .Dim = c(2L, 1L, 1L), .Dimnames 
 = list(
c(river1, river2), NULL, NULL))), .Names = a, header = 
 structure(list(
description = MATLAB 5.0 MAT-file, Platform: PCWIN, Created on:  
 Sun Mar
 13 18:51:54 2011  ,
version = 5, endian = little), .Names = c(description, 
 version, endian)))

 Cheers

 Ed


 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Sunday, March 13, 2011 8:01 PM
 To: Eduardo M. A. M.Mendes
 Cc: 'Joshua Wiley'; R-help@r-project.org
 Subject: Re: [R] readMat - how to retrieve the variables


 On Mar 13, 2011, at 6:42 PM, Eduardo M. A. M.Mendes wrote:


 Hi Joshua

 Many thanks.

 The values of flow can be accessed in a weird way and we can used 
 them for some calculations.  Since I am a newbie as far as using R is 
 concerned I wonder whether you could tell me how to create a 
 structure in R that looks like the one I have in matlab (that is, a 
 variable a that contains river1 and river2 that contains flow and 
 precipitation).

 If you posted the results of dput(a) ,  we might be able to test our 
 pet theories, but here is my hapless first guess:

 mat.R.struc - with(b$a[,,1],   #looks like it was a matrix that had
 lists as elements
  cbind(as.data.frame(river1), as.data.frame(river2) )
 )

 It's not so much that it will look like your Matlab structure, but 
 it could be something that you can work with. This will create a long- 
 format structure which is a typical one for plotting ans regression.
 Another option would be an R array which, unlike matrices, can have 
 more than 2 dimensions.



 Cheers

 Ed


 -Original Message-
 From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
 Sent: Sunday, March 13, 2011 7:20 PM
 To: Eduardo M. A. M.Mendes
 Cc: R-help@r-project.org
 Subject: Re: [R] readMat - how to retrieve the variables

 On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes 
 emammen...@gmail.com
 wrote:
 Hi Joshua

 Many thanks for the prompt reply.

 I have saved a short version of the matlab file and the output on R 
 is

 b=readMat(testr.mat)
 b
 $a
 , , 1

 [,1]
 river1 List,2
 river2 List,2

 It looks like you are dealing with a special series of lists nested 
 within three dimensional arrays within lists.  My suggestion would be 
 to double check that the matlab file has reasonable data (whatever 
 that means) and try to double check your use of readmat (do you meet 
 all the requirements for versions, etc.).  That is not a common R 
 structure so the extraction is similarly uncommon.
 Perhaps Henrik will be along with more helpful answers.

 Good luck,

 Josh


 attr(,header)
 attr(,header)$description
 [1] MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13
 18:51:54 2011  

 attr(,header)$version
 [1] 5

 attr(,header)$endian
 [1] little

 When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow 
 values.

 Unfortunately the data is confidential.

 Many thanks

 Ed


 -Original Message-
 From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
 Sent: Sunday, March 13, 2011 6:30 PM
 To: Eduardo M. A. M.Mendes
 Cc: R-help@r-project.org
 Subject: Re: [R] readMat - how to retrieve the variables

 Hi Ed,

 Can you please provide *at least* the R output from running:

 str(data)

 where data is the variable name you stored the results of
 readMat() in.  If it is reasonably small and can be sent as 
 plaintext (I do not know Matlabs file format off hand), you could 
 send us the actual data so we can try to read it in, but at the 
 least str() will let us see how R is storing your data

Re: [R] readMat - how to retrieve the variables

2011-03-13 Thread Eduardo M. A. M.Mendes
So sorry but the data is confidential.

Cheers

Ed


-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Sunday, March 13, 2011 9:16 PM
To: Eduardo M. A. M.Mendes
Cc: 'Joshua Wiley'; R-help@r-project.org
Subject: Re: [R] readMat - how to retrieve the variables


On Mar 13, 2011, at 7:48 PM, Eduardo M. A. M.Mendes wrote:

 Hi there

 ...   means that I have not copied all the data that R showed on the  
 screen.

I fail to see the point in posting mangled dput output.

--
David.

 Cheers

 Ed


 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Sunday, March 13, 2011 8:37 PM
 To: Eduardo M. A. M.Mendes
 Cc: 'Joshua Wiley'; R-help@r-project.org
 Subject: Re: [R] readMat - how to retrieve the variables


 On Mar 13, 2011, at 7:27 PM, Eduardo M. A. M.Mendes wrote:

 Hello there

 Here is the output of the command

 structure(list(a =
 structure(list(structure(list(structure(c(16.259746877453,
 17.7125316239611, 17.7801266531401, 18.7370886410339, 
 18.5622784910323, 19. 

 That seems pretty unlikely. All of those  are not in the output 
 from dput are they? The dimension of 3683 implies otherwise.

 
 ), .Dim = c(3683L, 1L)), structure(c(0, 0, 6.7, 46.1, 2, 0, 29.5, 
 93.7, 4.5, 39.6, 1.4, 5.5, 9, 12.2, 5.7, 0, 0, 0, 0, 8, 0, 19.5,
 30 
 
 ), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = list(
   c(flow, precip), NULL, NULL)), structure(list(structure(c(42, 
 42, 44, 60, 84, 97, 113, 357, 613, 495, 401, 295, 250, 228, 202,
 174 
 
 12, 36, 0, 2, 0, 6, 13, 0, 1, 0, 12, 0, 0, 32, 0, 0, 1, 36, 7, 36, 
 48, 27, 7), .Dim = c(3683L, 1L))), .Dim = c(2L, 1L, 1L), .Dimnames = 
 list(
   c(flow, precip), NULL, NULL))), .Dim = c(2L, 1L, 1L), .Dimnames 
 = list(
   c(river1, river2), NULL, NULL))), .Names = a, header = 
 structure(list(
   description = MATLAB 5.0 MAT-file, Platform: PCWIN, Created on:
 Sun Mar
 13 18:51:54 2011  ,
   version = 5, endian = little), .Names = c(description, 
 version, endian)))

 Cheers

 Ed


 -Original Message-
 From: David Winsemius [mailto:dwinsem...@comcast.net]
 Sent: Sunday, March 13, 2011 8:01 PM
 To: Eduardo M. A. M.Mendes
 Cc: 'Joshua Wiley'; R-help@r-project.org
 Subject: Re: [R] readMat - how to retrieve the variables


 On Mar 13, 2011, at 6:42 PM, Eduardo M. A. M.Mendes wrote:


 Hi Joshua

 Many thanks.

 The values of flow can be accessed in a weird way and we can used 
 them for some calculations.  Since I am a newbie as far as using R 
 is concerned I wonder whether you could tell me how to create a 
 structure in R that looks like the one I have in matlab (that is, a 
 variable a that contains river1 and river2 that contains flow and 
 precipitation).

 If you posted the results of dput(a) ,  we might be able to test our 
 pet theories, but here is my hapless first guess:

 mat.R.struc - with(b$a[,,1],   #looks like it was a matrix that had
 lists as elements
 cbind(as.data.frame(river1), as.data.frame(river2) )
)

 It's not so much that it will look like your Matlab structure, but 
 it could be something that you can work with. This will create a
 long-
 format structure which is a typical one for plotting ans regression.
 Another option would be an R array which, unlike matrices, can have 
 more than 2 dimensions.



 Cheers

 Ed


 -Original Message-
 From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
 Sent: Sunday, March 13, 2011 7:20 PM
 To: Eduardo M. A. M.Mendes
 Cc: R-help@r-project.org
 Subject: Re: [R] readMat - how to retrieve the variables

 On Sun, Mar 13, 2011 at 2:56 PM, Eduardo M. A. M.Mendes 
 emammen...@gmail.com
 wrote:
 Hi Joshua

 Many thanks for the prompt reply.

 I have saved a short version of the matlab file and the output on R 
 is

 b=readMat(testr.mat)
 b
 $a
 , , 1

[,1]
 river1 List,2
 river2 List,2

 It looks like you are dealing with a special series of lists nested 
 within three dimensional arrays within lists.  My suggestion would 
 be to double check that the matlab file has reasonable data 
 (whatever that means) and try to double check your use of readmat 
 (do you meet all the requirements for versions, etc.).  That is not 
 a common R structure so the extraction is similarly uncommon.
 Perhaps Henrik will be along with more helpful answers.

 Good luck,

 Josh


 attr(,header)
 attr(,header)$description
 [1] MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Mar 13
 18:51:54 2011  

 attr(,header)$version
 [1] 5

 attr(,header)$endian
 [1] little

 When I issue the command b$a[,,1]$river1[,,1]$flow  I see the flow 
 values.

 Unfortunately the data is confidential.

 Many thanks

 Ed


 -Original Message-
 From: Joshua Wiley [mailto:jwiley.ps...@gmail.com]
 Sent: Sunday, March 13, 2011 6:30 PM
 To: Eduardo M. A. M.Mendes
 Cc: R-help@r-project.org
 Subject: Re: [R

[R] Where can I find library rmutil?

2010-04-17 Thread Eduardo M. A. M.Mendes
Hello

I wonder whether I can find rmutil (it seem to be part of rcode or something
like that)?

Many thanks

Ed

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


Re: [R] Where can I find library rmutil?

2010-04-17 Thread Eduardo M. A. M.Mendes
Just after posting the question I stumbled at the site you've mentioned.

 

Many thanks

 

Ed

 

 

From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] 
Sent: Saturday, April 17, 2010 8:00 PM
To: Eduardo M. A. M.Mendes
Cc: r-h...@stat.math.ethz.ch
Subject: Re: [R] Where can I find library rmutil?

 

I believe you are referencing the rmutil by Lindsey.  See his website (
http://www.commanster.eu/rcode.html ).

 

Josh

On Sat, Apr 17, 2010 at 3:44 PM, Eduardo M. A. M.Mendes
emammen...@gmail.com wrote:

Hello

I wonder whether I can find rmutil (it seem to be part of rcode or something
like that)?

Many thanks

Ed

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


[[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] Problems with xyplot

2010-02-17 Thread Eduardo M. A. M.Mendes
Hello

 

I wonder whether someone can tell me what I am doing wrong.  Here is the
code (from Bayesian Computation with R - Chapter 2.3.R) that I am trying to
run 

 



# Section 2.3 Using a Discrete Prior



 

 graphics.off() # Close all graphics

 rm(list=ls())  # Clear all variables

 

 library(LearnBayes)

 library(lattice)

 

 p = seq(0.05, 0.95, by = 0.1)

 prior = c(1, 5.2, 8, 7.2, 4.6, 2.1, 0.7, 0.1, 0, 0)

 prior = prior/sum(prior)

 windows()

 plot(p, prior, type = h, ylab=Prior Probability)

 

 post = pdisc(p, prior,c(11, 16))

 print(round(cbind(p, prior, post),2))

 

 # Lattice Library

 PRIOR=data.frame(prior,p,prior)

 POST=data.frame(posterior,p,post)

 names(PRIOR)=c(Type,P,Probability)

 names(POST)=c(Type,P,Probability)

 xydata=rbind(PRIOR,POST)

 

 windows()

 
xyplot(Probability~P|Type,data=xydata,layout=c(1,2),type=h,lwd=3,col=blac
k)  # Last command

 

Although there is no warning or error msg after running the code
(source(Chapter.2.3.R), nothing shows up on the second window. However
when I issue the last command after the prompt on the command line a
graphics shows up.  What could be wrong?

 

Many thanks

 

Ed

 

 

 

 

 


[[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] Problems with xyplot

2010-02-17 Thread Eduardo M. A. M.Mendes
Yes, you were right.  Although I have browsed the FAQ I did not connect the
dots ... 

Many thanks

Ed.




-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Wednesday, February 17, 2010 8:22 PM
To: Eduardo M. A. M.Mendes
Cc: r-help@r-project.org
Subject: Re: [R] Problems with xyplot


On Feb 17, 2010, at 5:07 PM, Eduardo M. A. M.Mendes wrote:

 Hello

 I wonder whether someone can tell me what I am doing wrong.  Here is  
 the
 code (from Bayesian Computation with R - Chapter 2.3.R) that I am  
 trying to
 run

 

library(lattice)

 snipped code and many empty lines

  windows()
 xyplot(Probability~P| 
 Type,data=xydata,layout=c(1,2),type=h,lwd=3,col=blac
 k)  # Last command

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-grap
hics-not-work_003f

 Although there is no warning or error msg after running the code
 (source(Chapter.2.3.R), nothing shows up on the second window.  
 However
 when I issue the last command after the prompt on the command line a
 graphics shows up.  What could be wrong?

Failure to RTF?

-- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


Re: [R] R_USER - in which file should I include it?

2008-09-09 Thread Eduardo M. A. M.Mendes
Hello

Many thanks.  It works just fine.

How about the packages issue?  That is, same thing for the installation
path.

Cheers

Ed


-Original Message-
From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 08, 2008 10:01 PM
To: Eduardo M. A. M.Mendes
Cc: r-help@r-project.org
Subject: Re: [R] R_USER - in which file should I include it?

Try adding this at the end of your etc/Rprofile.site file.  That file
should already be there so you don't have to create it,
just edit it.

cat(Hello from Rprofile.site\n)
setwd(C:/Users/eduardo/Documents)

You may need to edit it as Administrator.   You should
see the Hello message in which case you will know that the
Rprofile.site file is being run.

That should work unless Tinn-R runs R in such a way as to
ignore Rprofile.site.

On Mon, Sep 8, 2008 at 8:11 PM, Eduardo M. A. M.Mendes
[EMAIL PROTECTED] wrote:
 Hello

 I am not sure whether R starts from the same dir.  For instance:

 a) if I double-click on R-2.7.2 icon and then issue the command getwd(),
the
 result is:

 getwd()
 [1] C:/Users/eduardo/Documents

 b) If R starts from within Tinn-R, the result is:

 getwd()
 [1] C:/Program Files/R/R-2/bin

 I want that no matter which calling R method I am using if I issue the
 command getwd() (first command) the result is:

 C:/Users/eduardo/Documents/R


 Moreover all new packages go to C:/Users/eduardo/Documents/R/win-library


 Thanks

 Ed

 -Original Message-
 From: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
 Sent: Monday, September 08, 2008 8:57 PM
 To: Eduardo M. A. M.Mendes
 Cc: r-help@r-project.org
 Subject: Re: [R] R_USER - in which file should I include it?

 Could you explain more clearly what you mean by the same?
 Do you mean that each time you click on R 2.7.2 icon on your
 desktop that running this from the R console:

 getwd()

 is the same directory on each startup?  Isn't that already the case?
 I don't think you need to set any environment variables at all.  If
 you don't set
 any environment variables then what specifically is happening that
 you don't want to happen?

 On Mon, Sep 8, 2008 at 7:10 PM, Eduardo M. A. M.Mendes
 [EMAIL PROTECTED] wrote:
 Hello

 I am a newbie.  I had my R upgraded from 2.7.1 to 2.7.2 and in doing so I
 decided to install all 2.7 versions under c:\program files\R\2.7 from now
 on (2.7.1 is located under .\2.7.1)

 Although I don't like the idea (I am running Vista), I have edited
 etc\Renviron.site to contain:


 R_USER=c:/Users/eduardo/Documents/R
 R_LIBS_USER=c:/Users/eduardo/Documents/R/win-library/2.7

 As far as R starting always from the same location, that is,
 c:/Users/eduardo/Documents/R, etc\Renviron.site didn't help.  So I wonder
 whether someone from the list could help me to:

 a) force R to start always from the same location
 b) force R to install all new packages in the same location


 Many thanks

 Ed

 PS. Before sending this email, I read windows FAQ and browsed the
archives
 (too many posts in the subject!).

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




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


Re: [R] R_USER - in which file should I include it?

2008-09-09 Thread Eduardo M. A. M.Mendes
Many thanks. I shall look at it. In case I run into trouble again, I'll try
to clarify the the same.

Ed
 

-Original Message-
From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 09, 2008 10:46 AM
To: Eduardo M. A. M.Mendes
Cc: r-help@r-project.org
Subject: Re: [R] R_USER - in which file should I include it?

You might look at ?.libPaths
(note the dot) and play around with adding a .libPaths command
to your Rprofile.site and again you may need Administrator rights
when editing it.  If that does not help then you can try clarifying
the problem.   In particular what the same refers to and what
is happening now and what you want to happen.

On Tue, Sep 9, 2008 at 9:14 AM, Eduardo M. A. M.Mendes
[EMAIL PROTECTED] wrote:
 Hello

 Many thanks.  It works just fine.

 How about the packages issue?  That is, same thing for the installation
 path.

 Cheers

 Ed


 -Original Message-
 From: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
 Sent: Monday, September 08, 2008 10:01 PM
 To: Eduardo M. A. M.Mendes
 Cc: r-help@r-project.org
 Subject: Re: [R] R_USER - in which file should I include it?

 Try adding this at the end of your etc/Rprofile.site file.  That file
 should already be there so you don't have to create it,
 just edit it.

 cat(Hello from Rprofile.site\n)
 setwd(C:/Users/eduardo/Documents)

 You may need to edit it as Administrator.   You should
 see the Hello message in which case you will know that the
 Rprofile.site file is being run.

 That should work unless Tinn-R runs R in such a way as to
 ignore Rprofile.site.

 On Mon, Sep 8, 2008 at 8:11 PM, Eduardo M. A. M.Mendes
 [EMAIL PROTECTED] wrote:
 Hello

 I am not sure whether R starts from the same dir.  For instance:

 a) if I double-click on R-2.7.2 icon and then issue the command getwd(),
 the
 result is:

 getwd()
 [1] C:/Users/eduardo/Documents

 b) If R starts from within Tinn-R, the result is:

 getwd()
 [1] C:/Program Files/R/R-2/bin

 I want that no matter which calling R method I am using if I issue the
 command getwd() (first command) the result is:

 C:/Users/eduardo/Documents/R


 Moreover all new packages go to
C:/Users/eduardo/Documents/R/win-library


 Thanks

 Ed

 -Original Message-
 From: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
 Sent: Monday, September 08, 2008 8:57 PM
 To: Eduardo M. A. M.Mendes
 Cc: r-help@r-project.org
 Subject: Re: [R] R_USER - in which file should I include it?

 Could you explain more clearly what you mean by the same?
 Do you mean that each time you click on R 2.7.2 icon on your
 desktop that running this from the R console:

 getwd()

 is the same directory on each startup?  Isn't that already the case?
 I don't think you need to set any environment variables at all.  If
 you don't set
 any environment variables then what specifically is happening that
 you don't want to happen?

 On Mon, Sep 8, 2008 at 7:10 PM, Eduardo M. A. M.Mendes
 [EMAIL PROTECTED] wrote:
 Hello

 I am a newbie.  I had my R upgraded from 2.7.1 to 2.7.2 and in doing so
I
 decided to install all 2.7 versions under c:\program files\R\2.7 from
now
 on (2.7.1 is located under .\2.7.1)

 Although I don't like the idea (I am running Vista), I have edited
 etc\Renviron.site to contain:


 R_USER=c:/Users/eduardo/Documents/R
 R_LIBS_USER=c:/Users/eduardo/Documents/R/win-library/2.7

 As far as R starting always from the same location, that is,
 c:/Users/eduardo/Documents/R, etc\Renviron.site didn't help.  So I
wonder
 whether someone from the list could help me to:

 a) force R to start always from the same location
 b) force R to install all new packages in the same location


 Many thanks

 Ed

 PS. Before sending this email, I read windows FAQ and browsed the
 archives
 (too many posts in the subject!).

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






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


[R] R_USER - in which file should I include it?

2008-09-08 Thread Eduardo M. A. M.Mendes
Hello

I am a newbie.  I had my R upgraded from 2.7.1 to 2.7.2 and in doing so I
decided to install all 2.7 versions under c:\program files\R\2.7 from now
on (2.7.1 is located under .\2.7.1) 

Although I don't like the idea (I am running Vista), I have edited
etc\Renviron.site to contain:


R_USER=c:/Users/eduardo/Documents/R
R_LIBS_USER=c:/Users/eduardo/Documents/R/win-library/2.7

As far as R starting always from the same location, that is,
c:/Users/eduardo/Documents/R, etc\Renviron.site didn't help.  So I wonder
whether someone from the list could help me to:

a) force R to start always from the same location
b) force R to install all new packages in the same location


Many thanks

Ed

PS. Before sending this email, I read windows FAQ and browsed the archives
(too many posts in the subject!).

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


Re: [R] R_USER - in which file should I include it?

2008-09-08 Thread Eduardo M. A. M.Mendes
Hello

I am not sure whether R starts from the same dir.  For instance:

a) if I double-click on R-2.7.2 icon and then issue the command getwd(), the
result is:

 getwd()
[1] C:/Users/eduardo/Documents

b) If R starts from within Tinn-R, the result is:

getwd()
[1] C:/Program Files/R/R-2/bin

I want that no matter which calling R method I am using if I issue the
command getwd() (first command) the result is:

C:/Users/eduardo/Documents/R


Moreover all new packages go to C:/Users/eduardo/Documents/R/win-library


Thanks 

Ed

-Original Message-
From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 08, 2008 8:57 PM
To: Eduardo M. A. M.Mendes
Cc: r-help@r-project.org
Subject: Re: [R] R_USER - in which file should I include it?

Could you explain more clearly what you mean by the same?
Do you mean that each time you click on R 2.7.2 icon on your
desktop that running this from the R console:

getwd()

is the same directory on each startup?  Isn't that already the case?
I don't think you need to set any environment variables at all.  If
you don't set
any environment variables then what specifically is happening that
you don't want to happen?

On Mon, Sep 8, 2008 at 7:10 PM, Eduardo M. A. M.Mendes
[EMAIL PROTECTED] wrote:
 Hello

 I am a newbie.  I had my R upgraded from 2.7.1 to 2.7.2 and in doing so I
 decided to install all 2.7 versions under c:\program files\R\2.7 from now
 on (2.7.1 is located under .\2.7.1)

 Although I don't like the idea (I am running Vista), I have edited
 etc\Renviron.site to contain:


 R_USER=c:/Users/eduardo/Documents/R
 R_LIBS_USER=c:/Users/eduardo/Documents/R/win-library/2.7

 As far as R starting always from the same location, that is,
 c:/Users/eduardo/Documents/R, etc\Renviron.site didn't help.  So I wonder
 whether someone from the list could help me to:

 a) force R to start always from the same location
 b) force R to install all new packages in the same location


 Many thanks

 Ed

 PS. Before sending this email, I read windows FAQ and browsed the archives
 (too many posts in the subject!).

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


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


[R] R_USER - in which file should I include it?

2008-09-07 Thread Eduardo M. A. M.Mendes
Hello

I am a newbie.  I had my R upgraded from 2.7.1 to 2.7.2 and in doing so I
decided to install all 2.7 versions under c:\program files\R\2.7 from now on
(2.7.1 is located under .\2.7.1) 

Although I don't like the idea (I am running Vista), I have edited
etc\Renviron.site to contain:


R_USER=c:/Users/eduardo/Documents/R
R_LIBS_USER=c:/Users/eduardo/Documents/R/win-library/2.7

As far as R starting always from the same location, that is,
c:/Users/eduardo/Documents/R, etc\Renviron.site didn't help.  So I wonder
whether someone from the list could help me to:

a) force R to start always from the same location
b) force R to install all new packages in the same location


Many thanks

Ed

PS. Before sending this email, I read windows FAQ and browsed the archives
(too many posts in the subject!).

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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_USER - in which file should I include it?

2008-09-07 Thread Eduardo M. A. M.Mendes
Hello

I am a newbie.  I had my R upgraded from 2.7.1 to 2.7.2 and in doing so I
decided to install all 2.7 versions under c:\program files\R\2.7 from now
on (2.7.1 is located under .\2.7.1) 

Although I don't like the idea (I am running Vista), I have edited
etc\Renviron.site to contain:


R_USER=c:/Users/eduardo/Documents/R
R_LIBS_USER=c:/Users/eduardo/Documents/R/win-library/2.7

As far as R starting always from the same location, that is,
c:/Users/eduardo/Documents/R, etc\Renviron.site didn't help.  So I wonder
whether someone from the list could help me to:

a) force R to start always from the same location
b) force R to install all new packages in the same location


Many thanks

Ed

PS. Before sending this email, I read windows FAQ and browsed the archives
(too many posts in the subject!).

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


Re: [R] Newbie: Examples on functions callling a library etc.

2008-08-29 Thread Eduardo M. A. M.Mendes
Hi Steve

That is exactly what I want. Many thanks.

Ed


-Original Message-
From: Steven McKinney [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 28, 2008 11:48 PM
To: Eduardo M. A. M.Mendes; r-help@r-project.org
Subject: RE: [R] Newbie: Examples on functions callling a library etc.


Hi Ed, 

Here's a simple example showing your needs:


myfun - function(n1, n2, n3) {
  mat1 - matrix(rep(1), nrow = n1, ncol = 3)
  mat2 - matrix(rep(2), nrow = n2, ncol = 4)
  mat3 - matrix(rep(3), nrow = n3, ncol = 5)

  require(survival) ## make sure the package you need is loaded
  mypkgfun - survival::is.Surv ## Use the '::' and ':::' extractors to get
visible and hidden functions respectively from the package

  list(mat1 = mat1, mat2 = mat2, mat3 = mat3, mypkgfun = mypkgfun) ## Return
the items in a list
}

## Now invoke the function
foo - myfun(n1 = 1, n2 = 1, n3 = 5)

## and look at the returned results
foo

 myfun - function(n1, n2, n3) {
+   mat1 - matrix(rep(1), nrow = n1, ncol = 3)
+   mat2 - matrix(rep(2), nrow = n2, ncol = 4)
+   mat3 - matrix(rep(3), nrow = n3, ncol = 5)
+ 
+   require(survival)
+   mypkgfun - survival::is.Surv
+ 
+   list(mat1 = mat1, mat2 = mat2, mat3 = mat3, mypkgfun = mypkgfun)
+ }
 
 foo - myfun(n1 = 1, n2 = 1, n3 = 5)
 
 foo
$mat1
 [,1] [,2] [,3]
[1,]111

$mat2
 [,1] [,2] [,3] [,4]
[1,]2222

$mat3
 [,1] [,2] [,3] [,4] [,5]
[1,]33333
[2,]33333
[3,]33333
[4,]33333
[5,]33333

$mypkgfun
function (x) 
inherits(x, Surv)
environment: namespace:survival

 

HTH

Steve McKinney


-Original Message-
From: [EMAIL PROTECTED] on behalf of Eduardo M. A. M.Mendes
Sent: Thu 8/28/2008 5:43 PM
To: r-help@r-project.org
Subject: [R] Newbie:  Examples on functions callling a library etc.
 
Hello

 

R is pretty new to me. I need to write a function that returns three
matrices of different dimensions.  In addition, I need to call a function
from a contributed package with the function.   I have browsed several
manuals and docs but the examples on them are either very simple or
extremely hard to follow.

 

Many thanks

 

Ed

 

 

 


[[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] Newbie: Examples on functions callling a library etc.

2008-08-29 Thread Eduardo M. A. M.Mendes
Hi

Many thanks.  I got another post to this list that gives an example of what
I need exactly, that is, require and ::

Cheers

Ed

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Ben Bolker
Sent: Thursday, August 28, 2008 11:44 PM
To: [EMAIL PROTECTED]
Subject: Re: [R] Newbie: Examples on functions callling a library etc.

Eduardo M. A. M.Mendes emammendes at gmail.com writes:

 R is pretty new to me. I need to write a function that returns three
 matrices of different dimensions.  In addition, I need to call a function
 from a contributed package with the function.   I have browsed several
 manuals and docs but the examples on them are either very simple or
 extremely hard to follow.
 
 Many thanks
 
 Ed
 

  I think you need to try to specify your needs a little bit
more carefully.  Here is a function that technically meets
your needs:

library(example_pkg)  ## to load the contributed package
myfunction - function() {  ## function with no arguments
   foo()## assuming the function foo is in the package
   list(matrix(nrow=2,ncol=2),matrix(nrow=3,ncol=3),matrix(nrow=4,ncol=4)
}

  But I suspect that doesn't really do what you need ...

  Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Newbie: Examples on functions callling a library etc.

2008-08-28 Thread Eduardo M. A. M.Mendes
Hello

 

R is pretty new to me. I need to write a function that returns three
matrices of different dimensions.  In addition, I need to call a function
from a contributed package with the function.   I have browsed several
manuals and docs but the examples on them are either very simple or
extremely hard to follow.

 

Many thanks

 

Ed

 

 

 


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