[R] cygwin clipboard

2019-05-21 Thread Ed Siefker
I'd like to be able to access the windows clipboard from R under Cygwin.
But...

> read.table(file="clipboard")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") : unable to contact X11 display
>

Is this supported in any way?  Thanks
-Ed

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] inverse of which()

2019-02-28 Thread Ed Siefker
That's exactly what I want! Thanks!
-Ed

On Wed, Feb 27, 2019 at 5:14 PM David L Carlson  wrote:
>
> I'm not sure I completely understand your question. Would using grepl() 
> instead of grep() let you do what you want?
>
> 
> David L Carlson
> Department of Anthropology
> Texas A University
> College Station, TX 77843-4352
>
> -Original Message-----
> From: R-help  On Behalf Of Ed Siefker
> Sent: Wednesday, February 27, 2019 5:03 PM
> To: r-help 
> Subject: [R] inverse of which()
>
> Given a vector of booleans, chich() will return indices that are TRUE.
>
> Given a vector of indices, how can I get a vector of booleans?
>
> My intent is to do logical operations on the output of grep().  Maybe
> there's a better way to do this?
>
> Thanks
> -Ed
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] inverse of which()

2019-02-27 Thread Ed Siefker
Given a vector of booleans, chich() will return indices that are TRUE.

Given a vector of indices, how can I get a vector of booleans?

My intent is to do logical operations on the output of grep().  Maybe
there's a better way to do this?

Thanks
-Ed

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 alpha entire plot?

2018-05-31 Thread Ed Siefker
I have two chromatograms I want plotted on the same axes.
I would like the plots to be transparent, so the first chart is
not obscured.

I have tried adjustcolor(..., alpha.f=0.3), the problem is that
my chromatogram is so dense with datapoints that they
overlap and the entire graph just ends up a solid color.  The
second histogram still obscures the first.

Consider this example:


col1 <- adjustcolor("red", alpha.f=0.3)
col2 <- adjustcolor("blue", alpha.f=0.3)
EU <- data.frame(EuStockMarkets)
with(EU, plot(DAX, CAC, col=col2, type="h", ylim=c(0,6000)))
par(new=TRUE)
with(EU, plot(DAX, FTSE, col=col1, type="h", ylim=c(0,6000)))

The density of the red plot around 2000 completely obscures the blue
plot behind it.

What I would like to do is plot both plots in solid colors, then alpha
the entire thing, and then overlay them.  Or some other method that
achieves a comparable result.
Thanks

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Exporting to text files

2018-05-18 Thread Ed Siefker
I have dose response data analyzed with the package 'drc'.
'summary(mymodel)' prints my kinetic parameters.  I want
that text in an ASCII text file.  I want to get exactly what I
would get if I copied and pasted from the terminal window.

I've read the documentation on data export to text files here:
https://cran.r-project.org/doc/manuals/r-release/R-data.html#Export-to-text-files

write() does not work.

> summary(mymodel)

Model fitted: Michaelis-Menten (2 parms)

Parameter estimates:

  Estimate Std. Error t-value  p-value
d:(Intercept)  213.435 67.094  3.1811 0.009801 **
e:(Intercept)   94.493 59.579  1.5860 0.143820
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error:

 22.03492 (10 degrees of freedom)
> write(summary(mymodel), "kinetics.txt")
Error in cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1), "\n"),  :
  argument 1 (type 'list') cannot be handled by 'cat'

If I try to unlist(mymodel):
> write(unlist(summary(mymodel)), "kinetics.txt")
I get the following contents of "kinetics.txt":

485.537711262143
4501.62443636671
3821.31920509004
3821.31920509004
3549.67055527084
213.435401944579
94.4931993582911
67.0941460663053
59.5791117361684
3.18113299681396
1.58601222147673
0.00980057624097692
0.143819823442402
MM.2()
continuous
10
4.63571040101587
3.93514151059103
3.93514151059103
3.65540149913749
Michaelis-Menten
2
22.0349202690217
10


How do I get the output of 'summary(mymodel)' verbatim? Why doesn't it
work the way I think it does? What documentation should I read to
understand what's going on here?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] drc, ggplot2, and gridExtra

2018-05-18 Thread Ed Siefker
I have dose response data I have analyzed with the 'drc' package.
Using plot() works great.  I want to arrange my plots and source
data on a single page.  I think 'gridExtra' is the usual package for
this.

I could use plot() and par(mfrow=...), but then I can't put the source
data table on the page.

gridExtra provides grid.table() which makes nice graphical tables. It
doesn't work with par(mfrow=...), but has the function grid.arrange()
instead.

Unfortunately, grid.arrange() doesn't accept plot(). It does work with
qplot() from 'ggplot2'.  Unfortunately, qplot() doesn't know how to
deal with data of class drc.

I'm at a loss on how to proceed here.  Any thoughts?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] ggplot inside function doesn't plot

2017-11-02 Thread Ed Siefker
I don't really understand. I mean, I understand the solution is
print(ggplot(...)).  But why is that required in a function and not at
the console?

Shouldn't I be able to rely on what I do at the console working in a
script?  Is this inconsistent behavior by design?



