[R] (simple) xml into data.frame and reverse
Hello, I am trying to convert a simple data.frame (it will always be a few equally long variables) into the XML format (which I don't understand too well but need as input for another program) and reverse the operation (from XML back into data.frame). I found some code which does the first and it works good enough for me (see below). Is there an easy way to reverse the operation? My XML files are nothing fancy (no child nodes or anything, at least as far as I can see. ### data.frame data<- as.data.frame(cbind(c(0 ,1 ),c( 500 , 300),c(200, 400))) names(data)<-c("age","0","1") ### converts data.frame into XML xml <- xmlTree() xml$addTag("populationsize", close=FALSE) for (i in 1:nrow(data)) { xml$addTag("size", close=FALSE) for (j in names(data)) { xml$addTag(j, data[i, j]) } xml$closeTag() } xml$closeTag() # view the result cat(saveXML(xml)) I put below also an example of how my data looks like. Thanks for any advice! Best and have a great day, Stefan APPENDIX XML-file -- 0 0 500 0 1 300 1 0 200 1 1 400 - DATAFRAME age0 1 0 500 300 1 200 400 __ 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] (simple) xml into data.frame and reverse
Hi Duncan, thanks for the advice and the link. I just realized there is a mistake in the code I posted and I currently don't have the time to correct it. So I can not try your function (yet). But I will do so in the next few days and tell you if it doesnt work. Thanks again and best, Stefan On Wed, Jul 15, 2009 at 2:37 PM, Duncan Temple Lang wrote: > > Thanks Dieter. It should have been > > http://www.omegahat.org/RSXML/xmlToDataFrame.R > > as it is an R file. > > Thanks > D. > > Dieter Menne wrote: >> >> >> Duncan Temple Lang wrote: >>> >>> >>> I wrote some relatively general functions, but hastily written functions >>> to read this sort of data. You can find them attached or at >>> >>> http://www.omegahat.org/RSXML/xmlToDataFrame.xml >>> >>> >> >> Looks like that's the wrong link. I also did not find it mentioned in the >> parent page. >> >> Dieter >> >> > > __ > 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] Reading a SpreadsheetML / XMLNS into R xmlns="urn:schemas-microsoft-com:office:spreadsheet
Hello, I use a software that outputs the data in a form/dialect(?) of xml (I think its called "SpreadsheetML", see below for an excerpt). It allows (admittedly) easy import of such files into Excel. I would like, however, to import it directly into R. I am familiar how to do that with standard xml-files (mostly thanks to Duncan Temple Lang's help). But I haven't found the right command yet to do it with this kind of data in R. I would figure it couldn't be to difficult as it is designed to hold the data in separate sheets that contain a single table. Any hint appreciated. Have a great weekend! Best, Stefan http://www.w3.org/TR/REC-html40";> 12.00 10005 10005 120 135 False False[... omission...] False False __ 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] XML: Reading transition matrices into R
Hello, from a software I have the following output in xml (see below): It is a series of matrices, for each age one. I have 3 categories (might vary in the application), hence, 3x3 matrices where each element gives the probability of transition from i to j. I would like read this data into R (preferably in a list, where each list element is one of the age specific matrices) and - after altering the values in R - write it back into the file. I know that there is an xml package in R with which I have already struggled, but I have to admit my understanding is too limited. Maybe somebody had a similar problem or know the code of the top of his or her head. Any help appreciated. Thanks and best, Stefan 001199.900120.000130.000210.0002299.8500230.000310.000320.0003399.85000.001120.001130.001210.00122100.001230.001310.001320.00133100.0101199.910120.010130.01 0210.0102299.8510230.010310.010320.0103399.85100.011120.011130.011210.01122100.011230.011310.011320.01133100.0201199.3520520120.647947420130.020210.0202297.10145620232.898549620310.020320.02033100.0211197.8213621122.178647321130.021210.0212293.621236.40821310.0213! 20.02133100.0 __ 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] XML: Reading transition matrices into R
Hello, thanks a lot. This is a form which I can work with in R. Another question, which I hope is not a bridge too far: Can I write the R matrix which your code created back into the xml format (i.e. with the same tags and structure) from which it came and hence feed it back to the original software? Best, Stefan On Thu, Nov 12, 2009 at 3:17 PM, Duncan Temple Lang wrote: > > > stefan.d...@gmail.com wrote: >> Hello, >> from a software I have the following output in xml (see below): >> It is a series of matrices, for each age one. I have 3 categories >> (might vary in the application), hence, 3x3 matrices where each >> element gives the probability of transition from i to j. I would like >> read this data into R (preferably in a list, where each list element >> is one of the age specific matrices) and - after altering the values >> in R - write it back into the file. I know that there is an xml >> package in R with which I have already struggled, but I have to admit >> my understanding is too limited. Maybe somebody had a similar problem >> or know the code of the top of his or her head. > > Hi Stefan > > There are many approaches for handling this. I assume that the primary > obstacle you are facing is extracting the values from the XML. The following > will do that for you. > We start with the content in transition.xml (or in a string in R). > Since the XML is very shallow, i.e. not very hierarchical, and all > the information is in the transition nodes under the root, we can > use xmlToList(). > This returns a list with an element for each > element, and such elements are character vectors containing the > values from age, sex, from, to, and percent. > So I've put these into a matrix and you are now back entirely > within R and can group the values by age and arrange them into > the individual transition matrices. > > > doc = xmlParse("transition.xml") > matrix(as.numeric(unlist(xmlToList(doc))), , 5, byrow = TRUE, > dimnames = list(NULL, names(xmlRoot(doc)[[1]]))) > > > D. > > > >> >> Any help appreciated. >> >> Thanks and best, >> Stefan >> >> >> >> >> >> >> 001199.900120.000130.000210.0002299.8500230.000310.000320.0003399.85000.00< > /! >> age>1120.001130.001210.00122100.001230.001310.001320.00133100.0101199.910120.0101 m! >> >30.01 >> 0210.0102299.8510230.010310.010320.0103399.85100.011120.011130.011210.0112 m! >> >2100.011230.011310.011320.01133100.0201199.3520520120.647947420130.020210.0202297.1014562023 e! >> nt>2.898549620>> 310.020320.02033100.0211197.8213621122.178647321130.021210.0212293.621236.40821310.0213>! >> 20.02133100.0 >> >> >> __ >> 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] XML: Reading transition matrices into R
Thank you so much You really helped me a lot! Best from R'dam, Stefan On Fri, Nov 13, 2009 at 2:14 AM, Duncan Temple Lang wrote: > > > stefan.d...@gmail.com wrote: >> Hello, >> thanks a lot. This is a form which I can work with in R. >> >> Another question, which I hope is not a bridge too far: Can I write >> the R matrix which your code created back into the xml format (i.e. >> with the same tags and structure) from which it came and hence feed it >> back to the original software? > > > trans = apply(xx, 1, function(x) { > tr = newXMLNode("transition") > mapply(newXMLNode, names(x), x, MoreArgs = list(parent > = tr)) > tr > }) > top = newXMLNode("transitionmatrix", .children = trans) > saveXML(top, "newTransition.xml") > > > > >> >> Best, >> Stefan >> >> >> On Thu, Nov 12, 2009 at 3:17 PM, Duncan Temple Lang >> wrote: >>> >>> stefan.d...@gmail.com wrote: >>>> Hello, >>>> from a software I have the following output in xml (see below): >>>> It is a series of matrices, for each age one. I have 3 categories >>>> (might vary in the application), hence, 3x3 matrices where each >>>> element gives the probability of transition from i to j. I would like >>>> read this data into R (preferably in a list, where each list element >>>> is one of the age specific matrices) and - after altering the values >>>> in R - write it back into the file. I know that there is an xml >>>> package in R with which I have already struggled, but I have to admit >>>> my understanding is too limited. Maybe somebody had a similar problem >>>> or know the code of the top of his or her head. >>> Hi Stefan >>> >>> There are many approaches for handling this. I assume that the primary >>> obstacle you are facing is extracting the values from the XML. The >>> following >>> will do that for you. >>> We start with the content in transition.xml (or in a string in R). >>> Since the XML is very shallow, i.e. not very hierarchical, and all >>> the information is in the transition nodes under the root, we can >>> use xmlToList(). >>> This returns a list with an element for each >>> element, and such elements are character vectors containing the >>> values from age, sex, from, to, and percent. >>> So I've put these into a matrix and you are now back entirely >>> within R and can group the values by age and arrange them into >>> the individual transition matrices. >>> >>> >>> doc = xmlParse("transition.xml") >>> matrix(as.numeric(unlist(xmlToList(doc))), , 5, byrow = TRUE, >>> dimnames = list(NULL, names(xmlRoot(doc)[[1]]))) >>> >>> >>> D. >>> >>> >>> >>>> Any help appreciated. >>>> >>>> Thanks and best, >>>> Stefan >>>> >>>> >>>> >>>> >>>> >>>> >>>> 001199.900120.000130.000210.0002299.8500230.000310.000320.0003399.85000.0 > 0< >>> /! >>>> age>1120.001130.001210.00122100.001230.001310.001320.00133100.0101199.910120.0101 ro >>> m! >>>> >30.01 >>>> 0210.0102299.8510230.010310.010320.0103399.85100.011120.011130.011210.0112 ro >>> m! >>>> >2100.011230.011310.011320.01133100.0201199.3520520120.647947420130.020210.0202297.1014562023 rc >>> e! >>>> nt>2.898549620>>>> 310.020320.02033100.0211197.8213621122.178647321130.021210.0212293.621236.40821310.0213 om >>>> ! >>>> 20.02133100.0 >>>> >>>> >>>> __ >>>> 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-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] Building US maps in R
Hi DD, if you have a .shp file (which in principal should exist of the kind of map your describing) you can load into R using this packages: http://r-spatial.sourceforge.net/ In addition, there is also the R-Geo list which is much more suited for this kind of questions: r-sig-...@stat.math.ethz.ch And there is always "the" book when it comes to R and spatial modeling (Applied Spatial Data Analysis With R): http://www.asdar-book.org/ Best of luck, Stefan On Mon, May 11, 2009 at 3:55 AM, Dirty D wrote: > Hi, > > I'm trying to build some maps of the US by county that will have the > following characteristics: > > Feature/Map > Map 1 > Map2 > Both > Broken out by county > Yes > Yes > Yes > Heatmaps of US Census Data for income by county > Yes > No > Yes > Heatmaps of US Census Data for race by county (recoded as white and > &non-white, with each county color coded based on the majority) > No > Yes > No > Polygon markers showing the coordinates of a list of restaurants that > have geographical coordinates attached > Yes > Yes > Yes > > > I started learning R a year ago, but had to drop it for work reasons. Is > there someone on the list who can help guide me through the process or > refer me to /very, very/ detailed instructions and tutorials? > > Thanks, > > DD > > [[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] strange (?) behavoir of expand.grid()
Hello, I came across a strange behavior of expand.grid (or at least strange to me). For certain values of one of my input variables - created by seq() - I have to use strings (e.g ==".6") to select a row of the object created by expand.grid(), for other values numerical (e.g. ==.8) and for some both work. Please find an example below. #Example x<- seq(0,1,1/10) y <- seq(0,1,1/10) gridd <- expand.grid(x,y ) gridd[which( gridd[,2]=="0.6" ),] #gives me the right data gridd[which( gridd[,2]==0.6 ) ,] #gives error message gridd[which( gridd[,2]=="0.4" ),] #gives right data gridd[which( gridd[,2]==0.4 ),] #gives right data gridd[which( gridd[,2]=="0.0" ),] #gives error message gridd[which( gridd[,2]==0.0 ),] #gives me the right data #End of Example I also encountered this phenomenon on another version of R and on another computer. Has anybody an idea what this is and how to overcome it? Best, Stefan Sys.getlocale() [1] "LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.1252;LC_MONETARY=English_United Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252" version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 8.0 year 2008 month 10 day20 svn rev46754 language R version.string R version 2.8.0 (2008-10-20) __ 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] strange (?) behavoir of expand.grid()
Hi ya'll, thanks for pointing out the obvious ;-) I didn't think of that (and I showed it to a fellow colleague who didn't spot it either, I am going to blame her for that). Best, Stefan On Tue, Apr 7, 2009 at 4:52 PM, Karl Ove Hufthammer wrote: > stefan.d...@gmail.com: > >> I came across a strange behavior of expand.grid (or at least strange to >> me). >> >> For certain values of one of my input variables - created by seq() - I >> have to use strings (e.g ==".6") to select a row of the object >> created by expand.grid(), for other values numerical (e.g. ==.8) and >> for some both work. > > It’s not a bug. Please see > http://wiki.r-project.org/rwiki/doku.php?id=misc:r_accuracy&s=floating > and the documents referenced therein. > > -- > Karl Ove Hufthammer > > __ > 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] Aggregate individual level data to age categories
Dear All, I have a seemingly standard problem to which I somehow I do not find a simple solution. I have individual level data where x is a categorical variable with 3 categories which I would like to aggregate by age. age x 45 1 45 2 46 1 47 3 47 3 and so on. It should after transformation look like that age x_1 x_2 x_3 451 0 1 461 0 0 47 00 2 Basically to calculate prevalences by age categories. Thanks for any pointers! Cheers! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Aggregate individual level data to age categories
well, if I think about, its actually a simple frequency table grouped by age. but it should be usable a matrix or data frame. On Wed, Feb 12, 2020 at 9:48 PM wrote: > > So a pivot table? > > On 12 Feb 2020 20:39, stefan.d...@gmail.com wrote: > > Dear All, > > I have a seemingly standard problem to which I somehow I do not find > a simple solution. I have individual level data where x is a > categorical variable with 3 categories which I would like to aggregate > by age. > > age x > 45 1 > 45 2 > 46 1 > 47 3 > 47 3 > and so on. > > It should after transformation look like that > > age x_1 x_2 x_3 > 451 0 1 > 461 0 0 > 47 00 2 > > Basically to calculate prevalences by age categories. > > Thanks for any pointers! > > Cheers! > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] Aggregate individual level data to age categories
Thank you, this is already very helpful. But how do I get it in the form age var_x=1 var_x=2 var_x=3 45 1 1 0 46 1 00 So it would be a data frame with 4 variables. Cheers! On Wed, Feb 12, 2020 at 10:25 PM William Dunlap wrote: > > You didn't say how you wanted to use it as a data.frame, but here is one way > > d <- data.frame( > check.names = FALSE, > age = c(45L, 45L, 46L, 47L, 47L), > x = c(1L, 2L, 1L, 3L, 3L)) > with(d, as.data.frame(table(age,x))) > > which gives: > age x Freq > 1 45 11 > 2 46 11 > 3 47 10 > 4 45 21 > 5 46 20 > 6 47 20 > 7 45 30 > 8 46 30 > 9 47 32 > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > > On Wed, Feb 12, 2020 at 1:12 PM stefan.d...@gmail.com > wrote: >> >> well, if I think about, its actually a simple frequency table grouped >> by age. but it should be usable a matrix or data frame. >> >> On Wed, Feb 12, 2020 at 9:48 PM wrote: >> > >> > So a pivot table? >> > >> > On 12 Feb 2020 20:39, stefan.d...@gmail.com wrote: >> > >> > Dear All, >> > >> > I have a seemingly standard problem to which I somehow I do not find >> > a simple solution. I have individual level data where x is a >> > categorical variable with 3 categories which I would like to aggregate >> > by age. >> > >> > age x >> > 45 1 >> > 45 2 >> > 46 1 >> > 47 3 >> > 47 3 >> > and so on. >> > >> > It should after transformation look like that >> > >> > age x_1 x_2 x_3 >> > 451 0 1 >> > 461 0 0 >> > 47 00 2 >> > >> > Basically to calculate prevalences by age categories. >> > >> > Thanks for any pointers! >> > >> > Cheers! >> > >> > __ >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> > 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 -- To UNSUBSCRIBE and more, see >> 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 -- To UNSUBSCRIBE and more, see 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] Aggregate individual level data to age categories
Thank you! This is exactly what I was looking for! Cheers! On Wed, Feb 12, 2020 at 11:29 PM Jim Lemon wrote: > > Hi Stefan, > How about this: > > sddf<-read.table(text="age x > 45 1 > 45 2 > 46 1 > 47 3 > 47 3", > header=TRUE) > library(prettyR) > sdtab<-xtab(age~x,sddf) > sdtab$counts > > Jim > > On Thu, Feb 13, 2020 at 7:40 AM stefan.d...@gmail.com > wrote: > > > > Dear All, > > > > I have a seemingly standard problem to which I somehow I do not find > > a simple solution. I have individual level data where x is a > > categorical variable with 3 categories which I would like to aggregate > > by age. > > > > age x > > 45 1 > > 45 2 > > 46 1 > > 47 3 > > 47 3 > > and so on. > > > > It should after transformation look like that > > > > age x_1 x_2 x_3 > > 451 0 1 > > 461 0 0 > > 47 00 2 > > > > Basically to calculate prevalences by age categories. > > > > Thanks for any pointers! > > > > Cheers! > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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 -- To UNSUBSCRIBE and more, see 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] xtable for latex: setting some values globally
Dear All, a quick xtable question. I do have quite a bunch of tables in my latex document which I produce with xtable. That works fine so far. But I wonder is it possible set some values such as "environement", "caption.placement", or "size" globally so that it applies for table unless otherwise specified? If anybody has quick fix, that would be helpful. Thanks and best, Stefan __ 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] xtable for latex: setting some values globally
fair enough! I was just hoping there was some free lunch... thanks and best from Rotterdam, Stefan On Wed, Jun 23, 2010 at 4:26 PM, Hadley Wickham wrote: >> If anybody has quick fix, that would be helpful. > > Write your own function that wraps xtable... > > Hadley > > > -- > Assistant Professor / Dobelman Family Junior Chair > Department of Statistics / Rice University > http://had.co.nz/ > __ 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] Sweave: The opposite of tangle
Hi, I am using Sweave to write an article. If I want to convert the *.rnw to a *.tex file I have to run Sweave which might take a long time. Is there away to get a tex-file as result without (evaluating) the R-chunks, i.e. the opposite of tangle (that just gives R-chunk). Thanks, Stefan __ 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] Sweave: The opposite of tangle
Thanks! That was exactly what I was looking for. Best, Stefan On Fri, Jun 25, 2010 at 12:37 PM, Kevin E. Thorpe wrote: > Kevin E. Thorpe wrote: >> >> stefan.d...@gmail.com wrote: >>> >>> Hi, >>> I am using Sweave to write an article. If I want to convert the *.rnw >>> to a *.tex file I have to run Sweave which might take a long time. Is >>> there away to get a tex-file as result without (evaluating) the >>> R-chunks, i.e. the opposite of tangle (that just gives R-chunk). >>> Thanks, >>> Stefan >>> >> >> This is untested, but does Sweave("file.rnw", eval=FASLE) do what you >> want? >> > > That should be FALSE above. Don't post before coffee. > h > > -- > Kevin E. Thorpe > Biostatistician/Trialist, Knowledge Translation Program > Assistant Professor, Dalla Lana School of Public Health > University of Toronto > email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016 > __ 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] comparing the fit of two (gamma) distributions for aggregated data
Hi, I have aggregated data in 5 categories and want to fit a gamma distribution to it (works fine). My question is that on theoretical grounds I could claim that the observation in the first category (the zero count) are certain, i.e. I know for sure the number. This would then mean in fitting a gamma distribution to the remaining 4 categories. My question is now how can I compare the fit between the two to choose what fits better? I think the AIC/BIC (or all likelihood based test) don't apply as I compare two different data sets (one with data for all 5 categories and one with the data of the 4 categories, hence the number of observations differs substantially) and similarly I think chi2 square test is not really revealing as in the number of observations is so large (the Null is rejected in both cases). Or would one of the tests still apply, claiming one is somehow nested in the other? Another I idea might be to fit to the 5 categories but restrict the estimator somehow so that it replicates the number of observations in the first category (all basically zero). I don't know if that is advisable (and if so, feasible). Any ideas or comments welcome. Below is some code with example data (but I have much more data to fit than just those). library(stats4) breaks.5 <- c(0,.25,20,40,60,120)#breaks counts.5 <- c(4422, 40225, 10973, 3145,3228) #number of obs, breaks.4 <- c(.25,20,40,60,120)#like above but just without the first categories counts.4 <- c( 40225, 10973, 3145,3228) #number of obs, ll <- function(shape, rate) #my likelihood function { z <- pgamma(breaks, shape=shape, rate=rate) -sum(counts * log(diff(z))) } #fitting the 5 categories breaks <-breaks.5 counts <- counts.5 results.mle.5<-mle(ll, start=list(shape=1, rate=1/mean(breaks))) #fitting the 4 categories breaks <-breaks.4 counts <- counts.4 results.mle.4<-mle(ll, start=list(shape=1, rate=1/mean(breaks))) Thanks, Stefan __ 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] reshape from wide to long, ordering of "varying"
Hello, I have data in the following form age sex Int.Prev.Est.1 Int.Prev.Est.2 Int.Prev.Est.3 Int.Prev.Est.4 Int.Prev.Est.5 93110 93 0 23.75482 57.86592 9.755003 4.343534 4.280714 93610 93 1 53.36475 39.47247 4.381618 1.622119 1.159044 94110 94 0 23.47514 58.23936 10.789339 3.690415 3.805741 94610 94 1 53.34524 39.32675 4.602774 1.520247 1.204988 95110 95 0 23.76256 58.18757 9.583178 4.186825 4.279866 95610 95 1 53.14037 39.55376 4.313944 1.632805 1.359124 and want to get it in the form: age sex cat Int.Prev.Est 93 0 1 23.75482 93 0 2 57.86592 93 0 3 9.755003 93 0 4 4.343534 () 95 141.632805 95 1 5 1.359124 I am getting close with reshape, but somehow the categorie varialbe is orderd 1...1, 2...2,3...3,4...4,55 instad as 1,2,3,4,5,1,2,3 reshape(UK.INT, idvar=1:2,times=1:5, varying=c("Int.Prev.Est.1", "Int.Prev.Est.2", "Int.Prev.Est.3", "Int.Prev.Est.4", "Int.Prev.Est.5"),v.names='cat', direction="long") # Here is some example data dput(tail(UK.INT)) structure(list(age = c(93, 93, 94, 94, 95, 95), sex = c(0, 1, 0, 1, 0, 1), Int.Prev.Est.1 = c(2647L, 19706L, 1832L, 15229L, 1277L, 11456L), Int.Prev.Est.2 = c(6448L, 14576L, 4545L, 11227L, 3127L, 8527L), Int.Prev.Est.3 = c(1087L, 1618L, 842L, 1314L, 515L, 930L), Int.Prev.Est.4 = c(484L, 599L, 288L, 434L, 225L, 352L), Int.Prev.Est.5 = c(477L, 428L, 297L, 344L, 230L, 293L)), .Names = c("age", "sex", "Int.Prev.Est.1", "Int.Prev.Est.2", "Int.Prev.Est.3", "Int.Prev.Est.4", "Int.Prev.Est.5"), row.names = c("93110", "93610", "94110", "94610", "95110", "95610"), class = "data.frame") I am wondering whether this is really feasible with reshape. Thanks for any hint. Best, stefan __ 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] reshape from wide to long, ordering of "varying"
Thanks a lot! Both solutions work great! On Thu, Oct 7, 2010 at 7:19 PM, Gabor Grothendieck wrote: > On Thu, Oct 7, 2010 at 1:05 PM, stefan.d...@gmail.com > wrote: >> Hello, >> I have data in the following form >> >> age sex Int.Prev.Est.1 Int.Prev.Est.2 Int.Prev.Est.3 >> Int.Prev.Est.4 Int.Prev.Est.5 >> 93110 93 0 23.75482 57.86592 9.755003 >> 4.343534 4.280714 >> 93610 93 1 53.36475 39.47247 4.381618 >> >> and want to get it in the form: >> >> age sex cat Int.Prev.Est >> 93 0 1 23.75482 >> 93 0 2 57.86592 >> 93 0 3 9.755003 >> 93 0 4 4.343534 >> () > > Try this: > > reshape(UK.INT, dir = "long", idvar = 1:2, varying = list(3:7), > v.names = "Int.Prev.Est", timevar = "cat") > > > -- > Statistics & Software Consulting > GKX Group, GKX Associates Inc. > tel: 1-877-GKX-GROUP > email: ggrothendieck at 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] Decision Trees /Decision Analysis with R?
Hello, this question is a bit out of the blue. I am a big R fan and user and in my new job I do some decision modeling (mostly health economics). For that decision trees are often used (I guess the most classic example is the investment decision A, B, and C with different probabilities, what is the expected payoff). We use a specialized software called TreeAge that some might know. The basic setup of such simulations is actually very simple and I guess useful in many fields. So I was wondering whether there is already a package out there in R that is doing such a thing? Thanks for any hints! Best, Stefan PS (By decision tree I don't mean cluster-like analysis of a data set splitting by identifying decision nods, but the other way around: I have decision nodes, what is my expected outcome.) __ 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] Decision Trees /Decision Analysis with R?
Thank you so much for reply. But I am looking for the exact opposite. I do not have a data set which I want to partition. But already a sequence/tree-like set of decision rules and with which I want to simulate what is my expected outcome/pay-off given a particular scenario. As far as I understand it, those packages could calculate the expected outcome AFTER having fit them to a particular data set and not construct a "synthetic" tree with exogenously defined decision nods/rules. Or am I wrong? Thanks and best, Stefan On Wed, Jun 8, 2011 at 2:03 PM, Jonathan Daily wrote: > See packages rpart, randomForest, party. > > Also, typing "R Decision Trees" produced good google results. > > http://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=R+Decision+Trees > > On Wed, Jun 8, 2011 at 7:02 AM, stefan.d...@gmail.com > wrote: >> Hello, >> >> this question is a bit out of the blue. >> >> I am a big R fan and user and in my new job I do some decision >> modeling (mostly health economics). For that decision trees are often >> used (I guess the most classic example is the investment decision A, >> B, and C with different probabilities, what is the expected payoff). >> We use a specialized software called TreeAge that some might know. >> The basic setup of such simulations is actually very simple and I >> guess useful in many fields. So I was wondering whether there is >> already a package out there in R that is doing such a thing? >> >> Thanks for any hints! >> Best, >> Stefan >> >> PS >> (By decision tree I don't mean cluster-like analysis of a data set >> splitting by identifying decision nods, but the other way around: I >> have decision nodes, what is my expected outcome.) >> >> __ >> 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. >> > > > > -- > === > Jon Daily > Technician > === > #!/usr/bin/env outside > # It's great, trust me. > __ 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] Decision Trees /Decision Analysis with R?
TreeAge works just fine. But its commercial, thats all... On Wed, Jun 8, 2011 at 6:17 PM, Graham Smith wrote: > Jon, > >> So TreeAge fits models but won't predict from them? That seems like >> bizarre behavior. > > Nothing bizarre about TreeAge, just a different tool in a different > disicpline. > > http://en.wikipedia.org/wiki/Decision_tree > > > Graham > __ 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] Decision Trees /Decision Analysis with R?
thanks for the hint, Kjetil. That looks more like what I am looking for. Thanks for all your mails! Best, Stefan On Wed, Jun 8, 2011 at 11:25 PM, Kjetil Halvorsen wrote: > see inline below. > > On Wed, Jun 8, 2011 at 12:37 PM, Anupam wrote: >> It is difficult for someone from a statistical frame of mind to understand >> what this is about --- you need to think a bit differently. It is mostly a >> simulation and decision analysis, with some use of statistical functions to >> draw random samples to simulate the fact that outcome of interest can take >> any value from a known or unknown distribution. For example, you may be >> comparing two interventions and a do-nothing decision to improve some health >> outcome of interest. The decision maker is interested in *relative* >> effectiveness and costs of the interventions to improve the outcome of >> interest. You have results from published literature that you can use as >> inputs into a simulation exercise to compare relative costs and >> benefits/effectiveness of the three options. A small decision tree can be >> easily simulated in a spreadsheet; for long trees with many decision nodes >> it is useful to have a specialized software. There are some Excel plugins >> that are sold about $100. Others are more expensive. >> >> I think R is not well suited for this kind of work. A decision analysis > > Not necessarily! A desicion tree model is a kind of graphical model. > See the CRAN task view gR > (graphical models in R) and maybe ask on the special interest mailing > list R-sig-gR > > kjetil > >> package in R may require user to write code like the one used in LaTeX or >> related programs (Metapost) to draw graphs of trees (e.g. complicated >> organizational trees, or hierarchical trees). However, in such a package >> there can be useful outputs, measures and graphs generated by R using code >> that may already exist for other packages. >> >> Look up journal "Medical Decision Making" to know what is being discussed. >> This method is used extensively in medicine and public health to study >> decisions. It even uses MCMC, though with a different flavor --- it may even >> be a different kind of food. >> >> Anupam. >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >> Behalf Of Jonathan Daily >> Sent: Wednesday, June 08, 2011 7:47 PM >> To: stefan.d...@gmail.com >> Cc: r-help@r-project.org >> Subject: Re: [R] Decision Trees /Decision Analysis with R? >> >> So TreeAge fits models but won't predict from them? That seems like bizarre >> behavior. I suppose I would recommend, then, looking at the source code from >> the aforementioned packages for how they store their split data. It sounds >> like you would have to write code to hack TreeAge outputs into another >> packages' format (e.g. look at ?rpart.object). >> >> Sorry I couldn't help more, >> Jon >> >> On Wed, Jun 8, 2011 at 9:47 AM, stefan.d...@gmail.com >> wrote: >>> Thank you so much for reply. But I am looking for the exact opposite. >>> >>> I do not have a data set which I want to partition. But already a >>> sequence/tree-like set of decision rules and with which I want to >>> simulate what is my expected outcome/pay-off given a particular >>> scenario. >>> As far as I understand it, those packages could calculate the expected >>> outcome AFTER having fit them to a particular data set and not >>> construct a "synthetic" tree with exogenously defined decision >>> nods/rules. Or am I wrong? >>> >>> >>> Thanks and best, >>> Stefan >>> >>> >>> >>> On Wed, Jun 8, 2011 at 2:03 PM, Jonathan Daily >> wrote: >>>> See packages rpart, randomForest, party. >>>> >>>> Also, typing "R Decision Trees" produced good google results. >>>> >>>> http://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=R+Decisi >>>> on+Trees >>>> >>>> On Wed, Jun 8, 2011 at 7:02 AM, stefan.d...@gmail.com >>>> wrote: >>>>> Hello, >>>>> >>>>> this question is a bit out of the blue. >>>>> >>>>> I am a big R fan and user and in my new job I do some decision >>>>> modeling (mostly health economics). For that decision trees are >>>>> often used (I guess the most classic example is the investment >>>>> decision A, B, and C with
[R] strange behavior of RODBC and/or ssconvert
Dear All, I have the following problem when reading files (a lot of them) in the spreadsheetML format into R. The spreadsheetML format is an xml format to allow easy import of multisheet data in Excel. As far as I can see, a direct import into R (using the XML package) is not feasible. I use the software ssconvert (included in Gnumeric) and call it from R. It converts the spreadsheetML into xls format. When I now import the newly created xls-file using RODBC package, the last row in each sheet is missing. However, when I open the xls-file the last row is present (hence, ssconvert doesn't delete it). When I now save the xls-file, and import it again using the RODB package, the data is now complete. Any idea what to do about that? My main problem is to get the spreadsheetML into R so I tried other file formats to which ssconvert can convert to, but only excel supports multisheets. Best, Stefan Example code: system(paste('ssconvert "excelcohortdata_men_reference scenario.xml" "excelcohortdata_men_reference scenario22.xls"')) channel1<-odbcConnectExcel("excelcohortdata_men_reference scenario10.xls") odbcGetInfo(channel1) sqlTables(channel1) sqlQuery(channel1, "select * from \"age 9in 2010$\"" ) sqlFetch(chanel1, "age 9in 2010"" __ 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] constructing a contingency table (ftable, table)
Dear all, an hopefully quick table question. I have the following data: Two objects that are 2*9 matrix with nine column names (Dis1, ..., Dis9) and the row names (2010,2020). The content are frequencies (numeric). In want to create a table that is along the lines of ftable(UCBAdmissions) and should looks like this: Dis1 | ...| Dis9 2010|2020||2010|2020 (first row,first column is the value of Dis1 in 2010 from first object)| (first row,second column is the value of Dis1 in 2020 from first object)| (second row,first column is the value of Dis1 in 2010 from second object)| (first row,second column is the value of Dis1 in 2020 from second object)| and so on So basically what ftable does. But I do not understand how I can turn my two matrices (which already contain the frequencies) into the appropriate table object (if thats the way to go). Thanks and best, Stefan __ 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] constructing a contingency table (ftable, table)
Hi Joris, thanks for your help. I just had to alter it slightly (basically just transposing): tmp <- array(rbind(t(test),t(test2)), dim=c(9,2,2), dimnames=list(colnames(test),rownames(test),c("Test","Test2"))) ftable(tmp) Thanks again! Best, Stefan On Tue, Jun 8, 2010 at 5:46 PM, Joris Meys wrote: > I could get something close to what you asked using a little hack, > emulating a table using an array based on your two matrices : > > test <- matrix(rpois(18,10),ncol=9,nrow=2) > colnames(test) <- paste("Dis",1:9,sep="") > rownames(test) <- c("2010","2020") > > test2 <- matrix(rpois(18,10),ncol=9,nrow=2) > colnames(test2) <- paste("Dis",1:9,sep="") > rownames(test2) <- c("2010","2020") > > tmp <- array(cbind(test,test2), > dim=c(2,9,2), > dimnames=list(rownames(test),colnames(test),c("Test","Test2"))) > > ftable(as.table(tmp)) > > Cheers > Joris > > On Tue, Jun 8, 2010 at 3:42 PM, stefan.d...@gmail.com > wrote: >> Dear all, >> an hopefully quick table question. >> >> I have the following data: >> Two objects that are 2*9 matrix with nine column names (Dis1, ..., >> Dis9) and the row names (2010,2020). The content are frequencies >> (numeric). >> >> In want to create a table that is along the lines of >> ftable(UCBAdmissions) and should looks like this: >> Dis1 | ...| Dis9 >> 2010|2020||2010|2020 >> (first row,first column is the value of Dis1 in 2010 from first >> object)| (first row,second column is the value of Dis1 in 2020 from >> first object)| >> (second row,first column is the value of Dis1 in 2010 from second >> object)| (first row,second column is the value of Dis1 in 2020 from >> second object)| >> and so on >> >> So basically what ftable does. But I do not understand how I can turn >> my two matrices (which already contain the frequencies) into the >> appropriate table object (if thats the way to go). >> >> Thanks and best, >> Stefan >> >> __ >> 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. >> > > > > -- > Joris Meys > Statistical consultant > > Ghent University > Faculty of Bioscience Engineering > Department of Applied mathematics, biometrics and process control > > tel : +32 9 264 59 87 > joris.m...@ugent.be > --- > Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php > __ 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] Decision Trees or Markov Models for Cost Effectiveness
Hi Noah, I did ask basically the same question about a year ago and there wasn't anything around (http://tolstoy.newcastle.edu.au/R/e14/help/11/06/3651.html) Although I agree that R would be very suitable for this kind of calculations exist. I guess one reason is that a decision tree is not really a branch of statistics. The advanced user of a decision tree will more likely program something in Excel. If you find something, please let us know. Best, Stefan On Tue, Jun 12, 2012 at 12:28 AM, Noah Silverman wrote: > Hello, > > I was just assigned to perform a cost effectiveness study in healthcare. We > are studying the cost effectiveness of a proposed diagnostic vs. current > screening procedures. > > One of the team members suggest a commercial software package called "TreeAge > Pro". Looking at the description, it appears to be a nice GUI to some very > simple models that could be easily constructed in R. > > Are there any packages in R for this type of analysis? > Additionally, does anyone have any suggestions in general regarding doing > this type of analysis in R? > > Thank You, > > -- > Noah Silverman > UCLA Department of Statistics > 8117 Math Sciences Building > Los Angeles, CA 90095 > > > [[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] paste together object names to pass it on to a function
Hello, I have a maybe trivial question, but I simply don't understand well enought how to work with text/strings: I have a rather compelx data structure, a big list with several sub-lists/dataframes and for certain calculations (which I do in loops), I only need a certain group of sub-lists/dataframes, which I want to specify with a name vector and paste together the object name and pass it on to a function. Here an (hopefully) instructive example #Data Example gnuff<-list() gnuff$IHD$LE<-66 gnuff$LUNG$LE <-55 #This is the list, where I collect data for different diseases at the second level of the list #Now I want to do calcualtions just for these two diseases and the sub-list "LE" within these diseases nam <- c("LUNG","IHD") for(i in 1:2) x[i] <- paste("gnuff",nam[i],"LE",sep="$") /2 x #So I try to paste the name of the object which I mean (gnuff$IHD$LEand gnuff$LUNG$LE, respectivly), but R treats them as a string and not as the name of an object. # I tried seveal commands to make it treat like an object name (the get() looked most promising), but so far to no avail #commands I have tried j <- eval(paste("gnuff",nam[i],"LE",sep="$")) parse(paste("gnuff",nam[i],sep="$")) quote(paste("gnuff",nam[i],sep="$")) get(paste("gnuff",nam[i],sep="$")) Anybody any hints where to look? Thanks and have a great weekend! Best, Stefan __ 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] paste together object names to pass it on to a function
Hello y'll, thanks a lot for your hints. The easiest solution was the one from Jim, using "[[" whose true function I did not realize fully. About apply and the sorts: I agree that if you get them to work the are much faster and yield nice, compact code. But I have never fully understood the inner workings and I think the provided examples (even in most books) rush over them. If I use them successfully, it is - at least in my case - more the result of trial and error and this does not make them a weapon of first choice. If someone has a good hint where they are explained accessibly, please share it. Thanks again and have a great week! Best, Stefan On Fri, Jan 30, 2009 at 7:54 PM, David Winsemius wrote: > Perhaps this will help: > > #Data Example > gnuff<-list() > gnuff$IHD$LE<-66 > gnuff$LUNG$LE <-55 > > #This is the list, where I collect data for different diseases at the > #second level of the list > #Now I want to do calcualtions just for these two diseases and the > #sub-list "LE" within these diseases > > nam <- c("LUNG","IHD") > > for(i in nam) print(gnuff[[i]]) # use the elements of nam as the index > values > > # the lack of output from an evaluation done within the for-loop might be > one of Burns' Infernal examples. > # here's see one of my "mistakes": for(i in nam) (gnuff[[i]]) > #---returns a list--- > #$LE > #[1] 55 > > #$LE > #[1] 66 > > #--- > for(i in nam) print(gnuff[[i]]$LE) #use list extraction to get the values > #[1] 55 > #[1] 66 > > > > On Jan 30, 2009, at 12:06 PM, stefan.d...@gmail.com wrote: > >> Hello, >> I have a maybe trivial question, but I simply don't understand well >> enought how to work with text/strings: >> >> I have a rather compelx data structure, a big list with several >> sub-lists/dataframes and for certain calculations (which I do in >> loops), I only need a certain group of sub-lists/dataframes, which I >> want to specify with a name vector and paste together the object name >> and pass it on to a function. >> >> Here an (hopefully) instructive example >> >> #Data Example >> gnuff<-list() >> gnuff$IHD$LE<-66 >> gnuff$LUNG$LE <-55 >> >> #This is the list, where I collect data for different diseases at the >> second level of the list >> #Now I want to do calcualtions just for these two diseases and the >> sub-list "LE" within these diseases >> >> >> nam <- c("LUNG","IHD") >> >> for(i in 1:2) >> x[i] <- paste("gnuff",nam[i],"LE",sep="$") /2 >> x >> >> #So I try to paste the name of the object which I mean >> (gnuff$IHD$LEand gnuff$LUNG$LE, respectivly), but R treats them as a >> string and not as the name of an object. >> # I tried seveal commands to make it treat like an object name (the >> get() looked most promising), but so far to no avail >> >> #commands I have tried >> j <- eval(paste("gnuff",nam[i],"LE",sep="$")) >> parse(paste("gnuff",nam[i],sep="$")) >> quote(paste("gnuff",nam[i],sep="$")) >> get(paste("gnuff",nam[i],sep="$")) >> >> Anybody any hints where to look? >> Thanks and have a great weekend! >> Best, >> Stefan >> >> __ >> 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.