[R] Select rows of a data frame according to values of vector in a list

2014-01-03 Thread Mohammad Tanvir Ahamed
Hi there !!

I have a list like as follows : 
>lis
$lis1
[1] 1 3 5 

$lis2
[1] 2 4 6 8 9

I have another data frame like as follows 
>df
1 10 110
2 15 120
3 20 130
4 25 140
5 30 150
6 35 160
7 40 150
8 45 180
9 50 190

Now i want to select the rows of data frame by the value of list and the output 
will be as list and as follows

>dat
$lis1
1 10 110
3 20 130
5 30 150 

$lis2
2 15 120
4 25 140
6 35 160
8 45 180
9 50 190

Any help will be very much appreciated. !!


Best regards


... 
Tanvir Ahamed
Göteborg, Sweden
[[alternative HTML version deleted]]

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


Re: [R] Select rows of a data frame according to values of vector in a list

2014-01-03 Thread Rui Barradas

Hello,

Try the following.

lapply(lis, function(i) df[i, ])


Hope this helps,

Rui Barradas

Em 03-01-2014 09:04, Mohammad Tanvir Ahamed escreveu:

Hi there !!

I have a list like as follows :

lis

$lis1
[1] 1 3 5

$lis2
[1] 2 4 6 8 9

I have another data frame like as follows

df

1 10 110
2 15 120
3 20 130
4 25 140
5 30 150
6 35 160
7 40 150
8 45 180
9 50 190

Now i want to select the rows of data frame by the value of list and the output 
will be as list and as follows


dat

$lis1
1 10 110
3 20 130
5 30 150

$lis2
2 15 120
4 25 140
6 35 160
8 45 180
9 50 190

Any help will be very much appreciated. !!


Best regards


...
Tanvir Ahamed
Göteborg, Sweden
[[alternative HTML version deleted]]



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



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


Re: [R] Select rows of a data frame according to values of vector in a list

2014-01-03 Thread Mohammad Tanvir Ahamed
Thanks !!
 
Best regards


... 
Tanvir Ahamed
Göteborg, Sweden



 From: Rui Barradas 

-h...@r-project.org> 
Sent: Friday, 3 January 2014, 10:58
Subject: Re: [R] Select rows of a data frame according to values of vector in a 
list


Hello,

Try the following.

lapply(lis, function(i) df[i, ])


Hope this helps,

Rui Barradas


Em 03-01-2014 09:04, Mohammad Tanvir Ahamed escreveu:
> Hi there !!
>
> I have a list like as follows :
>> lis
> $lis1
> [1] 1 3 5
>
> $lis2
> [1] 2 4 6 8 9
>
> I have another data frame like as follows
>> df
> 1 10 110
> 2 15 120
> 3 20 130
> 4 25 140
> 5 30 150
> 6 35 160
> 7 40 150
> 8 45 180
> 9 50 190
>
> Now i want to select the rows of data frame by the value of list and the 
> output will be as list and as follows
>
>> dat
> $lis1
> 1 10 110
> 3 20 130
> 5 30 150
>
> $lis2
> 2 15 120
> 4 25 140
> 6 35 160
> 8 45 180
> 9 50 190
>
[[elided Yahoo spam]]
>
>
> Best regards
>
>
> ...
> Tanvir Ahamed
> Göteborg, Sweden
>     [[alternative HTML version deleted]]
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]

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


[R] Ordering the rows of a data frame

2014-01-03 Thread Stefano Sofia

Dear R users,
I have two files of seasonal rainfall data (more than 10,000 rows each); here 
the first 8 rows of each file are reported.

Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
2000,1952,12,1,0,0,1953,3,1,0,0,307.20,90,100.0,1510
2000,1953,3,1,0,0,1953,6,1,0,0,153.60,92,100.0,1510
2000,1953,6,1,0,0,1953,9,1,0,0,181.00,92,100.0,1510
2000,1953,9,1,0,0,1953,12,1,0,0,202.40,91,100.0,1510
2000,1953,12,1,0,0,1954,3,1,0,0,153.80,90,100.0,1510
2000,1954,3,1,0,0,1954,6,1,0,0,286.20,92,100.0,1510
2000,1954,6,1,0,0,1954,9,1,0,0,142.80,92,100.0,1510
2000,1954,9,1,0,0,1954,12,1,0,0,186.60,91,100.0,1510
...

Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
1056,2004,12,1,0,0,2005,3,1,0,0,93.60,2833,32.8,15
1056,2005,3,1,0,0,2005,6,1,0,0,149.80,4406,49.9,15
1056,2005,6,1,0,0,2005,9,1,0,0,52.80,1440,16.3,15
1056,2005,9,1,0,0,2005,12,1,0,0,191.80,1201,13.7,15
1056,2005,12,1,0,0,2006,3,1,0,0,26.40,336,3.9,15
1056,2006,12,1,0,0,2007,3,1,0,0,59.00,3604,41.7,15
1056,2007,3,1,0,0,2007,6,1,0,0,181.16,4414,50.0,15
1056,2007,6,1,0,0,2007,9,1,0,0,96.00,7337,83.1,15
...

I have to load them as data frames, to merge them and sort them by 
(Y_init,M_init,D_init,Code_Raingouge).

I wrote a short function where I first load the two files as data frames

df_1 <- read.csv(file="prec_all_19521201_19821201.csv", sep=",")
df_2 <- read.csv(file="prec_all_19821201_20111201.csv", sep=",")

then I merge them by

df_final <- merge(df_1, df_2, all=TRUE)

and finally I try to order df_final through

df_final <- df_final[order(Y_init, M_init, D_init, Code_Raingouge), ]

but this returns only the first row.

I read the manual carefully and I saw some examples, but I have not been able 
to do this simple task.
I spent quite a long time and now I decided to ask the list.
Could please somebody help me to show me where the mistake is?

Thank you
Stefano




AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
è il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità ed 
urgenza, la risposta al presente messaggio di posta elettronica può essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

[[alternative HTML version deleted]]

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


[R] Package LaplacesDemon information

2014-01-03 Thread Vittorio Colagrande
Dear R-group

 

I can not install the package LaplacesDemon in version 3.0.2 of R.

I ask whether it is possible or, alternatively, signs for a equivalent package.



Thanks you and best regards.

Vittorio Colagrande

[[alternative HTML version deleted]]

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


