[R] Letter with tilde

2012-05-23 Thread Judith Flores
Hi,

   I was unable to find documentation about how to include the letter 'n' with 
tilde above it, like this: ñ.

   Is it possible to do that?

Thank you,

Judith
[[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] Reordering levels of a factor when the factor is part of a data frame

2012-02-06 Thread Judith Flores
Hello R-users,

   I have a data frame whose names of columns I don't know a priori, but the 
user of my code will know them. The user is supposed to save the name of the 
column that will need some reordering of the levels of the factor later on. The 
name of the column will be saved in an object called:

variab

the data frame is called df.


If I try to the do following:

df[variab]-factor(df[variab], levels=c(A2B,B31,C33))

it won't work because df[variab] is a data frame. The reason for reordering the 
levels of the factor is because once that variable is plotted, the levels of 
the factor need to appear in certain order.

   How can I re-order the levels of a factor whose name I don't know?


Thank you,

Judith
[[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] Superscripts in strip labels of lattice plot

2011-06-03 Thread Judith Flores
Hello,

   I need to add superscripts of the strip labels of a xyplot. 

For example: 


xyplot(a~b|c)

   Where c has 3 factor levels: A^2, A^3 and A^4. How can I introduce 
expressions in the strip labels?

Thank you very much!

Judith

__
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] mgp.axis.labels

2011-04-06 Thread Judith Flores
Hello,

   I am trying to use mgp.axis labels to locate the x-xis at a different 
distance from the one specified for the y-axis. I know I could use other 
functions such as mtext or axis. But I am curious to know about how to use 
'mgp'axis.labels' from the Hmisc package. I tried following the example in the 
documentation without success.

Sample code:

x-1:10
y-1:10

mgp.axis.labels(type='x', mgp=c(5,1,2))
plot(x,y, xlab=X)


   I know I am not really understanding the concept, but some guidance would be 
greatly appreciated.

Thank you,

Judith

__
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] Greek letter included in a character vector

2010-09-10 Thread Judith Flores
Hello,

   In the past I have used expression to include greek letters in axis 
labels, 
but this time I need to include the greek letter as part of a legend. 
Basically, 
I need to create the following vector to rename the levels of a factor:

c(Interferon-gamma, IL-10, IL-5), where gamma obviously needs to be 
printed as the greek letter gamma. I have tried expression(IFN-*gramma), but 
it only works when it is isolated, not as part of a vector.

Any guidance would be very appreciated.

Thank you,

Judith

__
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] Regular expression to define contents between parentheses

2009-08-25 Thread Judith Flores
Hello dear R-helpers,

   I haven't been able to figure out of find a solution in the R-help archives 
about how to delete all the characters contained in groups of parenthesis. I 
have a vector that looks more or less like this:

myvector-c(something (80 km/h, sd)  more (6 kg/L,sd), somethingelse (48 
m/s, sd)  moretoo (50g/L , sd))

I want to extract all the strings that are not contained in parenthesis, the 
goal would be to obtain the following new vector:

subvector-c(something  more, somethingelse  moretoo)

I tried the following, but this pattern seems to enclose all that is included 
between the first opened parenthesis and the last closed parethesis, which 
makes sense, but it's not what I need:

subvector-gsub(\\((.*)\\),,myvector


Your help will be very appreciated.

Thank you,

Judith

__
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] Stacked density plots

2009-04-10 Thread Judith Flores

Hello R-community,

I want to generate stacked density plots in lattice. My data consist of a 
numeric variable ('pid') that is measured in different individuals ('id'), 
which can be divided in two types ('type') and the measurements were repeated a 
different time points ('day').

I read in the Lattice book that this can be done using the 'flowViz' package, 
so I tried to reproduce the example given in there and obtained an error:

library('flowViz')
data(GvHD, package='flowCore)
densityplot(Visit~'FSC-H'|Patient, data=GvHD)

Error: ' FSC-H ' is/are no valid parameter(s) in this frame

I am not sure if I am missing something. I was hoping to apply something 
similar to my data, maybe like this?

desityplot(id~pid|type+day, data=mydata)

Thank you in advance for your help,

Judith

__
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 the y-axis units of a lattice histogram

2009-04-03 Thread Judith Flores

Hello,

   I need to multiply the number of counts in the y-axis of a lattice histogram 
by a constant factor, such that the plot would represent a different type of 
variable plotted in the y-axis, not counts. Can this be done?

Thank you,

Judith

__
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] Histogram with lattice with two 'conditional' variables

