Re: [R] error in installing igraph

2017-08-02 Thread Jeff Newmiller
This is a perfect example of a question that should have gone to the R-sig-mac 
mailing list. (Mentioned in the POSTING GUIDE... read it.) When you post there 
I recommend that you include the output of sessionInfo().
-- 
Sent from my phone. Please excuse my brevity.

On August 2, 2017 9:07:42 PM PDT, lily li  wrote:
>Hi R users,
>I got warning messages when installing the package, and I pasted the
>messages below. I checked updates that my R-studio is already the
>newest
>version. I don't know how to solve the problem. Thanks for your help.
>
>> library(igraph)
>Error in dyn.load(file, DLLpath = DLLpath, ...) :
>  unable to load shared object
>'/Library/Frameworks/R.framework/Versions/3.2/Resources/library/igraph/libs/igraph.so':
>
>dlopen(/Library/Frameworks/R.framework/Versions/3.2/Resources/library/igraph/libs/igraph.so,
>6): Library not loaded:
>/Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
>  Referenced from:
>/Library/Frameworks/R.framework/Versions/3.2/Resources/library/igraph/libs/igraph.so
>Reason: Incompatible library version: igraph.so requires version 3.4.0
>or
>later, but libRlapack.dylib provides version 3.2.0
>In addition: Warning message:
>package ‘igraph’ was built under R version 3.4.1
>Error: package or namespace load failed for ‘igraph’
>
>   [[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] error in installing igraph

2017-08-02 Thread lily li
Hi R users,
I got warning messages when installing the package, and I pasted the
messages below. I checked updates that my R-studio is already the newest
version. I don't know how to solve the problem. Thanks for your help.

> library(igraph)
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object
'/Library/Frameworks/R.framework/Versions/3.2/Resources/library/igraph/libs/igraph.so':

dlopen(/Library/Frameworks/R.framework/Versions/3.2/Resources/library/igraph/libs/igraph.so,
6): Library not loaded:
/Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
  Referenced from:
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/igraph/libs/igraph.so
  Reason: Incompatible library version: igraph.so requires version 3.4.0 or
later, but libRlapack.dylib provides version 3.2.0
In addition: Warning message:
package ‘igraph’ was built under R version 3.4.1
Error: package or namespace load failed for ‘igraph’

[[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] Extracting numeric part from a string

2017-08-02 Thread Marc Schwartz
Thanks Bert.

I should probably also explicitly mention that if Christofer wants to 
ultimately coerce the numeric components of the strings to numeric data types 
for subsequent mathematical operations, you will need to strip the commas 
anyway. 

In that case, my first response, where I did not include the comma character in 
the regex may be preferred.

Regards,

Marc



> On Aug 2, 2017, at 8:00 PM, Bert Gunter  wrote:
> 
> ... and Marc's solution is **much** better than mine.
> 
> -- 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, Aug 2, 2017 at 5:59 PM, Bert Gunter  wrote:
>> ... Or if you just want to stick with basic regex's without extra packages:
>> 
>>> x <- "\"cm_ffm\":\"563.77\""
>>> sub("[^[:digit:]]*([[:digit:]]*.?[[:digit:]]*).*","\\1",x)
>> 
>> [1] "563.77"
>> 
>> Cheers,
>> Bert
>> 
>> 
>> 
>> On Wed, Aug 2, 2017 at 5:16 PM, Ismail SEZEN  wrote:
>>> 
 On 3 Aug 2017, at 02:59, Christofer Bogaso  
 wrote:
 
 Hi again,
 
 I am struggling to extract the number part from below string :
 
 "\"cm_ffm\":\"563.77\""
 
 Basically, I need to extract 563.77 from above. The underlying number
 can be a whole number, and there could be comma separator as well.
 
 So far I tried below :
 
> library(stringr)
 
> str_extract("\"cm_ffm\":\"563.77\"", "[[:digit:]]+")
 
 [1] "563"
 
> 
 
 However, above code is only extracting the integer part.
 
 Could you please help how to achieve that. Thanks,
>>> 
>>> 
>>> library(readr)
>>> parse_number('"cm_ffm":"563.77”')
>>> 
>>> __
>>> 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] Extracting numeric part from a string

2017-08-02 Thread Bert Gunter
... and Marc's solution is **much** better than mine.

-- 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, Aug 2, 2017 at 5:59 PM, Bert Gunter  wrote:
> ... Or if you just want to stick with basic regex's without extra packages:
>
>> x <- "\"cm_ffm\":\"563.77\""
>> sub("[^[:digit:]]*([[:digit:]]*.?[[:digit:]]*).*","\\1",x)
>
> [1] "563.77"
>
> Cheers,
> Bert
>
>
>
> On Wed, Aug 2, 2017 at 5:16 PM, Ismail SEZEN  wrote:
>>
>>> On 3 Aug 2017, at 02:59, Christofer Bogaso  
>>> wrote:
>>>
>>> Hi again,
>>>
>>> I am struggling to extract the number part from below string :
>>>
>>> "\"cm_ffm\":\"563.77\""
>>>
>>> Basically, I need to extract 563.77 from above. The underlying number
>>> can be a whole number, and there could be comma separator as well.
>>>
>>> So far I tried below :
>>>
 library(stringr)
>>>
 str_extract("\"cm_ffm\":\"563.77\"", "[[:digit:]]+")
>>>
>>> [1] "563"
>>>

>>>
>>> However, above code is only extracting the integer part.
>>>
>>> Could you please help how to achieve that. Thanks,
>>
>>
>> library(readr)
>> parse_number('"cm_ffm":"563.77”')
>>
>> __
>> 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] Extracting numeric part from a string

2017-08-02 Thread Bert Gunter
... Or if you just want to stick with basic regex's without extra packages:

> x <- "\"cm_ffm\":\"563.77\""
> sub("[^[:digit:]]*([[:digit:]]*.?[[:digit:]]*).*","\\1",x)

[1] "563.77"

Cheers,
Bert



On Wed, Aug 2, 2017 at 5:16 PM, Ismail SEZEN  wrote:
>
>> On 3 Aug 2017, at 02:59, Christofer Bogaso  
>> wrote:
>>
>> Hi again,
>>
>> I am struggling to extract the number part from below string :
>>
>> "\"cm_ffm\":\"563.77\""
>>
>> Basically, I need to extract 563.77 from above. The underlying number
>> can be a whole number, and there could be comma separator as well.
>>
>> So far I tried below :
>>
>>> library(stringr)
>>
>>> str_extract("\"cm_ffm\":\"563.77\"", "[[:digit:]]+")
>>
>> [1] "563"
>>
>>>
>>
>> However, above code is only extracting the integer part.
>>
>> Could you please help how to achieve that. Thanks,
>
>
> library(readr)
> parse_number('"cm_ffm":"563.77”')
>
> __
> 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] Extracting numeric part from a string

2017-08-02 Thread Marc Schwartz

> On Aug 2, 2017, at 7:42 PM, Marc Schwartz  wrote:
> 
> 
>> On Aug 2, 2017, at 6:59 PM, Christofer Bogaso  
>> wrote:
>> 
>> Hi again,
>> 
>> I am struggling to extract the number part from below string :
>> 
>> "\"cm_ffm\":\"563.77\""
>> 
>> Basically, I need to extract 563.77 from above. The underlying number
>> can be a whole number, and there could be comma separator as well.
>> 
>> So far I tried below :
>> 
>>> library(stringr)
>> 
>>> str_extract("\"cm_ffm\":\"563.77\"", "[[:digit:]]+")
>> 
>> [1] "563"
>> 
>>> 
>> 
>> However, above code is only extracting the integer part.
>> 
>> Could you please help how to achieve that. Thanks,
> 
> 
> Using ?gsub:
> 
> X <- "\"cm_ffm\":\"563.77\""
> 
> > gsub("[^0-9.]", "",  X)
> [1] "563.77"
> 
> or
> 
> > gsub("[^[:digit:].]", "",  X)
> [1] "563.77"
> 
> 
> Basically, remove any characters that are not digits or the decimal point, 
> presuming your pattern is consistent across your data.


