Re: [R] Improving performance of split-apply problem

2012-02-23 Thread R. Michael Weylandt
It looks like what you are doing is reasonably efficient: I do think there's a residuals element to the object returned by lm() so you could just call that directly (which will be just a little more efficient). The bulk of the time is probably being taken up in the lm() call, which has alot of

Re: [R] changing time span

2012-02-23 Thread R. Michael Weylandt
? window Michael On Thu, Feb 23, 2012 at 7:09 AM, phillen phlent...@gmail.com wrote: hi there! i am desperately in need for help. i have read in data: qthm=read.csv(qthm.csv,sep=;,header=TRUE)  then created time series ie m2=ts(log(qthm$m2), start=c(1959, 1), frequency=4) transformed

Re: [R] How can I ran an R command whcih is present as the content of a character object

2012-02-23 Thread R. Michael Weylandt
eval(parse(text = rcom)) Michael On Thu, Feb 23, 2012 at 8:30 AM, Aniruddha Mukherjee aniruddha.mukher...@tcs.com wrote: I have an object called rcom which was created by the command rcom -mean(mat_rix$COL_1). Also the data-frame mat_rix is well defined with numeric values in its column 1 and

Re: [R] extract subset of data.frame

2012-02-23 Thread R. Michael Weylandt
df[value %in% v, ] Michael On Thu, Feb 23, 2012 at 10:48 AM, syrvn ment...@gmx.net wrote: Hello, consider the following data.frame df and vector v df - data.frame(group = c(A,B,C,D), value = c(1,2,3,4)) v - c(2,3) How can I return a sub data.frame which has only the rows left where

Re: [R] convert zoo object to standard R object so I can plot and output to csv file

2012-02-23 Thread R. Michael Weylandt
If you could just construct the zoo object you want to plot and then use dput() on it to create a plain-text representation (safe for emailing) that'd make it easiest for us to help you. We can't do much right now since we don't have the text file in question. Michael On Thu, Feb 23, 2012 at

Re: [R] R CMD INSTALL with configure args

2012-02-23 Thread R. Michael Weylandt
shell you're using). Michael On Thu, Feb 23, 2012 at 1:47 PM, Erin Hodgess erinm.hodg...@gmail.com wrote: Sorry...Debian On Thu, Feb 23, 2012 at 11:51 AM, R. Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com wrote: What OS? Michael On Feb 23, 2012, at 12:44 PM, Erin

Re: [R] cor() on sets of vectors

2012-02-23 Thread R. Michael Weylandt
sapply(1:NCOL(x), function(n) cor(x[n], y[n])) is a quick and dirty way, though probably not optimal. Michael On Thu, Feb 23, 2012 at 5:10 PM, Sam Steingold s...@gnu.org wrote: suppose I have two sets of vectors: x1,x2,...,xN and y1,y2,...,yN. I want N correlations: cor(x1,y1), cor(x2,y2),

Re: [R] saving all data in r object

2012-02-24 Thread R. Michael Weylandt
You have three problems: 1) You don't post with context 2) You have a (likely OS permissions) issue that keeps you from accessing the RData file 3) You can't put a whole bunch of data in a single element of an object (ie., you are trying to put a column of data in a single element of an object:

Re: [R] find difference between data frames

2012-02-24 Thread R. Michael Weylandt
I'm not sure if you mean to ignore row 6 while ignoring row 4 or not so here are two solutions (depending on what you meant) dput(x) # dput is your friend structure(list(kind = c(1L, 1L, 1L, 1L, 2L, 2L), x = c(8L, 44L, 25L, 36L, 2L, 36L), y = c(9L, 3L, 7L, 20L, 14L, 20L)), .Names = c(kind, x, y),

Re: [R] remove multiple objects starting with same name

2012-02-24 Thread R. Michael Weylandt
rm(list = ls(pattern = object)) Michael On Fri, Feb 24, 2012 at 4:40 PM, katarv katiasm...@gmail.com wrote: Hi, I'm trying to figure out syntax R function rm() needs to remove all objects starting with same name.  For example, if I have object1, object2, object3, i want to do an operation

Re: [R] listing array after loop

2012-02-24 Thread R. Michael Weylandt
This sure sounds like you need to read the advice I gave you on the other thread where you asked the same questions... Michael On Fri, Feb 24, 2012 at 5:04 PM, uday uday_143...@hotmail.com wrote: The following error I got Warning messages: 1: In sci.lat[i] = data[, 7] :  number of items to

Re: [R] Table into a list

2012-02-24 Thread R. Michael Weylandt
Your question is not well formed: do you want a list or a string (totally different things)? Or even more likely, a character vector? What do you have now: is it really an array (=matrix) or is it the data.frame it looks like? If it's a matrix: x - matrix(letters[1:8], ncol = 2) x - as.vector(x)

Re: [R] Table into a list

2012-02-24 Thread R. Michael Weylandt
My apologies: I missed the order of the desired output: the easiest thing to do is likely to use the same techniques given below (and by others in this thread) with a transpose t() before. Michael On Sat, Feb 25, 2012 at 2:05 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: Your

Re: [R] Telling plot() the max y value to expect when plotting one distribution and then using lines() to add more distributions

2012-02-25 Thread R. Michael Weylandt
, legend = PARAMETERS[, label], lwd = 1, col = PARAMETERS[, color]) grid() Hope this helps, Michael On Sat, Feb 25, 2012 at 2:22 AM, R. Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com wrote: Easiest thing to do: use the optional ylim argument to plot (taking values like c

Re: [R] Help needed please

2012-02-25 Thread R. Michael Weylandt
Look at ?optim and example(optim) Michael On Sat, Feb 25, 2012 at 11:47 AM, Jaymin Shah jayminsh...@hotmail.com wrote: I was wondering how to make a function which minimises  a vector (a,b,c,d). I have an equation ( for simplicity) say its 5 -(3a+4b+6c+8d) and i want to make this equation

Re: [R] Telling plot() the max y value to expect when plotting one distribution and then using lines() to add more distributions

2012-02-25 Thread R. Michael Weylandt
I had never actually played with matplot before -- thanks for the great tip. Michael On Sat, Feb 25, 2012 at 7:39 PM, Peter Ehlers ehl...@ucalgary.ca wrote: See inline below. On 2012-02-25 12:40, R. Michael Weylandt wrote: I might (re-)format your code as follows -- others will make some

Re: [R] assign same legend colors than in the grouped data plot

2012-02-25 Thread R. Michael Weylandt
Your code isn't reproducible...(note the legend block -- that's not code) and (if I had to guess) it looks like you are using attach(). Don't do that... What do you mean it doesn't work? You say something about plotting lines, but your working code (the first block) doesn't do that... If

