Displaying 20 results from an estimated 10000 matches similar to: "re-order the rows of a data frame accroding to a specified order of some column"
2008 Oct 29
4
How to get the duplicated elements from a vector?
Dear all,
How can I get the duplicated elements from a vector? For example,
x <- c("yes", "no", "yes", "yes", "no", "not sure"), how can I filter
out all the elements which occured >=2 times?
Thanks for any help!
Regards,
Leon
2013 Apr 12
1
Removing rows that are duplicates but column values are in reversed order
Hi,
From your example data,
dat1<- read.table(text="
id1?? id2?? value
a????? b?????? 10
c????? d??????? 11
b???? a???????? 10
c????? e???????? 12
",sep="",header=TRUE,stringsAsFactors=FALSE)
#it is easier to get the output you wanted
dat1[!duplicated(dat1$value),]
#? id1 id2 value
#1?? a?? b??? 10
#2?? c?? d??? 11
#4?? c?? e??? 12
But, if you have cases like the one
2008 Oct 17
2
A question about "union"
Dear all,
I have a question about "union". "union" handles two vectors'
elements to get their union, but I have many vectors and I want to get
the union of all of them. So I wrote a loop:
all <-c();
for(var in ls(pattern="xyz"))
# all of the vectors with pattern of "xyz"
{
all <- union(all, var);
}
but the result is like this:
2005 Jul 04
1
question about boxplot axis
Hi:
I have a question making side by side boxplot.
My response is numeric and I want to make a side by
side boxplot of it accroding to a factor vector. So,
there are several boxplots on the same plot. Each
boxplot is with respect to one level for a factor. The
levels of
the factor are some characters. When I make the plot,
the boxplots are arranged according to the alphabetic
order of the
2008 Feb 23
1
ginv and matlab's pinv give different results
Dear all;
I'm kind of confused with the results obtained using the ginv function
from package MASS and pinv function from Matlab. Accroding to the
documentation both functions performs a Moore-Penrose generalized
inverse of a matrix X. The problem is when I change the tolerance
value, say to 1E-3.
Here is some output from ginv
195.2674402 235.6758714 335.0830253 8.977515484 -291.7798965
2009 Apr 17
1
Monotone Transformation
Hi, I am trying to use R to mimic what I did in SAS.
proc transreg data=x ;
model identity(GSI)=monotone(group1);
output out=d2 pprefix=M;
run;
Accroding to SAS documentation, the MONOTONE transfomation algorithm comes
from (Kruskal 1964, secondary approach to ties). I have tried ace. it does
provide some kind of monotone transformation, but it is not what I expected.
Here is how
2008 Nov 15
2
Which data structure in R can mimic hash in PERL best?
Dear all,
Which data structure in R can mimic hash in PERL? I'd like to set up
a lookup table, which could be accomplished by HASH if using PERL. Which
of the data structures in R is the most efficient for lookup table?
Thanks for your help.
Best regards,
Leon
2007 Oct 27
1
Newton method iteration problem
Hi all,
I am coding for finding the root of f(x)= phi(x) -alpha where phi(x) is the
cumulative density function and alpha is constant . The problem right now is
I can't get the "initialX" representing the root out of the while loop when
ending , it seems to me it disappear when the loop ends accroding to the
error message. I need help . Please suggest the cause or solution to this
2002 Dec 17
4
booting from local disk
Hi,
I've mostly set up a kickstart for RedHat 8.0.
I'm using the instructions posted by Alf W. :
http://www.stanford.edu/~alfw/PXE-Kickstart/PXE-Kickstart.html
The whole thing works, except when I go to reboot the system it hangs.
ie.
TFTP Prefix:
Trying to load: pxelinux.cfg/AABBCCDD
Trying to load: pxelinux.cfg/AABBCCD
Trying to load: pxelinux.cfg/AABBCC
Trying to load:
2009 Aug 12
1
pretty display or print for data frames ?
Hi, all
I have a question of adjusting the output of a data frame with many
columns. By default, print() will print out several columns according to
the window size, and then it scrolls down and print out left columns.
How can I make it print all the columns in the same line?
I found options(width=80 or 120 or whatever) will the change the
behavior of print() and got the effect what
2009 Nov 11
1
p-value calculation on a joint distribution
Dear R users,
For a uni-variable distribution represented in a numerical vector,
we can obtain a distribution function using 'ecdf', and then calculate
corresponding p-values. But if I have a 2-column dataframe representing
a bi-variable joint distribution, given a pair of values, how can I get
the p-value? And how can I plot out the density of the joint distribution?
Best
2011 Dec 18
1
Beginner help: Excluding directories by pattern
I apologize in advance for asking a beginner question, but I really
could not figure this from the manual page.
I want to copy some files with rsync, and not copy others.
The stuff that I do not want to copy looks like this:
System Volume Information/_restore*/RP*
WINDOWS/Prefetch/*
Documents and Settings/leila/Local Settings/Application
Data/Google/Chrome/Application/*/Installer/chrome.7z
2013 Dec 15
1
Rows to Column
Hi all,
I'm kinda new in R programming and I need some help preparing a database to
run logistic regression.
I have data in a tuple form:
*id cat val*
1 A 2
1 C 4
3 B 1
5 A 2
6 A 3
6 B 5
6 C 2
8 B 5
8 D 2
9 D 3
and would like to have it like:
*id catA catB catC catD*
1 2 0 4 0
3 0 1 0 0
5 2 0 0 0
6 3
2012 Oct 14
6
transforming a .csv file column names as per a particular column rows using R code
Hello all,
I have a .csv file like below.
Tool,Step_Number,Data1,Data2... etc up to 100 columns.
A,1,0,1
A,2,3,1
A,3,2,1
.
.
B,1,3,2
B,2,1,2
B,3,3,2
.
.
...... so on upto 50 rows
where the column "*Tool*" has distinct steps in second column
"*Step_Number*",but both have same entries in Step_Number column.
I want the output like below.
2006 Jan 09
2
Ruby on Rails and WURFL?
Hi!
I''m a newcommer to Ruby and Rails. I''ve just got the environment done on
my Mac OS X machine and I am eager to start to learn more!
It seems as such a great plattform for doing webapplications.
I have a specific task I would like to acomplish but being a newbie with
Rails and Ruby am not sure where to start.
What I want to do is to create a mobile site that is very
2012 Aug 03
4
How to concatenate a several rows according with a column ?
Hi, I'm a new user or R and I try to concatenate a several rows according
with the value in a column.
this is my data.frame and I want to concatenate my data.frame according with
the column "b" and make a new data.frame with the information in the others
columns.
>table1
a b c d
1 E001234 TSA IP234 like_domain
2
2018 Feb 25
1
reshaping column items into rows per unique ID
Hi Allaisone,
I took a slightly different approach but you might find this either as or
more useful than your approach, or at least a start on the path to a
solution you need.
df1 <-
data.frame(CustId=c(1,1,1,2,3,3,4,4,4),DietType=c("a","c","b","f","a","j","c","c","f"),
2018 Feb 25
0
reshaping column items into rows per unique ID
I believe you need to spend time with an R tutorial or two: a data frame
(presumably the "table" data structure you describe) can *not* contain
"blanks" -- all columns must be the same length, which means NA's are
filled in as needed.
Also, 8e^5 * 7e^4 = 5.6e^10, which almost certainly will not fit into any
local version of R (maybe it would in some server version --
2018 Feb 25
4
reshaping column items into rows per unique ID
Hi All
I have a datafram which looks like this :
CustomerID DietType
1 a
1 c
1 b
2 f
2 a
3 j
4 c
4 c
4 f
And I would like to reshape this so I can
2007 Sep 01
1
why doesn't as.character of this factor create a vector ofcharacters?
This message didn't seem to have been somewhat forgotten. Here is a reply.
When you constructed the data.frame, all strings were converted to
factors. If you didn't want that, it would have been possible to
specify it:
df<-data.frame(a=a,b=b,c=c,stringsAsFactors=F)
Then everything would work as intended:
one.line<-as.character(df[df$a=="Abraham",])
Actually, the real