Re: [R] Monotone splines

2007-09-06 Thread Stephen Ellner
if your data set is large. Stephen P. Ellner ([EMAIL PROTECTED]) Department of Ecology and Evolutionary Biology Corson Hall, Cornell University, Ithaca NY 14853-2701 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] The variables combined in a table from other table and combination questions

2007-09-06 Thread Stephen Weigand
!!! Best regrards Hsin Ya Lee I don't understand exactly what you want but perhaps start with this: expand.grid(pH = c(1.2, 7.4), Formulation = c(F, S, MF)) Hope this helps, Stephen -- Rochester, Minn. USA __ R-help@stat.math.ethz.ch mailing list

Re: [R] subscript out of bounds Error in predict.naivebayes

2007-08-28 Thread Stephen Weigand
for a bigger data set and retain a subset of the predictions. Hope this helps, Stephen -- Rochester, Minn. USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R

Re: [R] How to merge string to DF

2007-08-24 Thread Stephen Tucker
This seems to work: tmp - aggregate(DF$y, list(DF$x, DF$f), mean) tmp2 - aggregate(DF$conc, list(DF$x, DF$f), paste,collapse=, ) names(tmp2)[3] - var1 final - merge(tmp,tmp2) --- Lauri Nikkinen [EMAIL PROTECTED] wrote: #Hi R-users, #I have an example DF like this: y1 - rnorm(10) + 6.8

[R] Vectors in R (WAS Re: Does anyone.... worth a warning?!? No warning at all)

2007-08-21 Thread Stephen Tucker
vectors, and the structure of the output is less unpredictable to me if I can figure out which attributes are potentially modified in the returned object. I wonder if anyone has additional thoughts on this. Stephen P.S. I agree that R/S does have its own peculiarities, but I think having them

Re: [R] Stacked Bar

2007-08-21 Thread Stephen Tucker
I think you want to use the 'density' argument. For example: barplot(1:5,col=1) legend(topleft,fill=1,legend=text,cex=1.2) par(new=TRUE) barplot(1:5,density=5,col=2) legend(topleft,fill=2,density=20,legend=text,bty=n,cex=1.2) (if you wanted to overlay solid colors with hatching) Here's the

[R] open/execute/call/run an external file

2007-08-21 Thread STEPHEN M POWERS
I'm trying to figure out how to trigger a process from within R. I have an exectuable file that runs a Fortran model, but ideally, would like to run it from R. Note that I'm not talking about importing the function at all, passing variables, or anything complicated like that. I basically just

Re: [R] polar.plot orientation and scale in plotrix

2007-08-20 Thread Stephen Tucker
I think that's the standard presentation for polar plots (theta measured from positive x-axis) - that I've seen, anyway. But for customization you can shift your origin for theta and define your own labels. For example, here is a modification to the example in the help page for polar.plot():

Re: [R] converting character string to an expression

2007-08-08 Thread Stephen Tucker
I think you're looking for parse(text=paste(letters[1:3], collapse=+)) --- Jarrod Hadfield [EMAIL PROTECTED] wrote: Hi Everyone, I would simply like to coerce a character string into an expression: something like: as.expression(paste(letters[1:3], collapse=+)) but I can't seem to

Re: [R] Catch errors

2007-08-06 Thread Stephen Tucker
?try or ?tryCatch http://www.maths.lth.se/help/R/ExceptionHandlingInR/ for example... tryCatch(lme(Y ~ X1*X2, random = ~1|subj, Model[i]), error=function(err) return(0)) (you can do something with 'err' or just return 0 as above) --- Gang Chen [EMAIL PROTECTED] wrote: I run a

Re: [R] Catch errors

2007-08-06 Thread Stephen Tucker
On Aug 6, 2007, at 1:44 PM, Stephen Tucker wrote: ?try or ?tryCatch http://www.maths.lth.se/help/R/ExceptionHandlingInR/ for example... tryCatch(lme(Y ~ X1*X2, random = ~1|subj, Model[i]), error=function(err) return(0)) (you can do something with 'err' or just

Re: [R] About grep

2007-08-06 Thread Stephen Tucker
try grep(paste(^,b[2],$,sep=),a) your version will match b2: grep(^b[2]$,c(b,b2,b3)) [1] 2 --- Shao [EMAIL PROTECTED] wrote: Hi,everyone. I have a problem when using the grep. for example: a - c(aa,aba,abac) b- c(ab,aba) I want to match the whole word,so grep(^aba$,a) it

Re: [R] using loops to create multiple images

2007-08-05 Thread Stephen Tucker
Not sure exactly what 'results' is doing there or 'barplot(table(i),...)' does [see ?table] but I think this is sort of what you want to do? ## Variable assignment G01_01 - 1:10 G01_02 - 2:6 ## Combine to list* varnames - paste(G01_,substring(100+1:2,2),sep=) vars -

