Re: [R] Mean absolute error from data matrix

2021-06-23 Thread PIKAL Petr
Hi. First, please do not post in HTML. It usually scrambles any posted code. Second, as you did not post any code or data your message was not scrambled but I wonder what are columns and what are rows and what do you actually calculates. From Suppose the ist column of the > second matrix is S

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Avi Gross via R-help
Just a caution. There IS an operator of `!!` in the tidyverse called "bang bang" that does a kind of substitution and you can look up the help page for it as: ?`!!` I just tried it on an example and it definitely will in some cases do this other evaluation. I doubt this will clash, but of cou

Re: [R] Special characters in cell names

2021-06-23 Thread David Winsemius
On my keyboard the key is share with the tilde symbol and is up on the left hand corner. Sent from my iPhone > On Jun 23, 2021, at 2:45 PM, David Winsemius wrote: > > Backticks. NOT apostrophes. > > — David > > Sent from my iPhone > >> On Jun 23, 2021, at 2:40 PM, Mahmood Naderan wrote:

Re: [R] Special characters in cell names

2021-06-23 Thread Mahmood Naderan
OK I understand. Thanks a lot. Regards, Mahmood On Wed, Jun 23, 2021 at 11:46 PM Bert Gunter wrote: > Try: > ggplot(mydata, aes(x=W, y=`X/Y`)) + geom_violin(trim=FALSE) > > Note the use of *backticks*, ``, not single quotes, ' ' . ** They are > different.** > > So, yes, your data got read

Re: [R] Special characters in cell names

2021-06-23 Thread Bert Gunter
Try: ggplot(mydata, aes(x=W, y=`X/Y`)) + geom_violin(trim=FALSE) Note the use of *backticks*, ``, not single quotes, ' ' . ** They are different.** So, yes, your data got read in correctly, presumably because "/" is considered a character in your locale. It is not in mine. So my suggestion was i

Re: [R] Special characters in cell names

2021-06-23 Thread David Winsemius
Backticks. NOT apostrophes. — David Sent from my iPhone > On Jun 23, 2021, at 2:40 PM, Mahmood Naderan wrote: > > Hi Bert, > I don't know what does "check.names" do here, but my commands look like > > >> mydata <- read.csv('r.3080..csv', header=T,row.names=1) > >> head(mydata) >

Re: [R] Special characters in cell names

2021-06-23 Thread Mahmood Naderan
Hi Bert, I don't know what does "check.names" do here, but my commands look like > mydata <- read.csv('r.3080..csv', header=T,row.names=1) > head(mydata) W AX/Y P1 M 1.469734 0.004144405 P2M 20.584841 0.008010306 P3 M 53.519800 0.1660

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread William Michels via R-help
Hi Phillips, Maybe these examples will be useful: > vec <- c("a","b","c","d","e") > vec[c(1,1,1,0,0)] [1] "a" "a" "a" > vec[c(1,1,1,2,2)] [1] "a" "a" "a" "b" "b" > vec[c(5,5,5,5,5)] [1] "e" "e" "e" "e" "e" > vec[c(NA,NA,NA,0,0,0,0)] [1] NA NA NA > vec[c(NA,NA,NA,1,1,1,1)] [1] NA NA NA "a" "a"

Re: [R] Special characters in cell names

2021-06-23 Thread Bert Gunter
I found your specification quite vague. What did you mean by a "data file" -- a data frame in R? -- a file in the file system? I may be completely wrong here, but another possibility is that you read your data into an R data.frame via, e.g. read.table() or read.csv(), but failed to specify the che

Re: [R] Special characters in cell names

2021-06-23 Thread Mahmood Naderan
Unfortunately, using 'X/Y' doesn't work either. Instead I used labels like below P + scale_y_continuous(name="X/Y") Thanks for the suggestions. Regards, Mahmood On Wed, Jun 23, 2021 at 9:22 PM Eric Berger wrote: > If no one comes up with a better suggestion: > a. Change the column name to

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Jeff Newmiller
IMO that puts the cart before the horse. rlang implements these "operators" in very focused situations using custom expression parsing, and if they cannot tell the difference between numeric/logical and character data then rlang is broken. That said, I do think as.logical() is more direct than

Re: [R] Special characters in cell names