Re: [R] question about user written function (newb question)

2012-02-26 Thread R. Michael Weylandt
Short answer to a very good question: one has to use function(x) tail(x, 1) syntax to avoid using the default tail(x, 6). There are some other ways to achieve the same thing, but I think this syntax is generally preferred for its clarity. Other question: yes I believe so. Michael On Sun, Feb

Re: [R] Help needed! Error in setwd(newdir) : cannot change working directory

2012-02-26 Thread R. Michael Weylandt
This is a mess -- please resend in plain text. Also, there are not, to my knowledge, packages (not libraries) called A, B, or C so your script doesn't even begin to look reproducible were it legible. Do you have read/write access to the directories in question? Michael On Sat, Feb 25, 2012 at

Re: [R] win zip archive of library(HH) for R2.12.0

2012-02-26 Thread R. Michael Weylandt
Old sources are available here: http://cran.r-project.org/src/contrib/Archive/HH/ You'll have to see which ones are compatible Michael On Mon, Feb 27, 2012 at 1:02 AM, Vijayan Padmanabhan v.padmanab...@itc.in wrote: Dear R Group Can any body point me to a link from where I can get zip archive

Re: [R] win zip archive of library(HH) for R2.12.0

2012-02-26 Thread R. Michael Weylandt
without proof can be denied without proof - Euclide. *R. Michael Weylandt michael.weyla...@gmail.com* 02/27/2012 11:38 AM To Vijayan Padmanabhan v.padmanab...@itc.in cc r-help@r-project.org Subject Re: [R] win zip archive of library(HH) for R2.12.0 Old sources are available here

Re: [R] read.csv converts NA to missing values

2012-02-27 Thread R. Michael Weylandt
I believe read.csv(..., na.strings = ) will do it. Michael On Mon, Feb 27, 2012 at 8:15 AM, nikhil abhyankar nsabhyan...@gmail.com wrote: Hello, I have a CSV file with region codes listed in a column. E.g. 'AS' for Asia, 'AU' for Australia and 'NA' North America. However, the data frame

Re: [R] strange behaviour of POSIXlt POSIXt object

2012-02-27 Thread R. Michael Weylandt
Hadley's lubridate package might be of some help to you. Michael On Mon, Feb 27, 2012 at 11:40 AM, ikuzar raz...@hotmail.fr wrote: So, how is the correct way to increment the day ? -- View this message in context:

Re: [R] Installing package QRMlib

2012-02-27 Thread R. Michael Weylandt
Do you perhaps need to add install.packages(..., type=src)? Just a (untested) guess... Michael On Mon, Feb 27, 2012 at 12:07 PM, DT54321 deepan.tailo...@gmail.com wrote: Hi, I am having real problems downloading the package 'QRMlib'. The tar.gz file is shown here:

Re: [R] export 3D array to .txt file

2012-02-27 Thread R. Michael Weylandt
You can save it directly as an R object with save() and load with load() -- that's probably easiest. It should be portable between R platforms and sesions, but won't be easily accessible to other programs. Michael On Mon, Feb 27, 2012 at 3:45 PM, frauke fh...@andrew.cmu.edu wrote: Hey, I have

