[R] Fwd: problem with kmeans

2014-04-28 Thread cassie jones
Dear R-users,

I am trying to run kmeans on a set comprising of 100 observations. But R
somehow can not figure out the true underlying groups, although other
software such as Jmp, MINITAB are producing the desired result.

Following is a brief example of what I am doing.

library(stringdist)
test=c('hematolgy','hemtology','oncology','onclogy',
'oncolgy','dermatolgy','dermatoloy','dematology',
'neurolog','nerology','neurolgy','nerology')

dis=stringdistmatrix(test,test, method = "lv")

set.seed(123)
cl=kmeans(dis,4)


grp_cl=vector('list',4)

for(i in 1:4)
{
grp_cl[[i]]=test[which(cl$cluster==i)]
}
grp_cl

[[1]]
[1] "oncology" "onclogy"

[[2]]
[1] "neurolog" "nerology" "neurolgy" "nerology"

[[3]]
[1] "oncolgy"

[[4]]
[1] "hematolgy"  "hemtology"  "dermatolgy" "dermatoloy" "dematology"

In the above example, the 'test' variable consists of a set of
terminologies with various typos and I am trying to group the similar types
of words based on their string distance. Unfortunately kmeans is not able
to replicate the following result that the other software are able to
produce.
[[1]]
[1] "oncology" "onclogy"  "oncolgy"

[[2]]
[1] "neurolog" "nerology" "neurolgy" "nerology"

[[3]]
[1] "dermatolgy" "dermatoloy" "dematology"

[[4]]
[1] "hematolgy"  "hemtology"


Does anyone know if there is a way out, I have heard from a lot of people
that multivariate analysis in R does not produce the desired result most of
the time. Any help is really appreciated.


Thanks in advance.


Cassie

