Displaying 20 results from an estimated 10000 matches similar to: "How to update a column in a dataframe, more simply..."
2006 Jan 10
1
extracting coefficients from lmer
Dear R-Helpers,
I want to compare the results of outputs from glmmPQL and lmer analyses.
I could do this if I could extract the coefficients and standard errors
from the summaries of the lmer models. This is easy to do for the glmmPQL
summaries, using
> glmm.fit <- try(glmmPQL(score ~ x*type, random = ~ 1 | subject, data = df,
family = binomial), TRUE)
> summary(glmmPQL.fit)$tTable
2011 Sep 22
2
Proportions of a vector
>
> Hi all,
> I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6)
>
> I want to return a vector with the corresponding probabilities based on the
> amount of times the numbers occurred. For example, I should get the
> following vector for xm:
> prob.xm = c(1/9, 1/9, 1/9, 1/9, 3/9, 3/9, 3/9, 2/9, 2/9)
>
Using prop.table gives:
Usage (with table)
> prob.xm <-
2010 Feb 17
2
extract the data that match
Hi r-users,
I would like to extract the data that match. Attached is my data:
I'm interested in matchind the value in column 'intg' with value in column 'rand_no'
> cbind(z=z,intg=dd,rand_no = rr)
z intg rand_no
[1,] 0.00 0.000 0.001
[2,] 0.01 0.000 0.002
[3,] 0.02 0.000 0.002
[4,] 0.03 0.000 0.003
[5,] 0.04 0.000 0.003
[6,]
2006 Feb 24
2
Sorting a dataframe by one column?
Given the following dataframe:
A=1:10
B=(a-5)^2
DATAFRAME=data.frame(A,B)
How can I sort DATAFRAME increasing (or decreasing, for that matter)
by B without making reference to A, or any other column?
I've read ?order and ?sort but cannot seem to figure this out.
Thank you.
Mark
2011 Aug 24
4
Column of probabilities
Hi all,
I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6)
I want to return a vector with the corresponding probabilities based on the
amount of times the numbers occurred. For example, I should get the
following vector for xm:
prob.xm = c(1/9, 1/9, 1/9, 1/9, 3/9, 3/9, 3/9, 2/9, 2/9)
Any help greatly appreciated.
--
Thanks,
Jim.
[[alternative HTML version deleted]]
2011 Jul 11
3
Stacked bar plot of frequency vs time
Hi All,
New to R, but committed. I looked in a number of places but can't figure out
my current problem. I have date of the type:
Time Type1 Type2 Type3
1 .50 .25 .25
4 .55 .25 .20
5 .65 .20 .15
etc
which describe the frequency of types 1, 2 and 3 (adding up to 100%) over
time. I would like to create a stacked bar chart showing these
2004 Aug 06
1
Comparing rows in a dataframe
Hello
I have a longitudinal dataframe organized in the long format and would like to make comparison between successive rows if certain conditions apply. Specifically, I have four variables of interest: grade, score, year, and schid, associated with each school with 3 measurements per school per grade, therefore the rows are temporally ordered and each school occupies multiple rows. For example,
2008 Mar 25
2
Combining logical operators to extract columns from a dataframe
Hi R-helpers,
I have a dataframe (called data) with 100 columns, the columns of which are
named with integers ranging from 1900 to 1999.
I wish to extract those columns which names are >=1950 and <=1970.
I tried:
data2<-subset(data,select=(names(data)>=1950 & names(data)<=1970))
but that doesn't work.
Any ideas?
Thanks! Mark
[[alternative HTML version deleted]]
2009 Nov 24
2
How to identify the rows in my dataframe with a negative value in any column?
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091124/27851110/attachment-0001.pl>
2008 Jun 16
1
回复: cch() and coxph() for case-cohort
I tried to compare if cch() and coxph() can generate same result for
same case cohort data
Use the standard data in cch(): nwtco
Since in cch contains the cohort size=4028, while ccoh.data size =1154
after selection, but coxph does not contain info of cohort size=4028.
The rough estimate between coxph() and cch() is same, but the lower
and upper CI and P-value are a little different. Can we
2008 May 08
1
Reading multiple tables from file
Dear R-users,
I have output files having a variable number of tables
in the following format:
-------------
1
Pietje
I1 I2 Value
1 1 0.11
1 2 0.12
2 1 0.21
2
Jantje
I1 I2 I3 Value
1 1 1 0.111
3 3 3 0.333
...
-------------
Would there be an easy way
of turning this into (a list of) data.frames
with names Pietje, Jantje
and variables I1,I2,...Value?
(I1,I2 are string or categorical,
2011 Nov 14
3
max & min values within dataframe
dear R-team
I need to find the min, max values for each patient from dataset and keep
the output of it as a dataframe with the following columns
- Patient nr
- Region (remains same per patient)
- Min score
- Max score
Patient Region Score Time
1 1 X 19 28
2 1 X 20 126
3 1 X 22 100
4 1 X 25 191
5 2 Y 12 1
2006 Jan 07
8
Using find_by_sql to get the sum of a column
Hello,
I was wondering if there was a method in Rails that returns the sum of a
column. For example, I have a column called ''score'' and writing a SQL
statement such a ''select sum(score) from table_name'' does return the sum
of the values in the column. In the past (not too long ago being a
newbie), I defined all sorts of methods only to discover that Rails
2009 Oct 21
2
How to average subgroups in a dataframe? (not sure how to apply aggregate(..))
Dear all,
Lets say I have the following data frame:
> set.seed(1)
> col1 <- c(rep('happy',9), rep('sad', 9))
> col2 <- rep(c(rep('alpha', 3), rep('beta', 3), rep('gamma', 3)),2)
> dates <- as.Date(rep(c('2009-10-13', '2009-10-14', '2009-10-15'),6))
> score=rnorm(18, 10, 3)
> df1<-data.frame(col1=col1,
2011 Feb 10
1
Ggplot: free x-scales in a facet-grid
Hello,
I have a ggplot that has the looks of the plot that I want, but it doesn't
have the right layout.
The data is an ordered melted dataframe:
- ID
- type (to use for a faced grid)
- time - type
- time - value (POSIXct)
- pos (to use for a faced grid, this is an index to split the plot)
The goal of the plot is to create a time line for each ID (different points
of time). The ID's
2012 Jun 02
2
mgcv (bam) very large standard error difference between versions 1.7-11 and 1.7-17, bug?
Dear useRs,
I reran an analysis with bam (mgcv, version 1.7-17) originally
conducted using an older version of bam (mgcv, version 1.7-11) and
this resulted in the same estimates, but much lower standard errors
(in some cases 20 times as low) and lower p-values. This obviously
results in a larger set of significant predictors. Is this result
expected given the improvements in the new version? Or
2012 Jun 01
2
how to add a 'label' column
Hello R users,
I'd like to ask a question about how to add a new column. So, below is my
situation.
In order to perform the repeated ANOVA, I first imported the following
table.
score=read.csv("patients_tests.csv");
subject test1 test2 test3 test4 test5 test6
test7
1 ab 0.17687 0.16715 0.17009 0.16480 0.16116 0.24502 0.17975
2 cl
2009 Jun 17
2
How to translate a dataframe into the R code that makes that dataframe?
Hi,
I am helping another R user (off list) and I would like to email her
an R script containing the data she needs and the code to solve her
problem. I have made a small dummy dataset, but instead of sending her
a CSV I would prefer to send the data embedded in the script, so there
would be a like in the script like:
my.df<-c( etc, etc, etc
I have made the dataframe (in a spreadsheet) and
2010 May 19
1
printing a dataframe by categories
I am looking for the following simple question.
I have a data frame with names and numbers, divided in categories.
I would like to produce a text file with page breaks,
listing the names and numbers by category,
and totalling the numbers.
Example:
Name<-LETTERS[1:6]
Score<-rep(5:8,length.out=6)
Form<-rep(1:2,each=3)
x<-data.frame(Name,Score,Form)
This gives approximately
2009 Feb 13
1
equivalent to SAS genmod code in R?
Hello,
I have to run a general linear mixed model which looks at 2 dependent
variables at the same time (var1 divided by var2). I have tryed to search
for such a kind of model structure but since I just started using R my
search was not successful. Especielly since I only have an old SAS GENMOD
code structure from my project supervisor as an indication.
My question is no, does there exist a code