Re: [R] Ordering the rows of a data frame

2014-01-03 Thread Ista Zahn
On Fri, Jan 3, 2014 at 9:41 AM, Stefano Sofia
 wrote:
>
> Dear R users,
> I have two files of seasonal rainfall data (more than 10,000 rows each); here 
> the first 8 rows of each file are reported.
>
> Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
> 2000,1952,12,1,0,0,1953,3,1,0,0,307.20,90,100.0,1510
> 2000,1953,3,1,0,0,1953,6,1,0,0,153.60,92,100.0,1510
> 2000,1953,6,1,0,0,1953,9,1,0,0,181.00,92,100.0,1510
> 2000,1953,9,1,0,0,1953,12,1,0,0,202.40,91,100.0,1510
> 2000,1953,12,1,0,0,1954,3,1,0,0,153.80,90,100.0,1510
> 2000,1954,3,1,0,0,1954,6,1,0,0,286.20,92,100.0,1510
> 2000,1954,6,1,0,0,1954,9,1,0,0,142.80,92,100.0,1510
> 2000,1954,9,1,0,0,1954,12,1,0,0,186.60,91,100.0,1510
> ...
>
> Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
> 1056,2004,12,1,0,0,2005,3,1,0,0,93.60,2833,32.8,15
> 1056,2005,3,1,0,0,2005,6,1,0,0,149.80,4406,49.9,15
> 1056,2005,6,1,0,0,2005,9,1,0,0,52.80,1440,16.3,15
> 1056,2005,9,1,0,0,2005,12,1,0,0,191.80,1201,13.7,15
> 1056,2005,12,1,0,0,2006,3,1,0,0,26.40,336,3.9,15
> 1056,2006,12,1,0,0,2007,3,1,0,0,59.00,3604,41.7,15
> 1056,2007,3,1,0,0,2007,6,1,0,0,181.16,4414,50.0,15
> 1056,2007,6,1,0,0,2007,9,1,0,0,96.00,7337,83.1,15
> ...
>
> I have to load them as data frames, to merge them and sort them by 
> (Y_init,M_init,D_init,Code_Raingouge).
>
> I wrote a short function where I first load the two files as data frames
>
> df_1 <- read.csv(file="prec_all_19521201_19821201.csv", sep=",")
> df_2 <- read.csv(file="prec_all_19821201_20111201.csv", sep=",")
>
> then I merge them by
>
> df_final <- merge(df_1, df_2, all=TRUE)
>
> and finally I try to order df_final through
>
> df_final <- df_final[order(Y_init, M_init, D_init, Code_Raingouge), ]

You probably need

df_final <- df_final[order(df_final$Y_init, df_final$M_init,
df_final$D_init, df_final$Code_Raingouge), ]

or

df_final <- df_final[with(df_final, order(Y_init, M_init, D_init,
Code_Raingouge)), ]

>
> but this returns only the first row.

That is strange; do you have copies of Y_init, M_init etc. in your workspace?

>
> I read the manual carefully and I saw some examples, but I have not been able 
> to do this simple task.

I can see how the data.frame sorting examples in  ?order would lead to
this confusion, as they are limited to the special case where the
variables you want to sort by are in the workspace rather than (as is
more often the case) variables in the data.frame itself.

> I spent quite a long time and now I decided to ask the list.
> Could please somebody help me to show me where the mistake is?
>
> Thank you
> Stefano
>
>
> 
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
> informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
> alla ricezione. I messaggi di posta elettronica per i client di Regione 
> Marche possono contenere informazioni confidenziali e con privilegi legali. 
> Se non si è il destinatario specificato, non leggere, copiare, inoltrare o 
> archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, 
> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio 
> computer. Ai sensi dell’art. 6 della DGR n. 1394/2008 si segnala che, in caso 
> di necessità ed urgenza, la risposta al presente messaggio di posta 
> elettronica può essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by 
> persons entitled to receive the confidential information it may contain. 
> E-mail messages to clients of Regione Marche may contain information that is 
> confidential and legally privileged. Please do not read, copy, forward, or 
> store this message unless you are an intended recipient of it. If you have 
> received this message in error, please forward it to the sender and delete it 
> completely from your computer system.
>
> [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Ordering the rows of a data frame

2014-01-03 Thread Dmitry Pavlyuk
Hi Sofia!

You need to attach the data file before sorting:

attach(df_final)

or just use full qualified names (like df_final$Y_init)

Dmitry

On 03/01/2014 16:41, Stefano Sofia wrote:
> Dear R users,
> I have two files of seasonal rainfall data (more than 10,000 rows each); here 
> the first 8 rows of each file are reported.
>
> Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
> 2000,1952,12,1,0,0,1953,3,1,0,0,307.20,90,100.0,1510
> 2000,1953,3,1,0,0,1953,6,1,0,0,153.60,92,100.0,1510
> 2000,1953,6,1,0,0,1953,9,1,0,0,181.00,92,100.0,1510
> 2000,1953,9,1,0,0,1953,12,1,0,0,202.40,91,100.0,1510
> 2000,1953,12,1,0,0,1954,3,1,0,0,153.80,90,100.0,1510
> 2000,1954,3,1,0,0,1954,6,1,0,0,286.20,92,100.0,1510
> 2000,1954,6,1,0,0,1954,9,1,0,0,142.80,92,100.0,1510
> 2000,1954,9,1,0,0,1954,12,1,0,0,186.60,91,100.0,1510
> ...
>
> Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
> 1056,2004,12,1,0,0,2005,3,1,0,0,93.60,2833,32.8,15
> 1056,2005,3,1,0,0,2005,6,1,0,0,149.80,4406,49.9,15
> 1056,2005,6,1,0,0,2005,9,1,0,0,52.80,1440,16.3,15
> 1056,2005,9,1,0,0,2005,12,1,0,0,191.80,1201,13.7,15
> 1056,2005,12,1,0,0,2006,3,1,0,0,26.40,336,3.9,15
> 1056,2006,12,1,0,0,2007,3,1,0,0,59.00,3604,41.7,15
> 1056,2007,3,1,0,0,2007,6,1,0,0,181.16,4414,50.0,15
> 1056,2007,6,1,0,0,2007,9,1,0,0,96.00,7337,83.1,15
> ...
>
> I have to load them as data frames, to merge them and sort them by 
> (Y_init,M_init,D_init,Code_Raingouge).
>
> I wrote a short function where I first load the two files as data frames
>
> df_1 <- read.csv(file="prec_all_19521201_19821201.csv", sep=",")
> df_2 <- read.csv(file="prec_all_19821201_20111201.csv", sep=",")
>
> then I merge them by
>
> df_final <- merge(df_1, df_2, all=TRUE)
>
> and finally I try to order df_final through
>
> df_final <- df_final[order(Y_init, M_init, D_init, Code_Raingouge), ]
>
> but this returns only the first row.
>
> I read the manual carefully and I saw some examples, but I have not been able 
> to do this simple task.
> I spent quite a long time and now I decided to ask the list.
> Could please somebody help me to show me where the mistake is?
>
> Thank you
> Stefano
>
>
> 
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
> informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
> alla ricezione. I messaggi di posta elettronica per i client di Regione 
> Marche possono contenere informazioni confidenziali e con privilegi legali. 
> Se non si è il destinatario specificato, non leggere, copiare, inoltrare o 
> archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, 
> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio 
> computer. Ai sensi dellâEUR^(TM)art. 6 della DGR n. 1394/2008 si segnala che, 
> in caso di necessità ed urgenza, la risposta al presente messaggio di posta 
> elettronica può essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by 
> persons entitled to receive the confidential information it may contain. 
> E-mail messages to clients of Regione Marche may contain information that is 
> confidential and legally privileged. Please do not read, copy, forward, or 
> store this message unless you are an intended recipient of it. If you have 
> received this message in error, please forward it to the sender and delete it 
> completely from your computer system.
>
>   [[alternative HTML version deleted]]
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


[R] Linear transformation of multivariate normal

2014-01-03 Thread Dmitry Pavlyuk

Hello, Colleges!

I'm having a problem with illustration of linear transformation of 
multivariate gaussian RV using R.

According to the theory, if X ~ N(0, I), then CX ~ N(0,CC').
But the code below doesn't illustrate this. Please could you help me to 
find a mistake



require(tmvtnorm)
C = matrix(c(2,0,1,1), 2,2)
x = c(1,2)
pmvnorm(lower=rep(-Inf,2),upper=x, sigma=diag(2))

[1] 0.822204
attr(,"error")
[1] 1e-15
attr(,"msg")
[1] "Normal Completion"

pmvnorm(lower=rep(-Inf,2),upper=as.vector(C%*%x), sigma=C %*% t(C))

[1] 0.9452332
attr(,"error")
[1] 1e-15
attr(,"msg")
[1] "Normal Completion"

Dmitry

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


[R] multitaper power analysis

2014-01-03 Thread catalin roibu
Dear all,

I have a big problem with R. I want to make a multitaper power spectrum
analysis of a time series using 3 tapers and a resolution of two years with
robust background noise estimation. I try different packages but
unsuccessful.

library(multitaper)

d<-spec.mtm(CAMstd, nw=2, k=3,deltat=1/12,dtUnits="year")

library(psd)
dB<-Years
dd<-pilot_spec(CAMstd, x.frequency = 2,log="dB",
   ntap = 3, remove.AR = 0, plot = T, verbose = FALSE)


Please give a solution to succeed with this analysis.

Thank you very much!

-- 
---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
   +4 0766 71 76 58
FAX:+4 0230 52 16 64
silvic.usv.ro

[[alternative HTML version deleted]]

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


Re: [R] Ordering the rows of a data frame

2014-01-03 Thread Bert Gunter
Inline

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Fri, Jan 3, 2014 at 7:08 AM, Dmitry Pavlyuk
 wrote:
> Hi Sofia!
>
> You need to attach the data file before sorting:

This is false! -- and generally a bad idea.  See ?with
Please do not give advice without checking whether it is correct.

-- Bert


>
> attach(df_final)
>
> or just use full qualified names (like df_final$Y_init)
>
> Dmitry
>
> On 03/01/2014 16:41, Stefano Sofia wrote:
>> Dear R users,
>> I have two files of seasonal rainfall data (more than 10,000 rows each); 
>> here the first 8 rows of each file are reported.
>>
>> Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
>> 2000,1952,12,1,0,0,1953,3,1,0,0,307.20,90,100.0,1510
>> 2000,1953,3,1,0,0,1953,6,1,0,0,153.60,92,100.0,1510
>> 2000,1953,6,1,0,0,1953,9,1,0,0,181.00,92,100.0,1510
>> 2000,1953,9,1,0,0,1953,12,1,0,0,202.40,91,100.0,1510
>> 2000,1953,12,1,0,0,1954,3,1,0,0,153.80,90,100.0,1510
>> 2000,1954,3,1,0,0,1954,6,1,0,0,286.20,92,100.0,1510
>> 2000,1954,6,1,0,0,1954,9,1,0,0,142.80,92,100.0,1510
>> 2000,1954,9,1,0,0,1954,12,1,0,0,186.60,91,100.0,1510
>> ...
>>
>> Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
>> 1056,2004,12,1,0,0,2005,3,1,0,0,93.60,2833,32.8,15
>> 1056,2005,3,1,0,0,2005,6,1,0,0,149.80,4406,49.9,15
>> 1056,2005,6,1,0,0,2005,9,1,0,0,52.80,1440,16.3,15
>> 1056,2005,9,1,0,0,2005,12,1,0,0,191.80,1201,13.7,15
>> 1056,2005,12,1,0,0,2006,3,1,0,0,26.40,336,3.9,15
>> 1056,2006,12,1,0,0,2007,3,1,0,0,59.00,3604,41.7,15
>> 1056,2007,3,1,0,0,2007,6,1,0,0,181.16,4414,50.0,15
>> 1056,2007,6,1,0,0,2007,9,1,0,0,96.00,7337,83.1,15
>> ...
>>
>> I have to load them as data frames, to merge them and sort them by 
>> (Y_init,M_init,D_init,Code_Raingouge).
>>
>> I wrote a short function where I first load the two files as data frames
>>
>> df_1 <- read.csv(file="prec_all_19521201_19821201.csv", sep=",")
>> df_2 <- read.csv(file="prec_all_19821201_20111201.csv", sep=",")
>>
>> then I merge them by
>>
>> df_final <- merge(df_1, df_2, all=TRUE)
>>
>> and finally I try to order df_final through
>>
>> df_final <- df_final[order(Y_init, M_init, D_init, Code_Raingouge), ]
>>
>> but this returns only the first row.
>>
>> I read the manual carefully and I saw some examples, but I have not been 
>> able to do this simple task.
>> I spent quite a long time and now I decided to ask the list.
>> Could please somebody help me to show me where the mistake is?
>>
>> Thank you
>> Stefano
>>
>>
>> 
>>
>> AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
>> informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
>> alla ricezione. I messaggi di posta elettronica per i client di Regione 
>> Marche possono contenere informazioni confidenziali e con privilegi legali. 
>> Se non si è il destinatario specificato, non leggere, copiare, inoltrare o 
>> archiviare questo messaggio. Se si è ricevuto questo messaggio per errore, 
>> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio 
>> computer. Ai sensi dellâEUR^(TM)art. 6 della DGR n. 1394/2008 si segnala 
>> che, in caso di necessità ed urgenza, la risposta al presente messaggio di 
>> posta elettronica può essere visionata da persone estranee al destinatario.
>> IMPORTANT NOTICE: This e-mail message is intended to be received only by 
>> persons entitled to receive the confidential information it may contain. 
>> E-mail messages to clients of Regione Marche may contain information that is 
>> confidential and legally privileged. Please do not read, copy, forward, or 
>> store this message unless you are an intended recipient of it. If you have 
>> received this message in error, please forward it to the sender and delete 
>> it completely from your computer system.
>>
>>   [[alternative HTML version deleted]]
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
> [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

[R] (no subject)

2014-01-03 Thread tania dehesh
Hi
I have a factor in two
level and a continues variable nested in one of the factor A levels. Does it
nested ancova model? Please guide me
Regards,
[[alternative HTML version deleted]]

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


[R] APA two-way bar-chart

2014-01-03 Thread Benjamin Telkamp [via R]
Dear R-users,

I'm struggling with APA formatted two way BAR-charts according to apa-style
i should have the legend in the background of my plot (so above the bars and
not beside the picture/plot itself) and the background should be completely
white without gridlines or what so ever. Could any one give me a hint or
solution? See Below for my commands

thank you so much,

Benjamin Telkamp (Email: inzichtel...@gmail.com, The Netherlands)

these are the commands used so far which just didn't give me what i wanted

library(ggplot2)
library(foreign)
install.packages("Hmisc")
DATA1 <- read.spss(file=DATA1, use.value.labels=TRUE, to.data.frame=TRUE)
Bar_PD <- ggplot(DATA1, aes(Age_group, IRI_PD ))
Bar_PD + stat_summary(fun.y = mean, geom = "bar", fill = "Purple") +
stat_summary(fun.data = mean_cl_normal, geom = "errorbar", width = 0.2) +
labs (x = "Leeftijdsgroep", y = "IRI PD") + theme(plot.background =
element_rect(colour= "White"))







__
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/APA-two-way-bar-chart-tp4683046.html
This email was sent by Benjamin Telkamp (via Nabble)
To receive all replies by email, subscribe to this discussion: 
http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=subscribe_by_code&node=4683046&code=ci1oZWxwQHItcHJvamVjdC5vcmd8NDY4MzA0NnwtNzg0MjM1NTA4
[[alternative HTML version deleted]]

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


Re: [R] Ordering the rows of a data frame

2014-01-03 Thread Dmitry Pavlyuk
Bert, why do you think that "attach" is not working in this case? Did 
you check it before your advice? :)
I agree about "generally bad approach", but it is quite convenient for 
work with one data set.


Dmitry

On 03/01/2014 18:28, Bert Gunter wrote:

Inline

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Fri, Jan 3, 2014 at 7:08 AM, Dmitry Pavlyuk
 wrote:

Hi Sofia!

You need to attach the data file before sorting:

This is false! -- and generally a bad idea.  See ?with
Please do not give advice without checking whether it is correct.

-- Bert



attach(df_final)

or just use full qualified names (like df_final$Y_init)

Dmitry

On 03/01/2014 16:41, Stefano Sofia wrote:

Dear R users,
I have two files of seasonal rainfall data (more than 10,000 rows each); here 
the first 8 rows of each file are reported.

Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
2000,1952,12,1,0,0,1953,3,1,0,0,307.20,90,100.0,1510
2000,1953,3,1,0,0,1953,6,1,0,0,153.60,92,100.0,1510
2000,1953,6,1,0,0,1953,9,1,0,0,181.00,92,100.0,1510
2000,1953,9,1,0,0,1953,12,1,0,0,202.40,91,100.0,1510
2000,1953,12,1,0,0,1954,3,1,0,0,153.80,90,100.0,1510
2000,1954,3,1,0,0,1954,6,1,0,0,286.20,92,100.0,1510
2000,1954,6,1,0,0,1954,9,1,0,0,142.80,92,100.0,1510
2000,1954,9,1,0,0,1954,12,1,0,0,186.60,91,100.0,1510
...

Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
1056,2004,12,1,0,0,2005,3,1,0,0,93.60,2833,32.8,15
1056,2005,3,1,0,0,2005,6,1,0,0,149.80,4406,49.9,15
1056,2005,6,1,0,0,2005,9,1,0,0,52.80,1440,16.3,15
1056,2005,9,1,0,0,2005,12,1,0,0,191.80,1201,13.7,15
1056,2005,12,1,0,0,2006,3,1,0,0,26.40,336,3.9,15
1056,2006,12,1,0,0,2007,3,1,0,0,59.00,3604,41.7,15
1056,2007,3,1,0,0,2007,6,1,0,0,181.16,4414,50.0,15
1056,2007,6,1,0,0,2007,9,1,0,0,96.00,7337,83.1,15
...

I have to load them as data frames, to merge them and sort them by 
(Y_init,M_init,D_init,Code_Raingouge).

I wrote a short function where I first load the two files as data frames

df_1 <- read.csv(file="prec_all_19521201_19821201.csv", sep=",")
df_2 <- read.csv(file="prec_all_19821201_20111201.csv", sep=",")

then I merge them by

df_final <- merge(df_1, df_2, all=TRUE)

and finally I try to order df_final through

df_final <- df_final[order(Y_init, M_init, D_init, Code_Raingouge), ]

but this returns only the first row.

I read the manual carefully and I saw some examples, but I have not been able 
to do this simple task.
I spent quite a long time and now I decided to ask the list.
Could please somebody help me to show me where the mistake is?

Thank you
Stefano




AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere 
informazioni confidenziali, pertanto è destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
è il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si è ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dellâEUR^(TM)art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessità 
 ed urgenza, la risposta al presente messaggio di posta elettronica può essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

   [[alternative HTML version deleted]]



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


 [[alternative HTML version deleted]]


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



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

Re: [R] Ordering the rows of a data frame

2014-01-03 Thread Bert Gunter
You misunderstand = I was not sufficiently clear.

What is false is your statement that "you **need** to attach the data
file before sorting." You do not. with()/within() can be used to avoid
using the fully qualified names without attaching. I did not claim
that attaching first would not work, only that it was not
**necessary** and is generally unwise.


-- Bert



Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Fri, Jan 3, 2014 at 9:21 AM, Dmitry Pavlyuk
 wrote:
> Bert, why do you think that "attach" is not working in this case? Did you
> check it before your advice? :)
> I agree about "generally bad approach", but it is quite convenient for work
> with one data set.
>
> Dmitry
>
> On 03/01/2014 18:28, Bert Gunter wrote:
>>
>> Inline
>>
>> Bert Gunter
>> Genentech Nonclinical Biostatistics
>> (650) 467-7374
>>
>> "Data is not information. Information is not knowledge. And knowledge
>> is certainly not wisdom."
>> H. Gilbert Welch
>>
>>
>>
>>
>> On Fri, Jan 3, 2014 at 7:08 AM, Dmitry Pavlyuk
>>  wrote:
>>>
>>> Hi Sofia!
>>>
>>> You need to attach the data file before sorting:
>>
>> This is false! -- and generally a bad idea.  See ?with
>> Please do not give advice without checking whether it is correct.
>>
>> -- Bert
>>
>>
>>> attach(df_final)
>>>
>>> or just use full qualified names (like df_final$Y_init)
>>>
>>> Dmitry
>>>
>>> On 03/01/2014 16:41, Stefano Sofia wrote:

 Dear R users,
 I have two files of seasonal rainfall data (more than 10,000 rows each);
 here the first 8 rows of each file are reported.


 Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
 2000,1952,12,1,0,0,1953,3,1,0,0,307.20,90,100.0,1510
 2000,1953,3,1,0,0,1953,6,1,0,0,153.60,92,100.0,1510
 2000,1953,6,1,0,0,1953,9,1,0,0,181.00,92,100.0,1510
 2000,1953,9,1,0,0,1953,12,1,0,0,202.40,91,100.0,1510
 2000,1953,12,1,0,0,1954,3,1,0,0,153.80,90,100.0,1510
 2000,1954,3,1,0,0,1954,6,1,0,0,286.20,92,100.0,1510
 2000,1954,6,1,0,0,1954,9,1,0,0,142.80,92,100.0,1510
 2000,1954,9,1,0,0,1954,12,1,0,0,186.60,91,100.0,1510
 ...


 Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
 1056,2004,12,1,0,0,2005,3,1,0,0,93.60,2833,32.8,15
 1056,2005,3,1,0,0,2005,6,1,0,0,149.80,4406,49.9,15
 1056,2005,6,1,0,0,2005,9,1,0,0,52.80,1440,16.3,15
 1056,2005,9,1,0,0,2005,12,1,0,0,191.80,1201,13.7,15
 1056,2005,12,1,0,0,2006,3,1,0,0,26.40,336,3.9,15
 1056,2006,12,1,0,0,2007,3,1,0,0,59.00,3604,41.7,15
 1056,2007,3,1,0,0,2007,6,1,0,0,181.16,4414,50.0,15
 1056,2007,6,1,0,0,2007,9,1,0,0,96.00,7337,83.1,15
 ...

 I have to load them as data frames, to merge them and sort them by
 (Y_init,M_init,D_init,Code_Raingouge).

 I wrote a short function where I first load the two files as data frames

 df_1 <- read.csv(file="prec_all_19521201_19821201.csv", sep=",")
 df_2 <- read.csv(file="prec_all_19821201_20111201.csv", sep=",")

 then I merge them by

 df_final <- merge(df_1, df_2, all=TRUE)

 and finally I try to order df_final through

 df_final <- df_final[order(Y_init, M_init, D_init, Code_Raingouge), ]

 but this returns only the first row.

 I read the manual carefully and I saw some examples, but I have not been
 able to do this simple task.
 I spent quite a long time and now I decided to ask the list.
 Could please somebody help me to show me where the mistake is?

 Thank you
 Stefano


 

 AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere
 informazioni confidenziali, pertanto è destinato solo a persone 
 autorizzate
 alla ricezione. I messaggi di posta elettronica per i client di Regione
 Marche possono contenere informazioni confidenziali e con privilegi legali.
 Se non si è il destinatario specificato, non leggere, copiare, inoltrare o
 archiviare questo messaggio. Se si è ricevuto questo messaggio per errore,
 inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio
 computer. Ai sensi dellâEUR^(TM)art. 6 della DGR n. 1394/2008 si segnala
 che, in caso di necessità ed urgenza, la risposta al presente messaggio di
 posta elettronica può essere visionata da persone estranee al 
 destinatario.
 IMPORTANT NOTICE: This e-mail message is intended to be received only by
 persons entitled to receive the confidential information it may contain.
 E-mail messages to clients of Regione Marche may contain information that 
 is
 confidential and legally privileged. Please do not read, copy, forward, or
 store this message un

Re: [R] Package LaplacesDemon information

2014-01-03 Thread David Winsemius

On Jan 3, 2014, at 6:45 AM, Vittorio Colagrande wrote:

> Dear R-group
> 
> 
> 
> I can not install the package LaplacesDemon in version 3.0.2 of R.
> 
> I ask whether it is possible or, alternatively, signs for a equivalent 
> package.
> 
> 
> 
> Thanks you and best regards.
> 
> Vittorio Colagrande
> 
>   [[alternative HTML version deleted]]

Please read the Posting Guide. You have offered precious little information 
about the causes of your failure. There are several specific requests in the 
Posting Guide that when you provide them will help people decode your mysteries.

> 
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

-- 

David Winsemius
Alameda, CA, USA

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


[R] robust definition of \code{} for a knitr-produced document

2014-01-03 Thread Michael Friendly
[Not sure if I should post this here, or on a another list, but will try 
here first...]


For a book I'm writing using knitr .Rnw files, I would like to use 
\code{} to mark

*all* R code, without having to escape special characters that appear in R
names, formulas, etc.

In the past, I've use the LaTeX definition of \code{} in the test
file below, without problems.

However, in the context of my book project,
\code{y ~ (A + B)^2} fails, and I'm forced to use \verb|y ~ (A + B)^2|,
or for other cases explicitly escape the special characters, as
in \code{str\_length()} or \code{Arthritis\$sex}.

Below is a test file that *works*.  What I don't know is how to find out why
it doesn't work in the context of my book project.

--- begin code-test.tex ---
\documentclass{article}
\usepackage{url}
\makeatletter
\newcommand\code{\bgroup\@makeother\_\@makeother\~\@makeother\$\@makeother\^\@codex}
\def\@codex#1{{\normalfont\ttfamily\hyphenchar\font=-1 #1}\egroup}
\makeatother

\begin{document}
Testing use of code fragments with special characters without
having to escape them.

\begin{itemize}
  \item Formulas--
   code: \code{y ~ (A + B)^2};
   verb:  \verb|y ~ (A + B)^2|;
   url: \url{y ~ (A + B)^2}
  \item Underscored names--
   code: \code{str_length()};
   verb: \verb|str_length()|;
   url: \url{str_length()}
  \item \$ names--
   code: \code{Arthritis$sex};
   verb:  \verb|Arthritis$sex|;
   url: \url{Arthritis$sex}

\end{itemize}
\end{document}
--- end code-test.tex


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

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


Re: [R] R crashes with memory errors on a 256GB machine (and system shoes only 60GB usage)

2014-01-03 Thread Xebar Saram
Hi again and thank you all for the answers

i need to add that im a relatively R neewb so i apologize in advance

i started R with the --vanilla option and ran gc()

this is the output i get:

> gc()
 used (Mb) gc trigger (Mb) max used (Mb)
Ncells 182236  9.8 407500 21.8   35 18.7
Vcells 277896  2.2 786432  6.0   785897  6.0

also this is the memory.profile()

> memory.profile()
   NULL  symbolpairlist closure environment promise
  15611   866952277 3144175
   language special builtinchar logical integer
  21636  44 63763614574   11089
 double complex   character ... anylist
782   1   20934   0   08023
 expressionbytecode externalptr weakref raw  S4
  162711272 364 365 831
>

im running on linux (arch linux) and 'free' shows this:


zeltak@zuni ~ ↳ free -h
 total   used   free sharedbuffers cached
Mem:  251G99G   152G66G   249M84G
-/+ buffers/cache:14G   237G
Swap:   0B 0B 0B

im not running any parrallel stuff at all

milan: how does one know if the  memory is fragmented?

thank you all again i really appreciate the help

best

Z



On Thu, Jan 2, 2014 at 10:35 PM, Ben Bolker  wrote:

> Xebar Saram  gmail.com> writes:
>
> >
> > Hi All,
> >
> > I have a terrible issue i cant seem to debug which is halting my work
> > completely. I have R 3.02 installed on a linux machine (arch
> linux-latest)
> > which I built specifically for running high memory use models. the system
> > is a 16 core, 256 GB RAM machine. it worked well at the start but in the
> > recent days i keep getting errors and crashes regarding memory use, such
> as
> > "cannot create vector size of XXX, not enough memory" etc
> >
> > when looking at top (linux system monitor) i see i barley scrape the 60
> GB
> > of ram (out of 256GB)
> >
> > i really don't know how to debug this and my whole work is halted due to
> > this so any help would be greatly appreciated
>
>   I'm very sympathetic, but it will be almost impossible to debug
> this sort of a problem remotely, without a reproducible example.
> The only guess that I can make, if you *really* are running *exactly*
> the same code as you previously ran successfully, is that you might
> have some very large objects hidden away in a saved workspace in a
> .RData file that's being loaded automatically ...
>
>   I would check whether gc(), memory.profile(), etc. give sensible results
> in a clean R session (R --vanilla).
>
>   Ben Bolker
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Ordering the rows of a data frame

2014-01-03 Thread Dmitry Pavlyuk

Ah, ok, thank you for explanations!

Dmitry

On 03/01/2014 20:00, Bert Gunter wrote:

You misunderstand = I was not sufficiently clear.

What is false is your statement that "you **need** to attach the data
file before sorting." You do not. with()/within() can be used to avoid
using the fully qualified names without attaching. I did not claim
that attaching first would not work, only that it was not
**necessary** and is generally unwise.


-- Bert



Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Fri, Jan 3, 2014 at 9:21 AM, Dmitry Pavlyuk
 wrote:

Bert, why do you think that "attach" is not working in this case? Did you
check it before your advice? :)
I agree about "generally bad approach", but it is quite convenient for work
with one data set.