2021-06-23 Thread Eric Berger
If no one comes up with a better suggestion: a. Change the column name to "Y" so that you get the plot you want b. Use axis labels and legend text to show the text that you want. (The user never has to know that you changed the column name 😃) HTH, Eric On Wed, Jun 23, 2021 at 9:58 PM Mahmood Nade

Re: [R] interactively getting alist of functions for a given package?

2021-06-23 Thread Duncan Murdoch
On 23/06/2021 2:51 p.m., Jeff Newmiller wrote: RStudio seems to have done this. If you have it, try typing ggplot2::line and the popup will suggest (among other options) geom_line. Yes, though it may not be quite right. Back in May when I typed library(rgl their autocompletion gave me l

Re: [R] Wayland backend for R

2021-06-23 Thread Phillips Rogfield
Dear Robert, Thank you very much for your suggestion. I solved by compiling R with --with-cairo, and installing cairo-devel and pango-devel. Notably, you also need pango-devel. The configure script does not complain if it is missing, but then plotting won't work. Best regards. On 23/06/2021

Re: [R] Special characters in cell names

2021-06-23 Thread Duncan Murdoch
On 23/06/2021 11:38 a.m., Mahmood Naderan wrote: Hi I have a column in my data file which is "X/Y". With '/' I want to emphasize that values are the ratio of X over Y. Problem is that in the following command for a violin plot, I am not able to specify that '/' even with double quotes. p <- ggpl

Re: [R] Special characters in cell names

2021-06-23 Thread Bill Dunlap
Use backquotes, `X/Y`, to specify a name, not double quotes. -Bill On Wed, Jun 23, 2021 at 11:58 AM Mahmood Naderan wrote: > Hi > I have a column in my data file which is "X/Y". With '/' I want to > emphasize that values are the ratio of X over Y. > Problem is that in the following command for

[R] Special characters in cell names

2021-06-23 Thread Mahmood Naderan
Hi I have a column in my data file which is "X/Y". With '/' I want to emphasize that values are the ratio of X over Y. Problem is that in the following command for a violin plot, I am not able to specify that '/' even with double quotes. p <- ggplot(mydata, aes(x=W, y="X/Y")) + geom_violin(trim=FA

Re: [R] interactively getting alist of functions for a given package?

2021-06-23 Thread Jeff Newmiller
RStudio seems to have done this. If you have it, try typing ggplot2::line and the popup will suggest (among other options) geom_line. On June 23, 2021 10:10:07 AM PDT, Duncan Murdoch wrote: >On 23/06/2021 8:37 a.m., Greg Minshall wrote: >> hi. >> >> at the R prompt, i often hit, e.g., "data.t

Re: [R] Plot NUTS regions with color

2021-06-23 Thread Bert Gunter
I suggest you post this in the r-sig-geo list rather than here. The expertise you seek is more likely to be there. 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 "Bloom County" comic strip )

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Bill Dunlap
Note that !! and !!! are special operators involving "quasiquotation" in the dplyr package. I would use as.logical(x) instead of !!x since its meaning is clear to any user. -Bill On Wed, Jun 23, 2021 at 11:13 AM Jeff Newmiller wrote: > For the record, `!!` is not an operator so it does not "op

Re: [R] Wayland backend for R

2021-06-23 Thread Robert Knight
Perhaps software rendering would work. Export RSTUDIO_CHROMIUM_ARGUMENTS="--disable-gpu" /usr/lib/rstudio/bin/rstudio On Wed, Jun 23, 2021, 10:01 AM Phillips Rogfield wrote: > Hello Paul, > > thank you for your kind advice. > > RStudio doesn't start at all this way. It gives me the following

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Jeff Newmiller
For the record, `!!` is not an operator so it does not "operate" on anything. The right ! does per the help page (?`!`) interpret non-zero values as TRUE and invert that logic, yielding a logical result even if the input is not logical. The left ! inverts that again, yielding a logical vector wi

[R] Mean absolute error from data matrix

2021-06-23 Thread Faheem Jan via R-help
I have data matrix of order 24*2192 where 2192 are the days and 24 are hour's of a single day,so simple words I have 2192 days and each day having 24 observations.the data matrix is divided into two matrix,the ist matrix is of order 24*1827 and second is of order 24*365. Suppose the ist column o

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Phillips Rogfield
Dear all, thank for for your suggestion. Yes I come from languages where 1 means TRUE and 0 means FALSE. In particular from C/C++ and Python. Evidently this is not the case for R. In my mind I kind took for granted that that was the case (1=TRUE, 0=FALSE). Knowing this is not the case for R m

[R] Plot NUTS regions with color

2021-06-23 Thread Phillips Rogfield
Dear R-help ML, I have downloaded the NUTS shapefiles from here: https://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/administrative-units-statistical-units/nuts I can load them with the following code: library(rgdal) shp_bdir <- [PATH TO SHAPE FILE] layername <- "NUTS_RG_

Re: [R] interactively getting alist of functions for a given package?

2021-06-23 Thread Duncan Murdoch
On 23/06/2021 8:37 a.m., Greg Minshall wrote: hi. at the R prompt, i often hit, e.g., "data.table::", to try to find a routine in a give package. however, some packages have a *lot* of functions (i'm looking at *you*, ggplot2...), so if i know the routine name starts with, e.g., "set", i can fi

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Bert Gunter
Just as a way to save a bit of typing, instead of > as.logical(0:4) [1] FALSE TRUE TRUE TRUE TRUE > !!(0:4) [1] FALSE TRUE TRUE TRUE TRUE DO NOTE that the parentheses in the second expression should never be omitted, a possible reason to prefer the as.logical() construction. Also note th

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Avi Gross via R-help
This is unfortunately a bad habit many of us got from earlier languages like the C group of languages where 0 is FALSE and 1 (and anything non-zero) is TRUE. A language like Python is arguably even worse in that all kinds of things can be TRUE or FALSE in odd ways, like a non-empty string or even a

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Bill Dunlap
> a variable that equals 1 for the elements I want to select: > > t = c(1,1,1,0,0) How do you typically make such a variable? If you use something like t <- ifelse(x == "Yes", 1, 0) you should instead use t <- x == "Yes" Naming the variable something like 'isYes' instead of 't' might help

Re: [R] interactively getting alist of functions for a given package?

2021-06-23 Thread Greg Minshall
Bert, > ?ls and note the "pattern" argument. ... > ls("package:base", pat =".*set.*") awesome -- thanks! cheers, Greg __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Eric Berger
In my code, instead of 't', I name a vector of indices with a meaningful name, such as idxV, to make it obvious. Alternatively, a minor change in your style would be to replace your definition of t by t <- as.logical(c(1,1,1,0,0)) HTH, Eric On Wed, Jun 23, 2021 at 6:11 PM Phillips Rogfield wr

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Jeff Newmiller
I practically never construct vectors like your `t` so it isn't a problem. And since I make a habit of verifying the types of all vectors I am using in expressions, if it did come up I would notice. On June 23, 2021 8:06:05 AM PDT, Phillips Rogfield wrote: >I make the same mistake all over aga

[R] How to spot/stop making the same mistake

2021-06-23 Thread Phillips Rogfield
I make the same mistake all over again. In particular, suppose we have: a = c(1,2,3,4,5) and a variable that equals 1 for the elements I want to select: t = c(1,1,1,0,0) To select the first 3 elements. The problem is that a[t] would repeat the first element 3 times . I have to either

Re: [R] Mediation analysis takes up all RAM, then all swap, and then RStudio/terminal suddenly closes

2021-06-23 Thread Phillips Rogfield
Hello Bert, thank you for your kinds answer. No I didn't contact the maintainer of the package first, that's my fault :) I have come to the conclusion that the problem is that I don't have enough resources on my PC (RAM) for the task at hand. I have tried to run it on a remote VM with more RAM

Re: [R] Wayland backend for R

2021-06-23 Thread Phillips Rogfield
Hello Paul, thank you for your kind advice. RStudio doesn't start at all this way. It gives me the following error: $ QT_QPA_PLATFORM=wayland rstudio Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. QSocketNotifier: Can only be used wi

Re: [R] interactively getting alist of functions for a given package?

2021-06-23 Thread Bert Gunter
?ls and note the "pattern" argument. e.g. ls("package:base", pat =".*set.*") 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 "Bloom County" comic strip ) On Wed, Jun 23, 2021 at 5:38 AM Gre

[R] interactively getting alist of functions for a given package?

2021-06-23 Thread Greg Minshall
hi. at the R prompt, i often hit, e.g., "data.table::", to try to find a routine in a give package. however, some packages have a *lot* of functions (i'm looking at *you*, ggplot2...), so if i know the routine name starts with, e.g., "set", i can filter the returned list of routines by typing "da