2009-04-02 Thread Judith Flores

Hello dear R-community,

I have been trying to figure out a way to generate histograms of a numeric 
variable observed in different entities ('individual' below). Each one of this 
entities is classified as A or B (according to the pseudo-code below):


variable-sample(rep(1:10,10))
individual-rep(1:10, length(variable))
group-rep(LETTERS[1:2],length(variable)/2)

mydata-data.frame(variable,individual,group)

library('lattice')

attach(mydata)
individual-as.factor(individual)
group-as.factor(group)
histogram(~variable|individual+group)

   If you run the above code you will obtain a series of panels that correspond 
to every entity, but replicated, which makes sense because I am telling it to 
generate histograms by entity and by group, but the reality is that each entity 
only belongs to one of the groups, but then some plots appear empty, as they 
should. That means that only the plots that have data in it are 'real'.

   My question is: how can I generate a layout where only the 'real' data 
exists and still get the two strips that specify the individual and group?

Thank you very much in advance for any help you can provide me with,

Judith

__
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 mix different font styles in axis label of lattice plot?

2008-10-03 Thread Judith Flores
Hello,

   I have a y-axis label that reads:  S. schenckii yeast cells. The part that 
reads S. schenckii needs to be in italic style, the rest of the text is 
normal style. How can I specify the different font styles for each part of the 
y-axis label?  

Thank you,

Judith

__
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] grep, gsub and metacharacters

2008-08-22 Thread Judith Flores
Hello,

   I have an expression that I want to substitute for something else.

myvector-c(ajkhfkiuwe,Variable(kg/min))

if I use the following code to extract variable(kg/min) and substitute it for 
va

gsub(myvector[grep(var, myvector, ignore=T)], va, myvector)

 grep identifies the element of the vector that matches my query, but it won't 
substitute the value. I have been reading the help pages for regular 
expression, but still can't figure out the syntax to read parenthesis and 
forward slashes, which are considered metacharacters.


As usual, thank you for your help,

Judith

__
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] Open directory within a menu in tcltk

2008-08-18 Thread Judith Flores
Hello,

I am trying to setup a menu to open files and directories. I have the 
following code:




opendir-function() {
  dirname-tclvalue(tkchooseDirectory())
}

openfile-function() {
  filename-tclvalue(tkgetOpenFile())
}

require(tcltk)
t1-tktoplevel()
topMenu-tkmenu(t1)
tkconfigure(t1,menu=topMenu)

plotMenu-tkmenu(topMenu, tearoff=FALSE)

tkadd(plotMenu,command,label=Open file, command=openfile)
tkadd(plotMenu, command,label=Select directory,command=opendir)
tkadd(plotMenu,command,label=Quit, command=function() tkdestroy(t1))
tkadd(topMenu, cascade, label=Menu,menu=plotMenu) 

tkfocus(t1)

  I can extract a file, but not a directory, I obtain the following error 
message:

Error in function ():
cannot change value of locked binding for 'dirname'.

  I would appreciate very much any help or explanation on this.

As always, thank you,

Judith

__
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 add 'specific length' segments to lattice plots

2008-08-08 Thread Judith Flores
Hello,

   I would like to add a horizontal line to each individual panel panel, the 
length  of the segment is given by a vector. If you run the following lines (a 
very simplified version of my script and data):




group-c('A','A','A','A','B','B','B','B','C','C','C','C')
value-c(89,35,58,33,45,79,66,73,35,37,12,39)
day-c(0,10,0,10,0,9,0,9,0,5,0,5)
index-c(2,2,2,2,4,4,4,4,7,7,7,7)
subgroup-c('g1','g1','g2','g2','g3','g3','g2','g2','g4','g4','g2','g2')

data-data.frame(group,value,day,index, subgroup)

library('lattice')

xyplot(data$value~data$day|data$group, groups=data$subgroup,

panel=function(x,y,...) {
panel.xyplot(x,y, type='b',...)
}
)

 
  What I would like to add to each panel is a horizontal line that, always 
starting at 0 for the value of the first argument of the function 
panel.segments, and the length of the segment will be defined by a value of the 
vector data$index. For example:

panel.segments(x[x==0],y[y==20],x[data$index],y[y==20])

  This means that 3 of the arguments will be constants, only the third argument 
is variable. So I tried something  like this:


