Re: [R] i need help in documentation

2012-07-05 Thread R. Michael Weylandt
R does not, to my knowledge, have anything quite like Python's docstrings (which seems to be what you are talking about) but you might look at Roxygen2 on CRAN which should get you started in this direction. Best, Michael On Thu, Jul 5, 2012 at 7:37 AM, purushothaman purushothama...@ge.com

Re: [R] vector entry in matix

2012-07-05 Thread R. Michael Weylandt
It is possible to put dimensionality on a list (i.e., a generic vector), which might be what you're looking for. x - list(1:4, letters[1:4], function(x,y) x + y, rnorm(50)) dim(x) - c(2,2) x[[1,2]] x[[2,2]] x[[3,2]] # Error Best, Michael On Thu, Jul 5, 2012 at 8:19 AM, Thomas C.

Re: [R] 7 days confusion over lists

2012-07-05 Thread R. Michael Weylandt
Could you make a reproducible example? [http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example] I can't run any of your code as is. A few comments inline. On Thu, Jul 5, 2012 at 9:44 AM, Wageningen-eR igor.milosavlje...@wur.nl wrote: Hello, I am a Masters student

Re: [R] skipped correlation

2012-07-05 Thread R. Michael Weylandt
library(sos) findFun(scor) will get you going in the right direction but I'm not sure I see a scor function (I presume you're looking for the robust correlation metric). Do you have a citation for such a function? For a work around, robust::covRob gives robust covariance which possibly could be

Re: [R] reshape2 errors on data frame

2012-07-05 Thread R. Michael Weylandt michael.weyla...@gmail.com
On Jul 5, 2012, at 1:28 PM, Rich Shepard rshep...@appl-ecosys.com wrote: On Thu, 5 Jul 2012, Rich Shepard wrote: I wonder if the issue is with the logical columns; I've not used them before, only dates, factors, and numerals. I'll try without the logicals and see if there's a difference.

Re: [R] Silencing the output of install.packages()

2012-07-05 Thread R. Michael Weylandt
On Thu, Jul 5, 2012 at 1:03 PM, craigcitro craigci...@gmail.com wrote: Is there a way to suppress the output of 'install.packages()'? I have seen that the 'download.file' function has a 'quiet' option but I do not know how to use it. I do not see any good reason to allow that. A user should

Re: [R] loop in list

2012-06-30 Thread R. Michael Weylandt michael.weyla...@gmail.com
I might think replicate() is slightly more idiomatic, but I'm not in a position to check if simplify=FALSE will keep a list. Best, Michael On Jun 30, 2012, at 7:13 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, You can avoid the loop using lapply. f - function(x) sample(100, 10)

Re: [R] Nested For Loop

2012-06-29 Thread R. Michael Weylandt michael.weyla...@gmail.com
Don't (can't) use paste0 with sep='' -- that's redundant, and I'm surprised not an error. Michael On Jun 29, 2012, at 7:18 PM, arun smartpink...@yahoo.com wrote: Hi, I knew that you already got many replies. Here is my contribution.

Re: [R] File Handling in R

2012-06-28 Thread R. Michael Weylandt michael.weyla...@gmail.com
Take a look at scan and/or readLines Michael On Jun 28, 2012, at 9:02 AM, HIMANSHU MITTAL hm3...@gmail.com wrote: Hello all, I have a txt file with some data which isn't in any organized form like a table, but just simple text. Is there any way to read the file char by char and store the

Re: [R] Extract upper case letters

2012-06-27 Thread R. Michael Weylandt
How do you want your output? If you want a character vector of lowercase letters, just use gsub([^::A-Z::],, t) to substitute for all non-uppercase characters. strsplit() can lead you to a vector of the single-letter upper case letters. Best, Michael On Wed, Jun 27, 2012 at 2:15 PM, mdvaan

Re: [R] graph with two different arithmetic scales

2012-06-27 Thread R. Michael Weylandt
take a look at library(zoo) example(plot.zoo) which shows one way to do this, Best, Michael On Wed, Jun 27, 2012 at 6:50 PM, denissearchundia denissearchun...@yahoo.com.mx wrote: hi i try to do a graph who shows 2 time series at the same time thanks! -- View this message in context:

Re: [R] qplot and colors (Please Help)

2012-06-27 Thread R. Michael Weylandt
Hi David, I believe you left out saying what color scheme you would prefer, so it's hard to help, but you might be a start by looking at the appropriate parts of Hadley's website here: http://had.co.nz/ggplot2/, particularly the scales section. Best, Michael On Wed, Jun 27, 2012 at 11:07 AM,

Re: [R] question about formatting Dates

