-1

I am trying to repeat my data frame by 400k times, but it seems it got to an error at the end.

Here's my code in the script:

 unique_car_data <- data.frame(year = c('2010'), make = c('Toyota'), model = c('Fortuner'), trim = c("2.5 G"), transmission = c("AT"), category = c("Pribadi"), tipe.penjual = c("Dealer"))

 unique_car_data[rep(seq_len(nrow(unique_car_data)), each=400000),]

Here is the last rows in the console:

  1.1423   2010 Toyota Fortuner 2.5 G           AT  Pribadi       Dealer
  1.1424   2010 Toyota Fortuner 2.5 G           AT  Pribadi       Dealer
  1.1425   2010 Toyota Fortuner 2.5 G           AT  Pribadi       Dealer
  1.1426   2010 Toyota Fortuner 2.5 G           AT  Pribadi       Dealer
  1.1427   2010 Toyota Fortuner 2.5 G           AT  Pribadi       Dealer
  [ reached getOption("max.print") -- omitted 398572 rows ]

When I type in my data frame again in the console, there was only 1 row in the dataframe.

> unique_car_data
  year   make    model  trim transmission category tipe.penjual
1 2010 Toyota Fortuner 2.5 G           AT  Pribadi       Dealer

Does anyone know what happened? and how do I replicate for 400k rows? Thanks

dpt
  • 9
  • 2
  • 1
    you putted the replicated data only to the terminal. You didn't save per `... <- unique_car_data[rep(..), ]` to a named object. – jogo Dec 05 '15 at 10:36
  • possibly dublicate of http://stackoverflow.com/questions/31241285/r-console-output-too-long-how-can-i-view-outputs-in-less – jogo Dec 05 '15 at 11:10

1 Answers1

2

You just need to enter the rep back into the data frame (it currently only printed it, never saved it). Try this:

    unique_car_date <- unique_car_data[rep(seq_len(nrow(unique_car_data)), each=400000),]
ecohen
  • 56
  • 4