Dmitry

On 03/01/2014 18:28, Bert Gunter wrote:

Inline

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Fri, Jan 3, 2014 at 7:08 AM, Dmitry Pavlyuk
 wrote:

Hi Sofia!

You need to attach the data file before sorting:

This is false! -- and generally a bad idea.  See ?with
Please do not give advice without checking whether it is correct.

-- Bert



attach(df_final)

or just use full qualified names (like df_final$Y_init)

Dmitry

On 03/01/2014 16:41, Stefano Sofia wrote:

Dear R users,
I have two files of seasonal rainfall data (more than 10,000 rows each);
here the first 8 rows of each file are reported.


Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
2000,1952,12,1,0,0,1953,3,1,0,0,307.20,90,100.0,1510
2000,1953,3,1,0,0,1953,6,1,0,0,153.60,92,100.0,1510
2000,1953,6,1,0,0,1953,9,1,0,0,181.00,92,100.0,1510
2000,1953,9,1,0,0,1953,12,1,0,0,202.40,91,100.0,1510
2000,1953,12,1,0,0,1954,3,1,0,0,153.80,90,100.0,1510
2000,1954,3,1,0,0,1954,6,1,0,0,286.20,92,100.0,1510
2000,1954,6,1,0,0,1954,9,1,0,0,142.80,92,100.0,1510
2000,1954,9,1,0,0,1954,12,1,0,0,186.60,91,100.0,1510
...


