Make R objects pasteable
Usage
pasteable(x, target = c("sheet", "chat"))
Examples
# Meaningful row names are kept
pasteable(mtcars)
#> [1] "row_names\tmpg\tcyl\tdisp\thp\tdrat\twt\tqsec\tvs\tam\tgear\tcarb\nMazda RX4\t21\t6\t160\t110\t3.9\t2.62\t16.46\t0\t1\t4\t4\nMazda RX4 Wag\t21\t6\t160\t110\t3.9\t2.875\t17.02\t0\t1\t4\t4\nDatsun 710\t22.8\t4\t108\t93\t3.85\t2.32\t18.61\t1\t1\t4\t1\nHornet 4 Drive\t21.4\t6\t258\t110\t3.08\t3.215\t19.44\t1\t0\t3\t1\nHornet Sportabout\t18.7\t8\t360\t175\t3.15\t3.44\t17.02\t0\t0\t3\t2\nValiant\t18.1\t6\t225\t105\t2.76\t3.46\t20.22\t1\t0\t3\t1\nDuster 360\t14.3\t8\t360\t245\t3.21\t3.57\t15.84\t0\t0\t3\t4\nMerc 240D\t24.4\t4\t146.7\t62\t3.69\t3.19\t20\t1\t0\t4\t2\nMerc 230\t22.8\t4\t140.8\t95\t3.92\t3.15\t22.9\t1\t0\t4\t2\nMerc 280\t19.2\t6\t167.6\t123\t3.92\t3.44\t18.3\t1\t0\t4\t4\nMerc 280C\t17.8\t6\t167.6\t123\t3.92\t3.44\t18.9\t1\t0\t4\t4\nMerc 450SE\t16.4\t8\t275.8\t180\t3.07\t4.07\t17.4\t0\t0\t3\t3\nMerc 450SL\t17.3\t8\t275.8\t180\t3.07\t3.73\t17.6\t0\t0\t3\t3\nMerc 450SLC\t15.2\t8\t275.8\t180\t3.07\t3.78\t18\t0\t0\t3\t3\nCadillac Fleetwood\t10.4\t8\t472\t205\t2.93\t5.25\t17.98\t0\t0\t3\t4\nLincoln Continental\t10.4\t8\t460\t215\t3\t5.424\t17.82\t0\t0\t3\t4\nChrysler Imperial\t14.7\t8\t440\t230\t3.23\t5.345\t17.42\t0\t0\t3\t4\nFiat 128\t32.4\t4\t78.7\t66\t4.08\t2.2\t19.47\t1\t1\t4\t1\nHonda Civic\t30.4\t4\t75.7\t52\t4.93\t1.615\t18.52\t1\t1\t4\t2\nToyota Corolla\t33.9\t4\t71.1\t65\t4.22\t1.835\t19.9\t1\t1\t4\t1\nToyota Corona\t21.5\t4\t120.1\t97\t3.7\t2.465\t20.01\t1\t0\t3\t1\nDodge Challenger\t15.5\t8\t318\t150\t2.76\t3.52\t16.87\t0\t0\t3\t2\nAMC Javelin\t15.2\t8\t304\t150\t3.15\t3.435\t17.3\t0\t0\t3\t2\nCamaro Z28\t13.3\t8\t350\t245\t3.73\t3.84\t15.41\t0\t0\t3\t4\nPontiac Firebird\t19.2\t8\t400\t175\t3.08\t3.845\t17.05\t0\t0\t3\t2\nFiat X1-9\t27.3\t4\t79\t66\t4.08\t1.935\t18.9\t1\t1\t4\t1\nPorsche 914-2\t26\t4\t120.3\t91\t4.43\t2.14\t16.7\t0\t1\t5\t2\nLotus Europa\t30.4\t4\t95.1\t113\t3.77\t1.513\t16.9\t1\t1\t5\t2\nFord Pantera L\t15.8\t8\t351\t264\t4.22\t3.17\t14.5\t0\t1\t5\t4\nFerrari Dino\t19.7\t6\t145\t175\t3.62\t2.77\t15.5\t0\t1\t5\t6\nMaserati Bora\t15\t8\t301\t335\t3.54\t3.57\t14.6\t0\t1\t5\t8\nVolvo 142E\t21.4\t4\t121\t109\t4.11\t2.78\t18.6\t1\t1\t4\t2"
# Row names that are a sequence are dropped
pasteable(iris)
#> [1] "Sepal.Length\tSepal.Width\tPetal.Length\tPetal.Width\tSpecies\n5.1\t3.5\t1.4\t0.2\tsetosa\n4.9\t3\t1.4\t0.2\tsetosa\n4.7\t3.2\t1.3\t0.2\tsetosa\n4.6\t3.1\t1.5\t0.2\tsetosa\n5\t3.6\t1.4\t0.2\tsetosa\n5.4\t3.9\t1.7\t0.4\tsetosa\n4.6\t3.4\t1.4\t0.3\tsetosa\n5\t3.4\t1.5\t0.2\tsetosa\n4.4\t2.9\t1.4\t0.2\tsetosa\n4.9\t3.1\t1.5\t0.1\tsetosa\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.7\t1.4\tversicolor\n6.4\t3.2\t4.5\t1.5\tversicolor\n6.9\t3.1\t4.9\t1.5\tversicolor\n5.5\t2.3\t4\t1.3\tversicolor\n6.5\t2.8\t4.6\t1.5\tversicolor\n5.7\t2.8\t4.5\t1.3\tversicolor\n6.3\t3.3\t4.7\t1.6\tversicolor\n4.9\t2.4\t3.3\t1\tversicolor\n6.6\t2.9\t4.6\t1.3\tversicolor\n5.2\t2.7\t3.9\t1.4\tversicolor\n5\t2\t3.5\t1\tversicolor\n5.9\t3\t4.2\t1.5\tversicolor\n6\t2.2\t4\t1\tversicolor\n6.1\t2.9\t4.7\t1.4\tversicolor\n5.6\t2.9\t3.6\t1.3\tversicolor\n6.7\t3.1\t4.4\t1.4\tversicolor\n5.6\t3\t4.5\t1.5\tversicolor\n5.8\t2.7\t4.1\t1\tversicolor\n6.2\t2.2\t4.5\t1.5\tversicolor\n5.6\t2.5\t3.9\t1.1\tversicolor\n5.9\t3.2\t4.8\t1.8\tversicolor\n6.1\t2.8\t4\t1.3\tversicolor\n6.3\t2.5\t4.9\t1.5\tversicolor\n6.1\t2.8\t4.7\t1.2\tversicolor\n6.4\t2.9\t4.3\t1.3\tversicolor\n6.6\t3\t4.4\t1.4\tversicolor\n6.8\t2.8\t4.8\t1.4\tversicolor\n6.7\t3\t5\t1.7\tversicolor\n6\t2.9\t4.5\t1.5\tversicolor\n5.7\t2.6\t3.5\t1\tversicolor\n5.5\t2.4\t3.8\t1.1\tversicolor\n5.5\t2.4\t3.7\t1\tversicolor\n5.8\t2.7\t3.9\t1.2\tversicolor\n6\t2.7\t5.1\t1.6\tversicolor\n5.4\t3\t4.5\t1.5\tversicolor\n6\t3.4\t4.5\t1.6\tversicolor\n6.7\t3.1\t4.7\t1.5\tversicolor\n6.3\t2.3\t4.4\t1.3\tversicolor\n5.6\t3\t4.1\t1.3\tversicolor\n5.5\t2.5\t4\t1.3\tversicolor\n5.5\t2.6\t4.4\t1.2\tversicolor\n6.1\t3\t4.6\t1.4\tversicolor\n5.8\t2.6\t4\t1.2\tversicolor\n5\t2.3\t3.3\t1\tversicolor\n5.6\t2.7\t4.2\t1.3\tversicolor\n5.7\t3\t4.2\t1.2\tversicolor\n5.7\t2.9\t4.2\t1.3\tversicolor\n6.2\t2.9\t4.3\t1.3\tversicolor\n5.1\t2.5\t3\t1.1\tversicolor\n5.7\t2.8\t4.1\t1.3\tversicolor\n6.3\t3.3\t6\t2.5\tvirginica\n5.8\t2.7\t5.1\t1.9\tvirginica\n7.1\t3\t5.9\t2.1\tvirginica\n6.3\t2.9\t5.6\t1.8\tvirginica\n6.5\t3\t5.8\t2.2\tvirginica\n7.6\t3\t6.6\t2.1\tvirginica\n4.9\t2.5\t4.5\t1.7\tvirginica\n7.3\t2.9\t6.3\t1.8\tvirginica\n6.7\t2.5\t5.8\t1.8\tvirginica\n7.2\t3.6\t6.1\t2.5\tvirginica\n6.5\t3.2\t5.1\t2\tvirginica\n6.4\t2.7\t5.3\t1.9\tvirginica\n6.8\t3\t5.5\t2.1\tvirginica\n5.7\t2.5\t5\t2\tvirginica\n5.8\t2.8\t5.1\t2.4\tvirginica\n6.4\t3.2\t5.3\t2.3\tvirginica\n6.5\t3\t5.5\t1.8\tvirginica\n7.7\t3.8\t6.7\t2.2\tvirginica\n7.7\t2.6\t6.9\t2.3\tvirginica\n6\t2.2\t5\t1.5\tvirginica\n6.9\t3.2\t5.7\t2.3\tvirginica\n5.6\t2.8\t4.9\t2\tvirginica\n7.7\t2.8\t6.7\t2\tvirginica\n6.3\t2.7\t4.9\t1.8\tvirginica\n6.7\t3.3\t5.7\t2.1\tvirginica\n7.2\t3.2\t6\t1.8\tvirginica\n6.2\t2.8\t4.8\t1.8\tvirginica\n6.1\t3\t4.9\t1.8\tvirginica\n6.4\t2.8\t5.6\t2.1\tvirginica\n7.2\t3\t5.8\t1.6\tvirginica\n7.4\t2.8\t6.1\t1.9\tvirginica\n7.9\t3.8\t6.4\t2\tvirginica\n6.4\t2.8\t5.6\t2.2\tvirginica\n6.3\t2.8\t5.1\t1.5\tvirginica\n6.1\t2.6\t5.6\t1.4\tvirginica\n7.7\t3\t6.1\t2.3\tvirginica\n6.3\t3.4\t5.6\t2.4\tvirginica\n6.4\t3.1\t5.5\t1.8\tvirginica\n6\t3\t4.8\t1.8\tvirginica\n6.9\t3.1\t5.4\t2.1\tvirginica\n6.7\t3.1\t5.6\t2.4\tvirginica\n6.9\t3.1\t5.1\t2.3\tvirginica\n5.8\t2.7\t5.1\t1.9\tvirginica\n6.8\t3.2\t5.9\t2.3\tvirginica\n6.7\t3.3\t5.7\t2.5\tvirginica\n6.7\t3\t5.2\t2.3\tvirginica\n6.3\t2.5\t5\t1.9\tvirginica\n6.5\t3\t5.2\t2\tvirginica\n6.2\t3.4\t5.4\t2.3\tvirginica\n5.9\t3\t5.1\t1.8\tvirginica"
# Fixed width output for sharing on slack or other markdown destination
pasteable(mtcars, target = "chat")
#> [1] " mpg cyl disp hp drat wt qsec vs am gear carb\nMazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4\nMazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4\nDatsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1\nHornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1\nHornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2\nValiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1\nDuster 360 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4\nMerc 240D 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2\nMerc 230 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2\nMerc 280 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4\nMerc 280C 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4\nMerc 450SE 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3\nMerc 450SL 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3\nMerc 450SLC 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3\nCadillac Fleetwood 10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4\nLincoln Continental 10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4\nChrysler Imperial 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4\nFiat 128 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1\nHonda Civic 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2\nToyota Corolla 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1\nToyota Corona 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1\nDodge Challenger 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2\nAMC Javelin 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2\nCamaro Z28 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4\nPontiac Firebird 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2\nFiat X1-9 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1\nPorsche 914-2 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2\nLotus Europa 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2\nFord Pantera L 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4\nFerrari Dino 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6\nMaserati Bora 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8\nVolvo 142E 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2"
# Lists are simply converted
pasteable(list(123, "abc", cool = "R"), target = "chat")
#> [1] "123, abc, R"