> x <- c(1,3,5)
> y <- c(2,4,6)
> xy <- sort(c(x,y))
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Shubha Vishwanath Karanth
Sent: Wednesday, July 23, 2008 8:55 AM
To: [EMAIL PROTECTED]
Subject: [R] Simple... but...
Hi R,
If
x=c(1,3,5)
y=c(2,4,6)
> data <- data.frame(Year=c(2000,2001,2002),
A=c(4,2,1),
B=c(3,1,2),
C=c(0,3,5))
> data.mat <- as.matrix(data)[,2:4]
> rownames(data.mat) <- data$Year
> data.mat <- t(data.mat)
> barplot(data.mat,beside=TRUE)
-Original Message--
Try sourcing in the 'new.legend' function below. It's the legend
function with a new argument called 'box.col'. The argument will change
the color of the box surrounding the legend. If I understand what it is
you are looking for, this should work. Also, I didn't see a way to
change the axis bar
I've dabbled in this a little bit, and the result of my dabbling is
attached. I'll give you fair warning, however. The attached function
can take a long time to run, and if your model has 10 or more
predictors, you may be retired before it finishes running.
In any case, it will models for all po
I've attached some functions I've written based on previous questions
that have been posted here. Unfortunately, I was too lazy to give
credit to previous commenters in my Rd file, and for that I hope they'll
forgive me.
In any case, please be assured that the functions I've attached are in
no
Has anyone ever tried putting a circle around a letter or a number in a
plot title?
For instance, if I have a plot title "Scatterplot for Subject 24", I
want to put a circle around 24 to distinguish that plot from the other
30 I've generated. Any tips or ideas beyond plotting a circle in the
marg
What you did works well. You could also try the following.
table(x)["1"]
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Randall Wrong
Sent: Friday, February 26, 2010 9:41 AM
To: r-help@r-project.org
Subject: [R] counting the num
But if x has any missing values:
> x <- c(1, 1, 1, NA, NA, 2, 1, NA)
>
> sum( x == 1)
[1] NA
>
> sum(x==1, na.rm=TRUE)
[1] 4
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Henrique Dallazuanna
Sent: Friday, February 26, 2010
> as.data.frame(t(df))
For example
> x <- as.data.frame(t(mtcars))
> typeof(x)
[1] "list"
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Sebastian Bauer
Sent: Tuesday, March 02, 2010 8:12 AM
To: r-help@r-project.org
Subject: [R]
As has been pointed out, there are tools in R to help find the commands
you are looking for.
As a practical note, I recommend starting with '?' if you think you know
what command you need.
If you're unsure of what command you need, my next step would be
help.search(). Often, the results from her
Does anyone have any experience retrieving latitutde and longitude for
an address from the Google Maps API?
I'd like to have an R script that submits a street address, city, state,
and zip code and returns the coordinates. So far, I've been submitting
the coordinates from another program, then
The only thing you're missing is the midpoints of the bars. Since you
specified
> Graph <- barplot(dat$Average)
You can get the midpoints from the Graph object. So to put the number
on top of each bar you might use something like:
> text(Graph, dat$Average, dat$Average)
-Original Message
Look at the xpd option in ?par. If you set par(xpd=TRUE) you should be
able to add a segment for what you want. But please let me know if
someone gives you a better way to do this.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Al
If x is your vector of character date variables:
orig.date <- as.Date(x, format=c("%m/%d/%Y"))
new.date <- format(x, format=c("%m/%d/%y"))
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Hosack, Michael
Sent: Tuesday, March 23, 2010
> x[seq(1, nrow(x), by=5), ]
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of David Winsemius
Sent: Thursday, October 08, 2009 4:19 PM
To: Ashta
Cc: R help
Subject: Re: [R] row selection
On Oct 8, 2009, at 4:14 PM, Ashta wrote:
>
sub3 <- x[-seq(1, nrow(x), by=5), ]
Notice the '-' in front of the seq() command. This will select
everything but what is in the sequence.
From: Ashta [mailto:sewa...@gmail.com]
Sent: Friday, October 09, 2009 12:42 PM
To: Nutter, Benjamin
I usually use the following function:
last.record <- function(data, id, ..., na.last=TRUE, decreasing=FALSE){
#*** Make vector of variables to sort by
v <- c(id, unlist(list(...)))
#*** Sort Data Frame
data <- data[do.call(order,
c(data[,v, drop=FALSE], na.last=na.last,
decre
?mtext
You may need to adjust the margins. For this I recommend adjusting that
mar option in par (see ?par).
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Bernardo Rangel Tura
Sent: Wednesday, May 13, 2009 6:31 AM
To: r-help
Su
as.numeric() doesn't convert factors to the explicit value, nor should
it. Under what you're expecting, ff you have a factor where the levels
are "Female" and "Male", using as.numeric() wouldn't produce anything
meaningful.
However, as.numeric() does something much smarter. It converts "Female"
I understood this to mean you want to open a new plotting window on each
iteration of the loop. If this is correct, I usually go about it by
using x11()
If you're looking to add additional lines or points, then you may want
to look at the aptly named functions lines() and points().
If neither of
March 25, 2009 3:00 PM
To: Nutter, Benjamin
Cc: r-help@r-project.org
Subject: Re: [R] Plot inside For loop
basically the for loop goes something like this
setCounters(135);
for(i in 1:query) {
plot(c2data[start1:count,],c3data[start1:count,],xlim=c(-30,100),
ylim=c(-30,90), sub=i);
Shucks, Dimitris beat me to it. And his code is a bit more elegant than
mine. But since I did the work I may as well post it, right?
This version incorporates a couple of error checks to make sure all your
arguments are matrices with the same number of rows.
add.by.name <- function(...){
args
x <-
data.frame(matrix(c(rep(11,4),rep(12,3),rep(13,3),rep(0,3),1,rep(0,4),re
p(1,2)),ncol=2))
id.keep <- unique(subset(x,X2>0)$X1)
x2 <- subset(x,X1 %in% id.keep)
x2
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Stephan Lindner
For a single row where mat is your matrix and r is the row
> sum(!is.na(mat[r,]))
For every row in the matrix
> rowSums(!is.na(mat))
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Verena Weber
Sent: Tuesday, December 29, 2009 8:
It seems from your example that you're assuming all of the vectors have
the same length. If this is the case, then a data.frame might be your
friend.
> df <- data.frame(
v1 = c(0, 1, 0),
v2 = c(1, 1, 0),
v3 = c(2, 1, 2),
v4 = c(2, 2, 1),
v5 = c(0, 1, 1) )
> x <- 5
> get.var
Try "\%d/\%m/\%Y"
Escaping the % should do the trick. If I remember correctly, Latex uses
the % as the comment delimiter. I don't know if that's the cause of the
error, but escaping it has always solve the problem for me.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-
Data<-c("1131", "1132", "1731" ,"1732" ,"1821" ,"1822", "2221" ,"",
"2241" ,"2242","414342" ,"414371" ,"414372")
Bldgid<-substring(as.character(Data),1,nchar(Data)-1)
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of LCOG1
Sent: Tu
I'm stumped. I have a dataset I want to melt to create a temporal sequence of
events for each subject, but in each row, I would like to retain the baseline
characteristics.
D <- structure(list(ID = c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"),
AGE = structure(c(68L,
My apologies for coming late into this conversation, but I'm curious about
something in your response
You use the following code to peform a likelihood ratio test between an lm
object and a mer object
fm0 <- lm(distance~age,data=Orthodont)
fm2 <- lmer(distance~age+(1|Subject),data=Orthodont,REM
I'm in the middle of my own little intellectual exercise comparing
dcast() and reshape() and have successfully stumped myself. I want to
melt() a data frame, then dcast() it into a new form. After doing so, I
want to duplicate the process using reshape().
So far, I can do the melt and cast
re
[mailto:dwinsem...@comcast.net]
Sent: Wednesday, October 17, 2012 5:18 PM
To: Nutter, Benjamin
Cc: r-help@r-project.org
Subject: Re: [R] Comparing dcast and reshape
On Oct 17, 2012, at 2:09 PM, Nutter, Benjamin wrote:
> I'm in the middle of my own little intellectual exercise comparing
&g
Here's a thread that has some good discussion on the topic
http://r.789695.n4.nabble.com/Running-script-with-double-click-td1579014.html
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Bert Gunter
Sent: Tuesday, September 28, 2010
I've noticed it, but I haven't looked into it much since I rarely work
on Vista. I have found that opening R before I open Tinn-R tends to
work better than using Tinn-R to open the preferred GUI.
Benjamin
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-pro
My apologies for coming to the party so late.
I'm sure this question has been answered a couple of times. The
attached function is one I pulled from the help archives, but I can't
seem to duplicate the search that led me to it.
In any case, I've attached the function I found, and an .Rd file I u
I hope you'll all forgive me for displaying my severe lack of knowledge on this
topic, and I can't really provide much in the way of reproducible code.
A colleague of mine has asked if I know how to import an S object into R. The
object is stored in a file named 'pre3.f' When I open the file
com]
Sent: Tuesday, May 24, 2011 12:20 PM
To: Nutter, Benjamin
Cc: r-help@r-project.org
Subject: Re: [R] Loading an S object into R
Hi Benjamin,
I also have no experience with S plus, but the suggestions on the R
Import/Export manual seem worth trying:
http://cran.r-project.org/doc/manuals/R-data.ht
Fibonacci <- c(1, 1)
while (max (Fibonacci) < 500){
Fibonacci <- c(Fibonacci, sum(tail(Fibonacci, 2))) }
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Georgina Imberger
Sent: Wednesday, April 20, 2011 5:43 AM
To: r-help@r-projec
Depending on what else you're writing around the %, you might consider
using the latexTranslate() function in Hmisc.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of viostorm
Sent: Sunday, April 24, 2011 8:48 AM
To: r-help@r-project.o
I have my own function for doing this that is similar to the one presented
below. Others may have other ideas that work better. As a general rule, I
would caution against writing out just the label without the variable name.
The only reason I see to separate the labels and names is if you are
Whether I use stringsAsFactors=FALSE or stringsAsFactors=TRUE tends to rely on
where my data are coming from. If the data are coming from our Oracle
databases (well controlled data), I import the with stringsAsFactors=TRUE and
everything is great. If the data are given to me by a fellow in the
With any sort of reproducible report, you'll have to 'manually place' all of
the tables and figures at least once. If done well, however, you'll only have
to ever do it once.
I'm not an Sweave expert (yet, regrettably), but using lazyWeave, you could
generate a customized ANOVA table using t
I've developed a preference for
x$y %in% "Low"
when subsetting.
Benjamin Nutter | Biostatistician | Quantitative Health Sciences
Cleveland Clinic | 9500 Euclid Ave. | Cleveland, OH 44195 | (216)
445-1365
-Original Message-
From: r-help-boun...@r-project.org [mailto
This is a function I use for these kinds of situations. Assuming the delimiter
within the column is consistent and the spelling is consistent, it is pretty
useful.
The function returns a vector of 0/1 values, 1 if the text in level is found, 0
otherwise.
var=the variable
level=The value of int
I'm thoroughly stumped. I've been playing with RODBC and wanted to see if I
could retrieve data from text files using this package as well (for the most
part, this is an intellectual exercise, but occasionally I do get data files
large enough in CSV format RODBC could be helpful) .
I set up a
-1365
-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com]
Sent: Thursday, February 16, 2012 1:15 PM
To: Nutter, Benjamin
Cc: r-help@r-project.org
Subject: Re: [R] Reading Text Files with RODBC
On Thu, Feb 16, 2012 at 10:12 AM, Nutter, Benjamin wrote:
> I'm thoro
I've run into this situation and have been able to prevent problems by using
> lme4::VarCor(...)
Benjamin Nutter | Biostatistician | Quantitative Health Sciences
Cleveland Clinic | 9500 Euclid Ave. | Cleveland, OH 44195 | (216)
445-1365
-Original Message-
From: r-help-
So long as x is a character vector, I tend to use the following for this
problem.
> x <- c("12/31/11 23:45", "1/1/12 2:15")
>
> x.split <- strsplit(x, " ")
>
> x.date <- sapply(x.split, function(y) return(y[1]))
> x.time <- sapply(x.split, function(y) if (length(y) > 1) return(y[2]) else NA)
>
For example:
myDir <- "some file path"
filenames <- list.files(myDir)
filenames <- filenames[grep("[.]csv", filenames)]
data_names <- gsub("[.]csv", "", filenames)
for(i in 1:length(filenames)) assign(data_names[i], read.csv(file.path(myDir,
filenames[i])))
Benjamin Nutter | Biostatistic
I've tried to tackle a similar question at the request of a coworker.
Unfortunately, it is difficult to read in HTML code because it lacks
character that can consistently be used as a delimiter. The only
guideline I can offer is that any text you're interested in is going to
be between a ">" and a
The function given below is one I've written to handle repeated
measures. I've also included the Help File. If you happen to see any
potential improvements, I would be open to suggestions.
###
### Function Code
###
'Bland.Altman' <- function(x,y,alpha=.05,rep.meas=FALSE,subject,...){
#***
I have successfully completed building a package to contain the
functions I commonly use. However, I need to have other packages
installed in order for some of my functions to work. I've been studying
the instructions on installing packages for about a month now, but still
haven't figured this on
tions in
the survival package will work within my functions even without
explicitly loading the package?
Thanks for the help.
Benjamin
-Original Message-
From: Uwe Ligges [mailto:[EMAIL PROTECTED]
Sent: Saturday, November 17, 2007 12:04 PM
To: Nutter, Benjamin
Cc: [EMAIL PROTECTED]
Subjec
Perhaps a simpler way might be to use the na argument in read.table. for
instance:
> read.table( filename, na=0, ...)
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Amit Patel
Sent: Tuesday, September 16, 2008 9:32 AM
To: r-help@r-project.org
Subject: [R
You might also consider
?confint
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jorge Ivan Velez
Sent: Monday, September 22, 2008 5:36 PM
To: Luciano La Sala
Cc: R mailing list
Subject: Re: [R] Coefficients, OR and 95% CL
Dear Luciano,
See ?logistic.dis
I hope you'll forgive me for resurrecting this thread. My question
refers to John Fox's comments in the discussion of lsmeans from
https://stat.ethz.ch/pipermail/r-help/2008-June/164106.html
John you said, "It wouldn't be hard, however, to do the computations
yourself, using the coefficient vect
Perhaps it would be easier to try something like this:
> df1 <- read.table(filename, ... ) # All columns read as characters
> df1 <- t(df1) # Transpose df1
> write.table <- (df1, newfile, ...) # Write the transposed data
# to a new file
>
?apply
e.g. apply(matrix,1,sd)
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Alex99
Sent: Wednesday, October 15, 2008 1:17 PM
To: r-help@r-project.org
Subject: [R] Standard deviation for rows
Hi everyone,
I have just started using R, and I have a sim
Abou,
I presume this may be a task you will need to perform with some
regularity. I took the liberty of turning Duncan Murdoch's suggested
code into a function for you (I hope you don't mind, Duncan). Good
luck.
On a personal note, it's good to see a familiar name. I hope all is
well with you.
?floor
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of zahid khan
Sent: Wednesday, January 14, 2009 8:34 AM
To: r-h...@stat.math.ethz.ch
Subject: [R] help
Dear ALL
suppose "x=7.5",and i need of only integer part of variable "x" tha
Jim's solution is more elegant than the following (and probably more
efficient) but you could also try the following (This let's you sort by
AN/HN, and then by the number at the start of the filename):
> text <- c( "26M_AN_C.bmp", "22M_AN_C.bmp", "20M_HA_O.bmp",
"20M_AN_C.bmp", "26M_H
-Original Message-
From: Nutter, Benjamin
Sent: Monday, February 02, 2009 7:37 AM
To: 'venkata kirankumar'
Subject: RE: [R] parsing problem
This is how I would approach it. I'd be happy to know if there's a
better way.
#*** Initial Data Frame
x <-
c("Ko
Those of us on this list (with the possible exception of one or two
nutters)
would take it that it goes without saying that R was developed on the
basis
of S --- we all ***know*** that.
Just want to clarify that the nutters referred to here are not the same
as the Nutters that bear my n
Why use a loop? Try using diff()
x <- c(4, 19, 21, 45, 50, 73, 78, 83, 87, 94)
sum(diff(x))
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Rafael Moral
Sent: Thursday, March 12, 2009 9:04 AM
To: r-help@r-project.org
Subject: [R] h
I apologize up front for this being a little long. I hope it's
understandable. Please let me know if I need to clarify anything.
Several months ago I wrote a series of functions to help me take my R
analyses and build custom reports in html files. Each function either
builds or modifies a string
** Sorry to repost. I forgot to include a function necessary to make
the example work **
I apologize up front for this being a little long. I hope it's
understandable. Please let me know if I need to clarify anything.
Several months ago I wrote a series of functions to help me take my R
analyse
If I understand what you're seeking to do, you might also consider the
rplot() function written by Rolf Turner. It can be found at
http://tolstoy.newcastle.edu.au/R/help/02a/1174.html
Benjamin
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Plantky
Se
I believe the defaults in barplot are found using
grey.colors{GrDevices}.
?grey.colors
(For some reason my machine won't pull up the help files for grey.colors
from the command line, but I can still access it through the html help).
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMA
67 matches
Mail list logo