On Thu, Nov 2, 2017 at 11:54 AM, David Winsemius <dwinsem...@comcast.net> wrote:
>
>> On Nov 2, 2017, at 9:27 AM, Ed Siefker <ebs15...@gmail.com> wrote:
>>
>> I have a function:
>>
>> myplot <- function (X) {
>>d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
>>png(paste("img/", X, ".png", sep=""))
>>ggplot(d, aes(x=condition, y=count, color=condition)) +
>>geom_point(position=position_jitter(w=0.1,h=0)) +
>>scale_y_log10(breaks=c(25,100,400)) +
>>ggtitle(X) +
>>theme(plot.title = element_text(hjust = 0.5))
>>
>>dev.off()
>>}
>>
>> 'd' is a dataframe
>>
>> count  condition
>> E11.5 F20HET BA40_quant   955.9788   E11.5 F20HET
>> E11.5 F20HET BA45_quant   796.2863   E11.5 F20HET
>> E11.5 F20HET BB84_quant   745.0340   E11.5 F20HET
>> E11.5 F9.20DKO YEH3_quant 334.2994 E11.5 F9.20DKO
>> E11.5 F9.20DKO fkm1_quant 313.7307 E11.5 F9.20DKO
>> E11.5 F9.20DKO zzE2_quant 349.3313 E11.5 F9.20DKO
>>
>> If I set X="Etv5" and paste the contents of the function into R, I get
>> 'img/Etv5.png'
>> If I run myplot(X), I get nothing.
>>
>>
>>> X
>> [1] "Etv5"
>>> list.files("img")
>> character(0)
>>> myplot(X)
>> null device
>>  1
>>> list.files("img")
>> character(0)
>>> d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
>>> png(paste("img/", X, ".png", sep=""))
>>> ggplot(d, aes(x=condition, y=count, color=condition)) +
>> + geom_point(position=position_jitter(w=0.1,h=0)) +
>> + scale_y_log10(breaks=c(25,100,400)) +
>> + ggtitle(X) +
>> + theme(plot.title = element_text(hjust = 0.5))
>>> dev.off()
>> null device
>>  1
>>> list.files("img")
>> [1] "Etv5.png"
>>
>> Why doesn't my function work?
>
> `ggplot` creates an object. You need to print it when used inside a function. 
> Inside a function (in a more restricted environment) there is no 
> parse-eval-print-loop.
>
>
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
> David Winsemius
> Alameda, CA, USA
>
> 'Any technology distinguishable from magic is insufficiently advanced.'   
> -Gehm's Corollary to Clarke's Third Law
>
>
>
>
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] ggplot inside function doesn't plot

2017-11-02 Thread Ed Siefker
I have a function:

myplot <- function (X) {
d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
png(paste("img/", X, ".png", sep=""))
ggplot(d, aes(x=condition, y=count, color=condition)) +
geom_point(position=position_jitter(w=0.1,h=0)) +
scale_y_log10(breaks=c(25,100,400)) +
ggtitle(X) +
theme(plot.title = element_text(hjust = 0.5))

dev.off()
}

'd' is a dataframe

 count  condition
E11.5 F20HET BA40_quant   955.9788   E11.5 F20HET
E11.5 F20HET BA45_quant   796.2863   E11.5 F20HET
E11.5 F20HET BB84_quant   745.0340   E11.5 F20HET
E11.5 F9.20DKO YEH3_quant 334.2994 E11.5 F9.20DKO
E11.5 F9.20DKO fkm1_quant 313.7307 E11.5 F9.20DKO
E11.5 F9.20DKO zzE2_quant 349.3313 E11.5 F9.20DKO

If I set X="Etv5" and paste the contents of the function into R, I get
'img/Etv5.png'
If I run myplot(X), I get nothing.


> X
[1] "Etv5"
> list.files("img")
character(0)
> myplot(X)
null device
  1
> list.files("img")
character(0)
> d <- plotCounts(dds2, gene=X, intgroup="condition", returnData=TRUE)
> png(paste("img/", X, ".png", sep=""))
> ggplot(d, aes(x=condition, y=count, color=condition)) +
+ geom_point(position=position_jitter(w=0.1,h=0)) +
+ scale_y_log10(breaks=c(25,100,400)) +
+ ggtitle(X) +
+ theme(plot.title = element_text(hjust = 0.5))
> dev.off()
null device
  1
> list.files("img")
[1] "Etv5.png"

Why doesn't my function work?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] googlesheets gs_reshape_cellfeed()

2017-11-01 Thread Ed Siefker
I have a google spreadsheet with a column of hyperlinks I want the URL from.
The googlesheets package can return this information with gs_read_cellfeed(),
but it needs to be reshaped with gs_reshape_cellfeed().  Problem is,
gs_reshape_cellfeed() returns the 'value' of the cells, not the
'input_value' making
it exactly like gs_read().

How do I extract input_value from a cell feed in a convenient format? I want a
data frame that looks exactly like the output of gs_read(), except returning
'input_value' instead of 'value'.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] as.data.frame doesn't set col.names

2017-10-24 Thread Ed Siefker
Wait.  Now I'm really confused.