xyplot(data$value~data$day|data$group, groups=data$subgroup,

panel=function(x,y,k=data$index, subscripts,...) {
panel.xyplot(x,y, type='b',...)
panel.segments(0,20,k[subscripts], 20)
}
)

 
But I obtain and error message letting me know that argument 'subscripts' is 
missing.

   Could some one explain to me what I am doing wrong? And how can I obtain a 
horizontal line per panel?

Thank you, as always, for your help and guidance,

Judith

__
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] tklistbox and extracting selection to R

2008-07-22 Thread Judith Flores
Dear experts,

   I am trying to understand why is it that when I paste (into the R console) 
the following code to select an option from a list:

  require(tcltk)
  tt-tktoplevel()
  tl-tklistbox(tt,height=ntx,selectmode=single,background=white)
  tkgrid(tklabel(tt,text=Select the legend of ))
  tkgrid(tl)
  treatments-levels.tx
  for(i in (1:ntx))
  {
  tkinsert(tl,end,treatments[i])
  }

  OnOK-function()
  {
  tx.choice1-treatments[as.integer(tkcurselection(tl))+1]
  tkdestroy(tt)

  }
  OK.but-tkbutton(tt,text=OK, command=OnOK)
  tkgrid(OK.but)

tx.choice1


 the console can't find tx.choice1, but if I type tx.choice1 directly into 
the console, it returns the value I selected from the list.

   I am running R 2.7.1, OS: linnux, I run R within emacs.

Thank you very much for you help,

Judith

__
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] Retrieving data from a tcl /tk function

2008-07-18 Thread Judith Flores
Hello,

   I am sorry if this is an answered question, but I did my homework for a long 
while and couldn't figure out a way to retrieve data entry from a model dialog. 
In one of the examples compiled by James Wettenhall:

odalDialog - function(title, question, entryInit, entryWidth = 20,
returnValOnCancel = ID_CANCEL) {
dlg - tktoplevel()
tkwm.deiconify(dlg)
tkgrab.set(dlg)
tkfocus(dlg)
tkwm.title(dlg, title)
textEntryVarTcl - tclVar(paste(entryInit))
textEntryWidget - tkentry(dlg, width = paste(entryWidth),
textvariable = textEntryVarTcl)
tkgrid(tklabel(dlg, text =))
tkgrid(tklabel(dlg, text = question), textEntryWidget)
tkgrid(tklabel(dlg, text =))
ReturnVal - returnValOnCancel

onOK - function() {
ReturnVal - tclvalue(textEntryVarTcl)
tkgrab.release(dlg)
tkdestroy(dlg)
tkfocus(ttMain)
}
onCancel - function() {
ReturnVal - returnValOnCancel
tkgrab.release(dlg)
tkdestroy(dlg)
tkfocus(ttMain)
}
OK.but - tkbutton(dlg, text =OK   , command = onOK)
Cancel.but - tkbutton(dlg, text =  Cancel , command = onCancel)
tkgrid(OK.but, Cancel.but)
tkgrid(tklabel(dlg, text = ))

tkfocus(dlg)
tkbind(dlg, Destroy, function() {tkgrab.release(dlg); tkfocus(ttMain)})
tkbind(textEntryWidget, Return, onOK)
tkwait.window(dlg)

return(ReturnVal)
}

# Create a main window with a button which activates our dialog
require(tcltk)
ttMain - tktoplevel()
tktitle(ttMain) - ttMain
launchDialog - function() {
ReturnVal - modalDialog(First Name Entry, Enter Your First Name, )
if (ReturnVal == ID_CANCEL) return()
tkmessageBox(title = Greeting,
message = paste(Hello, , ReturnVal, ., sep = ))
}
launchDlg.button - tkbutton(ttMain, text = Launch Dialog, command = 
launchDialog)
tkpack(launchDlg.button)


  How can I retrieve the input value of ReturnVal? Also, is there a book 
that you would recommend to understand the interface between tcl/tk and R?  Dr. 
Dalgaard's article was very helpful, but wondering if there is more information 
on the topic.


Thank you for your help,

__
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] Function to verify existence of an R object

2008-07-16 Thread Judith Flores
Hello,

   is there a function to check if an object exists?

Thank you,

Judith

__
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 package to use to create a GUI

2008-07-15 Thread Judith Flores
Hello dead R-experts,

   I work on x86_64-suse-linux and I am using R 2.7.1. I created several 
scripts that will be used by several people that are not familiar with R. I 
would like to create a GUI to call the scripts that the users would choose to 
run, also, the GUI should allow them to choose the directories where their raw 
data resides, the scripts will be fed with such raw data. 

   My question is the following: is there a R package that has built-in 
