Displaying 20 results from an estimated 300 matches similar to: "Using vectors of names in calls for functions"
2012 Nov 19
5
help on matrix column removal based on another matrix results
Hi everyone, now I am trying to finish writing the code (I had asked for
assistance on subtracting arrays)
This is what I what I am running in R:
> source("/home/ie/Documents/TTU/GA_Research/GLUE/R-Project/R_GLUE_Example/NSEr.R")
NSEr <- function (obs, sim)
{
{jjh <- (as.vector(obs) - sim)^2
Xjjhs <- apply(Xjjh, 2, sum)
Yii <- (obs - mean(obs))^2
Yiis <- apply(Yii, 2,
2007 Dec 13
2
use ggplot in a function to which a column name is given
Hi everyone, Hi ggplot users in particular,
ggplot makes it very easy to plot things given their names when you
use it interactively (and therefore can provide the names of the
columns).
qplot(x,foo,data=A) where A has columns (x,y,foo,bar) for example
but I would like to use this from inside a function to which the name
of the column is given. I cannot find an elegant way to make this
2006 Nov 15
1
trellis.par.set and grid : how to set by default that I want a grid on my graphes ?
Hello all,
I want to draw a grid behind my graphes, using lattice package.
I manage to do it with instructions like this one :
xyplot(Sepal.Length + Sepal.Width ~ Petal.Length ,
data = iris, allow.multiple = TRUE, scales = "same",type="l",
panel = function(...) { panel.grid(h=-1, v= -1) ;
panel.superpose(...)
}
)
I was wondering if there were a way to do it
2007 Nov 30
1
formula substitution by its calculated value
Dear R_Users,
I am confronted to a technical issue that I wouldn't even know how to start to handle and where to look at. It is about data manipulation in a dataframe and value substitution
Imagine I have a matrix describing a set of chemical equations.
Colnames are Components names and Rownames are Reaction names
Each cell in that matrix corresponds to the stoechiometric coefficient to the
2007 Mar 08
2
sending a vector of characters as arguments for a function
Dear all,
It seems to be a recurrent problem to me and I am asking your help to
get over it once for all ...
My idea is :
I have variables C_1, C_2, C_3 ... that corresponds to vectors of size
n, and I would like to cbind them.
I get a vector of their names using : temp<- ls(pat="C")
And I like to find a way to use this vector temp as an argument to
cbind.
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,
2011 Aug 15
1
ggplot in a function confusion!
Whats going on here?
df<-data.frame(x=1:10,y=1:10)
ggplot()+geom_point(data=df,aes(x=x,y=y)) ## this is the normal usage
right?
ggplot()+geom_point(data=df,aes(x=df[,1],y=df[,2])) ## but I can also feed
it column indices
ggplot()+geom_point(aes(x=df[,'x'],y=df[,'y'])) ## or column names.
## but if i wrap it in a function...
plot.func.one<-function(dff,x.var,y.var){
2011 Dec 09
3
ggplot with geom_tile
Dear R-users,
I am trying to make a plot with ggplot-geom_tile(), but cannot remove some unwanted (white) lines through my plot.
Below a reproducible example:
#####
library(ggplot2)
tot=as.data.frame(rep(seq(-50,50,5),each=21))
names(tot)="precip"
temp=rep(seq(-5,5,0.5),21)
tot$temp=temp
disc=array(dim=c(21,21))
for(i in 1:21){
for(y in 1:21){
temp<-
2005 Apr 28
2
Reconstruction of a "valid" expression within a function
Hello all,
I have some trouble in reconstructing a valid expression within a
function,
here is my question.
I am building a function :
SUB<-function(DF,subset=TRUE) {
#where DF is a data frame, with Var1, Var2, Fact1, Fact2, Fact3
#and subset would be an expression, eg. Fact3 == 1
#in a first time I want to build a subset from DF
#I managed to, with an expression like eg. DF$Fact3,
# but I
2013 Jul 25
1
GGplot 2 – cannot get histogram and box plot axis to match.
Problem:
I am trying to get the histogram and box plot x axis to match. I?ve tried using the expand_limits function to make the axis match but that didn?t make the axis match. The histogram?s axis are still consistently larger than the ones for the box plot (though the function did help). Does anyone have a suggestion as to what I should do instead?
Background:
I am building a Shiny app that
2010 Nov 20
2
Merge two ggplots
Hello everyone.
I am using ggplot and I need some help to merge these two plots into one.
plot_CR<-function(x,y,agentid,CRagent){
library(ggplot2)
agent<-CRagent[[agentid]] # To make following expression shorter
ggplot((data.frame(x=CRX,y=CRY,sr=agent$sr)))+
geom_point(aes(x,y,colour=cut(sr,c(0,-10,-20,-30,-40,-50,-60,-70,-80))))+
geom_text(aes(x,y,color=cut(sr,
2007 Jan 10
2
USB Flash disk with sector size 2048
Hello every one an a pretty new year.
I'm making a derivative a the Feather linux-live which can be found
here:
http://franboisson.homeip.net/clef/ClefAgreg.iso
Everything works find except with USB key with sector size different
then 512 (2048 in my case). I look at the source of syslinux and change
the following:
* The test in syslxmod.c
* Change each time I see SECTOR_SHIFT=9 in
2006 Nov 28
1
problem with source(), parse() and "french" colnames
Hello every one
Working under Windows Xp in French, and R version 2.4.0 (and : >
localeToCharset() : "ISO8859-1" )
I am trying to source a file with basic commands.
source("R files/InputFile Analysis (Calculs et mises à l'échelle - gestion
des pb d'unités).r")
and it works fine as long as I do not use command like these ones :
2011 Aug 31
2
ggplot2 to create a "square" plot
Dear all,
I am using ggplot with geom_tile to print as an image a matrix I have. My matrix is a squared one of 512*512 cells.
The code that does that is written below
> print(v + geom_tile(aes(fill=dB))+ opts(axis.text.x=theme_text(size=20),axis.text.y=theme_text(size=20), axis.title.x=theme_text(size=25) , axis.title.y=theme_text(size=25), legend.title=theme_text(size=25,hjust=-0.4) ,
2008 Mar 26
2
ggplot2 argument handling odd
Hello there,
I'm trying to do lots of plots in one for-loop. But somehow ggplot does
not evaluate arguments as expected. Here is an example:
library(lattice)
library(ggplot2)
pl <- list()
pl2 <- list()
cDat <- as.data.frame(cbind(x1=0:100,x2=0:10,x3=1:20))
for(obs in c("x1", "x2")) {
pl[[obs]] <- xyplot(cDat[,obs] ~ cDat[,"x3"], main=obs)
2008 Mar 25
2
ggplot2 - facetting
Dear All,
After having overcome the issue of legends (thanks, Thierry, once
more), I am trying to use facetting, but here also I can not find how
to do this. I do not want to use qplot, but rather the more flexible
options. However, it seems I am doing still something pretty stupid,
because I always get an error, even if it seems I am doing everything
like the examples.
My code is below.
2009 Sep 21
1
RODBC : using and passing queries that use " in some arguments
Dear R users,
I am trying to connect R to data that is in a Access Database but I have problem with the construction of queries using special characters.
I am using RODBC package.
The following is working :
> MyQuery<-paste("SELECT first( (DateHeure) ) , avg(NNO3_AT322_OUT_moy) AS Cond FROM Colonne_3 ")
> Col3<-sqlQuery(con, query=MyQuery)
> Col3
2008 Feb 05
2
using image to show RGB image data ?
Hello all,
I'm now using image() to show image data (in my case dumps of SOM
weights) but would like to show RGB colour data, not just single "z"
colour values.
I've currently been using seq() to skip 4 values, so I can show the R, G
or B channels separately as "z". But is there a way I can show all three
channels simultaneously as a proper colour image?
Thanks,
B.
2009 Feb 26
1
gplot problems with faceting
Dear R-Listers,
I am very confused with what seems to be a misuse of the faceting options with gplot function and I hope you might help me on this.
z contains various simulation results from simulations with different set of parameters.
I melt my data to have the following data.frame structure :
> str(z)
'data.frame': 12383 obs. of 5 variables:
$ vID : num 1 2 3 4 5 6 7 8
2011 May 26
1
Question about ggplot2
Hi all,
Is there any way for me to to string in the argument of qplot or ggplot? for
example
qplot(x='carat',y='price',data=diamonds,geom=c('point','smooth'))
instead of
qplot(x=carat,y=price,data=diamonds,geom=c('point','smooth'))
Thanks!!
Regards,
TszKin Julian
[[alternative HTML version deleted]]