Sorry, forgot that you indicated that there could be a comma:

X <- "\"cm_ffm\":\"1,563.77\""

> gsub("[^0-9.,]", "",  X)
[1] "1,563.77"

> gsub("[^[:digit:].,]", "",  X)
[1] "1,563.77"


Regards,

Marc

__
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] Extracting numeric part from a string

2017-08-02 Thread Marc Schwartz

> On Aug 2, 2017, at 6:59 PM, Christofer Bogaso  
> wrote:
> 
> Hi again,
> 
> I am struggling to extract the number part from below string :
> 
> "\"cm_ffm\":\"563.77\""
> 
> Basically, I need to extract 563.77 from above. The underlying number
> can be a whole number, and there could be comma separator as well.
> 
> So far I tried below :
> 
>> library(stringr)
> 
>> str_extract("\"cm_ffm\":\"563.77\"", "[[:digit:]]+")
> 
> [1] "563"
> 
>> 
> 
> However, above code is only extracting the integer part.
> 
> Could you please help how to achieve that. Thanks,


Using ?gsub:

X <- "\"cm_ffm\":\"563.77\""

> gsub("[^0-9.]", "",  X)
[1] "563.77"

or

> gsub("[^[:digit:].]", "",  X)
[1] "563.77"


Basically, remove any characters that are not digits or the decimal point, 
presuming your pattern is consistent across your data.

Regards,

Marc Schwartz


[[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] Extracting numeric part from a string

2017-08-02 Thread Ismail SEZEN

> On 3 Aug 2017, at 02:59, Christofer Bogaso  
> wrote:
> 
> Hi again,
> 
> I am struggling to extract the number part from below string :
> 
> "\"cm_ffm\":\"563.77\""
> 
> Basically, I need to extract 563.77 from above. The underlying number
> can be a whole number, and there could be comma separator as well.
> 
> So far I tried below :
> 
>> library(stringr)
> 
>> str_extract("\"cm_ffm\":\"563.77\"", "[[:digit:]]+")
> 
> [1] "563"
> 
>> 
> 
> However, above code is only extracting the integer part.
> 
> Could you please help how to achieve that. Thanks,


library(readr)
parse_number('"cm_ffm":"563.77”')

__
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] Extracting numeric part from a string

2017-08-02 Thread Christofer Bogaso
Hi again,

I am struggling to extract the number part from below string :

"\"cm_ffm\":\"563.77\""

Basically, I need to extract 563.77 from above. The underlying number
can be a whole number, and there could be comma separator as well.

So far I tried below :

> library(stringr)

> str_extract("\"cm_ffm\":\"563.77\"", "[[:digit:]]+")

[1] "563"

>

However, above code is only extracting the integer part.

Could you please help how to achieve that. Thanks,

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


Re: [R] How to concatenate in R

2017-08-02 Thread Marc Girondot

Le 02/08/2017 à 13:06, Swain, Subrat a écrit :

Hi,

I have 6 excel files, I want to concatenate all and create one excel files, How 
to program that in R.(I need the code)

Kind regards,

SUBRAT SWAIN

IMPORTANT NOTICE:
The information in this email (and any attachments) is confidential. If you are not the 
intended recipient, you must not use or disseminate the information. If you have received 
this email in error, please immediately notify me by "Reply" command and 
permanently delete the original and any copies or printouts thereof. Although this email 
and any attachments are believed to be free of any virus or other defect that might 
affect any computer system into which it is received and opened, it is the responsibility 
of the recipient to ensure that it is virus free and no responsibility is accepted by 
American International Group, Inc. or its subsidiaries or affiliates either jointly or 
severally, for any loss or damage arising in any way from its use.

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

If you have just 6 files to concatanate and if you don't know at all 
about R, it will be easier to open each of the 6 files in Excel, copy 
the content and paste the content on a virgin sheet.


If you need this code because it is homework, you should first try 
yourself and propose some code that produces error or unwanted results. 
We are not here to do your homework.


Sincerely

Marc

--
__
Marc Girondot, Pr

Laboratoire Ecologie, Systématique et Evolution
Equipe de Conservation des Populations et des Communautés
CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
Bâtiment 362
91405 Orsay Cedex, France

Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53
e-mail: marc.giron...@u-psud.fr
Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
Skype: girondot

__
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] problema al transformar columna tipo "factor" a tipo "numeric" en data.table

2017-08-02 Thread Carlos Ortega
Hola,

Hacerlo dentro de data.table tampoco es que te ofrezca muchas ventajas...

datos$coltipofactor <- as.factor(datos$coltipofactor)

Saludos,
Carlos Ortega
www.qualityexcellence.es


El 2 de agosto de 2017, 19:16, eric  escribió:

> Estimada comunidad, quiero pedirles ayuda con un problema que parece
> simple, pero que no se como resolver. Resulta que quiero transformar una
> columna tipo "factor" a tipo "numeric" en un data.table, pero al hacerlo
> asi:
>
> datos[, coltipofactor:=as.numeric(coltipofactor)]
>
> toma los datos de "coltipofactor" y los cambia de manera consecutiva a los
> que estaban en la columna. Me explico, "coltipofactor" contiene numeros del
> 1 al 12, que representan meses. Cuando transformo la columna a numerica el
> 1 se transforma en 13, el 2 en 14 el 3 en 15 y asi ...
>
> Que estoy haciendo mal ? como se hace bien ? o no se puede hacer ?
>
> Ya me habia pasado esto antes, y lo resolvi de forma manual, pero ahora
> son muchos datos y seguro que hay una forma correcta de hacerlo.
>
> Muchas gracias,
>
> Eric.
>
> ___
> 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


[R-es] problema al transformar columna tipo "factor" a tipo "numeric" en data.table

2017-08-02 Thread eric

  
  
Estimada comunidad, quiero pedirles ayuda con un problema que parece
simple, pero que no se como resolver. Resulta que quiero transformar
una columna tipo "factor" a tipo "numeric" en un data.table, pero al
hacerlo asi:

datos[, coltipofactor:=as.numeric(coltipofactor)]

toma los datos de "coltipofactor" y los cambia de manera consecutiva
a los que estaban en la columna. Me explico, "coltipofactor"
contiene numeros del 1 al 12, que representan meses. Cuando
transformo la columna a numerica el 1 se transforma en 13, el 2 en
14 el 3 en 15 y asi ...

Que estoy haciendo mal ? como se hace bien ? o no se puede hacer ?

Ya me habia pasado esto antes, y lo resolvi de forma manual, pero
ahora son muchos datos y seguro que hay una forma correcta de
hacerlo.

Muchas gracias,

Eric.
  


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

Re: [R] switch of cex adjustment with mfrow?

2017-08-02 Thread Duncan Murdoch

On 02/08/2017 8:29 AM, Jannis via R-help wrote:

Dear list members,


i am trying to create multiple figures with identical layout (i.e. font sizes 
etc.) for a publication created with Latex. To do so (i.e. to get identical 
font sizes) I save all plots as a pdf with widths and heights as they would 
later appear in the paper (to prevent scaling etc.). My problem now is that I 
create several multipanel plots with par(mfrow=c(...)) which sometimes changes 
the cex value. Is there any way (other than using layout() etc which would mean 
a lot of recoding) to prevent this and have identical point and font sizes and 
line widths etc throughout all plots? I tried to increase the cex value so that 
after the reduction by mfrow it is again 1 but I am not sure whether this 
prevents all resizing and was hoping for an easier way to achive this?
Any ideas?


The par() help page describes the changes that happen when mfrow or 
mfcol are set.


You can specify cex when you set mfrow, e.g. instead of

par(mfrow=c(2,2))

use

par(mfrow=c(2,2), cex = 1)

You could put this in a function to save typing (and allow flexibility). 
 For example,


