[R] mzR and Rcpp version bug
Good morning everyone, I'm having the following error when I try to load the *mzR* libary. Does someone have a clue where to search for a solution. I tried to re-install *mzR *and *Rcpp* also, but with no effect. - library(mzR) Lade nötiges Paket: Rcpp Error : .onLoad in loadNamespace() für 'mzR' fehlgeschlagen, Details: Aufruf: value[[3L]](cond) Fehler: failed to load module Ramp from package mzR kann Vektor der Größe 13.2 GB nicht allozieren Zusätzlich: Warnmeldungen: 1: In fun(libname, pkgname) : mzR has been built against a different Rcpp version than is installed on your system. This might lead to errors when loading mzR. If you encounter such issues, please send a report, including the output of sessionInfo() to the Bioc mailing list -- http://www.bioconductor.org/help/mailing-list. 2: In Module(m, pkg, mustStart = TRUE) : Reached total allocation of 8183Mb: see help(memory.size) 3: In Module(m, pkg, mustStart = TRUE) : Reached total allocation of 8183Mb: see help(memory.size) 4: In Module(m, pkg, mustStart = TRUE) : Reached total allocation of 8183Mb: see help(memory.size) 5: In Module(m, pkg, mustStart = TRUE) : Reached total allocation of 8183Mb: see help(memory.size) Fehler: Laden von Paket oder Namensraum für 'mzR' fehlgeschlagen sessionInfo() R version 3.0.3 (2014-03-06) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] LC_TIME=German_Germany.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Rcpp_0.11.1 loaded via a namespace (and not attached): [1] Biobase_2.20.1 BiocGenerics_0.6.0 parallel_3.0.3 - Best Regards, László-András Zsurzsa Master of Informatics Student, Technical University Munich, Germany [[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] Shiny - can one create one RUN button?
Maybe this link can help you: http://rstudio.github.io/shiny/tutorial/#more-widgets This is an example with submit button. - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Fri, Sep 13, 2013 at 12:21 AM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! I am learning to use Shiny. Imagine my ui.r file contains two different inputs that I can change: sidebarPanel( numericInput(input1, My input 1:, 5), numericInput(input2, My input 2:, 10) ) And I am generating (in server.r file) the sum of those two using reactive({... If I change just one of the inputs, I immediately get the changed result - because the whole expression is reactive. Question: is there any way to delay the production of the output until one wants it to be produced (i.e., only after one selected all the correct inputs needed) and have something like a RUN button? Thank you! -- Dimitri Liakhovitski [[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] XLSX package + Excel creation question
http://stackoverflow.com/questions/18511249/excel-cell-coloring-using-xlsx This is the initial post on stackoverflow. Please look at this maybe I'm clearer here. Thank you in advance, - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Fri, Aug 30, 2013 at 3:48 PM, jim holtman jholt...@gmail.com wrote: You can also look at the XLConnect package. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Aug 29, 2013 at 9:40 AM, Zsurzsa Laszlo zsurzsalas...@gmail.com wrote: I understand you response but it does not solve the problem. I'am aware that one can simply color every cell in an excel file by using his own algorithm. The question was if I can write my data to a *single* cells and use different formatting for every piece of data. - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 3:36 PM, Rainer Hurling rhur...@gwdg.de wrote: Am 29.08.2013 15:03 (UTC+1) schrieb Zsurzsa Laszlo: First of all thank you for the quick resposen. I know I can color and set up every cell. I will take a look again * CellStyle* but is it possbile for example to write an array to a single cell that has different colors for some data. Basically the color depends on the data. As far as I know there is no ready to use functionality to mask groups of selected cells. You have to write your own function, which selects the right cells and changes their style with setCellStyle(cell, cellStyle). Some hints are given in the examples section of ?CellStyle. - - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 2:55 PM, Rainer Hurling rhur...@gwdg.de wrote: Am 29.08.2013 12:08 (UTC+1) schrieb Zsurzsa Laszlo: Dear R users, I have a question about the xlsx package. It's possible to create excel files and color cells and etc. yes, with package xlsx you can colourize you data sheets, even the fonts. See for example ?CellStyle . A good demonstration of the capabilities is on http://tradeblotter.wordpress.com/2013/05/02/writing-from-r-to-excel-with-xlsx/ My question would be that is it possible to color only some part of the data hold in a cell. Let's assume I've got the following data : 167,153,120,100 and I want to color to red everything that is bigger then 120. How can I achive this using R. Example file setup with a few lines in attachment. (SEL_MASS column can be used for example) Attachment missing ... HTH, Rainer Thank you in advance, - - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - [[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. [[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] XLSX package + Excel creation question
Thank you for the reply, I wount post any other link anymore. I did not know it's not allowed. - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Wed, Sep 4, 2013 at 1:22 PM, Keith Jewell keith.jew...@campdenbri.co.ukwrote: I'll skip over the courtesy implications of double posting/pointing to stackoverflow. The stackoverflow thread makes it look as if you need to learn more Excel. Do you really not know what an Excel template is? It sounds as if you want what Excel calls conditional formatting which you can specify as custom number formats, see http://www.ozgrid.com/Excel/ **CustomFormats.htm http://www.ozgrid.com/Excel/CustomFormats.htm. Excel's help on custom number formats says: To specify number formats that will be applied only if a number meets a condition that you specify, enclose the condition in square brackets. The condition consists of a comparison operator (comparison operator: A sign that is used in comparison criteria to compare two values. Operators include: = Equal to, Greater than, Less than, = Greater than or equal to, = Less than or equal to, and Not equal to.) and a value. For example, the following format displays numbers that are less than or equal to 100 in a red font and numbers that are greater than 100 in a blue font. [Red][=100];[Blue][100] -- R package xlsx allows such formats (?DataFormat) as does R package XLConnect (?setDataFormat). HTH Keith J On 04/09/2013 09:57, Zsurzsa Laszlo wrote: http://stackoverflow.com/**questions/18511249/excel-cell-** coloring-using-xlsxhttp://stackoverflow.com/questions/18511249/excel-cell-coloring-using-xlsx This is the initial post on stackoverflow. Please look at this maybe I'm clearer here. Thank you in advance, --**--** - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - --**--** - On Fri, Aug 30, 2013 at 3:48 PM, jim holtmanjholt...@gmail.com wrote: You can also look at the XLConnect package. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Thu, Aug 29, 2013 at 9:40 AM, Zsurzsa Laszlozsurzsalas...@gmail.com* * wrote: I understand you response but it does not solve the problem. I'am aware that one can simply color every cell in an excel file by using his own algorithm. The question was if I can write my data to a *single* cells and use different formatting for every piece of data. --**--** - - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - --**--** - On Thu, Aug 29, 2013 at 3:36 PM, Rainer Hurlingrhur...@gwdg.de wrote: Am 29.08.2013 15:03 (UTC+1) schrieb Zsurzsa Laszlo: First of all thank you for the quick resposen. I know I can color and set up every cell. I will take a look again * CellStyle* but is it possbile for example to write an array to a single cell that has different colors for some data. Basically the color depends on the data. As far as I know there is no ready to use functionality to mask groups of selected cells. You have to write your own function, which selects the right cells and changes their style with setCellStyle(cell, cellStyle). Some hints are given in the examples section of ?CellStyle. --**--** - - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - --**--** - On Thu, Aug 29, 2013 at 2:55 PM, Rainer Hurlingrhur...@gwdg.de wrote: Am 29.08.2013 12:08 (UTC+1) schrieb Zsurzsa Laszlo: Dear R users, I have a question about the xlsx package. It's possible to create excel files and color cells and etc. yes, with package xlsx you can colourize you data sheets, even the fonts. See for example ?CellStyle . A good demonstration of the capabilities is on http://tradeblotter.wordpress.**com/2013/05/02/writing-from
Re: [R] Help If
Hey if (( (1==1) (2==2) ) || (3==3)) { print( hello world) } - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 11:11 AM, Zsurzsa Laszlo zsurzsalas...@gmail.comwrote: Hey if (( (1==1) (2==2) ) || (3==3)) { print( hello world) } - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 10:16 AM, Mª Teresa Martinez Soriano teresama...@hotmail.com wrote: Hi to everyone and sorry for my question, I would like to use IF in an example like this: If((condition1 and condition2) Or (condition 3 and condition4)) {print uhvef} BUt I don´t know how to write it correctly, Thanks in advance [[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.
[R] XLSX package + Excel creation question
Dear R users, I have a question about the xlsx package. It's possible to create excel files and color cells and etc. My question would be that is it possible to color only some part of the data hold in a cell. Let's assume I've got the following data : 167,153,120,100 and I want to color to red everything that is bigger then 120. How can I achive this using R. Example file setup with a few lines in attachment. (SEL_MASS column can be used for example) Thank you in advance, - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - __ 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] XLSX package + Excel creation question
First of all thank you for the quick resposen. I know I can color and set up every cell. I will take a look again * CellStyle* but is it possbile for example to write an array to a single cell that has different colors for some data. Basically the color depends on the data. - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 2:55 PM, Rainer Hurling rhur...@gwdg.de wrote: Am 29.08.2013 12:08 (UTC+1) schrieb Zsurzsa Laszlo: Dear R users, I have a question about the xlsx package. It's possible to create excel files and color cells and etc. yes, with package xlsx you can colourize you data sheets, even the fonts. See for example ?CellStyle . A good demonstration of the capabilities is on http://tradeblotter.wordpress.com/2013/05/02/writing-from-r-to-excel-with-xlsx/ My question would be that is it possible to color only some part of the data hold in a cell. Let's assume I've got the following data : 167,153,120,100 and I want to color to red everything that is bigger then 120. How can I achive this using R. Example file setup with a few lines in attachment. (SEL_MASS column can be used for example) Attachment missing ... HTH, Rainer Thank you in advance, - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - [[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] XLSX package + Excel creation question
I understand you response but it does not solve the problem. I'am aware that one can simply color every cell in an excel file by using his own algorithm. The question was if I can write my data to a *single* cells and use different formatting for every piece of data. - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 3:36 PM, Rainer Hurling rhur...@gwdg.de wrote: Am 29.08.2013 15:03 (UTC+1) schrieb Zsurzsa Laszlo: First of all thank you for the quick resposen. I know I can color and set up every cell. I will take a look again * CellStyle* but is it possbile for example to write an array to a single cell that has different colors for some data. Basically the color depends on the data. As far as I know there is no ready to use functionality to mask groups of selected cells. You have to write your own function, which selects the right cells and changes their style with setCellStyle(cell, cellStyle). Some hints are given in the examples section of ?CellStyle. - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 2:55 PM, Rainer Hurling rhur...@gwdg.de wrote: Am 29.08.2013 12:08 (UTC+1) schrieb Zsurzsa Laszlo: Dear R users, I have a question about the xlsx package. It's possible to create excel files and color cells and etc. yes, with package xlsx you can colourize you data sheets, even the fonts. See for example ?CellStyle . A good demonstration of the capabilities is on http://tradeblotter.wordpress.com/2013/05/02/writing-from-r-to-excel-with-xlsx/ My question would be that is it possible to color only some part of the data hold in a cell. Let's assume I've got the following data : 167,153,120,100 and I want to color to red everything that is bigger then 120. How can I achive this using R. Example file setup with a few lines in attachment. (SEL_MASS column can be used for example) Attachment missing ... HTH, Rainer Thank you in advance, - - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - [[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] Help R
Do you have NA/NAN in your data set? If yes our check with an IF or substitute them with a value that fits your need. I hope I understood correctly your problem. - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Thu, Aug 29, 2013 at 3:49 PM, Mª Teresa Martinez Soriano teresama...@hotmail.com wrote: Hi to everyone, I would like to replace some values in a data.frame (D) str(D) 'data.frame': 116 obs. of 10 variables: $ X. : int 1108 1591 3408 3872 5823 8099 10640 12600 14680 14698 ... $ media : num 22 86.6 807 103.2 73 ... $ IE.2003: num 32 92 166 237 161 ... $ IE.2004: num 63 122.8 290 117.8 73.6 ... $ IE.2005: num 60 277 302 154 134 ... $ IE.2006: num 39 87 322 113 70 ... $ IE.2007: num 4 95 621 116 80 ... $ IE.2008: num 8 94 1071 90 74 ... $ IE.2009: num 16 81 1301 94 69 ... $ IE.2010: num 5 76 1225 1911 72 ... D X. media IE.2003 IE.2004 IE.2005 IE.2006 IE.2007 IE.2008 IE.2009 IE.2010 1 1108 22.032.063.060.0 39 4.0 8 16 5.0 2 1591 86.692.0 122.8 276.6 8795.0 94 8176.0 3 3408 807.0 166.0 290.0 302.0 322 621.01071 1301 1225.0 4 3872 103.25000 237.2 117.8 154.4 113 116.0 90 94 1911.2 5 5823 73.0 160.673.6 133.6 7080.0 74 6972.0 6 8099 125.16667 169.0 206.0 196.0 161 150.0 94 7278.0 7 10640 67.3 494.8 168.2 424.8 476 670.6 74 7751.0 8 12600 2417.0 1958.0 1871.0 1960.02383 2453.02506 2758 2442.0 9 14680 38.0 142.246.030.0 61 404.0 42 19 243.8 10 14698 698.16667 505.0 482.0 553.0 664 847.0 800 679 646.0 WHat I really want to do is: for( i in 1: nrow(D)) { for( j in 5:ncol(D)) { D[((D[i,j]/D[i,2])1.5)]15999)]-100 } } Error en `[-.data.frame`(`*tmp*`, (D[i, j] 15999), value = 1e+06) : missing values are not allowed in subscripted assignments of data frames [[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] R Language Newbie
Can you specify you're task? I don't understand totally what you need to do? You're already getting odd numbers with : seq(1,100,by=2) - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Wed, Aug 28, 2013 at 12:18 AM, arun smartpink...@yahoo.com wrote: Hi, set.seed(29) myVector- rnorm(100) seq(1,100,by=2) # [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 #[26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 myVector[seq(1,100,by=2)] rev(myVector) sum(myVector0) #[1] 46 #or table(myVector0) # #FALSE TRUE # 5446 A.K. Hey guys, this is my first week taking R language courses and I'm having trouble with this assignment. I think I got the hang of it to an extent but was wondering if I could get help on one tiny part of my assignment. How can I get odd numbers from the vector I've created? To show you guys I've done the majority of my homework by myself I've included screenshots. __ 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] R Language Newbie
Hello, #3 myVector - c(1:100) oddVector - myVector[c(1:100) %% 2 == 1] odd - myVector[c(1:100) %% 2 == 1] identical( odd, seq(1,100,by=2)) gives me FALSE #3 Is this what you suggested? - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Wed, Aug 28, 2013 at 2:17 PM, arun smartpink...@yahoo.com wrote: HI, I was talking about another method to get the same result: myVector[1:100%%2==1] identical(myVector[1:100%%2==1],myVector[seq(1,100,by=2)]) #[1] TRUE Hope it helps. A.K. From: Zsurzsa Laszlo zsurzsalas...@gmail.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Wednesday, August 28, 2013 5:21 AM Subject: Re: [R] R Language Newbie Can you specify you're task? I don't understand totally what you need to do? You're already getting odd numbers with : seq(1,100,by=2) -- László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Wed, Aug 28, 2013 at 12:18 AM, arun smartpink...@yahoo.com wrote: Hi, set.seed(29) myVector- rnorm(100) seq(1,100,by=2) # [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 #[26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 myVector[seq(1,100,by=2)] rev(myVector) sum(myVector0) #[1] 46 #or table(myVector0) # #FALSE TRUE # 5446 A.K. Hey guys, this is my first week taking R language courses and I'm having trouble with this assignment. I think I got the hang of it to an extent but was wondering if I could get help on one tiny part of my assignment. How can I get odd numbers from the vector I've created? To show you guys I've done the majority of my homework by myself I've included screenshots. __ 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] R Language Newbie
Hey Sure sorry for the mistake, That was i meant to be also. I this what you were searching? - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Wed, Aug 28, 2013 at 3:03 PM, arun smartpink...@yahoo.com wrote: HI, 'odd' and 'oddVector' are the same. identical(odd,oddVector) #[1] TRUE identical(odd,myVector[seq(1,100,by=2)]) myVector# #[1] TRUE A.K. From: Zsurzsa Laszlo zsurzsalas...@gmail.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Wednesday, August 28, 2013 8:58 AM Subject: Re: [R] R Language Newbie Hello, #3 myVector - c(1:100) oddVector - myVector[c(1:100) %% 2 == 1] odd - myVector[c(1:100) %% 2 == 1] identical( odd, seq(1,100,by=2)) gives me FALSE #3 Is this what you suggested? - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Wed, Aug 28, 2013 at 2:17 PM, arun smartpink...@yahoo.com wrote: HI, I was talking about another method to get the same result: myVector[1:100%%2==1] identical(myVector[1:100%%2==1],myVector[seq(1,100,by=2)]) #[1] TRUE Hope it helps. A.K. From: Zsurzsa Laszlo zsurzsalas...@gmail.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Wednesday, August 28, 2013 5:21 AM Subject: Re: [R] R Language Newbie Can you specify you're task? I don't understand totally what you need to do? You're already getting odd numbers with : seq(1,100,by=2) -- László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - On Wed, Aug 28, 2013 at 12:18 AM, arun smartpink...@yahoo.com wrote: Hi, set.seed(29) myVector- rnorm(100) seq(1,100,by=2) # [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 #[26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 myVector[seq(1,100,by=2)] rev(myVector) sum(myVector0) #[1] 46 #or table(myVector0) # #FALSE TRUE # 5446 A.K. Hey guys, this is my first week taking R language courses and I'm having trouble with this assignment. I think I got the hang of it to an extent but was wondering if I could get help on one tiny part of my assignment. How can I get odd numbers from the vector I've created? To show you guys I've done the majority of my homework by myself I've included screenshots. __ 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.
[R] PubChem Request Search Script
Dear all, The question would be: I would love to get information and match names of different chemistry compounds. A compound looks like this. Link: http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=2 The task is the following: 1. You input a name via R to the link, then a database searches a similar or the same compound for you. (you autotype the name in the input field left to the search button.) 2. parse the information that you get back. (This I can do already via R) Thank you for you're attention, - - László-András Zsurzsa,- - Msc. Infromatics, Technical University Munich, Germany - - Scientific Employee, TUM - - [[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] readLines() problem-error
Hello everyone, I have my program like this: while (length(oneLine - readLines(con, n = 1, warn = FALSE)) 0) { # here I process the line I read } The problem is it gives me different output every time. I get a problem/ error like: Closing unused connection (con). Sadly I can't provide the file because it's ,ore then a GB. Thank you in advance, --- - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, - --- [[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] Help with installing a .tar.gz package on windows
have you checked the bit version !? Which R do you use? 32 or 64 bit? --- - László-András Zsurzsa, - - Msc. Infromatics, Technical University Munich, - --- On Mon, Jul 8, 2013 at 2:15 AM, Lucy Leigh lucy.le...@newcastle.edu.auwrote: Hi, I have a source package that isn't available as a windows zip file. Can anyone explain to me how I can install this on my windows R platform? When I use the following code: install.packages(PReMiuM_3.0.21.tar.gz, type = source) I get this error message: * installing *source* package 'PReMiuM' ... ** libs *** arch - i386 ERROR: compilation failed for package 'PReMiuM' * removing 'C:/Program Files/R/R-3.0.1/library/PReMiuM' Warning messages: 1: running command 'C:/PROGRA~1/R/R-30~1.1/bin/x64/R CMD INSTALL -l C:\Program Files\R\R-3.0.1\library PReMiuM_3.0.21.tar.gz' had status 1 2: In install.packages(PReMiuM_3.0.21.tar.gz, type = source) : installation of package PReMiuM_3.0.21.tar.gz had non-zero exit status Thanks for any help anyone can give me, Lucy __ 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.
[R] String based chemical name identification
The problem is the following: I have two big databases one look like this: 2-Methyl-4-trimethylsilyloxyoct-5-yne Benzoic acid, methyl ester Benzoic acid, 2-methyl-, methyl ester Acetic acid, phenylmethyl ester 2,7-Dimethyl-4-trimethylsilyloxyoct-7-en-5-yne etc. The second one looks like this: Name: D-Tagatose 1,6-bisphosphate Name: 1-Phosphatidyl-D-myo-inositol;: 1-Phosphatidyl-1D-myo-inositol;: 1-Phosphatidyl-myo-inositol;: Phosphatidyl-1D-myo-inositol;: (3-Phosphatidyl)-1-D-inositol;: 1,2-Diacyl-sn-glycero-3-phosphoinositol;: Phosphatidylinositol Name: Androstenedione;: Androst-4-ene-3,17-dione;: 4-Androstene-3,17-dione Name: Spermine;: N,N'-Bis(3-aminopropyl)-1,4-butanediamine Name: H+;: Hydron Name: 3-Iodo-L-tyrosine etc. Both of them have more then 3000 lines. Matching their name by hand is not an option because I don't know chemistry. *Possible solution I came up with*: Go through all the names of the first database and then try to match with the other one. I'm using *regexec *and *strsplit *functions for the matching. Basically I split the name into small chunks and try to get some hit in the other database. I can supply code If needed but I did not want to spam in the first mail. Any solution is welcome! It can be in pseudo-cod also or in any type of logical arguing. It does not matter. Laszlo-Andras Zsurzsa Msc. Informatics, Technical University Munchen [[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] altering identity column
Hi there, I have a huge dataframe containing 70,000 observations. I have filtered this dataframe (let it's name be transformed_dataframe) as I wanted to select only those observations which are greater than or equal to 60,001 regarding the very first identity column. So I have a transformed dataframe now including 10,000 obeservations (from 60,001 - to 70,000) and if you send head(transformed_dataframe) into R it looks like this: variable1 variable2 variable3 variable4 ... 60 001 ...... ... ... 60 002 ...... ... ... 60 003 ...... ... ... 60 004 ...... ... ... 60 005 ...... ... ... Sending tail(transformed_dataframe) into R it is going to be something like: variable1 variable2 variable3 variable4 ... 69 996 ...... ... ... 69 997 ...... ... ... 69 998 ... ... ... ... 69 999 ...... ... ... 70 000 ...... ... ... Now is there a quick way to alter this indexing of rows in case of my transformed_dataframe? I mean, I would like to get indices 1, 2, 3, etc... instead of 60 001, 60 002, 60 003 etc... So by sending head(transformed_dataframe) and tail(transformed_dataframe) I would like to see: variable1 variable2 variable3 variable4 ... 1 ......... ... 2 ......... ... 3 ......... ... 4 ......... ... 5 ......... ... and variable1 variable2 variable3 variable4 ... 9 996......... ... 9 997......... ... 9 998......... ... 9 999......... ... 10 000 ......... ... Thank you very much, best regards, Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] quantile function - I need only the quantile value itself
Hi, I am using the quantile function currently and I have just bumped into a little problem. I have a very small data frame something like this: small_df - c(7,3,4,7,1,10,12,1,12,4,4,8,6,11,9,10,4,13,3,9,6,5,2,10,7,14,2,7,10,10,7,8,2,11,3,10,11,3,11,14,12,7,6,11) small_df Now in the next step I would like to calculate the quantile value of the previous data frame at the probability of 95% the following way: quantile(small_df,probs=0.95) The result: 95% 12.85 Now I need to get only the number 12.85. I do not want to present the probability 95% here. Is there any possible way to tell the program to do so? Regards, Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] deleting the first two characters in each row of a factorized column
Hello, I'd like to ask you something again. I have a database and it has a column which looks like this one here: small_factor - factor(c(d_variable1,d_variable2,d_variable3)) small_factor Now the thing is that I would like to convert each element of this factorized column. Basically I want to rewrite the words in it without the first two characters: d and _ and I would like to get the followings as a result: variable1, variable2, variable3. Is there an easy way to do this? Thank you, Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] recalling different data frames (the way you do in Excel VB but now) in
Hello everyone, I'd like to ask you a question again, basically focusing on referring to different objects. Let's suppose we create the following databases this way: id -c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3) a -c(3,1,3,3,1,3,3,3,3,1,3,2,1,2,1,3,3,2,1,1,1,3,1,3,3,3,2,1,1,3) b -c(3,2,1,1,1,1,1,1,1,1,1,2,1,3,2,1,1,1,2,1,3,1,2,2,1,3,3,2,3,2) c -c(1,3,2,3,2,1,2,3,3,2,2,3,1,2,3,3,3,1,1,2,3,3,1,2,2,3,2,2,3,2) d -c(3,3,3,1,3,2,2,1,2,3,2,2,2,1,3,1,2,2,3,2,3,2,3,2,1,1,1,1,1,2) e -c(2,3,1,2,1,2,3,3,1,1,2,1,1,3,3,2,1,1,3,3,2,2,3,3,3,2,3,2,1,4) df -data.frame(id,a,b,c,d,e) df for (i in 1:3) assign(paste(df, i, sep=.), split(df,df$id)[[i]]) df.1 df.2 df.3 Now in the next step I'd like to get or recall these databases but not just simply sending 'df.1', 'df.2', 'df.3' to R (because my real df database is much bigger and much more complicated than this simplified one as usual). I would have liked to do this the similar way you recall these things in Excel Visual Basic. You know, if we were in an Excel VB world I would do something like: sub exercise () for i = 1 to 3 df.i // perform this and that etc.// next i end sub Returning to R: first I wanted to do it this way: for (i in 1:3) df.i (perform this and that etc...) But of course it is wrong. Is there a proper way to handle this one? What do I miss? I do not know if my question is clear... Thank you very much and thanks for the previous answers as well! Happy R-exploring! Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] recalling different data frames (the way you do in Excel VB)
Hello everyone, I'd like to ask you a question again, basically focusing on referring to different objects. Let's suppose we create the following databases this way: id -c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3) a -c(3,1,3,3,1,3,3,3,3,1,3,2,1,2,1,3,3,2,1,1,1,3,1,3,3,3,2,1,1,3) b -c(3,2,1,1,1,1,1,1,1,1,1,2,1,3,2,1,1,1,2,1,3,1,2,2,1,3,3,2,3,2) c -c(1,3,2,3,2,1,2,3,3,2,2,3,1,2,3,3,3,1,1,2,3,3,1,2,2,3,2,2,3,2) d -c(3,3,3,1,3,2,2,1,2,3,2,2,2,1,3,1,2,2,3,2,3,2,3,2,1,1,1,1,1,2) e -c(2,3,1,2,1,2,3,3,1,1,2,1,1,3,3,2,1,1,3,3,2,2,3,3,3,2,3,2,1,4) df -data.frame(id,a,b,c,d,e) df for (i in 1:3) assign(paste(df, i, sep=.), split(df,df$id)[[i]]) df.1 df.2 df.3 Now in the next step I'd like to get or recall these databases but not just simply sending 'df.1', 'df.2', 'df.3' to R (because my real df database is much bigger and much more complicated than this simplified one as usual). I would have liked to do this the similar way you recall these things in Excel Visual Basic. You know, if we were in an Excel VB world I would do something like: sub exercise () for i = 1 to 3 df.i // perform this and that etc.// next i end sub Returning to R: first I wanted to do it this way: for (i in 1:3) df.i (perform this and that etc...) But of course it is wrong. Is there a proper way to handle this one? What do I miss? I do not know if my question is clear... Thank you very much and thanks for the previous answers as well! Happy R-exploring! Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] persuade tabulate function to count NAs in a data frame
Hi, I'd like to ask you a question again. It is basically about data frames, NAs and tabulate function. I have this data frame. I already used this in one of the previous questions of mine. It intentionally looks this simple, my real 'df' dataframe is much bigger actually and again, I am not willing to annoy anyone with huge databases... So, my database: id -c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3) a -c(3,1,3,3,1,3,3,3,3,1,3,2,1,2,1,3,3,2,1,1,1,3,1,3,3,3,2,1,1,3) b -c(3,2,1,1,1,1,1,1,1,1,1,2,1,3,2,1,1,1,2,1,3,1,2,2,1,3,3,2,3,2) c -c(1,3,2,3,2,1,2,3,3,2,2,3,1,2,3,3,3,1,1,2,3,3,1,2,2,3,2,2,3,2) d -c(3,3,3,1,3,2,2,1,2,3,2,2,2,1,3,1,2,2,3,2,3,2,3,2,1,1,1,1,1,2) e -c(2,3,1,2,1,2,3,3,1,1,2,1,1,3,3,2,1,1,3,3,2,2,3,3,3,2,3,2,1,4) df -data.frame(id,a,b,c,d,e) df I have managed to calculate the distributions of the numbers occurring in columns 'b' to 'e' but considering the fact at the very same time that these distributions should be 'groupped by' the id numbers in column 'id'. It works fine, check it - matrix(matrix(unlist(lapply(df[,(-(1))],function(x) tapply(x,df$id,tabulate,nbins=nlevels(factor(df[,2] [[1]])),ncol=3,nrow=3,byrow=TRUE) matrix(matrix(unlist(lapply(df[,(-(1))],function(x) tapply(x,df$id,tabulate,nbins=nlevels(factor(df[,3] [[2]])),ncol=3,nrow=3,byrow=TRUE) matrix(matrix(unlist(lapply(df[,(-(1))],function(x) tapply(x,df$id,tabulate,nbins=nlevels(factor(df[,4] [[3]])),ncol=3,nrow=3,byrow=TRUE) matrix(matrix(unlist(lapply(df[,(-(1))],function(x) tapply(x,df$id,tabulate,nbins=nlevels(factor(df[,5] [[4]])),ncol=3,nrow=3,byrow=TRUE) matrix(matrix(unlist(lapply(df[,(-(1))],function(x) tapply(x,df$id,tabulate,nbins=nlevels(factor(df[,6] [[5]])),ncol=4,nrow=3,byrow=TRUE) Now my problem is: what if my data frame contains NA values here and there and what if I want my in-built tabulate function to collect these NAs as well? So what if I want it to count how many occurrences I have from these NAs? Here's my modified data frame with the NAs: id -c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3) a -c(NA,1,3,3,1,3,3,3,3,1,3,2,1,2,1,3,3,2,1,1,1,3,1,3,3,3,2,1,1,3) b -c(3,2,1,1,1,1,1,1,1,1,1,2,1,3,2,1,1,1,2,1,3,1,2,2,1,3,3,2,3,2) c -c(1,3,2,3,2,1,2,3,3,2,2,3,NA,2,3,3,3,1,1,2,3,3,1,2,2,3,2,2,3,2) d -c(3,3,3,1,3,2,2,1,2,3,2,2,2,1,3,1,2,2,3,2,3,2,3,2,1,1,1,1,1,2) e -c(2,3,1,2,1,2,3,3,1,1,2,1,1,3,3,2,1,1,3,3,2,2,3,3,3,2,3,NA,1,4) df -data.frame(id,a,b,c,d,e) df At first I tried something like this (you see, the only thing I did was that I tried to apply this exclude=NULL thing). unlist(lapply(df[,(-(1))],function(x) tapply(x,df$id,tabulate,nbins=nlevels(factor(df[,2],exclude=NULL [[1]]) At least my code realizes the fact that I have 4 different levels in column 'a' (1,2,3,NA) and not only three (1,2,3). Check it here: nlevels(factor(df[,2],exclude=NULL)) But you see in the result that somehow it could not calculate the NAs. It says 3 0 6 0(!) 4 3 3 0 4 1 5 0 Instead of the correct: 3 0 6 1(!) 4 3 3 0 4 1 5 0 Or in case of: unlist(lapply(df[,(-(1))],function(x) tapply(x,df$id,tabulate,nbins=nlevels(factor(df[,4],exclude=NULL [[3]]) It says 2 4 4 0 2 3 4 0(!) 1 5 4 0 Instead of the correct 2 4 4 0 2 3 4 1(!) 1 5 4 0 etc. Does someone have any ideas how to persuade the function tabulate to count NAs? Is it possible at all? Thanks very much and have a pleasant weekend, Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] calculating the occurrences of distinct observations in the subsets of a dataframe
Hello everybody, I have a data frame in R which is similar to the follows. Actually my real 'df' dataframe is much bigger than this one here but I really do not want to confuse anybody so that is why I try to simplify things as much as possible. So here's the data frame. id -c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3) a -c(3,1,3,3,1,3,3,3,3,1,3,2,1,2,1,3,3,2,1,1,1,3,1,3,3,3,2,1,1,3) b -c(3,2,1,1,1,1,1,1,1,1,1,2,1,3,2,1,1,1,2,1,3,1,2,2,1,3,3,2,3,2) c -c(1,3,2,3,2,1,2,3,3,2,2,3,1,2,3,3,3,1,1,2,3,3,1,2,2,3,2,2,3,2) d -c(3,3,3,1,3,2,2,1,2,3,2,2,2,1,3,1,2,2,3,2,3,2,3,2,1,1,1,1,1,2) e -c(2,3,1,2,1,2,3,3,1,1,2,1,1,3,3,2,1,1,3,3,2,2,3,3,3,2,3,2,1,3) df -data.frame(id,a,b,c,d,e) df Basically what I would like to do is to get the occurrences of numbers for each column (a,b,c,d,e) and for each id group (1,2,3) (for this latter grouping see my column 'id'). So, for column 'a' and for id number '1' (for the latter see column 'id') the code would be something like this: as.numeric(table(df[1:10,2])) The results are: [1] 3 7 Just to briefly explain my results: in column 'a' (and regarding only those records which have number '1' in column 'id') we can say that: number 1 occured 3 times, and number 3 occured 7 times. Again, just to show you another example. For column 'a' and for id number '2' (for the latter grouping see again column 'id'): as.numeric(table(df[11:20,2])) After running the codes the results are: [1] 4 3 3 Let me explain a little again: in column 'a' and regarding only those observations which have number '2' in column 'id') we can say that number 1 occured 4 times number 2 occured 3 times and number 3 occured 3 times. Last example: for column 'e' and for id number '3' the code would be: as.numeric(table(df[21:30,6])) With the results: [1] 1 4 5 ...meaning that number '1' occured once, number '2' occured four times and number '3' occured 5 times. So this is what I would like to do. Calculating the occurrences of numbers for each custom-defined subsets (and then collecting these values into a data frame). I know it is NOT a difficult task but the PROBLEM is that I'm gonna have to change the input 'df' dataframe on a regular basis and hence both the overall number of rows and columns might CHANGE over time... What I have done so far is that I have separated the 'df' dataframe by columns, like this: for (z in (2:ncol(df))) assign(paste(df,z,sep=.),df[,z]) So df.2 will refer to df$a, df.3 will equal df$b, df.4 will equal df$c etc. But I'm really stuck now and I don't know how to move forward, you know, getting the occurrences for each column and each group of ids. Do you have any ideas? Best regards, Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] changing the dimensions of a matrix in a real specific way
Hi again, I'd like to ask you a question again. I have a matrix like this: a -matrix(c(1,2,3,4,5,6,7,8,9,10,11,12)) a [,1] [1,]1 [2,]2 [3,]3 [4,]4 [5,]5 [6,]6 [7,]7 [8,]8 [9,]9 [10,] 10 [11,] 11 [12,] 12 Is there a proper way to change the dimensions of this matrix so that I'll get this as a result: [,1] [,2] [,3] [1,] 123 [2,] 456 [3,] 789 [4,] 10 11 12 Thank you very much and have a pleasant day, Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] changing one character in the name of dataframes repeatedly
Hello Ivan, Thank you very much for your comments, they were really useful and I’ll try to memorize and use them in the future. Getting back to my problem… well, I try to put it in a different way because I’m afraid this is gonna be a little bit more difficult than I thought. So, here is my refreshed database (it is a little bit more similar to my original database than my previous ’df’ database in my previous letter, although still simplified). id -c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3) a -c(3,1,3,3,1,3,3,3,3,1,3,2,1,2,1,3,3,2,1,1,1,3,1,3,3,3,2,1,1,3) b -c(3,2,1,1,1,1,1,1,1,1,1,2,1,3,2,1,1,1,2,1,3,1,2,2,1,3,3,2,3,2) c -c(1,3,2,3,2,1,2,3,3,2,2,3,1,2,3,3,3,1,1,2,3,3,1,2,2,3,2,2,3,2) d -c(3,3,3,1,3,2,2,1,2,3,2,2,2,1,3,1,2,2,3,2,3,2,3,2,1,1,1,1,1,2) e -c(2,3,1,2,1,2,3,3,1,1,2,1,1,3,3,2,1,1,3,3,2,2,3,3,3,2,3,2,1,3) df -data.frame(id,a,b,c,d,e) df Basically what I would like to do is to get the distributions of the numbers for each column (a,b,c,d,e) and for each group (1,2,3) (for this latter grouping see my column ’id’). So, for column ’a’ and for number ’1’ (for the latter see column ’id’): as.numeric(table(df[1:10,2]))[1]/sum(as.numeric(table(df[1:10,2]))) as.numeric(table(df[1:10,2]))[2]/sum(as.numeric(table(df[1:10,2]))) Fist time you get: [1] 0.3, then you get: [1] 0.7 Just to briefly explain my results: in column ’a’ (and regarding only those records which have number ’1’ in column ’id’) we can say that: number 1 occured 3 times, and number 3 occured 7 times. 3 / (3+7) = 0.3, and 7 / (3+7) = 0.7 Again, just to show you another example. For column ’a’ and for number ’2’ (for the latter grouping see again column ’id’): as.numeric(table(df[11:20,2]))[1]/sum(as.numeric(table(df[11:20,2]))) as.numeric(table(df[11:20,2]))[2]/sum(as.numeric(table(df[11:20,2]))) as.numeric(table(df[11:20,2]))[3]/sum(as.numeric(table(df[11:20,2]))) After running the codes the results are: 0.4, 0.3, 0.3. Let me explain a little again: in column ’a’ and regarding only those observations which have number ’2’ in column ’id’) we can say that Number 1 occured 4 times number 2 occured 3 times and number 3 occured 3 times. Now the results are obvious: 4/10 = 0.4, 3/10=0.3, 3/10=0.3 etc. So this is what I would like to do. Calculating distributions for each custom-defined subsets and then collecting these values into a data frame. The reason I wanted to sort out the problem with indices like ’i’, ’k’ etc. (you know we discussed it previously) was because I’m gonna have to change the input ’df’ dataframe on a regular basis and hence both the overall number of rows and columns might change over time… Thank you again, Laszlo -- View this message in context: http://r.789695.n4.nabble.com/changing-one-character-in-the-name-of-dataframes-repeatedly-tp3348390p3382288.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] changing one character in the name of dataframes repeatedly
Dear R-community, I'd like to ask you a question concerning R again. I try to keep this simple because I am not willing to confuse you at all. I have a little data frame which I have created the following way: a -c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6) b -c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30) df -as.data.frame(cbind(a,b)) df Now in the next step I would have liked to create smaller dataframes where the data have been extracted (basically splitted) from the main 'df' dataframe according to the numbers in df$a. Something like this: a b 1 1 1 2 1 3 1 4 1 5 a b 2 6 2 7 2 8 2 9 2 10 a b 3 11 3 12 3 13 3 14 3 15 a b 4 16 4 17 4 18 4 19 4 20 etc. It is not quite difficult to do this part. But!! I also want that the name of each and every small dataframe should refer to the fact that according to which number in df$a have I selected the data in df$b. For example: df.1 meaning I have only chosen those numbers in df$b which have value 1 in df$a df.1 a b 1 1 1 2 1 3 1 4 1 5 df.2 meaning I have only chosen those numbers in df$b which have value 2 in df$a. df.2 a b 2 6 2 7 2 8 2 9 2 10 df.3 meaning I have only chosen those numbers in df$b which have value 3 in df$a. a b 3 11 3 12 3 13 3 14 3 15 etc... I know it would not be difficult to do this in this way: df.1 -split(df,df$a)[[1]] df.2 -split(df,df$a)[[2]] df.3 -split(df,df$a)[[3]] df.4 -split(df,df$a)[[4]] etc... But as a matter of fact, my real df dataframe consists of more than 4400 records so it is impossible to do this manually for a numerous times with the previously mentioned split function. I wanted to use loops and managing the problem in the following (wrong) way: for (i in 1:6) { df.i -split(df,df$a)[[i]] } After I wanted to enter df.1, df.2, etc... R sent me the message: Error: object 'df.1' not found. However, it recognized df.i and listed following: a b 6 26 6 27 6 28 6 29 6 30 Can you help me with this matter? I wonder if there is a proper way to do this which I haven't figured out yet... Thank you very much and have a pleasant weekend, Laszlo Bodnar Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] changing one character in the name of dataframes repeatedly
Dear R-community, I'd like to ask you a question concerning R again. I try to keep this simple because I am not willing to confuse you at all. I have a little data frame which I have created the following way: a -c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6) b -c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30) df -as.data.frame(cbind(a,b)) df Now in the next step I would have liked to create smaller dataframes where the data have been extracted (basically splitted) from the main 'df' dataframe according to the numbers in df$a. Something like this: a b 1 1 1 2 1 3 1 4 1 5 a b 2 6 2 7 2 8 2 9 2 10 a b 3 11 3 12 3 13 3 14 3 15 a b 4 16 4 17 4 18 4 19 4 20 etc. It is not quite difficult to do this part. But!! I also want that the name of each and every small dataframe should refer to the fact that according to which number in df$a have I selected the data in df$b. For example: df.1 meaning I have only chosen those numbers in df$b which have value 1 in df$a df.1 a b 1 1 1 2 1 3 1 4 1 5 df.2 meaning I have only chosen those numbers in df$b which have value 2 in df$a. df.2 a b 2 6 2 7 2 8 2 9 2 10 df.3 meaning I have only chosen those numbers in df$b which have value 3 in df$a. a b 3 11 3 12 3 13 3 14 3 15 etc... I know it would not be difficult to do this in this way: df.1 -split(df,df$a)[[1]] df.2 -split(df,df$a)[[2]] df.3 -split(df,df$a)[[3]] df.4 -split(df,df$a)[[4]] etc... But as a matter of fact, my real df dataframe consists of more than 4400 records so it is impossible to do this manually for a numerous times with the previously mentioned split function. I wanted to use loops and managing the problem in the following (wrong) way: for (i in 1:6) { df.i -split(df,df$a)[[i]] } After I wanted to enter df.1, df.2, etc... R sent me the message: Error: object 'df.1' not found. However, it recognized df.i and listed following: a b 6 26 6 27 6 28 6 29 6 30 Can you help me with this matter? I wonder if there is a proper way to do this which I haven't figured out yet... Thank you very much and have a pleasant weekend, Laszlo Bodnar Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] creating additional column
Thank you Philipp, it is very useful! How come I haven't figured it out myself I dont know... Have a pleasant weekend! Laszlo -- View this message in context: http://r.789695.n4.nabble.com/creating-additional-column-tp3341224p3348552.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] creating additional column
Hello everybody, I have a little problem in good old R. It is basically the following. I have this small database with 3 rows and the following columns: d1, d2, d3 and Highest d value - which selects the highest value from d1, d2, d3 in each row. d1 d2 d3 Highest d value 1 51.398426 39.111721 11.6086220 51.398426 2 4.0578017.7284070.1234711 7.728407 3 7.2793417.36050918.2964676 18.296468 I'd like to make an additional column which shows the label of the relevant column where we've found the maximum d value. Something like this: d1 d2 d3 Highest d value Where is the maximum? 1 51.398426 39.111721 11.6086220 51.398426 d1 2 4.0578017.7284070.1234711 7.728407d2 3 7.2793417.36050918.2964676 18.296468 d3 Is there an easy way to do this? Thank you very much and have a pleasant day! Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] bootstrap resampling question
Hello there, I have a problem concerning bootstrapping in R - especially focusing on the resampling part of it. I try to sum it up in a simplified way so that I would not confuse anybody. I have a small database consisting of 20 observations (basically numbers from 1 to 20, I mean: 1, 2, 3, 4, 5, ... 18, 19, 20). I would like to resample this database many times for the bootstrap process with the following two conditions. The resampled databases should also have 20 observations and you can select each of the previously mentioned 20 numbers with replacement. I guess it is obvious so far. Now the more difficult second condition is that one number can be selected only maximum 5 times. In order to make this clear I try to show you an example. So there can be resampled databases like the following ones: (1st database) 1,2,1,2,1,2,1,2,1,2,3,3,3,3,3,4,4,4,4,4 (4 different numbers are chosen, each selected 5 times) (2nd database) 1,8,8,6,8,8,8,2,3,4,5,6,6,6,6,7,19,1,1,1 (Two numbers - 8 and 6 - selected 5 times, number 1 selected four times, the others selected less than 4 times) My very first guess that came to my mind whilst thinking about the problem was the sample function where there are settings like replace=TRUE and prob=... where you can create a probability vector i.e. how much should be the probability of selecting a number. So I tried to calculate probabilities first. I thought the problem can basically described as a k-combination with repetitions. Unfortunately the only thing I could calculate so far is the total number of all possible selections which amounts to 137 846 527 049. Anybody knows how to implement my second tricky condition into one of the R functions? Are 'boot' and 'bootstrap' packages capable of managing this? I guess they are, I just couldn't figure it out yet... Thanks very much! Best regards, Laszlo Bodnar Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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] bootstrap resampling - simplified
Hello there, I have a problem concerning bootstrapping in R - especially focusing on the resampling part of it. I try to sum it up in a simplified way so that I would not confuse anybody. I have a small database consisting of 20 observations (basically numbers from 1 to 20, I mean: 1, 2, 3, 4, 5, ... 18, 19, 20). I would like to resample this database many times for the bootstrap process with the following conditions. Firstly, every resampled database should also include 20 observations. Secondly, when selecting a number from the above-mentioned 20 numbers, you can do this selection with replacement. The difficult part comes now: one number can be selected only maximum 5 times. In order to make this clear I show you a couple of examples. So the resampled databases might be like the following ones: (1st database) 1,2,1,2,1,2,1,2,1,2,3,3,3,3,3,4,4,4,4,4 4 different numbers are chosen (1, 2, 3, 4), each selected - for the maximum possible - 5 times. (2nd database) 1,8,8,6,8,8,8,2,3,4,5,6,6,6,6,7,19,1,1,1 Two numbers - 8 and 6 - selected 5 times (the maximum possible times), number 1 selected 4 times, the others selected less than 4 times. (3rd database) 1,1,2,2,3,3,4,4,9,9,9,10,10,13,10,9,3,9,2,1 Number 9 chosen for the maximum possible 5 times, number 10, 3, 2, 1 chosen for 3 times, number 4 selected twice and number 13 selected only once. ... Anybody knows how to implement my tricky condition into one of the R functions - that one number can be selected only 5 times at most? Are 'boot' and 'bootstrap' packages capable of managing this? I guess they are, I just couldn't figure it out yet... Thanks very much! Best regards, Laszlo Bodnar Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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 - the condition has length 1 and only the first element will be used
Hello there, I don't know if I'm addressing my question to the right e-mail address, I hope I do. Actually I have a little problem concerning writing a code in R. I try to briefly sum up my problem. As you can see below, I created the functions Equation1 and Equation2 with some conditions. Equation1 -function(x){ if (x=0.25) y -1-4*x if (x0.25) y -0 y } Equation2 -function(x){ if (x=0.25)y -4*x if (x0.25 x=0.5) y -2-4*x if (x0.5) y -0 y } And then I generated a sequence of numbers from 0 to 1 using the following code: x -seq(0,1,0.05) What I intended to do was to create 3 columns like below. In the first column you can find all the x values I created just before using the seq procedure and in the next 2 columns you can see all the calculated values of functions Equation1 and Equation2 respectively. x Egyenlet1 Egyenlet2 0.00 1.000.00 0.05 0.800.20 0.10 0.600.40 0.15 0.400.60 0.20 0.200.80 0.25 0.001.00 0.30 0.000.80 0.35 0.000.60 0.40 0.000.40 0.45 0.000.20 0.50 0.000.00 0.55 0.000.00 0.60 0.000.00 0.65 0.000.00 0.70 0.000.00 0.75 0.000.00 0.80 0.000.00 0.85 0.000.00 0.90 0.000.00 0.95 0.000.00 1.00 0.000.00 Unfortunately I didn't know how to create these columns. Whenever I tried to send the following codes into R: Equation1(x) or Equation1(x) (remember x representing the values from 0 to 1) ...I instantaneously got a warning message saying: [1] 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -1.2 -1.4 -1.6 -1.8 -2.0 -2.2 -2.4 -2.6 -2.8 -3.0 Warning messages: 1: In if (x = 0.25) y - 1 - 4 * x : the condition has length 1 and only the first element will be used 2: In if (x 0.25) y - 0 : the condition has length 1 and only the first element will be used Could somebody please help me with this? I would greatly appreciate if somebody would reply. Thank you very much and have a pleasant day! Best regards, Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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 - the condition has length 1 and only the first element will be used
Hello there, I don't know if I'm addressing my question to the right e-mail address, I hope I do. Actually I have a little problem concerning writing a code in R. I try to briefly sum up my problem. As you can see below, I created the functions Equation1 and Equation2 with some conditions. Equation1 -function(x){ if (x=0.25) y -1-4*x if (x0.25) y -0 y } Equation2 -function(x){ if (x=0.25)y -4*x if (x0.25 x=0.5) y -2-4*x if (x0.5) y -0 y } And then I generated a sequence of numbers from 0 to 1 using the following code: x -seq(0,1,0.05) What I intended to do was to create 3 columns like below. In the first column you can find all the x values I created just before using the seq procedure and in the next 2 columns you can see all the calculated values of functions Equation1 and Equation2 respectively. x Egyenlet1 Egyenlet2 0.00 1.000.00 0.05 0.800.20 0.10 0.600.40 0.15 0.400.60 0.20 0.200.80 0.25 0.001.00 0.30 0.000.80 0.35 0.000.60 0.40 0.000.40 0.45 0.000.20 0.50 0.000.00 0.55 0.000.00 0.60 0.000.00 0.65 0.000.00 0.70 0.000.00 0.75 0.000.00 0.80 0.000.00 0.85 0.000.00 0.90 0.000.00 0.95 0.000.00 1.00 0.000.00 Unfortunately I didn't know how to create these columns. Whenever I tried to send the following codes into R: Equation1(x) or Equation1(x) (remember x representing the values from 0 to 1) ...I instantaneously got a warning message saying: [1] 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -1.2 -1.4 -1.6 -1.8 -2.0 -2.2 -2.4 -2.6 -2.8 -3.0 Warning messages: 1: In if (x = 0.25) y - 1 - 4 * x : the condition has length 1 and only the first element will be used 2: In if (x 0.25) y - 0 : the condition has length 1 and only the first element will be used Could somebody please help me with this? I would greatly appreciate if somebody would reply. Thank you very much and have a pleasant day! Best regards, Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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 - the condition has length 1 and only the first element will be used
Hi again! I just wanted to say that during typing my message before I mistyped certain of characters and I was just afraid that it might spoil the understanding of my message. So I corrected the characters and now I'm sending you this corrected letter again. Terribly sorry for my mistake. Thank you again, Laszlo. - Hello there, I don't know if I'm addressing my question to the right e-mail address, I hope I do. Actually I have a little problem concerning writing a code in R. I try to briefly sum up my problem. As you can see below, I created the functions Equation1 and Equation2 with some conditions. Equation1 -function(x){ if (x=0.25) y -1-4*x if (x0.25) y -0 y } Equation2 -function(x){ if (x=0.25)y -4*x if (x0.25 x=0.5) y -2-4*x if (x0.5) y -0 y } And then I generated a sequence of numbers from 0 to 1 using the following code: x -seq(0,1,0.05) What I intended to do was to create 3 columns like below. In the first column you can find all the x values I created just before using the seq procedure and in the next 2 columns you can see all the calculated values of functions Equation1 and Equation2 respectively. x Equation1 Equation2 0.00 1.000.00 0.05 0.800.20 0.10 0.600.40 0.15 0.400.60 0.20 0.200.80 0.25 0.001.00 0.30 0.000.80 0.35 0.000.60 0.40 0.000.40 0.45 0.000.20 0.50 0.000.00 0.55 0.000.00 0.60 0.000.00 0.65 0.000.00 0.70 0.000.00 0.75 0.000.00 0.80 0.000.00 0.85 0.000.00 0.90 0.000.00 0.95 0.000.00 1.00 0.000.00 Unfortunately I didn't know how to create these columns. Whenever I tried to send the following codes into R: Equation1(x) or Equation2(x) (remember x representing the values from 0 to 1) ...I instantaneously got a warning message saying: [1] 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.6 -0.8 -1.0 -1.2 -1.4 -1.6 -1.8 -2.0 -2.2 -2.4 -2.6 -2.8 -3.0 Warning messages: 1: In if (x = 0.25) y - 1 - 4 * x : the condition has length 1 and only the first element will be used 2: In if (x 0.25) y - 0 : the condition has length 1 and only the first element will be used Could somebody please help me with this? I would greatly appreciate if somebody would reply. Thank you very much and have a pleasant day! Best regards, Laszlo Ez az e-mail és az összes hozzá tartozó csatolt melléklet titkos és/vagy jogilag, szakmailag vagy más módon védett információt tartalmazhat. Amennyiben nem Ãn a levél cÃmzettje akkor a levél tartalmának közlése, reprodukálása, másolása, vagy egyéb más úton történÅ terjesztése, felhasználása szigorúan tilos. Amennyiben tévedésbÅl kapta meg ezt az üzenetet kérjük azonnal értesÃtse az üzenet küldÅjét. Az Erste Bank Hungary Zrt. (EBH) nem vállal felelÅsséget az információ teljes és pontos - cÃmzett(ek)hez történÅ - eljuttatásáért, valamint semmilyen késésért, kapcsolat megszakadásból eredÅ hibáért, vagy az információ felhasználásából vagy annak megbÃzhatatlanságából eredÅ kárért. Az üzenetek EBH-n kÃvüli küldÅje vagy cÃmzettje tudomásul veszi és hozzájárul, hogy az üzenetekhez más banki alkalmazott is hozzáférhet az EBH folytonos munkamenetének biztosÃtása érdekében. This e-mail and any attached files are confidential and/...{{dropped:19}} __ 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.