Displaying 20 results from an estimated 3000 matches similar to: "ggplot2: stat_bin ..count.. with geom_text when NA is present"
2009 Oct 06
1
ggplot2: mapping categorical variable to color aesthetic with faceting
Hello Again... I?m making a faceted plot of a response on two categorical
variables using ggplot2 and having troubles with the coloring. Here is a
sample that produces the desired plot:
compareCats <- function(data, res, fac1, fac2, colors) {
require(ggplot2)
p <- ggplot(data, aes(fac1, res)) + facet_grid(. ~ fac2)
jit <- position_jitter(width = 0.1)
p <- p +
2009 Oct 02
1
ggplot2: proper use of facet_grid inside a function
Hello Again R Folk:
I have found items about this in the archives, but I?m still not getting
it right. I want to use ggplot2 with facet_grid inside a function with
user specified variables, for instance:
p <- ggplot(data, aes_string(x = fac1, y = res)) + facet_grid(. ~
fac2)
Where data, fac1, fac2 and res are arguments to the function. I have
tried
p <- ggplot(data,
2010 Aug 26
3
Passing data to aov
Hello Again Gurus and Lurkers:
I?m trying to build a very user-friendly function which does aov without
having the user type in a formula (which would be tedious in this case).
The idea is to take the response from a PCA score matrix, and the factors
from a list. A simple example is the function given below, along with test
data and a sample call to the function.
I'm certainly having
2008 Mar 30
2
Definition of "wrapper"?
I think I more or less understand what a ?wrapper? is, but I?d like to hear
how more experienced R users define it, and especially I'd like to know if
there is a formal definition. In my reading, it seems like there are a
fairly wide range of meanings, but they are all conceptually similar.
I've looked in a couple of the classic R texts, the extensions and
developers' manuals, and R
2009 Nov 16
4
Where are usages like "== 2L" documented?
Gurus:
I keep seeing other people?s code that contain ideas like
If (x == 2L)
X[-1L]
X - 1L
I have some idea of what?s going on, but where is the use of concepts like
?2L? documented?
Thanks, Bryan
*************
Bryan Hanson
Acting Chair
Professor of Chemistry & Biochemistry
DePauw University, Greencastle IN USA
2009 May 22
1
regrouping factor levels
Hi all,
I had some trouble in?regrouping factor levels for a variable. After some experiments, I have figured out how I can recode to modify the factor levels. I would now like some help to understand why some methods work and others don't.
Here's my code :
rm(list=ls())
###some trials in recoding factor levels
char<-letters[1:10]
fac<-factor(char)
levels(fac)
print(fac)
##first
2010 Nov 29
3
Replacing several rows of a matrix at once
Hello Folks. This must be a silly question with a (not) obvious (to me)
answer.
Consider this:
tmp <- matrix(1:200, nrow = 20)
vec <- 300:309
tmp[9,] <- vec # replacing one row works fine
p <- c(3, 11, 17)
tmp[p,] <- vec
# replacing multple rows pastes the values down a column and recycles vec.
What I want to do is replace multiple rows simultaneously at once. I
suppose I can
2010 Mar 14
2
Why doesn't vec[-real.number] give an error or warning? Kids do the darndest things!
Hi all...
My students were conflating grepping for a value in a vector to get the
index, and then removing it with [-index], for instance like this:
set.seed(17)
v <- rnorm(20)
s <- v[-1.18]
They were trying to remove the 12th value in v, which is -1.18 or so.
But the result is, as documented in ?Extract, to coerce 1.18 to the next
lowest integer, and remove the 1st value of v, not the
2009 Sep 07
1
xyplot {lattice} are different types possible for each panel?
Hello R Folks...
Using the example below, I¹d like two of the panels to be plotted with type
= ³p² but the third to be done with type = ³h². I can¹t use type = c(³p²,
³p², ³h²) because this syntax applies all given types to every panel. I
don¹t think I can use groups and distribute.type because these are intended
for different styles of plotting within a single panel. As you can see, I
tried
2010 Apr 21
5
Bugs? when dealing with contrasts
R version 2.10.1 (2009-12-14)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with
2009 Dec 29
1
ggplot2, building a simple formula interface
I?m trying to build a simple formula interface to work with a function using
ggplot2. The following scheme ?works? up until the plot(p) request, at which
point there are complaints about xlim?s and a blank graphics window.
Looking at str(p) I do see the limits are NULL, plus layer 1 claims to have
an empty data frame (but df is reproduced correctly). I'm sure I'm missing
something really
2009 Aug 11
1
Selecting/Accessing the last vector in a list of a list of data.frames
Hello Again R Folks:
I?m trying to clean up some code. Suppose I have an object like this:
> str(test)
List of 2
$ G:List of 2
..$ cls:'data.frame': 101 obs. of 2 variables:
.. ..$ V1: num [1:101] -0.0019 -0.0019 -0.00189 -0.00188 -0.00186 ...
.. ..$ V2: num [1:101] 0.000206 0.000247 0.000288 0.000329 0.000371 ...
..$ rob:'data.frame': 101 obs. of 2
2008 Apr 17
2
Suggestions: Terminology & Pkgs for following spectra over time
Hi Folks... No code to troubleshoot here. I need some suggestions about the
right terminology to use in further searching, and any suggestions about R
pkgs that might be appropriate.
I am in the planning stages of a project in which IR, NMR and other spectra
(I'm a chemist) would be collected on various samples, and individual
samples would be followed over time. The spectra will be feature
2010 Jul 12
2
findInterval and data resolution
Hello Wise Ones...
I need a clever way around a problem with findInterval. Consider:
vec1 <- 1:10
vec2 <- seq(1, 10, by = 0.1)
x1 <- c(2:3)
a1 <- findInterval(x1, vec1); a1 # example 1
a2 <- findInterval(x1, vec2); a2 # example 2
In the problem I'm working on, vec* may be either integer or numeric, like
vec1 and vec2. I need to remove one or more sections of this vector;
2011 Dec 01
2
nipals in the chemometrics package in R
Hello
i need some precision about nipals in the chemometrics package in R .
When i use nipals in chemometrics i obtain T and P matrix.
I really don't understand what to do with these two matrix to obtain
the scores for every the component (like in spss fo example)
Comp1 Comp2 Comp3
quest1 0,8434 0,54333 0,3466
quest2 0,665 0,7655 0,433
Thank you very
2011 Dec 01
2
Writing a function, want a string argument to define the name of the excel sheet to be called
My question is this: is there a way I can make one of the arguments of the
function be a string the user can enter, and then have that be the excel
filename? ie,
foo <- function(x,y,NAME){
#make a matrix with x rows and y cols
M <- matrix(nrow=x,ncol=y)
#write the matrix
write.table(M, file = "result.csv",append=TRUE, sep = ",")
}
I've had a look but I
2011 May 20
3
Downloading a csv from Dropbox using the shareable link
Hello Kindred R Spirits...
I'm trying to get a file (csv) from Dropbox using their shareable link
concept. They issue a short URL that goes to a web page where you see
a button that says "Download File". They don't really give you the
URL of the file itself, just this page. Is there a way to coax R into
getting such a file? I don't even really want the file per
2009 Aug 10
3
Need Advice: Considering Converting a Package from S3 to S4
Hello R Folks...
Not a technical question, but I need some advice and perspective.
I?ve got a set of functions I?m planning to put together into a package.
The main hunk of data that gets used by different functions is currently an
S3 list. I?ve been reading about S4 objects, and I see the (numerous)
advantages of them. I have seen the recommendation that all new packages be
done with S4.
2006 Feb 13
2
?bug? strange factors produced by chron
Hallo all
Please help me. I am lost and do not know what is the problem. I have
a factor called kvartaly.
> attributes(kvartaly)
$levels
[1] "1Q.04" "2Q.04" "3Q.04" "4Q.04" "1Q.05" "2Q.05" "3Q.05" "4Q.05"
$class
[1] "factor"
> mode(kvartaly)
[1] "numeric"
> str(kvartaly)
Factor w/ 8
2009 Jun 25
1
How do I define the method for gcheckboxgroup in gWidgets?
Hi All...
I?m trying to build a small demo using gWidgets which permits interactive
scaling and selection among different things to plot. I can get the widgets
for scaling to work just fine. I am using gcheckboxgroup to make the
(possibly multiple) selections. However, I can?t seem to figure out how to
properly define the gcheckboxgroup; I can draw the widget properly, I think
my handler would