>
> head(samples)
  quant_samples   age sapply(yo, toupper)
E11.5 F20het BA40 E11.5 F20het BA40 E11.5  F20HET
E11.5 F20het BA45 E11.5 F20het BA45 E11.5  F20HET
E11.5 F20het BB84 E11.5 F20het BB84 E11.5  F20HET
E11.5 F9.20DKO KTr3 E11.5 F9.20DKO KTr3 E11.5F9.20DKO
E11.5 F9.20DKO PEd2 E11.5 F9.20DKO PEd2 E11.5F9.20DKO
E11.5 F9.20DKO j0J1 E11.5 F9.20DKO j0J1 E11.5F9.20DKO
> colnames(samples)
[1] "quant_samples" "age"   "geno"

Really, really confused.

On Tue, Oct 24, 2017 at 12:58 PM, Ed Siefker <ebs15...@gmail.com> wrote:
> Why doesn't this work?
>
>> samples$geno <- as.data.frame(sapply(yo, toupper), col.names="geno")
>> samples
>   quant_samples   age sapply(yo, toupper)
> E11.5 F20het BA40 E11.5 F20het BA40 E11.5  F20HET
> E11.5 F20het BA45 E11.5 F20het BA45 E11.5  F20HET

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] as.data.frame doesn't set col.names

2017-10-24 Thread Ed Siefker
Why doesn't this work?

> samples$geno <- as.data.frame(sapply(yo, toupper), col.names="geno")
> samples
  quant_samples   age sapply(yo, toupper)
E11.5 F20het BA40 E11.5 F20het BA40 E11.5  F20HET
E11.5 F20het BA45 E11.5 F20het BA45 E11.5  F20HET

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] A list of data frames and a list of colnames.

2017-10-23 Thread Ed Siefker
I have a list of file names, and a list of data frames contained in those files.

mynames <- list.files()
mydata <- lapply(mynames, read.delim)

Every file contains two columns.

> colnames(mydata[[1]])
[1] "Name" "NumReads"
> colnames(mydata[[2]])
[1] "Name" "NumReads"

I can set the colnames easily enough with a for loop.

for (i in seq_along(mynames)) {
colnames(mydata[[i]])[2] <- mynames[i]
}

Is there a nicer way to do this?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] data.matrix output is not numeric

2017-10-13 Thread Ed Siefker
I have a data frame full of integer values.  I need a matrix full of
numeric values.

?data.matrix reads:

 Return the matrix obtained by converting all the variables in a
 data frame to numeric mode and then binding them together as the
 columns of a matrix.

This does not work.

test.df <- data.frame(a=as.integer(c(1,2,3)), b=as.integer(c(4,5,6)))
> class(test.df[[1,1]])
[1] "integer"
> class(data.matrix(test.df)[[1]])
[1] "integer"

What's going on here?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Fwd: Boxplot, formula interface, and labels.

2017-09-28 Thread Ed Siefker
I knew I was making harder than it needed to be.  I see it now in ?boxplot
Thanks!

On Thu, Sep 28, 2017 at 12:30 PM, David L Carlson <dcarl...@tamu.edu> wrote:
> Just change the separator:
>
> data(Titanic)
> Titanic.df <- as.data.frame(Titanic)
> boxplot(Freq~Class*Sex, Titanic.df, cex.axis=.6, sep="\n")
>
> See attached .png.
>
> 
> David L Carlson
> Department of Anthropology
> Texas A University
> College Station, TX 77843-4352
>
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn
> Sent: Thursday, September 28, 2017 12:27 PM
> To: Ed Siefker <ebs15...@gmail.com>
> Cc: r-help <r-help@r-project.org>
> Subject: Re: [R] Boxplot, formula interface, and labels.
>
> mybp <- boxplot(count ~ geno * tissue, data = mydata, plot = FALSE) 
> mybp$names <- gsub("\\.", "\n", mybp$names)
> bxp(mybp)
>
> See ?boxplot for details.
>
> Best,
> Ista
>
> On Thu, Sep 28, 2017 at 12:40 PM, Ed Siefker <ebs15...@gmail.com> wrote:
>> I have data I'd like to plot using the formula interface to boxplot.
>> I call boxplot like so:
>>
>> with(mydata, boxplot(count ~ geno * tissue))
>>
>> I get a boxplot with x axis labels like "wt.kidney".  I would like to
>> change the '.' to a newline.  Where is this separator configured?
>>
>> Thanks,
>> -Ed
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
> 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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] Boxplot, formula interface, and labels.

2017-09-28 Thread Ed Siefker
Another way to think of this problem.  If I could get my hands on the
vector of names boxplot()
is creating, I could use gsub() to replace '.' with '\n'.

Is there something I could run before boxplot() that would give me
that vector of names which
I could then pass to boxplot()?

On Thu, Sep 28, 2017 at 11:40 AM, Ed Siefker <ebs15...@gmail.com> wrote:
> I have data I'd like to plot using the formula interface to boxplot.
> I call boxplot like so:
>
> with(mydata, boxplot(count ~ geno * tissue))
>
> I get a boxplot with x axis labels like "wt.kidney".  I would like
> to change the '.' to a newline.  Where is this separator configured?
>
> Thanks,
> -Ed

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Boxplot, formula interface, and labels.