Code_Raingouge,Y_init,M_init,D_init,h_init,m_init,Y_fin,M_fin,D_fin,h_fin,m_fin,Rainfall,N_Values,Quality_Level,Code_Station
1056,2004,12,1,0,0,2005,3,1,0,0,93.60,2833,32.8,15
1056,2005,3,1,0,0,2005,6,1,0,0,149.80,4406,49.9,15
1056,2005,6,1,0,0,2005,9,1,0,0,52.80,1440,16.3,15
1056,2005,9,1,0,0,2005,12,1,0,0,191.80,1201,13.7,15
1056,2005,12,1,0,0,2006,3,1,0,0,26.40,336,3.9,15
1056,2006,12,1,0,0,2007,3,1,0,0,59.00,3604,41.7,15
1056,2007,3,1,0,0,2007,6,1,0,0,181.16,4414,50.0,15
1056,2007,6,1,0,0,2007,9,1,0,0,96.00,7337,83.1,15
...

I have to load them as data frames, to merge them and sort them by
(Y_init,M_init,D_init,Code_Raingouge).

I wrote a short function where I first load the two files as data frames

df_1 <- read.csv(file="prec_all_19521201_19821201.csv", sep=",")
df_2 <- read.csv(file="prec_all_19821201_20111201.csv", sep=",")

