[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

[R] Not able to convert data.frame to numeric properly

2014-04-09 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

Re: [R] Not able to convert data.frame to numeric properly

2014-04-09 Thread Sachinthaka Abeywardana
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

[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

[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]);

[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

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

[R] functions with function inputs and optimisation

2013-05-10 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

[R] Divide matrix columns by different numbers

2013-05-02 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

[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

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

[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

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

Re: [R] installation of package had non-zero exit status

2013-03-20 Thread Sachinthaka Abeywardana
) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Sachinthaka Abeywardana sachin.abeyward...@gmail.com wrote: Hi all, I am trying to install this NBPSeq package, but I'm

[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

Re: [R] Select rows from Data Frame with conditions

2013-03-07 Thread Sachinthaka Abeywardana
my brevity. Sachinthaka Abeywardana sachin.abeyward...@gmail.com 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

[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

Re: [R] getting covariance ignoring NaN missing values

2013-03-07 Thread Sachinthaka Abeywardana
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 sachin.abeyward...@gmail.com

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

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

Re: [R] [twitteR-users] Not getting enough tweets in twitteR

2013-01-08 Thread Sachinthaka Abeywardana
/2012, to=01/12/2012) #second call On Wed, Jan 9, 2013 at 11:29 AM, Jeff Gentry gen...@hexdump.org 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

[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

Re: [R] twitteR location?

2012-08-15 Thread Sachinthaka Abeywardana
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

[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

Re: [R] twitteR location?

2012-08-14 Thread Sachinthaka Abeywardana
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

Re: [R] twitteR location?

2012-08-14 Thread Sachinthaka Abeywardana
')* 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

[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] 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,

Re: [R] pass by reference

2012-08-13 Thread Sachinthaka Abeywardana
at 9:08 PM, Sachinthaka Abeywardana sachin.abeyward...@gmail.com 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

Re: [R] pass by reference

2012-08-13 Thread Sachinthaka Abeywardana
1L 22L 33 NA 44 NA 55 NA On Mon, Aug 13, 2012 at 9:23 PM, Sachinthaka Abeywardana sachin.abeyward...@gmail.com 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

[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

[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

Re: [R] if else elseif for data frames

2012-08-12 Thread Sachinthaka Abeywardana
L 9 lowL 10 lowL A.K. - Original Message - From: Sachinthaka Abeywardana sachin.abeyward...@gmail.com 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

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

Re: [R] choosing multiple columns

2012-08-11 Thread Sachinthaka Abeywardana
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

[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

[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

[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

[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

[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

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

[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

[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

Re: [R] configuring a package for own personal needs

2011-12-06 Thread Sachinthaka Abeywardana
which sounds like you are. Michael On Tue, Dec 6, 2011 at 6:39 PM, Sachinthaka Abeywardana sachin.abeyward...@gmail.com 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

[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

[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

[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

Re: [R] efficient way to fill up matrix (and evaluate function)

2011-11-27 Thread Sachinthaka Abeywardana
an example as how to vectorize in R? Thanks, Sachin On Mon, Nov 28, 2011 at 3:25 PM, jim holtman jholt...@gmail.com 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

[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

Re: [R] Vectorizing for weighted distance

2011-11-17 Thread Sachinthaka Abeywardana
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

Re: [R] Vectorizing for weighted distance

2011-11-17 Thread Sachinthaka Abeywardana
is not a 1d matrix and so does not require explicit transposition. Michael On Thu, Nov 17, 2011 at 4:35 PM, Sachinthaka Abeywardana sachin.abeyward...@gmail.com 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

[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

Re: [R] calling self written R functions

2011-11-17 Thread Sachinthaka Abeywardana
: ?source source(/path/to/foo.R) will load it into R. Sarah On Thu, Nov 17, 2011 at 8:26 PM, Sachinthaka Abeywardana sachin.abeyward...@gmail.com 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

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

[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

[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

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 53: TRUE -5-3: FALSE (i.e. I've multiplied both sides by sign(-1))

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 lenth(time)){ bin_ave[k]=mean(time(i:i+6)); k=k+1; i=i+6; } if your data is in a table format replace time with mytable$time. hope this helps, Sachin p.s. sorry about corporate

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

[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

[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

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

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

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

[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

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

[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

[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

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

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

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

[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

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

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

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

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

[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

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

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

[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