Re: [R] Need help with time series

2025-01-14 Thread CALUM POLWART
acf wants a time series, so tries to make one: as.ts(myts) Time Series: Start = 19357 End = 20027 Frequency = 1 [1] 24957 NA NA NA NA NA NA NA NA NA [11] NA NA NA NA NA NA NA NA NA NA [21] NA NA NA NA

Re: [R] Citation for stock price data from Quantmod

2024-12-30 Thread CALUM POLWART
This isn't my field. But I'd have expected a sentence along the lines of: Stock prices were obtained from Yahoo Stocks[1] using the Quantmod R statistics package[2]. 1. Yahoo Citation 2. Quantmod citation That is readable. A further sentence: All analytical code is available from a publicly acc

Re: [R] Mutate issue help needed

2024-12-17 Thread CALUM POLWART
Indeed. When I try and recreate your problem I fail to find a problem. But almost certainly the issue lies in the file, or the reading of said file. Currently the code is fname <- "Buzz.txt" All <- fname That results in All containing "Buzz.txt" not the CONTENT of a file called Buzz.txt. As

Re: [R] Mutate issue help needed

2024-12-17 Thread CALUM POLWART
Am I being "thick" here .. mutate(data, *# text Is interpretated as mutate (data, * The star is the character... (Data is the line above being piped) Why have the comments been *'d?. Is that the source error or a posting error here? On Tue, 17 Dec 2024, 14:57 Ivan Krylov via R-help, wrote:

Re: [R] Weird Behavior of mean

2024-12-13 Thread CALUM POLWART
I've not checked the code, but I think that result would happen if mean uses something like if (na.rm == TRUE) { # do something to remove the NA's } And as uses something like If (na.rm != FALSE) { # do something to remove the NA's } Or perhaps ever na.rm == T If you ever see posts from B

Re: [R] [off-topic] crossword

2024-12-13 Thread CALUM POLWART
Well to complicate things, I don't think RULES is the answer. This is a cryptic crossword clue. They usually contain the answer twice (well... Cryptically!!) Writes in C or R, say. I think the answer is CODER If you look up the definition of say in the dictionary one option is: 1. give in

Re: [R] SQL and R

2024-12-11 Thread CALUM POLWART
And to answer the dependency question. Neither is dependent on the other. But both can be complimentary. If you consider that SQL*may* be a route to accessing your data (if it's in a database). And R *may* be a route to analysis of the data. If the data is in a CSV file, Excel file, API etc. y

Re: [R] Spreadsheets data

2024-12-05 Thread CALUM POLWART
And R Studio has an import data function that will provide a import command.. BUT Spreadsheet is a broad scope On Thu, 5 Dec 2024, 23:38 Martin Møller Skarbiniks Pedersen, < traxpla...@gmail.com> wrote: > On Thu, 5 Dec 2024 at 23:16, Figueiredo, Carlos via R-help > wrote: > > > > Hi there > >

Re: [R] Creating a script in Rstudio

2024-12-05 Thread CALUM POLWART
Carlos you are gonna have to provide at least a tiny smidge of information Reagent dataset? What is this? What is your problem with creating a script in R Studio. File New.. It kinda feels this is either "how do I use R studio" (in which case YouTube feels your friend) or "how do I use some very

Re: [R] DPLYR Multiple Mutate Statements On Same DataFrame

2024-10-17 Thread CALUM POLWART
Why can't you do: df0 |> mutate( ... ) |> mutate( ... ) |> mutate( ... ) I've simplified the code to show passing the result of the first line to the next rather than focussing on the detail. This would work with %>% as well as |> but I am anticipating that the more modern native pipe ( |> )

Re: [R] Is there a sexy way ...?

2024-09-28 Thread CALUM POLWART
Avi I fear this was all a huge social experiment. Testing if a post titled "sexy way" would increase engagement... On Sat, 28 Sep 2024, 07:21 , wrote: > I see a book coming: > "666 ways to do the same thing in R ranked by sexiness." > > Kidding aside, if you look under the covers of so

Re: [R] Problem with converting grib file to excel

2024-09-26 Thread CALUM POLWART
>> if it can be made available. It does look like the finial step of > reading > >> the data into raster failed, so then did the rest of th commands. > >> > >> -Roy > >> > >> > >> > On Sep 25, 2024, at 3:24 PM, CALUM POLWART >

Re: [R] Problem with converting grib file to excel

2024-09-25 Thread CALUM POLWART
Noticeable lack of silence in the group on this one. I've not got time to test currently. But my experience of geo location files - they often had more than 2 dimensional data. In other words you might have a boundary of a region as an object with long and lat for maybe 100 data points making up t

Re: [R] store list objects in data.table

2024-09-21 Thread CALUM POLWART
I think there is a typo in your reprex l(x^2) ?? mydt[1,2] contains a list. Which when unlisted contains a load of data. I'm not sure what you are asking for? Are you trying to unlist that and have it as a row? Sort of pivot.wider if you like or unnest in tidyverse concepts? I think the data.tab

Re: [R] (no subject)

2024-09-16 Thread CALUM POLWART
Rui's solution is good. Bert's suggestion is also good! For Berts suggestion you'd make the list bit list(mean = mean_narm) But prior to that define a function: mean_narm<- function(x) { m <- mean(x, na.rm = T) if (!is.Nan (m)) { m <- NA } return (m) } Would do what you suggested in your r

Re: [R] how to specify point symbols in the key on a lattice dotplot

2024-09-13 Thread CALUM POLWART
Add: key = list(points=16:17) Into the dotplot section possibly without the autokey On Fri, 13 Sep 2024, 08:19 Christopher W. Ryan, wrote: > I am making a dotplot with lattice, as follows: > > dd %>% dotplot( segment ~ transit_time, groups = impact, data = ., >as.table = TRUE,

Re: [R] Fill NA values in columns with values of another column

2024-08-27 Thread CALUM POLWART
Bert I thought she meant she wanted to replace the NAs with the 6. But I could be wrong. It looks like the data is combined from cbind. I'm going to give tidyverse examples because it's (/s) *"always"* (/s) easier. require(tidyverse) # impute the missing NAs myData <- cbind(VB1d[,1],s1id[,1])

Re: [R] Terminating a cmd windows from R

2024-08-17 Thread CALUM POLWART
cmd taskkill /PID 1234 Will kill process 1234 if you know it id So shell.exec can likely do this for you On Sat, 17 Aug 2024, 12:31 Duncan Murdoch, wrote: > On 2024-08-17 6:21 a.m., SIMON Nicolas via R-help wrote: > > I would like to stop a dos shell windows following the cmd (execute) > comma

Re: [R] boxplot notch

2024-08-16 Thread CALUM POLWART
Unless I'm missing the point, you are sending the summary data MS1s to the plot. Is that not a VERY unusual way to do it. Let box plot do the summary? Otherwise what do you want the notches to show? On Fri, 16 Aug 2024, 17:21 Chris Evans via R-help, wrote: > That's not really a reprex Sibylle.

Re: [R] If loop

2024-08-09 Thread CALUM POLWART
returning the list. > Use of "<<-" is rarely a good idea in R. > > -- Bert > > On Fri, Aug 9, 2024 at 1:53 AM CALUM POLWART wrote: > > > > OK. The fact it's in a function is making things clearer. > > > > Are you trying to update the value

Re: [R] If loop

2024-08-09 Thread CALUM POLWART
} else { > + {print ("cond21"); cat(cond21)} > + }} > > try1(joint12=TRUE) > [1] "joint12" > TRUE > [1] "marg1" > FALSE > > try1(marg1=TRUE) > [1] "marg1" > TRUE > [1] "joint12" > FALSE > > try

Re: [R] If loop

2024-08-08 Thread CALUM POLWART
Is something wrong in the initialisation part that we don't see? joint12 <- marg1 <-F marg1 <-T if (joint12) { print ("joint 12") cat (joint12) } if (marg1) { print("marg 1") cat(marg1) } Would probably be my diagnostic approach On Fri, 9 Aug 2024, 04:45 Steven Yen, wrote: > Can som

Re: [R] Extract

2024-07-22 Thread CALUM POLWART
But have we lured you to the dark side with the tidyverse yet ;-) On Mon, 22 Jul 2024, 15:22 Bert Gunter, wrote: > Thanks. > > I found this to be quite informative and a nice example of how useful > R-Help can be as a resource for R users. > > Best, > Bert > > On Mon, Jul 22, 2024 at 4:50 AM G