functions to create a GUI for linux? If so, what package is it? If not, what 
language would you recommend me to use to create the GUI?

Thank you very much in advance for any help you can provide me with,

Judith

__
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] (no subject)

2008-04-23 Thread Judith Flores
Hello,

   I have been trying to apply some of the different
ways suggested in the past to replace empty values in
a vector for a letter, without success.

   Actually, I have a data frame that might contain
empty values, I need to replace all those empty values
for the letter 'N'.

  This was my latest try:

   dat-read.csv('myfile.csv', na.strings=)

   

   


  

Be a better friend, newshound, and

__
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 the 'by' function within a 'for' loop

2008-04-22 Thread Judith Flores
Dear R experts,


I am sorry for sending this email again. I would
imagine yesterday and maybe today, have been very busy
days with the release of R v 2.7.0. I join all the R
users who are very gratful for your contant work and
efforts, specially knowing that you are doing this for
the sake of science, without gettig any compensation
for that.
Having written that, I decided to send the email
below again, in case it was forgotten; or maybe I am
missing something very basic?

   I am using version 2.7.0, in windows XP.

Start of yesterday's email:

I am trying to optimize my script, because right
now it requires a lot of memory. The goal is to
generate four plots in one page. Every plot
corresponds to the means and sem's calculated for a
given variable at different days. In order to obtain
the means and sem's I apply the 'by' function. The way
I have done it so far is like this:

Read the data
Generate a summary of the mean and sem of a variable
at every Day.
Plot the mean and sem of that variable.

Repeat the same process for the other 3 variables.

  I tried to optimize the code by using a for loop,
the code is below.

  

#Reading the data
dato-read.csv('mydata.csv')
names(dato)-c(id,day,tx,var1,var2,var3,var4)
dato-dato[,1:7]

#Specify varible to be plotted
variable-c('var1','var2','var3','var4')

#Define parameters of window where panel: margins,
number of plots in the panel
windows(height=9, width=9, rescale='fixed')
par(mfrow=c(2,2),xpd=T, bty='l',
omi=c(0.8,0.25,1.2,0.15), mai=c(1.1,0.8,0.3,0.3))


