Perhaps dta <- data.frame( SKU=c("4950","8488","1159"), Price=c(10,15,3),Qty=c(24,144,16),ID=c("10208473","38447769","43759115") ) Lists are not as easy to optimize performance with as tables are... unless you have a specific reason to use them I would minimize your use of single-element items in lists. On August 27, 2019 9:49:28 PM PDT, Jim Lemon <drjimlemon at gmail.com> wrote:>Hi Alex, >At a guess you may want something like this: > >data.frame(item="SKU",price=10,qty=2,ID="00001") > >This produces a data frame with one row. You will probably want many >more rows. > >Jim > >On Wed, Aug 28, 2019 at 2:21 PM Alex Naverniak <stopro888 at gmail.com> >wrote: >> >> Hi, >> I am trying to create Inventory structure with item SKU and 3 >subitems like >> "Price"; "Qty"; "ID". I tried >list(SKU,list("Item1","Item2","Item3")). It >> seem not to work. Please help with ideas. Thanks. >> Alex >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at 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 at 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.-- Sent from my phone. Please excuse my brevity.
Thank you. The problem is that I need multiple same size data structures for each item name. For example: Unique item name -"Table" has several (Lets say 5) subitems of 3 items in each("Size", "Price", "Qty"); Another item "Chair" has 4 subitems of the same structure (3 positions in each), etc. That list of furniture unique items may have indefinite number of triple subitems. I need to hace access to each position of subitem like [[1]][[3]][[2]]. I also need to dynamically add subitems and furniture items. The total size of furniture inventory is not known at the beginning. I hope it makes sense. Thank you. On Wed, Aug 28, 2019 at 2:18 AM Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:> Perhaps > > dta <- data.frame( SKU=c("4950","8488","1159"), > Price=c(10,15,3),Qty=c(24,144,16),ID=c("10208473","38447769","43759115") ) > > Lists are not as easy to optimize performance with as tables are... unless > you have a specific reason to use them I would minimize your use of > single-element items in lists. > > On August 27, 2019 9:49:28 PM PDT, Jim Lemon <drjimlemon at gmail.com> wrote: > >Hi Alex, > >At a guess you may want something like this: > > > >data.frame(item="SKU",price=10,qty=2,ID="00001") > > > >This produces a data frame with one row. You will probably want many > >more rows. > > > >Jim > > > >On Wed, Aug 28, 2019 at 2:21 PM Alex Naverniak <stopro888 at gmail.com> > >wrote: > >> > >> Hi, > >> I am trying to create Inventory structure with item SKU and 3 > >subitems like > >> "Price"; "Qty"; "ID". I tried > >list(SKU,list("Item1","Item2","Item3")). It > >> seem not to work. Please help with ideas. Thanks. > >> Alex > >> > >> [[alternative HTML version deleted]] > >> > >> ______________________________________________ > >> R-help at 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 at 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. > > -- > Sent from my phone. Please excuse my brevity. >[[alternative HTML version deleted]]
Why do you need to do this? It sounds like homework. Using multiple columns as lookup keys is the normal way this is handled. On August 28, 2019 7:10:34 AM PDT, Alex Naverniak <stopro888 at gmail.com> wrote:>Thank you. >The problem is that I need multiple same size data structures for each >item >name. For example: Unique item name -"Table" has several (Lets say 5) >subitems of 3 items in each("Size", "Price", "Qty"); Another item >"Chair" >has 4 subitems of the same structure (3 positions in each), etc. That >list >of furniture unique items may have indefinite number of triple >subitems. I >need to hace access to each position of subitem like [[1]][[3]][[2]]. I >also need to dynamically add subitems and furniture items. The total >size >of furniture inventory is not known at the beginning. I hope it makes >sense. Thank you. > >On Wed, Aug 28, 2019 at 2:18 AM Jeff Newmiller ><jdnewmil at dcn.davis.ca.us> >wrote: > >> Perhaps >> >> dta <- data.frame( SKU=c("4950","8488","1159"), >> >Price=c(10,15,3),Qty=c(24,144,16),ID=c("10208473","38447769","43759115") >) >> >> Lists are not as easy to optimize performance with as tables are... >unless >> you have a specific reason to use them I would minimize your use of >> single-element items in lists. >> >> On August 27, 2019 9:49:28 PM PDT, Jim Lemon <drjimlemon at gmail.com> >wrote: >> >Hi Alex, >> >At a guess you may want something like this: >> > >> >data.frame(item="SKU",price=10,qty=2,ID="00001") >> > >> >This produces a data frame with one row. You will probably want many >> >more rows. >> > >> >Jim >> > >> >On Wed, Aug 28, 2019 at 2:21 PM Alex Naverniak <stopro888 at gmail.com> >> >wrote: >> >> >> >> Hi, >> >> I am trying to create Inventory structure with item SKU and 3 >> >subitems like >> >> "Price"; "Qty"; "ID". I tried >> >list(SKU,list("Item1","Item2","Item3")). It >> >> seem not to work. Please help with ideas. Thanks. >> >> Alex >> >> >> >> [[alternative HTML version deleted]] >> >> >> >> ______________________________________________ >> >> R-help at 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 at 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. >> >> -- >> Sent from my phone. Please excuse my brevity. >>-- Sent from my phone. Please excuse my brevity.