[R] Works outside but not inside!

2017-02-15 Thread Keith S Weintraub
Folks, The following function works like a charm! > #Amortization for multiple rows > createAmorts<-function(ams, numPer, term) { > fctrs<-rep(1:term, each = numPer) > > oneRow<-function(am, fac){ > tdf<-data.frame(ams = c(am), yrs=fac) > agg<-aggregate(ams ~ yrs, data

[R] XLConnect Package

2016-04-19 Thread Keith S Weintraub
Folks, I am using the XLConnect package. I can download all the named ranges except a couple that are defined by the Excel function “Offset”. For example I have this named range: =OFFSET(APA!$A$1,0,0,APA!$K$11,3) I am pretty sure that this won’t work but I thought I would give it a shot here

Re: [R] Having trouble updating and installing R 3.2.1 and 3.2.2

2015-10-27 Thread Keith S Weintraub
----------- > Sent from my phone. Please excuse my brevity. > > On October 26, 2015 6:16:47 AM PDT, Keith S Weintraub > wrote: >> I uninstalled all versions of R on my computer and killed all R >> directories

Re: [R] Having trouble updating and installing R 3.2.1 and 3.2.2

2015-10-26 Thread Keith S Weintraub
> /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On October 25, 2015 7:50:07 AM PDT, Keith S Weintraub > wrote: >>

[R] Having trouble updating and installing R 3.2.1 and 3.2.2