then I merge them by

df_final <- merge(df_1, df_2, all=TRUE)

and finally I try to order df_final through

df_final <- df_final[order(Y_init, M_init, D_init, Code_Raingouge), ]

but this returns only the first row.

I read the manual carefully and I saw some examples, but I have not been
able to do this simple task.
I spent quite a long time and now I decided to ask the list.
Could please somebody help me to show me where the mistake is?

Thank you
Stefano




AVVISO IMPORTANTE: Questo messaggio di posta elettronica può contenere
informazioni confidenziali, pertanto è destinato solo a persone autorizzate
alla ricezione. I messaggi di posta elettronica per i client di Regione
Marche possono contenere informazioni confidenziali e con privilegi legali.
Se non si è il destinatario specificato, non leggere, copiare, inoltrare o
archiviare questo messaggio. Se si è ricevuto questo messaggio per errore,
inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio
computer. Ai sensi dellâEUR^(TM)art. 6 della DGR n. 1394/2008 si segnala
che, in caso di necessità ed urgenza, la risposta al presente messaggio di
posta elettronica può essere visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by
persons entitled to receive the confidential information it may contain.
E-mail messages to clients of Regione Marche may contain information that is
confidential and legally privileged. Please do not read, copy, forward, or
store this message unless you are an intended recipient of it. If you have
received this message in error, please forward it to the sender and delete
it completely from your computer system.