Re: [R] Using the pipe, |>, syntax with "names<-"

2024-07-21 Thread CALUM POLWART
The tidy solution is rename literally: z |> rename(foo = 2) Or you could do it with other functions z |> select ( 1, foo = 2) Or z |> mutate( foo = 2 ) |> # untested (always worry that makes the whole column 2) select (-2) But that's akin to z$foo <- z[2] z[2] <- null On Sun, 21 Jul 2024,

Re: [R] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread CALUM POLWART
I sometimes think people on this list are quite rude to posters. I'm afraid I'm likely to join in with some rudeness? 1. "Here is some code that works but also doesn't" is probably not going to get you an answer 2. I provide no information about the data it works on or doesn't 3. I tell you I'm u

Re: [R] Current version of R, 4.4.0 and patch to correct the bug fix related to the RStudio viewer pane on Windows systems

2024-05-16 Thread CALUM POLWART
Do you receive RDS objects from unknown (untrusted) sources? ?? If not - the security issue is a non-issue as I understand it. On Thu, 16 May 2024, 16:21 Vega, Ann (she/her/hers) via R-help, < r-help@r-project.org> wrote: > I help to coordinate the USEPA's R user group. We have over 500 member

Re: [R] Extracting values from Surv function in survival package

2024-05-16 Thread CALUM POLWART
I don't think that gives the summary of event numbers without extra work. library(survival) fit <- survfit( Surv(time,status)~sex,data=lung) summary(fit)$n.event [1] 3 1 2 1 1 1 1 2 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 3 1 1 1 1 1 2 [38] 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Re: [R] Extracting values from Surv function in survival package

