Re: [R] PLS in R

2017-12-06 Thread Bjørn-Helge Mevik
Margarida Soares  writes:

> library(pls)
> plsrcue<- plsr(cue~fb+cn+n+ph+fung+bact+resp, data = cue, ncomp=7,
> na.action = NULL, method = "kernelpls", scale=FALSE, validation = "LOO",
> model = TRUE, x = FALSE, y = FALSE)
> summary(plsrcue)
>
> and I got this output, where I think I can choose the number of components
> based on RMSEP, but how do I choose it?

There are no "hard" rules for how to choose the number of components,
but one rule of thumb is to stop when the RMSEP starts to flatten out,
or to increase.  In your case, I would say 4 components.  An easier way
to look at the RMSEP values is with plot(RMSEP(plsrcue)).

(There are some algorithms that can suggest the number of components for
you.  Two of those are implemented in the development of the plsr
package (hopefully released during Christmas).  You can check it out
here if you wish: https://github.com/bhmevik/pls .  Disclaimer: I am the
maintainer of the package. :) )

> - and also, how to proceed from here?

That depends on what you want to do/learn about the system you
aremodelling.  Many researchers in fields like spectroscopy or
chemometrics (where PLSR originated) plot loadings and scores and infer
things graphically.)

> - and how to make a correlation plot?

corrplot(plsrcue) - at least if you mean a correlation loadings plot.
See ?corrplot for details

> - what to do with the values, coefficients that I get in the Environment
> (pls values)

Again, that depends on what you want with your model.

-- 
Regards,
Bjørn-Helge Mevik


signature.asc
Description: PGP signature
__
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] parallel computing with foreach()

2017-12-06 Thread Peter Langfelder
Your code generates an error that has nothing to do with dopar. I have
no idea what your function stack is supposed to do; you may be
inadvertently calling utils::stack which would produce this kind of
error:

> stack(1:25, RAT = FALSE)
Error in data.frame(values = unlist(unname(x)), ind, stringsAsFactors = FALSE) :
  arguments imply differing number of rows: 25, 0

HTH,

Peter

On Wed, Dec 6, 2017 at 10:03 PM, Kumar Mainali  wrote:
> I have used foreach() for parallel computing but in the current problem, it
> is not working. Given the volume and type of the data involved in the
> analysis, I will try to give below the complete code without reproducible
> example.
>
> In short, each R environment will draw a set of separate files, perform the
> analysis and dump in separate folders.
>
> splist <- c("juoc", "juos", "jusc", "pico", "pifl", "pipo", "pire", "psme")
> covset <- c("PEN", "Thorn")
>
> foreach(i = 1:length(splist)) %:%
> foreach(j = 1:length(covset)) %dopar% {
>
> spname <- splist[i]; spname
> myTorP <- covset[j]; myTorP
>
> DataSpecies = data.frame(prsabs = rep(1, 10), lon = rep(30, 10), lat =
> rep(80, 10))
> myResp = as.numeric(DataSpecies[,1])
> myRespXY = DataSpecies[, c("lon", "lat")]
> # directory of a bunch of raster files specific to each R environment
> rastdir <- paste0(rootdir, "Current/", myTorP); rastdir
> rasterc = list.files(rastdir, pattern="\\.tif$", full.names = T)
> print(rasterc)
> myExplc = stack(rasterc, RAT=FALSE)
> }
>
> I get the following error message that most likely generates while stacking
> rasters because there are 25 rasters in the folder of each environment.
> Also, in the normal for loop, this reads all fine.
> Error in { :
>   task 1 failed - "arguments imply differing number of rows: 25, 0"
>
> 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] parallel computing with foreach()

2017-12-06 Thread Kumar Mainali
I have used foreach() for parallel computing but in the current problem, it
is not working. Given the volume and type of the data involved in the
analysis, I will try to give below the complete code without reproducible
example.

In short, each R environment will draw a set of separate files, perform the
analysis and dump in separate folders.

splist <- c("juoc", "juos", "jusc", "pico", "pifl", "pipo", "pire", "psme")
covset <- c("PEN", "Thorn")

foreach(i = 1:length(splist)) %:%
foreach(j = 1:length(covset)) %dopar% {

spname <- splist[i]; spname
myTorP <- covset[j]; myTorP

DataSpecies = data.frame(prsabs = rep(1, 10), lon = rep(30, 10), lat =
rep(80, 10))
myResp = as.numeric(DataSpecies[,1])
myRespXY = DataSpecies[, c("lon", "lat")]
# directory of a bunch of raster files specific to each R environment
rastdir <- paste0(rootdir, "Current/", myTorP); rastdir
rasterc = list.files(rastdir, pattern="\\.tif$", full.names = T)
print(rasterc)
myExplc = stack(rasterc, RAT=FALSE)
}

I get the following error message that most likely generates while stacking
rasters because there are 25 rasters in the folder of each environment.
Also, in the normal for loop, this reads all fine.
Error in { :
  task 1 failed - "arguments imply differing number of rows: 25, 0"

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] Remove

2017-12-06 Thread David Winsemius

> On Dec 6, 2017, at 4:27 PM, Ashta  wrote:
> 
> Thank you Ista! Worked fine.

Here's another (possibly more direct in its logic?):

 DM[ !ave(DM$x, DM$GR, FUN= function(x) {!length(unique(x))==1}), ]
  GR  x   y
5  B 25 321
6  B 25 512
7  B 25 123
8  B 25 451

-- 
David

> On Wed, Dec 6, 2017 at 5:59 PM, Ista Zahn  wrote:
>> Hi Ashta,
>> 
>> There are many ways to do it. Here is one:
>> 
>> vars <- sapply(split(DM$x, DM$GR), var)
>> DM[DM$GR %in% names(vars[vars > 0]), ]
>> 
>> Best
>> Ista
>> 
>> On Wed, Dec 6, 2017 at 6:58 PM, Ashta  wrote:
>>> Thank you Jeff,
>>> 
>>> subset( DM, "B" != x ), this works if I know the group only.
>>> But if I don't know that group in this case "B", how do I identify
>>> group(s) that  all elements of x have the same value?
>>> 
>>> On Wed, Dec 6, 2017 at 5:48 PM, Jeff Newmiller  
>>> wrote:
 subset( DM, "B" != x )
 
 This is covered in the Introduction to R document that comes with R.
 --
 Sent from my phone. Please excuse my brevity.
 
 On December 6, 2017 3:21:12 PM PST, David Winsemius 
  wrote:
> 
>> On Dec 6, 2017, at 3:15 PM, Ashta  wrote:
>> 
>> Hi all,
>> In a data set I have group(GR) and two variables   x and y. I want to
>> remove a  group that have  the same record for the x variable in each
>> row.
>> 
>> DM <- read.table( text='GR x y
>> A 25 125
>> A 23 135
>> A 14 145
>> A 12 230
>> B 25 321
>> B 25 512
>> B 25 123
>> B 25 451
>> C 11 521
>> C 14 235
>> C 15 258
>> C 10 654',header = TRUE, stringsAsFactors = FALSE)
>> 
>> In this example the output should contain group A and C  as group B
>> has   the same record  for the variable x .
>> 
>> The result will be
>> A 25 125
>> A 23 135
>> A 14 145
>> A 12 230
>> C 11 521
>> C 14 235
>> C 15 258
>> C 10 654
> 
> Try:
> 
> DM[ !duplicated(DM$x) , ]
>> 
>> How do I do it R?
>> Thank you.
>> 
>> __
>> 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
> 
> 'Any technology distinguishable from magic is insufficiently advanced.'
> -Gehm's Corollary to Clarke's Third Law
> 
> __
> 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.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

__
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] Remove

2017-12-06 Thread Ashta
Thank you Ista! Worked fine.

On Wed, Dec 6, 2017 at 5:59 PM, Ista Zahn  wrote:
> Hi Ashta,
>
> There are many ways to do it. Here is one:
>
> vars <- sapply(split(DM$x, DM$GR), var)
> DM[DM$GR %in% names(vars[vars > 0]), ]
>
> Best
> Ista
>
> On Wed, Dec 6, 2017 at 6:58 PM, Ashta  wrote:
>> Thank you Jeff,
>>
>> subset( DM, "B" != x ), this works if I know the group only.
>> But if I don't know that group in this case "B", how do I identify
>> group(s) that  all elements of x have the same value?
>>
>> On Wed, Dec 6, 2017 at 5:48 PM, Jeff Newmiller  
>> wrote:
>>> subset( DM, "B" != x )
>>>
>>> This is covered in the Introduction to R document that comes with R.
>>> --
>>> Sent from my phone. Please excuse my brevity.
>>>
>>> On December 6, 2017 3:21:12 PM PST, David Winsemius 
>>>  wrote:

> On Dec 6, 2017, at 3:15 PM, Ashta  wrote:
>
> Hi all,
> In a data set I have group(GR) and two variables   x and y. I want to
> remove a  group that have  the same record for the x variable in each
> row.
>
> DM <- read.table( text='GR x y
> A 25 125
> A 23 135
> A 14 145
> A 12 230
> B 25 321
> B 25 512
> B 25 123
> B 25 451
> C 11 521
> C 14 235
> C 15 258
> C 10 654',header = TRUE, stringsAsFactors = FALSE)
>
> In this example the output should contain group A and C  as group B
> has   the same record  for the variable x .
>
> The result will be
> A 25 125
> A 23 135
> A 14 145
> A 12 230
> C 11 521
> C 14 235
> C 15 258
> C 10 654

Try:

DM[ !duplicated(DM$x) , ]
>
> How do I do it R?
> Thank you.
>
> __
> 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

'Any technology distinguishable from magic is insufficiently advanced.'
  -Gehm's Corollary to Clarke's Third Law

__
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] Remove

2017-12-06 Thread Ista Zahn
Hi Ashta,

There are many ways to do it. Here is one:

vars <- sapply(split(DM$x, DM$GR), var)
DM[DM$GR %in% names(vars[vars > 0]), ]

Best
Ista

On Wed, Dec 6, 2017 at 6:58 PM, Ashta  wrote:
> Thank you Jeff,
>
> subset( DM, "B" != x ), this works if I know the group only.
> But if I don't know that group in this case "B", how do I identify
> group(s) that  all elements of x have the same value?
>
> On Wed, Dec 6, 2017 at 5:48 PM, Jeff Newmiller  
> wrote:
>> subset( DM, "B" != x )
>>
>> This is covered in the Introduction to R document that comes with R.
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>> On December 6, 2017 3:21:12 PM PST, David Winsemius  
>> wrote:
>>>
 On Dec 6, 2017, at 3:15 PM, Ashta  wrote:

 Hi all,
 In a data set I have group(GR) and two variables   x and y. I want to
 remove a  group that have  the same record for the x variable in each
 row.

 DM <- read.table( text='GR x y
 A 25 125
 A 23 135
 A 14 145
 A 12 230
 B 25 321
 B 25 512
 B 25 123
 B 25 451
 C 11 521
 C 14 235
 C 15 258
 C 10 654',header = TRUE, stringsAsFactors = FALSE)

 In this example the output should contain group A and C  as group B
 has   the same record  for the variable x .

 The result will be
 A 25 125
 A 23 135
 A 14 145
 A 12 230
 C 11 521
 C 14 235
 C 15 258
 C 10 654
>>>
>>>Try:
>>>
>>>DM[ !duplicated(DM$x) , ]

 How do I do it R?
 Thank you.

 __
 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
>>>
>>>'Any technology distinguishable from magic is insufficiently advanced.'
>>>  -Gehm's Corollary to Clarke's Third Law
>>>
>>>__
>>>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] Remove

2017-12-06 Thread Ashta
Thank you Jeff,

subset( DM, "B" != x ), this works if I know the group only.
But if I don't know that group in this case "B", how do I identify
group(s) that  all elements of x have the same value?

On Wed, Dec 6, 2017 at 5:48 PM, Jeff Newmiller  wrote:
> subset( DM, "B" != x )
>
> This is covered in the Introduction to R document that comes with R.
> --
> Sent from my phone. Please excuse my brevity.
>
> On December 6, 2017 3:21:12 PM PST, David Winsemius  
> wrote:
>>
>>> On Dec 6, 2017, at 3:15 PM, Ashta  wrote:
>>>
>>> Hi all,
>>> In a data set I have group(GR) and two variables   x and y. I want to
>>> remove a  group that have  the same record for the x variable in each
>>> row.
>>>
>>> DM <- read.table( text='GR x y
>>> A 25 125
>>> A 23 135
>>> A 14 145
>>> A 12 230
>>> B 25 321
>>> B 25 512
>>> B 25 123
>>> B 25 451
>>> C 11 521
>>> C 14 235
>>> C 15 258
>>> C 10 654',header = TRUE, stringsAsFactors = FALSE)
>>>
>>> In this example the output should contain group A and C  as group B
>>> has   the same record  for the variable x .
>>>
>>> The result will be
>>> A 25 125
>>> A 23 135
>>> A 14 145
>>> A 12 230
>>> C 11 521
>>> C 14 235
>>> C 15 258
>>> C 10 654
>>
>>Try:
>>
>>DM[ !duplicated(DM$x) , ]
>>>
>>> How do I do it R?
>>> Thank you.
>>>
>>> __
>>> 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
>>
>>'Any technology distinguishable from magic is insufficiently advanced.'
>>  -Gehm's Corollary to Clarke's Third Law
>>
>>__
>>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] Remove

