Hi David,
First I ordered the levels of each factor in a descending order based on
frequency.
Then, I used the following code to generate a matrix from the dataframe with
dummy variables and subsequently run the glmnet (coxnet)
## tranform categorical variables into binary variables with dummy
Hi,
dat1<- read.table("gao.txt",sep="",header=FALSE,stringsAsFactors=FALSE)
dat1
# V1 V2 V3 V4 V5 V6 V7 V8
#1 ref_gene_id ref_id class_code cuff_gene_id cuff_id FMI FPKM FPKM_conf_lo
#2 - - u C.3 C.3.1 100
On 13-09-2013, at 19:02, Patrick Schorderet
wrote:
>
> I'm trying to write an Automator script for people who don't want to run
> scripts from the R console.
> The workflow would ideally look like this:
> - Ask user to enter different parameters (I was able to do this part)
> - Run an R scrip
I own a lot to the folks on r-help list, especially arun who answered every
of my question and was never wrong. I am disinclined to once again ask this
question, since it is more arithmatic than technical. But, having worked 2
days on it, I realized my brain is just not juicy enough
Here
Sorry about that. I will try to reformat my question.
I have a dataset with format like:
--
> head(data)
V1 V2 V3 V4 V5 V6 V7 V8
1 ref_gene_id ref_id class_code cuff_gene_id cuff_id FMI FPKM FPKM_conf_lo
2
Please read the Posting Guide before you post again, and study how to make a
reproducible example of your problem [1], and change the settings on your mail
program to send plain text. I, for one, am not psychic, so need things spelled
out clearly.
[1]
http://stackoverflow.com/questions/5963269
Thanks a lot for all the responses!!
I then first test my data:
> dim(data)
[1] 52086 13
> if(grep(data[3,4],data[3,12])==1) print("Y")
[1] "Y"
> for(i in 1:52086){if(grep(data[i,4],data[i,12])==1) print ("Y")}
Error in if (grep(data[i, 4], data[i, 12]) == 1) print("Y") :
argument is of len
This is because you are not printing it (with the print or cat functions). Keep
in mind that the visible result you get from calling a function or evaluating a
variable interactively comes from the interactive R command line, not from R
itself. Once you put such an expression inside a function (
Hi,
Try:
for(i in 1:10) {print(grep("a",letters))}
[1] 1
[1] 1
[1] 1
[1] 1
[1] 1
[1] 1
[1] 1
[1] 1
[1] 1
[1] 1
x<- vector()
for(i in 1:10) {x[i]<-grep("a",letters) }
x
# [1] 1 1 1 1 1 1 1 1 1 1
A.K.
- Original Message -
From: capricy gao
To: "r-help@r-project.org"
Cc:
Sent: Frida
Wrap a print or cat function around it.
Sent from my iPhone
On Sep 13, 2013, at 6:29 PM, capricy gao wrote:
>
>
> I am just testing the possibility of using grep under for loop:
>
>> for(i in 1:10){grep("a",letters)}
>
>
> nothing came out;
>
> when I ran:
>
>
>> grep("a",letters),
>
Dear R community,
Please let me know if there is an R data set with time to multiple outcomes
(unordered failure events of different types).
I am specifically looking for non-competing risks so that I can have observed
times for both outcomes. Twin data or recurrent data will not work for me
b
Hello R-help,
I have recently generated some meta-data on SNP variation across whole
exomes and I need to begin sorting it into two camps: one in which the
alternate allele matches the derived form and one where the alternate
allele matches the ancestral form. I have the data saved as a .txt file
I'm trying to write an Automator script for people who don't want to run
scripts from the R console.
The workflow would ideally look like this:
- Ask user to enter different parameters (I was able to do this part)
- Run an R script using the paramters
I guess I need to run R via a shell script,
I am just testing the possibility of using grep under for loop:
>for(i in 1:10){grep("a",letters)}
nothing came out;
when I ran:
>grep("a",letters),
I got "1"
so in my for loop, I expected to see ten "1"s, but I did not.
Could anybody help me to figure out why? Thanks a lot for your h
?par documents this behavior. I think if you just initially large cex by
the appropriate amount, that might compensate for it, but I haven't tested
this (I use lattice and grid graphics). Otherwise, as suggested in ?par,
consider ?layout.
Cheers,
Bert
On Fri, Sep 13, 2013 at 9:51 AM, Jannis wro
The problem is solved with call to `do.call`:
|wrapperfX<- function(x){
dots<-if(missing(x)){
list()
}else{
list(x=x)
}
do.call(targetf,dots)
}|
It is a little awkward (such elementary operation should be one liner
IMHO), it might be slow, but it works.
I guess `match.cal
The newdata argument to predict should be a data.frame (or environment or list)
containing the variables that are on the right side of the formula (the
predictors).
In your case that means it should have a variable called 'Concentration'.
Since it didn't have such a variable (it contained only 'Re
On Sep 13, 2013, at 9:33 AM, E Joffe wrote:
Thank you so much for your answer !
As far as I understand, glmnet doesn't accept categorical variables
only
binary factors - so I had to create dummy variables for all
categorical
variables.
I was rather puzzled by your question. The conventi
Dear forum members,
Please help me understanding significance value when GLM done in r.
After doing minimal adequate model, I have found a number of independent
values which are significant. But doing their anova significant values are
different. Please find my result following. Which significan
On Sep 13, 2013, at 9:38 AM, Lutfor Rahman wrote:
Dear forum members,
Please help me understanding significance value when GLM done in r.
After doing minimal adequate model, I have found a number of
independent
values which are significant. But doing their anova significant
values are
di
I have a dataframe with 2 million rows and approximately 200 columns /
features. Approximately 30-40% of the entries are blank. I am trying to
find important features for a binary response variable. The predictors may
be categorical or continuous.
I started with applying logistic regression, but h
Hi list,
Sorry, this is not a question directly for R, rather for R code editor. I'm
posting it here to capture wider audience.
The problem I'm facing is that as sometimes my .rnw file gets bigger and
bigger, navigating through it becomes an issue. Scrolling back-n-forth or
remembering the
Dear R users,
if I use par(mfrow=c(3,3)), R automatically changes the value of cex and
even setting cex=1 in the same par() call does not seem to prevent this.
Even though such behavior may be helpful an many cases, I am wondering
whether there is a easy way to switch this off (short of setti
On Fri, 13 Sep 2013, William Dunlap wrote:
You may want to append -Inf (or 0 if you know the data cannot be
negative) to the start of your 'values' vector so you don't
have to write code to catch the cases when a threshold is below
the range of the values.
> findInterval(thresholds, c(0,valu
I am sorry,
I have a problem. When I use the "predict" function I am always obtaining the
same result and I don't know why. In adittion, the intercept and the residual
values I get are wrong too.
std:
[1] 0.068 0.117 0.167 0.269 0.470 0.722
Concentration:
[1] 3.90625 7.81250
You may want to append -Inf (or 0 if you know the data cannot be
negative) to the start of your 'values' vector so you don't
have to write code to catch the cases when a threshold is below
the range of the values.
> findInterval(thresholds, c(0,values,Inf))
[1] 1 5 5 5 8
> c(0, values, Inf
Thanks a lot!!, So nice to get such a fast reply and not having to break my
head with it for a few more hours.
much appreciated.
Guy
--
View this message in context:
http://r.789695.n4.nabble.com/help-with-a-simple-function-tp4676026p4676051.html
Sent from the R help mailing list archive at N
On Fri, 13 Sep 2013, William Dunlap wrote:
findInterval(thresholds, values)
[1] 1 4 4 4 7
Thanks a lot! But now I have a new problem, a typical R issue perhaps.
First, let's look at a successful case:
> thresholds <- c(1,3,5,7,9)
> values <- c(0.854, 1.648, 1.829, 1.874,
In the last week, SOMETHING on my system must have changed because
when trying to library() or install.packages() on R 3.0.1 x64 on a
Windows 2008 R2 server:
> library("raster")
Error in normalizePath(path.expand(path), winslash, mustWork) :
path[1]="D:/Users/[UID]/Documents/R/win-library/3.0":
Hi Bill,
Great soluiton!
Just to add:
if values are not sorted (in this case, okay)
set.seed(434)
val1<- rnorm(1e5)
set.seed(28)
thresh1<- sample(1:20,1e2,replace=TRUE)
system.time(res11<- findInterval(thresh1,val1))
#Error in findInterval(thresh1, val1) :
# 'vec' must be sorted non-de
> findInterval(thresholds, values)
[1] 1 4 4 4 7
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Zhang Weiwu
> Sent: Friday, September 13, 2013 3:14 AM
> To: r-help@r-
On Sep 13, 2013, at 9:33 AM, E Joffe wrote:
Thank you so much for your answer !
As far as I understand, glmnet doesn't accept categorical variables
only
binary factors - so I had to create dummy variables for all
categorical
variables.
It worked perfectly.
It's not exactly clear what wo
Hi,
Some speed comparison
set.seed(434)
val1<- rnorm(1e5)
set.seed(28)
thresh1<- sample(1:20,1e2,replace=TRUE)
system.time(res<- rowSums(t(replicate(length(thresh1),val1))<= thresh1))
# user system elapsed
# 0.320 0.064 0.382
system.time(res2<- sapply(thresh1,function(x) {sum(val1
T
Thank you so much for your answer !
As far as I understand, glmnet doesn't accept categorical variables only
binary factors - so I had to create dummy variables for all categorical
variables.
It worked perfectly.
Erel
Erel Joffe MD MSc
School of Biomedical Informatics
University of Texas - Heal
Hi,
You could try:
val1<- c(0.854400, 1.648465, 1.829830, 1.874704, 7.670915, 7.673585, 7.722619)
thresh1<- c(1,3,5,7,9)
rowSums(t(replicate(length(thresh1),val1))<= thresh1)
#[1] 1 4 4 4 7
#using ?sapply() could be shortened
sapply(thresh1,function(x) {sum(val1
To: r-help@r-project.org
Cc:
Sent:
On Sep 13, 2013, at 4:15 AM, E Joffe wrote:
Hello,
I have a problem with creating an identity matrix for glmnet by
using the
contrasts function.
Why do you want to do this?
I have a factor with 4 levels.
When I create dummy variables I think there should be n-1 variables
(in this
Hello, Adam,
I'm rather uncertain about your goal (and consequently even more so about
how to reach it), but anyway, maybe the function match.call() with its
argument expand.dots is of some help for you. From its help page:
"match.call is most commonly used in two circumstances:
To recor
Thanks a lot, Laszlo!
On Fri, Sep 13, 2013 at 6:56 AM, Zsurzsa Laszlo wrote:
> Maybe this link can help you:
>
> http://rstudio.github.io/shiny/tutorial/#more-widgets
>
> This is an example with submit button.
>
>
>
Maybe this link can help you:
http://rstudio.github.io/shiny/tutorial/#more-widgets
This is an example with submit button.
-
- László-András Zsurzsa,-
- Msc. Infrom
On Fri, 13 Sep 2013, Endy BlackEndy wrote:
Hi to every body. I would like assistance on how to implement the
log-log link function for binary response. Is there any package that
implements it?
One way is to use the cloglog link and just flip the response categories.
To use the log-log link d
Hi to every body. I would like assistance on how to implement the log-log
link function for binary response. Is there any package that implements it?
Many thanks
Endy
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
http
input:
> values
[1] 0.854400 1.648465 1.829830 1.874704 7.670915 7.673585 7.722619
> thresholds
[1] 1 3 5 7 9
expected output:
[1] 1 4 4 4 7
That is, need a vector of indexes of the maximum value below the threshold.
e.g.
First element is "1", becaus
(This is crosspost from
[1]http://stackoverflow.com/questions/18670895/how-to-write-a-wrapper-functi
on-which-can-honour-default-values-when-the-target, posted week ago, where
although the question did receive some attention, nobody was able to help
me.)
I'd like to write a more-
Hello,
I have a problem with creating an identity matrix for glmnet by using the
contrasts function.
I have a factor with 4 levels.
When I create dummy variables I think there should be n-1 variables (in this
case 3) - so that the contrasts would be against the baseline level.
This is al
hi, I am new to are, very new and want to ask what's wrong with this
function: It is suppose to read a table and return its matrix transposed
with NA replaced by the average of each column and a row of means at the
bottom row. The separated parts are returned correctly. Thanks a lot for any
help.
Looking back at my OP, I don't really see where the confusion is, I guess
you guys deal in code and not words, I'll have to remember that.
I thought it was an easy enough question that someone could bang out an
answer in a couple minutes. These are literally the first for() loops I've
ever made,
46 matches
Mail list logo