2012-06-26 Thread R. Michael Weylandt
On Tue, Jun 26, 2012 at 10:54 PM, Erin Hodgess erinm.hodg...@gmail.com wrote: Dear R People: I have dates as factors in the following: poudel.df$DATE [1] 1/2/2011  1/4/2011  1/4/2011  1/4/2011  1/6/2011  1/7/2011  1/8/2011 [8] 1/9/2011  1/10/2011 Levels: 1/10/2011 1/2/2011 1/4/2011

Re: [R] A solution for question about formatting Dates

2012-06-26 Thread R. Michael Weylandt
Please don't change subject lines for follow-on comments. It messes up threading in most readers: e.g., https://stat.ethz.ch/pipermail/r-help/2012-June/thread.html Michael On Tue, Jun 26, 2012 at 11:57 PM, Erin Hodgess erinm.hodg...@gmail.com wrote: Hello again: Here is a solution to the

Re: [R] Questions about doing analysis based on time

2012-06-25 Thread R. Michael Weylandt
On Fri, Jun 22, 2012 at 3:45 PM, APOCooter mikeedinge...@gmail.com wrote: [snip and rearrange] try to put your data in a proper time series class (zoo/xts if I might give a personal-ish plug) which will make all these calculations much easier. I thought that's what I was doing with

Re: [R] Defining multiple variables in a loop

2012-06-24 Thread R. Michael Weylandt
To elaborate on what Bert said: Lists are a variable length data structure which can hold most anything (even other lists) in them and are a great way to organize the sort of data you're working with. You can think of them as generic vectors. You can assign them names and access/subset them by

Re: [R] Can't save a plot

