Skip to content

how to store a number into a vector

6 messages · Quan Zhou, David Winsemius, jim holtman +1 more

#
On Jan 23, 2011, at 1:39 PM, Quan Zhou wrote:

            
?strsplit
?unlist
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
#
Do you want to store each digit as a separate character, or if you
want to compare the last three digits with other numbers, then use the
"%%" operator.
[1] 345
On Sun, Jan 23, 2011 at 1:39 PM, Quan Zhou <quan.poko2000 at gmail.com> wrote:

  
    
#
On Jan 23, 2011, at 6:00 PM, Thomas Stewart wrote:

            
str1 <- c(12345, 34567, 45678)
sapply(strsplit(as.character(str1), "") , unlist)

      [,1] [,2] [,3]
[1,] "1"  "3"  "4"
[2,] "2"  "4"  "5"
[3,] "3"  "5"  "6"
[4,] "4"  "6"  "7"
[5,] "5"  "7"  "8"

--  
David
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
#
On Jan 23, 2011, at 6:00 PM, Thomas Stewart wrote:

            
str1 <- c(12345, 34567, 45678)
sapply(strsplit(as.character(str1), "") , unlist)

     [,1] [,2] [,3]
[1,] "1"  "3"  "4"
[2,] "2"  "4"  "5"
[3,] "3"  "5"  "6"
[4,] "4"  "6"  "7"
[5,] "5"  "7"  "8"

-- David
David Winsemius, MD
Heritage Laboratories
West Hartford, CT