Displaying 20 results from an estimated 2000 matches similar to: "Reading .gsheet within R"
2012 Aug 30
4
Leading plus in numeric fields
Hello R experts,
I have go this data frame:
'data.frame': 1 obs. of 20 variables:
$ Anno : chr "PREVISIONI VS TARGET"
$ OreTot: num 41
$ GioTot: logi NA
$ OrGTot: logi NA
$ OreCli: num 99
$ GioCli: logi NA
$ OrGCli: logi NA
$ OreFor: num -27
$ GioFor: logi NA
$ OrGFor: logi NA
$ OreOrt: num -18
$ GioOrt: logi NA
$ OrGOrt: logi NA
$ OreSpo: num -6
$ GioSpo: logi
2011 Aug 28
4
How do I get a weighted frequency table?
? stato filtrato un testo allegato il cui set di caratteri non era
indicato...
Nome: non disponibile
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110828/d35f51a1/attachment.pl>
2011 Feb 09
1
Adding labels into lattice's barchart
*** APOLOGIZES FOR THOSE READING THE LIST THROUGH NABBLE THIS WAS ALREADY POSTED THERE BUT NOT FORWARDED TO THE LIST FOR SOME UNKNOWN REASON ***
I have a dataset that looks like:
$ V1: factor with 4 levels
$ V2: factor with 4 levels
$ V3: factor with 2 levels
$ V4: num (summing up to 100 within V3 levels)
$ V5: num (nr of cases for each unique combination of V1*V2*V3 levels)
Quite new to
2012 Feb 22
1
Multiple lines for each record: how do I handle that
? stato filtrato un testo allegato il cui set di caratteri non era
indicato...
Nome: non disponibile
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120222/a28536ba/attachment.pl>
2011 Jan 03
2
error in calling source(): invalid multibyte character in parser
Being italians when writing comments/instructions we use accented letters - like ?, ?, ?, etc.... when running R scripts using such characters I get and error saying:
invalid multibyte character in parser
I have been looking at the help and searched the r-help archives but I haven't find anything that I could intelligibly apply to my case.
Can anyone suggest a fix for this error?
Thanks,
2010 Dec 20
2
tabulating 2 factors weighting by a third var
Hi,
This must be an easy one but so far I haven't find a way out...
I have a data frame such as:
$ v1 : Factor w/ 5 levels
$ v2 : Factor w/ 2 levels
$ v3 : Class 'difftime' atomic [1:6666]
basically v1 and v2 are factors, while v3 is a variable containing the duration of certain activities (values ranging from 11 to 45000 sec, no missing values)
How can I get a table
2011 Jan 09
1
Getting total bar's label & value labels in a barplot
Hi,
I have been trying to get the label under the total column - i.e. a mean value of columns 2 to 6 - in a barplot I generate with this script:
t1 <- tapply(A, B, sum)
t1[8] <- mean(t1[2:6])
t1 <- as.table(t1)
barplot(t1, ylim=c(0,3000))
mtext("Var1", side = 1, line = 3)
mtext("Var2", side = 2, line = 3)
I have been trying to use
axis(1, at=1:8,
2010 Dec 19
3
monthly median in a daily dataset
Hello,
I have a multi-year dataset (see below) with date, a data value and a flag
for the data value. I want to find the monthly median for each month in this
dataset and then plot it. If anyone has suggestions they would be greatly
apperciated. It should be noted that there are some dates with no values and
they should be removed.
Thanks
Emily
> print ( str(data$flow$daily) )
2011 Aug 30
2
Showing zero frequencies with xtabs
? stato filtrato un testo allegato il cui set di caratteri non era
indicato...
Nome: non disponibile
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110830/7c33d4d0/attachment.pl>
2018 Apr 22
3
How to dynamically add variables to a dataframe
Hi,
I am a bit rusty with R programming and do not seem to find a solution to
add a number of variables to my existing dataframe. Basically I need to add
n=dim(d1)[1] variables to my d0 dataframe and I would like them to be named
V1, V2, V3, ... , V[dim(d1)[1])
When running the following code:
for (t in 1:dim(d1)[1]){
d0$V[t] <- 0
}
all I get is a V variable populated with zeros...
I am
2018 Apr 30
3
How to visualise what code is processed within a for loop
Luca,
If speed is important, you might improve performance by making d0 into a true matrix, rather than a data frame (assuming d0 is indeed a data frame at this point). Although data frames may look like matrices, they aren?t, and they have some overhead that matrices don?t. I don?t think you would be able to use the [[nm]] syntax with a matrix, but [ , nm] should work, provided the matrix has
2012 Aug 06
5
regexpr with accents
Hello,
I have build a syntax to find out if a given substring is included in a larger string that works like this:
d1$V1[regexpr("some text = 9",d1$V2)>0] <- 9
and this works all right till "some text" contains standard ASCII set. However, it does not work when accents are included as the following:
d1$V1[regexpr("some t?xt = 9",d1$V2)>0] <- 9
I have
2018 Apr 24
4
How to visualise what code is processed within a for loop
Hi,
I am trying to debug the following code:
for (i in 1:10){
t <- paste("d0$V",i,sep="")
t <- ifelse(regexpr(d1[i,1],d0$X0)>0,1,0)
}
and I would like to see what code is actually processing R, how can I do
that?
More to the point, I am trying to update my variables d0$V1 to d0$V10
according to the presence or absence of some text (contained in the file
d1)
2018 Apr 28
2
How to visualise what code is processed within a for loop
I forgot to explain why my suggestion.
The logical condition returns FALSE/TRUE that in R are coded as 0/1.
So all you have to do is coerce to integer.
This works because the ifelse will return a 1 or a 0 depending on the
condition. Meaning exactly the same values. And is more efficient since
ifelse creates both vectors, the true part and the false part, and then
indexes those vectors in
2018 Apr 30
0
How to visualise what code is processed within a for loop
Thank you for both replies Don & Rui,
The very issue here is that there is a search that needs to be done within
a text field and I agree with Rui later comment that regexpr might indeed
be the time consuming piece of code.
I might try to optimise this piece of code later on, but for the time being
I am working on the following part of building a neural network to try
indeed classifying some
2018 Apr 30
0
How to visualise what code is processed within a for loop
Hi Rui
Thank you for your suggestion,
I have tested the code suggested by you against that supplied by Don in
terms of timing and results are very much aligned: to populate a 5954x899
0/1 matrix on my machine your procedure took 79 secs, while the one with
ifelse employed 80 secs, hence unfortunately not really any significant
time saved there.
Nevertheless thank you for your contribution.
2018 Apr 28
2
How to visualise what code is processed within a for loop
Thanks Don,
for (i in 1:10){
nm <- paste0("V", i)
d0[[nm]] <- ifelse( regexpr(d1[i,1], d0$X0) > 0, 1, 0)
}
is exaclty what I needed.
Best regards,
Luca
2018-04-25 23:03 GMT+02:00 MacQueen, Don <macqueen1 at llnl.gov>:
> Your code doesn't make sense to me in a couple of ways.
>
> Inside the loop, the first line assigns a value to an
2018 Apr 22
0
How to dynamically add variables to a dataframe
Hi Luca,
How about this?
# create some dummy data since I don't have your d0 or d1
> n <- 3
> d0 <- data.frame(a=runif(5),b=runif(5))
# here's the suggested code
> d1 <- cbind(d0, matrix(0,nrow(d0),n))
> colnames(d1)[1:n + ncol(d0)] <- paste("V",1:n,sep="")
HTH,
Eric
On Sun, Apr 22, 2018 at 11:13 AM, Luca Meyer <lucam1968 at
2017 Dec 29
3
Writing text files out of a dataset
Hello,
I am trying to run the following syntax for all cases within the dataframe
"data"
d1 <- data[1,c("material")]
fileConn<-file("TESTI/d1.txt")
writeLines(d1, fileConn)
close(fileConn)
I am trying to use the for function:
for (i in 1:nrow(data)){
d[i] <- data[i,c("material")]
fileConn<-file("TESTI/d[i].txt")
2010 Dec 17
3
Alternative to extended recode sintax?
Dear R-users,
I have a factor variable within my data frame which I derive week after week from a POSIXct variable using the cut(var,"weeks") command I have found in the chron package. The levels() command gives me:
[1] "2009-03-30 00:00:00" "2009-04-06 00:00:00" "2009-04-13 00:00:00" "2009-04-20 00:00:00" "2009-04-27 00:00:00"