Re: [R] Correlate

2022-08-26 Thread Bert Gunter
And just for fun, here is a more "functional" version without the explicit 'for()' loops that gives the lower triangular values of the counts of nonmissing values for each correlation: ## (using John's notation) w <- expand.grid(1:nc,1:nc) f <- \(x) ifelse(x[1] <= x[2], NA, nrow(na.omit(dat[,x])))

Re: [R] Correlate

2022-08-26 Thread Val
Thank you John for your help and advice. On Fri, Aug 26, 2022 at 11:04 AM John Fox wrote: > > Dear Val, > > On 2022-08-26 10:41 a.m., Val wrote: > > Hi John and Timothy > > > > Thank you for your suggestion and help. Using the sample data, I did > > carry out a test run and found a difference in

Re: [R] html into R

2022-08-26 Thread Rui Barradas
Hello, You are right, I haven't assigned the return value. Start the pipe with something like RiverTweed <- page |> rest_of_pipe If you have more files to download and process, post an example of 2 or 3 links and I'll see if it can be automated. Also posting to R-help. Hope this helps,

Re: [R] html into R

2022-08-26 Thread Rui Barradas
Sorry, there's simpler code. I used html_elements (plural) and the result is a list. Use html_element (singular) and the output is a tibble. page |> html_element("table") |> html_table(header = TRUE) |> (\(x) { hdr <- unlist(x[3, ]) y <- x[-(1:3), ] names(y) <- hdr y })(

Re: [R] html into R

2022-08-26 Thread Rui Barradas
Hello, You can try the following. It worked with me. Read from the link and post-process the html data extracting the element "table" and then the table itself. This table has 3 rows before the actual table so the lapply below will get the table and its header. library(httr) library(rvest)