[R] showing ticks for censored data in survfit() in the rms package
The answer to this may be obvious, but I was wondering in the rms package and the survfit(), how you can plot the censored time points as ticks. Take for example, library(survival) library(rms) foo - data.frame(Time=c(1,2,3,4,5,6,10), Status=c(1,1,0,0,1,1,1)) answer - survfit(Surv(foo$Time, foo$Status==1) ~1) # this shows the censored time points as ticks at Time = 3 and 4 plot(answer) # how do you achieve something similar with survplot() survplot(answer) Thanks, Andrew __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to handle no lines in input with pipe()
Thank you very much for your suggestion...that works perfectly. Thanks, Andrew On Mon, Apr 4, 2011 at 5:46 PM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On Mon, 4 Apr 2011, Andrew Yee wrote: This has to do with using pipe() and grep and read.csv() I have a .csv file that I grep using pipe() and read.csv() as follows: read.csv(pipe('grep foo bar.csv')) However, is there a way to have this command run when for example, there is no foo text in the bar.csv file? I get an error message (appropriately): Error in read.table(file = file, header = header, sep = sep, quote = quote, : no lines available in input Is there a way to inspect the output of pipe before passing it on to read.csv()? You have to read from a pipe to 'inspect' it. So tmp - readLines(pipe('grep foo bar.csv')) if(!length(tmp)) do something else else { res - read.csv(con - textConnection(tmp)) close(con) } OTOH, unless the file is enormous you could simply read it into R and use grep(value = TRUE) on the character vector. Thanks, Andrew __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to handle no lines in input with pipe()
This has to do with using pipe() and grep and read.csv() I have a .csv file that I grep using pipe() and read.csv() as follows: read.csv(pipe('grep foo bar.csv')) However, is there a way to have this command run when for example, there is no foo text in the bar.csv file? I get an error message (appropriately): Error in read.table(file = file, header = header, sep = sep, quote = quote, : no lines available in input Is there a way to inspect the output of pipe before passing it on to read.csv()? Thanks, Andrew __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] trouble installing R-patched (R-2.12.0) when TMPDIR is specified
I'm mortified to report that the location I set in TMPDIR was not a valid directory in the system I was using (I copied it from another system), so this is a mea culpa on my part! Andrew On Mon, Oct 18, 2010 at 7:46 AM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On Sun, 17 Oct 2010, Andrew Yee wrote: I noticed that if I specify the location of TMPDIR in .bashrc as follows on a Linux 64 bit system: export TMPDIR=/store/home/ayee/.tmp I get the following error message when installing R 'installing' or making? Looks like the latter. make[3]: Entering directory `/home/ayee/R-patched/src/library/base' building package 'base' make[4]: Entering directory `/home/ayee/R-patched/src/library/base' /bin/sh: line 8: /store/home/ayee/.tmp/R24402: No such file or directory mv: cannot stat `/store/home/ayee/.tmp/R24402': No such file or directory make[4]: *** [mkR] Error 1 make[4]: Leaving directory `/home/ayee/R-patched/src/library/base' make[3]: *** [all] Error 2 make[3]: Leaving directory `/home/ayee/R-patched/src/library/base' make[2]: *** [R] Error 1 make[2]: Leaving directory `/home/ayee/R-patched/src/library' make[1]: *** [R] Error 1 make[1]: Leaving directory `/home/ayee/R-patched/src' make: *** [R] Error 1 [rambo:~/R-patched]$ However, when I don't specify TMPDIR, it installs fine. Any suggestions/comments? Check if /store/home/ayee/.tmp exists and is writeable. I get that message only if it does not. From the manual Ensure that the environment variable TMPDIR is either unset (and /tmp exists and can be written in and scripts can be executed from) or points to a valid temporary directory (one from which execution of scripts is allowed). Thanks, Andrew [[alternative HTML version deleted]] Please do as we ask and not send HTML. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] trouble installing R-patched (R-2.12.0) when TMPDIR is specified
I noticed that if I specify the location of TMPDIR in .bashrc as follows on a Linux 64 bit system: export TMPDIR=/store/home/ayee/.tmp I get the following error message when installing R make[3]: Entering directory `/home/ayee/R-patched/src/library/base' building package 'base' make[4]: Entering directory `/home/ayee/R-patched/src/library/base' /bin/sh: line 8: /store/home/ayee/.tmp/R24402: No such file or directory mv: cannot stat `/store/home/ayee/.tmp/R24402': No such file or directory make[4]: *** [mkR] Error 1 make[4]: Leaving directory `/home/ayee/R-patched/src/library/base' make[3]: *** [all] Error 2 make[3]: Leaving directory `/home/ayee/R-patched/src/library/base' make[2]: *** [R] Error 1 make[2]: Leaving directory `/home/ayee/R-patched/src/library' make[1]: *** [R] Error 1 make[1]: Leaving directory `/home/ayee/R-patched/src' make: *** [R] Error 1 [rambo:~/R-patched]$ However, when I don't specify TMPDIR, it installs fine. Any suggestions/comments? Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] as.Date() add a day to a date
I'm trying to understand why as.Date() is converting a the modified date of a file from August 22 to August 23. foo - file.info(file.to.process) str(foo) 'data.frame': 1 obs. of 10 variables: $ size : num 5.37e+09 $ isdir : logi FALSE $ mode :Class 'octmode' int 436 $ mtime : POSIXct, format: 2010-08-22 23:14:52 $ ctime : POSIXct, format: 2010-09-13 11:34:31 $ atime : POSIXct, format: 2010-09-09 15:42:00 $ uid : int 503 $ gid : int 503 $ uname : chr ayee $ grname: chr ayee as.Date(foo$mtime) [1] 2010-08-23 In this case as.Date(foo$mtime) gives August 23. I would have expected August 22. Thanks, Andrew sessionInfo() R version 2.11.1 Patched (2010-09-11 r52901) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.Date() add a day to a date
Thanks David, now I wonder how you can have as.Date() render the date using local time rather than UTC. Andrew On Mon, Sep 13, 2010 at 12:08 PM, David Winsemius dwinsem...@comcast.netwrote: On Sep 13, 2010, at 11:56 AM, Andrew Yee wrote: I'm trying to understand why as.Date() is converting a the modified date of a file from August 22 to August 23. foo - file.info(file.to.process) str(foo) 'data.frame': 1 obs. of 10 variables: $ size : num 5.37e+09 $ isdir : logi FALSE $ mode :Class 'octmode' int 436 $ mtime : POSIXct, format: 2010-08-22 23:14:52 $ ctime : POSIXct, format: 2010-09-13 11:34:31 $ atime : POSIXct, format: 2010-09-09 15:42:00 $ uid : int 503 $ gid : int 503 $ uname : chr ayee $ grname: chr ayee as.Date(foo$mtime) [1] 2010-08-23 In this case as.Date(foo$mtime) gives August 23. I would have expected August 22. You are pretty close to midnight. Probably a TZ issue. Check your locale settings versus UTC/GMT. dt - as.POSIXct(2010-08-22 23:14:52) as.Date(dt) [1] 2010-08-23 Happens to me too, but when its 23:14 here, (US-EDT) it's the next day in Greenwich. The help page says: The last [POSIXct] is converted to days by ignoring the time after midnight in the representation of the time in UTC. That is not entirely clear to my reading, but I am forced to conclude that it means as.Date returns the Date in UTC terms rather than in local terms. -- David. Thanks, Andrew sessionInfo() R version 2.11.1 Patched (2010-09-11 r52901) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] as.Date() add a day to a date
Henrique, thanks for your suggestion. For my applications, character would have been sufficient, so your suggestion of using format() works fine too. Perhaps I should submit a feature request for as.Date() to let you specify local time. Thanks, Andrew On Mon, Sep 13, 2010 at 2:06 PM, Henrique Dallazuanna www...@gmail.comwrote: Try this: format(dt, '%Y-%m-%d'), if you want Date class: as.Date(format(dt, '%Y-%m-%d')) On Mon, Sep 13, 2010 at 2:24 PM, Andrew Yee y...@post.harvard.edu wrote: Thanks David, now I wonder how you can have as.Date() render the date using local time rather than UTC. Andrew On Mon, Sep 13, 2010 at 12:08 PM, David Winsemius dwinsem...@comcast.net wrote: On Sep 13, 2010, at 11:56 AM, Andrew Yee wrote: I'm trying to understand why as.Date() is converting a the modified date of a file from August 22 to August 23. foo - file.info(file.to.process) str(foo) 'data.frame': 1 obs. of 10 variables: $ size : num 5.37e+09 $ isdir : logi FALSE $ mode :Class 'octmode' int 436 $ mtime : POSIXct, format: 2010-08-22 23:14:52 $ ctime : POSIXct, format: 2010-09-13 11:34:31 $ atime : POSIXct, format: 2010-09-09 15:42:00 $ uid : int 503 $ gid : int 503 $ uname : chr ayee $ grname: chr ayee as.Date(foo$mtime) [1] 2010-08-23 In this case as.Date(foo$mtime) gives August 23. I would have expected August 22. You are pretty close to midnight. Probably a TZ issue. Check your locale settings versus UTC/GMT. dt - as.POSIXct(2010-08-22 23:14:52) as.Date(dt) [1] 2010-08-23 Happens to me too, but when its 23:14 here, (US-EDT) it's the next day in Greenwich. The help page says: The last [POSIXct] is converted to days by ignoring the time after midnight in the representation of the time in UTC. That is not entirely clear to my reading, but I am forced to conclude that it means as.Date returns the Date in UTC terms rather than in local terms. -- David. Thanks, Andrew sessionInfo() R version 2.11.1 Patched (2010-09-11 r52901) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] using as.numeric() without generating warning message
I'm interested in testing whether or not a character string is numeric or not as follows: is.na(as.numeric('3')) # returns F is.na(as.numeric('A')) # I'd like this to return T without issuing a warning about NAs introduced by coercion. I guess you could suppress the warning with options(warn=-1), but I was wondering if there's an alternative. Or perhaps an alternative that doesn't use as.numeric()? Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using as.numeric() without generating warning message
Thanks for the tip! Andrew On Fri, Apr 9, 2010 at 8:04 PM, Gabor Grothendieck ggrothendi...@gmail.comwrote: Try this: suppressWarnings(as.numeric(A)) On Fri, Apr 9, 2010 at 7:22 PM, Andrew Yee y...@post.harvard.edu wrote: I'm interested in testing whether or not a character string is numeric or not as follows: is.na(as.numeric('3')) # returns F is.na(as.numeric('A')) # I'd like this to return T without issuing a warning about NAs introduced by coercion. I guess you could suppress the warning with options(warn=-1), but I was wondering if there's an alternative. Or perhaps an alternative that doesn't use as.numeric()? Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] specifying header in sqldf() and RSQLite
I have a file that I'm planning on manipulating with sqldf(). The header for this file is malformed, and I was wondering if there's a way to specify the values of the header ahead of time. I can see there are T/F options for header in sqldf(... list(header=T, ...), but was wondering if there's a way to explicitly stated what the header should be. Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting multiple lines of text to a data frame
Phil, thanks for your suggestion of unstack, which is just what I was looking for. Andrew On Fri, Mar 5, 2010 at 11:52 PM, Phil Spector spec...@stat.berkeley.edu wrote: Andrew- Maybe something like this: dd = read.table(filename) unstack(dd,V2~V1) A. B. C. 1 1 2 10.0 2 34 20 6.7 3 2 78 35.0 - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Fri, 5 Mar 2010, Andrew Yee wrote: I'm trying to find a way for converting multiple lines of text into a table. I'm not sure if there's a way where you can use read.delim() to read in multiple lines of text and create the following data frame with something akin to rehape()?. Apologies if there is an obvious way to do this. A: 1 B: 2 C: 10 A: 34 B: 20 C: 6.7 A: 2 B: 78 C: 35 Convert the above lines into the following data frame A B C 1 2 10 34 20 6.7 2 78 35 Thanks, Andrew __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] converting multiple lines of text to a data frame
I'm trying to find a way for converting multiple lines of text into a table. I'm not sure if there's a way where you can use read.delim() to read in multiple lines of text and create the following data frame with something akin to rehape()?. Apologies if there is an obvious way to do this. A: 1 B: 2 C: 10 A: 34 B: 20 C: 6.7 A: 2 B: 78 C: 35 Convert the above lines into the following data frame A B C 1 2 10 34 20 6.7 2 78 35 Thanks, Andrew __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tiff() and antialias option
Uwe, you're right, it turns out that cairo hadn't been previously installed on the system. Andrew 2010/2/19 Uwe Ligges lig...@statistik.tu-dortmund.de On 19.02.2010 17:44, Andrew Yee wrote: I was wondering if someone could help with the antialias option in tiff(). I'm running R 2.9.2 on a Linux machine. I'm working on creating a tiff file and have tried different antialias parameters, e.g. default, none, gray, and subpixel, but don't seem to be seeing a difference in the output. Or perhaps I'm missing something obvious? Perhaps you are not using type=cairo ? Uwe Ligges Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] tiff() and antialias option
I was wondering if someone could help with the antialias option in tiff(). I'm running R 2.9.2 on a Linux machine. I'm working on creating a tiff file and have tried different antialias parameters, e.g. default, none, gray, and subpixel, but don't seem to be seeing a difference in the output. Or perhaps I'm missing something obvious? Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] pdf() and pagecentre option
Hi, I was wondering how you can create a pdf where the output is vertically justified with for example a one inch margin on top using pdf(). For example in pdf(file='test.pdf', paper='letter', pagecentre=F) ### code for plot ### dev.off() is there an option where it generate output that starts from the top of the page rather than printing from the bottom of the page. Or will this require some adjustment of settings in par()? Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how do you know which functions are being debugged?
This is kind of a dumb question: I know you can use isdebugged() to find out if a specific function is flagged for debugging, but is there a way to list all the functions that are flagged for debugging? Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how do you know which functions are being debugged?
Thanks everyone for the responses. As a suggestion, wouldn't it be useful, that when you run isdebugged() without any parameters, it would just report back the functions that are being flagged for debugging? Andrew On Fri, Oct 23, 2009 at 2:12 PM, Yihui Xie xieyi...@gmail.com wrote: Oops... I forgot to mention that 'envir' (or 'pos') should be specified in ls()/get() in my last reply if you are looking for debugged functions in environments other than .GlobalEnv. Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-6609 Web: http://yihui.name Department of Statistics, Iowa State University 3211 Snedecor Hall, Ames, IA On Fri, Oct 23, 2009 at 1:02 PM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 10/23/2009 1:28 PM, Andrew Yee wrote: This is kind of a dumb question: I know you can use isdebugged() to find out if a specific function is flagged for debugging, but is there a way to list all the functions that are flagged for debugging? No, R doesn't keep any master list, it sets a flag in each one. So you could iterate over all visible objects to find the ones that have the flag set (and this is quite slow, there are a lot of places to look), but there would always be the chance that one was hiding somewhere you didn't look. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] converting matrix of lists to a regular matrix
Take the following code: foo - list() foo[[1]] - list(a=1, b=2) foo[[2]] - list(a=11, b=22) foo[[3]] - list(a=111, b=222) result - do.call(rbind, foo) result[,'a'] In this case, result[,'a'] shows a list. Is there a more elegant way such that result is a regular matrix of vectors? I imagine there are manual ways of going about this, but I was wondering if there was an obvious step that I was missing. Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting matrix of lists to a regular matrix
Gabor, thanks for the reply. However, the output of matrix(list(1, 11, 111, 2, 22, 222), nc = 2, dimnames = list(NULL, c(a, b))) is a matrix of lists. foo - matrix(list(1, 11, 111, 2, 22, 222), nc = 2, dimnames = list(NULL, c(a, b))) foo[,'a'] # returns a list One possible solution is as follows, though I wonder if this step could be avoided in the first place through more careful coding of the preliminary steps: new.result - matrix(unlist(result), ncol=ncol(result), dimnames=list(NULL, colnames(result))) # I use unlist() Andrew On Sat, Oct 3, 2009 at 8:01 PM, Gabor Grothendieck ggrothendi...@gmail.comwrote: Try this: matrix(list(1, 11, 111, 2, 22, 222), nc = 2, dimnames = list(NULL, c(a, b))) or out - list(1, 11, 111, 2, 22, 222) dim(out) - c(3, 2) colnames(out) - c(a, b) On Sat, Oct 3, 2009 at 7:51 PM, Andrew Yee y...@post.harvard.edu wrote: Take the following code: foo - list() foo[[1]] - list(a=1, b=2) foo[[2]] - list(a=11, b=22) foo[[3]] - list(a=111, b=222) result - do.call(rbind, foo) result[,'a'] In this case, result[,'a'] shows a list. Is there a more elegant way such that result is a regular matrix of vectors? I imagine there are manual ways of going about this, but I was wondering if there was an obvious step that I was missing. Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] converting matrix of lists to a regular matrix
Thanks, as you suggested, do.call(rbind, lapply(foo, unlist)) does the trick. On Sat, Oct 3, 2009 at 8:30 PM, David Winsemius dwinsem...@comcast.netwrote: On Oct 3, 2009, at 7:51 PM, Andrew Yee wrote: Take the following code: foo - list() foo[[1]] - list(a=1, b=2) foo[[2]] - list(a=11, b=22) foo[[3]] - list(a=111, b=222) Instead, perhaps: do.call(rbind, lapply(foo, unlist)) a b [1,] 1 2 [2,] 11 22 [3,] 111 222 do.call(rbind, lapply(foo, unlist))[,a] [1] 1 11 111 result - do.call(rbind, foo) result[,'a'] class(result) # also matrix In this case, result[,'a'] shows a list. Is there a more elegant way such that result is a regular matrix of vectors? I imagine there are manual ways of going about this, but I was wondering if there was an obvious step that I was missing. Your example shows that a matrix can be constructed around a list, although I agree with you that this seems a bit unusual. -- David Winsemius, MD Heritage Laboratories West Hartford, CT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] treating a data symbol like a character
Hi, is there a way to treat a data symbol, e.g. one with pch = 16, as a character? Specifically, I'm interested in creating a line of text as follows using the text() function O alpha O beta O gamma where the O is pch 16 and filled with a specific color. Not sure if this is possible or not. Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] treating a data symbol like a character
Thanks for your help. I should have been more clear in my initial e-mail. I shouldn't have used 'alpha' or 'beta,' to avoid confusion with them as Greek symbols. I should have stated something like: O foo O abcd O John While I'm familiar with using legend to make the filled boxes, I'm interested in creating a one line legend of sorts, but manually using text() with both data symbols defined by pch and text on the same line. Or is this not possible? I guess at the end of the day, I could use both points() and text(). Thanks, Andrew On Thu, Jul 9, 2009 at 11:03 AM, Jorge Ivan Velez jorgeivanve...@gmail.comwrote: Hi Andrew, Do you want to put the symbols you described as a legend in a plot? If so, here is one way: x - rnorm(3) plot(x, pch = 16, cex = 1.1, col = 1:3) legend('topleft', ncol = 3, c(expression(alpha), expression(beta), expression(gamma)), pch = 16, cex = 1.1, col = 1:3) Is you do not want to use legend, but place the symbols in each plot, then: plot(x, pch = 16, cex = 1.1, col = 1:3) text(1.05,1.01*x[1], expression(alpha) ) text(2.05,1.01*x[2], expression(beta) ) text(2.95,1.01*x[3], expression(gamma) ) should get you close. See ?text, ?expression and ?legend for more information. HTH, Jorge On Thu, Jul 9, 2009 at 10:53 AM, Andrew Yee y...@post.harvard.edu wrote: Hi, is there a way to treat a data symbol, e.g. one with pch = 16, as a character? Specifically, I'm interested in creating a line of text as follows using the text() function O alpha O beta O gamma where the O is pch 16 and filled with a specific color. Not sure if this is possible or not. Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] treating a data symbol like a character
Great, that's a good starting point. Andrew On Thu, Jul 9, 2009 at 11:20 AM, Jorge Ivan Velez jorgeivanve...@gmail.comwrote: Hi Andrew, If I understand correctly, then # Data x - c(3,4,2) # Collection of text and symbols Text - c('foo', 'abcd', 'John') PCH - c('+','O','$') # Plotting plot(x, pch = PCH) legend('topright', pch = PCH, Text, ncol = 3) should be close to what you want. Note that the text() / points() combination could be avoided when using legend(). Best, Jorge On Thu, Jul 9, 2009 at 11:08 AM, Andrew Yee wrote: Thanks for your help. I should have been more clear in my initial e-mail. I shouldn't have used 'alpha' or 'beta,' to avoid confusion with them as Greek symbols. I should have stated something like: O foo O abcd O John While I'm familiar with using legend to make the filled boxes, I'm interested in creating a one line legend of sorts, but manually using text() with both data symbols defined by pch and text on the same line. Or is this not possible? I guess at the end of the day, I could use both points() and text(). Thanks, Andrew On Thu, Jul 9, 2009 at 11:03 AM, Jorge Ivan Velez wrote: Hi Andrew, Do you want to put the symbols you described as a legend in a plot? If so, here is one way: x - rnorm(3) plot(x, pch = 16, cex = 1.1, col = 1:3) legend('topleft', ncol = 3, c(expression(alpha), expression(beta), expression(gamma)), pch = 16, cex = 1.1, col = 1:3) Is you do not want to use legend, but place the symbols in each plot, then: plot(x, pch = 16, cex = 1.1, col = 1:3) text(1.05,1.01*x[1], expression(alpha) ) text(2.05,1.01*x[2], expression(beta) ) text(2.95,1.01*x[3], expression(gamma) ) should get you close. See ?text, ?expression and ?legend for more information. HTH, Jorge On Thu, Jul 9, 2009 at 10:53 AM, Andrew Yee wrote: Hi, is there a way to treat a data symbol, e.g. one with pch = 16, as a character? Specifically, I'm interested in creating a line of text as follows using the text() function O alpha O beta O gamma where the O is pch 16 and filled with a specific color. Not sure if this is possible or not. Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] what happened to the xlsReadWrite package
Thanks for the detailed clarification. Perhaps the page here http://cran.r-project.org/web/packages/xlsReadWrite/ could include these explanations as well. I imagine I'm not the only user with these questions! Thanks, Andrew On Fri, Jun 26, 2009 at 2:48 AM, Prof Brian Ripley rip...@stats.ox.ac.ukwrote: On Fri, 26 Jun 2009, David Scott wrote: Andrew Yee wrote: A naive question: what happened to the xlsReadWrite package? http://cran.r-project.org/web/packages/xlsReadWrite/ It says that it was removed from the CRAN repository. Note that it was archived, not removed entirely. That is done with packages that no longer install and we don't get an update. The immediate problem with xlsReadWrite was that it was Windows-only and would not install under Windows in pre-2.9.0. Are there any plans for it be available again? The second issue was binary code in the package which is at least heavily frowned on in the CRAN source repository (we host BRugs elsewhere for that reason). There was a problem with proprietary code. Only in so far as it was binary. There are a number of CRAN packages with non-open-source code. Pick up the latest version from Hans-Peter Suter's website http://treetron.googlepages.com/ Which says the problem was the binary code. David Scott _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Graduate Officer, Department of Statistics Director of Consulting, Department of Statistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] what happened to the xlsReadWrite package
A naive question: what happened to the xlsReadWrite package? http://cran.r-project.org/web/packages/xlsReadWrite/ It says that it was removed from the CRAN repository. Are there any plans for it be available again? Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] stripchart and ordering of plot
Take for example the following stripchart that's created: b - 1:5 a - 11:15 e - 21:25 f - -11:-15 foo - rbind(b,a,e,f) stripchart(foo ~ rownames(foo)) In this case, I would like the bottom part of the plot to be the f vector, followed by the e vector, etc. However, R reorders the matrix and plots according to the alphabetical order of the rownames of foo. Is there a way to plot the matrix in the current order of the rownames? Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] stripchart and ordering of plot
Thanks, that works great. Andrew On Fri, May 22, 2009 at 5:42 PM, William Dunlap wdun...@tibco.com wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Andrew Yee Sent: Friday, May 22, 2009 2:16 PM To: r-h...@stat.math.ethz.ch Subject: [R] stripchart and ordering of plot Take for example the following stripchart that's created: b - 1:5 a - 11:15 e - 21:25 f - -11:-15 foo - rbind(b,a,e,f) stripchart(foo ~ rownames(foo)) In this case, I would like the bottom part of the plot to be the f vector, followed by the e vector, etc. However, R reorders the matrix and plots according to the alphabetical order of the rownames of foo. Is there a way to plot the matrix in the current order of the rownames? If you supply a factor it will use the order of the factor levels. If you supply a character vector, it converts it into a factor and the converter puts the levels in alphabetical order by default. Hence one solution is to change that character vector into a factor with the desired order of levels: stripchart(foo ~ factor(rownames(foo), levels=c(f,e,a,b)) Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] segfault when running heatmap()
Hi, I was wondering if someone in the mailing list has any insight into this segfault error that I consistently find when running a script containing heatmap() in R 2.8.1 and 2.8.0 on a Linux 64-bit machine. Some points: 1. This occurs when running heatmap(). 2. Interestingly, if I source() the script or copy and paste the script in its entirety, this error occurs. However, if I run the commands individually, heatmap() will actually work. 3. I've had this error occur on two types of machines as follows. Intel 64bit, linux kernel 2.6.18-92.1.22.el5, gcc version 4.1.2 as well as AMD 64bit, linux kernel 2.6.9-5.ELsmp, gcc version 3.4.3 Here is the error messages that I receive when I debug(heatmap) and source() the script containing heatmap(). The sessionInfo() follows. Browse[1] debug: op - par(no.readonly = TRUE) Browse[1] *** caught segfault *** address 0x103c93d53, cause 'memory not mapped' Traceback: 1: function (display = , width, height, pointsize, gamma, bg, canvas, fonts, xpos, ypos, title, type, antialias) {if (display == .Platform$GUI == AQUA is.na(Sys.getenv(DISPLAY, NA))) Sys.setenv(DISPLAY = :0)new - list()if (!missing(display)) new$display - displayif (!missing(width)) new$width - width if (!missing(height)) new$height - heightif (!missing(gamma)) new$gamma - gammaif (!missing(pointsize)) new$pointsize - pointsizeif (!missing(bg)) new$bg - bg if (!missing(canvas)) new$canvas - canvasif (!missing(xpos)) new$xpos - xposif (!missing(ypos)) new$ypos - yposif (!missing(title)) new$title - titleif (!checkIntFormat(new$title)) stop(invalid 'title')if (!missing(type)) new$type - match.arg(type, c(Xlib, cairo, nbcairo))if (!missing(antialias)) {new$antialias - pmatch(antialias, c(default, none, gray, subpixel)) if (is.na(new$antialias)) stop(invalid value for 'antialias')}d - check.options(new, name.opt = .X11.Options, envir = .X11env)type - if (capabilities(cairo)) switch(d$type, cairo = 1, nbcairo = 2, 0)else 0if (display == XImage) type - 0.Internal(X11(d$display, d$width, d$height, d$pointsize, d$gamma, d$colortype, d$maxcubesize, d$bg, d$canvas, d$fonts, NA_integer_, d$xpos, d$ypos, d$title, type, d$antialias))}() 2: par(no.readonly = TRUE) 3: heatmap(selected.matrix, distfun = cor.dist, zlim = zlim, col = colors.for.heatmap) 4: eval.with.vis(expr, envir, enclos) 5: eval.with.vis(ei, envir) Here is the sessionInfo() sessionInfo() R version 2.8.1 (2008-12-22) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] tools grid stats graphics grDevices utils datasets [8] methods base other attached packages: [1] u133x3p.db_2.2.5RSQLite_0.7-1 DBI_0.2-4 [4] AnnotationDbi_1.4.3 Biobase_2.2.2 vcd_1.2-3 [7] colorspace_1.0-0MASS_7.2-46 Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] testing for bimodal distribution
I'm not sure where to begin with this, but I was wondering if someone could refer me to an R package that would test to see if a distribution fits a bimodal distribution better than a unimodal distribution. Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] with lapply() how can you retrieve the name of the object
Thanks everyone for your suggestions (and sorry for the delay in the acknowledgement). Jorge and Jim, thanks for pointing out your approach. Andrew On Fri, Jul 18, 2008 at 7:02 PM, Jorge Ivan Velez [EMAIL PROTECTED]wrote: Dear Andrew, Following Jim Holtman' solution (thanks for pointed it out), try: a - data.frame(var.1 = 1:5) b - data.frame(var.1 = 11:15) test.list - list(a=a, b=b) do.call(rbind,lapply(names(test.list), function(x){ cbind(test.list[[x]], var.2=x) })) HTH, Jorge On Fri, Jul 18, 2008 at 6:57 PM, jim holtman [EMAIL PROTECTED] wrote: Is this what you wanted; you would use the 'names' to get the names in the lapply: lapply(names(test.list), function(x){ + cbind(test.list[[x]], var.2=x) + }) [[1]] var.1 var.2 1 1 a 2 2 a 3 3 a 4 4 a 5 5 a [[2]] var.1 var.2 111 b 212 b 313 b 414 b 515 b On Fri, Jul 18, 2008 at 6:31 PM, Jorge Ivan Velez [EMAIL PROTECTED] wrote: Dear Andrew, It's not the best solution but it does what you need: a - data.frame(var.1 = 1:5) b - data.frame(var.1 = 11:15) test.list - list(a=a, b=b) res=do.call(rbind,test.list) res$var.2=substr(rownames(res),1,1) rownames(res)=NULL res HTH, Jorge On Fri, Jul 18, 2008 at 6:21 PM, Andrew Yee [EMAIL PROTECTED] wrote: In the following code, I'd like to be able to create a new variable containing the value of the names of the list. a - data.frame(var.1 = 1:5) b - data.frame(var.1 = 11:15) test.list - list(a=a, b=b) # in this case, names(test.list) is a and b # and I'd like to use lapply() so that # I get something that looks like # var.1 var.2 # 1 a # 2 a # 3 a #etc. new.list - lapply(test.list, function(x) {x$var.2 - names(x) x} ) # the above clearly doesn't do it. How do you pull out the names of the thing that is being lapplied? Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] with lapply() how can you retrieve the name of the object
In the following code, I'd like to be able to create a new variable containing the value of the names of the list. a - data.frame(var.1 = 1:5) b - data.frame(var.1 = 11:15) test.list - list(a=a, b=b) # in this case, names(test.list) is a and b # and I'd like to use lapply() so that # I get something that looks like # var.1 var.2 # 1 a # 2 a # 3 a #etc. new.list - lapply(test.list, function(x) {x$var.2 - names(x) x} ) # the above clearly doesn't do it. How do you pull out the names of the thing that is being lapplied? Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] keeping original order in factor()
Apologies for the naieveness of this question, but I'm having trouble figuring out to have factor() maintain original ordering. For example, foo - c(b,b,a,a) levels(factor(foo, ordered=T)) #I'd like this to return as b a #not a b I thought having ordered=T would do the trick. Thanks, Andrew __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] in axis() suppressing axis line but keeping tick marks
I've been trying to figure out a parameter that will let you separately adjust the parameters for the axis line from the tick mark. In the following example, I would like to suppress the axis line, but keep the tick marks. Thanks, Andrew foo - data.frame(x=1:3, y=4:6) plot(foo$x, foo$y, type=n, axes=F) points(foo$x, foo$y) axis(side=1, at=foo$x, lty=0) #would like to figure out way to keep tick marks, but suppress axis line [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] in axis() suppressing axis line but keeping tick marks
Thanks for tracking this down. Andrew On Mon, Jun 16, 2008 at 4:49 PM, Peter Dalgaard [EMAIL PROTECTED] wrote: Andrew Yee wrote: I've been trying to figure out a parameter that will let you separately adjust the parameters for the axis line from the tick mark. In the following example, I would like to suppress the axis line, but keep the tick marks. The source code is the ultimate reference. We have in do_axis in src/main/plot.c: if (doticks) { gpptr(dd)-col = col;/*was fg */ GLine(axis_low, axis_base, axis_high, axis_base, NFC, dd); for (i = 0; i n; i++) { x = REAL(at)[i]; if (low = x x = high) { x = GConvertX(x, USER, NFC, dd); GLine(x, axis_base, x, axis_tick, NFC, dd); } } } and, as you see, there is no way the line parameters can change between the GLine calls, no hope of finding a magical par() setting. So I'm afraid you have to bite the bullet, do the relevant coordinate calculations, and use segments() do draw the ticks. (Or try convincing Paul Murrell to change the design, but that takes longer...). -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] controlling location of labels in axis()
Here's a naive question about axis() How do you control the location of the labels with the axis() command? In the following example: foo - data.frame(plot.x=seq(1:3), plot.y=seq(4:6)) plot(foo$plot.x, foo$plot.y, type='n', axes=FALSE) points(foo$plot.x, foo$plot.y) axis(1, at=foo$plot.x, labels=foo$plot.x) I'd like to be able the control the y location of the labels (i.e. move up or down in the graph). Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] controlling location of labels in axis()
Thanks for the reply. I think I've figured it out, you can set this with the mgp parameter. So I'd use the following statement instead: axis(1, at=foo$plot.x, labels=foo$plot.x, mgp=c(3,0.5,1)) #this brings the axis labels closer to the axis line Andrew On Thu, Jun 12, 2008 at 9:53 AM, Toby Marthews [EMAIL PROTECTED] wrote: Hi Andrew, Perhaps this example would help. You can add in spaces to the mtext text to move the text sideways. par(mai=c(0.5,0.5,0.5,0.5),oma=c(2,2,2,2)) #mai units are INCHES, oma units are LINES plot(runif(50),xlab=xlab,ylab=ylab,bty=l) #n.b. these labels don't appear mtext(First inner x axis label,side=1) mtext(First inner y axis label,side=2) mtext(Second inner x axis label,side=3) mtext(Second inner y axis label,side=4) mtext(First outer x axis label,side=1,outer=TRUE) mtext(First outer y axis label,side=2,outer=TRUE) mtext(Second outer x axis label,side=3,outer=TRUE) mtext(Second outer y axis label,side=4,outer=TRUE) Cheers, Toby Marthews Le Jeu 12 juin 2008 15:32, Andrew Yee a écrit : Here's a naive question about axis() How do you control the location of the labels with the axis() command? In the following example: foo - data.frame(plot.x=seq(1:3), plot.y=seq(4:6)) plot(foo$plot.x, foo$plot.y, type='n', axes=FALSE) points(foo$plot.x, foo$plot.y) axis(1, at=foo$plot.x, labels=foo$plot.x) I'd like to be able the control the y location of the labels (i.e. move up or down in the graph). Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] alternatives to RColorBrewer?
I've found RColorBrewer useful for its qualitative palettes, but wished that it could generate more than 12 qualitative palettes (e.g. with Set3). Any suggestions for alternative color palette generators that can handle e.g. 18 distinctive colors? (I'm aware of using rainbow(), but this doesn't generate enough distinct colors when the number of palettes is large). Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] alternatives to RColorBrewer?
Great, thanks, that was helpful. Andrew On Thu, Apr 24, 2008 at 2:15 PM, Achim Zeileis [EMAIL PROTECTED] wrote: On Thu, 24 Apr 2008, Andrew Yee wrote: I've found RColorBrewer useful for its qualitative palettes, but wished that it could generate more than 12 qualitative palettes (e.g. with Set3). Any suggestions for alternative color palette generators that can handle e.g. 18 distinctive colors? (I'm aware of using rainbow(), but this doesn't generate enough distinct colors when the number of palettes is large). Package vcd implements several palette generators in HCL space which are somewhat similar to the palettes in ColorBrewer but provide some more flexibility. The underlying ideas are explained here http://epub.wu-wien.ac.at/dyn/openURL?id=oai:epub.wu-wien.ac.at:epub-wu-01_c87 See also help(rainbow_hcl, package = vcd) which has a few more examples. However, I guess that it will be hard to select a qualitative palette with 18 distinct colors...I couldn't imagine a plot where it would be sufficiently easy for humans to decode that. But maybe you can combine that with some sequential or diverging palette or so? Best, Z Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] why is text being rasterized with text()
Thank you for looking at my code. You are absolutely right. I'm mortified that I didn't see the text() tucked inside the for loop. Once I took it out of the loop, the text() works fine. Thanks, Andrew On Thu, Apr 3, 2008 at 1:52 AM, Prof Brian Ripley [EMAIL PROTECTED] wrote: We haven't been told your OS or the graphics device or how you viewed PDF output. But all text on screen devices is rasterized -- they are raster devices. (That includes your pdf viewer.) You are writing the label 9 times in the same place. I suspect what you are seeing is a viewer artifact of doing so -- the antialiasing isn't working for you. On Thu, 3 Apr 2008, Andrew Yee wrote: Here's a question: I noticed that when I tried to create this simple graph of rectangles and text, R appears to generate text that is rasterized (this is seen both on the monitor and when the output is directed to a pdf file). Any thoughts? value.seq - c(4,as.character(seq(from=4,to=10)),11) frame() par(usr=c(0,10,0,10) ) for (r in 1:9) { rect(r,3,r+1,3.75, border = NA, col=heat.colors(9)[r]) #this text does not appear to be rasterized text(r+0.5,2.75, value.seq[r], cex=0.5) #this text appears to be rasterized text(5.5,2.25,expression (log2), cex=0.5) } Thanks, Andrew __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] why is text being rasterized with text()
Here's a question: I noticed that when I tried to create this simple graph of rectangles and text, R appears to generate text that is rasterized (this is seen both on the monitor and when the output is directed to a pdf file). Any thoughts? value.seq - c(4,as.character(seq(from=4,to=10)),11) frame() par(usr=c(0,10,0,10) ) for (r in 1:9) { rect(r,3,r+1,3.75, border = NA, col=heat.colors(9)[r]) #this text does not appear to be rasterized text(r+0.5,2.75, value.seq[r], cex=0.5) #this text appears to be rasterized text(5.5,2.25,expression (log2), cex=0.5) } Thanks, Andrew __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] changing color scheme in R in UNIX
Hi, I've been using R in Windows but am now starting to use it more often in the UNIX environment. In Windows, I'm used to the text provided by the user appearing in red, and the output from R appearing in blue. Is there a way to achieve this in UNIX? Thanks, Andrew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.