2024-05-15 Thread CALUM POLWART
More difficult than it should be IMO. survminer package is often helpful. But if you want to avoid dependency: library(survival) fit <- survfit( Surv(time,status)~sex,data=lung) surfable <-summary(fit)$table surfable # just the events surfable[,"events"] On Wed, 15 May 2024, 21:42 Dennis Fishe

Re: [R] Exceptional slowness with read.csv

2024-04-08 Thread CALUM POLWART
data.table's fread is also fast. Not sure about error handling. But I can merge 300 csvs with a total of 0.5m lines and 50 columns in a couple of minutes versus a lifetime with read.csv or readr::read_csv On Mon, 8 Apr 2024, 16:19 Stevie Pederson, wrote: > Hi Dave, > > That's rather frustratin

Re: [R] Problem with R coding

2024-03-12 Thread CALUM POLWART
That's almost certainly going to be either the utf-8 character in the path OR the use of one drive which isn't really a subfolder as I understand it. When I've had these issues in the past, I've been able to mount a drive (say U:/ ) which sites further down /up the folder tree so that R just calle

Re: [R] Including an external set of coded

2024-02-20 Thread CALUM POLWART
t to do this is to keep > my main programs compact. > > Steven from iPhone > > On Feb 21, 2024, at 12:44 AM, CALUM POLWART wrote: > >  > Are you asking to source lines 5-10 of a file for instance? > > Never seen that done in R. Feels a dodgy thing to do as changing l

Re: [R] Including an external set of coded

2024-02-20 Thread CALUM POLWART
Are you asking to source lines 5-10 of a file for instance? Never seen that done in R. Feels a dodgy thing to do as changing line will screw things up. On the other hand - I'd often have functions in a file called perhaps "functions.R" and source("functions.R") Then I can call an individual func

Re: [R] Avoiding Delete key function as 'Quit R' in Rterm when there are no characters in cursor line

2024-02-09 Thread CALUM POLWART
I don't use term, but I've just tested it and this is reproducable. Is it a bug? Not sure. If you hit c after getting the message it will cancel the q() request. On Fri, 9 Feb 2024, 17:21 Duncan Murdoch, wrote: > That looks to me like a bug, but I don't use Windows any more, so I > won't offer

