[R] Assign Names of columns in data.frame dinamically

2011-03-30 Thread Marcos Amaris Gonzalez
Hello List. I have many files of ECG, each one with 7 column and I need only the second column and the name of each ECG. I am doing this but althought I have various days trying this i haven't gotten, so I ask help with this, if somebody cans help me I'll be so thankfully. ---

[R] Graph many points without hiding some

2011-03-30 Thread Samuel Dennis
I have a very large dataset with three variables that I need to graph using a scatterplot. However I find that the first variable gets masked by the other two, so the graph looks entirely different depending on the order of variables. Does anyone have any suggestions how to manage this? This code

[R] Italicized title from index

2011-03-30 Thread Jeremy Newman
Hi all! I've written a handy script that uses a for loop to allow me to generate a large number of figures and statistical outputs for a large dataset. I am using indexing to retrieve a species name for the title of my graphs- which worked fine. However, I need to italicize these species names.

Re: [R] Poisson Regression

2011-03-30 Thread Ben Bolker
Jim Silverton gmail.com> writes: > > Is there R code that can do a Poisson Regression and plot the density of the > fitted values? > ?glm glm(...,family=poisson) ?predict.glm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listi

Re: [R] Poisson Regression

2011-03-30 Thread Jim Silverton
Is there R code that can do a Poisson Regression and plot the density of the fitted values? -- Thanks, Jim. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read t

[R] Problems reading excel file with RODBC connect

2011-03-30 Thread Luis Felipe Parra
Hello, I am trying to read an Excel file using RODBC connect (its attached) using the following code: Data<-odbcConnectExcel2007('acciones_col.xlsx',readOnly=T,) datos<-sqlFetch(Data,'Bloomberg') odbcClose(Data) The file contains stock data downloaded from bloomberg, and it contains five va

Re: [R] svg malformed on CentOS (epel R)

2011-03-30 Thread Jeroen Ooms
The problem has been resolved thanks to Tom Callaway from Redhat: Tom Callaway wrote: > > Looking at the R source code, it uses Cairo to do the SVG creation, and > the Cairo in RHEL-5 is very (very) old (1.2.4). > > Digging through Cairo's changelogs post 1.2.4, I came across this: > > "SVG: F

Re: [R] Lists of tables and conditional statements

2011-03-30 Thread David Winsemius
On Mar 30, 2011, at 7:27 PM, Henrique Dallazuanna wrote: Try this: lapply(l, function(x)x[x[,'Sum'] == 3,]) If this is the right answer, you should send a "solved" message. The dput extract was incomplete. -- David. On Wed, Mar 30, 2011 at 7:38 PM, Herbert, Alan G wrote: Hi R-users

[R] Help: creating owin{spatstat} objects from GIS data