2017-09-28 Thread Ed Siefker
I have data I'd like to plot using the formula interface to boxplot.
I call boxplot like so:

with(mydata, boxplot(count ~ geno * tissue))

I get a boxplot with x axis labels like "wt.kidney".  I would like
to change the '.' to a newline.  Where is this separator configured?

Thanks,
-Ed

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] T tests on multiple groups

2017-01-19 Thread Ed Siefker
I have a data set with observations on groups with multiple variables.
Let's call them GENO and AGE.  I have control and test genotypes
and two different ages.  It is only meaningful to compare control and
test within the same age.

I'd like to get the p value for each group compared back to control
of the appropriate age.  T-test requires that the grouping factor has
exactly two levels.   How can I do this efficiently?

I was hoping something like ttest(OBS ~ GENO * AGE, mydata) would work.
Is there something I can do with tapply() or aggregate() to do this?
I'd like to end up with a table that looks like this:

GENOAgeOBSp.val
control101.11
control100.91
control202.11
control201.91
A10110.01224066
A1090.01224066
A20210.003102783
A20190.003102783
B1040.057714305
B1060.057714305
B20140.005923285
B20160.005923285
AB1010.698488655
AB101.10.698488655
AB2020.552786405
AB202.20.552786405

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] merging dataframes in a list

2016-06-03 Thread Ed Siefker
Thanks, ldply got me a data frame straight away.  But it filled empty
spaces with NA and merge no longer works.

> ldply(mylist)
 name red green
1 sample1  20NA
2 sample1  NA15
3 sample2  10NA
4 sample2  NA30
> mydf <- ldply(mylist)
> merge(mydf[1,],mydf[2,])
[1] name  red   green
<0 rows> (or 0-length row.names)
> merge(mydf[1,],mydf[2,], by=1)
 name red.x green.x red.y green.y
1 sample120  NANA  15


How do I merge dataframes with NA?

On Fri, Jun 3, 2016 at 2:17 PM, Ulrik Stervbo <ulrik.ster...@gmail.com> wrote:
> You can use ldply in the plyr package to bind all the data.frames together
> (a regular loop will also work). Afterwards you can summarise using ddply
>
> Hope this helps
> Ulrik
>
>
> Ed Siefker <ebs15...@gmail.com> schrieb am Fr., 3. Juni 2016 21:10:
>>
>> aggregate isn't really what I want.  Maybe tapply?  I still can't get
>> it to work.
>>
>> > length(mylist)
>> [1] 4
>> > length(names)
>> [1] 4
>> > tapply(mylist, names, merge)
>> Error in tapply(mylist, names, merge) : arguments must have same length
>>
>> I guess because a list isn't an atomic data type.  What function will
>> do the same on lists?  lapply doesn't have a 'by' argument.
>>
>> On Fri, Jun 3, 2016 at 1:41 PM, Ed Siefker <ebs15...@gmail.com> wrote:
>> > I manually constructed the list of sample names and tried the
>> > aggregate call I mentioned.
>> > Merge works when called manually, but not when using aggregate.
>> >
>> >> mylist <- list(data.frame(name="sample1", red=20),
>> >> data.frame(name="sample1", green=15), data.frame(name="sample2", red=10),
>> >> data.frame(na me="sample2", green=30))
>> >>  names <- list("sample1", "sample1", "sample2", "sample2")
>> >> merge(mylist[1], mylist[2])
>> >  name red green
>> > 1 sample1  2015
>> >> merge(mylist[3], mylist[4])
>> >  name red green
>> > 1 sample2  1030
>> >> aggregate(mylist, by=as.list(names), merge)
>> > Error in as.data.frame(y) : argument "y" is missing, with no default
>> >
>> > What's the right way to do this?
>> >
>> > On Fri, Jun 3, 2016 at 1:20 PM, Ed Siefker <ebs15...@gmail.com> wrote:
>> >> I have a list of data as follows.
>> >>
>> >>> list(data.frame(name="sample1", red=20), data.frame(name="sample1",
>> >>> green=15), data.frame(name="sample2", red=10), data.frame(name="sample 
>> >>> 2",
>> >>> green=30))
>> >> [[1]]
>> >>  name red
>> >> 1 sample1  20
>> >>
>> >> [[2]]
>> >>  name green
>> >> 1 sample115
>> >>
>> >> [[3]]
>> >>  name red
>> >> 1 sample2  10
>> >>
>> >> [[4]]
>> >>  name green
>> >> 1 sample230
>> >>
>> >>
>> >> I would like to massage this into a data frame like this:
>> >>
>> >>  name red green
>> >> 1 sample1  2015
>> >> 2 sample2  1030
>> >>
>> >>
>> >> I'm imagining I can use aggregate(mylist, by=samplenames, merge)
>> >> right?  But how do I get the list of samplenames?  How do I subset
>> >> each dataframe inside the list?
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] merging dataframes in a list

2016-06-03 Thread Ed Siefker
aggregate isn't really what I want.  Maybe tapply?  I still can't get
it to work.

