If you start looking at the time series classes (xts, zoo, etc) they have
very quick and flexible lag functions built in.
Might this be a slightly more efficient solution for the homebrew
implementation?
OurLag - function(y, k=1) {
t = y[,1,drop=F]; d = y[,-1,drop=F];
if (is.matrix(y))
] - -1
}
result - -result[-(1:wait)]
In the end I'm happy with your solution!
Thank you for your help!
Thomas
Original-Nachricht
Datum: Fri, 29 Jul 2011 12:25:10 -0400
Von: R. Michael Weylandt michael.weyla...@gmail.com
michael.weyla...@gmail.com
An: Konrad Schubert
You are getting 105 because the default behavior of findInterval is such
that v[N+1] := + Inf (as noted in ? findInterval); that is, the last
interval is actually taken to stretch from the final element of sbwl.dates
unto eternity. It shouldn't be hard to write a catch line to set that to
But quite a few thousand dollars cheaper - seems a fair trade to me!
Seriously though: your last few requests have been focused on time objects,
so I strongly suggest you take a look at xts/zoo (
http://cran.r-project.org/web/packages/xts/index.html) -- it will make time
objects much easier for
))]
}
##value integer index matrix which can be used to index datacube
ind.matrix
}
On 08/04/2011 12:12 AM, R. Michael Weylandt michael.weyla...@gmail.com
wrote:
This might be a little late: but how about this (slightly clumsy)
function:
putValues- function(Insert, Destination
Check out ?savehistory in utils.
Also, I think most GUI's do this - I can certainly attest that RStudio does
Michael Weylandt
On Thu, Aug 4, 2011 at 11:55 AM, Bogdan Lataianu bodins...@gmail.comwrote:
I did save workspace and when I load it, I can see the variables,
using ls().
But I cannot
I hope someone experience with plyr package comes and helps because this
sounds like what it does well, but for your specific example something like
this works:
A = rbind(a,a2)
q = apply(A,2,function(x) {lm(x[1:nrow(a)] ~ x[-(1:nrow(a))])})
but yeah, that's pretty rough so I hope someone can
This seems to work:
apply(mat1,1,function(x){paste(x,collapse=)})
The collapse command inside of paste is (I think) the easiest way to
combine strings.
Michael Weylandt
On Thu, Aug 4, 2011 at 5:45 PM, Wegan, Michael (DNRE) weg...@michigan.gov
wrote:
I have a matrix of 5 columns and
monster!
Jannis
On 08/04/2011 09:58 PM, R. Michael Weylandt wrote:
Hi Jannis,
Like Gene, I'm not entirely sure what your code is intended to do, but it
wasn't hard to adapt mine to at least print out the desired slice through
the higher-dimensional array:
cubeValues- function(Insert
Yes, the stats package has a lag function, but it's not really appropriate
for the sample data Dimitri gave us: to wit, it's not of ts (time series)
class so lag doesn't know what to do with it and gives an error message.
Perhaps it's just that I never really took the time to get used to it, but
You can study this yourself using the System.time() utility: just write
System.time() around any block of code and R will time it for you.
Offhand, I'd guess example2 may be ever so slightly quicker since it doesn't
have to create colA and colB, but not to a degree that would be noticeable
for
*Is there a function or a package that can be used for comparation?*
Given that there is no such thing as comparation, I can only guess that
there's not...
Michael
PS -- Write back and actually explain what you are trying to do and we'll
talk.
On Fri, Aug 5, 2011 at 6:11 AM, kokavolchkov
AM, jim holtman jholt...@gmail.com wrote:
But there is:
Com`pa`ra´tion
n. 1. A making ready; provision.
Webster's Revised Unabridged Dictionary, published 1913 by C. G. Merriam
Co.
On Fri, Aug 5, 2011 at 9:12 AM, R. Michael Weylandt
michael.weyla...@gmail.com wrote
This is a textbook of when NOT to use a loop in R: rather make a function
that does what you want and use the replicate function to do it repeatedly.
f - function(){
return(-1000*quantile(rnorm(250,0,0.2),0.95)
}
x = replicate(1e5,f())
There are your desired numbers.
Some general coding
You should have been able to discern from the help pages that the generic
apply will do it.
E.g.,
apply(x,1,rank)
Now, you'll probably want to transpose the output of apply: it's a R
quirk/feature/bug/idiosyncrasy that apply(x,1,FUN) transposes the output and
most of the time I wind up
There are a few moving pieces to do this:
1) the toupper and tolower functions. These can do almost everything you
need:
x = lapply(x,toupper) ## This changes the things inside x but won't change
the names
2) Now, there are two ways to think about getting the elements from one list
to another:
efficient
than apply() ).
As here (I think), one often cannot vectorize and must loop in
interpreted code, and for this replicate() is fine and yields nice
clean code. But it's still a loop.
Cheers,
Bert
On Fri, Aug 5, 2011 at 9:15 AM, R. Michael Weylandt
michael.weyla...@gmail.com wrote
If you know the names will always work (i.e., names of y are always names of
x and the rows always have names) this should do it:
x[!(rownames(x) %in% rownames(y)),]
I.e., those rows of x such that their names are NOT included in the row
names of y.
Hope this helps,
Michael Weylandt
On Sat,
Welcome to the dark-side!
I think the View() command will do what you want. This brings up a new
window that displays the data spreadsheet style and you can scroll wherever
you wish. If you want to do work in your command window, the head() and
tail() commands will be of help to you.
If you are
I don't know lme models very well, but if you have standard errors for your
values, this shouldn't be too hard (as a last resort) using polygon()
For example
x = 1:10
y = x^2
y.Err = 2*x
y.Up = y + y.Err; y.Dn =y-y.Err
# This graph is actually quite ugly so don't copy the formatting
Would the image() function do what you need?
n = sample(1:50,25);
g = gray(n/max(n)) # set up color palate
g = rev(g) # reverse so max is black instead of white
image(as.matrix(n),col=g) # Requires a matrix input
I think you should be able to handle axes/ labels/ etc as normal:
Hi Tom,
What exactly is this function supposed to do? Your immediate problem is that
you are passing it a string x and asking for a mean of the string x
(hence complaints that it's not numeric) but I'm a little confused as to
what this is supposed to do when it works.
If you just want the mean
Hi Maxim,
I notice no one has replied to you (on list at least) so I'll take a stab at
answering your question and giving some productive advice.
I believe the axis command will do what you want with a little tweaking: It
certainly lines things up for me.
x -
I'd suggest you look into the xts class and write
require(xts)
xts = as.xts(1:5,Sys.Date()+1:5)
time(xts)[xts==3]
By the way, your code isn't pastable for me: not sure why.
Michael Weylandt
On Tue, Aug 9, 2011 at 10:39 PM, Richard Ma xuanlong...@uts.edu.au wrote:
Hi all,
I have a zoo time
D'Oh -- just spotted it (don't know what was wrong with me):
in your code: 2011-01-05 and ts = zoo(x dt) need to be changed.
If you do that, the same trick
time(ts)[ts==3]
will work. Still, I'm a big xts fan.
Michael
On Tue, Aug 9, 2011 at 10:45 PM, R. Michael Weylandt
michael.weyla
Perhaps you could shade the bars as appropriate?
I'm not going to use your data because it's not an easily paste-able but how
about this:
x = rnorm(100)
y = sample(c(A,B),100,replace=T,prob=c(0.7,0.3))
d = data.frame(level = x, status = y)
n = 10 # Number of bins
breaks = quantile(d$level,
unlist()
Michael Weylandt
On Wed, Aug 10, 2011 at 2:58 PM, Liviu Andronic landronim...@gmail.comwrote:
Dear all
How does one convert a non-symmetric list to a vector? See below:
x - list()
x[[1]] - letters[1:5]
x[[2]] - letters[6:10]
x[[3]] - letters[11:12]
x
[[1]]
[1] a b c d e
To pick random elements to sample, you can just use the sample function
sample(1:5,3,replace=T/F) # pick true or false as needed for your data.
If you replicate this, you should have no problem.
replicate(100,function() return(sample(1:5,3,replace=T/F)))
This will be plenty fast, but if you
Sorry, that second line of code won't work: do it in 2.
f - function() {return(sample(1:5,3,replace=T/F))}
replicate(100,f())
Michael
On Wed, Aug 10, 2011 at 3:06 PM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
To pick random elements to sample, you can just use the sample
Well, without saying what sort of random numbers you mean, it's a little
hard, but here's one straightforward way to do it for 2 normally distributed
rvs.
X1 = rnorm(100)
X2 = rnorm(100)
Y = X1
Z = 0.4*X1+sqrt(1-0.4)*X2
then
cor(Y,Z) ~ 0.4
In function terms:
CorrNorm - function(n=100, rho =
This sounds very much like a recursive problem: something like this seems to
get the gist of what you want.
DataSplits - function(Data, alpha = 0.05) {
DataSplitsCore - function(Data, alpha, level) {
tt - t.test(Data[,1],Data[,2])
print(tt)
if (tt$p.value alpha) {
unlist()
Michael Weylandt
On Thu, Aug 11, 2011 at 12:46 PM, Srinivas Iyyer
srini_iyyer_...@yahoo.comwrote:
hi I need help with list object.
I have a list object
a - c('apple','orange','grape')
b - c('car','truck','jeep')
c - list(a,b)
names(c) - c('fruit','vehicle')
c
$fruit
[1]
I'd suggest either a color plot as given by image() and related functions or
a 3d mesh-plot which you can get from persp()
E.g.,
x = seq(0,1,by=0.01); y = x
z = outer(x,y+1,/) # z = x/(y+1) -- I know that's not a density but you
can adapt as necessary
filled.contour(x,y,z)
persp(x,y,z)
There
Weylandt michael.weyla...@gmail.com*wrote:
From: R. Michael Weylandt michael.weyla...@gmail.com
Subject: Re: [R] help with loops
To: Srinivas Iyyer srini_iyyer_...@yahoo.com
Cc: r-help@r-project.org
Date: Thursday, August 11, 2011, 12:49 PM
unlist()
Michael Weylandt
On Thu, Aug 11, 2011
The previous two posters basically covered everything, but since I'm on the
train with not too much to do, here's a more detailed response building on
what they said. The following code is shovel-ready and can be pasted
directly to your command line if you have your main data frame called d
Yes, that likely is the source of the difference: I'm happy to help fix it
up (won't be hard), but I want to clarify exactly how you want the data
done:
say we have 20 variables x = 1:20 if there's a split we go to 1:10, 11:20;
then 1:5, 6:10, 11:15,16:20 etc
but what about situations with very
Hmmm, interesting problem. I now see your motivation for not using a data
frame set up in the split code: try this --
DataSplits - function(Data, alpha = 0.05) {
DataSplitsCore - function(Data1,Data2, alpha, level) {
tt - t.test(Data1,Data2)
print(tt)
if (tt$p.value
Sorry -- missed a tweak. The call to DataSplitsCore should read
nr = floor(NROW(Data)/2); Data1 = Data[(1:nr)]; Data2 = Data[-(1:nr)];
DataSplitsCore(Data1,Data2,alpha,level)
On Fri, Aug 12, 2011 at 11:46 AM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
Hmmm, interesting problem. I
It sounds like the data frame produced by Simulate() doesn't set the names
you want. You can probably fix this by including
colnames(Gestion) c(B,T1,... # etc)
immediately after the simulation.
Can't confirm this without knowing which of the excel/R interface packages
you're using, but I'd be
I believe you received an informative answer to both these questions from
Daniel Maiter one hour and twenty five minutes after sending your question:
I repeat it here just in case you didn't get it.
--
Q1 is very opaque because you are not even saying what kind of plot
to plot
all the data in a line plot - exactly how it is shown in the attached graph.
Mark
From: R. Michael Weylandt michael.weyla...@gmail.com
To: Mark D. d.mar...@ymail.com
Cc: r-help@r-project.org r-help@r-project.org
Sent: Saturday, 13 August 2011, 21
I believe it's a problem in your variable name hsa-miR-98. R wants to
interpret that as hsa less miR less 98. Since you don't have a variable
called hsa, R (rightly) complains.
Call ls() and see what R thinks your variables are named -- that will
hopefully make the problem evident.
Hope this
Two things,
1) You need to use square brackets in this case because model is an object,
not a function.
2) You probably want to use a list object to store a whole bunch of model
objects so you'll want double brackets.
model = list(NULL)
for (i in 1:1000) {
model[[i]] - lm(Y~X1+X2())
}
This,
I can't help with the questions on pooling regressions, but for the question
about data-frame usage, I'll note two things.
One,
x = data.frame(y = 1:3, z = 4:6)
is.data.frame(x)
TRUE
is.data.frame(t(x))
FALSE
is.data.frame(as.data.frame(t(x)))
TRUE
Two, you'll need to check that your row
be a special handling of names with brackets.
/johannes
Original-Nachricht
Datum: Mon, 15 Aug 2011 09:39:47 -0400
Von: R. Michael Weylandt michael.weyla...@gmail.com
An: Johannes Radinger jradin...@gmx.at
CC: r-help@r-project.org
Betreff: Re: [R] Extracting information
The most elegant solution is going to depend on where you data comes from,
but one way to do it if you have a matrix of data:
D = cbind(rcauchy(100), matrix(runif(100*50),ncol=50)) # Some nonsense data
lm(D[,1] ~ D[,-1])
If you let us know how your data is set up, a more specific response can be
I think everything below is right, but it's all a little helter-skelter so
take it with a grain of salt:
First things first, make your data with dput() for the list.
Y = structure(c(0, 35, 0, 0, 0, 0, 84, 84, 0, 48, 84, 0, 22, 0, 0,
0, 0, 0, 10, 0, 48, 0, 0, 48, 0, 22, 0, 0, 0, 0, 84, 84, 0, 48,
please help me with this.
Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London
From: R. Michael Weylandt [michael.weyla...@gmail.com]
Sent: Wednesday, August 17, 2011 7:11 PM
To: Bansal, Vikas
Cc: r-help@r
Assuming that the * in your [11,] example is a typo, would this work?
apply(out$desc,1,paste,collapse=)
Hope this helps,
Michael Weylandt
On Thu, Aug 18, 2011 at 2:35 PM, Eduardo Mendes emammen...@gmail.comwrote:
Dear R-Users
I have the following matrix
out$desc [,1]
There is a strsplit() function (syntax is (stringToBeSplit, splitAt) ) that
may be of use. I haven't followed the thread so I don't know how well it
handles the original problem.
Michael Weylandt
On Fri, Aug 19, 2011 at 12:41 PM, Ole Peter Smith ole@gmail.com wrote:
-- Forwarded
Read the documentation by typing ?qexp (or whatever other function) at the
command line.
But, since you asked and it won't take long to answer, the general pattern
is:
rDIST gives random numbers sampled from the distribution
dDIST gives the PDF
pDIST gives the CDF
qDIST gives the quantile
Can you say a little more about what you mean it does not work? I'd guess
you have a regular expression mistake and are probably getting more columns
than desired, but without an example, it's hard to be certain.
Use dput() and head() to give a small cut-and-paste-able example.
Michael
On Mon,
%in%
Here,
i %in% j
Hope this helps,
Michael
On Mon, Aug 22, 2011 at 11:51 AM, Martin Batholdy
batho...@googlemail.comwrote:
Hi,
I have the following problem:
I have two vectors:
i - c('a','c','g','h','b','d','f','k','l','e','i')
j - c('a', 'b', 'c')
now I would like to
I want to select the array columns that are not equal to 10. is ambiguous
to me.
Just to clarify, do you want to simply drop the column named array10 or do
you want to check each column for having one/all 10's as values and drop
based on that test?
Michael
On Mon, Aug 22, 2011 at 12:35 PM,
, Michael,
What I want to do is remove all the rows, for which array1, array2,
..array15 are all equal to 10.
I want to keep all the rows at least one of the array variables are not
equal to 10.
sorry for the confusion.
On Mon, Aug 22, 2011 at 9:52 AM, R. Michael Weylandt
michael.weyla
(x){any (x != 10), here x is a vector, x!=10 will give
a vector of logical value, right?
If it is, how can vector be compared to a scale, 10 in this case?
Thanks!
On Mon, Aug 22, 2011 at 10:16 AM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
This isn't the most beautiful code
Number 1 can be done as follows:
x = rnorm(50); y = rnorm(50)
xCDF = ecdf(x); yCDF = ecdf(y)
plot(xCDF)
lines(yCDF,col=2)
For the other ones, you are going to have to be a little more specific as to
how you want to do the approximation...but ?density might be a place to
start for #4, assuming
)? Can ecdf do this?
On Mon, Aug 22, 2011 at 2:24 PM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
Number 1 can be done as follows:
x = rnorm(50); y = rnorm(50)
xCDF = ecdf(x); yCDF = ecdf(y)
plot(xCDF)
lines(yCDF,col=2)
For the other ones, you are going to have to be a little
On Mon, Aug 22, 2011 at 4:57 PM, David Winsemius dwinsem...@comcast.netwrote:
On Aug 22, 2011, at 4:34 PM, David Winsemius wrote:
On Aug 22, 2011, at 3:50 PM, R. Michael Weylandt wrote:
Yes. The xCDF/yCDF objects that are returned by the ecdf function can be
called like functions
Two general R tips:
1) Don't name variables seq or var. These are two really important R
functions and you can get all sorts of unexpected craziness if you overload
them. Going forward, also watch out for t,c, T, F as well.
2) As others have noted, it's very possible to implement this without an
Without example code or data I can't guarantee this is your problem, but
have you looked at using xts(...,unique = F) instead of the default true.
Alternatively, let us see what your data actually looks like to R (dput) and
we'll help. But what you've got sounds like a problem in the date format,
On Mon, Aug 22, 2011 at 7:17 PM, David Winsemius dwinsem...@comcast.netwrote:
On Aug 22, 2011, at 6:26 PM, R. Michael Weylandt wrote:
On Mon, Aug 22, 2011 at 4:57 PM, David Winsemius dwinsem...@comcast.net
wrote:
On Aug 22, 2011, at 4:34 PM, David Winsemius wrote:
On Aug 22, 2011
I do not believe your code (minimal as it is) would work: the correct
argument is breaks. More generally, do you really mean to say that hist(x,
breaks = 20) immediately returns the bin counts? It doesn't on my machine
and if you knew how to get the counts, you should be able to get the
midpoints
Not directly related to what you said below, but might I suggest that for
numerical work all.equal() might be a little more robust in a
computationally heavy implementation.
x = c(0.812672,0.916541,0.797810) #dont' call variables c -- just a bad idea
y = x[1]+x[2]+x[3]
sum(x) ==y
[1] FALSE
which.min()
more generally
which(a==min(a))
Michael Weylandt
On Wed, Aug 24, 2011 at 12:03 PM, Chee Chen chee.c...@yahoo.com wrote:
Dear All,
I would like to ask a question on how to find the index of the minimum of
entries of a numeric vector, without using loops or user defined
I'm not sure I understand your question: a[[2]] is a matrix.
a - list(matrix(1:6,2),matrix(5:10,2))
is.matrix(a[[2]])
TRUE
x = a[[2]]
is.matrix(x)
TRUE
x+2
[,1] [,2] [,3]
[1,] 7 9 11
[2,] 810 12
a[[2]] + 2
[,1] [,2] [,3]
[1,] 7 9 11
[2,] 810 12
What
unlist
the sub-lists and that gives you a list of matrices, which, as I said
before, are matrices when subsetted with `[[`, but not `[`.
Michael
On Wed, Aug 24, 2011 at 2:37 PM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
I'm not sure I understand your question: a[[2]] is a matrix
If your numbers are all positive integers, this should work:
(tabulate(xm)[xm])/length(xm)
it can be put into a function for ease of use:
probVec - function(x) {(tabulate(x)[x])/length(x)}
You'll have some trouble if you have non-positive integers or non-integers.
Let me know if you need to
Read the plot documentation by typing ?plot, particularly the optional
argument main.
Hope this helps,
Michael Weylandt
On Wed, Aug 24, 2011 at 1:40 PM, upani1982 upananda.p...@gmail.com wrote:
Hi All,
I am new to this forum. I have just started learning R. When i use
plot(decompose(x)), i
The proper command is header = TRUE
capitalization is important for both *h*eader and T*RUE*
Hope this helps,
Michael Weylandt
On Wed, Aug 24, 2011 at 11:10 AM, shardman samuelhard...@hotmail.comwrote:
Hi,
I'm really new to R so I aoplogise if this is a stupid question.
I'm trying to
How are you storing the elements of the data frame? I'm working with a data
frame of doubles with no names and having trouble observing the same
problem. If they are factor levels though, that *might* account for it.
sessionInfo() might also help. Obviously it's not convenient to print this
It sounds like if you know you can pass the string A1 where you need it to
go, the command get() *might* be what you are looking for.
Also, you can make your code much faster/prettier because R is smart about
recycling vectors of different lengths:
char - paste(A,1:10, sep=)
x - paste(X,1:10,
Look at ylim, as an optional argument to plot.
Michael
On Thu, Aug 25, 2011 at 1:07 PM, Claudio Zanettini
claudio.zanett...@gmail.com wrote:
Hello everyone,
I have a graph and a segment parallel to the x axis at y=-10, x=0, and
bars on it.
Now the question is,
Is there a way to leave
, 1.03*max(y)) or something similar.
Michael Weylandt
On Thu, Aug 25, 2011 at 1:12 PM, Claudio Zanettini
claudio.zanett...@gmail.com wrote:
Yes I tried but if I set the lim to 0 then it will not displayed the line
that is at -10, right?
2011/8/25 R. Michael Weylandt michael.weyla
=( 0, 1000)
and under it a segment parallel to the x axis at -10.
I am sorry it is contorted thing :)
Claudio
2011/8/25 R. Michael Weylandt michael.weyla...@gmail.com
lim is not the argument: ylim is.
You put in a vector of length 2 comprising the min and max y you wish:
consider this:
x
I'm not going to download your data since it's probably irrelevant to your
problem and I have no interest in downloading unknown files.
Consider this instead:
library(quantmod)
SPY = getSymbols(SPY,auto.assign=F)
SPY = weeklyReturn(Ad(SPY))
densitySPY = density(SPY)
plot(densitySPY,main=Kernel
I'd suggest you should probably just use the simpler write.csv() function to
make a file type that will move much more conveniently between Excel and R.
The syntax is:
write.csv(ThingBeingSaved, filename.csv)
If you only put the file name to write.csv it will be placed in your working
I'd be willing to guess that some combination of
match()
%in%
unlist()
will get the job done, but without knowing what sort of data you have, I
can't write example code.
If you could, use the dput() function to turn your data into plain text and
let us work directly with it to help you out. If
There's nothing wrong with leaving in buggy code when there's a bug that you
just can't get (assuming it's part of your real code): I only ask for the
error message because it saves us a little bit of time if you can let us
know what errors you are getting.
Anyways, best of luck,
Michael
On
There's a no-homework policy on this list and given that you are sending
from a .student account and referencing example assignments, you probably
won't get any help. Looking at the given code, it seems like you should get
in touch with a TA sooner rather than later though.
Best of luck,
Michael
Hi Sam,
The heart of your problem is that you are not using strings in your off
statements. Rather, you are calling objects called norm and cumu and R is
trying to test those for equality.
In the first case, when you get to norm, R tries to call the norm()
function, which is the magnitude of a
Hmm, that's quite puzzling. I don't know but I'd willing to guess the
time/date stamps on a,b are more different than the output is leading us to
believe. My experience is that there's always more to a time/date object to
trick us up than one would expect.
If you could, dput() them so we can see
NA
2010-04-05 7.4040 28.30
2010-04-06 7.3317 28.38
2010-04-07 NA 28.21
2010-04-08 NA 28.31
2010-04-09 NA 28.47
which is probably what you want.
Regards
Petr
Hi
On 26 August 2011 03:37, R. Michael Weylandt
michael.weyla
I don't have the FactoMineR library so I can't replicate, but it seems that
your problem is that you never plot anything.
Effectively, your code runs
windows()
x = 1:5
x
and then wondering where your graph is.
Add plot(res.pca) and i think your problem will be solved.
Michael Weylandt
On
To save anyone else 30 seconds, here's how google translates the below:
Ladies and Gentlemen,
I would like to inform me whether there is the possibility of security
certificates for R packages are.
Sincerely,
Christopher W. Weinberger
2011/8/26 Christoph W. Weinberger
Well, here's one way you could do it:
# Don't run this unless you really mean it
clear - function(){rm(list=ls(.GlobalEnv), envir = .GlobalEnv)}
Both calls to .GlobalEnv seem necessary so that both rm() and ls() go
everywhere with it. However, this certainly isn't the most useful code
because it
Did you install the package quantmod?
install.packages(quantmod)
Michael
On Sat, Aug 27, 2011 at 4:32 PM, Yumin zpx...@gmail.com wrote:
Hi Michael:
I tried to simplify the code, but still failed.
*con - url(http://quote.yahoo.com;)
if(!inherits(try(open(con),
What is wrong with the getSymbols(IBM) command I originally suggested to
you?
Michael
On Sat, Aug 27, 2011 at 6:23 PM, Yumin zpx...@gmail.com wrote:
Hi Michael:
I installed: install. packages(quantmod) and now it accept
library(quantmod) sentence. BUT after input:
*
I have simplified the code only to download the sp500 index.
Perhaps you have, but you haven't provided any of that simplified code so
I'm a little skeptical.
I do have to say though, if you've managed to do it more efficiently than
the 12 characters in getSymbols() you are a far better coder
Two things:
It's just a guess as to what your problem is, but functions in R don't
usually act on the object that is passed to them, but rather a copy thereof:
if you want to keep the values calculated within the function, that's
usually done with an assignment statement combined with the
Can't help, code runs fine on my machine once you change valu to value.
Are you sure it fails in a vanilla run of R and isn't caused by any other
choices you have made along the way?
Michael
PS -- Here's the code
func - function(y, a, rate, sad){
f3 - function(z){
f1 -
How exactly do you mean it doesn't work? Copied from my GUI:
x = zoo(1:5, as.Date('2001-01-01')+1:5)
x[as.Date('2001-01-05')]
2001-01-05
4
x[as.Date('2001-01-05')] = 0
x
2001-01-02 2001-01-03 2001-01-04 2001-01-05 2001-01-06
1 2 3 0 5
PM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
How exactly do you mean it doesn't work? Copied from my GUI:
x = zoo(1:5, as.Date('2001-01-01')+1:5)
x[as.Date('2001-01-05')]
2001-01-05
4
x[as.Date('2001-01-05')] = 0
x
2001-01-02 2001-01-03 2001-01-04 2001-01-05 2001
? switch
Might do the job.
On Wed, Aug 31, 2011 at 1:27 PM, Antonio Silva aolinto@gmail.comwrote:
Hello
I'm translating a Visual Basic routine to R.
Which command in R is similar to select case in VB?
See the example:
select case int(AG)
case 0, 5, 8, 10
VAR = 37
case 1, 4
Suppose your data is called df.
df[rowSums(df == P)0,]
In short, this tests each element for equality for P, sums the number of
Ps found and subsets when that number is 0.
Michael
On Wed, Aug 31, 2011 at 1:28 PM, Joao Fadista joao.fadi...@med.lu.sewrote:
Dear all,
I would like to know how
Good Morning,
I'm trying to install the rJava package on a local (work) machine and having
some trouble. The following occurred in an RGui session.
sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252
Mr . .,
MASS::area comes to mind but it may be more helpful if you could say what
you are looking for / why integrate is not appropriate it is for whatever
you are doing.
Strictly speaking, I suppose there are all sorts of alternatives to
integrate() if you are willing to be really creative and
will be gratefull.
Thanks in advance.
On Thu, Sep 1, 2011 at 10:55 AM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
Mr . .,
MASS::area comes to mind but it may be more helpful if you could say what
you are looking for / why integrate is not appropriate it is for whatever
you
, appologies for my previous mistake. It was not my intention to
blame about integrate.
On Thu, Sep 1, 2011 at 11:49 AM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
I'm going to try to put this nicely:
What you provided is not a problem with integrate. Instead, you provided
a
rather
Dropping all occurences of a factor does not drop that level. This actually
turns out to be much more useful than it first might appear, but if you
really need to get around it, it can be done.
Look at this toy example:
R x = factor(c(A,B,C,A,B,C,C))
R x
[1] A B C A B C C
Levels: A B C
R x[x !=
1 - 100 of 2207 matches
Mail list logo