Re: [R] Can I set default parameters for the default graphics device?

2010-07-15 Thread James
Erik, On Thu, Jul 15, 2010 at 9:27 PM, Erik Iverson wrote: > Isn't that what you can do after you define mypng and set > options(device = "mypng") Thank you!  I completely missed the second part where you use that as the default device.  I must have skimmed your email. I'm definitely going to t

Re: [R] Sweave: infelicities with lattice graphics

2010-07-15 Thread Deepayan Sarkar
On Thu, Jul 15, 2010 at 1:51 PM, Michael Friendly wrote: > In a paper I'm writing using Sweave, I make use of lattice graphics, but > don't want to explicitly show (or explain) > in the article text the print() wrapper I need in code chunks for the graphs > to appear. I can solve this by including

Re: [R] aggregate(...) with multiple functions

2010-07-15 Thread Dennis Murphy
Hi: A nice package for doing this sort of thing is doBy. Let's manufacture an example since you didn't provide one: set.seed(126) d <- data.frame(g = rep(letters[1:3], each = 10), x1 = rnorm(30), x2 = rnorm(30, mean = 5), x3 = rnorm(30, mean = 10

Re: [R] export tables to excel files on multiple sheets with titles for each table

2010-07-15 Thread Erich Neuwirth
If you are exporting your dataframes to Excel on Windows and if you have Excel installed and if you are willing to make your hands dirty by programming VBA (the programming language built into Excel) and if you are willing to install RExcel (by way of the CRAN package RExcelInstaller or by visiti

Re: [R] how to skip a specific value when using apply() function to a matrix?

2010-07-15 Thread Wu Gong
There may exists a good solution, but I can only give a shortcut:) tmp2 <- (tmp1!=0)*tmp3 - A R learner. -- View this message in context: http://r.789695.n4.nabble.com/how-to-skip-a-specific-value-when-using-apply-function-to-a-matrix-tp2290898p2290925.html Sent from the R help mailing li

Re: [R] How to plot a histogram of weekday frequencies in a list of dates?

2010-07-15 Thread Wu Gong
Correction: ## Minus 7*60*60 seconds to change AM interval from 0-12AM to 7AM-7PM barplot(table(format((dates-7*60*60), "%w %p")),names.arg=labels) - A R learner. -- View this message in context: http://r.789695.n4.nabble.com/How-to-plot-a-histogram-of-weekday-frequencies-in-a-list-of-date

[R] Effects library LSM decimal place errors

2010-07-15 Thread Nieves Felipe
G'day, I'm calculating LSM for the following model, and am finding that R and SAS give different answers. Whilst the error is at the second or third decimal, the percentage error can be quite large. I'm using the effects library (Version: 2.0-10) on R 2.11.1 in the following manner: options(contr

Re: [R] How to plot a histogram of weekday frequencies in a list of dates?

2010-07-15 Thread Wu Gong
Hope it works. ## Create a sample of dates dates <- sample(seq(ISOdate(2009,1,1), ISOdate(2009,12,31), "hour"),1000) ## Create 14 labels for barplot("Mon AM","Mon PM",etc.) labels <- format(seq(ISOdate(2010,7,11,5), ISOdate(2010,7,18,4), "12 hours"),"%a %p") ## Use table function to calculate

[R] how to skip a specific value when using apply() function to a matrix?

2010-07-15 Thread Shuhua Zhan
Hello R experts, I'd like to studentize a matrix (tmp1) by column using apply() function and skip some specific values such as zeros in the example below to tmp2 but not tmp3. I used the script below and only can get a matrix tmp3. Could you please help me to studentize the matrix (tmp1) without

Re: [R] aggregate(...) with multiple functions

2010-07-15 Thread Gabor Grothendieck
On Thu, Jul 15, 2010 at 10:45 PM, Murat Tasan wrote: > hi all - i'm just wondering what sort of code people write to > essentially performa an aggregate call, but with different functions > being applied to the various columns. > > for example, if i have a data frame x and would like to marginaliz

[R] aggregate(...) with multiple functions

2010-07-15 Thread Murat Tasan
hi all - i'm just wondering what sort of code people write to essentially performa an aggregate call, but with different functions being applied to the various columns. for example, if i have a data frame x and would like to marginalize by a factor f for the rows, but apply mean() to col1 and medi

Re: [R] loess line predicting number where the line crosses zero twice

2010-07-15 Thread Peter Alspach
Tena koe Stephen You'll need to use loess(w[,"bkf_depths"]~w[,"measure"])) and predict with a sufficiently dense sequence of w[,'measure'] to interpolate to an 'accuracy' that meets your requirements. Actually, if I understand your data correctly, it could be that simple linear interpolation (

Re: [R] Storing processed results back into original objects

2010-07-15 Thread Jonathan Christensen
Steven, You can do it with assign() if you keep the names when you put the items in the list: Dlist <- list(D1=D1, D2=D2) # put the names of the objects in the list Newlist <- lapply(Dlist, function(x) x[, columns]) # create a new list with the output for(i in seq(length(Newlist))) { assign(na

Re: [R] Storing processed results back into original objects

2010-07-15 Thread Dennis Murphy
Hi: This seems to work: b <- lapply(Dlist, function(x) x[, columns]) dnames <- c('D1', 'D2') for(i in seq_along(dnames)) assign(dnames[i], b[[i]]) HTH, Dennis On Thu, Jul 15, 2010 at 6:18 PM, Steven Kang wrote: > Hi all, > > There are matrices with same column names but arranged in different o

Re: [R] Creating functions of "many" arguments

2010-07-15 Thread Erik Iverson
On 07/15/2010 08:32 PM, Axel Urbiz wrote: Dear users, My apologies for the simple question. I'd like to create a function where the number of arguments is as big as the size of my data set. Supose I have n observations in my data, how can I write a function like fun<- function (x1,x2,,xn)

[R] Creating functions of "many" arguments

2010-07-15 Thread Axel Urbiz
Dear users, My apologies for the simple question. I'd like to create a function where the number of arguments is as big as the size of my data set. Supose I have n observations in my data, how can I write a function like fun <- function (x1,x2,,xn) {x1*x2*...*xn} Thanks in advance for y

Re: [R] Can I set default parameters for the default graphics device?

2010-07-15 Thread Erik Iverson
So instead of: > mypng() > x=c(1,2,3) > plot(x,x) I can just do: > x=c(1,2,3) > plot(x,x) Isn't that what you can do after you define mypng and set options(device = "mypng") ? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailm

[R] Storing processed results back into original objects

2010-07-15 Thread Steven Kang
Hi all, There are matrices with same column names but arranged in different orders and I desire columns of these matrices to have same order. For example, below are 2 arbitrary data sets with columns arranged in different order. I require columns of these to have same order as specified in "colum

Re: [R] Can I set default parameters for the default graphics device?

2010-07-15 Thread James
On Thu, Jul 15, 2010 at 8:43 PM, Erik Iverson wrote: > On 07/15/2010 07:10 PM, James wrote: >> I'm completely new to R, and I'd like to do something like this: >> > x=c(1,2,3) >> > plot(x,x) >> At this point, R creates a file "Rplots.pdf", since the default device is >> PDF and the defa

Re: [R] Can I set default parameters for the default graphics device?

2010-07-15 Thread James
On Thu, Jul 15, 2010 at 8:36 PM, Sam Albers wrote: > Unless you aren't writing scripts why wouldn't you just use something like > this? > I'm writing scripts, and this is a convenience feature I'm trying to implement. I know it can be done manually, but I'd love to be able to set the default nam

Re: [R] Separating parts of a column of data in R

2010-07-15 Thread Wu Gong
I don't really understand your question. The function unique can remove duplicate elements. - A R learner. -- View this message in context: http://r.789695.n4.nabble.com/Separating-parts-of-a-column-of-data-in-R-tp2290793p2290840.html Sent from the R help mailing list archive at Nabble.com.

[R] Weighted densityplot?

2010-07-15 Thread Farley, Robert
I'm trying to plot a series of densities using/comparing differing weights. I see the reference to weights and subscripts, but I don't understand how to implement that. My data are of the form: I, J, Actual, Distance, Subset, Weight1, Weight2, ... I'm trying to see the effect of the distance

Re: [R] Can I set default parameters for the default graphics device?

2010-07-15 Thread Erik Iverson
On 07/15/2010 07:10 PM, James wrote: I'm completely new to R, and I'd like to do something like this: > x=c(1,2,3) > plot(x,x) At this point, R creates a file "Rplots.pdf", since the default device is PDF and the default filename is "Rplots.pdf". Since you're completely new to R,

Re: [R] Can I set default parameters for the default graphics device?

2010-07-15 Thread Sam Albers
Unless you aren't writing scripts why wouldn't you just use something like this? > x=c(1,2,3) > pdf("RRules.pdf") > plot(x,x) > dev.off() -- View this message in context: http://r.789695.n4.nabble.com/Can-I-set-default-parameters-for-the-default-graphics-device-tp2290827p2290836.html Sent fro

Re: [R] Proper use of grep

2010-07-15 Thread Doran, Harold
Excellent idea -Original Message- From: Erik Iverson [mailto:er...@ccbr.umn.edu] Sent: Thursday, July 15, 2010 5:40 PM To: Doran, Harold Cc: r-help@r-project.org Subject: Re: [R] Proper use of grep Doran, Harold wrote: > Thanks. Yes, I did that on a toy data set and with my real data.

Re: [R] Proper use of grep

2010-07-15 Thread Doran, Harold
Thanks. Yes, I did that on a toy data set and with my real data. It *seems* to have worked. I just work with grep so rarely that I didn't want to miss something. -Original Message- From: Erik Iverson [mailto:er...@ccbr.umn.edu] Sent: Thursday, July 15, 2010 5:36 PM To: Doran, Harold Cc

[R] Can I set default parameters for the default graphics device?

2010-07-15 Thread James
I'm completely new to R, and I'd like to do something like this: > x=c(1,2,3) > plot(x,x) At this point, R creates a file "Rplots.pdf", since the default device is PDF and the default filename is "Rplots.pdf". I know I can set the default device like this: > options(device="png") B

Re: [R] Repeated analysis over groups / Splitting by group variable

2010-07-15 Thread Peter Ehlers
I would change that first dataOnly in by(...) or lapply(...) to dataOnly[,-3]. In fact, if the dataframe mydata is suitably subset, then, because of the as.matrix() in function(x), both the by() and lapply() methods will work fine with mydata. -Peter Ehlers On 2010-07-15 15:42, Phil Spector w

[R] loess line predicting number where the line crosses zero twice

2010-07-15 Thread stephen sefick
These data represent stream channel cross-sectional surveys. I would like to be able to find the measurement on the tape (measure) where the Bank Full Depth (bkf_depths) is 0. This will happen twice because the channel has two sides. I thought fitting a loess line to these data and then predicti

Re: [R] KLdiv question (data.frame)

2010-07-15 Thread Peter Ehlers
On 2010-07-15 15:15, Ralf B wrote: Hi all, I wonder why KLdiv does not work with data.frames: Because it's not designed that way? (I assume that you mean KLdiv() in pkg:flexmix.) Check the help page. It's pretty clear about what input is wanted: a matrix object or a flexmix object (or FLXMC o

[R] Separating parts of a column of data in R

2010-07-15 Thread Carrot Top
Hi there, I am fairly new to R and I have been trying to figure out how to separate a column of substrate data that I have into separate parts using R. An example of my data looks like this is: gmtTime Classification ClassValue Species Count 1449 Sand30 14

Re: [R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Marc Schwartz
Ted, Based upon your code below, you might be better off using two lapply() constructs to create the x and y results separately, taking advantage of lapply()'s built-in ability to create lists 'on the fly', while returning a NULL when the function will not be applied to the data based upon your

[R] Problem installing rJava under FreeBSD

2010-07-15 Thread Iñigo Ortiz de Urbina
Hi there I am setting up a FreeBSD server for my research department at university, and one of my teachers needs specifically R modules like tm, RWeka, rJava and the like. I have installed FreeBSD 8.0/i386 and applied the relevant security patches as well as the native FreeBSD JDK 1.6 with its la

Re: [R] Sweave: infelicities with lattice graphics

2010-07-15 Thread Claudia Beleites
Dear David, you can use Gin: \setkeys{Gin}{width=0.5\linewidth} just before the chunk that actually produces the figure. and, cool, I hadn't realized, that <>= print ( <> ) @ works. with {} inside the print there can be even more than one statement in the chunk-with-lattice-functi

Re: [R] Backslash \ in string

2010-07-15 Thread Claudia Beleites
Jannis, You are right, it does not seem to matter. When the R string contains two \\, xtable prints it as only one \. I should have looked into the Latex output before posting! '\\' is just _one_ character in R: > nchar ("\\") [1] 1 Just like '\n' etc. It is just the `print`ed (as opposed

Re: [R] Repeated analysis over groups / Splitting by group variable

2010-07-15 Thread Phil Spector
Ralf - If you want to use by(), I think it should look like this: by(dataOnly,dataOnly[,3],function(x)KLdiv(as.matrix(x))) But you might find the following more useful: lapply(split(as.data.frame(dataOnly),dataOnly[,3]), function(x)KLdiv(as.matrix(x))) since it returns its re

Re: [R] Proper use of grep

2010-07-15 Thread Erik Iverson
Doran, Harold wrote: Thanks. Yes, I did that on a toy data set and with my real data. It *seems* to have worked. I just work with grep so rarely that I didn't want to miss something. Yes, I see no reason why it won't work. You can do another check 'manually'. You know how many of each you e

Re: [R] Proper use of grep

2010-07-15 Thread Erik Iverson
Doran, Harold wrote: I just need to confirm something with pattern matching folks. I have a factor with the following levels in a very large data set: levels(all$Classical.Statistic) [1] """AB;ABD" "CollapsedSteps" "CR_P""CR_Prop;CR_P;AB"

Re: [R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Ted Byers
Thanks Marc Part of the challenge here is that EVERYTHING is dynamic. New data is being added to the DB all the time Each active ID makes a new sample very day or at a minimum every week, and new IDs are added every week. So I can't hard code anything. If, for a given ID, I had 50 weekly sampl

[R] Proper use of grep

2010-07-15 Thread Doran, Harold
I just need to confirm something with pattern matching folks. I have a factor with the following levels in a very large data set: > levels(all$Classical.Statistic) [1] """AB;ABD" "CollapsedSteps" "CR_P""CR_Prop;CR_P;AB" [6]

Re: [R] Sweave: infelicities with lattice graphics

2010-07-15 Thread carslaw
I have wondered about this too. The approach I use isn't pretty but does have a couple of advantages - there is only one set of code to run and I have control over the figure size. The first part of the code below is what is shown in the document (but not run), and the second part actually run

Re: [R] Could you remove me from the mailing list? Thanks!

2010-07-15 Thread stephen sefick
Chester, You may unsubscribe yourself here: https://stat.ethz.ch/mailman/listinfo/r-help. A google search would have found this information for you. hth, Stephen Sefick On Thu, Jul 15, 2010 at 3:37 PM, Chester Kam wrote: > Dear R-help team, > > Could you please remove my e-mail (chester_...@yah

[R] Standard Error for individual patient survival with survfit and summary.survfit

2010-07-15 Thread Charles M. Rowland
I am using the coxph, survfit and summary.survfit functions to calculate an estimate of predicted survival with confidence interval for future patients based on the survival distribution of an existing cohort of subjects. I am trying to understand the calculation and interpretation of the std.

Re: [R] Search and extract string function

2010-07-15 Thread Marc Schwartz
On Jul 15, 2010, at 11:27 AM, AndrewPage wrote: > > Actually I have one more question that's somewhat related-- I'm starting out > by importing a .txt file that isn't divided into vectors and is at times > inconsistent with regards to spacing, indents, etc., so I can't rely on > those. It looks

[R] KLdiv question (data.frame)

2010-07-15 Thread Ralf B
Hi all, I wonder why KLdiv does not work with data.frames: n <- 50 mydata <- data.frame( sequence=c(1:n), data1=c(rnorm(n)), data2=c(rnorm(n)) ) # does NOT work KLdiv(mydata) # works fine dataOnly <- cbind(mydata$data1, mydata$data2, mydata$group) KLdiv(dataOnly) Any ide

[R] Repeated analysis over groups / Splitting by group variable

2010-07-15 Thread Ralf B
I am performing some analysis over a large data frame and would like to conduct repeated analysis over grouped-up subsets. How can I do that? Here some example code for clarification: require("flexmix") # for Kullback-Leibler divergence n <- 23 groups <- c(1,2,3) mydata <- data.frame(

Re: [R] Sweave: infelicities with lattice graphics

2010-07-15 Thread Claudia Beleites
Dear Michael, I know this situation from writing vignettes and I usually cheat a bit I redefine the functions along these lines: plotmap <- function (...) print (hyperSpec:::plotmap (...)) (plotmap is a lattice-function for hyperSpec objects) plotmap can tehn be used without the print in t

Re: [R] plot month and year

2010-07-15 Thread linda.s
The X axis on the plot now starts from 2008.0; Since the data starts from January 2008, can I make it 2008.1, and also show 2009.12 on the axis? Thanks. Linda On Wed, Jul 14, 2010 at 9:49 AM, Achim Zeileis wrote: > You do not provide a reproducible example, as the posting guide asks you to. > But

Re: [R] Creating Enumerated Variables

2010-07-15 Thread Dennis Murphy
Hi: I sincerely hope there's an easier way, but one method to get this is as follows, with d as the data frame name of your test data: d <- d[order(with(d, Age, School, rev(Grade))), ] d$Count <- do.call(c, mapply(seq, 1, as.vector(t(with(d, table(Age, School)) d > d ID Age School Grade Co

Re: [R] Sweave: infelicities with lattice graphics

2010-07-15 Thread Duncan Murdoch
On 15/07/2010 4:51 PM, Michael Friendly wrote: In a paper I'm writing using Sweave, I make use of lattice graphics, but don't want to explicitly show (or explain) in the article text the print() wrapper I need in code chunks for the graphs to appear. I can solve this by including each chunk twi

Re: [R] ed50

2010-07-15 Thread Dipa Hari
I don't know how to reparameterise the model. will you please give the detail for reparameterisation and delta method? Thanks --- On Tue, 7/13/10, Rubén Roa wrote: From: Rubén Roa Subject: RE: [R] ed50 To: "Dipa Hari" , r-help@r-project.org Date: Tuesday, July 13, 2010, 6:27 AM > -Men

Re: [R] Could you remove me from the mailing list? Thanks!

2010-07-15 Thread Corey Gallon
Chester, Please manage your subscription at https://stat.ethz.ch/mailman/listinfo/r-help Cheers, Corey * Sent from my BlackBerry handheld device -Original Message- From: Chester Kam Sender: Date: Thu, 15 Jul 2010 13:37:37 To: Subject: [R] Could you remove me from the mailing list

Re: [R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Marc Schwartz
Ted, I may not be completely clear on how you have your processes implemented, but some thoughts: If you will be creating multiple lists initially, where each list (say z1...z4) contains 1 or more data frames and all of the data frames have the same column structure, you can use: do.call(rb

Re: [R] Summing over intervals

2010-07-15 Thread Gabor Grothendieck
On Thu, Jul 15, 2010 at 4:21 PM, Dennis Murphy wrote: > Hi: > > Tal was on the right track, but the function in package zoo that applies > here is rollapply(): > > library(zoo) > m<-matrix(seq(1,80),ncol=20, nrow=4) > t(apply(m, 1, function(x) rollapply(zoo(x), width = 5, FUN = mean, by = 5))) >  

[R] Sweave: infelicities with lattice graphics

2010-07-15 Thread Michael Friendly
In a paper I'm writing using Sweave, I make use of lattice graphics, but don't want to explicitly show (or explain) in the article text the print() wrapper I need in code chunks for the graphs to appear. I can solve this by including each chunk twice, with different options, as in <>= library

[R] Could you remove me from the mailing list? Thanks!

2010-07-15 Thread Chester Kam
Dear R-help team, Could you please remove my e-mail (chester_...@yahoo.com) from the mailing list? Thanks so much! Chester [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-hel

Re: [R] How to delete a date frame from a data frame

2010-07-15 Thread Addi Wei
The data set for "combined" is pretty huge, but a few columns looks like this, so just picture it with 187 columns: dw_area vdw_vol vsa_acc vsa_acid vsa_base vsa_donvsa_hyd 1 0.8322680 0.93714800 -0.478551 -0.2791860 -0.724420 1.4647400 2 1.8746300 1.2639 0.23148

Re: [R] Summing over intervals

2010-07-15 Thread Dennis Murphy
Hi: Tal was on the right track, but the function in package zoo that applies here is rollapply(): library(zoo) m<-matrix(seq(1,80),ncol=20, nrow=4) t(apply(m, 1, function(x) rollapply(zoo(x), width = 5, FUN = mean, by = 5))) [,1] [,2] [,3] [,4] [1,]9 29 49 69 [2,] 10 30 50

Re: [R] How to delete a date frame from a data frame

2010-07-15 Thread Erik Iverson
It's high time for a small, reproducible example. Don't say, "for example", *give* us an example in R. That being said, something like combined[!names(combined) %in% names(miceSample)] might be a start... Addi Wei wrote: But "miceSample" has multiple columns... For example if nvars=4, I ha

Re: [R] Problem with offset (Glm or glmD) in Design library

2010-07-15 Thread Frank E Harrell Jr
On 07/15/2010 07:59 AM, Claus Dethlefsen / Region Nordjylland wrote: Dear List My question relates to the rms (or Design) package. I have modified the example from help(Glm) to include an offset argument. It works with "glm" but "Glm" gives the error Error in if (!length(fname) || !any(fname ==

Re: [R] How to delete a date frame from a data frame

2010-07-15 Thread Addi Wei
But "miceSample" has multiple columns... For example if nvars=4, I have 4 columns of data to delete from "combined". Specifically, I have 187 columns in "combined", and "miceSample" only has 4 columns. So the new data frame should have 183 columns. -- View this message in context: http://r

Re: [R] write.csv() : attempt to set 'append' ignored... Why?

2010-07-15 Thread Marc Schwartz
Yes, this behavior is new in 2.11.x. From the NEWS file: o write.csv[2] no longer allow 'append' to be changed: as ever, direct calls to write.table() give more flexibility as well as more room for error. HTH, Marc On Jul 15, 2010, at 3:01 PM, Jonathan Christensen wrote:

Re: [R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Ted Byers
Thanks Marc The next part of the question, though, involves the fact that there is a new 'z' list made in almost every iteration through the ID loop. I guess there are two parts to the question. First, how would I make a list containing all the data frames created by a call to rbind? I assume,

Re: [R] write.csv() : attempt to set 'append' ignored... Why?

2010-07-15 Thread Jonathan Christensen
Never mind, I found the answer to my own question. From the 2.11.0 change log: owrite.csv[2] no longer allow 'append' to be changed: as ever, direct calls to write.table() give more flexibility as well as more room for error. Jonathan On Thu, Jul 15, 2010 at 2:01 PM, Jonathan Ch

[R] local linear prediction

2010-07-15 Thread sebep
Hello everybody, I write my bachelor-work in statistic about "Methods of nonlinear prediction in time series". I will apply the local linear point forecast (from Yao and Tong (1994a): Nonparametric method with the kernel function). I couldn`t find a appropriate package for this method. Have somebo

Re: [R] send out put to file in R

2010-07-15 Thread chakri_amateur
Dear Gabor Csardi, Thanks. The problem is now resolved. > No wonder, writing computer programs is not just typing in random words > and let the computer figure > out what you are trying to do. At least not yet. Apart from typo errors like "wri" before "write..." and "lecompose" instead of "d

Re: [R] Search and extract string function

2010-07-15 Thread AndrewPage
Actually I have one more question that's somewhat related-- I'm starting out by importing a .txt file that isn't divided into vectors and is at times inconsistent with regards to spacing, indents, etc., so I can't rely on those. It looks something like this: "Drink=Coffee:Location=Office:Time=M

Re: [R] write.csv() : attempt to set 'append' ignored... Why?

2010-07-15 Thread Jonathan Christensen
Out of curiosity, is this a change in 2.11? I'm still runnning 2.10.1, ?write.csv mentions the other options being ignored, but not append. This might also explain why John Kane believes he has successfully used append with write.csv in that past. Jonathan On Thu, Jul 15, 2010 at 9:36 AM, Marc S

[R] How to plot a histogram of weekday frequencies in a list of dates?

2010-07-15 Thread David Stark
Question from an [R] novice... Hi, I have a vector of date/times like the one shown below (a truncated sample of a much longer list...) > dates[1:4] [1] "2006-03-16 08:41:00" "2006-03-16 10:28:00" "2006-03-16 11:03:00" [4] "2006-03-16 11:04:00" I would like to generate a weekday histogram showing

[R] FW: coeficient of determination

2010-07-15 Thread Alireza Ehsani
Hello there how can i calculate coefficient of determination with R? Kind regards Ali Reza Ehsani Ph.d. student [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

Re: [R] Search and extract string function

2010-07-15 Thread AndrewPage
Thanks! That's much less complicated and does everything I wanted it to do. -- View this message in context: http://r.789695.n4.nabble.com/Search-and-extract-string-function-tp2290268p2290356.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] write.csv() : attempt to set 'append' ignored... Why?

2010-07-15 Thread John Kane
Use write.table() instead. I thought that I had used write.csv() with an append before but I cannot find an example. Perhaps append= is not available in write.csv --- On Thu, 7/15/10, Cliff Clive wrote: > From: Cliff Clive > Subject: [R] write.csv() : attempt to set 'append' ignored... Wh

Re: [R] How to delete a date frame from a data frame

2010-07-15 Thread Marc Schwartz
On Jul 15, 2010, at 2:37 PM, Addi Wei wrote: > > e.g. I have a big data set called "combined", and then a small sample of > "combined" called "miceSample". I wish to delete "miceSample" from > "combined" to create a new smaller data set and store it into a new object. > > combined <- rbind(sca

[R] How to delete a date frame from a data frame

2010-07-15 Thread Addi Wei
e.g. I have a big data set called "combined", and then a small sample of "combined" called "miceSample". I wish to delete "miceSample" from "combined" to create a new smaller data set and store it into a new object. combined <- rbind(scaleMiceTrain, scaleMiceTest) miceSample <- sample(combined[

Re: [R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Marc Schwartz
On Jul 15, 2010, at 2:18 PM, Ted Byers wrote: > The data.frame is constructed by one of the following functions: > > funweek <- function(df) > if (length(df$elapsed_time) > 5) { >rv = fitdist(df$elapsed_time,"exp") >rv$year = df$sale_year[1] >rv$sample = df$sale_week[1] >rv$granu

[R] How do I combine lists of data.frames into a single data frame?

2010-07-15 Thread Ted Byers
The data.frame is constructed by one of the following functions: funweek <- function(df) if (length(df$elapsed_time) > 5) { rv = fitdist(df$elapsed_time,"exp") rv$year = df$sale_year[1] rv$sample = df$sale_week[1] rv$granularity = "week" rv } funmonth <- function(df) if (

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Benjamin Caldwell
Thanks all! That did it. On Thu, Jul 15, 2010 at 11:07 AM, Nikhil Kaza wrote: > Building on Erik's solution and because it would easier to do date > arithmetic.. > > d1 <- as.character(date) > d1 <- ifelse(nchar(d1)<4, paste(0,d1,sep=""),d1) > d2 <- as.Date(date, "%m%d") > > > On Jul 15, 2010, a

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Nikhil Kaza
Building on Erik's solution and because it would easier to do date arithmetic.. d1 <- as.character(date) d1 <- ifelse(nchar(d1)<4, paste(0,d1,sep=""),d1) d2 <- as.Date(date, "%m%d") On Jul 15, 2010, at 1:21 PM, btc1 wrote: Hello, I have a vector, "dates", as a series of 3 digit elements,

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Henrique Dallazuanna
Try this: gsub("^(.)", "\\1/", dates) On Thu, Jul 15, 2010 at 2:21 PM, btc1 wrote: > > Hello, I have a vector, "dates", as a series of 3 digit elements, i.e. > > date > [1] 528 528 528 528 528 528 528 528 528 528 528 528 708 708 708 708 708 > 708 > [19] 708 708 708 708 529 529 529 529 529 5

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Wu Gong
gsub("(.*)(.{2})","\\1/\\2",dates) - A R learner. -- View this message in context: http://r.789695.n4.nabble.com/Cut-a-within-elements-by-length-not-value-of-vectors-tp2290440p2290471.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] calling functions

2010-07-15 Thread Erik Iverson
louisey wrote: Hello everyone!! I have written a function in R and need to call it more than once say M times then take an average of my output. How would I tell R to automatically call my function many times instead of just the once? The natural way will depend on what you're trying to do

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Erik Iverson
btc1 wrote: Hello, I have a vector, "dates", as a series of 3 digit elements, i.e. > date [1] 528 528 528 528 528 528 528 528 528 528 528 528 708 708 708 708 708 708 [19] 708 708 708 708 529 529 529 529 529 529 529 529 529 529 529 529 529 529 [37] 529 624 I need to convert them into julian

[R] calling functions

2010-07-15 Thread louisey
Hello everyone!! I have written a function in R and need to call it more than once say M times then take an average of my output. How would I tell R to automatically call my function many times instead of just the once? Thanks! xxx -- View this message in context: http://r.789695.n4.nabble.c

Re: [R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread Martyn Byng
Hi, Is this what you are looking for? a = c(528,528,528,528,708,708,529,1208,423,1506,321) paste(substr(a,1,nchar(a)-2),substr(a,nchar(a)-1,nchar(a)),sep="/") [1] "5/28" "5/28" "5/28" "5/28" "7/08" "7/08" "5/29" "12/08" "4/23" "15/06" "3/21" Martyn -Original Message- From: r-h

[R] Cut a within elements by length, not value, of vectors

2010-07-15 Thread btc1
Hello, I have a vector, "dates", as a series of 3 digit elements, i.e. > date [1] 528 528 528 528 528 528 528 528 528 528 528 528 708 708 708 708 708 708 [19] 708 708 708 708 529 529 529 529 529 529 529 529 529 529 529 529 529 529 [37] 529 624 I need to convert them into julian, but have to i

Re: [R] replace negative numbers by smallest positive value in matrix

2010-07-15 Thread Juliet Hannah
Thanks Jun and Phil! On Thu, Jul 15, 2010 at 12:16 PM, Phil Spector wrote: > Juliet - >   Since you're operating on each column, apply() would > be the appropriate function; > > mymat = apply(mymat,2,function(x){x[x<0] = min(x[x>0]);x}) > > >                                        - Phil Spector

Re: [R] Mathematica and R

2010-07-15 Thread Duncan Murdoch
On 15/07/2010 12:11 PM, David Bickel wrote: Sage and Marc, thank you for your helpful replies. Since RLink enables R calls from Mathematica, I wonder if it would make the Mathematica "Front End" useful for organizing R work even if no Mathematica functions are needed. It would be nice R had so

Re: [R] Mathematica and R

2010-07-15 Thread Erik Iverson
David Bickel wrote: Sage and Marc, thank you for your helpful replies. Since RLink enables R calls from Mathematica, I wonder if it would make the Mathematica "Front End" useful for organizing R work even if no Mathematica functions are needed. It would be nice R had something like the "Fro

Re: [R] [R-pkgs] New package "list" for analyzing listsurveyexperiments

2010-07-15 Thread Bert Gunter
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Hadley Wickham Sent: Thursday, July 15, 2010 12:15 AM To: Yves Rosseel Cc: r-help@r-project.org; richard_rauber...@merck.com Subject: Re: [R] [R-pkgs] New package "list" for analyzing l

Re: [R] Creating Enumerated Variables

2010-07-15 Thread Wu Gong
If you only want a count, please try table text <- "ID Age School Grade 1 10 1 98 2 10 2 97 3 10 1 92 4 11 1 90 5 11 1 80 6 11 2 70 7 10 1 80 8 10 1 79 9 11 2 70" df <- read.table(textConnection(text),header=T) table(df[,2:3]) If you want sort the data, try order. - A R learner. -- View t

Re: [R] replace negative numbers by smallest positive value in matrix

2010-07-15 Thread Phil Spector
Juliet - Since you're operating on each column, apply() would be the appropriate function; mymat = apply(mymat,2,function(x){x[x<0] = min(x[x>0]);x}) - Phil Spector Statistical Computing Facility

Re: [R] Scatterplot_row match

2010-07-15 Thread Yanwei Tan
Dear Jonathan, Thanks a lot for your help! That works pretty well! Best wishes, Wei On 7/15/10 5:52 PM, Jonathan Flowers wrote: > Hi, > > What if you create two data frames, then merge them by gene id. > > If your data is in a data frame called "dframe"... > > df1 <- subset(dframe,select=c("id2c

Re: [R] Mathematica and R

2010-07-15 Thread David Bickel
Sage and Marc, thank you for your helpful replies. Since RLink enables R calls from Mathematica, I wonder if it would make the Mathematica "Front End" useful for organizing R work even if no Mathematica functions are needed. It would be nice R had something like the "Front End," a GUI that ena

Re: [R] Matrix Size

2010-07-15 Thread paul s
On 07/15/2010 05:07 AM, Peter Dalgaard wrote: paul s wrote: On 07/14/2010 06:15 PM, Peter Dalgaard wrote: A quick calculation reveals that a matrix of that size requires about 2.7 TERAbytes of storage, so I'm a bit confused as to how you might expect to fit it into 16GB of RAM... However, eve

Re: [R] replace negative numbers by smallest positive value in matrix

2010-07-15 Thread Jun Shen
Hi, Juliet, Something like this? mymat[mymat<0]<-min(mymat[mymat>0]) Jun On Thu, Jul 15, 2010 at 10:55 AM, Juliet Hannah wrote: > Hi Group, > > I have a matrix, and I would like to replace numbers less than 0 by > the smallest minimum number. Below is an > small matrix, and the loop I used. I

[R] replace negative numbers by smallest positive value in matrix

2010-07-15 Thread Juliet Hannah
Hi Group, I have a matrix, and I would like to replace numbers less than 0 by the smallest minimum number. Below is an small matrix, and the loop I used. I would like to get suggestions on the "R way" to do this. Thanks, Juliet # example data set mymat <- structure(c(-0.503183609420937, 0.1790

Re: [R] Scatterplot_row match

2010-07-15 Thread Jonathan Flowers
Hi, What if you create two data frames, then merge them by gene id. If your data is in a data frame called "dframe"... df1 <- subset(dframe,select=c("id2c","2c")) df2 <- subset(dframe,select=c("id1c","1c")) merged <- merge(df1,df2,by.x="id2c",by.y="id1c",all=TRUE) plot(merged$1c,merged$2c) Ch

Re: [R] Search and extract string function

2010-07-15 Thread Gabor Grothendieck
On Thu, Jul 15, 2010 at 10:48 AM, AndrewPage wrote: > > Hi all, > > I'm trying to write a function that will search and extract from a long > character string, but with a twist: I want to use the characters before and > the characters after what I want to extract as reference points.  For > exampl

Re: [R] Search and extract string function

2010-07-15 Thread Marc Schwartz
On Jul 15, 2010, at 9:48 AM, AndrewPage wrote: > > Hi all, > > I'm trying to write a function that will search and extract from a long > character string, but with a twist: I want to use the characters before and > the characters after what I want to extract as reference points. For > example,

Re: [R] randomForest outlier return NA

2010-07-15 Thread Pau Carrio Gaspar
Hi Andy, thanks for your reply and your further correction. While the next release is not available I rewrite my code with your suggestion in case it might help anyone. ### library(randomForest) set.seed(0) ## build data set in data frame X <- rbind( matrix( runif

  1   2   >