[R] Evaluated expression in lattice key

2015-01-17 Thread Naresh Gurbuxani
In a conditional xyplot, I would like to add some numerical results in every panel. Consider below example. df - data.frame(x = rnorm(100), name = A) df - within(df, {y - x + 0.2 * rnorm(100)}) df2 - data.frame(x = rnorm(100), y = rnorm(100), name = B) df - rbind(df, df2) rm(df2) with(df,

Re: [R] Evaluated expression in lattice key

2015-01-22 Thread Naresh Gurbuxani
) panel.text(1, -1, bquote(R^2 == .(summary(lm(y~x))$r.squared))) }, grid = TRUE ) Is this what you are looking for? I hope this helps. Chel Hee Lee On 01/17/2015 07:08 AM, Naresh Gurbuxani wrote: In a conditional xyplot, I would like to add some numerical results

[R] Help with lattice panel function

2015-04-29 Thread Naresh Gurbuxani
I want to plot multiple variables in xyplot, but plot loess trend for only one of these variables. My problem is that the last command below does not give the desired result. Any help will be gratefully received. Thanks,Naresh my.df - data.frame(date = as.numeric(as.Date(2015-01-01)) + 0:49, x

Re: [R] Help with lattice panel function

2015-04-29 Thread Naresh Gurbuxani
Naresh Gurbuxani naresh_gurbux...@hotmail.com: I want to plot multiple variables in xyplot, but plot loess trend for only one of these variables. My problem is that the last command below does not give the desired result. Any help will be gratefully received. Thanks,Naresh my.df

[R] lattice strip.custom function

2015-07-04 Thread Naresh Gurbuxani
I would like to use a mapping to name panel strips. Directly using mapping table does not work. What is the problem here? my.df - data.frame(x = rnorm(100, mean = 0, sd = 2), name = A) my.df - rbind(my.df, data.frame(x = rnorm(100, mean = 0, sd = 4), name = B)) my.df - rbind(my.df, data.frame(x

[R] tikzDevice and Sweave

2016-01-17 Thread Naresh Gurbuxani
I want to use tikz() function in tikzDevice package so that it generates a pdf file to be included in the bigger tex file. Below code works, but directly inserts tikz commands in the output tex file. This works: <>= This does not work: <>= Full code is given below:

Re: [R] lattice graph with free scales and reversed axis values

2016-11-05 Thread Naresh Gurbuxani
This worked very well for me. Thanks, Naresh From: P Tennant <philipt...@iinet.net.au> Sent: Saturday, November 5, 2016 7:57 PM To: Naresh Gurbuxani Cc: R-help@r-project.org Subject: Re: [R] lattice graph with free scales and reversed axis values Hi

[R] suppress labels in lattice barchart

2016-10-15 Thread Naresh Gurbuxani
I would like to print a barchart without labels for categorical variables.   What change should be made to below command? Thanks, Naresh boy.age <- data.frame(name = c("alpha", "beta", "charlie", "gerald"), age = c(7, 9, 6, 5)) boy.age$name <- with(boy.age, reorder(name, age)) # draws with

[R] where is .emacs file?

2017-03-01 Thread Naresh Gurbuxani
I am trying to install ESS so that it can be used when EMACS is launched from Mac Terminal.  After running "make" from the directory where ESS files are saved, the instructions ask the following to be added to .emacs file: (require 'ess-site) But I cannot find .emacs file. I have already

[R] function to return plots

2020-06-12 Thread Naresh Gurbuxani
I want to write a function that will return lattice plots. This simple function output a list of two plots. These plots can be individually shown on the console. But I am unable to put them on two panels of a single plot. What changes do I need to make to this function? Thanks, Naresh

Re: [R] function to return plots

2020-06-12 Thread Naresh Gurbuxani
Thanks for your quick response.  It works as I wanted.  From: Rui Barradas Sent: Friday, June 12, 2020 7:08 AM To: Naresh Gurbuxani ; r-help@r-project.org Subject: Re: [R] function to return plots   Hello, plot.list is a list, try '[[' to access its members. ('[' returns sub-lists.) plot

Re: [R] print only a few lines of an object

2022-03-24 Thread Naresh Gurbuxani
I hit send button too fast.   Thanks for this alternative solution, Naresh From: R-help on behalf of Naresh Gurbuxani Sent: Wednesday, March 23, 2022 6:16 PM To: David Carlson Cc: r-help mailing list ; John Fox Subject: Re: [R] print only a few lines of an object   Sent from my iPhone

Re: [R] print only a few lines of an object

2022-03-23 Thread Naresh Gurbuxani
t; 0.6265465033 >> [2,] -1.693822e+00 2.689917e-01 -1.703176e-01 1.128759e+00 >> -0.7594760299 >> [3,] 1.260585e-01 6.589839e-01 -7.928987e-01 6.430545e-01 >> 1.1951731814 >> [4,] -1.890582e+00 7.614779e-01 -5.726204e-01 1.090881e+00 >> 0.95705106

Re: [R] unable to load latticeExtra in AWS R

2023-09-11 Thread Naresh Gurbuxani
Reinstall of jpeg followed by reinstall of latticeExtra solved this problem. Thanks Sent from my iPhone > On Sep 8, 2023, at 6:34 PM, Ivan Krylov wrote: > > 8 сентября 2023 г. 22:25:10 UTC, Naresh Gurbuxani > пишет: >>> library(latticeExtra) >> Error: packa

[R] unable to load latticeExtra in AWS R

2023-09-08 Thread Naresh Gurbuxani
In my AWS Sagemaker account latticeExtra does not load. It has worked in the past. How can this problem be fixed? Thanks, Naresh Sent from my iPhone Begin forwarded message: Lattice package is preinstalled. I installed latticeExtra. > .libPaths() [1] "/home/ec2-user/SageMaker/R-library"

[R] data.table question

2023-08-30 Thread Naresh Gurbuxani
I want to apply interpolation functions from one data.table to each row of another data.table. interp.dt <- data.table(scen = rep(c("a", "b"), c(3, 3)), term = c(1, 20, 60, 1, 32, 72), shock = c(10, 20, 30, 9, 12, 32)) interp.fn <- function(df, x) with(df, approx(term, shock, xout = x)$y)

[R] RQuantLib installation problem

2023-09-23 Thread Naresh Gurbuxani
In my mac, using brew, I installed boost and quantlib packages. But installation of RQuantLib errored out because R could not find libgfortran.5.dylib My mac does have this file, but in a different location. Is there a simple fix to install RQuantLib? Thanks, Naresh ~ $ ls

[R] lattice densityplot with weights

2023-09-29 Thread Naresh Gurbuxani
density() function in R accepts weights as an input. Using this function, one can calculate density and plot it. Is it possible to combined these two operations in lattice densityplot()? mydf <- data.frame(name = "A", x = seq(-2.9, 2.9, by = 0.2), wt = diff(pnorm(seq(-3, 3, by = 0.2 mydf

Re: [R] RQuantLib installation problem

2023-09-26 Thread Naresh Gurbuxani
Updating to latest version of R and reinstalling RQuantLib worked. Thanks > On Sep 24, 2023, at 5:29 PM, David Winsemius wrote: > > > On 9/24/23 08:23, Ivan Krylov wrote: >> On Sun, 24 Sep 2023 02:19:20 + >> Naresh Gurbuxani wrote: >> >>>> in

Re: [R] data.table installation on intel macOS Ventura 13.6

2023-09-26 Thread Naresh Gurbuxani
allation > > You will see that you will most likely have to modify the "Makevars" file to > include the paths of different compilers. > > Thank you, > Carlos. > > On Mon, Sep 25, 2023 at 9:41 AM Ivan Krylov wrote: > On Sun, 24 Sep 2023 23:42:14 + >

[R] data.table installation on intel macOS Ventura 13.6

2023-09-24 Thread Naresh Gurbuxani
My data.table installation uses single thread only. Instruction on this site do not apply to Ventura 13.6 https://github.com/Rdatatable/data.table/wiki/Installation Has anyone got data.table working with multi-thread? Thanks, Naresh __

Re: [R] Merge with closest (not equal) time stamps

2023-08-24 Thread Naresh Gurbuxani
ham wrote: > > It sounds like you might want a rolling join, e.g. > https://dplyr.tidyverse.org/reference/join_by.html#rolling-joins. > > (And data.table has similar functionality which inspired dplyr) > > Hadley > > On Mon, Aug 7, 2023 at 9:32 PM Naresh Gurbuxani &

[R] A simple lattice histogram

2022-04-20 Thread Naresh Gurbuxani
I am struggling with a simple histogram where scales of x-axis should be free.   Each panel should only show the range relevant for data plotted in that panel.   library(lattice) library(AER) data(CreditCard) histogram( ~ card + reports, data = CreditCard, scales = "free") This code creates two

Re: [R] [External] A simple lattice histogram

2022-04-20 Thread Naresh Gurbuxani
c(0.5, 0, 1, 0.5), more = FALSE) Naresh From: Richard M. Heiberger Sent: Wednesday, April 20, 2022 12:02 PM To: Naresh Gurbuxani Cc: r-help@r-project.org Subject: Re: [External] [R] A simple lattice histogram   start here  library(latticeExtra)  c(histogram(~ card, data=CreditCard), histogr

Re: [R] [External] Sweave

2022-06-26 Thread Naresh Gurbuxani
install it on your own machine then you can continue working as before. From: R-help on behalf of Naresh Gurbuxani Sent: Sunday, June 26, 2022 9:28:41 AM To: r-help@r-project.org Subject: [External] [R] Sweave I want to use Sweave, but incorporate some features

Re: [R] Reference factors inside split

2022-07-11 Thread Naresh Gurbuxani
unt) > > myplots <- sapply(names(mydf.split), > function(name, x = NULL) { >df <- x[[name]] >myts <- aggregate(sale ~ date, FUN = sum, data = df) >xyplot(sale ~ date, data = myts, main = name) > }, x = mydf.split, USE.NAMES = TRUE, simplify = FALSE) &g

Re: [R] struccchange on zoo time series

2022-05-01 Thread Naresh Gurbuxani
>>>> Time series toolkit with identical behavior for all time series >>>>> classes: 'ts','xts', 'data.frame', 'data.table', 'tibble', 'zoo', >>>>> 'timeSeries', 'tsibble', 'tis' or 'irts'. Also converts reliably >>>>> between these classes. >&g

Re: [R] legend in plot

2022-05-06 Thread Naresh Gurbuxani
d Hi Naresh, Have a look at the emptyspace function in the plotrix package. This returns the center of the largest empty space on the plot. Jim On Thu, May 5, 2022 at 10:41 PM Naresh Gurbuxani mailto:naresh_gurbux...@hotmail.com>> wrote: > > Is it possible to define legend in the plot comman

[R] replicate results of tree package

2022-10-13 Thread Naresh Gurbuxani
I am trying to understand ``deviance'' in classification tree output from tree package. library(tree) set.seed(911) mydf <- data.frame( name = as.factor(rep(c("A", "B"), c(10, 10))), x = c(rnorm(10, -1), rnorm(10, 1)), y = c(rnorm(10, 1), rnorm(10, -1))) mytree <- tree(name ~ .,

Re: [R] lattice question

2022-08-10 Thread Naresh Gurbuxani
). Is it possible? Thanks, Narrsh Sent from my iPhone > On Aug 10, 2022, at 9:37 AM, Deepayan Sarkar > wrote: > > On Wed, Aug 10, 2022 at 4:53 PM Naresh Gurbuxani > wrote: >> >> >> I want to merge two panels into one. Is it possible to do this? >&g

Re: [R] lattice question

2022-08-12 Thread Naresh Gurbuxani
This is the solution I was looking for. Thanks to Deepayan and Bert for sticking with me. Naresh Sent from my iPhone On Aug 12, 2022, at 8:02 AM, Deepayan Sarkar wrote:  On Thu, Aug 11, 2022 at 9:03 PM Naresh Gurbuxani mailto:naresh_gurbux...@hotmail.com>> wrote: Bert,

[R] implicit loop for nested list

2023-01-26 Thread Naresh Gurbuxani
> > I am looking for a more elegant way to write below code. > > #Simulation results have different dimensions > mysim <- lapply(1:10, function(y) { >two.mat <- matrix(rnorm(4), nrow = 2) >four.mat <- matrix(rnorm(16), nrow = 4) >list(two.mat = two.mat, four.mat = four.mat) #results

Re: [R] implicit loop for nested list

2023-01-27 Thread Naresh Gurbuxani
lt;- do.call("cbind", mysim["two.mat", ]) > four.mat <- do.call("cbind", mysim["four.mat", ]) > ``` > >> On Thu, Jan 26, 2023 at 10:33 PM Naresh Gurbuxani >> wrote: >> >>> >>> I am looking for a more elegant

[R] Info files in Windows and Mac distributions

2023-01-22 Thread Naresh Gurbuxani
Recently I installed Linux on my desktop. I discovered that R for Linux ships with info files of manuals. R for Windows and Mac only ship with html and pdf files of manuals. Why not include info files in R distributions for Windows and Mac? These are very convenient with emacs. Using

[R] Plot R graphs in aws

2023-04-20 Thread Naresh Gurbuxani
In my Amazon Web Services (AWS) account, I use R via emacs launched from terminal. While R computations work well, viewing graphs is inconvenient. I am not able to use screen device. I can send graphs to a png or pdf file, then open the file. I would like a setup where code is run in one

[R] preserve class in apply function

2023-02-07 Thread Naresh Gurbuxani
> Consider a data.frame whose different columns have numeric, character, > and factor data. In apply function, R seems to pass all elements of a > row as character. Is it possible to preserve numeric class? > >> mydf <- data.frame(x = rnorm(10), y = runif(10)) >> apply(mydf, 1, function(row)

Re: [R] preserve class in apply function

2023-02-07 Thread Naresh Gurbuxani
26504430 0.02037657 > > Cheers > Petr > >> -Original Message- >> From: R-help On Behalf Of Naresh Gurbuxani >> Sent: Tuesday, February 7, 2023 1:52 PM >> To: r-help@r-project.org >> Subject: [R] preserve class in apply function >> >> &

[R] Merge with closest (not equal) time stamps

2023-08-07 Thread Naresh Gurbuxani
I have two dataframes, each with a column for timestamp. I want to merge the two dataframes such that each row from first dataframe is matched with the row in the second dataframe with most recent but preceding timestamp. Here is an example. option.trades <- data.frame(timestamp =

Re: [R] Merge with closest (not equal) time stamps

2023-08-08 Thread Naresh Gurbuxani
gt; dplyr::select(1,2,4,3) -> > myres2 > > identical(myres, myres2) ## TRUE > > > On Tue, Aug 8, 2023 at 5:32 AM Naresh Gurbuxani > wrote: >> >> >> I have two dataframes, each with a column for timestamp. I want to >> merge the two

[R] combine barchart and xyplot in lattice

2023-11-18 Thread Naresh Gurbuxani
In below graph, I would like to add two vertical lines using panel.abline().  Is this possible? Thanks, Naresh mydf <- data.frame(hour = rep(6:20, 2), traffic = c(round(dnorm(6:20, 9, 3) * 1), round(dnorm(6:20, 17, 4) * 1)), direction = rep(c("inbound", "outbound"), c(15, 15))) vehicles

Re: [R] combine barchart and xyplot in lattice

2023-11-18 Thread Naresh Gurbuxani
 AM, Deepayan Sarkar > wrote: > > On Sat, 18 Nov 2023 at 06:44, Naresh Gurbuxani > wrote: >> >> In below graph, I would like to add two vertical lines using >> panel.abline(). Is this possible? > > I assume you want the 'v' variable in panel.abline() to be inte

[R] Strange variable names in factor regression

2024-05-09 Thread Naresh Gurbuxani
On converting character variables to ordered factors, regression result has strange names. Is it possible to obtain same variable names with and without intercept? Thanks, Naresh mydf <- data.frame(date = seq.Date(as.Date("2024-01-01"), as.Date("2024-03-31"), by = 1)) mydf[, "wday"] <-

Re: [ESS] Help pops up in web browser

2020-02-22 Thread Naresh Gurbuxani via ESS-help
global-company-mode)   (setq company-frontends '(company-pseudo-tooltip-frontend     company-echo-metadata-frontend)))   ;; company-quickhelp set up (use-package company-quickhelp   :ensure t   :init   (company-quickhelp-mode 1)) From: Dirk Eddelbuettel Sent:

[ESS] Enable camelCase with flymake and lintr

2022-03-08 Thread Naresh Gurbuxani via ESS-help
In my ess version 18.10.2, flymake complaints when an object name is camelCase.  How can I tell flymake to accept cameCase names? Below code seems to have no impact. (setq ess-r-flymake-linters                                                           

Re: [ESS] Need help installing ess using M-x package-install-file

2022-12-12 Thread Naresh Gurbuxani via ESS-help
ote: > > Hello Naresh, > >> On Saturday, 10 Dec 2022 at 08:46, Naresh Gurbuxani via ESS-help wrote: >> In my organization, IT security set up disables emacs package >> installation from package archives (e.g. MELPA) using M-x >> package-install. Therefore, I am downloadi

[ESS] Need help installing ess using M-x package-install-file

2022-12-10 Thread Naresh Gurbuxani via ESS-help
In my organization, IT security set up disables emacs package installation from package archives (e.g. MELPA) using M-x package-install. Therefore, I am downloading package tar files from package archives, then using M-x package-install-file command. This method has successfully installed

[ESS] Tab completion for CamelCase

2022-11-07 Thread Naresh Gurbuxani via ESS-help
My ess setup on mac works well with tab completion of CamelCase variable names. However, on Windows, tab completes variable names with all lowercase letters. So it does give me complete variable name, which needs some letters to be converted to uppercase. Can tab completion on Windows give

Re: [ESS] Tab completion for CamelCase

2022-11-11 Thread Naresh Gurbuxani via ESS-help
> > Is it possible to use tab completion to get CamelCase variables inside a > string? > > Thanks, Naresh Sent from my iPhone > On Nov 8, 2022, at 11:09 AM, Martin Maechler > wrote: > >  >> >>>>>> Naresh Gurbuxani via ESS-help >>>&g