Re: [R] Problems using lm in combination with predict

2007-08-04 Thread Stephen Tucker
I think you need predict(mod,newdate) instead of predict(y,newdate) --- Maja Schröter [EMAIL PROTECTED] wrote: Hello everybody, I'm trying to predict a linear regression model but it does not work. My Model: y = Worktime + Vacation + Illnes + Bankholidays My modelmatrix is of

Re: [R] methods and classes and things

2007-08-04 Thread Stephen Tucker
methods(plot) --- Edna Bell [EMAIL PROTECTED] wrote: Hi R Gurus: I know that plot has extra things like plot.ts, plot.lm How would i find out all of them, please? Thanks, Edna __ R-help@stat.math.ethz.ch mailing list

Re: [R] request

2007-08-03 Thread Stephen Tucker
?cumsum --- zahid khan [EMAIL PROTECTED] wrote: I want to calculate the commulative sum of any numeric vector with the following command but this following command does not work comsum My question is , how we can calculate the commulative sum of any numeric vector with above command

Re: [R] t-distribution

2007-08-02 Thread Stephen Tucker
p - seq(0.001,0.999,,1000) x - qt(p,df=9) y - dt(x,df=9) plot(x,y,type=l) polygon(x=c(x,rev(x)),y=c(y,rep(0,length(y))),col=gray90) Hope this helps. ST --- Nair, Murlidharan T [EMAIL PROTECTED] wrote: Indeed, this is what I wanted, I figured it from the function you and Mark pointed me.

Re: [R] line widths of plotting symbols in the lattice

2007-08-02 Thread Stephen Tucker
Thanks to all for the response - the grid.points() solution works well. Stephen (oddly I missed when this thread and its response actually got posted... was starting to get worried) --- Deepayan Sarkar [EMAIL PROTECTED] wrote: On 7/31/07, Uwe Ligges [EMAIL PROTECTED] wrote: Stephen

Re: [R] t-distribution

2007-08-02 Thread Stephen Tucker
(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(y.tmp[b]))),col=gray90) Please let me know if I have made any mistakes. Thanks ../Murli -Original Message- From: Richard M. Heiberger [mailto:[EMAIL PROTECTED] Sent: Thu 8/2/2007 10:25 AM To: Nair, Murlidharan T; Stephen

Re: [R] y axix number into horizontal direction

2007-08-02 Thread Stephen Tucker
try par(las=1) plot(0,0,xaxt=n,type=n, ylim=c(0,100)) mtext(35,side=2,at=35) you can use 'las=1' in par(), plot(), axis(), etc. more generally, you can use 'srt' in text() to rotate tick labels: plot(1:10,1:10,xaxt=n,type=n, yaxt=n,ylim=c(0,100)) axis(1); axis(2,lab=FALSE)

[R] passing args to R CMD BATCH in win 2000

2007-08-01 Thread Stephen . Bond
is not passed to the R process. 11.Rout only shows processing time and 13.out does not have the value. Thank you all. stephen [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] shadow between two lines in plot()

2007-08-01 Thread Stephen Tucker
see ?rect, or, for more general shapes, ?polygon ## EXAMPLES plot(c(0,500),c(0,500),type=n,las=1) rect(par(usr)[1],200,par(usr)[2],300,col=grey90) points(seq(0,500,length=3),seq(0,500,length=3)) plot(c(0,500),c(0,500),type=n,las=1) polygon((par(usr)[1:2])[c(1,1,2,2)],

Re: [R] new user question on dataframe comparisons and plots

2007-08-01 Thread Stephen Tucker
Hi Conor, I hope I interpreted your question correctly. I think for the first one you are looking for a conditioning plot? I am going to create and use some nonsensical data - 'iris' comes with R so this should be reproducible on your machine: library(lattice) data(iris) x - iris # make some

Re: [R] Fitting exponential curve to data points

2007-07-30 Thread Stephen Tucker
Sorry, just got back into town. I wonder if AIC, BIC, or cross-validation scoring couldn't also be used as criteria for model selection - I've seen it mostly in the context of variable selection rather than 'form' selection but in principle might apply here? --- Dieter Menne [EMAIL PROTECTED]

Re: [R] manipulating arrays

2007-07-30 Thread Stephen Tucker
I think you are looking for append(), though it won't modify the object in-place like Python [I believe that is a product of R's 'functional programming' philosophy]. might want to check this entertaining thread: http://tolstoy.newcastle.edu.au/R/help/04/11/7727.html in this example it would be

[R] line widths of plotting symbols in the lattice

