Re: [R] Forestplot, grid graphics Viewplot grid.arange

2022-10-13 Thread Jim Lemon
Hi Mary, I didn't see any answers to your post, but doing something like this is quite easy in base graphics. If you are still stuck, I may be able to suggest something. Jim On Mon, Oct 10, 2022 at 6:05 PM Putt, Mary wrote: > > > I have created several plots using the forestplot package and the

Re: [R] cat in a subroutine

2022-10-13 Thread Steven T. Yen
Hello, Oh Lord, yes, I had a function called "cat", with argument "j". That was very dumb. Renaming function cat resolved the problem. I had lived with this problem too long---avoiding printing with cat altogether in this program. Thanks to all-Bill, Iva, Jim, Erin, Andrew for help! On 10/

Re: [R] intersection in data frame

2022-10-13 Thread Dénes Tóth
Or if your data is really large, you can try data.table::dcast(). > library(data.table) > dcast(ID ~ station, data = as.data.table(df1)) ID xy xz 1: 12 15 20 2: 13 16 19 (Note: instead of `as.data.table()`, you can use `setDT` or create your object as a data.table in the first place.) On

Re: [R] intersection in data frame

2022-10-13 Thread Rui Barradas
Hello, To reshape from long to wide format, here are two options: df1 <- 'IDstation value 12 xy15 12 xz20 13 xy 16 13 xz 19' df1 <- read.table(textConnection(df1), header = TRUE) # base R reshape(df1, direction = "wide", idvar = "ID", tim

Re: [R] intersection in data frame

