Re: [R] read multiple dataset at one time
Without more information on the format of the files, or any other thing, it is hard to give a full answer. But shortly: yes, it is possible. With a bit more details: You can combine: readLines (or read.table, or what ever will work for your file), with list.files And run through them with a for loop. Now that I am writing this, I am wondering if it could be possible to do this in some parallel function, instead of with a loop... On Mon, Apr 30, 2012 at 9:32 PM, ya xinxi...@163.com wrote: Hi, Is it possible to read, say 100 dat files in one time? I want to combine these 100 data set into one single dat file. Any suggestions? Thank you very much. ya [[alternative HTML version deleted]] __ R-help@r-project.org 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. [[alternative HTML version deleted]] __ R-help@r-project.org 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] Usage line in .pdf version of manual is truncated
Break the line :) On Mon, Apr 30, 2012 at 12:34 PM, Zeeberg, Barry (NIH/NCI) [E] zeebe...@mail.nih.gov wrote: I am creating a package, and a rather long usage line for one function becomes truncated in the generated .pdf manual. Is there a way that I can prevent that truncation? __ R-help@r-project.org 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. -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/ __ R-help@r-project.org 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] Questions
This is not the RStudio support forum. I use it, I like it, but you need to learn the difference between R and RStudio. In this case, the fact that you are using RStudio is probably irrelevant. What is more relevant is that you are not on windows, though I can't be sure what OS you actually are using. Your error message refers to UNIX, you refer to Excel, so you could be on MacOSX or on windows with a pipe into a UNIX server. (If the latter, the RStudio support team may have a FAQ on this problem.) Please read the Posting Guide mentioned at the end of every message on this list. I Googled this problem and found https://stat.ethz.ch/pipermail/r-help/2006-October/116363.html, which probably applies, but only you can tell for sure. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. haugb...@umn.edu wrote: Hello, I am having difficulty putting a frequency table on my clipboard in R studio. I do not know what the error message is. I was thinking it might have to do with changing a setting on my clipboard but I do not know how to do this. I will copy and paste the exact command and error message: write.table(dpx,clipboard,sep=\t) Error in file(file, ifelse(append, a, w)) : 'mode' for the clipboard must be 'r' on Unix I was able to create a frequency table as a value in my workspace. However, I am trying to put it on my clipboard and then export it into excel. I copied and pasted some of the commands below that I was getting error messages for which may be helpful. Once I am able to get the frequency table to show up on my workbook I was also wondering how to export it to excel and keep the same formatting (spaces between the different frequency tables)? Thank you! Lana getwd() [1] /Users/JoshandLana dpx - read.table(file.choose(), header = T, sep = \t) #edit(dpx) View(dpx) freqTable - table(dpx$ActorID,dpx$EmotionFaceTask.RESP,dpx$Emotion) write.table(dpx,clipboard,sep=\t,col.names=NA) Error in file(file, ifelse(append, a, w)) : 'mode' for the clipboard must be 'r' on Unix write.table(dpx,clipboard,sep=\t) Error in file(file, ifelse(append, a, w)) : 'mode' for the clipboard must be 'r' on Unix edit(dpx) Error in dataentry(datalist, modes) : Editing of matrix and data.frame objects is not currently supported in RStudio __ R-help@r-project.org 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@r-project.org 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 loess Standard Error of the Residuals
John: 1. This is not really an R question. You should post on statistics help list , e.f. stats.stackexchange.com Also, inline below. -- Bert On Mon, Apr 30, 2012 at 8:44 AM, John Haslett jhasl...@tcd.ie wrote: Dear All I'm having trouble working out what exactly loess means by its Standard Error of the Residuals denoted s and in particular when the weights argument is invoked. For example, if the weights are weights are all =1, then s^2 is nearly sum sq res/ (n -1 - 'equiv num paras') If the weights are all k then s is proportional to k If the weights are unequal, I don't know what it does. Help directs me to very old documentation on cloess, which sheds no great light. I'm sure this is written down somewhere... Don't be. Lowess/loess is very old, going back to the 1970's or early 80's I believe. You may have to go back to (Bill Cleveland's I believe) original papers. But, more to the point, lo(w)ess is algorithm, not model-based; so it is not exactly clear how to determine df used by the fitting and therefore those left for residuals. I'm not sure how accepted the definitions baked into R's calculations are. Again, original resources may be the only resource. Thanks in advance John Haslett Prof of Statistics, Trinity College Dublin Office phone + 353 1 896 1114 [[alternative HTML version deleted]] __ R-help@r-project.org 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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 loess Standard Error of the Residuals
On May 1, 2012, at 07:27 , Bert Gunter wrote: John: 1. This is not really an R question. You should post on statistics help list , e.f. stats.stackexchange.com If it is about the concrete implementation, then it is actually an R question. It probably won't harm to take a look at the code within stats:::simpleLoess, which at least brings some concepts to the surface: pseudoresiduals, trace.hat.out, etc. Some bells are heard ringing faintly from remote areas of my memory... The role of the weights is also quite apparent in that piece of code. Also, inline below. -- Bert On Mon, Apr 30, 2012 at 8:44 AM, John Haslett jhasl...@tcd.ie wrote: Dear All I'm having trouble working out what exactly loess means by its Standard Error of the Residuals denoted s and in particular when the weights argument is invoked. For example, if the weights are weights are all =1, then s^2 is nearly sum sq res/ (n -1 - 'equiv num paras') If the weights are all k then s is proportional to k If the weights are unequal, I don't know what it does. Help directs me to very old documentation on cloess, which sheds no great light. I'm sure this is written down somewhere... Don't be. Lowess/loess is very old, going back to the 1970's or early 80's I believe. You may have to go back to (Bill Cleveland's I believe) original papers. But, more to the point, lo(w)ess is algorithm, not model-based; so it is not exactly clear how to determine df used by the fitting and therefore those left for residuals. I'm not sure how accepted the definitions baked into R's calculations are. Again, original resources may be the only resource. Thanks in advance John Haslett Prof of Statistics, Trinity College Dublin Office phone + 353 1 896 1114 [[alternative HTML version deleted]] __ R-help@r-project.org 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org 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] testing parallel slopes assumption for Ordinal Logistic Regression
Hi everyone, I'm a bit new here (and new to R), and I was trying to do an OLR, and testing the parallel slope assumption seems be very important. I browsed through past postings, and didn't find much to help me in this area. I was wondering if anyone knew how I could go about doing this. Thank you. -- View this message in context: http://r.789695.n4.nabble.com/testing-parallel-slopes-assumption-for-Ordinal-Logistic-Regression-tp4600234.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] index moran
what is nb2listw in index moran? [[alternative HTML version deleted]] __ R-help@r-project.org 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] Re : index moran
? nb2listw - Mail original - De : Ulfa Hasanah hasanahulf...@yahoo.co.id À : r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch Cc : r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch Envoyé le : Mardi 1 mai 2012 16h06 Objet : [R] index moran what is nb2listw in index moran? [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] index moran
On May 1, 2012, at 09:06 , Ulfa Hasanah wrote: what is nb2listw in index moran? Did you try help(nb2listw) ? -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org 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] Regression
On Apr 30, 2012, at 20:27 , Saint wrote: Trying to do a regression for four variables. I get information only for two. The rest is marked NA. Why? And what does NA mean? Your design matrix is singular since p is constant and p+Sweden.infl.dev=Sweden.infl, so two coefficients are set to missing -- effectively, the corresponding predictors are removed from the model. You may have to read up on the basics of multiple regression. Thanks! Sweden.infl.dev - c(0.2, 0.6, -1, -0.2, -1, -1.5, -0.7, 0.7, -0.1, 0.3) Sweden.GDP.gap - c(-0.024662769, -0.01519859, -0.027251109, -0.027129556, -0.014561961, 0.007291667, 0.02695406, 0.01179481, 0.008348032, 0.0683083) Sweden.nom.int.rate - c(7.6, 8.91, 4.1, 4.35, 3.4, 3.25, 4, 3.75, 3.75, 2.75) Sweden.infl - c(2.2, 2.6, 1, 1.8, 1, 0.5, 1.3, 2.7, 1.9, 2.3) p - c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2) Sweden.Taylor.nom.p.infl - lm(Sweden.nom.int.rate ~ Sweden.infl.dev + Sweden.GDP.gap + p + Sweden.infl) Call: lm(formula = Sweden.nom.int.rate ~ Sweden.infl.dev + Sweden.GDP.gap + p + Sweden.infl) Coefficients: (Intercept) Sweden.infl.dev Sweden.GDP.gapp 4.6751.212 -43.695 NA Sweden.infl NA -- View this message in context: http://r.789695.n4.nabble.com/Regression-tp4598984.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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. -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org 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] Questions
On May 1, 2012, at 06:47 , Jeff Newmiller wrote: This is not the RStudio support forum. I use it, I like it, but you need to learn the difference between R and RStudio. In this case, the fact that you are using RStudio is probably irrelevant. What is more relevant is that you are not on windows, though I can't be sure what OS you actually are using. Your error message refers to UNIX, you refer to Excel, so you could be on MacOSX or on windows with a pipe into a UNIX server. (If the latter, the RStudio support team may have a FAQ on this problem.) Please read the Posting Guide mentioned at the end of every message on this list. I Googled this problem and found https://stat.ethz.ch/pipermail/r-help/2006-October/116363.html, which probably applies, but only you can tell for sure. A couple of red herrings here, I suspect. If it is a Mac issue, then R-sig-Mac could be relevant (although I'm beginning to have doubts that we should send _all_ entry-level Mac issues there, when corresponding Windows issues are not similarly diverted). The Clipboard section in help(file) is informative. Indeed, on OSX, this works: write.table(airquality,pipe(pbcopy)) head(read.table(pipe(pbpaste))) Ozone Solar.R Wind Temp Month Day 141 190 7.4 67 5 1 236 118 8.0 72 5 2 312 149 12.6 74 5 3 418 313 11.5 62 5 4 5NA NA 14.3 56 5 5 628 NA 14.9 66 5 6 -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org 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] compiling an R script
On 01.05.2012 00:12, strycker wrote: I'm interested in this question, too, not so I can hide code, but so I can run R code faster. It's been my experience that compiled code always runs faster than interpreted code. Can you explain further how to compile a front-end? -- View this message in context: http://r.789695.n4.nabble.com/compiling-an-R-script-tp2195949p4599541.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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. Hello, there is a thread on Stack Overflow concerning this: http://stackoverflow.com/questions/1452235/does-an-r-compiler-exist Regards! -- GnuPG Key:7340821E http://pgp.mit.edu:11371/pks/lookup?search=0x7340821eop=indexfingerprint=on [[alternative HTML version deleted]] __ R-help@r-project.org 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] Subtract days to dates in POSIXct format
Yes, sorting longitude and latitude correctly solves the problem! However, this only works near the Canaries. When selecting the January data (probable location: South African waters) sunrise time (but not sunset time) for the given coordinates is about 4 hours later than the local sunrise. Sys.setenv( TZ=GMT ) # set to the local timezone for column time dta -read.table(eg.txt,sep=',',col.names=c(ok,time,secs,lig),stringsAsFactors=FALSE) dta$dtm - as.POSIXct(dta$time, format=%d/%m/%y %T ) # depends on TZ site - SpatialPoints( matrix(c(-15.77, 27.82), nrow=1),proj4string=CRS(+proj=longlat +datum=WGS84)) # Canary Is dta$rise - sunriset(site, dta$dtm, direction=sunrise,POSIXct.out=TRUE)$time dta$set - sunriset( site, dta$dtm, direction=sunset, POSIXct.out=TRUE )$time dta$isnight - with( dta, !( rise dtm dtm set ) ) A=cbind(dta,colsplit(dta$time, split = \\s, names = c(date, clock))) B=cbind(A,colsplit(A$date, split = /, names = c(d, m, y))) C-subset(B,B$m==1) # January data; the bird was in South Atlantic waters write.table(C) Thank you very much for your help, Santi From: Jeff Newmiller jdnew...@dcn.davis.ca.us To: Santiago Guallar sgual...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Sent: Tuesday, May 1, 2012 1:14 AM Subject: Re: [R] Subtract days to dates in POSIXct format The sunrise and sunset are calculated for each time value on the input vector, but all times are treated in the TZ timezone. I can see that the Canary Islands are in the GMT timezone, so the example TZ is right. I can see that you entered the latitude and longitude backward (longitude is x), but I am not able to look at your data at the moment so I don't know whether that fixes your problem. Maptools assumes one location Depending on where the bird went in the South Atlantic, the assumed latitude could be several hours wrong, though. Also, there is dependence of length of day on latitude (made more noticeable by crossing the equator). --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Santiago Guallar sgual...@yahoo.com wrote: Thanks a lot, Jeff Yes, I applied colsplit in package reshape. Sorry, I forgot to state it in the piece of code I attached. Actually, these are archival data from a geolocator attached to a seabird. The origin lies on Gran Canaria and data were gathered all along its migratory journey for one full year, from the Canary Islands all the way to the South Atlantic Ocean and back. Variable lig, which stands for light, indicates daylight (aprox lig2) or its absence (lig2), so I know when it is nighttime or daytime for sure. However, I'd like to compare it with the output of the maptools functions. If I understood well maptools functions use astronomical algorithms to calculate sunrise and sunset based on one location and one POSIXct time. If I changed your invented coordinates and time for the real ones in my dataset would do the job correctly? When I put the aproximate coordinates it yields an incorrect output: site - SpatialPoints( matrix(c(27.82, -15.77), nrow=1),proj4string=CRS(+proj=longlat +datum=WGS84)) # didn't touch the rest of your code But I'm probably doing something wrong. Santi From: Jeff Newmiller jdnew...@dcn.davis.ca.us To: Santiago Guallar sgual...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Sent: Monday, April 30, 2012 5:51 PM Subject: Re: [R] Subtract days to dates in POSIXct format On Mon, 30 Apr 2012, Santiago Guallar wrote: Hello, I'm having problems working with date values in POSIXct format. Indeed you are. Here is what I got (eg.lig attached): x - read.table(eg.txt, sep = ',', col.names=c(ok,time,secs,lig)) # it gives time as factor z - cbind(x,colsplit(x$time, split=\\s, names=c(date, clock))) colsplit is not defined in base R, and it is redefined in a couple of packages. I am guessing you mean the one that is in the reshape package. zh-cbind(z,colsplit(z$clock,split=:,names=c(h,m,s))) zn - subset(zh, zh$lig= 5 zh$h8 | zh$h=22) # nighttime zn$timepos-as.POSIXct(zn$time,tz=GMT,format=%d/%m/%y %H:%M:%S) I want to assign timepos to its ?natural? night, that is, the night that goes from sunset of day x to sunrise of day x+1 corresponds to day x: You are working here with GMT, but there are many other possible timezones that this data could correspond to, and if the input time really is in GMT, then the interval of night could be
Re: [R] Clustering analysis with ordination plots
On 30.04.2012 18:44, borinot wrote: Hello to all, I'm new to R so I have a lot of problems with it, but I'll only ask the main one. I have clustered an environmental matrix We do not know what that is. Where is the example data? See the posting guide. with 2 different methods, Which? Where is the reproducible code? See the posting guide. and I'd like to plot them in a PCA PCA is a method for reduction of dimensions. Frequently, if reduction works nicely, you can find clusters when plotting the first few PCs. But plot them [clusters] in a PCA is semantically invalid. and a db-RDA. What is a db-RDA? I mean, I want see these clusters in the plots like points of differents colours, together with the rest information of the plot, but I don't know how to do this. Tells us how you clustered the data and how you visualized it so far and we may be able to show you how to go ahead. I've checked a lot of bibliography and forums, and I haven't found the solution... it can't be so hard! Well, thanks in advance! :) But really, read the posting guide in advance of follow up questions: It helps to improve the way you ask questions and hence you will probably get more useful answers. Uwe Ligges -- View this message in context: http://r.789695.n4.nabble.com/Clustering-analysis-with-ordination-plots-tp4598695.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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@r-project.org 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] Different varable lengths
-Original Message- From: sarah.gos...@gmail.com Sent: Mon, 30 Apr 2012 17:06:19 -0400 To: jrkrid...@inbox.com Subject: Re: [R] Different varable lengths Because of the missing comma. I knew I needed new glasses ! On Mon, Apr 30, 2012 at 4:56 PM, John Kane jrkrid...@inbox.com wrote: length(Sweden.GDP.gap.adjust) [1] 8 Sweden.GDP.gap.adjust [1] 0.673792123 1.196706756 1.196131539 0.646944002 -0.312886525 [6] -1.706584861 -0.369401194 -0.003280389 R is reading Sweden.GDP.gapp.adjust as having 8 elements. Why I don't know. John Kane Kingston ON Canada -Original Message- From: bahman.za...@comhem.se Sent: Mon, 30 Apr 2012 02:43:32 -0700 (PDT) To: r-help@r-project.org Subject: [R] Different varable lengths Hi! I'm trying to do a lm() test on three objects. My problem is that R protests and says that the variable lengths differ for one of the objects (Sweden.GDP.gap). But I have double checked that the number of observations are the same. All three objects should contain 9 observations but R only accepts 9 observations in two of the objects. The third must have 10! Very confusing because there is no 10th observation! # Adjusted Real rate - P Sweden.p.adjust - c(4.70243, 1.3776655, 1.117755, 1.6695175, 1.59282, 1.1017625, -0.04295, 2.2552875, 0.0552875) # Adjusted Inflation deviation Sweden.infl.dev.adjust - c(0.110382497, -0.261612509, 0.040847515, -0.195062497, -0.234362485, -0.023408728, 0.206421261, -0.079401261, 0.071828752) # Adjusted GDP-gap Sweden.GDP.gap.adjust - c(0.673792123, 1.196706756, 1.196131539, 0.646944002, -0.312886525, -1.180620213 -0.525964648, -0.369401194, -0.003280389) # OLS regression using ADJUSTED data.# Sweden.Taylor.real.adjust - lm(Sweden.p.adjust ~ Sweden.infl.dev.adjust + Sweden.GDP.gap.adjust) Error in model.frame.default(formula = Sweden.p.adjust ~ Sweden.infl.dev.adjust + : variable lengths differ (found for 'Sweden.GDP.gap.adjust') Why is this happening? / Saint -- Sarah Goslee http://www.functionaldiversity.org FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ R-help@r-project.org 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] Why does the order of terms in a formula translate into different models/ model matrices?
I know this is three months old, but I had put it on a mental TODO list to see whether it was something that could be fixed, and I finally got a little spare time for that sort of thing. It turns out that it can NOT be fixed (without fundamental design changes), so I thought I'd better record the conclusion for the archives. The reason is pretty simple: It is terms.formula that decides which terms require contrast coding and which need dummy coding. It does this based on the formula structure _only_; i.e., it has no information on whether variables are factors or numerical. E.g., you can do terms(~ a:x + a:b) ~a:x + a:b attr(,variables) list(a, x, b) attr(,factors) a:x a:b a 2 2 x 2 0 b 0 1 attr(,term.labels) [1] a:x a:b attr(,order) [1] 2 2 attr(,intercept) [1] 1 attr(,response) [1] 0 attr(,.Environment) environment: R_GlobalEnv in which there is no indication to terms() what kind of variable x is. So if you want different behavior if x is a factor than if it is continuous, you're out of luck... Not quite sure the last three lines of my note below make sense, though. -pd On Jan 29, 2012, at 11:24 , peter dalgaard wrote: On Jan 29, 2012, at 02:42 , Ben Bolker wrote: (quoting removed to make Gmane happy) AFAICS, this is a bug. I think so too, although I haven't got my head around it yet. Chuck, are you willing to post a summary of this to r-devel for discussion ... and/or post a bug report? You have to be very specific about what the bug is, if any... I.e., which precisely are the rules that are broken by the current behavior? Preferably also suggest a fix --- the corner cases of model.matrix and friends is some of the more impenetrable code in the R sources. Notice that order dependent parametrization of terms is not a bug per se, nor is the automatic switch to dummy coding of factors. Consider these cases: d - cbind(expand.grid(a=c(a,b),b=c(X,Y),c=c(U,W)),x=1:8) model.matrix(~ a:b + a:c, d) model.matrix(~ a:c + a:b, d) model.matrix(~ a:b + a:x, d) model.matrix(~ a:x + a:b, d) and notice that the logic applying to x is the same as that applying to c. The crux seems to be that the model ~a:c contains the model ~a whereas ~a:x does not, and hence the rationale for _not_ expanding a subsequent a:b term to dummies (namely that ~a is already in the model) fails. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org 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] Question about expand.grid function in R
Hi, I am extremely new to R, and was wondering if someone would be able to help me with a question regarding the expand.grid function. When I input expand.grid.rep - function(x, n=1) do.call(expand.grid, rep(list(x),n)) expand.grid.rep(c(a, b, c), 3) my output is as follows, Var1 Var2 Var3 1 a a a 2 b a a 3 c a a 4 a b a 5 b b a 6 c b a 7 a c a 8 b c a 9 c c a 10 a a b 11 b a b 12 c a b 13 a b b 14 b b b 15 c b b 16 a c b 17 b c b 18 c c b 19 a a c 20 b a c 21 c a c 22 a b c 23 b b c 24 c b c 25 a c c 26 b c c 27 c c c I was wondering if there was anyway I can change the row numbers to labels that indicate what is in each row. Instead of a 1, I'd like to have a label saying aaa, etc. I'm not sure if this is even possible within the expand.grid function but any help would be appreciated. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org 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] Area between 2 curves
Yes, i have install the Package Bolstad. And it works (sintegral). -- View this message in context: http://r.789695.n4.nabble.com/Area-between-2-curves-tp4597813p4600629.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Question about expand.grid function in R
I don't think you can do it within expand.grid() but something like this might work: rownames(x) - apply(x, 1, paste, collapse = ) Michael On Tue, May 1, 2012 at 5:05 AM, Kelly Cool kellycoo...@yahoo.com wrote: Hi, I am extremely new to R, and was wondering if someone would be able to help me with a question regarding the expand.grid function. When I input expand.grid.rep - function(x, n=1) do.call(expand.grid, rep(list(x),n)) expand.grid.rep(c(a, b, c), 3) my output is as follows, Var1 Var2 Var3 1 a a a 2 b a a 3 c a a 4 a b a 5 b b a 6 c b a 7 a c a 8 b c a 9 c c a 10 a a b 11 b a b 12 c a b 13 a b b 14 b b b 15 c b b 16 a c b 17 b c b 18 c c b 19 a a c 20 b a c 21 c a c 22 a b c 23 b b c 24 c b c 25 a c c 26 b c c 27 c c c I was wondering if there was anyway I can change the row numbers to labels that indicate what is in each row. Instead of a 1, I'd like to have a label saying aaa, etc. I'm not sure if this is even possible within the expand.grid function but any help would be appreciated. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] Optim (fct): Parameters=LowerBounds
There's no reason that the optimum cannot be at the bounds. Bounded problems really do sometimes have solutions on those bounds. Compute the unconstrained gradient of your objective function at the bounds and see if the function is reduced when going across the bounds. The function here is assumed to be the neg. LL that one is MINIMIZING. There are many aspects of R, optimization in particular, where it would help if we required an operator's license. It is not a magical spell that solves problems automatically, but a tool much like a chainsaw that can as easily cut your arm off as saw a log. JN On 05/01/2012 06:00 AM, r-help-requ...@r-project.org wrote: Message: 54 Date: Mon, 30 Apr 2012 08:30:24 -0700 (PDT) From: barb mainze...@hotmail.com To: r-help@r-project.org Subject: [R] Optim (fct): Parameters=LowerBounds!? Message-ID: 1335799824557-4598504.p...@n4.nabble.com Content-Type: text/plain; charset=UTF-8 Hey, i am trying to do the MLE for Garch and have a problem with the optim function. Initally i tried optim with Method=BFGS. Reading trhough the forum i found out i would neet bounds. So i went on with Method=L-BFGS-B. But now my parameters equal the lower bounds. out - optim(par=initial, fn=LogLik.GARCH,X=X, P=1, Q=1, method = L-BFGS-B,lower =c(0.01,0.01,0.01), upper =c(0.99,0.99,0.99)) out --- *$par [1] 0.01 0.01 0.01* [...] $convergence [1] 0 *$message [1] CONVERGENCE: NORM OF PROJECTED GRADIENT = PGTOL*--- __ R-help@r-project.org 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] question on jitter in plot.Predict in rms
Mike, Try plot(pref, ..., scat1d.opts=list(frac=0.025, lwd=0.3, nhistSpike=i)) where i = 1 to always use spike histograms (default is to use them if n = 2000) or i=1e7 to never use them and to always jitter instead. There are many other scat1d options you can pass through scat1d.opts. Frank Mike Babyak wrote Dear colleagues, I have a question regarding controlling the jitter when plotting predictions in the rms package. Below I've simulated some data that reflect what I'm working with. The model predicts a continuous variable with an ordinal score, a two-level group, and a continuous covariate. Of primary interest is a plot of the group by score interaction, where the score is the ordinal variable, and the group Ns are quite disparate. When I produce the plot for the predicted values with the data=llist argument, as expected I get datadensity hatch marks. However, in the group with the smaller N, I get jittered datadensity points, while in the group with the larger N, the jitter apparently defaults to single vertical lines, which I assume is because the jitter would look like a black blob. Some of my co-authors are a bit worried about how that looks, so here I am. Apart from abandoning data=llist altogether, is there a way to modify the jitter in the smaller group so it behaves like the larger one? Of secondary importance, anything you can tell me about improving my clumsy little simulation code would be welcome--I have little to no idea what I'm doing there. for example, would there be a way to produce the group variable with the disparate Ns more directly? Thanks, Mike Babyak Behavioral Medicine Research Center Duke University Medical Center #question about jitter/llist in rms #R v 2.14.1 under windows 7 #question about jitter/llist in rms require(rms) #simulate some data n = 5000 age = runif(n) score = runif(n) + 0.5*age group- as.numeric(sample(c(FALSE,TRUE), 5000, replace=T, prob=c(.1, .9))) ordscore = as.numeric(factor(rep(1:5, length.out=n))) table(group,ordscore) e = rnorm(n, 0, 0.1) #true model y = group + 0.6*ordscore + group*ordscore + .2*age + e #convert group to factor group.f-as.factor(group) #save data characterics dd1-datadist(age,ordscore,group.f) options(datadist=dd1) #estimate model reg1-ols(y~group.f+ordscore+group.f*ordscore+age,x=T,y=T) #plot results preg-Predict(reg1,ordscore,group.f) #produces interaction plot with datadensity hatch marks plot(preg,data=llist(ordscore,group.f)) [[alternative HTML version deleted]] __ R-help@ 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. - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/question-on-jitter-in-plot-Predict-in-rms-tp4598555p4600795.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Question about expand.grid function in R
On May 1, 2012, at 15:36 , R. Michael Weylandt wrote: I don't think you can do it within expand.grid() but something like this might work: rownames(x) - apply(x, 1, paste, collapse = ) Also rownames(x) - do.call(paste, c(x, sep=)) or, in recent versions, rownames(x) - do.call(paste0, x) Michael On Tue, May 1, 2012 at 5:05 AM, Kelly Cool kellycoo...@yahoo.com wrote: Hi, I am extremely new to R, and was wondering if someone would be able to help me with a question regarding the expand.grid function. When I input expand.grid.rep - function(x, n=1) do.call(expand.grid, rep(list(x),n)) expand.grid.rep(c(a, b, c), 3) my output is as follows, Var1 Var2 Var3 1 aaa 2 baa 3 caa 4 aba 5 bba 6 cba 7 aca 8 bca 9 cca 10aab 11bab 12cab 13abb 14bbb 15cbb 16acb 17bcb 18ccb 19aac 20bac 21cac 22abc 23bbc 24cbc 25acc 26bcc 27ccc I was wondering if there was anyway I can change the row numbers to labels that indicate what is in each row. Instead of a 1, I'd like to have a label saying aaa, etc. I'm not sure if this is even possible within the expand.grid function but any help would be appreciated. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org 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] Usage line in .pdf version of manual is truncated
There is actually another approach which can do the job automatically; see the function reformat_code() in R2roxygen (remember to back up your Rd files before you use it). If you document your package with roxygen2, things can be even easier -- just call the function rab() to roxygenize and reformat code. This is what I do with all my packages. Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Mon, Apr 30, 2012 at 10:37 PM, Joshua Wiley jwiley.ps...@gmail.com wrote: Break the line :) On Mon, Apr 30, 2012 at 12:34 PM, Zeeberg, Barry (NIH/NCI) [E] zeebe...@mail.nih.gov wrote: I am creating a package, and a rather long usage line for one function becomes truncated in the generated .pdf manual. Is there a way that I can prevent that truncation? __ R-help@r-project.org 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] error bars for a barchart
Hi I have the following barchart to which I want to add error bars. library(lattice) barchart(Change~fTreat,groups=Process,change, auto.key=list(points=FALSE,rectangles=TRUE), panel=function(x, y,...){ panel.barchart(x,y,origin = 0,...); panel.abline(h=0,col=black,...); } ) I have tried using the panel.errbars from the memisc package which works great for xyplots, but when I add it to my code it does not respect the groups. library(memisc) barchart(cbind(Change,lower,upper)~fTreat,groups=Process,change, ylab=Pocertage change, ylim=-115:50, scales=list(alternating=FALSE, tick.number=7, tck=c(-1,0)), panel=function(x, y,groups,...){ panel.barchart(x,y=change$Change,groups=change$Process,origin = 0,...); panel.abline(h=0,col=black,...); panel.errbars(x,y,make.grid=none,ewidth=0.2,type=n,...) } ) Any ideas of how to add error bars to my plot either using the panel.errbars or any other function? The data: structure(list(Treat = structure(c(3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L), .Label = c(12-380, 12-750, 8-380, 8-750), class = factor), Process = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c(Resp, Cal), class = c(ordered, factor)), Change = c(-33.05, -34.74, 20.94, 18.06, 6.85, -28.57, -8.1, -78.72), upper = c(-13.22896628, -28.61149669, 31.29930461, 27.30173776, 39.73271282, 9.458372948, 13.11035572, -47.03745704), lower = c(-52.86120694, -40.87446411, 10.57421563, 8.822042178, -26.03144161, -66.60447035, -29.30563327, -110.3973761), fTreat = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c(8-380, 8-750, 12-380, 12-750), class = c(ordered, factor))), .Names = c(Treat, Process, Change, upper, lower, fTreat), row.names = c(NA, -8L), class = data.frame) Regards Beatriz de Francisco Mora PhD Student The Scottish Association for Marine Science Scottish Marine Institute Oban PA37 1QA Tel: 06131 559000 (switchboard) Fax: 01631559001 E. beatriz.defranci...@sams.ac.ukmailto:beatriz.defranci...@sams.ac.uk http://www.smi.ac.uk/beatriz-de-franciso The Scottish Association for Marine Science (SAMS) is registered in Scotland as a Company Limited by Guarantee (SC009292) and is a registered charity (9206). SAMS has an actively trading wholly owned subsidiary company: SAMS Research Services Ltd a Limited Company (SC224404). All Companies in the group are registered in Scotland and share a registered office at Scottish Marine Institute, Oban Argyll PA37 1QA. The content of this message may contain personal views which are not the views of SAMS unless specifically stated. Please note that all email traffic is monitored for purposes of security and spam filtering. As such individual emails may be examined in more detail. [[alternative HTML version deleted]] __ R-help@r-project.org 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] 95% confidence interval of the coefficients from a bootstrap analysis
Hello, baconbeach wrote Thanks again for your swift response!! With your last line, I get rowMeans(sapply(stor.confint, colMeans)) 2.5 %97.5 % 0.3256882 0.4604677 I need the values (2.5% and 97.5%) for each variable of my model. I don't think this what I am getting. This is what my script looks like now, after your help: N = length (data_Pb[,1]) B = 1 stor.r2 = rep(0,B) stor.coeffs - vector(list, B) stor.confint - vector(list, B) for (i in 1:B){ idx = sample(1:N, replace=T) newdata = data_Pb[idx,] L_NPRI_25k - log(newdata$NPRI_25k+1) data_Pb.boot = lm(newdata$Log_Level ~ newdata$Ind_5k + newdata$MineP_50k + newdata$NPRI_10k + L_NPRI_25k ) stor.r2[i] = summary(data_Pb.boot)$r.squared stor.coeffs [[i]] - coef(data_Pb.boot) stor.confint[[i]] - confint(data_Pb.boot) } hist(stor.r2, xlab=R-squared,main=Distribution of R-squared - Lead (log)) summary(stor.r2) rowMeans(sapply(stor.confint, colMeans)) rowMeans(sapply(stor.coeffs, colMeans)) Thanks Steeve Ok, my mistake. Bootstrapped values for each coefficient, obviously. Try, after the loop, # Transform list into matrix, before applying 'colMeans' stor.coeffs - do.call(rbind, stor.coeffs) colMeans(stor.coeffs) # The same, but in two steps Q2.5 - lapply(stor.confint, function(x) x[ , 1]) Q2.5 - do.call(rbind, Q2.5) head(Q2.5) Q97.5 - lapply(stor.confint, function(x) x[ , 2]) Q97.5 - do.call(rbind, Q97.5) head(Q97.5) colMeans(Q2.5) colMeans(Q97.5) # Maybe this is better stor.ci - data.frame(Q2.5=colMeans(Q2.5), Q97.5=colMeans(Q97.5)) rm(Q2.5, Q97.5) # Final clean-up Maybe you could reuse the name 'stor.confint', it would save some memory. Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/95-confidence-interval-of-the-coefficients-from-a-bootstrap-analysis-tp4599692p4600737.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] error bars for a barchart
Hi I have the following barchart to which I want to add error bars. library(lattice) barchart(Change~fTreat,groups=Process,change, auto.key=list(points=FALSE,rectangles=TRUE), panel=function(x, y,...){ panel.barchart(x,y,origin = 0,...); panel.abline(h=0,col=black,...); } ) I have tried using the panel.errbars from the memisc package which works great for xyplots, but when I add it to my code it does not respect the groups. library(memisc) barchart(cbind(Change,lower,upper)~fTreat,groups=Process,change, ylab=Pocertage change, ylim=-115:50, scales=list(alternating=FALSE, tick.number=7, tck=c(-1,0)), panel=function(x, y,groups,...){ panel.barchart(x,y=change$Change,groups=change$Process,origin = 0,...); panel.abline(h=0,col=black,...); panel.errbars(x,y,make.grid=none,ewidth=0.2,type=n,...) } ) Any ideas of how to add error bars to my plot either using the panel.errbars or any other function? The data: structure(list(Treat = structure(c(3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L), .Label = c(12-380, 12-750, 8-380, 8-750), class = factor), Process = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c(Resp, Cal), class = c(ordered, factor)), Change = c(-33.05, -34.74, 20.94, 18.06, 6.85, -28.57, -8.1, -78.72), upper = c(-13.22896628, -28.61149669, 31.29930461, 27.30173776, 39.73271282, 9.458372948, 13.11035572, -47.03745704), lower = c(-52.86120694, -40.87446411, 10.57421563, 8.822042178, -26.03144161, -66.60447035, -29.30563327, -110.3973761), fTreat = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c(8-380, 8-750, 12-380, 12-750), class = c(ordered, factor))), .Names = c(Treat, Process, Change, upper, lower, fTreat), row.names = c(NA, -8L), class = data.frame) Regards Beatriz de Francisco Mora PhD Student The Scottish Association for Marine Science Scottish Marine Institute Oban PA37 1QA Tel: 06131 559000 (switchboard) Fax: 01631559001 E. beatriz.defranci...@sams.ac.ukmailto:beatriz.defranci...@sams.ac.uk http://www.smi.ac.uk/beatriz-de-franciso The Scottish Association for Marine Science (SAMS) is registered in Scotland as a Company Limited by Guarantee (SC009292) and is a registered charity (9206). SAMS has an actively trading wholly owned subsidiary company: SAMS Research Services Ltd a Limited Company (SC224404). All Companies in the group are registered in Scotland and share a registered office at Scottish Marine Institute, Oban Argyll PA37 1QA. The content of this message may contain personal views which are not the views of SAMS unless specifically stated. Please note that all email traffic is monitored for purposes of security and spam filtering. As such individual emails may be examined in more detail. [[alternative HTML version deleted]] __ R-help@r-project.org 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] Regression
Thank u! -- View this message in context: http://r.789695.n4.nabble.com/Regression-tp4598984p4600776.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] rbind-ing numeric matrices
Good morning, I'm running into trouble rbind-ing numeric matrices with differing numbers of rows. In particular, there seem to be issues whenever a one-row numeric matrix is involved. Assume A is a numeric matrix with 1 row and Y columns and B is a numeric matrix with X rows and Y columns. Let C be the result of rbinding A and B. Then C is a numeric matrix with X + 1 rows and Y columns, only instead of the rows of B being stacked beneath the row of A as expected, the first Y elements of the 1st column of B are placed in the 2nd row of C, the remaining values of B are discarded, and NULL values fill out the rest of the matrix C. The number of columns of A and B match. The colnames of A and B match. Both are numeric matrices. I've pored over the rbind/cbind documentation but can't identify why I'm getting this behavior from rbind. I'd be extremely grateful for your suggestions or thoughts. Nick [[alternative HTML version deleted]] __ R-help@r-project.org 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] rbind-ing numeric matrices
Hi Nick, We absolutely need a reproducible example, with code and data, to be able to help you. Because otherwise I can't replicate your problem: A - matrix(1:5, nrow=1, ncol=5) B - matrix(6:20, nrow=3, ncol=5) C - rbind(A, B) A [,1] [,2] [,3] [,4] [,5] [1,]12345 B [,1] [,2] [,3] [,4] [,5] [1,]69 12 15 18 [2,]7 10 13 16 19 [3,]8 11 14 17 20 C [,1] [,2] [,3] [,4] [,5] [1,]12345 [2,]69 12 15 18 [3,]7 10 13 16 19 [4,]8 11 14 17 20 Sarah On Tue, May 1, 2012 at 11:52 AM, Nick Switanek nswita...@gmail.com wrote: Good morning, I'm running into trouble rbind-ing numeric matrices with differing numbers of rows. In particular, there seem to be issues whenever a one-row numeric matrix is involved. Assume A is a numeric matrix with 1 row and Y columns and B is a numeric matrix with X rows and Y columns. Let C be the result of rbinding A and B. Then C is a numeric matrix with X + 1 rows and Y columns, only instead of the rows of B being stacked beneath the row of A as expected, the first Y elements of the 1st column of B are placed in the 2nd row of C, the remaining values of B are discarded, and NULL values fill out the rest of the matrix C. The number of columns of A and B match. The colnames of A and B match. Both are numeric matrices. I've pored over the rbind/cbind documentation but can't identify why I'm getting this behavior from rbind. I'd be extremely grateful for your suggestions or thoughts. Nick -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org 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] rbind-ing numeric matrices
Hi, On Tue, May 1, 2012 at 11:52 AM, Nick Switanek nswita...@gmail.com wrote: Good morning, I'm running into trouble rbind-ing numeric matrices with differing numbers of rows. In particular, there seem to be issues whenever a one-row numeric matrix is involved. Assume A is a numeric matrix with 1 row and Y columns and B is a numeric matrix with X rows and Y columns. Let C be the result of rbinding A and B. Then C is a numeric matrix with X + 1 rows and Y columns, only instead of the rows of B being stacked beneath the row of A as expected, the first Y elements of the 1st column of B are placed in the 2nd row of C, the remaining values of B are discarded, and NULL values fill out the rest of the matrix C. The number of columns of A and B match. The colnames of A and B match. Both are numeric matrices. I've pored over the rbind/cbind documentation but can't identify why I'm getting this behavior from rbind. I'd be extremely grateful for your suggestions or thoughts. If everything you say is true (and I'm understanding what you're saying), there must be something else going on with your data. Consider: R m1 - matrix(-(1:5), nrow=1) R m2 - matrix(1:20, ncol=5) R rbind(m1, m2) [,1] [,2] [,3] [,4] [,5] [1,] -1 -2 -3 -4 -5 [2,]159 13 17 [3,]26 10 14 18 [4,]37 11 15 19 [5,]48 12 16 20 Can you provide a small example of your data that reproduces the problem you're seeing? Construct these objects in your workspace and copy/paste the output of dput on your m1 and m2 matrices so we can easily work w/ them. Cheers, -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org 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] [fields:image.plot] subtitle under title (not image)?
summary: how to make image.plot print a subtitle between the title and the image, rather than under the image? details: I've got a project https://github.com/TomRoche/ioapi-hack-R that illustrates the use of (et al) the R packages {ncdf4, fields, M3} for processing and visualizing IOAPI data. The data being visualized consists of a series of layers (mostly representing emissions from a particular tuple of agricultural {cultivar, cultivation technique}) over a surface (in the upper midwest US). I'm currently plotting https://github.com/downloads/TomRoche/ioapi-hack-R/compare.DN2.layers.pdf each layer, and including some information about the layer in a title and subtitle. The title is where I want it--above the image--but the subtitle is printing below the image; I'd prefer it between the title and the image. Can this be done? FWIW, the code that plots (in https://github.com/TomRoche/ioapi-hack-R/blob/master/plotLayersForTimestep.r ) is like if (data to plot is not all NA) { # determine quantiles, then image.plot(plot.list, xlab=, ylab=, axes=F, col=colors(100), axis.args=list(at=quantiles, labels=quantiles.formatted), main=title, sub=subtitle) lines(map) } else { plot(0, type=n, axes=F, xlab=, ylab=, xlim=range(x.centers), ylim=range(y.centers), main=title, sub=subtitle) lines(map) } # end testing data TIA, Tom Roche tom_ro...@pobox.com __ R-help@r-project.org 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] error bars for a barchart
Hi, I think the issue is not respecting the groups but finding the x-location of the center of bars in panel.barchart(groups,...). Don't know about the memisc package, but doesn't look like it provides an easy solution. This is how I do it: http://www.mail-archive.com/r-help@r-project.org/msg162299.html Might need to modify some for your data. HTH On Tue, May 1, 2012 at 8:01 AM, Beatriz De Francisco beatriz.defranci...@sams.ac.uk wrote: Hi I have the following barchart to which I want to add error bars. library(lattice) barchart(Change~fTreat,groups=Process,change, auto.key=list(points=FALSE,rectangles=TRUE), panel=function(x, y,...){ panel.barchart(x,y,origin = 0,...); panel.abline(h=0,col=black,...); } ) I have tried using the panel.errbars from the memisc package which works great for xyplots, but when I add it to my code it does not respect the groups. library(memisc) barchart(cbind(Change,lower,upper)~fTreat,groups=Process,change, ylab=Pocertage change, ylim=-115:50, scales=list(alternating=FALSE, tick.number=7, tck=c(-1,0)), panel=function(x, y,groups,...){ panel.barchart(x,y=change$Change,groups=change$Process,origin = 0,...); panel.abline(h=0,col=black,...); panel.errbars(x,y,make.grid=none,ewidth=0.2,type=n,...) } ) Any ideas of how to add error bars to my plot either using the panel.errbars or any other function? The data: structure(list(Treat = structure(c(3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L), .Label = c(12-380, 12-750, 8-380, 8-750), class = factor), Process = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c(Resp, Cal), class = c(ordered, factor)), Change = c(-33.05, -34.74, 20.94, 18.06, 6.85, -28.57, -8.1, -78.72), upper = c(-13.22896628, -28.61149669, 31.29930461, 27.30173776, 39.73271282, 9.458372948, 13.11035572, -47.03745704), lower = c(-52.86120694, -40.87446411, 10.57421563, 8.822042178, -26.03144161, -66.60447035, -29.30563327, -110.3973761), fTreat = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c(8-380, 8-750, 12-380, 12-750), class = c(ordered, factor))), .Names = c(Treat, Process, Change, upper, lower, fTreat), row.names = c(NA, -8L), class = data.frame) Regards Beatriz de Francisco Mora PhD Student The Scottish Association for Marine Science Scottish Marine Institute Oban PA37 1QA Tel: 06131 559000 (switchboard) Fax: 01631559001 E. beatriz.defranci...@sams.ac.ukmailto:beatriz.defranci...@sams.ac.uk http://www.smi.ac.uk/beatriz-de-franciso The Scottish Association for Marine Science (SAMS) is registered in Scotland as a Company Limited by Guarantee (SC009292) and is a registered charity (9206). SAMS has an actively trading wholly owned subsidiary company: SAMS Research Services Ltd a Limited Company (SC224404). All Companies in the group are registered in Scotland and share a registered office at Scottish Marine Institute, Oban Argyll PA37 1QA. The content of this message may contain personal views which are not the views of SAMS unless specifically stated. Please note that all email traffic is monitored for purposes of security and spam filtering. As such individual emails may be examined in more detail. [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest - matrix(1:12,nr=4) dftest - data.frame(mtest) ix - cbind(1:2,2:3) mtest[ix] - NA mtest [,1] [,2] [,3] [1,]1 NA9 [2,]26 NA [3,]37 11 [4,]48 12 ## But ... dftest[ix] - NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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] rbind-ing numeric matrices
Thank you, Steve and Sarah, for your swift replies. I didn't know about dput(). class() returns matrix for A, B, and C, but here: class(A) [1] matrix class(B) [1] matrix dput(A) structure(list(1239814462, 1239814601, 14349, 3, 4, 0, 12, 46601, 17801, 12401, 106001), .Dim = c(1L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) dput(B) structure(c(1239197400, 1239199200, 1239202800, 1239199199, 1239202799, 1239206399, 14342, 14342, 14342, 3, 3, 3, 0, 0, 0, 0, 0, 0, 9, 10, 11, 35999, 39599, 43199, 7199, 10799, 14399, 1799, 5399, 8999, 1799, 5399, 8999), .Dim = c(3L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) C - rbind(A,B) dput(C) structure(list(1239814462, 1239197400, NULL, NULL, 1239814601, 1239199200, NULL, NULL, 14349, 1239202800, NULL, NULL, 3, 1239199199, NULL, NULL, 4, 1239202799, NULL, NULL, 0, 1239206399, NULL, NULL, 12, 14342, NULL, NULL, 46601, 14342, NULL, NULL, 17801, 14342, NULL, NULL, 12401, 3, NULL, NULL, 106001, 3, NULL, NULL), .Dim = c(4L, 11L), .Dimnames = list(NULL, c(a, b, c, d, e, f, g, h, i, j, k))) But how do I convert A to the appropriate form for rbinding? Not simply with as.matrix(). Witness: dput(as.matrix(A)) structure(list(1239814462, 1239814601, 14349, 3, 4, 0, 12, 46601, 17801, 12401, 106001), .Dim = c(1L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) I think we're closer but I still need your help! Nick On Tue, May 1, 2012 at 12:02 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi, On Tue, May 1, 2012 at 11:52 AM, Nick Switanek nswita...@gmail.com wrote: Good morning, I'm running into trouble rbind-ing numeric matrices with differing numbers of rows. In particular, there seem to be issues whenever a one-row numeric matrix is involved. Assume A is a numeric matrix with 1 row and Y columns and B is a numeric matrix with X rows and Y columns. Let C be the result of rbinding A and B. Then C is a numeric matrix with X + 1 rows and Y columns, only instead of the rows of B being stacked beneath the row of A as expected, the first Y elements of the 1st column of B are placed in the 2nd row of C, the remaining values of B are discarded, and NULL values fill out the rest of the matrix C. The number of columns of A and B match. The colnames of A and B match. Both are numeric matrices. I've pored over the rbind/cbind documentation but can't identify why I'm getting this behavior from rbind. I'd be extremely grateful for your suggestions or thoughts. If everything you say is true (and I'm understanding what you're saying), there must be something else going on with your data. Consider: R m1 - matrix(-(1:5), nrow=1) R m2 - matrix(1:20, ncol=5) R rbind(m1, m2) [,1] [,2] [,3] [,4] [,5] [1,] -1 -2 -3 -4 -5 [2,]159 13 17 [3,]26 10 14 18 [4,]37 11 15 19 [5,]48 12 16 20 Can you provide a small example of your data that reproduces the problem you're seeing? Construct these objects in your workspace and copy/paste the output of dput on your m1 and m2 matrices so we can easily work w/ them. Cheers, -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact [[alternative HTML version deleted]] __ R-help@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
Hi Bert, The failure itself is the documented behavior: ?'[.data.frame' says Matrix indexing ('x[i]' with a logical or a 2-column integer matrix 'i') using '[' is not recommended, and barely supported. For extraction, 'x' is first coerced to a matrix. For replacement, a logical matrix (only) can be used to select the elements to be replaced in the same way as for a matrix. The error message may be a bit hinky, as obviously data.frames can be indexed by things other than logical matricies. Or is there another reason this strikes you as odd? Best, Ista On Tue, May 1, 2012 at 1:33 PM, Bert Gunter gunter.ber...@gene.com wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest - matrix(1:12,nr=4) dftest - data.frame(mtest) ix - cbind(1:2,2:3) mtest[ix] - NA mtest [,1] [,2] [,3] [1,] 1 NA 9 [2,] 2 6 NA [3,] 3 7 11 [4,] 4 8 12 ## But ... dftest[ix] - NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
On 01-May-2012 17:33:23 Bert Gunter wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest - matrix(1:12,nr=4) dftest - data.frame(mtest) ix - cbind(1:2,2:3) mtest[ix] - NA mtest [,1] [,2] [,3] [1,]1 NA9 [2,]26 NA [3,]37 11 [4,]48 12 ## But ... dftest[ix] - NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert Also interesting is that, prior to the substitution commands, mtest[ix] # [1] 5 10 dftest[ix] # [1] 5 10 both as one would expect on Bert's naive gounds (which, I confess, I also share[d]). Ted. - E-Mail: (Ted Harding) ted.hard...@wlandres.net Date: 01-May-2012 Time: 19:03:14 This message was sent by XFMail __ R-help@r-project.org 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] rbind-ing numeric matrices
Hi Nick, On Tue, May 1, 2012 at 1:56 PM, Nick Switanek nswita...@gmail.com wrote: Thank you, Steve and Sarah, for your swift replies. I didn't know about dput(). class() returns matrix for A, B, and C, but here: class(A) [1] matrix class(B) [1] matrix dput(A) structure(list(1239814462, 1239814601, 14349, 3, 4, 0, 12, 46601, 17801, 12401, 106001), .Dim = c(1L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) I'm not sure how you created A, but it's a list - see the structure given by dput(), and also: is.list(A) [1] TRUE is.list(B) [1] FALSE dput(B) structure(c(1239197400, 1239199200, 1239202800, 1239199199, 1239202799, 1239206399, 14342, 14342, 14342, 3, 3, 3, 0, 0, 0, 0, 0, 0, 9, 10, 11, 35999, 39599, 43199, 7199, 10799, 14399, 1799, 5399, 8999, 1799, 5399, 8999), .Dim = c(3L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) Note that the structure for B doesn't say anything about it being a list. In this particular case, you can fix that with: rbind(unlist(A), B) a b c d e f g h i j k [1,] 1239814462 1239814601 14349 3 4 0 12 46601 17801 12401 106001 [2,] 1239197400 1239199199 14342 3 0 0 9 35999 7199 1799 1799 [3,] 1239199200 1239202799 14342 3 0 0 10 39599 10799 5399 5399 [4,] 1239202800 1239206399 14342 3 0 0 11 43199 14399 8999 8999 But now I'm curious where A came from. Sarah C - rbind(A,B) dput(C) structure(list(1239814462, 1239197400, NULL, NULL, 1239814601, 1239199200, NULL, NULL, 14349, 1239202800, NULL, NULL, 3, 1239199199, NULL, NULL, 4, 1239202799, NULL, NULL, 0, 1239206399, NULL, NULL, 12, 14342, NULL, NULL, 46601, 14342, NULL, NULL, 17801, 14342, NULL, NULL, 12401, 3, NULL, NULL, 106001, 3, NULL, NULL), .Dim = c(4L, 11L), .Dimnames = list(NULL, c(a, b, c, d, e, f, g, h, i, j, k))) But how do I convert A to the appropriate form for rbinding? Not simply with as.matrix(). Witness: dput(as.matrix(A)) structure(list(1239814462, 1239814601, 14349, 3, 4, 0, 12, 46601, 17801, 12401, 106001), .Dim = c(1L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) I think we're closer but I still need your help! Nick On Tue, May 1, 2012 at 12:02 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi, On Tue, May 1, 2012 at 11:52 AM, Nick Switanek nswita...@gmail.com wrote: Good morning, I'm running into trouble rbind-ing numeric matrices with differing numbers of rows. In particular, there seem to be issues whenever a one-row numeric matrix is involved. Assume A is a numeric matrix with 1 row and Y columns and B is a numeric matrix with X rows and Y columns. Let C be the result of rbinding A and B. Then C is a numeric matrix with X + 1 rows and Y columns, only instead of the rows of B being stacked beneath the row of A as expected, the first Y elements of the 1st column of B are placed in the 2nd row of C, the remaining values of B are discarded, and NULL values fill out the rest of the matrix C. The number of columns of A and B match. The colnames of A and B match. Both are numeric matrices. I've pored over the rbind/cbind documentation but can't identify why I'm getting this behavior from rbind. I'd be extremely grateful for your suggestions or thoughts. If everything you say is true (and I'm understanding what you're saying), there must be something else going on with your data. Consider: R m1 - matrix(-(1:5), nrow=1) R m2 - matrix(1:20, ncol=5) R rbind(m1, m2) [,1] [,2] [,3] [,4] [,5] [1,] -1 -2 -3 -4 -5 [2,] 1 5 9 13 17 [3,] 2 6 10 14 18 [4,] 3 7 11 15 19 [5,] 4 8 12 16 20 Can you provide a small example of your data that reproduces the problem you're seeing? Construct these objects in your workspace and copy/paste the output of dput on your m1 and m2 matrices so we can easily work w/ them. Cheers, -steve -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
Many thanks, Ista: I only looked in ].default so the answer is: Alternative 4: dumb Bert. Rap knuckles with ruler. Actually, indexing by a logical matrix doesn't make much sense to me in either case, as it does not have the effect of selecting individual elements, which is what numeric matrix indices do. But that's a matter of usage, neither bug nor feature. If I had gotten something like the error message: Matrix indices not allowed for replacement in data frames, I would not have been surprised. But as you said, the behavior **IS** documented. Best, Bert On Tue, May 1, 2012 at 10:49 AM, Ista Zahn istaz...@gmail.com wrote: Hi Bert, The failure itself is the documented behavior: ?'[.data.frame' says Matrix indexing ('x[i]' with a logical or a 2-column integer matrix 'i') using '[' is not recommended, and barely supported. For extraction, 'x' is first coerced to a matrix. For replacement, a logical matrix (only) can be used to select the elements to be replaced in the same way as for a matrix. The error message may be a bit hinky, as obviously data.frames can be indexed by things other than logical matricies. Or is there another reason this strikes you as odd? Best, Ista On Tue, May 1, 2012 at 1:33 PM, Bert Gunter gunter.ber...@gene.com wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest - matrix(1:12,nr=4) dftest - data.frame(mtest) ix - cbind(1:2,2:3) mtest[ix] - NA mtest [,1] [,2] [,3] [1,] 1 NA 9 [2,] 2 6 NA [3,] 3 7 11 [4,] 4 8 12 ## But ... dftest[ix] - NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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] rbind-ing numeric matrices
Thank you, Sarah! Yes, unlist() looks like it will do just what I need. Thank you. I took a different tack. I'd changed the function returning A to coerce the row from the data.frame using as.numeric(). Any reason to prefer your way or mine? thanks again, Nick On Tue, May 1, 2012 at 2:08 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Hi Nick, On Tue, May 1, 2012 at 1:56 PM, Nick Switanek nswita...@gmail.com wrote: Thank you, Steve and Sarah, for your swift replies. I didn't know about dput(). class() returns matrix for A, B, and C, but here: class(A) [1] matrix class(B) [1] matrix dput(A) structure(list(1239814462, 1239814601, 14349, 3, 4, 0, 12, 46601, 17801, 12401, 106001), .Dim = c(1L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) I'm not sure how you created A, but it's a list - see the structure given by dput(), and also: is.list(A) [1] TRUE is.list(B) [1] FALSE dput(B) structure(c(1239197400, 1239199200, 1239202800, 1239199199, 1239202799, 1239206399, 14342, 14342, 14342, 3, 3, 3, 0, 0, 0, 0, 0, 0, 9, 10, 11, 35999, 39599, 43199, 7199, 10799, 14399, 1799, 5399, 8999, 1799, 5399, 8999), .Dim = c(3L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) Note that the structure for B doesn't say anything about it being a list. In this particular case, you can fix that with: rbind(unlist(A), B) a b c d e f g h i j k [1,] 1239814462 1239814601 14349 3 4 0 12 46601 17801 12401 106001 [2,] 1239197400 1239199199 14342 3 0 0 9 35999 7199 1799 1799 [3,] 1239199200 1239202799 14342 3 0 0 10 39599 10799 5399 5399 [4,] 1239202800 1239206399 14342 3 0 0 11 43199 14399 8999 8999 But now I'm curious where A came from. Sarah C - rbind(A,B) dput(C) structure(list(1239814462, 1239197400, NULL, NULL, 1239814601, 1239199200, NULL, NULL, 14349, 1239202800, NULL, NULL, 3, 1239199199, NULL, NULL, 4, 1239202799, NULL, NULL, 0, 1239206399, NULL, NULL, 12, 14342, NULL, NULL, 46601, 14342, NULL, NULL, 17801, 14342, NULL, NULL, 12401, 3, NULL, NULL, 106001, 3, NULL, NULL), .Dim = c(4L, 11L), .Dimnames = list(NULL, c(a, b, c, d, e, f, g, h, i, j, k))) But how do I convert A to the appropriate form for rbinding? Not simply with as.matrix(). Witness: dput(as.matrix(A)) structure(list(1239814462, 1239814601, 14349, 3, 4, 0, 12, 46601, 17801, 12401, 106001), .Dim = c(1L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) I think we're closer but I still need your help! Nick On Tue, May 1, 2012 at 12:02 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi, On Tue, May 1, 2012 at 11:52 AM, Nick Switanek nswita...@gmail.com wrote: Good morning, I'm running into trouble rbind-ing numeric matrices with differing numbers of rows. In particular, there seem to be issues whenever a one-row numeric matrix is involved. Assume A is a numeric matrix with 1 row and Y columns and B is a numeric matrix with X rows and Y columns. Let C be the result of rbinding A and B. Then C is a numeric matrix with X + 1 rows and Y columns, only instead of the rows of B being stacked beneath the row of A as expected, the first Y elements of the 1st column of B are placed in the 2nd row of C, the remaining values of B are discarded, and NULL values fill out the rest of the matrix C. The number of columns of A and B match. The colnames of A and B match. Both are numeric matrices. I've pored over the rbind/cbind documentation but can't identify why I'm getting this behavior from rbind. I'd be extremely grateful for your suggestions or thoughts. If everything you say is true (and I'm understanding what you're saying), there must be something else going on with your data. Consider: R m1 - matrix(-(1:5), nrow=1) R m2 - matrix(1:20, ncol=5) R rbind(m1, m2) [,1] [,2] [,3] [,4] [,5] [1,] -1 -2 -3 -4 -5 [2,]159 13 17 [3,]26 10 14 18 [4,]37 11 15 19 [5,]48 12 16 20 Can you provide a small example of your data that reproduces the problem you're seeing? Construct these objects in your workspace and copy/paste the output of dput on your m1 and m2 matrices so we can easily work w/ them. Cheers, -steve -- Sarah Goslee http://www.functionaldiversity.org [[alternative HTML version deleted]] __ R-help@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
On 01/05/2012 2:12 PM, Bert Gunter wrote: Many thanks, Ista: I only looked in ].default so the answer is: Alternative 4: dumb Bert. Rap knuckles with ruler. Actually, indexing by a logical matrix doesn't make much sense to me in either case, as it does not have the effect of selecting individual elements, which is what numeric matrix indices do. But that's a matter of usage, neither bug nor feature. If I had gotten something like the error message: Matrix indices not allowed for replacement in data frames, I would not have been surprised. But as you said, the behavior **IS** documented. Your version is not correct: matrix indices *are* allowed for replacement, but only logical matrix indices, not two column numerical ones. The message might be clearer if instead of saying only logical matrix subscripts are allowed in replacement it said matrix subscripts must be logical matrices in replacement, but I think the basic problem is the limitation. I'll fix that. Duncan Murdoch Best, Bert On Tue, May 1, 2012 at 10:49 AM, Ista Zahnistaz...@gmail.com wrote: Hi Bert, The failure itself is the documented behavior: ?'[.data.frame' says Matrix indexing ('x[i]' with a logical or a 2-column integer matrix 'i') using '[' is not recommended, and barely supported. For extraction, 'x' is first coerced to a matrix. For replacement, a logical matrix (only) can be used to select the elements to be replaced in the same way as for a matrix. The error message may be a bit hinky, as obviously data.frames can be indexed by things other than logical matricies. Or is there another reason this strikes you as odd? Best, Ista On Tue, May 1, 2012 at 1:33 PM, Bert Guntergunter.ber...@gene.com wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest- matrix(1:12,nr=4) dftest- data.frame(mtest) ix- cbind(1:2,2:3) mtest[ix]- NA mtest [,1] [,2] [,3] [1,]1 NA9 [2,]26 NA [3,]37 11 [4,]48 12 ## But ... dftest[ix]- NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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@r-project.org 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] rbind-ing numeric matrices
On Tue, May 1, 2012 at 2:12 PM, Nick Switanek nswita...@gmail.com wrote: Thank you, Sarah! Yes, unlist() looks like it will do just what I need. Thank you. I took a different tack. I'd changed the function returning A to coerce the row from the data.frame using as.numeric(). Any reason to prefer your way or mine? Possibly, but we would need to know what you did to produce A to be certain. Sarah thanks again, Nick On Tue, May 1, 2012 at 2:08 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Hi Nick, On Tue, May 1, 2012 at 1:56 PM, Nick Switanek nswita...@gmail.com wrote: Thank you, Steve and Sarah, for your swift replies. I didn't know about dput(). class() returns matrix for A, B, and C, but here: class(A) [1] matrix class(B) [1] matrix dput(A) structure(list(1239814462, 1239814601, 14349, 3, 4, 0, 12, 46601, 17801, 12401, 106001), .Dim = c(1L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) I'm not sure how you created A, but it's a list - see the structure given by dput(), and also: is.list(A) [1] TRUE is.list(B) [1] FALSE dput(B) structure(c(1239197400, 1239199200, 1239202800, 1239199199, 1239202799, 1239206399, 14342, 14342, 14342, 3, 3, 3, 0, 0, 0, 0, 0, 0, 9, 10, 11, 35999, 39599, 43199, 7199, 10799, 14399, 1799, 5399, 8999, 1799, 5399, 8999), .Dim = c(3L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) Note that the structure for B doesn't say anything about it being a list. In this particular case, you can fix that with: rbind(unlist(A), B) a b c d e f g h i j k [1,] 1239814462 1239814601 14349 3 4 0 12 46601 17801 12401 106001 [2,] 1239197400 1239199199 14342 3 0 0 9 35999 7199 1799 1799 [3,] 1239199200 1239202799 14342 3 0 0 10 39599 10799 5399 5399 [4,] 1239202800 1239206399 14342 3 0 0 11 43199 14399 8999 8999 But now I'm curious where A came from. Sarah C - rbind(A,B) dput(C) structure(list(1239814462, 1239197400, NULL, NULL, 1239814601, 1239199200, NULL, NULL, 14349, 1239202800, NULL, NULL, 3, 1239199199, NULL, NULL, 4, 1239202799, NULL, NULL, 0, 1239206399, NULL, NULL, 12, 14342, NULL, NULL, 46601, 14342, NULL, NULL, 17801, 14342, NULL, NULL, 12401, 3, NULL, NULL, 106001, 3, NULL, NULL), .Dim = c(4L, 11L), .Dimnames = list(NULL, c(a, b, c, d, e, f, g, h, i, j, k))) But how do I convert A to the appropriate form for rbinding? Not simply with as.matrix(). Witness: dput(as.matrix(A)) structure(list(1239814462, 1239814601, 14349, 3, 4, 0, 12, 46601, 17801, 12401, 106001), .Dim = c(1L, 11L), .Dimnames = list( NULL, c(a, b, c, d, e, f, g, h, i, j, k))) I think we're closer but I still need your help! Nick On Tue, May 1, 2012 at 12:02 PM, Steve Lianoglou mailinglist.honey...@gmail.com wrote: Hi, On Tue, May 1, 2012 at 11:52 AM, Nick Switanek nswita...@gmail.com wrote: Good morning, I'm running into trouble rbind-ing numeric matrices with differing numbers of rows. In particular, there seem to be issues whenever a one-row numeric matrix is involved. Assume A is a numeric matrix with 1 row and Y columns and B is a numeric matrix with X rows and Y columns. Let C be the result of rbinding A and B. Then C is a numeric matrix with X + 1 rows and Y columns, only instead of the rows of B being stacked beneath the row of A as expected, the first Y elements of the 1st column of B are placed in the 2nd row of C, the remaining values of B are discarded, and NULL values fill out the rest of the matrix C. The number of columns of A and B match. The colnames of A and B match. Both are numeric matrices. I've pored over the rbind/cbind documentation but can't identify why I'm getting this behavior from rbind. I'd be extremely grateful for your suggestions or thoughts. If everything you say is true (and I'm understanding what you're saying), there must be something else going on with your data. Consider: R m1 - matrix(-(1:5), nrow=1) R m2 - matrix(1:20, ncol=5) R rbind(m1, m2) [,1] [,2] [,3] [,4] [,5] [1,] -1 -2 -3 -4 -5 [2,] 1 5 9 13 17 [3,] 2 6 10 14 18 [4,] 3 7 11 15 19 [5,] 4 8 12 16 20 Can you provide a small example of your data that reproduces the problem you're seeing? Construct these objects in your workspace and copy/paste the output of dput on your m1 and m2 matrices so we can easily work w/ them. Cheers, -steve -- Sarah Goslee http://www.functionaldiversity.org -- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
[R] VarCorr procedure from lme4
Folks In trying to use lmer for a hierarchical model, I encountered the following message: Error in UseMethod(VarCorr) : no applicable method for 'VarCorr' applied to an object of class mer foo.mer - lmer(y ~ TP + (TP|M),data=joe.q) head(joe.q[,1:5]) TP M AB Trty 1 1 Jan A NN 19.20002 2 1 Jan A NN 19.06378 3 1 Jan A NN 21.36292 4 1 Jan A NN 16.85191 5 1 Jan A N 17.89363 6 1 Jan A N 15.53853 I tried this through the display(foo.mer) from arm and by VarCorr(foo.mer) My understanding is the VarCorr was essentially designed to work with 'mer' objects. Am I wrong about this? The lmer procedure seemed to work fine -- David K Stevens, P.E., Ph.D., Professor Civil and Environmental Engineering Utah Water Research Laboratory 8200 Old Main Hill Logan, UT 84322-8200 435 797 3229 - voice 435 797 1363 - fax david.stev...@usu.edu [[alternative HTML version deleted]] __ R-help@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
Duncan: Maybe there **is** a bug, then. zmat - matrix(1:12,nr=4) zdf - data.frame(zmat) ix - cbind(c(FALSE,TRUE),c(TRUE,TRUE)) zmat[ix] [1] 2 3 4 6 7 8 10 11 12 zdf[ix] [1] 2 3 4 6 7 8 10 11 12 zmat[ix] - NA zmat [,1] [,2] [,3] [1,]159 [2,] NA NA NA [3,] NA NA NA [4,] NA NA NA ## ?? zdf[ix] - NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement That matrix replacement should not work with (in general mixed type) data frames seems reasonable, actually. Trying to fix things may not be. But I leave this to you and your fellow expeRts, Cheers, Bert On Tue, May 1, 2012 at 11:30 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 01/05/2012 2:12 PM, Bert Gunter wrote: Many thanks, Ista: I only looked in ].default so the answer is: Alternative 4: dumb Bert. Rap knuckles with ruler. Actually, indexing by a logical matrix doesn't make much sense to me in either case, as it does not have the effect of selecting individual elements, which is what numeric matrix indices do. But that's a matter of usage, neither bug nor feature. If I had gotten something like the error message: Matrix indices not allowed for replacement in data frames, I would not have been surprised. But as you said, the behavior **IS** documented. Your version is not correct: matrix indices *are* allowed for replacement, but only logical matrix indices, not two column numerical ones. The message might be clearer if instead of saying only logical matrix subscripts are allowed in replacement it said matrix subscripts must be logical matrices in replacement, but I think the basic problem is the limitation. I'll fix that. Duncan Murdoch Best, Bert On Tue, May 1, 2012 at 10:49 AM, Ista Zahnistaz...@gmail.com wrote: Hi Bert, The failure itself is the documented behavior: ?'[.data.frame' says Matrix indexing ('x[i]' with a logical or a 2-column integer matrix 'i') using '[' is not recommended, and barely supported. For extraction, 'x' is first coerced to a matrix. For replacement, a logical matrix (only) can be used to select the elements to be replaced in the same way as for a matrix. The error message may be a bit hinky, as obviously data.frames can be indexed by things other than logical matricies. Or is there another reason this strikes you as odd? Best, Ista On Tue, May 1, 2012 at 1:33 PM, Bert Guntergunter.ber...@gene.com wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest- matrix(1:12,nr=4) dftest- data.frame(mtest) ix- cbind(1:2,2:3) mtest[ix]- NA mtest [,1] [,2] [,3] [1,] 1 NA 9 [2,] 2 6 NA [3,] 3 7 11 [4,] 4 8 12 ## But ... dftest[ix]- NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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] VarCorr procedure from lme4
Can you give sessionInfo()? It is working fine for me. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Stevens Sent: Tuesday, May 01, 2012 2:38 PM To: r-help@r-project.org Subject: [R] VarCorr procedure from lme4 Folks In trying to use lmer for a hierarchical model, I encountered the following message: Error in UseMethod(VarCorr) : no applicable method for 'VarCorr' applied to an object of class mer foo.mer - lmer(y ~ TP + (TP|M),data=joe.q) head(joe.q[,1:5]) TP M AB Trty 1 1 Jan A NN 19.20002 2 1 Jan A NN 19.06378 3 1 Jan A NN 21.36292 4 1 Jan A NN 16.85191 5 1 Jan A N 17.89363 6 1 Jan A N 15.53853 I tried this through the display(foo.mer) from arm and by VarCorr(foo.mer) My understanding is the VarCorr was essentially designed to work with 'mer' objects. Am I wrong about this? The lmer procedure seemed to work fine -- David K Stevens, P.E., Ph.D., Professor Civil and Environmental Engineering Utah Water Research Laboratory 8200 Old Main Hill Logan, UT 84322-8200 435 797 3229 - voice 435 797 1363 - fax david.stev...@usu.edu [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
The difference is in recycling. If the logical matrix has the same dimensions, it seems to work: jx - cbind(c(FALSE, TRUE, FALSE, TRUE), c(TRUE, FALSE, TRUE, FALSE), c(FALSE, TRUE, FALSE, TRUE)) zmat[jx] - NA zmat [,1] [,2] [,3] [1,]1 NA9 [2,] NA6 NA [3,]3 NA 11 [4,] NA8 NA zdf[jx] - NA zdf X1 X2 X3 1 1 NA 9 2 NA 6 NA 3 3 NA 11 4 NA 8 NA -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Bert Gunter Sent: Tuesday, May 01, 2012 1:46 PM To: Duncan Murdoch Cc: r-help@r-project.org Subject: Re: [R] Data frame vs matrix quirk: Hinky error message? Duncan: Maybe there **is** a bug, then. zmat - matrix(1:12,nr=4) zdf - data.frame(zmat) ix - cbind(c(FALSE,TRUE),c(TRUE,TRUE)) zmat[ix] [1] 2 3 4 6 7 8 10 11 12 zdf[ix] [1] 2 3 4 6 7 8 10 11 12 zmat[ix] - NA zmat [,1] [,2] [,3] [1,]159 [2,] NA NA NA [3,] NA NA NA [4,] NA NA NA ## ?? zdf[ix] - NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement That matrix replacement should not work with (in general mixed type) data frames seems reasonable, actually. Trying to fix things may not be. But I leave this to you and your fellow expeRts, Cheers, Bert On Tue, May 1, 2012 at 11:30 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 01/05/2012 2:12 PM, Bert Gunter wrote: Many thanks, Ista: I only looked in ].default so the answer is: Alternative 4: dumb Bert. Rap knuckles with ruler. Actually, indexing by a logical matrix doesn't make much sense to me in either case, as it does not have the effect of selecting individual elements, which is what numeric matrix indices do. But that's a matter of usage, neither bug nor feature. If I had gotten something like the error message: Matrix indices not allowed for replacement in data frames, I would not have been surprised. But as you said, the behavior **IS** documented. Your version is not correct: matrix indices *are* allowed for replacement, but only logical matrix indices, not two column numerical ones. The message might be clearer if instead of saying only logical matrix subscripts are allowed in replacement it said matrix subscripts must be logical matrices in replacement, but I think the basic problem is the limitation. I'll fix that. Duncan Murdoch Best, Bert On Tue, May 1, 2012 at 10:49 AM, Ista Zahnistaz...@gmail.com wrote: Hi Bert, The failure itself is the documented behavior: ?'[.data.frame' says Matrix indexing ('x[i]' with a logical or a 2-column integer matrix 'i') using '[' is not recommended, and barely supported. For extraction, 'x' is first coerced to a matrix. For replacement, a logical matrix (only) can be used to select the elements to be replaced in the same way as for a matrix. The error message may be a bit hinky, as obviously data.frames can be indexed by things other than logical matricies. Or is there another reason this strikes you as odd? Best, Ista On Tue, May 1, 2012 at 1:33 PM, Bert Guntergunter.ber...@gene.com wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest- matrix(1:12,nr=4) dftest- data.frame(mtest) ix- cbind(1:2,2:3) mtest[ix]- NA mtest [,1] [,2] [,3] [1,] 1 NA 9 [2,] 2 6 NA [3,] 3 7 11 [4,] 4 8 12 ## But ... dftest[ix]- NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional- groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-
Re: [R] Data frame vs matrix quirk: Hinky error message?
On 01/05/2012 2:45 PM, Bert Gunter wrote: Duncan: Maybe there **is** a bug, then. zmat- matrix(1:12,nr=4) zdf- data.frame(zmat) ix- cbind(c(FALSE,TRUE),c(TRUE,TRUE)) zmat[ix] [1] 2 3 4 6 7 8 10 11 12 zdf[ix] [1] 2 3 4 6 7 8 10 11 12 zmat[ix]- NA zmat [,1] [,2] [,3] [1,]159 [2,] NA NA NA [3,] NA NA NA [4,] NA NA NA ## ?? zdf[ix]- NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement That matrix replacement should not work with (in general mixed type) data frames seems reasonable, actually. Trying to fix things may not be. But I leave this to you and your fellow expeRts, My intention is to allow two column numeric indices, not to change the behaviour for logical matrix indices. I'm planning to leave the not recommended note in the help page, because there will still be surprises as above, but the error message will just say illegal matrix index in replacement The rule will remain that a logical matrix needs to be of the same dimension as the original dataframe. I'm not sure if this is documented currently, but it will be. Duncan Murdoch Cheers, Bert On Tue, May 1, 2012 at 11:30 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 01/05/2012 2:12 PM, Bert Gunter wrote: Many thanks, Ista: I only looked in ].default so the answer is: Alternative 4: dumb Bert. Rap knuckles with ruler. Actually, indexing by a logical matrix doesn't make much sense to me in either case, as it does not have the effect of selecting individual elements, which is what numeric matrix indices do. But that's a matter of usage, neither bug nor feature. If I had gotten something like the error message: Matrix indices not allowed for replacement in data frames, I would not have been surprised. But as you said, the behavior **IS** documented. Your version is not correct: matrix indices *are* allowed for replacement, but only logical matrix indices, not two column numerical ones. The message might be clearer if instead of saying only logical matrix subscripts are allowed in replacement it said matrix subscripts must be logical matrices in replacement, but I think the basic problem is the limitation. I'll fix that. Duncan Murdoch Best, Bert On Tue, May 1, 2012 at 10:49 AM, Ista Zahnistaz...@gmail.comwrote: Hi Bert, The failure itself is the documented behavior: ?'[.data.frame' says Matrix indexing ('x[i]' with a logical or a 2-column integer matrix 'i') using '[' is not recommended, and barely supported. For extraction, 'x' is first coerced to a matrix. For replacement, a logical matrix (only) can be used to select the elements to be replaced in the same way as for a matrix. The error message may be a bit hinky, as obviously data.frames can be indexed by things other than logical matricies. Or is there another reason this strikes you as odd? Best, Ista On Tue, May 1, 2012 at 1:33 PM, Bert Guntergunter.ber...@gene.com wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest- matrix(1:12,nr=4) dftest- data.frame(mtest) ix- cbind(1:2,2:3) mtest[ix]- NA mtest [,1] [,2] [,3] [1,]1 NA9 [2,]26 NA [3,]37 11 [4,]48 12 ## But ... dftest[ix]- NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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@r-project.org 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] VarCorr procedure from lme4
It could be a bad coexistence between packages in the same R session. Are you using nlme and/or doBy packages too? Bests. Walmes. == Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail: wal...@ufpr.br twitter: @walmeszeviani homepage: http://www.leg.ufpr.br/~walmes linux user number: 531218 == [[alternative HTML version deleted]] __ R-help@r-project.org 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] error bars for a barchart
I have a repoducibe example here http://ridiculas.wordpress.com/2011/11/23/media-e-desvio-padrao-de-muitas-variaveis-separado-por-grupos/ Sorry for it be in Portuguese. Walmes. == Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail: wal...@ufpr.br twitter: @walmeszeviani homepage: http://www.leg.ufpr.br/~walmes linux user number: 531218 == [[alternative HTML version deleted]] __ R-help@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
Bert, I think this is what is needed for the data frame ix - cbind(1:2,2:3) ixm - matrix(FALSE,4,3) ixm[ix] - TRUE zdf[ixm] - NA Hope this is helpful, Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Bert Gunter Sent: Tuesday, May 01, 2012 11:46 AM To: Duncan Murdoch Cc: r-help@r-project.org Subject: Re: [R] Data frame vs matrix quirk: Hinky error message? Duncan: Maybe there **is** a bug, then. zmat - matrix(1:12,nr=4) zdf - data.frame(zmat) ix - cbind(c(FALSE,TRUE),c(TRUE,TRUE)) zmat[ix] [1] 2 3 4 6 7 8 10 11 12 zdf[ix] [1] 2 3 4 6 7 8 10 11 12 zmat[ix] - NA zmat [,1] [,2] [,3] [1,]159 [2,] NA NA NA [3,] NA NA NA [4,] NA NA NA ## ?? zdf[ix] - NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement That matrix replacement should not work with (in general mixed type) data frames seems reasonable, actually. Trying to fix things may not be. But I leave this to you and your fellow expeRts, Cheers, Bert On Tue, May 1, 2012 at 11:30 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 01/05/2012 2:12 PM, Bert Gunter wrote: Many thanks, Ista: I only looked in ].default so the answer is: Alternative 4: dumb Bert. Rap knuckles with ruler. Actually, indexing by a logical matrix doesn't make much sense to me in either case, as it does not have the effect of selecting individual elements, which is what numeric matrix indices do. But that's a matter of usage, neither bug nor feature. If I had gotten something like the error message: Matrix indices not allowed for replacement in data frames, I would not have been surprised. But as you said, the behavior **IS** documented. Your version is not correct: matrix indices *are* allowed for replacement, but only logical matrix indices, not two column numerical ones. The message might be clearer if instead of saying only logical matrix subscripts are allowed in replacement it said matrix subscripts must be logical matrices in replacement, but I think the basic problem is the limitation. I'll fix that. Duncan Murdoch Best, Bert On Tue, May 1, 2012 at 10:49 AM, Ista Zahnistaz...@gmail.com wrote: Hi Bert, The failure itself is the documented behavior: ?'[.data.frame' says Matrix indexing ('x[i]' with a logical or a 2-column integer matrix 'i') using '[' is not recommended, and barely supported. For extraction, 'x' is first coerced to a matrix. For replacement, a logical matrix (only) can be used to select the elements to be replaced in the same way as for a matrix. The error message may be a bit hinky, as obviously data.frames can be indexed by things other than logical matricies. Or is there another reason this strikes you as odd? Best, Ista On Tue, May 1, 2012 at 1:33 PM, Bert Guntergunter.ber...@gene.com wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest- matrix(1:12,nr=4) dftest- data.frame(mtest) ix- cbind(1:2,2:3) mtest[ix]- NA mtest [,1] [,2] [,3] [1,] 1 NA 9 [2,] 2 6 NA [3,] 3 7 11 [4,] 4 8 12 ## But ... dftest[ix]- NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional- groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb- biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
[R] Define lower-upper bound for parameters in Optim using Nelder-Mead method
Dear UseRs, Is there a way to define the lower-upper bounds for parameters fitted by optim using the Nelder-Mead method ? Thanks, Arnaud [[alternative HTML version deleted]] __ R-help@r-project.org 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] Define lower-upper bound for parameters in Optim using Nelder-Mead method
On Wed, May 2, 2012 at 7:58 AM, Arnaud Mosnier a.mosn...@gmail.com wrote: Dear UseRs, Is there a way to define the lower-upper bounds for parameters fitted by optim using the Nelder-Mead method ? It depends a bit on whether it's plausible that the solution is on the boundary. If not, simply returning Inf for values outside the range will work. -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ R-help@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
Many thanks to all. I appreciate your kindness and patience. The point is, of course, that matrix subscripting by logicals requires different semantics than by numeric indices, as it must. I'd still say this is a case of option 4, dumb Bert: I should have figured this out. Duncan's proposed changes to both behavior and documentation would certainly address all my points of confusion. However, I agree that numeric replacement indices for data frames may be a can of worms: presumably silent type conversion would be required when replacing values in mixed type columns. Keeping the warnings in -- and maybe issuing some more when the type conversion occurs -- is certainly a good idea. Best, Bert On Tue, May 1, 2012 at 12:57 PM, Nordlund, Dan (DSHS/RDA) nord...@dshs.wa.gov wrote: Bert, I think this is what is needed for the data frame ix - cbind(1:2,2:3) ixm - matrix(FALSE,4,3) ixm[ix] - TRUE zdf[ixm] - NA Hope this is helpful, Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Bert Gunter Sent: Tuesday, May 01, 2012 11:46 AM To: Duncan Murdoch Cc: r-help@r-project.org Subject: Re: [R] Data frame vs matrix quirk: Hinky error message? Duncan: Maybe there **is** a bug, then. zmat - matrix(1:12,nr=4) zdf - data.frame(zmat) ix - cbind(c(FALSE,TRUE),c(TRUE,TRUE)) zmat[ix] [1] 2 3 4 6 7 8 10 11 12 zdf[ix] [1] 2 3 4 6 7 8 10 11 12 zmat[ix] - NA zmat [,1] [,2] [,3] [1,] 1 5 9 [2,] NA NA NA [3,] NA NA NA [4,] NA NA NA ## ?? zdf[ix] - NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement That matrix replacement should not work with (in general mixed type) data frames seems reasonable, actually. Trying to fix things may not be. But I leave this to you and your fellow expeRts, Cheers, Bert On Tue, May 1, 2012 at 11:30 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 01/05/2012 2:12 PM, Bert Gunter wrote: Many thanks, Ista: I only looked in ].default so the answer is: Alternative 4: dumb Bert. Rap knuckles with ruler. Actually, indexing by a logical matrix doesn't make much sense to me in either case, as it does not have the effect of selecting individual elements, which is what numeric matrix indices do. But that's a matter of usage, neither bug nor feature. If I had gotten something like the error message: Matrix indices not allowed for replacement in data frames, I would not have been surprised. But as you said, the behavior **IS** documented. Your version is not correct: matrix indices *are* allowed for replacement, but only logical matrix indices, not two column numerical ones. The message might be clearer if instead of saying only logical matrix subscripts are allowed in replacement it said matrix subscripts must be logical matrices in replacement, but I think the basic problem is the limitation. I'll fix that. Duncan Murdoch Best, Bert On Tue, May 1, 2012 at 10:49 AM, Ista Zahnistaz...@gmail.com wrote: Hi Bert, The failure itself is the documented behavior: ?'[.data.frame' says Matrix indexing ('x[i]' with a logical or a 2-column integer matrix 'i') using '[' is not recommended, and barely supported. For extraction, 'x' is first coerced to a matrix. For replacement, a logical matrix (only) can be used to select the elements to be replaced in the same way as for a matrix. The error message may be a bit hinky, as obviously data.frames can be indexed by things other than logical matricies. Or is there another reason this strikes you as odd? Best, Ista On Tue, May 1, 2012 at 1:33 PM, Bert Guntergunter.ber...@gene.com wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest- matrix(1:12,nr=4) dftest- data.frame(mtest) ix- cbind(1:2,2:3) mtest[ix]- NA mtest [,1] [,2] [,3] [1,] 1 NA 9 [2,] 2 6 NA [3,] 3 7 11 [4,] 4 8 12 ## But ... dftest[ix]- NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website:
Re: [R] Data frame vs matrix quirk: Hinky error message?
On 12-05-01 3:57 PM, Nordlund, Dan (DSHS/RDA) wrote: Bert, I think this is what is needed for the data frame ix- cbind(1:2,2:3) ixm- matrix(FALSE,4,3) ixm[ix]- TRUE zdf[ixm]- NA Hope this is helpful, That's essentially what I did in adding the numeric indexing. The only complication was handling the case where ix contains out of bound values; users don't want to hear that ixm[ix] - TRUE failed. Duncan Murdoch Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Bert Gunter Sent: Tuesday, May 01, 2012 11:46 AM To: Duncan Murdoch Cc: r-help@r-project.org Subject: Re: [R] Data frame vs matrix quirk: Hinky error message? Duncan: Maybe there **is** a bug, then. zmat- matrix(1:12,nr=4) zdf- data.frame(zmat) ix- cbind(c(FALSE,TRUE),c(TRUE,TRUE)) zmat[ix] [1] 2 3 4 6 7 8 10 11 12 zdf[ix] [1] 2 3 4 6 7 8 10 11 12 zmat[ix]- NA zmat [,1] [,2] [,3] [1,]159 [2,] NA NA NA [3,] NA NA NA [4,] NA NA NA ## ?? zdf[ix]- NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement That matrix replacement should not work with (in general mixed type) data frames seems reasonable, actually. Trying to fix things may not be. But I leave this to you and your fellow expeRts, Cheers, Bert On Tue, May 1, 2012 at 11:30 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 01/05/2012 2:12 PM, Bert Gunter wrote: Many thanks, Ista: I only looked in ].default so the answer is: Alternative 4: dumb Bert. Rap knuckles with ruler. Actually, indexing by a logical matrix doesn't make much sense to me in either case, as it does not have the effect of selecting individual elements, which is what numeric matrix indices do. But that's a matter of usage, neither bug nor feature. If I had gotten something like the error message: Matrix indices not allowed for replacement in data frames, I would not have been surprised. But as you said, the behavior **IS** documented. Your version is not correct: matrix indices *are* allowed for replacement, but only logical matrix indices, not two column numerical ones. The message might be clearer if instead of saying only logical matrix subscripts are allowed in replacement it said matrix subscripts must be logical matrices in replacement, but I think the basic problem is the limitation. I'll fix that. Duncan Murdoch Best, Bert On Tue, May 1, 2012 at 10:49 AM, Ista Zahnistaz...@gmail.com wrote: Hi Bert, The failure itself is the documented behavior: ?'[.data.frame' says Matrix indexing ('x[i]' with a logical or a 2-column integer matrix 'i') using '[' is not recommended, and barely supported. For extraction, 'x' is first coerced to a matrix. For replacement, a logical matrix (only) can be used to select the elements to be replaced in the same way as for a matrix. The error message may be a bit hinky, as obviously data.frames can be indexed by things other than logical matricies. Or is there another reason this strikes you as odd? Best, Ista On Tue, May 1, 2012 at 1:33 PM, Bert Guntergunter.ber...@gene.com wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest- matrix(1:12,nr=4) dftest- data.frame(mtest) ix- cbind(1:2,2:3) mtest[ix]- NA mtest [,1] [,2] [,3] [1,]1 NA9 [2,]26 NA [3,]37 11 [4,]48 12 ## But ... dftest[ix]- NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional- groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb- biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list
Re: [R] 95% confidence interval of the coefficients from a bootstrap analysis
Hi Rui, You are awesome!!! It worked perfectly!! Thanks -- View this message in context: http://r.789695.n4.nabble.com/95-confidence-interval-of-the-coefficients-from-a-bootstrap-analysis-tp4599692p4601296.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] [fields:image.plot] subtitle under title (not image)?
Tom, The sub argument will always put text at the bottom -- this is all plotting in R not just image.plot If you want two lines in the title just build in a new line: z- outer( 1:15, 1:10,+) image.plot( z, main=the title \n the subtitle) Best, Doug - Doug Nychka, Institute for Mathematics Applied to Geosciences National Center for Atmospheric Research Boulder, CO Email: nychka AT ucar DOT edu Web: www.image.ucar.edu/~nychka Voice: 303-497-1711 FAX: 303-497-1298 Business Cell: 303-725-3199 On May 1, 2012, at 10:25 AM, Tom Roche wrote: summary: how to make image.plot print a subtitle between the title and the image, rather than under the image? details: I've got a project https://github.com/TomRoche/ioapi-hack-R that illustrates the use of (et al) the R packages {ncdf4, fields, M3} for processing and visualizing IOAPI data. The data being visualized consists of a series of layers (mostly representing emissions from a particular tuple of agricultural {cultivar, cultivation technique}) over a surface (in the upper midwest US). I'm currently plotting https://github.com/downloads/TomRoche/ioapi-hack-R/compare.DN2.layers.pdf each layer, and including some information about the layer in a title and subtitle. The title is where I want it--above the image--but the subtitle is printing below the image; I'd prefer it between the title and the image. Can this be done? FWIW, the code that plots (in https://github.com/TomRoche/ioapi-hack-R/blob/master/plotLayersForTimestep.r ) is like if (data to plot is not all NA) { # determine quantiles, then image.plot(plot.list, xlab=, ylab=, axes=F, col=colors(100), axis.args=list(at=quantiles, labels=quantiles.formatted), main=title, sub=subtitle) lines(map) } else { plot(0, type=n, axes=F, xlab=, ylab=, xlim=range(x.centers), ylim=range(y.centers), main=title, sub=subtitle) lines(map) } # end testing data TIA, Tom Roche tom_ro...@pobox.com [[alternative HTML version deleted]] __ R-help@r-project.org 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] Arules and different item columns with same item labelsŠ.
Dear Users, I have data that have different data columns (hair color, eye color, etc. ) with same item labels and I do not want to recode them like haircolor=brown, etc. Is it possible to do it automatically? Thanks right now for your tips and given directions. -- Levent TERLEMEZ [[alternative HTML version deleted]] __ R-help@r-project.org 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] Forecast Package for 2.15.0
Anyone else having problems installing this package? Any ideas for fixing? Thanks, Jess -- View this message in context: http://r.789695.n4.nabble.com/Forecast-Package-for-2-15-0-tp4601328.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
P.S. The way the logical matrix is constructed is NOT general purpose. Quoting myself quoting Bert, Actually, it works, as long as the logical index matrix has the same dimensions as the data frame. zmat - matrix(1:12,nr=4) zdf - data.frame(zmat) # Numeric index matrix. ix - cbind(1:2,2:3) # Logical index matrix. ix2 - row(zdf) == ix[, 1] col(zdf) == ix[, 2] Here the number of rows in zdf is a multiple of the vectors ix[, 1] and ix[ , 2] lengths. The recycling rules makes it work. But if the numeric index matrix has, say, 3 rows, another way of constructing the logical one would be needed. jx - cbind(1:3, c(2:3, 3)) row(zdf) == jx[, 1] col(zdf) == jx[, 2] [,1] [,2] [,3] [1,] FALSE FALSE FALSE [2,] FALSE FALSE FALSE [3,] FALSE FALSE FALSE [4,] FALSE FALSE FALSE (Anyway, I don't believe that was the point.) R.B. -- View this message in context: http://r.789695.n4.nabble.com/Data-frame-vs-matrix-quirk-Hinky-error-message-tp4601254p4601558.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Plotting shapefiles on existing maps
Very helpful. One (possible) correction inline below... On Thu, 30 Mar 2006, Ray Brownrigg wrote: From: nhy303 at abdn.ac.uk I have plotted a map of the Barents Sea and surrounding coastline using: map('worldHires',ylim=c(50,85),xlim=c(5,65),fill=T,resolution=0) map.axes() map.scale(x=30,metric=T) Next, I imported a shapefile with depth contours for the sea: contours-read.shape(D://My Documents/BarentsSea.shp,dbf.data=T) (This is in mercator projection). Despite extensive searches of the help files and R site, I cannot find a way to plot the contours onto the map. Does anyone have any suggestions? It is not clear to me exactly what you are having difficulty with, but if you are able to produce a contour plot from that data, then note that both contour() and map() have an add argument, so as long as the axis limits are conformant (i.e. both longitude/latitude) you can add one plot to the other. You cannot add projected data to a map() plot - as Ray suggests, the input shapefile has to be in geographical, not projected coordinates. If you know the projection of the shapefile (or if there is a *.prj file accompanying the *.shp), try using the transform() method in the rgdal package to do this. If there is a *.prj file, this should work: library(rgdal) my_lines - readOGR(directory, shapefile_without_extension) my_lines1 - transform(my_lines, CRS(+proj=longlat +ellps=WGS84)) *I believe the above line should be: my_lines1 - spTransform(my_lines, CRS(+proj=longlat +ellps=WGS84)) plot(my_lines1, add=TRUE) If not, you'll need to work out exactly what the projection is, and set it in PROJ.4 notation by: proj4string(my_lines) - CRS(what you found out) before transform(). Please in both cases do bbox(my_lines1) to see if you are in the right ballpark. Perhaps the trick is in converting your contours data into longitude/latitude form for the x and y components. Hope this helps, Ray Brownrigg __ R-help at 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 -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no Brandon [[alternative HTML version deleted]] __ R-help@r-project.org 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] Problems accessing environment() in function
Hi all, I am trying to create a list of all variable/value combinations in environment(). When a function with unset arguments is called, the method I have been using fails with a missing argument error. However it should be possible to simply skip these missing objects in the generation of the list? Could anyone recommend me a better way (that does not use a slow for/eval-combination) to achieve the desired effect? You can easily reproduce my problem using this code: -- test1 - function(a, b, c) { x - as.list(environment()) print (hi from test1!) test2(a = a, b = b, c = c) } test2 - function(a, b, c) { # PROBLEM: Why can't I get a list as in test1() here? x - as.list(environment()) print (hi from test2!) } test1() -- I want my list x in test2() to work behave just like x in test1(). (In this example the correct list in test2() would be empty). Thanks a lot for your time. Best wishes, Heiko Neuhaus __ R-help@r-project.org 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] Hypothesis Testing using Wald Criterion for two regression models with dummy variables
I have two models, controlled by dummy variables to see if the models can be combined into one model with similar intercepts and slopes. Has anyone tried to conduct this type of test in R. I am utilizing the econometric idea of hypothesis testing through the hypothesis of coincidence. I have tried to run an anova with test of Chisq, but I am not sure what the results are telling. In addition, I used the rms package with a lrm model in an anova test, again I am not sure what the results are telling me: Try 1 anova(H,Ha,test=Chi) Analysis of Variance Table Model 1: logload ~ logflow Model 2: logload ~ dummy + logflow Res.DfRSS Df Sum of Sq Pr(Chi) 1 17 4.6742 2 16 2.6314 12.0428 0.0004245 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Try 2: fit-lrm(logload~logflow+dummy) anova(fit) Wald Statistics Response: logload Factor Chi-Square d.f. P logflow17.56 1.0001 dummy 5.22 10.0224 TOTAL 18.03 20.0001 Can anyone help me with this? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Hypothesis-Testing-using-Wald-Criterion-for-two-regression-models-with-dummy-variables-tp4601582.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Fitting a first order compartment model in nlme
Hello, I am using SSfol in nlme to fit some data for the change of N concentration (N) in plant tissue over time (gdd). The model works nicely for 2 out of 3 treatments, so I would really like to use it, but it consistently has a bad fit for my third treatment. I am pasting the figure for the third treatment only. I feel that I have my fixed and random effects properly identified, but have also tried many combinations to see if I can improve the fit. Are there any other ideas of what I can do to capture the highest point of N with the model? http://r.789695.n4.nabble.com/file/n4601419/Predicted_N_2.png Here is my code for the figure followed by a link to the dataset. library(nlme) cna-read.table(aboveground C and N, dates removed, zeros added.txt, header=TRUE) ###Aboveground 2011, treatment PF only n11a-subset(cna, cna$year == 2011 cna$ground == Above cna$trt == PF) n11a$plotF - as.factor(n11a$plot) n11aG-groupedData(N ~ gdd | plotF, data=n11a) fit.dose- nlsList(N ~ SSfol(dose, gdd, lke, lka, lCl), data = n11aG) plot(intervals(fit.dose), layout=c(3,1)) fit.nlme.11a- nlme(fit.dose, random=pdDiag(lCl ~ 1)) fit.nlme2.11a-update(fit.nlme.11a, random = list(lCl + lka ~ 1)) png(thermaltimefigs/Predicted N 1.png) plot(augPred(fit.nlme.11a), level = 0:1) dev.off() png(thermaltimefigs/Predicted N 2.png) plot(augPred(fit.nlme2.11a), level = 0:1) dev.off() data at: http://dl.dropbox.com/u/21080842/aboveground%20C%20and%20N%2C%20dates%20removed%2C%20zeros%20added.txt Thanks, Ranae -- View this message in context: http://r.789695.n4.nabble.com/Fitting-a-first-order-compartment-model-in-nlme-tp4601419.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
Hello, Bert Gunter wrote Duncan: Maybe there **is** a bug, then. zmat - matrix(1:12,nr=4) zdf - data.frame(zmat) ix - cbind(c(FALSE,TRUE),c(TRUE,TRUE)) zmat[ix] [1] 2 3 4 6 7 8 10 11 12 zdf[ix] [1] 2 3 4 6 7 8 10 11 12 zmat[ix] - NA zmat [,1] [,2] [,3] [1,]159 [2,] NA NA NA [3,] NA NA NA [4,] NA NA NA ## ?? zdf[ix] - NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement That matrix replacement should not work with (in general mixed type) data frames seems reasonable, actually. Trying to fix things may not be. But I leave this to you and your fellow expeRts, Cheers, Bert On Tue, May 1, 2012 at 11:30 AM, Duncan Murdoch lt;murdoch.duncan@gt; wrote: On 01/05/2012 2:12 PM, Bert Gunter wrote: Many thanks, Ista: I only looked in ].default so the answer is: Alternative 4: dumb Bert. Rap knuckles with ruler. Actually, indexing by a logical matrix doesn't make much sense to me in either case, as it does not have the effect of selecting individual elements, which is what numeric matrix indices do. But that's a matter of usage, neither bug nor feature. If I had gotten something like the error message: Matrix indices not allowed for replacement in data frames, I would not have been surprised. But as you said, the behavior **IS** documented. Your version is not correct: matrix indices *are* allowed for replacement, but only logical matrix indices, not two column numerical ones. The message might be clearer if instead of saying only logical matrix subscripts are allowed in replacement it said matrix subscripts must be logical matrices in replacement, but I think the basic problem is the limitation. I'll fix that. Duncan Murdoch Best, Bert On Tue, May 1, 2012 at 10:49 AM, Ista Zahnlt;istazahn@gt; wrote: Hi Bert, The failure itself is the documented behavior: ?'[.data.frame' says Matrix indexing ('x[i]' with a logical or a 2-column integer matrix 'i') using '[' is not recommended, and barely supported. For extraction, 'x' is first coerced to a matrix. For replacement, a logical matrix (only) can be used to select the elements to be replaced in the same way as for a matrix. The error message may be a bit hinky, as obviously data.frames can be indexed by things other than logical matricies. Or is there another reason this strikes you as odd? Best, Ista On Tue, May 1, 2012 at 1:33 PM, Bert Gunterlt;gunter.berton@gt; wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest- matrix(1:12,nr=4) dftest- data.frame(mtest) ix- cbind(1:2,2:3) mtest[ix]- NA mtest [,1] [,2] [,3] [1,] 1 NA 9 [2,] 2 6 NA [3,] 3 7 11 [4,] 4 8 12 ## But ... dftest[ix]- NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@ 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@ 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. Actually, it works, as long as the logical index matrix has the same dimensions as the data frame. zmat - matrix(1:12,nr=4) zdf - data.frame(zmat) # Numeric index matrix. ix - cbind(1:2,2:3) # Logical index matrix. ix2 - row(zdf) == ix[, 1] col(zdf) == ix[, 2] zmat[ix] zmat[ix2] zdf[ix] zdf[ix2] zmat[ix] - NA zmat # So far so good, # But now, as already seen, error zdf[ix] - NA # Works zdf[ix2] - NA zdf It even makes sense... Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Data-frame-vs-matrix-quirk-Hinky-error-message-tp4601254p4601507.html Sent from the R help mailing list archive at Nabble.com.
[R] How to Export an R outcome to an Excel Spreadsheet
Hello R community, I basically created a normal distribution with mean 2500 and standard deviation = 450 with a sample of size 50 and assigned that to a variable named genvar2 with the following command: genvar2-rnorm(mean=2500, sd=450, n=50) Now, the output of genvar2 generates de following: [1] 2478.126 2671.259 2163.879 2440.796 2702.234 1871.514 2525.127 2830.688 [9] 2704.148 3464.478 2609.795 3368.288 2661.613 2731.901 2535.846 2165.461 [17] 1870.069 3513.533 2053.342 2447.887 2605.913 2188.192 2514.004 2965.374 [25] 3550.454 1783.323 2568.323 2324.673 2528.994 2433.895 2751.111 2727.282 [33] 1837.081 1896.721 3445.993 1357.462 2348.177 2368.423 2029.738 2500.372 [41] 2000.008 3088.112 3003.325 2763.740 2475.636 1860.988 2292.909 2134.172 [49] 2291.116 2851.066 I want to export all of these numbers into a column in an excel file (in an xlsx and .csv format). How can I do this? Any help will be greatly appreciated, Best regards, Paul [[alternative HTML version deleted]] __ R-help@r-project.org 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] How to Export an R outcome to an Excel Spreadsheet
?write.table Googling it would find the same thing -Roy On May 1, 2012, at 1:41 PM, Paul Bernal wrote: Hello R community, I basically created a normal distribution with mean 2500 and standard deviation = 450 with a sample of size 50 and assigned that to a variable named genvar2 with the following command: genvar2-rnorm(mean=2500, sd=450, n=50) Now, the output of genvar2 generates de following: [1] 2478.126 2671.259 2163.879 2440.796 2702.234 1871.514 2525.127 2830.688 [9] 2704.148 3464.478 2609.795 3368.288 2661.613 2731.901 2535.846 2165.461 [17] 1870.069 3513.533 2053.342 2447.887 2605.913 2188.192 2514.004 2965.374 [25] 3550.454 1783.323 2568.323 2324.673 2528.994 2433.895 2751.111 2727.282 [33] 1837.081 1896.721 3445.993 1357.462 2348.177 2368.423 2029.738 2500.372 [41] 2000.008 3088.112 3003.325 2763.740 2475.636 1860.988 2292.909 2134.172 [49] 2291.116 2851.066 I want to export all of these numbers into a column in an excel file (in an xlsx and .csv format). How can I do this? Any help will be greatly appreciated, Best regards, Paul [[alternative HTML version deleted]] __ R-help@r-project.org 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. ** The contents of this message do not reflect any position of the U.S. Government or NOAA. ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center 1352 Lighthouse Avenue Pacific Grove, CA 93950-2097 e-mail: roy.mendelss...@noaa.gov (Note new e-mail address) voice: (831)-648-9029 fax: (831)-648-8440 www: http://www.pfeg.noaa.gov/ Old age and treachery will overcome youth and skill. From those who have been given much, much will be expected the arc of the moral universe is long, but it bends toward justice -MLK Jr. __ R-help@r-project.org 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] Forecast Package for 2.15.0
No What have you tried? OS? R build? Install method? Error messages? Note this has some C++ dependencies so it might be a little tricky to compile if you are missing necessary tools. Michael On May 1, 2012, at 2:05 PM, slipkid90515 jessica.lyn.ol...@gmail.com wrote: Anyone else having problems installing this package? Any ideas for fixing? Thanks, Jess -- View this message in context: http://r.789695.n4.nabble.com/Forecast-Package-for-2-15-0-tp4601328.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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@r-project.org 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] Data frame vs matrix quirk: Hinky error message?
On May 1, 2012, at 1:33 PM, Bert Gunter wrote: AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? mtest - matrix(1:12,nr=4) dftest - data.frame(mtest) ix - cbind(1:2,2:3) mtest[ix] - NA mtest [,1] [,2] [,3] [1,]1 NA9 [2,]26 NA [3,]37 11 [4,]48 12 ## But ... dftest[ix] - NA Error in `[-.data.frame`(`*tmp*`, ix, value = NA) : only logical matrix subscripts are allowed in replacement I'm not sure _I_ would have expected '[-.data.frame' to recognize that a matrix was being offered because the [.] formalism without a comma (called i-indexing on the help page) would generally be referencing only columns (i.e. list elements). I had not realized the possibilitiy of offering a logical matrix to df but it does succeed as predicted by ?[.data.frame For replacement, a logical matrix (only) can be used to select the elements to be replaced in the same way as for a matrix. So how you want to characterize documented behavior is your call. I would never choose the label you offered. mtest - matrix(FALSE, 4,4) ix - cbind(1:2,2:3) dftest - data.frame(mtest) mtest[ix] - TRUE dftest[mtest] - a dftest X1X2X3X4 1 FALSE a FALSE FALSE 2 FALSE FALSE a FALSE 3 FALSE FALSE FALSE FALSE 4 FALSE FALSE FALSE FALSE The nonassignment operation still succeeds: dftest[ix] [1] a a Obviously, I was expecting matrix indexing for replacement to work similarly in both cases; however, I can see why it would be problematic for data frames (mixed types), but was a bit nonplussed by the error message, which seems hinky to me. Cheers, Bert -- -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org 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] Define lower-upper bound for parameters in Optim using Nelder-Mead method
On 01-May-2012 19:58:41 Arnaud Mosnier wrote: Dear UseRs, Is there a way to define the lower-upper bounds for parameters fitted by optim using the Nelder-Mead method ? Thanks, Arnaud The Nelder-Mead method does not provide built-in capability to set bounds on the range of paramaters. However, you can achieve it by hand by re-defining the function being minimised, so that it tests whether an out-of-range parameter parameter value is being used. If not out-of-range, then return the standard value of the function. If out-of range, then return a very large value. Nelder-Mead will very happily bounce off high walls of this kind, and if the minimum of the function is at the wall will happily converge as close to it as you please. Hoping this helps, Ted. - E-Mail: (Ted Harding) ted.hard...@wlandres.net Date: 01-May-2012 Time: 22:39:15 This message was sent by XFMail __ R-help@r-project.org 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] How to Export an R outcome to an Excel Spreadsheet
Hello R community, I basically created a normal distribution with mean 2500 and standard deviation = 450 with a sample of size 50 and assigned that to a variable named genvar2 with the following command: genvar2-rnorm(mean=2500, sd=450, n=50) Now, the output of genvar2 generates de following: [1] 2478.126 2671.259 2163.879 2440.796 2702.234 1871.514 2525.127 2830.688 [9] 2704.148 3464.478 2609.795 3368.288 2661.613 2731.901 2535.846 2165.461 [17] 1870.069 3513.533 2053.342 2447.887 2605.913 2188.192 2514.004 2965.374 [25] 3550.454 1783.323 2568.323 2324.673 2528.994 2433.895 2751.111 2727.282 [33] 1837.081 1896.721 3445.993 1357.462 2348.177 2368.423 2029.738 2500.372 [41] 2000.008 3088.112 3003.325 2763.740 2475.636 1860.988 2292.909 2134.172 [49] 2291.116 2851.066 I want to export all of these numbers into a column in an excel file (in an xlsx and .csv format). How can I do this? Any help will be greatly appreciated, Best regards, Paul -- View this message in context: http://r.789695.n4.nabble.com/How-to-Export-an-R-outcome-to-an-Excel-Spreadshee-t-tp4601703.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Forecast Package for 2.15.0
After poking around a little bit, I was able to install the package using the Install packages from local zip(s) files command from the Packages menu. I had to go grab the zip file from http://cran.stat.sfu.ca/bin/windows/contrib/2.15/; because it looked like R was going to a nonexistent URL when I just used the install.packages command in the console. I had to do the same thing for the tseries package, so could that suggest that it's a problem with R? Is it pointing to the wrong places? In any case, problem solved :) Thanks, Jess -- View this message in context: http://r.789695.n4.nabble.com/Forecast-Package-for-2-15-0-tp4601328p4601792.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Where to find the p-value of a correlation test
Awesome! cor.text() is what I was looking for! Thank you Duncan! On Wed, Apr 25, 2012 at 9:43 AM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 12-04-25 9:30 AM, Aaditya Nanduri wrote: Hey everyone, I hope this finds you in good cheer. I just have a quick question: What is the function that outputs the p-value for correlation? cor(x,y) only provides the R value. I would like the p-value associated with it. cor(x,y) calculates the correlation, it doesn't perform a test, so there is no p-value. cor.test() performs a test. Duncan Murdoch -- *Aaditya Nanduri | Statistical Analyst*** Business Analytics Aflac Worldwide Headquarters 1932 Wynnton Road, Columbus, Georgia 31999 Tel: 706.596.2986 | Cell: 908.380.4560 [[alternative HTML version deleted]] __ R-help@r-project.org 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] Where to find the p-value of a correlation test
Im sorry. I meant cor.test() On Tue, May 1, 2012 at 6:16 PM, Aaditya Nanduri aaditya.nand...@gmail.comwrote: Awesome! cor.text() is what I was looking for! Thank you Duncan! On Wed, Apr 25, 2012 at 9:43 AM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 12-04-25 9:30 AM, Aaditya Nanduri wrote: Hey everyone, I hope this finds you in good cheer. I just have a quick question: What is the function that outputs the p-value for correlation? cor(x,y) only provides the R value. I would like the p-value associated with it. cor(x,y) calculates the correlation, it doesn't perform a test, so there is no p-value. cor.test() performs a test. Duncan Murdoch -- *Aaditya Nanduri | Statistical Analyst*** Business Analytics Aflac Worldwide Headquarters 1932 Wynnton Road, Columbus, Georgia 31999 Tel: 706.596.2986 | Cell: 908.380.4560 -- *Aaditya Nanduri | Statistical Analyst*** Business Analytics Aflac Worldwide Headquarters 1932 Wynnton Road, Columbus, Georgia 31999 Tel: 706.596.2986 | Cell: 908.380.4560 [[alternative HTML version deleted]] __ R-help@r-project.org 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] Forecast Package for 2.15.0
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of slipkid90515 Sent: Tuesday, May 01, 2012 2:41 PM To: r-help@r-project.org Subject: Re: [R] Forecast Package for 2.15.0 After poking around a little bit, I was able to install the package using the Install packages from local zip(s) files command from the Packages menu. I had to go grab the zip file from http://cran.stat.sfu.ca/bin/windows/contrib/2.15/; because it looked like R was going to a nonexistent URL when I just used the install.packages command in the console. I had to do the same thing for the tseries package, so could that suggest that it's a problem with R? Is it pointing to the wrong places? In any case, problem solved :) Thanks, Jess Jess, We need a reproducible example, i.e. you need to tell us exactly what you typed or what you selected from the menu and also what didn't work (error messages, etc) before we can help. Did you use install.packages() from the console or terminal window, or did you use Install package(s)... from the packages menu? Are you behind a proxy server? If so, you may need to see ?setInternet2 help page. Hope this is helpful, Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 __ R-help@r-project.org 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] How to Export an R outcome to an Excel Spreadsheet
? write.csv Michael On May 1, 2012, at 4:52 PM, PaulJr paulberna...@gmail.com wrote: Hello R community, I basically created a normal distribution with mean 2500 and standard deviation = 450 with a sample of size 50 and assigned that to a variable named genvar2 with the following command: genvar2-rnorm(mean=2500, sd=450, n=50) Now, the output of genvar2 generates de following: [1] 2478.126 2671.259 2163.879 2440.796 2702.234 1871.514 2525.127 2830.688 [9] 2704.148 3464.478 2609.795 3368.288 2661.613 2731.901 2535.846 2165.461 [17] 1870.069 3513.533 2053.342 2447.887 2605.913 2188.192 2514.004 2965.374 [25] 3550.454 1783.323 2568.323 2324.673 2528.994 2433.895 2751.111 2727.282 [33] 1837.081 1896.721 3445.993 1357.462 2348.177 2368.423 2029.738 2500.372 [41] 2000.008 3088.112 3003.325 2763.740 2475.636 1860.988 2292.909 2134.172 [49] 2291.116 2851.066 I want to export all of these numbers into a column in an excel file (in an xlsx and .csv format). How can I do this? Any help will be greatly appreciated, Best regards, Paul -- View this message in context: http://r.789695.n4.nabble.com/How-to-Export-an-R-outcome-to-an-Excel-Spreadshee-t-tp4601703.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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@r-project.org 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] Define lower-upper bound for parameters in Optim using Nelder-Mead method
Ted.Harding at wlandres.net writes: On 01-May-2012 19:58:41 Arnaud Mosnier wrote: Dear UseRs, Is there a way to define the lower-upper bounds for parameters fitted by optim using the Nelder-Mead method ? Thanks, Arnaud The Nelder-Mead method does not provide built-in capability to set bounds on the range of paramaters. However, you can achieve it by hand by re-defining the function being minimised, so that it tests whether an out-of-range parameter parameter value is being used. If not out-of-range, then return the standard value of the function. If out-of range, then return a very large value. Nelder-Mead will very happily bounce off high walls of this kind, and if the minimum of the function is at the wall will happily converge as close to it as you please. In addition to these options, there is also a derivative-free box-constrained optimizer (bobyqa) in the 'minqa' package (and in an optim-like wrapper via the optimx package), and a box-constrained Nelder-Mead optimizer in the development (r-forge) version of lme4, which is based on the NLopt optimization library (also accessible via the nloptr package). __ R-help@r-project.org 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] VarCorr procedure from lme4
Yes - I also have nlme. Bad juju? David On 5/1/2012 1:32 PM, Walmes Zeviani wrote: It could be a bad coexistence between packages in the same R session. Are you using nlme and/or doBy packages too? Bests. Walmes. == Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail: wal...@ufpr.br twitter: @walmeszeviani homepage: http://www.leg.ufpr.br/~walmes linux user number: 531218 == [[alternative HTML version deleted]] __ R-help@r-project.org 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. -- David K Stevens, P.E., Ph.D., Professor Civil and Environmental Engineering Utah Water Research Laboratory 8200 Old Main Hill Logan, UT 84322-8200 435 797 3229 - voice 435 797 1363 - fax david.stev...@usu.edu [[alternative HTML version deleted]] __ R-help@r-project.org 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] VarCorr procedure from lme4
That was it - detaching 'nlme' was the trick. Thanks Walmes and the rest. David On 5/1/2012 7:47 PM, David Stevens wrote: Yes - I also have nlme. Bad juju? David On 5/1/2012 1:32 PM, Walmes Zeviani wrote: It could be a bad coexistence between packages in the same R session. Are you using nlme and/or doBy packages too? Bests. Walmes. == Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail: wal...@ufpr.br twitter: @walmeszeviani homepage: http://www.leg.ufpr.br/~walmes linux user number: 531218 == [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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. -- David K Stevens, P.E., Ph.D., Professor Civil and Environmental Engineering Utah Water Research Laboratory 8200 Old Main Hill Logan, UT 84322-8200 435 797 3229 - voice 435 797 1363 - fax david.stev...@usu.edu [[alternative HTML version deleted]] __ R-help@r-project.org 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] please help me
hi all,can you help me? index moran is very difficut for me, i have data n neighbor as enclosure: please help me to make the program for find index moran value each variabel,...thank very much __ R-help@r-project.org 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] coxph reference hazard rate
Hi, In the following results I interpret exp(coef) as the factor that multiplies the base hazard rate if the corresponding variable is TRUE. For example, when the bucket is ks008 and fidelity = 3, then the rate, compared to the base rate h_0(t), is h(t) = 0.200 h_0(t). My question is then, to what case does the base hazard rate correspond to? I would expect the reference to be the first factor value, i.e. bucket jpc001 with fidelity = 3, but its exp(coef) is not one. I verified the contrasts, and the row corresponding to the first factor value is zero everywhere; moreover, I didn't change the default, so a bad setting of the contrasts doesn't seem to be the issue. Best, ge Call: coxph(formula = Surv(time, event = (censored == FALSE)) ~ bucket:factor(fidelity 3), data = week.15) coef exp(coef) se(coef) z p bucketjpc001:factor(fidelity 3)FALSE -1.606 0.201 0.00624 -257.5 0 bucketks006:factor(fidelity 3)FALSE -1.613 0.199 0.00627 -257.5 0 bucketks007:factor(fidelity 3)FALSE -1.620 0.198 0.00626 -258.8 0 bucketks008:factor(fidelity 3)FALSE -1.611 0.200 0.00625 -257.6 0 bucketks009:factor(fidelity 3)FALSE -1.620 0.198 0.00626 -258.9 0 bucketks010:factor(fidelity 3)FALSE -1.619 0.198 0.00626 -258.6 0 bucketjpc001:factor(fidelity 3)TRUE -0.156 0.856 0.00596 -26.2 0 bucketks006:factor(fidelity 3)TRUE -0.171 0.842 0.00600 -28.6 0 bucketks007:factor(fidelity 3)TRUE -0.168 0.845 0.00602 -28.0 0 bucketks008:factor(fidelity 3)TRUE -0.167 0.846 0.00600 -27.8 0 bucketks009:factor(fidelity 3)TRUE -0.170 0.844 0.00599 -28.4 0 bucketks010:factor(fidelity 3)TRUE NANA 0.0 NA NA Likelihood ratio test=294562 on 11 df, p=0 n= 1173838, number of events= 629383 -- View this message in context: http://r.789695.n4.nabble.com/coxph-reference-hazard-rate-tp4602092.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Robust estimation of a geometric random variable
Hi, I have a bunch of data which is assumed to be instances of a geometric random variable with outliers. How can I do a robust estimation of the parameter p so that the effect of outliers is minimized? As a part of the estimation process, I also need to know which are the outliers in the data. I found glmrob which does robust estimation of Poisson and binomial random variables but not geometric random variable. I understand that the maximum likelihood estimate of p of geometric random variable is the mean of the instance values. So if we do robust estimate of mean of the instance values, can we say that we are doing robust estimation of the underlying geometric random variable? If so, which method is most suitable for doing the robust mean estimation. (I am a newbie in statistics and R). Thanks suresh [[alternative HTML version deleted]] __ R-help@r-project.org 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] Numeric data not numeric in .csv file
I am a raw novice to R, playing around with a mini .csv dataset created in Excel. I can read it in and the data looks OK in Excel and upon initial inspection in R: hikes - read.csv(/Users/eproper/Desktop/hikes.csv, header=TRUE) print(hikes) does exactly what it is supposed to do. Two of the variables are genuine strings, but the others ought to be numeric, and R will calculate their min, max etc. However, is.numeric returns FALSE for all of them; storage.mode returns language. as.numeric returns Error: 'pairlist' object cannot be coerced to type 'double'. In what I suspect is a related problem, any command that calls for a variable name requires an initial ~ to work. That is, instead of plot(miles) I have to use plot(~miles). No doubt there is some very elementary mistake I am making, but I can't figure it out. Any help would be appreciated. http://theturducken.blogspot.com/ [[alternative HTML version deleted]] __ R-help@r-project.org 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] MCMCglmm priors including phylogeny
Hi all, I'm hoping I might be able to get some help with some issues specifying priors for MCMCglmm. I'm trying to fit a gaussian glmm using MCMCglmm to a data set with two (correlated) response variables. The response variables are both logit-transformed proportions (there are a few reasons why I've chosen these with gaussian error over binomal glmm, which I won't go into). Each probability represents a response for a single plant species (c.150 species), and I want to incorporate the phylogeny (almost fully resolved with only 2 polytomies, including branch lengths) in the error structure. There is only 1 explanatory variable, a 5-level factor. I'm using uninformative priors for fixed parameters (i.e. not specifying any priors). Here's my code: #prior model1 prior1-list(R = list(V = diag(2)*x, n=2), G = list(G1=list(V = diag(2)*x, n=2))) #model1 m1-MCMCglmm(cbind(y1.logit,y2.logit) ~ trait:Ecotype - 1, random=~us(trait):animal, rcov=~us(trait):units, family=c(gaussian,gaussian), prior=prior1, data=meandata, pedigree=meantree, nodes=TIPS, thin=100, nitt=15, burnin=3, verbose=F) #prior model2 prior2-list(R = list(V = diag(2)*x, n=2)) #model2 m2-MCMCglmm(cbind(reac.prob.logit,inert.prob.logit) ~ trait:Ecotype - 1, rcov=~us(trait):units, family=c(gaussian,gaussian), prior=prior2, data=meandata, thin=100, nitt=15, burnin=3, verbose=F) I've tried prior variance values of 5, 10, 50, 100, 500, 1000, 5000 and 1 (by varying x in the code above), and I've used a large thinning interval (100) to deal with autocorrelation arising from the correlated responses. Chains seem to mix well as long as I use enough iterations (over 10 seems to be best). Posterior distributions from plot(model) are normal-distributed for fixed effects and residuals in every case. However, posteriors for errors don't behave as nicely: - Lower prior values (superficially 100) result in positively-skewed distributions for trait:animal whereas higher prior values (superficially 100) are much more normal. With the logit data running from ~-3.5 to ~10, it seems that the prior values that result in well-fitting models are higher than the variance of the data itself. - Fixed parameter values vary (but not considerably) with choice of prior, but error parameters seem to be more sensitive to prior choice. - Posterior means for errors and residuals are larger and more variable for y1:y1 and y2:y2 combinations (in the hundreds) but smaller for y1:y2 and y2:y1 combinations (in the tens). Considering this, my first question is: what are appropriate priors for G and R? I'm aware that my priors assume a priori independence between the two responses, and I know that they will covary, but my understanding is that specifying us(trait) in my errors and residuals in my residuals should estimate covariance anyway. But, my second question is this: what are the merits in using a multi-response model? The phylogenetic models are taking a fair amount of time to run, and I hope that without the need to estimate covariances, they might be a bit speedier. At some point, I will want to incorporate replication within species in the analysis (populations nested within species), but for now I'm really just interested in looking at mean response per species. I'm assuming that priors will probably be of similar value (but more of them) once I include within-species replication... or will I have to go through this again?? Any help appreciated, thanks in advance Iain Iain Stott Centre for Ecology and Conservation University of Exeter, Cornwall Campus Tremough Treliever Road Penryn Cornwall TR10 9EZ Tel: 01326 371852 http://biosciences.exeter.ac.uk/cec/staff/postgradresearch/iainstott/ __ R-help@r-project.org 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] error bars for a barchart
Thank you for your example. I only skimmed it, but since both solutions use nlevels and box.ratio it is no surprise we end up at the same place (although I do think your g-median is nicer than my 3/4). Thing is, I wouldn't call either of these simple... would be nice if one could just query the new centers, but I don't know if there is a way without hacking panel.barchart itself ? Cheers On Tue, May 1, 2012 at 1:34 PM, Walmes Zeviani walmeszevi...@gmail.com wrote: I have a repoducibe example here http://ridiculas.wordpress.com/2011/11/23/media-e-desvio-padrao-de-muitas-variaveis-separado-por-grupos/ Sorry for it be in Portuguese. Walmes. == Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail: wal...@ufpr.br twitter: @walmeszeviani homepage: http://www.leg.ufpr.br/~walmes linux user number: 531218 == __ R-help@r-project.org 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] Numeric data not numeric in .csv file
Sounds like you have some text in your csv file. Open it with a text editor and look at it. Some common problems are: alphabetic or symbol characters, spaces, quotes around numbers. Also watch out for blank rows or columns. Read the Posting Guide (mentioned at the bottom of every post). Tips: The dput function is useful for generating an unambiguous representation of your data, which is key in getting correct advice around here. The head function can be used to chop off a short amount of data if you have a lot. The str function is good for troubleshooting your own issues. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Eve Proper epro...@gmail.com wrote: I am a raw novice to R, playing around with a mini .csv dataset created in Excel. I can read it in and the data looks OK in Excel and upon initial inspection in R: hikes - read.csv(/Users/eproper/Desktop/hikes.csv, header=TRUE) print(hikes) does exactly what it is supposed to do. Two of the variables are genuine strings, but the others ought to be numeric, and R will calculate their min, max etc. However, is.numeric returns FALSE for all of them; storage.mode returns language. as.numeric returns Error: 'pairlist' object cannot be coerced to type 'double'. In what I suspect is a related problem, any command that calls for a variable name requires an initial ~ to work. That is, instead of plot(miles) I have to use plot(~miles). No doubt there is some very elementary mistake I am making, but I can't figure it out. Any help would be appreciated. http://theturducken.blogspot.com/ [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] returning value from source() in R .Net
Hello I would like to source an R script from within a C# .Net application equivalent to: source(my_r_code.r) I can get this to run but am not sure how to retrieve R objects defined with script my_r_code.r at runtime. For example, if my_r_code.r contains #-- contents of my_r_code.r- x - 1:10 xmean - mean(x) #-- My question is how to return the value of xmean to the .Net application? Paul [[alternative HTML version deleted]] __ R-help@r-project.org 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] Equivalent of Nothing (in VBA) or [] in Matlab in R
Hello, I'm glad it worked. You could have posted it in r-help, this may be of use to others... Rui Barradas Citando sb kr shinilku...@hotmail.com: Hi Rui Barradas, as you guessed the second option worked Thanks again lm Date: Sun, 29 Apr 2012 16:52:45 -0700 From: ruipbarra...@sapo.pt To: r-help@r-project.org Subject: Re: [R] Equivalent of Nothing (in VBA) or [] in Matlab in R Hello, There are other types of empty objects in R (zero length or dimension). Maybe some of these x - list() length(x) x - matrix(list()) dim(x) - c(0, 0) x Matlab's [] is the empty matrix so maybe the second works. Other possibilities could be x - numeric(0) (or integer(0) or character(0)). Trial and error might get you there... Hope this helps, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Equivalent-of-Nothing-in-VBA-or-in-Matlab-in-R-tp4595385p4597157.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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. [[alternative HTML version deleted]] __ R-help@r-project.org 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] returning value from source() in R .Net
I am mystified as to why you think you can source a snippet of one interpreted language into a different compiled language. Fortunately this is not the correct forum for your question, so I can punt. Google suggests that you look at rdotnet.codeplex.com, and perhaps read their documentation, and if that doesn't help then post your question on their discussion forum. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. paul.rusto...@csiro.au wrote: Hello I would like to source an R script from within a C# .Net application equivalent to: source(my_r_code.r) I can get this to run but am not sure how to retrieve R objects defined with script my_r_code.r at runtime. For example, if my_r_code.r contains #-- contents of my_r_code.r- x - 1:10 xmean - mean(x) #-- My question is how to return the value of xmean to the .Net application? Paul [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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.