[R] print(cat(bleh)) shows up strange NULL

Spencer Graves spencer.graves at pdf.com
Tue Jan 4 23:48:14 CET 2005


      Consider the following: 

 > for(i in 1:2)cat(i, "")
1 2 >
 > for(i in 1:2)print(i)
[1] 1
[1] 2
 > for(i in 1:2)print(cat(i))
1NULL
2NULL
   
      hope this helps.  spencer graves

Dan Bolser wrote:

>I am trying the following code...
>
>for(i in 1:bins){
>  print(cat(c(i, length(var1[var1==i]))))
>}
>
>Where var1 is a vector with zero or more values = {1, 2, ..., bins} (or
>something like that).
>
>The result I get is...
>
>1 33NULL
>2 28NULL
>3 39NULL
>4 27NULL
>5 32NULL
>6 30NULL
>7 23NULL
>8 16NULL
>9 10NULL
>10 15NULL
>11 13NULL
>12 7NULL
>13 3NULL
>14 7NULL
>15 2NULL
>16 0NULL
>17 2NULL
>18 0NULL
>19 0NULL
>20 3NULL
>
>I don't know what I am doing to get those stray NULL characters printed.
>
>I also tried...
>
>for(i in 1:bins){
>  print(cat(i, length(var1[var1==i])))
>}
>
>Which is essentially the same.
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>




More information about the R-help mailing list