Displaying 20 results from an estimated 5000 matches similar to: "Maintaining factors when copying from one data frame to another"
2005 Jan 06
1
Calculating a table of symbol frequencies
Hello all:
I have a protein sequence alignment in a data frame (align1, 72 x 236),
where each row is a protein and each column a site in the alignment. AA is
vector of amino acid symbols plus "-" (gap). I can calculate amino acid
frequencies at each site by:
>align1.F <- matrix(0,nrow=22,ncol=236,dimnames=list(AA,seq(1:236)))
>for(i in 1:236)
>
2005 Mar 01
1
Two problems building a package
Hello all:
I have written a few R scripts and am trying to turn them into a package for
submission to CRAN. All of these scripts are R code only, no C or C++ or
anything else. I'm working with R 2.0.1 running on a Windows XP machine. So
far running ">rcmd install --build --docs=normal mypkge" seems to work
(i.e., the library "mypkge" is installed in R\rw2001\library and
2005 Jan 03
1
Calculating symbol (letter) frequencies
Hello:
I am attempting to use R to analyze amino acid frequencies in aligned
protein sequences and need some help. So far, I have imported my sequence
alignment into a data frame (lets call it "alignment") with each site in one
column, so that I have a data frame consisting of columns of letters (the 21
amino acid symbols plus "-") with row names being the corresponding
2003 Apr 07
4
subsetting a dataframe
How does one remove a column from a data frame when the name of
the column to remove is stored in a variable?
For Example:
colname <- "LOT"
newdf <- subset(olddf,select = - colname)
The above statement will give an error, but thats what I'm trying to
accomplish.
If I had used:
newdf <- subset(olddf,select = - LOT)
then it would have worked, but as I said the column
2006 Jul 21
1
insert insertRow?
Dear all,
In the search for a command to insert a row between other rows in a data
frame I found that there seems to be no such command in the base R
package. There is however a very simple function insertRow in the
micEcon package, that makes use of rbind. I wondered if it would not be
possible to include the following micEcon functions in the base package:
insertRow
insertCol
Since the
2006 Jul 21
1
insert insertRow?
Dear all,
In the search for a command to insert a row between other rows in a data
frame I found that there seems to be no such command in the base R
package. There is however a very simple function insertRow in the
micEcon package, that makes use of rbind. I wondered if it would not be
possible to include the following micEcon functions in the base package:
insertRow
insertCol
Since the
2008 Mar 06
2
Help with parsing a data file
Hi All,
I need to parse data from a file, example shown below. The first two lines
can be skipped, the third line contains the column names. The next 13 lines
can be skipped. The next line "1991" is a year value, with the following 13
values data for that year. The file then repeats this format with (year, 13
lines of data for that year). I would ideally like to end up with an
2010 Jun 18
5
extract date time from a text file
I a have a text file where every line is like that:
"2007-12-03 13:50:17 Juan Perez"
("yy-mm-dd hh:mm:ss First Name Second Name")
I would like to make a data frame with two column one for date and the
other one for name.
When I use read.delim it was transformed in a data frame with 4 colums.
Bye,
Sebasti?n.
2004 Nov 09
0
Vector multiplication wrap-around
Greetings:
In a function I'm trying to write I am multiplying each row in a matrix by a
vector. When the vector extends beyond the end of the matrix I need to have
the multiplication wrap around (continue with column 1 of the matrix).
Initially I got this to work with a loop (old programming habits die hard).
Now, after going back through MASS I've figured out how to do the
multiplication
2007 Nov 09
3
Normalizing grouped data in a data frame
Hi
I am a newbie to R but have tried a number of ways in R to do this and
can't find a good solution. (I could do it out of R in perl or awk but
would like to know how to do this in R).
I have a large data frame 49 variables and 7000 observations however for
simplicity I can express it in the following data frame
Base, Image, LVEF, ES_Time
A, 1, 4.32, 0.89
A, 2, 4.98, 0.67
A, 3, 3.7, 0.5
2006 Sep 11
9
rename cols
A quick question please!
How do you rename column names? i.e. V1 --> Apple; V2 --> Orange, etc.
thx much
ej
[[alternative HTML version deleted]]
2004 Jul 16
3
still problems with predict!
Hi all,
I still have problems with the predict function by setting up the values on
which I want to predict
ie:
original df: p1 (193 obs) variates y x1 x2
rm(list=ls())
x1<-rnorm(193)
x2<-runif(193,-5,5)
y<-rnorm(193)+x1+x2
p1<-as.data.frame(cbind(y,x1,x2))
p1
y x1 x2
1 -0.6056448 -0.1113607 -0.5859728
2 -4.2841793 -1.0432688 -3.3116807
......
192
2011 Nov 11
2
One step way to create data frame with variable "variable names"?
Suppose
plotx <- "someName"
modx <- "otherName"
plotxRange <- c(10,20)
modxVals <- c(1,2,3)
It often happens I want to create a dataframe or object with plotx or
modx as the variable names. But can't understand syntax to do that.
I can get this done in 2 steps, creating the data frame and then
assigning names, as in
newdf <- data.frame( c(1, 2, 3, 4),
2012 May 14
2
Error in names(x) <- value: 'names' attribute must be the same length as the vector
Dear R-helpers,
I am stuck on an error in R: When I run my code (below), I get this error
back:
Error in names(x) <- value :
'names' attribute must be the same length as the vector
Then when I use traceback(), R gives me back this in return:
`colnames<-`(`*tmp*`, value = c(""Item", "Color" ,"Number", "Size"))
I'm not exactly
2003 Sep 05
2
eliminating a large subset of data from a frame
I have a data frame with 155,000 rows. One of the columns
represents the user id (of which about 10,000 are unique). I am
able to isolate 1000 of these user ids (stored in a list) that
I want to eliminate from the data set, but I don't know of an
efficient way to do this. Certainly this would be slow:
newdf<-df
for(i in listofbadusers) {
newdf<-subset(tmp,uid!=i)
}
is there a better
2018 Apr 27
5
predict.glm returns different results for the same model
Hi all,
Very surprising (to me!) and mystifying result from predict.glm(): the
predictions vary depending on whether or not I use ns() or
splines::ns(). Reprex follows:
library(splines)
set.seed(12345)
dat <- data.frame(claim = rbinom(1000, 1, 0.5))
mns <- c(3.4, 3.6)
sds <- c(0.24, 0.35)
dat$wind <- exp(rnorm(nrow(dat), mean = mns[dat$claim + 1], sd =
sds[dat$claim + 1]))
dat <-
2012 Feb 25
1
Unexpected behavior in factor level ordering
Hello, Everybody:
This may not be a "bug", but for me it is an unexpected outcome. A
factor variable's levels
do not retain their ordering after the levels function is used. I
supply an example in which
a factor with values "BC" "AD" (in that order) is unintentionally
re-alphabetized by the levels
function.
To me, this is very bad behavior. Would you agree?
#
2017 Jul 16
3
Arranging column data to create plots
Dear All,
I need some help arranging data that was imported.
The imported data frame looks something like this (the actual file is huge, so this is example data)
DF:
IDKey X1 Y1 X2 Y2 X3 Y3 X4 Y4
Name1 21 15 25 10
Name2 15 18 35 24 27 45
Name3 17 21 30 22 15 40 32 55
I would like to create a new data frame with the following
NewDF:
IDKey X Y
Name1 21 15
Name1
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),
2011 Sep 21
1
Problem with predict and lines in plotting binomial glm
Problems with predict and lines in plotting binomial glm
Dear R-helpers
I have found quite a lot of tips on how to work with glm through this mailing list, but still have a problem that I can't solve.
I have got a data set of which the x-variable is count data and the y-variable is proportional data, and I want to know what the relationship between the variables are.
The data was