2012-06-23 Thread R. Michael Weylandt
Are you sure it's not working? That's exactly what the console is supposed to display (the message means you've switched from the jpeg _to_ the null device) -- check again to make sure the file wasn't created -- I think you'll be pleasantly surprised. If you're not sure where to check, look in

Re: [R] Questions about doing analysis based on time

2012-06-22 Thread R. Michael Weylandt
On Fri, Jun 22, 2012 at 2:18 PM, John Kane jrkrid...@inbox.com wrote: Hi and welcome to the R-help list. It would be much better for readers to get your data in a more easily used format. There is a function called dput() that will output your data in a way that R can read easily. We

Re: [R] problem with loading the dynamic object(.so file) inside a R package

2012-06-22 Thread R. Michael Weylandt
I believe that useDynLib() in the NAMESPACE file should do it for you. Best, Michael On Fri, Jun 22, 2012 at 1:36 PM, xuan zhao xuan.z...@sentrana.com wrote: I have built a R package including the C code. My question is: Can the shared object get loaded automatically as we load the R package?

Re: [R] dropping variables from a data frame inside a function

2012-06-22 Thread R. Michael Weylandt
I think the OP might also be tripped up on the fact that R is pass-by-value so effects on df inside DropLikeSAS won't have impact outside the function's scope. The df inside of DropLikeSAS() is changed as expected, but that has no effect on the df outside that function. To the OP: There are ways

Re: [R] apply() function: margin argument: 2L versus 2

2012-06-22 Thread R. Michael Weylandt
On Fri, Jun 22, 2012 at 5:53 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, 2L is an integer, 2 might be or not. In the case of apply(), there is no difference. All possible values for margin? Any possible(*) combination of the dimensions of 'x' in apply(x, margin, function) (*)

Re: [R] Uniroot error message with in intergration

2012-06-22 Thread R. Michael Weylandt
On Fri, Jun 22, 2012 at 4:00 PM, jeka12386 jeka12...@hotmail.co.uk wrote: Dear all I am trying to calculate the value of n using uniroot.  Here is the message I am having: Error in uniroot(integ, lower = 0, upper = 1000, n) :  'interval' must be a vector of length 2 Please  would you

Re: [R] Variance with confidence interval

2012-06-22 Thread R. Michael Weylandt
On Fri, Jun 22, 2012 at 5:13 AM, Mohan Radhakrishnan moh...@fss.co.in wrote: Hi,      Is there a way to calculate variance directly by specifying confidence interval using R ? I am specifically asking because I wanted to investigate how this could be useful for project schedule variance

Re: [R] Distribution and location scale family

2012-06-21 Thread R. Michael Weylandt
This has the distinctive sound of homework and we unfortunately can't help with that. You might want to look at fitdistr in the MASS package though. Best of luck to you though, Michael On Thu, Jun 21, 2012 at 7:10 AM, Noor.v.d.Assem noor.v.d.as...@gmail.com wrote: Hi, For some dataset I have

Re: [R] Function for testing

2012-06-21 Thread R. Michael Weylandt
Hi, this has the distinctive sound of homework, so I hesitate to give too much help, but two things I note immediately. In defining resx / resy (good preallocation!) you probably mean n instead of N. A standard way to check how often a condition occurs is something like: x - rnorm(50) mean(x

Re: [R] R crashes with kud-kernelUD(data, h=LSCV) script

2012-06-21 Thread R. Michael Weylandt
Hi Amanda, I can't reproduce this without your data set. Would it be possible for you to give us dput(head(data, 20)) if you need further help? Also, if you could supply the output of sessionInfo()? That's often helpful for anything that crashes [that term means many things to different people

Re: [R] R function similar to gradient function in Matlab?

2012-06-21 Thread R. Michael Weylandt michael.weyla...@gmail.com
I don't have a Matlab license or enough experience with it to know what gradient does, but I know there's a Matlab-to-R dictionary out there that many folks find helpful. It might have what you need (or just be generally useful). http://cran.r-project.org/doc/contrib/Hiebeler-matlabR.pdf Not

Re: [R] Package for Jump detection

2012-06-21 Thread R. Michael Weylandt
This might be a question more suited for the R-SIG-Finance list. Best, Michael On Wed, Jun 20, 2012 at 3:44 AM, rahul deora rahulsparx2...@gmail.com wrote: Dear All, Are there any packages in R to carry out the jump detection test and find the jump sizes and its its time of occurence on high

Re: [R] binary operators that never return missing values

2012-06-20 Thread R. Michael Weylandt
Hi Anthony, No, I don't believe this exists on CRAN already (happy to be proven wrong though) but I might suggest you approach things a different way: instead of defining this operator by operator with infix notation, why not go after `+`, `` directly? If you put a class on your vectors, you can

[R] Going backwards through plot panels

2012-06-20 Thread R. Michael Weylandt
R-helpers, I'm looking to set up multi-screen plots with layout() or par(mfrow/mfcol = ) but I'm not sure if there's an easy way to go backwards among the panels. E.g. layout(1:2) plot(1:4) plot(1:8) Here I'd like to put some more on the 1:4 plot (e.g., some points or a line or a legend) but

Re: [R] binary operators that never return missing values

2012-06-20 Thread R. Michael Weylandt
. Michael Weylandt michael.weyla...@gmail.com wrote: Hi Anthony, No, I don't believe this exists on CRAN already (happy to be proven wrong though) but I might suggest you approach things a different way: instead of defining this operator by operator with infix notation, why not go after

Re: [R] Going backwards through plot panels

2012-06-20 Thread R. Michael Weylandt
On Wed, Jun 20, 2012 at 4:46 PM, Richard M. Heiberger r...@temple.edu wrote: ?par read about mfg which allows you to index into the arrangement set by mfrow and mfcol Rich On Wed, Jun 20, 2012 at 5:27 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: R-helpers, I'm looking to set

Re: [R] How to calculate values with percent sign imported from Excel?

2012-06-20 Thread R. Michael Weylandt michael.weyla...@gmail.com
Something like: X - as.character(data.name) X - as.double(gsub(%,, X))/100 mean(X) quantile(X) etc. Untested [I'm not at my computer so the args for gsub() might be out of order] but one possible solution pattern. Michael On Jun 20, 2012, at 8:26 PM, C W tmrs...@gmail.com wrote: Hi R

Re: [R] Analyzing 2008 ANES using the weight variable

2012-06-19 Thread R. Michael Weylandt
Most modelling functions take a weights= argument so once you decide what sort of model you are looking for, that should be the way to proceed. But do be forewarned that there are a few kinds of weights in statistics and it's not standardized which is the default across different statistical

Re: [R] checking the validity of the expressions

2012-06-18 Thread R. Michael Weylandt
What does any of this mean? Can you give a concrete example of the transformation you hope to accomplish? Michael On Mon, Jun 18, 2012 at 3:10 AM, arunkumar akpbond...@gmail.com wrote: hi I have a data and have to convert it into the given expression like data=1000:2000 and

Re: [R] Package of EM and MI for IRT in R

2012-06-18 Thread R. Michael Weylandt
Possibly Amelia: http://cran.r-project.org/web/packages/Amelia/index.html Best, Michael On Mon, Jun 18, 2012 at 3:19 AM, Kamontip Srihaset kamonti...@student.chula.ac.th wrote: Dear all members, I am Phd. candidate student at Chulalongkorn U., Thailand. I am interested in expectation

Re: [R] Inconsistency using seq

2012-06-18 Thread R. Michael Weylandt michael.weyla...@gmail.com
No, this is rather the nature of floating point calculations. You may perhaps be looking for ?all.equal or R FAQ 7.31 (I think that's the one) which is google-able. It's a complicated subject, but those should get you started. Best, Michael On Jun 18, 2012, at 2:58 PM, hamoreno

Re: [R] Trying to speed up an if/else statement in simulations

2012-06-18 Thread R. Michael Weylandt
I might try something like: data[data$flag1 == 1, flag2] - runif(sum(data$flag1 == 1)) 0.95 and similarly for the other case. Hope this helps, Michael On Mon, Jun 18, 2012 at 12:29 PM, nqf n.j.frank...@pgr.reading.ac.uk wrote: Dear R-help, I am trying to write a function to simulate

Re: [R] Error w/ Start up Script

2012-06-18 Thread R. Michael Weylandt
You are perhaps not using suppressPackageStartupMessages() correctly if you're getting those warnings: my .Rprofile has these lines: suppressPackageStartupMessages(library(quantmod)) suppressPackageStartupMessages(library(ggplot2)) suppressPackageStartupMessages(library(lattice)) but produces no

Re: [R] Changing many csv files using apply?

2012-06-18 Thread R. Michael Weylandt
sapply() won't be notably faster. What you might try (no guarantee) is wrapping things up as if you were going to use sapply() but instead use mclapply() from the parallel package -- that will parallelize the results and should be faster by roughly as many cores as you use. The no guarantee

Re: [R] how to get help for a package. Thanks!

2012-06-18 Thread R. Michael Weylandt
The help function in R is just that -- a function -- so you have to invoke it, e.g., as help(mean) rather than just typing Help. You might also try help.start() which opens a fuller help system in your browser. To see the available functionality of the package, the easiest way is to check its

Re: [R] How to save my result with Loops

2012-06-17 Thread R. Michael Weylandt
Short answer: don't. R is built around vectors and lists. Trying to put individual variates in their own scalar variables is almost always a bad idea. Long answer: you can do it with assign() but I won't tell you how in light of my short answer. Michael On Sun, Jun 17, 2012 at 8:30 AM, Cassie

Re: [R] FW: Multivariate Normal and loops

2012-06-17 Thread R. Michael Weylandt
It's requested to cc the list on our back-and-forths so that i) you can get help faster (I was moving all yesterday and it's a Hallmark holiday in the US today) since others may respond; ii) others can benefit by reading the archives. On Sun, Jun 17, 2012 at 4:34 AM, Giulia Motta

Re: [R] Multi-threads in R

2012-06-17 Thread R. Michael Weylandt michael.weyla...@gmail.com
Take a look at the parallel package which ships with all current versions of R. Michael On Jun 17, 2012, at 11:39 AM, Gary Dong pdxgary...@gmail.com wrote: Dear R users, I'm wonder if there is a easy way to make R use multi-CPUs on my computer. My computer has four CPUs but R uses only

Re: [R] Multi-threads in R

2012-06-17 Thread R. Michael Weylandt
at 1:23 PM, Gary Dong pdxgary...@gmail.com wrote: Thanks for all replied. I read the introduction of R parallel. Is it for loops only? Gary On Sun, Jun 17, 2012 at 10:04 AM, R. Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com wrote: Take a look at the parallel package

Re: [R] noob requesting help

2012-06-16 Thread R. Michael Weylandt michael.weyla...@gmail.com
On Jun 16, 2012, at 1:56 PM, capital_P peterv...@hotmail.com wrote: David Winsemius wrote Try dat2 - data.frame(do.call(cbind, dat), stringsAsFactors=FALSE) Use instead: dat2 - data.frame( dat, stringsAsFactors=FALSE) Both do not seem to work: dat2 -

Re: [R] spelling correction using R

2012-06-15 Thread R. Michael Weylandt
Grammar is quite complicated, but for spelling you might try this wonderful article by Peter Norvig: http://norvig.com/spell-correct.html Michael On Fri, Jun 15, 2012 at 12:10 AM, raishilpa raishilpa@gmail.com wrote: hello I want a code which can correct the spelling mistakes  as well as

Re: [R] Apply() on columns

2012-06-15 Thread R. Michael Weylandt
Just to take a stab at it, I'd suggest you don't actually need apply() and could simply get what you need with hist(DATA[,4:6]) if your data is as described. Michael On Fri, Jun 15, 2012 at 7:23 AM, Jean V Adams jvad...@usgs.gov wrote: Frans, I'm not sure I understand what you're after. I

Re: [R] POSIXlt and trunc

2012-06-15 Thread R. Michael Weylandt
General rule of thumb: use POSIXct rather than POSIXlt for such things and only convert to POSIXlt (losslessly) at the end of your calculations when you need it for display reasons. Internally, POSIXct is just a double, so it is nice to do calculations on, while POSIXlt is a list-like object which

Re: [R] R: Securities earning covariance

2012-06-15 Thread R. Michael Weylandt
I'm somewhat confused: i) What does this have to do with your subject line? ii) There does not exist -- to my knowledge -- an implementation of R which runs on the JVM. iii) Have you simply looked into R's native parallel computing options? That seems to be (maybe?) what you are trying to do.

Re: [R] help in sentDetect() fuction

2012-06-15 Thread R. Michael Weylandt
On Fri, Jun 15, 2012 at 1:48 AM, raishilpa raishilpa@gmail.com wrote: hello, I am using the following code s-I am very happy, excited, and optimistic.I am very scared, annoyed, and irritated.Iraq’s political crisis entered its second week one step closer to the potential.dissolution of

Re: [R] spelling correction using R

2012-06-15 Thread R. Michael Weylandt
with the linked code is that it doesn't define out before using it. I might suggest you actually read the entire page -- the fix is already posted there. Michael I am unable to remove the error...can anyone help in removing the error...? On Fri, Jun 15, 2012 at 6:40 PM, R. Michael Weylandt

Re: [R] Looking for Speed in a Toy Simulation Example

2012-06-15 Thread R. Michael Weylandt
As of recent versions of R, you can actually go for what are officially recognized as ultimate speed functions .rowSums() and friends. You might also use the compiler() package to byte-compile that inner loop. [The function going to sapply] It won't be massive, but perhaps another 3 or 4x

Re: [R] Looking for Speed in a Toy Simulation Example

2012-06-15 Thread R. Michael Weylandt
On Fri, Jun 15, 2012 at 9:48 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: As of recent versions of R, you can actually go for what are officially recognized as ultimate speed functions .rowSums() and friends. Sorry, perhaps that wasn't totally clear. Regarding .rowSums() note

Re: [R] Divide all rows of a data frame by the first row.

2012-06-15 Thread R. Michael Weylandt
Honestly, given what a pain dates are in Excel, I might simply import them as strings and do the conversion on the R side of things. Also, I'd recommend you use Date objects rather than POSIXct to cut out the unnecessary complexity of timezones, DST, etc. [See Gabor's article in RNews 4/1 for a

Re: [R] R under JVM

2012-06-15 Thread R. Michael Weylandt
on rJava which allows both-way connectivity and probably places nicer with R than proprietary windows projects. Best, Michael Thanks again Angelo -Messaggio originale- Da: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] Inviato: venerdě 15 giugno 2012 16.16 A: LINARDI

Re: [R] Multivariate Normal and loops

2012-06-15 Thread R. Michael Weylandt
I don't think you need loops at all actually :-) [The main thing to working with R vs. C is vectorization -- embrace it now and life will be much better] You could do something like this: library(MASS) # Provides a multivariate normal distribution mvrnorm(100, c(1,5), matrix(c(2,1,1,2), ncol =

Re: [R] R -- JVM

2012-06-15 Thread R. Michael Weylandt
) but data integrity should be guaranteed. Michael Thanks again for you kindness and help. Angelo -Messaggio originale- Da: Oliver Ruebenacker [mailto:cur...@gmail.com] Inviato: venerdì 15 giugno 2012 17.36 A: R. Michael Weylandt Cc: LINARDI ANGELO; r-help@r-project.org Oggetto: Re

Re: [R] R: Securities earning covariance

2012-06-15 Thread R. Michael Weylandt
On Fri, Jun 15, 2012 at 10:35 AM, Oliver Ruebenacker cur...@gmail.com wrote:     Hello, On Fri, Jun 15, 2012 at 10:15 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: ii) There does not exist -- to my knowledge -- an implementation of R which runs on the JVM.  I think he means

