Re: [R] rbind common header to file list

2021-01-19 Thread Jeff Newmiller
a) I recommend _not_ overwriting the input files. Very difficult to debug/recover if anything goes wrong. b) I recommend making a function that takes the file name, source directory, and destination directory, and reads the file, makes the change, and writes it to the output directory. c)

Re: [R] Error: cons memory exhausted (limit reached?): Memory Management?

2021-01-19 Thread Christopher Lloyd via R-help
Cheers Bert, Will do. Best wishes, Chris On Wednesday, 20 January 2021, 00:35:26 GMT, Bert Gunter wrote: You might do better posting this on r-sig-geo -- I believe you will more likely find the expertise you seek there. Could be wrong of course. Bert Gunter "The trouble with having

Re: [R] Error: cons memory exhausted (limit reached?): Memory Management?

2021-01-19 Thread Bert Gunter
You might do better posting this on r-sig-geo -- I believe you will more likely find the expertise you seek there. Could be wrong of course. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his

Re: [R] writing a function to work with dplyr::mutate()

2021-01-19 Thread Jeff Newmiller
I avoid case_when, so don't complain to me about it. Bert and I both suggested standard evaluation approaches that are very amenable to using lookup tables. On January 19, 2021 1:51:17 PM PST, Steven Rigatti wrote: >I use case_when a lot - but I have a lot of dynamic tables to treat >this >way

[R] rbind common header to file list

2021-01-19 Thread Miluji Sb
Dear all, I have more than 200 text files in a folder without header - example below. I would like to read, add a common date header to all the files, and write (replace) the files. ## Read files filelist = list.files(pattern = ".*.txt") datalist = lapply(filelist, function(x)read.table(x,

Re: [R] Monospaced font not shown correctly (Xubuntu 20.04)

2021-01-19 Thread Paul Murrell
Hi The switch to XUbunutu 20.04 may mean a switch to Pango > 1.44 (it does on Ubuntu 20.04), which means loss of support for Type 1 fonts (on Cairo-based graphics devices). The Courier fonts (the default for "mono" on Cairo-based devices) that you found are all Type 1 (.pfb) fonts. What

Re: [R] Different results on running Wilcoxon Rank Sum test in R and SPSS

2021-01-19 Thread John Fox
Dear Bharat Rawlley, What you tried to do appears to be nonsense. That is, you're treating PFD_n and drug_code as if they were scores for two different groups. I assume that what you really want to do is to treat PFD_n as a vector of scores and drug_code as defining two groups. If that's

Re: [R] writing a function to work with dplyr::mutate()

2021-01-19 Thread John Kane
David library(tidyverse) char_vec <- sample(c("a", "b", "c"), 10, replace = TRUE) recode(char_vec, a = "Apple") works for me. On Tue, 19 Jan 2021 at 15:13, David Winsemius wrote: > > On 1/19/21 11:17 AM, Bill Dunlap wrote: > > Your translate... function seems unnecessarily complicated and

[R] Error: cons memory exhausted (limit reached?): Memory Management?

2021-01-19 Thread Christopher Lloyd via R-help
Hi all, I think this is only the second time that I have posted so I apologise if my etiquette isn't quite correct. I'm loading a large (~30GB) geojson file into R using readOGR on a HPC. I am also loading a small shapefile, and then trying to undertake some processing on the large geojson

Re: [R] writing a function to work with dplyr::mutate()

2021-01-19 Thread David Winsemius
Sent from my iPhone > On Jan 19, 2021, at 1:52 PM, Steven Rigatti wrote: > > I use case_when a lot - but I have a lot of dynamic tables to treat this > way and case_when has to be hard-coded. But, but, but my case_when-based illustration let you pass a parameter dataframe that

Re: [R] writing a function to work with dplyr::mutate()

2021-01-19 Thread Steven Rigatti
I use case_when a lot - but I have a lot of dynamic tables to treat this way and case_when has to be hard-coded. On Tue, Jan 19, 2021 at 3:48 PM Jeff Newmiller wrote: > Second this. There is also the findInterval function, which omits the > factor attributes and just returns integers that can

Re: [R] writing a function to work with dplyr::mutate()

2021-01-19 Thread Jeff Newmiller
Second this. There is also the findInterval function, which omits the factor attributes and just returns integers that can be used in lookup tables. On January 19, 2021 10:33:59 AM PST, Bert Gunter wrote: >If you are willing to entertain another approach, have a look at ?cut. >By >defining the

Re: [R] writing a function to work with dplyr::mutate()

2021-01-19 Thread David Winsemius
On 1/19/21 11:17 AM, Bill Dunlap wrote: Your translate... function seems unnecessarily complicated and reusing the name 'var' for both the input and the data.frame containing the input makes it confusing to me. The following replacement, f, uses your algorithm but I think gets the answer you

Re: [R] writing a function to work with dplyr::mutate()

