Re: [R] Help

2024-02-04 Thread Jinsong Zhao
?plotmath expression(R^2==0.62) On 2024/2/4 18:10, Jibrin Alhassan wrote: I have done a scatter plot in R. I want to insert the coefficient of determination R^2 = 0.62 as a text in the plot. I have tried to write R^2 but could not produce R2. I would appreciate it if someone could help me with

Re: [R] linear programming in R | limits to what it can do, or my mistake?

2024-01-30 Thread Jinsong Zhao
On 2024/1/30 20:00, Martin Becker wrote: Apart from the fact that the statement "such that t1+t2+t3+t4=2970 (as it must)" is not correct, the LP can be implemented as follows: I was confused by "such that t1+t2+t3+t4=2970 (as it must)", otherwise, I also get the same solution. library(lpSol

Re: [R] is.na(strptime (...)) return TRUE on FreeBSD

2023-05-12 Thread Jinsong Zhao
On 2023/5/12 18:16, Rasmus Liland wrote: Hi! I ran the code (d <- strptime("1970-01-01 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz = "")) is.na(d) dput(unclass(d)) as.POSIXct(d) (d <- is.na(strptime("1970-01-03 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz = '

Re: [R] is.na(strptime (...)) return TRUE on FreeBSD

2023-05-11 Thread Jinsong Zhao
On 2023/5/11 23:06, Ivan Krylov wrote: В Thu, 11 May 2023 22:15:49 +0800 Jinsong Zhao пишет: > (d <- strptime("1970-01-01 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz > = "")) [1] "1970-01-01 12:00:00 CST" > is.na(d) [1] TRUE Glad to se

Re: [R] is.na(strptime (...)) return TRUE on FreeBSD

2023-05-11 Thread Jinsong Zhao
On 2023/5/12 1:34, Rainer Hurling wrote: Am 11.05.23 um 16:15 schrieb Jinsong Zhao: Hi there, The following codes may cause the problem in R 4.3.0 on FreeBSD in my last post: Error in as.POSIXlt.character(x, tz, ...)  > (d <- strptime("1970-01-01 12:00:00 UTC", "%Y

Re: [R] is.na(strptime (...)) return TRUE on FreeBSD

2023-05-11 Thread Jinsong Zhao
On 2023/5/11 23:06, Ivan Krylov wrote: В Thu, 11 May 2023 22:15:49 +0800 Jinsong Zhao пишет: > (d <- strptime("1970-01-01 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz > = "")) [1] "1970-01-01 12:00:00 CST" > is.na(d) [1] TRUE Glad to se

[R] is.na(strptime (...)) return TRUE on FreeBSD

2023-05-11 Thread Jinsong Zhao
Hi there, The following codes may cause the problem in R 4.3.0 on FreeBSD in my last post: Error in as.POSIXlt.character(x, tz, ...) > (d <- strptime("1970-01-01 12:00:00 UTC", "%Y-%m-%d %H:%M:%OS", tz = "")) [1] "1970-01-01 12:00:00 CST" > is.na(d) [1] TRUE In R 4.3.0 on windows, > (d <- st

Re: [R] Error in as.POSIXlt.character(x, tz, ...)

2023-05-11 Thread Jinsong Zhao
The origin of this problem is when I try to update rstan package in R 4.3.0 on FreeBSD. I get the same error as that https://github.com/stan-dev/rstan/issues/612 However, I did not encounter this problem when using R 4.2.x or 4.1.x on FreeBSD. Best, Jinsong On 2023/5/11 16:56, Jinsong Zhao

Re: [R] Error in as.POSIXlt.character(x, tz, ...)

2023-05-11 Thread Jinsong Zhao
On 2023/5/11 17:22, Ivan Krylov wrote: В Thu, 11 May 2023 16:56:41 +0800 Jinsong Zhao пишет: When I run the following code in R 4.3.0 on FreeBSD, I got error. > as.POSIXct("1970-01-01 00:00.00 UTC") Error in as.POSIXlt.character(x, tz, ...) : character string is not

Re: [R] Error in as.POSIXlt.character(x, tz, ...)

2023-05-11 Thread Jinsong Zhao
aracter(x, tz, ...) : character string is not in a standard unambiguous format I copy the code from a web page. It works in R 4.3.0 on Windows and R 4.1.2 on an old CentOS. Best, Jinsong On May 11, 2023 1:56:41 AM PDT, Jinsong Zhao wrote: Hi there, When I run the following code in R 4.3.0 on F

[R] Error in as.POSIXlt.character(x, tz, ...)

2023-05-11 Thread Jinsong Zhao
Hi there, When I run the following code in R 4.3.0 on FreeBSD, I got error. > as.POSIXct("1970-01-01 00:00.00 UTC") Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format The same code could give correct answer in R 4.3.0 on Windows, and R 4.1.2

[R] single character in R, and how to manipulate it

2023-03-30 Thread Jinsong Zhao
Hi there, I just noticed that "crt" is a graphical parameter, which is stated as follows in the help page of "par": A numerical value specifying (in degrees) how single characters should be rotated. It is unwise to expect values other than multiples of 90 to work... However, I did not find an

Re: [R] bgroup not rendering properly

2022-12-13 Thread Jinsong Zhao
On 2022/12/13 18:02, Martin Maechler wrote: Jinsong Zhao on Tue, 13 Dec 2022 17:07:00 +0800 writes: > I don > On 2022/12/13 10:13, Derek Ogle wrote: >> bgroup() from plotmath does not render properly for >> me. For example >> >

Re: [R] bgroup not rendering properly

2022-12-13 Thread Jinsong Zhao
I don On 2022/12/13 10:13, Derek Ogle wrote: bgroup() from plotmath does not render properly for me. For example plot(0,xlim=c(0,1),ylim=c(0,1)) text(0.3,0.5,expression(bgroup('(',atop(x,y),')'))) text(0.7,0.5,expression(group('(',atop(x,y),')'))) and library(ggplot2) ggplot(mtcars, aes(wt, m

Re: [R] shaded area between a curve and a circle

2022-10-23 Thread Jinsong Zhao
The figure is not ok. The coordinate of the normal curve is not the same as that of the circle. In fact, there are only four intersections other than eight that your figure show. Best, Jinsong On 2022/10/23 3:05, L... L... wrote: Dear, I have a picture in which I draw a circle over the stand

Re: [R] unexpected 'else' in " else"

2022-10-21 Thread Jinsong Zhao
Dear John, Thank you very much for the explanation. It cleared up my confusion about the syntax of "if ... else...", which in the help page of "if" said: ``` In particular, you should not have a newline between ‘}’ and ‘else’ to avoid a syntax error in entering a ‘if ... else’ constru

Re: [R] unexpected 'else' in " else"

2022-10-21 Thread Jinsong Zhao
change it to if (is.matrix(r)) {     r[w != 0, , drop = FALSE] } else r[w != 0] or {     if (is.matrix(r))         r[w != 0, , drop = FALSE]     else r[w != 0] } or if (is.matrix(r)) r[w != 0, , drop = FALSE] else r[w != 0] On Fri., Oct. 21, 2022, 05:29 Jinsong Zhao, wrote: Hi there

[R] unexpected 'else' in " else"

2022-10-21 Thread Jinsong Zhao
Hi there, The following code would cause R error: > w <- 1:5 > r <- 1:5 > if (is.matrix(r)) + r[w != 0, , drop = FALSE] > else r[w != 0] Error: unexpected 'else' in "else" However, the code: if (is.matrix(r)) r[w != 0, , drop = FALSE]

Re: [R] how to enlarge the legend

2022-10-09 Thread Jinsong Zhao
ext, ltext) Best, Uwe Ligges On 09.10.2022 16:54, Jinsong Zhao wrote: Hi there, in the following code, I'd like to enlarge the filled box but not the legend text. plot.new() legend("topleft", "text", fill = "gray") # filled box is too small legend("to

[R] how to enlarge the legend

2022-10-09 Thread Jinsong Zhao
Hi there, in the following code, I'd like to enlarge the filled box but not the legend text. plot.new() legend("topleft", "text", fill = "gray") # filled box is too small legend("top", "text", fill = "gray", cex = 2) # filled box is ok but text is too large # I can use point to mimic fill

[R] apply to row and column of matrix

2022-09-26 Thread Jinsong Zhao
Hi there, I try to calculate the cumsum of row and column of a matrix as follows. > m <- matrix(1:10, ncol = 2) > m [,1] [,2] [1,]    1    6 [2,]    2    7 [3,]    3    8 [4,]    4    9 [5,]    5   10 > apply(m, 1, cumsum) [,1] [,2] [,3] [,4] [,5] [1,]    1    2    3    4    5 [2,]   

[R] expand a matrix

2022-09-05 Thread Jinsong Zhao
Hi there, I have a matrix likes: > m [,1] [,2] [,3] [,4] [1,] NA123 [2,]1 NA65 [3,]26 NA4 [4,]354 NA I hope to expand it to 10 by 10 matrix, M, likes: > M [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] NA NA NA

[R] polygon is not filled by color with alpha when outside of plot region

2021-10-21 Thread Jinsong Zhao
Hi there, Here is the codes that could demo the problem: # work as expected plot(1:5) polygon(c(1.5, 6.5, 6.5, 1.5), c(1.5, 1.5, 6.5, 6.5), col = "gray") # the polygon at right upper is not filled by gray with alpha = 0.5 plot(1:5) polygon(c(1.5, 6.5, 6.5, 1.5), c(1.5, 1.5, 6.5, 6.5), col = ad

Re: [R] small object but huge RData file exported

2021-10-21 Thread Jinsong Zhao
now and save that. On October 20, 2021 11:09:10 PM PDT, Jinsong Zhao wrote: This example has demoed the similar or same characteristics of my question. If I save(formula, file = "abc.RData") and then in a new launched R session, I load("abc.RData") formula x ~ y I w

Re: [R] small object but huge RData file exported

2021-10-20 Thread Jinsong Zhao
728 bytes # Actual serialization size length(serialize(formula, connection = NULL)) [1] 8000203 # A better size estimate lobstr::obj_size(formula) 8,000,888 B /Henrik On Wed, Oct 20, 2021 at 12:57 PM Duncan Murdoch wrote: On 20/10/2021 9:20 a.m., Jinsong Zhao wrote: On 2021/10/20 21:0

Re: [R] small object but huge RData file exported

2021-10-20 Thread Jinsong Zhao
On 2021/10/20 21:05, Duncan Murdoch wrote: On 20/10/2021 8:57 a.m., Jinsong Zhao wrote: Hi there, I have a RData file that is obtained by save.image() with size about 74.0 MB (77,608,222 bytes). When load into R, I measured the size of each object with object.size(): object.size(combn.rda.m

[R] small object but huge RData file exported

2021-10-20 Thread Jinsong Zhao
Hi there, I have a RData file that is obtained by save.image() with size about 74.0 MB (77,608,222 bytes). When load into R, I measured the size of each object with object.size(): object.size(combn.rda.m) 105448 bytes object.size(cross) 102064 bytes object.size(denitr.1) 25032 bytes ob

Re: [R] question about the difference of AIC()

2021-05-12 Thread Jinsong Zhao
On 2021/5/12 19:49, Jinsong Zhao wrote: Hi there, I learned that AIC = 2 * npar - 2 * log(logLik(model)), where k is the number of estimated parameters in the model. k should be npar in the above sentence. Sorry for the mistake. For examle: > set.seed(123) > y <- rnorm(15) >

[R] question about the difference of AIC()

2021-05-12 Thread Jinsong Zhao
Hi there, I learned that AIC = 2 * npar - 2 * log(logLik(model)), where k is the number of estimated parameters in the model. For examle: > set.seed(123) > y <- rnorm(15) > fm <- lm(y ~ 1) In this example, npar should be 1, so, AIC is: > 2*1 - 2 * logLik(fm) 'log Lik.' 38.49275 (df=2) However

Re: [R] ISO recommendations for plot output format from R to MS Word

2021-02-12 Thread Jinsong Zhao
On 2021/2/13 7:05, Robert Dodier wrote: I need to export plots (constructed with plot and with ggplot) from R to be imported into a MS Word document. I am working with MS Word for Mac version 16.16.10 (copyright 2018) and R versions 3.6.3 and/or 4.0.3. I have verified that the version of MS Wor

Re: [R] write.csv covert Åland to land

2020-10-20 Thread Jinsong Zhao
ing what your encoding is. On Tue, 20 Oct 2020 at 08:22, Jinsong Zhao <mailto:jsz...@yeah.net>> wrote: Hi there, Why the same string is displayed in different form?  > abc[,1] [1] "Åland"       "Afghanistan"  > abc           na

Re: [R] write.csv covert Åland to land

2020-10-20 Thread Jinsong Zhao
t; dget("aa.txt")[,1] [1] "land""Afghanistan" Best, Jinsong On 2020/10/20 17:13, Jinsong Zhao wrote: Hi there, I tried to export the names of country to a csv file with write.csv(). In the resulted file, Åland was coverted to land. Is there any way could preve

Re: [R] write.csv covert Åland to land

2020-10-20 Thread Jinsong Zhao
On 2020/10/20 17:23, Dr Eberhard W Lisse wrote: ?file.write() look for fileEncoding? el There is no file.write(). I have tried fileEncoding = "utf8" and "latin1" in write.csv(). However, it does not have effect. The output is is land or land. Best, Jinsong On 20/10

[R] write.csv covert Åland to land

2020-10-20 Thread Jinsong Zhao
Hi there, I tried to export the names of country to a csv file with write.csv(). In the resulted file, Åland was coverted to land. Is there any way could prevent this happening? Thanks! > abc [1] "Åland" > write.table(abc, file = "") "x" "1" "land" Best, Jinsong

[R] text on curve

2020-09-22 Thread Jinsong Zhao
Hi there, I write a simple function that could place text along a curve. Since I am not familiar with the operation of rotating graphical elements, e.g., text, rectangle, etc., I hope you could give suggestions or hints on how to improve it. Thanks in advance. # Here is the code: getCurrentAs

Re: [R] tempdir() does not respect TMPDIR

2020-08-30 Thread Jinsong Zhao
er load ~/.Renviron (e.g. C:/Users\alice/Documents/.Renviron) unless the .RData file is in that folder too. This looks odd to me but it could be that I made another mistake in my conclusions above. I let someone else with a less mushy brain take over from here. /Henrik On Sat, Aug 29,

Re: [R] tempdir() does not respect TMPDIR

2020-08-30 Thread Jinsong Zhao
could be that I made another mistake in my conclusions above. I let someone else with a less mushy brain take over from here. /Henrik On Sat, Aug 29, 2020 at 4:31 PM Jinsong Zhao wrote: I read the help page, I don't understand it very well, since I set the environmental variable TMPDIR in

Re: [R] tempdir() does not respect TMPDIR

2020-08-29 Thread Jinsong Zhao
ed before the interpreter is started.** /Henrik On Sat, Aug 29, 2020 at 6:40 AM Jinsong Zhao wrote: Hi there, When I started R by double clicking on Rgui icon (I am on Windows), the tempdir() returned the tmpdir in the directory I set in .Renviron. If I started R by double clicking on a

[R] tempdir() does not respect TMPDIR

2020-08-29 Thread Jinsong Zhao
Hi there, When I started R by double clicking on Rgui icon (I am on Windows), the tempdir() returned the tmpdir in the directory I set in .Renviron. If I started R by double clicking on a *.RData file, the tempdir() return the tmpdir in the directory setting by Windows system. I don't know whe

[R] how to extract specific subscript of a matrix

2020-06-10 Thread Jinsong Zhao
Hi there, I have a matrix similar as: M <- matrix(c(2,2,rep(1,12), 2), nrow = 5,byrow = FALSE) I hope to get the border subscript of the block with value 1. In the above example, I hope to get: (3,1), (5,1), (5,2), (4,2), (4,3), (1,3), (1,2), (3,2) Is there any function can do that? or any

Re: [R] [FORGED] Re: paste workable code to R 4.0.0 cause error

2020-04-28 Thread Jinsong Zhao
" or by using copy-and-paste. Must be Windoze thing.  Switch to Linux! cheers, Rolf Turner n 29/04/20 2:25 pm, Jinsong Zhao wrote: > On 2020/4/29 8:05, Jinsong Zhao wrote: >> Hi there, >> >> I have a piece of source code with some i

Re: [R] paste workable code to R 4.0.0 cause error

2020-04-28 Thread Jinsong Zhao
On 2020/4/29 8:05, Jinsong Zhao wrote: Hi there, I have a piece of source code with some inline comments in Chinese. It works well when I copy it from a editor (gvim here), and paste it to Rgui console on R 3.6.3, however, when I do the same thing, R 4.0.0 give error message: Error

[R] paste workable code to R 4.0.0 cause error

2020-04-28 Thread Jinsong Zhao
Hi there, I have a piece of source code with some inline comments in Chinese. It works well when I copy it from a editor (gvim here), and paste it to Rgui console on R 3.6.3, however, when I do the same thing, R 4.0.0 give error message: Error: invalid multibyte character in parser at line 2

Re: [R] help.start() caused high CPU loading

2020-04-28 Thread Jinsong Zhao
On 2020/4/28 15:44, Abby Spurdle wrote: Again, if R was using 25% while showing the prompt and waiting for user input, that would be a bug in R. 25% CPU is used by R. And R shows the prompt and waits for user input. Here is a report of the CPU usage by Rgui from Windows command line: C:\Users\

Re: [R] help.start() caused high CPU loading

2020-04-27 Thread Jinsong Zhao
ot; "04/28/2020 13:43:46.168","1.244979" "04/28/2020 13:43:51.188","4.054443" "04/28/2020 13:43:56.209","0.00" "04/28/2020 13:44:01.239","0.310505" ... At 51", start Rgui, and 06" call help.start() fro

Re: [R] help.start() caused high CPU loading

2020-04-27 Thread Jinsong Zhao
On 2020/4/28 3:40, Abby Spurdle wrote: (3) If (2) true, how much CPU is R using? 0%. (4) If (3) is zero, what processes are using the CPU the most? In such case, almost every processes is using the CPU in a very low percentage, i.e., 1% or below. I don't recognized those processes. Now, I in

Re: [R] help.start() caused high CPU loading

2020-04-27 Thread Jinsong Zhao
someone here maybe able to offer advise... Thanks for those suggestions. Best, Jinsong On Mon, Apr 27, 2020 at 7:51 PM Jinsong Zhao wrote: Hi there, After calling help.start(), I noticed that CPU loading is up to about 25% (my CPU is core i5 with 4 core). In the out html page, if I click "P

[R] help.start() caused high CPU loading

2020-04-27 Thread Jinsong Zhao
Hi there, After calling help.start(), I noticed that CPU loading is up to about 25% (my CPU is core i5 with 4 core). In the out html page, if I click "Packages", the CPU loading may be up to 75% or much higher. After closing the browser, the CPU loading does not drop. If I just use ?plot to

Re: [R] .libPaths() can not deal non-latin characters?

2019-10-21 Thread Jinsong Zhao
te: The folder must exist. If not, .libPaths() *silently* ignores it. Could that be it? Henrik On Mon, Oct 21, 2019, 02:32 Jinsong Zhao <mailto:jsz...@yeah.net>> wrote: Hi there, I have a computer run Win10 with user names in Chinese. I installed R on it. It can run n

[R] .libPaths() can not deal non-latin characters?

2019-10-21 Thread Jinsong Zhao
Hi there, I have a computer run Win10 with user names in Chinese. I installed R on it. It can run normally. When I installed a package, for example, ada, then the library would be installed into "C:/Users/中文/Documents/R/win-library/3.6", where "中文" is my user name. > library(ada) Error in li

[R] how to use a matrix as an index to another matrix?

2019-10-11 Thread Jinsong Zhao
Hi there, I have two matrices, A and B. The columns of B is the index of the corresponding columns of A. I hope to rearrange of A by B. A minimal example is following: > set.seed(123) > A <- matrix(sample(1:10), nrow = 5) > B <- matrix(c(sample(1:5), sample(1:5)), nrow =5, byrow = FALSE) > A

[R] how to keep colnames of matrix when put it into a data frame

2018-12-09 Thread Jinsong Zhao
Hi there, In the following mini-example, I hope to keep the column names of mat, but failed. # mini-example > mat <- matrix(1:9, nrow = 3) > colnames(mat) <- paste("(", 1:3, ")", sep = "") > mat (1) (2) (3) [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 > data.frame(x = 1:3, mat) x X.

Re: [R] how to pass arguments to panel.cor in pairs()

2018-10-09 Thread Jinsong Zhao
On 2018/10/9 23:22, Duncan Murdoch wrote: On 09/10/2018 10:53 AM, Jinsong Zhao wrote: Hi there, Here is the panel.cor function from ?pairs:   panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...)   {   usr <- par("usr"); on.exit(par(usr

[R] how to pass arguments to panel.cor in pairs()

2018-10-09 Thread Jinsong Zhao
Hi there, Here is the panel.cor function from ?pairs: panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...) { usr <- par("usr"); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r <- abs(cor(x, y)) txt <- format(c(r, 0.123456789), digits = digi

[R] MASS::boxcox "object not found"

2018-08-05 Thread Jinsong Zhao
Hi there, I wrote a function that wraps MASS::boxcox as: bc <- function(vec) { lam <- boxcox(lm(vec ~ 1)) lam <- lam$x[which.max(lam$y)] (vec^lam - 1)/lam } When I invoke it as: > x <- runif(20) > bc(x) Error in eval(predvars, data, env) : object 'vec' not found I have googled, and re

[R] how to locate specific line?

2018-07-27 Thread Jinsong Zhao
Hi there, I have a large/huge text file. I need to locate a line in the file with a specific string, for example, "Data Points". Now, I use the following code to do: df <- readLines(file) l <- grep("Data Points", df) However, in this case, the file will be read throughout into R. When the f

[R] strange behavior of plotmath

2018-05-21 Thread Jinsong Zhao
hi there, I find the following codes produce strange output. plot(1:10, xlab = expression(NO[3]^-~(mg/L))) you will notice that the unit, mg/L is in superscript format. That means that "~" is not for space. However, the help page of plotmath does not mention this behavior. Best, Jinsong

[R] difference between ifelse and if...else?

2017-12-13 Thread Jinsong Zhao
Hi there, I don't know why the following codes are return different results. > ifelse(3 > 2, 1:3, length(1:3)) [1] 1 > if (3 > 2) 1:3 else length(1:3) [1] 1 2 3 Any hints? Best, Jinsong __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more

[R] How to code the factor for ANOVA

2017-06-25 Thread Jinsong Zhao
Hi there, I have a experimental design related question. I have done a experiment with 3 factors. The design matrix is similar to: data.frame(Factor.1 = rep(rep(0:2, each = 3),3), Factor.2 = rep(c("U","S","N"), 9), Factor.3 = rep(0:2, each = 9)) Factor.1 Factor.2 Factor.3 1 0

Re: [R] how to assign a value to a specific position of a list

2017-05-01 Thread Jinsong Zhao
;parse") If the answer is parse() you should usually rethink the question. -- Thomas Lumley R-help (February 2005) --- It is much easier to handle this using a data structure containing a list of lists: l <- rep(list(list()), 10) for ( i in 1:10 ) l[[i]][[1]] <- 5

Re: [R] how to assign a value to a specific position of a list

2017-04-30 Thread Jinsong Zhao
On 2017/4/30 23:17, Jinsong Zhao wrote: Hi there, I have a problem with assign(). Here is the demo code: for (i in 1:10) { # create a list with variable name as list_1, list_2, ..., etc. assign(paste("list_", i, sep = ""), list()) # I hope to assign 5 to list_?[[1

[R] how to assign a value to a specific position of a list

2017-04-30 Thread Jinsong Zhao
Hi there, I have a problem with assign(). Here is the demo code: for (i in 1:10) { # create a list with variable name as list_1, list_2, ..., etc. assign(paste("list_", i, sep = ""), list()) # I hope to assign 5 to list_?[[1]], but I don't know how to code it. # list_1[[1]] <- 5 # wo

Re: [R] [FORGED] difference metric info of same font on different device

2017-04-10 Thread Jinsong Zhao
postscript() with CIDFont setting. Best, Jinsong On 7/04/2017 8:05 p.m., Jinsong Zhao wrote: Hi there, I try to plot with custom fonts, which have good shape Latin and CJK characters. I set up all the fonts correctly. However, when I plot the same code on png() and postscript(), I get different r

Re: [R] difference metric info of same font on different device

2017-04-08 Thread Jinsong Zhao
On 2017/4/7 23:13, Jeff Newmiller wrote: I think it is a fundamental characteristic of graphics drivers that output will look different in the details... you are on a wild goose chase. Postscript in particular has a huge advantage in font presentation over other graphics output mechanisms.

Re: [R] difference metric info of same font on different device

2017-04-08 Thread Jinsong Zhao
On 2017/4/7 23:13, Jeff Newmiller wrote: I think it is a fundamental characteristic of graphics drivers that output will look different in the details... you are on a wild goose chase. Postscript in particular has a huge advantage in font presentation over other graphics output mechanisms.

[R] difference metric info of same font on different device

2017-04-07 Thread Jinsong Zhao
Hi there, I try to plot with custom fonts, which have good shape Latin and CJK characters. I set up all the fonts correctly. However, when I plot the same code on png() and postscript(), I get different result. The main problem is the space between characters is narrower in postscript() than

[R] ! in expression(!abc) that produces !(abc).

2017-03-28 Thread Jinsong Zhao
Hi there, I happened to find the expression(!abc) produces !(abc) when I used plotmath in a text annotation. Here is the mini-example. > plot(1, type = "n") > text(1,1, expression(!abc)) I don't find "!" in plotmath document. By the way, how to reduce the space between two adjacent strings,

Re: [R] [FORGED] Can fallback font be specified?

2017-03-27 Thread Jinsong Zhao
;') Does that help at all? Paul Thank you very much. The code solve my concerns about fonts. gridGraphics make me to draw my plot in base graphics that I used to. I can convert SVG to any other format using Inkscape. Best, Jinsong On 24/03/2017 3:24 a.m., Jinsong Zhao wrote: Hi th

Re: [R] Can fallback font be specified?

2017-03-26 Thread Jinsong Zhao
use fontforge core dump. I don't have chance to test it. Will the R core team or someone response to it, if I filed a wishlist in R bugzilla? Best, Jinsong On 2017/3/23 22:24, Jinsong Zhao wrote: Hi there, I am a Chinese R user. I hope to plot the following code with Chinese in one f

[R] Can fallback font be specified?

2017-03-23 Thread Jinsong Zhao
Hi there, I am a Chinese R user. I hope to plot the following code with Chinese in one font family, such as SimHei, but English in another font family, such as Times New Roman. plot(1:10, type = "n", xlab = "Hello \u4F60\u597D", family = "serif") In my case, the system default font is "SimSu

[R] same column name in a data frame

2017-03-13 Thread Jinsong Zhao
Hi there, I happened to find the following code can generate a data frame with same column name. > x <- data.frame(a=c(1,2,3)) > y <- data.frame(a=c(2,3,4)) > z <- cbind(x,y) However, in this case, one can not use the $ to extract the second column, right? Is it possible to prevent the cbi

Re: [R] different between read.table and read.delim

2016-12-22 Thread Jinsong Zhao
22, 2016 at 10:24 PM, Jinsong Zhao wrote: Hi there, I have a data set file, called "ecotox.rep", which is a delimited file separated with "|". When I tried to read the file with the following command, df <- read.table("ecotox.rep", sep = "|", header

[R] different between read.table and read.delim

2016-12-22 Thread Jinsong Zhao
Hi there, I have a data set file, called "ecotox.rep", which is a delimited file separated with "|". When I tried to read the file with the following command, > df <- read.table("ecotox.rep", sep = "|", header = TRUE, stringsAsFactors=FALSE) I got the error messages: Error in scan(file =

[R] does save.image() also save the random state?

2016-02-05 Thread Jinsong Zhao
Dear there, Here is a snipped code, > rm(list = ls()) > x <- 123 > save.image("abc.RData") > rm(list = ls()) > load("abc.RData") > sample(10) [1] 3 7 4 6 10 2 5 9 8 1 > rm(list = ls()) > load("abc.RData") > sample(10) [1] 3 7 4 6 10 2 5 9 8 1 you will see that, after loading

[R] difference between write.csv(...) and write.table(..., sep=", ")

2015-08-16 Thread Jinsong Zhao
Hi there, I notice that write.csv is a wrap of write.table. However, I can't get the same results using both functions. Here is a reproducible example: > x <- matrix(1:6, nrow =2) > rownames(x) <- letters[1:2] > colnames(x) <- LETTERS[1:3] > write.csv(x, "") "","A","B","C" "a",1,3,5 "b",2,4,6

[R] ANOVA for nested design

2015-05-15 Thread Jinsong Zhao
Hi there, The following is a simple design. A and B are factors with their levels randomly selected. In other words, A and B are random. The data is recorded in "abc", as: > dput(abc) structure(list(water = c(12.1, 12.1, 12.8, 12.8, 14.4, 14.4, 14.7, 14.5, 23.1, 23.4, 28.1, 28.8), A = structur

[R] Where is the R Graph Gallery?

2015-04-18 Thread Jinsong Zhao
Hi there, Does anyone here know where does the R Graph Gallery (http://addictedtor.free.fr/graphiques/) move to? I googled, but don't find any useful hints. Any help? Thanks in advance! Best, Jinsong __ R-help@r-project.org mailing list -- To UNSU

[R] [off-topic] R Homepage

2015-04-17 Thread Jinsong Zhao
Hi there, It's a off-topic post. It seems that the R home page changed a lot. There are no plot at the right frame. Why are they removed? Will it or an alternative be back in future? Another question is about the ``What's New?'' page. The latest announcement is not archived in that page. In

Re: [R] class of strptime() output

2015-01-05 Thread Jinsong Zhao
On 2015/1/5 20:51, David Winsemius wrote: On Jan 5, 2015, at 5:47 PM, Jinsong Zhao wrote: On 2015/1/5 17:28, Ben Bolker wrote: Jinsong Zhao yeah.net> writes: In the following code snippet, # a <- strptime("121114 0510", "%m%d%y %H%M") b <- data.frame(date = a

Re: [R] class of strptime() output

2015-01-05 Thread Jinsong Zhao
On 2015/1/5 17:28, Ben Bolker wrote: Jinsong Zhao yeah.net> writes: In the following code snippet, # a <- strptime("121114 0510", "%m%d%y %H%M") b <- data.frame(date = a, res = 1:5) class(a) class(b[1,1]) # I am wondering why the class of a and b[1,1] are not the

[R] class of strptime() output

2015-01-05 Thread Jinsong Zhao
Hi there, In the following code snippet, # a <- strptime("121114 0510", "%m%d%y %H%M") b <- data.frame(date = a, res = 1:5) class(a) class(b[1,1]) # I am wondering why the class of a and b[1,1] are not the same. How to make the class of a and b[1,1] to be same? I would really appreciate you for

Re: [R] using pdf(file="") encount a Chinese garbled

2014-09-11 Thread Jinsong Zhao
On 2014/9/11 21:10, PO SU wrote: Dear expeRts, When i use the following codes: pdf(file="1.pdf",width=15) plot(1:3,main="你好") dev.off() #There were 12 warnings (use warnings() to see them) I find that "你好" can't show correctly in pdf file, but i just plot(1:3,main="你好")

Re: [R] depth of labels of axis

2014-09-05 Thread Jinsong Zhao
t regards, Jinsong -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: Thursday, September 4, 2014 2:25 PM To: Jinsong Zhao Cc: r-help@r-project.org Subject: Re: [R] depth of labels of axis On Sep 3, 2014, at 10:0

Re: [R] depth of labels of axis

2014-09-05 Thread Jinsong Zhao
On 2014/9/4 12:24, David Winsemius wrote: On Sep 3, 2014, at 10:05 PM, Jinsong Zhao wrote: On 2014/9/3 21:33, Jinsong Zhao wrote: On 2014/9/2 11:50, David L Carlson wrote: The bottom of the expression is set by the lowest character (which can even change for subscripted letters with

Re: [R] depth of labels of axis

2014-09-03 Thread Jinsong Zhao
On 2014/9/3 21:33, Jinsong Zhao wrote: On 2014/9/2 11:50, David L Carlson wrote: The bottom of the expression is set by the lowest character (which can even change for subscripted letters with descenders. The solution is to get axis() to align the tops of the axis labels and move the line up to

Re: [R] depth of labels of axis

2014-09-03 Thread Jinsong Zhao
epartment of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jinsong Zhao Sent: Monday, September 1, 2014 6:41 PM To: r-help@r-project.org Subject: [R] depth

Re: [R] depth of labels of axis

2014-09-03 Thread Jinsong Zhao
On 2014/9/1 20:39, David Winsemius wrote: On Sep 1, 2014, at 4:40 PM, Jinsong Zhao wrote: Hi there, With the following code, plot(1:5, xaxt = "n") axis(1, at = 1:5, labels = c(expression(E[g]), "E", expression(E[j]), "E", expression(E[t]))) you may notice that

[R] depth of labels of axis

2014-09-01 Thread Jinsong Zhao
Hi there, With the following code, plot(1:5, xaxt = "n") axis(1, at = 1:5, labels = c(expression(E[g]), "E", expression(E[j]), "E", expression(E[t]))) you may notice that the "E" within labels of axis(1) are not at the same depth. So the vision of axis(1) labels is something like wave. Is

Re: [R] loading saved files with objects in same names

2014-08-22 Thread Jinsong Zhao
s.1, df.1, jags.1, Mean, N In this case, how to access the masked objects? Best, Jinsong On Mon, Aug 18, 2014 at 5:30 PM, Jinsong Zhao wrote: Hi there, I have several saved data files (e.g., A.RData, B.RData and C.RData). In each file, there are some objects with same names but different cont

Re: [R] loading saved files with objects in same names

2014-08-18 Thread Jinsong Zhao
lap TIBCO Software wdunlap tibco.com Thank you very much. It is what I want. new.environment() is not defined in R 3.1.1. There is new.env(). Best, Jinsong On Mon, Aug 18, 2014 at 5:30 PM, Jinsong Zhao wrote: Hi there, I have several saved data files (e.g., A.RData, B.RData and C.RData).

Re: [R] principle component values on PCA plots do not match

2014-08-18 Thread Jinsong Zhao
Hi, There is a scale factor associated with biplot when plotting the PCA result. Please read the help page of biplot.princomp or/and the source code of this function. HIH, Jinsong On 2014/8/18 16:31, John Romansic wrote: Hi all, I am using prcomp to do Principle Components Analysis and hav

[R] loading saved files with objects in same names

2014-08-18 Thread Jinsong Zhao
Hi there, I have several saved data files (e.g., A.RData, B.RData and C.RData). In each file, there are some objects with same names but different contents. Now, I need to compare those objects through plotting. However, I can't find a way to load them into a workspace. The only thing I can d

Re: [R] efficient way to replace a range of numeric with a integer in a matrix

2014-08-11 Thread Jinsong Zhao
sitive numbers?) Bill Dunlap TIBCO Software wdunlap tibco.com Thank you very much. I think findInterval() is what I want. Regards, Jinsong On Mon, Aug 11, 2014 at 2:40 PM, Jinsong Zhao wrote: Hi there, I hope to replace a range of numeric in a matrix with a integer. For example, in the follo

[R] efficient way to replace a range of numeric with a integer in a matrix

2014-08-11 Thread Jinsong Zhao
Hi there, I hope to replace a range of numeric in a matrix with a integer. For example, in the following matrix, I want to use 1 to replace the elements range from 0.0 to 1.0, and all larger than 1. with 2. > (m <- matrix(runif(16, 0, 2), nrow = 4)) [,1] [,2] [,3] [,4

Re: [R] Size of win.metafile

2014-05-27 Thread Jinsong Zhao
may have something to do with the size of emf file. However, when setting it to 72 by windows.options, only the display size in screen has been changed. It don't affect the actual plot size when saving it as emf file. It also 384x384px instead of 288x288px. Best, Jinsong On May 27,

Re: [R] Size of win.metafile

2014-05-27 Thread Jinsong Zhao
ot is scaled at 75%. The original size is same as the one produced by ``win.metafile'' and inserted into Word. Now, it regresses to my original question. Best, Jinsong On May 27, 2014, at 12:28, Jinsong Zhao wrote: Jean, Thank you for checking the problem. I have the same softwar

Re: [R] Size of win.metafile

2014-05-27 Thread Jinsong Zhao
1.0, and Word 2010 version 14.0.7116.5000. Not sure why it works differently for you. Jean On Mon, May 26, 2014 at 2:34 PM, Jinsong Zhao mailto:jsz...@yeah.net>> wrote: Hi there, I hope to use the emf plot produced by R in Word. However, I have problems with setting the plot siz

[R] Size of win.metafile

2014-05-26 Thread Jinsong Zhao
Hi there, I hope to use the emf plot produced by R in Word. However, I have problems with setting the plot size. Here is a mini-example code: win.metafile("abcd.emf", height =4, width=4) plot(1:10) dev.off() I hope to get a emf plot with size 4x4in and pointsize 12pt. However, I got a plot w

[R] vector density plot

2014-03-29 Thread Jinsong Zhao
Hi there, Is there a function in R that can draw vector density plot? The vector density plot example can be found here: http://reference.wolfram.com/mathematica/ref/VectorDensityPlot.html As for the vector field plot, I found a function that has been posted in this mailing list: https://sta

Re: [R] is it possible to get the coordinate of mtext()?

2014-03-17 Thread Jinsong Zhao
On 2014/3/17 15:32, Jim Lemon wrote: On 03/18/2014 09:18 AM, Jinsong Zhao wrote: Hi there, I hope to rotate the Y label of axis(4) with -90 degree. I can typeset the Y label using text() with srt = -90. However, I cannot get the coordinate of the position that mtext() used. In other words, I

  1   2   >