2022-10-13 Thread Ben Tupper
Hi, If you are game to use a tidy approach then you can use tidyr::pivot_wider() library(dplyr) library(tidyr) x <- dplyr::tribble( ~ID, ~station, ~value, 12, "xy", 15, 12, "xz", 20, 13, "xy", 16, 13, "xz", 19) tidyr::pivot_wider(x, names_from = station,

[R] intersection in data frame

2022-10-13 Thread Gábor Malomsoki
Dears, i need to create from a column of observations variables in a datafram like this way: example: original: IDstation value 12 xy15 12 xz20 13 xy 16 13 xz 19 new df: ID xy xz 12 15 20 13 16 19 i have been loo

[R] [R-pkgs] gsDesign 3.4.0 is released

2022-10-13 Thread Nan Xiao
Dear all, A new version of gsDesign (3.4.0) is now on CRAN (https://cran.r-project.org/package=gsDesign). gsDesign supports group sequential clinical trial design, largely as presented in Jennison and Turnbull (2000). This version removes restrictions on conditional power calculations for inte

Re: [R] UTF-8 to the console

2022-10-13 Thread Tomas Kalibera
On 6/23/22 13:36, Ivan Krylov wrote: On Thu, 23 Jun 2022 12:26:23 +0200 Helmut Schütz wrote: txt <- "x ≥ y, x \u2265 y; a ≈ b, a \u2248 b" Encoding(txt) <- "UTF-8" There shouldn't be a need to change the encoding. If you're creating a Unicode literal, R should already choose UTF-8 for the r

Re: [R] UTF-8 to the console

2022-10-13 Thread Tomas Kalibera
Dear Helmut, thanks for the report, this is actually a bug in Rterm (or Windows, hard to tell, but something that can be fixed in Rterm). More below On 6/23/22 12:26, Helmut Schütz wrote: Dear all, I want to send UTF-8 characters to the console. Font in the GUI-Preference 'Lucida Console',

Re: [R] prcomp - arbitrary direction of the returned principal components

2022-10-13 Thread John C Nash
This reminds me of a situation in 1975 where a large computer service bureau had contracted to migrate scientific software from a Univac 1108 to a an IBM System 360. They spent 3 weeks trying to get the IBM to give the same eigenvectors on a problem as the Univac. There were at least 2 eigenvalue

Re: [R] cat in a subroutine

2022-10-13 Thread Bill Dunlap
Do you have another function called "cat" in scope? (with an argument called "j")? Before calling cat("...") call print(cat) and print(find("cat")). -Bill On Thu, Oct 13, 2022 at 12:35 AM Steven T. Yen wrote: > I have had an issue with printing (with cat) in a subroutine for which I > do not

Re: [R] prcomp - arbitrary direction of the returned principal components

2022-10-13 Thread Ashim Kapoor
Dear All, Many thanks for your replies. My PC1 loading turns out to be : 1/sqrt(2) , -1/sqrt(2) In simple words : I had 2 variables and I ran prcomp on them. I got my PC1 as : .7071068 var1 - .7071068 var2 PC2 turned out to be the same as PC1 with a PLUS replacing the minus, ie. .7071068 var1

Re: [R] Problem with Windows clipboard and UTF-8

2022-10-13 Thread Tomas Kalibera
Hi Andrew, On 9/30/22 15:05, Andrew Hart via R-help wrote: Hi everyone, Recently I upgraded to R 4.2.1 which now uses UTF-8 internally as its native encoding. Very nice. However, I've discovered that if I use writeClipboard to try and move a string containing accented characters to the Windo

[R] replicate results of tree package

2022-10-13 Thread Naresh Gurbuxani
I am trying to understand ``deviance'' in classification tree output from tree package. library(tree) set.seed(911) mydf <- data.frame( name = as.factor(rep(c("A", "B"), c(10, 10))), x = c(rnorm(10, -1), rnorm(10, 1)), y = c(rnorm(10, 1), rnorm(10, -1))) mytree <- tree(name ~ ., da

Re: [R] prcomp - arbitrary direction of the returned principal components

2022-10-13 Thread Ebert,Timothy Aaron
I still do not understand. However, the general approach would be to identify a specific value to test. If the test is TRUE then do "this" otherwise do nothing. Once the test condition is properly identified, the coding easily follows. abs() is the same as if x<0 then x = -x (non-R code, jus

Re: [R] prcomp - arbitrary direction of the returned principal components

2022-10-13 Thread Ivan Krylov
В Wed, 12 Oct 2022 17:18:26 +0530 Ashim Kapoor пишет: > My problem is that I am building an index based on Principal > Components Analysis. > When the index is high it should indicate stress in the market. Have you considered using supervised methods, like PLS, to predict stress in the market?

Re: [R] cat in a subroutine

2022-10-13 Thread Ivan Krylov
В Thu, 13 Oct 2022 15:49:57 +0800 "Steven T. Yen" пишет: > No. Removing the second line (so that cat simply prints something > else), > > cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit > Probabilities") > #    "\n\nlogistic =",logistic) > > I get yet another nonsense: > >

Re: [R] cat in a subroutine

2022-10-13 Thread Steven Yen
No. I just run the subroutine containing those line, with result going to destination go probit1.r.me.it and printed it. Steven from iPhone > On Oct 13, 2022, at 5:09 PM, Jim Lemon wrote: > > Have you assigned the valuie of goprobit1.r.me.kr to "fortytwo", or > indeed anything? > > Jim > >>

Re: [R] cat in a subroutine

2022-10-13 Thread Jim Lemon
Have you assigned the valuie of goprobit1.r.me.kr to "fortytwo", or indeed anything? Jim On Thu, Oct 13, 2022 at 8:02 PM Steven T. Yen wrote: > > Not really. > > fortytwo<-42 > cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit > Probabilities", > "logisitic =",fortytwo,"\n"

Re: [R] cat in a subroutine

2022-10-13 Thread Steven T. Yen
Not really. fortytwo<-42 cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit Probabilities",     "logisitic =",fortytwo,"\n") > goprobit1.r.me.kr<-me.gologit.r(goprobit1,embellished=TRUE, + resampling=TRUE,ndraws=5); goprobit1.r.me.kr Error in ca

Re: [R] cat in a subroutine

2022-10-13 Thread Jim Lemon
Hi Steven & Erin, This works: fortytwo<-42 cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit Probabilities","logisitic =",fortytwo,"\n") j<-grep(".one\\b",c(".one\\a",".one\\b")) Marginal and Discrete Effects of Gen Ordered Logit / Probit Probabilities logisitic = 42 If I don't

Re: [R] cat in a subroutine

2022-10-13 Thread Steven Yen
t<-abs(me)/se; p<-2*(1-pt(t,nrow(x))) sig<-my.sig.levels(p) out<-data.frame(round(cbind(me,se,t,p),digits)); out<-cbind(out,sig) rownames(out)<-names(me) colnames(out)<-c("est","se","t","p","sig") cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit Probabilities", "\n\nlogistic

Re: [R] cat in a subroutine

2022-10-13 Thread Erin Hodgess
Steven, would you mind putting that section of code in again, with the cat statement, please? I have an idea... Erin Hodgess, PhD mailto: erinm.hodg...@gmail.com On Thu, Oct 13, 2022 at 2:13 AM Jim Lemon wrote: > Hi Steven, > I think Erin is right, unless there is a variable named "logistic" >

Re: [R] cat in a subroutine

2022-10-13 Thread Steven Yen
Yes, these lines are part of a subroutine calling yet more procedures. What frustrated me was, I am not doing anything different from other routines. My cat command in the recent code does not do anything other than printing a line of plain text. I am clueless. Steven from iPhone > On Oct 13,

Re: [R] cat in a subroutine

2022-10-13 Thread Jim Lemon
Hi Steven, I think Erin is right, unless there is a variable named "logistic" visible within the function, "cat" will think it is either an argument or an R object. If you have the "psych" package loaded, it may see it as a closure. There is also a "Logistic" in the stats package, but that shouldn'

Re: [R] cat in a subroutine

2022-10-13 Thread Steven T. Yen
Thanks Erin. No. Removing the second line (so that cat simply prints something else), cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit Probabilities") #    "\n\nlogistic =",logistic) I get yet another nonsense: Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logi

Re: [R] cat in a subroutine

2022-10-13 Thread Erin Hodgess
All right. Are these lines of code part of a larger function, please? Is that function possibly calling a loop, please? Thanks, Erin On Thu, Oct 13, 2022 at 1:49 AM Steven T. Yen wrote: > Thanks Erin. > > No. Removing the second line (so that cat simply prints something else), > > cat("\nMarg

Re: [R] cat in a subroutine

2022-10-13 Thread Erin Hodgess
Hi Steven: Do you have a variable called logistic, please? I think that might be the culprit. Thanks, Erin On Thu, Oct 13, 2022 at 1:35 AM Steven T. Yen wrote: > I have had an issue with printing (with cat) in a subroutine for which I > do not have a applicable example, but I am still hoping

[R] cat in a subroutine

2022-10-13 Thread Steven T. Yen
I have had an issue with printing (with cat) in a subroutine for which I do not have a applicable example, but I am still hoping to get some help. In the following, the first block of code works fine. ... t<-abs(me)/se; p<-2*(1-pt(t,nrow(x))) sig<-my.sig.levels(p) out<-data.frame(round(cbind(m