Re: [R] how to cumulate up times

2012-04-24 Thread R. Michael Weylandt
? cumsum something like library(chron) # Reporting packages you use is always considerate mt <- times(c('00:05:00', '00:15:00', '00:30:00')) # Spaces are legible! times("09:30:00") + cumsum(mt) Michael On Tue, Apr 24, 2012 at 11:35 AM, René Mayer wrote: > Dear List, > given a vecor of times i

Re: [R] zipfR help

2012-04-24 Thread R. Michael Weylandt
   15 27 381 > [471] 1  6  6  47 341    3  19 6  2  62 > [481] 2761   196    19 49 100    7  10 40 22 5 > [491] 2040   8  68 41 17 4  44 3  2554   81 > 180 Levels: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1

Re: [R] Number of lines in analysis after removed missings

2012-04-24 Thread R. Michael Weylandt
Take a look at nobs() Michael On Tue, Apr 24, 2012 at 10:05 AM, Eiko Fried wrote: > I have a dataset with plenty of variables and lots of missing data. As far > as I understand, R automatically removes subjects with missing values. > > I'm trying to fit a mixed effects model, adding covariate by

Re: [R] trouble loading ggplot2 using R

2012-04-24 Thread R. Michael Weylandt
What is the output of your sessionInfo()? Many folks have ggplot2 running on Snow Leopard (myself included) -- most likely, you need to update something or other... Michael On Tue, Apr 24, 2012 at 9:26 AM, ramonovelar wrote: > Hello, > > I have a similar error, running R in Snow Leopard too > >>

Re: [R] Scatter plot / LOESS, or LOWESS for more than one parameter

2012-04-23 Thread R. Michael Weylandt
The scatter plot is easy: plot(pH1 ~ pH2, data = OBJ) When you say a loess for each -- how do you break them up? Are there repeat values for pH1? If so, this might be hard to do in base graphics, but ggplot2 would make it easy: library(ggplot2) ggplot(OBJ, aes(x = pH1, y = pH2)) + geom_point() +

Re: [R] zipfR help

2012-04-23 Thread R. Michael Weylandt
It depends how you want to ensure that condition -- if you just want to censor at an upper bound of 6k, this is easy: pmin(zmsample, 6000) If you want to sample "as before" but it just happens to all be less than 6000 -- that's not really a rigorous statement, but just go with it -- intuitively,

Re: [R] plot function creating bars instead of lines

2012-04-23 Thread R. Michael Weylandt
It is indeed the fact you're plotting factors, but unless you say what "as intended" is, it's hard to provide exactly what you're seeking. Perhaps this will help though: X <- factor(sample(letters[1:5], 15, TRUE)) Y <- rnorm(15) dats <- data.frame(X, Y) plot(Y ~ X, data = dats) # No good plot(X

Re: [R] check for difference.

2012-04-23 Thread R. Michael Weylandt
Lists of numbers of length ~1000 are no problem for the wilcox.test() function (Mann-Whitney is a special case) if you leave the default exact = NULL. The choice of test is all yours. Michael On Mon, Apr 23, 2012 at 12:39 PM, aoife doherty wrote: > Hello > I have two lists of numbers, each list

Re: [R] Newbie Question on making subsets for every element of a table column

2012-04-23 Thread R. Michael Weylandt
There are, but it's generally considered better style to keep them all in a single list and use lapply() if you want to do things to each element. Michael On Mon, Apr 23, 2012 at 5:33 PM, cyclondude wrote: > Yes. That is what I was looking for.  Is there a simple way to (in this > scenario) > >

Re: [R] Assignment problems

