[R] SOLVED: Re: Source into a specified environment

2017-01-09 Thread G . Maubach
Hi Jim,

many thanks for your answer.

That's exactly what I need.

Many thanks again.

Kind regards

Georg




Von:jim holtman 
An: g.maub...@weinwolf.de, 
Kopie:  R mailing list 
Datum:  10.01.2017 03:59
Betreff:Re: [R] Source into a specified environment



?sys.source

Here is an example of the way I use it:

# read my functions into a environment
.my.env.jph <- new.env()
.sys.source('~/C_Drive/perf/bin/perfmon.r', envir=.my.env.jph)
attach(.my.env.jph)


Jim Holtman
Data Munger Guru
 
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Mon, Jan 9, 2017 at 11:21 AM,  wrote:
Hi All,

I wish everyone a happy new year.

I have the following code:

-- cut --

modules <- c("t_calculate_RFM_model.R", "t_count_na.R",
"t_export_table_2_xls.R",
 "t_find_duplicates_in_variable.R",
"t_find_originals_and_duplicates.R",
 "t_frequencies.R", "t_inspect_dataset.R",
"t_merge_variables.R",
 "t_openxlsx_shortcuts.r", "t_rename_variables.R",
"t_select_chunks.R")

toolbox <- new.env(parent = emptyenv())

for (file in modules)
{
  source(file = file.path(
c_path_full$modules,  # path to modules
file),
echo = TRUE)
}

-- cut --

I would like to know how I can source the modules into the newly created
environment called "toolbox"?

I had a look at the help file for ?source but this function can read in
only in the current environment or the global environment (= default).

I tried also the following

-- cut --

for (file in modules))
{
  do.call(
what = "source",
args = list(
  file = file.path(c_path_full$modules,
   file),
  echo = TRUE
),
envir = toolbox
  )
}

-- cut --

But this did not work, i. e. it did not load the modules into the
environment "toolbox" but into the .GlobalEnv.

I also had a look at "assign", but assign() askes for a name of an object
in quotes. This way I could not figure out how to use it in a loop or
function to name the element in "toolbox" after the modules names:

assign("t_add_sheet", t_add_sheet, envir = toolbox)  # works
assign(quote(t_add_sheet), t_add_sheet, envir = toolbox)  # does NOT work
assign(as.name(t_add_sheet), t_add_sheet, envir = toolbix)  # does NOT
work


Is there a way to load the modules directly into the "toolbox"
environment?

Kind regards

Georg

__
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-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] mstate with multiple initial states?

2017-01-09 Thread Lucy Leigh
Hi,

I have a multi-state model that I would like to estimate using the 'mstate' 
package - but I am not sure how best to approach it and was wondering

if anyone could provide some insight for me.

Basically, I have a group of kids who have been randomized to one of 2 
treatments, A or B. If they do well on either of these, they

are discharged (A -->D or B--> D). If they do poorly, kids who were receiving 
treatment A are moved onto treatment B (A-->B), but kids

on B can't go to A, they go straight into ICU (A-->C). If the kids who went 
from A-->B do well they are discharged (A-->B-->D), and if they

do poorly they go to ICU (A-->B-->C), and then finally after ICU they are 
discharged (C-->D). There are also a small number of kids who were sent

straight to ICU (so...in fact there are 3 initial states). So the transition 
matrix looks like:


 A  B C  D

A   NA   1NA   1

B  NA   NA   1 1

C  NA   NA   NA  1

D  NA   NA  NA  NA


However, I am not sure whether I can do this in 'mstate', as there are three 
initial states? The program requires that we start with

a wide data set, in which  there is an event indicator for each state, and a 
time of entry into each state. If they don't enter a state, then

the time for that state is set to last follow-up (page 4 of 
https://www.jstatsoft.org/article/view/v038i07 ).


So, in the case where a kid starts in A, and goes to D; the data would look 
like:

   A.status  A.timeB.status   B.time   C.Status   C.Time  D.Status  
D.time

 1 00 Final   0 
   Final 1  Final


And I think this is OK in terms of what is specified for B, because technically 
the kid is at risk of transitioning into B

until they are discharged.


But what about a kid who starts in B and goes to D? The corresponding data 
would possibly be?:

   A.status  A.timeB.status   B.time   C.Status   C.Time  D.Status  
D.time

 0   Final1   0 0   
 Final 1  Final


However, this to me doesn't look right, as technically they are never at risk 
of going to A if they started in B.

I tried setting the A.time to 0 to reflect the fact that they are never at risk 
of going back to A, but the numbers I got

from the model  (events$model) were incorrect - basically all the events were 
going to A, and no one was in B.

And for the kids that started in C...similarly.



So, I was wondering, would it be valid to create a new initial state (e.g. P = 
pre-treatment), from which the child

then transitions immediately (at say, time  = 0.1) to either A or B (or C). So 
the matrix would be:


 P  A  B C  D

P   NA   1  1  1 NA

A  NA   NA1NA1

B  NA   NA   NA1 1

C  NA   NA   NA  NA1

D  NA   NA  NA  NA   NA


And then the data for someone who went from A--D would be


  A.status  A.timeB.status   B.time   C.Status   C.Time  D.Status  
D.time

  1 0.100.1 0   
 Final 1  Final


And then the data for someone who went from B--D would be


   A.status  A.time  B.status   B.time  C.Status   C.Time  
D.Status  D.time

 0  0.1 1 0 .10 
   Final 1  Final



When I code the model like this, then the number of events I get from the model 
is correct.


However, I am not sure whether adding this extra initial state is a valid 
option?



Thanks in advance for anyone who can help me out,

Lucy Leigh




mstate: An R Package for the Analysis of Competing Risks 
...
www.jstatsoft.org
Authors: Liesbeth C. de Wreede, Marta Fiocco, Hein Putter: Title: mstate: An R 
Package for the Analysis of Competing Risks and Multi-State Models



[[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] R install/libraries

2017-01-09 Thread Jeff Newmiller
I have noticed a behavior where if I update a package with dependencies, 
sometimes it fails and the package that was outdated but installed is no longer 
installed. Once I run install.packages again, it usually seems to work just 
fine. I have not noticed that base packages are more susceptible to this than 
contributed packages. 
-- 
Sent from my phone. Please excuse my brevity.

On January 9, 2017 4:47:16 PM PST, Chris  wrote:
>thx. when I let R installed to "my documents" (which is basically world
>read/writable) not all dependent packages download/install with the
>library. 
>When R tells me it can't find the dependent librariies, I manually
>download and install.
>
>Is that typical behaviour for R? Chris Barker, Ph.D.
>Adjunct Associate Professor of Biostatistics - UIC-SPH
>and
>President and Owner
>Statistical Planning and Analysis Services, Inc.
>www.barkerstats.com
>415 609 7473 
>skype: barkerstats
>
> 
>
>On Monday, January 9, 2017 4:41 PM, Jeff Newmiller
> wrote:
> 
>
>Your (updated) personal library should receive any updated versions of
>base packages that were originally installed with R. The outdated
>packages in the system library tend to become irrelevant over time with
>normal use. It is possible to update them but for most people fixing
>that is not worth the risk of breaking permissions on your personal
>library. 

__
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] Source into a specified environment

2017-01-09 Thread jim holtman
?sys.source

Here is an example of the way I use it:

# read my functions into a environment
.my.env.jph <- new.env()
.sys.source('~/C_Drive/perf/bin/perfmon.r', envir=.my.env.jph)
attach(.my.env.jph)


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Mon, Jan 9, 2017 at 11:21 AM,  wrote:

> Hi All,
>
> I wish everyone a happy new year.
>
> I have the following code:
>
> -- cut --
>
> modules <- c("t_calculate_RFM_model.R", "t_count_na.R",
> "t_export_table_2_xls.R",
>  "t_find_duplicates_in_variable.R",
> "t_find_originals_and_duplicates.R",
>  "t_frequencies.R", "t_inspect_dataset.R",
> "t_merge_variables.R",
>  "t_openxlsx_shortcuts.r", "t_rename_variables.R",
> "t_select_chunks.R")
>
> toolbox <- new.env(parent = emptyenv())
>
> for (file in modules)
> {
>   source(file = file.path(
> c_path_full$modules,  # path to modules
> file),
> echo = TRUE)
> }
>
> -- cut --
>
> I would like to know how I can source the modules into the newly created
> environment called "toolbox"?
>
> I had a look at the help file for ?source but this function can read in
> only in the current environment or the global environment (= default).
>
> I tried also the following
>
> -- cut --
>
> for (file in modules))
> {
>   do.call(
> what = "source",
> args = list(
>   file = file.path(c_path_full$modules,
>file),
>   echo = TRUE
> ),
> envir = toolbox
>   )
> }
>
> -- cut --
>
> But this did not work, i. e. it did not load the modules into the
> environment "toolbox" but into the .GlobalEnv.
>
> I also had a look at "assign", but assign() askes for a name of an object
> in quotes. This way I could not figure out how to use it in a loop or
> function to name the element in "toolbox" after the modules names:
>
> assign("t_add_sheet", t_add_sheet, envir = toolbox)  # works
> assign(quote(t_add_sheet), t_add_sheet, envir = toolbox)  # does NOT work
> assign(as.name(t_add_sheet), t_add_sheet, envir = toolbix)  # does NOT
> work
>
>
> Is there a way to load the modules directly into the "toolbox"
> environment?
>
> Kind regards
>
> Georg
>
> __
> 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: [ESS] ess-16.10 / Error 2

