Displaying 20 results from an estimated 2000 matches similar to: "Switching labels on a factor"
2006 Dec 18
1
Applying variable labels across a data frame
Hi All,
I'm working on a class example that demonstrates one way to deal with
factors and their labels. I create a function called myLabeler and apply
it with lapply. It works on the whole data frame when I subscript it as
in lapply( myQFvars[ ,myQFnames ], myLabeler ) but does not work if I
leave the [] subscripts off. I would appreciate it if anyone could tell
me why. The program below
2009 Jul 11
3
Reading data entered within an R program
Dear R-helpers,
I know of two ways to reading data within an R program, using
textConnection and stdin (demo program below). I've Googled about and
looked in several books for comparisons of the two approaches but
haven't found anything. Are there any particular advantages or
disadvantages to these two approaches? If you were teaching R beginners,
which would you present?
Thanks,
Bob
2006 Nov 25
3
Multiple Conditional Tranformations
Greetings,
I'm learning R and I'm stuck on a basic concept: how to specify a
logical condition once and then perform multiple transformations under
that condition. The program below is simplified to demonstrate the goal.
Its results are exactly what I want, but I would like to check the
logical state of gender only once and create both (or any number of)
scores at once.
2012 Jan 19
2
Reading in tab (and space) delimited data within a script XXXX
Hello everyone,
I use Bob Muenchen's approach for reading in "in-stream" (to use SAS
parlance) delimited data within a script. This works great:
mystring <-
"id,workshop,gender,q1,q2,q3,q4
1,1,f,1,1,5,1
2,2,f,2,1,4,1
3,1,f,2,2,4,3
4,2, ,3,1, ,3
5,1,m,4,5,2,4
6,2,m,5,4,5,5
7,1,m,5,3,4,4
8,2,m,4,5,5,5"
mydata <- read.table( textConnection(mystring),
2006 Dec 28
2
Aggregation using list with Hmisc summarize function
Hi All,
I'm using the Hmisc summarize function and used list instead of llist to
provide the by variables. It generated an error message. Is this a bug,
or do I misunderstand how Hmisc works with lists? The program below
demonstrates the error message.
Thanks,
Bob
x<-1:8
group <- c(1,1,1,1,2,2,2,2)
gender<- c(1,2,1,2,1,2,1,2)
mydata<-data.frame(x,group,gender)
2009 Feb 12
2
SAS Institute Adding Support for R
Hi Folks,
SAS Institute is adding official support for R:
http://support.sas.com/rnd/app/studio/Rinterface2.html
Cheers,
Bob
=========================================================
Bob Muenchen (pronounced Min'-chen),
Manager, Research Computing Support
U of TN Office of Information Technology
Stokely Management Center, Suite 200
916 Volunteer Blvd., Knoxville, TN
2008 Feb 12
3
How many R packages?
Hi All,
I searched around to find the number of R packages currently available,
but didn't find anything, so I choose all repositories & told it to
install. The list contained about 2,856 (correcting roughly for those
installed). But the list includes repetitions such as 19 names that
begin with "bvbovine".
Selecting only CRAN and CRAN(extras) I get 1,344.
Is there an easier
2008 Mar 10
1
When to quote a package name
Dear HelpeRs,
I'm confused about the role of quotes around package names on the
library and detach functions. Books on R use both approaches:
library(Hmisc)
describe(mydata)
detach(package:Hmisc)
and
library("Hmisc")
describe(mydata)
detach("package:Hmisc")
The help file for detach says "quoted or unquoted" and the help file for
library says about the
2009 Jan 23
2
The Quality & Accuracy of R
Hi All,
We have all had to face skeptical colleagues asking if software made by
volunteers could match the quality and accuracy of commercially written
software. Thanks to the prompting of a recent R-help thread, I read, "R:
Regulatory Compliance and Validation Issues, A Guidance Document for the
Use of R in Regulated Clinical Trial Environments
(http://www.r-project.org/doc/R-FDA.pdf).
2008 Mar 08
5
Non-visible functions are asterisked
Dear R-Helpers,
I suspect I'm about to ask a FAQ, but I haven't been able to find an
answer in the FAQ, AItR or an R Site Search. When I look at the methods
of summary (below) it says, "Non-visible functions are asterisked". I
looked at the help file for summary.princomp, which did not comment on
it being non-visible. I ran its help file example, which printed visible
output. I
2007 Feb 10
1
JGR data editor question
Hi All,
I'm learning JGR 1.4-15 with R 2.4.1 in Windows XP (all patches
applied). JGR looks great but I'm having trouble getting the data editor
to save my results. I don't see anything in R-help about it. Here are
the steps I followed:
1. I chose "Tools>Object Browser" & double-clicked on a data frame,
"mydata".
2. A spreadsheet editor popped up and
2007 Sep 09
1
stacking data frames with different variables
Hi All,
If I need to stack two data frames, I can use rbind, but it requires
that all variables exist in both sets. I can make that happen, but other
stat packages would figure out where the differences were, add the
missing variables to each, set their values to missing and stack them.
Is there a more automatic way to do that in R?
Below is an example program.
Thanks,
Bob
# Top data frame has
2008 Apr 04
2
NA vs. <NA>
Dear R-Helpers,
Why does R show character missing values in vectors as NA and when
stored in a data frame as <NA>? I've searched but did not find an
explanation.
Thanks,
Bob
> gender <- c("f","f","f",NA,"m","m","m","m")
> gender
[1] "f" "f" "f" NA "m" "m"
2007 Apr 09
3
do.call vs. lapply for lists
Hi All,
I'm trying to understand the difference between do.call and lapply for
applying a function to a list. Below is one of the variations of
programs (by Marc Schwartz) discussed here recently to select the first
and last n observations per group.
I've looked in several books, the R FAQ and searched the archives, but I
can't find enough to figure out why lapply doesn't do what
2007 Sep 02
2
NAs in indices
Hi All,
I'm fiddling with an program to read a text file containing periods that
SAS uses for missing values. I know that if I had the original SAS data
set instead of a text file, R would handle this conversion for me.
Data frames do not allow missing values in their indices but vectors do.
Why is that? A search of the error message points out the problem and
solution but not why they
2007 Jan 29
1
R for SAS & SPSS Users Document
Greetings,
I am pleased to announce the availability of the document, "R for SAS
and SPSS Users", at
http://oit.utk.edu/scc/RforSAS&SPSSusers.doc . It presents an
introductory view of R for people who already know SAS and/or SPSS.
Included are 27 programs written in all three languages (i.e. 81 total)
so that people can see how R works compared to the other two, task by
task.
I
2008 Apr 13
1
.Rprofile, date tagging history, loading packages
Dear R-Helpers,
I'm fiddling with my .Rprofile in Windows XP & R 2.7.0 Beta. I prefer to
manually save my workspace but automatically save my command history via
the .Rprofile. That is working fine once I found that "utils::" was
required before the loadhistory & savehistory functions. What I would
like to do is add a separator line with a date between the histories of
each
2007 Aug 26
3
subset using noncontiguous variables by name (not index)
Hi All,
I'm using the subset function to select a list of variables, some of
which are contiguous in the data frame, and others of which are not. It
works fine when I use the form:
subset(mydata,select=c(x1,x3:x5,x7) )
In reality, my list is far more complex. So I would like to store it in
a variable to substitute in for c(x1,x3:x5,x7) but cannot get it to
work. That use of the c function
2007 Sep 01
2
Comparing "transform" to "with"
Hi All,
I've been successfully using the with function for analyses and the
transform function for multiple transformations. Then I thought, why not
use "with" for both? I ran into problems & couldn't figure them out from
help files or books. So I created a simplified version of what I'm
doing:
rm( list=ls() )
x1<-c(1,3,3)
x2<-c(3,2,1)
x3<-c(2,5,2)
2010 Aug 03
1
releveling a numeric by factor interaction
Can anyone help me with the necessary code to relevel a numeric*factor
interaction term in a linear model? I would like to report the estimate,
std. error and t-value for the reference factor.
First, I estimated a linear model with dummy variables and was able to
retrieve model estimates for the reference factor using relevel.
for example:
> summary(update(mod.mod, . ~ . - dummy +
+