I am trying to replace a for loop by using sapply, The code is for forecasting
using arima. The code is as follows:-
---
far-function(p)
{
cat(does it come here value of p, p)
tryCatch({
air.model -Arima(tsa,order=c(i-1,j-1,k-1),
I have a data frame of data I want to map. I've already created a base map
called 'England'. The data frame is as follows:
'data.frame': 2303 obs. of 13 variables:
$ Response.ID: int 1 2 3 4 5 6 7 8 9 10 ...
$ Year : int 2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 ...
$ Sex
Your error references a column that is not mentioned in your sample line of
code. . suggesting that something else is going on.
The usual advice applies, as the footer always says:
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal,
Amit,
Your question isn't necessarily complete. You haven't provided a
reproducible example of your data or an error message. At first glance you
aren't passing anything to your 'far' function except for 'p' and yet it
uses i,j,k,l,m,n,testsize1, and act1. You should generally try to avoid
Hi David,
thanks a lot for the response. I see that this works. I am not sure, however,
what the appropriate way to do this is. It also works if you do not define
weights in the boot() function (weighted bootstrap) but rather in the vw_m_diff
function (ordinary bootstrap), i.e.,
vw_m_diff -
Charles ,
I am not getting an error . The final array A does not have the values in it.
Here is the reproducible code. I have even tried using paasing ervalue as a
parameter to the function far.
Hi,
I have this:
y = matrix(cbind(c(0, 0.5, 1),c(0, 0.5, 1)),ncol=2)
z = matrix(c(12, -6),ncol=2)
In matlab I would do this
y .* x
I would get this in matlab
ans
0-0
6-3
12 -6
What is the equivalent in R?
Thanks
[[alternative HTML version deleted]]
If I pass all the variables to the function in the following way then I get the
following error Error in cat(Value of error, ervalue[i, j, k, l, m, n, p]) :
argument ervalue is missing, with no default. Finally the A array should
have all the root mean square value calculated for each run
Thank you Chel Hee.
Isn't there a simpler way to do so?
On Wed, Nov 19, 2014 at 3:35 PM, Chel Hee Lee chl...@mail.usask.ca wrote:
y = matrix(cbind(c(0, 0.5, 1),c(0, 0.5, 1)),ncol=2)
z = matrix(c(12, -6),ncol=2)
t(apply(y, 1, function(x) x*z))
[,1] [,2]
[1,]00
[2,]6 -3
On 19-11-2014, at 15:22, Ruima E. ruimax...@gmail.com wrote:
Hi,
I have this:
y = matrix(cbind(c(0, 0.5, 1),c(0, 0.5, 1)),ncol=2)
z = matrix(c(12, -6),ncol=2)
In matlab I would do this
y .* x
I would get this in matlab
ans
0-0
6-3
12 -6
What is the equivalent
On Tue, Nov 18, 2014 at 9:42 PM, Upananda Pani upananda.p...@gmail.com wrote:
Dear All,
I want to read the my time series data using XTS package and then to
calculate return using PeformanceAnalytics Package but i am getting the
following error. Please help me to solve the problem. The error
Zilefac,
I tried to run your reproducible code, but you didn't provide an object
xy.
Jean
On Tue, Nov 18, 2014 at 10:20 AM, Zilefac Elvis zilefacel...@yahoo.com
wrote:
Hi,
I am trying to convert lat/lon to UTM but my results are extremely flawed.
Is it because of wrong UTM zone or my lon
On Wed, Nov 19, 2014 at 9:50 AM, Berend Hasselman b...@xs4all.nl wrote:
On 19-11-2014, at 15:22, Ruima E. ruimax...@gmail.com wrote:
Hi,
I have this:
y = matrix(cbind(c(0, 0.5, 1),c(0, 0.5, 1)),ncol=2)
z = matrix(c(12, -6),ncol=2)
In matlab I would do this
y .* x
I would get this in
Hi Admas,Sorry I missed out the reproducible example.Here it is:
dput(xy)structure(list(ID = 1:120, X = c(-102.6, -101.9, -97.1, -97, -95.7,
-99.1, -100.1, -97.2, -97, -99.3, -96, -95.2, -98.8, -98.1, -99.6, -97.8,
-96.1, -98.3, -95.6, -96.8, -101.2, -101.1, -97.2, -111.1, -111.2, -116,
-117.6,
Amit,
Even if you aren't getting an error with your original global variables it
is far better practice to avoid global variables to make you code much more
stable. Of course you ultimately get to decide how your code is written.
That said, your error from the modified far function to include
When your matrices are the same size, the * operator does what you want. The
problem is that you have to make a conforming version of z before you can use
that operator.
y*matrix(rep(z,3),ncol=2,byrow=TRUE)
or
y*matrix(rep(z,each=3),ncol=2)
To interpret this, just keep in mind that matrices
Charles,
Some variables were missing in the code. I have put them in this code. Now what
happens is the value of cat(Value of error, ervalue[i,j,k,l,m,n,p]) gives
error value for various runs but they are not in the final Array A. You will
have to go through the runs carefully. The array
Dear all;I want to do N.network for pH and predict its future.but when I run
the code and plot them (the measured data and the predicted), the predicted
data in all station are same.i do not know what is wrong with this. Here are
the codes that I used:fit - neuralnet(pH ~ station.2 + Day,data
Another (simpler) way that I can think is that
y * matrix(rep(z,3), ncol=ncol(y), byrow=TRUE)
[,1] [,2]
[1,]00
[2,]6 -3
[3,] 12 -6
I hope this helps.
Chel Hee Lee
On 14-11-19 08:43 AM, Ruima E. wrote:
Thank you Chel Hee.
Isn't there a simpler way to do so?
On
y = matrix(cbind(c(0, 0.5, 1),c(0, 0.5, 1)),ncol=2)
z = matrix(c(12, -6),ncol=2)
t(apply(y, 1, function(x) x*z))
[,1] [,2]
[1,]00
[2,]6 -3
[3,] 12 -6
I hope this helps.
Chel Hee Lee
On 14-11-19 08:22 AM, Ruima E. wrote:
Hi,
I have this:
y = matrix(cbind(c(0, 0.5,
Hi,
It is better to use sweep() for these kinds of problems, see ?sweep
y - matrix(cbind(c(0, 0.5, 1),c(0, 0.5, 1)),ncol=2)
z - matrix(c(12, -6),ncol=2)
sweep(y, 2, z, *)
Best,
Denes
On 11/19/2014 03:50 PM, Berend Hasselman wrote:
On 19-11-2014, at 15:22, Ruima E. ruimax...@gmail.com
Hi,
just for the records, your original code seems incorrect, see inline.
On 11/19/2014 03:22 PM, Ruima E. wrote:
Hi,
I have this:
y = matrix(cbind(c(0, 0.5, 1),c(0, 0.5, 1)),ncol=2)
z = matrix(c(12, -6),ncol=2)
In matlab I would do this
y .* x
Here you wrote 'x' which I guess refers to
I have a test.csv with two fields year and sale, with below values:
year sale
20011002002200
This is what I did in R.
aaa-read.csv(test.csv)
plot(aaa)
But when I call the above plot function why I'm getting decimals in x-axis
(year) ex: 2001.0, 2002.05
Please help.
It can be simplified a bit, though, as the second operand in the multiplication
does not need to be a matrix:
y * rep(z,each=3)
On 19 Nov 2014, at 16:24 , Jeff Newmiller jdnew...@dcn.davis.ca.us wrote:
When your matrices are the same size, the * operator does what you want.
Hi,
Since you didn't provide a reproducible example, we have no way of knowing.
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
But if I were you, I'd start with
str(aaa)
because my first guess is that your data import did not work as you expected.
On
The following provides array A with 3.212016 as the last value. The error
values are indeed in the array here. There is also another with 6.281757
that I noticed at first glance.
errf-function(act, res, testsize, flag)
{
j=1
if(flag==1)
{
j-nrow(d)-testsize
}
print(act)
Hi,
I have two groups of persons, GRP0 and GRP1, on which I measured three
continuous variables: VAR1, VAR2 and VAR3.
I would like to use Mancova in R with:
- VAR1, VAR2 and VAR3 as outcome variables
- GRP={0,1} as predictor variable
- age and gender = {F,M} as covariates
What would be the
Dear list,
I'm running windows 7 with R i386 3.1.2. I'm trying to load a excel
spreadsheet into R using the xlsx package. I posted my code below with the
error I got.
[R Studio]
library(xlsx)
quiz1q3data - read.xlsx(quiz1q3.xlsx,sheetIndex=1,header=FALSE)
Error in .jcall(RJavaTools,
Or ... if you mean simpler as in less to type, you can define your own
binary operator by enclosing it in % signs, and the assign any of the
previously proposed solutions, e.g.
y = matrix(cbind(c(0, 0.5, 1),c(0, 0.5, 1)),ncol=2)
z = matrix(c(12, -6),ncol=2)
'%.*%' - function(a,b) {a * rep(b,
On Nov 19, 2014, at 6:08 AM, i.petzev wrote:
Hi David,
thanks a lot for the response. I see that this works. I am not sure, however,
what the appropriate way to do this is. It also works if you do not define
weights in the boot() function (weighted bootstrap) but rather in the
Zilefac,
When I try
library(rgdal)
utm - project(as.matrix(xy[,c(X,Y)]), +proj=longlat +ellps=WGS84
+datum=WGS84 +no_defs)
plot(utm)
the points look fine. Similar to
map(world, xlim=range(xy$X), ylim=range(xy$Y))
points(xy[, c(X, Y)])
What's wrong with them?
Jean
On Wed, Nov 19, 2014 at
I'm looking for a package that would take a mathematical function
written in symbolic notation and convert it into R code.
What I have in mind would be something like the following:
1) Have a GUI (e.g. something like Microsoft Word equation editor, but
computer readable) to produce an
I'm trying to use the Rmpfr library with the round() function to apply
the round half to even rule and achieve correct results, without
errors due the finite precision of float point values.
Example of problem:
round(1.225,2)
#[1] 1.23
So far, this is what I've achieved:
library(Rmpfr)
x -
I have a script that uses RWeka (and consequently rJava). When I run
it in Rstudio everything works fine. When I run it with `R CMD BATCH`,
everything also works fine. However, when I run it with Rscript, I get
the following error:
Error in FUN(X[[1L]], ...) :
object is not a Java object
The following is printed for i,j,k,l,m,n,p 2 2 2 2 2 1 2
Value of error 6.281757Value of i,j,k,l,m,n,p 2 2 2 2 2 1 2, , 1, 1, 1, 1, 1
Thus ervalue[2,2,2,2,2,1,2] should be 6.28175, But after all the runs if you
try to get this array value it is NA. Also I think A is a list so not sure how
to
Ah, this is because you are overwriting your 'A' with each loop. As a
simple way to demonstrate this I changed:
A-array(, c(maxval,maxval,maxval,maxval,maxval,maxval, 2))
to
A - list()
and then I changed
A - sapply((1:Permax),function(p) far(p, i, j, k, l, m,n,
ervalue),simplify=FALSE)
to
Hi Adam,I was not sure if my solution was correct.This is what I got using
ArcGIS to convert the same coordinates:
+proj=lcc +lat_1=49 +lat_2=77 +lat_0=49 +lon_0=-95 +x_0=0 +y_0=0 +datum=NAD83
+units=m +no_defs +ellps=GRS80 +towgs84=0,0,0
structure(list(Long = c(662843L, 303344L, 634922L,
Hi,
On Nov 19, 2014, at 11:48 AM, Jeff Hansen dsche...@gmail.com wrote:
I have a script that uses RWeka (and consequently rJava). When I run
it in Rstudio everything works fine. When I run it with `R CMD BATCH`,
everything also works fine. However, when I run it with Rscript, I get
the
Hi,
I am currently using the lattice library and trellis graphs to explore my
data. Without going into too much detail of the data I just have a
question about how dot plot in the lattice library scales things...
I have normalised data that I am exploring as a function of time
partitioned by
Hi,
Ignore the last email - R has plotted the number of data points (100) I
have and using that as a scale rather than the normalised data values
Sorry to be a pest!!
Julie
Julie Hope (NERC PhD Student)
Sediment Ecology Research Group, University of St Andrews
School of Geoscience, Bangor
On Nov 19, 2014, at 9:17 AM, Scott Rifkin wrote:
I'm looking for a package that would take a mathematical function written in
symbolic notation and convert it into R code.
What I have in mind would be something like the following:
1) Have a GUI (e.g. something like Microsoft Word
David, Thanks for your reply and suggestions of packages - let me
clarify what I am looking for:
The web editor you pointed out is the sort of equation editor I'm
looking for and I had seen others like this.Let's say I use that one
(step 1) and then have Latex code (step 2). Step (3)
When using Rscript, the 'methods' package is not loaded/attached by
default, which it is when you use R. See ?Rscript for details. For
any scripts intended for batch usage, the safest is to only assume
that 'base' is attached, but nothing else.
/Henrik
On Wed, Nov 19, 2014 at 10:03 AM, Ben
My guess is that perhaps
plot(aaa$year, aaa$sale)
will produce something closer to what was expected.
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 11/19/14, 8:26 AM, Sarah Goslee sarah.gos...@gmail.com wrote:
Hi,
Since
By the way, this question is more appropriate for R-sig-geo.
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 11/18/14, 8:20 AM, Zilefac Elvis zilefacel...@yahoo.com wrote:
Hi,
I am trying to convert lat/lon to UTM but my
What you have written does not work in Matlab -
y = [0 0;0.5 0.5;1 1]
y =
0 0
0.50000.5000
1.1.
z = [12, -6]
z =
12-6
.
y .* z
Error using .*
Matrix dimensions must agree.
When dimensions agree it you get the same result in R as in
Zilefac,
Those do look different. I called that data frame arc, and ran this code
to look at all three versions of the coordinates.
par(mfrow=c(2, 2))
map(world, type=n, xlim=range(xy$X), ylim=range(xy$Y), mar=c(1, 1, 2,
1))
points(xy[, c(X, Y)])
mtext(xy lat long, side=3, font=2, line=1)
Many thanks Jean for the clarification.Zilefac.
[[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
Dear Sir/Madam,
I am a PhD candidate and writing my dissertation about portfolio optimization
in R. However, I have some problems with the codes. It always give the
dimension error. Could you help me to fix it?
Yours sincerely,
Here are the codes:
optimization - function(x) {
mean -
Hi programming fellows,
Please consider the following data frame:
df - structure(list(date = structure(c(1251350100.288, 1251351900,
1251353699.712, 1251355500.288, 1251357300, 1251359099.712), class =
c(POSIXct, POSIXt)), mix.ratio.csi = c(442.78316237477, 436.757082063885,
425.742872761246,
this got fixed when I added 3 more rows to my existing test.csv file, i.e.
new file got below data, with additional 3 rows:
year sale
2001 100
2002 200
2003 300
2004 400
2005 500
What's the secret behind 5 rows , i mean is there any link between plot
chart and 5
How do I set the limits of my x and y axis in svyplot? xlim and ylim does
not work.
Regards,
Raphael
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the
Hi. Your failure to post in plain text has nearly rendered your example code
unusable. Please post in plain text, not HTML. Also, the ToKeep attribute was
most of your example, yet was completely irrelevant.
I recommend avoiding the variable name df as it is easily confused with the
base
Ahora sí, perfecto!!
Muchas gracias y saludos
Juan.
De: Adolfo Álvarez [mailto:adalva...@gmail.com]
Enviado el: miércoles, 19 de noviembre de 2014 10:30
Para: JCMld
CC: r-help-es@r-project.org
Asunto: Re: [R-es] aplanar campo multivalor en data frame
Mis disculpas, me he liado al
Hola,
Como comenta Carlos el problema va a ser la codificación de las
cadenas de texto. Yo me encontré con problemas de este tipo en distintas
ocasiones y no tengo muy claro los detalles de como maneja esto R
internamente.
El problema no solo aparece con ficheros de texto (cuidado
55 matches
Mail list logo