> length(mylist)
[1] 4
> length(names)
[1] 4
> tapply(mylist, names, merge)
Error in tapply(mylist, names, merge) : arguments must have same length

I guess because a list isn't an atomic data type.  What function will
do the same on lists?  lapply doesn't have a 'by' argument.

On Fri, Jun 3, 2016 at 1:41 PM, Ed Siefker <ebs15...@gmail.com> wrote:
> I manually constructed the list of sample names and tried the
> aggregate call I mentioned.
> Merge works when called manually, but not when using aggregate.
>
>> mylist <- list(data.frame(name="sample1", red=20), 
>> data.frame(name="sample1", green=15), data.frame(name="sample2", red=10), 
>> data.frame(na me="sample2", green=30))
>>  names <- list("sample1", "sample1", "sample2", "sample2")
>> merge(mylist[1], mylist[2])
>  name red green
> 1 sample1  2015
>> merge(mylist[3], mylist[4])
>  name red green
> 1 sample2  1030
>> aggregate(mylist, by=as.list(names), merge)
> Error in as.data.frame(y) : argument "y" is missing, with no default
>
> What's the right way to do this?
>
> On Fri, Jun 3, 2016 at 1:20 PM, Ed Siefker <ebs15...@gmail.com> wrote:
>> I have a list of data as follows.
>>
>>> list(data.frame(name="sample1", red=20), data.frame(name="sample1", 
>>> green=15), data.frame(name="sample2", red=10), data.frame(name="sample 2", 
>>> green=30))
>> [[1]]
>>  name red
>> 1 sample1  20
>>
>> [[2]]
>>  name green
>> 1 sample115
>>
>> [[3]]
>>  name red
>> 1 sample2  10
>>
>> [[4]]
>>  name green
>> 1 sample230
>>
>>
>> I would like to massage this into a data frame like this:
>>
>>  name red green
>> 1 sample1  2015
>> 2 sample2  1030
>>
>>
>> I'm imagining I can use aggregate(mylist, by=samplenames, merge)
>> right?  But how do I get the list of samplenames?  How do I subset
>> each dataframe inside the list?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] merging dataframes in a list

2016-06-03 Thread Ed Siefker
I manually constructed the list of sample names and tried the
aggregate call I mentioned.
Merge works when called manually, but not when using aggregate.

> mylist <- list(data.frame(name="sample1", red=20), data.frame(name="sample1", 
> green=15), data.frame(name="sample2", red=10), data.frame(na me="sample2", 
> green=30))
>  names <- list("sample1", "sample1", "sample2", "sample2")
> merge(mylist[1], mylist[2])
 name red green
1 sample1  2015
> merge(mylist[3], mylist[4])
 name red green
1 sample2  1030
> aggregate(mylist, by=as.list(names), merge)
Error in as.data.frame(y) : argument "y" is missing, with no default

What's the right way to do this?

On Fri, Jun 3, 2016 at 1:20 PM, Ed Siefker <ebs15...@gmail.com> wrote:
> I have a list of data as follows.
>
>> list(data.frame(name="sample1", red=20), data.frame(name="sample1", 
>> green=15), data.frame(name="sample2", red=10), data.frame(name="sample 2", 
>> green=30))
> [[1]]
>  name red
> 1 sample1  20
>
> [[2]]
>  name green
> 1 sample115
>
> [[3]]
>  name red
> 1 sample2  10
>
> [[4]]
>  name green
> 1 sample230
>
>
> I would like to massage this into a data frame like this:
>
>  name red green
> 1 sample1  2015
> 2 sample2  1030
>
>
> I'm imagining I can use aggregate(mylist, by=samplenames, merge)
> right?  But how do I get the list of samplenames?  How do I subset
> each dataframe inside the list?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] merging dataframes in a list

2016-06-03 Thread Ed Siefker
I have a list of data as follows.

> list(data.frame(name="sample1", red=20), data.frame(name="sample1", 
> green=15), data.frame(name="sample2", red=10), data.frame(name="sample 2", 
> green=30))
[[1]]
 name red
1 sample1  20

[[2]]
 name green
1 sample115

[[3]]
 name red
1 sample2  10

[[4]]
 name green
1 sample230


I would like to massage this into a data frame like this:

 name red green
1 sample1  2015
2 sample2  1030


I'm imagining I can use aggregate(mylist, by=samplenames, merge)
right?  But how do I get the list of samplenames?  How do I subset
each dataframe inside the list?

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] reading data into nested frames

2016-06-02 Thread Ed Siefker
I have many data files named like this:

E11.5-021415-dko-1-1-masked-bottom-area.tsv
E11.5-021415-dko-1-1-masked-top-area.tsv
E11.5-021415-dko-1-2-masked-bottom-area.tsv
E11.5-021415-dko-1-2-masked-top-area.tsv
E11.5-021415-dko-1-3-masked-bottom-area.tsv
E11.5-021415-dko-1-3-masked-top-area.tsv

age-date-genotype-num-slicenum-filler-position-data