2017-12-06 Thread Jeff Newmiller
subset( DM, "B" != x )

This is covered in the Introduction to R document that comes with R.
-- 
Sent from my phone. Please excuse my brevity.

On December 6, 2017 3:21:12 PM PST, David Winsemius  
wrote:
>
>> On Dec 6, 2017, at 3:15 PM, Ashta  wrote:
>> 
>> Hi all,
>> In a data set I have group(GR) and two variables   x and y. I want to
>> remove a  group that have  the same record for the x variable in each
>> row.
>> 
>> DM <- read.table( text='GR x y
>> A 25 125
>> A 23 135
>> A 14 145
>> A 12 230
>> B 25 321
>> B 25 512
>> B 25 123
>> B 25 451
>> C 11 521
>> C 14 235
>> C 15 258
>> C 10 654',header = TRUE, stringsAsFactors = FALSE)
>> 
>> In this example the output should contain group A and C  as group B
>> has   the same record  for the variable x .
>> 
>> The result will be
>> A 25 125
>> A 23 135
>> A 14 145
>> A 12 230
>> C 11 521
>> C 14 235
>> C 15 258
>> C 10 654
>
>Try:
>
>DM[ !duplicated(DM$x) , ]
>> 
>> How do I do it R?
>> Thank you.
>> 
>> __
>> 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
>
>'Any technology distinguishable from magic is insufficiently advanced.'
>  -Gehm's Corollary to Clarke's Third Law
>
>__
>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] Remove

2017-12-06 Thread Ashta
Thank you David.
This will not work.  Tthis removes only duplicate records.
DM[ !duplicated(DM$x) , ]

My goal is to remove the group if all elements of x in that group have
 the same value.


On Wed, Dec 6, 2017 at 5:21 PM, David Winsemius  wrote:
>
>> On Dec 6, 2017, at 3:15 PM, Ashta  wrote:
>>
>> Hi all,
>> In a data set I have group(GR) and two variables   x and y. I want to
>> remove a  group that have  the same record for the x variable in each
>> row.
>>
>> DM <- read.table( text='GR x y
>> A 25 125
>> A 23 135
>> A 14 145
>> A 12 230
>> B 25 321
>> B 25 512
>> B 25 123
>> B 25 451
>> C 11 521
>> C 14 235
>> C 15 258
>> C 10 654',header = TRUE, stringsAsFactors = FALSE)
>>
>> In this example the output should contain group A and C  as group B
>> has   the same record  for the variable x .
>>
>> The result will be
>> A 25 125
>> A 23 135
>> A 14 145
>> A 12 230
>> C 11 521
>> C 14 235
>> C 15 258
>> C 10 654
>
> Try:
>
> DM[ !duplicated(DM$x) , ]
>>
>> How do I do it R?
>> Thank you.
>>
>> __
>> 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
>
> 'Any technology distinguishable from magic is insufficiently advanced.'   
> -Gehm's Corollary to Clarke's Third Law
>
>
>
>
>

__
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] Remove

2017-12-06 Thread David Winsemius

> On Dec 6, 2017, at 3:15 PM, Ashta  wrote:
> 
> Hi all,
> In a data set I have group(GR) and two variables   x and y. I want to
> remove a  group that have  the same record for the x variable in each
> row.
> 
> DM <- read.table( text='GR x y
> A 25 125
> A 23 135
> A 14 145
> A 12 230
> B 25 321
> B 25 512
> B 25 123
> B 25 451
> C 11 521
> C 14 235
> C 15 258
> C 10 654',header = TRUE, stringsAsFactors = FALSE)
> 
> In this example the output should contain group A and C  as group B
> has   the same record  for the variable x .
> 
> The result will be
> A 25 125
> A 23 135
> A 14 145
> A 12 230
> C 11 521
> C 14 235
> C 15 258
> C 10 654

Try:

DM[ !duplicated(DM$x) , ]
> 
> How do I do it R?
> Thank you.
> 
> __
> 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

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

__
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] Remove

2017-12-06 Thread Ashta
Hi all,
In a data set I have group(GR) and two variables   x and y. I want to
remove a  group that have  the same record for the x variable in each
row.

DM <- read.table( text='GR x y
A 25 125
A 23 135
A 14 145
A 12 230
B 25 321
B 25 512
B 25 123
B 25 451
C 11 521
C 14 235
C 15 258
C 10 654',header = TRUE, stringsAsFactors = FALSE)

In this example the output should contain group A and C  as group B
has   the same record  for the variable x .

The result will be
A 25 125
A 23 135
A 14 145
A 12 230
C 11 521
C 14 235
C 15 258
C 10 654

How do I do it R?
Thank you.

__
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] STATA base de datos

2017-12-06 Thread Carlos Ortega
Sí, estás un tanto al límite de la capacidad de tu ordenador.
Varias cosas que no has comentado:

   - ¿Qué versión de R usas?
   - ¿Usas una versión de 32bits ó 64bits?.
   - ¿Windows?, supongo.
  - En Windows puedes ver los recursos de tu máquina y confirmar que
  cuando tienes el conjunto cargado en R estás muy al límite de tu RAM.

Con todo esto cosas que puedes hacer:

   - Hacer un muestreo. Nada más cargar el conjunto puedes hacer algo como
   esto:

# De esta forma te quedas con un 75% de los datos.

datos_samp <- datos[ sample(1:nrow(datos), nrow(datos)*0.75) , ]

rm(datos)

