How to create Minimal List of two Lists in R? -


i trying create minimal list of 2 lists in r based on thread how make great r reproducible example? not cover list of lists basic example. wanted minimum data sample of following structure b length can minimised must heterogeneous

list of 2  $ :'data.frame':   541650 obs. of  2 variables:   ..$ v1: num [1:541650] -0.21 -0.205 -0.225 -0.22 -0.21 -0.19 -0.205 -0.205 -0.205 -0.205 ...   ..$ v2: num [1:541650] -0.245 -0.22 -0.2 -0.2 -0.195 -0.2 -0.19 -0.185 -0.18 -0.185 ...  $ :'data.frame':   426098 obs. of  2 variables:   ..$ v1: num [1:426098] -0.285 -0.285 -0.185 -0.285 -0.385 -0.305 -0.305 -0.125 -0.015 -0.285 ...   ..$ v2: num [1:426098] -0.445 -0.6 -0.815 -0.665 -0.49 -0.68 -0.555 -0.755 -0.795 -0.405 ... 

doing dput(files), big example data. doing reproduce(files), same case. tried dput(head(files, 5)) 1 list , returns 5 digits. pseudocode

  • structure list of 2 lists b(1,2) length of b(1,2) varies such

    length(b(1)_i) = length(b(2)_i)  
  • minimise length of b(1,2) keep heterogeneous length of subsequent bs

wanted output structure

list of 2 $ data.frame 11 obs. of 2 variables      $ v1: num [1:11] -0.21 -0.205 ...     $ v2: num [1.11] -0.245 -0.22 ... $ data.frame 7 obs. of 2 variables      $ v1: num [1:7] -0.285 -0.286 ...     $ v2: num [1.7] -0.445 -0.6 ... 

r: 3.3.1
os: debian 8.5

this can done in couple of ways. create 2 data.frame , place in list

lst <- list(data.frame(v1 = rnorm(11), v2 = rnorm(11)),               data.frame(v1 = rnorm(7), v2 = rnorm(7)))  

or if there many data.frames create, use loop

lst1 <- lapply(c(11, 7), function(n) data.frame(v1 = rnorm(n),                                 v2 = rnorm(n))) 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -