search for: sachinthaka

Displaying 20 results from an estimated 48 matches for "sachinthaka".

Did you mean: chinthaka
2012 Aug 14
4
pass by reference
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]]
2013 Jun 26
3
match rows of R
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,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 ################################# which(m==c(2,5,8)) # I want this to return 2 ###################### Thanks, Sachin [[alternative HTML version deleted]]
2013 Sep 13
2
xtable use plus minus
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
2012 Aug 13
4
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
2013 May 02
3
Divide matrix columns by different numbers
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,] 1 2 [2,]
2013 Apr 18
3
Using different function (parameters) with apply
Hi All, I have the following problem (read the commented bit below): a<-matrix(1:9,nrow=3) a [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 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.0 7 [2,] 1 2.5 4 [3,] 1 2.0 3
2013 Jan 14
4
Grabbing Specific Words from Content (basic text mining)
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
2013 Mar 08
2
Select rows from Data Frame with conditions
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
2012 Aug 14
3
set working directory to current source directory
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]]
2011 Nov 18
2
calling self written R functions
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
2011 Nov 28
2
efficient way to fill up matrix (and evaluate function)
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
2011 Dec 06
2
configuring a package for own personal needs
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
2012 Aug 11
3
choosing multiple columns
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]]
2010 Nov 10
5
arrays of arrays
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*
2010 Nov 11
4
Troubleshooting sweave
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
2010 Oct 13
2
drilling down data on charts
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 ---
2010 Nov 11
2
comma separated format
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 ---
2010 Nov 12
2
switching only axis off in plot
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-YYYY, MAR-YYYY and so on, so I could fit a label on x-axis. Thanks, Sachin p.s. sorry about corporate
2010 Oct 08
3
Running R on a server
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.
2010 Dec 07
1
getting R to download data
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 -