Re: [R] kmeans: how to retrieve clusters

2012-02-28 Thread R. Michael Weylandt
But it won't be hard at allyou can likely get what you need using the tapply() function (or ave) Michael On Tue, Feb 28, 2012 at 4:33 AM, ikuzar raz...@hotmail.fr wrote: Hi, Ok, I understand what you mean. I wanted to get sorted data group by cluster  in output ... But I have to do it

Re: [R] how to append element at last position in array dynamically

2012-02-28 Thread R. Michael Weylandt
You need to reassign the value of append back to h -- in more technical terms, this is a pass-by-value rather than pass-by-reference behavior: h - append(h, 9) This is not likely to be efficient in production code, however. Michael On Tue, Feb 28, 2012 at 7:15 AM, sagarnikam123

Re: [R] how to get file name/file path

2012-02-28 Thread R. Michael Weylandt
Use this line instead: table - read.table(fileIchoose - file.choose(), skip = 1) This will have the side effect of creating fileIchoose as a variable containing a file path. Michael On Tue, Feb 28, 2012 at 8:34 AM, sagarnikam123 sagarnikam...@gmail.com wrote: i open a table

Re: [R] Error in read.table(file = file, header = header, sep = sep, quote = quote, : more columns than column names

2012-02-28 Thread R. Michael Weylandt
What is initialCuratedDF? I'm not seeing it in any standard location so there's no way to debug it... Also see inline. Michael On Tue, Feb 28, 2012 at 2:41 PM, Ben Ganzfried ben.ganzfr...@gmail.com wrote: Hey, I just googled my error and many things came up.  I followed the leads and read

Re: [R] Error: could not find function hier.part

2012-02-28 Thread R. Michael Weylandt
It would seem that hier.part is not in the gtools packagedo you have some reference that suggests otherwise? I don't know the function, but I might suggest you check the hier.part package (also on CRAN). Michael On Tue, Feb 28, 2012 at 4:27 PM, haiyan tucsonaug...@gmail.com wrote: Error:

Re: [R] Installing package QRMlib

2012-02-28 Thread R. Michael Weylandt
Please quote context. You can open it with any plain text editor. (i.e., notepad) Michael On Tue, Feb 28, 2012 at 2:42 PM, DT54321 deepan.tailo...@gmail.com wrote: Yes, I did. But my Windows did not know what program to open it with... -- View this message in context:

Re: [R] Export nls object to text file

2012-02-29 Thread R. Michael Weylandt
You can save it as an R Data file using save() and then reload it with load() -- there's not a natural way to make it something that lives nicely in a text file (since an nls object is quite complex) -- if you are just going to be using the object again in R I'd recommend the first. If you need it

Re: [R] Using a FOR LOOP to name objects

2012-02-29 Thread R. Michael Weylandt
In short, don't -- use a named list instead. Long answer: ?assign ?get Michael On Tue, Feb 28, 2012 at 10:40 PM, michaelyb cel81009...@gmail.com wrote: Hello, I am trying to use a for loop to name objects in each iteraction. As in the following example (which doesn't work quite well)

Re: [R] Database

2012-02-29 Thread R. Michael Weylandt
I don't use Access but my general impression is that the advantages it brings will be similar to those brought by any other database: performance rather than ability -- they are both Turing complete after all, after some trickery on the SQL end. Databases allow much larger data sets than R

Re: [R] Error occurred during mean calculation of a column of a data frame, which is apparently contents numeric data

2012-02-29 Thread R. Michael Weylandt
Factors are internally stored as integers (enums if you have used other programming languages) with a special label set -- it's more memory efficient than storing the whole string over and over. Michael On Wed, Feb 29, 2012 at 5:49 AM, Aniruddha Mukherjee aniruddha.mukher...@tcs.com wrote:

Re: [R] Converting a function from Splus to R

2012-02-29 Thread R. Michael Weylandt
Change the name to something syntactically valid? The problem is that you can't (well, you can, but it's ill advised) have variable names beginning with numbers. They don't seem to be used much so there won't be much trouble in that. Michael 2012/2/29 Freddy Hernández fhern...@gmail.com: I

Re: [R] Error in Aggregate

2012-02-29 Thread R. Michael Weylandt
The error message is clear: your problem is that your data.frame (note the period) contains factors. Use str(data) -- also don't use data as it's a function name -- to see which ones and change as appropriate. Michael On Wed, Feb 29, 2012 at 7:16 AM, arunkumar akpbond...@gmail.com wrote: Hi

Re: [R] Converting a function from Splus to R

2012-02-29 Thread R. Michael Weylandt
Oh...that does make more sense -- seemed like a rather odd choice of variable name. Michael On Wed, Feb 29, 2012 at 8:40 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On 29/02/2012 13:24, R. Michael Weylandt wrote: Change the name to something syntactically valid? The problem

