Displaying 20 results from an estimated 30000 matches similar to: "convert data frame values"
2008 Apr 22
4
how to convert non numeric data into numeric?
I am having the following error in my function
function(theta,reqdIRR)
{
theta1<-theta[1]
theta2<-theta[2]
n<-length(reqdIRR)
constant<- n*(theta1+theta2)
sum1<-lapply(reqdIRR*exp(theta1),FUN = sum)
sum2<-lapply(exp(theta2 - reqdIRR*exp(theta1)),FUN = sum)
sum = sum1 + sum2
log.fcn = constant - as.numeric(sum)
result = - log.fcn
return(result)
}
*error :
2008 Apr 13
3
Matched pairs with two data frames
Hi,
I have a frame "treat" and want to find matched pairs in the data frame
"control". In the matched (combined) data frame there should be two
variables (0/1),indicating the "source" of the data (treat or control),
so that it is possibe to set a "filter" (extraxt/select data).
#Here are the dataframes (my real data frames have many variables)
treat <-
2008 Feb 14
1
deleting certain observations in a data frame
Hi, I'm wondering what the fastest way is to delete certain data points (observations) in a data frame.
I have a vector of the indices/row.names I would like to delete. I have tried replacing list by list, but it always complains about different lengths, "replacing list of length a with length b" and so on.
Another way to think of it is that it's a generazation of na.rm I
2003 Oct 09
1
Scoping rules
Dear List members:
I'm using R1.7.1 (Windows 2000) and having difficulty with scoping.
I've studied the FAQ and on-line manuals and think I have identified
the
source of my difficulty, but cannot work out the solution.
For the purposes of illustration. I have three functions as defined
below:
fnA <- function(my.x)
{
list(first=as.character(substitute(my.x)), second=sqrt(my.x))
}
2004 Oct 28
3
ifelse() question
Hi
I have a data.frame with dim = 18638 (rows) 6 (cols)
names(dat)
[1] "id" "long" "lat" "species" "type" "size"
Variable "species" and "type" are factors. Species has 5 levels "BOV" "CAP"
"CER" "OVI" "POR"
Variable "type" has 11 levels
2008 Jan 30
2
data.frame transformation
Dear all,
maybe somebody can provide some help for this problem:
Example:
I've got the following dataframe "data":
grid.id<-c(1:4)
lat<-c(10,12,13,15)
species1<-c(0,0,0,1)
species2<-c(1,1,0,0)
species3<-c(1,1,1,1)
data<-data.frame(cbind(grid.id,lat,species1,species2,species3))
How can I, out of "data" make a new dataframe, where the cells of value
2008 Mar 28
3
Converting a data frame to matrix
Hello:
I have a tab delim file with 100 rows and 100 columns.
I have numerical values in this table. What I want is to create an image
color map with color gradation.
my values range from -5 to 0. max value is 0.
to acheive this, I need to convert my data.frame into matrix.
I tried following :
mydf <- read.table('mytable',sep='\t',header=T)
mydf1 <- mydf[,2:100]
2013 Apr 03
2
Creating data frame from individual files
Dear Group:
I have 72 files (.txt).
Each file has 2 columns and column 1 is always identical for all 70 files.
Each file has 90,799 rows and is standard across all files.
I want to create a matrix 40(rows) x 70 columns.
I tried :
temp = list.files(pattern="*.txt")
named.list <- lapply(temp, read.delim)
library(data.table)
files.matrix <-rbindlist(named.list)
>
2008 Sep 12
2
Creating data frame from existing data frame
I'm new to R, using it for an engineering stats class, and the first project
is focused on creating data frames and plotting graphs. So far I have
imported a set of data from a text file and saved it as a variable (using
the read.table() function). One of the columns of the data consists of
years, and I'm supposed to create a data frame that only consists the the
date from one given year
2008 Apr 23
2
Replecing empty values with a letter (continuation)
Sorry, I hit the send botton by accident. Here is my
code so far:
dat<-read.csv('myfile.csv', na.strings="")
dat[is.na(dat]<-'N'
But it doesn't replace the <NA> for the letter 'N'.
I am using R v 2/7/0, running it under Windows
XP.
Thank you,
Judith
2004 Dec 01
2
unbalanced design
Hi all,
I'm new to R and have the following problem:
I have a 2 factor design (a has 2 levels, b has 3 levels). I have an
object kidney.aov which is an aov(y ~ a*b), and when I ask for
model.tables(kidney.avo, se=T) I get the following message along with
the table of effects:
Design is unbalanced - use se.contrast() for se's
but the design is NOT unbalanced... each fator level
2008 Mar 11
2
Adding x-axis values to a histogram
Dear useRs,
Is there a way one can add x-axis values to a histogram? Example:
z = rgamma(n=1000, shape = 8, scale = 1000)
hist(z, breaks = 30)
Currently I see 4 x-axis values: 5000, 10000, 15000, 20000. Can I add more
values or modify the ones currently showing? I tried ?hist, yet couldn't
work this out.
Thank you very much.
-----
~~~~~~~~~~~~~~~~~~~~~~~~~~
Diego Mazzeo
Actuarial Science
2008 May 21
2
Converting Data Types
Hi,
How can I convert the matrices to list.
For example I have this snippet:
samples<-mymatrix[1,]
print(samples)
which prints:
V1 V2 V3 V4 V5 V6
1 103.9 88.5 242.9 206.6 175.7 164.4
How can I convert the object "samples" such that it prints:
[1] 103.9 88.5 242.9 206.6 175.7 164.4
The reason I ask this because I can't use the former
"samples"
2008 Oct 08
3
Re move repeated values
Dear R users,
I'd like to make this data
rem.y = c(-1,0,2,4,5)
from
y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5).
That is, I need to remove repeated values.
Here is my code, but I don't think it is efficient. How could I improve
this?
#------------------------------------------------------------------------
y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5)
n=length(y)
for (i in 1:n) #
2009 Mar 31
2
convert table to list
Hi there,
This is probably a rather simple question - but I was not able to solve it
so far.
I would like to convert the following table:
A B C D
x 10 20 30 40
y 11 21 31 41
z 12 32 42
to a list with three columns like:
A x 10
A y 11
A z 12
B x 20
.
.
.
Any hints how do do this in R would be very much apprechiated.
cheers,
Herwig
--
View this message in context:
2008 Sep 07
3
how to draw a vertical line from points to x-axis
Hello,
I want to know how to draw a line connecting each point to the x-axis
perpendicularly (i.e. a vertical line).
abline(v=...) seems not to work for my purpose, because it runs over the
data point. Can anyone help? Thanks.
Anny
[[alternative HTML version deleted]]
2008 May 06
1
Dendrogram label size
Is it possible to resize the labels in a dendrogram without applying
circles and triangles to edges?
I tried cex.labels:
plot(scoreDendogramObj, horiz=TRUE, axes=FALSE, cex.labels=0.8)
but that didn't have any effect.
Thanks,
Alex
2006 Aug 16
1
confusing about contrasts concept
Hi all,
Where can I find a thorough explanation of Contrasts and Contrasts Matrices?
I read some help but still confused.
Thank you,
Tian
[[alternative HTML version deleted]]
2007 Oct 24
2
adding total row/column to table-command
Dear R,
I am often adding a total rows or column (sum over all rows or columns)
when using table(data$1,data$2)... I do this now by adding the rows/columns
and rbind() or cbind()... But there must be a more efficient way.... Could
someone please give me a hint?
Thank you!
With my best regards, Georg.
*******************
Georg Ehret
Johns Hopkins
Baltimore
[[alternative HTML version deleted]]
2008 Feb 20
1
Deleting multiple rows based on a variable
Hello,
I have a dataset which consists of 9 columns (variables) and 35 rows
(observations). I am doing a simple linear regression of one variable
on the other. There are some observations that are outliers and I would
like to remove them based on another variable (it's a unique, numeric
variable). How do you tell R to remove multiple rows (observations)
based on a variable value?