similar to: conditional Dataframe filling

Displaying 20 results from an estimated 5000 matches similar to: "conditional Dataframe filling"

2012 Jul 24
5
First value in a row
Hi. This is likely a trivial problem but have not found a solution. Imagine the following dataframe: Lat Lon x1 x2 x3 01 10 NA NA .1 01 11 NA .2 .3 01 12 .4 .5 .6 I want to generate another column that consist of the first value in each row from columns x1 to x3. That is NewColumn .1 .2 .4 Any input greatly appreciated, Thanks, Camilo Camilo Mora, Ph.D.
2013 Mar 13
3
loop in a data.table
Hi everyone, I have a data.table called "data" with many columns which I want to group by column1 using data.table, given how fast it is. The problem with looping a data.table is that data.table does not like quotations to define the column names (e.g. "col2" instead of col2). I found a way around which is to use get("col2"), which works fine but the
2013 Mar 02
3
replace zeros for NA in a column based on values of another column
Hi everyone, Imagine that I have a data frame with four columns: data<- a b c d 0 1 1 0 1 1 1 1 1 0 0 1 I want to replace the zeros in columns a:b for NA only for the rows in which column d are zero. So a b c d NA 1 1 0 1 1 1 1 1 0 0 1 I am trying
2012 Sep 02
1
why variations in accuracy between R to ARCGIS for the same point reprojection?
Hi everyone, I wonder if anyone knows the reason why the outputs of the same reprojection in r and arcgis are different?. The magnitude of the change can be up to 40 km in the poles. Basically, I have a database of points equally separated by one degree over the globe. In ARCGIS, I am projecting the data in GCS-WGS-1984 and then reprojected it to Berhmann to ensure equal area
2013 Mar 23
1
Error with custom function in apply: ”Error in FUN(newX[, i], ...) : unused argument(s) (newX[, i])”
Hi everyone, I wonder if I can get your help using a custom function in apply. Imagine the following dataframe called "data": LowLim HighLim A1 A2 A3 A4 4 6 3 4 5 6 4 6 4 5 5 6 2 3 1 4 2 3 2 3 NA NA NA NA We have created a custom function (see below) that takes the values in a given row between columns A1 to A4 to see if they are outside the limits in the same
2013 May 11
3
boxplot with grouped variables
my dataset looked like this in the beginning: >Daten V1 V2 V3 1 Dosis Gewicht Geschlecht 2 0 6.62 m 3 0 6.65 m 4 0 5.78 m 5 0 5.63 m I need box plots for V2 with all combination of V1 and V3, so I deleted the first row, and tried this: boxplot(Daten$V2[Daten$V3=="m"]) but it does not work and I
2013 Mar 19
4
Copying rows in data frames
Hi, I'm trying to copy the first row of one data frame to another. This is the statement I am using : df2[1,]<-df1[1,]; I have printed them out separately: df1[1,] = A C D E F But after copying: df2[1,] = 96 29 88 122 68 Why isn't it copying? They are both data frames, and "as.character" isn't working either. Thanks for your input :) [[alternative HTML version
2013 Aug 22
1
converting a summary table to survey database form
Hi! I am looking to choose a condom based on its pleasure score. I received some summarised data from 10 individuals: structure(list(Ramses = c(4, 4, 5, 5, 6, 3, 4, 4, 3, 4), Sheiks = c(5, 5, 6, 4, 7, 6, 4, 5, 6, 3), Trojans = c(7, 8, 7, 9, 6, 3, 2, 2, 2, 3), Unnamed = c(2, 1, 1, 3, 3, 4, 5, 4, 4, 3)), .Names = c("Ramses", "Sheiks", "Trojans", "Unnamed"),
2013 May 07
4
how to calculate the mean in a period of time?
Hi, Your question is still not clear. May be this helps: dat2<- read.table(text=" patient_id????? t???????? scores 1????????????????????? 0??????????????? 1.6 1????????????????????? 1??????????????? 2.6 1????????????????????? 2???????????????? 2.2 1????????????????????? 3???????????????? 1.8 2????????????????????? 0????????????????? 2.3 2?????????????????????? 2???????????????? 2.5
2013 Sep 25
1
Best and worst values for each date
Hi, May be you can try this: obj_name<- load("arun.RData") Pred1<- get(obj_name[1]) Actual1<- get(obj_name[2]) library(reshape2) dat<-cbind(melt(Pred1,id.vars="S1"),value2=melt(Actual1,id.vars="S1")[,3])? # to reshape to long form colnames(dat)[3:4]<- c("Predict","Actual") dat$variable<- as.character(dat$variable) #not that
2012 Oct 26
3
Delete row if two values in a matrix are equal
Hi all and thank you for your time. I would like to delete rows from this matrix I call "var" if the character in Ref_Allele is equal to the character in Var_Allele. I have attached a before and after, to help my poor explanation. If someone could provide me with some code, or some guidance I would really appreciate it. Thank you again. "Before" > var Ref_Pos Ref_Allele
2012 Oct 24
2
Recode function car package erases previous values
Hi all, I am attempting to create a new variable based on values of other variables. The variable is called pharm. It basically takes the numeric code of 1 as yes and 0 to be No from the variable B20_C1 (a question on a survey). However, I would also like to have a level for non-respondents and these are captured in the variable nr.B20C, which is a 1 when there is a non-response on the whole group
2013 Jun 15
2
Plotting two y-axis vs non-numeric x-axis
Hi dear all, the following code is correct. but I want to use non-numeric x-axis, for example if I replace time <- seq(0,72,6) by month <- c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","Pag") Ofcourse I use factor(month) instead of
2010 Aug 14
1
confidence Intervals for predictions in GLS
Hi everyone: Is there a function in R to calculate the confidence intervals for the predictions of a GLS(Generalized Least Square) model? The function "predict" gives confidence intervals for the predictions of other types of models (lm, glm, etc) but not gls. Any input will be much appreciated, Best, Camilo Camilo Mora, Ph.D. Department of Biology Dalhouisie University
2013 May 07
4
create unique ID for each group
Hey All, I have a dataset(dat1) like this: ObsNumber ID Weight 1 0001 12 2 0001 13 3 0001 14 4 0002 16 5 0002 17 And another dataset(dat2) like this: ID Height 0001 3.2 0001 2.6 0001
2013 Apr 12
5
how to change the date into an interval of date?
Hi, I am not sure I understand your question correctly. dat1<- read.table(text=" id??????????? responsed_at???????????????? number_of_connection????????????????? scores 1????????????????? 12-01-2010?????????????????????????????????? 1????????????????????????????????????????????? 2 1????????????????? 15-02-2010??????????????????????????????????
2008 Mar 25
2
Compare two data sets
I would like to compare two data sets saved as text files (example below) to determine if both sets are identical(or if dat2 is missing information that is included in dat1) and if they are not identical list what information is different between the two sets(ie output "a1", "a3" as the differing information). The overall purpose would be to remove "a1" and
2012 Jun 07
3
conditional statement to replace values in dataframe with NA
Hello and thanks for helping. #some data L3 <- LETTERS[1:3] dat1 <- data.frame(cbind(x=1, y=rep(1:3,2), fac=sample(L3, 6, replace=TRUE))) #When x==1 and y==1 I want to replace the 1 values with NA #I can select the rows I want: dat2<-subset(dat1,x==1 & y==1) #replace the 1 with NA dat2$x<-rep(NA,nrow(dat2) dat2$y<-rep(NA,nrow(dat2) #select the other rows and rbind
2013 Sep 02
1
R dataframe and looping help
HI, You may try this: dat1<- read.table(text=" CustID TripDate Store Bread Butter Milk Eggs 1 2-Jan-12 a 2 0 2 1 1 6-Jan-12 c 0 3 3 0 1 9-Jan-12 a 3 3 0 0 1 31-Mar-13 a 3 0 0 0 2 31-Aug-12 a 0 3 3 0 2 24-Sep-12 a 3 3 0 0 2 25-Sep-12 b 3 0 0 0 ",sep="",header=TRUE,stringsAsFactors=FALSE) dat2<- dat1[,-c(1:3)] res<- lapply(seq_len(ncol(dat2)),function(i)
2010 Mar 22
1
Replacing elements of list
Dear all, I have following two list object, both are basically collection of matrices : dat1 <- matrix(rnorm(25*6), ncol=6) dat1 <- split(dat1, seq(5,25,by=5)) dat1 <- lapply(dat1, matrix, ncol=6) dat2 <- matrix(rnorm(25*4), ncol=4) dat2 <- split(dat2, seq(5,25,by=5)) dat2 <- lapply(dat2, matrix, ncol=4) Now I want to replace last 4 columns of each matrix at "dat1"