for (k in variable) {

dat-dato[!is.na(k),]



summ-by(dat,dat[,c(tx,day)], function(x) {
mn-mean(x$k)
std-sd(x$k)
n-length(x$k)
se-std/sqrt(n)
lowb-mn-se
upb-mn+se
   
data.frame(tx=x$tx[1],day=x$day[1],mn=mn,std=std,lowb=lowb,upb=upb,se=se)
})
summ-do.call(rbind,summ)
  



#Definining x axis range
xmax-unique(max(summ$day,na.rm=TRUE))
xmin-unique(min(summ$day,na.rm=TRUE))

yaxmin-unique(min(summ$lowb))
yaxmax-unique(max(summ$upb))


plot(1,1,type='n',xlab='Day',xlim=c(xmin,xmax),ylim=c(yaxmin,yaxmax),
ylab=k,
   
las=1,cex.lab=1,xaxp=c(xmin,xmax,diff(range(c(xmin,xmax)
points(summ$day,summ$mn)

}




Where variable is a vector that specifies all the
variables I want to plot.

But I am getting the following error:

“Error in var(as.vector(x), na.rm = na.rm) : 'x' is
empty
In addition: Warning message:
In mean.default(x$k) : argument is not numeric or
logical: returning NA”

   Could some one please show me how to structure my
code to achieve my final goal, which is to simplify
it?

I am attaching a csv file in case you want to run my
code.

Thank you very much in advance for your time and help,

Judith





  

Be a better friend, newshound, and 
__
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 the 'by' function withing a 'for' loop

2008-04-21 Thread Judith Flores
Dear R experts,

I am trying to optimize my script, because right
now it requires a lot of memory. The goal is to
generate four plots in one page. Every plot
corresponds to the means and sem's calculated for a
given variable at different days. In order to obtain
the means and sem's I apply the 'by' function. The way
I have done it so far is like this:

Read the data
Generate a summary of the mean and sem of a variable
at every Day.
Plot the mean and sem of that variable.

Repeat the same process for the other 3 variables.

  I tried to optimize the code by using a for loop,
the code is below.

  

#Reading the data
dato-read.csv('mydata.csv')
names(dato)-c(id,day,tx,var1,var2,var3,var4)
dato-dato[,1:7]

#Specify varible to be plotted
variable-c('var1','var2','var3','var4')

#Define parameters of window where panel: margins,
number of plots in the panel
windows(height=9, width=9, rescale='fixed')
par(mfrow=c(2,2),xpd=T, bty='l',
omi=c(0.8,0.25,1.2,0.15), mai=c(1.1,0.8,0.3,0.3))


for (k in variable) {

dat-dato[!is.na(k),]



summ-by(dat,dat[,c(tx,day)], function(x) {
mn-mean(x$k)
std-sd(x$k)
n-length(x$k)
se-std/sqrt(n)
lowb-mn-se
upb-mn+se
   
data.frame(tx=x$tx[1],day=x$day[1],mn=mn,std=std,lowb=lowb,upb=upb,se=se)
})
summ-do.call(rbind,summ)
  



#Definining x axis range
xmax-unique(max(summ$day,na.rm=TRUE))
xmin-unique(min(summ$day,na.rm=TRUE))

yaxmin-unique(min(summ$lowb))
yaxmax-unique(max(summ$upb))


plot(1,1,type='n',xlab='Day',xlim=c(xmin,xmax),ylim=c(yaxmin,yaxmax),
ylab=k,
   
las=1,cex.lab=1,xaxp=c(xmin,xmax,diff(range(c(xmin,xmax)
points(summ$day,summ$mn)

}




Where variable is a vector that specifies all the
variables I want to plot.

But I am getting the following error:

“Error in var(as.vector(x), na.rm = na.rm) : 'x' is
empty
In addition: Warning message:
In mean.default(x$k) : argument is not numeric or
logical: returning NA”

   Could some one please show me how to structure my
code to achieve my final goal, which is to simplify
it?

I am attaching a csv file in case you want to run my
code.

Thank you very much in advance for your time and help,

Judith



  

Be a better friend, newshound, and 
__
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] Combining many csv files into one and adding a column with an id of each csv file read

2008-04-08 Thread Judith Flores
Dear R experts,

   I have been looking into the help-pages and old
questions from the R-Help site, but the options
offered there don't seem to work in my case.

  First of all, I am working on Windows XP, using R
version 2.6.2.

  I am attaching two csv files as an example of how
the data I am traying to put together is delivered to
us. On the first row of every csv file is the name of
the file, along with the pathfile. This is what I have
been doing with every csv files (per seprate), which
of course is not the most efficient way to do it;
basically, it reads the csv file, then deletes the
first 3 rows and some columns that we don't need and
finally I add another column that identifies all the
rows of the csv file as belonging to one subject only,
I have to do this for further manipulations with all
the data:

filename-'1_504_d0.csv'

dat-read.csv(filename, header=F)
dat-dat[c(-1:-3),c(-1,-4,-5,-6,-7,-9,-10,-11,-12)]
names(dat)-c('time','T1','T2')
dat-dat[,1:3]

dat$id-as.character(filename)

  Since I have multiple csv files to read and I need
to have them consolidated in one data frame, how can I
apply the above manipulations to all the csv files and
at the same time put them in one files?

At the end, I need a big data frame that has 4
columns

'Time', 'T1', T2', 'id'

I hope I have provided enough information.

Thank you in advance for your help,

Judith



  

[[elided Yahoo spam]]
__
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] Multiple lines with a different color assigned to each line (corrected code)

2008-02-26 Thread Judith Flores
Sorry, I just realized I didn't type in the correct
names of the variables I am working with, this is how
it should be:

plot(1,1,type=n)
for (i in summ$tx) {

   points(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
   lines(summ$timep[summ$tx==i],summ$mn[summ$tx==i])
}


Thank you,

Judith



  

Be a better friend, newshound, and

__
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] Add a rectangle behind a plot

2008-02-26 Thread Judith Flores
Hi there,

   I found one reference to add a reactangle behind a
plot using plot(...,add=T), I tried this but didn't
obtain the desired result.

If a I have the following code:

plot(x,y)
rect(xleft, ybottom, xright,ytop,col='green)

   The rectangle appear on top of the plot.

Any help will be greatly appreciated,

Judith

 


  

Never miss a thing.  Make Yahoo your home page.

__
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] R console closes on its own

2008-02-20 Thread Judith Flores
Dear R-experts,

   I am running a script that has the following
structure:

windows(height=5.5,width=8)

dat-read.csv(myfile.csv)
names(dat)-c('a','b','c','d')
dat-dat[,1:4]

xyplot(dat$a~dat$b)


   Then I usually save the plot as a PDF (from the
menu in the R console). I can save the PDF twice in a
row; but at the third time, right when I am about to
give a name to the graph, R crashes, no error
messages.

  I am using R 2.6.2, for Windows. I copy the script
from TinnR.

Thank you in adavance for any help,

Judith



  

Never miss a thing.  Make Yahoo your home page.

__
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] Replacing a character string when finding substring match

2008-02-14 Thread Judith Flores
Dear R-experts,

  I need to replace the values of a vector(tx) with a
word ('Vehicle') when the value of the vector contains
the word 'vehicle'. Sometimes, the value could be 'MCT
vehicle', or 'control-vehicle', etc.
  I tried gsub like this 

treatment-gsub('vehicle','Vehicle', tx, 
ignore.case=T)

   But then I end up with values like 'MCT Vehicle' or
'control-Vehicle'. I want the values to be one word:
'Vehicle'.



Thank you in advance for any help.






  

Be a better friend, newshound, and

__
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] Retrieving data frames from a for loop

2008-02-14 Thread Judith Flores
Dear R-helpers,

   I need to retrieve the data frames generated in a
for loop. What I have looks something like this:

where tab is a pre-existing data frame.

for (i in 1:20) {

 g-sample(rep(LETTERS[1:2],each=10))
 combination-data.frame(tab,g)

}

   I tried to name every single combination doing
this:

assign(paste('combination',i), combination)

  without success.

I need to retrieve every combination per separate.

Thank you once again for your help.


  

Looking for last minute shopping deals?

__
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] Sampling

2008-02-05 Thread Judith Flores
Hi there,

   I want to generate different samples using the
followindg code:


g-sample(LETTERS[1:2], 24, replace=T)

   How can I specify that I need 12 As and 12 Bs?

Thank you,

Judith


  

Be a better friend, newshound, and

__
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] Grouping

2008-01-24 Thread Judith Flores
I need to group some subjects according to two
variables (var1, var2)

I have a data frame that looks something like this:

Subject   var1   var2   
1 400150 
2 320100 
3 580600 
4 145789 

   
  Each suject would fall into one of 2 categories ('A'
or 'B'). I want to find (and see) all the possible
combinations of letter assignment that exist, but
every combination needs to have an equal amount of
subjects categorized as 'A' or 'B'(eg. if I have 20
subjects there should be 10 assigned with letter 'A'
and 10 with letter 'B')

Thank you in advance for any hints,

Judith


  

Never miss a thing.  Make Yahoo your home page.

__
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] Adding a table to a lattice plot

2008-01-22 Thread Judith Flores
Hi,

   Is there an analog function of textplot in the
lattice package? I need to add a data frame to a
lattice plot. I work in a Windows environment and I am
using R v 2.6.1

Thank you,

Judith


  

Be a better friend, newshound, and

__
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] Adding a table to a plot