2012-04-23 Thread R. Michael Weylandt
That's not the ifelse() that's the for loop returning NULL (everything's a function!). If you put the assignment inside you'll get expected behavior. x <- (for(i in 1:5) i) # Strange for(i in 1:5) x<- i # Normal (but notice you only get the last value because previous ones are overwritten) Michae

Re: [R] Assignment problems

2012-04-22 Thread R. Michael Weylandt
Look at ?ifelse, a combination of logical subscripting and mean(), or even better ?ave -- I can't say too much more; there's a no homework policy on this list and I recognize that first solution as mine already... (I should have noted that the first time) Michael On Apr 22, 2012, at 2:54 PM,

Re: [R] difficulty in Formatting time series data

2012-04-22 Thread R. Michael Weylandt
Yes dput() for a reproducible example with some minimal reproducible code (and the packages "day.of.week" and wday() come from...) x <- xts(10, Sys.Date()) wday(x) seems fine for me. "precisely the wrong answers" -- interesting turn of phrase. Michael On Sun, Apr 22, 2012 at 12:53 PM, Rag

Re: [R] contour algorithm

2012-04-21 Thread R. Michael Weylandt
The C implementation of the algorithm is here: http://svn.r-project.org/R/trunk/src/main/plot3d.c (grep filledcontour) but I don't see a reference other than to Ross Ihaka. Hope this helps, Michael On Sat, Apr 21, 2012 at 9:21 PM, Stoch astic wrote: > First time user, so sorry if I don't under

Re: [R] Is there a overall calculation precision control in R

2012-04-20 Thread R. Michael Weylandt
On the R level, I believe you're limited by the type of numeric representation being used: either 32-big integer or 64-bit double. See the storage.mode() of your objects. External code can make use of 128-bit types if desired, but I don't believe those can be naturally represented back at the R lev

Re: [R] Manually reconstructing arima model from coefficients

2012-04-20 Thread R. Michael Weylandt
Ahh, I understand -- unfortunately, I'm not aware of an easy way to do this so you'll have to hack your own: this doesn't look too hard however, if you call getAnywhere(predict.Arima) you can get the prediction scheme R uses. It seems that most of the heavy lifting is already in C so you'd probab

Re: [R] Intergration of a function

2012-04-20 Thread R. Michael Weylandt
whathaveyoutried.com Michael On Fri, Apr 20, 2012 at 5:47 AM, dcgf wrote: > I am trying to integrate this function > > f_x(x) = (1/(2pi))*(1+sin(2x)) for o < x < 2 > > I know the answer is (x/(2*pi))-(cos(2x)/(4*pi)) but I must be doing > something wrong.. > > -- > View this message in context:

Re: [R] vector subtraction

2012-04-20 Thread R. Michael Weylandt
You're thinking about it wrong. This is an arithmetic sequence: seq(from = 1000, by = -30, length.out = 15) Michael On Fri, Apr 20, 2012 at 5:14 AM, uday wrote: > I would like to calculate vector from existing  value > e.g > v       <- 1000 > s       <- 30 > d1    <- v-s >                   d

Re: [R] Sort out number on value

2012-04-20 Thread R. Michael Weylandt
This really has little to do with sorting, but can be much more easily done with logical subscripting: x[x < 20] which I read as "x such that x is less than 20". Hope this helps, Michael On Fri, Apr 20, 2012 at 6:26 AM, Yellow wrote: > Can anyone help me maybe with a question I can seem to fin

Re: [R] Reading a file with random whitespace

2012-04-19 Thread R. Michael Weylandt
It looks like you might want to use read.fwf for fixed width files Michael On Thu, Apr 19, 2012 at 3:45 PM, John S wrote: > Dear R-users, > > I have a large data file that I am trying to read in R where the file has a > white space at the begging and at random places. The whitespace is actually

Re: [R] mlogit learning error

2012-04-19 Thread R. Michael Weylandt
There's something in your data that makes the model computationally singular when you take the various subsettings... Can you provide a small reproducible example so we can help narrow it down? It looks like you're using different data for each mlogit though so I'm not sure how the comparison that

Re: [R] suggested method to transform list to a matrix

2012-04-19 Thread R. Michael Weylandt
Use matrix subsetting like this: x <- matrix(1:9,3) rownames(x) <- letters[1:3] colnames(x) <- LETTERS[1:3] print(x) usrs <- c("a","b","a") vars <- c("C","C","A") counts <- c(10,11,12) x[cbind(usrs, vars)] <- counts print(x) Hope this helps, Michael On Thu, Apr 19, 2012 at 1:48 PM, Tim Stutt

Re: [R] Compare String Similarity

2012-04-19 Thread R. Michael Weylandt
Though if you do decide to use Levenstein, it's implemented here in R: http://finzi.psych.upenn.edu/R/library/RecordLinkage/html/strcmp.html I'm pretty sure this is in C code so it should be mighty fast. Michael On Thu, Apr 19, 2012 at 11:40 AM, Bert Gunter wrote: > Wrong list.This is R, not st

Re: [R] Help in using unique count by match function

2012-04-19 Thread R. Michael Weylandt
I think the OP is looking for the construct length(unique(x)) but not really sure what the rest of the question is. Michael On Apr 19, 2012, at 2:12 AM, Petr PIKAL wrote: > Hi > > Your question is rather cryptic. Why the output shall be 3? What has > unique count to do with match function?

Re: [R] How to add specific column to data.set?

2012-04-18 Thread R. Michael Weylandt
No like I said, lapply gets columnwise results (if you stopped there, it would tell you whether each country is in the EU separately) and the Reduce() combines them. Re-read my explanation and play around with it on your own data set. To convert 1 -> True and 2 -> False, you could use Boolean

Re: [R] Help with creating conditional categorical variables in R

2012-04-18 Thread R. Michael Weylandt
Your problem is that columns A & B contain something that can't be ordered. (Likely "factor" (=categorical) data like Male / Female rather than numeric like 10 and 5) Use str(data_2) to see what classes your data are -- they sometimes get converted in unexpected ways if you aren't careful in setti

Re: [R] interpolation issue

2012-04-18 Thread R. Michael Weylandt
Your problem is that length(x) != length(y) approx uses linear interpolation but there's no way to make sense of that if you can't match up the x and y coordinates -- and you can't match up the x and y coordinates if there aren't the same number of them. Michael On Wed, Apr 18, 2012 at 10:15 AM,

Re: [R] simple time series plot

2012-04-18 Thread R. Michael Weylandt
The preferred format for time series will be something like this: Sensor1Sensor2 Sensor3 T1 Read1_1 Read2_1 Read3_1 T2 Read1_2 Read2_2 Read3_2 T3 Read1_3 Read2_3 Read3_3 if you can get that. CSV separations are nice but not as essential as the columnar organization. (It's pos

Re: [R] How to add specific column to data.set?

2012-04-18 Thread R. Michael Weylandt
I'll unpack it bit by bit: stringsAsFactors = FALSE is a command to tell R how to construct the data frame: this doesn't apply to you because you already have a data frame, but I need it to set up my examples. By default, when you give R data that looks like strings/labels, it wants to convert tho

Re: [R] introducing R to high school students

2012-04-17 Thread R. Michael Weylandt
In addition to whatever feedback you may get here, you might subscribe to the SIG-Teaching list for another interested population. Michael On Tue, Apr 17, 2012 at 10:46 PM, Christopher W Ryan wrote: > I participate peripherally on a listserve for middle- and high-school > science teachers. Somet

Re: [R] How to add specific column to data.set?

2012-04-17 Thread R. Michael Weylandt
Ok, so you simply need to use the methods David or I provided -- it looks like you don't even have to change the variable names... Is there something that isn't clear now? Also, reproducible examples are much better if you use dput() so they are actually reproducible Michael On Tue, Apr 17,

Re: [R] Manually reconstructing arima model from coefficients

2012-04-17 Thread R. Michael Weylandt
What exactly do you mean by "apply" it to a different data set? Unlike regular regressions, time series models don't (generally) use new data to make forecasts ... By the way, this is a good guide to the time series functionality available in R: http://cran.r-project.org/web/views/TimeSeries.html

Re: [R] How to add specific column to data.set?

2012-04-17 Thread R. Michael Weylandt
Reproducible example not provided... try this -- it should generalize to multiple columns: EU <- c("UK","FR","DE") # Yes, I know there are more countries <- data.frame( country1 = c("US","CH","UK","AU"), country2 = c( "CA", "MX", "FR", "DE"), stringsAsFactors = FALSE) cbind(countries, EU.Memb

Re: [R] How to create a data.frame from several time series?

2012-04-17 Thread R. Michael Weylandt
It's a rather risky idea to call your function aggregate.zoo -- that's actually a pre-existing function and it could (will!) confuse the method dispatch system. In short, S3 methods use the name convention generic.class (e.g., aggregate is the generic and zoo is the class) so when you just use ag

Re: [R] How to add specific column to data.set?

2012-04-17 Thread R. Michael Weylandt
Do you have lists or something like a data.frame? Your printout suggests you don't actually have a list. (well, data.frames really are lists but let's just not talk about that) Perhaps %in% is what you are looking for... EU <- c("UK","FR","DE") # Yes, I know there are more countries <- c("US

Re: [R] puzzling Date math result

2012-04-17 Thread R. Michael Weylandt
A slightly quieter response: Please use dput() to create a reproducible example -- for this case, if x and y aren't too long, it seems that dput(x) and dput(y) would comprise one. str() helps (and thank you for that -- it gave me a place to start), but it doesn't provide quite enough to reproduce

Re: [R] Problem accessing .Rdata objects in a loop

2012-04-17 Thread R. Michael Weylandt
I'm not sure that's francy's problem. This seems to work for me: # Some fake data nms <- letters[1:5] lapply(nms, function(x) assign(x, rnorm(10), .GlobalEnv)) # Make some .Rdata files lapply(nms, function(x) save(list =x, file = paste0(x, ".Rdata"))) # Check they are there list.files() # Bring

Re: [R] formatting sub-second intervals

2012-04-16 Thread R. Michael Weylandt
It looks to me like it's written in the penultimate paragraph of the details section for ?strptime Michael On Mon, Apr 16, 2012 at 12:50 PM, Gene Leynes wrote: > I would like to suggest that there is some documentation missing from > strptime. > > There appears to be a way to show second decimal

Re: [R] arrangement

2012-04-16 Thread R. Michael Weylandt
He's saying it looks like you need to transpose your matrix with the t() function -- documentation can be attained by typing ?t at the console -- and that you'll need to subset to get the rows you want. It's not quite clear to us which order your rows are actually in because you sent HTML email whi

Re: [R] Installation of R 2.15.0

2012-04-16 Thread R. Michael Weylandt
Certainly in theory, though the CRAN installers might over-write the old version automatically. [I'm pretty sure they do for mac, don't know about Windows] The way to ensure both versions remain will depend on the OP's unstated OS. Michael On Mon, Apr 16, 2012 at 6:57 AM, ya wrote: > Hi Partha,

Re: [R] Displayed Date Format in Plot Title.

2012-04-13 Thread R. Michael Weylandt
as.Date() attemps to coerce a character string to a date where you specify the input format -- if you want to specify an output format, you need ?strftime [str + f + time == string format time] E.g., titleDate <- as.Date("2011-05-03", format = "%Y-%m-%d") plot(1:10, main = strftime(titleDate, "%

Re: [R] Help with vectorization

2012-04-12 Thread R. Michael Weylandt
Strange, that isn't the error I get: > mouter(wl, k1, k2, k3, FUN = function(w, k1, k2, k3) k1 *exp(k2 / (w + k3))) Error in FUN(X, Y, ...) : argument "k2" is missing, with no default Still, it's a problem with my mouter() function which was only tested on binary operators (and then only really

Re: [R] How to automate creation of plots (create series of plots)

2012-04-12 Thread R. Michael Weylandt
I'm not quite sure what you are asking -- when you say an XY plot I presume you mean a scatter plot of X against Y, but how do the values underneath the headers play in? Do you just want different symbols? With a little bit of data wrangling, I think this actually seems quite well suited to the gg

Re: [R] Applying a function to categorized data?

2012-04-12 Thread R. Michael Weylandt
You can also get the official getting started tutorial by typing help.start() at the command prompt. Michael On Thu, Apr 12, 2012 at 2:52 PM, steven mosher wrote: >  Welcome to R and the list. > >  Others may suggest books ( Nutshell was my first ) but first there are > some things that will h

Re: [R] Simple Problem: Plotting mathematical functions

2012-04-12 Thread R. Michael Weylandt
It seems that your first problem is syntax: 2x will thrown an error, while 2*x won't. Google around for a good intro tutorial (there's the main one you can access by typing help.start() and it's quite good) and these sorts of things will be explained. You might also want to use the curve func

Re: [R] Help with vectorization

2012-04-12 Thread R. Michael Weylandt
Perhaps ?outer -- well, not outer directly, but a multivariate outer -- I keep this one around for personal use: `mouter` <- function(..., FUN = "*"){ dotArgs <- list(...) FUN <- match.fun(FUN) if(length(dotArgs) == 1L) return(unlist(dotArgs)) if (length(dotArgs) == 2L)

Re: [R] Organizations where IT has approved the use of R software

2012-04-12 Thread R. Michael Weylandt
Slightly on topic, just yesterday, the CFPB announced they'll be using R in their work: http://blog.revolutionanalytics.com/applications/ Depending on the scale of your organization, it may not be the open-source nature that's quite the problem of the "IT Gang" but rather the support (or lack ther

Re: [R] number of warnings

2012-04-12 Thread R. Michael Weylandt
Just a joke -- since you post through Nabble instead of being a list subscriber, the vast majority of us didn't see your original post and instead only saw your "cry for help" Michael On Thu, Apr 12, 2012 at 10:08 AM, helin_susam wrote: > Sorry, I did not understand. What does it mean " call 999

Re: [R] Definition of "lag" is opposite in ts and xts objects!

2012-04-11 Thread R. Michael Weylandt
Yes, this is as documented. See ? lag.xts under details for the justification and how to change the default if desired. Michael On Wed, Apr 11, 2012 at 11:13 PM, jpm miao wrote: > BTW, zoo is like ts in the application of lag. > In other words, zoo and xts are opposite in this issue. > > 2012/4/

Re: [R] r graphing

2012-04-11 Thread R. Michael Weylandt
k you so much.. > > is it possible to make arrows show up at the end of axis.. and make > numberings show up in the middle axis?? > > From: R. Michael Weylandt > To: John Kim ; r-help > Sent: Wednesday, April 11, 2012 4:06 PM > Subject: Re: [R] r graphing > > Alternativel

Re: [R] r graphing

2012-04-11 Thread R. Michael Weylandt
Alternatively, you can use curve(x^3, from = -5, to = 5); abline(h = 0, v = 0, lty = 2) which will work even if the axes aren't in the middle of the image. Michael On Wed, Apr 11, 2012 at 6:54 PM, R. Michael Weylandt wrote: > Please reply all to the list and don't send HTML.

Re: [R] r graphing

2012-04-11 Thread R. Michael Weylandt
can realize that?? > > john > > > From: R. Michael Weylandt > To: John Kim > Cc: r-help@r-project.org; provicon2...@yahoo.com > Sent: Wednesday, April 11, 2012 2:37 PM > Subject: Re: [R] r graphing > > The easiest way is to just use ?curve (type ?curve at the p

Re: [R] r graphing

2012-04-11 Thread R. Michael Weylandt
The easiest way is to just use ?curve (type ?curve at the prompt to get documentation for curve): e.g., curve(x^3, from = -5, to = 5) You could also build the plot yourself like: x <- seq(-5, 5, length.out = 200) y <- x^3 plot(x,y) Michael On Wed, Apr 11, 2012 at 4:41 PM, John Kim wrote: > ca

Re: [R] multicore/mcparallel error

2012-04-11 Thread R. Michael Weylandt
le to find one. > > Is there an mclapply included in 2.15?  Is there a parallel package I'm > missing?  Or am I completely misunderstanding your response? > > Thanks! > > Wyatt > > -Original Message- > From: R. Michael Weylandt [mailto:michael.weyla...

Re: [R] 7 arguments passed to .Internal(identical) which requires 6

2012-04-11 Thread R. Michael Weylandt
Can you give the line of code that gives the error? That'd make it much easier to see what's there that should/shouldn't be. Michael On Wed, Apr 11, 2012 at 11:28 AM, krtek wrote: > Thank you!  Updating to R-patched really helped me. > > My problem were not been into my code. I've tried to run s

Re: [R] inference for customized regression in R?

2012-04-11 Thread R. Michael Weylandt
e answers: http://stats.stackexchange.com/questions/26277/how-to-bootstrap-prediction-intervals-for-customized-regression-models-in-r Michael Weylandt On Wed, Apr 11, 2012 at 10:29 AM, Michael wrote: > Hi all, > > Are there functions in R that could help me do the following? > > We have a special type

Re: [R] Merging multiple .csv files

2012-04-11 Thread R. Michael Weylandt
Simply pass all = FALSE to merge_all merge_all(list_of_files, by = "Name", all = FALSE) Michael On Wed, Apr 11, 2012 at 1:09 AM, Chintanu wrote: > Thanks to David and Michael > > Michael: > > That works, however with a glitch. Each of my 24 files has got two columns: > "Name", and "Rank/score".

Re: [R] 7 arguments passed to .Internal(identical) which requires 6

2012-04-11 Thread R. Michael Weylandt
Well, obviously the interface to .Internal(identical) changed between 2.13.x and 2.15 -- as, ?.Internal says: Only true R wizards should even consider using this function... Anyways, find where you use it in your script and then we can help -- there's not much we can do without seeing the relevant

Re: [R] What is a better way to deal with lag/difference and loops in time series using R?

2012-04-11 Thread R. Michael Weylandt
this: >    xts<-as.ts(x) >    y1<-ts(NA, start=start(y), end=end(y),frequency=frequency(y)) >    y<-as.xts(y1) > >    Is there any easier way to do it? > >    Thanks > > miao > > > 2012/4/11 R. Michael Weylandt >> >> Two ways around this:

Re: [R] Merging multiple .csv files

2012-04-10 Thread R. Michael Weylandt
Your problem is that you can't merge the file names, but you need to load them into R and merge the resulting objects. This should be straightforward enough to do: file_list <- list.files() list_of_files <- lapply(file_list, read.csv) # Read in each file merge_all(list_of_files, by = "Name") Mic

Re: [R] Error using return() function inside for loop and if statement

2012-04-10 Thread R. Michael Weylandt
ruinf(1)    { >       return(num1) >    }else{ >       return(num2) >    } > } > > And then, run 20 iterations of the function. > > On Tue, Apr 10, 2012 at 11:26 PM, R. Michael Weylandt > wrote: >> >> The error message should make it pretty clear -- you are

Re: [R] plot 2 graphs on the same x-y plane

2012-04-10 Thread R. Michael Weylandt
You were told before this isn't a Mac question so please don't cc R-SIG-Mac. I'm not sure what this bit of your reply means "My question is to find any command to plot the data I got from the field;" but your reply later suggests that your problem is that you are overriding previous plots on a giv

Re: [R] What is a better way to deal with lag/difference and loops in time series using R?

2012-04-10 Thread R. Michael Weylandt
Two ways around this: I = Easy) Just use zoo/xts objects. ts objects a real pain in the proverbial donkey because of things like this. Something like: library(xts) PI1.yq <- as.xts(PI1) # Specialty class for quarterly data (or regular zoo works) lag(PI1.yq) II = Hard) lag on a ts actually chang

Re: [R] plot 2 graphs on the same x-y plane

2012-04-10 Thread R. Michael Weylandt
This is the same malformatted message you posted on R-SIG-Mac even after David specifically asked for clarification not to reward bad behavior, but perhaps this will enlighten: # Minimal reproducible data! x <- runif(15, 0, 5) y <- 3*x - 2 + runif(15) dat <- data.frame(x = x, y = y) rm(list =

Re: [R] Error using return() function inside for loop and if statement

2012-04-10 Thread R. Michael Weylandt
The error message should make it pretty clear -- you aren't inside a function so you can't return() a value which is, by definition, what functions (and only functions) do.** Not sure there's a great reference for this though beyond the error message Incidentally, what are you trying to do her

Re: [R] R2.11.1 seq.int difference between by and length.out

2012-04-10 Thread R. Michael Weylandt
So it's a machine/OS issue: if you really want to trace it down, take a look here: http://svn.r-project.org/R/trunk/src/main/seq.c seq.int() in R goes to do_seq() in C, but at this point it's probably best to identify it as floating-point gremlins and to work around. Michael On Tue, Apr 10, 2012

Re: [R] multicore/mcparallel error

2012-04-10 Thread R. Michael Weylandt
I don't know the multicore package, but if possible, it might be easier to upgrade to 2.15 and use the new built-in parallel package that was introduced in R 2.14. Then your syntax would be something like mclapply(files, illumqc) Michael On Tue, Apr 10, 2012 at 11:33 AM, Wyatt McMahon wrote: >

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread R. Michael Weylandt
   b > 3      3      c > >> df$chaVec > [1] "a" "b" "c" > > documentation of data.frame says the option is true by default. > > > Am 10.04.2012 um 17:38 schrieb R. Michael Weylandt: > >> Don't use cbind() -- it forces everythi

Re: [R] R2.11.1 seq.int difference between by and length.out

2012-04-10 Thread R. Michael Weylandt
What difference is it you are worried about:? identical(seq.int(0,1,length.out = 11), seq.int(0,1, by = 0.1)) # TRUE Though that may be OS dependent. M On Tue, Apr 10, 2012 at 10:51 AM, Alexander wrote: > > Berend Hasselman wrote >> >> On 10-04-2012, at 15:54, Alexander wrote: >> >>> I am work

Re: [R] Error: cannot allocate vector of size...

2012-04-10 Thread R. Michael Weylandt
You probably have more objects in your workspace than you did previously. Clean them out (or just use a new R session) and things should go back to normal. You might also want to follow up on the help(memory.size) hint though -- doesn't Windows impose a memory limit unless you ask it for more? Mi

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread R. Michael Weylandt
Don't use cbind() -- it forces everything into a single type, here string, which in turn becomes factor. Simply, data.frame(a, b, c) Like David mentioned a few days ago, I have no idea who is promoting this data.frame(cbind(...)) idiom, but it's a terrible idea (albeit one that seems to be very

Re: [R] Creating a loop with an indefinite end term

2012-04-10 Thread R. Michael Weylandt
You might want to use a while loop instead, something like: while(TRUE){ # Do things # Test: if your condition has occured if(conditionHappened) break # break will end loop. } Michael On Tue, Apr 10, 2012 at 10:48 AM, Steve Lavrenz wrote: > Everyone, > > I'm very new to R, especially when

Re: [R] plyr: set '.progress' argument to default to "text"

2012-04-10 Thread R. Michael Weylandt
You might try the Defaults package. Michael On Tue, Apr 10, 2012 at 10:54 AM, Liviu Andronic wrote: > Dear all > Is it possible to set globally the option .progress = "text" to all > the apply functions in 'plyr'. For example, current default is > daply(..., .progress = "none"). I would like to

Re: [R] plotting multiple plot in same graph

2012-04-10 Thread R. Michael Weylandt
A slightly easier formulation of the second proposal from Jessica: plot(c(0,0) , xlim = range(x1, x2, x3), ylim = range(y), type = "n") will set the canvas correctly. On Tue, Apr 10, 2012 at 10:10 AM, Jessica Streicher wrote: > Hello Arunkamar! > > Basically: > > plot(x1,y) > lines(x2,y) > line

Re: [R] how to save multiple work space

2012-04-10 Thread R. Michael Weylandt
ifferent R image file? > > > > On 2012-4-10 14:54, R. Michael Weylandt wrote: >> >> You'll need to save them manually to avoid name conflicts -- save.image() >> is the function to do so but you need to give a file name. >> >> Michael >> >&g

Re: [R] how to save multiple work space

2012-04-10 Thread R. Michael Weylandt
You'll need to save them manually to avoid name conflicts -- save.image() is the function to do so but you need to give a file name. Michael On Apr 10, 2012, at 7:41 AM, ya wrote: > Hi guys, > > I have a question. I am running 3 R sessions simultaneously for different > analysis. I found ou

Re: [R] quantmod getOptionChain Not Work

2012-04-09 Thread R. Michael Weylandt
ks for this.  I tried to figure out how to download that > version, but found the documentation on SVN's quite confusing.  Is there > anyway that you could make that version available? > > Much appreciated. > --John Sparks > > > > On Fri, March 23, 2012 5:55 pm, R. M

Re: [R] Comparing 2 means. pls help

2012-04-09 Thread R. Michael Weylandt
You should look up what a t-test is. Michael On Mon, Apr 9, 2012 at 2:58 AM, ali_protocol wrote: > I am interested in the difference of 2 data: > > mat1= c(2.2, 2.3, 2.2,2.5) > mat2= c(2.6, 2.8, 2.7,2.4) > > mat= mat2-mat1 > > I perform an action on both mat1 and mat2, and I get > mat1prime and

Re: [R] newbie question: strategy

2012-04-08 Thread R. Michael Weylandt
Just a heads up: I'm pretty sure Josh and the other QS developers have access to intra-day data, but they can't provide an example using it in the package because the EULAs of most data providers won't allow direct redistribution of their data. The examples included all go online and download data

Re: [R] R help

2012-04-07 Thread R. Michael Weylandt
This is, more often that not, statistically speaking a bad idea: you're likely to get a false positive (https://xkcd.com/882/) But it sounds like something along these lines should work for you to get the models : x <- data.frame(rnorm(50), rnorm(50), rnorm(50), rnorm(50)) m <- vector("list", nco

Re: [R] How do I get a rough quick utility plot of a time series?

2012-04-07 Thread R. Michael Weylandt
One last try -- though if you cannot figure out how to take the name of your object and put it in dput( NameOfObjectGoesHere ) after I gave you a worked example of how to do so, it seems unlikely that this will help: # Attempt to recreate your data library(zoo) x <- read.zoo(textConnection("monoMn

Re: [R] pause code in R code?

2012-04-07 Thread R. Michael Weylandt
Are you sure you are executing that line of code? Michael On Sat, Apr 7, 2012 at 9:18 AM, Hurr wrote: > readline("press return to continue") > worked as a pause until I used it in 4 places in a different program where > none of them wait. > What problem do I look for? > > > -- > View this me

Re: [R] newbie question: strategy

2012-04-07 Thread R. Michael Weylandt
So you want us to deliver an entire backtesting architecture for you? That's a pretty hefty request... But being R, it's already been done. This has all basically been made available in the quantstrat project (google it) -- the documentation is online and you can see lots of worked examples in the

Re: [R] How do I get a rough quick utility plot of a time series?

2012-04-06 Thread R. Michael Weylandt
This still isn't reproducible -- when I said use dput() I meant it. x <- data.frame(x = 1:5, y = letters[1:5], z = factor(sample(1:3,5, TRUE))) # complicated dput(x) # Easy to copy and paste. Also, what package is the linearizeTime function from? I'm having trouble finding it on CRAN. If you can

Re: [R] Converting data frame to its object results in matrix of strings

2012-04-06 Thread R. Michael Weylandt
Try this: x <- xts(as.character(1:10), Sys.Date() + 0:9) storage.mode(x) <- "double" Michael On Fri, Apr 6, 2012 at 1:13 PM, Noah Silverman wrote: > Hi, > > I have a rather large data frame (500 x 5000) that I want to convert to a > proper xts object. > > I am able to properly generate an xts

Re: [R] avoiding for loops

2012-04-06 Thread R. Michael Weylandt
Usually you can just use cor() and it will do all the possibilities directly: x <- matrix(rnorm(100), ncol = 10) cor(x) But that works on the columns, so you'll need to transpose things if you want all possible row combinations: cor(t(x)) Hope this helps, Michael On Fri, Apr 6, 2012 at 9:57 AM,

Re: [R] Order sapply

2012-04-06 Thread R. Michael Weylandt
On Fri, Apr 6, 2012 at 10:27 AM, MSousa wrote: > Good Afternoon, > >   I have the following code, but it seems that something must be doing > wrong, because it is giving the results I want. Didn't someone else have that problem just a few weeks ago? :-P Michael > The idea is to create segments

Re: [R] producing vignettes

2012-04-05 Thread R. Michael Weylandt
Probably to pull down the source of one and study it directly: if you already know LaTeX and R, Sweave isn't much more to master: zoo does vignettes nicely, but any package with vignettes should be pretty good. Michael On Thu, Apr 5, 2012 at 4:33 PM, Erin Hodgess wrote: > Hi R People: > > What i

Re: [R] Best way to search r- functions and mailing list?

2012-04-05 Thread R. Michael Weylandt
http://www.rseek.org/ perhaps. [Take a look at the tabs on the RHS after you do a search] Michael On Thu, Apr 5, 2012 at 11:36 AM, Jonathan Greenberg wrote: > R-helpers: > > It looks like http://finzi.psych.upenn.edu/search.html has stopped > spidering the mailing lists -- this used to be my go-

Re: [R] Using download.file() to grab information from a Password Protected Website

2012-04-04 Thread R. Michael Weylandt
Authenticated access is sometimes a little harder than a simple download -- the RCurl package provides tools that will be helpful, but you'll need to tailor things to the sort of authentication used on the other end. getURL iprovides one example of password authentication in the examples. If you ar

Re: [R] How do I get a rough quick utility plot of a time series?

2012-04-04 Thread R. Michael Weylandt
Give a reproducible example (use dput()) and someone will be able to help you. Otherwise, we're just guessing at what your data looks like. Also, ?plot or ?matplot might help. Particularly, see the second example for matplot. It might be what you are looking for. A lesson of all this is though, p

Re: [R] spaghetti plots in R

2012-04-04 Thread R. Michael Weylandt
Can't you just combine your matrices into a single matrix: rbind() or cbind() should do the job. Michael On Wed, Apr 4, 2012 at 12:24 PM, uday wrote: > Hi Liviu , > now I can see that function but the problem is that its only applicable for > single data frame. as I wrote in my first post that I

Re: [R] plot with a regression line(s)

2012-04-04 Thread R. Michael Weylandt
I'm not sure what your definition of easier would be, but there are some style things you might want to be aware of: I) the name is likely to hit up against the S3 generic plot() when applied to a glm object. This might lead to strange bugs at some point. II) you can test !is.null once and use

Re: [R] filling small gaps of N/A

2012-04-04 Thread R. Michael Weylandt
No problem -- best of luck with it: the zoo package is one of the best documentation-wise and I'd advise you to look at the available vignettes when you have time. Vignettes are extended documentation included in some packages that give a more systematic presentation than can be given in the help

Re: [R] CSPADE error: system invocation error

2012-04-03 Thread R. Michael Weylandt
> [4] lattice_0.20-0 > > loaded via a namespace (and not attached): > [1] grid_2.14.2 tools_2.14.2 >> > -Original Message- > From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] > Sent: Wednesday, 4 April 2012 2:35 PM > To: Sue Xu > Cc:

Re: [R] CSPADE error: system invocation error

2012-04-03 Thread R. Michael Weylandt
It works fine for me: can you give sessionInfo()? Michael On Tue, Apr 3, 2012 at 9:27 PM, Sue Xu wrote: > Hi, > > I am trying to use the CSPADE function as part of the ArulesSequences > package. When running with my own data I get a system invocation error, and > also get the same when running

Re: [R] A introductory question about Zips law (Newbie to statistics)

2012-04-03 Thread R. Michael Weylandt
The zipfR package might be of help to you Michael On Sat, Mar 31, 2012 at 2:03 AM, ali_protocol wrote: > Hi everyone. > > Newbie to statistics. > > I have 40 matrices of ~400 values. how may I determine whether the > distribution follows zips law? > > response <-sample (1:20,400*4, replace= TRUE

Re: [R] Create Model Object (setClass?setMethod?)

2012-04-03 Thread R. Michael Weylandt
Setting a class is quite easy if you are in the S3 (read: easier) system: x <- 1:15 class(x) <- "YourClass" summary.YourClass <- function(x, ...) cat("The mean of your object is ", mean(x), "\n") summary(x) Michael On Tue, Apr 3, 2012 at 12:54 PM, casperyc wrote: > Hi all, > > I have a self w

Re: [R] grouping

2012-04-03 Thread R. Michael Weylandt
Please take a look at my first reply to you: ave(y, findInterval(y, quantile(y, c(0.33, 0.66 Then read ?ave for an explanation of the syntax. ave takes two vectors, the first being the data to be averaged, the second being an index to split by. You don't want to use split() here. Michael On

Re: [R] np package problem

2012-04-03 Thread R. Michael Weylandt
You need to load it once per session with library(np) Michael On Tue, Apr 3, 2012 at 2:46 PM, dnewbold wrote: > Hi, Im trying to run a non parametric regression and I wish to use function > npreg(), I installed the np package, but I am being told that npreg doesnt > exist. Any advice on how I co

Re: [R] filling small gaps of N/A

2012-04-03 Thread R. Michael Weylandt
Like I said in my followup, please pass the maxgap argument: i.e., na.approx(x, maxgap = 4) x <- zoo(1:20, Sys.Date() + 1:20) x[2:4] <- NA # Short run of NA's x[10:16] <- NA # Long run of NA's na.approx(x) # All filled in na.approx(x, maxgap = 4) # Only the short one filled in Michael On Tue,

<    5   6   7   8   9   10   11   12   13   14   >