2017-01-09 Thread Eric Lindblad via ESS-help
Dear Martin Mächler,

System: Slackware Linux (version 14.0)
CPUs: Intel(R) Atom(TM) CPU N270 @1.60GHz
GNU Emacs 24.2.1

> Your emacs version 24.2 (2012)  is relatively old.
> The oldest version I have had access relatively quickly, is 24.3
> and if I type
>C-h f  defvar-local

> there, I get a "positive" result.

> What happens if you start emacs and ask for  'defvar-local' (as
> I did above)?

Describe function: defvar-local [No match]

Running 'make' again after the patch was applied resulted in the following 
output.

sh-4.2$ cd ess-16.10
sh-4.2$ make
cd etc; make all
make[1]: Entering directory `/home/eric/ess-16.10/etc'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/eric/ess-16.10/etc'
cd lisp; make all
make[1]: Entering directory `/home/eric/ess-16.10/lisp'
emacs -batch -no-site-file -no-init-file -l ./ess-comp.el -f batch-byte-compile 
ess-custom.el
loading 'ess-compat ..
loading 'ess-custom ..
loading 'ess ..
loading 'ess-site ..
[ess-site:] ess-lisp-directory = '/home/eric/ess-16.10/lisp'
[ess-site:] require 'ess   *ITSELF* ...
[ess-site:] .. after requiring 'ess ...
[ess-site:] Before requiring dialect 'ess-*-d 
[ess-site:] require 'ess-r-d ...
[ess-r-d:] (require 'ess-s-l)
[ess-s-l:] (def** ) only ...
Cannot open load file: cl-lib
make[1]: *** [ess-custom.elc] Error 255
make[1]: Leaving directory `/home/eric/ess-16.10/lisp'
make: *** [all] Error 2
sh-4.2$  

Checking the emacs-lisp directory it appears that cl-lib.el was not included in 
version 24.2.1, though it's presence is noted in emacs-24.3.

sh-4.2$ ls /usr/share/emacs/24.2/lisp/emacs-lisp/cl*
/usr/share/emacs/24.2/lisp/emacs-lisp/cl-extra.el.gz
/usr/share/emacs/24.2/lisp/emacs-lisp/cl-extra.elc
/usr/share/emacs/24.2/lisp/emacs-lisp/cl-indent.el.gz
/usr/share/emacs/24.2/lisp/emacs-lisp/cl-indent.elc
/usr/share/emacs/24.2/lisp/emacs-lisp/cl-loaddefs.el
/usr/share/emacs/24.2/lisp/emacs-lisp/cl-macs.el.gz
/usr/share/emacs/24.2/lisp/emacs-lisp/cl-macs.elc
/usr/share/emacs/24.2/lisp/emacs-lisp/cl-seq.el.gz
/usr/share/emacs/24.2/lisp/emacs-lisp/cl-seq.elc
/usr/share/emacs/24.2/lisp/emacs-lisp/cl-specs.el
/usr/share/emacs/24.2/lisp/emacs-lisp/cl.el.gz
/usr/share/emacs/24.2/lisp/emacs-lisp/cl.elc
sh-4.2$ 

Sincerely,
Eric Lindblad
http://www.nurmi-labs.blogspot.com


On Mon, 1/9/17, Martin Maechler < ... > wrote:
Subject: Re: [ESS] ess-16.10 / Error 2
To: "Eric Lindblad" < ... >
Cc: ess-help@r-project.org
Date: Monday, January 9, 2017, 12:14 PM

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

Re: [R] gridExtra-arrangeGrob

2017-01-09 Thread Felipe Carrillo via R-help
I am not sure if something was wrong with my gridExtra installation or grid but 
after uninstall/re-install of the packages (and reboot) the code is working 
properly. Thank you all. 
 

On Monday, January 9, 2017 9:51 AM, David Winsemius 
 wrote:
 
 

 
> On Jan 9, 2017, at 3:35 AM, John Kane via R-help  wrote:
> 
> I'm not sure what the problem is but, if nothing else, it looks like you need 
> to do 
> library(grid)
> It may be that an early version of ggplot2 or gridExtra was automatically 
> loading grid and it no longer does.  
> 
> 
> 
> 
>    On Monday, January 9, 2017 1:08 AM, Felipe Carrillo via R-help 
> wrote:
> 
> 
>  Hi;The code below used to work on my older version of gridExtra but doesn't 
>work with the new version. Could someonegive me a hint on how to translate 
>this code to the new version of gridExtra code? Thank you beforehand.
> p1 <- ggplot(iris,aes(Sepal.Length,  Petal.Length, colour=Species)) +
> geom_point() + theme_bw() + theme(legend.position='top')
> 
>  grid.arrange(p1, arrangeGrob(p1,p1,p1, heights=c(0.33, .33,.33), ncol=1), 
>ncol=2)
>  #Create 2 columns with different width using the 'widths' argument in the 
>grid.arrange call
>  grid.arrange(p1, arrangeGrob(p1,p1,p1, heights=c(0.33, .40,.27), ncol=1), 
>ncol=2,widths=c(1.25,0.75))
> p <- rectGrob()  
>  grid.arrange(p, arrangeGrob(p,p,p, heights=c(0.33, .33,.33), ncol=1), ncol=2)

The lattice library attaches the grid functions via a namespace mechanism but 
it does not actually load the package. That meant that attempts to use grid 
functions from the console would fail. Perhaps this is also the practice of the 
ggplot2 authors? In any event, the grid.arrange and arrangeGrob functions are 
not from grid, but rather from gridExtra, which I am not seeing being loaded.

-- 
David.


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

David Winsemius
Alameda, CA, USA


 
   
[[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] how to proof the trend of two columns of data?

2017-01-09 Thread David L Carlson
The list does not assist with homework problems. If this is not a class 
assignment, you should be more specific about what you have tried and provide a 
reproducible example (a sample of the real data or some made-up data that has 
the same columns and data types). In the meantime you could also try the 
following R command:

> ?kruskal.test

-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas
Sent: Monday, January 9, 2017 11:28 AM
To: vod vos; r-help
Subject: Re: [R] how to proof the trend of two columns of data?

Hello,

Inline.

Em 09-01-2017 14:55, vod vos escreveu:
> Hello everyone,
>
>
>
> If there are two columns, one is age (numeric, cut to several groups), the 
> other is hair color type(factor: yellow, black, white).
>
>
>
> If the age column is not normal distributed

If you use ?lm, it's the residuals that should be normally distributed, 
not age.
You can also use ?glm with a binomial link, in which case you should 
recode type as white/not white.

Hope this helps,

Rui Barradas

, which statistic method should use to prove the trend relationship 
between them, for example, the older has more probability of white hair 
type? Are there any existed R package to figure out this situation?
>
>
>
> Thank you.
>
>
>
>
>   [[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-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-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-es] Unir archivos netCDF

2017-01-09 Thread Joan Giménez Verdugo
Hola Isa,

No creo que sea lo más elegante para unir ficheros netCDF pero yo lo que
hago es crear un netCDF vacío y almacenar ahí primero un netCDF y luego el
siguiente. Eso por ejemplo lo hago cuando tengo series temporales de dos
satélites diferentes con diferente resolución, por lo tanto resampleo uno
para que todo esté en la misma resolución y luego lo junto en un único
netCDF para hacer los siguientes pasos en R.

Para crear el netCDF vacío tienes que usar:

dim.def.ncdf # para definir las dimensiones que necesitas para el nuevo
netCDF que será tu contenedor de datos

var.def.ncdf # definir las variables del nuevo netCDF

create.ncdf # crear el nuevo netCDF

Para rellenar el netCDF:

put.var.ncdf #  para poner los valores de cada variable

close.ncdf # es necesario cerrar el nuevo netCDF una vez hayas puesto las
variables.

Espero que sirva de ayuda.

Si alguien tiene una solución más elegante será bienvenida.

Joan

-- 
*Joan Giménez Verdugo*
*PhD Student* *Severo Ochoa*
Estación Biológica de Doñana (EBD-CSIC)
Department of Conservation Biology
Americo Vespucio Ave, s/n
41092 Sevilla (Spain)
www.ebd.csic.es
---
Research Gate: Joan Giménez

Phone: +34 619 176 849
ü Please consider the environment before printing this E-mail

[[alternative HTML version deleted]]

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


Re: [R] gridExtra-arrangeGrob

2017-01-09 Thread David Winsemius

> On Jan 9, 2017, at 3:35 AM, John Kane via R-help  wrote:
> 
> I'm not sure what the problem is but, if nothing else, it looks like you need 
> to do 
> library(grid)
> It may be that an early version of ggplot2 or gridExtra was automatically 
> loading grid and it no longer does.  
> 
> 
> 
> 
>On Monday, January 9, 2017 1:08 AM, Felipe Carrillo via R-help 
>  wrote:
> 
> 
>  Hi;The code below used to work on my older version of gridExtra but doesn't 
> work with the new version. Could someonegive me a hint on how to translate 
> this code to the new version of gridExtra code? Thank you beforehand.
> p1 <- ggplot(iris,aes(Sepal.Length,  Petal.Length, colour=Species)) +
> geom_point() + theme_bw() + theme(legend.position='top')
> 
>  grid.arrange(p1, arrangeGrob(p1,p1,p1, heights=c(0.33, .33,.33), ncol=1), 
> ncol=2)
>  #Create 2 columns with different width using the 'widths' argument in the 
> grid.arrange call
>   grid.arrange(p1, arrangeGrob(p1,p1,p1, heights=c(0.33, .40,.27), ncol=1), 
> ncol=2,widths=c(1.25,0.75))
> p <- rectGrob()  
>  grid.arrange(p, arrangeGrob(p,p,p, heights=c(0.33, .33,.33), ncol=1), ncol=2)

The lattice library attaches the grid functions via a namespace mechanism but 
it does not actually load the package. That meant that attempts to use grid 
functions from the console would fail. Perhaps this is also the practice of the 
ggplot2 authors? In any event, the grid.arrange and arrangeGrob functions are 
not from grid, but rather from gridExtra, which I am not seeing being loaded.

-- 
David.


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

David Winsemius
Alameda, CA, USA

__
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 proof the trend of two columns of data?

2017-01-09 Thread Rui Barradas

Hello,

Inline.

Em 09-01-2017 14:55, vod vos escreveu:

Hello everyone,



If there are two columns, one is age (numeric, cut to several groups), the 
other is hair color type(factor: yellow, black, white).



If the age column is not normal distributed


If you use ?lm, it's the residuals that should be normally distributed, 
not age.
You can also use ?glm with a binomial link, in which case you should 
recode type as white/not white.


Hope this helps,

Rui Barradas

, which statistic method should use to prove the trend relationship 
between them, for example, the older has more probability of white hair 
type? Are there any existed R package to figure out this situation?




Thank you.




[[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-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] how to proof the trend of two columns of data?

2017-01-09 Thread vod vos
Hello everyone,



If there are two columns, one is age (numeric, cut to several groups), the 
other is hair color type(factor: yellow, black, white). 



If the age column is not normal distributed, which statistic method should use 
to prove the trend relationship between them, for example, the older has more 
probability of white hair type? Are there any existed R package to figure out 
this situation?



Thank you.




[[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] Source into a specified environment

2017-01-09 Thread Ivan Calandra

Hi Georg,

Not sure how it would work in your case, but the 'local' argument to 
source() is not only TRUE or FALSE; you can also specify an environment.


HTH,
Ivan

--
Ivan Calandra, PhD
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
calan...@rgzm.de
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra
https://rgzm.academia.edu/IvanCalandra
https://publons.com/author/705639/

Le 09/01/2017 à 17:21, g.maub...@weinwolf.de a écrit :

Hi All,

I wish everyone a happy new year.

I have the following code:

-- cut --

modules <- c("t_calculate_RFM_model.R", "t_count_na.R",
"t_export_table_2_xls.R",
  "t_find_duplicates_in_variable.R",
"t_find_originals_and_duplicates.R",
  "t_frequencies.R", "t_inspect_dataset.R",
"t_merge_variables.R",
  "t_openxlsx_shortcuts.r", "t_rename_variables.R",
"t_select_chunks.R")

toolbox <- new.env(parent = emptyenv())

for (file in modules)
{
   source(file = file.path(
 c_path_full$modules,  # path to modules
 file),
 echo = TRUE)
}

-- cut --

I would like to know how I can source the modules into the newly created
environment called "toolbox"?

I had a look at the help file for ?source but this function can read in
only in the current environment or the global environment (= default).

I tried also the following

-- cut --

for (file in modules))
{
   do.call(
 what = "source",
 args = list(
   file = file.path(c_path_full$modules,
file),
   echo = TRUE
 ),
 envir = toolbox
   )
}

-- cut --

But this did not work, i. e. it did not load the modules into the
environment "toolbox" but into the .GlobalEnv.

I also had a look at "assign", but assign() askes for a name of an object
in quotes. This way I could not figure out how to use it in a loop or
function to name the element in "toolbox" after the modules names:

assign("t_add_sheet", t_add_sheet, envir = toolbox)  # works
assign(quote(t_add_sheet), t_add_sheet, envir = toolbox)  # does NOT work
assign(as.name(t_add_sheet), t_add_sheet, envir = toolbix)  # does NOT
work


Is there a way to load the modules directly into the "toolbox"
environment?

Kind regards

Georg

__
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-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] Source into a specified environment

2017-01-09 Thread G . Maubach
Hi All,

I wish everyone a happy new year.

I have the following code:

-- cut --

modules <- c("t_calculate_RFM_model.R", "t_count_na.R", 
"t_export_table_2_xls.R",
 "t_find_duplicates_in_variable.R", 
"t_find_originals_and_duplicates.R",
 "t_frequencies.R", "t_inspect_dataset.R", 
"t_merge_variables.R",
 "t_openxlsx_shortcuts.r", "t_rename_variables.R", 
"t_select_chunks.R")

toolbox <- new.env(parent = emptyenv())

for (file in modules)
{
  source(file = file.path(
c_path_full$modules,  # path to modules
file),
echo = TRUE)
}

-- cut --

I would like to know how I can source the modules into the newly created 
environment called "toolbox"?

I had a look at the help file for ?source but this function can read in 
only in the current environment or the global environment (= default).

I tried also the following

-- cut --

for (file in modules))
{
  do.call(
what = "source",
args = list(
  file = file.path(c_path_full$modules,
   file),
  echo = TRUE
),
envir = toolbox
  )
}

-- cut --

But this did not work, i. e. it did not load the modules into the 
environment "toolbox" but into the .GlobalEnv.

I also had a look at "assign", but assign() askes for a name of an object 
in quotes. This way I could not figure out how to use it in a loop or 
function to name the element in "toolbox" after the modules names:

assign("t_add_sheet", t_add_sheet, envir = toolbox)  # works
assign(quote(t_add_sheet), t_add_sheet, envir = toolbox)  # does NOT work
assign(as.name(t_add_sheet), t_add_sheet, envir = toolbix)  # does NOT 
work


Is there a way to load the modules directly into the "toolbox" 
environment?

Kind regards

Georg

__
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-es] Leer csv separado por comas y por espacios

2017-01-09 Thread eric
Y si lees el archivo por lineas con readLines() y luego usas "buscar y 
reemplazar" y cambias "comas" por \tab, grabas, cierras, y vuelves a 
leer todo con fread o read.csv?


Slds, eric.





On 01/09/2017 05:42 AM, Jesús Para Fernández wrote:

Buenas compa�eros!


Tengo una duda y no se muy bine como resolverlo. Tengo un csv en el que hay 
variables separadas por comas y otras esparadas por espacios (tabulaciones). 
Algo as�


V1V2   V3,V4

M1   123   2512,2522

M2   117   2852,3521

...



Para leerlo he probado poniendo:


datos<-read.csv("c:/datos/listado.txt",sep=c(",","","\t"),header=F)


Pero no me funciona, es decir, la separada por el espacio en blanco no la 
distingue y la mete en lo mismo.


Lo he solucionado hacinedo un strsplit pero es un poco co�azo andar parcheando 
algo que tendria que leer bien directametne.


�Alguna idea de porque no est� cogiendo bien el fichero?


Gracias

Jes�s

[[alternative HTML version deleted]]



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



--
Forest Engineer
Master in Environmental and Natural Resource Economics
Ph.D. student in Sciences of Natural Resources at La Frontera University
Member in AguaDeTemu2030, citizen movement for Temuco with green city 
standards for living


Nota: Las tildes se han omitido para asegurar compatibilidad con algunos 
lectores de correo.


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

Re: [R-es] Unir archivos netCDF

2017-01-09 Thread Carlos Ortega
Hola,

Por si te puede ayudar:

http://stackoverflow.com/questions/29101807/how-to-merge-netcdf-file-into-one
http://stackoverflow.com/questions/18866266/combine-netcdf-files-to-average-the-values-for-variables-in-r

Saludos,
Carlos Ortega
www.qualityexcellence.es



2017-01-09 10:34 GMT+01:00 Isa García Barón :

> Buenos días lista,
>
> Lo que quiero es unir archivos netCDF. Tengo varios archivos con las mismas
> características, pero de días consecutivos y me gustaría unir todos.
>
> He probado con las funciones "transNcdfMerge" y "aggregateNcdf", ambas del
> paquete ncdf.tools. Con ninguna de las dos he conseguido nada, a
> continuación os copio el script que he escrito hasta el momento:
>
> setwd(DataDir_geo_cur)
>
> ## lista con todos los archivo netCDF contenido en el directorio:
> files = list.files(DataDir_geo_cur,pattern='*.nc',full.names=TRUE)
>
> ## leemos todos los archivos:
> for(i in seq_along(files)) {
>   assign(paste0("gc",i),nc_open(files[i]))
> }
>
> # ejemplo de uno de los archivos
> gc1
>
> File C:/use/dt_global_allsat_msla_uv_20070905_20140106.nc
> (NC_FORMAT_CLASSIC):
>
>  5 variables (excluding dimension variables):
> float lat_bnds[nv,lat]
> float lon_bnds[nv,lon]
> int crs[]
> grid_mapping_name: latitude_longitude
> semi_major_axis: 6371000
> inverse_flattening: 0
> int u[lon,lat,time]
> _FillValue: -2147483647
> long_name: Geostrophic velocity anomalies: zonal component
> standard_name:
> surface_eastward_geostrophic_sea_water_velocity_assuming_
> sea_level_for_geoid
> units: m/s
> scale_factor: 1e-04
> int v[lon,lat,time]
> _FillValue: -2147483647
> long_name: Geostrophic velocity anomalies: meridian component
> standard_name:
> surface_northward_geostrophic_sea_water_velocity_assuming_
> sea_level_for_geoid
> units: m/s
> scale_factor: 1e-04
>
>  4 dimensions:
> time  Size:1
> long_name: Time
> standard_name: time
> units: days since 1950-01-01 00:00:00 UTC
> calendar: julian
> axis: T
> lat  Size:720
> long_name: Latitude
> standard_name: latitude
> units: degrees_north
> bounds: lat_bnds
> axis: Y
> valid_min: -90
> valid_max: 90
> lon  Size:1440
> long_name: Longitude
> standard_name: longitude
> units: degrees_east
> bounds: lon_bnds
> axis: X
> valid_min: 0
> valid_max: 360
> nv  Size:2
>
> 26 global attributes:
> cdm_data_type: Grid
> title: DT merged Global Ocean Gridded Geostrophic Velocities
> SSALTO/Duacs L4 product
> summary: This dataset contains Delayed Time Level-4 geostrophic
> velocities products from multi-satellite observations over Global Ocean.
> comment: Surface product; Geostrophic Velocities referenced to the
> [1993, 2012] period
> time_coverage_resolution: P1D
> product_version: 5.0
> institution: CNES, CLS
> project: SSALTO/DUACS
> references: www.aviso.altimetry.fr
> contact: av...@altimetry.fr
> license:
> http://www.aviso.altimetry.fr/fileadmin/documents/data/License_Aviso.pdf
> platform: Envisat, Geosat Follow On, Jason-1
> date_created: 2014-02-27 20:27:23
> history: 2014-02-27 20:27:23:creation
> Conventions: CF-1.6
> standard_name_vocabulary:
> http://cf-pcmdi.llnl.gov/documents/cf-standard-names/
> standard-name-table/12/cf-standard-name-table.html
> geospatial_lat_min: -90
> geospatial_lat_max: 90
> geospatial_lon_min: 0
> geospatial_lon_max: 360
> geospatial_vertical_min: 0.0
> geospatial_vertical_max: 0.0
> geospatial_lat_units: degrees_north
> geospatial_lon_units: degrees_east
> geospatial_lat_resolution: 0.25
> geospatial_lon_resolution: 0.25
>
> ## creamos un vector con todos los archivos abiertos en el environment:
> names = ls(pattern='gc')
>
> ## Intento de unión con la función transNcdfMerge:
> Geo_cur <- transNcdfMerge(names, path.target = DataDir)
>
> Error in convertDateNcdf2R(fileT) : File gc1 is not existent!
>
> ## Intento de unión con la función aggregateNcdf:
> Geo_cur_1 <- aggregateNcdf(names, path.out = DataDir, period=1)
>
> Error in system(command, as.integer(flag), f, stdout, stderr) : character
> string expected as first argument
>
> Espero que podaís ayudarme, muchísimas gracias y feliz año!
>
> *---
> --*
> *Isabel García Barón*
> Email: xan...@gmail.com
> PhD Student at AZTI Foundation -  AZTI Fundazioa
> Marine Ecosystems Functioning
> 

[R] Error in ReadInputs(dat1, constant1, stopmissing = c(40, 40, 10), timestep = "daily", : Missing data of Tmax.daily.

2017-01-09 Thread Frederic Ntirenganya
Dear All,

Could you please give me a hint on how to overcome this error?

Here is the code:


data("constants")
constant1<-constants
constant1$lat<-dat1$Latitude[1]
constant1$lat_rad<-0.10123

dat1<-omit(dat1)
# ReadInputs climate data
data <- ReadInputs(dat1, constant1,
   stopmissing=c(40,40,10),
   timestep="daily",
   interp_missing_days = T,
   interp_missing_entries = T,
   interp_abnormal = T,
   missing_method = "DoY average",
   abnormal_method = "DoY average")
results <- ET.HargreavesSamani(data,constant1, ts="daily")


dput(head(dat1))structure(list(Year = structure(c(1L, 1L, 1L, 1L, 1L,
1L), .Label = c("1984",
"1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992",
"1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000",
"2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008",
"2009"), class = "factor"), Month = structure(c(1L, 1L, 1L, 1L,
1L, 1L), .Label = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
"10", "11", "12"), class = "factor"), Day = 1:6, WindSpeed = c(5L,
4L, 4L, 3L, 5L, 6L), Sunshine = c(6.3, 4.8, 0.6, 8.2, 7.3, 1.7
), Tmax = c(27.4, 26.3, 22.9, 27.7, 28.5, 25.5), Tmin = c(14.5,
16, 14.4, 14.8, 16.6, 15.4), Hmax = c(100L, 95L, 97L, 100L, 97L,
99L), Hmin = c(45L, 62L, 72L, 55L, 54L, 63L), Station.Name = structure(c(1L,
1L, 1L, 1L, 1L, 1L), .Label = "KIGALI AERO", class = "factor"),
Elevation = c(1490L, 1490L, 1490L, 1490L, 1490L, 1490L),
Longitude = c(30.11, 30.11, 30.11, 30.11, 30.11, 30.11),
Latitude = c(-1.95, -1.95, -1.95, -1.95, -1.95, -1.95), Date =
structure(c(5113,
5114, 5115, 5116, 5117, 5118), class = "Date")), .Names = c("Year",
"Month", "Day", "WindSpeed", "Sunshine", "Tmax", "Tmin", "Hmax",
"Hmin", "Station.Name", "Elevation", "Longitude", "Latitude",
"Date"), na.action = structure(c(257L, 325L, 326L, 393L, 424L,
425L, 428L, 436L, 564L, 632L, 635L, 636L, 647L, 747L, 778L, 790L,
822L, 823L, 852L, 853L, 884L, 886L, 910L, 911L, 912L, 913L, 914L,
915L, 927L, 945L, 999L, 1019L, 1054L, 1156L, 1398L, 1445L, 1468L,
1489L, 1667L, 1742L, 1754L, 1766L, 1819L, 1822L, 1973L, 2142L,
2162L, 2163L, 2164L, 2165L, 2166L, 2167L, 2168L, 2169L, 2170L,
2171L, 2172L, 2173L, 2174L, 2175L, 2176L, 2177L, 2178L, 2179L,
2180L, 2181L, 2182L, 2183L, 2184L, 2185L, 2186L, 2187L, 2188L,
2189L, 2190L, 2191L, 2192L, 2283L, 2316L, 2420L, 2469L, 2478L,
2484L, 2603L, 2627L, 2831L, 2832L, 2833L, 2834L, 2835L, 2836L,
2837L, 2838L, 2839L, 2840L, 2841L, 2842L, 2843L, 2844L, 2845L,
2846L, 2847L, 2848L, 2849L, 2850L, 2851L, 2852L, 2853L, 2854L,
2855L, 2856L, 2857L, 2858L, 2859L, 2860L, 2861L, 2862L, 2863L,
2864L, 2865L, 2866L, 2867L, 2868L, 2869L, 2870L, 2871L, 2872L,
2873L, 2874L, 2875L, 2876L, 2877L, 2878L, 2879L, 2880L, 2881L,
2882L, 2883L, 2884L, 2885L, 2886L, 2887L, 2888L, 2889L, 2890L,
2891L, 2892L, 2893L, 2894L, 2895L, 2896L, 2897L, 2898L, 2899L,
2900L, 2901L, 2902L, 2903L, 2904L, 2905L, 2906L, 2907L, 2908L,
2909L, 2910L, 2911L, 2912L, 2913L, 2914L, 2915L, 2916L, 2917L,
2918L, 2919L, 2920L, 2921L, 2922L, 2923L, 2924L, 2925L, 2926L,
2927L, 2928L, 2929L, 2930L, 2931L, 2932L, 2933L, 2934L, 2935L,
2936L, 2937L, 2938L, 2939L, 2940L, 2941L, 2942L, 2943L, 2944L,
2945L, 2946L, 2947L, 2948L, 2949L, 2950L, 2951L, 2952L, 2953L,
2954L, 2955L, 2956L, 2957L, 2958L, 2959L, 2960L, 2961L, 2962L,
2963L, 2964L, 2965L, 2966L, 2967L, 2968L, 2969L, 2970L, 2971L,
2972L, 2973L, 2974L, 2975L, 2976L, 2977L, 2978L, 2979L, 2980L,
2981L, 2982L, 2983L, 2984L, 2985L, 2986L, 2987L, 2988L, 2989L,
2990L, 2991L, 2992L, 2993L, 2994L, 2995L, 2996L, 2997L, 2998L,
2999L, 3000L, 3001L, 3002L, 3003L, 3004L, 3005L, 3006L, 3007L,
3008L, 3009L, 3010L, 3011L, 3012L, 3013L, 3014L, 3015L, 3016L,
3017L, 3018L, 3019L, 3020L, 3021L, 3022L, 3023L, 3024L, 3025L,
3026L, 3027L, 3028L, 3029L, 3030L, 3031L, 3032L, 3033L, 3034L,
3035L, 3036L, 3037L, 3038L, 3039L, 3040L, 3041L, 3042L, 3043L,
3044L, 3045L, 3046L, 3047L, 3048L, 3049L, 3050L, 3051L, 3052L,
3053L, 3054L, 3055L, 3056L, 3057L, 3058L, 3059L, 3060L, 3061L,
3062L, 3063L, 3064L, 3065L, 3066L, 3067L, 3068L, 3069L, 3070L,
3071L, 3072L, 3073L, 3074L, 3075L, 3076L, 3077L, 3078L, 3079L,
3080L, 3081L, 3082L, 3083L, 3084L, 3085L, 3086L, 3087L, 3088L,
3089L, 3090L, 3091L, 3092L, 3093L, 3094L, 3095L, 3096L, 3097L,
3098L, 3099L, 3100L, 3101L, 3102L, 3103L, 3104L, 3105L, 3106L,
3107L, 3108L, 3109L, 3110L, 3111L, 3112L, 3113L, 3114L, 3115L,
3116L, 3117L, 3118L, 3119L, 3120L, 3121L, 3122L, 3123L, 3124L,
3125L, 3126L, 3127L, 3128L, 3129L, 3130L, 3131L, 3132L, 3133L,
3134L, 3135L, 3136L, 3137L, 3138L, 3139L, 3140L, 3141L, 3142L,
3143L, 3144L, 3145L, 3146L, 3147L, 3148L, 3149L, 3150L, 3151L,
3152L, 3153L, 3154L, 3155L, 3156L, 3157L, 3158L, 3159L, 3160L,
3161L, 3162L, 3163L, 3164L, 3165L, 3166L, 3167L, 3168L, 3169L,
3170L, 3171L, 3172L, 3173L, 3174L, 3175L, 3176L, 3177L, 3178L,
3179L, 3180L, 3181L, 3182L, 3183L, 3184L, 3185L, 3186L, 3187L,
3188L, 3189L, 3190L, 3191L, 

Re: [R-es] Unir archivos netCDF

2017-01-09 Thread javier.ruben.marcuzzi
Estimada Isa García Barón

No se sobe netCDF, en su ejemplo usa Windows, yo supe agregar un archivo a 
otro, o en otras palabras, crear un archivo donde se copia el contenido de 
otros, pero son archivos de texto, para eso hay una herramienta para concatenar 
en el sistema operativo, y otra más simple pero en node js que se utiliza para 
unir varios archivos de JavaScript en uno solo, luego se optimiza (quita 
espacios, etc.).

Si netCDF acepta concatenar archivos, podría ser una alternativa, pero se 
trabajan como archivos de texto.

Javier Rubén Marcuzzi

De: Isa García Barón
Enviado: lunes, 9 de enero de 2017 6:34
Para: r-help-es@r-project.org
Asunto: [R-es] Unir archivos netCDF

Buenos días lista,

Lo que quiero es unir archivos netCDF. Tengo varios archivos con las mismas
características, pero de días consecutivos y me gustaría unir todos.

He probado con las funciones "transNcdfMerge" y "aggregateNcdf", ambas del
paquete ncdf.tools. Con ninguna de las dos he conseguido nada, a
continuación os copio el script que he escrito hasta el momento:

setwd(DataDir_geo_cur)

## lista con todos los archivo netCDF contenido en el directorio:
files = list.files(DataDir_geo_cur,pattern='*.nc',full.names=TRUE)

## leemos todos los archivos:
for(i in seq_along(files)) {
  assign(paste0("gc",i),nc_open(files[i]))
}

# ejemplo de uno de los archivos
gc1

File C:/use/dt_global_allsat_msla_uv_20070905_20140106.nc
(NC_FORMAT_CLASSIC):

 5 variables (excluding dimension variables):
float lat_bnds[nv,lat]
float lon_bnds[nv,lon]
int crs[]
grid_mapping_name: latitude_longitude
semi_major_axis: 6371000
inverse_flattening: 0
int u[lon,lat,time]
_FillValue: -2147483647
long_name: Geostrophic velocity anomalies: zonal component
standard_name:
surface_eastward_geostrophic_sea_water_velocity_assuming_sea_level_for_geoid
units: m/s
scale_factor: 1e-04
int v[lon,lat,time]
_FillValue: -2147483647
long_name: Geostrophic velocity anomalies: meridian component
standard_name:
surface_northward_geostrophic_sea_water_velocity_assuming_sea_level_for_geoid
units: m/s
scale_factor: 1e-04

 4 dimensions:
time  Size:1
long_name: Time
standard_name: time
units: days since 1950-01-01 00:00:00 UTC
calendar: julian
axis: T
lat  Size:720
long_name: Latitude
standard_name: latitude
units: degrees_north
bounds: lat_bnds
axis: Y
valid_min: -90
valid_max: 90
lon  Size:1440
long_name: Longitude
standard_name: longitude
units: degrees_east
bounds: lon_bnds
axis: X
valid_min: 0
valid_max: 360
nv  Size:2

26 global attributes:
cdm_data_type: Grid
title: DT merged Global Ocean Gridded Geostrophic Velocities
SSALTO/Duacs L4 product
summary: This dataset contains Delayed Time Level-4 geostrophic
velocities products from multi-satellite observations over Global Ocean.
comment: Surface product; Geostrophic Velocities referenced to the
[1993, 2012] period
time_coverage_resolution: P1D
product_version: 5.0
institution: CNES, CLS
project: SSALTO/DUACS
references: www.aviso.altimetry.fr
contact: av...@altimetry.fr
license:
http://www.aviso.altimetry.fr/fileadmin/documents/data/License_Aviso.pdf
platform: Envisat, Geosat Follow On, Jason-1
date_created: 2014-02-27 20:27:23
history: 2014-02-27 20:27:23:creation
Conventions: CF-1.6
standard_name_vocabulary:
http://cf-pcmdi.llnl.gov/documents/cf-standard-names/standard-name-table/12/cf-standard-name-table.html
geospatial_lat_min: -90
geospatial_lat_max: 90
geospatial_lon_min: 0
geospatial_lon_max: 360
geospatial_vertical_min: 0.0
geospatial_vertical_max: 0.0
geospatial_lat_units: degrees_north
geospatial_lon_units: degrees_east
geospatial_lat_resolution: 0.25
geospatial_lon_resolution: 0.25

## creamos un vector con todos los archivos abiertos en el environment:
names = ls(pattern='gc')

## Intento de unión con la función transNcdfMerge:
Geo_cur <- transNcdfMerge(names, path.target = DataDir)

Error in convertDateNcdf2R(fileT) : File gc1 is not existent!

## Intento de unión con la función aggregateNcdf:
Geo_cur_1 <- aggregateNcdf(names, path.out = DataDir, period=1)

Error in system(command, as.integer(flag), f, stdout, stderr) : character
string expected as first argument

Espero que podaís ayudarme, muchísimas gracias y feliz año!

*-*
*Isabel García 

Re: [R-es] Leer csv separado por comas y por espacios

2017-01-09 Thread javier.ruben.marcuzzi
Estimado Jesús Para Fernández

Por regla al guardar la información hay que informar donde se separa, en su 
caso hay dos casos, comas y espacios, no se como llego a eso, pero yo 
intentaría de escribir nuevamente el fichero con los datos, ¿Cuántos datos son? 
Porque si entran en la capacidad de una hoja de cálculos, posiblemente con 
Excel al importarlos pueda marcar la separación de campos, luego guardar esto 
en otro archivo e importarlo en R. Posiblemente es más sencillo que awk, pero 
también el trabajar con cadenas puede ser muy útil (yo se hacerlo), la única 
recomendación es conocer muy bien la separación, porque puede ser que dentro de 
los datos hay una condición válida como cadena reconocida por el lenguaje 
informático pero que no es una separación real de datos. Por ejemplo, yo vivo 
en una provincia que se llama Santa Fe, si se busca una cadena donde hay un 
espacio entre las palabras como separación de datos, estaría cometiendo un 
error, por otro lado si busco más de dos espacios en blanco entre palabras como 
separación de datos, posiblemente vino espumoso, quedaría como un dato, cuándo 
en realidad puede ser bebida vino, categoría de bebida espumoso.

En su ejemplo no hay palabras, hay números, un posible error puede ser la 
separación decimal o puntuación de miles (, y .), particularidad que se define 
en el sistema operativo y si se comparten datos por ahí viene un archivo con 
alguna codificación no pensada.

Javier Rubén Marcuzzi

De: Jesús Para Fernández
Enviado: lunes, 9 de enero de 2017 10:06
Para: Carlos Ortega
CC: r-help-es@r-project.org
Asunto: Re: [R-es] Leer csv separado por comas y por espacios

Pens� que ser�a mucho m�s sencillo.


Al final optar� por lo que he hecho, el strstrip


Gracias de todos modos

Jes�s



De: Carlos Ortega 
Enviado: lunes, 9 de enero de 2017 12:49
Para: Jes�s Para Fern�ndez
Cc: r-help-es@r-project.org
Asunto: Re: [R-es] Leer csv separado por comas y por espacios

Hola,

El par�metro "sep" de "read.csv()" ha de ser �nico. No puedes utilizar varias 
opciones, aunque es cierto que en la documentaci�n no lo advierte. Por lo que 
tienes que utilizar otra estrategia para leer el fichero.

Te sugerir�a varias cosas:

  *   Probar con la funci�n "fread()" del paquete "data.table" que es algo m�s 
inteligente que read.csv. Aunque no tengo claro que realmente te vaya a 
funcionar... pero por probar...
  *   Una segunda opci�n es un poco m�s trabajosa que es el leer el fichero con 
"readLines", de esta forma te generar� un data.frame con una fila por l�nea del 
fichero. Luego tendr�s que construir una l�gica para que si la l�nea tiene "," 
como separador separes las variables y si el separador es un "tab" que haga lo 
propio.
  *   Otra opci�n m�s limpia y sencilla es pre-procesar el fichero en el SO con 
funciones del tipo "sed", "awk" y dejarlo con el formato, separadores que m�s 
te interese.
  *   Y si el fichero tiene bloques con "," y otros bloques con "tab" como 
separador, puedes utilizar "read.table" y decir que vaya saltando el n�mero de 
filas, que no tienen el separador que has definido...

Saludos,
Carlos Ortega
www.qualityexcellence.es
[http://qualityexcellence.es/images/1_blanco.jpg]

QualityExcellence
www.qualityexcellence.es
QUALITY EXCELLENCE, consultores en calidad, procesos y mejora continua


El 9 de enero de 2017, 9:42, Jes�s Para Fern�ndez 
> escribi�:
Buenas compa�eros!


Tengo una duda y no se muy bine como resolverlo. Tengo un csv en el que hay 
variables separadas por comas y otras esparadas por espacios (tabulaciones). 
Algo as�


V1V2   V3,V4

M1   123   2512,2522

M2   117   2852,3521

...



Para leerlo he probado poniendo:


datos<-read.csv("c:/datos/listado.txt",sep=c(",","","\t"),header=F)


Pero no me funciona, es decir, la separada por el espacio en blanco no la 
distingue y la mete en lo mismo.


Lo he solucionado hacinedo un strsplit pero es un poco co�azo andar parcheando 
algo que tendria que leer bien directametne.


�Alguna idea de porque no est� cogiendo bien el fichero?


Gracias

Jes�s

[[alternative HTML version deleted]]


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



--
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]



[[alternative HTML version deleted]]

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

Re: [R] gridExtra-arrangeGrob

2017-01-09 Thread John Kane via R-help
I'm not sure what the problem is but, if nothing else, it looks like you need 
to do 
library(grid)
It may be that an early version of ggplot2 or gridExtra was automatically 
loading grid and it no longer does.  


 

On Monday, January 9, 2017 1:08 AM, Felipe Carrillo via R-help 
 wrote:
 

  Hi;The code below used to work on my older version of gridExtra but doesn't 
work with the new version. Could someonegive me a hint on how to translate this 
code to the new version of gridExtra code? Thank you beforehand.
p1 <- ggplot(iris,aes(Sepal.Length,  Petal.Length, colour=Species)) +
geom_point() + theme_bw() + theme(legend.position='top')

 grid.arrange(p1, arrangeGrob(p1,p1,p1, heights=c(0.33, .33,.33), ncol=1), 
ncol=2)
 #Create 2 columns with different width using the 'widths' argument in the 
grid.arrange call
  grid.arrange(p1, arrangeGrob(p1,p1,p1, heights=c(0.33, .40,.27), ncol=1), 
ncol=2,widths=c(1.25,0.75))
p <- rectGrob()  
 grid.arrange(p, arrangeGrob(p,p,p, heights=c(0.33, .33,.33), ncol=1), ncol=2)

    [[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: [ESS] ess-16.10 / Error 2

2017-01-09 Thread Martin Maechler

> ESS project,
> One of the developers asked that I forward this.
> 
> I send the output of running 'make' on ess-16.10.
> 
> Sincerely,
> Eric Lindblad
> http://www.nurmi-labs.blogspot.com
> 
> 
> System: Slackware Linux (version 14.0)
> CPUs: Intel(R) Atom(TM) CPU N270 @1.60GHz
> 
> sh-4.2$ emacs --version
> GNU Emacs 24.2.1
> Copyright (C) 2012 Free Software Foundation, Inc.
> GNU Emacs comes with ABSOLUTELY NO WARRANTY.
> You may redistribute copies of Emacs
> under the terms of the GNU General Public License.
> For more information about these matters, see the file named COPYING.
> sh-4.2$ cd ess-16.10
> sh-4.2$ make
> cd etc; make all
> make[1]: Entering directory `/root/00/ess-16.10/etc'
> make[1]: Nothing to be done for `all'.
> make[1]: Leaving directory `/root/00/ess-16.10/etc'
> cd lisp; make all
> make[1]: Entering directory `/root/00/ess-16.10/lisp'
> emacs -batch -no-site-file -no-init-file -l ./ess-comp.el -f 
> batch-byte-compile ess-custom.el
> loading 'ess-compat ..
> loading 'ess-custom ..
> loading 'ess ..
> Symbol's function definition is void: defvar-local

Your emacs version 24.2 (2012)  is relatively old.
The oldest version I have had access relatively quickly, is 24.3
and if I type
C-h f  defvar-local

there, I get a "positive" result.

What happens if you start emacs and ask for  'defvar-local' (as
I did above)?

Also, you could apply the following patch to the ess sources --
and report back if it helps ! ---
It defines  defvar-local {the way it is defined in a recent version
of emacs, so it may not work necessarily work well in emacs 24.2
!} in case it is not found :


--- ess/lisp/ess-compat.el
+++ ess/lisp/ess-compat.el
@@ -278,6 +278,18 @@ mode is enabled.  Usually, such commands should use
 also checks the value of `use-empty-active-region'."
 (and transient-mark-mode mark-active)))
 
