similar to: help with if statement

Displaying 20 results from an estimated 12000 matches similar to: "help with if statement"

2012 Jun 20
3
data normalization
I have a dataframe such like the following: ID TIME DV 1 0 0.880146038 1 1 0.88669051 1 3 0.610784702 1 5 0.756046666 2 0 0.456263368 2 1 0.369991537 2 3 0.508798346 2 5 0.441037014 3 0 0.854905349 3 1 0.960457553 3 3 0.609434409 3 5 0.655006334 . . . . . . I would like to generate another column with the normalized values of DV. for each ID, normalize to the value at TIME 0. I was able to
2012 Jul 16
2
extract number from a mixture of character and number
Hi, all, I have a column like the following: ID TIME sub_001 0 sub_001 24 sub_002 0 sub_002 24 sub_003 0 sub_003 24 sub_004 0 sub_005 24 .. .. is there a way for me to just
2012 Jun 20
2
can not read a table
I have a table like the following: TABLE NO. 1 ID TIME 1325 0 1325 0 . . . . . . TABLE NO. 1 ID TIME 1325 0 1325 0 . . . . . . TABLE NO. 1 ID TIME 1325 0 1325 0 . . . . . . TABLE NO. 1 ID TIME 1325 0 1325 0 . . . . . . I used the following code: sim <- read.table("sim.tab", skip=1, as.is=T,header=T) it did not work, as there're rows with characters in between the data.
2009 Oct 28
4
Insertar filas en un data frame
Hola, Por favor, necesito insertar una fila debajo de las filas que tengan DV distinto de cero, pero no me deja insertar hasta el final de la tabla. Esta es mi tabla y este es el código con el que estoy apurado. C ID TIME DV AMT RATE CMT SS II EVID GRUPO VISITA DOSIS VECES FORMA NAP EDAD SEXO ALTURA PESO 11 0 0 3 0 1 1 12 1 3 0 3 2 1 0 77 2 147 74 11 1.417 0.001 0 0 2 0 0 0 3 0 3 2 1 0.001
2008 Jun 22
1
two newbie questions
# I've tried to make this easy to paste into R, though it's probably so simple you won't need to. # I have some data (there are many more variables, but this is a reasonable approximation of it) # here's a fabricated data frame that is similar in form to mine: my.df <- data.frame(replicate(10, round(rnorm(100, mean=3.5, sd=1)))) var.list <- c("dv1",
2007 Jul 13
2
Suggestion to extend aggregate() to return multiple and/or named values
Hi all, This is my first post to the developers list. As I understand it, aggregate() currently repeats a function across cells in a dataframe but is only able to handle functions with single value returns. Aggregate() also lacks the ability to retain the names given to the returned value. I've created an agg() function (pasted below) that is apparently backwards compatible (i.e.
2013 Feb 13
1
An extended Hodgkin-Huxley model that doesn't want to work.
Hi All I have been struggling with this model for some time now and I just can't get it to work correctly. The messages I get when running the code is: DLSODA- Warning..Internal T (=R1) and H (=R2) are such that in the machine, T + H = T on the next step (H = step size). Solver will continue anyway. In above message, R = [1] 0 0 DINTDY- T (=R1) illegal In above message, R = [1]
2005 Jun 22
2
Trouble with ifelse and if statement (PR#7962)
Full_Name: Woolton Lee Version: 2.1 OS: windows Submission from: (NULL) (128.118.224.46) I did the following ('g' and 'h' are both numeric vectors) > i <- abs(g-h) creating a vector 'i' with values, > i [1] 0.08 0.00 0.33 0.00 0.00 0.00 0.00 0.33 0.00 0.00 0.08 0.08 0.20 0.00 0.13 Now, I want to create a new vector =1 whenever 'i' = 0.33 and =0
2008 Jul 28
2
Help with a loop
HI: I need ideas on how to make this code shorter (maybe with a second loop?). The code as it is works, but in this case I only have 14 samples, but it will become insane with more, so I need a way to make it more automatic. The problem is that the output from ts1, ts2, and so on is a vector with more than one value, so I do not know how to solve this. Thanks Prenewbie The code is the
2010 Jul 07
1
ifelse statement
Hi, I am a newbie of R, and playing with the "ifelse" statement. I have the following codes: ## first, for(i in 1:3) { for(j in 2:4) { cor.temp <- cor(iris.allnum[,i], iris.allnum[,j]) if(i==1 & j==2) corr.iris <- cor.temp else corr.iris <- c(corr.iris, cor.temp) } } this code is working fine. I also tried to perform the same thing in another way with "ifelse":
2010 Jan 14
5
Better way than an ifelse statement?
Hello All, I am trying to create a column of weights based off of factor levels from another column. I am using the weights to calculate L scores. Here is an example where the first column are scores, the second is my "factor" and the third I want to be a column of weights. I can do what I want with an ifelse statement (see below), but I am wondering if anyone knows of a cleaner way
2012 Mar 17
3
rtriang using ifelse statement
Hi All, I want to draw samples (n=4) from one of 2 triangular distributions for each value in a matrix. I am using an ifelse statement to try to define which distribution to draw from. >From the output, I can see that the ifelse statement is choosing the correct distribution, however, my n=4 simulations aren't occurring. Is there a way to adjust the ifelse statement to fix this, or must
2011 Jul 11
1
Ifelse statement
Hello everyone, I have a (small) issue. I already googled a lot, so I decided to use ifelse instead of if (){} else{} All the elements seem to work seperately, but combined in the ifelse statement, it doesn't seem to work. #The price function is a function which is normally distributed with only positive answers price<-function() {abs(rnorm(1,10,25))} #Before I use pieceprice in the
2011 Mar 10
1
How to use conditional statement
Dear R helpers Suppose val1 = c(10, 20, 35, 80, 12) val2 = c(3, 8, 11, 7) I want to select either val1 or val2 depending on value of third quantity val3. val3 assumes either of the values "Monthly" or "Yearly". If val3 = "Monthly", then val = val1 and if val3 = "Yearly", then val = val2. I tried the ifelse statement as ifelse(val3 =
2010 Jul 21
1
xtable with ifelse statement
Hi there, I'm very new on R and I hope someone can help me to solve the problem in using the ifelse statement with the xtable function(library xtable). I'm trying to get the printing of the elements of two lists in a sorted way. These two list have in common the their names. I will try to give an example: the first list looks like this: $code1 Code code1 Nation
2005 Dec 13
2
creating a subset of a dataset using ifelse statement?
I am using R in a Microsoft Windows environment. I have a dataset called “mp1b”. I have a variable called h. h can take a value from -1 to 5. If h <1, I want to create a new dataset called mp2 that is the same as mp1b: “mp2<-mp1b” If h > 0, I want to set create a dataset mp2, where I limit the original dataset to those where mp1b$group = =h. similar to:
2009 Jun 23
2
Problem with ifelse statement
Hi R-helpers, I am trying to use this ifelse statement to recode a variable: > data$SOCIAL_STATUS<-ifelse(data$SOCIAL_STATUS=="B" & data$MALE>4, "C", "B") (i.e., if social status is B and there are more than 4 males, then recode social status to C; otherwise, leave it B) But, it's not working. See the below R output. Notice that there were 71
2007 Jan 19
3
if else statement
Hello, I'm doing some scripting and I've noticed that R doesn't seem to have an if (cond){ do }ifelse (cond) { do } else { do } type block. Is this correct or am I missing something. THX Paul -- Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute
2006 Mar 27
1
Differential Equations
Dear R-community My ODE problems looks as follows: (1) dA/dt = u*A - v*B (2) dB/dt = v*B - u*A where u is a constant, and v=k*t (k=constant, t=time) Does anybody knows a good function/procedure of solving? Should one involve the equation (3) dv/dt = k? Thanks for your support. -- Dominik Heinzmann Master of Science in Mathematics, EPFL Ph.D. student in Biostatistics Institute of Mathematics
2011 Sep 16
3
Problematic If-Else statement
Hi guys, My code (next 2 lines below) isn't doing what I'm expecting it to: tmp <- ifelse(uncurated$days_to_tumor_recurrence=="null","norecurrence","recurrence") curated$recurrence_status <- tmp I want the column "recurrence_status" in my output file to have values "recurrence" (if the input value had a number in the