An individual sample is an age-date-geno-num, each sample has two
parts, and is composed of around 10 slices.  Each row of the tsv is an
area which will be summed for the total area.

What I want is a dataframe, with a row for each sample and a column
for bottom and top.  Under bottom and top, I want each element to be a
dataframe with a row for each slice and a column for the area.

So I can lapply over this list of files, use strsplit to pull out the
slice num and put the area into the correct row of a dataframe easily
enough.  But I have a line for every datapoint, not sample, and there
would be a dataframe for each area.

How can I merge all the data for the slices into one data frame?  Does
this make sense?
Thanks
-Ed

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] lists and rownames

2016-04-18 Thread Ed Siefker
I'm doing some string manipulation on a vector of file names, and noticed
something curious.  When I strsplit the vector, I get a list of
character vectors.
The list is numbered, as lists are.  When I cast that list as a data
frame with 'as.data.frame()', the resulting columns have names derived
from the original filenames.

Example code is below.  My question is, where are these names stored
in the list?  Are there methods that can access this from the list?
Is there a way to preserve them verbatim?  Thanks
-Ed

> example.names
[1] "con1-1-masked-bottom-green.tsv" "con1-1-masked-bottom-red.tsv"
[3] "con1-1-masked-top-green.tsv""con1-1-masked-top-red.tsv"
> example.list <- strsplit(example.names, "-")
> example.list
[[1]]
[1] "con1"  "1" "masked""bottom""green.tsv"

[[2]]
[1] "con1""1"   "masked"  "bottom"  "red.tsv"

[[3]]
[1] "con1"  "1" "masked""top"   "green.tsv"

[[4]]
[1] "con1""1"   "masked"  "top" "red.tsv"

> example.df <- as.data.frame(example.list)
> example.df
  c..con11maskedbottomgreen.tsv..
1con1
2   1
3  masked
4  bottom
5   green.tsv
  c..con11maskedbottomred.tsv..
1  con1
2 1
3masked
4bottom
5   red.tsv
  c..con11maskedtopgreen.tsv..
1 con1
21
3   masked
4  top
5green.tsv
  c..con11maskedtopred.tsv..
1   con1
2  1
3 masked
4top
5red.tsv

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] aggregate and the $ operator

2016-01-22 Thread Ed Siefker
So that's how that works!  Thanks.

On Fri, Jan 22, 2016 at 1:32 PM, Joe Ceradini <joecerad...@gmail.com> wrote:
> Does this do what you want?
>
> aggregate(Nuclei ~ Slide, example, sum)
>
> On Fri, Jan 22, 2016 at 12:20 PM, Ed Siefker <ebs15...@gmail.com> wrote:
>>
>> Aggregate does the right thing with column names when passing it
>> numerical coordinates.
>> Given a dataframe like this:
>>
>>   Nuclei Positive Nuclei Slide
>> 1133  96A1
>> 2 96  70A1
>> 3 62  52A2
>> 4 60  50A2
>>
>> I can call 'aggregate' like this:
>>
>> > aggregate(example[1], by=example[3], sum)
>>   Slide Nuclei
>> 1A1229
>> 2A2122
>>
>> But that means I have to keep track of which column is which number.
>> If I try it the
>> easy way, it doesn't keep track of column names and it forces me to
>> coerce the 'by'
>> to a list.
>>
>> > aggregate(example$Nuclei, by=list(example$Slide), sum)
>>   Group.1   x
>> 1  A1 229
>> 2  A2 122
>>
>> Is there a better way to do this?  Thanks
>> -Ed
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
>
>
>
> --
> Cooperative Fish and Wildlife Research Unit
> Zoology and Physiology Dept.
> University of Wyoming
> joecerad...@gmail.com / 914.707.8506
> wyocoopunit.org
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] aggregate and the $ operator

2016-01-22 Thread Ed Siefker
Aggregate does the right thing with column names when passing it
numerical coordinates.
Given a dataframe like this:

  Nuclei Positive Nuclei Slide
1133  96A1
2 96  70A1
3 62  52A2
4 60  50A2

I can call 'aggregate' like this:

> aggregate(example[1], by=example[3], sum)
  Slide Nuclei
1A1229
2A2122

But that means I have to keep track of which column is which number.
If I try it the
easy way, it doesn't keep track of column names and it forces me to
coerce the 'by'
to a list.

> aggregate(example$Nuclei, by=list(example$Slide), sum)
  Group.1   x
1  A1 229
2  A2 122

Is there a better way to do this?  Thanks
-Ed

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] plot changes usr?

2015-09-28 Thread Ed Siefker
I'm trying to plot() over an existing plot() like this:

> attach(mtcars)
> plot(mpg, hp)
> par(new=TRUE)
> par("usr")
[1]   9.46  34.84  40.68 346.32
> plot(mpg, hp, col="red", axes=FALSE, xlim=par("usr")[1:2], 
> ylim=par("usr")[3:4], xlab="", ylab="")
> par("usr")
[1]   8.4448  35.8552  28.4544 358.5456

For some reason "usr" is changing, and so it's not plotting over the
existing data in the right place.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Java requested System.exit(130)

