Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

importWizard

A widget for importing data to R


Description

Functions constructs a widget that allows users to inport data file to R. The imported data will be returned as an R data frame together with the argument list used to import the data using read.table

Usage

importWizard(filename = "", maxRow = 400)
initImportWizard(env)
getTopCan(base, env)
getAFrame(base, env)
finish(env)
getState1Frame(base, env)
setState1BFrame(frame, env)
setState1TFrame(frame, viewer, delims, env, startList)
showData4State1(widget, env)
setState1MFrame(frame, env, dataViewer)
getState2Frame(base, env, state = "state2", reset = FALSE)
setState2MFrame(frame,env)
setSepRadios(frame, env, state = "state2")
setQuoteList(frame, env)
setQuote(listBox, env, state = "state2")
setState2BFrame(frame, env)
showData4State2(canvas, env, state = "state2")
getState3Frame(base, env)
setState3TFrame(frame, env)
setState3BFrame(frame, env)
getName4Data(filename, objType)
writeCol4Matrix(tempFrame, dataFile, colInfos, env)
popStartLine(startList, env)
readFileByLines(filename)

Arguments

filename

filename a character string for the name of the file to be imported. The default is an empty string and users have to click a browse button to get the file name through fileBrowser

maxRow

maxRow an integer for the maximum number of rows of the data file to be imported to be shown on the widget. The default is 200 rows

env

env an R environment object for storing the required information

base

base a tcltk window to hold a canvas on the top and frames in the bottom

frame

frame a tcktl frame

viewer

viewer a tkwin object for a widget

delims

delims a character string for a file separater

widget

widget a tcltk widget

state

state a character string for the state of importing process

listBox

listBox a tcltk list box

canvas

canvas a tcltk canvas

tempFrame

tempFrame a tcltk frame that will be used to hold widget elements

dataFile

dataFile a data matrix holding data to be displayed

colInfos

colInfos an object of class colInfo with a name, type, and drop slot

reset

reset a boolean that is TRUE when the window needs to be reset

dataViewer

dataViewer a tkwin object for a list box

objType

objType a character string indicating the data type of an object to be saved. Defaulted to "object"

startList

startList a tk text box object

Details

importWizard mimics the interface of MS Excel and collects arguments for the function read.table. Due to performace concern, a maximum number of rows (maxRow) set by users will be displayed. Overly long data set may cause slow response of the system.

initImportWizard initializes the interface for importWizard by creating a widget with an empty top canvas and bottom frame filled with four buttons.

getTopCan Creates a canvas that is going to be filled by a frame created by other functions depending on the state of the importing process.

getAFrame Gets a frame for the canvas created by initImportWizard based on the current state of importing process.

finish Finishes the importing process and returns a data frame read from a file using read.table.

getState1Frame Returns a tcltk frame containing a list box to show a data file read by readLines and widgets for user imports.

setState1BFrame Fills the bottom frame of the frame created by getState1Frame with a list box.

setState1TFrame Fills the top frame of the frame created by getState1Frame with a list box.

showData4State1 Populates a tcltk list or text widget with data read using readLines.

setState1MFrame Fills the mid frame of the frame created by getState1Frame.

getState2Frame Returns a tcltk frame containing a canvas to show a data file read by read.table and widgets for user imports.

setState2MFrame Fills the mid frame of the frame created by getState2Frame.

setSepRadios Renders radio buttons for options of file separators in the frame created by setState2MFrame.

setQuoteList Renders the selection list for the quote used by a data file in the frame created by setState2MFrame.

setQuote Sets the value when a user has selected the quote used by a data file.

setState2BFrame Fills the bottom frame of the frame created by getState2Frame with a canvas.

showData4State2 Populates the canvas created by setState2BFrame using data read by read.table.

getState3Frame Returns a tcltk frame containing a canvas to show a data file read by read.table and widgets for user imports.

setState3TFrame Fills the top frame of the frame created by getState3Frame.

setState3BFrame Fills the bottom frame of the frame created by getState3Frame.

getName4Data Takes user input for a file name using a widget.

writeCol4Matrix Creates a tcltk frame with list boxes as columns displaying data of a data matrix.

Value

getTopCan returns a tcltk canvas.

getAFrame returns a tcltk frame.

finish returns a data.frame.

getState1Frame returns a tcltk frame with several widgets.

setState1BFrame returns the tkwin object of list box.

getState2Frame returns a tcltk frame with several widgets.

getState3Frame returns a tcltk frame with several widgets.

getName4Data returns a character string for the name of a file to be saved.

Author(s)

Jianhua Zhang

See Also

Examples

if(interactive()){
      importWizard()
  }

tkWidgets

R based tk widgets

v1.68.0
Artistic-2.0
Authors
J. Zhang <jzhang@jimmy.harvard.edu>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.