-2

Consider the following example:

library(digest)
hash <- digest("hello world", algo="md5", serialize=F)
hash

produces [1] "5eb63bbbe01eeed093cb22bb8f5acdc3"

For my purposes, I only want the raw string output with no embellishments or extras. The objective is to alter the script so it produces 5eb63bbbe01eeed093cb22bb8f5acdc3.

I've spent over an hour looking for any way to get rid of the [1] and the documentation has been absolutely terrible. Most of the search results are manipulation, clickbait, wrong, or scams.

Array indexing doesn't work:

hash[1]

produces [1] "5eb63bbbe01eeed093cb22bb8f5acdc3", because apparently an array is the first element of itself which makes no programmatic sense whatsoever.

typeof(hash)

produces [1] "character". Really?

substr(hash[1], 4, 1000)

produces [1] "63bbbe01eeed093cb22bb8f5acdc3".

How do I just make that [1] and preferably the quotes as well go away? There's absolutely no instructions searchable on the web as far as I know.

More generally, I'd like a function or procedure to convert anything to a string for manipulation and post-processing.

user1258361
  • 1,133
  • 2
  • 16
  • 25

1 Answers1

3
   library(digest)
   hash <- digest("hello world", algo="md5", serialize=F)
   cat(hash)
markhogue
  • 1,056
  • 1
  • 6
  • 16