Displaying 20 results from an estimated 20000 matches similar to: "replace values in vector from a replacement table"
2010 Jul 23
2
, Updating Table
Hi everyone,
Is there any command for updating table withing a loop? For instance, at i, I have a table as ZZ = table(data.raw[1:ind[i]]) where "ind" = c(10, 20, 30, ...). Then , ZZ will be as follow
"A" "B" "C"
3 10 2
At (i + 1), ZZ = table(data.raw[(ind[i]+1):ind[i+1]])
"A" "B" "D"
4 7 8
Is there any
2012 Feb 05
1
how to REPLACE VALUES in a dataframe
Hi,
I have two data frames (u and v).
> u
coe nam
1 0 Time
2 0 Poten
3 0 AdvExp
4 0 Share
5 0 Change
6 0 Accounts
7 0 Work
8 0 Rating
> v
coeff enter
1 0.7272727 Accounts
2 0.3211112 Time
3 0.0500123 Poten
I want to update the values of coe in u by using the values ofcoeff in v.
That is, I want to get the following result
>
2012 Jul 10
3
fill 0-row data.frame with 1 line of NAs
Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:
> (.xb <- iris[ iris$Species=='zz', ])
[1] Sepal.Length Sepal.Width Petal.Length Petal.Width Species
<0 rows> (or 0-length row.names)
> dim(.xb)
[1] 0 5
> (.xa <-
2011 May 24
2
plotting single variables common to multiple data frames
Hello all,
I have files (see attached) which are created daily. I want to load
about a weeks worth of them (7 daily files) and plot a weeks worth of
one variable together. So one variable name is delta_D_H. I would like
to plot this variable from all 7 days on one plot. I'm having trouble
figure out how to do this.
I've loaded them all up using this
time=Sys.time()
t1<-
2012 Feb 21
2
Dataframes in PLS package
I have been working with the pls procedure and have problems getting the
procedure to work with matrix or frame data. I suspect the problem lies in
my understanding of frames, but can't find anything in the documentation
that will help.
Here is what I have done:
I read in an 10000 x 8 table of data, and assign the first four columns to
matrix A and the second four to matrix B
pls <-
2012 Apr 25
1
recommended way to group function calls in Sweave
Dear all
When using Sweave, I'm always hitting the same bump: I want to group
repetitive calls in a function, but I want both the results and the
function calls in the printed output. Let me explain myself.
Consider the following computation in an Sweave document:
summary(iris[,1:2])
cor(iris[,1:2])
When using these two calls directly, I obtain the following output:
> summary(iris[,1:2])
2002 May 20
1
how does one apply Western Electric / AT&T rules to R plots?
I have searched for info on how to apply the Western Electric rules for
process control, to data and plots I have in R, but I have not been able
to learn how.
Any help would be greatly appreciated.
Thank you,
sjcrauhut at agere.com
05/20/02
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read
2011 Oct 18
1
How to read data sequentially into R (line by line)?
I have a data set like this in one .txt file (cols separated by !):
APE!KKU!684!
APE!VAL!!
APE!UASU!!
APE!PLA!1!
APE!E!10!
APE!TPVA!17122009!
APE!STAP!1!
GG!KK!KK!
APE!KKU!684!
APE!VAL!!
APE!UASU!!
APE!PLA!1!
APE!E!10!
APE!TPVA!17122009!
APE!STAP!1!
GG!KK!KK!
APE!KKU!684!
APE!VAL!!
APE!UASU!!
APE!PLA!1!
APE!E!10!
APE!TPVA!17122009!
APE!STAP!1!
GG!KK!KK!
it contains over 14 000 000 records. Now
2013 Sep 12
4
on how to make a skip-table
I've got two data frames, as shown below:
(NR means Number of Record)
> record.lenths
NR length
1 100
2 130
3 150
4 148
5 100
6 83
7 60
> valida.records
NR factor
1 3
2 4
4 8
7 9
And I intend to obtain the following skip-table:
>
2009 Aug 07
0
[LLVMdev] [PATCH] PR2218
On Jul 25, 2009, at 4:48 PM, Jakub Staszak wrote:
> Hello,
>
> Sorry for my stupid mistakes. I hope that everything is fine now.
> This patch fixes PR2218. There are no loads in example, however
> "instcombine" changes memcpy() into store/load.
Hi Jakub,
Sorry for the delay, I'm way behind on code review. Generally if you
respond quickly, I'll remember
2009 Aug 20
4
expanding 1:12 months to Jan:Dec
Dear R users
I would like to do some spreadsheet style expansion of dates. For
example, I would need to obtain a vector of months. I approached in an
obviously wrong way:
> paste(01:12)
[1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12"
> as.Date(paste(01:12),
2009 Sep 02
2
[LLVMdev] [PATCH] PR2218
Hello,
I fixed my patch as you asked. Sorry for the delay, I'd been working
on my SSU patch (http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-August/025347.html
)
I hope that everything is fine now.
-Jakub
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr2218-3.patch
Type: application/octet-stream
Size: 7511 bytes
Desc: not available
URL:
2006 Apr 06
3
convert a data frame to matrix - changed column name
I have a question, which very easy to solve, but I can't find a solution.
I want to convert a data frame to matrix. Here my toy example:
> L3 <- c(1:3)
> L10 <- c(1:6)
> d <- data.frame(cbind(x=c(10,20), y=L10), fac=sample(L3, + 6, repl=TRUE))
> d
x y fac
1 10 1 1
2 20 2 1
3 10 3 1
4 20 4 3
5 10 5 2
6 20 6 2
> is.data.frame(d)
[1] TRUE
> sapply(d,
2010 May 12
1
Is there an easier way to replace the object name in the R code
Hi all,
I have a R code with quite a few lines. For instance
AA <- read.csv(C:\\AA.txt)
AA.diff <- diff(log(AA))
.....
....
Now I want to re-define the code with different object, like BB,
CC......ZZ(the codes are the same). Thus, I was wondering whether their is
an efficient way or automatic way to replace and generate new objects rather
than using "find and replace" function
2005 Sep 01
1
More block diagonal matrix construction code
Folks:
In answer to a query, Andy Liaw recently submitted some code to construct a
block diagonal matrix. For what seemed a fairly straightforward task, the
code seemed a little "overweight" to me (that's an American stock analyst's
term, btw), so I came up with a slightly cleaner version (with help from
Andy):
bdiag<-function(...){
mlist<-list(...)
## handle case in
2013 Oct 04
3
Trying to avoid nested loop
Dear R users.
I'm trying to avoid using nested loops in the following code but I'm not sure how to proceed. Any help would be greatly appreciated.
With regards,Phil
X = matrix(rnorm(100), 10, 10)
## Version with nested loopsresult = 0
for(m in 1:nrow(X)){ for(n in 1:ncol(X)){ if(X[m,n] != 0){ result = result + (X[m,n] / (1 + abs(m - n))) } }}
## No loop-sum(ifelse(M
2006 May 12
2
Help In Function
Hi All,
I need a basic help from you. I've built a function like this,
windowlength<-function(x)
{
z <- rep(seq(0,331,by=x-1)+1, each=2)
zz <- z[-c(1,length(z))]
ind <- as.data.frame(matrix(zz, nr=2))
j<-lapply(ind, function(x) mat[x[1]:x[2],])
cat("For",x/4,"month
2009 May 15
4
replace "%" with "\%"
Dear all,
I'm trying to gsub() "%" with "\%" with no obvious success.
> temp1 <- c("mean", "sd", "0%", "25%", "50%", "75%", "100%")
> temp1
[1] "mean" "sd" "0%" "25%" "50%" "75%" "100%"
> gsub("%",
2004 Jan 26
5
conditional assignment
Hi all
I want to conditionally operate on certain elements of a matrix, let me
explain it with a simple vector example
> z<- c(1, 2, 3)
> zz <- c(0,0,0)
> null <- (z > 2) & ( zz <- z)
> zz
[1] 1 2 3
why zz is not (0, 0, 3) ?????
the null <- assignment is to keep the console silent
in the other hand, it curious that null has reasonable values
> null
[1]
2017 Oct 13
1
comparing two strings from data
Combining and completing the advice from Greg and Boris the complete
solution is two lines:
data_2 <- read.csv("excel_data.csv", stringsAsFactors = FALSE)
match_list <- match( data_2$data1, data_2$data2 )
The vector match_list will have the matching position when it exists and
NA's otherwise. Its length will be the same as the length of data_2$data1.
You should get