+(unless (fboundp 'defvar-local)
+  (defmacro defvar-local (var val  docstring)
+"Define VAR as a buffer-local variable with default value VAL.
+Like `defvar' but additionally marks the variable as being automatically
+buffer-local wherever it is set."
+(declare (debug defvar) (doc-string 3))
+;; Can't use backquote here, it's too early in the bootstrap.
+(list 'progn (list 'defvar var val docstring)
+  (list 'make-variable-buffer-local (list 'quote var)
+
+
+
 (provide 'ess-compat)


I hope this helps further!

Best regards,
Martin Maechler
ETH Zurich



> make[1]: *** [ess-custom.elc] Error 255
> make[1]: Leaving directory `/root/00/ess-16.10/lisp'
> make: *** [all] Error 2
> sh-4.2$

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


Re: [R] R install/libraries

2017-01-09 Thread Jeff Newmiller
You seem to have shafted yourself by thinking you need to run R as 
administrator... ever.

Use Run as Administrator to run the command line and delete your My Documents/R 
folder and then exit that command line and stay out of it and don't run R as 
administrator again, because by doing so you prevent yourself from using it as 
it is intended... non-administrator.

Don't make any effort to modify the system library. It is unnecessary and only 
causes trouble. If R doesn't re-create your personal library for you then you 
can re-create My Documents/R/win-library/3.3 yourself with File Explorer. 

https://stat.ethz.ch/pipermail/r-help//2013-March/349131.html

fortunes::fortune(337)

-- 
Sent from my phone. Please excuse my brevity.

On January 8, 2017 8:52:24 PM PST, Chris  wrote:
>I'd appreciate a tip on (re-)installing libraries for R on my windows
>machine 
>I have a windows (Windows 7)  computer and a recent version of R
>installed (3.3.2).  I discovered that when I install R libraries they
>install to the "my documents" folder rather than to "program files"This
>seems to also create problems installing the dependent libraries when a
>library installs.
>I'm presuming that R libraries are not installing to "program files"
>due to some permission/administrator privilege problems.
>I have tried manually copying files from my documents to program files
>which didn't seem to completely fix the problem.
>I also installed "r studio" but that hasn't resolved the problem of
>libraries not finding other libraries it depends on.A specific example,
>typically I use Frank Harrel's HMISC, however in my current
>installation it doesn't find "openssl". 
>installation tips appreciated.
> Chris Barker, Ph.D.
>Adjunct Associate Professor of Biostatistics - UIC-SPH
>and
>President and Owner
>Statistical Planning and Analysis Services, Inc.
>www.barkerstats.com
>415 609 7473 
>skype: barkerstats
>
>
>   [[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-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] testing whether clusters in a PCA plot are significantly different from one another

2017-01-09 Thread Marchesi, Julian
Dear Micheal

So I would be much better off just reporting the PCA as is and conclude what i 
can from plot

cheers

Julian

Julian R. Marchesi

Deputy Director and Professor of Clinical Microbiome Research at the  Centre 
for Digestive and Gut Health, Imperial College London, London W2 1NY Tel: +44 
(0)20 331 26197

and

Professor of Human Microbiome Research at the School of Biosciences, Museum 
Avenue, Cardiff University, Cardiff, CF10 3AT, Tel: +44 (0)29 208 74188, Fax: 
+44 (0)29 20874305, Mobile 07885 569144





From: Michael Friendly 
Sent: 07 January 2017 17:15
To: Marchesi, Julian; 'r-help@r-project.org'
Subject: Re: testing whether clusters in a PCA plot are significantly different 
from one another

Significance tests for group differences in a MANOVA of
lm(cbind(pc1, pc2) ~ group)

will get you what you want, but you are advised DON'T DO THIS, at least
without a huge grain of salt and a slew of mea culpas.
Otherwise, you are committing p-value abuse and contributing to the
notion that significance tests must be used to justify all conclusions.

The p-values will not be correct under standard normal theory of the
multivariate GLM because the pc1 and pc2 were chosen to optimize
the variance accounted for by their linear combinations and there
is no theory that can correct for this, AFAIK.  The cluster "group"
assignment was also chosen to optimize some (other) criterion.



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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