2015-10-25 Thread Keith S Weintraub
I get the following error: Warning message: In normalizePath(path.expand(path), winslash, mustWork) : path[1]="C:\Users\Administrator\My Documents/R/win-library/3.2": Access is denied This may be the first time that I have tried to upgrade R since I upgraded my Windows installation (on Parall

Re: [R] Households per Census block

2015-08-04 Thread Keith S Weintraub
d." > > Best, > > -- Zack > - > Zack W. Almquist > Assistant Professor > Department of Sociology and School of Statistics > Affiliate, Minnesota Population Center > University of Minnesota > > On Tue, Aug 4, 2015 at 2:12 PM, Zack Almquist wrote: > Hi K

Re: [R] Households per Census block

2015-08-04 Thread Keith S Weintraub
starts at position 328 and ends at 336. just modify this loop and you'll get > a table with one-record-per-census-block in every state. > > https://github.com/davidbrae/swmap/blob/master/how%20to%20map%20the%20consumer%20expenditure%20survey.R#L104 > > (1) line 134 cha

[R] Households per Census block

2015-08-03 Thread Keith S Weintraub
Folks, I am using the UScensus2010 package and I am trying to figure out the number of households per census block. There are a number of possible data downloads in the package but apparently I am not smart enough to figure out which data-set is appropriate and what functions to use. Any help

Re: [R] open xlsx file using read.xls function of gdata package

2015-04-05 Thread Keith S Weintraub
Will it work with .xlsm files? Best, KW > You might try the readxl package - it's only available on github but it > reads both xlsx and xls. All going well, it should be on its way to CRAN > next week. > > Hadley > > On Friday, April 3, 2015, Luigi Marongiu wrote: > >> Dear all, >> I am tryin

Re: [R] Debug package options

2015-03-31 Thread Keith S Weintraub
me to have the right size font and Tk window to be able to do debugging using the debug package. In case you are interested I use Windows 7 on my Mac via Parallels. Thanks again, Best, KW > On Mar 30, 2015, at 2:05 PM, Duncan Murdoch wrote: > > On 30/03/2015 1:50 PM, Keith S W

[R] Debug package options

2015-03-30 Thread Keith S Weintraub
Folks, I would like change some of the options for the Tk window that pops up when using the debug package. I know how to change the options: e.g. options(debug.font = "Courier 12 italic”). Is there a way to “preset” these in my environment so when debug starts up I have all the options set u

[R] C#

2015-03-10 Thread Keith S Weintraub
I will keep this short as this might be the wrong list: I have found one (beta) project that allows R to interface with C#. Are there others? Any favorites. Best, KW __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.eth

[R] Interview questions?

2015-01-11 Thread Keith S Weintraub
Folks, I was wondering if anyone has put together a list of R job interview questions? I’m thinking of about 5-20 possibly open ended questions for interviewing a candidate to do R programming. Just programming. Not statistics or mathematics. What I don’t want are tricky “puzzles” that are more

Re: [R] Befuddled by ddply

2014-10-03 Thread Keith S Weintraub
then it made more sense. > > Dennis > > On Thu, Oct 2, 2014 at 7:19 AM, Keith S Weintraub wrote: >> Folks, >> >> I have the following data: >> >> mdf<-structure(list(a = 1:3, b = c(10, 20, 30)), .Names = c("a", "b" >> ), row.

[R] Befuddled by ddply

2014-10-02 Thread Keith S Weintraub
Folks, I have the following data: mdf<-structure(list(a = 1:3, b = c(10, 20, 30)), .Names = c("a", "b" ), row.names = c(NA, -3L), class = "data.frame") And function: defCurveBreak<-function(x, y) { cumsum(rep(diff(c(0, x)), each = y)/y) } lapply'ing to get the result "foo" foo<-data.frame(l

Re: [R] Can't seem to get lapply to work.

2014-09-26 Thread Keith S Weintraub
ware/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On September 25, 2014 8:25:44 PM PDT, Keith S Weintraub > wrote: >> Folks, &g

[R] Can't seem to get lapply to work.

2014-09-25 Thread Keith S Weintraub
Folks, I have the following problem. tstSet<-structure(list(corr = c(0.59, 0.62), term = c(7, 7), am = c("AmYes", "AmNo"), prem = c(19.5, 14.75)), .Names = c("corr", "term", "am", "prem"), out.attrs = structure(list(dim = structure(c(3L, 2L, 2L, 41L), .Names = c("corr", "term", "am", "prem")),

Re: [R] XLConnect on Linux Mint Maya

2014-07-31 Thread Keith S Weintraub
t.ethz.ch/mailman/listinfo/r-sig-debian. You may have > better luck asking your question there. > > Best, > Ista > > On Thu, Jul 31, 2014 at 8:46 AM, Keith S Weintraub wrote: >> Ista Et Al, >> Unfortunately your suggestion to use remove.packages did exactly the reverse

Re: [R] XLConnect on Linux Mint Maya

2014-07-31 Thread Keith S Weintraub
:Basics: ##.#. ##.#. Live Go... >> Live: OO#.. Dead: OO#.. Playing >> Research Engineer (Solar/Batteries O.O#. #.O#. with >> /Software/Embedded Controllers) .OO#. .OO#. rocks...1k >> -

Re: [R] XLConnect on Linux Mint Maya

2014-07-29 Thread Keith S Weintraub
29 08:28 /home/refserv/R/i686-pc-linux-gnu-library/3.1/rJava/libs/rJava.so The file rJava.so exists. Thanks so much for your time and help, Best, KW -- On Jul 24, 2014, at 11:16 PM, John McKown wrote: > On Thu, Jul 24, 2014 at 8:36 PM, Keith S Weintraub wrote: >> Folks, >> >

[R] XLConnect on Linux Mint Maya

2014-07-24 Thread Keith S Weintraub
Folks, I have been trying to get XLConnect to work on my Linux Mint Maya machine. R works fine but this package doesn't seem to want to build. Here is the message I get after supposedly building XLConnect and rJava: >> require(XLConnect) > Loading required package: XLConnect > Error : .onLoad

Re: [R] Data Frame to list?

2014-03-08 Thread Keith S Weintraub
Arun et al. Thanks, This is exactly what I need. All the best, KW -- On Mar 7, 2014, at 10:59 PM, arun wrote: > Try: > oof1 <- list() > oof1[foo$name] <- foo$num > A.K. > > > > > On Friday, March 7, 2014 10:43 PM, Keith S Weintraub wrote: > Folks,

[R] Data Frame to list?

2014-03-07 Thread Keith S Weintraub
Folks, I have a data frame as follows: > foo<-structure(list(name = c("A", "B", "C"), num = c(3L, 2L, 1L)), .Names = > c("name", "num"), row.names = c(NA, -3L), class = "data.frame") > str(foo) 'data.frame': 3 obs. of 2 variables: $ name: chr "A" "B" "C" $ num : int 3 2 1 > foo name

Re: [R] shapiro.test

2014-02-25 Thread Keith S Weintraub
Regarding : "... I don't know what the 4th to last page would be called (could add another ante-, or in R just use tail(book,4))..." According to wordsmith.org (sign up it's free, note I have no affiliation to that site) the word is "preantepenultimate". Check it out: http://wordsmith.org/words

Re: [R] creating an equivalent of r-help on r.stackexchange.com ?

2014-02-04 Thread Keith S Weintraub
My sentiments exactly! Thanks to all for taking the time to flesh out the potential flaws of the stackexchange "solution". KW > Date: Tue, 04 Feb 2014 10:36:21 +1300 > From: Rolf Turner > To: Bert Gunter > Cc: "r-help@r-project.org" > Subject: Re: [R] creating an equivalent of r-help on >

Re: [R] Best way to get the prices from these strings?

2014-01-29 Thread Keith S Weintraub
Thanks to Dan Wang, Petr Pikal, Arun, Jim Holtman and Arun for all of your solutions. All the best, KW -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/post

[R] Best way to get the prices from these strings?

2014-01-29 Thread Keith S Weintraub
Folks, I got the following prices by scraping a web page just for my own edification: thePrices<- c("id=\"p0\">$69.95", "id=\"p1\">$44.95", "id=\"p2\">$69.95", "id=\"p3\">$59.95", "id=\"p4\">$69.95", "id=\"p5\">$79.95", "id=\"p6\">$89.95", "id=\"p7\">$59.95", "id=\"p8\">$59.95", "id=\"p9\">$79

Re: [R] How to "apply" correctly.

2014-01-07 Thread Keith S Weintraub
In your example that doesn't work you are > ending up with a vector rather than a one > column data frame. > > Pat > > > On 07/01/2014 17:44, Keith S Weintraub wrote: >> Folks, >> >> # I have the following function: >> >> breakByFreq<-fu

[R] How to "apply" correctly.

2014-01-07 Thread Keith S Weintraub
Folks, # I have the following function: breakByFreq<-function(freq, defData) { breakUpFun<-function(freq, defs) { if(freq != 1) { defs<-diff(c(0, defs)) defs<-cumsum(rep(defs/freq, each = freq)) } defs } defMat<-sapply(defData[,-1], function(x) breakUpFun(freq, x))

[R] Applying and labeling scenarios

2013-10-04 Thread Keith S Weintraub
Folks, I have a working version of the code below for my "real world" problem. I was wondering if there was a better way to do this. I have 3 sets of parameters and I want to iterate over all combinations and label the results. Would some of the plyr tools make this easier? # Input Scenarios

[R] Simple example of web-scraping.

2013-07-23 Thread Keith S Weintraub
Folks, I was wondering if anyone has an example or a pointer to an example of code to scrape a web page. The tricky parts for me are the following: * I might need to get multiple pages in sequence. * I need to login with user-name and password. Thanks for your time and help, KW -- ___

Re: [R] Add a column to a dataframe based on multiple other column values

2013-06-12 Thread Keith S Weintraub
Tom, Here is my solution. Note that I assume the columns are interleaved as you describe below. I'm sure others will have better replies. Note that using dput helps the helpers. # From dput(mdat) mdat<-structure(list(x1 = c(2L, 2L, 2L, 3L, 3L, 30L, 32L, 33L, 33L), y1 = c(100L, 100L, 100L,

Re: [R] ggpairs in GGally replaces plotmatrix in ggplot2

2013-06-11 Thread Keith S Weintraub
Yes. I was able to run it in RStudio but it did seem much slower than in R.app (on the Mac). Note that the "it" that I ran still didn't give the same results as plotmatrix. Thanks, KW -- On Jun 11, 2013, at 11:16 AM, John Kane wrote: > Note that the code below might not work in RStudio. I a

Re: [R] ggpairs in GGally replaces plotmatrix in ggplot2

2013-06-11 Thread Keith S Weintraub
John, Thanks for that. Unfortunately it doesn't reproduce the chart in the plotmatrix call from the original question. That chart had what looked like densities (I think that is correct as I looked at the plotmatrix code) down the diagonal. I am not sure which options would give that result in

Re: [R] R-help Digest, Vol 124, Issue 12

2013-06-11 Thread Keith S Weintraub
Folks, Sorry for butting in here. I ran the code from John Kane below and it worked fine. I did however get a deprecation message suggesting the use of ggpairs from the GGally package to make this chart. Unfortunately I haven't found the correct incantation to get the diagonal to display th

Re: [R] Some unrelated questions.

2013-05-07 Thread Keith S Weintraub
Jim, Thanks for your comments. KW -- On May 6, 2013, at 5:48 PM, Jim Lemon wrote: > see inline > > On 05/07/2013 02:14 AM, Keith S Weintraub wrote: >> Folks, >> >> I have been working on an R project that has a few dozen functions. >> >> I have so

[R] Some unrelated questions.

2013-05-06 Thread Keith S Weintraub
Folks, I have been working on an R project that has a few dozen functions. I have some questions that are only tangentially related and might only be a difference in style. 1. Some of my functions take single-row data.frames as input parameters lists. I don't force the user of the function to

[R] Best way to calculate averages of Blocks in an matrix?

2013-04-17 Thread Keith S Weintraub
Folks, I recently was given a simulated data set like the following subset: sim_sub<-structure(list(V11 = c(0.01, 0, 0, 0.01, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), V12 = c(0, 0, 0, 0.01, 0.03, 0, 0, 0, 0, 0, 0, 0.01, 0, 0.01, 0, 0, 0, 0, 0, 0.04), V13 = c(0, 0, 0, 0.01, 0, 0, 0,

[R] gc()

2013-04-12 Thread Keith S Weintraub
Folks, I have some computations in a function that create some large matrices. I have been in the habit in these circumstances to call "null out" a matrix once used and call gc(). Some pseudo code: theFunction<-function(x, y, z, 1) { myMatrix <- black.box.function(x, y, z, 100

Re: [R] arrayInd and which

2013-04-05 Thread Keith S Weintraub
>> >> On Apr 3, 2013, at 7:53 AM, Keith S Weintraub wrote: >> >>> Folks, >>> >>> I have Googled but not found much regarding arrayInd aside from the "which" >>> help page. >>> >>> Any good examples or docs on

[R] arrayInd and which

2013-04-03 Thread Keith S Weintraub
Folks, I have Googled but not found much regarding arrayInd aside from the "which" help page. Any good examples or docs on what arrayInd does that is better or different from which()? In addition take the following 20x10 matrix: td<-structure(c(1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 6, 6, 6,

[R] lognormal sampleing using covariance matrix

2013-04-02 Thread Keith S Weintraub
Andras, I am no expert but you could start with correlated normal random variables and then convert to lognormal. You can use rmvsnorm from the {fCopulae} package to generate the correlated normals. Here is a call that I have used in the past: set.seed(12345) numSims<-10 # number of mult