Martin Maechler
1997-Oct-04  15:49 UTC
R-alpha: paste problem in TASKS --- yes, I do really want it
This is from line 104 of current TASKS:
----------------------------------------------------------------------
TASK:	"paste" problem
STATUS:	Open
FROM:	maechler@stat.math.ethz.ch
	in S,
		paste(....., collapse = string)
	always returns ONE string  (a character vector of length 1),
	according to documentation and several examples.
	in R, this is not true:
		R> paste(rep(" ",0), collapse="...") #anything for
collapse
		character(0)
		S> paste(rep(" ",0), collapse="...") #anything for
collapse
		[1] ""
	Again, I think	R  is more logical than S here, but it was decided
	that in minor cases, compatibility comes first...
	[ Low priority.	 Complain if you really need it. ]
			 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
			 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I hereby complain .
Yes I do want it.  The current behaviour results in  code being broken 
which would work otherwise.
{{of course I can always fix that code by an extra if(....) else .....
  but the point is that if  parse(..) behaved more reasonable,
  I did not have to fix that code..
}}
Yet another example is the  `fun()' Example in  ?tempfile
[in the latest snapshot of R-0.60]
which terminates on error for me just because of the above bug:
fun <- function() {
  FILE <- tempfile("fun")
  on.exit(unlink(FILE))
  system(paste("printenv >", FILE))
  x <- strsplit(scan(FILE, what = ""), "=")
  v <- n <- character(LEN <- length(x))
  for (i in 1:LEN) {
    n[i] <- x[[i]][1]
    v[i] <- paste(x[[i]][-1], collapse = "=")
  }
  structure(v, names = n)
}
> fun()
Read 83 items
Error in "[<-"(c("/u/sfs/adm",
"/usr/local/bin",
".:/u/maechler/bib:/u/maechler/tex/styles:.:/u/sfs/bib",  : nothing to
replace with
--- and the reason is:    x[[i]][-1]  is empty (some environment values are
					        just defined with no value ..)
 in which case 
		 paste(x[[i]][-1], collapse = "=")
 returns 
		 character(0)
 where it rather should return (IMHO)  
	
		 ""
 v[i] <- character(0)  then gives the error, whereas
 v[i] <- ""		would exactly produce what is wanted.
-----
Martin
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To:
r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
I tried compiling R-0.50-a4 with Microsoft Visual C++ 5.0 on Windows NT 4.2 and have some problems. I am doing this with the hope of being able to contribute to further development of R for Windows. I followed the instructions in the R/src/windows directory, copying the resulting files to my PC. Most source files that are not Windows dependent compile fine, others such as wincons.c, plotmath.c do not. I have noticed some missing header files: <env.h> not in my compiler distribution <dl.h> is this HP specific? presumably not needed shellapi.h I am also not sure if all the needed symbols and compiler options are being properly defined at compile time. If a working makefile could be made available it might give me some clues about how to proceed. Any suggestions? Rob Creecy Census Bureau =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-