Displaying 20 results from an estimated 20000 matches similar to: "Subsetting problem data, 2"
2012 May 21
1
Complex text parsing task
Hello Everyone,
I have what I think is a complex text parsing task. I've provided some sample data below. There's a relatively simple version of the coding that needs to be done and a more complex version. If someone could help me out with either version, I'd greatly appreciate it.
Here are my sample data.
haveData <-
structure(list(profile_key = structure(c(1L, 1L, 2L, 2L, 2L,
2012 May 31
3
How can I get this function to work?
Hello All,
Can anyone tell help me understand why the function below doesn't work and how I can fix it? Below are some sample data, some code that works on individual rows of the data, and my attempt to translate that code into a function. My hope is to get the function working and then to apply it to the larger data frame using ddply() from the plyr package or possibly some other approach.
2009 Sep 23
1
dotchart to barplots
Hi,
I am trying to plot the following data so that it can be visually represented well. I tried the dotchart but I felt it was too spread out. Then I tried the barplot which is good enough for me. Is there a way to give the labels for the y-axis as in the dot chart? Also, I feel the grey level is confusing, so is there options for designs within the bars? I cannot use color as the journal wants
2012 Oct 08
3
How to count combinations
Dear all,
Need a help. I would like to count combination of two columns:
structure(list(V1 = structure(c(4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("23",
"55", "67", "Env"), class = "factor"), V2 = structure(c(9L, 7L,
7L, 7L, 2L, 1L, 11L, 11L, 11L, 11L, 5L, 6L, 6L, 3L, 8L, 2L, 1L,
4L, 4L,
2010 Feb 04
1
for loop with if statment problem
Both of the approx functions work correctly individually, but they are
not being distinguished in the for loop by the if statments. Any help
would be appreciated. for loop of interest is below
x <- (structure(list(Site = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L,
2010 Jul 18
2
simple loop(?) analysing subsets
Hi All,
I have a large data set with many columns of data. One of these columns is a
species identifier and the remainder are variables such as temperature or
mass. Currently I am carrying out a single regression on subsets of the data
set, e.g. separated data sets with only the data from one species at a time.
I have been searching for a thread that will help me to understand how best
to repeat
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
2011 Nov 19
3
Data analysis: normal approximation for binomial
Dear R experts,
I am trying to analyze data from an article, the data looks like this
Patient Age Sex Aura preCSM preFreq preIntensity postFreq postIntensity
postOutcome
1 47 F A 4 6 9 2 8 SD
2 40 F A/N 5 8 9 0 0 E
3 49 M N 5 8 9 2 6 SD
4 40 F A 5 3 10 0 0 E
5 42 F N 5 4 9 0 0 E
6 35 F N 5 8 9 12 7 NR
7 38 F A 5 NA 10 2 9 SD
8 44 M A 4 4 10 0 0 E
9 47 M A 4 5 8 2 7 SD
10 53 F A 5 3 10 0 0 E
11
2008 Dec 02
1
ggplot2 facet_wrap problem
Hadley,
I don't know if I am doing something wrong or if it is ggplot please
see the two graphs at the bottom of the page (code).
melt.nut <- (structure(list(RiverMile = c(119L, 119L, 119L, 119L, 119L, 119L,
119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L,
179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L,
185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L,
2010 Apr 19
1
What is mclust up to? Different clusters found if x and y interchanged
Hello All...
I gave a task to my students that involved using mclust to look for clusters
in some bivariate data of isotopes vs various mining locations. They
discovered something I didn?t expect; the data (called tur) is appended
below.
p <- qplot(x = dD, y = dCu65, data = tur, color = mine)
print(p) # simple bivariate plot of the data; looks fine
mod1 <- Mclust(tur[,2:3])
mod1$G
mod2
2012 Oct 05
5
Missing data (Na) and chi-square tests
Dear everyone
I am a bit of a computer imbecile and are having problems with R.
I am using R in my research project to do chi-square tests on data imported
from excel .
However I have som missing data in one of my variables (columns) and I need
R to "exclude" these and make chi-square test on the data that I have.
I use a formula to make 2x2 tables which is:
data <-
2013 Jan 24
4
sorting/grouping/classification problem?
Hi,
I'm a database admin for a database which manage chromatographic results of products during stability studies.
I use R for the reporting of the results in MS Word through R2wd.
But now I think I need your help:
suppose we have the following data frame:
ID rrt Mnd Result
1 0.45 0 0.10
1 0.48 0 0.30
1 1.24 0 0.50
2 0.45 3 0.20
2 0.48 3 0.60
2 1.22 3 0.40
3
2011 Jan 20
4
subsets
Dear R people
Could you please help.
Basically, there are two variables in my data set. Each patient ('id')
may have one or more diseases ('diagnosis'). It looks like
id diagnosis
1 ah
2 ah
2 ihd
2 im
3 ah
3 stroke
4 ah
4 ihd
4 angina
5 ihd
..............
Q: How to make three data sets:
1. Patients with ah and ihd
2. Patients with ah but no ihd
3. Patients with ihd but no
2017 Jul 22
1
3-day moving average for block maxima
Dear r-users,
I would like to construct 3-day moving average for block maxima series.
I tried this:
bmthree <- lapply(split(dt, dt$Year), function(x) max(sapply(1:(nrow(x)-2),
function(i) with(x, mean(Amount[i:(i+2)],na.rm=TRUE)))))
bmthree
and got the following output.
$`1971`
[1] 70.81667
$`1972`
[1] 68.94553
$`1973`
[1] 102.7236
$`1974`
[1] 73.6625
$`1975`
[1]
2012 Sep 18
2
Formula in a data-frame
Hello all,
I'm new in R, and I have a data-frame like this (dput information below):
Specie Fooditem Occurrence Volume
1 Schizodon vegetal 1 0.05
2 Schizodon sediment 1 0.60
3 Schizodon vegetal 1 0.15
4 Schizodon alga 1 0.05
5 Schizodon sediment 1 0.90
6 Schizodon
2012 Jan 09
3
as.numeric() generates NAs inside an apply call, but fine outside of it
Hello-
I have rather a messy SPSS file which I have imported to R, I've dput'd
some of the columns at the end of this message. I wish to get rid of all
the labels and have numeric values using as.numeric. The funny thing is
it works like this:
as.numeric(mydata[,2]) # generates correct numbers
however, if I pass the whole dataframe at once like this:
apply(mydata, 1:2, function(x)
2010 Jul 02
2
Problem with aggregating data across time points
Hello-
I have a dataset which basically looks like this:
Location Sex Date Time Verbal Self harm
Violence_objects Violence
A 1 1-4-2007 1800 3 0
1 3
A 1 1-4-2007 1230 2 1
2 4
D 2 2-4-2007 1100 0
2017 Oct 20
1
Error messages using nonlinear regression function (nls)
Hi
Keep your messages in the list, you increase your chance to get some answer.
I changed your data to groupedData object (see below), but I did not find any problem in it.
plot(wlg)
gives reasonable picture and I am not such expert to see any problem with data. Seems to me, that something has to be wrong with nlsList function.
> wheat.list <- nlsList(Prop ~ SSlogis(end,Asym, xmid,
2011 Jan 19
1
Using subset to filter data table
I am having difficulty understanding how I would constrain a data set by
filtering out 'records' based on certain criteria.
Using SQL I could query using 'select * from my.data where LithClass in
('sand', 'clay')' or some such.
Using subset, there seem to be ghosts left behind (that is, all of the
LithClass *.Labels* remain after subset)
> dput(tcc)
2012 May 04
7
Breaking up a Row in R (transpose)
I have the following:
Time A1 A1 B1 B1 C1 C2
x y x y x y
0 5 6 6 7 7 9
1 3 4 4 3 9 9
2 5 2 6 4 7 4
I want to change it to the following:
0 1 2
x y x y x y
A1 5 6 3 4 5 2
B1