2008-01-18 Thread Judith Flores
Hi R-experts,

   Is it possible to add a table (text and lines) to
the plot area?

I have a data frame that looks something like this:

mydata

 Time   SD   Mean
   12.5   30
   2a.3   40


I am using R 2.6.1, in Windows.

Thank you,

Judith Flores
 


  

Looking for last minute shopping deals?

__
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] Different display of same graphs on different screens

2007-12-13 Thread Judith Flores
Dear R-experts,

   I need to run a R code on different computers (MACs
and PCs) on different monitos sizes. The code
generates graphs that are displayed in the same page.
But there are some elements of the graphs that appear
at the right position on a PC, but they don't appear
at all when I run it on a MAC. I have R v 2.5.1
installed in both types of systems.

  I specify windows(height=10, width=10) at the
beggining of the code.

I am guessing it has to do with devices, but I am not
sure what to specify.

Thank you,

Judith


  

Never miss a thing.  Make Yahoo your home page.

__
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] Saving lattice plot as a PDF

2007-12-09 Thread Judith Flores
Hi there,

I need to save a series of lattice plots as a PDF,
this is my code so far:

windows(height=8,width=6)
plot.new()
library('grid')
lattice.options(layout.heights=list(top.padding=list(x=0.15,
units=inches)))
print(plot1, split=c(1,1,2,3), more=TRUE)
print(plot2, split=c(1,2,2,3), more=TRUE)
print(plot3, split=c(1,3,2,3), more=TRUE)
print(plot4, split=c(2,1,2,3), more=TRUE)
print(plot5, split=c(2,2,2,3), more=TRUE)
print(plot6, split=c(2,3,2,3), more=FALSE)

