Re: [R] (no subject)

2018-08-07 Thread Jim Lemon
Hi malika,
You don't seem to have defined your functions correctly. For example:

H<-function(u,x1)

would define an empty function H if that command worked, but it doesn't

Jim


On Tue, Aug 7, 2018 at 3:51 PM, malika yassa via R-help
 wrote:
> hellothis is my programmeyou can help me, i cann't found a solution for H  
> and this  function i calculate for all value for x1thank you
>
>
> x<-rexp(N,2)
>
> z<-rnorm(0,1,n)
>
> g
> h=max(x)-min(x)
>
> n1=n^0.17
>
> h1=h/n1
>
> k=2
>
> x1<-seq(from=-2,to=2,by=0.1)
>
> s[i]=(x[i]+x[i+1])/2
>
> for(i in 1:N)
>
> fkS<-function(m,k){fkm=-m*(abs(Z-m)=k)-k*(Z-m<=-k)}
>
> k1<-function(u,x1){-1/(2*pi)exp((x1-u)/h1}
>
> for (i in 1:n)
>
> {k1(u,x1)=integrate(-1/(2*pi)exp((x1-u)/h1,lower=s[i-1],upper=s[i])}
>
>
>
>
>
> H<-function(u,x1)
>
> for (i in 1:n)
>
> {H(u,x1)=sum(g[i]*fkS*integrate(k1,lower=s[i-1],upper=s[i])
>
> }
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Lag function

2018-08-07 Thread Bert Gunter
Well, maybe. Whether it's +24 or -24 depends on what you mean by "one day
lag." I suspect you mean -24, but perhaps this will help you decide:

test <- ts(1:72, frequency = 24)
plot(lag(test,24))
plot(lag(test,-24))

Note that the +24 moves the time base back 24 observable units (= hours)
and -24 moves it forward 24 hours. This means that the day 2 observations
are those from day 1, etc., which is usually what is wanted for lag. But
you decide.

Cheers,
Bert



Bert Gunter

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

On Tue, Aug 7, 2018 at 7:47 AM, Edoardo Silvestri <
silvestri.cas...@gmail.com> wrote:

> I have an hourly database and I defined a variable as follows:
> time<-ts(data$variable, frequency=24)
>
> If i need to create the variables with one day lag, the corresponding
> command is lag(time,24)?
>
> Thank you
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] Lag function

2018-08-07 Thread Edoardo Silvestri
I have an hourly database and I defined a variable as follows:
time<-ts(data$variable, frequency=24)

If i need to create the variables with one day lag, the corresponding
command is lag(time,24)?

Thank you

[[alternative HTML version deleted]]

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


Re: [R] loop over matrix: subscript out of bounds

2018-08-07 Thread Rui Barradas

Hello,

If it is not running as you want it, you should say what went wrong.
Post the code that you have tried and the expected output, please.
(In fact, the lack of expected output was the reason why my suggestion 
was completely off target.)


Rui Barradas

On 07/08/2018 09:20, Maija Sirkjärvi wrote:

Thanks, but I didn't quite get it. And I don't get it running as it should.

ti 7. elok. 2018 klo 10.47 Martin Maechler (maech...@stat.math.ethz.ch
) kirjoitti:


 > Thanks for help!
 > However, changing the index from i to j for the column vector
changes the
 > output. I would like the matrix to be the following:

 > -1 1 0 0 0 0 0
 > 0 -1 1 0 0 0 0
 > 0 0 -1 1 0 0 0
 > .
 > etc.

 > How to code it?

as Enrico Schumann showed you:  Without any loop, a very nice
R-ish way (see his message)!

Martin

 > Best,
 > Maija



__
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] Contar DNI por Jurisdicción.

2018-08-07 Thread juan manuel dias
Muchas gracias a todos! Lo resolví de esta forma.

contarDNI_jurisdiccion <-
aggregate(siprovi_diat$DNI~siprovi_diat$jurisdicción,FUN=length,data=siprovi_diat);
View(contarDNI)


El 6 de agosto de 2018, 19:00, Carlos Ortega 
escribió:

> O directamente un sencillo table:
>
> resultado = table(tu_df$JURISDICCION, tu_df$DNI)
>
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>
> El 6 de agosto de 2018, 23:29, eric  escribió:
>
>> Hola, una forma con la libreria data.table:
>>
>> library(data.table)
>>
>> as.data.table(el_data.frame)
>>
>> el_data.frame[, length(DNI), by=JURISDICCION]
>>
>>JURISDICCION V1
>> 1:   As  3
>> 2: Ríos  3
>>
>>
>> Suerte !
>>
>> Eric.
>>
>>
>>
>>
>>
>> On 08/06/2018 04:45 PM, juan manuel dias wrote:
>>
>> Hola,
>>
>> Tengo el siguiente DATA FRAME
>>
>> DNI   JURISDICCION  DISPOSITIVO   NOMBRE  APELLIDO
>> 1Bs As
>> 2Bs As
>> 3Bs As4Entre Ríos 
>> 
>> 5Entre Ríos
>> 6Entre Ríos
>>
>> Quiero contar DNI por Jurisdicción, quedando una tabla que sea:
>>
>> DNI   JURISDICCION
>> 3Bs As
>> 3Entre Ríos
>>
>> Tanto DNI como Jurisdicción son factores.
>>
>> Muchas gracias.
>>
>> Saludos, Juan.
>>
>>  [[alternative HTML version deleted]]
>>
>> ___
>> R-help-es mailing 
>> listR-help-es@r-project.orghttps://stat.ethz.ch/mailman/listinfo/r-help-es
>>
>>
>> --
>> Nota: Las tildes se han omitido para asegurar compatibilidad con algunos 
>> lectores de correo.
>>
>>
>> ___
>> R-help-es mailing list
>> R-help-es@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>
>>
>
>
> --
> 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] installing R in Amazon linux AMI