Re: [R] Save multiple plots in a single pdf file when the plots are generated by a single plot command

2012-06-15 Thread R. Michael Weylandt
On Fri, Jun 15, 2012 at 4:39 PM, Debs Majumdar debs_st...@yahoo.com wrote: Hi, I am trying to save multiple plots in a single pdf file when  the plots are generated by a single plot command. I am using the lordif package which generates multiple plots with one command. pdf(education.pdf)

Re: [R] Save multiple plots in a single pdf file when the plots are generated by a single plot command

2012-06-15 Thread R. Michael Weylandt
American)) dev.off() pdf   2 - Original Message - From: R. Michael Weylandt michael.weyla...@gmail.com To: Debs Majumdar debs_st...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Sent: Friday, June 15, 2012 3:48 PM Subject: Re: [R] Save multiple plots

Re: [R] Replication of linear model/autoregressive model

2012-06-15 Thread R. Michael Weylandt
On Fri, Jun 15, 2012 at 6:56 AM, Al Ehan aehan3...@gmail.com wrote: Hi, I would like to make a replication of 10 of a linear, first order Autoregressive function, with respect to the replication of its innovation, e. for example: #where e is a random variables of innovation (from GEV

Re: [R] time zones and the chron to POSIXct conversion

2012-06-15 Thread R. Michael Weylandt
It does seem that as.POSIXct.date doesn't respect the tz= argument the generic suggests it would. I'd think this is a bug that could be changed without breaking back-compatibility, but I don't have the power to make such things happen. R-Core ruling? Michael On Fri, Jun 15, 2012 at 2:25 AM,

