Comment by Thomas Philips on Correct syntax for manually scaling the width of...
They did produce output, but i want to ensure that my code does not produce errors or warnings. There's a ggplot2 blog at tidyverse.org/blog/2022/08/ggplot2-3-4-0-size-to-linewidth that addresses the...
View ArticleComment by Thomas Philips on Correct syntax for manually scaling the width of...
Perfect! My searching did not turn up this link and it solves the problem completely. Thank you very much.
View ArticleComment by Thomas Philips on Change font family to math italic in ggplot...
When I look for fonts I get > windowsFonts() $serif [1] "TT Times New Roman" $sans [1] "TT Arial" $mono [1] "TT Courier New" But this can't be right - LyX has a wide range of fonts that it uses, and...
View ArticleComment by Thomas Philips on Problem using lapply in R with a function that...
Thank you. I was dimly aware of vectorization (min vs. pmin), but did not know that I could vectorize most any function.
View ArticleComment by Thomas Philips on Data table output looks very different than xts...
Thank you Rui, this makes everything clear. I have in the past converted between long and wide formats using the reshape2 format, but this is now deprecated. It may be necessary to modify the function...
View ArticleComment by Thomas Philips on Data table output looks very different than xts...
Perfect - thank you very much
View ArticleComment by Thomas Philips on What is the equivalent of reshape2's melt in...
Perfect, thank you very much. I now see it mentioned in passing in the last line of Fast Data Manipulation
View ArticleComment by Thomas Philips on Cannot write to a worksheet with openxlsx2
Thanks - the syntax wasn't obvious from the manual. I did see wb$add_worksheet() , and assumed wb_add_worksheet() would work identically.
View ArticleComment by Thomas Philips on Openxlsx2 does not write tables correctly - it...
It's worth pointing out that I didn't have this problem with openxlsx: it wrote the table to Excel without any problem. I tried openxlsx2 as it seemed more current than openxlsx and expected that the...
View ArticleComment by Thomas Philips on How to change the root directory for the Jupyter...
It also works with WinPython using the WinPython Command Prompt. I type: jupyter notebook --notebook-dir "C:\XXX\YYY (for the old style Jupyter notebooks) or jupyter lab --notebook-dir "C:\XXX\YYY"...
View ArticleComment by Thomas Philips on WinPython Path for Jupyter notebooks does not...
Thank you Wayne - the %cd didn't work, but your pointer to changing the root directory at startup did. I opened a WinPython command prompt and typed jupyter notebook --notebook-dir "C:\DIRNAME" (for a...
View ArticleUsing dplyr and mutate to counting the number of columns that meet a criterion
Minimal example: A small dataframe with 4 columns and a variable that holds the name of a new column I want to create. The new column is TRUE if responses to more than a certain number of questions...
View ArticleAccessing the columns of a pandas DataFrame via a string variable
I've set up a little function that takes in a pandas DataFrame and a few parameters, and then attempts to create an OLS regression using statsmodels. It's designed to allow me to call it from a loop,...
View ArticleProblem using rowwise() to count the number of NA's in each row of a dataframe
I'm having trouble using rowwise() to count the number of NAs in each row. My minimal example:df <- data.frame(Q1 = c(rep(1, 1), rep(NA, 9)), Q2 = c(rep(2, 2), rep(NA, 8)), Q3 = c(rep(3, 3), rep(NA,...
View ArticleMultiply two columns in a pandas MultiIndex dataframe
I have never used multiIndex pandas dataframes, and the Python API for CalcBench, a financial program I use, returned one when I typed the following code:dataItems = ["ROE", "StockholdersEquity",...
View ArticleLay out multiple ggplot graphs on a page
I generate a list of ggplot objects inside a loop as follows:myPlots = list()for(i in 1:length(maturities)){ myPlots[[i]] <- ggplot(deltaIR.df, aes(sample = deltaIR.df[,i])) + stat_qq() +...
View ArticleR openxlsx not formatting percentages correctly
I use openxlsx to write dataframes from an R script to Excel. I was on R 4.05 (and possibly and older version of openxlsx) and the following statement worked just fine:options("openxlsx.numFmt" =...
View ArticleSummary statistics with grouping by multiple columns dataframe vs. data.table...
I'm working my way through the Titanic Study in Frank Harrell's R Flow course (http://hbiostat.org/rflow/case.html) and have a question about summarizing data. The raw data (Titanic5.csv) can be...
View ArticleChecking if an R function argument is an NA causes a problem when applied to...
I created a function to turn pounds, shillings and pence into a decimal price that starts by checking if the argument is NA or an empty character string. It works perfectly with a single character...
View ArticleCalculating the cumulative sum of the columns in a dataframe with NAs
I have a dataframe that has some NAs in it, and want to create a new set of columns with the cumulative sum of a subset of the original columns, with NAs being ignored. A minimal example follows:x =...
View Article