2018-08-07 Thread akshay kulkarni
dear members,
I am using R in AWS. I am currently using RHEL AMI 
in ec2 instance. I want to shift to Amazon LINUX AMI to lower costs.

How do you install R in Amazon lINUX AMI? I have searched the web, and , to my 
disappointment have not found any articles on how to install R in Amazon linux 
AMI, as is there for RED HAT AMI.

Any help?

Very many thanks for your time and effort...
yours sincerely,
AKSHAY M KULKARNI

[[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] linear regression

2018-08-07 Thread Jim Lemon
Hi Kenneth,
My guess is that you have tried to send screenshots of your output and
these were blocked. Try to cut and paste the output into your message.

Jim


On Tue, Aug 7, 2018 at 6:38 PM, John  wrote:
> On Mon, 6 Aug 2018 20:18:38 +0200
> kenneth Barnhoorn  wrote:
>
> Your examples did not appear.  Remember to use plain text rather
> than html.
>
> JWDougherty
>
>> I have a problem with a linear regression output.
>>
>> In January I made an analysis of some data and received an certain
>> output, if I run the same code now I don’t receive the same output
>> and I don’t see why. It is important to know the country, so I would
>> like to see the country names behind the coefficient names like in
>> January?
>>
>> January:
>>
>>
>>
>>
>> Now:
>>
>> __
>> 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] linear regression

2018-08-07 Thread John
On Mon, 6 Aug 2018 20:18:38 +0200
kenneth Barnhoorn  wrote:

Your examples did not appear.  Remember to use plain text rather
than html.

JWDougherty

> I have a problem with a linear regression output. 
> 
> In January I made an analysis of some data and received an certain
> output, if I run the same code now I don’t receive the same output
> and I don’t see why. It is important to know the country, so I would
> like to see the country names behind the coefficient names like in
> January? 
> 
> January:
> 
> 
> 
> 
> Now: 
> 
> __
> 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] loop over matrix: subscript out of bounds

2018-08-07 Thread Maija Sirkjärvi
Thanks, but I didn't quite get it. And I don't get it running as it should.

ti 7. elok. 2018 klo 10.47 Martin Maechler (maech...@stat.math.ethz.ch)
kirjoitti:

>
> > Thanks for help!
> > However, changing the index from i to j for the column vector changes the
> > output. I would like the matrix to be the following:
>
> > -1 1 0 0 0 0 0
> > 0 -1 1 0 0 0 0
> > 0 0 -1 1 0 0 0
> > .
> > etc.
>
> > How to code it?
>
> as Enrico Schumann showed you:  Without any loop, a very nice
> R-ish way (see his message)!
>
> Martin
>
> > Best,
> > Maija
>
>

[[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] loop over matrix: subscript out of bounds

2018-08-07 Thread Martin Maechler


> Thanks for help!
> However, changing the index from i to j for the column vector changes the
> output. I would like the matrix to be the following:

> -1 1 0 0 0 0 0
> 0 -1 1 0 0 0 0
> 0 0 -1 1 0 0 0
> .
> etc.

> How to code it?

as Enrico Schumann showed you:  Without any loop, a very nice
R-ish way (see his message)!

Martin

> Best,
> Maija

__
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] loop over matrix: subscript out of bounds

2018-08-07 Thread Maija Sirkjärvi
Thanks for help!

However, changing the index from i to j for the column vector changes the
output. I would like the matrix to be the following:

-1 1 0 0 0 0 0
0 -1 1 0 0 0 0
0 0 -1 1 0 0 0
.
etc.

How to code it?

Best,
Maija


>> myMatrix <- matrix(0,5,12)
>> for(i in 1:nrow(myMatrix)) {
>>for(i in 1:ncol(myMatrix)) {
>>  myMatrix[i,i] = -1
>>  myMatrix[i,i+1] = 1
>> }}
>> print(myMatrix)



ma 6. elok. 2018 klo 13.58 Rui Barradas (ruipbarra...@sapo.pt) kirjoitti:

> Hello,
>
> Eric is right but...
>
> You have two assignments. The second sets a value that will be
> overwritten is the next iteration by myMatrix[i,i] = -1 when 'i' becomes
> the next value.
>
> If you fix the second index and use 'j', you might as well do
>
> myMatrix[] = -1
> myMatrix[, ncol(myMatrix)] = 1
>
> Hope this helps,
>
> Rui Barradas
>
> Às 10:24 de 06/08/2018, Eric Berger escreveu:
> > Both loops are on 'i', which is a bad idea. :-)
> > Also myMatrix[i,i+1] will be out-of-bounds if i = ncol(myMatrix)
> >
> >
> > On Mon, Aug 6, 2018 at 12:02 PM, Maija Sirkjärvi <
> maija.sirkja...@gmail.com>
> > wrote:
> >
> >> I have a basic for loop with a simple matrix. The code is doing what it
> is
> >> supposed to do, but I'm still wondering the error "subscript out of
> >> bounds". What would be a smoother way to code such a basic for loop?
> >>
> >> myMatrix <- matrix(0,5,12)
> >> for(i in 1:nrow(myMatrix)) {
> >>for(i in 1:ncol(myMatrix)) {
> >>  myMatrix[i,i] = -1
> >>  myMatrix[i,i+1] = 1
> >> }}
> >> print(myMatrix)
> >>
> >> Thanks in advance!
> >>
> >>  [[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide http://www.R-project.org/
> >> posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

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