Y a partir de aquí ya trabajas con datos_samp


   - ​Puedes convertir tus datos​ a data.table (no sé si lo has usado
   antes... que permite comprimir el data.frame. Lo harías así:


library(foreign)

​library(data.table)​

datos = as.data.
​table​
(read.dta("private98-06more_than9.dta"))


Y a partir ya trabajar con "datos" como data.table.


Saludos,
Carlos Ortega
www.qualityexcellence.es


El 6 de diciembre de 2017, 22:03, Javier Marcuzzi <
javier.ruben.marcu...@gmail.com> escribió:

> Estimados
>
> Pienso que falta memoria, aparte de las sugerencias ya aportadas, de
> pronto se podrían colocar algunos rm(liberar_de_memoria), para no tener
> ocupado espacio que no es requerido porque ese paso ya fue realizado.
>
> Javier Rubén Marcuzzi
>
> El 6 de diciembre de 2017, 13:58, Antonio Rodriguez Andres <
> antoniorodriguezandre...@gmail.com> escribió:
>
>> Carlos
>> He tecleado lo siguiente para leer el fichero de Stata
>>
>> library(foreign)
>> datos = as.data.frame(read.dta("private98-06more_than9.dta"))
>> save(datos, file="data.RData")
>> load("data.RData")
>> dim(datos)
>> class(datos)
>>
>> Tiene ese numero de filas y columnas que son las variables.
>>
>>  dim(datos)[1] 9418455  28
>>
>> Mi memoria RAM es 4GB, pero he conseguido leer los datos, y tambien
>> hacer un histograma de age, aunque es dificil ver algo por la cantidad
>> de individuos que hay en la base de datos.
>>
>> hist(datos$age, main="Titulo", xlab="Age")
>>
>> Ya cuando intento ver los valores perdidos con
>>
>> is.na(datos) me sale error
>>
>>
>> Error: cannot allocate vector of size 1006.0 Mb
>>
>> Saludos
>>
>>
>>
>> 2017-12-06 13:49 GMT+01:00 Carlos Ortega :
>>
>> > OK.
>> > Lee primero los datos, guarda el data.frame (.RData o en un .csv o lo
>> que
>> > quieras).
>> > Sal de RStudio o incluso reinicia el ordenador para liberar el máximo de
>> > memoria.
>> >
>> > Y comienza una nueva sesión con RStudio cargando los datos con
>> "fread()".
>> > Por otro lado, este conjunto de datos ¿cómo es de grande (filas y
>> > columnas)?.
>> >
>> > ¿Y qué máquina tienes?. ¿Cuanta RAM tienes?.
>> >
>> > Gracias,
>> > Carlos.
>> >
>> >
>> > El 6 de diciembre de 2017, 13:42, Antonio Rodriguez Andres <
>> > antoniorodriguezandre...@gmail.com> escribió:
>> >
>> >> Carlos
>> >>
>> >> use library foreign, y read.dta. Consegui leer los datos. Pero demora
>> >> mucho. explore los datos con head y tail, y con summary. Conseguis los
>> >> resultados. Muy lento. Una cosa a. hacer es un histograma y ahi ya
>> ponia
>> >> cannot allocate memory.
>> >>
>> >> Pense que podria leer los datos de otra manera mas eficiente.
>> >>
>> >> El 6/12/2017 13:32, "Carlos Ortega" 
>> escribió:
>> >>
>> >>> Pero entonces, ¿has leído ya el fichero en RStudio? ¿lo has convertido
>> >>> de Stata a csv o algún otro formato que con el que puedas trabajar en
>> >>> RStudio?.
>> >>> ¿O ahora el problema es que has convertido el fichero pero no puedes
>> >>> hacer ningún tipo de análisis porque tu equipo no tiene suficientes
>> >>> recursos?...
>> >>>
>> >>> Gracias,
>> >>> Carlos.
>> >>>
>> >>> El 6 de diciembre de 2017, 13:09, Antonio Rodriguez Andres <
>> >>> antoniorodriguezandre...@gmail.com> escribió:
>> >>>
>>  He llegado hacer un summary o algo asi. Despues de leerlo pero tarda
>>  mucho.
>>  Y si hago un histograma de una variable edad, hay colapsa.
>> 
>>  El 6/12/2017 13:05, "Antonio Rodriguez Andres" <
>>  antoniorodriguezandre...@gmail.com> escribió:
>> 
>>  > Freddy
>>  >
>>  > el archivo lo leo en segundos en Stata. puedo probar el paquete
>>  heaven.
>>  > Pero si recuerdo me dio problemas en RStudio
>>  >
>>  > El 6/12/2017 13:03, "Freddy Omar López Quintero" <
>>  freddy.vat...@gmail.com>
>>  > escribió:
>>  >
>>  >> El mié, 06-12-2017 a las 12:55 +0100, Antonio Rodriguez Andres
>>  escribió:
>>  >>
>>  >> me sale problema
>>  >> de memoria.
>>  >>
>>  >>
>>  >> Pregunta posiblemente tonta: ¿tienes suficiente memoria para
>>  procesar un
>>  >> archivo de tales dimensiones? Puede que ni aún cambiando la manera
>>  de leer
>>  >> el archivo realmente lo puedas procesar.
>>  >>
>>  >>
>>  >> Entonces, una solucion es intentar pasar de STATA a CSV y luego
>> usar
>>  el
>>  >> comando 

Re: [R] Coeficients estimation in a repeated measures linear model

2017-12-06 Thread Jim Lemon
Hi Sergio,
You seem to be aiming for a univariate repeated measures analysis.
Maybe this will help:

subno<-rep(1:6,2)
dat <- data.frame(subno=rep(1:6,2),,vals = c(ctrl, ttd),
   cond = c(rep("ctrl", 6), rep("ttd", 6)), ind = factor(rep(1:6, 2)))
fit<-aov(vals~ind+cond+Error(subno),data=dat)
fit
summary(fit)

Note that the assumptions of this model are easy to violate.

Jim


On Thu, Dec 7, 2017 at 1:17 AM, Sergio PV  wrote:
> Dear Users,
>
> I am trying to understand the inner workings of a repeated measures linear
> model. Take for example a situation with 6 individuals sampled twice for
> two conditions (control and treated).
>
> set.seed(12)
> ctrl <- rnorm(n = 6, mean = 2)
> ttd <- rnorm(n = 6, mean = 10)
> dat <- data.frame(vals = c(ctrl, ttd),
>   group = c(rep("ctrl", 6), rep("ttd", 6)),
>   ind = factor(rep(1:6, 2)))
>
> fit <- lm(vals ~ ind + group, data = dat)
> model.matrix(~ ind + group, data = dat)
>
> I am puzzled on how the coeficients are calculated. For example, according
> to the model matrix, I thought the intercept would be individual 1 control.
> But that is clearly not the case.
> For the last coeficient, I understand it as the mean of all differences
> between treated vs control at each individual.
>
> I would greatly appreciate if someone could clarify to me how the
> coefficients in this situation are estimated.
>
> Thanks
>
> [[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-es] STATA base de datos

2017-12-06 Thread Javier Marcuzzi
Estimados

Pienso que falta memoria, aparte de las sugerencias ya aportadas, de pronto
se podrían colocar algunos rm(liberar_de_memoria), para no tener ocupado
espacio que no es requerido porque ese paso ya fue realizado.

Javier Rubén Marcuzzi

El 6 de diciembre de 2017, 13:58, Antonio Rodriguez Andres <
antoniorodriguezandre...@gmail.com> escribió:

> Carlos
> He tecleado lo siguiente para leer el fichero de Stata
>
> library(foreign)
> datos = as.data.frame(read.dta("private98-06more_than9.dta"))
> save(datos, file="data.RData")
> load("data.RData")
> dim(datos)
> class(datos)
>
> Tiene ese numero de filas y columnas que son las variables.
>
>  dim(datos)[1] 9418455  28
>
> Mi memoria RAM es 4GB, pero he conseguido leer los datos, y tambien
> hacer un histograma de age, aunque es dificil ver algo por la cantidad
> de individuos que hay en la base de datos.
>
> hist(datos$age, main="Titulo", xlab="Age")
>
> Ya cuando intento ver los valores perdidos con
>
> is.na(datos) me sale error
>
>
> Error: cannot allocate vector of size 1006.0 Mb
>
> Saludos
>
>
>
> 2017-12-06 13:49 GMT+01:00 Carlos Ortega :
>
> > OK.
> > Lee primero los datos, guarda el data.frame (.RData o en un .csv o lo que
> > quieras).
> > Sal de RStudio o incluso reinicia el ordenador para liberar el máximo de
> > memoria.
> >
> > Y comienza una nueva sesión con RStudio cargando los datos con "fread()".
> > Por otro lado, este conjunto de datos ¿cómo es de grande (filas y
> > columnas)?.
> >
> > ¿Y qué máquina tienes?. ¿Cuanta RAM tienes?.
> >
> > Gracias,
> > Carlos.
> >
> >
> > El 6 de diciembre de 2017, 13:42, Antonio Rodriguez Andres <
> > antoniorodriguezandre...@gmail.com> escribió:
> >
> >> Carlos
> >>
> >> use library foreign, y read.dta. Consegui leer los datos. Pero demora
> >> mucho. explore los datos con head y tail, y con summary. Conseguis los
> >> resultados. Muy lento. Una cosa a. hacer es un histograma y ahi ya ponia
> >> cannot allocate memory.
> >>
> >> Pense que podria leer los datos de otra manera mas eficiente.
> >>
> >> El 6/12/2017 13:32, "Carlos Ortega" 
> escribió:
> >>
> >>> Pero entonces, ¿has leído ya el fichero en RStudio? ¿lo has convertido
> >>> de Stata a csv o algún otro formato que con el que puedas trabajar en
> >>> RStudio?.
> >>> ¿O ahora el problema es que has convertido el fichero pero no puedes
> >>> hacer ningún tipo de análisis porque tu equipo no tiene suficientes
> >>> recursos?...
> >>>
> >>> Gracias,
> >>> Carlos.
> >>>
> >>> El 6 de diciembre de 2017, 13:09, Antonio Rodriguez Andres <
> >>> antoniorodriguezandre...@gmail.com> escribió:
> >>>
>  He llegado hacer un summary o algo asi. Despues de leerlo pero tarda
>  mucho.
>  Y si hago un histograma de una variable edad, hay colapsa.
> 
>  El 6/12/2017 13:05, "Antonio Rodriguez Andres" <
>  antoniorodriguezandre...@gmail.com> escribió:
> 
>  > Freddy
>  >
>  > el archivo lo leo en segundos en Stata. puedo probar el paquete
>  heaven.
>  > Pero si recuerdo me dio problemas en RStudio
>  >
>  > El 6/12/2017 13:03, "Freddy Omar López Quintero" <
>  freddy.vat...@gmail.com>
>  > escribió:
>  >
>  >> El mié, 06-12-2017 a las 12:55 +0100, Antonio Rodriguez Andres
>  escribió:
>  >>
>  >> me sale problema
>  >> de memoria.
>  >>
>  >>
>  >> Pregunta posiblemente tonta: ¿tienes suficiente memoria para
>  procesar un
>  >> archivo de tales dimensiones? Puede que ni aún cambiando la manera
>  de leer
>  >> el archivo realmente lo puedas procesar.
>  >>
>  >>
>  >> Entonces, una solucion es intentar pasar de STATA a CSV y luego
> usar
>  el
>  >> comando fread, y finalmente cargar los datos como RData
>  >>
>  >>
>  >> ¿Has probado el paquete haven y específicamente su función
> read_dta?
>  >> Parece que es bastante más eficiente que la de foreign y preserva
> más
>  >> características que trae el formato de stata.
>  >>
>  >> ¡Ojalá algo sirva!
>  >>
>  >> ¡Salud!
>  >>
>  >> --
>  >>
>  >> «...homines autem hominum causa esse generatos...»
>  >>
>  >> Cicero
>  >>
>  >
> 
>  [[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
> >>>
> >>
> >
> >
> > --
> > Saludos,
> > Carlos Ortega
> > www.qualityexcellence.es
> >
>
>
>
> --
>
> Member, Editorial Committee, *The Economic and Labour Relations Review* (a
> SAGE journal)
>
> http://elr.sagepub.com/
>
> Member, Editorial Committee, African Journal of Economic and Management
> Studies
>
> http://emeraldgrouppublishing.com/products/journals/
> editorial_team.htm?id=ajems
>
> 

Re: [R] Odd dates generated in Forecasts

2017-12-06 Thread David Winsemius

> On Dec 6, 2017, at 11:09 AM, Paul Bernal  wrote:
> 
> Thank you very much David. As a matter of fact, I solved it by doing the 
> following:
> 
> MyTimeSeriesObj <- ts(MyData, freq=365.25/7, 
> start=decimal_date(mdy("01-04-2003")))
> 
> After doing that adjustment, my forecasts dates started from 2017 on.

Not clear what MyData consisted of. If it was the factor variable in the 
`dataset` object in your earlier communication, then you gave the `ts`  
function garbage. The fact that it was labeled to your liking would not create 
a palatable result.

-- 
David.
> 
> Cheers,
> 
> Paul
> 
> 2017-12-06 12:03 GMT-05:00 David Winsemius :
> 
> > On Dec 6, 2017, at 5:07 AM, Paul Bernal  wrote:
> >
> > Dear friends,
> >
> > I have a weekly time series which starts on Jan 4th, 2003 and ends on
> > december 31st, 2016.
> >
> > I set up my ts object as follows:
> >
> > MyTseries <- ts(mydataset, start=2003, end=2016, frequency=52)
> >
> > MyModel <- auto.arima(MyTseries, d=1, D=1)
> >
> > MyModelForecast <- forecast (MyModel, h=12)
> >
> > Since my last observation was on december 31st, 2016 I expected my forecast
> > date to start on 2017, but instead it returned odd dates.
> >
> > This is my dataset
> >
> > dput(dataset):
> >
> > structure(list(Date = structure(c(8L, 22L, 36L, 50L, 64L, 78L,
> > 92L, 106L, 120L, 134L, 148L, 162L, 176L, 190L, 204L, 218L, 232L,
> > 246L, 260L, 274L, 288L, 302L, 316L, 330L, 344L, 358L, 372L, 386L,
> > 400L, 414L, 428L, 442L, 456L, 470L, 484L, 498L, 512L, 526L, 540L,
> > 554L, 568L, 582L, 596L, 610L, 624L, 638L, 652L, 666L, 680L, 694L,
> > 708L, 722L, 5L, 19L, 33L, 47L, 61L, 75L, 89L, 103L, 117L, 130L,
> > 144L, 158L, 172L, 186L, 200L, 214L, 228L, 242L, 256L, 270L, 284L,
> > 298L, 312L, 326L, 340L, 354L, 368L, 382L, 396L, 410L, 424L, 438L,
> > 452L, 466L, 480L, 494L, 508L, 522L, 536L, 550L, 564L, 578L, 592L,
> > 606L, 620L, 634L, 648L, 662L, 676L, 690L, 704L, 718L, 1L, 15L,
> > 29L, 43L, 57L, 71L, 85L, 99L, 113L, 127L, 141L, 155L, 169L, 183L,
> > 197L, 211L, 225L, 239L, 253L, 267L, 281L, 295L, 309L, 323L, 337L,
> > 351L, 365L, 379L, 393L, 407L, 421L, 435L, 449L, 463L, 477L, 491L,
> > 505L, 519L, 533L, 547L, 561L, 575L, 589L, 603L, 617L, 631L, 645L,
> > 659L, 673L, 687L, 701L, 715L, 729L, 13L, 27L, 41L, 55L, 69L,
> > 83L, 97L, 111L, 126L, 140L, 154L, 168L, 182L, 196L, 210L, 224L,
> > 238L, 252L, 266L, 280L, 294L, 308L, 322L, 336L, 350L, 364L, 378L,
> > 392L, 406L, 420L, 434L, 448L, 462L, 476L, 490L, 504L, 518L, 532L,
> > 546L, 560L, 574L, 588L, 602L, 616L, 630L, 644L, 658L, 672L, 686L,
> > 700L, 714L, 728L, 12L, 26L, 40L, 54L, 68L, 82L, 96L, 110L, 124L,
> > 138L, 152L, 166L, 180L, 194L, 208L, 222L, 236L, 250L, 264L, 278L,
> > 292L, 306L, 320L, 334L, 348L, 362L, 376L, 390L, 404L, 418L, 432L,
> > 446L, 460L, 474L, 488L, 502L, 516L, 530L, 544L, 558L, 572L, 586L,
> > 600L, 614L, 628L, 642L, 656L, 670L, 684L, 698L, 712L, 726L, 10L,
> > 24L, 38L, 52L, 66L, 80L, 94L, 108L, 121L, 135L, 149L, 163L, 177L,
> > 191L, 205L, 219L, 233L, 247L, 261L, 275L, 289L, 303L, 317L, 331L,
> > 345L, 359L, 373L, 387L, 401L, 415L, 429L, 443L, 457L, 471L, 485L,
> > 499L, 513L, 527L, 541L, 555L, 569L, 583L, 597L, 611L, 625L, 639L,
> > 653L, 667L, 681L, 695L, 709L, 723L, 6L, 20L, 34L, 48L, 62L, 76L,
> > 90L, 104L, 118L, 132L, 146L, 160L, 174L, 188L, 202L, 216L, 230L,
> > 244L, 258L, 272L, 286L, 300L, 314L, 328L, 342L, 356L, 370L, 384L,
> > 398L, 412L, 426L, 440L, 454L, 468L, 482L, 496L, 510L, 524L, 538L,
> > 552L, 566L, 580L, 594L, 608L, 622L, 636L, 650L, 664L, 678L, 692L,
> > 706L, 720L, 3L, 17L, 31L, 45L, 59L, 73L, 87L, 101L, 115L, 131L,
> > 145L, 159L, 173L, 187L, 201L, 215L, 229L, 243L, 257L, 271L, 285L,
> > 299L, 313L, 327L, 341L, 355L, 369L, 383L, 397L, 411L, 425L, 439L,
> > 453L, 467L, 481L, 495L, 509L, 523L, 537L, 551L, 565L, 579L, 593L,
> > 607L, 621L, 635L, 649L, 663L, 677L, 691L, 705L, 719L, 2L, 16L,
> > 30L, 44L, 58L, 72L, 86L, 100L, 114L, 128L, 142L, 156L, 170L,
> > 184L, 198L, 212L, 226L, 240L, 254L, 268L, 282L, 296L, 310L, 324L,
> > 338L, 352L, 366L, 380L, 394L, 408L, 422L, 436L, 450L, 464L, 478L,
> > 492L, 506L, 520L, 534L, 548L, 562L, 576L, 590L, 604L, 618L, 632L,
> > 646L, 660L, 674L, 688L, 702L, 716L, 730L, 14L, 28L, 42L, 56L,
> > 70L, 84L, 98L, 112L, 125L, 139L, 153L, 167L, 181L, 195L, 209L,
> > 223L, 237L, 251L, 265L, 279L, 293L, 307L, 321L, 335L, 349L, 363L,
> > 377L, 391L, 405L, 419L, 433L, 447L, 461L, 475L, 489L, 503L, 517L,
> > 531L, 545L, 559L, 573L, 587L, 601L, 615L, 629L, 643L, 657L, 671L,
> > 685L, 699L, 713L, 727L, 11L, 25L, 39L, 53L, 67L, 81L, 95L, 109L,
> > 123L, 137L, 151L, 165L, 179L, 193L, 207L, 221L, 235L, 249L, 263L,
> > 277L, 291L, 305L, 319L, 333L, 347L, 361L, 375L, 389L, 403L, 417L,
> > 431L, 445L, 459L, 473L, 487L, 501L, 515L, 529L, 543L, 557L, 571L,
> > 585L, 599L, 613L, 627L, 641L, 655L, 669L, 683L, 697L, 711L, 725L,
> > 9L, 23L, 37L, 51L, 65L, 79L, 93L, 107L, 122L, 136L, 150L, 164L,
> > 178L, 192L, 

Re: [R] Odd dates generated in Forecasts

2017-12-06 Thread Paul Bernal
Thank you very much David. As a matter of fact, I solved it by doing the
following:

MyTimeSeriesObj <- ts(MyData, freq=365.25/7,
start=decimal_date(mdy("01-04-2003")))

After doing that adjustment, my forecasts dates started from 2017 on.

Cheers,

Paul

2017-12-06 12:03 GMT-05:00 David Winsemius :

>
> > On Dec 6, 2017, at 5:07 AM, Paul Bernal  wrote:
> >
> > Dear friends,
> >
> > I have a weekly time series which starts on Jan 4th, 2003 and ends on
> > december 31st, 2016.
> >
> > I set up my ts object as follows:
> >
> > MyTseries <- ts(mydataset, start=2003, end=2016, frequency=52)
> >
> > MyModel <- auto.arima(MyTseries, d=1, D=1)
> >
> > MyModelForecast <- forecast (MyModel, h=12)
> >
> > Since my last observation was on december 31st, 2016 I expected my
> forecast
> > date to start on 2017, but instead it returned odd dates.
> >
> > This is my dataset
> >
> > dput(dataset):
> >
> > structure(list(Date = structure(c(8L, 22L, 36L, 50L, 64L, 78L,
> > 92L, 106L, 120L, 134L, 148L, 162L, 176L, 190L, 204L, 218L, 232L,
> > 246L, 260L, 274L, 288L, 302L, 316L, 330L, 344L, 358L, 372L, 386L,
> > 400L, 414L, 428L, 442L, 456L, 470L, 484L, 498L, 512L, 526L, 540L,
> > 554L, 568L, 582L, 596L, 610L, 624L, 638L, 652L, 666L, 680L, 694L,
> > 708L, 722L, 5L, 19L, 33L, 47L, 61L, 75L, 89L, 103L, 117L, 130L,
> > 144L, 158L, 172L, 186L, 200L, 214L, 228L, 242L, 256L, 270L, 284L,
> > 298L, 312L, 326L, 340L, 354L, 368L, 382L, 396L, 410L, 424L, 438L,
> > 452L, 466L, 480L, 494L, 508L, 522L, 536L, 550L, 564L, 578L, 592L,
> > 606L, 620L, 634L, 648L, 662L, 676L, 690L, 704L, 718L, 1L, 15L,
> > 29L, 43L, 57L, 71L, 85L, 99L, 113L, 127L, 141L, 155L, 169L, 183L,
> > 197L, 211L, 225L, 239L, 253L, 267L, 281L, 295L, 309L, 323L, 337L,
> > 351L, 365L, 379L, 393L, 407L, 421L, 435L, 449L, 463L, 477L, 491L,
> > 505L, 519L, 533L, 547L, 561L, 575L, 589L, 603L, 617L, 631L, 645L,
> > 659L, 673L, 687L, 701L, 715L, 729L, 13L, 27L, 41L, 55L, 69L,
> > 83L, 97L, 111L, 126L, 140L, 154L, 168L, 182L, 196L, 210L, 224L,
> > 238L, 252L, 266L, 280L, 294L, 308L, 322L, 336L, 350L, 364L, 378L,
> > 392L, 406L, 420L, 434L, 448L, 462L, 476L, 490L, 504L, 518L, 532L,
> > 546L, 560L, 574L, 588L, 602L, 616L, 630L, 644L, 658L, 672L, 686L,
> > 700L, 714L, 728L, 12L, 26L, 40L, 54L, 68L, 82L, 96L, 110L, 124L,
> > 138L, 152L, 166L, 180L, 194L, 208L, 222L, 236L, 250L, 264L, 278L,
> > 292L, 306L, 320L, 334L, 348L, 362L, 376L, 390L, 404L, 418L, 432L,
> > 446L, 460L, 474L, 488L, 502L, 516L, 530L, 544L, 558L, 572L, 586L,
> > 600L, 614L, 628L, 642L, 656L, 670L, 684L, 698L, 712L, 726L, 10L,
> > 24L, 38L, 52L, 66L, 80L, 94L, 108L, 121L, 135L, 149L, 163L, 177L,
> > 191L, 205L, 219L, 233L, 247L, 261L, 275L, 289L, 303L, 317L, 331L,
> > 345L, 359L, 373L, 387L, 401L, 415L, 429L, 443L, 457L, 471L, 485L,
> > 499L, 513L, 527L, 541L, 555L, 569L, 583L, 597L, 611L, 625L, 639L,
> > 653L, 667L, 681L, 695L, 709L, 723L, 6L, 20L, 34L, 48L, 62L, 76L,
> > 90L, 104L, 118L, 132L, 146L, 160L, 174L, 188L, 202L, 216L, 230L,
> > 244L, 258L, 272L, 286L, 300L, 314L, 328L, 342L, 356L, 370L, 384L,
> > 398L, 412L, 426L, 440L, 454L, 468L, 482L, 496L, 510L, 524L, 538L,
> > 552L, 566L, 580L, 594L, 608L, 622L, 636L, 650L, 664L, 678L, 692L,
> > 706L, 720L, 3L, 17L, 31L, 45L, 59L, 73L, 87L, 101L, 115L, 131L,
> > 145L, 159L, 173L, 187L, 201L, 215L, 229L, 243L, 257L, 271L, 285L,
> > 299L, 313L, 327L, 341L, 355L, 369L, 383L, 397L, 411L, 425L, 439L,
> > 453L, 467L, 481L, 495L, 509L, 523L, 537L, 551L, 565L, 579L, 593L,
> > 607L, 621L, 635L, 649L, 663L, 677L, 691L, 705L, 719L, 2L, 16L,
> > 30L, 44L, 58L, 72L, 86L, 100L, 114L, 128L, 142L, 156L, 170L,
> > 184L, 198L, 212L, 226L, 240L, 254L, 268L, 282L, 296L, 310L, 324L,
> > 338L, 352L, 366L, 380L, 394L, 408L, 422L, 436L, 450L, 464L, 478L,
> > 492L, 506L, 520L, 534L, 548L, 562L, 576L, 590L, 604L, 618L, 632L,
> > 646L, 660L, 674L, 688L, 702L, 716L, 730L, 14L, 28L, 42L, 56L,
> > 70L, 84L, 98L, 112L, 125L, 139L, 153L, 167L, 181L, 195L, 209L,
> > 223L, 237L, 251L, 265L, 279L, 293L, 307L, 321L, 335L, 349L, 363L,
> > 377L, 391L, 405L, 419L, 433L, 447L, 461L, 475L, 489L, 503L, 517L,
> > 531L, 545L, 559L, 573L, 587L, 601L, 615L, 629L, 643L, 657L, 671L,
> > 685L, 699L, 713L, 727L, 11L, 25L, 39L, 53L, 67L, 81L, 95L, 109L,
> > 123L, 137L, 151L, 165L, 179L, 193L, 207L, 221L, 235L, 249L, 263L,
> > 277L, 291L, 305L, 319L, 333L, 347L, 361L, 375L, 389L, 403L, 417L,
> > 431L, 445L, 459L, 473L, 487L, 501L, 515L, 529L, 543L, 557L, 571L,
> > 585L, 599L, 613L, 627L, 641L, 655L, 669L, 683L, 697L, 711L, 725L,
> > 9L, 23L, 37L, 51L, 65L, 79L, 93L, 107L, 122L, 136L, 150L, 164L,
> > 178L, 192L, 206L, 220L, 234L, 248L, 262L, 276L, 290L, 304L, 318L,
> > 332L, 346L, 360L, 374L, 388L, 402L, 416L, 430L, 444L, 458L, 472L,
> > 486L, 500L, 514L, 528L, 542L, 556L, 570L, 584L, 598L, 612L, 626L,
> > 640L, 654L, 668L, 682L, 696L, 710L, 724L, 7L, 21L, 35L, 49L,
> > 63L, 77L, 91L, 105L, 119L, 133L, 147L, 161L, 175L, 189L, 203L,
> > 217L, 231L, 245L, 259L, 273L, 287L, 

Re: [R] Coeficients estimation in a repeated measures linear model

2017-12-06 Thread Bert Gunter
Sergio:

1. You do not have a "repeated measures linear model" .

2. This list is not designed to replace your own efforts to learn the
necessary R background, in this case, factor coding and contrasts in linear
models. I would suggest you spend some time with any of the many fine R
linear model tutorials that can be found on the web. Here is one place to
look for suggestions: https://www.rstudio.com/online-learning/#R  . But
just googling around you'll probably find something that may suit even
better.

3. This list is primarily for R programming help, not statistics help
(although they do sometimes intersect). For the latter, try a statistics
site like stats.stackexchange.com  .

4. Finally, as always, consulting with a local statistical resource, if
available, is always worth considering.

HTH.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Wed, Dec 6, 2017 at 6:17 AM, Sergio PV  wrote:

> Dear Users,
>
> I am trying to understand the inner workings of a repeated measures linear
> model. Take for example a situation with 6 individuals sampled twice for
> two conditions (control and treated).
>
> set.seed(12)
> ctrl <- rnorm(n = 6, mean = 2)
> ttd <- rnorm(n = 6, mean = 10)
> dat <- data.frame(vals = c(ctrl, ttd),
>   group = c(rep("ctrl", 6), rep("ttd", 6)),
>   ind = factor(rep(1:6, 2)))
>
> fit <- lm(vals ~ ind + group, data = dat)
> model.matrix(~ ind + group, data = dat)
>
> I am puzzled on how the coeficients are calculated. For example, according
> to the model matrix, I thought the intercept would be individual 1 control.
> But that is clearly not the case.
> For the last coeficient, I understand it as the mean of all differences
> between treated vs control at each individual.
>
> I would greatly appreciate if someone could clarify to me how the
> coefficients in this situation are estimated.
>
> Thanks
>
> [[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-es] ORACLE SQL/ LEER DATOS EN R

2017-12-06 Thread Francisco Rodríguez
Efectivamente el problema en general es que para jdbc tendrás que instalar 
rjava al igual que para los drivers nativos como roracle. Eso en máquina en 
local implica que tendrás que indicar una variable de entorno para localizar el 
jvm creo recordar aunque hay mucha ayuda en stackover. Hecho eso es 
recomendable  si vas por esa vía usar la libreria dbi para lanzar las sql



Enviado desde mi smartphone Samsung Galaxy.


 Mensaje original 
De: Javier Nieto 
Fecha: 6/12/17 17:43 (GMT+01:00)
Para: Antonio Rodriguez Andres , 
r-help-es@r-project.org
Asunto: Re: [R-es] ORACLE SQL/ LEER DATOS EN R

Hola, ya comentaron bastante al respecto del tema, sin embargo algo que he 
notado es que las consultas con ROracle son más rápidas que con RODBC. Mi 
recomendación sería: siempre que puedas usar el driver nativo de la base de 
datos en cuestión(obviamente si existe) úsalo, en segundo lugar RJDBC y al 
final RODBC.



Saludos


De: R-help-es  en nombre de Antonio Rodriguez 
Andres 
Enviado: miércoles, 6 de diciembre de 2017 05:42:50 a. m.
Para: Francisco Rodríguez
CC: r-help-es
Asunto: Re: [R-es] ORACLE SQL/ LEER DATOS EN R

Muchas gracias por la ayuda y el consejo

Saludos

2017-12-06 12:31 GMT+01:00 Francisco Rodríguez :

> Con oracle puedes usar, si tu máquina es de 64bits la librería Roracle que
> va muy bien y no es muy complicada de instalar.
>
>
> Hay que distinguir 2 cosas, cuando accedes a la base de datos y allí haces
> la consulta, eso da igual si lo haces con RODBC o Roracle y cuando cargas
> los datos en tu data.frame, en esta operación, ya no está usando el gestor
> de base de datos sino tu propio R. La velocidad y cantidad de datos que
> puedas cargar dependerá en el segundo paso de tu máquina y del software, es
> aquí donde merece la pena para grandes datos usar Roracle porque debería ir
> mejor.
>
>
> Claramente la limitación la vas a tener ya que al cargar los datos en
> memoria podrá alogar el máximo de RAM de que disponga tu máquina local,
> aunque puede ir consultando por partes
> esto no deja de ser una "chapuza" con la que hay que convivir en R, lo
> ideal aquí sería que conforme vas leyendo escribir en disco duro y liberar
> memoria para seguir leyendo el resto de os datos y así ir por bloques,
> sobre todo si tu data.frame va a pesar más de 20GB (salvo que dispongas de
> un servidor), aquí te las tendrás que ingeniar yo no he visto (salvo que
> alguien conozca algo más) librerías que me permitan hacer esta operación de
> modo lo más optimizado posible, cuando me ha ocurrido esto he tenido que
> montarme alguna función para hacerlo y lógicamente el proceso puede ser
> bastante lento
>
> Por tanto mi recomendación si vas a trabajar con Oracle y si tienes una
> máquina de 64bits es que al menos uses ROracle, funciona bastante bien
>
> Un saludo
>
> Un saludo
> --
> *De:* R-help-es  en nombre de ismael
> mardomingo 
> *Enviado:* miércoles, 6 de diciembre de 2017 11:12
> *Para:* Antonio Rodriguez Andres; r-help-es
> *Asunto:* Re: [R-es] ORACLE SQL/ LEER DATOS EN R
>
> Yo he accedido sin problemas a bases de datos de Oracle desde R con el
> paquete RODBC. Si tienes tablas muy grandes siempre puedes realizar la
> lectura por partes a trav�s de consultas.
>
>
>
> Para poder acceder he configurado, trabajo con Windows, en Herramientas
> Administrativas -->Or�genes de Datos ODBC (32 o 64 bits seg�n el sistema
> que tengas) un origen de datos a la base de datos Oracle que utilizo para
> conectarme desde R con el paquete RODBC y accedes sin problemas.
>
>
>
> Un saludo,
>
> Ismael
>
>
>
> Enviado desde Correo para
> Windows 10
>
>
>
> 
> De: R-help-es  en nombre de Antonio
> Rodriguez Andres 
> Enviado: Wednesday, December 6, 2017 10:10:19 AM
> Para: r-help-es
> Asunto: [R-es] ORACLE SQL/ LEER DATOS EN R
>
> Estimados usuarios de R
>
> Buenos d�as a todos los usuarios. Estamos intentando abrir una base de
> datos de ORACLE en R. Es una base de datos muy grande con datos inviduales
> sobre empleo de los individuos y sus caracteristicas. He echado un vistazo
> a https://www.r-bloggers.com/connecting-r-to-an-oracle-database/,y
> aparecen algunas instrucciones y el paquete RODBC.
>
> Alguien tiene experiencia con estas bases de datos? donde podria encontrar
> mas informacion? Asumo que otro problema puede ser el problema de memoria
> en el ordenador, al ser una enorme base de datos. Pero esto entiendo que se
> puede solucionar.
>
> Agradeceria cualquier sugerencia o ayuda
>
> Saludos
> Antonio
>
> [[alternative HTML version deleted]]
>
> 

Re: [R] Odd dates generated in Forecasts

2017-12-06 Thread David Winsemius

> On Dec 6, 2017, at 5:07 AM, Paul Bernal  wrote:
> 
> Dear friends,
> 
> I have a weekly time series which starts on Jan 4th, 2003 and ends on
> december 31st, 2016.
> 
> I set up my ts object as follows:
> 
> MyTseries <- ts(mydataset, start=2003, end=2016, frequency=52)
> 
> MyModel <- auto.arima(MyTseries, d=1, D=1)
> 
> MyModelForecast <- forecast (MyModel, h=12)
> 
> Since my last observation was on december 31st, 2016 I expected my forecast
> date to start on 2017, but instead it returned odd dates.
> 
> This is my dataset
> 
> dput(dataset):
> 
> structure(list(Date = structure(c(8L, 22L, 36L, 50L, 64L, 78L,
> 92L, 106L, 120L, 134L, 148L, 162L, 176L, 190L, 204L, 218L, 232L,
> 246L, 260L, 274L, 288L, 302L, 316L, 330L, 344L, 358L, 372L, 386L,
> 400L, 414L, 428L, 442L, 456L, 470L, 484L, 498L, 512L, 526L, 540L,
> 554L, 568L, 582L, 596L, 610L, 624L, 638L, 652L, 666L, 680L, 694L,
> 708L, 722L, 5L, 19L, 33L, 47L, 61L, 75L, 89L, 103L, 117L, 130L,
> 144L, 158L, 172L, 186L, 200L, 214L, 228L, 242L, 256L, 270L, 284L,
> 298L, 312L, 326L, 340L, 354L, 368L, 382L, 396L, 410L, 424L, 438L,
> 452L, 466L, 480L, 494L, 508L, 522L, 536L, 550L, 564L, 578L, 592L,
> 606L, 620L, 634L, 648L, 662L, 676L, 690L, 704L, 718L, 1L, 15L,
> 29L, 43L, 57L, 71L, 85L, 99L, 113L, 127L, 141L, 155L, 169L, 183L,
> 197L, 211L, 225L, 239L, 253L, 267L, 281L, 295L, 309L, 323L, 337L,
> 351L, 365L, 379L, 393L, 407L, 421L, 435L, 449L, 463L, 477L, 491L,
> 505L, 519L, 533L, 547L, 561L, 575L, 589L, 603L, 617L, 631L, 645L,
> 659L, 673L, 687L, 701L, 715L, 729L, 13L, 27L, 41L, 55L, 69L,
> 83L, 97L, 111L, 126L, 140L, 154L, 168L, 182L, 196L, 210L, 224L,
> 238L, 252L, 266L, 280L, 294L, 308L, 322L, 336L, 350L, 364L, 378L,
> 392L, 406L, 420L, 434L, 448L, 462L, 476L, 490L, 504L, 518L, 532L,
> 546L, 560L, 574L, 588L, 602L, 616L, 630L, 644L, 658L, 672L, 686L,
> 700L, 714L, 728L, 12L, 26L, 40L, 54L, 68L, 82L, 96L, 110L, 124L,
> 138L, 152L, 166L, 180L, 194L, 208L, 222L, 236L, 250L, 264L, 278L,
> 292L, 306L, 320L, 334L, 348L, 362L, 376L, 390L, 404L, 418L, 432L,
> 446L, 460L, 474L, 488L, 502L, 516L, 530L, 544L, 558L, 572L, 586L,
> 600L, 614L, 628L, 642L, 656L, 670L, 684L, 698L, 712L, 726L, 10L,
> 24L, 38L, 52L, 66L, 80L, 94L, 108L, 121L, 135L, 149L, 163L, 177L,
> 191L, 205L, 219L, 233L, 247L, 261L, 275L, 289L, 303L, 317L, 331L,
> 345L, 359L, 373L, 387L, 401L, 415L, 429L, 443L, 457L, 471L, 485L,
> 499L, 513L, 527L, 541L, 555L, 569L, 583L, 597L, 611L, 625L, 639L,
> 653L, 667L, 681L, 695L, 709L, 723L, 6L, 20L, 34L, 48L, 62L, 76L,
> 90L, 104L, 118L, 132L, 146L, 160L, 174L, 188L, 202L, 216L, 230L,
> 244L, 258L, 272L, 286L, 300L, 314L, 328L, 342L, 356L, 370L, 384L,
> 398L, 412L, 426L, 440L, 454L, 468L, 482L, 496L, 510L, 524L, 538L,
> 552L, 566L, 580L, 594L, 608L, 622L, 636L, 650L, 664L, 678L, 692L,
> 706L, 720L, 3L, 17L, 31L, 45L, 59L, 73L, 87L, 101L, 115L, 131L,
> 145L, 159L, 173L, 187L, 201L, 215L, 229L, 243L, 257L, 271L, 285L,
> 299L, 313L, 327L, 341L, 355L, 369L, 383L, 397L, 411L, 425L, 439L,
> 453L, 467L, 481L, 495L, 509L, 523L, 537L, 551L, 565L, 579L, 593L,
> 607L, 621L, 635L, 649L, 663L, 677L, 691L, 705L, 719L, 2L, 16L,
> 30L, 44L, 58L, 72L, 86L, 100L, 114L, 128L, 142L, 156L, 170L,
> 184L, 198L, 212L, 226L, 240L, 254L, 268L, 282L, 296L, 310L, 324L,
> 338L, 352L, 366L, 380L, 394L, 408L, 422L, 436L, 450L, 464L, 478L,
> 492L, 506L, 520L, 534L, 548L, 562L, 576L, 590L, 604L, 618L, 632L,
> 646L, 660L, 674L, 688L, 702L, 716L, 730L, 14L, 28L, 42L, 56L,
> 70L, 84L, 98L, 112L, 125L, 139L, 153L, 167L, 181L, 195L, 209L,
> 223L, 237L, 251L, 265L, 279L, 293L, 307L, 321L, 335L, 349L, 363L,
> 377L, 391L, 405L, 419L, 433L, 447L, 461L, 475L, 489L, 503L, 517L,
> 531L, 545L, 559L, 573L, 587L, 601L, 615L, 629L, 643L, 657L, 671L,
> 685L, 699L, 713L, 727L, 11L, 25L, 39L, 53L, 67L, 81L, 95L, 109L,
> 123L, 137L, 151L, 165L, 179L, 193L, 207L, 221L, 235L, 249L, 263L,
> 277L, 291L, 305L, 319L, 333L, 347L, 361L, 375L, 389L, 403L, 417L,
> 431L, 445L, 459L, 473L, 487L, 501L, 515L, 529L, 543L, 557L, 571L,
> 585L, 599L, 613L, 627L, 641L, 655L, 669L, 683L, 697L, 711L, 725L,
> 9L, 23L, 37L, 51L, 65L, 79L, 93L, 107L, 122L, 136L, 150L, 164L,
> 178L, 192L, 206L, 220L, 234L, 248L, 262L, 276L, 290L, 304L, 318L,
> 332L, 346L, 360L, 374L, 388L, 402L, 416L, 430L, 444L, 458L, 472L,
> 486L, 500L, 514L, 528L, 542L, 556L, 570L, 584L, 598L, 612L, 626L,
> 640L, 654L, 668L, 682L, 696L, 710L, 724L, 7L, 21L, 35L, 49L,
> 63L, 77L, 91L, 105L, 119L, 133L, 147L, 161L, 175L, 189L, 203L,
> 217L, 231L, 245L, 259L, 273L, 287L, 301L, 315L, 329L, 343L, 357L,
> 371L, 385L, 399L, 413L, 427L, 441L, 455L, 469L, 483L, 497L, 511L,
> 525L, 539L, 553L, 567L, 581L, 595L, 609L, 623L, 637L, 651L, 665L,
> 679L, 693L, 707L, 721L, 4L, 18L, 32L, 46L, 60L, 74L, 88L, 102L,
> 116L, 129L, 143L, 157L, 171L, 185L, 199L, 213L, 227L, 241L, 255L,
> 269L, 283L, 297L, 311L, 325L, 339L, 353L, 367L, 381L, 395L, 409L,
> 423L, 437L, 451L, 465L, 479L, 493L, 507L, 521L, 535L, 549L, 563L,
> 577L, 591L, 605L, 619L, 633L, 647L, 661L, 

Re: [R-es] ORACLE SQL/ LEER DATOS EN R

2017-12-06 Thread Javier Nieto
Hola, ya comentaron bastante al respecto del tema, sin embargo algo que he 
notado es que las consultas con ROracle son más rápidas que con RODBC. Mi 
recomendación sería: siempre que puedas usar el driver nativo de la base de 
datos en cuestión(obviamente si existe) úsalo, en segundo lugar RJDBC y al 
final RODBC.



Saludos


De: R-help-es  en nombre de Antonio Rodriguez 
Andres 
Enviado: miércoles, 6 de diciembre de 2017 05:42:50 a. m.
Para: Francisco Rodríguez
CC: r-help-es
Asunto: Re: [R-es] ORACLE SQL/ LEER DATOS EN R

Muchas gracias por la ayuda y el consejo

Saludos

2017-12-06 12:31 GMT+01:00 Francisco Rodríguez :

> Con oracle puedes usar, si tu máquina es de 64bits la librería Roracle que
> va muy bien y no es muy complicada de instalar.
>
>
> Hay que distinguir 2 cosas, cuando accedes a la base de datos y allí haces
> la consulta, eso da igual si lo haces con RODBC o Roracle y cuando cargas
> los datos en tu data.frame, en esta operación, ya no está usando el gestor
> de base de datos sino tu propio R. La velocidad y cantidad de datos que
> puedas cargar dependerá en el segundo paso de tu máquina y del software, es
> aquí donde merece la pena para grandes datos usar Roracle porque debería ir
> mejor.
>
>
> Claramente la limitación la vas a tener ya que al cargar los datos en
> memoria podrá alogar el máximo de RAM de que disponga tu máquina local,
> aunque puede ir consultando por partes
> esto no deja de ser una "chapuza" con la que hay que convivir en R, lo
> ideal aquí sería que conforme vas leyendo escribir en disco duro y liberar
> memoria para seguir leyendo el resto de os datos y así ir por bloques,
> sobre todo si tu data.frame va a pesar más de 20GB (salvo que dispongas de
> un servidor), aquí te las tendrás que ingeniar yo no he visto (salvo que
> alguien conozca algo más) librerías que me permitan hacer esta operación de
> modo lo más optimizado posible, cuando me ha ocurrido esto he tenido que
> montarme alguna función para hacerlo y lógicamente el proceso puede ser
> bastante lento
>
> Por tanto mi recomendación si vas a trabajar con Oracle y si tienes una
> máquina de 64bits es que al menos uses ROracle, funciona bastante bien
>
> Un saludo
>
> Un saludo
> --
> *De:* R-help-es  en nombre de ismael
> mardomingo 
> *Enviado:* miércoles, 6 de diciembre de 2017 11:12
> *Para:* Antonio Rodriguez Andres; r-help-es
> *Asunto:* Re: [R-es] ORACLE SQL/ LEER DATOS EN R
>
> Yo he accedido sin problemas a bases de datos de Oracle desde R con el
> paquete RODBC. Si tienes tablas muy grandes siempre puedes realizar la
> lectura por partes a trav�s de consultas.
>
>
>
> Para poder acceder he configurado, trabajo con Windows, en Herramientas
> Administrativas -->Or�genes de Datos ODBC (32 o 64 bits seg�n el sistema
> que tengas) un origen de datos a la base de datos Oracle que utilizo para
> conectarme desde R con el paquete RODBC y accedes sin problemas.
>
>
>
> Un saludo,
>
> Ismael
>
>
>
> Enviado desde Correo para
> Windows 10
>
>
>
> 
> De: R-help-es  en nombre de Antonio
> Rodriguez Andres 
> Enviado: Wednesday, December 6, 2017 10:10:19 AM
> Para: r-help-es
> Asunto: [R-es] ORACLE SQL/ LEER DATOS EN R
>
> Estimados usuarios de R
>
> Buenos d�as a todos los usuarios. Estamos intentando abrir una base de
> datos de ORACLE en R. Es una base de datos muy grande con datos inviduales
> sobre empleo de los individuos y sus caracteristicas. He echado un vistazo
> a https://www.r-bloggers.com/connecting-r-to-an-oracle-database/,y
> aparecen algunas instrucciones y el paquete RODBC.
>
> Alguien tiene experiencia con estas bases de datos? donde podria encontrar
> mas informacion? Asumo que otro problema puede ser el problema de memoria
> en el ordenador, al ser una enorme base de datos. Pero esto entiendo que se
> puede solucionar.
>
> Agradeceria cualquier sugerencia o ayuda
>
> Saludos
> Antonio
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
> Página de Información de R-help-es
> 
> stat.ethz.ch
> Esta es una lista de correo para solicitar ayuda sobre R en español y se
> entiende como un complemento social a la documentación, libros, etc.
> disponibles sobre R ...
>
>
>
> [[alternative HTML version deleted]]
>
>


--

Member, Editorial Committee, *The Economic and Labour Relations Review* (a
SAGE journal)

http://elr.sagepub.com/

Member, Editorial Committee, African Journal of Economic and Management
Studies


[ESS] ESS and JSM in Vancouver

2017-12-06 Thread Sparapani, Rodney
Hi Gang:

I would like to propose an ESS roundtable for JSM in Vancouver.  Could those of
you interested in attending please let me know?  Thanks

--
Rodney Sparapani, PhD
Assistant Professor of Biostatistics
Medical College of Wisconsin, Milwaukee
__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


[R] Coeficients estimation in a repeated measures linear model

2017-12-06 Thread Sergio PV
Dear Users,

I am trying to understand the inner workings of a repeated measures linear
model. Take for example a situation with 6 individuals sampled twice for
two conditions (control and treated).

set.seed(12)
ctrl <- rnorm(n = 6, mean = 2)
ttd <- rnorm(n = 6, mean = 10)
dat <- data.frame(vals = c(ctrl, ttd),
  group = c(rep("ctrl", 6), rep("ttd", 6)),
  ind = factor(rep(1:6, 2)))

fit <- lm(vals ~ ind + group, data = dat)
model.matrix(~ ind + group, data = dat)

I am puzzled on how the coeficients are calculated. For example, according
to the model matrix, I thought the intercept would be individual 1 control.
But that is clearly not the case.
For the last coeficient, I understand it as the mean of all differences
between treated vs control at each individual.

I would greatly appreciate if someone could clarify to me how the
coefficients in this situation are estimated.

Thanks

[[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-es] STATA base de datos

2017-12-06 Thread Antonio Rodriguez Andres
Gracias Carlos. Voy a probar y te digo.

El 6/12/2017 13:49, "Carlos Ortega"  escribió:

> OK.
> Lee primero los datos, guarda el data.frame (.RData o en un .csv o lo que
> quieras).
> Sal de RStudio o incluso reinicia el ordenador para liberar el máximo de
> memoria.
>
> Y comienza una nueva sesión con RStudio cargando los datos con "fread()".
> Por otro lado, este conjunto de datos ¿cómo es de grande (filas y
> columnas)?.
>
> ¿Y qué máquina tienes?. ¿Cuanta RAM tienes?.
>
> Gracias,
> Carlos.
>
>
> El 6 de diciembre de 2017, 13:42, Antonio Rodriguez Andres <
> antoniorodriguezandre...@gmail.com> escribió:
>
>> Carlos
>>
>> use library foreign, y read.dta. Consegui leer los datos. Pero demora
>> mucho. explore los datos con head y tail, y con summary. Conseguis los
>> resultados. Muy lento. Una cosa a. hacer es un histograma y ahi ya ponia
>> cannot allocate memory.
>>
>> Pense que podria leer los datos de otra manera mas eficiente.
>>
>> El 6/12/2017 13:32, "Carlos Ortega"  escribió:
>>
>>> Pero entonces, ¿has leído ya el fichero en RStudio? ¿lo has convertido
>>> de Stata a csv o algún otro formato que con el que puedas trabajar en
>>> RStudio?.
>>> ¿O ahora el problema es que has convertido el fichero pero no puedes
>>> hacer ningún tipo de análisis porque tu equipo no tiene suficientes
>>> recursos?...
>>>
>>> Gracias,
>>> Carlos.
>>>
>>> El 6 de diciembre de 2017, 13:09, Antonio Rodriguez Andres <
>>> antoniorodriguezandre...@gmail.com> escribió:
>>>
 He llegado hacer un summary o algo asi. Despues de leerlo pero tarda
 mucho.
 Y si hago un histograma de una variable edad, hay colapsa.

 El 6/12/2017 13:05, "Antonio Rodriguez Andres" <
 antoniorodriguezandre...@gmail.com> escribió:

 > Freddy
 >
 > el archivo lo leo en segundos en Stata. puedo probar el paquete
 heaven.
 > Pero si recuerdo me dio problemas en RStudio
 >
 > El 6/12/2017 13:03, "Freddy Omar López Quintero" <
 freddy.vat...@gmail.com>
 > escribió:
 >
 >> El mié, 06-12-2017 a las 12:55 +0100, Antonio Rodriguez Andres
 escribió:
 >>
 >> me sale problema
 >> de memoria.
 >>
 >>
 >> Pregunta posiblemente tonta: ¿tienes suficiente memoria para
 procesar un
 >> archivo de tales dimensiones? Puede que ni aún cambiando la manera
 de leer
 >> el archivo realmente lo puedas procesar.
 >>
 >>
 >> Entonces, una solucion es intentar pasar de STATA a CSV y luego usar
 el
 >> comando fread, y finalmente cargar los datos como RData
 >>
 >>
 >> ¿Has probado el paquete haven y específicamente su función read_dta?
 >> Parece que es bastante más eficiente que la de foreign y preserva más
 >> características que trae el formato de stata.
 >>
 >> ¡Ojalá algo sirva!
 >>
 >> ¡Salud!
 >>
 >> --
 >>
 >> «...homines autem hominum causa esse generatos...»
 >>
 >> Cicero
 >>
 >

 [[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
>>>
>>
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>

[[alternative HTML version deleted]]

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


[R] Odd dates generated in Forecasts

2017-12-06 Thread Paul Bernal
Dear friends,

I have a weekly time series which starts on Jan 4th, 2003 and ends on
december 31st, 2016.

I set up my ts object as follows:

MyTseries <- ts(mydataset, start=2003, end=2016, frequency=52)

MyModel <- auto.arima(MyTseries, d=1, D=1)

MyModelForecast <- forecast (MyModel, h=12)

Since my last observation was on december 31st, 2016 I expected my forecast
date to start on 2017, but instead it returned odd dates.

This is my dataset

dput(dataset):

structure(list(Date = structure(c(8L, 22L, 36L, 50L, 64L, 78L,
92L, 106L, 120L, 134L, 148L, 162L, 176L, 190L, 204L, 218L, 232L,
246L, 260L, 274L, 288L, 302L, 316L, 330L, 344L, 358L, 372L, 386L,
400L, 414L, 428L, 442L, 456L, 470L, 484L, 498L, 512L, 526L, 540L,
554L, 568L, 582L, 596L, 610L, 624L, 638L, 652L, 666L, 680L, 694L,
708L, 722L, 5L, 19L, 33L, 47L, 61L, 75L, 89L, 103L, 117L, 130L,
144L, 158L, 172L, 186L, 200L, 214L, 228L, 242L, 256L, 270L, 284L,
298L, 312L, 326L, 340L, 354L, 368L, 382L, 396L, 410L, 424L, 438L,
452L, 466L, 480L, 494L, 508L, 522L, 536L, 550L, 564L, 578L, 592L,
606L, 620L, 634L, 648L, 662L, 676L, 690L, 704L, 718L, 1L, 15L,
29L, 43L, 57L, 71L, 85L, 99L, 113L, 127L, 141L, 155L, 169L, 183L,
197L, 211L, 225L, 239L, 253L, 267L, 281L, 295L, 309L, 323L, 337L,
351L, 365L, 379L, 393L, 407L, 421L, 435L, 449L, 463L, 477L, 491L,
505L, 519L, 533L, 547L, 561L, 575L, 589L, 603L, 617L, 631L, 645L,
659L, 673L, 687L, 701L, 715L, 729L, 13L, 27L, 41L, 55L, 69L,
83L, 97L, 111L, 126L, 140L, 154L, 168L, 182L, 196L, 210L, 224L,
238L, 252L, 266L, 280L, 294L, 308L, 322L, 336L, 350L, 364L, 378L,
392L, 406L, 420L, 434L, 448L, 462L, 476L, 490L, 504L, 518L, 532L,
546L, 560L, 574L, 588L, 602L, 616L, 630L, 644L, 658L, 672L, 686L,
700L, 714L, 728L, 12L, 26L, 40L, 54L, 68L, 82L, 96L, 110L, 124L,
138L, 152L, 166L, 180L, 194L, 208L, 222L, 236L, 250L, 264L, 278L,
292L, 306L, 320L, 334L, 348L, 362L, 376L, 390L, 404L, 418L, 432L,
446L, 460L, 474L, 488L, 502L, 516L, 530L, 544L, 558L, 572L, 586L,
600L, 614L, 628L, 642L, 656L, 670L, 684L, 698L, 712L, 726L, 10L,
24L, 38L, 52L, 66L, 80L, 94L, 108L, 121L, 135L, 149L, 163L, 177L,
191L, 205L, 219L, 233L, 247L, 261L, 275L, 289L, 303L, 317L, 331L,
345L, 359L, 373L, 387L, 401L, 415L, 429L, 443L, 457L, 471L, 485L,
499L, 513L, 527L, 541L, 555L, 569L, 583L, 597L, 611L, 625L, 639L,
653L, 667L, 681L, 695L, 709L, 723L, 6L, 20L, 34L, 48L, 62L, 76L,
90L, 104L, 118L, 132L, 146L, 160L, 174L, 188L, 202L, 216L, 230L,
244L, 258L, 272L, 286L, 300L, 314L, 328L, 342L, 356L, 370L, 384L,
398L, 412L, 426L, 440L, 454L, 468L, 482L, 496L, 510L, 524L, 538L,
552L, 566L, 580L, 594L, 608L, 622L, 636L, 650L, 664L, 678L, 692L,
706L, 720L, 3L, 17L, 31L, 45L, 59L, 73L, 87L, 101L, 115L, 131L,
145L, 159L, 173L, 187L, 201L, 215L, 229L, 243L, 257L, 271L, 285L,
299L, 313L, 327L, 341L, 355L, 369L, 383L, 397L, 411L, 425L, 439L,
453L, 467L, 481L, 495L, 509L, 523L, 537L, 551L, 565L, 579L, 593L,
607L, 621L, 635L, 649L, 663L, 677L, 691L, 705L, 719L, 2L, 16L,
30L, 44L, 58L, 72L, 86L, 100L, 114L, 128L, 142L, 156L, 170L,
184L, 198L, 212L, 226L, 240L, 254L, 268L, 282L, 296L, 310L, 324L,
338L, 352L, 366L, 380L, 394L, 408L, 422L, 436L, 450L, 464L, 478L,
492L, 506L, 520L, 534L, 548L, 562L, 576L, 590L, 604L, 618L, 632L,
646L, 660L, 674L, 688L, 702L, 716L, 730L, 14L, 28L, 42L, 56L,
70L, 84L, 98L, 112L, 125L, 139L, 153L, 167L, 181L, 195L, 209L,
223L, 237L, 251L, 265L, 279L, 293L, 307L, 321L, 335L, 349L, 363L,
377L, 391L, 405L, 419L, 433L, 447L, 461L, 475L, 489L, 503L, 517L,
531L, 545L, 559L, 573L, 587L, 601L, 615L, 629L, 643L, 657L, 671L,
685L, 699L, 713L, 727L, 11L, 25L, 39L, 53L, 67L, 81L, 95L, 109L,
123L, 137L, 151L, 165L, 179L, 193L, 207L, 221L, 235L, 249L, 263L,
277L, 291L, 305L, 319L, 333L, 347L, 361L, 375L, 389L, 403L, 417L,
431L, 445L, 459L, 473L, 487L, 501L, 515L, 529L, 543L, 557L, 571L,
585L, 599L, 613L, 627L, 641L, 655L, 669L, 683L, 697L, 711L, 725L,
9L, 23L, 37L, 51L, 65L, 79L, 93L, 107L, 122L, 136L, 150L, 164L,
178L, 192L, 206L, 220L, 234L, 248L, 262L, 276L, 290L, 304L, 318L,
332L, 346L, 360L, 374L, 388L, 402L, 416L, 430L, 444L, 458L, 472L,
486L, 500L, 514L, 528L, 542L, 556L, 570L, 584L, 598L, 612L, 626L,
640L, 654L, 668L, 682L, 696L, 710L, 724L, 7L, 21L, 35L, 49L,
63L, 77L, 91L, 105L, 119L, 133L, 147L, 161L, 175L, 189L, 203L,
217L, 231L, 245L, 259L, 273L, 287L, 301L, 315L, 329L, 343L, 357L,
371L, 385L, 399L, 413L, 427L, 441L, 455L, 469L, 483L, 497L, 511L,
525L, 539L, 553L, 567L, 581L, 595L, 609L, 623L, 637L, 651L, 665L,
679L, 693L, 707L, 721L, 4L, 18L, 32L, 46L, 60L, 74L, 88L, 102L,
116L, 129L, 143L, 157L, 171L, 185L, 199L, 213L, 227L, 241L, 255L,
269L, 283L, 297L, 311L, 325L, 339L, 353L, 367L, 381L, 395L, 409L,
423L, 437L, 451L, 465L, 479L, 493L, 507L, 521L, 535L, 549L, 563L,
577L, 591L, 605L, 619L, 633L, 647L, 661L, 675L, 689L, 703L, 717L,
731L), .Label = c("01/01/05", "01/01/11", "01/02/10", "01/02/16",
"01/03/04", "01/03/09", "01/03/15", "01/04/03", "01/04/14", "01/05/08",
"01/05/13", "01/06/07", "01/07/06", "01/07/12", "01/08/05", "01/08/11",
"01/09/10", 

Re: [R-es] STATA base de datos

2017-12-06 Thread Carlos Ortega
OK.
Lee primero los datos, guarda el data.frame (.RData o en un .csv o lo que
quieras).
Sal de RStudio o incluso reinicia el ordenador para liberar el máximo de
memoria.

Y comienza una nueva sesión con RStudio cargando los datos con "fread()".
Por otro lado, este conjunto de datos ¿cómo es de grande (filas y
columnas)?.

¿Y qué máquina tienes?. ¿Cuanta RAM tienes?.

Gracias,
Carlos.


El 6 de diciembre de 2017, 13:42, Antonio Rodriguez Andres <
antoniorodriguezandre...@gmail.com> escribió:

> Carlos
>
> use library foreign, y read.dta. Consegui leer los datos. Pero demora
> mucho. explore los datos con head y tail, y con summary. Conseguis los
> resultados. Muy lento. Una cosa a. hacer es un histograma y ahi ya ponia
> cannot allocate memory.
>
> Pense que podria leer los datos de otra manera mas eficiente.
>
> El 6/12/2017 13:32, "Carlos Ortega"  escribió:
>
>> Pero entonces, ¿has leído ya el fichero en RStudio? ¿lo has convertido de
>> Stata a csv o algún otro formato que con el que puedas trabajar en RStudio?.
>> ¿O ahora el problema es que has convertido el fichero pero no puedes
>> hacer ningún tipo de análisis porque tu equipo no tiene suficientes
>> recursos?...
>>
>> Gracias,
>> Carlos.
>>
>> El 6 de diciembre de 2017, 13:09, Antonio Rodriguez Andres <
>> antoniorodriguezandre...@gmail.com> escribió:
>>
>>> He llegado hacer un summary o algo asi. Despues de leerlo pero tarda
>>> mucho.
>>> Y si hago un histograma de una variable edad, hay colapsa.
>>>
>>> El 6/12/2017 13:05, "Antonio Rodriguez Andres" <
>>> antoniorodriguezandre...@gmail.com> escribió:
>>>
>>> > Freddy
>>> >
>>> > el archivo lo leo en segundos en Stata. puedo probar el paquete heaven.
>>> > Pero si recuerdo me dio problemas en RStudio
>>> >
>>> > El 6/12/2017 13:03, "Freddy Omar López Quintero" <
>>> freddy.vat...@gmail.com>
>>> > escribió:
>>> >
>>> >> El mié, 06-12-2017 a las 12:55 +0100, Antonio Rodriguez Andres
>>> escribió:
>>> >>
>>> >> me sale problema
>>> >> de memoria.
>>> >>
>>> >>
>>> >> Pregunta posiblemente tonta: ¿tienes suficiente memoria para procesar
>>> un
>>> >> archivo de tales dimensiones? Puede que ni aún cambiando la manera de
>>> leer
>>> >> el archivo realmente lo puedas procesar.
>>> >>
>>> >>
>>> >> Entonces, una solucion es intentar pasar de STATA a CSV y luego usar
>>> el
>>> >> comando fread, y finalmente cargar los datos como RData
>>> >>
>>> >>
>>> >> ¿Has probado el paquete haven y específicamente su función read_dta?
>>> >> Parece que es bastante más eficiente que la de foreign y preserva más
>>> >> características que trae el formato de stata.
>>> >>
>>> >> ¡Ojalá algo sirva!
>>> >>
>>> >> ¡Salud!
>>> >>
>>> >> --
>>> >>
>>> >> «...homines autem hominum causa esse generatos...»
>>> >>
>>> >> Cicero
>>> >>
>>> >
>>>
>>> [[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
>>
>


-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[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-es] STATA base de datos

2017-12-06 Thread eric

  
  
Hola Antonio, luego de instalar el paquete data.table tienes que
  cagar la libreria antes de poder usar fread(), para esto tienes
  que hacer:
library(data.table)
otro detalles es que si quieres usar data.table no debes usar
  as.data.frame(), es decir, la linea en que lees deberia ser:
datacz <- fread('output.csv')

Y es buena idea si despues de leer la BD usas setkey() para "ordenar" la BD y aprovechar el orden para hacer mas rapidos los calculos (aunque no estoy completamente seguro de esto ultimo, pero puedes leer al respecto y asegurarte).

Suerte con tu BD !!

Eric.




  


On 12/06/2017 08:55 AM, Antonio
  Rodriguez Andres wrote:


  Tengo una base de datos muy grande en formato Stata, (dta), he probado a
leerla con el paquete foreign, y el comando
read.dta, pero como tiene 28 variables y casi medio millon de individuos,
cuando pruebo a hacer graficas o algo, me sale problema
de memoria.

Entonces, una solucion es intentar pasar de STATA a CSV y luego usar el
comando fread, y finalmente cargar los datos como RData.

SIn embargo he intentado

setwd("C:/Users/and0096/Desktop/TREXIMA")
library ('foreign')
write.table(read.dta(file.choose('private98-06more_than9.dta')),
file="output.csv", quote = FALSE, sep = ",")




Pero de esta manera me demora mucho, se queda el computador como colgado,
hay alguna otra manera de hacerlo mas rapida. El fichero de Stata
tiene bastante peso (726, 625 bytes). Solo llego al fichero output.csv.
He instalado el paquete data.table
pero cuando tecleo

datacz = as.data.frame(fread('output.csv'))


Error in fread("output.csv") : could not find function "fread"



Entiendo que algo mal estoy haciendo. Alguna idea mejor de como leer ese
fichero de STATA

Saludos cordiales

Antonio





-- 
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] STATA base de datos

2017-12-06 Thread Antonio Rodriguez Andres
Carlos

use library foreign, y read.dta. Consegui leer los datos. Pero demora
mucho. explore los datos con head y tail, y con summary. Conseguis los
resultados. Muy lento. Una cosa a. hacer es un histograma y ahi ya ponia
cannot allocate memory.

Pense que podria leer los datos de otra manera mas eficiente.

El 6/12/2017 13:32, "Carlos Ortega"  escribió:

> Pero entonces, ¿has leído ya el fichero en RStudio? ¿lo has convertido de
> Stata a csv o algún otro formato que con el que puedas trabajar en RStudio?.
> ¿O ahora el problema es que has convertido el fichero pero no puedes hacer
> ningún tipo de análisis porque tu equipo no tiene suficientes recursos?...
>
> Gracias,
> Carlos.
>
> El 6 de diciembre de 2017, 13:09, Antonio Rodriguez Andres <
> antoniorodriguezandre...@gmail.com> escribió:
>
>> He llegado hacer un summary o algo asi. Despues de leerlo pero tarda
>> mucho.
>> Y si hago un histograma de una variable edad, hay colapsa.
>>
>> El 6/12/2017 13:05, "Antonio Rodriguez Andres" <
>> antoniorodriguezandre...@gmail.com> escribió:
>>
>> > Freddy
>> >
>> > el archivo lo leo en segundos en Stata. puedo probar el paquete heaven.
>> > Pero si recuerdo me dio problemas en RStudio
>> >
>> > El 6/12/2017 13:03, "Freddy Omar López Quintero" <
>> freddy.vat...@gmail.com>
>> > escribió:
>> >
>> >> El mié, 06-12-2017 a las 12:55 +0100, Antonio Rodriguez Andres
>> escribió:
>> >>
>> >> me sale problema
>> >> de memoria.
>> >>
>> >>
>> >> Pregunta posiblemente tonta: ¿tienes suficiente memoria para procesar
>> un
>> >> archivo de tales dimensiones? Puede que ni aún cambiando la manera de
>> leer
>> >> el archivo realmente lo puedas procesar.
>> >>
>> >>
>> >> Entonces, una solucion es intentar pasar de STATA a CSV y luego usar el
>> >> comando fread, y finalmente cargar los datos como RData
>> >>
>> >>
>> >> ¿Has probado el paquete haven y específicamente su función read_dta?
>> >> Parece que es bastante más eficiente que la de foreign y preserva más
>> >> características que trae el formato de stata.
>> >>
>> >> ¡Ojalá algo sirva!
>> >>
>> >> ¡Salud!
>> >>
>> >> --
>> >>
>> >> «...homines autem hominum causa esse generatos...»
>> >>
>> >> Cicero
>> >>
>> >
>>
>> [[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]]

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


Re: [R-es] STATA base de datos

2017-12-06 Thread Carlos Ortega
Pero entonces, ¿has leído ya el fichero en RStudio? ¿lo has convertido de
Stata a csv o algún otro formato que con el que puedas trabajar en RStudio?.
¿O ahora el problema es que has convertido el fichero pero no puedes hacer
ningún tipo de análisis porque tu equipo no tiene suficientes recursos?...

Gracias,
Carlos.

El 6 de diciembre de 2017, 13:09, Antonio Rodriguez Andres <
antoniorodriguezandre...@gmail.com> escribió:

> He llegado hacer un summary o algo asi. Despues de leerlo pero tarda mucho.
> Y si hago un histograma de una variable edad, hay colapsa.
>
> El 6/12/2017 13:05, "Antonio Rodriguez Andres" <
> antoniorodriguezandre...@gmail.com> escribió:
>
> > Freddy
> >
> > el archivo lo leo en segundos en Stata. puedo probar el paquete heaven.
> > Pero si recuerdo me dio problemas en RStudio
> >
> > El 6/12/2017 13:03, "Freddy Omar López Quintero" <
> freddy.vat...@gmail.com>
> > escribió:
> >
> >> El mié, 06-12-2017 a las 12:55 +0100, Antonio Rodriguez Andres escribió:
> >>
> >> me sale problema
> >> de memoria.
> >>
> >>
> >> Pregunta posiblemente tonta: ¿tienes suficiente memoria para procesar un
> >> archivo de tales dimensiones? Puede que ni aún cambiando la manera de
> leer
> >> el archivo realmente lo puedas procesar.
> >>
> >>
> >> Entonces, una solucion es intentar pasar de STATA a CSV y luego usar el
> >> comando fread, y finalmente cargar los datos como RData
> >>
> >>
> >> ¿Has probado el paquete haven y específicamente su función read_dta?
> >> Parece que es bastante más eficiente que la de foreign y preserva más
> >> características que trae el formato de stata.
> >>
> >> ¡Ojalá algo sirva!
> >>
> >> ¡Salud!
> >>
> >> --
> >>
> >> «...homines autem hominum causa esse generatos...»
> >>
> >> Cicero
> >>
> >
>
> [[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]]

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


Re: [R-es] STATA base de datos

2017-12-06 Thread Antonio Rodriguez Andres
He llegado hacer un summary o algo asi. Despues de leerlo pero tarda mucho.
Y si hago un histograma de una variable edad, hay colapsa.

El 6/12/2017 13:05, "Antonio Rodriguez Andres" <
antoniorodriguezandre...@gmail.com> escribió:

> Freddy
>
> el archivo lo leo en segundos en Stata. puedo probar el paquete heaven.
> Pero si recuerdo me dio problemas en RStudio
>
> El 6/12/2017 13:03, "Freddy Omar López Quintero" 
> escribió:
>
>> El mié, 06-12-2017 a las 12:55 +0100, Antonio Rodriguez Andres escribió:
>>
>> me sale problema
>> de memoria.
>>
>>
>> Pregunta posiblemente tonta: ¿tienes suficiente memoria para procesar un
>> archivo de tales dimensiones? Puede que ni aún cambiando la manera de leer
>> el archivo realmente lo puedas procesar.
>>
>>
>> Entonces, una solucion es intentar pasar de STATA a CSV y luego usar el
>> comando fread, y finalmente cargar los datos como RData
>>
>>
>> ¿Has probado el paquete haven y específicamente su función read_dta?
>> Parece que es bastante más eficiente que la de foreign y preserva más
>> características que trae el formato de stata.
>>
>> ¡Ojalá algo sirva!
>>
>> ¡Salud!
>>
>> --
>>
>> «...homines autem hominum causa esse generatos...»
>>
>> Cicero
>>
>

[[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-es] STATA base de datos

2017-12-06 Thread Antonio Rodriguez Andres
Freddy

el archivo lo leo en segundos en Stata. puedo probar el paquete heaven.
Pero si recuerdo me dio problemas en RStudio

El 6/12/2017 13:03, "Freddy Omar López Quintero" 
escribió:

> El mié, 06-12-2017 a las 12:55 +0100, Antonio Rodriguez Andres escribió:
>
> me sale problema
> de memoria.
>
>
> Pregunta posiblemente tonta: ¿tienes suficiente memoria para procesar un
> archivo de tales dimensiones? Puede que ni aún cambiando la manera de leer
> el archivo realmente lo puedas procesar.
>
>
> Entonces, una solucion es intentar pasar de STATA a CSV y luego usar el
> comando fread, y finalmente cargar los datos como RData
>
>
> ¿Has probado el paquete haven y específicamente su función read_dta?
> Parece que es bastante más eficiente que la de foreign y preserva más
> características que trae el formato de stata.
>
> ¡Ojalá algo sirva!
>
> ¡Salud!
>
> --
>
> «...homines autem hominum causa esse generatos...»
>
> Cicero
>

[[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-es] STATA base de datos

2017-12-06 Thread Freddy Omar López Quintero
El mié, 06-12-2017 a las 12:55 +0100, Antonio Rodriguez Andres
escribió:
> me sale problema
> de memoria.

Pregunta posiblemente tonta: ¿tienes suficiente memoria para procesar
un archivo de tales dimensiones? Puede que ni aún cambiando la manera
de leer el archivo realmente lo puedas procesar.
> Entonces, una solucion es intentar pasar de STATA a CSV y luego usar
> el
> comando fread, y finalmente cargar los datos como RData

¿Has probado el paquete haven y específicamente su función read_dta?
Parece que es bastante más eficiente que la de foreign y preserva más
características que trae el formato de stata.

¡Ojalá algo sirva!

¡Salud!


-- 
«...homines autem hominum causa esse generatos...»

Cicero
[[alternative HTML version deleted]]

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


[R-es] STATA base de datos

2017-12-06 Thread Antonio Rodriguez Andres
Tengo una base de datos muy grande en formato Stata, (dta), he probado a
leerla con el paquete foreign, y el comando
read.dta, pero como tiene 28 variables y casi medio millon de individuos,
cuando pruebo a hacer graficas o algo, me sale problema
de memoria.

Entonces, una solucion es intentar pasar de STATA a CSV y luego usar el
comando fread, y finalmente cargar los datos como RData.

SIn embargo he intentado

setwd("C:/Users/and0096/Desktop/TREXIMA")
library ('foreign')
write.table(read.dta(file.choose('private98-06more_than9.dta')),
file="output.csv", quote = FALSE, sep = ",")




Pero de esta manera me demora mucho, se queda el computador como colgado,
hay alguna otra manera de hacerlo mas rapida. El fichero de Stata
tiene bastante peso (726, 625 bytes). Solo llego al fichero output.csv.
He instalado el paquete data.table
pero cuando tecleo

datacz = as.data.frame(fread('output.csv'))


Error in fread("output.csv") : could not find function "fread"



Entiendo que algo mal estoy haciendo. Alguna idea mejor de como leer ese
fichero de STATA

Saludos cordiales

Antonio


-- 

Member, Editorial Committee, *The Economic and Labour Relations Review* (a
SAGE journal)

http://elr.sagepub.com/

Member, Editorial Committee, African Journal of Economic and Management
Studies

http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems

https://www.researchgate.net/profile/Antonio_Andres (Research Gate profile)

[[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-es] ORACLE SQL/ LEER DATOS EN R

2017-12-06 Thread Antonio Rodriguez Andres
Muchas gracias por la ayuda y el consejo

Saludos

2017-12-06 12:31 GMT+01:00 Francisco Rodríguez :

> Con oracle puedes usar, si tu máquina es de 64bits la librería Roracle que
> va muy bien y no es muy complicada de instalar.
>
>
> Hay que distinguir 2 cosas, cuando accedes a la base de datos y allí haces
> la consulta, eso da igual si lo haces con RODBC o Roracle y cuando cargas
> los datos en tu data.frame, en esta operación, ya no está usando el gestor
> de base de datos sino tu propio R. La velocidad y cantidad de datos que
> puedas cargar dependerá en el segundo paso de tu máquina y del software, es
> aquí donde merece la pena para grandes datos usar Roracle porque debería ir
> mejor.
>
>
> Claramente la limitación la vas a tener ya que al cargar los datos en
> memoria podrá alogar el máximo de RAM de que disponga tu máquina local,
> aunque puede ir consultando por partes
> esto no deja de ser una "chapuza" con la que hay que convivir en R, lo
> ideal aquí sería que conforme vas leyendo escribir en disco duro y liberar
> memoria para seguir leyendo el resto de os datos y así ir por bloques,
> sobre todo si tu data.frame va a pesar más de 20GB (salvo que dispongas de
> un servidor), aquí te las tendrás que ingeniar yo no he visto (salvo que
> alguien conozca algo más) librerías que me permitan hacer esta operación de
> modo lo más optimizado posible, cuando me ha ocurrido esto he tenido que
> montarme alguna función para hacerlo y lógicamente el proceso puede ser
> bastante lento
>
> Por tanto mi recomendación si vas a trabajar con Oracle y si tienes una
> máquina de 64bits es que al menos uses ROracle, funciona bastante bien
>
> Un saludo
>
> Un saludo
> --
> *De:* R-help-es  en nombre de ismael
> mardomingo 
> *Enviado:* miércoles, 6 de diciembre de 2017 11:12
> *Para:* Antonio Rodriguez Andres; r-help-es
> *Asunto:* Re: [R-es] ORACLE SQL/ LEER DATOS EN R
>
> Yo he accedido sin problemas a bases de datos de Oracle desde R con el
> paquete RODBC. Si tienes tablas muy grandes siempre puedes realizar la
> lectura por partes a trav�s de consultas.
>
>
>
> Para poder acceder he configurado, trabajo con Windows, en Herramientas
> Administrativas -->Or�genes de Datos ODBC (32 o 64 bits seg�n el sistema
> que tengas) un origen de datos a la base de datos Oracle que utilizo para
> conectarme desde R con el paquete RODBC y accedes sin problemas.
>
>
>
> Un saludo,
>
> Ismael
>
>
>
> Enviado desde Correo para
> Windows 10
>
>
>
> 
> De: R-help-es  en nombre de Antonio
> Rodriguez Andres 
> Enviado: Wednesday, December 6, 2017 10:10:19 AM
> Para: r-help-es
> Asunto: [R-es] ORACLE SQL/ LEER DATOS EN R
>
> Estimados usuarios de R
>
> Buenos d�as a todos los usuarios. Estamos intentando abrir una base de
> datos de ORACLE en R. Es una base de datos muy grande con datos inviduales
> sobre empleo de los individuos y sus caracteristicas. He echado un vistazo
> a https://www.r-bloggers.com/connecting-r-to-an-oracle-database/,y
> aparecen algunas instrucciones y el paquete RODBC.
>
> Alguien tiene experiencia con estas bases de datos? donde podria encontrar
> mas informacion? Asumo que otro problema puede ser el problema de memoria
> en el ordenador, al ser una enorme base de datos. Pero esto entiendo que se
> puede solucionar.
>
> Agradeceria cualquier sugerencia o ayuda
>
> Saludos
> Antonio
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
> Página de Información de R-help-es
> 
> stat.ethz.ch
> Esta es una lista de correo para solicitar ayuda sobre R en español y se
> entiende como un complemento social a la documentación, libros, etc.
> disponibles sobre R ...
>
>
>
> [[alternative HTML version deleted]]
>
>


-- 

Member, Editorial Committee, *The Economic and Labour Relations Review* (a
SAGE journal)

http://elr.sagepub.com/

Member, Editorial Committee, African Journal of Economic and Management
Studies

http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems

https://www.researchgate.net/profile/Antonio_Andres (Research Gate profile)

[[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-es] ORACLE SQL/ LEER DATOS EN R

2017-12-06 Thread Francisco Rodríguez
Con oracle puedes usar, si tu máquina es de 64bits la librería Roracle que va 
muy bien y no es muy complicada de instalar.


Hay que distinguir 2 cosas, cuando accedes a la base de datos y allí haces la 
consulta, eso da igual si lo haces con RODBC o Roracle y cuando cargas los 
datos en tu data.frame, en esta operación, ya no está usando el gestor de base 
de datos sino tu propio R. La velocidad y cantidad de datos que puedas cargar 
dependerá en el segundo paso de tu máquina y del software, es aquí donde merece 
la pena para grandes datos usar Roracle porque debería ir mejor.


Claramente la limitación la vas a tener ya que al cargar los datos en memoria 
podrá alogar el máximo de RAM de que disponga tu máquina local, aunque puede ir 
consultando por partes

esto no deja de ser una "chapuza" con la que hay que convivir en R, lo ideal 
aquí sería que conforme vas leyendo escribir en disco duro y liberar memoria 
para seguir leyendo el resto de os datos y así ir por bloques, sobre todo si tu 
data.frame va a pesar más de 20GB (salvo que dispongas de un servidor), aquí te 
las tendrás que ingeniar yo no he visto (salvo que alguien conozca algo más) 
librerías que me permitan hacer esta operación de modo lo más optimizado 
posible, cuando me ha ocurrido esto he tenido que montarme alguna función para 
hacerlo y lógicamente el proceso puede ser bastante lento

Por tanto mi recomendación si vas a trabajar con Oracle y si tienes una máquina 
de 64bits es que al menos uses ROracle, funciona bastante bien

Un saludo

Un saludo

De: R-help-es  en nombre de ismael mardomingo 

Enviado: miércoles, 6 de diciembre de 2017 11:12
Para: Antonio Rodriguez Andres; r-help-es
Asunto: Re: [R-es] ORACLE SQL/ LEER DATOS EN R

Yo he accedido sin problemas a bases de datos de Oracle desde R con el paquete 
RODBC. Si tienes tablas muy grandes siempre puedes realizar la lectura por 
partes a trav�s de consultas.



Para poder acceder he configurado, trabajo con Windows, en Herramientas 
Administrativas -->Or�genes de Datos ODBC (32 o 64 bits seg�n el sistema que 
tengas) un origen de datos a la base de datos Oracle que utilizo para 
conectarme desde R con el paquete RODBC y accedes sin problemas.



Un saludo,

Ismael



Enviado desde Correo para 
Windows 10




De: R-help-es  en nombre de Antonio Rodriguez 
Andres 
Enviado: Wednesday, December 6, 2017 10:10:19 AM
Para: r-help-es
Asunto: [R-es] ORACLE SQL/ LEER DATOS EN R

Estimados usuarios de R

Buenos d�as a todos los usuarios. Estamos intentando abrir una base de
datos de ORACLE en R. Es una base de datos muy grande con datos inviduales
sobre empleo de los individuos y sus caracteristicas. He echado un vistazo
a https://www.r-bloggers.com/connecting-r-to-an-oracle-database/,y
aparecen algunas instrucciones y el paquete RODBC.

Alguien tiene experiencia con estas bases de datos? donde podria encontrar
mas informacion? Asumo que otro problema puede ser el problema de memoria
en el ordenador, al ser una enorme base de datos. Pero esto entiendo que se
puede solucionar.

Agradeceria cualquier sugerencia o ayuda

Saludos
Antonio

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es
Página de Información de 
R-help-es
stat.ethz.ch
Esta es una lista de correo para solicitar ayuda sobre R en español y se 
entiende como un complemento social a la documentación, libros, etc. 
disponibles sobre R ...




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

[R-es] ORACLE SQL/ LEER DATOS EN R

2017-12-06 Thread Antonio Rodriguez Andres
Estimados usuarios de R

Buenos días a todos los usuarios. Estamos intentando abrir una base de
datos de ORACLE en R. Es una base de datos muy grande con datos inviduales
sobre empleo de los individuos y sus caracteristicas. He echado un vistazo
a https://www.r-bloggers.com/connecting-r-to-an-oracle-database/,y
aparecen algunas instrucciones y el paquete RODBC.

Alguien tiene experiencia con estas bases de datos? donde podria encontrar
mas informacion? Asumo que otro problema puede ser el problema de memoria
en el ordenador, al ser una enorme base de datos. Pero esto entiendo que se
puede solucionar.

Agradeceria cualquier sugerencia o ayuda

Saludos
Antonio

[[alternative HTML version deleted]]

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