Displaying 20 results from an estimated 4000 matches similar to: "adding group totals to a table"
2007 Dec 06
5
relationship between two factors
I have a dataset with two variables that are factors:
1) Decision Making Satisfaction (DMS), values = A - Completely, B -
Mostly, C - Partly, D - Not at all
2) IT Satisfaction values (ITS), values = A - Completely, B - Mostly, C
- Partly, D - Not at all
I would like to produce a table (matrix) and a chart of the factors,
with counts at the cross sections:
A B C D
A
B
2011 Mar 16
3
making dataframes
Dear all,
I have a dataframe which looks like this (dummy):
date<-c("jan", "feb", "mar", "apr", "may", "june", "july",
"aug","sep","oct","nov","dec")
col1<-c(8.2,5.4,4.3,4.1,3.1,2.5,1.1,4.5,3.2,1.9,7.8,6.5)
col2<-c(3.1,2.3,4.7,6.9,7.5,1.1,3.6,8.5,7.5,2.5,4.1,2.3)
2012 Aug 13
4
if else elseif for data frames
Hi all,
It seems like I cannot use normal 'if' for data frames. What would be the
best way to do the following.
if data$col1='high'
data$col2='H'
else if data$col1='Neutral'
data$col2='N'
else if data$col='low'
data$col2='L'
else
#chuch a warning?
Note that col2 was not an existing column and was newly assigned for this
2006 Mar 16
3
Did I use "step" function correctly? (Is R's step() function reliable?)
Hi all,
I put up an exhaustive model to use R's "step" function:
------------------------
mygam=gam(col1 ~ 1
+ col2 + col3 + col4
+ col2 ^ 2 + col3 ^ 2 + col4 ^ 2
+ col2 ^ 3 + col3 ^ 3 + col4 ^ 3
+ s(col2, 1) + s(col3, 1) + s(col4, 1)
+ s(col2, 2) + s(col3, 2) + s(col4, 2)
+ s(col2, 3) + s(col3, 3) + s(col4, 3)
+ s(col2, 4) + s(col3, 4) + s(col4, 4)
+ s(col2, 5) + s(col3,
2017 Aug 23
2
Comparing 2 dale columns
Dear R fellows,
I created a new column Date_flag to compare the dates of COL1 and COL2 using the code
below. But it showed that 5/1/15 is greater than 6/1/2014 and 5/1/2015 greater than
7/1/2014 despite the year is greater. How do I fix that? I did try to format as %y/%m/%d
but it does not fix that.
data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1)
COL1 COL2
6/1/14
2018 Feb 25
3
include
Thank you Jim,
I read the data as you suggested but I could not find K1 in col1.
rbind(preval,mydat) Col1 Col2 col3
1 <NA> <NA> <NA>
2 X1 <NA> <NA>
3 Y1 <NA> <NA>
4 K2 <NA> <NA>
5 W1 <NA> <NA>
6 Z1 K1 K2
7 Z2 <NA> <NA>
8 Z3 X1 <NA>
9 Z4 Y1 W1
On Sat, Feb 24, 2018 at 6:18 PM, Jim
2018 Feb 25
0
include
Hi Val,
My fault - I assumed that the NA would be first in the result produced
by "unique":
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
val23<-unique(unlist(mydat[,c("Col2","col3")]))
napos<-which(is.na(val23))
preval<-data.frame(Col1=val23[-napos],
2018 Feb 25
2
include
HI Jim and all,
I want to put one more condition. Include col2 and col3 if they are not
in col1.
Here is the data
mydat <- read.table(textConnection("Col1 Col2 col3
K2 X1 NA
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
The desired out put would be
Col1 Col2 col3
1 X1 0 0
2 K1 0 0
3 Y1 0 0
4 W1 0 0
6 K2 X1
2005 Oct 07
2
finding missing lines...
Take this as an example:
> a=data.frame(col1=c(1,2,3,4,5), col2=c
("my","beloved","daughter","son","wife"))
> b=data.frame(col1=c(1,2,4),
col2=c("my","beloved","son"))
> a
col1 col2
1 1 my
2
2 beloved
3 3 daughter
4 4 son
5 5 wife
> b
col1 col2
1 1 my
2
2017 Aug 23
0
Comparing 2 dale columns
Patrick,
## Run the following script an notice the different values of the dataframe "data" in each instance.
# I understand you have done something like the following:
data <- data.frame(COL1 = c("6/1/14", "7/1/14"),
COL2 = c("5/1/15", "5/1/15"), stringsAsFactors = FALSE)
data$Date_Flag <- ifelse(data$COL2 >
2018 Feb 25
2
include
Sorry , I hit the send key accidentally here is my complete message.
Thank you Jim and all, I got it.
I have one more question on the original question
What does this "[-1] " do?
preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1],
Col2=NA,col3=NA)
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2
2017 Aug 23
2
Comparing 2 dale columns
Thanks. But when I apply your codes I get all NA instead of TRUE and FALSE
________________________________
From: PIKAL Petr <petr.pikal at precheza.cz>
Sent: Wednesday, August 23, 2017 11:20:00 AM
To: Patrick Casimir; r-help at r-project.org
Subject: RE: Comparing 2 dale columns
Hi
your code is wrong.
I get
> test<-read.table("clipboard", header=T)
> str(test)
2010 Jul 24
2
union data in column
Is there any function/way to merge/unite the following data
GENEID col1 col2 col3 col4
G234064 1 0 0 0
G234064 1 0 0 0
G234064 1 0 0 0
G234064 0 1
2008 Aug 20
3
vector operation using regexpr?
Hi,
Here's my problem... I have a data frame with three columns containing
strings. The first columns is a simple character. I want to get the
index of that character in the second column and use it to extract the
item from the third column. I can do this using a scalar method. But
I'm not finding a vector method. An example is below.
col1 col2 col3
'L'
2008 Feb 10
11
data frame question
Hello
I have 2 data frames df1 and df2. I would like to create a
new data frame new_df which will contain only the common rows based on the first 2
columns (chrN and start). The column score in the new data frame
should
be replaced with a column containing the average score (average_score) from df1
and df2.
df1= data.frame(chrN= c(“chr1”, “chr1”, “chr1”, “chr1”, “chr2”,
“chr2”, “chr2”),
2013 Jan 11
3
split & rbind (cast) dataframe
Hi,
I would like to split dataframe based on one colum and want
to connect the two dataframes by rows (like rbind). Here a small example:
# The orgininal dataframe
df1 <- data.frame(col1 = c("A","A","B","B"),col2 = c(1:4), col3 = c(1:4))
# The datafame how it could look like
df2 <- data.frame(A.col2 = c(1,2), A.col3 = c(1,2), B.col2 = c(3,4),
B.col3
2018 Feb 25
0
include
Jim has been exceedingly patient (and may well continue to be so), but this smells like "failure to launch". At what point will you start showing your (failed) attempts at solving your own problems so we can help you work on your specific weaknesses and become self-sufficient?
--
Sent from my phone. Please excuse my brevity.
On February 25, 2018 7:55:55 AM PST, Val <valkremk at
2006 Mar 06
1
Sort problem in merge()
Hello!
I am merging two datasets and I have encountered a problem with sort.
Can someone please point me to my error. Here is the example.
## I have dataframes, first one with factor and second one with factor
## and integer
> tmp1 <- data.frame(col1 = factor(c("A", "A", "C", "C", "0", "0")))
> tmp2 <- data.frame(col1 =
2018 Feb 25
0
include
hi Val,
Your problem seems to be that the data are read in as a factor. The
simplest way I can think of to get around this is:
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1],
Col2=NA,col3=NA)
rbind(preval,mydat)
2012 Aug 03
3
embedding data frame in R code?
I would like to insert a few modest size data frames directly into my
R code. a short illustration example of what I want is
d <- read.csv( _END_, row.names=1 )
, "col1", "col2"
"row1",1,2
"row2",3,4
__END__
right now, the data sits in external files. I could put each column
into its own vector and then combine into a data frame, but this seems