[[alternative HTML version deleted]]



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

[R] Permutation test with raster data

2014-01-03 Thread Stefan Mühlbauer
Hello!
 
I am having two variables x and y (whereas y is a set of raster images) and 
want to
quantify the correlation between x and y by calculating the Pearson
Correlation Coefficient. In order to ensure how signficant the correlation
results are, I am interested in getting the p-value (<0.1) for this two
tailed student-t distribution. The problem now is: I have a very small
number of observations and therefore would need to make a permutation test,
which enables to simulate a high number of observations.
 
So far I did  the Pearsons Correlation and Significance test, but without
applying permutaton test. I used following formula for obtaining the
p-values:
 
T = r*(sqrt(n-2))/sqrt(1-r²)
p-value = 2 P [ T(n-2) ≥ |t|]
r...Pearson correlation coefficient
n...degree of freedom
 
Now I have to redo everything using a permutation test. I thought of 
implementing 'lmp' function in 'calc' function of raster package.
The two variables I wanted to save within two lists. I am interested in getting 
the p-value for each pixel. Can this work?
 
I will very much appreaciate your help!
 
                                        
       

Dipl.-Ing. Stefan Mühlbauer, MSc

Kaiser Strasse 85/2/15
A - 1070 Wien

E-Mail:
stefan.mue...@yahoo.de
dattel_pa...@yahoo.de

[[alternative HTML version deleted]]

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


Re: [R] Permutation test with raster data

2014-01-03 Thread Rolf Turner


See in-line below.

cheers,

Rolf Turner

On 04/01/14 12:48, Stefan Mühlbauer wrote:

Hello!
Â
I am having two variables x and y (whereas y is a set of raster images) and 
want to
quantify the correlation between x and y by calculating the Pearson
Correlation Coefficient. In order to ensure how signficant the correlation
results are, I am interested in getting the p-value (<0.1) for this two
tailed student-t distribution. The problem now is: I have a very small
number of observations and therefore would need to make a permutation test,
which enables to simulate a high number of observations.


You are deluding yourself.

Â
So far I did  the Pearsons Correlation and Significance test, but without
applying permutaton test. I used following formula for obtaining the
p-values:
Â
T = r*(sqrt(n-2))/sqrt(1-r²)
p-value = 2 P [ T(n-2) ≥ |t|]
r...Pearson correlation coefficient
n...degree of freedom
Â
Now I have to redo everything using a permutation test. I thought of 
implementing 'lmp' function in 'calc' function of raster package.
The two variables I wanted to save within two lists. I am interested in getting 
the p-value for each pixel. Can this work?
Â
I will very much appreaciate your help!


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


[R] Unstack a dataframe using RCommander

2014-01-03 Thread David Arnold
Hi,

Looking to see how to unstack a dataframe using RCommander. The dataset I'm
using is:

http://www.sagepub.com/dsur/study/DSUR%20Data%20Files/Chapter%209/SpiderLong.dat

I want to use RCommander to change it to this form:

http://www.sagepub.com/dsur/study/DSUR%20Data%20Files/Chapter%209/SpiderWide.dat

Possible?

In R, I would just load the datafile into spiderLong, then run
unstack(spiderLong,Anxiety~Group), but I am trying to find out if I can do
the same just using RCommander.

D.



--
View this message in context: 
http://r.789695.n4.nabble.com/Unstack-a-dataframe-using-RCommander-tp4683072.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] R crashes with memory errors on a 256GB machine (and system shoes only 60GB usage)

2014-01-03 Thread jim holtman
It would help to know the sizes of the objects that have in your
workspace and also provide the 10 prior lines of your script at the
point of the error so that we can see what you are trying to do.  The
following commands will list out the sizes of the objects:


