similar to: re-code missing value

Displaying 20 results from an estimated 50000 matches similar to: "re-code missing value"

2008 Jul 20
3
Order of columns(variables) in dataframe
Dear R experts,   I have a dataframe with 4 columns (variables). I want to redorder (or reposition) these columns on the basis of a value in its last row. e.g.   df1<-data.frame( v1= c(2,3,1,9,5), v2=c(8,5,12,4,11), v3=c(7,8,2,6,9), v4=c(1,4,6,3,6))    > df1    v1 v2 v3 v4 1  2  8  7  1 2  3  5  8  4 3  1 12  2  6 4  9  4  6  3 5  5 11  9  6 I wanto to get the order of df1 on the basis of
2013 Mar 12
2
Troubleshooting code
Hi everyone, I am having trouble understanding where I went wrong with my code. It seems to logically be "all there" but the output says otherwise. I know this is a bit long but I can't seem to find the errors so I would appreciate your help :) This is my program : files<-Sys.glob("*.rescount.txt");length<-length(files);* #selecting all files of a particular
2008 Oct 16
3
how to count unique observations by variables
Dear R-helpers, I have a data frame with 3 variables, each record is a unique combination of the three variables. I would like to count the number of unique values of v3 in each v1, and save it as a new variable v4 in the same data frame. e.g. df1 [v1] [v2] [v3] [1,] "a" "C" "1" [2,] "b" "C" "2" [3,] "c" "B"
2012 Sep 26
5
create new column in a DF according to values from another column
Hi everyone, I have a small problem in my R-code. Imagine this DF for example: DF <- data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10)) I would like to add a new column "Station" in this DF. This new column must be automatically filled with: "V1" or "V2" or "V3". The choice must be done on the numbers (1st column). For example, I would like
2013 Feb 03
1
Adding complex new columns to data frame depending on existing column
Hello I have a data frame as below V1 V2 V3 V4 V5 V6 chr1 18884 C CAAAA 2 0 chr1 135419 TATACA T 2 0 chr1 332045 T TTG 0 2 chr1 453838 T TAC 2 0 chr1 567652 T TG 1 0 chr1 602541 TTTA T 2 0 on which I want to perform complex rearrangement such that: if V3 is a string >1 (i.e line 2) then I
2009 Nov 11
1
loop through variable names
Often I perform the same task on a series of variables in a dataframe, by looping through a character vector that holds the names and using paste(), eval(), and parse() inside the loop. For instance: thesevars<-names(environmental) environmental$ToyOutcome<-rnorm(nrow(environmental)) tableOfResults<-data.frame(var=thesevars) tableOfResults$Beta<- NA
2013 Jan 15
1
SQLDF column errors
I am trying to exclude integer values from a small data frame 1, d1 that have matching hits in data frame 2, d2 (Very big) which involves matching those hits first. I am trying to use sqldf on the df's in the following fashion: df1: V1 12675 14753 16222 18765 df2: head(df2) V1 V2 13647 rd1500 14753 rd1580 15987 rd1590 16222 rd2020.....
2010 May 20
2
How to extract rows from data frame based on unique variable groupings
R community, I would like to know how to extract rows from a data frame (DF) such that each row in the new data frame (D.F) represents the first instance of a unique variable pairing in the original dataframe (ordered first by variable V1 then by variable V2). The unique function does not seem to be able to accomplish this. I imagine there must be a simple solution for this, but I can't
2002 Sep 09
1
getting variable names into formulas
Hello, I have a dataframe with several hundred variables. I would like to explore updates of some baseline lme fit by including each of some subset of these variables, one at a time. For various reasons it is inconvenient to rely on the positions of the numbered columns in the dataframe. Here is what I want to do: mod.baseline<-lme(fixed=foo,data=dat,random=bar) for(thisvar in vars){
2008 Sep 14
5
difference of two data frames
Hello I have 2 data frames DF1 and DF2 where DF2 is a subset of DF1: DF1= data.frame(V1=1:6, V2= letters[1:6]) DF2= data.frame(V1=1:3, V2= letters[1:3]) How do I create a new data frame of the difference between DF1 and DF2 newDF=data.frame(V1=4:6, V2= letters[4:6]) In my real data, the rows are not in order as in the example I provided. Thanks much Joseph [[alternative HTML version
2006 Jan 11
3
dataframes with only one variable
Subsetting from a dataframe with only one variable returns a vector, not a dataframe. This seems somewhat inconsistent. Wouldn't it be better if subsetting would respect the structure completely? v1<-1:4 v2<-4:1 df1<-data.frame(v1) df2<-data.frame(v1,v2) sel1<-c(TRUE,TRUE,TRUE,TRUE) > df1[sel1,] [1] 1 2 3 4 > df2[sel1,] v1 v2 1 1 4 2 2 3 3 3 2 4 4 1 -- Erich
2011 Nov 30
1
Replace columns in a data.frame randomly splitted
Dear community, I'm working with the data.frame attached ( http://r.789695.n4.nabble.com/file/n4122926/df1.xls df1.xls ), let's call it df1. I typed: df1<- read.xls("C:/... dir .../df1.xls",colNames= TRUE, rowNames= TRUE) Then I splited randomly df1 using splitdf function (http://gettinggeneticsdone.blogspot.com/2011/03/splitting- dataset-revisited-keeping.html)
2008 Nov 25
2
dataframe
hi there I have a dataframe abc 123 345 abc 345 456 lmn 567 345 hkl 568 535 lmn 096 456 lmn 768 094 i want the uniques of column 1 and there corresponsing column 2 and 3 output abc 123 345 lmn 567 345 hkl 568 535 cbind(DF1[,1],DF1[which(unique(DF1[,1]),c(2,3)]) but didnt work kindly let me know how to go abt it ramya -- View this message in context:
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
2010 Nov 09
5
Question regarding to replace <NA>
Dear r-users, Basically, I have a data as follows, > data S s1 s2 s3 s4 s5 prob obs num.strata 1 NNNNN N N N N N 0.0000108 32 <NA> 2 NNNNY N N N N Y 0.0005292 16 <NA> 3 NNNYN N N N Y N 0.0005292 24 <NA> 4 NNNYY N N N Y Y 0.0259308 8 1 .... I want to replace <NA> by 0, when I tried the following
2010 Mar 11
3
Define column names to a series of data.frames
Greets to the list! I am aware that this topic has been discussed several times. And I've read quite some related posts [1]. Yet, can't seem to give a solution to my problem. I have 6 data frames consisting of 6 rows x 7 columns put together from other data.frames. Something like: a b c d e f g v1 # # # # # # # v2 # # # # # # # v3 # # # # # # # v4 # # # # # # # v5 # # # # # # # v6
2012 Jul 14
3
Can't understand syntax
OK, I need help!! I've been searching, but I don't understand the logic of some this dataframe addressing syntax. What is this type of code called? test [["v3"]] [is.na(test[["v2"]])] <-10 #choose column v3 where column v2 is == 4 and replace with 10 and where is it documented? The code below works for what I want to do (find the non-missing value in a row),
2017 Sep 27
2
disturbed legend in ggplot2
Dear friends - below is a subset of a much larger material showing two ways of generating two "lines". The intention is to have the colour reflect a variable, pH, but the legend is disturbed. The little part marked "3" above the colour scale is unwelcome. Why did it appear? How could I avoid it? I'm on Windows 7, R version 3.4.1 (2017-06-30) -- "Single
2010 Sep 27
1
conditional assignment of colors in xyplot()
# Dear R Community, # I have this data frame: df1 <- data.frame( F1 = factor( c( rep("D1",12),rep("D2",12),rep("D3",12) ) ), F2 = factor( rep( rep( paste("O",1:6,sep=""), rep(2,6) ), 3) ), F3 = factor( rep( c("V1","V2"), 18 ) ), S1 =
2011 Oct 01
2
Help with cast/reshape
I realize that this is terribly basic, but I just don't seem to see it at this moment, so I would very much appreciate your help. How shall I transform this dataframe: > df1 ? Name Index Value 1??? a???? 1?? 0.1 2??? a???? 2?? 0.2 3??? a???? 3?? 0.3 4??? a???? 4?? 0.4 5??? b???? 1?? 2.1 6??? b???? 2?? 2.2 7??? b???? 3?? 2.3 8??? b???? 4?? 2.4 into this dataframe: > df2 ??? Index?