setmfrow <- function(nr, nc, cex = 1) {
  par(mfrow = c(nr, nc), cex = cex)
}


Then use

setmfrow(2,2)

and set both things at once.

Duncan Murdoch

__
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] switch of cex adjustment with mfrow?

2017-08-02 Thread S Ellison
Checking ?par, 
" In a layout with exactly two rows and columns the base value
   of '"cex"' is reduced by a factor of 0.83: if there are three
   or more of either rows or columns, the reduction factor is
   0.66."

You should be able to simply set cex to 1/0.83 for a 2x2 layout and by 1/0.66 
for larger layouts, in a nw 'par' call after setting mfrow or mfcol.
More generally, use the cex value set by mfrow/col:

par(mfrow=c(2,2))
par(cex=1/par("cex"))

plot(1:10)
#Normal size symbols, labels etc.


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jannis via
> R-help
> Sent: 02 August 2017 13:29
> To: r-help@r-project.org
> Subject: [R] switch of cex adjustment with mfrow?
> 
> Dear list members,
> 
> 
> i am trying to create multiple figures with identical layout (i.e. font sizes 
> etc.)
> for a publication created with Latex. To do so (i.e. to get identical font 
> sizes) I
> save all plots as a pdf with widths and heights as they would later appear in
> the paper (to prevent scaling etc.). My problem now is that I create several
> multipanel plots with par(mfrow=c(...)) which sometimes changes the cex
> value. Is there any way (other than using layout() etc which would mean a lot
> of recoding) to prevent this and have identical point and font sizes and line
> widths etc throughout all plots? I tried to increase the cex value so that 
> after
> the reduction by mfrow it is again 1 but I am not sure whether this prevents
> all resizing and was hoping for an easier way to achive this?
> Any ideas?
> CheersJannis
> 
>   [[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.


***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


Re: [R] How to concatenate in R

2017-08-02 Thread PIKAL Petr
Hi

You have plenty of options.

see e.g.
?merge
?cbind
?rbind

If you want more specific answer you need to provide more specific question.

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Swain, Subrat
> Sent: Wednesday, August 2, 2017 1:07 PM
> To: r-help@r-project.org
> Subject: [R] How to concatenate in R
>
>
> Hi,
>
> I have 6 excel files, I want to concatenate all and create one excel files, 
> How to
> program that in R.(I need the code)
>
> Kind regards,
>
> SUBRAT SWAIN
>
> IMPORTANT NOTICE:
> The information in this email (and any attachments) is confidential. If you 
> are
> not the intended recipient, you must not use or disseminate the information. 
> If
> you have received this email in error, please immediately notify me by "Reply"
> command and permanently delete the original and any copies or printouts
> thereof. Although this email and any attachments are believed to be free of 
> any
> virus or other defect that might affect any computer system into which it is
> received and opened, it is the responsibility of the recipient to ensure that 
> it is
> virus free and no responsibility is accepted by American International Group,
> Inc. or its subsidiaries or affiliates either jointly or severally, for any 
> loss or
> damage arising in any way from its use.
>
>   [[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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
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] Superscript and subscrib R for legend x-axis and y-axis and colour different subjects in longitudinal data with different colours

2017-08-02 Thread Rosa Oliveira
Dear all and Pikal (in particular :))

Pikal, I’m sorry. It works!!! 

Thank you very much :)

Best,
Rosa Oliveira



> On 1 Aug 2017, at 16:31, PIKAL Petr  wrote:
> 
> Hi
>  
> Keep your messages coppied to R helplist, others could give you answers too.
>  
> See in line
>  
> From: Rosa Oliveira [mailto:rosit...@gmail.com] 
> Sent: Tuesday, August 1, 2017 4:38 PM
> To: PIKAL Petr 
> Subject: Re: [R] Superscript and subscrib R for legend x-axis and y-axis and 
> colour different subjects in longitudinal data with different colours
>  
> Hi Pikal, 
>  
> I looked your message, but I think you do not answer the question, right?
>  
>  
> Why do you think so. did you try it?
>  
> I basically suggested
>  
> plot(c(1:5), type = "n",
> xlab=expression("t"[i]),
> ylab=expression("y"^ij))
> mtext(expression(lambda^2))
>  
> which by my humble opinion is precisely what you wanted.
>  
> I want to write t_i instead of "Day in ICU” [i subscript for t] and y_ij 
> instead of "CRP (mg/dL)” [ij superscript for y].
>  
> If it is not you need to express yourself more clearly. My crystal ball is 
> broken.
>  
> Cheers
> Petr
>  
> On 31 Jul 2017, at 13:44, PIKAL Petr  > wrote:
>  
> Hi
>  
>  
> From: Rosa Oliveira [mailto:rosit...@gmail.com ] 
> Sent: Monday, July 31, 2017 11:47 AM
> To: Martin Maechler  >
> Cc: PIKAL Petr >; 
> r-help mailing list >
> Subject: Re: [R] Superscript and subscrib R for legend x-axis and y-axis and 
> colour different subjects in longitudinal data with different colours
>  
> Hi, everyone,
>  
> Before everything, thanks. Lots of thanks ;)
>  
> I don’t think you understood everything I need to do.
>  
> Most probably because you did not tell precisely what you really want.
>  
> I want to write t_i instead of "Day in ICU” [i subscript for t] and y_ij 
> instead of "CRP (mg/dL)” [ij superscript for y]. The label of the axis… :( 
>  
> So something like that.
> plot(c(1:5), CRP7raw[1,], type = "n", xlim=c(1,5),
> ylim=c(-10,5) ,
> xlab=expression("t"[i]),
> ylab=expression("y"^ij))
> mtext(expression(lambda^2))
>  
> Cheers
> Petr
>  
> Can you help me on that task?
>  
> Thanks! 
>  
> Best,
> Rosa Oliveira
>  
>  
> On 31 Jul 2017, at 10:28, Martin Maechler  > wrote:
>  
> PIKAL Petr >
>on Mon, 31 Jul 2017 09:11:18 + writes:
>  
> Hi Martin see in line
>  
> -Original Message- From: Martin Maechler
> [mailto:maech...@stat.math.ethz.ch ] Sent: 
> Monday, July
> 31, 2017 10:52 AM To: PIKAL Petr  >
> Cc: Rosa Oliveira >; r-help 
> mailing
> list project.org > 
> 
> Subject: Re: [R] Superscript and subscrib R for legend
> x-axis and y-axis and colour different subjects in
> longitudinal data with different colours
> 
> 
> 
> Hi Rosa > something like
>  
> plot(1,1, sub=expression(lambda^"2"))
>  
> So with your example, do you want something like
>  
> plot(c(1:5), CRP7raw[1,], type = "n", xlim=c(1,5),
> ylim=c(-10,5) , > xlab="Day in ICU", > ylab="CRP
> (mg/dL)", > sub = mtext(expression(lambda^2)))
> 
> OOps!  Either plot( ..., sub = *) or plot( ... ) ;
> mtext(*)
> 
> but not both!
>  
> You are right, I used a code from OP and did not much
> think about it. Strangely enough, the code worked without
> any complain. Probably mtext is "stronger" than sub and
> overrides it.
> 
> Well, well, "the magic of R"  .
> Not quite:  mtext(..) is a valid function call that is evaluated
> before plot() finishes; then it returns NULL invisibly, and
> 'plot(*, sub=NULL)' does nothing "coincidentally" (but for good
> reasons)
> 
> Martin
> 
> 
> Cheers Petr
>  
>  
> CRP7graph <- apply(CRP7, 1, lines, col="gray")
>  
> Cheers > Petr
> 
> 
> 
> -Original Message- > > From: R-help
> [mailto:r-help-boun...@r-project.org ] 
> On Behalf Of Rosa >
> 
> Oliveira > > Sent: Friday, July 28, 2017 5:07 PM > >
> To: r-help mailing list >;
> R-help@r-project.org  > > Subject: [R] 
> Superscript and
> subscrib R for legend x-axis and y-axis > > and colour
> different subjects in longitudinal data with different >
> 
> colours
> 
> 
> I am trying to make a x-axis and y-axis titles with
> both a special > > character and a subscript. I am not
> being able to do this. I think > > its just a placing of
> my parenthesis, but I've tried (seemingly) everything.
> 
> 
> Even more, when 

Re: [R] How to concatenate in R

2017-08-02 Thread Mark Sharp
You will need to understand dataframes and how to add those together. Use the 
help system by typing ?rbind at the console prompt. There are numerous examples 
to be found with a simple web search.

Robert Kabacoff has a great book and website the provides examples and 
explanation at http://www.statmethods.net/management/merging.html

Look at the readxl package. You may want to start with 
http://readxl.tidyverse.org.

Mark
R. Mark Sharp, Ph.D.
msh...@txbiomed.org





> On Aug 2, 2017, at 6:06 AM, Swain, Subrat  wrote:
>
>
> Hi,
>
> I have 6 excel files, I want to concatenate all and create one excel files, 
> How to program that in R.(I need the code)
>
> Kind regards,
>
> SUBRAT SWAIN
>
> IMPORTANT NOTICE:
> The information in this email (and any attachments) is confidential. If you 
> are not the intended recipient, you must not use or disseminate the 
> information. If you have received this email in error, please immediately 
> notify me by "Reply" command and permanently delete the original and any 
> copies or printouts thereof. Although this email and any attachments are 
> believed to be free of any virus or other defect that might affect any 
> computer system into which it is received and opened, it is the 
> responsibility of the recipient to ensure that it is virus free and no 
> responsibility is accepted by American International Group, Inc. or its 
> subsidiaries or affiliates either jointly or severally, for any loss or 
> damage arising in any way from its use.
>
> [[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.

CONFIDENTIALITY NOTICE: This e-mail and any files and/or...{{dropped:10}}

__
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 attribute from netcdf4 object

2017-08-02 Thread Marc Girondot
Le 02/08/2017 à 12:03, raphael.fel...@agroscope.admin.ch a écrit :
> Dear all
>
> For a model I need to combine several netCDF files into one (which works 
> fine). For better overview I'd like to delete/remove some of the attributes. 
> Is there a simple way doing this?
>
> I'm using the package netcdf4, which creates an object of class(nc) = 
> "ncdf4". It seems that for earlier versions of netcdf objects, there was the 
> function att.delete.nc{RNetCDF}. But this functions returns the following 
> error, when applied to ncdf4-classes:
> Error: class(ncfile) == "NetCDF" is not TRUE
You should use package ncdf4 or package RNetCDF, but not mixed both.
Marc
>
> Thanks a lot for any help.
>
> Kind regards
>
> Raphael Felber
>
> 
> Raphael Felber, Dr. sc.
> Wissenschaftlicher Mitarbeiter, Klima und Lufthygiene
>
> Eidgen�ssisches Departement f�r
> Wirtschaft, Bildung und Forschung WBF
> Agroscope
> Forschungsbereich Agrar�kologie und Umwelt
>
> Reckenholzstrasse 191, 8046 Z�rich
> Tel. 058 468 75 11
> Fax 058 468 72 01
> raphael.fel...@agroscope.admin.ch
> www.agroscope.ch
>
>
>   [[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.


-- 
__
Marc Girondot, Pr

Laboratoire Ecologie, Systématique et Evolution
Equipe de Conservation des Populations et des Communautés
CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
Bâtiment 362
91405 Orsay Cedex, France

Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53
e-mail: marc.giron...@u-psud.fr
Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
Skype: girondot


[[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] How to concatenate in R

2017-08-02 Thread Swain, Subrat

Hi,

I have 6 excel files, I want to concatenate all and create one excel files, How 
to program that in R.(I need the code)

Kind regards,

SUBRAT SWAIN

IMPORTANT NOTICE: 
The information in this email (and any attachments) is confidential. If you are 
not the intended recipient, you must not use or disseminate the information. If 
you have received this email in error, please immediately notify me by "Reply" 
command and permanently delete the original and any copies or printouts 
thereof. Although this email and any attachments are believed to be free of any 
virus or other defect that might affect any computer system into which it is 
received and opened, it is the responsibility of the recipient to ensure that 
it is virus free and no responsibility is accepted by American International 
Group, Inc. or its subsidiaries or affiliates either jointly or severally, for 
any loss or damage arising in any way from its use.

[[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] [R-pkgs] glmnetUtils 1.1 now available

2017-08-02 Thread Hong Ooi via R-packages
The version 1.1 update to my glmnetUtils package is now available on CRAN. 
glmnetUtils provides a formula interface for the 'glmnet' package for 
elasticnet regression, a method for cross-validating the alpha parameter, and 
other quality-of-life tools.


>From the NEWS.md file:

- Now allows interaction and expression terms without requiring 
use.model.frame=TRUE. This works in an additive fashion, ie the formula ~ a + 
b:c + d*e is treated as consisting of three terms, a, b:c and d*e each of which 
is processed independently of the others. A dot in the formula includes all 
main effect terms, ie ~ . + a:b + f(x) expands to ~ a + b + x + a:b + f(x) 
(assuming a, b and x are the only columns in the data). Note that a formula 
like ~ (a + b) + (c + d) will be treated as two terms, a + b and c + d.

- The call component of a glmnet/cv.glmnet object that uses the original 
matrix/vector interface is now useful.

- You can now explicitly specify the vector of crossvalidation folds (for the 
inner loop over lambda) when calling cva.glmnet.

- Correctly handle non-syntactic factor variables in a formula.

You can download it from: https://cran.r-project.org/package=glmnetUtils

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

__
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] switch of cex adjustment with mfrow?

2017-08-02 Thread Jannis via R-help
Dear list members, 


i am trying to create multiple figures with identical layout (i.e. font sizes 
etc.) for a publication created with Latex. To do so (i.e. to get identical 
font sizes) I save all plots as a pdf with widths and heights as they would 
later appear in the paper (to prevent scaling etc.). My problem now is that I 
create several multipanel plots with par(mfrow=c(...)) which sometimes changes 
the cex value. Is there any way (other than using layout() etc which would mean 
a lot of recoding) to prevent this and have identical point and font sizes and 
line widths etc throughout all plots? I tried to increase the cex value so that 
after the reduction by mfrow it is again 1 but I am not sure whether this 
prevents all resizing and was hoping for an easier way to achive this?
Any ideas?
CheersJannis

[[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] One Dimensional Monte Carlo Simulation

2017-08-02 Thread HUL-Anthony Egerton
Jason,

Many thanks for your email and the kind assistance provided. 

This is very beautiful code that it is a joy to work through, especially so for 
a beginner like me. I have a couple of quick comments/questions as follows;-

- I made a mistake in specifying L, it should be 7.5e6, which makes far more 
sense
- do you use 7 in the sim function as it is a more than adequate limit given 
the level of lambda.risk here, please?
- shouldn't the i<-freq>1:7 line actually be i<-freq>=1:7?
- excuse my ignorance, but how does the breaks=7 argument impact the sim 
function?

I had made some progress with my own version, which now incorporates a second 
Poisson distribution for catastrophe losses, as follows;-

L<-c(2.5e6,7.5e6,22.5e6)
ln<-c(15.08707, 0.8592507)
lambda<-c(2,0.4)
iterations<-replicate(1,{
freq<-(qpois(runif(2),lambda))
i<-1
temp<-0
while (i<=freq[1]){
sev<-pmin(L[2],pmax(0,(qlnorm(runif(1),ln[1],ln[2])-L[1])))
temp<-temp+sev
i<-i+1}
min(L[3],(temp+(freq[2]*L[2])))})


However, your approach is much simpler and more elegant. Thank you again for 
the insights. 

Best regards,

Tony


Anthony A H Egerton MA MBA ACII
李晋唐
HUNTINGTON UNDERWRITING LIMITED
Labuan FT, Malaysia



CONFIDENTIALITY NOTE: 
 
The information contained in this email message may be legally privileged and 
contain confidential information and is intended only for the use of the 
individual or entity to whom it is addressed. If the reader of this message is 
not the intended recipient, you are hereby notified that any dissemination, 
distribution or copy of this message is strictly prohibited. If you have 
received this email in error, please immediately delete this message.

> On 2 Aug 2017, at 5:13 AM, Law, Jason  wrote:
> 
> Tony,
> 
> I’m not sure what exactly you’re trying to do, but you're not really taking 
> advantage of vectorization in your R code. I've tried to clean it up a 
> little. The clamped lognormal is almost always 0 or L? That seems a little 
> odd. You seem to be using the inverse cdf method of drawing samples. That's 
> not necessary in R for standard probability distributions. You may want to do 
> a little more investigating of basic programming tasks in R before you dig 
> into a complex simulation.
> 
> scale   <- 15.08707 
> shape   <-  0.8592507 
> lambda.risk <-  1.75 
> L   <-  7.5e5 
> R   <-  2.5e6
> 
> # Generate n random poisson with rate = lambda.risk
> frequency <- function(n) rpois(n,lambda.risk)
> 
> # clamp a numeric to 0, L
> clamp <- function(x, min, max) pmin(max, pmax(min, x))
> 
> # Generate lognormal shifted by R
> severity <- function(n) rlnorm(n,scale,shape)-R
> 
> clamp(severity(100), 0, L) # Lognormal shifted left by R, and then clamped 
> between 0 and L? Almost always equal to 0 or L
> 
> sim <- function(breaks = 7){
>  freq   <- frequency(1)
>  i  <- freq > 1:7
>  sev<- clamp(severity(sum(i)), 0, L)
>  claims <- rep(0, 7)
>  claims[i] <- sev
>  min(22.5e6,sum(claims)) 
> }
> 
> hist(iterations <- replicate(1, sim()), breaks = 20)
> 
> 
> 
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of HUL-Anthony 
> Egerton
> Sent: Friday, July 14, 2017 7:45 PM
> To: r-help@r-project.org
> Subject: Re: [R] One Dimensional Monte Carlo Simulation
> 
> Further to my email below, I have just realised that I forgot to include the 
> specification of L and R.
> 
> Hence, the code needs to include the following additional lines at the start;-
> 
> L<-7.5e6
> R<-2.5e6
> 
> Apologies for any confusion caused!
> 
> Best regards,
> 
> Tony
> 
> 
>> On 12 Jul 2017, at 10:03 AM, HUL-Anthony Egerton 
>>  wrote:
>> 
>> I am trying to code a basic Monte Carlo Simulation in R where a Poisson 
>> distribution generates a frequency output that is then input into a 
>> Lognormal distribution, which produces a different, independent severity for 
>> each incidence. The individual incidences are then summed to produce an 
>> aggregate amount per period/iteration. 
>> 
>> Here is the code;-
>> 
>> scale<-15.08707 
>> shape<-0.8592507 
>> lambda.risk<-1.75 
>> L<-7.5e5 
>> R<-2.5e6 
>> iterations<-replicate(1,{ 
>>   claims1<-0 
>>   claims2<-0 
>>   claims3<-0 
>>   claims4<-0 
>>   claims5<-0 
>> claims6<-0 
>>   claims7<-0 
>>   claims<-c(claims1,claims2,claims3,claims4,claims5,claims6,claims7)
>>   freq<-(qpois(runif(1),lambda.risk)) 
>>   sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) 
>>   if(freq>=1){claims1<-sev} 
>>   sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) 
>>   if(freq>=2){claims2<-sev} 
>>   sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) 
>>   if (freq>=3) {claims3<-sev} 
>>   sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) 
>>   if (freq>=4) {claims4<-sev} 
>>   sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) 
>>   if (freq>=5) {claims5<-sev} 
>>   sev<-pmin(L,pmax(0,(qlnorm(runif(1),scale,shape)-R))) 
>>   if (freq>=6) 

Re: [R] Looping Through QuantMod Objects

2017-08-02 Thread Joshua Ulrich
Use auto.assign = FALSE in your getFinancials() call, and use
viewFinancials() to extract the data you want.

items <- c("Cash & Equivalents",
   "Short Term Investments",
   "Cash and Short Term Investments")
tickers <- c("AAPL", "IBM", "MSFT")
for (ticker in tickers) {
  Data <- getFinancials(ticker, auto.assign = FALSE)
  HoldQuart <- viewFinancials(Data, "BS", "Q")
  CashHold <- subset(HoldQuart,rownames(HoldQuart) %in% items)
  CashT <- t(CashHold)
  Cashdf <- data.frame(CashT)
  Cashdf$tic <- ticker
  assign(paste0(ticker, ".c"), Cashdf)
}

If you want to continue processing the data in each [ticker].c object,
it would be better to put the body of the loop into a function and
call lapply(tickers, myfunction).  Then you can use lapply() on the
result to continue applying functions to the data.

You might also be interested in the stackFinancials function I wrote about:
http://blog.fosstrading.com/2017/02/stack-financials.html

Best,
Josh


On Wed, Aug 2, 2017 at 10:00 AM, Sparks, John James  wrote:
> Dear R Helpers,
>
> I have run into a problem trying to perform a number of actions on a set
> of quantmod data objects through a loop and I am hoping that this is an
> easy problem for someone else as opposed to very  difficult for me.
>
> The example task is to get the first three objects of the quarterly
> balance sheet for a number of companies from the getFinancials object and
> put them together into a single file.  I can do this one by one, but if I
> try to build a loop and use the get function then the results are not
> anticipated and leave me baffled.
>
> If I do it one at a time all is good.
>
>
> require(quantmod)
>
> getFinancials("AAPL")
> getFinancials("IBM")
> getFinancials("MSFT")
>
>
> items=c("Cash & Equivalents","Short Term Investments","Cash and Short Term
> Investments")
>
> HoldQuart<-AAPL.f$BS$Q
> CashHold<-subset(HoldQuart,rownames(HoldQuart) %in% items)
> CashT<-t(CashHold)
> Cashdf<-data.frame(CashT)
> Cashdf$tic<-"AAPL"
> AAPL.c<-Cashdf
>
> HoldQuart<-IBM.f$BS$Q
> CashHold<-subset(HoldQuart,rownames(HoldQuart) %in% items)
> CashT<-t(CashHold)
> Cashdf<-data.frame(CashT)
> Cashdf$tic<-"IBM"
> IBM.c<-Cashdf
>
>
> HoldQuart<-MSFT.f$BS$Q
> CashHold<-subset(HoldQuart,rownames(HoldQuart) %in% items)
> CashT<-t(CashHold)
> Cashdf<-data.frame(CashT)
> Cashdf$tic<-"MSFT"
> MSFT.c<-Cashdf
>
>
> BigCash<-rbind(AAPL.c, IBM.c, MSFT.c)
> #setwd<-("C:/Users/HP USER/Documents")
> #write.csv(BigCash,file="CashList.csv")
>
>
> When I try to process through this using a loop, however, things go south
> pretty quickly.
>
> tickerlist<-ls(pattern="^[A-Z]+\\.f")
>
> for( i in 1:1)
> {
> test<-get(paste0(tickerlist[i],"$BS$Q"))
> }
>
> Error in get(paste0(tickerlist[i], "$BS$Q")) :
>   object 'AAPL.f$BS$Q' not found
>
> So I tried to break it up into smaller steps, but the resulting matrix
> seems to have lost its structure (see below).
>
> If someone could help me out, I sure would appreciate.
>
> Thanks.
> --John Sparks
>
>
> tickerlist<-ls(pattern="^[A-Z]+\\.f")
> for( i in 1:1)
> {
> HoldFin<-get(tickerlist[i])
> BSQ<-as.matrix(paste0(HoldFin,"$BS$Q"))
> }
> BSQ
>
> [1,] "list(Q = c(52896, NA, 52896, 32305, 20591, 3718, 2776, NA, NA, NA,
> NA, 38799, 14097, NA, NA, -165, 14684, 11029, NA, NA, 11029, NA, NA, NA,
> 11029, NA, 11029, 11029, NA, NA, NA, NA, 5261.69, 2.1, NA, 0.57, NA, NA,
> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2.1, 78351, NA, 78351, 48175,
> 30176, 3946, 2871, NA, NA, NA, NA, 54992, 23359, NA, NA, 122, 24180,
> 17891, NA, NA, 17891, NA, NA, NA, 17891, NA, 17891, 17891, NA, NA, NA, NA,
> 5327.99, 3.36, NA, 0.57, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
> 3.36, \n46852, NA, 46852, 29039, 17813, 3482, 2570, NA, NA, NA, NA, 35091,
> 11761, NA, NA, -159, 12188, 9014, NA, NA, 9014, NA, NA, NA, 9014, NA,
> 9014, 9014, NA, NA, NA, NA, 5393.33, 1.67, NA, 0.57, NA, NA, NA, NA, NA,
> NA, NA, NA, NA, NA, NA, NA, 1.67, 42358, NA, 42358, 26252, 16106, 3441,
> 2560, NA, NA, NA, NA, 32253, 10105, NA, NA, -263, 10469, 7796, NA, NA,
> 7796, NA, NA, NA, 7796, NA, 7796, 7796, NA, NA, NA, NA, 5472.78, 1.42, NA,
> 0.57, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1.42, 50557, NA,
> 50557, \n30636, 19921, 3423, 2511, NA, NA, NA, NA, 36570, 13987, NA, NA,
> -510, 14142, 10516, NA, NA, 10516, NA, NA, NA, 10516, NA, 10516, 10516,
> NA, NA, NA, NA, 5540.89, 1.9, NA, 0.52, NA, NA, NA, NA, NA, NA, NA, NA,
> NA, NA, NA, NA, 1.9), A = c(215639, NA, 215639, 131376, 84263, 14194,
> 10045, NA, NA, NA, NA, 155615, 60024, NA, NA, -1195, 61372, 45687, NA, NA,
> 45687, NA, NA, NA, 45687, NA, 45687, 45687, NA, NA, NA, NA, 5500.28, 8.31,
> NA, 2.18, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 8.31, 233715,
> NA, \n233715, 140089, 93626, 14329, 8067, NA, NA, NA, NA, 162485, 71230,
> NA, NA, -903, 72515, 53394, NA, NA, 53394, NA, NA, NA, 53394, NA, 53394,
> 53394, NA, NA, NA, NA, 5793.07, 9.22, NA, 1.98, NA, NA, NA, NA, NA, NA,
> NA, NA, NA, NA, NA, NA, 9.22, 182795, NA, 

Re: [R] Error in `row.names<-.data.frame`(`*tmp*`, value = c("1.9", "1.9", "1.9", : duplicate 'row.names' are not allowed

2017-08-02 Thread PIKAL Petr
Hi

I did not notice any answer to your question so I try. After studying docs and 
other responses to similar question I deduct that chid.var and alt.var are 
mixed together and new data frame is being build with chid.var and alt.var 
combination as new row names. As the combination is not unique this operation 
results to error.

But I may be completely wrong.

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
> san...@free.fr
> Sent: Saturday, July 29, 2017 1:40 AM
> To: r-help@r-project.org
> Subject: [R] Error in `row.names<-.data.frame`(`*tmp*`, value = c("1.9", 
> "1.9",
> "1.9", : duplicate 'row.names' are not allowed
>
>  Hi,
> Can someone explain this error below,
> I don't understand why the 2 int columns are associated to make a row name
>
> > horse1.data<-read.csv("cte2.csv", header=TRUE, sep=";")
> > h1.dat<-mlogit.data(data=horse1.data,choice="win",chid.var="raceid",al
> > t.var="nbChev",shape="long")
> Error in `row.names<-.data.frame`(`*tmp*`, value = c("1.9", "1.9", "1.9",  :
>   duplicate 'row.names' are not allowed
> In addition: Warning message:
> non-unique values when setting 'row.names': ‘1.9’, ‘2.17’
>
> > head(horse1.data,27)
>raceid nbChev  cteD cteTh win
> 1   1  9  29.6  23.8  no
> 2   1  9   5.3   6.7  no
> 3   1  9  10.9  11.5  no
> 4   1  9   8.2   6.7 yes
> 5   1  9  17.8  18.2  no
> 6   1  9  26.0  30.0  no
> 7   1  9   4.4   5.7  no
> 8   1  9   4.9   6.0  no
> 9   1  9   4.5   6.9  no
> 10  2 17  32.1  48.3  no
> 11  2 17   8.8  24.5  no
> 12  2 17  36.7  18.3  no
> 13  2 17   6.7  11.8 yes
> 14  2 17  10.3  12.8  no
> 15  2 17  61.6  68.5  no
> 16  2 17   2.5   6.7  no
> 17  2 17  27.7  30.9  no
> 18  2 17   8.4  10.5  no
> 19  2 17  56.5  40.7  no
> 20  2 17  95.5  11.9  no
> 21  2 17  12.7   6.4  no
> 22  2 17  19.6  14.2  no
> 23  2 17 269.6  67.2  no
> 24  2 17 300.0  75.6  no
> 25  2 17 300.0 114.3  no
> 26  2 17  36.3  16.9  no
>
> > str(horse1.data)
> 'data.frame':26 obs. of  5 variables:
>  $ raceid: int  1 1 1 1 1 1 1 1 1 2 ...
>  $ nbChev: int  9 9 9 9 9 9 9 9 9 17 ...
>  $ cteD  : num  29.6 5.3 10.9 8.2 17.8 26 4.4 4.9 4.5 32.1 ...
>  $ cteTh : num  23.8 6.7 11.5 6.7 18.2 30 5.7 6 6.9 48.3 ...
>  $ win   : Factor w/ 2 levels "no","yes": 1 1 1 2 1 1 1 1 1 1 ...
>
> below the .csv file url for those willing to reproduce the error
> https://www.dropbox.com/s/wv7nq8tk9k87le5/cte2.csv?dl=0
>
> sandoz
>
> __
> 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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:

[R] Looping Through QuantMod Objects

2017-08-02 Thread Sparks, John James
Dear R Helpers,

I have run into a problem trying to perform a number of actions on a set
of quantmod data objects through a loop and I am hoping that this is an
easy problem for someone else as opposed to very  difficult for me.

The example task is to get the first three objects of the quarterly
balance sheet for a number of companies from the getFinancials object and
put them together into a single file.  I can do this one by one, but if I
try to build a loop and use the get function then the results are not
anticipated and leave me baffled.

If I do it one at a time all is good.


require(quantmod)

getFinancials("AAPL")
getFinancials("IBM")
getFinancials("MSFT")


items=c("Cash & Equivalents","Short Term Investments","Cash and Short Term
Investments")

HoldQuart<-AAPL.f$BS$Q
CashHold<-subset(HoldQuart,rownames(HoldQuart) %in% items)
CashT<-t(CashHold)
Cashdf<-data.frame(CashT)
Cashdf$tic<-"AAPL"
AAPL.c<-Cashdf

HoldQuart<-IBM.f$BS$Q
CashHold<-subset(HoldQuart,rownames(HoldQuart) %in% items)
CashT<-t(CashHold)
Cashdf<-data.frame(CashT)
Cashdf$tic<-"IBM"
IBM.c<-Cashdf


HoldQuart<-MSFT.f$BS$Q
CashHold<-subset(HoldQuart,rownames(HoldQuart) %in% items)
CashT<-t(CashHold)
Cashdf<-data.frame(CashT)
Cashdf$tic<-"MSFT"
MSFT.c<-Cashdf


BigCash<-rbind(AAPL.c, IBM.c, MSFT.c)
#setwd<-("C:/Users/HP USER/Documents")
#write.csv(BigCash,file="CashList.csv")


When I try to process through this using a loop, however, things go south
pretty quickly.

tickerlist<-ls(pattern="^[A-Z]+\\.f")

for( i in 1:1)
{
test<-get(paste0(tickerlist[i],"$BS$Q"))
}

Error in get(paste0(tickerlist[i], "$BS$Q")) :
  object 'AAPL.f$BS$Q' not found

So I tried to break it up into smaller steps, but the resulting matrix
seems to have lost its structure (see below).

If someone could help me out, I sure would appreciate.

Thanks.
--John Sparks


tickerlist<-ls(pattern="^[A-Z]+\\.f")
for( i in 1:1)
{
HoldFin<-get(tickerlist[i])
BSQ<-as.matrix(paste0(HoldFin,"$BS$Q"))
}
BSQ

[1,] "list(Q = c(52896, NA, 52896, 32305, 20591, 3718, 2776, NA, NA, NA,
NA, 38799, 14097, NA, NA, -165, 14684, 11029, NA, NA, 11029, NA, NA, NA,
11029, NA, 11029, 11029, NA, NA, NA, NA, 5261.69, 2.1, NA, 0.57, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2.1, 78351, NA, 78351, 48175,
30176, 3946, 2871, NA, NA, NA, NA, 54992, 23359, NA, NA, 122, 24180,
17891, NA, NA, 17891, NA, NA, NA, 17891, NA, 17891, 17891, NA, NA, NA, NA,
5327.99, 3.36, NA, 0.57, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
3.36, \n46852, NA, 46852, 29039, 17813, 3482, 2570, NA, NA, NA, NA, 35091,
11761, NA, NA, -159, 12188, 9014, NA, NA, 9014, NA, NA, NA, 9014, NA,
9014, 9014, NA, NA, NA, NA, 5393.33, 1.67, NA, 0.57, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 1.67, 42358, NA, 42358, 26252, 16106, 3441,
2560, NA, NA, NA, NA, 32253, 10105, NA, NA, -263, 10469, 7796, NA, NA,
7796, NA, NA, NA, 7796, NA, 7796, 7796, NA, NA, NA, NA, 5472.78, 1.42, NA,
0.57, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1.42, 50557, NA,
50557, \n30636, 19921, 3423, 2511, NA, NA, NA, NA, 36570, 13987, NA, NA,
-510, 14142, 10516, NA, NA, 10516, NA, NA, NA, 10516, NA, 10516, 10516,
NA, NA, NA, NA, 5540.89, 1.9, NA, 0.52, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 1.9), A = c(215639, NA, 215639, 131376, 84263, 14194,
10045, NA, NA, NA, NA, 155615, 60024, NA, NA, -1195, 61372, 45687, NA, NA,
45687, NA, NA, NA, 45687, NA, 45687, 45687, NA, NA, NA, NA, 5500.28, 8.31,
NA, 2.18, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 8.31, 233715,
NA, \n233715, 140089, 93626, 14329, 8067, NA, NA, NA, NA, 162485, 71230,
NA, NA, -903, 72515, 53394, NA, NA, 53394, NA, NA, NA, 53394, NA, 53394,
53394, NA, NA, NA, NA, 5793.07, 9.22, NA, 1.98, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, 9.22, 182795, NA, 182795, 112258, 70537, 11993,
6041, NA, NA, NA, NA, 130292, 52503, NA, NA, -311, 53483, 39510, NA, NA,
39510, NA, NA, NA, 39510, NA, 39510, 39510, NA, NA, NA, 0, 6122.66, 6.45,
NA, 1.81, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 6.45, 170910,
\nNA, 170910, 106606, 64304, 10830, 4475, NA, NA, NA, NA, 121911, 48999,
NA, NA, -24, 50155, 37037, NA, NA, 37037, NA, NA, NA, 37037, NA, 37037,
37037, NA, NA, NA, 0, 6521.5, 5.68, NA, 1.63, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, 5.68))$BS$Q"
[2,] "list(Q = c(NA, 59501, 67101, 11579, NA, 20612, 2910, NA, 11367,
101990, 65124, -37961, 5473, 2617, 189740, 7549, 334532, 28573, 21665,
9992, 3999, 9113, 73342, 84531, NA, 84531, 98522, 28226, NA, 14351,
200450, NA, NA, 33579, NA, 100925, NA, -902, 134082, 334532, NA, 5205.81,
NA, 51093, 60452, 14057, NA, 27977, 2712, NA, 12191, 103332, 62759,
-36249, 5423, 2848, 185638, 7390, 331141, 38510, 21895, 10493, 3499, 9733,
84130, 73557, NA, 73557, 87549, 26948, NA, 14116, 198751, NA, NA, 32144,
NA, 11, \nNA, -1567, 132390, 331141, NA, 5255.42, NA, 58554, 67155,
15754, NA, 29299, 2132, NA, 8283, 106869, 61245, -34235, 5414, 3206,
170430, 8757, 321686, 37294, 20951, 8105, 3500, 9156, 79006, 75427, NA,
75427, 87032, 26019, NA, 12985, 

Re: [R] Remove attribute from netcdf4 object

2017-08-02 Thread raphael.felber
Hi Marc

That's a workaround I can use. Thanks. I'm a newbie regarding netCDF data. Is 
there any information I'm losing when switching between the packages?

Raphael

Von: Marc Girondot [mailto:marc.giron...@u-psud.fr]
Gesendet: Mittwoch, 2. August 2017 15:13
An: Felber Raphael Agroscope 
Betreff: Re: AW: [R] Remove attribute from netcdf4 object

ok. Sorry, I didn't understood good.
I don't think you can do it in ncdf4 functions. The only solution would be to 
open it in RNetCDF, delete the attribute, save it and then open it in ncdf4.

Marc

Le 02/08/2017 à 15:02, 
raphael.fel...@agroscope.admin.ch a 
écrit :
Dear Marc

Thanks for your remark. I don't want to use both packages. I mentioned the 
package RNetCDF to show that there is a similar function I' d like to use.

Raphael

Von: Marc Girondot [mailto:marc.giron...@u-psud.fr]
Gesendet: Mittwoch, 2. August 2017 14:51
An: Felber Raphael Agroscope 
; 
r-help@r-project.org
Betreff: Re: [R] Remove attribute from netcdf4 object

Le 02/08/2017 à 12:03, 
raphael.fel...@agroscope.admin.ch a 
écrit :

Dear all



For a model I need to combine several netCDF files into one (which works fine). 
For better overview I'd like to delete/remove some of the attributes. Is there 
a simple way doing this?



I'm using the package netcdf4, which creates an object of class(nc) = "ncdf4". 
It seems that for earlier versions of netcdf objects, there was the function 
att.delete.nc{RNetCDF}. But this functions returns the following error, when 
applied to ncdf4-classes:

Error: class(ncfile) == "NetCDF" is not TRUE
You should use package ncdf4 or package RNetCDF, but not mixed both.
Marc







Thanks a lot for any help.



Kind regards



Raphael Felber





Raphael Felber, Dr. sc.

Wissenschaftlicher Mitarbeiter, Klima und Lufthygiene



Eidgen�ssisches Departement f�r

Wirtschaft, Bildung und Forschung WBF

Agroscope

Forschungsbereich Agrar�kologie und Umwelt



Reckenholzstrasse 191, 8046 Z�rich

Tel. 058 468 75 11

Fax 058 468 72 01

raphael.fel...@agroscope.admin.ch

www.agroscope.ch





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



--

__

Marc Girondot, Pr



Laboratoire Ecologie, Systématique et Evolution

Equipe de Conservation des Populations et des Communautés

CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079

Bâtiment 362

91405 Orsay Cedex, France



Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53

e-mail: marc.giron...@u-psud.fr

Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html

Skype: girondot



--

__

Marc Girondot, Pr



Laboratoire Ecologie, Systématique et Evolution

Equipe de Conservation des Populations et des Communautés

CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079

Bâtiment 362

91405 Orsay Cedex, France



Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53

e-mail: marc.giron...@u-psud.fr

Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html

Skype: girondot

[[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 attribute from netcdf4 object

2017-08-02 Thread raphael.felber
Dear Marc

Thanks for your remark. I don't want to use both packages. I mentioned the 
package RNetCDF to show that there is a similar function I' d like to use.

Raphael

Von: Marc Girondot [mailto:marc.giron...@u-psud.fr]
Gesendet: Mittwoch, 2. August 2017 14:51
An: Felber Raphael Agroscope ; 
r-help@r-project.org
Betreff: Re: [R] Remove attribute from netcdf4 object

Le 02/08/2017 à 12:03, 
raphael.fel...@agroscope.admin.ch a 
écrit :

Dear all



For a model I need to combine several netCDF files into one (which works fine). 
For better overview I'd like to delete/remove some of the attributes. Is there 
a simple way doing this?



I'm using the package netcdf4, which creates an object of class(nc) = "ncdf4". 
It seems that for earlier versions of netcdf objects, there was the function 
att.delete.nc{RNetCDF}. But this functions returns the following error, when 
applied to ncdf4-classes:

Error: class(ncfile) == "NetCDF" is not TRUE
You should use package ncdf4 or package RNetCDF, but not mixed both.
Marc






Thanks a lot for any help.



Kind regards



Raphael Felber





Raphael Felber, Dr. sc.

Wissenschaftlicher Mitarbeiter, Klima und Lufthygiene



Eidgen�ssisches Departement f�r

Wirtschaft, Bildung und Forschung WBF

Agroscope

Forschungsbereich Agrar�kologie und Umwelt



Reckenholzstrasse 191, 8046 Z�rich

Tel. 058 468 75 11

Fax 058 468 72 01

raphael.fel...@agroscope.admin.ch

www.agroscope.ch





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



--

__

Marc Girondot, Pr



Laboratoire Ecologie, Systématique et Evolution

Equipe de Conservation des Populations et des Communautés

CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079

Bâtiment 362

91405 Orsay Cedex, France



Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53

e-mail: marc.giron...@u-psud.fr

Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html

Skype: girondot

[[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] Remove attribute from netcdf4 object

2017-08-02 Thread raphael.felber
Dear all

For a model I need to combine several netCDF files into one (which works fine). 
For better overview I'd like to delete/remove some of the attributes. Is there 
a simple way doing this?

I'm using the package netcdf4, which creates an object of class(nc) = "ncdf4". 
It seems that for earlier versions of netcdf objects, there was the function 
att.delete.nc{RNetCDF}. But this functions returns the following error, when 
applied to ncdf4-classes:
Error: class(ncfile) == "NetCDF" is not TRUE

Thanks a lot for any help.

Kind regards

Raphael Felber


Raphael Felber, Dr. sc.
Wissenschaftlicher Mitarbeiter, Klima und Lufthygiene

Eidgen�ssisches Departement f�r
Wirtschaft, Bildung und Forschung WBF
Agroscope
Forschungsbereich Agrar�kologie und Umwelt

Reckenholzstrasse 191, 8046 Z�rich
Tel. 058 468 75 11
Fax 058 468 72 01
raphael.fel...@agroscope.admin.ch
www.agroscope.ch


[[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] Generating samples from truncated multivariate Student-t distribution

2017-08-02 Thread Martin Maechler
> David Winsemius 
> on Tue, 9 May 2017 14:33:04 -0700 writes:

>> On May 9, 2017, at 2:05 PM, Czarek Kowalski  
wrote:
>> 
>> I have already posted that in attachement - pdf file.

> I see that now. I failed to scroll to the 3rd page.

from a late reader:

Please, Czarek, and every other future reader:   This is an
unwritten "regulation" about all R lists I know (a few of which
I co-maintain): 

___>  R code must be given as unformatted plain text  rather than
___>  in a formatted document (pdf in your case) 


>> I am posting plain text here:

good .. and please do always on these lists


Martin Maechler, ETH Zurich & R Core


>> 
>>> library(tmvtnorm)
>>> meann = c(55, 40, 50, 35, 45, 30)
>>> covv = matrix(c(  1, 1, 0, 2, -1, -1,
>> 1, 16, -6, -6, -2, 12,
>> 0, -6, 4, 2, -2, -5,
>> 2, -6, 2, 25, 0, -17,
>> -1, -2, -2, 0, 9, -5,
>> -1, 12, -5, -17, -5, 36), 6, 6)
>> df = 4
>> lower = c(20, 20, 20, 20, 20, 20)
>> upper = c(60, 60, 60, 60, 60, 60)
>> X1 <- rtmvt(n=10, meann, covv, df, lower, upper)
>> 
>> 
>>> sum(X1[,1]) / 10
>> [1] 54.98258
>> sum(X1[,2]) / 10
>> [1] 40.36153
>> sum(X1[,3]) / 10
>> [1] 49.83571
>> sum(X1[,4]) / 10
>> [1] 34.69571  # "4th element of mean vector"
>> sum(X1[,5]) / 10
>> [1] 44.81081
>> sum(X1[,6]) / 10
>> [1] 31.10834
>> 
>> And corresponding results received using equation (3) from pdf file:
>> [54.97,
>> 40,
>> 49.95,
>> 35.31, #  "4th element of mean vector"
>> 44.94,
>> 31.32]
>> 

> I get similar results for the output from your code, 

> My 100-fold run of your calculations were:

> meansBig <- replicate(100, {Xbig <- rtmvt(n=10, meann, covv, df, 
lower, upper)
> colMeans(Xbig)} )

> describe(meansBig[4,])  # describe is from Hmisc package

> meansBig[4, ] 
> n  missing distinct Info Mean  Gmd  .05  .10  .25 
> 1000  1001 34.7  0.0195434.6834.68
34.69 
> .50  .75  .90  .95 
> 34.7034.7234.7234.73 

> lowest : 34.65222 34.66675 34.66703 34.66875 34.67566
> highest: 34.72939 34.73012 34.73051 34.73742 34.74441


> So agree, 35.31 is outside the plausible range of an RV formed with that 
package, but I don't have any code relating to your calculations from theory.

> Best;
> David.


>> On 9 May 2017 at 22:17, David Winsemius  wrote:
>>> 
 On May 9, 2017, at 1:11 PM, Czarek Kowalski  
wrote:
 
 Of course I have expected the difference between theory and a sample
 of realizations of RV's and result mean should still be a random
 variable. But, for example for 4th element of mean vector: 35.31 -
 34.69571 = 0.61429. It is quite big difference, nieprawdaż? I have
 expected that the difference would be smaller because of law of large
 numbers (for 10mln samples the difference is quite similar).
>>> 
>>> I for one have no idea what is meant by a "4th element of mean vector". 
So I have now idea what to consider "big". I have found that my intuitions 
about multivariate distributions, especially those where the covariate 
structure is as complex as you have assumed, are often far from simulated 
results.
>>> 
>>> I suggest you post some code and results.
>>> 
>>> --
>>> David.
>>> 
>>> 
 
 On 9 May 2017 at 21:40, David Winsemius  wrote:
> 
> On May 9, 2017, at 10:09 AM, Czarek Kowalski  
> wrote:
> 
> Dear Members,
> I am working with 6-dimensional Student-t distribution with 4 degrees
> of freedom truncated to [20; 60]. I have generated 100 000 samples
> from truncated multivariate Student-t distribution using rtmvt
> function from package ‘tmvtnorm’. I have also calculated  mean vector
> using equation (3) from attached pdf. The problem is, that after
> summing all elements in one column of rtmvt result (and dividing by
> 100 000) I do not receive the same result as using (3) equation. Could
> You tell me, what is incorrect, why there is a difference?
> 
> I guess the question is why you would NOT expect a difference between 
theory and a sample of realizations of RV's? The result mean should still be a 
random variable, night wahr?
> 
> 
> Yours faithfully
> Czarek Kowalski
> __
> 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,