Re: [R] R interpreting numeric field as a boolean field

2024-01-30 Thread CALUM POLWART
And your other option - recode what gets imported. It may well be you will actually want the blanks to be NAs for instance rather than blank. I'm assuming the True and False are >$0 and $0 from your description. (Or maybe vice versa). So I'd have made my column name something like "OverZeroDollars"

Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread CALUM POLWART
help(read_docx) says that the function only imports one docx file. In > order to read multiple files, use a for loop or the lapply function. > I told you people will suggest better ways to loop!! > > docx_summary(read_docx("Now they want us to charge our electric cars > from litter bins.docx"))

Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread CALUM POLWART
It sounded like he looked at officeR but I would agree content <- officer::docx_summary("filename.docx") Would get the text content into an object called content. That object is a data.frame so you can then manipulate it. To be more specific, we might need an example of the DF You can loop thi

Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread CALUM POLWART
textreadr would be the obvious approach. When you say it is depreciated do you mean it's not available on cran? Sometimes maintaining a package on cran in just a pain in the ass. devtools::install_github("trinker/textreadr") Should let you install it. In theory docx files are actually just zip

Re: [R] adding "Page X of XX" to PDFs

2023-12-02 Thread CALUM POLWART
You could easily omit the Page X of xX, but leave the timestamp Then add Page X of XX programmatically using pdftools or some similar pdf command line tools. On Sat, 2 Dec 2023, 22:35 , wrote: > Having read all of the replies, it seems there are solutions for the > question and the OP points ou

Re: [R] adding "Page X of XX" to PDFs

2023-12-02 Thread CALUM POLWART
Can you provide a very simplified version of how the PDF is created? On Sat, 2 Dec 2023, 14:39 Dennis Fisher, wrote: > OS X > R 4.3.1 > > Colleagues > > I often create multipage PDFs [pdf()] in which the text "Page X" appears > in the margin. These PDFs are created automatically using a massi

Re: [R] ggplot adjust two y-axis

2023-11-25 Thread CALUM POLWART
This is doable. But it's also considered a data visualisation hell! So Hadley didn't make it easy. I can provide more details on how to do it later (replying from phone just now). BUT there is very much a question of should you be plotting like that. It's probably worth giving it serious thought b

Re: [R] I need to create new variables based on two numeric variables and one dichotomize conditional category variables.

2023-11-05 Thread CALUM POLWART
ded. An example might be aspects of the ggplot program > where you may get a mysterious order of presentation in the graph unless > you create a factor with the order you wish to have used and avoid it > making one invisibly. > > From: CALUM POLWART > Sent: Saturday, November 4, 2

Re: [R] I need to create new variables based on two numeric variables and one dichotomize conditional category variables.

2023-11-04 Thread CALUM POLWART
I might have factored the gender. I'm not sure it would in any way be quicker. But might be to some extent easier to develop variations of. And is sort of what factors should be doing... # make dummy data gender <- c("Male", "Female", "Male", "Female") WC <- c(70,60,75,65) TG <- c(0.9, 1.1, 1.2,

Re: [R] Question about R software and output

2023-10-03 Thread CALUM POLWART
Charity There is OFTEN confusion what we mean when we say "R". R is effectively a single bit of software with a ton of other bits of software as optional extras. You might think of some of those optional extras like apps on a phone. You'd say you have a phone when you can open the box and power

Re: [R] How to fix this problem