[[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] problem with input of integrate function

2013-06-16 Thread cassie jones
Hi David,

Thank you so much.

-Cassie


On Sun, Jun 16, 2013 at 9:19 PM, David Winsemius wrote:

>
> On Jun 16, 2013, at 7:15 PM, David Winsemius wrote:
>
> >
> > On Jun 16, 2013, at 6:46 PM, cassie jones wrote:
> >
> >> Dear R-users,
> >>
> >> I am trying to integrate a function using integrate command in R.
> >> The function is as follows,
> >>
> >> integrand
> >> function(x,a)
> >> {
> >> exp(-0.5*a*(1+x^2))/(1+x^2)
> >> }
> >>
> >> Now while I want to integrate it using the command integrate, I get the
> >> following error,
> >>
> >> integrate(integrand(x,2),0,inf)
> >>
> >> Error in match.fun(f) :
> >> 'integrand(x, 2)' is not a function, character or symbol
> >>
> >> I understand that the argument of integrate needs to be solely
> dependent on
> >> x, that is why it is not able to recognize the input as there are both x
> >> and a. But I need to have the integrand dependent on the variable a.
> Does
> >> anyone know how can I handle the problem? Any help is appreciated.
> >
> > You also misspelled `Inf`
> >
> >> integrand <- function(x,a=2)
> > + {
> > + exp(-0.5*a*(1+x^2))/(1+x^2)
> > + }
> >>
> >> integrate(integrand,0,Inf)
> > 0.247085 with absolute error < 3e-05
>
> Can also use '..." argument:
>
> ?integrate
>
>  integrand <- function(x,a)
>  {
>  exp(-0.5*a*(1+x^2))/(1+x^2)
>  }
>
>  integrate(integrand,0,Inf, a=2)
> # 0.247085 with absolute error < 3e-05
> >
> >
> >>
> >> Thanks in advance.
> >>
> >> -Cassie
> >>
> >>  [[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.
> >
> > 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.
>
> David Winsemius
> Alameda, CA, USA
>
>

[[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] problem with input of integrate function

2013-06-16 Thread cassie jones
Dear R-users,

I am trying to integrate a function using integrate command in R.
The function is as follows,

integrand
function(x,a)
 {
 exp(-0.5*a*(1+x^2))/(1+x^2)
 }

Now while I want to integrate it using the command integrate, I get the
following error,

integrate(integrand(x,2),0,inf)

Error in match.fun(f) :
  'integrand(x, 2)' is not a function, character or symbol

I understand that the argument of integrate needs to be solely dependent on
x, that is why it is not able to recognize the input as there are both x
and a. But I need to have the integrand dependent on the variable a. Does
anyone know how can I handle the problem? Any help is appreciated.

Thanks in advance.

-Cassie

[[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] simulation from truncated skew normal

2013-06-11 Thread cassie jones
Hello R-users,

I am trying to simulate from truncated skew normal distribution. I know
there are ways to simulate from skewed normal distribution such as rsn(sn)
or rsnorm(VGAM), but I could not find any command to simulate from a
truncated skew-normal distribution. Does anyone know how to do that? Any
help is appreciated.

Thanks in advance.

Cassie

[[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] problem with the image command

2013-04-09 Thread cassie jones
Yes, I did. But I get the following error with the command
image(x=long,y=lat,z=values)

"Error in image.default(x=long,y=lat,z=values):
 error in evaluating the argument 'x' in selecting a method for function
'image': Error in long: recursive indexing failed at level 2"


Thanks,
Cassie

On Tue, Apr 9, 2013 at 8:16 PM, Pascal Oettli  wrote:

> Hi,
>
> Did you carefully read the help for "image" ?
>
> ## Default S3 method:
> image(x, y, z, zlim, xlim, ylim, col = heat.colors(12),
>   add = FALSE, xaxs = "i", yaxs = "i", xlab, ylab,
>   breaks, oldstyle = FALSE, useRaster, ...)
>
> Regards,
> Pascal
>
>
>
> On 04/10/2013 10:07 AM, cassie jones wrote:
>
>> Hello R-users,
>>
>> I am trying to do an image plot where I have been given latitudes,
>> longitudes and the values at the corresponding locations. A sample of the
>> data is given as follows:
>>
>> values=c(0,1,0,0,0,0,2,2,0,0)
>> lat=c(29.6660,29.6756,29.3492,**29.2654,29.2827,29.4070,35.**
>> 3510,35.6590,35.7587,38.2794)
>> long=c(-95.8121,-95.6565,-95.**5771,-95.4400,-95.4356,-95.**
>> 0294,-81.7940,-81.4850,-81.**3777,-86.)
>>
>>
>> I used the following command to generate the image plot along with an U.S.
>> map:
>>
>> library(maps)
>> image(values,x=sort(long),y=**sort(lat))
>> map("state",add=T)
>>
>> But every time I run the code I get the following error:
>>
>> Error in image.default(values,x=sort(**long),y=sort(lat),
>>
>> increasing 'x' and 'y' values expected
>>
>> Even though I sort the latitude and longitude in increasing order, I am
>> getting this error. Any help is greatly appreciated.
>>
>> Thanks in advance,
>>
>> Cassie.
>>
>> [[alternative HTML version deleted]]
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <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] problem with the image command

2013-04-09 Thread cassie jones
Hello R-users,

I am trying to do an image plot where I have been given latitudes,
longitudes and the values at the corresponding locations. A sample of the
data is given as follows:

   values=c(0,1,0,0,0,0,2,2,0,0)
lat=c(29.6660,29.6756,29.3492,29.2654,29.2827,29.4070,35.3510,35.6590,35.7587,38.2794)
long=c(-95.8121,-95.6565,-95.5771,-95.4400,-95.4356,-95.0294,-81.7940,-81.4850,-81.3777,-86.)


I used the following command to generate the image plot along with an U.S.
map:

library(maps)
image(values,x=sort(long),y=sort(lat))
map("state",add=T)

But every time I run the code I get the following error:

Error in image.default(values,x=sort(long),y=sort(lat),

increasing 'x' and 'y' values expected

Even though I sort the latitude and longitude in increasing order, I am
getting this error. Any help is greatly appreciated.

Thanks in advance,

Cassie.

[[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] problem with break command

2012-04-26 Thread cassie jones
Thanks Berend, you are right. The break command would not work here. But
the while loop is taking time to generate the desired.

On Thu, Apr 26, 2012 at 2:39 PM, Berend Hasselman  wrote:

>
> On 26-04-2012, at 21:30, cassie jones wrote:
>
> > Hello R-users,
> >
> > I am having a problem with the 'break' command in R. I am wondering if
> > anyone can help me out with this. My program is similar to the following.
> >
> > a=rep(NA,5)
> > a[1]=0
> > for(i in 2:5)
> > {
> >a[i]=a[i-1]+runif(1,0,3)
> >if(a[i]>5)
> >{
> >i=2
> >break
> >}
> > }
> >
> > What exactly I am trying to do is find the sequence 'a' where the
> > individual values of 'a' would not be larger than 5. In any sequence, if
> it
> > becomes larger than 5, it would set the counter to be 2 and regenerate
> from
> > i=2. But I guess I have not put the break command in the right place, so
> > even though the 'if' condition becomes true and it sets i=2, it does not
> > regenerate the values of 'a' since the beginning. Any help is really
> > appreciated.
>
>
> break will exit the for loop. You cannot achieve what you desire with
> break.
>
> You need a while loop for this.
>
> i <- 2
> while( i <= 5 )
> # for(i in 2:5)
> {
>   a[i] <- a[i-1]+runif(1,0,3)
>   if(a[i]>5) i <- 2 else i <- i+1
> }
>
> And hope that the while loop will eventually terminate.
>
> Berend
>
>

[[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] problem with break command

2012-04-26 Thread cassie jones
Hello R-users,

I am having a problem with the 'break' command in R. I am wondering if
anyone can help me out with this. My program is similar to the following.

a=rep(NA,5)
a[1]=0
for(i in 2:5)
{
a[i]=a[i-1]+runif(1,0,3)
if(a[i]>5)
{
i=2
break
}
}

What exactly I am trying to do is find the sequence 'a' where the
individual values of 'a' would not be larger than 5. In any sequence, if it
becomes larger than 5, it would set the counter to be 2 and regenerate from
i=2. But I guess I have not put the break command in the right place, so
even though the 'if' condition becomes true and it sets i=2, it does not
regenerate the values of 'a' since the beginning. Any help is really
appreciated.

Thanks in advance.

Cassie

[[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] how to convert seconds to 12 hour time format

2012-04-09 Thread cassie jones
Thanks Henrique.It worked!!! I appreciate your help.

Cassie

On Mon, Apr 9, 2012 at 8:06 PM, Henrique Dallazuanna wrote:

> Try this:
>
> Sys.setlocale(category = "LC_TIME", locale = "US")
> format(as.POSIXct('0001-01-01 00:00:00') + x, "%I:%M:%S %p")
>
>
> On Mon, Apr 9, 2012 at 9:38 PM, cassie jones 
> wrote:
> >
> > Hello everyone,
> >
> > I am wondering if there is any routine in R which can convert time given
> in
> > 'seconds' unit to the 12 hour time format. For example, suppose the data
> > set looks like
> >
> > x=c(36885,84000,20)  #x in seconds
> >
> > I want to get the output as
> >
> > [1] " 11:14:45 AM"
> > [2] " 11:20:00 PM"
> > [3] "12:20:00 AM"
> >
> > Does anyone have any idea? Thanks in advance.
> >
> >
> > Cassie
> >
> >[[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.
>
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>

[[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] how to convert seconds to 12 hour time format

2012-04-09 Thread cassie jones
Hello everyone,

I am wondering if there is any routine in R which can convert time given in
'seconds' unit to the 12 hour time format. For example, suppose the data
set looks like

x=c(36885,84000,20)  #x in seconds

I want to get the output as

[1] " 11:14:45 AM"
[2] " 11:20:00 PM"
[3] "12:20:00 AM"

Does anyone have any idea? Thanks in advance.


Cassie

[[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] spectral analysis

2011-08-23 Thread cassie jones
Is there anything in R similar to spectogram command in matlab?

On Tue, Aug 23, 2011 at 10:20 AM, Petr PIKAL  wrote:

> Hi
>
>
> > Hi all,
> >
> > I am trying to do spectral analysis of a time series data. But I am not
> sure
> > how to do it. Can anyone tell me if there are any package I can use to
> do
> > the analysis using fast fourier transform?
>
> Maybe ?fft or ?spectrum
>
> Regards
> Petr
>
> >
> > Thanks in advance.
> >
> >
> > Cassie
> >
> >[[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] spectral analysis

2011-08-23 Thread cassie jones
Hi all,

I am trying to do spectral analysis of a time series data. But I am not sure
how to do it. Can anyone tell me if there are any package I can use to do
the analysis using fast fourier transform?

Thanks in advance.


Cassie

[[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] replacing duplicate rows

2011-07-21 Thread cassie jones
Hi all,

I have a matrix which looks like the following,

x=matrix(c(1,2,3,4,3,5,4,6,4,9),5,2,byrow=T)

Now, I want to replace the 2nd columns of those 4 rows which have duplicate
entries in the 1st column. For example, x[2,1]=x[3,1]=3 and I want to
replace x[3,2] by x[2,2]. Similarly, I want to replace x[5,2] with x[4,2],
which means that for duplicate entries in the 1st column, I want to replace
the corresponding entries in the 2nd column with its 1st entry of the
duplicate row.

Can anybody help me in this regard?

Thanks,
Cassie

[[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] issue with strptime

2011-06-17 Thread cassie jones
Hi everyone,

I have bunch of date and time observations in the format %Y-%m-%d %I %M %S
%p. I used strptime() to read this format. But the problem is some of the
times are in the format of  %I %M %p, so for those times, strptime is giving
me NA values.

For example,

strptime(paste("2009-04-08","1:49:47 PM"),format="%Y-%m-%d %I:%M:%S %p")

[1] "2009-04-08 13:49:47"


But

strptime(paste("2009-04-08","1:49 PM"),format="%Y-%m-%d %I:%M:%S %p")

[1] NA

Now I have approximately 1 observations, so I can't go through all the
observations individually in order to find which row in the array has this
format.

Can anyone suggest me how to handle this issue? Is there any way to convert
%I %M %p format to %I %M %S %p?

Thanks in advance for the help.

Cassie

[[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] simulation from truncated poisson

2011-05-16 Thread cassie jones
It is truncated from left.

On Mon, May 16, 2011 at 6:33 PM, Greg Snow  wrote:

> Which direction is it truncated?  (only values less than a allowed or only
> greater?).
>
> One simple approach is rejection sampling, just generate from a regular
> poisson distribution, then throw away any values in the truncated region.
>  Another approach if the legal values are those from 0 to a, so that there
> is a finite number of possibilities, then you can use the sample function
> with replace=TRUE and using probabilities from the poisson in the legal
> range.
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of cassie jones
> Sent: Monday, May 16, 2011 5:28 PM
> To: r-help@r-project.org
> Subject: [R] simulation from truncated poisson
>
> Dear all,
>
> I need to simulate values from a Poisson distribution which is truncated at
> certain value 'a'. Can anyone tell me if there is in-built package in R
> which can simulate from a truncated Poisson? If not, what should be the
> steps to write a function which would do that?
>
> Thanks in advance.
>
>
> Cassie
>
> [[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.


Re: [R] simulation from truncated poisson

2011-05-16 Thread cassie jones
Thanks for the help. I appreciate.

On Mon, May 16, 2011 at 10:19 PM, Greg Snow  wrote:

> So there is no maximum value, just a minimum (greater than 0)? Correct?  In
> that case the sample option will not work (unless you choose some really
> high value and say that you won’t go above that), but the rejection sampling
> would still work.  How efficiently it works will depend on how much
> probability a regular poisson would put into the truncated region.
>
>
>
> Another possibility is to find the probability of being in the truncated
> region, then generate a uniform between that value and 1, then feed that
> uniform into the qpois function.
>
>
>
> *From:* cassie jones [mailto:cassiejone...@gmail.com]
> *Sent:* Monday, May 16, 2011 7:46 PM
> *To:* Greg Snow
> *Cc:* r-help@r-project.org
> *Subject:* Re: [R] simulation from truncated poisson
>
>
>
> It is truncated from left.
>
> On Mon, May 16, 2011 at 6:33 PM, Greg Snow  wrote:
>
> Which direction is it truncated?  (only values less than a allowed or only
> greater?).
>
> One simple approach is rejection sampling, just generate from a regular
> poisson distribution, then throw away any values in the truncated region.
>  Another approach if the legal values are those from 0 to a, so that there
> is a finite number of possibilities, then you can use the sample function
> with replace=TRUE and using probabilities from the poisson in the legal
> range.
>
>
> -----Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of cassie jones
> Sent: Monday, May 16, 2011 5:28 PM
> To: r-help@r-project.org
> Subject: [R] simulation from truncated poisson
>
> Dear all,
>
> I need to simulate values from a Poisson distribution which is truncated at
> certain value 'a'. Can anyone tell me if there is in-built package in R
> which can simulate from a truncated Poisson? If not, what should be the
> steps to write a function which would do that?
>
> Thanks in advance.
>
>
> Cassie
>
>[[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] simulation from truncated poisson

2011-05-16 Thread cassie jones
Dear all,

I need to simulate values from a Poisson distribution which is truncated at
certain value 'a'. Can anyone tell me if there is in-built package in R
which can simulate from a truncated Poisson? If not, what should be the
steps to write a function which would do that?

Thanks in advance.


Cassie

[[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] Simulation from discrete uniform

2011-04-07 Thread cassie jones
Dear all,

I am trying to simulate from discrete uniform distribution. But I could not
find any in-built code in R. Could anyone help me please?


Thanks in advance for the time and help.




Cassie

[[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] defining an array with one of the elements being a vector

2011-03-08 Thread cassie jones
Dear all,


I am trying to define an array as follows:

a=array(NA,c(m,2,N,G)),

Even though the numbers N and G are fixed, m is a vector. So, I can't define
'a' as above.

 For eg,

N=3
G=6,
but m=c(2,7,5) and length(m)=N.


Can anyone suggest me how can I define 'a' when m is a vector?


Thanks in advance for your help.


Cassie

[[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 needed with histogram plotting

2011-03-06 Thread cassie jones
Dear all,

I am trying to plot 3 histograms on the same graph using the following
command.

hist(x,xlim=c(0,100))
hist(y,add=TRUE)
hist(z,add=TRUE)

The xlim of y is c(20,21) and that of z is c(99,99.5) , whereas the variable
x has xlim at c(0.5,2). Apparently, the graph end of displaying a line only,
corresponding to each histogram due to the wide range of the xlim and
tightness of the histograms. I need to plot them on the same graph for
comparison purpose. Can anyone suggest me a better way to do it? I am
wondering if there is any command in R, where we can break the x-axis into
several parts putting a 'break' at the discontinuity..what I mean is if the
x-axis start from 0 and break at say 3, then start at 19 and break at 21 and
the last part starts at say 98. In this way, the histograms would be
prominent.

Thanks in advance.


Cassie

[[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] how to overlay a map of US on image plot

2011-02-13 Thread cassie jones
Dear all,

I have a data set which has latitude, longitude (not in increasing order)
and observed precipitation corresponding to those locations. I am using
image.plot command for that. But I want to overlay a map of US on that plot.
I know we can use map('usa') to draw it, but I dont know how can I overlay
it on the plot of the precipitation data. Can anyone please help me with it?


Thanks in advance.

Cassie.

[[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] replace a row in a matrix

2010-11-14 Thread cassie jones
Dear all,


I created a n*2 matrix and I want to replace the ith row with a vector. Can
anyone suggest me what is the simple way to do it? Sorry for bothering you
with such  simple question. I appreciate any hints or advice.


Thanks in advance.

Cassie

[[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] simulation from pareto distn

2010-11-09 Thread cassie jones
Dear all,

I am trying to simulate from truncated Pareto distribution. I know there is
a package called PtProcess for Pareto distribution...but it is not for
truncated one. Can anyone please help me with this?

Thanks in advance.

Cassie

[[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] executing loop

2010-09-29 Thread cassie jones
Dear All,


I am trying to define a loop for a m*n matrix, where i=1:n and j=1:m. Unlike
the usual for loop, i should go in the following way:

For j=1,
i=1,2,3,n
For j=2,
i=n,n-1,n-2,..,1
For j=3,
i=1,2,3,.n etc.
which means i should go in either increasing or decreasing order
alternatively.
Can anyone please help me in doing this?


Thanks,
Cassie

[[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] plotting convex hull for 3D

2010-09-19 Thread cassie jones
Dear all,

I have a 3 dimensional data and I need to plot a convex hull to it. I have
done it for 2 dimensional case using chull command in R. But I think it does
not work for more than 2 dimension.
Can anyone help me with this? Is there anyway to plot the convex hull for
more than 2 D case?

Thanks.

[[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] executing loop in circular way

2010-09-09 Thread cassie jones
Dear all,

I am writing a program using for loop. The loop contains i which runs from
1:n. There is a feature I need to include here. That is, when i=n, i+1 would
be 1, not n+1. Basically the loop should run in a circular fashion. That
also means, if i=1, i-1=n.

Can anyone help me with this? How can I define it?

Thanks.

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