Displaying 20 results from an estimated 20000 matches similar to: "Removing a single element from an array"
2011 Jul 13
1
UNIX diff function
Colleagues,
(R: 2.13.0; OS X)
I often receive sequential datasets in which there are new rows interposed between existing rows. For example:
SET1 <- data.frame(list(LETTERS=LETTERS[c(1:4, 6:10)], NUMBERS=c(1:4, 6:10)))
SET2 <- data.frame(list(LETTERS=LETTERS[1:10], NUMBERS=1:10))
> SET1
LETTERS NUMBERS
1 A 1
2 B 2
3 C 3
4 D 4
5
2011 Dec 31
2
read.csv error: invalid multibyte string
R version: 2.13.1
OS X
Colleagues,
I am working with a CSV file; for testing purposes, I created an XLS version of the file.
When I read these files using read.xls (gdata) or read.csv, I encounter an error:
Error in type.convert(data[[i]], as.is = as.is[i], dec = dec, na.strings = character(0L)) :
invalid multibyte string at '<b0>C'
The error occurs whether or not I invoke
2011 Aug 10
1
Reading XML files masquerading as XL files
R version 2.13.1
OS X (or Windows)
Colleagues,
I received a number of files with a .xls extension. These files open in XL and, by all appearances, are XL files. However, it appears to me that the files are actually XML:
> readLines(dir()[16])[1:10]
[1] "<?xml version=\"1.0\"?>"
[2] "<Workbook
2010 Feb 12
1
Identifying special characters in a text file
Colleagues
R 2.10.1 on a Mac
I read in textfiles using readLines, then I process those files, then I use R to execute another program. Occasionally those files contain characters other than letter / numbers / routine punctuation marks. For example, a bullet (option-8 on a Mac) triggers the problem.
Although R can read and process those characters, the other program cannot so I would like to
2011 Mar 25
2
Finding the common portion of strings
Colleagues
R: 2.12.2
OS X
I have a set of text objects in the form (I am showing 3 of what is more likely to be 20 or so):
OBJECTS <- c("abcSOMETHINGCOMMONegf", "xSOMETHINGCOMMONyz", "SOMETHINGCOMMONnme")
As you can see, all contain "SOMETHINGCOMMON" and the position varies. But, I don't know what that "SOMETHINGCOMMON" is.
Is there an
2011 Mar 29
2
Probing a function
R 2.12.2
Windows 7
Colleagues,
I just took advantage of the function:
readWindowsShortcut
in R.utils. It accomplished my goals and I was interested in learning its inner workings. So, I typed the function at the command line (without arguments or parentheses). R returned:
function (...)
UseMethod("readWindowsShortcut")
<environment: namespace:R.utils>
providing no
2010 Jul 20
1
Registered / trademark signs
Colleagues,
What is the easiest means to embed a:
? (registered)
or
? (trademark)
sign in text in a graphic. I would like to use mtext and avoid plotmath, if possible. Ideally, the sign should be superscripted but I can easily sacrifice that.
Optimally, I need a solution that works in both OS X and Windows (? XP) and with R versions ? 2.11
Thanks in advance.
Dennis
Dennis Fisher MD
P <
2010 May 05
1
Unexpected call to "require"
Colleagues
I am executing a length script in R (20K lines). At one point, it returns:
> Loading required package: tcltk
> Loading Tcl/Tk interface ... done
> Loading required package: Hmisc
> Loading required package: survival
> Loading required package: stats
> Loading required package: graphics
> Loading required package: splines
> Attaching package: 'Hmisc'
2011 Mar 04
1
Environment variable PATH in Windows
Colleagues,
I am trying to understand how R (2.12.1) obtains the PATH environment variable in Windows (7 or Vista). Startup {base} directs one to:
"R_ENVIRON" -- which equals "" in my systems
R_HOME/etc/Renviron.site -- which does not exist
Next, it directs to:
R_HOME/etc/Rprofile.site -- which also does not exist (the expected behavior in a "factory-fresh"
2012 Sep 27
1
Speeding up time conversion
R 2.15.1
OS X.7.4
Colleagues,
I have a large dataset (27773536 records, the file is several GB) that contains a column of date / time entries in the format:
"2/1/2011 13:25:01"
I need to convert these to numeric values (ideally in seconds; the origin [e.g., 1970-01-01] is not important).
I am using:
as.numeric(strptime(DATA$DATADTM, "%m/%d/%Y %H:%M:%S"))
It takes 21
2010 Mar 24
1
shading an area of a graphic
Colleagues
OS 10.5
R: 2.10.1
I have a simple x-y plot for which I would like to shade the lower (or upper) part of the interior region (i.e., the area bounded by the axes). If the delineation between top and bottom were linear, it would be use to use the polygon function. However, the delineation is a curve (which I can describe by an equation). In theory, I could divide the x-axis into a
2010 Oct 11
1
grep triggering error on unicode character
Colleagues,
[R 2.11; OS X]
I am processing a file on the fly that contains the following text:
XXX??
[email clients may display this differently -- the string is three X's followed by two instances of the letter a with an acute accent]
I read the file with:
X <- readLines(FILENAME)
In this instance, the text of interest is on line 213. When I examine line 213, it reads:
XXX\xe1\xe1
2011 May 26
4
Applying "toupper" to only portions of text strings
Colleagues
Assume that I have a vector containing some text strings, some of which contain a particular character. I could like to apply "toupper" to the text before the character. For example (in this case, "|" is the particular character):
ORIGINAL:
TEXT <- c("aaaa", "bbb|cc", "|ddd")
AFTER APPLICATION OF toupper:
TEXT <-
2009 Nov 13
5
Help with complicated regular expression
Colleagues,
I am using R (2.9.2, all platforms) to search for a complicated text
string using regular expressions. I would appreciate any help you can
provide.
The string consists of the following elements:
SOMEWORDWITHNOSPACES
any number of spaces and/or tabs
(
any number of spaces and/or tabs
integer
any number of spaces and/or tabs
)
Examples include:
WORD ( 123 )
WORD(1 )
2017 Dec 01
0
Timezone problem with 3.4.2
Mark
Thanks for pointing this out. I did a default installation of R. Does this mean that I need to reinstall from the command line?
Dennis
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com <http://www.plessthan.com/>
> On Nov 30, 2017, at 6:42 PM, R. Mark Sharp <rmsharp at me.com> wrote:
>
>
2018 Feb 22
2
Problem with geterrmessage()
Luke
Thanks ? I revised the code to:
ERRORMESSAGE <- try(source(USERSCRIPTFILE, local=T), silent=T)
print(ERRORMESSAGE) now returns:
$value
[1] 0
$visible
[1] FALSE
Not clear what to make of that.
Dennis
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com
> On Feb 22, 2018, at 12:45 PM, luke-tierney at
2004 Dec 17
2
Is the page number in a document created with "pdf()" accessible?
When I create pdf documents in R using pdf(), each page has text in the
outer margin indicating the page number. I track page numbers in a
cumbersome manner. Is the page number in a multi-page document tracked
internally by par() or some other function?
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-8864)
Fax: 1-415-564-2220
www.PLessThan.com
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,
2020 Oct 24
0
Package recommendations for outputting table with cell formatting
Will this need to be done many times? If not, it might be just as easy
to apply conditional formatting to cells after they're already in
Excel.
On Fri, Oct 23, 2020 at 8:28 PM Dennis Fisher <fisher at plessthan.com> wrote:
>
> R 4.0.2
> OS X
>
> Colleagues
>
> I have the unfortunate need to create a large number of tables (destined for a Word document). I need to
2010 Mar 27
1
string width calculation
Colleagues,
I am trying to create a PDF document in which I use margin text with two different fonts. The resulting text might be:
XXXXXyZZZ
where X and Z are one font and Y is the other.
My plan was to do this in the following manner:
mtext("XXXXX ZZZ", cex=2, adj=0.5, family=SOMEFONT)
mtext("Y", cex=2, adj=??, family=DIFFERENTFONT)
My question regards how to calculate