2013-10-01 Thread Ed Siefker
I'm used to using ctrl-c to end operations without killing R.  But I've used
xlsx in this session, which loads Java, which apparently intercepts the
ctrl-C.  Accordingly, I hit ctrl-C, R died, and I lost a lot of work.

I did some looking, and found a
thread(http://comments.gmane.org/gmane.comp.lang.r.rosuda.devel/1368)
that says:

Yes, at least on Sun JVMs you need to add -Xrs java option so the JVM
doesn't steal SIGINT from R (see archives).

So, how do I actually do that? I'm not running java from the command line,
I'm using library(xlsx).  How do I tell R to pass that option to the JVM?
Thanks
-Ed

__
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] why is this a factor?

2013-08-28 Thread Ed Siefker
I have a table, and I want a new column to add some annotations to.
But it ends up as a factor instead of characters, and won't let me add
arbitrary text.

 data(iris)
 iris-data.frame(iris,annot=c())
 iris[1,annot]-annotation
Warning message:
In `[-.factor`(`*tmp*`, iseq, value = annotation) :
  invalid factor level, NAs generated
 class(iris[,annot])
[1] factor
 class(c())
[1] character

Why is c() a character, but when I add it to a data frame it's a factor?
What am I missing?  Is there a better way to add a new column to
a data frame?

__
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] Why do I have a column called row.names?

2012-06-04 Thread Ed Siefker
I'm trying to read in a tab separated table with read.delim().
I don't particularly care what the row names are.
My data file looks like this:


start   stopSymbol  Insert sequence Clone End Pair  FISH
203048  67173930ABC8-43024000D23TI:993812543
 TI:993834585
255176  87869359ABC8-43034700N15TI:995224581
 TI:995237913
1022033 1060472 ABC27-1253C21   TI:2094436044   TI:2094696079
1022033 1061172 ABC23-1388A1TI:2120730727   TI:2121592459



I have to do something with row.names because my first column has
duplicate entries.  So I read in the file like this:

 BACS-read.delim(testdata.txt, row.names=NULL, fill=TRUE)
 head(BACS)
  row.namesstart stop Symbol Insert.sequence Clone.End.Pair
1203048 67173930 ABC8-43024000D23 NATI:993812543  TI:993834585
2255176 87869359 ABC8-43034700N15 NATI:995224581  TI:995237913
3   1022033  1060472ABC27-1253C21 NA   TI:2094436044 TI:2094696079
4   1022033  1061172 ABC23-1388A1 NA   TI:2120730727 TI:2121592459
  FISH
1   NA
2   NA
3   NA
4   NA


Why is there a column named row.names?  I've tried a few different
ways of invoking this, but I always get the first column named row.names,
and the rest of the columns shifted by one.

Obviously I could fix this by using row.names-, but I'd like to understand
why this happens.  Any insight?

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


Re: [R] Why do I have a column called row.names?

2012-06-04 Thread Ed Siefker
I did read that, and I still don't understand why I have a column
called row.names.
I used row.names = NULL in order to get numbered row names, which was
successful:

 row.names(BACS)
[1] 1 2 3 4

I don't see what this has to do with an extraneous column name.  Can you be
more explicit as to what exactly I'm supposed to take away from this segment
of the help file?  Thanks.

On Mon, Jun 4, 2012 at 1:05 PM, David L Carlson dcarl...@tamu.edu wrote:
 Try help(read.delim) - always a good strategy before using a function for
 the first time:

 In it, you will find: Using row.names = NULL forces row numbering. Missing
 or NULL row.names generate row names that are considered to be 'automatic'
 (and not preserved by as.matrix).

 --
 David L Carlson
 Associate Professor of Anthropology
 Texas AM University
 College Station, TX 77843-4352


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Ed Siefker
 Sent: Monday, June 04, 2012 12:47 PM
 To: r-help@r-project.org
 Subject: [R] Why do I have a column called row.names?

 I'm trying to read in a tab separated table with read.delim().
 I don't particularly care what the row names are.
 My data file looks like this:


 start   stop    Symbol  Insert sequence Clone End Pair  FISH
 203048  67173930        ABC8-43024000D23                TI:993812543
  TI:993834585
 255176  87869359        ABC8-43034700N15                TI:995224581
  TI:995237913
 1022033 1060472 ABC27-1253C21           TI:2094436044   TI:2094696079
 1022033 1061172 ABC23-1388A1            TI:2120730727   TI:2121592459



 I have to do something with row.names because my first column has
 duplicate entries.  So I read in the file like this:

  BACS-read.delim(testdata.txt, row.names=NULL, fill=TRUE)
  head(BACS)
   row.names    start             stop Symbol Insert.sequence
 Clone.End.Pair
 1    203048 67173930 ABC8-43024000D23     NA    TI:993812543
 TI:993834585
 2    255176 87869359 ABC8-43034700N15     NA    TI:995224581
 TI:995237913
 3   1022033  1060472    ABC27-1253C21     NA   TI:2094436044
 TI:2094696079
 4   1022033  1061172     ABC23-1388A1     NA   TI:2120730727
 TI:2121592459
   FISH
 1   NA
 2   NA
 3   NA
 4   NA


 Why is there a column named row.names?  I've tried a few different
 ways of invoking this, but I always get the first column named
 row.names,
 and the rest of the columns shifted by one.

 Obviously I could fix this by using row.names-, but I'd like to
 understand
 why this happens.  Any insight?

 __
 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-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] lapply and paste