Re: [R] time zones and the chron to POSIXct conversion

2012-06-15 Thread R. Michael Weylandt
On Fri, Jun 15, 2012 at 11:26 PM, David Winsemius dwinsem...@comcast.net wrote: On Jun 15, 2012, at 11:18 PM, R. Michael Weylandt wrote: It does seem that as.POSIXct.date doesn't respect the tz= argument the generic suggests it would. Why would a date function have a TZ? `as.Date` wouldn't

Re: [R] Question about sampling

2012-06-14 Thread R. Michael Weylandt
sample() takes a prob = argument which lets you supply weights, which need not sum to one so, if I understand you, you could just pass TRUEs and FALSEs for those rows you want. If I'm wrong about that last bit, I'm still pretty confident sample(prob = ) is the way to go. Best, Michael On Thu,

Re: [R] R matrix help

2012-06-14 Thread R. Michael Weylandt
But there are multiple shapes for matrices with 12 elements -- how did you get 3x4 ? You also could have had 1x12, 2x6, 3x4, 4x3, 6x2,12x1 If you have an R object, you can use dim() on it. [Or perhaps slightly more robustly, NCOL() and NROW()] Michael On Thu, Jun 14, 2012 at 7:51 AM,

Re: [R] Question about sampling

2012-06-14 Thread R. Michael Weylandt
are equally important. I  need  simply that my subset has in each column the same frequency of  1 that in the original dataset Thank you again Guido 2012/6/14 R. Michael Weylandt michael.weyla...@gmail.com sample() takes a prob = argument which lets you supply weights, which need not sum to one

