[rkward] /: Fix help search.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Mar 7 09:05:56 UTC 2016


Git commit 12e8d93b85b12661ce595b9b7c9486f30b10ff97 by Thomas Friedrichsmeier.
Committed on 07/03/2016 at 09:05.
Pushed by tfry into branch 'master'.

Fix help search.

Thanks to Stefan for reporting!

M  +3    -1    ChangeLog
M  +10   -4    rkward/rbackend/rpackages/rkward/R/internal_help.R

http://commits.kde.org/rkward/12e8d93b85b12661ce595b9b7c9486f30b10ff97

diff --git a/ChangeLog b/ChangeLog
index 081ec39..271bd42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+- Fixed: Help Search was not longer working correctly with recent version of R                     TODO: which version?
+- Fix compilation with R 3.3.x
 - Provide better status feedback when searching / filtering among installable packages
 - Add access to basic menu items for docked previews
 - Move preview controls to the button-column of dialogs                                            TODO document, polish
@@ -12,7 +14,7 @@
 - File selectors in "Import XYZ" plugins now filter for standard file extensions, by default
 - Add previews for CSV, SPSS, and Stata import plugins
 - Allow previews for data, (HTML) output, and custom types of previews
-- Allow previews to be docked to the dialog window, add dock them, by default                      TODO: update documentation on placemnet
+- Allow previews to be docked to the dialog window, and dock them, by default                      TODO: update documentation on placemnet
 - Implicitly save code preview visibility and size (instead of the former explicit settings)
 - data.frame objects outside of globalenv() can be opened read-only in an editor window
 - Show a warning screen when invoking plugins from the command line (or from clicking an rkward://-link in an external application)
diff --git a/rkward/rbackend/rpackages/rkward/R/internal_help.R b/rkward/rbackend/rpackages/rkward/R/internal_help.R
index 9fbcb3b..84ce113 100644
--- a/rkward/rbackend/rpackages/rkward/R/internal_help.R
+++ b/rkward/rbackend/rpackages/rkward/R/internal_help.R
@@ -40,8 +40,14 @@
 # Simple wrapper around help.search. Concatenates the relevant fields of the results in order for passing to the frontend.
 #' @export
 ".rk.get.search.results" <- function (pattern, ...) {
-	H=as.data.frame (help.search(pattern, ...)$matches)
-	# NOTE: The field "Type" was added in R 2.14.0. For earlier versions of R, only help pages were returned as results of help.search()
-	if ((dim (H)[1] > 0) && (is.null (H$Type))) H$Type <- "help"
-	c (as.character (H$topic), as.character (H$title), as.character(H$Package), as.character(H$Type))
+	H = as.data.frame(help.search(pattern, ...)$matches)
+	fields <- names (H)
+	c(
+		# NOTE: Field header capitalization appears to have changed in some version of R around 3.2.x
+		as.character (if ("topic" %in% fields) H$topic else H$Topic),
+		as.character (if ("title" %in% fields) H$title else H$Title),
+		as.character (if ("package" %in% fields) H$package else H$Package),
+		# NOTE: The field "Type" was added in R 2.14.0. For earlier versions of R, only help pages were returned as results of help.search()
+		as.character (if ("Type" %in% fields) H$Type else rep ("help", length.out=dim(H)[1]))
+	)
 }



More information about the rkward-tracker mailing list