2012-03-28 Thread Ed Siefker
I have a list of suffixes I want to turn into file names with extensions.

suff- c(C1, C2, C3)
paste(filename_, suff[[1]], .ext, sep=)
[1] filename_C1.ext

How do I use lapply() on that call to paste()?
What's the right way to do this:

filenames -  lapply(suff, paste, ...)

?

Can I have lapply() reorder the arguments to FUN?

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


Re: [R] lapply and paste

2012-03-28 Thread Ed Siefker
Thank you, I was confused about that.  What exactly is lapply for then,
if R handles this kind of thing automatically?  Are there functions that are
not vectorized?


On Wed, Mar 28, 2012 at 1:37 PM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
 I think you're confused about the need for lapply -- paste is
 vectorized so this

 paste(filename_, suff, .ext, sep = )

 will work. But if you want to use lapply (for whatever reason) try this:

 lapply(suff, function(x) paste(filename_, x, .ext, sep = )

 Michael

 On Wed, Mar 28, 2012 at 2:31 PM, Ed Siefker ebs15...@gmail.com wrote:
 I have a list of suffixes I want to turn into file names with extensions.

 suff- c(C1, C2, C3)
 paste(filename_, suff[[1]], .ext, sep=)
 [1] filename_C1.ext

 How do I use lapply() on that call to paste()?
 What's the right way to do this:

 filenames -  lapply(suff, paste, ...)

 ?

 Can I have lapply() reorder the arguments to FUN?

 __
 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-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] avoiding for loops

2012-03-25 Thread Ed Siefker
I have data that looks like this:

 df1
  group id
1   red  A
2   red  B
3   red  C
4  blue  D
5  blue  E
6  blue  F


I want a list of the groups containing vectors with the ids.I am
avoiding subset(), as it is
only recommended for interactive use.  Here's what I have so far:

df1 - data.frame(group=c(red, red, red, blue, blue,
blue), id=c(A, B, C, D, E, F))

groups - levels(df1$group)
byid - lapply(groups, ==, df1$group)
groupIDX - lapply(byid, which)

 groupIDX
[[1]]
[1] 4 5 6

[[2]]
[1] 1 2 3



This gives me a list of the indices for each group.  I want to subset
df1 based on this list.
If I want just one group I can do this:

 df1[groupIDX[[1]],]$id
[1] D E F


What sort of statement should I use if I want a result like:
[[1]]
[1] D E F
Levels: A B C D E F

[[2]]
[1] A B C
Levels: A B C D E F


So far, I've used a for loop.  Can I express this with apply statements?

groupIDs - list(1:length(groupIDX))
groupData-
for (i in 1:length(groupIDX)) {
groupIDs[[i]] - df1[groupIDX[[i]],]$id
}

__
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] argument names inside a function?

2012-03-24 Thread Ed Siefker
Is there a way I can get the names of the arguments passed to a
function from within a function?

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


Re: [R] argument names inside a function?

2012-03-24 Thread Ed Siefker
Thanks, deparse(substitute()) does exactly what I want.

On Sat, Mar 24, 2012 at 4:20 PM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
 Can you be a little more concrete?

 If you want the form of the expression given (rather than its value),
 deparse(substitute()) will work:

 fnc1 - function(x){ deparse(substitute(x))}

 fnc1(3) # 3

 fnc1(x) # x

 fnc1(x + 4) # x+4

 If you are passing them through the ... argument, you can coerce that
 to a list and use the names() attribute.

 If you want to reconstruct the exact call (e.g., for a modelling
 function), match.call() will do it.

 Hope this helps,
 Michael


__
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] subsetting by cell value with a list

2012-03-15 Thread Ed Siefker
I would like to subset by dataframe by matching all rows that have any value
from a list of values.  I can get it to work if I have exactly one value,
I'm not
sure how to do it with a list of values though.

This works and gives me exactly one line:
my.df[ which( mydf$IDX==17)), ]

I would like to do something like this:
my.df[ which( mydf$IDX==c(17, 42), ]

Obviously that won't work, but I hope the meaning is clear.
What's the right way to express this?

[[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] Rserve as a proxy

2012-03-12 Thread Ed Siefker
Is there a simple way to use Rserve/RSclient as a proxy to transparently
send requests from a local instance of R to a remote instance?   It seems
like this would by doable by wrapping each call that doesn't refer to a
local path inside RSeval.  Is this harder than it seems?  Does this already
exist somewhere?

[[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] logical to vector?

2012-03-07 Thread Ed Siefker
I am trying to use the coXpress function from
the coXpress package.  This function requires
numerical vectors indicating which columns
are in which group.

The problem is, I can only figure out how
to get a logical structure, not a numerical one.
In other words, coXpress wants something like:
1:3

 I have something like:
TRUE TRUE TRUE FALSE FALSE

Can I convert one into the other easily?

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