2011-03-30 Thread Axel Urbiz
Dear R list, I'm trying to create an object of class "owin" (observation window) in the package spatstat from GIS mapping data. Here's an example of my problem. Everything goes well until the last line of code. I get the error message shown at the bottom: library(spatstat) library(sp) library(mapt

Re: [R] Lists of tables and conditional statements

2011-03-30 Thread Henrique Dallazuanna
Try this: lapply(l, function(x)x[x[,'Sum'] == 3,]) On Wed, Mar 30, 2011 at 7:38 PM, Herbert, Alan G wrote: > Hi R-users, > > I have a list containing numeric tables of differing row length. I want to > make a new list that contains only rows from tables with a "Sum" greater than > 3, plus the

Re: [R] how about a "

2011-03-30 Thread William Dunlap
The %...% operators are not a panacea. they have the same precedence as `*` and `/` (I think) so you get things like: > x %<-% 10 - 8 # %<-% has higher precedence than - [1] 2 > x # not what you thought it would be [1] 10 > x %<-% 10 ^3 # but lower than ^ [1] 1000 > x # this is wha

Re: [R] how about a "

2011-03-30 Thread John Fox
Dear Carl, I think that the following does what you want: > `%<-%` <- function(e1, e2){ + e1 <- deparse(substitute(e1)) + env <- parent.frame() + assign(e1, e2, envir=env) + e2 + } > x %<-% 10 [1] 10 > x [1] 10 But, as has been pointed out, it's probably easier just to parenthesize the

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Gabor Grothendieck
On Wed, Mar 30, 2011 at 5:10 PM, Dimitri Liakhovitski wrote: > Yes, zoo! That's what I forgot. It's great. > Henrique, thanks a lot! One question: > > if the data are as I originally posted - then week numbered 52 is > actually the very first week (it straddles 2008-2009). > What if the data much

Re: [R] how about a "

2011-03-30 Thread Ista Zahn
Hi Carl, Well, we already have (newobject <- somefunction()), so wrote: > I was cursing Matlab again today (what else is new) because the default > action for every Matlab command is to spew the result to the console, and > one must remember to put that darn ";"  at the end of every line. > > So

Re: [R] Lists of tables and conditional statements

2011-03-30 Thread David Winsemius
On Mar 30, 2011, at 5:38 PM, Herbert, Alan G wrote: Hi R-users, I have a list containing numeric tables of differing row length. I want to make a new list that contains only rows from tables with a "Sum" greater than 3, plus the names of each table. I was wondering whether there is an el

[R] how about a "

2011-03-30 Thread Carl Witthoft
I was cursing Matlab again today (what else is new) because the default action for every Matlab command is to spew the result to the console, and one must remember to put that darn ";" at the end of every line. So I just wondered: was there ever a discussion as to providing some modified ver

[R] Lists of tables and conditional statements

2011-03-30 Thread Herbert, Alan G
Hi R-users, I have a list containing numeric tables of differing row length. I want to make a new list that contains only rows from tables with a "Sum" greater than 3, plus the names of each table. I was wondering whether there is an elegant way to do this using apply of related functions as th

[R] calculating the mode in R...

2011-03-30 Thread Carl Witthoft
Here's my modest contribution: smode<-function(x){ xtab<-table(x) modes<-xtab[max(xtab)==xtab] mag<-as.numeric(modes[1]) #in case mult. modes, this is safer themodes<-names(modes) mout<-list(themodes=themodes,modeval=mag) return(mout) } (I

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread David Winsemius
On Mar 30, 2011, at 2:35 PM, Dimitri Liakhovitski wrote: Henrique, this is great, thank you! It's almost what I was looking for! Only one small thing - it doesn't "merge" the results for weeks that "straddle" 2 years. In my example - last week of year 2008 and the very first week of 2009 are o

Re: [R] Is there a function to save the content in R console to some file?

2011-03-30 Thread ep
You can use "Save history..." from the R-Console. Greetings ep -- View this message in context: http://r.789695.n4.nabble.com/Is-there-a-function-to-save-the-content-in-R-console-to-some-file-tp3419138p3419499.html Sent from the R help mailing list archive at Nabble.com. ___

Re: [R] How to define new operator in R?

2011-03-30 Thread Frank Schwidom
Hi, you may overwrite existing opreators in the current environment for example: > `+` <- `*` > 2+3 [1] 6 Regards! On Wed, Mar 30, 2011 at 10:04:19AM -0600, Chuanlong Du wrote: > Hello, everyone! > > Does anyone know how make some symbols have special means in R? For example, > we know that

Re: [R] Multiple area plots to share the same x-axis

2011-03-30 Thread jovian
Thank you Ista. On Wed, Mar 30, 2011 at 5:42 PM, Ista Zahn-2 [via R] wrote: > Use facetting: > > sets <- rbind(cbind(set="set1", set), cbind(set="set2", set2)) > ggplot(sets, aes(x = time, y = hours)) + >   geom_area(colour = 'red', fill = 'red', alpha = 0.5) + >   geom_area(stat = 'smooth', sp

Re: [R] Creating error bars in scatterplot() function (cars-Package)

2011-03-30 Thread David Winsemius
On Mar 30, 2011, at 5:10 PM, philsen wrote: Dear list, I am new to R and trying to create a grouped (four groups) scatter plot with error bars (only in y-direction) using the scatterplot() function from the car package. The code I am using for plotting the scatter plot is: scatterplot(a$s

Re: [R] How to put line linking two plots

2011-03-30 Thread Paul Murrell
Hi On 30/03/2011 10:54 p.m., Mario Valle wrote: Hello! Suppose I have three charts like below. The top chart is a general overview and the bottom charts are related so some point of this chart. To make clear this relationship I want to draw a line between (4,0.9) in the top chart and (10,1) in t

[R] Creating error bars in scatterplot() function (cars-Package)

2011-03-30 Thread philsen
Dear list, I am new to R and trying to create a grouped (four groups) scatter plot with error bars (only in y-direction) using the scatterplot() function from the car package. The code I am using for plotting the scatter plot is: scatterplot(a$s_profile~a$s_plot | a$group, data=a) which gives

Re: [R] lattice: wireframe "eats up" points; how to make points on wireframe visible?

2011-03-30 Thread Marius Hofert
Dear Deepayan, thanks for answering. It's never too late to be useful. I see your point in the minimal example. I checked the z-axis limits in my original problem for the point to be inside and it wasn't there. I can't easily reproduce it from the minimal example though. I'll get back to you if I

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Henrique Dallazuanna
This puts 'NA' in the first week of the year. Take a look on the code below: 2009.52 %% 1 On Wed, Mar 30, 2011 at 6:35 PM, Dimitri Liakhovitski wrote: > Henrique, this is beautiful, thank you so much. > This is a great and correct solution. > > A stupid question: what does the line is.na(wk) <

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Dimitri Liakhovitski
Henrique, this is beautiful, thank you so much. This is a great and correct solution. A stupid question: what does the line is.na(wk) <- wk %% 1 == 0 do? Thank you! Dimitri On Wed, Mar 30, 2011 at 5:25 PM, Henrique Dallazuanna wrote: > You're right: > > wk <- as.numeric(format(myframe$dates, "%Y

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Henrique Dallazuanna
You're right: wk <- as.numeric(format(myframe$dates, "%Y.%W")) is.na(wk) <- wk %% 1 == 0 solution<-aggregate(value ~ group + na.locf(wk), myframe, FUN = sum) On Wed, Mar 30, 2011 at 6:10 PM, Dimitri Liakhovitski wrote: > Yes, zoo! That's what I forgot. It's great. > Henrique, thanks a lot! One

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Dimitri Liakhovitski
Yes, zoo! That's what I forgot. It's great. Henrique, thanks a lot! One question: if the data are as I originally posted - then week numbered 52 is actually the very first week (it straddles 2008-2009). What if the data much longer (like in the code below - same as before, but more dates) so that

Re: [R] Package XML: Parse Garmin *.tcx file problems

2011-03-30 Thread Duncan Temple Lang
Hi Michael Almost certainly, the problem is that the document has a default namespace. You need to identify the namespace in the XPath query. xpathApply() endeavors to make this simple: xpathApply(doc2, "//x:TotalTimeSeconds", xmlValue, namespaces = "x") I suspect that will give you back some

Re: [R] How to define new operator in R?

2011-03-30 Thread Spencer Graves
'+' is a generic function, so different methods can be defined for different classes of objects. Consider the following: methods('+') [1] +.Date +.POSIXt # Methods defined for 'Date' and 'POSIXt' objects > args('+.Date') # standard argument names are e1 and e2 function (e1, e2) NULL

Re: [R] fonts in mosaic

2011-03-30 Thread Erich Neuwirth
Here is a more complete solution to my problem. The fact that the parameters are called gp_varnames, gp_labels, and gp_text on one hand, but main_gp and and sub_gp on the other hand comes as a surprise when one tries to find a solution. windowsFonts(calibri = windowsFont("Calibri")) mosaic(UCBAdm

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Henrique Dallazuanna
Try this: library(zoo) wk <- as.numeric(format(myframe$dates, '%W')) is.na(wk) <- wk == 0 aggregate(value ~ group + na.locf(wk), myframe, FUN = sum) On Wed, Mar 30, 2011 at 4:35 PM, Dimitri Liakhovitski wrote: > Henrique, this is great, thank you! > > It's almost what I was looking for! Only o

Re: [R] Is there a function to save the content in R console to some file?

2011-03-30 Thread David Winsemius
On Mar 30, 2011, at 11:02 AM, Chuanlong Du wrote: Hello, everyone! Does anyone know whether there's a function in R which can save the content in R console to some file? I'm using Windows system and the usual R console instead of Rstudio. You might want to look at : ?capture.output ?si

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread jim holtman
Here is a way of taking a sequence of dates and breaking them into weeks that start on Monday (you can change it) and it will span across years: > # create a couple of years of dates > x <- seq(as.Date('2009-7-8'), as.Date('2012-3-7'), by = '1 day') > # determine when the Monday for the first date

Re: [R] How to define new operator in R?

2011-03-30 Thread baptiste auguie
Hi, Also, try this and rm() it immediately, `+` <- function(x, y) x - y 1+1 rm(`+`) 1+1 baptiste On 31 March 2011 05:04, Chuanlong Du wrote: > Hello, everyone! > > Does anyone know how make some symbols have special means in R? For example, > we know that "+" in R means the sum of the two ope

Re: [R] Using graphics straight from R into published articles

2011-03-30 Thread baptiste auguie
Hi, For most purposes, I find that R graphics get 95% of the work done towards final publication. A couple of personal comments, - lattice, ggplot2, RColorBrewer, evidently. ggplot2, in particular, makes really good aesthetic decisions by default. - whilst R devices are really good, I find there

[R] Package XML: Parse Garmin *.tcx file problems

2011-03-30 Thread Folkes, Michael
I'm struggling with package XML to parse a Garmin file (named *.tcx). I wonder if it's form is incomplete, but appreciably reluctant to paste even a shortened version. The output below shows I can get nodes, but an attempt at value of a single node comes up empty (even though there is data there.

[R] [R-pkgs] Package ChemoSpec 1.46 Now Available on CRAN

2011-03-30 Thread Bryan Hanson
I'm pleased to announce that the ChemoSpec package is available on CRAN for the first time (as version 1.46-4). ChemoSpec is a collection of functions for plotting spectra (NMR, IR etc) and carrying out various forms of top-down exploratory data analysis, such as HCA, PCA and model-based clu

[R] [R-pkgs] Package FuncMap Now Available on CRAN

2011-03-30 Thread Bryan Hanson
I'm pleased to announce that the FuncMap (v 1.0) package is available on CRAN. This is a single function package that makes hive plots of function calls for a specified package. Hive plots are a powerful concept developed by Martin Krzywinski at the Genome Sciences Center (mkweb.bcgsc.ca/

Re: [R] fonts in mosaic

2011-03-30 Thread Prof Brian Ripley
On Wed, 30 Mar 2011, Achim Zeileis wrote: On Wed, 30 Mar 2011, Erich Neuwirth wrote: Achim I simply want to replace the font R uses on mosaic (whatever it is) by a font of my choice (say Calibri or Arial) because I need to embed the R charts in a PowerPoint presentation and want the fonts to m

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Dimitri Liakhovitski
Henrique, this is great, thank you! It's almost what I was looking for! Only one small thing - it doesn't "merge" the results for weeks that "straddle" 2 years. In my example - last week of year 2008 and the very first week of 2009 are one week. Any way to "join them"? Asking because in reality I'

Re: [R] How to define new operator in R?

2011-03-30 Thread Henrique Dallazuanna
Try this: `%a%` <- function(x, y)paste(x, y, sep = ',') 2 %a% 3 On Wed, Mar 30, 2011 at 1:04 PM, Chuanlong Du wrote: > Hello, everyone! > > Does anyone know how make some symbols have special means in R? For example, > we know that "+" in R means the sum of the two operand on its left and > ri

Re: [R] How can we modify attributes of files in Windows Systems using R?

2011-03-30 Thread Henrique Dallazuanna
You've tried: shell("ATTRIB +H C:\\your_file_name") ? On Wed, Mar 30, 2011 at 12:59 PM, Chuanlong Du wrote: > Hello! > > Does any one know how to modify attributes of files (hide, read only and > etc) in Windows Systems using R? I tried to use shell to call system > command, but it seems that

Re: [R] sampling design runs with no errors but returns empty data set

2011-03-30 Thread Thomas Lumley
On Thu, Mar 31, 2011 at 4:01 AM, Simon Kiss wrote: > Dear colleagues, > I'm working with the 2008 Canada Election Studies > (http://www.queensu.ca/cora/_files/_CES/CES2008.sav.zip), trying to construct > a weighted national sample using the survey package. > Three weights are included in the nat

Re: [R] Using graphics straight from R into published articles

2011-03-30 Thread David Winsemius
On Mar 30, 2011, at 11:56 AM, blanco wrote: Wow - thanks all for your helpful replies. Awesome forum. Am I right to assume that you use the postscript function to create .ps and .pdf files from R? No, just .ps and .eps files. The pdf() functon is for the obvious purposes. ?Devices

Re: [R] Creating 3 vectors that sum to 1

2011-03-30 Thread Greg Snow
Here is one comparison: library(TeachingDemos) library(gtools) dirfun1 <- function(n, pch='.',...,orig=TRUE) { if(orig) { tmp <- matrix( runif(n*2), n, 2 ) rtmp <- cbind( pmin( tmp[,1], tmp[,2] ), abs( tmp[,1]-tmp[,2] ), 1-pmax( tmp[,1], tmp[,2] ) )

Re: [R] Using graphics straight from R into published articles

2011-03-30 Thread Philipp Pagel
On Wed, Mar 30, 2011 at 09:56:09AM -0700, blanco wrote: > Wow - thanks all for your helpful replies. Awesome forum. > > Am I right to assume that you use the postscript function to create .ps and > .pdf files from R? almost: postscript(..., onefile=FALSE) # for eps pdf() # for PDF And don't f

Re: [R] postscript rotation (bug?)

2011-03-30 Thread Marc Schwartz
On Mar 30, 2011, at 11:51 AM, Wayne Lee wrote: > Dear Marc, > > Your answer on post > https://stat.ethz.ch/pipermail/r-help/2005-March/067634.html > has a broken link. > > Thank you, > W Wayne, here is the original thread being referenced from March of 2005: https://stat.ethz.ch/pipermail

Re: [R] How to define new operator in R?

2011-03-30 Thread David Winsemius
On Mar 30, 2011, at 11:04 AM, Chuanlong Du wrote: Hello, everyone! Does anyone know how make some symbols have special means in R? For example, we know that "+" in R means the sum of the two operand on its left and right. I want to define some operators in R by myself. Is this possible?

Re: [R] VECM with UNRESTRICTED TREND

2011-03-30 Thread Grzegorz Konat
Hello Bernhard, Thank You very much. Unfortunately I'm still not really sure how should I use dummy vars in this context... If I have a system of three variables (x, y, z), lag order = 2 and 1 cointegrating relation, what should I do? I mean, what kind of 'pattern' should be used to create those d

Re: [R] Class noquote to matrix

2011-03-30 Thread Mark Ebbert
I knew there had to be a simple solution. Thank you! On Mar 30, 2011, at 3:04 AM, Peter Ehlers wrote: > On 2011-03-29 19:12, Mark Ebbert wrote: >> Hi, >> >> I apologize if the solution is right in front of me, but I can't find >> anything on how to convert a class of 'noquote' to 'matrix'. I've

[R] postscript rotation (bug?)

2011-03-30 Thread Wayne Lee
Dear Marc, Your answer on post https://stat.ethz.ch/pipermail/r-help/2005-March/067634.html has a broken link. Thank you, W __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.

[R] Is there a function to save the content in R console to some file?

2011-03-30 Thread Chuanlong Du
Hello, everyone! Does anyone know whether there's a function in R which can save the content in R console to some file? I'm using Windows system and the usual R console instead of Rstudio. Regards! -- Chuanlong Du Department of Statistcis Iowa State University Ames, IA, US 50011 [[alte

[R] Noble America Announcement for Summer Internship 2011

2011-03-30 Thread Wang Yu
# Noble America Announcement for Summer Internship 2011 ## Organization Name: Noble America, http://www.thisisnoble.com/ Location: Stamford, Connecticut, USA Period: 10-12 Weeks for Sum

[R] How can we modify attributes of files in Windows Systems using R?

2011-03-30 Thread Chuanlong Du
Hello! Does any one know how to modify attributes of files (hide, read only and etc) in Windows Systems using R? I tried to use shell to call system command, but it seems that it doesn't work well. Sometimes it works but sometimes not. Regards! -- Chuanlong Du Department of Statistcis Iowa Stat

[R] How to define new operator in R?

2011-03-30 Thread Chuanlong Du
Hello, everyone! Does anyone know how make some symbols have special means in R? For example, we know that "+" in R means the sum of the two operand on its left and right. I want to define some operators in R by myself. Is this possible? Regards! -- Chuanlong Du Department of Statistcis Iowa St

Re: [R] Using graphics straight from R into published articles

2011-03-30 Thread blanco
Wow - thanks all for your helpful replies. Awesome forum. Am I right to assume that you use the postscript function to create .ps and .pdf files from R? blanco -- View this message in context: http://r.789695.n4.nabble.com/Using-graphics-straight-from-R-into-published-articles-tp3415401p34186

Re: [R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Henrique Dallazuanna
Try this: aggregate(value ~ group + format(dates, "%Y.%W"), myframe, FUN = sum) On Wed, Mar 30, 2011 at 11:23 AM, Dimitri Liakhovitski wrote: > Dear everybody, > > I have the following challenge. I have a data set with 2 subgroups, > dates (days), and corresponding values (see example code belo

Re: [R] fonts in mosaic

2011-03-30 Thread Achim Zeileis
On Wed, 30 Mar 2011, Erich Neuwirth wrote: Achim I simply want to replace the font R uses on mosaic (whatever it is) by a font of my choice (say Calibri or Arial) because I need to embed the R charts in a PowerPoint presentation and want the fonts to match. Ah, ok, sorry I misread your mail.

Re: [R] Dirichlet surface

2011-03-30 Thread Gavin Simpson
On Wed, 2011-03-30 at 11:12 -0700, Kehl Dániel wrote: > Actually, it works for the a=1 case, not for the others. It still gives > the invalid 'zlim argument' error. > I'll try to work it out maybe instead of NULL giving a c which is > dependent on the max(z). Sorry, I misread the helpfile - the

Re: [R] save ordinary numerical calculations as pdf

2011-03-30 Thread baptiste auguie
Hi, If you want grid graphics: For data.frames and matrices, gridExtra has a grid.table() function. For strings (paragraph), Rgraphics has a function too, whose name i forget. It could be possible to combine the two and define a method to display lists as well. HTH, baptiste On 30 March 2011

Re: [R] fonts in mosaic

2011-03-30 Thread Henrique Dallazuanna
Try this: windowsFonts(calibri = windowsFont("Calibri")) mosaic(UCBAdmissions, labeling_args = list( gp_labels = gpar(fontsize = 12, fontfamily = "calibri"), gp_varnames = gpar(fontsize = 16, fontfamily = "calibri") )) On Wed, Mar 30, 2011 at 3:25 PM, Erich Neuwirth wrote: > Achim > I simpl

Re: [R] optim and optimize are not finding the right parameter

2011-03-30 Thread Dimitri Liakhovitski
Thank you, Ravi - definitely better! On Wed, Mar 30, 2011 at 2:06 PM, Ravi Varadhan wrote: > Try this: > > pred <- pred/1e06 > > DV <- DV/1e03 > > opt1 <- optim(fn=my.function, par=1.0) > opt2 <- optim(fn=my.function, par=1.0, method="BFGS") > opt3 <- optim(fn=my.function, par=1.0, method="L-BFGS

Re: [R] fonts in mosaic

2011-03-30 Thread Erich Neuwirth
Achim I simply want to replace the font R uses on mosaic (whatever it is) by a font of my choice (say Calibri or Arial) because I need to embed the R charts in a PowerPoint presentation and want the fonts to match. And I want the most simple way of accomplishing this. I worked my way through the st

Re: [R] Using xlevels

2011-03-30 Thread William Dunlap
Terry, The fact that model.frame attaches xlevels to the terms based on factors in the input data.frame (and attaches dataClass based on the input data.frame), but the subsequent call to model.matrix is responsible for turning character vectors in the data.frame into factors (and then into contr

Re: [R] Dirichlet surface

2011-03-30 Thread Kehl Dániel
Actually, it works for the a=1 case, not for the others. It still gives the invalid 'zlim argument' error. I'll try to work it out maybe instead of NULL giving a c which is dependent on the max(z). Daniel 2011-03-30 10:42 keltezéssel, Kehl Dániel írta: It helped a lot indeed, thank you very m

Re: [R] optim and optimize are not finding the right parameter

2011-03-30 Thread Ravi Varadhan
Try this: pred <- pred/1e06 DV <- DV/1e03 opt1 <- optim(fn=my.function, par=1.0) opt2 <- optim(fn=my.function, par=1.0, method="BFGS") opt3 <- optim(fn=my.function, par=1.0, method="L-BFGS-B", lower=0, upper=1) opt1 opt2 opt3 Ravi. --- Ravi V

Re: [R] Dirichlet surface

2011-03-30 Thread Kehl Dániel
It helped a lot indeed, thank you very much! Now I understand why it was a problem for persp! Daniel 2011-03-30 10:31 keltezéssel, Gavin Simpson írta: On Wed, 2011-03-30 at 09:55 -0700, Kehl Dániel wrote: Dear David, I think that is a small bug too, maybe because the function is constant? is

Re: [R] Dirichlet surface

2011-03-30 Thread Gavin Simpson
On Wed, 2011-03-30 at 09:55 -0700, Kehl Dániel wrote: > Dear David, > > I think that is a small bug too, maybe because the function is constant? > is there a nice way to put the c(0,2.1) argument optionally, only if all > the parameters are 1? > Should I post the problem somewhere else (developer

Re: [R] Quick recode of -999 to NA in R

2011-03-30 Thread Marc Schwartz
On Mar 30, 2011, at 11:52 AM, Gabor Grothendieck wrote: > On Wed, Mar 30, 2011 at 11:51 AM, peter dalgaard wrote: >> >> On Mar 30, 2011, at 16:05 , Christopher Desjardins wrote: >> dat0 <- read.table('tim1.dat', na = -999) >>> >>> Ah ... yes. I knew that but clearly didn't at

Re: [R] Using xlevels

2011-03-30 Thread Terry Therneau
I see the logic now. I think that more sentences in the document would be very helpful, however. What is written is very subtle. I suggest the following small expansion for model.matrix.Rd: \item{data}{a data frame. If the object has a \code{terms} attribute then it is assumed to be the resul

Re: [R] Quick recode of -999 to NA in R

2011-03-30 Thread Christopher Desjardins
On Wed, Mar 30, 2011 at 10:51 AM, peter dalgaard wrote: > > On Mar 30, 2011, at 16:05 , Christopher Desjardins wrote: > > >> > >> dat0 <- read.table('tim1.dat', na = -999) > >> > > > > Ah ... yes. I knew that but clearly didn't at the time of my question or > > script writing. > > Thanks, > > Chr

Re: [R] optim and optimize are not finding the right parameter

2011-03-30 Thread Bert Gunter
Not sure it's the case here, but numeric optimizers are well-known to be subject to scaling issues. -- Bert On Wed, Mar 30, 2011 at 9:45 AM, Dimitri Liakhovitski wrote: > Dear all, > > I have a function that predicts DV based on one predictor pred: > > pred<-c(0,300,780,1560,2340

Re: [R] summing values by week - based on daily dates - but with somedates missing

2011-03-30 Thread Dimitri Liakhovitski
Thank you, Martyn. But it looks like this way we are getting sums by day - i.e., across all Mondays, all Tuesdays, etc. Maybe I did not explain well, sorry! The desired output would contain sums for each WHOLE week - across all days that comprise that week - Monday through Sunday. Makes sense? Dimi

Re: [R] Dirichlet surface

2011-03-30 Thread Kehl Dániel
Dear David, I think that is a small bug too, maybe because the function is constant? is there a nice way to put the c(0,2.1) argument optionally, only if all the parameters are 1? Should I post the problem somewhere else (developers maybe?) thanks: Daniel 2011-03-30 04:42 keltezéssel, David W

Re: [R] summing values by week - based on daily dates - but with somedates missing

2011-03-30 Thread Martyn Byng
Hi, How about something like: sum.by.day <- function(ff) { by.day <- split(ff$value,weekdays(ff$dates)) lapply(by.day,sum) } by.grp <- split(myframe,myframe$group) lapply(by.grp,sum.by.day) Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-pro

Re: [R] Quick recode of -999 to NA in R

2011-03-30 Thread Gabor Grothendieck
On Wed, Mar 30, 2011 at 11:51 AM, peter dalgaard wrote: > > On Mar 30, 2011, at 16:05 , Christopher Desjardins wrote: > >>> >>> dat0 <- read.table('tim1.dat', na = -999) >>> >> >> Ah ... yes. I knew that but clearly didn't at the time of my question or >> script writing. >> Thanks, >> Chris > > De

[R] optim and optimize are not finding the right parameter

2011-03-30 Thread Dimitri Liakhovitski
Dear all, I have a function that predicts DV based on one predictor pred: pred<-c(0,300,780,1560,2340,13120) DV<-c(0,500,1000,1400,1700,1900) ## I define Function 1 that computes the predicted value based on pred values and parameters a and b: calc_DV_pred <- function(a,b) {

[R] Multistep forecasting with neural networks

2011-03-30 Thread Sara Szeremeta
HI! Would anybody suggest what function/package/method can I use to obtain forecasts for horizons longer than 1 period ahead? I want to do multistep forecasts with multilayer feedforward networks. I have tried several packages, but it turned out that the functions yield only one-step forecasts.

Re: [R] Quick recode of -999 to NA in R

2011-03-30 Thread Clint Bowman
Amen. Ditto for "-999.000", "-999.00" and all of the other ones that various (usually Fortran) programmers have used. Has the most recent Fortran standard come around to understanding NA? -- Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTER

Re: [R] Quick recode of -999 to NA in R

2011-03-30 Thread peter dalgaard
On Mar 30, 2011, at 16:05 , Christopher Desjardins wrote: >> >> dat0 <- read.table('tim1.dat', na = -999) >> > > Ah ... yes. I knew that but clearly didn't at the time of my question or > script writing. > Thanks, > Chris Depending on where your data came from, you could get caught by the fac

Re: [R] VECM with UNRESTRICTED TREND

2011-03-30 Thread Pfaff, Bernhard Dr.
Hello Greg, you can exploit the argument 'dumvar' for this. See ?ca.jo Best, Bernhard > -Ursprüngliche Nachricht- > Von: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] Im Auftrag von Grzegorz Konat > Gesendet: Mittwoch, 30. März 2011 16:46 > An: r-help@r-project.o

Re: [R] Degrees of freedom for lm in logLik and AIC

2011-03-30 Thread peter dalgaard
On Mar 28, 2011, at 16:53 , Ben Bolker wrote: > Rubén Roa azti.es> writes: > >> >> >> However, shouldn't _free parameters_ only be counted for degrees of >> freedom and for calculation of AIC? >> The sigma parameter is profiled out in a least-squares >> linear regression, so it's not free,

Re: [R] Multiple area plots to share the same x-axis

2011-03-30 Thread Ista Zahn
Use facetting: sets <- rbind(cbind(set="set1", set), cbind(set="set2", set2)) ggplot(sets, aes(x = time, y = hours)) + geom_area(colour = 'red', fill = 'red', alpha = 0.5) + geom_area(stat = 'smooth', span = 0.2, alpha = 0.3) + ylim(0,40) + facet_grid(set ~ .) Best, Ista On Wed, Mar 30,

Re: [R] Using xlevels

2011-03-30 Thread Prof Brian Ripley
On Wed, 30 Mar 2011, Terry Therneau wrote: I'm working on predict.survreg and am confused about xlevels. The model.frame method has the argument, but none of the standard methods (model.frame.lm, model.frame.glm) appear to make use of it. But I see this in predict.lm: m <- model.frame

Re: [R] Multiple area plots to share the same x-axis

2011-03-30 Thread Werner Heijstek
I'm going to go ahead and shamelessly bump this question up the list. I saw that out of the 34 posts yesterday, only 9 did not receive an answer. Perhaps someone who finds this question trivial is checking his e-mail right now :) Werner On Tue, Mar 29, 2011 at 10:20 AM, jovian wrote: > Hello, >

[R] VECM with UNRESTRICTED TREND

2011-03-30 Thread Grzegorz Konat
Dear All, My question is: how can I estimate VECM system with "unrestricted trend" (aka "case 5") option as a deterministic term? As far as I know, ca.jo in urca package allows for "restricted trend" only [vecm <- ca.jo(data, type = "trace"/"eigen", ecdet = "trend", K = n, spec = "transitory"/"l

[R] sampling design runs with no errors but returns empty data set

2011-03-30 Thread Simon Kiss
Dear colleagues, I'm working with the 2008 Canada Election Studies (http://www.queensu.ca/cora/_files/_CES/CES2008.sav.zip), trying to construct a weighted national sample using the survey package. Three weights are included in the national survey (a household weight, a provincial weight and a

Re: [R] fonts in mosaic

2011-03-30 Thread Achim Zeileis
On Wed, 30 Mar 2011, Erich Neuwirth wrote: I need to change the font(s) used in mosaic from package vcd. The help file and the vignette do not give very explicit examples for doing that. The easiest solution would be changing the font for everything on the graph: var labels, var names, title, su

[R] Using xlevels

2011-03-30 Thread Terry Therneau
I'm working on predict.survreg and am confused about xlevels. The model.frame method has the argument, but none of the standard methods (model.frame.lm, model.frame.glm) appear to make use of it. The documentation for model.matrix states: xlev: to be used as argument of model.frame if data has n

[R] summing values by week - based on daily dates - but with some dates missing

2011-03-30 Thread Dimitri Liakhovitski
Dear everybody, I have the following challenge. I have a data set with 2 subgroups, dates (days), and corresponding values (see example code below). Within each subgroup: I need to aggregate (sum) the values by week - for weeks that start on a Monday (for example, 2008-12-29 was a Monday). I find

Re: [R] save ordinary numerical calculations as pdf

2011-03-30 Thread Rmh
The latex() function in the Hmisc package will typeset your objects. Embed that in a tex document and run pdflatex. Rich Sent from my iPhone On Mar 30, 2011, at 5:51, "Maas James Dr (MED)" wrote: > I'd like to save some calculation outputs as a pdf, to incorporate with > others in a document

Re: [R] Quick recode of -999 to NA in R

2011-03-30 Thread Christopher Desjardins
Ah ... yes. I knew that but clearly didn't at the time of my question or script writing. Thanks, Chris On Wed, Mar 30, 2011 at 8:22 AM, Henrique Dallazuanna wrote: > Try: > > dat0 <- read.table('tim1.dat', na = -999) > Ah ... yes. I knew that but clearly didn't at the time of my question or scri

Re: [R] save ordinary numerical calculations as pdf

2011-03-30 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 30/03/11 15:42, Rainer M Krug wrote: > On 30/03/11 11:51, Maas James Dr (MED) wrote: >> I'd like to save some calculation outputs as a pdf, to incorporate with >> others in a document. I've tried > >> pdf("filename") >> name_of_object_to_output >

Re: [R] Quick recode of -999 to NA in R

2011-03-30 Thread Muhammad Rahiz
Try using a loop like the following dat0 <- read.table("time1.dat") id <- c("e1dq", "e1arcp", "e1dev", "s1prcp", "s1nrcp","s1ints","a1gpar", "a1pias", "a1devt") for (a in 1:length(id)) { dat0[dat0$id[a]==-999.,as.character(id[a])] <- NA } -- Muhammad Rahiz Researcher & DPhil Candi

Re: [R] save ordinary numerical calculations as pdf

2011-03-30 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 30/03/11 11:51, Maas James Dr (MED) wrote: > I'd like to save some calculation outputs as a pdf, to incorporate with > others in a document. I've tried > > pdf("filename") > name_of_object_to_output > dev.off() > > but it doesn't seem to work, a

Re: [R] Not all rows are being read-in

2011-03-30 Thread Dimitri Liakhovitski
Philipp, you are a savior! That's exactly what has been happening - and it was driving me crazy. quote="" fixed things. Thank you very much! Dimitri On Wed, Mar 30, 2011 at 5:01 AM, Philipp Pagel wrote: > On Tue, Mar 29, 2011 at 06:58:59PM -0400, Dimitri Liakhovitski wrote: >> I have a tab-delimi

Re: [R] How to regress data into coefficients for a gamma function

2011-03-30 Thread JLucke
Regression for the gamma distribution can be expressed as a generalized linear model. Check Chapter 8 of McCullagh, P. & Nelder, J. A. (1989), Generalized linear models, Chapman & Hall, London, UK. Walter Anderson Sent by: r-help-boun...@r-project.org 03/29/2011 09:57 AM To r-help@r-proj

  1   2   >