Re: [R] Time difference between two dates/timing

2012-06-14 Thread R. Michael Weylandt
You have been asked before (by me!) to give reproducible examples using dput()... You might need the diff() function. Michael On Thu, Jun 14, 2012 at 5:08 AM, Rantony antony.akk...@ge.com wrote: Hi, Here, i have a matrix like this MyMatrix - *DATETIME        HEADER1            HEADER2*

Re: [R] Can someone recommend a package for SNP cluster analysis of Fluidigm microarrays?

2012-06-14 Thread R. Michael Weylandt
I do think this is more of a Bioconductor question -- but no worries, they're all much nicer there than we are here and won't flame you if you double post :-) Best, Michael On Thu, Jun 14, 2012 at 12:37 PM, Hans Thompson hans.thomps...@gmail.com wrote: I know that there are quite a few packages

Re: [R] Error in sort(abs(diff(genomdat)))[1:n.keep] : only 0's may be mixed with negative subscripts

2012-06-12 Thread R. Michael Weylandt
Your problem is that n.keep is less than 0. Why that is I cannot tell without appropriate context. E.g., x - 1:10 x[2:5] x[0:1] x[(-3):1] Michael On Tue, Jun 12, 2012 at 6:01 AM, sanshine s.a.j.van_der_ze...@lumc.nl wrote: Hello everyone, I`m trying to normalize and analize an illumina

Re: [R] String Manipulation in R

2012-06-12 Thread R. Michael Weylandt
grepl Michael On Tue, Jun 12, 2012 at 8:51 AM, anjali jeevi...@gmail.com wrote: Hi , Is there any inbuilt functions  to check whether a substring is present in a string and give the result as boolean Thanks -- View this message in context:

Re: [R] R-SCRIPT Label Calling Method

2012-06-12 Thread R. Michael Weylandt
Short answer: no. Long answer: use a closure if for some bizarre reason you just can't use a loop. Bonus tip: change the last three lines to: d - c 5 for speed and clarity! Michael On Tue, Jun 12, 2012 at 9:25 AM, Rantony antony.akk...@ge.com wrote: Hi, here i have some code... a -1

Re: [R] Reference on data manipulation

2012-06-12 Thread R. Michael Weylandt
Probably Spector (http://www.amazon.com/Data-Manipulation-R-Use/dp/0387747303) if you want a dead-tree book. Otherwise, just read the archives of this list and the R-bloggers aggregator and you should be able to pick up most everything you need. Michael On Tue, Jun 12, 2012 at 9:58 AM, XINLI LI

Re: [R] How to index a matrix with different row-number for each column?

2012-06-12 Thread R. Michael Weylandt
I think you are looking for mt[cbind(vt, seq_along(vt))] which uses some trickines known as matrix indexing (basically, the two columns created by cbind() are considered row col indices -- then seq_along() gives the col1,col2, bit as needed. HTH, Michael On Tue, Jun 12, 2012 at 10:28 AM,

Re: [R] Yahoo/Google quotes symbols

2012-06-12 Thread R. Michael Weylandt
TTR::stockSymbols Michael On Tue, Jun 12, 2012 at 1:12 PM, Vikram Bahure economics.vik...@gmail.com wrote: Dear R users, I was working on get.hist.quote to download data, but for this I need to know yahoo quotes (for stocks) from the beginning. Is there any simple way to get all symbols for

Re: [R] adjust space between horizontal legend text in a barplot

2012-06-12 Thread R. Michael Weylandt
As noted below: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. For more on how to do that see: i) https://github.com/hadley/devtools/wiki/Reproducibility ii)

Re: [R] How to write text in bar plot in R?

2012-06-12 Thread R. Michael Weylandt
? text Michael On Tue, Jun 12, 2012 at 8:49 PM, Manish Gupta mandecent.gu...@gmail.com wrote: Hi, I am working on R plot but i need to write some text for the bars where the value is = 0 counts     3  4  5  0 12  0  4  1  3  0  1 http://r.789695.n4.nabble.com/file/n4633190/1.png My

Re: [R] problem about set operation and computation after split

2012-06-12 Thread R. Michael Weylandt
On Wed, Jun 6, 2012 at 2:43 AM, bestbird bestbird7...@gmail.com wrote: hi,    I met some problems in R, plz help me. 1. How to do a intersect operation among several groups in one list, without a loop statement? (I think It may be a list)   create data:   myData - data.frame(product =

Re: [R] Why is my data always imported as a list?

2012-06-11 Thread R. Michael Weylandt
They aren't quite lists --- they are actually data.frame()s which are a special sort of list with rownames and other nice things. To your immediate question, I think you're looking for the formula interface: boxplot(Value ~ State.Fips, data = CB_un) The data= argument is important so boxplot

Re: [R] Data.frames can not hold objects...What can be done in the following scenario?

2012-06-11 Thread R. Michael Weylandt
It is possible to chain together uses of `[[` -- e.g., x - list(1:5, list(letters[1:5], list(LETTERS[1:5]))) x[[c(1,2)]] # 2L x[[c(2,1,3)]] # c x[[c(2,2,1,3)]] # C which is sometimes useful. Best, Michael On Mon, Jun 11, 2012 at 4:35 PM, Onur Uncu onuru...@gmail.com wrote: Rui and the

Re: [R] eclipse cran r

2012-06-11 Thread R. Michael Weylandt
There's no such thing as cran r -- there's just R, possibly using the binaries distributed by CRAN. [Both are capitalized, por favor] With that said, I believe the term you are looking for is Sweave or, for a slightly different take on things, knitr. Both are well documented with a little bit of

Re: [R] saving sublist lda object with save.image()

2012-06-11 Thread R. Michael Weylandt
Untested guess -- are you reloading MASS in the new R session? I don't believe loaded packages are saved in the session image... If MASS isn't around, R won't know how to plot an lda object. Best, Michael On Mon, Jun 11, 2012 at 4:55 PM, dga...@huskers.unl.edu dga...@huskers.unl.edu wrote:

Re: [R] How to see the implementation of print function for a class from a package?

2012-06-10 Thread R. Michael Weylandt
, 2012 at 12:49 AM, Majid Einian einia...@gmail.com wrote: I am working on the package datation and it is not on CRAN. On Sun, Jun 10, 2012 at 8:28 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: I presume your problem is that you are looking for non-exported methods in some unstated

Re: [R] Storing datasets

2012-06-09 Thread R. Michael Weylandt michael.weyla...@gmail.com
Take a look at ?replicate. Michael On Jun 9, 2012, at 5:16 AM, Rody rodric_seu...@hotmail.com wrote: Hi everyone I need to make a work for school in R and one of my questions is to create 225 datasets of 100 observations and they need to be t_225 distributed. So, I know how to make one

Re: [R] Inf and NA

2012-06-09 Thread R. Michael Weylandt
Take a look at this: x - matrix(1:9, 3) x[2,2] - Inf x[3,1] - NA rowMeans(x * is.finite(x), na.rm = TRUE) I at first thought you could simply use x[is.finite(x)] but that looses the matrix-ness of it so instead, we use the fact that 0 * Inf = NaN which gets killed by na.rm = TRUE. Also see my

Re: [R] Reshaping columns

2012-06-09 Thread R. Michael Weylandt
Perhaps something like this: x - c(11, 001100, 001001) # Test data strsplit(x,) # See what strsplit does do.call(rbind, strsplit(x,)) # Now combine the list elements nicely. Incidentally, your question was grossly malformed, involving both incomplete data and that in a non-reproducible

Re: [R] Applying a function to a column of a data frame

2012-06-09 Thread R. Michael Weylandt
No worries -- it's an important question and it introduces you to one of the most important R idioms. [And you get bonus points for having a well formed question!] You're probably looking for something like this: apply(testframe, 1, function(x) testfun(x[2])) Which goes row-by-row and

Re: [R] How to see the implementation of print function for a class from a package?

2012-06-09 Thread R. Michael Weylandt
I presume your problem is that you are looking for non-exported methods in some unstated package. Generally the pattern is something like this methods(plot) # shows all plot.* methods methods(class = lm) # shows all *.lm methods Those marked with a star are not exported but you can get at them

Re: [R] Re-creating distributions

2012-06-08 Thread R. Michael Weylandt
greatly apreciate your help, Sincerely, Andras gunter.ber...@gene.com wrote: From: Bert Gunter gunter.ber...@gene.com Subject: Re: [R] Re-creating distributions To: R. Michael Weylandt michael.weyla...@gmail.com Cc: Andras Farkas motyoc...@yahoo.com, r-help@r-project.org Date: Friday

Re: [R] Problems when install ROCR

2012-06-08 Thread R. Michael Weylandt
Well, I know that ROCR and gplots are on CRAN so you should probably be installing them with install.packages() on your magical and unspecified OS and version of R. Michael On Fri, Jun 8, 2012 at 2:07 AM, guoshicheng2005 guoshicheng2...@yeah.net wrote: I meet lots of problem when installing the

Re: [R] Holt Winters in R - Help needed

2012-06-08 Thread R. Michael Weylandt
You need to set the frequency attribute of your time series. E.g., HoltWinters(ts(sample(100))) HoltWinters(ts(sample(100), frequency = 4)) # Quarterly data See ?ts for what frequency is and to figure out what makes sense for your problem. Best, Michael On Fri, Jun 8, 2012 at 9:49 AM,

Re: [R] How to build a large identity matrix faster?

2012-06-08 Thread R. Michael Weylandt
For the matter and hand, you can probably get to it by simply trying base:::diag. In this case, it's not too hard because what you're seeing is the S4 generic that the Matrix package is defining _over_ the regular base function generic. More generally, going down the rabbit hole of S4: As it

Re: [R] How to build a large identity matrix faster?

2012-06-08 Thread R. Michael Weylandt
On Fri, Jun 8, 2012 at 5:31 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: For the matter and hand, you can probably get to it by simply trying base:::diag. In this case, it's not too hard because what you're seeing is the S4 generic that the Matrix package is defining _over_

Re: [R] flagging values without a loop

2012-06-07 Thread R. Michael Weylandt
In two steps, you could use ave() to split by hour and find the maximum of price and then use an ifelse clause on the resulting vector to see when that actually equals the given price and assign Y/N appropriately, I'll leave the implementation as an exercise to the reader :-) Best, Michael On

Re: [R] Re-creating distributions

2012-06-07 Thread R. Michael Weylandt
Short answer: no, those are (in general) insufficient parameters to characterize a distribution. Long answer: unfortunately, it's not uncommon that those summary statistics are the only ones reported based on someone or other's limited experience with the Gaussian. There are a few things you

Re: [R] package zoo, function na.spline with option maxgap - Error: attempt to apply non-function?

2012-06-06 Thread R. Michael Weylandt
Thanks for the great reproducible example -- I can confirm on the devel version of zoo. I'd venture it's a buglet in that maxgap gets passed (by way of dots) to na.spline -- na.spline.zoo -- na.spline.default -- na.spline.vec -- to both .fill_short_gaps (good) and spline (bad) which is where the

Re: [R] Problems installing Packages

2012-06-03 Thread R. Michael Weylandt
I'm not really an expert on BLAS-y things, but wouldn't there be more problems upstream with R if it weren't able to find the local BLAS? I was under the impression that R shipped it's own BLAS but could also be directed to one at compile time -- either way, I would guess that many other would

Re: [R] Loop question

2012-05-31 Thread R. Michael Weylandt
Note that in R = 2.15 you can also use paste0 for this operation more efficiently. Michael On Thu, May 31, 2012 at 1:58 AM, Özgür Asar oa...@metu.edu.tr wrote: Dear Sebastian, The following will create the names paste(sb,1:5,sep=) paste(sw,1:5,sep=) paste(Lw,1:5,sep=) paste(Lb,1:5,sep=)

Re: [R] Warning message: numerical expression has 1000 elements: only the first used

2012-05-31 Thread R. Michael Weylandt
Ozgur -- No, this is not what the OP seems to be asking for (and it's bad code anyways -- I've mentioned the importance of pre-allocation to you before): OP, if I understand you, you are looking for a cumsum() operation: something like: t - rbinom(1000, 1, 0.5) t[t==0] - (-1) cumsum(t)

Re: [R] density plots using density.lf, data.frame and sort.int errors

2012-05-31 Thread R. Michael Weylandt
My guess (unconfirmed) is that read.table() gives you a data frame but density.lf expects an atomic (= not a list = not a data frame) vector. Perhaps try density.lf(x[,1]) to just send the column -- the drop behavior should make sure this is an atomic vector. If that doesn't help, please do

<    2   3   4   5   6   7   8   9   10   11   >