[R] list of data frame objects
Hi Folks, I need to extract the list of all my data frame objects. With objects() I can list all objects and was hoping to use something like the following: objects()[is.data.frame(objects())] to extracts all my objects that are data frame... What am I doing wrong? Thanks - Tim - Any questions? Get answers on any topic at Yahoo! Answers. Try it now. [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] list of data frame objects
try something like the following (untested): objs - ls() sapply(objs, function(obj) inherits(get(obj), data.frame)) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm Quoting Tim McDonald [EMAIL PROTECTED]: Hi Folks, I need to extract the list of all my data frame objects. With objects() I can list all objects and was hoping to use something like the following: objects()[is.data.frame(objects())] to extracts all my objects that are data frame... What am I doing wrong? Thanks - Tim - Any questions? Get answers on any topic at Yahoo! Answers. Try it now. [[alternative HTML version deleted]] __ 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, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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, reproducible code.
[R] Help with pair plot
Hi, I'm trying to create a plot using pair. Currently I'm doing the following pairs(~mpg + hp + wt , data=cars, labels = c(Miles per Gallon,Horsepower,Weight),pch = c(24,25)[unclass(cars$tr + 1)], bg = c(red, green3)[unclass(cars$tr + 1)],panel=panel.smooth) for the attached dataset. However,instead of using panel.smooth I would rather have two fitted regression lines for each car transmission type (cars$tr). Is this possible? Thank you Ben __ 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, reproducible code.
Re: [R] Help with pair plot
I forgot to add that I figured how to do a single regression line using: panel.fitline-function(x, y, digits=2, prefix=, cex.cor, ...) { points(x, y, ...) reg - coef(lm(y ~ x)) abline(coef=reg,untf=F,col=blue) } and adding: panel=panel.fitline to pairs. But I am not sure how to add two lines differentiated by cars$tr. Thank you for your help! Ben On 2/18/07, Benjamin Dickgiesser [EMAIL PROTECTED] wrote: Hi, I'm trying to create a plot using pair. Currently I'm doing the following pairs(~mpg + hp + wt , data=cars, labels = c(Miles per Gallon,Horsepower,Weight),pch = c(24,25)[unclass(cars$tr + 1)], bg = c(red, green3)[unclass(cars$tr + 1)],panel=panel.smooth) for the attached dataset. However,instead of using panel.smooth I would rather have two fitted regression lines for each car transmission type (cars$tr). Is this possible? Thank you Ben __ 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, reproducible code.
[R] dbi, rodbc, rmysql, charset problem
Dear List In my short life as a beginning R-user i've encountered a following problem that i'm unable to solve myself: I have a database in MySQL containing table and field names as well as some data containing Polish accentuated characters (like ąśęć), utf8-encoded. It works just fine with just any external query browser i can find, jdbc, odbc, native, whatever. Also mysql is happy about my charset. It also seems to be configured correctly: mysql status -- mysql Ver 14.12 Distrib 5.0.24a, for pc-linux-gnu (i486) using readline 5.1 Connection id: 16 Current database: Current user: [EMAIL PROTECTED] SSL:Not in use Current pager: stdout Using outfile: '' Using delimiter:; Server version: 5.0.24a-Debian_9-log Protocol version: 10 Connection: Localhost via UNIX socket Server characterset:utf8 Db characterset:utf8 Client characterset:utf8 Conn. characterset:utf8 UNIX socket:/var/run/mysqld/mysqld.sock Uptime: 1 hour 37 min 17 sec Threads: 2 Questions: 240 Slow queries: 0 Opens: 175 Flush tables: 1 Open tables: 64 Queries per second avg: 0.041 Yet if i use R's RODBC or RMySQL to connect to my database i can't see these accentuated characters: library(RODBC) con -odbcConnect(trybunal, uid=root, pwd=mypassword) sqlTable(con) the output (abridged) is like that: TABLE_CAT TABLE_SCHEMTABLE_NAME TABLE_TYPE REMARKS 14 trybunal Wyk?adnia innych przepisf3w TABLE MySQL instead of F3 i should see ó and instead of ? a ł. It is just the same if i use RMySQL instead of RODBC: library(RMySQL) con -dbConnect(dbDriver(MySQL), dbname=trybunal, username=root, password=mypassword) dbListTables(con) the output (abridged) is like that: [13] UstawaWyk?adnia innych przepisf3w and if i use dbReadTable(con, Metryczka) (Metryczka being one table in the database) i get: Error in make.names(as.character(names), allow_) : invalid multibyte string 11 It works without error if i set LC_ALL to C, but obviously without Polish charset. Strange thing is that Sys.getlocale() gives me [1]LC_CTYPE=pl_PL.UTF-8;LC_NUMERIC=C;LC_TIME=pl_PL.UTF-8;LC_COLLATE=pl_PL.UTF-8; LC_MONETARY=pl_PL.UTF-8;LC_MESSAGES=pl_PL.UTF-8; LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C So it is utf8 all over the place. Also R works just fine with read.table() if the table contains utf8-encoded chars. Thus the problem is just with R-mysql connection. It seems therefore that dbi package does not support non-ascii charsets. Questions: 1. Is above conclusion correct or am i doing something wrong ? 2. If it is correct, is there any way to use table and field names as they are now (with non-ascii chars) in my SQL queries (e.g. SELECT `Wykładnia przedmiotu kontroli`.*) ? I can live with Polish characters missing in the output if i have to but i must address the database fields/tables. I can't change their names of as this would mean rebuilding database frontend. I can't import data to R by exporting the database and then importing it via read.table because i want a live application and must keep things simple. Any help will be greatly appreciated. -- janek0 [EMAIL PROTECTED] __ 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, reproducible code.
[R] Lattice graphics: minor tick marks and panel.axis() question(s)
Hello, I have been a long-time Traditional graphics user and now moving to try Lattice graphics. At the moment I cannot figure out how to place minor tick marks in a figure made with Lattice's xyplot(). In Traditional graphics, after calling plot() I would make two calls to axis(). From the manuals and help documentation I learned that 'scales' takes multiple 'at' arguments only if they apply to each of the different panels, so I thought to call 'panel.axis' in my panel function. However I have a few questions regarding this procedure: 1) the placement of the ticks is not where I expect, 2) I cannot seem to get tick marks to point outwards even when I set the clipping parameter in trellis parameters to off 3) (for multiple panels) I cannot figure out how to specify bottom or top in each panel such that they appear on the side that the default routine places major tickmarks I have included example code at the bottom of this message. I would appreciate any help if these issues are intuitively obvious to an experienced Lattice user. Thank you very much in advance! Stephen Tucker [using Windows XP and R 2.4.0] # Example code # #+ Define example data + # x = 0.1 to 10 uniformly spaced in lognormal(base10) scale # y = log10(x) + random noise # this is repeated for four groups: a,b,c,d xpoints = c(rep(1:9,times=2)*10^rep(c(-1,0),each=9),10) df = data.frame(x=rep(xpoints,times=4), y = rep(log10(xpoints),times=4)+rep(rnorm(length(xpoints),0,0.2),times=4), g = rep(rep(letters[1:4],each=length(xpoints)),times=4)) #+ #+ Set clipping parameter + clip = trellis.par.get(clip) clip$panel = off trellis.par.set(clip,clip) #+ #+ Define panel function + # plot x,y points # draw axis myPanelFunction = function(x,y,...) { xpoints = c(rep(1:9,times=2)*10^rep(c(-1,0),each=9),10) panel.xyplot(x,y,...) panel.axis(bottom,at=xpoints,labels=FALSE, tck=-0.5) #cannot get positive values of tck to work } #+ #+ Call to xyplot() + xyplot(y~x|g,data=df, panel = myPanelFunction, scales=list(x=list(log=TRUE,at=c(0.1,1,10), labels=parse(text=paste(10^,-1:1, index.cond=list(c(3,4,1,2))) #+ The fish are biting. __ 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, reproducible code.
[R] 1st International R/Rmetrics Workshop
The 1st International R/Rmetrics User and Developer Workshop ... will take place from July 8-12th, 2007 at Meielisalp, Lake Thune, Switzerland. See www.rmetrics.org The Workshop Focuses on ... using R/Rmetrics as the premier open source solution for financial market analysis, valuation of financial instruments, and insurance tasks, providing a platform for R/Rmetrics users to discuss and exchange ideas how R and Rmetrics can be used to do computations, data analysis, and visualization in finance and insurance, giving an overview of the new features of the rapidly evolving R/Rmetrics project and discussing future developments. The Program Consists of ... presentations of new R/Rmetrics directions and developments through keynote lectures. user-contributed presentations reflecting the wide range of fields in which R and Rmetrics are used in finance and insurance to analyze and model data. bringing together developers, practitioners, and users from finance and insurance providing a platform for common discussions and exchange of ideas. Organization ... Rmetrics Foundation, co-organized by Swiss Federal Institute of Technology, Zurich, and University of Economics and Business Administration, Vienna. Web Site: www.rmetrics.org Conference Chairs: Diethelm Würtz, Swiss Federal Institute of Technology, Zurich Kurt Hornik, University of Economics and Business Administration, Vienna __ 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, reproducible code.
Re: [R] dbi, rodbc, rmysql, charset problem
You seem never to have told R or us what charset these data are in. I think it is likely that they are being transferred in latin2 (like your email), and you are running R in UTF-8 according to Sys.getlocale. So what you need to do is to either 1) Run R in latin2 or 2) use iconv() to convert the results from latin2 to UTF-8. UTF-8 is relatively new in the DBMS world. For ODBC, look at the bug reports on the MySQL site. Using RODBC with UTF-8 locales is on my TODO list, but of no urgency at all. On Sun, 18 Feb 2007, janek0 wrote: Dear List In my short life as a beginning R-user i've encountered a following problem that i'm unable to solve myself: I have a database in MySQL containing table and field names as well as some data containing Polish accentuated characters (like ), utf8-encoded. It works just fine with just any external query browser i can find, jdbc, odbc, native, whatever. Also mysql is happy about my charset. It also seems to be configured correctly: mysql status -- mysql Ver 14.12 Distrib 5.0.24a, for pc-linux-gnu (i486) using readline 5.1 Connection id: 16 Current database: Current user: [EMAIL PROTECTED] SSL:Not in use Current pager: stdout Using outfile: '' Using delimiter:; Server version: 5.0.24a-Debian_9-log Protocol version: 10 Connection: Localhost via UNIX socket Server characterset:utf8 Db characterset:utf8 Client characterset:utf8 Conn. characterset:utf8 UNIX socket:/var/run/mysqld/mysqld.sock Uptime: 1 hour 37 min 17 sec Threads: 2 Questions: 240 Slow queries: 0 Opens: 175 Flush tables: 1 Open tables: 64 Queries per second avg: 0.041 Yet if i use R's RODBC or RMySQL to connect to my database i can't see these accentuated characters: library(RODBC) con -odbcConnect(trybunal, uid=root, pwd=mypassword) sqlTable(con) the output (abridged) is like that: TABLE_CAT TABLE_SCHEMTABLE_NAME TABLE_TYPE REMARKS 14 trybunal Wyk?adnia innych przepisf3w TABLE MySQL instead of F3 i should see ó and instead of ? a ?. It is just the same if i use RMySQL instead of RODBC: library(RMySQL) con -dbConnect(dbDriver(MySQL), dbname=trybunal, username=root, password=mypassword) dbListTables(con) the output (abridged) is like that: [13] UstawaWyk?adnia innych przepisf3w and if i use dbReadTable(con, Metryczka) (Metryczka being one table in the database) i get: Error in make.names(as.character(names), allow_) : invalid multibyte string 11 It works without error if i set LC_ALL to C, but obviously without Polish charset. Strange thing is that Sys.getlocale() gives me [1]LC_CTYPE=pl_PL.UTF-8;LC_NUMERIC=C;LC_TIME=pl_PL.UTF-8;LC_COLLATE=pl_PL.UTF-8; LC_MONETARY=pl_PL.UTF-8;LC_MESSAGES=pl_PL.UTF-8; LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C So it is utf8 all over the place. Also R works just fine with read.table() if the table contains utf8-encoded chars. Thus the problem is just with R-mysql connection. It seems therefore that dbi package does not support non-ascii charsets. Questions: 1. Is above conclusion correct or am i doing something wrong ? 2. If it is correct, is there any way to use table and field names as they are now (with non-ascii chars) in my SQL queries (e.g. SELECT `Wyk?adnia przedmiotu kontroli`.*) ? I can live with Polish characters missing in the output if i have to but i must address the database fields/tables. I can't change their names of as this would mean rebuilding database frontend. I can't import data to R by exporting the database and then importing it via read.table because i want a live application and must keep things simple. Any help will be greatly appreciated. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ 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, reproducible code.
[R] heatmap row cell size
Hello all- I am having trouble with the cell sizes that heatmap defaults too. I have a matrix of 160 rows and 5 columns that I am trying to display with heatmap(). When I do this, the cells default to really wide and very short. This makes the labels for the rows very hard to read, in fact the only way I can read them is to make the jpeg output very large and zoom in, and even then it's hard to read and the cells are so wide that you can't see the dendrogram while seeing the labels. I would like to try to have a tall, skinny heatmap with row labels big enough to read. I was able to get closer to what I want with this command... jpeg(file = view_heat.jpg,width = 4000, height = 6000) heatmap(elmat,col= brewer.pal(9,PuOr), cexCol = .8, margin = c(.01,130)) # dev.off() but it only uses a quarter of the jpeg and it is still really hard to see both the dendrogram on the left and read the labels on the right. Is there a way I can set the actual width and height of the cells so I can use the full size of the jpeg and read my labels? thanks in advance Ivan [[alternative HTML version deleted]] __ 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, reproducible code.
[R] r-help@stat.math.ethz.ch
doh-trying again- this time remember text only. Hello all- I am having trouble with the cell sizes that heatmap defaults too. I have a matrix of 160 rows and 5 columns that I am trying to display with heatmap(). When I do this, the cells default to really wide and very short. This makes the labels for the rows very hard to read, in fact the only way I can read them is to make the jpeg output very large and zoom in, and even then it's hard to read and the cells are so wide that you can't see the dendrogram while seeing the labels. I would like to try to have a tall, skinny heatmap with row labels big enough to read. I was able to get closer to what I want with this command... jpeg(file = view_heat.jpg,width = 4000, height = 6000) heatmap(elmat,col= brewer.pal(9,PuOr), cexCol = .8, margin = c(.01,130)) # dev.off() but it only uses a quarter of the jpeg and it is still really hard to see both the dendrogram on the left and read the labels on the right. Is there a way I can set the actual width and height of the cells so I can use the full size of the jpeg and read my labels? thanks in advance Ivan __ 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, reproducible code.
[R] Predict(); Warning rank deficient matrix
I am trying to use lm() for resression followed by stepAIC function. Now when i try to use to predict for some input, predict() gives a warning : prediction from a Rank deficient matrix may be misleading. As I am new to R (or to statistics) How alarming this warning may be? Regards, The fish are biting. __ 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, reproducible code.
[R] Suppressing \newcolumntype{} declaration in latex.default() in Hmisc
Dear r-helpers, When use latex() on a matrix, I set the option dcolumn = T. As a result, in front of each tabular I get \newcolumntype{.}{D{.}{.}{-1}} The LaTeX compiler complains about these multiple redeclarations. _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ 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, reproducible code.
[R] principal components analysis
Hi, just downloaded R. I need to run a simple Principal Components Analysis, with a plot and the variables scores as output. Does anyone have some scripts ready and easy to use...that anyone can understand... Thank you -- View this message in context: http://www.nabble.com/principal-components-analysis-tf3249342.html#a9032578 Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
[R] printing intermediate lines while in a function
Hi, I'm trying to make a function which does a lot of computational work and visualization work. This won't be a problem, but as things can get a lot of computational time, I would like to print what is going on, but also instructions about what the user should do. A small example: fctn - function(data.df){ cat(Calculating linear regression \n) data.lm - lm(y~x,data.df) cat(Calculating ANOVA \n) data.aov- aov(data.lm) cat(Plotting graphs \n) plot(y~x, data.df) cat(Click on the graph to set X and Y limits \n)} lim - locator(n=2) plot(y~x,data.df,ylim=sort(lim$y),xlim=sort(lim$x)) ... } But unfortunately R will do first the calculations and then afterwards return the strings. Is there a way around? Thanks Bart [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] Suppressing \newcolumntype{} declaration in latex.default() in Hmisc
Dear r-helpers, I didn't include a clear question in my previous posting. Here is a better version: When I use latex() on a matrix, I set the option dcolumn = T. As a result, in the *.tex file before each tabular I get \newcolumntype{.}{D{.}{.}{-1}} The LaTeX compiler complains about these multiple redeclarations. Is there a way to suppress this? _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ 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, reproducible code.
[R] User defined split function in rpart
Dear R community, I am trying to write my own user defined split function for rpart. I read the example in the tests directory and I understand the general idea of the how to implement user defined splitting functions. However, I am having troubles with addressing the data frame used in calling rpart in my split functions. For example, in the evaluation function that is called once per node, I want to fit a proportional odds model to the data in the node and use its deviance as node deviance: evalf - function(y,x,parms) { pomnode-polr(dataframe$y~dataframe$x,dataframe,weights=dataframe$Freq) more code } The dataframe used in the polr call should be the data of the current node. How can I address the data of the current node and assign it to the dataframe? Thank you for your help, Tobias Guennel __ 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, reproducible code.
[R] Forecasting Uncertainly
Does anyone know a function to calculate non-parametric prediction intervals of an output from a neural network? The probabilistic distribution of the target variable is not normal. I need a way to estimate uncertainly in a forecasting obtained with a neural network. Regards, Ricardo Bessa __ 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, reproducible code.
Re: [R] principal components analysis
--- sabat [EMAIL PROTECTED] wrote: Hi, just downloaded R. I need to run a simple Principal Components Analysis, with a plot and the variables scores as output. Does anyone have some scripts ready and easy to use...that anyone can understand... Thank you Would ?princomp help? If you try the example I'd suggest modifying biplot(pc.cr) to biplot(pc.cr, cex=.5) to reduce the size of the labels to a more readable size. __ 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, reproducible code.
[R] Urgent: How to obtain the Consistent Standard Errors after apply 2SLS through tsls() from sem or systemfit(2SLS) without this error message !!!!!!!!!!!!!
Hi, I am trying to obtain the heteroskedasticity consitent standard errors (HCSE) after apply 2SLS. I obtain 2SLS through tsls from package sem or systemfit: tsls library (sem) Reg2SLS -tsls(LnP~Sc+Ag+Ag2+Var+R+D,~I2+Ag+Ag2+Var+R+D) summary (Reg2SLS) systemfit library (systemfit) RS - LnP~Sc+Ag+Ag2+Var+R+D Inst - ~I2+Ag+Ag2+Var+R+D labels -list(RS) system -list(RS) Reg2SLS - systemfit(2SLS, system, labels, Inst, saveMemory=TRUE) summary (Reg2SLS) If I try to obtain the HCSE with robcov I obtain the following error message in both cases: Error in rep.default(1, p) : rep() incorrect type for second argument If I tried to apply vcovHAC or vcovHC in the systemfit output of 2SLS I receive the following messages of errors respectively: Error in estfun(x) : no applicable method for estfun (for vcovHAC) Error in terms.default(object) : no terms component (for vcovHC) If somebody can help me to solve this problem I will thank you a lot. Best regards Guillermo [[alternative HTML version deleted]] __ 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, reproducible code.
[R] help with loop over data frame
Dear List, This may be the fifth time Ive tried to send this to the list so apologies if there are multiple emails. I need some help getting started with this problem. I have a data frame containing a year of daily stock prices in the following format: Date Open HighLowClose 1/15/2000 10 11 8 10 1/16/2000 12 12 10 11 etc.. I want to create a new data frame which shows only the rows where the column value Open for 'today' is higher than the column value High for the previous day (previous row). How do I loop over each day accessing values from different rows and columns, as is needed here? I have tried 'if' statements but none have worked. Any help appreciated. Regards, Alf Sammassimo Melbourne,Australia __ 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, reproducible code.
Re: [R] help with loop over data frame
On Mon, 2007-02-19 at 13:38 +1100, Dr Remo Sammassimo wrote: Dear List, This may be the fifth time Ive tried to send this to the list so apologies if there are multiple emails. I need some help getting started with this problem. I have a data frame containing a year of daily stock prices in the following format: Date Open HighLowClose 1/15/2000 10 11 8 10 1/16/2000 12 12 10 11 etc.. I want to create a new data frame which shows only the rows where the column value Open for 'today' is higher than the column value High for the previous day (previous row). How do I loop over each day accessing values from different rows and columns, as is needed here? I have tried 'if' statements but none have worked. Any help appreciated. Regards, Alf Sammassimo Melbourne,Australia I think that this should do it. Presuming that your data frame is called 'DF': Rows - which(sapply(seq(along = rownames(DF))[-1], function(x) DF[x, Open] DF[x - 1, High])) + 1 DF.New - DF[Rows, ] The first line sets up a sequence from 2:nrows(DF) and then loops over those indices. The indices are passed as 'x' to the function, which compares the current row (x) Open value with the prior row (x - 1) High value. This returns TRUE or FALSE for each row compared. If TRUE, which() then returns the index of the row plus 1, since we do not want the first row. Those indices are assigned to 'Rows', which is then used to subset 'DF' and create 'DF.New'. Just using the data you have above: DF.New Date Open High Low Close 2 1/16/2000 12 12 1011 See ?which, ?sapply and ?seq HTH, Marc Schwartz __ 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, reproducible code.
Re: [R] RSNPper SNPinfo and making it handle a vector
I tried biomaRt library(biomaRt) ensnp = useMart(snp, dataset = hsapiens_snp) snp = getSNP(chromosome = 17, start = 73649033, end = 73679033, mart = ensnp) show(snp) Gave me a nice table but it did not seem to permit starting from the point of knowing the SNP and entering a list of rs##. I guess I could always fudge around. But it does not provide the one-stop I was looking for. you might look at the biomaRt package in Bioconductor and see if its snp query resolution facilities meet your needs. __ 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, reproducible code.
[R] Randomly extract rows from a data frame
Hi, I am looking for a way to randomly extract a specified number of rows from a data frame. I was planning on binding a column of random numbers to the data frame and then sorting the data frame using this bound column. But I can't figure out how to use this column to sort the entire data frame so that the content of the rows remains together. Does anyone know how I can do this? Hints for other ways to approach this problem would also be appreciated. Cheers Amy Amy Whitehead School of Biological Sciences University of Canterbury Private Bag 4800 Christchurch Ph 03 364 2987 ext 7033 Cellphone 021 2020525 Email [EMAIL PROTECTED] __ 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, reproducible code.
Re: [R] Randomly extract rows from a data frame
On Mon, 2007-02-19 at 16:10 +1300, Amy Whitehead wrote: Hi, I am looking for a way to randomly extract a specified number of rows from a data frame. I was planning on binding a column of random numbers to the data frame and then sorting the data frame using this bound column. But I can't figure out how to use this column to sort the entire data frame so that the content of the rows remains together. Does anyone know how I can do this? Hints for other ways to approach this problem would also be appreciated. Cheers Amy See ?sample Using the 'iris' dataset in R: # Select 2 random rows iris[sample(nrow(iris), 2), ] Sepal.Length Sepal.Width Petal.Length Petal.WidthSpecies 96 5.7 3.0 4.2 1.2 versicolor 17 5.4 3.9 1.3 0.4 setosa # Select 5 random rows iris[sample(nrow(iris), 5), ] Sepal.Length Sepal.Width Petal.Length Petal.WidthSpecies 83 5.8 2.7 3.9 1.2 versicolor 12 4.8 3.4 1.6 0.2 setosa 63 6.0 2.2 4.0 1.0 versicolor 80 5.7 2.6 3.5 1.0 versicolor 49 5.3 3.7 1.5 0.2 setosa HTH, Marc Schwartz __ 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, reproducible code.
Re: [R] Randomly extract rows from a data frame
On Mon, 19 Feb 2007, Amy Whitehead wrote: Hi, I am looking for a way to randomly extract a specified number of rows from a data frame. I was planning on binding a column of random numbers to the data frame and then sorting the data frame using this bound column. But I can't figure out how to use this column to sort the entire data frame so that the content of the rows remains together. Does anyone know how I can do this? Hints for other ways to approach this problem would also be appreciated. Cheers Amy It is a bit easier than that. Here is one way: df - airquality rNames - row.names(df) sampRows - sample(rNames,10) sampRows [1] 137 56 1 135 62 43 12 128 86 54 subset(df,rNames%in%sampRows) Ozone Solar.R Wind Temp Month Day 1 41 190 7.4 67 5 1 12 16 256 9.7 69 5 12 43 NA 250 9.2 92 6 12 54 NA 91 4.6 76 6 23 56 NA 135 8.0 75 6 25 62135 269 4.1 84 7 1 86108 223 8.0 85 7 25 12847 95 7.4 87 9 5 13521 259 15.5 76 9 12 137 9 24 10.9 71 9 14 David Scott _ David Scott Department of Statistics, Tamaki Campus The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000 Email: [EMAIL PROTECTED] Graduate Officer, Department of Statistics __ 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, reproducible code.
Re: [R] Randomly extract rows from a data frame
amy, here is a piece of code copied from my blog, which might answer part of your question. library(MASS); data(Boston); # DIVIDE DATA INTO TESTING AND TRAINING SETS set.seed(2005); test.rows - sample(1:nrow(Boston), 100); test.set - Boston[test.rows, ]; train.set - Boston[-test.rows, ]; On 2/18/07, Amy Whitehead [EMAIL PROTECTED] wrote: Hi, I am looking for a way to randomly extract a specified number of rows from a data frame. I was planning on binding a column of random numbers to the data frame and then sorting the data frame using this bound column. But I can't figure out how to use this column to sort the entire data frame so that the content of the rows remains together. Does anyone know how I can do this? Hints for other ways to approach this problem would also be appreciated. Cheers Amy Amy Whitehead School of Biological Sciences University of Canterbury Private Bag 4800 Christchurch Ph 03 364 2987 ext 7033 Cellphone 021 2020525 Email [EMAIL PROTECTED] __ 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, reproducible code. -- WenSui Liu A lousy statistician who happens to know a little programming (http://spaces.msn.com/statcompute/blog) __ 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, reproducible code.
[R] Google, hard disc drives and R
A recent paper from Google Labs, interesting in many respects, not the least the exclusive use of R for data analysis and graphics (alas not cited in the approved manner): http://labs.google.com/papers/disk_failures.pdf Perhaps some of the eminences grises of the R Foundation could prevail upon Google to make some the data reported in the paper available for inclusion in an R library or two, for pedagogical purposes? Tim C __ 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, reproducible code.