cbind(sapply(ls(), function(x){
object.size(get(x))
}))

copy and paste it into the command line when the error occurs.

Jim Holtman
Data Munger Guru

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


On Fri, Jan 3, 2014 at 3:40 PM, Xebar Saram  wrote:
> Hi again and thank you all for the answers
>
> i need to add that im a relatively R neewb so i apologize in advance
>
> i started R with the --vanilla option and ran gc()
>
> this is the output i get:
>
>> gc()
>  used (Mb) gc trigger (Mb) max used (Mb)
> Ncells 182236  9.8 407500 21.8   35 18.7
> Vcells 277896  2.2 786432  6.0   785897  6.0
>
> also this is the memory.profile()
>
>> memory.profile()
>NULL  symbolpairlist closure environment promise
>   15611   866952277 3144175
>language special builtinchar logical integer
>   21636  44 63763614574   11089
>  double complex   character ... anylist
> 782   1   20934   0   08023
>  expressionbytecode externalptr weakref raw  S4
>   162711272 364 365 831
>>
>
> im running on linux (arch linux) and 'free' shows this:
>
>
> zeltak@zuni ~ ↳ free -h
>  total   used   free sharedbuffers cached
> Mem:  251G99G   152G66G   249M84G
> -/+ buffers/cache:14G   237G
> Swap:   0B 0B 0B
>
> im not running any parrallel stuff at all
>
> milan: how does one know if the  memory is fragmented?
>
> thank you all again i really appreciate the help
>
> best
>
> Z
>
>
>
> On Thu, Jan 2, 2014 at 10:35 PM, Ben Bolker  wrote:
>
>> Xebar Saram  gmail.com> writes:
>>
>> >
>> > Hi All,
>> >
>> > I have a terrible issue i cant seem to debug which is halting my work
>> > completely. I have R 3.02 installed on a linux machine (arch
>> linux-latest)
>> > which I built specifically for running high memory use models. the system
>> > is a 16 core, 256 GB RAM machine. it worked well at the start but in the
>> > recent days i keep getting errors and crashes regarding memory use, such
>> as
>> > "cannot create vector size of XXX, not enough memory" etc
>> >
>> > when looking at top (linux system monitor) i see i barley scrape the 60
>> GB
>> > of ram (out of 256GB)
>> >
>> > i really don't know how to debug this and my whole work is halted due to
>> > this so any help would be greatly appreciated
>>
>>   I'm very sympathetic, but it will be almost impossible to debug
>> this sort of a problem remotely, without a reproducible example.
>> The only guess that I can make, if you *really* are running *exactly*
>> the same code as you previously ran successfully, is that you might
>> have some very large objects hidden away in a saved workspace in a
>> .RData file that's being loaded automatically ...
>>
>>   I would check whether gc(), memory.profile(), etc. give sensible results
>> in a clean R session (R --vanilla).
>>
>>   Ben Bolker
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] Parse character strings so they "align" (line up/match) properly

2014-01-03 Thread Joshua Banta
Dear listserv,

I don't know if this question is more appropriate for the Bioconductor listserv 
or the general R listserv. I am asking it here because I believe this problem 
can be solved using regular R commands in the base package. I suspect you all 
will be very helpful.

I have genetic sequence data in the following form. Each letter represents a 
nucleotide.

ref.sequence <- "ATAGCCGCA"
sequence1 <- "AT[G][C][C]AGCCG[T]CA"
sequence2 <- "ATAGCCGC[C][A][C]A"
sequence3 <- "AT[GCC]AGCCGCA"

The brackets indicate nucleotide "insertions" relative to the reference 
sequence ("ref.sequence"). Some sequences may have some/all of the insertions, 
some may not.

What I want is for all of the positions to "align" (line up) properly. 
Therefore, the sequences lacking a particular insertion should get scored with 
a dash (or dashes) at that position.

I want to end up with this:

ref.sequence should look like this: "AT---AGCCG-C---A"
sequence1 should look like this: "AT[G][C][C]AGCCG[T]C---A"
sequence2 should look like this: "AT---AGCCG-C[C][A][C]A"
sequence3 should look like this: "AT[G][C][C]AGCCG-C---A"

So how can I make this happen efficiently?

Thanks very much in advance,
---
Josh Banta, Ph.D
Assistant Professor
Department of Biology
The University of Texas at Tyler
Tyler, TX 75799
Tel: (903) 565-5655
http://plantevolutionaryecology.org

[[alternative HTML version deleted]]

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


[R] p value of trends for odds ratios (or hazard ratios)

2014-01-03 Thread zhu yao
Dear Sir
Many papers calculated the p value of trends for odds ratios of ordered
category variables. I have found the tabodds command in Stata. But how to
do it in R?
Thanks

*Yao Zhu*


*Department of UrologyFudan University Shanghai Cancer CenterShanghai,
China*

[[alternative HTML version deleted]]

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


[R] [R-pkgs] caret version 6.0-21

2014-01-03 Thread Kuhn, Max
The caret package (short for Classification And REgression
Training) attempts to streamline the process for creating
predictive models. The package contains tools for:

 - data splitting
 - pre-processing
 - feature selection
 - model tuning using resampling (with parallel processing)
 - variable importance estimation

as well as other functionality. The package website has lengthy
descriptions of functionality:

   http://caret.r-forge.r-project.org/

A new version, 6.0-21, was just released to CRAN and contains
major improvements:

 - A new system for user-defined models has been added. See
  http://caret.r-forge.r-project.org/custom_models.html.

 - When creating the grid of tuning parameter values, the column
  names no longer need to be preceded by a period. Periods can
  still be used as before but are not required.

 - trainControl now has a 'method = "none"' resampling option that
  bypasses model tuning and fits the model to the entire training
  set.

- Several new models were added, bringing the total number of
  models up to 149.

 - ggplot methods were added for several classes.

Most changes are not user-visible so that the impact on current
scripts should be minimal.

For this caret update, the AppliedPredictiveModeling package will be
brought up to date shortly with slightly modified scripts for the
analyses contained in the text.

Thanks to the R community and caret contributors: Jed Wing, Steve
Weston, Andre Williams, Chris Keefer, Allan Engelhardt, Tony Cooper,
Zachary Mayer and the R Core Team.

Please contact me (max.k...@pfizer.com) with any comments, suggestions,
questions or ideas for a good wedding toasts.

Max

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

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