RobinHankin / disordR

1 stars 0 forks source link

paste() problem #23

Open RobinHankin opened 3 years ago

RobinHankin commented 3 years ago

Look:

paste(disord(letters),"3",sep="")
 [1] "a3" "b3" "c3" "d3" "e3" "f3" "g3" "h3" "i3" "j3" "k3" "l3" "m3" "n3" "o3"
[16] "p3" "q3" "r3" "s3" "t3" "u3" "v3" "w3" "x3" "y3" "z3"
> 

the output should be a disord object, not a vector.

RobinHankin commented 2 years ago

Following shows what we want paste() to do:

> l <- disord(letters)
> disord(paste(elements(l),"3",sep="_"),h=hash(l))
A disord object with hash 005ae317c931561a05b53fcfa860d7ac61dfec85 and elements
 [1] "a_3" "b_3" "c_3" "d_3" "e_3" "f_3" "g_3" "h_3" "i_3" "j_3" "k_3" "l_3"
[13] "m_3" "n_3" "o_3" "p_3" "q_3" "r_3" "s_3" "t_3" "u_3" "v_3" "w_3" "x_3"
[25] "y_3" "z_3"
(in some order)
> 
RobinHankin commented 2 years ago

There is some documentation at ?dotsMethods which might help.

RobinHankin commented 2 years ago

Look:

paste(disord(letters),disord(LETTERS))
 [1] "a A" "b B" "c C" "d D" "e E" "f F" "g G" "h H" "i I" "j J" "k K" "l L"
[13] "m M" "n N" "o O" "p P" "q Q" "r R" "s S" "t T" "u U" "v V" "w W" "x X"
[25] "y Y" "z Z"
> 

This should (of course) return an error.

RobinHankin commented 2 years ago

Also:

 paste(letters,collapse="_")
[1] "a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z"
 paste(disord(letters),collapse="_")
[1] "a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z"

The first line is fine (of course), but the second line should return an error