2023-09-25 Thread CALUM POLWART
Using readr to read the data might let you clean it on the way in... readr::read_csv("filename.csv", col_types = list(rep(col_numeric(),6)) On Mon, 25 Sep 2023, 16:54 Ebert,Timothy Aaron, wrote: > An update please: > Collectively we have suggested removing commas from the "E..coli" column, > ch

Re: [R] OFF TOPIC: chatGPT glibly produces a lot of wrong answers?

2023-08-13 Thread CALUM POLWART
It does often behave better if you say to it "that doesn't seem to be working" and perhaps some error message It is afterall a language tool. Its function is to provide text that seems real. If you ask it a science question and ask it to provide references in Vancouver format, it can format the r

Re: [R] geom_smooth

2023-08-11 Thread CALUM POLWART
+ geom_ribbon(stat = "smooth", se = TRUE, alpha = 0, # or, use fill = NA colour = "black", linetype = "dotted") Does that work? On Sat, 12 Aug 2023, 06:12 Rui Barradas, wrote: > Às 05:17 de 12/08/2023, Thomas Subia via R-help escreveu: >

[R] Live data collection, analysis & update of slides ..

2023-07-22 Thread CALUM POLWART
I'm looking for a way to do some live data analysis taking audience votes, presenting their results, potentially posing some new questions to vote on, and present those and vote. I'm interested in any suggestions from the collective minds here about the potential best approaches. I can obviously

Re: [R] plotly question

2023-07-22 Thread CALUM POLWART
I was just replying to say which bit do you consider the indicator. But I see Boris has provided a Chat GPT solution. Running it hopefully shows you how to change colours on various parts. On Fri, 21 Jul 2023, 22:43 Jeff Newmiller, wrote: > plotly is _not_ associated with posit. I think you

Re: [R] how to change the y-axis to logarithmic in a barplot ggplot

2023-07-16 Thread CALUM POLWART
t; I will find the ggplot help. > > But I have tried everything, including what you have suggested and nothing > works. > > Kind regards, > Maria > > > > > > > Στις Κυριακή 16 Ιουλίου 2023 στις 11:22:36 μ.μ. GMT+1, ο χρήστης CALUM > POLWART έγραψε: > &

Re: [R] how to change the y-axis to logarithmic in a barplot ggplot

2023-07-16 Thread CALUM POLWART
Try adding scale_y_log10() This is a general R help list. It's not a ggplot list and you are likely to be chased off to ggplot's package maintainers nominated support pages. But really a Google search should surely have found this? On Sun, 16 Jul 2023, 22:51 Maria Lathouri via R-help, wrote:

Re: [R] Asking about R "Security" ..

2023-05-17 Thread CALUM POLWART
Chris replied off list to say he hadn't directed the OP to NHS R Community so it seems prudent to point a link here for eternity -- because there will be another NHS Security Audit with questions that don't fit R properly and the guys in the community may be best placed to answer them Linky: https

Re: [R] Asking about R "Security" ..

2023-05-17 Thread CALUM POLWART
Chris Presumably you've also pointed her to the NHS R community and in particular is slack group? There are so many variables in what was even being asked it's going to take some time to work through, did the mean R or R Studio or R Studio Cloud... Before any packages.. On Wed, 17 May 2023, 10:4

Re: [R] R does not run under latest RStudio

2023-04-07 Thread CALUM POLWART
Obviously running R is pretty fundamental to running R studio. So it seems rather odd to be thinking you'd need to stop using R studio unless you are doing something odd On Fri, 7 Apr 2023, 02:18 Sorkin, John, wrote: > I have also had difficulty running R in RStudio. Has anyone else had > proble

Re: [R] R does not run under latest RStudio

2023-04-07 Thread CALUM POLWART
R studio sometimes isn't happy with i386 versions. Although I thought they had put support back in. If you have the option for 64bit, use 64bit R. I've also had similar issues when R couldn't find the executable. But absolutely would expect if you post this on the community forum someone would be

Re: [R] connect MSSQL server problem

2023-03-17 Thread CALUM POLWART
This doesn't sound like it is R failing, it sounds like you don't know the appropriate connection details for the server. You need to find them out and come back rather than simply try different username and passwords... Can you connect to the server using any other ODBC connection and those crede

Re: [R] Date order question

2023-01-04 Thread CALUM POLWART
On Wed, 4 Jan 2023, 21:29 Ebert,Timothy Aaron, wrote: > > As you are plotting strings, you could put a space character in front of > the December dates so that they are first. > date<-c(" 12-29"," 12-30","01-01") > That fixes the problem in this example. You can order all the dates by > putting m

Re: [R] is it possible to run multiple rmd files together

2023-01-04 Thread CALUM POLWART
I get frustrated by our peers who reply "please provide a worked example" but OMG... Please provide a worked example! You can't use: source("filename.Rmd") as it isn't a simple set of R code. You can do: Rmarkdown::render("filename.Rmd") You can also knit child files. But it is completely uncl

Re: [R] Reg: To change the x axis label in ts.plot function

2022-12-24 Thread CALUM POLWART
https://stackoverflow.com/questions/49679699/time-series-plot-change-x-axis-format-in-r Is as good a solution as possible using ts I think. On Sat, 24 Dec 2022, 18:58 Upananda Pani, wrote: > Dear All, > I have the data set with daily dates (5-days trading in a week) and price > data. I want

Re: [R] datatable using dt not able to print background colors

2022-12-17 Thread CALUM POLWART
I don't think this is an R issue, it's a HTML tables issue // browser issue. There are some hacks using background image (not R specific). BUT before you do any of this... Consider if colour is your answer! 8% of males are colour blind, so your table isn't as accessible as you may think it is. T

Re: [R] getting data from a "vertical" table into a "2-dimensional" grid

2022-10-21 Thread CALUM POLWART
You asked for base R but also said or using other methods. So for completeness here is a solution using Tidyverse library(tidyverse) data_original <- data.frame( year = c('1990', '1999', '1990', '1989'), size = c('s', 'l', 'xl', 'xs'), n = c(99, 33, 3, 4) ) data_original |> pivot_wider(

Re: [R] removing non-table lines

2022-09-18 Thread CALUM POLWART
Can you provide a sample of say the first 3 rows then the last 2 rows before the CSV starts. Are there always the same number of lines at the top? Or can it vary depending what non-sense the Met Office decided to contaminate it with? This should be solvable with some sample data. Base R or Tidyv

Re: [R] Remove line from data file

2022-09-18 Thread CALUM POLWART
the change(s) using > Excel. > > > > For future reference, when I look at your solutions below, what do you > mean by “value to delete”? Could that just be a row number? I was wanting > to delete something like the 18th row in the dataframe? > > > > *From: *CALUM P

Re: [R] Remove line from data file

2022-09-18 Thread CALUM POLWART
>From the file? Or the data frame once its loaded? What format is the file? CSV? Do you know the line that needs deleted? mydf <- read.csv("myfile.csv") mydf2 <- mydf[-columnName == "valuetodelete", ] # Note the - infront of column name # or perhaps columnName != "value to delete", ] write.csv

Re: [R] Need to insert various rows of data from a data frame after particular rows from another dataframe

2022-07-26 Thread CALUM POLWART
Not very clear what you are trying to do. But I'd have thought possibly dplyr left_join might be a solution for you. The base R equivalent is merge(). It might be a rbind or cbind can do it too. On Wed, 27 Jul 2022, 03:30 Ranjeet Kumar Jha, wrote: > Hello Everyone, > > I have dataset in a part

Re: [R] Restoration of "rite" package of R as R-script editor or the like

2022-05-23 Thread CALUM POLWART
As has been said, it's not for R CRAN to fix. This is open source code. If the package maintainer is no longer keen anyone can fork the code, maintain it and release it back to Cran and provided it meets their rules it would be available for all. (If it doesn't you just need to provide the install

Re: [R] Not sure this is something R could do but it feels like it should be.

2013-06-09 Thread Calum Polwart
Calum Hi Calum, I can only answer from the perspective of someone who calculated doses of alcohol for experimental subjects many years ago. It was not possible to apply a linear function across the range due to a number of factors. One is that BAC, which was the target value, is dependent upon t

Re: [R] puzzling Date math result

2012-04-17 Thread Calum Polwart
On Tue, 17 Apr 2012 10:44:40 -0400, Denis Chabot wrote: > Hi, > > I cannot make a reproducible example easily for my problem, so I'll > describe it as best as I can. YOU KIND OF NEED ONE... >> a=test1$période[21] > >> b=test2$date[22] > a f > argin-left:5px; width:100%">b > > [1] "2011