[R] Stop R from changing matrix to numeric

2014-12-16 Thread Sachinthaka Abeywardana
I have the following cost function:
cost<-function(x){
x[,1]*sin(4*x[,1])+1.1*x[,2]*sin(2*x[,2])
}

If I send in a matrix which has MORE than one row and 2 columns, this
works fine. However, if I try to do cost(t(as.matrix(c(1,1 it
gives me an index error. When I tried debugging it, I found that the
type of matrix 'x' was converted to numeric.

How do I prevent this conversion from matrix to numeric if its a
matrix with just one row? The only way it would work is if I have:
x[1]*sin(4*x[1])+1.1*x[2]*sin(2*x[2]), which in turn wont work with a
matrix input.

Thanks,
Sachin

__
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] Not able to convert data.frame to numeric properly

2014-04-08 Thread Sachinthaka Abeywardana
a is ofcourse a subset of data.frame, a ROW of the original table specifically.

> str(a)
'data.frame': 1 obs. of  4 variables:
 $ GHP: Factor w/ 51 levels "0.0944","0.1446",..: 33
 $ GP : Factor w/ 51 levels "0.1755","0.3582",..: 29
 $ T  : num 2.9
 $ Tn : num 3.3
> dput(a)
structure(list(GHP = structure(33L, .Label = c("0.0944", "0.1446",
"0.2", "0.4124", "0.7601", "0.871", "0.8849", "0.9176", "1.0168",
"1.0663", "1.0947", "1.1823", "1.1831", "1.2418", "1.2542", "1.3082",
"1.3283", "1.3758", "1.4437", "1.4621", "1.5769", "1.6699", "1.7306",
"1.8366", "1.8456", "1.8651", "1.8972", "1.9595", "2.0781", "2.0802",
"2.1553", "2.2097", "2.2194", "2.3669", "2.3935", "2.5351", "2.5374",
"2.5966", "2.6934", "2.7764", "2.9073", "6.003", "6.0825", "6.1013",
"6.1068", "6.1675", "6.2401", "6.6001", "6.6047", "7.8665", "+AC0-27.0565"
), class = "factor"), GP = structure(29L, .Label = c("0.1755",
"0.3582", "0.4155", "0.4208", "0.7388", "0.8394", "0.8853", "0.9254",
"0.9423", "0.9695", "0.9757", "0.9793", "0.9896", "1.0422", "1.0519",
"1.116", "1.2482", "1.2691", "1.2735", "1.2788", "1.2948", "1.3141",
"1.3204", "1.4006", "1.5333", "1.6157", "1.9003", "2.6024", "2.6561",
"2.7466", "2.7572", "2.8108", "2.8256", "2.9565", "2.978", "3.0665",
"3.1155", "3.2027", "3.2123", "3.257", "3.4055", "6.0616", "6.0671",
"6.1166", "6.2053", "6.592", "6.6734", "7.005", "7.3159", "8.5777",
"+AC0-20.3347"), class = "factor"), T = 2.9007, Tn = 3.2988), .Names = c("GHP",
"GP", "T", "Tn"), row.names = 28L, class = "data.frame")

On Wed, Apr 9, 2014 at 4:17 PM, Frede Aakmann Tøgersen  wrote:
> We can't say because we don't know how a was created.
>
> Please email the output from
>
> str(a)
>
> and
>
> dput(a)
>
>
>
> Yours sincerely / Med venlig hilsen
>
>
> Frede Aakmann Tøgersen
> Specialist, M.Sc., Ph.D.
> Plant Performance & Modeling
>
> Technology & Service Solutions
> T +45 9730 5135
> M +45 2547 6050
> fr...@vestas.com
> http://www.vestas.com
>
> Company reg. name: Vestas Wind Systems A/S
> This e-mail is subject to our e-mail disclaimer statement.
> Please refer to www.vestas.com/legal/notice
> If you have received this e-mail in error please contact the sender.
>
>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
>> On Behalf Of Sachinthaka Abeywardana
>> Sent: 9. april 2014 08:11
>> To: r-help@r-project.org
>> Subject: [R] Not able to convert data.frame to numeric properly
>>
>> I have the following:
>>
>>
>> >a #note that the 28 is a row.name
>>
>> GHP GP  T Tn
>> 28   2.2194 2.6561 2.9007 3.2988
>>
>> >min(as.numeric(a))
>> 2.9007
>> >min(as.numeric(as.character(a)))
>> 2.9007
>> >as.numeric(as.character(a)) #What's going on here???
>> [1] 33. 29.  2.9007  3.2988
>>
>> So basically how do I get this to show the correct value of 2.21 as my
>> minimum value?
>>
>> Thanks,
>> Sachin
>>
>> __
>> 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] Not able to convert data.frame to numeric properly

2014-04-08 Thread Sachinthaka Abeywardana
I have the following:


>a #note that the 28 is a row.name

GHP GP  T Tn
28   2.2194 2.6561 2.9007 3.2988

>min(as.numeric(a))
2.9007
>min(as.numeric(as.character(a)))
2.9007
>as.numeric(as.character(a)) #What's going on here???
[1] 33. 29.  2.9007  3.2988

So basically how do I get this to show the correct value of 2.21 as my
minimum value?

Thanks,
Sachin

__
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] xtable use plus minus

2013-09-12 Thread Sachinthaka Abeywardana
I am using a similar dataset to the following:

a= c("Fruits", "Adam","errorA", "steve", "errorS",
 "apples", 17.1,2.22, 3.2,1.1,
 "oranges", 3.1,2.55, 18.1,3.2 )
a_table=data.matrix(t(matrix(a,nrow=5)))

I would like to plus minus every second column starting from errorA (using
xtable/ hmisc)

example output (ignoring decimals):

 Fruits && Adam && Steve \\
 Apples && 17\pm 2 && 3 \pm 1 \\
 Oranges && 3\pm 2 && 18 \pm 3\\

Additionally is there any way I can have just to 2 d.p.?

Thanks,
Sachin

[[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] xtable Highlight the lowest and plus minus

2013-09-10 Thread Sachinthaka Abeywardana
I am using a similar dataset to the following:

a= c("Fruits", "Adam","errorA", "steve", "errorS",
 "apples", 17.1,2.22, 3.2,1.1,
 "oranges", 3.1,2.55, 18.1,3.2 )
a_table=data.matrix(t(matrix(a,nrow=5)))

I would like to highlight the smallest value in the Adam and Steve columns
and, also plus and minus the errors *(using xtable/ hmisc)*

example output (ignoring decimals):

 Fruits && Adam && Steve \\
 Apples && 17\pm 2 && \mathbf{3 \pm 1} \\
 Oranges && \mathbf{3\pm 2} && 18 \pm 3\\

Additionally is there any way I can have just to 2 d.p.?

[[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] Get Index of variables from stepAIC

2013-08-25 Thread Sachinthaka Abeywardana
I am regressing a gene on another gene subset. Then I use stepAIC to reduce
the number of explanatory genes. How do I get the index of the NON-omitted
variables, so that I could analyse them?

gene_subset=c(y=genes[,i], genes[,other_genes]);
reduced_model=stepAIC(y~.,data=gene_subset,trace=false);

[[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] stepAIC problem

2013-08-22 Thread Sachinthaka Abeywardana
Hi all,

I get the expected behaviour of getting a useful model if I do the following

fit<-lm(
expressions[,i]~expressions[,pa_all[1]]+expressions[,pa_all[2]]+expressions[,pa_all[3]]+expressions[,pa_all[4]]+expressions[,pa_all[5]])
step<-stepAIC(fit, direction="both")

Output:
Step: AIC=-78.75

expressions[, i] ~ expressions[, pa_all[5]]

   Df Sum of SqRSS AIC
  43.714 -78.750
+ expressions[, pa_all[4]]  1   0.83982 42.874 -78.690
+ expressions[, pa_all[2]]  1   0.80449 42.909 -78.608
- expressions[, pa_all[5]]  1   1.13431 44.848 -78.188
+ expressions[, pa_all[1]]  1   0.08445 43.630 -76.944
+ expressions[, pa_all[3]]  1   0.07620 43.638 -76.925




but if I do this instead, stepAIC isn't deleting any of the unwanted
columns. It seems to think it can only delete the entire set or none at all.

fit<-lm(expressions[,i]~expressions[,pa_all[1:5]])step<-stepAIC(fit,
direction="both")


Output:

Start:  AIC=-74.42
expressions[, i] ~ expressions[, pa_all[1:5]]

 Df Sum of SqRSS AIC
- expressions[, pa_all[1:5]]  52.7111 44.848 -78.188
42.137 -74.424

Step:  AIC=-78.19
expressions[, i] ~ 1

 Df Sum of SqRSS AIC
44.848 -78.188
+ expressions[, pa_all[1:5]]  52.7111 42.137 -74.424


Thanks,

Sachin

[[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] nth root of matrix

2013-07-02 Thread Sachinthaka Abeywardana
Hi all,

I want to do the following:

a=matrix(c(-1,-2,-3))
a^(1/3) #get 3rd root of numbers[,1]

[1,]  NaN
[2,]  NaN
[3,]  NaN


All I get is NaNs, what is the proper way of doing this? Would like to
retain the fact that it is a matrix if possible (not a requirement
though).


Thanks,

Sachin

[[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] match rows of R

2013-06-26 Thread Sachinthaka Abeywardana
Hi all,

What would be an efficient way to match rows of a matrix to a vector?

ex:

m<-matrix(1:9, nrow=3)

m [,1] [,2] [,3]
[1,]147
[2,]258
[3,]369

#
which(m==c(2,5,8))# I want this to return 2
##

Thanks,
Sachin

[[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] functions with function inputs and optimisation

2013-05-09 Thread Sachinthaka Abeywardana
Hi all,

Would be great if you could help me get my head around the "further
arguemnts" in the optim function. Let's say we have f and g as shown:

f<-function(x,a,b){(x-a)^2+b}

optim(100,fn=f,gr=NULL,2,5) #the NULL is annoying

g<-function(x,a){2*(x-a)} optim(100,fn=f,gr=g,2,5)


1. How does optim know that 2,5 both go into f whereas g only accepts the
first of those arguments. WHAT IF for some random reason I wanted there to
be no common parameters, what then? so for example the input for g to be 3
s.t. f(x,2,5) and g(x,3)

2. Is there a way for me to skip writing gr=NULL the first time I implement
this? Its quite important for me as I want to implement optimx where the
"further arguments" are the last ones, and I do not want to go setting each
parameter to some sort of default. basically I want to say:

optim(100,fn=f,further_args=c(2,5))

Thanks in advance,
Sachin

[[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] Divide matrix columns by different numbers

2013-05-01 Thread Sachinthaka Abeywardana
Hi all,

I have a feeling the most efficient way to do the following is to use
apply, but I'm still wrapping my head around the function.

k=matrix(1:6,nrow=3)

div=1:2


Questions is how do I get R to divide the first column by 1 (div[1]) and
the second column by 2 (div[2])

k/div treats k as a vector and does the following (not what I want)

>k/div


  [,1] [,2]
[1,]12
[2,]15
[3,]33



Thanks,
Sachin

[[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] Meijer G-function

2013-04-22 Thread Sachinthaka Abeywardana
Hi All,

Does anyone know if there is an implementation of the G-function in R.

If so please let me know (could not find this on google).

Thanks,
Sachin

[[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] Using different function (parameters) with apply

2013-04-17 Thread Sachinthaka Abeywardana
Hi All,

I have the following problem (read the commented bit below):

a<-matrix(1:9,nrow=3)


a

 [,1] [,2] [,3]
[1,]147
[2,]258
[3,]369


div<-1:3

apply(a,2,function(x)x/div) ##want to divide each column by div-
instead each row is divided##


 [,1] [,2] [,3]
[1,]1  4.07
[2,]1  2.54
[3,]1  2.03


apply(a,1,function(x)x/div) ##Changing Margin from 2 to 1 does
something completele weird## [,1] [,2] [,3]
[1,] 1.00 2.003
[2,] 2.00 2.503
[3,] 2.33 2.673


Any thoughts?


Thanks,

Sachin

[[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] Accessing examplars in apcluster (apcluster package)

2013-04-04 Thread Sachinthaka Abeywardana
Hi,

I was wondering how it was possible to access the actual cluster exemplars
from the APResult class. Currently it only spits it out onto the terminal
if you type the object but there is no other way to see which one is the
examplar.

Would appreciate any help.

Thanks,
Sachin

[[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 interactive networks in R

2013-03-27 Thread Sachinthaka Abeywardana
Hi all,

I was wondering if there was package/ tutorial somewhere so that I can
plot INTERACTIVE networks in R. What I mean by interactive is that you
can zoom in, twist and rotate, and if necessary move nodes around.

Any thoughts?

Thanks,
Sachin

__
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] installation of package had non-zero exit status

2013-03-20 Thread Sachinthaka Abeywardana
my mistake, had to install the dependency from bioconductor.

Thank you,
Sachin


On Thu, Mar 21, 2013 at 4:11 PM, Jeff Newmiller wrote:

> Contact the package author?
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  Live
> Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
> ---
> Sent from my phone. Please excuse my brevity.
>
> Sachinthaka Abeywardana  wrote:
>
> >Hi all,
> >
> >
> >I am trying to install this NBPSeq package, but I'm now getting the
> >error shown below with ANY package that I try to install.
> >
> >
> >installation of package �NBPSeq� had non-zero exit status
> >
> >
> >This started happening ever since I tried to install a package that I
> >downloaded from a personal website (for some reason only worked on my
> >windows partition). I'm using Ubuntu.
> >
> >
> >Any thoughts?
> >
> >
> >Thanks,
> >
> >Sachin
> >
> >   [[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] installation of package had non-zero exit status

2013-03-20 Thread Sachinthaka Abeywardana
Hi all,


I am trying to install this NBPSeq package, but I'm now getting the
error shown below with ANY package that I try to install.


installation of package ‘NBPSeq’ had non-zero exit status


This started happening ever since I tried to install a package that I
downloaded from a personal website (for some reason only worked on my
windows partition). I'm using Ubuntu.


Any thoughts?


Thanks,

Sachin

[[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] getting covariance ignoring NaN missing values

2013-03-07 Thread Sachinthaka Abeywardana
thanks, appreciate it


On Fri, Mar 8, 2013 at 2:49 PM, arun  wrote:

>
>
> Hi,
> If you look at ?cov(),
> there are options for 'use':
> set.seed(15)
> a=array(rnorm(9),dim=c(3,3))
>  a[3,2]<- NaN
>
>  cov(a,use="complete.obs")
> #   [,1][,2]   [,3]
> #[1,]  1.2360602 -0.32167789  0.8395953
> #[2,] -0.3216779  0.08371491 -0.2185001
> #[3,]  0.8395953 -0.21850006  0.5702960
>  cov(a,use="na.or.complete")
> #   [,1][,2]   [,3]
> #[1,]  1.2360602 -0.32167789  0.8395953
> #[2,] -0.3216779  0.08371491 -0.2185001
> #[3,]  0.8395953 -0.21850006  0.5702960
>  cov(a,use="pairwise.complete.obs")
> #   [,1][,2]   [,3]
> #[1,]  1.2570603 -0.32167789  0.7377472
> #[2,] -0.3216779  0.08371491 -0.2185001
> #[3,]  0.7377472 -0.21850006  0.4433438
> A.K.
>
>
>
>
> - Original Message -
> From: Sachinthaka Abeywardana 
> To: "r-help@r-project.org" 
> Cc:
> Sent: Thursday, March 7, 2013 10:36 PM
> Subject: [R] getting covariance ignoring NaN missing values
>
> Hi all,
>
> I have a matrix that has many NaN values. As soon as one of the columns has
> a missing (NaN) value the covariance estimation gets thrown off.
>
> Is there a robust way to do this?
>
> Thanks,
> Sachin
>
> a=array(rnorm(9),dim=c(3,3))> a[,1]   [,2]  [,3]
> [1,] -0.79418236  0.7813952  0.855881
> [2,] -1.65347906 -1.9462446 -0.376325
> [3,] -0.03144987  0.6756862 -1.879801> a[3,2]=NANError: object 'NAN'
> not found> a[3,2]=NaN> a[,1]   [,2]  [,3]
> [1,] -0.79418236  0.7813952  0.855881
> [2,] -1.65347906 -1.9462446 -0.376325
> [3,] -0.03144987NaN -1.879801> cov(a)   [,1] [,2]
>  [,3]
> [1,]  0.6585217   NA -0.5777408
> [2,] NA   NA NA
> [3,] -0.5777408   NA  1.8771214
>
> [[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] getting covariance ignoring NaN missing values

2013-03-07 Thread Sachinthaka Abeywardana
Hi all,

I have a matrix that has many NaN values. As soon as one of the columns has
a missing (NaN) value the covariance estimation gets thrown off.

Is there a robust way to do this?

Thanks,
Sachin

a=array(rnorm(9),dim=c(3,3))> a[,1]   [,2]  [,3]
[1,] -0.79418236  0.7813952  0.855881
[2,] -1.65347906 -1.9462446 -0.376325
[3,] -0.03144987  0.6756862 -1.879801> a[3,2]=NANError: object 'NAN'
not found> a[3,2]=NaN> a[,1]   [,2]  [,3]
[1,] -0.79418236  0.7813952  0.855881
[2,] -1.65347906 -1.9462446 -0.376325
[3,] -0.03144987NaN -1.879801> cov(a)   [,1] [,2]   [,3]
[1,]  0.6585217   NA -0.5777408
[2,] NA   NA NA
[3,] -0.5777408   NA  1.8771214

[[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 from Data Frame with conditions

2013-03-07 Thread Sachinthaka Abeywardana
yep, that did the trick.

Thanks,
Sachin


On Fri, Mar 8, 2013 at 1:24 PM, Jeff Newmiller wrote:

> Something along the lines of
>
> top100 <- A[match(B,A[,1]),]
>
> Please provide R code with sample data and desired output. See
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  Live
> Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
> ---
> Sent from my phone. Please excuse my brevity.
>
> Sachinthaka Abeywardana  wrote:
>
> >Hi all,
> >
> >I have two dataframes. The first (A) contains all the stock prices for
> >today including today. So the first column is the stock Symbol and the
> >second column is the stock price. The second (B) is the symbol list in
> >the
> >top 100 stocks.
> >
> >I want to pick out from dataframe A only the rows containing the
> >symbols
> >from B. i.e. something like:
> >
> >prices <- A[A[,1]==B,2]
> >
> >is there any way to do this without using a for loop, I have to do this
> >365
> >times (i.e. for one year).
> >
> >Thanks,
> >Sachin
> >
> >   [[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] Select rows from Data Frame with conditions

2013-03-07 Thread Sachinthaka Abeywardana
Hi all,

I have two dataframes. The first (A) contains all the stock prices for
today including today. So the first column is the stock Symbol and the
second column is the stock price. The second (B) is the symbol list in the
top 100 stocks.

I want to pick out from dataframe A only the rows containing the symbols
from B. i.e. something like:

prices <- A[A[,1]==B,2]

is there any way to do this without using a for loop, I have to do this 365
times (i.e. for one year).

Thanks,
Sachin

[[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] Grabbing Specific Words from Content (basic text mining)

2013-01-14 Thread Sachinthaka Abeywardana
Hi all,

Suppose I have a data frame with mixed content (name age and address).

a<-"Name: John Smith Age: 35 Address: 32, street, sub, something"
b<-data.frame(a)

1. The question is I want to extract the name age and
address separately from this data frame (containing potentially more
people).

2. Also just incase I have to deal with it how would the syntax change if I
had "Name" as opposed to "Name:" (without the colon).

Any thoughts are much appreciated.

Thanks,
Sachin

[[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] [twitteR-users] Not getting enough tweets in twitteR

2013-01-08 Thread Sachinthaka Abeywardana
Is there a way to limit the tweets by date so that I can do multiple calls
to get the required number of tweets? For example, something in the lines
of:

police<-userTimeline('@**nswpolice',n=1000,since="01/12/2012",
to="01/01/2013")  #first call
police<-userTimeline('@**nswpolice',n=1000,since="01/11/2012",
to="01/12/2012")  #second call




On Wed, Jan 9, 2013 at 11:29 AM, Jeff Gentry  wrote:

> On Wed, 9 Jan 2013, Sachinthaka Abeywardana wrote:
>
>> I am trying to download as many tweets as possible (say 1000). The
>> documentation states that the limit is 3200.
>> However when I run
>> police<-userTimeline('@**nswpolice',n=1000) it returns random amounts.
>> When I
>> ran it today I got 144, yesterday it was around 300.
>>
>
> The most likely explanation is that you're bumping into the API's
> limitation for time. The Twitter API typically will only give you results
> that go back for a few days, regardless of what you request.
>

[[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] Not getting enough tweets in twitteR

2013-01-08 Thread Sachinthaka Abeywardana
Hi all,

I am trying to download as many tweets as possible (say 1000). The
documentation states that the limit is 3200.

However when I run
police<-userTimeline('@nswpolice',n=1000) it returns random amounts. When I
ran it today I got 144, yesterday it was around 300.

Any thoughts?

Thanks,
Sachin

[[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] Get Cran R to use system proxy settings

2012-10-03 Thread Sachinthaka Abeywardana
Hi all,

I am using Ubuntu and I am having quite a bit of difficulty trying to
get R to use the system proxy settings. Any suggestions?

Thanks,
Sachin

__
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] twitteR location?

2012-08-14 Thread Sachinthaka Abeywardana
Did you mean the Vignette for twitteR? there is no FAQ section that I can
see and I could not get the following to work either:

a<-searchTwitter("sydney", n=100, geocode='-33.871841,151.206709, 1mi')


returns with a null list. Is there some sort of registration I need to
do for this to work? The above is the latitude longitude for Sydney
from google maps.


Thanks,

Sachin


On Wed, Aug 15, 2012 at 9:43 AM, Bhupendrasinh Thakre  wrote:

> Please read the FAQ file for twitteR.
> It mentions how to get both and as well as radius.
>
> Best Regards,
>
> Bhupendrasinh Thakre
> Sent from my iPhone
>
> On Aug 14, 2012, at 6:06 PM, Sachinthaka Abeywardana <
> sachin.abeyward...@gmail.com> wrote:
>
> > Hi all,
> >
> > Is it possible to get the latitude and longitude of the location of a
> > tweet? If I do
> >
> > tweets<- searchTwitter("#obama", n=200)  #get tweets
> > df <- twListToDF(tweets)  #converts to data frame
> > for ease of viewing
> >
> > it does not seem to be getting the location of where that tweet was
> posted.
> >> From what I read from the twitter API this is possible?
> >
> > Thanks,
> > Sachin
> >
> >[[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] twitteR location?

2012-08-14 Thread Sachinthaka Abeywardana
That worked but how do you get the location of one particular tweet. So
from that list of 10, say the first tweet, is there a way to say at exactly
what location it was tweeted?

Thanks,
Sachin

On Wed, Aug 15, 2012 at 2:36 PM, Bhupendrasinh Thakre  wrote:

> There is something wrong in your geo code. What was the source.
> Although some trial and error suggests that we should use lat and lang
> till 4 decimal only. Don't know why.
> I have changed the geo-code somewhat and it works.
>
> Changed Code :
>
> *searchTwitter('sydney', n=10,geocode='-33.8389,151.2101,1mi')*
>
>
> Bhupendrasinh Thakre
>
> Sent from my Mac
>
>
>
> On Aug 14, 2012, at 11:17 PM, Sachinthaka Abeywardana <
> sachin.abeyward...@gmail.com> wrote:
>
> what am I doing wrong here? Increased the radius to 10,000 miles and the
> dates are for the last two years. Surely this should get some tweets?
>
> a<-searchTwitter("sydney", n=100, geocode='-33.871841,151.206709, 1mi', 
> since="2010-01-01", until="2012-08-01")
>
>
> Thanks,
>
> Sachin
>
>
> On Wed, Aug 15, 2012 at 10:38 AM, Bhupendrasinh Thakre <
> vickytha...@gmail.com> wrote:
>
>> Very true, it does bring null list.
>> However while giving some other inputs like since, until, lang as Null
>> you will get desired result.
>>
>>
>>  Bhupendrasinh Thakre
>>
>>
>>
>>
>>
>> On Aug 14, 2012, at 7:04 PM, Sachinthaka Abeywardana <
>> sachin.abeyward...@gmail.com> wrote:
>>
>> a<-searchTwitter("sydney", n=100, geocode='-33.871841,151.206709, 1mi')
>>
>>
>>
>
>

[[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] twitteR location?

2012-08-14 Thread Sachinthaka Abeywardana
what am I doing wrong here? Increased the radius to 10,000 miles and the
dates are for the last two years. Surely this should get some tweets?

a<-searchTwitter("sydney", n=100, geocode='-33.871841,151.206709,
1mi', since="2010-01-01", until="2012-08-01")


Thanks,

Sachin


On Wed, Aug 15, 2012 at 10:38 AM, Bhupendrasinh Thakre <
vickytha...@gmail.com> wrote:

> Very true, it does bring null list.
> However while giving some other inputs like since, until, lang as Null you
> will get desired result.
>
>
> Bhupendrasinh Thakre
>
>
>
>
>
> On Aug 14, 2012, at 7:04 PM, Sachinthaka Abeywardana <
> sachin.abeyward...@gmail.com> wrote:
>
> a<-searchTwitter("sydney", n=100, geocode='-33.871841,151.206709, 1mi')
>
>
>

[[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] twitteR location?

2012-08-14 Thread Sachinthaka Abeywardana
Hi all,

Is it possible to get the latitude and longitude of the location of a
tweet? If I do

tweets<- searchTwitter("#obama", n=200)  #get tweets
df <- twListToDF(tweets)  #converts to data frame
for ease of viewing

it does not seem to be getting the location of where that tweet was posted.
>From what I read from the twitter API this is possible?

Thanks,
Sachin

[[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] anova in unbalanced data

2012-08-13 Thread Sachinthaka Abeywardana
Hi all,

Say I have the following data:

a<-data.frame(col1=c(rep("a",5),rep("b",7)),col2=runif(12))

a_aov<-aov(a$col2~a$col1)

summary(aov)


Note that there are 5 observations for a and 7 for b, thus is
unbalanced. What would be the correct way of doing anova for this set?


Thanks,

Sachin

[[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] pass by reference

2012-08-13 Thread Sachinthaka Abeywardana
Think you are missing the point, assigning the value back is the same as
passing by value. This is rather inefficient if you ever have to deal with
large datasets. You dont want to keep having a local copy within the scope
of the function and then copying over the original.

On Tue, Aug 14, 2012 at 11:25 AM, jim holtman  wrote:

> The assign the value back to the object:
>
> > data<-data.frame(col1=c(1,2,3,4,5))
> >
> > getcol2<-function(data){
> + data$col2[data$col1<=2]="L"
> + data  # return value
> + }
> >
> > data <- getcol2(data)  # save the return value
> > data
>   col1 col2
> 11L
> 2    2L
> 33 
> 44 
> 55 
> >
>
>
> On Mon, Aug 13, 2012 at 9:23 PM, Sachinthaka Abeywardana
>  wrote:
> > Hi Jim, R,
> >
> > What you just showed me simply prints out the 2nd column. If you inspect
> > your original data, it still just has 1 column. So its still passing by
> > value.
> >
> > Thanks,
> > Sachin
> >
> > On Tue, Aug 14, 2012 at 11:19 AM, jim holtman 
> wrote:
> >>
> >> You have to return the value of 'data' from the function.  Functions
> >> do not have "side effects".
> >>
> >> > data<-data.frame(col1=c(1,2,3,4,5))
> >> >
> >> > getcol2<-function(data){
> >> + data$col2[data$col1<=2]="L"
> >> + data  # return value
> >> + }
> >> >
> >> > getcol2(data)
> >>   col1 col2
> >> 11L
> >> 22L
> >> 33 
> >> 44 
> >> 55 
> >> >
> >>
> >>
> >> On Mon, Aug 13, 2012 at 9:08 PM, Sachinthaka Abeywardana
> >>  wrote:
> >> > Hi all,
> >> >
> >> > I want to do the following:
> >> >
> >> > data<-data.frame(col1=c(1,2,3,4,5))
> >> >
> >> > getcol2<-function(data){
> >> > data$col2[data$col1<=2]="L"
> >> > }
> >> >
> >> > getcol2(data)
> >> >
> >> > Unfortunately in the above col2 does not appear in the final data. So
> >> > how
> >> > would you pass this by reference such that you would get it back?
> >> >
> >> > Thanks,
> >> > Sachin
> >> >
> >> > [[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.
> >>
> >>
> >>
> >> --
> >> 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.
> >
> >
>
>
>
> --
> 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.
>

[[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] pass by reference

2012-08-13 Thread Sachinthaka Abeywardana
Hi Jim, R,

What you just showed me simply prints out the 2nd column. If you inspect
your original data, it still just has 1 column. So its still passing by
value.

Thanks,
Sachin

On Tue, Aug 14, 2012 at 11:19 AM, jim holtman  wrote:

> You have to return the value of 'data' from the function.  Functions
> do not have "side effects".
>
> > data<-data.frame(col1=c(1,2,3,4,5))
> >
> > getcol2<-function(data){
> + data$col2[data$col1<=2]="L"
> + data  # return value
> + }
> >
> > getcol2(data)
>   col1 col2
> 11L
> 22L
> 33 
> 44 
> 55 
> >
>
>
> On Mon, Aug 13, 2012 at 9:08 PM, Sachinthaka Abeywardana
>  wrote:
> > Hi all,
> >
> > I want to do the following:
> >
> > data<-data.frame(col1=c(1,2,3,4,5))
> >
> > getcol2<-function(data){
> > data$col2[data$col1<=2]="L"
> > }
> >
> > getcol2(data)
> >
> > Unfortunately in the above col2 does not appear in the final data. So how
> > would you pass this by reference such that you would get it back?
> >
> > Thanks,
> > Sachin
> >
> > [[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.
>
>
>
> --
> 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.
>

[[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] pass by reference

2012-08-13 Thread Sachinthaka Abeywardana
Hi all,

I want to do the following:

data<-data.frame(col1=c(1,2,3,4,5))

getcol2<-function(data){
data$col2[data$col1<=2]="L"
}

getcol2(data)

Unfortunately in the above col2 does not appear in the final data. So how
would you pass this by reference such that you would get it back?

Thanks,
Sachin

[[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] set working directory to current source directory

2012-08-13 Thread Sachinthaka Abeywardana
Hi all,

Is there a way to get cran R to set the working directory to be wherever
the source file is? Each time I work on a project on different computers I
keep having to set the working directory which is getting quite annoying.

Thanks,
Sachin

[[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] if else elseif for data frames

2012-08-12 Thread Sachinthaka Abeywardana
The thing is I have about 10 cases. I saw the ifelse statement but was
wondering if there was a cleaner method of doing it. The coding will get
really messy when I write all 10 cases.

Cheers,
Sachin

On Mon, Aug 13, 2012 at 11:04 AM, arun  wrote:

> Hi,
> Try this:
> dat1<-data.frame(col1=c(rep("high",3),rep("Neutral",3),rep("low",4)))
>
>  
> dat1$col2<-ifelse(dat1$col1=="high",dat1$col2<-"H",ifelse(dat1$col1=="Neutral",dat1$col2<-"N","L"))
> dat1
>   col1 col2
> 1 highH
> 2 highH
> 3 highH
> 4  NeutralN
> 5  NeutralN
> 6  NeutralN
> 7  low    L
> 8  lowL
> 9  lowL
> 10 lowL
>
> A.K.
>
>
>
>
> - Original Message -
> From: Sachinthaka Abeywardana 
> To: r-help@r-project.org
> Cc:
> Sent: Sunday, August 12, 2012 8:43 PM
> Subject: [R] if else elseif for data frames
>
> Hi all,
>
> It seems like I cannot use normal 'if' for data frames. What would be the
> best way to do the following.
>
> if data$col1='high'
> data$col2='H'
> else if data$col1='Neutral'
> data$col2='N'
> else if data$col='low'
>data$col2='L'
> else
>#chuch a warning?
>
>
> Note that col2 was not an existing column and was newly assigned for this
> task.
>
> Thanks,
> Sachin
>
> [[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] if else elseif for data frames

2012-08-12 Thread Sachinthaka Abeywardana
Hi all,

It seems like I cannot use normal 'if' for data frames. What would be the
best way to do the following.

if data$col1='high'
data$col2='H'
else if data$col1='Neutral'
data$col2='N'
else if data$col='low'
   data$col2='L'
else
   #chuch a warning?


Note that col2 was not an existing column and was newly assigned for this
task.

Thanks,
Sachin

[[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] choosing multiple columns

2012-08-11 Thread Sachinthaka Abeywardana
I should have mentioned that I do not know the number index of the columns,
but regardless, thanks for the responses

On Sat, Aug 11, 2012 at 10:46 PM, Ista Zahn  wrote:

> Hi Sachin,
>
> There are at least two ways. The safer way is to use a regular
> expression to find the matching columns, like this:
>
> a <- initial_data[grep("^OFB[0-9]+", names(initial_data))]
>
> Alternatively, if you know that the columns you want are the first 8
> you can select them by position, like this:
>
> a <- initial_data[1:8]
>
> Best,
> Ista
>
> On Sat, Aug 11, 2012 at 7:59 AM, Sachinthaka Abeywardana
>  wrote:
> > Hi all,
> >
> > I have a data frame that has the columns OFB1, OFB2, OFB3,... OFB10.
> >
> > How do I select the first 8 columns efficiently without typing each and
> > every one of them. i.e. I want something like:
> >
> > a<-data.frame(initial_data$OFB1-10) #i know this is wrong, what would be
> > the correct syntax?
> >
> > Thanks,
> > Sachin
> >
> > [[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] choosing multiple columns

2012-08-11 Thread Sachinthaka Abeywardana
Hi all,

I have a data frame that has the columns OFB1, OFB2, OFB3,... OFB10.

How do I select the first 8 columns efficiently without typing each and
every one of them. i.e. I want something like:

a<-data.frame(initial_data$OFB1-10) #i know this is wrong, what would be
the correct syntax?

Thanks,
Sachin

[[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] tm_map help

2012-02-26 Thread Sachinthaka Abeywardana
Hi all,

I am trying to do some text mining with twitter and I am getting the error:

Error in structure(names(sapply(possibleCompletions, "[", 1)), names = x) :
  'names' attribute [1] must be the same length as the vector [0]


When I use tm_map. Has anyone had/seen this error before? The code I
have is shown below and this error only occurs with #qantas, hashtags
like #asx, #obama work ok.


Appreciate any help.

Thanks,

Sachin


library(twitteR)
library(tm)
library(wordcloud)


hashTag<-function (hashTag, minFreq){

tweets<- searchTwitter(hashTag, n=200)
df <- do.call("rbind", lapply(tweets, as.data.frame))

myCorpus <- Corpus(VectorSource(df$text))
myCorpus <- tm_map(myCorpus, function(x) iconv(enc2utf8(x), sub = "byte"))
myCorpus <- tm_map(myCorpus, tolower)
myCorpus <- tm_map(myCorpus, removePunctuation)
myCorpus <- tm_map(myCorpus, removeNumbers)
myStopwords <- c(stopwords('english'), "available", "via")
myCorpus <- tm_map(myCorpus, removeWords, myStopwords)

dictCorpus <- myCorpus
myCorpus <- tm_map(myCorpus, stemDocument)

ERROR HAPPENS ON NEXT LINE##
myCorpus <- tm_map(myCorpus, stemCompletion, dictionary=dictCorpus)
myDtm <- TermDocumentMatrix(myCorpus, control = list(minWordLength = 1))

m <- as.matrix(myDtm)
v <- sort(rowSums(m), decreasing=TRUE)
myNames <- names(v)
d <- data.frame(word=myNames, freq=v)
wordcloud(d$word, d$freq, min.freq=minFreq)
list(freq=v, TextMatrix=myDtm)
}


qantas=hashTag("#qantas", 7)

[[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] Wavelet matrix

2012-01-24 Thread Sachinthaka Abeywardana
Hi all,

I am needing to create a wavelet Basis matrix such that f=Bw where f is the
signal, B the basis matrix and, w the weight matrix. I am not concerned
about w which I can easily obtain from most wavelet packages. Is there a
package/ function that can create the B matrix (supposing it is a Haar
wavelet for now, if it helps)? I have tried to look in WaveLab and Rice
Wavelet toolbox (in Matlab) without much luck.

If there is no package, it would be great if someone could point me in the
general direction.

Any help would be appreciated.

Thanks,
Sachin

[[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] Clustering and visualising a wordcloud

2012-01-23 Thread Sachinthaka Abeywardana
Is there a package (and for that matter a function) that I can use to
create clustered wordclouds. The current wordcloud package simply has more
frequent words as larger words, whereas what I want is the cluster centre
to be the more frequent words but, the closer a word is to another the
higher the co occurences.

For example in a document if the words {bus, drive, eat, pizza} appeared as
the most frequent word, you would expect {bus, drive} to be close to each
other, whereas {eat,pizza} to be away from the other cluster but close to
each other.

Thanks,
Sachin

[[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] Does wordcloud do clustering

2012-01-12 Thread Sachinthaka Abeywardana
Hi All,

If anyone is using wordcloud, do you know if it clusters word that are used
together. For example in a document if the words {bus, drive, eat, pizza}
appeared as the most frequent word, you would expect {bus, drive} to be
close to each other, whereas {eat,pizza} to be away from the other cluster
but close to each other.

Thanks,
Sachin

[[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] cannot get tweets from twitteR

2012-01-11 Thread Sachinthaka Abeywardana
Btw I tried this on the terminal in R and it worked, restarted Rstudio and
it still doesn't work there. Rstudio bug or something else?

Sachin

[[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] cannot get tweets from twitteR

2012-01-11 Thread Sachinthaka Abeywardana
Hi all,

I was following the tutorial in:
http://www.rdatamining.com/examples/text-mining and using the package
twitteR i attempted to execute userTimeline and got the error:

rdmTweets<-userTimeline("rdatamining",n=100)Error in .self$twFromJSON(out) :
  Error: Rate limit exceeded. Clients may not make more than 150
requests per hour.


Any suggestions as how to fix this? Note I did not try to do access
150 tweets or anything of the sort.


Thanks,

Sachin

[[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] best tools for developing in C

2011-12-20 Thread Sachinthaka Abeywardana
Hi all,

I want to write some C code that I will be able to call from R. The only
problem that I have is, I want to be able to say set breakpoints and do
some general debugging without having to do trial error with the code.

Currently I am using Rstudio, but to my knowledge this doesn't exactly let
you compile C code? Let me know what my options are.

Thanks,
Sachin

[[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] configuring a package for own personal needs

2011-12-06 Thread Sachinthaka Abeywardana
Hi Michael/ everyone,

I guess a big part of the question was also how would you compile (remember
that some of the code is written in C)? Any recommended tutorials on this?

Sachin

On Wed, Dec 7, 2011 at 11:16 AM, R. Michael Weylandt <
michael.weyla...@gmail.com> wrote:

> The easiest thing is probably to download source files from CRAN and
> edit the R code, which can be found in the R2Cuba_vvv/R/ directory
> (vvv is the version code), re-build and then you should be good
> permanently. I just looked at the source on my machine: very easily
> done, if you feel comfortable with the compiling which sounds like you
> are.
>
> Michael
>
> On Tue, Dec 6, 2011 at 6:39 PM, Sachinthaka Abeywardana
>  wrote:
> > Hi All,
> >
> > There is a function in package "R2Cuba" called Cuhre that I need to use.
> It
> > keeps spitting out a new-line which I really dont want it to do. So I was
> > wondering what is the best way of configuring the package. I tried
> copying
> > and pasting the code into Cuhre2 and getting rid of the newline command
> BUT
> > that didn't work since it seems to have some private functions which I do
> > not have access to.
> >
> > So what is the best way of rewriting the package and compiling it (some
> of
> > the code is written in C). Note that I want to do some other
> configurations
> > besides the above mentioned (incase you were going to mention some sort
> of
> > noprint option).
> >
> > Thanks,
> > Sachin
> >
> >[[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] configuring a package for own personal needs

2011-12-06 Thread Sachinthaka Abeywardana
Hi All,

There is a function in package "R2Cuba" called Cuhre that I need to use. It
keeps spitting out a new-line which I really dont want it to do. So I was
wondering what is the best way of configuring the package. I tried copying
and pasting the code into Cuhre2 and getting rid of the newline command BUT
that didn't work since it seems to have some private functions which I do
not have access to.

So what is the best way of rewriting the package and compiling it (some of
the code is written in C). Note that I want to do some other configurations
besides the above mentioned (incase you were going to mention some sort of
noprint option).

Thanks,
Sachin

[[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] R2Cuba package, failed with message ‘Dimension out of range’

2011-12-01 Thread Sachinthaka Abeywardana
Hi All,

I get the message failed with message ‘Dimension out of range’ when using
cuhre in package R2Cuba. Does anyone know what this mean? Or would I need
to email the package author?

The funny thing is it does give a result and comparing it to
"adaptIntegrate" in package cubature, the two numbers are very close.

Thanks,
Sachin

[[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] efficient way to fill up matrix (and evaluate function)

2011-11-27 Thread Sachinthaka Abeywardana
Hi Jim,

What exactly do you mean by vectorized. I think outer looks like what I was
looking for. BUT there was a (weighted) distance matrix calculation that I
was trying to vectorize, which wasnt related to this post. Could you proved
a bit more details as to what you were referring to, and maybe an example
as how to vectorize in R?

Thanks,
Sachin

On Mon, Nov 28, 2011 at 3:25 PM, jim holtman  wrote:

> Take a look at 'outer'  and vectorized your function.  Also look at
> 'expand.grid'.
>
>
> On Sunday, November 27, 2011, Sachinthaka Abeywardana <
> sachin.abeyward...@gmail.com> wrote:
> > Hi All,
> >
> > I want to do something along the lines of:
> > for (i in 1:n){
> >for (j in 1:n){
> >A[i,j]<-myfunc(x[i], x[j])
> >}
> > }
> >
> > The question is what would be the most efficient way of doing this. Would
> > using functions such as sapply be more efficient that using a for loop?
> >
> > Note that n can be a few thousand. Thus atleast a 1000x1000 matrix.
> >
> > Thanks,
> > Sachin
> >
> >[[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.
> >
>
> --
> 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.
>

[[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] efficient way to fill up matrix (and evaluate function)

2011-11-27 Thread Sachinthaka Abeywardana
Hi All,

I want to do something along the lines of:
for (i in 1:n){
for (j in 1:n){
A[i,j]<-myfunc(x[i], x[j])
}
}

The question is what would be the most efficient way of doing this. Would
using functions such as sapply be more efficient that using a for loop?

Note that n can be a few thousand. Thus atleast a 1000x1000 matrix.

Thanks,
Sachin

[[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] function manipulation for integration

2011-11-27 Thread Sachinthaka Abeywardana
Hi All,

I'm trying to use one of the (2D) numerical integration functions, which is
not where the problem is. The function definition is as follows:

adaptIntegrate(f, lowerLimit, upperLimit, ...)

The problem is that I want to integrate a 3D function which has been
parametrised such that it is a 2D function:
eg. I want to integrate f(x_start+gradient_x*t1, y_start+gradient_y*t2) for
t1 in [0,1] and t2 in [0,1].

To explain the example in another way I only have access to f, x_start,
y_start and the gradients. Note that I want to be able to change x_start,
y_start such that I can do different integrals.

Any thoughts?

Thanks,
Sachin

[[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] assigning multiple outputs

2011-11-18 Thread Sachinthaka Abeywardana
Hi All,

So I figured out how to do multiple outputs, but whats the best/
recommended way of assigning them.

f<-function{a=1; b=1; list(a,b)}

I want to be able to say assign into a and b straight away rather that
doing a=f()[[1]] and b=f()[[2]]. It would be best if I can get around this
without having to assigning this to a third dummy variable.

Thanks,
Sachin

[[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] calculating symmetric matrix

2011-11-17 Thread Sachinthaka Abeywardana
Hi All,

I need to a calculation W%*%d. However I know that this matrix is symmetric
(since W=t(d)%*%w). My question is considering that I only need to
calculate the lower/ upper triangle (n(n+1)/2 elements) rather than the n^2
elements of the entire matrix. Is there a way to do this efficiently.

My 'n' can be quite large (upto 10,000 or more?).

Thanks,
Sachin

[[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] calling self written R functions

2011-11-17 Thread Sachinthaka Abeywardana
Looks like the function I was looking for was source(), but thanks Joshua I
certainly do need to make a package once I finish this set of re-coding
into R from Matlab. Fingers crossed the effort is worth it.

Thanks,
Sachin

On Fri, Nov 18, 2011 at 1:34 PM, Sarah Goslee wrote:

> ?source
>
> source("/path/to/foo.R") will load it into R.
>
> Sarah
>
> On Thu, Nov 17, 2011 at 8:26 PM, Sachinthaka Abeywardana
>  wrote:
> > Hi All,
> >
> > I have written a function (say) called foo, saved in a file called
> > foo.R. Just going by Matlab syntax I usually just change my folder path
> and
> > therefore can call it at will.
> >
> > When it comes to R, how is the usual way of calling/loading it? because R
> > doesnt seem to automatically find the function from a folder (which might
> > be stupid to attempt in the first place).
> >
> > Thanks,
> > Sachin
> >
>
>
> --
> Sarah Goslee
> http://www.functionaldiversity.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] calling self written R functions

2011-11-17 Thread Sachinthaka Abeywardana
Hi All,

I have written a function (say) called foo, saved in a file called
foo.R. Just going by Matlab syntax I usually just change my folder path and
therefore can call it at will.

When it comes to R, how is the usual way of calling/loading it? because R
doesnt seem to automatically find the function from a folder (which might
be stupid to attempt in the first place).

Thanks,
Sachin

[[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] Vectorizing for weighted distance

2011-11-17 Thread Sachinthaka Abeywardana
Hi Michael,

Thanks for that. The X1 and X2 are vectors are typically 1000 by 3
matrices, and hoping to scale up to much larger dimensions (say 20,000 by
3).

I do appreciate your help and seems like this is the best way to do this, I
was just wondering if I could squeeze out just a bit more performance,
thats all.

Anyway thanks again, much appreciated.

Thanks,
Sachin

On Fri, Nov 18, 2011 at 9:15 AM, R. Michael Weylandt <
michael.weyla...@gmail.com> wrote:

> I fail to see why you would need another idea: you asked how to
> multiply matrices efficiently, I told you how to multiply matrices
> efficiently.
>
> if you want to calculate X1-X2 times W times X1-X2, then simply do so:
>
> X1 <- matrix(1:6, 3)
> X2 <- matrix(7:12, 3)
> W = matrix(runif(9), 3)
>
> t(X1-X2) %*% W %*% (X1-X2)
>
> which gives
>
> 142.7789 142.7789
> 142.7789 142.7789
>
> You could squeeze out one iota more of speed with
>
> crossprod(X1-X2, W) %*% (X1-X2)
>
> to get the same result, but unless you are doing massive scale linear
> processing, I'm not sure it's worth the loss of clarity.
>
> I was only giving you a heads up on the sometimes confusing difference
> between matrix multiplication in MATLAB and in R by which a vector is
> not a 1d matrix and so does not require explicit transposition.
>
> Michael
>
>
> On Thu, Nov 17, 2011 at 4:35 PM, Sachinthaka Abeywardana
>  wrote:
> > I'm not quite sure of what you mean by not worry if it's 1d R matrices.
> X1
> > and X2 are both n by d matrices and W is d by d.
> >
> > Thanks for the help though. Any other ideas?
> >
> > Thanks
> > Sachin
> >
> > On Friday, November 18, 2011, R. Michael Weylandt
> >  wrote:
> >> The fastest is probably to just implement the matrix calculation
> >> directly in R with the %*% operator.
> >>
> >> (X1-X2) %*% W %*% (X1-X2)
> >>
> >> You don't need to worry about the transposing if you are passing R
> >> vectors X1,X2. If they are 1-d matrices, you might need to.
> >>
> >> Michael
> >>
> >> On Thu, Nov 17, 2011 at 1:30 AM, Sachinthaka Abeywardana
> >>  wrote:
> >>> Hi All,
> >>>
> >>> I am trying to convert the following piece of matlab code to R:
> >>>
> >>> XX1 = sum(w(:,ones(1,N1)).*X1.*X1,1);  #square the elements of
> >>> X1,
> >>> weight it and repeat this vector N1 times
> >>> XX2 = sum(w(:,ones(1,N2)).*X2.*X2,1);  #square the elements of
> >>> X2,
> >>> weigh and repeat this vector N2 times
> >>> X1X2 = (w(:,ones(1,N1)).*X1)'*X2; #get the weighted
> >>> 'covariance' term
> >>> XX1T = XX1';  #transpose
> >>> z = XX1T(:,ones(1,N2)) + XX2(ones(1,N1),:) - 2*X1X2;#get
> the
> >>> squared weighted distance
> >>>
> >>> which is basically doing: z=(X1-X2)' W (X1-X2)
> >>>
> >>> What would the best way (for SPEED) to do this? or is vectorizing as
> >>> above
> >>> the best? Any hints, suggestions?
> >>>
> >>> Thanks,
> >>> Sachin
> >>>
> >>>[[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] Vectorizing for weighted distance

2011-11-17 Thread Sachinthaka Abeywardana
I'm not quite sure of what you mean by not worry if it's 1d R matrices. X1
and X2 are both n by d matrices and W is d by d.

Thanks for the help though. Any other ideas?

Thanks
Sachin

On Friday, November 18, 2011, R. Michael Weylandt <
michael.weyla...@gmail.com> wrote:
> The fastest is probably to just implement the matrix calculation
> directly in R with the %*% operator.
>
> (X1-X2) %*% W %*% (X1-X2)
>
> You don't need to worry about the transposing if you are passing R
> vectors X1,X2. If they are 1-d matrices, you might need to.
>
> Michael
>
> On Thu, Nov 17, 2011 at 1:30 AM, Sachinthaka Abeywardana
>  wrote:
>> Hi All,
>>
>> I am trying to convert the following piece of matlab code to R:
>>
>> XX1 = sum(w(:,ones(1,N1)).*X1.*X1,1);  #square the elements of
X1,
>> weight it and repeat this vector N1 times
>> XX2 = sum(w(:,ones(1,N2)).*X2.*X2,1);  #square the elements of
X2,
>> weigh and repeat this vector N2 times
>> X1X2 = (w(:,ones(1,N1)).*X1)'*X2; #get the weighted
>> 'covariance' term
>> XX1T = XX1';  #transpose
>> z = XX1T(:,ones(1,N2)) + XX2(ones(1,N1),:) - 2*X1X2;#get the
>> squared weighted distance
>>
>> which is basically doing: z=(X1-X2)' W (X1-X2)
>>
>> What would the best way (for SPEED) to do this? or is vectorizing as
above
>> the best? Any hints, suggestions?
>>
>> Thanks,
>> Sachin
>>
>>[[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] Vectorizing for weighted distance

2011-11-16 Thread Sachinthaka Abeywardana
Hi All,

I am trying to convert the following piece of matlab code to R:

XX1 = sum(w(:,ones(1,N1)).*X1.*X1,1);  #square the elements of X1,
weight it and repeat this vector N1 times
XX2 = sum(w(:,ones(1,N2)).*X2.*X2,1);  #square the elements of X2,
weigh and repeat this vector N2 times
X1X2 = (w(:,ones(1,N1)).*X1)'*X2; #get the weighted
'covariance' term
XX1T = XX1';  #transpose
z = XX1T(:,ones(1,N2)) + XX2(ones(1,N1),:) - 2*X1X2;#get the
squared weighted distance

which is basically doing: z=(X1-X2)' W (X1-X2)

What would the best way (for SPEED) to do this? or is vectorizing as above
the best? Any hints, suggestions?

Thanks,
Sachin

[[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] getting R to download data

2010-12-07 Thread sachinthaka . abeywardana

Hi All,

Is it possible to write a program such that it downloads a csv from a given
web address? Would be great if this could be done at a particular time
during the day as well. Say 9AM monday-friday.

Incase you are curious Im just trying to analyse some stocks data.

Thanks,
Sachin
p.s. sorry about corporate notice

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz ...{{dropped:3}}

__
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] Pass an operator to function

2010-11-30 Thread sachinthaka . abeywardana
If you only want to deal with the less than or greater than operation a
cheap trick would be:

test <- function(a, b, sign) {
  foo <- (a*sign > b*sign);
  return(foo);
}

might have to tweak the syntax.

The idea behind this is that
5>3: TRUE
-5>-3: FALSE (i.e. I've multiplied both sides by sign(-1))

Hope this helps,
Sachin
p.s. sorry about corporate notice.

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz ...{{dropped:3}}

__
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 "bin"/average" time points?

2010-11-25 Thread sachinthaka . abeywardana
It would be something like this (might have to change the syntax a bit)

bin_ave=0;
while (i 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] cannot see the y-labels (getting cut-off)

2010-11-14 Thread sachinthaka . abeywardana

Hi All,

When I run the following code, I cannot see the entire number. As opposed
to seeing 1,000,000,000. I only see 000,000 because the rest is cut off.

The cex option doesn't seem to be doing anything at all.

y<-seq(1e09,5e09,1e09);
plot(1:5,y,ylab='',yaxt='n' );
axis(2, at=y, labels=formatC(y,big.mark=",",format="fg"),las=2,cex=0.1);

Any thoughts?

Thanks,
Sachin
p.s. sorry about corporate notice.

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz ...{{dropped:3}}

__
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] switching only axis off in plot

2010-11-11 Thread sachinthaka . abeywardana

Hi R,

In the following code my x-axis is formatted in month format. Which Im
happy with. The y-axis is what I want to re-format with something else. My
question is, is it possible just to switch off the xaxis in plot function
(see below). If not how do you get the months to show up as FEB-,
MAR- and so on, so I could fit a label on x-axis.

Thanks,
Sachin
p.s. sorry about corporate notice.

period<-c(100120,100220,100320);
y<-1:3;
period<-as.Date(strptime(period,("%y%m%d")));

#the x-axis has a nice format with the month names
win.graph();
plot(period,y);

#I dont want to lose this x-axis formatting :-(
win.graph();
plot(period,y, axes=FALSE, ann=FALSE);
axis(2, at=1:3, labels=c("A","B","C"));

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] font family in R

2010-11-11 Thread sachinthaka . abeywardana

Hi All,

I've been looking around (maybe not extensively) but I couldn't find any
documentation on the list of fonts thats useable with R.

Im trying to change the font of the title, seems like mtext is the only way
so far, which can actually write on top of each other depending on the
lines:

plot(1:5,1:5);
mtext("Title",side=3,cex=3.5,line=1);
mtext("Sub Title",side=3,cex=2.1,line=0);

Ofcourse I wont be using titles that big but would be great if R handled
that on its own rather than me having to worry about maximum height of
tables.

Also are there any packages out there that is better than the base R
graphics (mind you I do like it).

Thanks,
Sachin
p.s. sorry about corporate notice.

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] Troubleshooting sweave

2010-11-11 Thread sachinthaka . abeywardana
seems like the texi2dvi doesnt exist on R2.12.0 anymore?

Sachin
p.s. sorry about corporate notice

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] Troubleshooting sweave

2010-11-11 Thread sachinthaka . abeywardana

Hi All,

I've reproduced the example from Prof. Friedrich Leisch's webpage. When I
write sweave("Example-1.Snw") OR sweave("Example-1.Rnw"), (yes, I renamed
them). I get the following error:

Writing to file example-1.tex
Processing code chunks ...
 1 : echo term verbatim

Error:  chunk 1
Error in library(ctest) : there is no package called 'ctest'

Also while I'm at it, is there an R command to compile the tex file as a
pdf or does the Sweave() function do that for me?

Thanks,
Sachin
p.s. sorry about the corporate notice.

example-1.Rnw: from http://www.statistik.lmu.de/~leisch/Sweave/

\documentclass[a4paper]{article}

\title{Sweave Example 1}
\author{Friedrich Leisch}

\begin{document}

\maketitle

In this example we embed parts of the examples from the
\texttt{kruskal.test} help page into a \LaTeX{} document:

<<>>=
data(airquality)
library(ctest)
kruskal.test(Ozone ~ Month, data = airquality)
@
which shows that the location parameter of the Ozone
distribution varies significantly from month to month. Finally we
include a boxplot of the data:

\begin{center}
<>=
boxplot(Ozone ~ Month, data = airquality)
@
\end{center}

\end{document}

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] comma separated format

2010-11-11 Thread sachinthaka . abeywardana

Hi All,

I'm trying to create labels to plot such that it doesn't show up as
scientific notation. So for example how do I get R to show 1e06 as
$1,000,000.

I was wondering if there was a single function which allows you to do that,
the same way that as.Date() allows you to show in date format on a plot.

Thanks,
Sachin

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] plot options including formatting axes

2010-11-10 Thread sachinthaka . abeywardana

Hi All,

Currently my plot shows the y-axis in scientific notation (1e07 and so on).
I want to be able to display this in dollars such that it shows $10,000,000
(including the commas). How do I do this.

Also with the xlabel and ylabel. I've specified: 'title('Cash vs
Time',xlab='Period',ylab=''); Im hoping that this will also not display
anything on the y-axis. Instead it is actually overwriting the default
x-label and the default y-label remains the same.

Is there something I was supposed to do. I thought by specifying the 'xlab'
option in title it gets rid of the default one.

Thanks,
Sachin

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] trouble with plotting data- possible bug?

2010-11-10 Thread sachinthaka . abeywardana
whoops, sorry for the trouble everyone, managed to solve it. I didnt set
the ylim range so ofcourse it couldn't "see" where the other plots were
going to be.

Thanks
Sachin
p.s. sorry about the corporate notice

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] trouble with plotting data- possible bug?

2010-11-10 Thread sachinthaka . abeywardana

Hi all,

When I write out some values and then use 'plot' and 'lines' respectively I
can get R to plot me two lines. However when I get the data from a csv file
and run it I only manage to get one line running (whichever was invoked
first). The sample files are attached below and I've reproduced the code
below with the suspicious part marked as #??? (not even sure if thats
actually whats wrong).

Thanks in advance.
Sachin

A<-read.csv("small_table.csv", stringsAsFactors = FALSE);
A$period[nchar(A$period)==5]<-paste("0",A$period[nchar(A
$period)==5],sep="");
A$period<-as.Date(strptime(A$period,("%y%m%d")));

#get all unique names
name<-unique(A$LEVEL);

#create a table for each manager for discount_count_percentage
level=6;
month<-as.numeric(A$Month[A$LEVEL==name[level]]);
month3<-as.numeric(A$Month3[A$LEVEL==name[level]]);

period<-A$period[A$LEVEL==name[level]];
#???why is this part going wrong?
plot(period, month, type='l');
lines(period, month3, col=2);

p.s. sorry about corporate notice

 (See attached file: small_table.csv)(See attached file: test.R)
--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header. 
__
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] arrays of arrays

2010-11-09 Thread sachinthaka . abeywardana
Hi Michael,

Thanks for that. Its a starting point I guess. But what if I didn't know
the length of the outer vector is? (i.e. all dimensions are variable). Or
for that matter I don't actually know what the initial dimensions are going
to be. All of it is created within a for loop.

I was hoping for something like a C++ vector, where you can specify
vector> myarray. I'm sure lists is definitely the way to go,
but not sure how to implement it.

Cheers,
Sachin

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] concatenating a string to a column

2010-11-09 Thread sachinthaka . abeywardana

Hi All,

Suppose I want to concatenate a zero to all the values to a column called
period in data frame A. I want to do the following but the following
command actually deletes the entire column altogether.

 A$period<-cat(A$period,"0",sep="");

Any help would be appreciated.

Thanks,
Sachin
p.s. sorry about the corporate notice.

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] arrays of arrays

2010-11-09 Thread sachinthaka . abeywardana
Hi Erik,

Thanks for replying. Only problem with that is that each row has 5 elements
(or 5 columns). I want varying number of columns as shown in my example.

x<-  0   0   1   1
 1   3   5
 4
 7   -1  8   9  
 10  6

Regards,
Sachin
p.s. sorry about corporate notice.

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] arrays of arrays

2010-11-09 Thread sachinthaka . abeywardana

Hi All,

I want to have an array/ matrix that looks this

x<- 0   0   1   1
1   3   5
4   4
7   -1  8   9   10  6

I hope this makes sense. So basically if I want x[1,3] it will access 0 and
similarly x[4,2], -1.

Thanks in advance,
Sachin
p.s. sorry about the corporate notice.

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] date conversion and plot

2010-11-08 Thread sachinthaka . abeywardana

Hi All,

I have a date in the format of yymmdd (without any of the backslashes, eg.
100731). How do I convert this into a Rdate and plot it? I don't want the
number of days from 1970's showing up as my date (Its the date I require).

Thanks,
Sachin
p.s. sorry about the corporate notice I can't remove it.

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] parallel for loop

2010-10-31 Thread sachinthaka . abeywardana

Hi all,

Just following on from a previous thread (for loop). Is there a parallel
'for' loop like matlab (parfor maybe?). I know there was a Nvidia GPU
version for blas somewhere. But is there a CPU or a GPU version of the for
loop?

Thanks,
Sachin
p.s. sorry about the corporate notice below: cant get rid of it. Don't have
other mail client access at the office :(

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] cube root of a negative number

2010-10-26 Thread sachinthaka . abeywardana
hmm interesting. When I did -4^(1/3) got the correct answer, but then again
that's because it processes the negative later. i.e. -4^(1/2) gave me -2
instead of the 2i I expected. Also when I did (-4+0i)^(1/3) it gave me
0.793701+1.37473i. Possible bug?

Sachin

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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 simulate from an estimated density

2010-10-24 Thread sachinthaka . abeywardana
You usually simulate a distribution by:
1. building the cumulative distribution (use cumsum).
2. Simulating a random number (from uniform distribution, use runif
(number_of_simulations_needed)).
3. Get the closest number to the number simulated from the cumulative
distribution.
4. The corresponding value is your distribution.

As to comparing them look up a Q-Q plot.

hope this helps (or what you asked for),
Sachin
p.s. I'm sorry if this has an corporate disclaimer attached (don't know how
to get rid of it).

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] loading workspace- getting annoying

2010-10-20 Thread sachinthaka . abeywardana

I stupidly decided to save my last workspace (a large dataset) and every
time I open R it loads it back in. Can I stop this? Also how do you clear
variables.

Thanks,
Sachin

--- Please consider the environment before printing this email ---

Allianz - General Insurance Company of the Year 2009+
+ Australia and New Zealand Insurance Industry Awards

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] Accessing table elements and escape characters

2010-10-19 Thread sachinthaka . abeywardana

Hi All,

Are there any escape characters that I should be aware of when using
table.read? I don't have any '#' characters in this table.
I get the error:
 A<-read.table("P:/temp.csv",header=TRUE, sep=",");
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
na.strings,  :
  line 11018 did not have 85 elements

but when i open it in excel everything is fine.

If I use the fill=TRUE parameter I don't get the error BUT I do end up with
weird (and wrong) stuff when I try to access SOME elements.
eg.
A[2,"ACT_PREFIX"]
[1]
Levels:  C

should have been "T"... does this have anything to do with the fact that
the separator is a comma, and new line is not included in sep?

thanks in advance,
Sachin

--- Please consider the environment before printing this email ---

Allianz - General Insurance Company of the Year 2009+
+ Australia and New Zealand Insurance Industry Awards

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] drilling down data on charts

2010-10-13 Thread sachinthaka . abeywardana
Just to clarify I meant opening it in a new window (and perhaps closing old
frame?).

Thanks again,
Sachin



   
 Sachinthaka   
 Abeywardana/HO/Al 
 lianz-AU   To 
   r-help@r-project.org
 14/10/2010 10:00   cc 
 AM
   Subject 
   drilling down data on charts
  Please consider  
 the environment   
 before printing   
 this email
   
   
   



Hey all,

Suppose a=b^2 for starters. I want to be able to create a graph that
displays a initially and if i was to click on 'a' to show 'b' on the chart
itself. Does anyone know if this is possible in R?

Also as an extension (not necessary as yet) to output the above into a
'html' file.

Thanks,
Sachin

--- Please consider the environment before printing this email ---

Allianz - General Insurance Company of the Year 2009+
+ Australia and New Zealand Insurance Industry Awards

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] drilling down data on charts

2010-10-13 Thread sachinthaka . abeywardana

Hey all,

Suppose a=b^2 for starters. I want to be able to create a graph that
displays a initially and if i was to click on 'a' to show 'b' on the chart
itself. Does anyone know if this is possible in R?

Also as an extension (not necessary as yet) to output the above into a
'html' file.

Thanks,
Sachin

--- Please consider the environment before printing this email ---

Allianz - General Insurance Company of the Year 2009+
+ Australia and New Zealand Insurance Industry Awards

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
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] Running R on a server

2010-10-07 Thread sachinthaka . abeywardana

Hi All,

I am trying to run R scripts on a server rather than my own machine. The
biggest reason being that the data can be 3GB+; more than my RAM can
handle. Anyway is there a way to do this.

I am trying to find a SAS alternative.

In SAS you can do (keyword) rsubmit; and get things running remotely on a
server. Is there something similar on R. Couldn't find a comprehensive
answer online.

Thanks in advance,
Sachin

--- Please consider the environment before printing this email ---

Allianz - General Insurance Company of the Year 2009+
+ Australia and New Zealand Insurance Industry Awards

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

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