[R] Having problems with the ifelse and negative numbers

2019-12-09 Thread rsherry8
Please consider the following two R statements: A = runif(20, min=-1,max=1) ifelse( A < 0, sqrt(-A), A ) The second statement produces the following error message: rt(-A) : NaNs produced I understand that you cannot take the square root of a negative number but I thought the

Re: [R] Reading an excel file

2019-01-10 Thread rsherry8
The way I have done it in the past is to convert to an CSV file. One advantage of this approach is that should my r script accidental write to the file, my original Excel file is not damaged. Bob Sherry On 1/10/2019 4:39 PM, Bernard Comcast wrote: What is the best way to read in data of any

Re: [R] Problem with LM

2018-12-18 Thread rsherry8
ote that that variable names y, x, x2 are column names of the ## data.frame z2 ## please review the definitions and examples of data.frame in ?data.frame ## also the argument requirements for lm in ?lm On Tue, Dec 18, 2018 at 6:32 PM rsherry8 wrote: The values read into z2 came from a CSV file. Ple

[R] Problem with LM

2018-12-18 Thread rsherry8
The values read into z2 came from a CSV file. Please consider this R session: > length(x2) [1] 1632 > length(x) [1] 1632 > length(z2) [1] 1632 > head(z2) [1] 28914.0 28960.5 28994.5 29083.0 29083.0 29083.0 > tail(z2) [1] 32729.65 32751.85 32386.05 32379.75 32379.15 31977.15 > lm ( y ~ x2 + x,

[R] Problem with Plotting in R

2018-12-18 Thread rsherry8
Please consider the following R statements: > x = seq(1:1632) > length( MyData$NWorth ) [1] 1632 > length( MyData$NWorthSm ) [1] 1632 > plot( x, MyData$NWorth, type="l" ) > plot( x, MyData$NWorthSm, type="l" ) > plot( x, MyData$NWorth, MyData$NWorthSm, type="l"

[R] For Loop

2018-09-22 Thread rsherry8
It is my impression that good R programmers make very little use of the for statement. Please consider the following R statement: for( i in 1:(len-1) ) s[i] = log(c1[i+1]/c1[i], base = exp(1) ) One problem I have found with this statement is that s must exist before the statement

Re: [R] Trying to Generalize a Function in R

2018-08-10 Thread rsherry8
owing statement: diff = seq(1:(length-1)) I thank you for your help. I also think the version of the function posted by Joshua Ulrich is better. I found his post to be very educational. Bob On 8/9/2018 6:48 PM, Duncan Murdoch wrote: On 09/08/2018 6:21 PM, rsherry8 wrote: Duncan, You are rig

Re: [R] Trying to Generalize a Function in R

2018-08-09 Thread rsherry8
o you get when you type class(AVB)? Peter On Thu, Aug 9, 2018 at 2:24 PM rsherry8 wrote: Peter, Thanks for the response. I tired the following command: AVB[["AVB.Close"]] and I got: Error in AVB[["AVB.Close"]] : subscript out of bounds Are you assuming that AVB is

Re: [R] Trying to Generalize a Function in R

2018-08-09 Thread rsherry8
, you can use AVB[["AVB.Close"]] instead of AVB$AVB.Close. You can them use something like AVB[[paste0(symbol, ".Close"]] to generalize the retrieval of list components. HTH, Peter On Thu, Aug 9, 2018 at 12:40 PM rsherry8 wrote: I wrote the following function: # This method

Re: [R] Trying to Generalize a Function in R

2018-08-09 Thread rsherry8
ist components. HTH, Peter On Thu, Aug 9, 2018 at 12:40 PM rsherry8 wrote: I wrote the following function: # This method gets historical stock data for the stock Avalon Bay whose symbol is AVB. getReturns <- function(norm = FALSE) { library(quantmod) getSymbols("AVB"

[R] Trying to Generalize a Function in R

2018-08-09 Thread rsherry8
I wrote the following function: # This method gets historical stock data for the stock Avalon Bay whose symbol is AVB. getReturns <- function(norm = FALSE) { library(quantmod) getSymbols("AVB", src = "yahoo", from = start, to = end) length = length( AVB$AVB.Close ) close =

Re: [R] security using R at work

2018-08-08 Thread rsherry8
I consider R to be secure. It is possible, but very unlikely, that there are some back door traps in R where somebody could access your data. There is no software that is 100% secure and R is not 100% secure. Bob On 8/8/2018 11:09 AM, Laurence Clark wrote: Hello all, I want to download R

Re: [R] RQuantLib

2017-12-30 Thread rsherry8
in the United States and it worked. I am wondering if that matters. I want to thank everybody for their help. Bob Sherry On 12/30/2017 12:44 PM, David Winsemius wrote: On Dec 30, 2017, at 7:54 AM, rsherry8 <rsher...@comcast.net> wrote: OA, Thanks for the response. I downloaded the file

Re: [R] RQuantLib

2017-12-30 Thread rsherry8
.uk> wrote: >> >Dear Bob >> > >> >In fact the current release is 3.4.3 I can think of no reason why that >> >should matter here but it might be worth trying to upgrade to it. >> > >> >Michael >> > >> >On 29/12/2017 18:31, rsherry8

Re: [R] RQuantLib

2017-12-30 Thread rsherry8
t; 2. And install it from local zip files. This you find on the Packages > menu. > > Hope it helps > OA > > > On Fri, Dec 29, 2017 at 10:31 AM, rsherry8 <rsher...@comcast.net > <mailto:rsher...@comcast.net>> wrote: > > Joshua, > > Thanks for the

Re: [R] RQuantLib

2017-12-29 Thread rsherry8
nto ‘C:/Users/rsher/Documents/R/win-library/3.4’ (as ‘lib’ is unspecified) Warning message: package ‘RQuantLib’ is not available (for R version 3.4.2) Please help. Thanks, Bob Sherry On 12/28/2017 10:28 PM, Joshua Ulrich wrote: On Thu, Dec 28, 2017 at 6:02 PM, rsherry8 <rsher...@comcast.net

[R] RQuantLib

2017-12-28 Thread rsherry8
I have recently installed R on my new computer. I also want to install the package RQuantLib. So I run the following command and get the following output: > install.packages("RQuantLib") Installing package into ‘C:/Users/rsher/Documents/R/win-library/3.2’ (as ‘lib’ is unspecified) ---