Re: [R] puzzling results from logistic regression

2012-02-29 Thread R. Michael Weylandt
Formally, look at Pr(|z|). Informally, look at the null and residual deviances from print(aa). Michael On Wed, Feb 29, 2012 at 10:14 AM, Michael comtech@gmail.com wrote: How did you see it's non-significant? Thanks! On Wed, Feb 29, 2012 at 9:10 AM, Sarah Goslee

Re: [R] identifying a column name correctly to use in a formula

2012-02-29 Thread R. Michael Weylandt
Your method of constructing a formula is funny: is there a term called interaction or do you mean an interaction in the statistical sense? Once you do that, I'd think the easiest way to proceed is to use as.formula() to construct your formula programmatically and then to pass that to glm().

Re: [R] How are the coefficients for the ur.ers, type DF-GLS calculated?

2012-02-29 Thread R. Michael Weylandt
Simply type ur.ers on a line by itself to see how the calculation is implemented. Michael On Wed, Feb 29, 2012 at 11:20 AM, ackbar03 wda...@gmail.com wrote: I need some real help on this, really stuck how are the coefficients for ur.ers(y, type = c(DF-GLS, P-test), model = c(constant,

Re: [R] How to extract numerical values from time series forecast

2012-02-29 Thread R. Michael Weylandt
Perhaps you need the forecast() function? Michael On Wed, Feb 29, 2012 at 12:01 PM, ForzaBruta s207027...@live.nmmu.ac.za wrote: hi all. i'm busy with some time series data, starting from an earlier period until the current day. i have created a time series forecast taking into account the

Re: [R] convert list to text file

2012-03-01 Thread R. Michael Weylandt
Perhaps something like sink(outtext.txt) lapply(LIST, print) sink() You could replace print with cat and friends if you wanted more detailed control over the look of the output. Michael On Thu, Mar 1, 2012 at 5:28 AM, t.galesl...@ebh.umcn.nl wrote: Dear R users, Is it possible to write the

Re: [R] Problems downloading file

2012-03-01 Thread R. Michael Weylandt
It might be a local network or OS issue: this works fine for me on my personal Mac download.file(url = http://ir.eia.gov/wpsr/psw09.xls;, destfile = ~/herewego.xls, mode = wb) Someone with more Windows knowledge may have to help you out, but often using IE settings (activated by the setInternet2

Re: [R] function for filtering and deleting vector entries

2012-03-01 Thread R. Michael Weylandt
Of course, just use x - fun(Temp, v) x$Temp # To get back temp x[[Temp]] x$v # To get back v x[[v]] Michael On Thu, Mar 1, 2012 at 3:15 PM, babyluck madr...@gmx.ch wrote: Thank you Rui, that helped a lot. The correct values show up when I'm using the following code. Now  fun(Temp,v)  

Re: [R] fridays date to date

2012-03-01 Thread R. Michael Weylandt
Inelegant, but here's one way: d1 - Sys.Date() d2 - Sys.Date() + 100 library(lubridate) d - seq(d1, d2, by = day) d[wday(d)==6] Michael On Thu, Mar 1, 2012 at 3:02 PM, Ben quant ccqu...@gmail.com wrote: Hello, How do I get the dates of all Fridays between two dates? thanks, Ben      

Re: [R] 3d surface plot (ideally using rgl package)?

2012-03-02 Thread R. Michael Weylandt
It is by no means clear what the peaks function does or if it has any R equivalent, but perhaps looking at demo(rgl) will get you started. After that, you should probably show what you've tried (at least as far as replicating the calculation aspects). Michael On Fri, Mar 2, 2012 at 1:32 AM,

Re: [R] Dataframes in PLS package

2012-03-03 Thread R. Michael Weylandt
Can you post dput(head(eqn, 30)) so we can take a look at your data? It's something of a cryptic error and that would go a long way in helping us help you. Without that though, I'm not sure you need the I(as.matrix.(dep)) and I(as.matrix(ind)), I would imagine (untested) that eqn -

Re: [R] How can I map by results to original list of indices or first difference of column of data.frame with two factors?

2012-03-03 Thread R. Michael Weylandt
It'd be doubly helpful if you could post desired output as well. If you haven't seen it before, the easiest way to post R data is to use the dput() function to get a plain-text (mailing list friendly) representation. If your data is large, dput(head(DATA, 30)) should suffice. (We wouldn't want

Re: [R] Using ddply within a function by argument transfer

2012-03-03 Thread R. Michael Weylandt
Untested, but it might be simpler than that: suspicious.vowels(pb,c(Type,Sex,Vowel),F1,F2) Note that F1 is in quotes but F2 isn't. Michael On Sat, Mar 3, 2012 at 5:46 PM, Fredrik Karlsson dargo...@gmail.com wrote: Dear list, Sorry, but I cannot get my head around how and I could pass

Re: [R] How do I create a scatterplot with two explanatory variables?

2012-03-03 Thread R. Michael Weylandt
That code doesn't seem to run (much to a little bit of surprise) as is: try this: d - structure(list(REMOVED = c(0.07, 0.1, 0.11, 0.12, 0.15, 0.19, 0.28, 0.31, 0.3, 0.34, 0.35, 0.39, 0.38, 0.4, 0.42, 0.4, 0.41, 0.42, 0.48, 0.48, 0.47, 0.49, 0.5, 0.51, 0.53, 0.58, 0.59, 0.65, 0.6, 0.6, 0.69, 0.7,

Re: [R] Dataframes in PLS package

2012-03-04 Thread R. Michael Weylandt
No. Do not do that. While it looks nice at first, it quickly becomes the source of innumerable errors. Michael On Sun, Mar 4, 2012 at 1:56 AM, Kazuo Ishii freepar...@gmail.com wrote: 2012/3/4, westland westl...@uic.edu: I am still/again having trouble getting PLSR to recognize the input data

Re: [R] Dataframes in PLS package

2012-03-04 Thread R. Michael Weylandt
concerning how I might fiddle the files to get them into a format that PLSR package would like, that would be great Chris Westland On Sat, Mar 3, 2012 at 8:17 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: Can you post dput(head(eqn, 30)) so we can take a look at your data? It's

Re: [R] source for function sample() in package base?

2012-03-05 Thread R. Michael Weylandt
It's an internal function so you have to look into the C sources: it's here under do_sample, but you'll have to follow all sorts of other functions down the rabbit hole if you want to understand the whole thing. http://svn.r-project.org/R/trunk/src/main/random.c Michael On Mon, Mar 5, 2012 at

Re: [R] rm(list=ls())

2012-03-05 Thread R. Michael Weylandt
No, it won't give the same result. If you load packages or have hidden variables / environments, they'll remain in the session or if you change global options they'll stay. It's a somewhat frequently asked question, but there's no way to get a factory fresh session without restarting R. You can

Re: [R] Error in file(fname, r) : invalid 'description' argument when running maptools' readAsciiGrid on a dataframe

2012-03-05 Thread R. Michael Weylandt
What are surfA, surfB? There's nothing to suggest that difcount is vectorized so if they are vectors of length 1 that could lead to your problem. Michael On Mon, Mar 5, 2012 at 2:07 PM, Colin Wren colindw...@gmail.com wrote: Hi, I'm trying to calculate a sum of differences between two ascii

Re: [R] how to run system command

2012-03-06 Thread R. Michael Weylandt
Those are error messages from the shell, not real values for what you think you are doing. Are you looking for the getwd() and Sys.date() functions instead? Michael On Tue, Mar 6, 2012 at 6:56 AM, sagarnikam123 sagarnikam...@gmail.com wrote: i run like ,but it giving other than what i expect i

Re: [R] Help on reshape function

2012-03-06 Thread R. Michael Weylandt
library(reshape2) melt(df, id.vars = c(ID1, ID2, ID3))[, -4] # To drop an extraneous column (but you should take a look and see what it is for future reference) Michael On Tue, Mar 6, 2012 at 6:17 AM, mails mails00...@gmail.com wrote: Hello, I am trying to reshape a data.frame in wide

Re: [R] evaluate String

2012-03-06 Thread R. Michael Weylandt
eval(parse(text = STRING)) but you often don't need to do this. A somewhat canonical quote in the R-world: If the answer is parse() you should usually rethink the question. -- Thomas Lumley, R-help (February 2005) Michael On Tue, Mar 6, 2012 at 10:06 AM, Lucas lpchaparro...@gmail.com wrote:

Re: [R] times series trellis plot

2012-03-06 Thread R. Michael Weylandt
Type at your console: library(lattice) example(xyplot.zoo) I think the second and third do what you were asking. Otherwise, please describe in more detail what you mean about add other variables to each panel -- how do you want these displayed and what sort of variables are they? On Tue, Mar 6,

Re: [R] Help on reshape function

2012-03-06 Thread R. Michael Weylandt
You'll need to use the cast() function but I can't say more unless you can provide more specifics. I believe Hadley's website has more documentation than the package: http://had.co.nz/reshape/ Michael On Tue, Mar 6, 2012 at 9:34 AM, mails mails00...@gmail.com wrote: Hey Michael, thanks for

Re: [R] frequency count by row

2012-03-06 Thread R. Michael Weylandt
Or perhaps faster but less general: rowSums(mydata != 0) Michael On Tue, Mar 6, 2012 at 12:56 PM, Sarah Goslee sarah.gos...@gmail.com wrote: A reproducible example would be helpful, but lacking that here's some untested code. If your data frame has NA values, those will also need to be dealt

Re: [R] problem with data

2012-03-07 Thread R. Michael Weylandt
Perhaps you should dput() you data so this is reproducible... Michael On Wed, Mar 7, 2012 at 10:15 AM, RMSOPS ricardosousa2...@clix.pt wrote: Good Afternoon,    I have a small problem with the following code. # The x.sub$Time[[1]]  2006-10-31 19:03:01 EST # when put in variable star

Re: [R] Save/Load function()-result to file in a loop

2012-03-08 Thread R. Michael Weylandt
Load doesn't return the object you saved, but rather a character vector with the name of that object, here x. So you would do something like load(/path/to/file_A) x # Here's your data or more robustly get(load(/path/to/file_A)) See ?load (value) for details. Michael On Thu, Mar 8, 2012 at

Re: [R] Correlation analysis for an exon array

2012-03-08 Thread R. Michael Weylandt
This question seems more suited to the Bioconductor mailing list: you'll get specialized (and very good) help if you post there. Michael On Thu, Mar 8, 2012 at 6:22 AM, Ekta Jain ekta_j...@jubilantbiosys.com wrote: Dear All, I have an exon array and did not find any differential gene

Re: [R] problem with data

2012-03-08 Thread R. Michael Weylandt
dput(x.sub) so we can see what you really have. Michael On Thu, Mar 8, 2012 at 4:35 AM, RMSOPS ricardosousa2...@clix.pt wrote: Hello   In the variable x.sub$Time i have the many dates in format  2006-10-31 20:10:35 EST, for example when print (x.sub$Time) give this [1] 2006-10-31

Re: [R] how to modify the tickment of x-axis

2012-03-08 Thread R. Michael Weylandt
One way is to do it manually plot(..., xaxt = n) axis(1, at = seq_along(wnd), labels = paste(seq_along(wnd), h) The other is to give plot x and y vectors. Michael On Wed, Mar 7, 2012 at 10:25 PM, Jie Tang totang...@gmail.com wrote: hi  I plot a series of observation data every minutes in a

Re: [R] Sampling problems

2012-03-08 Thread R. Michael Weylandt
Please use dput() to give a reproducible example: I can make this work on a data frame quite easily -- x - data.frame(1:10, letters[1:10], rnorm(10)) str(x) print(x) x[sample(nrow(x), 5), ] So it's not a problem with something being a data frame or having factors. Michael On Thu, Mar 8, 2012

Re: [R] Find identical pairs

2012-03-08 Thread R. Michael Weylandt
Perhaps which(x == y) or intersect(x,y) or x %in% y or many others. You really need to give an example of x and y and say what you mean by identical pairs to get any concrete suggestions. Michael On Thu, Mar 8, 2012 at 11:17 AM, Alaios ala...@yahoo.com wrote: Dear all I am having two numerical

Re: [R] Calculating length of consecutive sequences within a vector

2012-03-08 Thread R. Michael Weylandt
rle should get you started. Michael On Thu, Mar 8, 2012 at 9:35 AM, Jorge Molinos jgarc...@tcd.ie wrote: Hi all, I have a nx1 logical array of zeros and ones and I want to calculate the individual lengths of all 1-consecutive sequences contained in it. Is there an easy quick way to do

Re: [R] Copy dataframe for another

2012-03-08 Thread R. Michael Weylandt
What goes wrong? Your code isn't reproducible and you didn't give an error message. I'd mention that d - Null does not assign NULL to d which might lead to a dimension mismatch at some point. Also, something about your loop syntax seems funny: you are looping over rows but selecting columns of

Re: [R] Boxplot Fill Pattern

2012-03-08 Thread R. Michael Weylandt
On Thu, Mar 8, 2012 at 1:08 PM, Gabriel Yospin yosp...@gmail.com wrote: Hello R Help! Hello Gabe Yospin! (I feel like I should start playing some arena rock anthem now ;-) ) I would like to make a legible boxplot of tree growth rates for each of seven tree species at each of seven different

Re: [R] Correlation between 2 matrices but with subset of variables

2012-03-08 Thread R. Michael Weylandt
Well, it would be possible to set something up to select out just the right pairs each time, but on my system the following a - matrix(rnorm(40 * 732), 40) b - matrix(rnorm(40 * 1230), 40) system.time(cor(a,b,method = pearson)) takes about a tenth of a second so any more elective approach will

Re: [R] Boxplot Fill Pattern

2012-03-08 Thread R. Michael Weylandt
(theme_bw()) ggplot(datnew.lo, aes(x = sp, y = ga)) + geom_boxplot() + facet_wrap(~site, ncol = 7) + opts(axis.text.x=theme_text(angle=90, size = 8, hjust = 1)) + xlab(Species) + ylab(expression(paste('Basal Area Growth Increment (mm  '^{2},')'))) On Thu, Mar 8, 2012 at 12:22 PM, R. Michael

Re: [R] rpanel / list error

2012-03-09 Thread R. Michael Weylandt
Yes, please upload some code / data (minimal working example). The easiest way to upload data is to use dput() for a plain text representation. Also remember that the majority of R-Helpers don't use Nabble (rather they use an email client directly) so it's easier for us if you put things in the

Re: [R] From (common IDs different Names) To (common IDs common Names)

2012-03-09 Thread R. Michael Weylandt
library(stringr) x$Name - str_trim(gsub([ABC] Branch, ,x$Name)) Michael On Fri, Mar 9, 2012 at 12:32 AM, Sichong Chen csc...@gmail.com wrote: Dear Community I have a large dataframe x as follows with common ids but different names: x - data.frame(ID = c(1,1,2,2,2,3,3), + Name = c(B Branch

Re: [R] R versus R Studio output differences

2012-03-09 Thread R. Michael Weylandt
Reproducible code please. (I'm quite surprised this would happen -- are you sure there's no stochastic element to your calculation that explains the differences?) But the canonical answer is the CLI R and the CRAN binaries. Michael On Fri, Mar 9, 2012 at 7:11 AM, Aayush Raman

Re: [R] R versus R Studio output differences

2012-03-09 Thread R. Michael Weylandt
Missed that...thank you. Michael On Fri, Mar 9, 2012 at 8:21 AM, peter dalgaard pda...@gmail.com wrote: On Mar 9, 2012, at 13:15 , R. Michael Weylandt wrote: Reproducible code please. (I'm quite surprised this would happen -- are you sure there's no stochastic element to your calculation

Re: [R] sort dates

2012-03-09 Thread R. Michael Weylandt
? sort x - c(Sys.Date(), Sys.Date() + 1, Sys.Date() - 1) print(x) print(sort(x)) Michael On Fri, Mar 9, 2012 at 8:35 AM, carol white wht_...@yahoo.com wrote: Hello, How is it possible to sort dates in R? Cheers, Carol __

Re: [R] Plotting shaded areas

2012-03-09 Thread R. Michael Weylandt
Perhaps ?polygon Michael On Fri, Mar 9, 2012 at 6:10 AM, aoife aoife.m.dohe...@gmail.com wrote: May I ask, is it possible using plotrix to shade a group of variables differentially from the rest of a graph, eg so the output looks similar to this, where the nodes of open circles are my nodes

Re: [R] layer plots.

2012-03-09 Thread R. Michael Weylandt
No idea what table1, table2 are plot(1:5, type = l) points(5:1, col = 2) should get you started. Michael On Fri, Mar 9, 2012 at 10:17 AM, aaral singh aaral.si...@gmail.com wrote: Hello. I have 2 plots. plot1 -plot(table1) plot2 -plot(table2) How may i plot these both on the same

Re: [R] Create a list object in a loop

2012-03-09 Thread R. Michael Weylandt
You are overriding b at each loop iteration and consequently only keeping the last one. Perhaps b - list() for(i in sort(unique(OT1$month))){ a-OT1[OT1$month==i,] b[[i]]-ppp(a$longitude,a$latitude,marks=a$fTSUM,window=newW) plot(b[[i]],main=i) } Generally it's bad practice

Re: [R] help please. 2 tables, which test?

2012-03-09 Thread R. Michael Weylandt
You should probably read up on what the chi-squared test actually tests: in one form, it asks whether some set of observations could have come from a given multinomial distribution. Concretely, it asks whether it is reasonable to get 3 blues, 4 reds, and 2 whites from a uniform distribution over

Re: [R] layer plots.

2012-03-09 Thread R. Michael Weylandt
overlapping the other? i.e. to view two sets of data in one 2D space? Many thanks On Fri, Mar 9, 2012 at 3:51 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: No idea what table1, table2 are plot(1:5, type = l) points(5:1, col = 2) should get you started. Michael

Re: [R] qbeta function in R

2012-03-09 Thread R. Michael Weylandt
It's here (search the sources for the appropriately named qbeta.c) but I can't guarantee you'll understand it easily: Martin Maechler (and others) works hard to make these the best in the business, but that performance comes at a price, here paid in opacity:

Re: [R] How do I do a pretty scatter plot using ggplot2?

2012-03-09 Thread R. Michael Weylandt
That doesn't really seem to make sense to me as a graphical representation (transforming adjacent y values differently), but if you really want to do so, here's what I'd do if I understand your goal (the preprocessing is independent of the graphics engine): DAT - data.frame(x = runif(1000, 0,

Re: [R] How do I do a pretty scatter plot using ggplot2?

2012-03-09 Thread R. Michael Weylandt
) + facet_wrap( ~ xbin) + geom_step(aes(x = seq_along(y), y = sort(y))) and see this for more: http://had.co.nz/ggplot2/geom_step.html Michael Weylandt I ran your program but couldn't figure out the meaning of the dots in your plot? Thanks again! On Fri, Mar 9, 2012 at 7:07 PM, R. Michael

Re: [R] How do I do a pretty scatter plot using ggplot2?

2012-03-09 Thread R. Michael Weylandt
thoughts? Thanks a lot! On Fri, Mar 9, 2012 at 8:51 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Fri, Mar 9, 2012 at 9:28 PM, Michael comtech@gmail.com wrote: Thanks a lot Mike! Michael if you don't mind. (Though admittedly it leads to some degree of confusion

Re: [R] Subsetting a data.frame - Read in with FWF format from .DAT file

2012-03-09 Thread R. Michael Weylandt
Inline. On Fri, Mar 9, 2012 at 7:04 PM, RHelpPlease rrum...@trghcsolutions.com wrote: Hi there, I am having trouble subsetting a data frame by a conditional via one column (of many). I read the file into R through read.fwf, where I specified column widths. Original data is .DAT.  I then

Re: [R] Paste ignore arrayys

2012-03-10 Thread R. Michael Weylandt
Read ?paste and use something like paste(GPS_, paste(TimeStamps, collapse = _), sep = ) Michael On Sat, Mar 10, 2012 at 11:41 AM, Alaios ala...@yahoo.com wrote: Dear all, I am using paste to create a file name. filename- paste(GPS_, TimeStamps, sep=) where TimeStamps is a character vector,

Re: [R] Help on subgraphs in xyplot of lattice library

2012-03-10 Thread R. Michael Weylandt
What does your data look likedput() is your friend. Also, it'd be helpful if you could give base graphics code for more-or-less what you are looking for (since you can do so already) as it's pretty hard to describe graphics without pictures. Running example(xyplot) might help you get started

Re: [R] resume on error

2012-03-10 Thread R. Michael Weylandt
? try or ? tryCatch Michael On Sat, Mar 10, 2012 at 6:08 PM, Alaios ala...@yahoo.com wrote: Dear all, I would like to ask you how I can catch an error on R and then ask it to resume. For example I have a large for loop and I know for a small number inside that loop there will be errors.

Re: [R] Generating abnormal returns in R

2012-03-10 Thread R. Michael Weylandt
Well, it's not hard to write the code for it, but if you know the secret way to accurately model abnormal returns, you'll be a far richer man than I quite soon. Less snidely, one needs to say quite a bit more about a distribution to specify it than not Gaussian. Michael On Sat, Mar 10, 2012 at

Re: [R] applying a function in list of indexed elements of a vector:

2012-03-10 Thread R. Michael Weylandt
Your code for iy doesn't work as providedI'll assume you meant this instead: iy - list(c(1, 2),c(1, 2), c(1, 2, 3, 4), c(2, 3, 5), c(4), c(5, 6, 7), c(7, 8, 9)) Then sapply(iy, function(x) sum(Y1[x])) Michael On Sat, Mar 10, 2012 at 5:01 PM, aldi a...@dsgmail.wustl.edu wrote: Hi, I

Re: [R] Help on subgraphs in xyplot of lattice library

2012-03-10 Thread R. Michael Weylandt
, idx against diff_std3. I have looked at sample xyplot codes, but still did not know how to realize this. Thanks again! Chee From: R. Michael Weylandt Sent: Saturday, March 10, 2012 12:20 PM To: Chee Chen Cc: R-ORG Subject: Re: [R] Help on subgraphs in xyplot of lattice library

Re: [R] rpanel / list error

2012-03-10 Thread R. Michael Weylandt
Your immediate problem seems to be that you use sum as a variable name when it is also a function name. You also have scoping issues that result from how you're using with() -- if you don't return an object, it gets thrown away after the with() function is done (part of the functional paradigm) --

Re: [R] (Fisher) Randomization Test for Matched Pairs: Permutation Data Setup Based on Signs

2012-03-10 Thread R. Michael Weylandt
In general, I *think* this is a hard problem (it sounds knapsack-ish) but since you are on small enough data sets, that's probably not so important: if I understand you right, this little function will help you. plusminus - function(n){ t(as.matrix(do.call(expand.grid, rep(list(c(-1,1)),

Re: [R] resume on error

2012-03-12 Thread R. Michael Weylandt
of try() to an object. Check whether that object is of class try-error and if so, do whatever you want the failure case to be. Sarah B.R Alex  From: R. Michael Weylandt michael.weyla...@gmail.com Cc: R help R-help@r-project.org Sent: Sunday, March 11

Re: [R] Window on a vector

2012-03-12 Thread R. Michael Weylandt
It's not always true that going out of bounds in subscripting gives an error (as you seem to assert in your original post) x - 1:3 x[4] # No error and note that mean() has a na.rm argument. Perhaps you should construct a *reproducible* example of what you think will go wrong. Michael On Mon,

Re: [R] how to calculate a variance and covariance matrix for a vector

2012-03-12 Thread R. Michael Weylandt
On Mon, Mar 12, 2012 at 11:42 AM, huang jialin huangps...@gmail.com wrote: Hello, I have a vector {a, b1, b2, b3, b4}. What does this mean? Is this a character vector giving names of objects that exist elsewhere in the workspace? Else, how do you tell a/b1/b2 apart in a vector? You probably

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