similar to: Startup speed for a lengthy script

Displaying 20 results from an estimated 10000 matches similar to: "Startup speed for a lengthy script"

2008 Jun 02
1
Lengthy delay in sourcing a large function
Colleagues, I have a script that contains ~ 10,000 lines of code. Most of it is written as small functions. However, for various reasons, the final function is ~1500 lines of code. I realize that this may not be optimal but the code evolved that way and breaking it into smaller pieces is complicated because of the passing of arguments. I have "cat(date())" statements at
2009 May 11
1
R errors when trying to read a file
Colleagues, I have encountered a problem in version 2.9 of R, running in both Vista and OS X. My code is quite lengthy but the critical line is: if (file.exists(FILENAME)) readLines(FILENAME)) This triggers the error: Error in file(con, "r") : cannot open the connection Calls: readLines -> file Execution halted The file that it is reading is being created on the fly, then
2010 Jan 09
1
Reducing the size of a large script top speed onset of execution
Colleagues, (R 2.10 on all platforms) I have a lengthy script (18000 lines) that runs within a graphical interface. The script consists of 100's of function followed by a single command that calls these functions (execution depends on a number of environment variables passed to the script). As a result, nothing is executed until the final line of code is read. It takes 15-20
2008 Oct 12
2
proper use of textConnection
Colleagues, Using R2.7.0 in OS X, I am having trouble understanding the command textConnection. My situation is as follows: 1. I am trying to read a lengthy file (45000 lines) that has headers ~ every 1000 lines. read.table (or its variants) fail because of the recurrent headers. 2. My present approach is the following: a. use readLines to read the file, save as an array b. use grep
2013 Mar 04
1
Syntax for error messages
R 2.15 OS X and Windows Colleagues, I am running a lengthy R script (> 20K lines of code) within a GUI build in RealBasic. There are rare instances in which an error is triggered in R. I am trying to trap these based on their syntax. I have identified three general formats for error messages: Error in Error: object Error: could Each is these is followed by some informative text.
2011 Apr 10
3
Adding margin text to lattice graphics
Colleagues I am learning lattice graphics (R 2.12.2; OS X). Several days ago, I inquired about adding margin text to lattice graphics. Jim Price offered a useful reply, suggesting that I add: page = function(page) grid.text('words', x = 0.5, y = 0.01) to my call to the function. The entire function that he suggested was; xyplot(1 ~ 1, par.settings = list(layout.heights =
2014 Apr 30
2
"Name partially matched in data frame"
R 3.1.0 OS X Colleagues, I recently updated to 3.1.0 and I have encountered Warning messages: ... Name partially matched in data frame when I do something like: DATAFRAME$colname where colname is actually something longer than that (but unambiguous). I have much appreciated the partial matching capabilities because it fits with my workflow. I often receive updated data months after the
2007 Sep 04
2
Recursive concatenation
Colleagues, I want to create the following array: "A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3" I recall that there is a trick using "c" or "paste" permitting me to form all combinations of c("A", "B", "C") and 1:3. But, I can't recall the
2009 Sep 29
3
Deleting a column in a dataframe by name
Colleagues, Hopefully a simple problem: I want to delete a column with a known name from a dataframe. I could write: FRAME <- FRAME[, names(FRAME) != NAMETODELETE] or FRAME <- FRAME[, !names(FRAME) %in% c(NAME1, NAME2, ETC)] Is there some simpler means to accomplish this? Dennis Dennis Fisher MD P < (The "P Less Than" Company) Phone: 1-866-PLessThan (1-866-753-7784)
2008 Dec 15
3
opening a PDF document
Colleagues, I am interesting in opening a PDF document via the command line from both Windows, OS X, and Linux ( R version 2.8.0). I found a command openPDF in Biobase. However, I would rather execute the command myself. For example, in OS X: > system("open filename.pdf") is successful. Is there a comparable command line command for Windows or Linux? Dennis Dennis Fisher
2008 Jul 29
1
Removing script file
Colleagues, (Running R 2.7.0) I have a script that I want to delete as it completes execution. The penultimate line of the script (before the quit command) is: file.remove("Scriptname") The script is executed as: R --no-save < Scriptname In OS X and Linux this is successful and returns: > > file.remove("x") > [1] TRUE and the file is deleted In Windows XP,
2005 Jan 17
2
Question about time series
I have data in the following format: > DATE [1] "01/13/2004" In order to find the difference between two data points, I presently use brute force to calculate the day of the year: > strptime(DATE, format="%m/%d/%Y")$yday [1] 12 Although this works, it may not be robust over different years. I assume that R is sufficiently clever that a much simpler approach
2006 Oct 21
2
Filling in a series
Colleagues After reading in some clinical data, I discovered that the subject ID column contains entries only for the first record for each individual; subsequent rows are recorded as NA. For example: > 1 > NA > NA > NA > NA > 2 > NA > NA > NA > NA > 3 > NA > NA > ... I can think of various approaches to replace the NA values with appropriate
2005 Jul 22
3
Question regarding subsetting
I run R 2.1.1 in a Linux environment (RedHat 9) although my question is not platform-specific. Consider the following: > A <- c("Prefix-aaa", "Prefix-bbb", "Prefix-ccc") > B <- strsplit(A, "-") > B [[1]] [1] "Prefix" "aaa" [[2]] [1] "Prefix" "bbb" [[3]] [1] "Prefix" "ccc" How
2008 May 10
2
Random number generation
Colleagues, I have encountered behavior of random number generation that eludes me. I generate a random integer in a particular range using the following code: sample(1000:9999, size=1) This code exists within a script that starts with the command: remove(list=ls()) Each time that I run the script, it yields the same random number: 6420. I thought that the problem might result from
2008 Apr 11
3
strsplit and sapply
Colleagues, I have some text: TEXT <- c("a", "bb;ccc", "dddd;eeeee;ffffff") I want to retrieve the portion of each element before the first semicolon. I can split each element using strsplit: SPLIT <- strsplit(TEXT, ";") This yields: > SPLIT [[1]] [1] "a" [[2]] [1] "bb" "ccc" [[3]] [1] "dddd"
2005 Dec 04
2
tiff graphics
Colleagues I frequently insert PDF graphics created with R into Word (Office 2004 for Mac) documents. The documents are created on either a Linux machine (RedHat 9) or a Mac (Tiger). I am using R 2.2.0. These pdf graphics often lose a great deal of resolution after insertion into Word compared to their high quality when printed as PDF documents. I recently learned that converting the
2008 Sep 17
1
Dealing with missing EOL at end of file
Colleagues, I am using R 2.7.2 on all three platforms (OS X; Windows; Linux) and I have encountered the following problem: I use R to issue a system call the execute a command in the OS. For example: system("DOSOMETHING TOSOMEFILE") In most situations, this task completes successfully and control returns to R. However, in rare situations, the target file (TOSOMEFILE) is
2009 Mar 23
1
Confusion regarding environments invoked by "source" command
Colleagues, R version 2.8.1 in OS X Within a function (which is already within a function), I am sourcing a file. The syntax of the command is something like (this is just an example; the actual code is much more complicated): BIGFUNCTION <- function() { DATAFRAME <- [some commands to create a dataframe] MYFUNCTION(DATAFRAME) } MYFUNCTION <- function(DATAFRAME) { print(ls())
2008 Jan 26
1
Capturing info from system calls in Windows
Colleagues, I am preparing scripts that will be used by others on both Windows and Linux/OSX platforms. The scripts call an existing Fortran application. The user may have any of a a variety of Fortran compilers - my goal is to determine whether or not the test command returns "no input files" or "command not found" (i.e., so that I can confirm which Fortran they