ltext(grid.locator(), label='text', cex=1.3)
ltext(grid.locator(), label='text', cex=1.3)

And when I open the PDF created I see text at the
bottom of may layout, even though I placed it at the
top of the sheet.. If I save it as a metafile of PNG
the layoout is correct.

I have tried trellis.devices, what do I need to do to
retain the laout properties in a PDF format?

Thank you,

Judith






  

Looking for last minute shopping deals?

__
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] Viewport and grid.draw

2007-12-09 Thread Judith Flores
Hi Deepayan and everyone,

   I need to add a common legend to a group of latice
graphs, I have tried different ways using viewport and
grid.draw without success.

Here is what I have:

plot.new()

library(grid)
library('IDPmisc')

print(plot1, split=c(1,1,2,4), more=TRUE)
print(plot4, split=c(2,1,2,4), more=TRUE)
print(plot2, split=c(1,2,2,4), more=TRUE)
print(plot5, split=c(2,2,2,4), more=TRUE)
print(plot3, split=c(1,3,2,4), more=TRUE)
print(plot6, split=c(1,4,1,4), more=FALSE)
grid.text(vp=do.call(viewport,grid.locator(unit=npc)),
label='A', gp=gpar(fontsize=20))
grid.text(vp=do.call(viewport,grid.locator(unit=npc)),
label='B', gp=gpar(fontsize=20))





key1-draw.leg(key=list(text=list(c('some text',
'text2')),points=list(pch=c(17,15
vp.key-viewport(grid.locator(unit=npc))
pushViewport(vp.key)
grid.draw(key1)

grid.locator cannot be one of the arguments of
viewport, but waht would be the analog of this
argument in viewport then?

Thank you,

Judith




  

Be a better friend, newshound, and

__
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] Adding text outside lattice plot

2007-12-08 Thread Judith Flores
Hello,

   I need to add some text in the upper left position,
outside a lattice plot. 

xyplot(x~y)
ltext(locator(1), label='My text')

doesn't work. 


I would appreciate any help. Tahnk you,

Judith


  

Be a better friend, newshound, and

__
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] Ordering the levels of a vector

2007-12-03 Thread Judith Flores
Hi,

   I have a vector in a data frame that looks
something like this:

day-c('Day -1','Day 6','Day 10')


   This vector specifies the order in which several
panel will appear in a lattice plots. But the order in
which such plots will appear will be the following:
Day -1, Day 10, Day 6. Which makes sense, but I cannot
name the Days like this: Day -01,Day 10, Day 06, which
would put the levels in the order I want them to be.

  Now, this vector won't always have the same values,
it could be:

day-c('Day -1, 'Day 2','Day 14')

   So I cannot set the levels manually:

levels(day)-c('Day -1', 'Day something','Day
something else')
 I tried as.ordered, but I guess I am not using the
right function. 

How can I command the script to put the panels in the
original  order given of the vector in a data frame?

Thank  you,

Judith








  

Be a better friend, newshound, and

__
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] Dismiss previous email

2007-11-30 Thread Judith Flores
Sorry about that, it was sent by accident.

I have a data frame that looks something like this:

   id dayk
  56  -1  566
  63  -1  680
  73  -1  773
  56   2  298
  63   2  273
  
Of course, it is a very simplified version of the
real data frame I am working on. I need to add another
column that would represent a percent change in k from
day -1, by id. I put only two ids at day 2 to
emphasize the fact that after day -1 some subjects
won't be on the data frame any more.

I tried something like this:

pck-by(dat,dat[,c(id,day)], function(x) {
  pc-((x$k-x$k[x$day==-1])/x$k[x$day==-1])*100
  })
but it didn't work. 

Then I tried:

for(i in dat$id) {

for(s in dat$day) {
pc-((dat$k[dat$id==i 
dat$day==s]-dat$k[dat$id==i 
dat$day==-1])/dat$k[dat$id==i  dat$day==-1])*100
}
}
without success.

I am sure it is very simple to do, but I would
appreciate any hints.

Thank you,

Judith



 


  

Be a better pen pal.

__
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] (no subject)

2007-11-30 Thread Judith Flores
Hi,

   I have a data frame that looks something like this:

 id dayk
   656  -1  566
   663  -1  680
   673  -1  773
   675  -1  761
   704  -1  685
   714  -1  636
   717  -1  421
   719  -1  645
   727  -1  761
  731  -1  663
11  735  -1  603
12  738  -1  865
13  742  -1  594
14  744  -1  601
15  747  -1  816
16  749  -1  802
17  753  -1  811
18  761  -1  585
19  768  -1  644
20  771  -1  649
21  772  -1  679
22  788  -1  467
23  799  -1  572
24   81  -1  446
25  656   2  298
26  663   2  273
27  673   2  837
28  675   2  830
29  704   2  297
30  714   2  255
31  717   2  197
32  719   2  756
33  727   2  844
34  731   2  265
35  735   2  228
36  738   2  913
37  742   2  250
38  744   2  837
39  747   2  316
40  749   2  871
41  753   2  455
42  761   2  893
43  768   2  916
44  771   2  797
45  772   2  371
46  788   2  659
47  799   2  398



  

Never miss a thing.  Make Yahoo your home page.

__
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] Manipulating x axis in stripchart

2007-11-20 Thread Judith Flores
Hi all,

   I I need to manipulate the x axis in a stripchart.
I will use one of the data sets included in R to
explain what I need to do.

attach(ToothGrowth)

stripchart(len[supp=='VC']~dose[supp=='VC'],
vertical=TRUE, group.names=c('A','A','A'))

stripchart(len[supp=='OJ']~dose[supp=='OJ'], add=TRUE,
vertical=TRUE, at=c(1:3)+.1,
group.names=c('B','B','B'))

As you can read from the code above, I wanted to add
the 'B' to the x axis to diffrenciate each pair of
strips from each other. But only the 'A's appear.

I tried something like this too, but now '.5','1' and
'2' along with the 'A' and 'B'.

attach(ToothGrowth)

stripchart(len[supp=='VC']~dose[supp=='VC'],
vertical=TRUE)
axis(side=1,labels=c('A','B','A','B','A','B'),
at=c(.4,.5,.9,1.1,1.9,2.1))


stripchart(len[supp=='OJ']~dose[supp=='OJ'], add=TRUE,
vertical=TRUE, at=c(1:3)+.1)

And finally I tried setting par(xaxt='n') before
stripchart, but then I can't add anything to the x
axis.

  Is there a way to manipulate the x axis in a
stripchart like this?

Thank you very much in advance for your help,

Judith

__
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] Arranging multiple lattice plots in one page

