Displaying 20 results from an estimated 3000 matches similar to: "replacing NA for zero"
2007 Apr 25
1
help
Hi all,
I have 2 questions:
1)How do I calculate the mean on an imported txt file? I've imported the 
file below and that's what it looks like imported. How do I then calcuate 
the mean, median, or mode on the column LeafArea using the desktop R 
package?
Any help would be greatly appreciated!!
Thanks,
Nat
   LeafType Leaflets LeafArea ShapeRatio LeafWeight LeafThickness
1         1 
2008 Jan 10
2
`[.data.frame`(df3, , -2) and NA columns
Dear baseRs,
I recently made a mistake when renaming data frame columns, accidentally
creating an NA column. I found the following strange behavior when negative
indexes are used.
Can anyone explain what happens here.  No "workarounds" required, just  curious.
Dieter
Version: Windows, R version 2.6.1 (2007-11-26)
#-----------------------------
df = data.frame(a=0:10,b=10:20)
df[,-2]
2009 Jan 21
3
merging several dataframes from a list
Hi there,
I have a list of dataframes (generated by reading multiple files) and all 
dataframes are comparable in dimension and column names. They also have a 
common column, which, I'd like to use for merging. To give a simple example of 
what I have:
df1 <- data.frame(c(LETTERS[1:5]), c(2,6,3,1,9))
names(df1) <- c("pos", "data")
df3 <- df2 <- df1
df2$data
2011 Aug 18
2
Best way/practice to create a new data frame from two given ones with last column computed from the two data frames?
Dear expeRts,
What is the best approach to create a third data frame from two given ones, when
the new/third data frame has last column computed from the last columns of the two given
data frames?
## Okay, sounds complicated, so here is an example. Assume we have the two data frames:
df1 <- data.frame(Year=rep(2001:2010, each=2), Group=c("Group 1","Group 2"), Value=1:20)
2009 Oct 05
1
How to get NA's into the output of xtabs?
Dear all,
Lets say I have the following data frame:
> df1 <- data.frame(Show=c('Star Trek', 'Babylon 5', 'Dr Who'), Size=c(0.7, 0.0, 0.701),  Date=as.Date(c('2007-08-03', '2007-08-03', '2007-08-03'), format='%Y-%m-%d'))
> df2 <- data.frame(Show=c('Star Trek', 'Dr Who', 'Torchwood'), Size=c(0.8, 0.85,
2012 Sep 28
2
Converting array to matrix
Hi,
I have a 3d array as below, I want to make this array to a matrix of p=50(rows) and n=20(columns) with the coverage values .
The code before the array is:
library(binom)
Loading required package: lattice
pi.seq<-seq(from = 0.01, to = 0.5, by = 0.01)
no.seq<-seq(from = 5, to = 100, by = 5)
cp.all = binom.coverage( p = pi.seq, n = no.seq , conf.level = 0.95, method = "exact")
2008 Feb 19
2
Looping through a list of objects & do something...
Hey Folks,
Could somebody show me how to loop through a list of dataframes?  I want to
be able to generically access their elements and do something with them.
For instance, instead of this:
df1<- data.frame(x=(1:5),y=(1:5));
df2<- data.frame(x=(1:5),y=(1:5));
df3<- data.frame(x=(1:5),y=(1:5));
plot(df1$x,df1$y);
plot(df2$x,df2$y);
plot(df3$x,df3$y);
I would like to do something like:
2008 Jan 24
2
boxplot axis labelling
Hi,
   i'm very new to R, so sorry for what i'm sure is a very basic question. I'm
   producing a boxplot with the data below:
   df3<-data.frame(
   x=c(10,11,115,12,13,14,16,17,18,21,22,23,24,26,27,28,29,3,30,32,33,34,35,4,4
   1,45,5,50,52,56,58,6,67,6738,68,7,8,9),
   fq=c(8,11,1,2,4,4,2,2,6,3,4,2,2,1,1,1,4,51,3,1,1,1,1,35,1,1,19,2,1,1,1,14,1,
   1,1,10,13,5),
  
2010 May 11
2
Regex and gsub
Dear group,
Here is my df :
df3 <-
structure(list(DESCRIPTION = c("COPPER May/10", "COTTON NO.2 Jul/10", 
"CRUDE OIL miNY May/10", "GOLD Jun/10", "ROBUSTA COFFEE (10) Jul/10", 
"SOYBEANS Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 May/10", 
"WHEAT Jul/10", "SPCL HIGH GRADE ZINC USD",
2008 Jul 26
1
Can't get the correct order from melt.data.frame of reshape library.
Simple illustration, 
 
> df3 <- data.frame(id=c(3,2,1,4), age=c(40,50,60,50), dose1=c(1,2,1,2), dose2=c(2,1,2,1), dose4=c(3,3,3,3))> df3  id age dose1 dose2 dose41  3  40     1     2     32  2  50     2     1     33  1  60     1     2     34  4  50     2     1     3> melt.data.frame(df3, id.var=1:2, na.rm=T)   id age variable value1   3  40    dose1     12   2  50    dose1     23   1 
2009 Feb 19
3
Multiple merge, better solution?
Hello,
My problem is that I would like to merge multiple files with a common
column but merge accepts only two
data.frames to merge. In the real situation, I have 26 different
data.frames with a common column. I can of course use merge many times
(see below) but what would be more sophisticated solution? For loop?
Any ideas?
DF1 <- data.frame(var1 = letters[1:5], a = rnorm(5))
DF2 <-
2009 Oct 07
1
merging dataframes with an unequal number of variables
Hallo Everyone
I have the kind of problem that one should never have because one must
always plan well and communicate with your team. But now I haven't so here
is my problem.
I have data coming in on a daily basis from surveys in 10 towns. The
questionnaire has 62 variables but some of the regions have used older
versions of the questionnaire that have a few variables less. I want to
combine
2012 Jan 02
2
Conditionally adding a constant
I am trying to add a constant to the previous value of a variable based on
certain conditions. Maybe there is a simple way to do this that I am missing
completely. I have given an example below:
df <- data.frame(x = c(1,2,3,4,5), y = c(10,20,30,NA,NA))
> df
  x  y
1 1 10
2 2 20
3 3 30
4 4 NA
5 5 NA
I want to add 2 to the previous value of y, if x exceeds 3 (also will have
to handle NAs in
2004 Mar 15
1
gzfile & read.table on Win32
Hello ...
Are there any known problems or even gotchas to look out for when using a
gzfile connection in read.csv/read.table in Windows?
In the package PROcess, available at
www.bioconductor.org/repository/devel/package/html/PROcess.html
there are two files in the PROcess/inst/Test directory which are of the
extension *.csv.gz.
With both files, if I open up a gzfile connection, say:
vv <-
2011 Dec 07
2
Dividing rows when time is overlapping
Hi all,
I have dataframe that was created from the fusion of two dataframes. Both
spanned over the same time intervall but contained different information.
When I put them together, the info overlapped since there is no holes in the
time interval of one of the dataframe. Here is an example where the rows
"sp=A and B" are part of a first df and the rows "sp=C" come from a
2004 Mar 09
5
Adding data.frames together
I have a series of data frames that are identical structurally, i.e. -
made with the same code, but I need to add them together so that they
become one, longer, data frame, i.e. - each of the slot vectors are
increased in length by the length of the added data frame vectors.
So if I have df1 with a slot A so that length(df1$A) = 100 and I have
df2 with a slot A so that length(df2$A)=200 then I
2010 Sep 15
1
Format Data Issue??
R Users,
I am new to R and have tried to figure out how to automate this
process instead of using excel.  I have read in this dataframe into r
with read.table.  I need to reshape the data from the first table into
the format of the second table.
TractID	StandID	Species	CruiseDate	DBHClass	TreesPerAcre
Carbon	Stand 1	Loblolly Pine	       5/20/2010	10    	1.2
Carbon	Stand 1	Loblolly Pine	      
2012 Jul 18
2
duplicate data between two data frames according to row names
Hi everybody.
I'll first explain my problem and what I'm trying to do. 
Admit this example:
I'm working on 5 different weather stations.
I have first in one file 3 of these 5 weather stations, containing their
data. Here's an example of this file:
DF1 <- data.frame(station=c("ST001","ST004","ST005"),data=c(5,2,8))
And my two other stations in
2011 Jun 06
1
Merge two columns of a data frame
I have the following data:
prefix <- c("cheap", "budget")
roots <- c("car insurance", "auto insurance")
suffix <- c("quote", "quotes")
prefix2 <- c("cheap", "budget")
roots2 <- c("car insurance", "auto insurance")
roots3 <- c("car insurance", "auto
2003 Sep 04
1
error in lm.fit
Hello R user, 
I have several data frames with >100 columns and I did a linear regression 
over time of each column
df1.lm <- lapply(df1, function(x) lm(x~year)$coeff[2])
that worked fine and I get slope of each column oder time - until I divided 
df1 by df2 
df3 <- df1/df2
> df3.lm <- lapply(df3, function(x) lm(x~year)$coeff[2])
Error in lm.fit(x, y, offset = offset, ...) :