2021-01-19 Thread Bill Dunlap
Your translate... function seems unnecessarily complicated and reusing the name 'var' for both the input and the data.frame containing the input makes it confusing to me. The following replacement, f, uses your algorithm but I think gets the answer you want. f <- function(var, upper, lookup) {

Re: [R] writing a function to work with dplyr::mutate()

2021-01-19 Thread Steven Rigatti
It's not that I can't get the output I want. I was able to do that. It is just that I can't make it pipeable - I get that weird error message that I don't understand. On Tue, Jan 19, 2021 at 1:34 PM Bert Gunter wrote: > If you are willing to entertain another approach, have a look at ?cut. By >

Re: [R] writing a function to work with dplyr::mutate()

2021-01-19 Thread David Winsemius
On 1/19/21 7:50 AM, Steven Rigatti wrote: I am having some problems with what seems like a pretty simple issue. I have some data where I want to convert numbers. Specifically, this is cancer data and the size of tumors is encoded using millimeter measurements. However, if the actual

Re: [R] writing a function to work with dplyr::mutate()

2021-01-19 Thread Bert Gunter
If you are willing to entertain another approach, have a look at ?cut. By defining the 'breaks' argument appropriately, you can easily create a factor that tells you which values should be looked up and which accepted as is. If I understand correctly, this seems to be what you want. If I have not,

[R] writing a function to work with dplyr::mutate()

2021-01-19 Thread Steven Rigatti
I am having some problems with what seems like a pretty simple issue. I have some data where I want to convert numbers. Specifically, this is cancer data and the size of tumors is encoded using millimeter measurements. However, if the actual measurement is not available the coding may imply a less

Re: [R] [SPAM] Re: Different results on running Wilcoxon Rank Sum test in R and SPSS

2021-01-19 Thread Michael Dewey
See comments inline On 19/01/2021 10:46, bharat rawlley wrote: Thank you for the reply and suggestion, Michael! I used dput() and this is the output I can share with you. Simply explained, I have 3 columns namely, drug_code, freq4w_n and PFD_n. Each column has 132 values (including NA). The

[R] Monospaced font not shown correctly (Xubuntu 20.04)

2021-01-19 Thread Viechtbauer, Wolfgang (SP)
Hi all, On my system (Xubuntu 20.04), using par(family="mono") is not rendered correctly. The same issue was raised here: https://stackoverflow.com/questions/64207220/rendering-plot-in-r-with-mono-spaced-family-font-does-not-display-characters-any Using par(family="monospace") does work:

Re: [R] Errors and OS Differences with as.POSIXct and as.POSIXlt

2021-01-19 Thread Bill Denney
There are many caveats about OS specificity on the strptime help page, but most of them have to do with formatting and fewer with validation. My reading of the strptime page indicates that conversion with as.POSIXct() will validate daylight savings times which the examples I gave indicate it is

Re: [R] parallel: socket connection behind a NAT router

2021-01-19 Thread Jiefei Wang
Thanks! This solution also looks promising. It should be more stable than using ssh tunneling. I will also explore this method. Best, Jiefei On Tue, Jan 19, 2021 at 3:11 PM Martin Morgan wrote: > A different approach uses doRedis > https://CRAN.R-project.org/package=doRedis (currently

Re: [R] parallel: socket connection behind a NAT router

2021-01-19 Thread Jiefei Wang
Thank you! It works now!! Your guess is correct, I'm using windows so the default ssh does not work. Sadly the bug hasn't been fixed yet. The PuTTY solution works like a charm. Glad to know the ssh tunneling trick. This is much simpler than using port hole punching. This package is awesome! Many

Re: [ESS] ess-watch over tramp

2021-01-19 Thread Lionel Henry via ESS-help
This is https://github.com/emacs-ess/ESS/issues/1047 Best, Lionel On 1/19/21, Jeremie Juste via ESS-help wrote: > Hello, > > I would like to use ess-watch from a remote session but I receive the > follow error. When I execute M-x ess-watch > > Error in as.environment("ESSR") : > no item called

Re: [R] Different results on running Wilcoxon Rank Sum test in R and SPSS

2021-01-19 Thread bharat rawlley via R-help
Thank you for the reply and suggestion, Michael!  I used dput() and this is the output I can share with you. Simply explained, I have 3 columns namely, drug_code, freq4w_n and PFD_n. Each column has 132 values (including NA). The problem with the Wilcoxon Rank Sum test has been described in my

Re: [R] Different results on running Wilcoxon Rank Sum test in R and SPSS

2021-01-19 Thread Michael Dewey
Unfortunately your data did not come through. Try using dput() and then pasting that into the body of your e-mail message. On 18/01/2021 17:26, bharat rawlley via R-help wrote: Hello, On running the Wilcoxon Rank Sum test in R and SPSS, I am getting the following discrepancies which I am

Re: [R] Errors and OS Differences with as.POSIXct and as.POSIXlt

2021-01-19 Thread Rui Barradas
Hello, R 4.0.3 on Ubuntu 20.04, sessionInfo() below. A fix is to use as.POSIXct instead: rui@rui:~$ Rscript --vanilla -e 'as.POSIXlt("2018-03-11 02:09", tz="America/New_York")' #[1] "2018-03-11 02:09:00 EDT" rui@rui:~$ Rscript --vanilla -e 'as.POSIXct("2018-03-11 02:09",

[ESS] ess-watch over tramp

2021-01-19 Thread Jeremie Juste via ESS-help
Hello, I would like to use ess-watch from a remote session but I receive the follow error. When I execute M-x ess-watch Error in as.environment("ESSR") : no item called "ESSR" on the search list The problem seems to lie with, as.environment("ESSR") that cannot be found on the remote on my

Re: [R] Errors and OS Differences with as.POSIXct and as.POSIXlt

2021-01-19 Thread Jeff Newmiller
This is as described in the documentation, due to OS differences, e.g [1]. [1] https://stat.ethz.ch/R-manual/R-devel/library/base/html/strptime.html On January 18, 2021 5:56:11 PM PST, Bill Denney wrote: >Hello, > > > >Dates created with as.POSIXct differ between Windows/Mac and Linux.

[R] Errors and OS Differences with as.POSIXct and as.POSIXlt

2021-01-19 Thread Bill Denney
Hello, Dates created with as.POSIXct differ between Windows/Mac and Linux. Specifically this time that is during a gap when the hour does not exist due to daylight savings time: as.POSIXct("2018-03-11 02:09:36", tz="America/New_York") Gives on Windows: [1] "2018-03-11 EST" Gives on