2007-07-30 Thread Stephen Tucker
looking through the documentation for xyplot, panel.points, trellis.par.set, and the R-help archives. Maybe it goes by another name? Thanks in advance, Stephen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

Re: [R] Redirecting print output

2007-07-24 Thread Stephen Tucker
Here are two simple ways: === method1 === cat(line1,\n,file=output.txt) cat(line2,\n,file=output.txt,append=TRUE) === method2 === sink(output.txt) cat(line1,\n) cat(line2,\n) out - lm(y~x,data=data.frame(x=1:10,y=(1:10+rnorm(10,0,0.1 print(out) sink() And then there is 'Sweave'. Check out,

Re: [R] persp and greek symbols in the axes labels

2007-07-24 Thread Stephen Tucker
I don't know why it doesn't work but I think people generally recommend that you use wireframe() in lattice rather than persp(), because wireframe is more customizable (the pdf document referred to in this post is pretty good): http://tolstoy.newcastle.edu.au/R/e2/help/07/03/12534.html Here's an

Re: [R] Fitting exponential curve to data points

2007-07-24 Thread Stephen Tucker
I think your way is probably the easiest (shockingly). For instance, here are some alternatives - I think in both cases you have to calculate the coefficient of determination (R^2) manually. My understanding is that multiple R^2 in your case is the usual R^2 because you only have one predictor

Re: [R] Fitting exponential curve to data points

2007-07-24 Thread Stephen Tucker
Well spoken. And since log transformations are nonlinear and 'compresses' the data, it's not surprising to find that the fit doesn't look so nice while the fit metrics tell you that a model does a good job. --- [EMAIL PROTECTED] wrote: On 24-Jul-07 01:09:06, Andrew Clegg wrote: Hi folks,

[R] Fwd: Re: Fitting exponential curve to data points

2007-07-24 Thread Stephen Tucker
around that. --- Stephen Tucker [EMAIL PROTECTED] wrote: ## Data input input - Year Count 1999 3 2000 5 2001 9 2002 30 2003 62 2004 154 2005 245 2006 321 dat - read.table(textConnection(input),header=TRUE) dat[,] - lapply(dat,function(x) x-x[1]) # shifting

Re: [R] Data Set

2007-07-23 Thread Stephen Tucker
know how it was created originally but may be convenient to reassign names by names(Monsoon) - make.names(names(Monsoon)) --- Gavin Simpson [EMAIL PROTECTED] wrote: On Sun, 2007-07-22 at 21:51 -0700, Stephen Tucker wrote: It turns out that - and (space) are not valid variable names

Re: [R] ?R: Removing white space betwen multiple plots, traditional graphics

2007-07-22 Thread Stephen Tucker
You could try par(mar=c(0,5,0,2), mfrow = c(6,1), oma=c(5,0,2,0)) ##...then, your plots...## --- Mr Natural [EMAIL PROTECTED] wrote: I would appreciate suggestions for removing the white spaces the graphs in a stack: par(mar=c(2,2,1,1), mfrow = c(6,1)) mydates-dates(1:20,origin=c(month

Re: [R] tagging results of apply

2007-07-22 Thread Stephen Tucker
-0.03372794 -0.05874675 Hope this helps, Stephen --- Bernzweig, Bruce (Consultant) [EMAIL PROTECTED] wrote: In trying to get a better understanding of vectorization I wrote the following code: My objective is to take two sets of time series and calculate the correlations for each

Re: [R] tagging results of apply

2007-07-22 Thread Stephen Tucker
-0.8213577 0.371248 mat2col5 -0.001457972 0.03998203 0.4273667 0.526239 0.4390378 --- Stephen Tucker [EMAIL PROTECTED] wrote: Dear Bruce, In your functions, you need to use your bound variable, 'x' [not mat1] in your anonymous function [function(x)] as the argument to cor

Re: [R] Data Set

2007-07-22 Thread Stephen Tucker
Could you post the output from str(data) ? Perhaps that will give us a clue. --- amna khan [EMAIL PROTECTED] wrote: Sir the station name S.Sharif exists in the data but still the error is ocurring of being not found. Please help in this regard. On 7/22/07, Gavin Simpson [EMAIL

Re: [R] Write columns from within a list to a matrix?

2007-07-22 Thread Stephen Tucker
Very close... Actually it's more like savecol2=sapply(test, function(x) x[,1]) to get the same matrix as you showed in your for-loop (did you actually want the first or second column?). when I have multiple complex lists I am trying to manage... for this, you can try mapply() which goes

Re: [R] Data Set

2007-07-22 Thread Stephen Tucker
... $ Faisalabad: num [1:56] 79.2 43.9 55.4 ... $ Lahore: num [1:60] 32.5 81.5 28.7 ... when I attach the data file and access the site S-Sharif or D-I Khan or Mian Wali then error messages occur. Please help in this regard. Thank You On 7/23/07, Stephen Tucker [EMAIL

Re: [R] how to combine presence only data sets to one presence/absence table

2007-07-18 Thread Stephen Tucker
I think you can still read as a table, just use argument fill=TRUE. Reading from Excel in general: you can save data as 'csv' or tab-delimited file and then use read.csv or read.delim, respectively, or use one of the packages listed in the following post (for some reason lines breaks are messed

Re: [R] Drawing rectangles in multiple panels

2007-07-17 Thread Stephen Tucker
, ...) } panel.qrect - function(rect.info) { function(x, y, ...) { environment(ri) - environment() ### ri(x, y, ..., rect.info = rect.info) } } xyplot(runif(30) ~ runif(30) | gl(3, 10), panel = panel.qrect(rectInfo)) On 7/14/07, Stephen

Re: [R] Drawing rectangles in multiple panels

2007-07-17 Thread Stephen Tucker
good to know (and cool demonstrations btw). Thanks! Stephen --- Deepayan Sarkar [EMAIL PROTECTED] wrote: On 7/14/07, Stephen Tucker [EMAIL PROTECTED] wrote: I wonder what kind of objects? Are there large advantages for allowing lattice functions to operate on objects other than data frames

Re: [R] Optimization

2007-07-17 Thread Stephen Tucker
My apologies, didn't see the boundary constraints. Try this one... f - function(x) (sqrt((x[1]*0.114434)^2+(x[2]*0.043966)^2+(x[3]*0.100031)^2)-0.04)^2 optim(par=rep(0,3),f,lower=rep(0,3),upper=rep(1,3),method=L-BFGS-B) and check ?optim --- massimiliano.talarico [EMAIL PROTECTED] wrote:

Re: [R] scaling of different data sets in ggplot

2007-07-17 Thread Stephen Tucker
their language... So, hope you don't mind, but I may ask some more 'can ggplot do this' questions in the future. But keep up the good work, Stephen --- hadley wickham [EMAIL PROTECTED] wrote: Hi Stephen, You can't do that in ggplot (have two different scales) because I think it's generally

Re: [R] Optimization

2007-07-17 Thread Stephen Tucker
f - function(x) (sqrt((x[1]*0.114434)^2+(x[2]*0.043966)^2+(x[3]*0.100031)^2)-0.04)^2 optim(c(0,0,0),f) see ?optim for details on arguments, options, etc. --- massimiliano.talarico [EMAIL PROTECTED] wrote: I'm sorry the function is

Re: [R] Optimization

2007-07-17 Thread Stephen Tucker
My apologies, I read the post over too quickly (even the second time). It's been a while since I've played around with anything other than box constraints, but this one is conducive to a brute-force approach (employing Berwin suggestions). The pseudo-code would look something like this: delta -

Re: [R] Alternative to xyplot()?

2007-07-17 Thread Stephen Tucker
What's wrong with lattice? Here's an alternative: library(ggplot2) ggplot(data=data.frame(x,y,grps=factor(grps)), mapping=aes(x=x,y=y,colour=grps)) + # define data geom_identity() +# points geom_smooth(method=lm) # regression line

[R] polymorphic functions in ggplot? (WAS Re: Drawing rectangles in multiple panels)

2007-07-14 Thread Stephen Tucker
Regarding your earlier statement, I tend to think in very data centric approach, where you first generate the data (in a data frame) and then you plot it. There is very little data creation/modification during the plotting itself... Is the data generation and plotting truly separate and

[R] scaling of different data sets in ggplot

2007-07-14 Thread Stephen Tucker
the scaling a priori to create a new variable, (2) plotting points from the new variable, and (3) creating a new axis with custom labels. Which then brings me back to ...how to add new guides? :) Thanks, Stephen

Re: [R] How to read many files at one time?

2007-07-14 Thread Stephen Tucker
This should do it: allData - sapply(paste(Sim,1:20,sep=), function(.x) read.table(paste(.x,txt,sep=.)), simplify=FALSE) see ?read.table for specification of delimiters, etc. allData will be a list, and you can access the contents of each file by any of the

Re: [R] Drawing rectangles in multiple panels

2007-07-14 Thread Stephen Tucker
I wonder what kind of objects? Are there large advantages for allowing lattice functions to operate on objects other than data frames - I couldn't find any screenshots of flowViz but I imagine those objects would probably be list of arrays and such? I tend to think of mapply() [and more recently

Re: [R] Drawing rectangles in multiple panels

2007-07-14 Thread Stephen Tucker
(panel.qrect, list(rect.info = rectInfo))) The createWrapper approach does have an advantage in the situation where the function analogous to panel.qrect is existing since using scoping then involves manipulation of environments in the closure approach. On 7/11/07, Stephen Tucker [EMAIL PROTECTED

Re: [R] Drawing rectangles in multiple panels

2007-07-11 Thread Stephen Tucker
Not that Trellis/lattice was entirely easy to learn at first. :) I've been playing around with ggplot2 and there is a plot()-like wrapper for building a quick plot [incidentally, called qplot()], but otherwise it's my understanding that you superpose elements (incrementally) to build up to the

Re: [R] Drawing rectangles in multiple panels

2007-07-11 Thread Stephen Tucker
In the Trellis approach, another way (I like) to deal with multiple pieces of external data sources is to 'attach' them to panel functions through lexical closures. For instance... rectInfo - list(matrix(runif(4), 2, 2), matrix(runif(4), 2, 2), matrix(runif(4), 2, 2))

Re: [R] Drawing rectangles in multiple panels

2007-07-11 Thread Stephen Tucker
appealing - in an hour I picked up enough to do quite a bit, just by going through examples in the author's book http://had.co.nz/ggplot2/. Will be interesting to see how this package will be received by the community. Stephen --- Stephen Tucker [EMAIL PROTECTED] wrote: Not that Trellis/lattice

Re: [R] Multiple Stripcharts

2007-07-07 Thread Stephen Tucker
I'm not able to make out your data but something like this? df - data.frame(A=rnorm(10),B=rnorm(10),C=runif(10)) stripchart(df,method=jitter) --- Tavpritesh Sethi [EMAIL PROTECTED] wrote: Hi all, I have 205 rows with measurements for three categories of people. I want to generate stripplots

Re: [R] color scale in rgl plots

2007-07-07 Thread Stephen Tucker
Hi David, I'm not an expert in 'rgl', but to determine data-dependent color for points I often use cut(). # using a very simple example, x - 1:2; y - 1:2; z - matrix(1:4,ncol=2) # the following image will be a projection of my intended 3-D 'rgl' plot # into 2-D space (if we don't consider color

Re: [R] Loop and function

2007-07-05 Thread Stephen Tucker
You do not have matching parentheses in this line returnlow - gpdlow(var[,i][var[,i](p[,i][[2]]) most likely there is a syntax error that halts the execution of the assignment statement? --- livia [EMAIL PROTECTED] wrote: Hi All, I am trying to make a loop for a function and I am using

Re: [R] select data from large CSV file

2007-07-05 Thread Stephen C. Upton
Hi Lars, I haven't tried this, but I believe there were a couple of messages on the list recently on reading large files that basically used scan with connections, and reading in by blocks. see ?scan, ?connections HTH steve Lars Modig wrote: Hello I’ve got a large CSV file (500M) with

[R] nls() lower/upper bound specification

2007-07-04 Thread Stephen Tucker
), lower=list(beta1=1,beta2=1,beta3=1)) Thanks in advance! Stephen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented

Re: [R] Problems using imported data

2007-07-03 Thread Stephen Tucker
Actually, I believe attach() and detached() is discouraged nowadays... x - read.delim(Filename.txt, header=TRUE) You can access your data by column: x[,1] x[,c(1,3)] or if your first column is named Col1 and the third Col3, x[,Col1] x[,c(Col1,Col3)] and you can do the same to access by row -

Re: [R] regexpr

2007-06-29 Thread Stephen Tucker
I think you are looking for paste(). And you can replace your for loop with lapply(), which will apply regexpr to every element of 'mylist' (as the first argument, which is 'pattern'). 'text' can be a vector also: mylist - c(MN,NY,FL) lapply(paste(mylist,$,sep=),regexpr,text=Those from MN:)

Re: [R] Assign name to a name

2007-06-29 Thread Stephen Tucker
You can just create another variable which contains the names you want: ## let Year - c(rep(1999,2),rep(2000,2),rep(2001,3)) ## one alternative getYearCode1 - function(yr) { # yr can be a vector ifelse(yr==1999,Year1, ifelse(yr==2000,Year2, ifelse(yr==2001,Year3)))

Re: [R] Function call within a function.

2007-06-28 Thread Stephen Tucker
Dear John, Perhaps I am mistaken in what you are trying to accomplish but it seems like what is required is that you call lstfun() outside of ukn(). [and remove the call to lstfun() in ukn()]. nts - lstfun(myfile, aa, bb) results - ukn(dd1, a, b, nts$cda) Alternatively, you can eliminate the

Re: [R] Looking for parallel functionality between Matlab and R

2007-06-27 Thread Stephen Tucker
This zooming function on the R-Wiki page was very neat: http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:interactive_zooming Also, to answer question (a), maybe these examples might help? ## add elements to plot plot(1:10,1:10) lines(1:10,(1:10)/2) points(1:10,(1:10)/1.5) ## add

Re: [R] simultaneous actions of grep ???

2007-06-26 Thread Stephen Tucker
You can list them together using | (which stands for 'or'): c-subset(c,!rownames(c) %in% grep(.1|.5|.6|.9,rownames(c),value=T)) but . means any character for regular expressions, so if you meant a decimal place, you probably want to escape them with a \\: c-subset(c,!rownames(c) %in%

Re: [R] simultaneous actions of grep ???

2007-06-26 Thread Stephen Tucker
My mistake... last alternative should be: c-subset(c,regexpr(\\.1|\\.5|\\.6|\\.9,rownames(c)) 0) --- Stephen Tucker [EMAIL PROTECTED] wrote: You can list them together using | (which stands for 'or'): c-subset(c,!rownames(c) %in% grep(.1|.5|.6|.9,rownames(c),value=T

Re: [R] changing the position of the y label (ylab)

2007-06-26 Thread Stephen Tucker
If by 'position' you mean the distance from the axes, I think 'mgp' is the argument you are looking for (see ?par)- You can set this in par(), plot() [which will affect both x and y labels], or title(): par(mar=rep(6,4)) plot(NA,NA,xlim=0:1,ylim=0:1,xlab=X,ylab=) title(ylab=Y2,mgp=c(4,1,0)) if

Re: [R] ylab at the right hand of a plot with two y axes

2007-06-26 Thread Stephen Tucker
Here are two ways: ## method 1 plot(1:100,y1) par(new=TRUE) plot(1:100,y2,xlab=,ylab=,col=2,axes=FALSE) axis(4,col=2,col.axis=2) ## method 2 plot.new() plot.window(xlim=c(1,100),ylim=range(y1)) points(1:100,y1) axis(1) axis(2) title(xlab=x,ylab=y1) plot.window(xlim=c(1,100),ylim=range(y2))

Re: [R] R-excel

2007-06-25 Thread Stephen Tucker
There are also some notes about this in the R Data Import/Export manual: http://cran.r-project.org/doc/manuals/R-data.html#Reading-Excel-spreadsheets But I've gathered the following examples from the R-help mailing list archives [in addition to the option of saving the spreadsheet as a .csv file

Re: [R] FW: Suse RPM installation problem

2007-06-22 Thread Stephen Henderson
why 'whereis' does not identify this-- or why it lists the file 3 times?. I'm also puzzled why they chose to call the file exactly the same thing. I will next try rpm --force as you suggest. Stephen -Original Message- From: Peter Dalgaard [mailto:[EMAIL PROTECTED] Sent: Fri 6/22/2007

Re: [R] FW: Suse RPM installation problem

2007-06-22 Thread Stephen Henderson
this and not the 32bit file? Or do I need to edit something in the rpm file? Thanks -Original Message- From: Peter Dalgaard [mailto:[EMAIL PROTECTED] Sent: Thu 6/21/2007 6:34 PM To: Stephen Henderson Cc: r-help@stat.math.ethz.ch Subject: Re: [R] FW: Suse RPM installation problem Stephen Henderson

[R] FW: Suse RPM installation problem

2007-06-21 Thread Stephen Henderson
reading the Installation manual I noted that libpng is mention in the context of a source build. I therefore downloaded libpng-1.2.18 (v-1.2.8 or later is specified in the manual) and succesfully compiled this. This did not however help with my problem. Any suggestions? Thanks Stephen Henderson

Re: [R] Dissimilarity Analysis

2007-06-20 Thread stephen cox
with the labdsv library itself - nothing you are doing wrong. The results will still be valid - but the use of symbol.For is something that will eventually need to be changed in the labdsv library. hth, stephen __ R-help@stat.math.ethz.ch mailing list https

Re: [R] Computing time differences

2007-06-20 Thread Stephen Tucker
Here is one way: Vector1 - c(20080621.00,20080623.00) Vector2 - c(20080620.00,20080622.00) do.call(difftime, c(apply(cbind(time1=Vector1,time2=Vector2),2, function(x) strptime(x,format=%Y%m%d.00)), units=hours)) see ?strptime, ?difftime and

Re: [R] data type for block data?

2007-06-19 Thread Stephen Tucker
Hi Paul, Hope this is what you're looking for: ## reading in text (the first 13 rows of cc from your posting) ## and using smaller indices [(3,8) instead of (10,40)] ## for this example cc - mode-(do.call(rbind, +strsplit(readLines(textConnection(txt))[-1],[ ]{2,}))[,-1], +

Re: [R] : create a PDF file (text (print list) and grafics)

2007-06-19 Thread Stephen Tucker
Hi Ana, There are two ways in which I imagine this can be done: (1) create a layout [using layout()] and printing the text on a blank plot; (2) using Sweave. ## === Method 1 example... === pdf() layout(matrix(c(1,1,2,3),ncol=2,byrow=TRUE),widths=c(1,1),heights=c(3,2)) par(mar=c(0,0,5,0))

[R] passing (or obtaining) index or element name of list to FUN in lapply()

2007-06-13 Thread Stephen Tucker
for x in D.iteritems()] ## returns element key (name) along with element contents [('sape', 4139), ('jack', 4098)] And this is something of the effect I was looking for... Thanks to all, Stephen __ R-help@stat.math.ethz.ch mailing list https

Re: [R] Viewing a data object

2007-06-13 Thread Stephen Tucker
Hi Horace, I have also thought that it may be useful but I don't know of any Object Explorer available for R. However, (you may alread know this but) (1) you can view your list of objects in R with objects(), (2) view objects in a spreadsheet-like table (if they are matrices or data frames)

Re: [R] passing (or obtaining) index or element name of list to FUN in lapply()

2007-06-13 Thread Stephen Tucker
a fear response at the thought of a loop... (and as of recently, I have been infatuated with the notion of adhering, albeit loosely, to the 'functional programming' paradigm which makes me doubly fearful of loops) Thanks and best regards, Stephen --- Prof Brian Ripley [EMAIL PROTECTED] wrote: On Tue

Re: [R] selecting characters from a line of text

2007-06-11 Thread Stephen Tucker
Maybe substring() is what you're looking for? Some examples: substring(textstring,1,5) [1] texts substring(textstring,3) [1] xtstring substring(textstring,3,nchar(textstring)) [1] xtstring --- Tim Holland [EMAIL PROTECTED] wrote: Is there a way in R to select certain characters from a line

Re: [R] How to specify the start position using plot

2007-06-10 Thread Stephen Tucker
plot(x=1:10,y=1:10,xlim=c(0,5),ylim=c(6,10)) a lot of the arguments descriptions for plot() are contained in ?par --- Patrick Wang [EMAIL PROTECTED] wrote: Hi, How to specify the start position of Y in plot command, hopefully I can specify the range of X and Y axis. I checked the ?plot,

Re: [R] Tools For Preparing Data For Analysis

2007-06-10 Thread Stephen Tucker
Since R is supposed to be a complete programming language, I wonder why these tools couldn't be implemented in R (unless speed is the issue). Of course, it's a naive desire to have a single language that does everything, but it seems that R currently has most of the functions necessary to do the

Re: [R] Tools For Preparing Data For Analysis

2007-06-10 Thread Stephen Tucker
4 [2,] 2 4 5 [3,] 3 4 6 # then mode(m) - numeric # or m - apply(m,2,type.convert) # will give m [,1] [,2] [,3] [,4] [1,]12 NA4 [2,]2 NA45 [3,]34 NA6 --- [EMAIL PROTECTED] wrote: On 10-Jun-07 19:27:50, Stephen Tucker wrote

Re: [R] Different fonts on different axes

2007-05-31 Thread Stephen Weigand
There's also this approach plot(runif(10), ylab=list(Red, Bold?, col = red, font = 2), xlab=Black, standard?) On 5/31/07, Greg Snow [EMAIL PROTECTED] wrote: Try this: plot(runif(10), ylab=, xlab=Black, standard?) mtext('Red, Bold', side=2, line=3, col='red', font=2) Hope this helps,

Re: [R] looking for the na.omit equivalent for a matrix of characters

2007-05-28 Thread Stephen Tucker
You can also use type.convert() if you did want to convert your characters to numbers and NA's to NA's so that you can use na.omit(). x - matrix(0,5,5) x[1,3] - x[4,4] - NA newx - apply(x,2,type.convert) newx [,1] [,2] [,3] [,4] [,5] [1,]00 NA00 [2,]0000

Re: [R] lme with corAR1 errors - can't find AR coefficient in output

2007-05-25 Thread Stephen Weigand
$model$corStruct, unconstrained = FALSE) Stephen -- Rochester, Minn. USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

[R] [R-pkgs] New package earth

2007-05-11 Thread Stephen Milborrow
of cases: 31 Selected 4 of 5 terms, and 2 of 2 predictors Number of terms at each degree of interaction: 1 3 (additive model) GCV: 11 RSS: 213 GRSq: 0.96 RSq: 0.97 Regards, Stephen Milborrow ___ R-packages mailing list [EMAIL PROTECTED] https

Re: [R] loop in function

2007-05-05 Thread Stephen Tucker
Actually I am not sure what you want exactly, but is it df1 -data.frame(b=c(1,2,3,4,5,5,6,7,8,9,10)) df2 -data.frame(x=c(1,2,3,4,5), y=c(2,5,4,6,5), z=c(10, 8, 7, 9, 3)) df1 - cbind(df1, colnames-(sapply(with(df2,(x+y)/z), function(a,b) a/b,b=df1$b),

Re: [R] Single Title for the Multiple plot page

2007-05-03 Thread Stephen Tucker
Sometimes I just overlay a blank plot and annotate with text. par(mfrow=c(1,2), oma=c(2,0,2,0)) plot(1:10) plot(1:10) oldpar - par() par(mfrow=c(1,1),new=TRUE,mar=rep(0,4),oma=rep(0,4)) plot.window(xlim=c(0,1),ylim=c(0,1),mar=rep(0,4)) text(0.5,c(0.98,0.02),c(Centered Overall Title,Centered

[R] regular expressions with grep() and negative indexing

2007-04-25 Thread Stephen Tucker
am trying to minimize intermediate variable assignment (perhaps a futile effort). But if anyone knows of an easy solution, I'd appreciate a tip. Thanks very much! Stephen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r

Re: [R] Sum of specific column

2007-04-25 Thread Stephen Weigand
Good luck, Stephen -- Rochester, Minn. USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained

Re: [R] regular expressions with grep() and negative indexing

2007-04-25 Thread Stephen Tucker
Thanks guys for the suggestions guys- I come across this problem a lot but now I have many solutions. Thank you, Stephen --- Peter Dalgaard [EMAIL PROTECTED] wrote: Peter Dalgaard wrote: Stephen Tucker wrote: Dear R-helpers, Does anyone know how to use regular expressions

Re: [R] queries

2007-04-22 Thread Stephen Tucker
hist(rnorm(100),xlab=Data,ylab=Count,main=) title(main=Histogram of ...,cex=0.5) see ?par for details on xlab, ylab, main, and cex arguments. You can call these from title() or include them in hist(). I called title(main=..) separately to control its size separately from the rest of the text

Re: [R] queries

2007-04-22 Thread Stephen Tucker
My apologies. Second line should be title(main=Histogram of ...,cex.main=0.5) Actually I just realized you can also do hist(rnorm(100),xlab=Data,ylab=Count,cex.main=0.5) ...this way you don't have to call title() separately. --- Stephen Tucker [EMAIL PROTECTED] wrote: hist(rnorm(100),xlab

Re: [R] Opinion on R plots: connecting X and Y

2007-04-20 Thread Stephen Tucker
Edward Tufte seems to have some opinions on this topic. In The Visual Display of Quantitative Information (Chapter 6: Data-Ink Maximization and Graphical Design - Redesign of the Scatterplot), he presents several alternatives (1) non-data-bearing frame in conventional scatterplots (equivalent to

Re: [R] Using mean if two values are identical

2007-04-19 Thread Stephen Tucker
## making data up # make matrix with some equal values mat - cbind(x=rnorm(10),y=rnorm(10),z=rnorm(10)) mat[c(8,9),y] - mat[c(1,7),x] mat x y z [1,] 0.26116849 0.5823529 -0.96924020 [2,] -0.21415406 0.1085396 2.00542549 [3,] 0.56890081 -1.2526322

Re: [R] Error with strptime

2007-04-19 Thread Stephen Tucker
you have to use POSIXct classes to include date-time objects into data frames. strptime() returns an object of class of POSIXlt. when you do the cbind(), it automatically converts test2 into POSIXct you probably want bsamp$spltime-as.POSIXct(strptime(test,format=%d-%B-%y %H:%M)) (but please be

Re: [R] Character coerced to factor and I cannot get it back

2007-04-19 Thread Stephen Tucker
You can also set this option globally with options(stringsAsFactors = TRUE) I believe this was added in R 2.4.0. --- Gabor Grothendieck [EMAIL PROTECTED] wrote: Try this: DF - data.frame(let = letters[1:3], num = 1:3, stringsAsFactors = FALSE) str(DF) On 4/19/07, John Kane [EMAIL

Re: [R] importing excel-file

2007-04-18 Thread Stephen Tucker
I use gdata and it works quite well for me. It's as easy as install.packages(gdata) library(gdata) data = read.xls(mydata.xls,sheet=1) [read.xls() can take other arguments] It requires concurrent installation of Perl, but installing Perl is also simple. For Windows, you can get it here:

Re: [R] Data Manipulation using R

2007-04-18 Thread Stephen Tucker
...is this what you're looking for? donedat - subset(data,ID 6000 | ID = 7000) findat - donedat[-unique(rapply(donedat,function(x) which( x 0 ))),,drop=FALSE] the second line looks through each column, and finds the indices of negative values - rapply() returns

  1   2   3   >