Re: [R] format integer numbers with leading 0

2018-01-04 Thread David Wolfskill
On Thu, Jan 04, 2018 at 09:12:12PM +0100, Marc Girondot via R-help wrote: > Dear R-er, > > I would like format integer number as characters with leading 0 for a > fixed width, for example: > > 1 shoud be "01" > 2 shoud be "02" > 20 should be "20" > > Now I use: > > x <- c(1, 2, 20) > > gsub("

Re: [R] Help with Regular expression

2018-01-03 Thread David Wolfskill
On Wed, Jan 03, 2018 at 07:56:27PM +0530, Christofer Bogaso wrote: > Hi, > > I was working on following expression : > > "\":\"03-JAN-2018 16:00:00\"" > > > This is basically a combination of Date and Time mixed with some Noise. > > I want to extract only Date and Time part i.e. "03-JAN-2018 1

Re: [R] help with grep list files

2017-02-20 Thread David Wolfskill
On Mon, Feb 20, 2017 at 03:41:50PM -0600, Glenn Schultz wrote: > All, > > I have the following files in a directory and I would like only a list of > those starting with “lld" and ending with “dat”. I used the following and it > gives me the lld files > > list.files(path = readpath, pattern

Re: [R] How might I work with a data.frame where each physical row represents several logical rows?

2017-01-04 Thread David Wolfskill
On Wed, Jan 04, 2017 at 08:33:46PM -0800, David Winsemius wrote: > ... > Perhaps something like this: > > # function to read the values in 'values': > parse_values <- function(x) {scan(text= gsub( "\\[|\\]","",x), sep=",") } > > # the apply function reads line-by-line > new_dat <- apply(test_d

[R] How might I work with a data.frame where each physical row represents several logical rows?

2017-01-04 Thread David Wolfskill
I have (time series) data extracted from a repository that is stored such that each record is for an hour, but each record contains an ordered set of values throughout the hour. In the following exmaple, I'll show sets of 4, depicting 0, 15, 30, and 45 minutes after each "start" point (respectivel

Re: [R] using a regular expression

2016-09-11 Thread David Wolfskill
On Sat, Sep 10, 2016 at 07:23:37PM +, Glenn Schultz wrote: > ... > Below is the function that I am writing.  I am using sed to replace the hex > characters.  First, to get past NUL I use sed to replace hex 00 with hex 20.   > This has worked.  Once the Nul is removed and can successfully parse

Re: [R] aggregate and the $ operator

2016-01-22 Thread David Wolfskill
On Fri, Jan 22, 2016 at 01:20:59PM -0600, Ed Siefker wrote: > Aggregate does the right thing with column names when passing it > numerical coordinates. > Given a dataframe like this: > > Nuclei Positive Nuclei Slide > 1133 96A1 > 2 96 70A1 > 3 62

Re: [R] Filtering Cases with != NA

2015-12-17 Thread David Wolfskill
On Thu, Dec 17, 2015 at 01:50:29PM +0100, g.maub...@weinwolf.de wrote: > Dear All, > > I am new to "R" and search for a solution to exclude cases if a certain > variable contains NA for a case. > ... > I would like to create a subset excluding case 3 Miller NA. > > I tried to following: > > ne

Re: [R] Extract an number from a character

2015-11-23 Thread David Wolfskill
On Mon, Nov 23, 2015 at 12:20:53PM -0800, Sam Albers wrote: > Hello, > > I have a problem to which I am certain grep or gsub or that family of > functions are the solution. However, I just can't seem to wrap my mind > around exactly how. I have a dataframe below that has the dimensions > of a net.

Re: [R] regex - extracting 2 numbers and " from strings

2015-10-08 Thread David Wolfskill
On Thu, Oct 08, 2015 at 05:45:13PM -0500, Omar André Gonzáles Díaz wrote: > Hi I have a vector of 100 elementos like this ones: > > a <- c("SMART TV LCD FHD 70\" LC70LE660", "LED FULL HD 58'' LE58D3140") > > I want to put just the (70\") and (58'') in a vector b. > > This is my try, but is not w

Re: [R] Generate a vector of values, given a vector of keys and a table?

2015-09-11 Thread David Wolfskill
On Fri, Sep 11, 2015 at 04:42:07PM +0200, peter dalgaard wrote: > Or change the data format slightly and use indexing: > > > l > keyval > [1,] "1.1" "1" > [2,] "1.9" "1" > [3,] "1.4" "15000" > [4,] "1.5" "2" > [5,] "1.15" "25000" > > v <- l[,2] > > names(v) <- l[,1] >

Re: [R] Generate a vector of values, given a vector of keys and a table?

2015-09-11 Thread David Wolfskill
On Thu, Sep 10, 2015 at 10:30:50PM -0700, Bert Gunter wrote: > ?match > > as in: > > > y <- lk_up[match(x,lk_up[,"key"]),"val"] > > y > [1] "1" "1" "1" "1" "15000" "15000" "2" > [8] "2" "2" "2" > ... Aye -- thank you very much! Peace, david -- David H. Wolfski

[R] Generate a vector of values, given a vector of keys and a table?

2015-09-10 Thread David Wolfskill
I apologize in advance: I must be overlooking something quite simple, but I'm failing to make progress. Suppose I have a "lookup table": Browse[2]> dput(lk_up) structure(c("1.1", "1.9", "1.4", "1.5", "1.15", "1", "1", "15000", "2", "25000"), .Dim = c(5L, 2L), .Dimnames = list( NU

Re: [R] data.frame: data-driven column selections that vary by row??

2015-03-31 Thread David Wolfskill
On Tue, Mar 31, 2015 at 07:11:28AM -0800, John Kane wrote: > I think we need some data and code > Reproducibility > https://github.com/hadley/devtools/wiki/Reproducibility > > http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example > I apologize for failing to

Re: [R] Help with POSIX

2015-03-30 Thread David Wolfskill
On Tue, Mar 31, 2015 at 01:15:09AM +, Doran, Harold wrote: > I?m struggling a bit with learning about POSIX objects to do some basic > things with objects of this class. Suppose I have the following simple example > > times <- c("03:20", "29:56", "03:30", "21:03", "56:26") > > aa <- strptime

[R] data.frame: data-driven column selections that vary by row??

2015-03-30 Thread David Wolfskill
Sorry if that's confusing: I'm probably confused. :-( I am collecting and trying to analyze data regarding performance of computer systems. After extracting the data from its repository, I have created and used a Perl script to generate a (relatively) simple CSV, each record of which contains: *

Re: [R] [SOLVED -- my fault] png-generation from script (non-X11 env) now broken?

2014-02-25 Thread David Wolfskill
On Tue, Feb 25, 2014 at 10:36:29AM -0800, David Wolfskill wrote: > ... > This morning, I found a message in my mailbox from such a preview run: > > | Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width, : > | unable to start device PNG &g

Re: [R] png-generation from script (non-X11 env) now broken?

2014-02-25 Thread David Wolfskill
On Tue, Feb 25, 2014 at 11:10:12AM -0800, Jeff Newmiller wrote: > This is really not new... Google is your friend... http://bit.ly/1fCUnQH... > or read FAQ 7.19. The fact that this "changed" for you seems more like > something changed on your end... did your admin remove X11 from your system? > .

Re: [R] png-generation from script (non-X11 env) now broken?

2014-02-25 Thread David Wolfskill
On Tue, Feb 25, 2014 at 01:45:40PM -0500, epi wrote: > Hi, > > You can try to use cairo instead of png. > IT doesn?t require X. > try putting this line in a Rprofile file : > > > options(bitmapType="cairo") > .. Thank you for the suggestion. Early in the first function my script invokes

[R] png-generation from script (non-X11 env) now broken?

2014-02-25 Thread David Wolfskill
Since ... hmmm.. May 2012, I've had a cron-initiated script running monthly to extract some data and generate some numeric tables and plots (in PNG format). In its "normal" mode, the script automagically sends its results to a small handful of managers on the first of each month. Out of self-defe

[R] Having trouble controlling plot() output (e.g., color)

2012-02-03 Thread David Wolfskill
I expect that there's something glaringly obvious that I'm overlooking, as I'm justr getting back involved in using R after a several-month hiatus (from R). So I welcome clues. When I invoke plot(), merely specifying a data.frame with 2 columns, specify the plot type ("type") of "p" ("points"), a

[R] Function to "lump" factors together?

2011-10-17 Thread David Wolfskill
Sorry about the odd terminology, but I suspect that my intent might be completely missed had I used "aggregate" or "classify" (each of which appears to have some rather special meanings in statistical analysis and modeling). I have some data about software builds; one of the characteristics of eac

Re: [R] create arrays

2011-05-06 Thread David Wolfskill
On Fri, May 06, 2011 at 12:11:30PM -0700, Schatzi wrote: > In Matlab, an array can be created from 1 - 30 using the command similar to R > which is 1:30. Then, to make the array step by 0.1 the command is 1:0.1:30 > which is 1, 1.1, 1.2,...,29.9,30. How can I do this in R? > ... This may well be a

Re: [R] Regexp question

2011-05-04 Thread David Wolfskill
On Wed, May 04, 2011 at 10:41:36PM +0300, johannes rara wrote: > I have a string like this > > st <- "SELECT COUNT(empid), COUNT(mgrid), COUNT(empname), > COUNT(salary), FROM Employees" > > How can I remove the last comma before the FROM statement? This doesn't use a regex, per se, but: > st <-

Re: [R] Fatal error: unable to restore saved dat in .RData

2011-03-29 Thread David Wolfskill
On Tue, Mar 29, 2011 at 10:29:52PM -0400, John Sorkin wrote: > Windows 7 > R 2.12.2 > > When I launch R, I get the following error message: > > Fatal error: unable to restore saved dat in .RData > > > after which R closes. > > What does the error message mean, and what can I do to get R to wor

Re: [R] Preserving the class of POSIXt objects

2011-03-25 Thread David Wolfskill
On Fri, Mar 25, 2011 at 09:14:50PM +, Kenn Konstabel wrote: > Dear all, > > I am working with a list of objects each of which contains two POSIXct > objects (say, $Start and $End) and a number of different data in > addition to that. Now an easy way to extract Start times of all object > could

Re: [R] extracting file names

2011-03-23 Thread David Wolfskill
On Thu, Mar 24, 2011 at 03:49:32PM +1300, Darcy Webber wrote: > Dear R users, > > I am trying to figure out a way to extract the original file name of a > .DAT (e.g., IC48.DAT) file imported into R using the file.choose() > function, i.e., > > dat <- read.table(file.choose(), header = FALSE) > >

Re: [R] Separators in strptime---needed?

2011-03-23 Thread David Wolfskill
On Wed, Mar 23, 2011 at 03:22:52PM -0700, John Kane wrote: > For some reason I thought that I could read some text into dates without a > separator? Am I wrong? > > Examples > > Works, it appears > ccc <- c("2011-04-07", "1989-10-12") > x <- strptime(ccc, "%Y-%m-%d") > > Does not work > ddd

Re: [R] [O/T] reference for regular expressions

2011-03-19 Thread David Wolfskill
On Fri, Mar 18, 2011 at 09:45:57PM -0500, Erin Hodgess wrote: > Dear R People: > > Could someone recommend a good reference on regular expressions, please? > ... Mastering Regular Expressions; Friedl, Jeffrey E. F.; ISBN 9780596528126. Many of the O'Reilly books (as this one) may be purchased in

Re: [R] Histograms with strings,

2011-03-17 Thread David Wolfskill
On Thu, Mar 17, 2011 at 10:06:21PM +, Khanvilkar, Shashank wrote: > Hello, > Thanks in advance for any help, > > I have read a CSV file in which there is a column for an IP addr as in: > > tmpInFile$V2 > [1] "74.125.224.38" "74.125.224.38" "129.46.71.19" "129.46.71.19" > [5] "129.46.71.1

Re: [R] Using barplot() with zoo -- names.arg not permitted?

2011-03-17 Thread David Wolfskill
On Thu, Mar 17, 2011 at 07:52:29PM -0400, Gabor Grothendieck wrote: > ... > > I hope to learn what I'm misunderstanding. > ... > > This line in the code above produces an invalid object: > class(df$time) <- "POSIXct" > > It should be: > class(df$time) <- c("POSIXct", "POSIXt") Ah. Thank you, Si

Re: [R] Using barplot() with zoo -- names.arg not permitted?

2011-03-17 Thread David Wolfskill
On Thu, Mar 17, 2011 at 10:23:33AM -0400, Gabor Grothendieck wrote: > On Thu, Mar 17, 2011 at 9:38 AM, David Wolfskill wrote: > ... > > But the X-axis labels show up as "large integers" -- the POSIXct values > > are apparently treated as numeric quantities for this

[R] Using barplot() with zoo -- names.arg not permitted?

2011-03-17 Thread David Wolfskill
I've used barplot(), including the anmes.arg parameter, on data frames successfully, but I'm even newer to using zoo than I am to R. :-} I am working on a functon that accepts a data frame ("df") as its primary argument, extracts information from it to create a zoo, then generates a plot based on

Re: [R] Help with read.csv

2011-03-09 Thread David Wolfskill
On Wed, Mar 09, 2011 at 04:32:29PM -0600, Giovanni Petris wrote: > > Hello, > > I have a file that looks like this: > > Date,Hour,DA_DMD,DMD,DA_RTP,RTP,, > 1/1/2006,1,3393.9,3412,76.65,105.04,, > 1/1/2006,2,3173.3,3202,69.20,67.67,, > 1/1/2006,3,3040.0,3051,69.20,77.67,, > 1/1/2006,4,2998.2,2979

[R] Advice/suggestions on using a stacked barplot with "zoo"?

2011-02-22 Thread David Wolfskill
I'm not sure I'm using appropriate tools for what I'm trying to do; a reason for my lack of certainty is that I'm encountering difficulty with what I thought would be fairly simple: labeling the X axis of my graphs with human-readable timestamps. I'm using R 2.12.1, running in a FreeBSD 8.2-PREREL

Re: [R] expected behavior when parsing lines with special characters

2011-02-15 Thread David Wolfskill
On Tue, Feb 15, 2011 at 12:21:18PM -0500, Robert M. Flight wrote: > Say I have a tab-delimited table I want to read into R. What should I > expect to happen if some of the entries contain the character " ' "? I > thought it would read the file fine, but that is not what happens. > Instead, all the

[R] Is there a way to force counters to be treated as "unsigned?"

2011-02-14 Thread David Wolfskill
I am acquiring some sampled data that is time-stamped (with a POSIXct). Some of the data is in the form of "counters" -- that is, what is interesting isn't value of a given counter at a given time, but the change in the counter from one sample to a later one. As the counters are only incremented,

[R] "Error in plot.window(...) : invalid 'xlim' value" from plot(...par(new = TRUE))

2011-02-09 Thread David Wolfskill
[New to the community; still in early part of R's learning curve.] Several months ago, I was requested to generate some graphs on a periodic basis. Accordingly, I managed to figure out a way to do so, using a combination of Perl and R (in a FreeBSD environment). While I've needed to adjust a few