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
", "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",
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.298
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/ hmi
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 p
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=
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
ex
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
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
##
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 opti
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 ve
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.eth
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] [,
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
[[alterna
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-
.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
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 webs
> #[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
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
Live: OO#.. Dead: OO#.. Playing
> Research Engineer (Solar/BatteriesO.O#. #.O#. with
> /Software/Embedded Controllers) .OO#. .OO#. rocks...1k
> ---
> Sent from my
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 contai
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
Timeline('@**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 10
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,
Sachi
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 p
> 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
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
1")
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.
>
>
> Bhupen
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 tha
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
<- 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 j
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,
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,
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]]
_
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 Abey
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 existin
olumns, 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
&g
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
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
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 Haa
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 th
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 c
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
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
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 le
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
> &g
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 c
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 numbe
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 <
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
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
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 h
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.
rce
>
> 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 b
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 fun
ou 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:
&
> 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
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 t
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
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(-
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.
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
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-,
M
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:
plo
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 Ba
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
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
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='');
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 Gen
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 t
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 fo
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.
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
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 ad
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 rem
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
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 b
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
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+
+
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 d
Just to clarify I meant opening it in a new window (and perhaps closing old
frame?).
Thanks again,
Sachin
Sachinthaka
Abeywardana/HO/Al
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,
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 remo
83 matches
Mail list logo