2007-11-16 Thread Judith Flores
Hi,

   I am trying to arrange 3 different lattice plots in
one page. I tried defining par and layout without
success.

What I wrote looks something like this:

par(mfrow=c(3,1))

barplot(...)
xyplot(...)
barplot(...)

   


  

Never miss a thing.  Make Yahoo your home page.

__
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 the text in the strips of lattice plots and y axis

2007-11-14 Thread Judith Flores
Dear R-helpers,

   I am sorry for asking something I know has been
asked before, I have tried different combinations in
the strip function without success...


I am using version 2.5.1 and work on a PC.

   I have  barcharts generated from the following
formula:

barchart(y1+y2+y3~x | g)

I need to change the names of the variables y1,y2 or
y3 that currently appear in the strips, I have two
strips per panel, one corresponds to the name of the
variable (y1 or y2) and the second strip to the value
of the conditional variable (g has two levels, this
means I have 6 panels total).

  Instead of y1,y2 and y3 I would like the strips to
read 'name of variable y1', 'name of variable y2',
'name of variable y3'; of course these are not the
real names I want to assign to those variables.

  And my second question is regarding the the limits
of the y axis. If I setup scales to relation='free', I
obtain 6 different scales, which is expected. But I
need the panels that correspond to each y variable
have the same scale. I tried something like this:

prepanel=function(x,y,...) {ylim=list(min(y),max(y)) }

   but didn't work...

What do I need to do?

Thank you very much in advance for your help,

Judith


  

Never miss a thing.  Make Yahoo your home page.

__
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] caTools package

2007-10-10 Thread Judith Flores
Hi,

   I tried to install the caTools package manually
from the main R Project website and I get the
following error message when typing library('caTools')

Error in library(caTools) : 
  'caTools' is not a valid package -- installed 
2.0.0?

   What am I doing wrong? Also, why is this package
not available in the list of packages for direct
installation from the R console?

Thank you,

Judith

__
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] Adding a table to a plot area

2007-09-21 Thread Judith Flores
Is there a command to insert a table into the plot
area other that using text?

Thank you.


  

Luggage? GPS? Comic books?

__
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.