Displaying 20 results from an estimated 2000 matches similar to: "reshape"
2013 Apr 29
1
how to add new rows in a dataframe?
Hi,
dat1<- read.table(text="
id??????????????? t???????????????????? scores
2???????????????? 0??????????????????????? 1.2
2???????????????? 2???????????????????????? 2.3
2???????????????? 3??????????????????????? 3.6
2???????????????? 4??????????????????????? 5.6
2???????????????? 6??????????????????????? 7.8
3???????????????? 0??????????????????????? 1.6
3????????????????
2013 May 22
0
calcul of the mean in a period of time
Hi,
I guess you meant this:
dat2<- read.table(text="
patient_id????? t???????? scores
1????????????????????? 0??????????????? 1.6
1????????????????????? 1??????????????? 2.6
1????????????????????? 2???????????????? 2.2
1????????????????????? 3???????????????? 1.8
2????????????????????? 0????????????????? 2.3
2?????????????????????? 2???????????????? 2.5
2?????????????????????
2013 Mar 22
3
Distance calculation
Hi Elisa,
I hope this is what you wanted.
dat1<-read.csv("peaks.csv",sep=",")
#Subset
dat2<-dat1[1:5,]
res1<-do.call(cbind,lapply(seq_len(nrow(dat2)),function(i) do.call(rbind,lapply(split(rbind(dat2[i,],dat2[-i,]),1:nrow(rbind(dat2[i,],dat2[-i,]))), function(x) {x1<-rbind(dat2[i,],x);
2012 Dec 24
2
colmeans not working
[text file is also attached in case you find the format of email difficult to understand]
Dear useRs,You must all the planning for the christmas, but i am stucked in my office on the following issue
i had a file containg information about station name, year, month, day, and discharge information. i opened it by using
following command
> dat1<-read.table("EL.csv",header=TRUE,
2013 Apr 14
1
possible loop problem
Hi,
It would be better if you provided the output of dput(dataset).? I am not sure about the structure of your dataset.
Just from reading the data as is shown.
dat1<- read.table(text="
separator,tissID
>,>,2
,2,1
,6,5
,11,13
>,>,4
,4,9
,6,2
,7,3
,21,1
,23,58
,25,9
,26,4
>,>,11
,1,12
>,>,21
,4,1
,11,3
2013 Jun 04
0
choose the lines2
HI,
You can do this:
dat1<- read.csv("dat7.csv",header=TRUE,stringsAsFactors=FALSE,sep="\t")
dat.bru<- dat1[!is.na(dat1$evnmt_brutal),]
fun2<- function(dat){?
????? lst1<- split(dat,dat$patient_id)
??? lst2<- lapply(lst1,function(x) x[cumsum(x$evnmt_brutal==0)>0,])
??? lst3<- lapply(lst2,function(x) x[!(all(x$evnmt_brutal==1)|all(x$evnmt_brutal==0)),])
2013 Feb 19
1
data format
Hi,
Try this:
el<- read.csv("el.csv",header=TRUE,sep="\t",stringsAsFactors=FALSE)
?elsplit<- split(el,el$st)
?
datetrial<-data.frame(date1=seq.Date(as.Date("1930.1.1",format="%Y.%m.%d"),as.Date("2010.12.31",format="%Y.%m.%d"),by="day"))
elsplit1<- lapply(elsplit,function(x)
2013 Nov 19
0
How to extract sets of rows (not sorted) from text file in R, do some methods on these rows, save the result in another text file, then pick others set of rows and do the same
Hi,
You may need ?split(), or ?aggregate() or ?ddply() from library(plyr)
dat1 <- read.table(tex="1 2 4 7 8 9
1 4 5 8 9
1 4 5 6 9
2 3 4 8
3 6 7 8
1 5 6 9
2 5 7 9",header=FALSE,sep="",fill=TRUE)?
##
?res1 <- do.call(rbind,lapply(split(dat1,dat1[,1]),function(x) c(V1=x[1,1],colSums(x[,-1],na.rm=TRUE))))
2013 Nov 05
0
Sampling question
Hi,
You may try:
dat1 <- structure(list(SubID = 1:8, CSE1 = c(6L, 6L, 5L, 5L, 5L, 5L,
3L, 3L), CSE2 = c(5L, 4L, 5L, 4L, 6L, 4L, 6L, 6L), CSE3 = c(6L,
7L, 5L, 3L, 7L, 3L, 6L, 6L), CSE4 = c(2L, 2L, 5L, 4L, 5L, 6L,
3L, 3L), WSE1 = c(6L, 6L, 5L, 4L, 6L, 4L, 6L, 6L), WSE2 = c(2L,
6L, 5L, 4L, 4L, 3L, 5L, 5L), WSE3 = c(2L, 2L, 4L, 5L, 4L, 7L,
2L, 4L), WSE4 = c(4L, 3L, 5L, 2L, 1L, 3L, 1L, 7L)),
2017 Aug 27
6
regex - optional part isn't considered in replacement with gsub
Hello, I need some help with regex.
I have this to sentences. I need to extract both "49MU6300" and "LE32S5970"
and put them in a new colum "SKU".
A) SMART TV UHD 49'' CURVO 49MU6300
B) SMART TV HD 32'' LE32S5970
DataFrame for testing:
ecommerce <- data.frame(a = c(1,2), producto = c("SMART TV UHD 49'' CURVO
49MU6300",
2017 Aug 27
0
regex - optional part isn't considered in replacement with gsub
Omar:
I don't think this can work. For example number-letter patterns 4),
5), and 6) would all be matched by pattern 6).
As Jeff indicated, you need to provide the delimiters -- what
characters come before and after the SKU patterns -- to be able to
recognize them. In a quick look at the text file you attached, the
delimiters appeared to be either "-" or " " (blank) and
2012 Aug 07
0
predicting test dataset response from training dataset with randomForest
Hi
I am new to R so I apologize if this is trivial.
I am trying to predict the resistance or susceptibility of my
sequences to a certain drug with a randomForest function from a file
with amino acids on each of the positions in the protein. I ran the
following:
> library(randomForest)
>
> path <- "C:\\..."
> path2 <- "..."
> name <-
2013 May 07
4
how to calculate the mean in a period of time?
Hi,
Your question is still not clear.
May be this helps:
dat2<- read.table(text="
patient_id????? t???????? scores
1????????????????????? 0??????????????? 1.6
1????????????????????? 1??????????????? 2.6
1????????????????????? 2???????????????? 2.2
1????????????????????? 3???????????????? 1.8
2????????????????????? 0????????????????? 2.3
2?????????????????????? 2???????????????? 2.5
2017 Aug 28
0
regex - optional part isn't considered in replacement with gsub
"Please, consider that some SKUs have "-"
in the middle, for example: "PG-9021".
Then you need to include these in the list of patterns you gave. Try it
again -- this time with a **complete** list.
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his
2013 Sep 09
0
Duplicated genes
Hi,
May be you can try this:
dat1New<-? dat1[!(duplicated(dat1$gene)|duplicated(dat1$gene,fromLast=TRUE)),]
dat2<-dat1[duplicated(dat1$gene)|duplicated(dat1$gene,fromLast=TRUE),]
?lst1<-split(dat2,dat2$gene)
dat3<-unsplit(lapply(lst1,function(x) {x1<- sum(apply(x[,6:32],2,function(y) y[1]>=y[2]));x2<- sum(apply(x[,6:32],2, function(y) y[1]<=y[2])); if(x1>x2) x[1,] else
2004 Jun 01
1
swapping with data.frame
Hi there,
I have some data which are convenient to enter as lists. For example:
t1<-list(fname="animal1",testname="hyla",dspkr="left",res1=39.7,res2=15.0)
t2<-list(fname="animal1",testname="bufo",dspkr="left",res1=14.4,res2=56.1)
2012 Jan 04
1
function in R for my exercise
Hi R helpers!
I have a question. I'm trying to create a function for an exercise. Here are
the arguments I should include:
x and y are numeric
z is a name ("plus","minus","multiply","divide")
and swap is logical.
Here is what the function should do:
When z="plus", then x+y is performed and so on for the other z names. It
should give a NA
2010 Mar 22
1
Replacing elements of list
Dear all,
I have following two list object, both are basically collection of matrices
:
dat1 <- matrix(rnorm(25*6), ncol=6)
dat1 <- split(dat1, seq(5,25,by=5))
dat1 <- lapply(dat1, matrix, ncol=6)
dat2 <- matrix(rnorm(25*4), ncol=4)
dat2 <- split(dat2, seq(5,25,by=5))
dat2 <- lapply(dat2, matrix, ncol=4)
Now I want to replace last 4 columns of each matrix at "dat1"
2006 Sep 01
1
integration problem with gamma function
Dear R-list members,
I have a problem with translating a mathematica script into R. The whole
script is at the end of the email (with initial values for easy
reproduction) and can be pasted directly into R. The problematic part
(which is included below of course) is
<--- Original Mathematica --->
(* p_svbar *)
UiA = Ni (Dsi - 2Di A + A^2)/2;
UiiA = Nii (Dsii - 2Dii A + A^2)/2;
psvbar =
2013 Mar 02
0
explanation of the problem..
HI Utpal,
Alight, I will look into it.? I was under the impression that this is what you wanted:
dat1<- structure(list(V1 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L), V2 = c(1L,
1L, 1L, 1L, 1L, 1L, 0L), V3 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L),
??? V4 = c(1L, 1L, 0L, 1L, 1L, 1L, 1L), V5 = c(1L, 1L, 1L, 1L,
??? 1L, 0L, 1L), V6 = c(1L, 1L, 1L, 0L, 1L, 1L, 1L), V7 = c(1L,
??? 1L, 1L, 1L, 1L, 1L, 1L), V8 = c(1L,