Re: [R] dplyr or plyr or both?
I never realised that nonsense results don’n bother experienced users….. Probably I am not experienced wiith my 6years of R professional work. I think your advise is incomplete: a %>% dplyr::group_by(groep) %>% dplyr::summarise(m=mean(v),n=dplyr::n()) Gives the same problems and makes the line ugly. Or how would you do this? I stick with my advise: use dplyr. if you do not need plyr: stay away from it. If you need it: do not attach it, but use the plyr:: notation. I agree that plyr is something else as dplyr, and unfortunately plyr will be used for some time. Verzonden vanuit Mail voor Windows 10 Van: Jeff Newmiller [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] dplyr or plyr or both?
Hello Christopher and others : What cannot be stressed enough is: do not combine both packages, it gives errors and incorrect results! I will show that below a<-data.frame(groep=1:4,v=1:40) library(dplyr) a %>% group_by(groep) %>% summarise(m=mean(v),n=n()) # groep m n # # 1 11910 # 2 22010 # 3 32110 # 4 42210 # correct library(plyr) a %>% group_by(groep) %>% summarise(m=mean(v),n=n()) Error in n() : This function should not be called directly # ??? a %>% group_by(groep) %>% summarise(m=mean(v)) # m # 1 20.5 #incorrect! -- So both n() and group_by from dplyr don't work after library(plyr)! My advice is: do not use plyr. Unfortunately plyr has some functions that are very important, and that are not in dplyr. For instance: rbind.fill() (for combining the rows of two dataframes with unequal columns). If you need this: do'nt library plyr, use plyr::rbind.fil Until now I have the impression that it is also possible to library dplyr after plyr, but it is better to remove plyr! This is a serious problem that has been reported before, but not solved (in dplyr 0.5.0 and plyr 1.8.4) Frams 2016-09-15 16:09 GMT+02:00 Christopher W Ryan: > I've set myself the task of learning about these packages, and about > tidy data concepts. > > What is the relationship between plyr and dplyr? Does the latter > replace the former (meaning I can concentrate on learning the latter)? > Or is there ever a need to use functions from both (meaning I should > learn both)? > > Thanks. > > --Chris Ryan > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need help in installing packages in R
Three remarks: 1. 'Install.Packages=="RODBC"' does nothing. Where did you find that? The command is install.packages("RODBC") 2. Sometimes it is a good idea to start reading a manual. 3. Please do not post in html Frans 2016-02-25 17:11 GMT+01:00 Bhavani Akila: > Hi, > > I have just started learning about "R" programming language. I tried to > connect it to SQL server using "RODBC". On trying to install packages in R > with the command > Eg., 'Install.Packages=="RODBC"', the zip file is not getting downloaded as > am not able to access to the webpage since am working in a restricted > environment. > > I have some how managed to get the zip file, but I have no idea how to > install it into my system(Because on installing using "R Console", it > itself is getting unpacked and getting installed in a specific location) > > Can I just install by unzipping and placing the file in some random > location and connect R with SQL or is there any procedure to install the > package? > > Kindly help me install "R Packages" without the use of "R Console"(With the > use of zip file). > > Thanks in advance..!!! > -- > > Bhavani.P > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] write.xlsx- writing in a single sheet
Do you mean that you try to write several dataframes to the same sheet? You have asked this before, and I think it has been said that that is not possible with write.xls. I suppose that you still try to write rows of data of varying length to one sheet. I think that is possible with the lowlevel functions of xlsx (like createRow, createWorkbook), but not with write.xlsx. Read the documentation of xlsx for this. I have no experience with this. In addition to that: would you please stop sending messages in html? This has been asked to you before, and in general people are very irritated about this, and won't answer your questions. Frans 2016-01-15 15:43 GMT+01:00 Mohsen Jafarikia: > Hello all: > > I am having problem writing a few files in a single sheet of excel. It > seems R has problem writing on the same sheet. Maybe there is a command > that I am missing. Here is the code I am using: > > library(xlsx) > > ifn11 <- "A1.xlsx" > dat11 <- read.xlsx(ifn11, sheetName="A.csv", header = TRUE) > > ifn12 <- "A2.xlsx" > dat12 <- read.xlsx(ifn12, sheetName="A.csv", header = TRUE) > > ifn13 <- "A3.xlsx" > dat13 <- read.xlsx(ifn13, sheetName="A.csv", header = TRUE) > > ifn21 <- "F1.xlsx" > dat21 <- read.xlsx(ifn21, sheetName="F.csv",header = TRUE) > > ifn22 <- "F2.xlsx" > dat22 <- read.xlsx(ifn22, sheetName="F.csv",header = TRUE) > > ifn23 <- "F3.xlsx" > dat23 <- read.xlsx(ifn23, sheetName="F.csv",header = TRUE) > > write.xlsx(dat11, file="AC.xlsx", sheetName="A", append=FALSE) > write.xlsx(dat12, file="AC.xlsx", append= > TRUE) > write.xlsx(dat13, file="AC.xlsx", append= > TRUE) > write.xlsx(dat21, file="AC.xlsx", sheetName="F", append= TRUE) > write.xlsx(dat22, file="AC.xlsx", append= > TRUE) > write.xlsx(dat23, file="AC.xlsx", append= > TRUE) > > And here is the error message I am having: > > Error in .jcall(wb, "Lorg/apache/poi/ss/usermodel/Sheet;", "createSheet", > : > java.lang.IllegalArgumentException: The workbook already contains a sheet > of this name > > This error message comes after running the write.xlsx(dat13, > file="AC.xlsx", showNA=FALSE, row.names=FALSE, append= TRUE) line. Program > creates a sheet named "A" when writes dat11, then creates "sheet1" after > writing dat12 and when tries to write dat13, it gives me error. It seems it > tries to write on "sheet1" which already exists. I would like dat11, dat12 > and dat13 will be all written after each other on sheet "A" and dat12, > dat22 and dat23 in sheet "F". > > Anybody has any comments please. > > Regards, > Mohsen > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multiple CSV files in different sheets of an Excel file
Hi Mohse, You can do that with the append parameter of the write.xlsx routine in the xlsx package: xlsx::write.xlsx(file1,file='X.xlsx',sheetName = '1') xlsx::write.xlsx(file2,file='X.xlsx',sheetName = '2',append = T) Success! Frans 2016-01-13 15:18 GMT+01:00 Mohsen Jafarikia: > I have multiple CSV files that I would like to have them in a single Excel > file. For example, I have file1.csv and file2.csv and I want to have > file.xls where file1.csv and file2.csv each have been copied to a single > sheet of the file.xls file. > > Thanks, > Mohsen > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multiple CSV files in different sheets of an Excel file
Hi Mohsen, Just read them with read.csv or read.table (file1<-read.csv(file=.), and you can write them. Success! Frams 2016-01-13 15:47 GMT+01:00 Mohsen Jafarikia <jafari...@gmail.com>: > Thanks Frans, > > My files are CSV. If presume first I should convert them to Excel format > and run the code you have suggested. Am I right? > > Thanks again, > Mohsen > > > On Wed, Jan 13, 2016 at 9:44 AM, Frans Marcelissen < > fransiepansiekever...@gmail.com> wrote: > >> Hi Mohse, >> You can do that with the append parameter of the write.xlsx routine in >> the xlsx package: >> >> xlsx::write.xlsx(file1,file='X.xlsx',sheetName = '1') >> xlsx::write.xlsx(file2,file='X.xlsx',sheetName = '2',append = T) >> >> Success! >> Frans >> >> 2016-01-13 15:18 GMT+01:00 Mohsen Jafarikia <jafari...@gmail.com>: >> >>> I have multiple CSV files that I would like to have them in a single >>> Excel >>> file. For example, I have file1.csv and file2.csv and I want to have >>> file.xls where file1.csv and file2.csv each have been copied to a single >>> sheet of the file.xls file. >>> >>> Thanks, >>> Mohsen >>> >>> [[alternative HTML version deleted]] >>> >>> __ >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >>> >> >> > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reformatting dataframe for use with icc()
I think this is what reshape is made for... Frans -- rater.id <- c(1, 2, 1, 3, 2, 3) observation <- c(1, 1, 2, 2, 3, 3) rating <- c(6, 7, 4, 6, 2, 4) dat=data.frame(rater.id,observation,rating) library(reshape) dat2<-melt(dat, id.vars = c('rater.id','observation')) cast(dat2,observation~rater.id) observation 1 2 3 1 6 7 NA 2 4 NA 6 3 NA 2 4 2015-10-10 20:15 GMT+02:00 David L Carlson: > Don't post in html, the list scrambles your tables. Assuming your data > looks like this > > > rater.id <- c(1, 2, 1, 3, 2, 3) > > observation <- c(1, 1, 2, 2, 3, 3) > > rating <- c(6, 7, 4, 6, 2, 4) > > dat <- data.frame(rbind(rater.id, observation, rating)) > > dat > X1 X2 X3 X4 X5 X6 > rater.id 1 2 1 3 2 3 > observation 1 1 2 2 3 3 > rating 6 7 4 6 2 4 > > We need to transpose the data and then use xtabs(). This will work as long > as there is not more than one rating on an observation by the same rater: > > > t(dat) >rater.id observation rating > X11 1 6 > X22 1 7 > X31 2 4 > X43 2 6 > X52 3 2 > X63 3 4 > > > tbl <- xtabs(rating~observation+rater.id, t(dat)) > > tbl >rater.id > observation 1 2 3 > 1 6 7 0 > 2 4 0 6 > 3 0 2 4 > > If the 0's are a problem: > > > tbl[tbl==0] <- NA > > print(tbl, na.print=NA) >rater.id > observation123 > 167 > 24 6 > 3 24 > > > David L. Carlson > Department of Anthropology > Texas A University > > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Chad > Danyluck > Sent: Friday, October 9, 2015 4:02 PM > To: r-help@r-project.org > Subject: [R] Reformatting dataframe for use with icc() > > Hello, > > I want to determine the inter-rater reliability of ratings made from a > random selection of observers and observations. I plan to use the irr > package to calculate the ICC, however, my dataframe is not organized in a > way that the icc() function can handle. The icc() function works with > dataframes in the following format: > > rater1 rater2 rater3... > observation > 1 6 7 NA > 2 4NA 6 > 3 NA 2 4 > ... > > My dataframe is organized in the following format: > > rater.id 1 2 1 3 2 3 ... > observation 1 1 2 2 3 3 ... > rating 6 7 4 6 2 4 ... > > I would like to reformat my dataframe as it is organized in the first > example but I am not sure how to go about doing this. Any suggestions would > be appreciated. > > Kind regards, > > Chad > > -- > Chad M. Danyluck, MA > PhD Candidate, Psychology > University of Toronto > > > > “There is nothing either good or bad but thinking makes it so.” - William > Shakespeare > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Attaching a pdf file to an email generated with sendmailR?
Hi Michael, I don't know whether there is a particulal reason for using sendmailR, but I use mailR for this without any problem. mailR::send.mail(from, to, subject = "", body = "", encoding = "iso-8859-1", html = FALSE, inline = FALSE, smtp = list(), authenticate = FALSE, send = TRUE, attach.files = NULL, debug = FALSE, ...) If you use an external smtp server, enter login name and password in parameter smtp as follows: smtp = list(host.name = "smtp.X", port = X, user.name = "X", passwd = "X", ssl = X) 2015-10-08 18:49 GMT+02:00 Michael Ashton: > For some time I have been using sendmailR to generate a simple message > when a report was done running. > > Recently, I started adding a couple of pertinent statistics in the body of > the email. > > Now, I've finally decided that what the heck, I ought to simply attach the > report itself to the email. The report is generated as a pdf file. > > I can't seem to get this to work in any simple way with mime_part; if I > specify a path to the file it simply assumes that > "P:/blablabla/thefile.pdf" is a message I want to put in a text file > attachment. > > I assume I am doing something incorrectly and likely something simple. But > maybe there is a clever trick I am missing. My send line is simply: > > sendmail(from,to,subject,body,control=list(smtpServer="mail.optonline.net > ")) > > where body is something like this: > > body <- list("Here's your stupid file",mime_part(x="P:/partofpath/ > thefile.pdf",name="file.pdf")) > > Any suggestions are welcome! > > Thanks, > > Mike > > > This email and any attachments are confidential and in...{{dropped:13}} __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R, RStudio, and a server for my iPad.
Running rstudio (server) on an ipad. I do'nt have an ipad anymore, but some years ago I noticed that rstudio (server) worked fine on an ipad of you have a separate keyboard. It does not work with the virtual keyboard. The same is true with android tablets. Frans 2014-04-12 3:38 GMT+02:00 Roy Mendelssohn roy.mendelss...@noaa.gov: GIYF - Google VPN and iPad. -Roy On Apr 11, 2014, at 6:34 PM, John Sorkin jsor...@grecc.umaryland.edu wrote: David, Thank you for your assistance. I have, in fact been able to get things to work, at least when my iPad is on my local network. I had to do the following: (1) install Linux (I used linux Mint) on a computer on my LAN (2) install R on the linux box (accomplished using the Mint package manager) (3) install Rstudio and RStudio server on the linux box (accomplished using the Mint package manager) (4) obtain the linux computer's internal IP address (obtained using ifconfig command entered at a terminal). The internal IP address was 192.168.0.101 (5) use a browser on my iPad (I used google chrome, I believe firefox would also work) to connect to the linux box, requesting a connection using port 8787 In the brower I entered http://192.168.0.101:8787 This works like a charm; I can now control RStudio, which runs on the Linux box, by typing on my iPad. I thus gain access to RStudio on my iPad, RStudio works exactly as if it were running directly on my iPad, hooray! My remaining problem is to determine how I can gain access to the linux box from outside my LAN. I know the IP address of my cable router xx.xx.xx.xx (forgive me I am not listing my external IP address for security reasons), but I don't know how I can address the linux box from outside my LAN. Clearly I can't use 192.168.0.101 as it is an internal IP address, and I can't use the external IP address, xx.xx.xx.xx as it is the address of my cable box, not the address of the Linux box behind the cable modem. If I can figure how to address the linux box from outside my LAN my problem will be solved! If anyone can help me with this last problem I would be grateful. I know it is not strictly an R question, but in my case it is related to running R, at least on my iPad. John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) David Winsemius dwinsem...@comcast.net 4/11/2014 9:06 PM On Apr 11, 2014, at 2:00 PM, John Sorkin wrote: I bemoan the fact that I can not run R or Rstudio on my iPad. A possible work around would be to set up a server (probably under Linux), and get the server to present a web page that to would allow me to run R on the server. I fear that the response so far has been focussing on RStudio when the desire at its minimum was to run interactive R session on an iPad. Why not use an SSH client to connect to a machine that recognizes the security keys? https://itunes.apple.com/us/app/server-auditor-ssh-client/id549039908?mt=8 I think RServe could be the server end, but I do not know how graphics devices would be handled. Maybe just create pdfs on the server? Is there a sendfile function that an SSH client could receive and allow the iPad user to open? I think the stats-rosuda-devel mailing list might be the place to find experienced users of such techniques. -- David. I have searched the web for a clear, simple answer on how to do this but can not find one. There are answers, but not for someone who has not built a Linux server. Can someone provide either a reference to, or a short explanation of how I can build the server, get R or RStudio to run on it, and get the server and its R or RStudio program available to me on my iPad? I can probably find guidance on how to build an Apache server under Linux. Thank you, John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. __ R-help@r-project.org mailing list
Re: [R] Merge two vectors into one
Why not simply a-1:3 b-4:5 c(a,b) [1] 1 2 3 4 5 2014-03-22 23:22 GMT+01:00 Tham Tran hanhtham.t...@yahoo.com.vn: Dear R users, Given two vectors x and y a=1 2 3 b=4 5 6 i want to combine them into a single vector z as 1 4 2 5 3 6 Thanks for your help Tham -- View this message in context: http://r.789695.n4.nabble.com/Merge-two-vectors-into-one-tp4687361.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to add a line in the graph?
Hi, On itself one way of doing this is: lines(seq(-4,4,0.1),sapply(seq(-4,4,0.1),function(t)0.83*t-0.44*t^2)) The curve does not fit in the scale, however. Are you sure the formula is correct? Then you have to adapt the scale: plot.new() plot.window(xlim=c(-4,4), ylim=c(-10,16)) axis(1) axis(2) t--4:4 y-c(5,7,10,13,15,16,14,12,11) lines(t,y,type=l) lines(seq(-4,4,0.1),sapply(seq(-4,4,0.1),function(t)0.83*t-0.44*t^2)) ) 2013/12/15 æ°´éæµæ·± 1248283...@qq.com t--4:4 y-c(5,7,10,13,15,16,14,12,11) plot(t,y,type=l) how can i add a curve y=0.83*t-0.44*t^2 in the graph? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- --- dr F.H.G. (Frans) Marcelissen DigiPsy (www.DigiPsy.nl http://www.digipsy.nl/) Pomperschans 26 5595 AV Leende tel: 040 2065030/06 2325 06 53 skype adres: frans.marcelissen email: frans.marcelis...@digipsy.nl [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Replace NA's with value in the next row
R purists forbid the use of the for loop, but I am afraid this is the most simple solution: for (i in 1:(length(V6)-1)) if(is.na(V6[i])) V6[i]-V6[i+1] 2013/11/14 Jim Lemon j...@bitwrit.com.au On 11/14/2013 04:02 PM, dila radi wrote: Hi all, I have a data set which treat missing value as NA and now I need to replace all these NA's by using number in the same row but different column. Here is the part of my data: V1 V2 V3 V4 V5 V6 V7 0 0 0 1.2 0 0 0.259 0 0 12.8 0 23.7 0 8.495 6 0 81.7 0.2 0 20 19.937 0 1.5 60.9 0 0 15.5 13.900 1 13 56.8 17.5 32.8 6.4 27.654 4 3 66.4 2 0.3 NA 17.145 I want to replace (V6, 6) with (V7, 6). I have about 1000 NA's in V6 which I want to replace with the same row in V7. The other values in V6, I want to keep remain the same. How to achieve this? Assuming my data is called Targetstation, I have tried this: Targetstation- within(Targetstation, v6- replace(v6, is.na(v6), v7[ is.na (v6)])) But R gives me this: Warning messages: 1: In is.na(v6) : is.na() applied to non-(list or vector) of type 'NULL' 2: In is.na(v6) : is.na() applied to non-(list or vector) of type 'NULL' Hi Dila, You could do this like this: V6NA-is.na(Targetstation$V6) Targetstation$V6[V6NA]-Targetstation$V7[V6NA] but if you want to use the above, I think you will have to replace the is.na(V6) with is.na(Targetstation$V6) or use the method above. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/ posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- --- dr F.H.G. (Frans) Marcelissen DigiPsy (www.DigiPsy.nl http://www.digipsy.nl/) Pomperschans 26 5595 AV Leende tel: 040 2065030/06 2325 06 53 skype adres: frans.marcelissen email: frans.marcelis...@digipsy.nl [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] strange conversion char to date
Hi R-friends, Can anyone explain the following strange behavior to me? as.Date( 4/25/71,%m/%d/%y) [1] 1971-04-25 as.Date( 4/25/62,%m/%d/%y) [1] 2062-04-25 so 71 is converted to 1971, while 62 is converted to 2062? Does anyone know why? And is there a simple way to specify the date? (does works the same way in R 2.01 as well as in 1.9) --- dr F.H.G. (Frans) Marcelissen DigiPsy (www.DigiPsy.nl http://www.digipsy.nl/) Pomperschans 26 5595 AV Leende tel: 040 2065030/06 2325 06 53 skype adres: frans.marcelissen email: frans.marcelis...@digipsy.nl [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R 14.0, ggplot2: could not find function initRefFields
Hi, I have a problem combining R and SPSS (21). I do not know whether the solution is in R or in spss, so I will post both in the R group and in the SPSS group. I use the R plugin in spss(21). The most important reason to use this plugin is ggplot2 (spss does not have a decent graphical system). This plugin requires R 14.0 (14.2 or 15 does not work). When I install R it gives an warning: library(ggplot2) Warning message: package ggplot2 was built under R version 2.14.2 After that, when i use gplot2: ggplot()+geom_bar(aes(x=factor(1),y=10)) Error in initFields(scales = scales) : could not find function initRefFields I found on internet that the solution for this problem is upgrading to a newer version of R (and indeed, on 2.15 or 3.0 ggplot2 works fine). spss needs 2.14.0, however. Does anyone know a solution? Thanks Frans [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] exporting tables to word
Hi Allie, My preferred method is by means of odfWeave. Odfweave generates a libreoffice file, which can directly be transferred to word. A second way is run R from within spss. Spss has a much better output than R, but you can use the output system of spss (by means of spsspivottable.Display()) Frans 2013/4/2 Alexander Shenkin ashen...@ufl.edu Hello all, What is your preferred method to export tables (from ftable()) to Word? Do you just export to a text file and then copy/paste? Or perhaps via HTML output? Thanks, Allie __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 14.0, ggplot2: could not find function initRefFields
I agree that what I said was one sided. I know that the spss GPL and ggplot2 are based on the same grammar. I have the impression that ggplot2 is much easier to use. But I must agree that I stopped trying to understand gpl after discovering ggplot2. Frans 2013/4/2 J. R. M. Hosking jrmhosk...@gmail.com On 2013-04-02 04:28, Frans Marcelissen wrote: Hi, I have a problem combining R and SPSS (21). I do not know whether the solution is in R or in spss, so I will post both in the R group and in the SPSS group. I use the R plugin in spss(21). The most important reason to use this plugin is ggplot2 (spss does not have a decent graphical system). This Huh? IBM SPSS Statistics has a Graphics Production Language that its reference guide describes as a concise and flexible language based on the grammar described in [Leland Wilkinson's book] *The Grammar of Graphics*. ggplot2 is an implementation of the Grammar of Graphics. It seems likely that whatever you were hoping to achieve with ggplot2 can also be done natively in SPSS. J. R. M. Hosking plugin requires R 14.0 (14.2 or 15 does not work). When I install R it gives an warning: library(ggplot2) Warning message: package ggplot2 was built under R version 2.14.2 After that, when i use gplot2: ggplot()+geom_bar(aes(x=**factor(1),y=10)) Error in initFields(scales = scales) : could not find function initRefFields I found on internet that the solution for this problem is upgrading to a newer version of R (and indeed, on 2.15 or 3.0 ggplot2 works fine). spss needs 2.14.0, however. Does anyone know a solution? Thanks Frans [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- --- dr F.H.G. (Frans) Marcelissen DigiPsy (www.DigiPsy.nl http://www.digipsy.nl/) Pomperschans 26 5595 AV Leende tel: 040 2065030/06 2325 06 53 skype adres: frans.marcelissen email: frans.marcelis...@digipsy.nl [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Dealing with parentheses within variable names
Try sub([(],, names(dataFrams) and sub([)],, names(dataFrams) Frans 2013/2/28 Jesus Munoz Serrano jesusmunozserr...@gmail.com Dear all I'm having some problems with a data set that has parenthesis within the variable names. A example of this kind of variable names is the following: fBodyGyroskewness()Z The case is that R is having a lot of troubles to identify the variable (probably it does understand it like a function). I've tried (among other things) to remove the parenthesis from the name using the following command: names(dataFrame) - sub((),, names(dataFrame)) but It didn't work. Sorry if it's a silly issue but I would really appreciate if anybody could help me. Thank you very much. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Dealing with parentheses within variable names
Sorry: sub([(],, names(dataFrame) and sub([)],, names(dataFrame) Frans 2013/3/1 Frans Marcelissen fransiepansiekever...@gmail.com: Try sub([(],, names(dataFrams) and sub([)],, names(dataFrams) Frans 2013/2/28 Jesus Munoz Serrano jesusmunozserr...@gmail.com Dear all I'm having some problems with a data set that has parenthesis within the variable names. A example of this kind of variable names is the following: fBodyGyroskewness()Z The case is that R is having a lot of troubles to identify the variable (probably it does understand it like a function). I've tried (among other things) to remove the parenthesis from the name using the following command: names(dataFrame) - sub((),, names(dataFrame)) but It didn't work. Sorry if it's a silly issue but I would really appreciate if anybody could help me. Thank you very much. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to findout the name of a dataframe
Let'say we have a dataframe mydata with column v1. If mydata$v1 is passed to a function, is there way, then, to extract the name of the dataframe? What I now do is passing the name of the dataframe to the funcion, so passing two parameters. Maybe with mydata$v1 it is not possible, but with mydata['v1'] or mydata[,'v1'] it is? Thanks Frans --- Frans Marcelissen fransiepansiekever...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Test if mysql connection is alive
Hi fellows, I use RMySQL. I want to reconnect, if the connections is not alive anymore. if (!connected()) con-dbConnect(MySQL(),user=.., password=..,host=..,db=..) But how can I do the test connected()? I thought the way to do this was, connected()-function(){return (exists(con) isIdCurrent(con))} But that does'n work, after some time connected() returns TRUE, but the next dbGetQuery signals Error in mysqlExecStatement(conn, statement, ...) : RS-DBI driver: (could not run statement: MySQL server has gone away) How can I test if the connection is still valid? Thanks Frans __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with functions as arguments
Hi Ian, The remark of Rainer is correct, but I think the solution is very simpe: f1 = function(a) { b = a + 1 b } f2 = function(x, z) { y = x*z(x) -2 y } f2(x = 3, z = f1) [1] 10 Or are you intending something else? Best wishes, Frans -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Ian Renner Verzonden: dinsdag 12 februari 2013 8:30 Aan: r-help@r-project.org Onderwerp: [R] Help with functions as arguments Hi, I am trying to write a function which defines some arguments, then uses those arguments as arguments of other function calls. It's a bit tricky to explain, so a simple example will have to suffice. I imagine this has a simple solution, but perusing through environments and other help lists has not helped. Suppose I have two functions: f1 = function(a) { b = a + 1 b } f2 = function(x, z) { y = x*z -2 y } Where I am running into trouble is when I want to call function f1 within function f2: f2(x = 3, z = f1(x)) This returns the error: Error in f1(x) : object 'x' not found I'm not sure how to define environments within the functions so that the just-defined 'x' may be passed as an argument to f1 within f2. Any help would be greatly appreciated! Ian Renner [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R and SSH / exchange R objects between client and server
Hi Martin, In addition to what Duncan writes: I think winscp does exactly what you want. You can copy objects from/to linux, but also edit files from linux on the winduts machine without explicitly copying (of course you do copy the file, but is done automatically). Bye Frans --- dr F.H.G. (Frans) Marcelissen fransiepansiekever...@hotmail.com -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Duncan Murdoch Verzonden: dinsdag 1 januari 2013 21:39 Aan: Martin Batholdy CC: r-help@r-project.org Onderwerp: Re: [R] R and SSH / exchange R objects between client and server On 13-01-01 2:42 PM, Martin Batholdy wrote: Hi, I have a laptop (Mac OS) and a remote PC (Ubuntu) and would like to do the heavy work on the remote machine but control it via the laptop. I managed to install ssh server and can now remotely connect to my PC via ssh and can start an R session in the terminal. However, I still don't quite understand how I can now exchange R objects. I have the raw data I want to read and analyse on my laptop. So I need to read the files on the laptop and 'send' the r object to the remote PC. The remote PC should then do the heavy calculations and send back the result data frames, so that I can export/save the result tables on my laptop. Is this even possible with ssh (send R objects from client to server and vice versa)? Use save() and load() to create and read binary files containing the objects you want to exchange. Use scp to move them between systems. (Or sftp, or something else to move files.) Are there R packages who help to establish ssh connections? Not that I know of. You just use the command line utilities via system() or shell(). Can I also connect to the server via the R gui? Not with base R. There are some front ends written by others that do this, e.g. RStudio. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2: setting martin
Hi Ista, Your suggestion is not the solution I need. My problem is that in this way each plot gets another margin. I try to create a presentation with about 10 plots.The presentation does'nt look well if each plot has another marging. Is there way to set the margin manually? Frans -Oorspronkelijk bericht- Van: Ista Zahn [mailto:istaz...@gmail.com] Verzonden: zaterdag 22 december 2012 0:47 Aan: Frans Marcelissen CC: R-help@r-project.org Onderwerp: Re: [R] ggplot2: setting martin Well, the margin is being set large enough to accommodate the labels. So if you want narrower margins just shorten the labels: library(stringr) P + scale_x_discrete(labels = function(x) str_wrap(x, width=12)) HTH, Ista On Fri, Dec 21, 2012 at 5:35 PM, Frans Marcelissen frans.marcelis...@digipsy.nl wrote: Is it possible to set the margin in ggplot2 to a fixed size? I create many plots, and I want them to look the same. Especially I want them to have the same left margin. But P-ggplot()+geom_bar(aes(c(short label1,short label2),runif(2)))+coord_flip() P-creates a plot with another margin as ggplot()+geom_bar(aes(c(very very very very long label1,short label2),runif(2)))+coord_flip() In the standard plot system margins can be set with par(mar=c(...)), but this doesn't work in ggplot2 I thought I could do it with plot.margin, but p+theme(plot.margin= unit(c(0, 0, 0,3), cm)) doesn't work,it adds extra, external margins. Does anyone know a solution? Thanks Frans [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] setting the margin size in ggplot2
Is it possible to set the margin in ggplot to a fixed size? I create many plots, and I want them to look the same. Especially I want them to have the same left margin, with different labels. But P-ggplot()+geom_bar(aes(c(short label1,short label2),runif(2)))+coord_flip() creates a plot with another margin as P-ggplot()+geom_bar(aes(c(very very very very label1,short label2),runif(2)))+coord_flip() In the standard plot system margins can be set with par(mar=c(…….)), but this doesn’t work in ggplot2 I thought I could do it with plot.margin, but p+theme(plot.margin= unit(c(0, 0, 0,3), cm)) doesn’t work,it adds an extra, external margin. Does anyone know a solution? Thanks Frans __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot2: setting martin
Is it possible to set the margin in ggplot2 to a fixed size? I create many plots, and I want them to look the same. Especially I want them to have the same left margin. But P-ggplot()+geom_bar(aes(c(short label1,short label2),runif(2)))+coord_flip() P-creates a plot with another margin as ggplot()+geom_bar(aes(c(very very very very long label1,short label2),runif(2)))+coord_flip() In the standard plot system margins can be set with par(mar=c(...)), but this doesn't work in ggplot2 I thought I could do it with plot.margin, but p+theme(plot.margin= unit(c(0, 0, 0,3), cm)) doesn't work,it adds extra, external margins. Does anyone know a solution? Thanks Frans --- dr F.H.G. (Frans) Marcelissen DigiPsy ( http://www.digipsy.nl/ www.DigiPsy.nl) Pomperschans 26 5595 AV Leende tel: 040 7630487 (let op: nieuw nummer, oude nummer blijft actief) skype adres: frans.marcelissen email: mailto:frans.marcelis...@digipsy.nl frans.marcelis...@digipsy.nl [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] avoid - in specific case
I agree with this. But there is (in my opinion) a much more dangerous point: ab If there is an object called b in the function, it uses this b. But if you forgot to inialise b in the function, it looks in the global environment. So the following happens: b-100 a-b (if there is no b in the function, it uses b in the global environment. So a=100 b9 (writes to b in the local environment) Now b in the global environment is 100, while b in the function is 9 It would be more logical if a-b would give an error if b does not exist in the function (just like pascal does). --- Frans -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Duncan Murdoch Verzonden: vrijdag 5 oktober 2012 14:26 Aan: Berry Boessenkool CC: R Help Onderwerp: Re: [R] avoid - in specific case On 05/10/2012 8:19 AM, Berry Boessenkool wrote: Hi all, I improved a function drawing horizontal histograms (code below) which uses barplot and works fine. It does,however, need to assign a function to the global environment to later find the actual location on the vertical axis, and not the number of bars used by barplot. Hopefully, running the examples below will illustrate that. As said, it works perfectly fine and does exactly what I want. The problem arises now that I'm building a package (just for myself, for now) and run into R CMD check telling me 'no visible binding for '-' assignment'. (wording below) Similar problem as in http://r.789695.n4.nabble.com/R-CMD-check-tells-me-no-visible-binding- for-global-variable-what-does-it-mean-td1837236.html My question is: Is there a way to avoid assigning the function to the global environment with - but still have it available? I know it is generally not good practice. You can return the function as the value of your function. A bonus: if it is created within the body of your function, it will have access to all the local variables there. You shouldn't write to the global environment, because globalenv belongs to the user, not to you. If the user wants your function in the global environment s/he can just assign the value of your function to a variable there. Duncan Murdoch Or ist it OK in a case like this, and is there a way to avoid the notes from the rcmd check (make the function package-compatible)? Or should I just ignore these notes? (I'm completely new to building packages and cannot judge the importance yet.) I'd be very thankful for any hints! Berry PS: I recently read about barcharts in lattice, but by now I'm already used to my function. (And I learned a lot writing it a couple of years ago). # Function horiz.hist - function(Data, breaks=Sturges, col=transparent, las=1, ylim=range(HBreaks), labelat=pretty(ylim), labels=labelat, border=par(fg), ... ) {a - hist(Data, plot=FALSE, breaks=breaks) HBreaks - a$breaks HBreak1 - a$breaks[1] hpos - function(Pos) (Pos-HBreak1)*(length(HBreaks)-1)/ diff(range(HBreaks)) # Assign a function to the global environment with values calculated inside the main function. barplot(a$counts, space=0, horiz=T, ylim=hpos(ylim), col=col, border=border,...) axis(2, at=hpos(labelat), labels=labels, las=las, ...) print(use hpos() to address y-coordinates) } # Data and basic concept set.seed(8); ExampleData - rnorm(50,8,5)+5 hist(ExampleData) horiz.hist(ExampleData, xlab=absolute frequency) # Caution: the labels at the y-axis are not the real coordinates! # abline(h=2) will draw above the second bar, not at the label value 2. Use hpos: abline(h=hpos(11), col=2) # Further arguments horiz.hist(ExampleData, xlim=c(-8,20)) horiz.hist(ExampleData, main=the ... argument worked!, col.axis=3) hist(ExampleData, xlim=c(-10,40)) # with xlim horiz.hist(ExampleData, ylim=c(-10,40), border=red) # with ylim horiz.hist(ExampleData, breaks=20, col=orange) axis(2, hpos(0:10), labels=F, col=2) # another use of hpos() # One shortcoming: doesn't work with breakpoints provided as a vector with different widths of the bars Wording from the rcmd check when building a package: * checking R code for possible problems ... NOTE horiz.hist: no visible binding for '-' assignment to 'hpos' horiz.hist: no visible global function definition for 'hpos' [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __
Re: [R] Importing a CSV file
Hi, Should'nt it be A - read.csv(C:Users\\Anthi\\Desktop\\R\\A.csv, header=TRUE) (c:\\ becomes c:\ In general I think it is better to use / and //) Frans -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Sarah Goslee Verzonden: woensdag 19 september 2012 15:44 Aan: Anthi Oikonomou CC: r-h...@stat.math.ethz.ch Onderwerp: Re: [R] Importing a CSV file Hi, load() is for R's binary data files. You need to use read.csv(), as you tried, but probably with the complete path. A - read.csv(C:\\Users\\Anthi\\Desktop\\R\\A.csv, header=TRUE) Sarah On Wed, Sep 19, 2012 at 4:54 AM, Anthi Oikonomou anthi.oi...@gmail.com wrote: Hi, I am trying to import csv file in R console I have saved my data in a file on the desktop named R and here is my problematic script load(C:\\Users\\Anthi\\Desktop\\R\\A.csv) Error: bad restore file magic number (file may be corrupted) -- no data loaded In addition: Warning message: file 'A.csv' has magic number ';Abra' Use of save versions prior to 2 is deprecated when I don t load and I ask to read here is the answer A -read.csv(A.csv,header=TRUE) Error in file(file, rt) : cannot open the connection In addition: Warning message: In file(file, rt) : cannot open file 'A.csv': No such file or directory Do you know what should I do? Thank you in advance -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rstudio client on the i-pad
Hi, The combination of ipad+rstudio (server) would be a fantastic combination-if it worked. It _is_ possible to run rstudio in the safari browser of the ipad, but the keyboard doesn't work correctly (blanks are inserted after each character), making it almost impossible to use. Does anyone know a solution? Or know when a solution is ready? --- dr F.H.G. (Frans) Marcelissen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] odfWeave , UTF-8 locale and posix
Hello, I have a serious problem with odfWeave. I use odfWeave to produce on-line reports on a webserver. When the template file contains trema's (ë) or accents (é), odfWeave breaks with the unfamous error Unable to convert h.odt to the current locale. You may need to process this file in a UTF-8 locale I use a apache server under ubuntu. The output of the locale command on the webserver is LANG= LC_CTYPE=POSIX LC_NUMERIC=POSIX LC_TIME=POSIX LC_COLLATE=POSIX LC_MONETARY=POSIX LC_MESSAGES=POSIX LC_PAPER=POSIX LC_NAME=POSIX LC_ADDRESS=POSIX LC_TELEPHONE=POSIX LC_MEASUREMENT=POSIX LC_IDENTIFICATION=POSIX LC_ALL= Indeed, no UTF-8 Does anyone know how to change the locale to utf-8, under linux server? Thanks, Frans [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Running odfWeave on its own examples.odt
Hi, I had the same problem unde linux. My friend Albert Jan Roskam knew the solution: add Sys.setlocale(category = LC_ALL, locale = en_US.UTF-8) I suppose this also works under windows. Frans -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens John C Nash Verzonden: vrijdag 10 augustus 2012 15:16 Aan: Duncan Murdoch CC: r-help@r-project.org Onderwerp: Re: [R] Running odfWeave on its own examples.odt My bad. Should have included sessionInfo(). Here it is for the two virtual machines -- rebooting is a pain! Since Duncan found it worked for him, I suspect some configuration issue. I'm happy to off-list until it is resolved. I also see the locales, which are clearly NOT utf8, so maybe Cygwin let's me change them? JN WinXP: Professional, Version 2002, Service Pack 3 sessionInfo() R version 2.15.1 (2012-06-22) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] MASS_7.3-18odfWeave_0.8.1 XML_3.9-4.1lattice_0.20-6 loaded via a namespace (and not attached): [1] tools_2.15.1 Win7: (Professional, Service Pack 1) sessionInfo() R version 2.15.1 (2012-06-22) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] odfWeave_0.8.1 XML_3.9-4.1lattice_0.20-6 loaded via a namespace (and not attached): [1] grid_2.15.1 On 12-08-10 08:59 AM, Duncan Murdoch wrote: On 12-08-10 7:55 AM, John C Nash wrote: I'm trying to see if I can help some Windows users, but in WinXP and Win7 virtual machines and in a Win 7-64 real environment, after extracting the odfWeave examples.odt from the package and putting it in my working directory (My Documents) where R can see and unpack it, I get unable to convert 'examples.odt' to the current locale. I've tried some searches about UTF8 on Windows, which gave discouraging answers, and also the Sweave manual suggestions of different options(), e.g., I tried the suggestions regarding useFancyQuotes but without success. Things work fine (of course!) in Linux of different flavours, so I suspect this is a general Win issue, and I'm hopeful there is a simple workaround. The reproducible code is to source(tester.R) from R prompt or else Rscript tester.R where tester.R contains library(odfWeave) test-odfWeave(examples.odt, ex1out.odt) and this gives the same message unable to convert examples.odt in the current locale. For information, changing the file to simple.odt does work, at least on one of my systems. I just tried that in WinXP 32 bit, and it ran without problem. This was in R-patched, with odfWeave 0.8.1. Which versions were you using? Duncan Murdoch John Nash __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] variable (column) in a data frame
Hoi Pauli, There is a difference between two ways of accessing columns in a matrex: df$aaa NULL df[AAA] Error in `[.data.frame`(df, AAA) : undefined columns selected So df[AAA] or df[,AAA] gives the error message you expect. --- Frans -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Paulo Barata Verzonden: zondag 15 juli 2012 16:31 Aan: r-help@r-project.org Onderwerp: [R] variable (column) in a data frame To the R help list, When using a data frame, there is no warning or error message when I refer to a non-existent variable inside the data frame. Example: ##-- a - c(1,2,3) b - c(11,22,33) df - data.frame(a,b) df ## correct: there is a column in df named 'a' ## the sum is correctly performed sum(df$a==2) ## incorrect: there is no column in df named 'aaa', ## but the sum is performed anyway without either warning or error sum(df$aaa==2) ##-- Is there some way to make R issue either a warning or an error message in such a situation? I am using R version 2.15.1 64-bit on Windows 7 Professional. Thank you very much. Paulo Barata - Paulo Barata ENSP - Fundação Oswaldo Cruz Rua Leopoldo Bulhões 1480 - 8A 21041-210 Rio de Janeiro - RJ Brazil E-mail: paulo.bar...@ensp.fiocruz.br __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Pass parameter to odfWeave
OdfWeave is a great way of creating reports and other quality output from R. But is there a simple way to pass a parameter to the report? What I mean is: odfWeave(templatefile,outputfile) creates the report. If would be much more flexible if it would be possible to do something like odfWeave(templatefile,outputfile, versionnumber) to pass versionnumber to the templatefile, or even odfWeave(templatefile,outputfile,parameterfile) to pass the name of a file where other variables are stored. Is something like this possible? The only way I see is store parameters in a file that is read in templatefile.Thank for any suggestionsFrans [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] odfWeave, xtable and tex
Hello, I try to use xtable under odfWeave. With echo=FALSE,results=xml= library(xtable) xtable(iris) @ this results in an endless list of xmlParseEntityRef: no name On internet I find that results should be tex: echo=FALSE,results=tex= However, now the result is: 'arg' should be one of verbatim, xml, hide I tried this on windows and on linux, with the same results. Does anyone know what to doe? Thanks Frans [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Print-quality output from R: some questions about R2wd
Hi,My major problem with R was always the quality of the output. Recently I found R2wd, which solved this problem. R2wd makes it possible to write output directly to a word file, end to produce high-quality tables.I have two problems with R2wd, however.1. The documentation says it is possible to open an existing doc file in R2wd (wdGet(filename=hoepedepoep.doc)). This does not work (Error in if (!(tmp[[ActiveDocument]][[Name]] == filename)) tmp$Open(paste(path, : argument is of length zero).Does anyone know what could be wrong?2. R2wd uses rcomm. After starting R2wd in the standard (windows) interface, the help system of R does not work freezes. Within rstudio this problem does not occur. If anyone could help me: thanksFrans [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cannot install Rcmdr on ubuntu 11.4
Hello, For one reason or another, I cannot install Rcmdr on my R 2.12.2 ubuntu 11.4 system. I run R as root When I try to install Rcmdr, then whatever mirror I select, I get the message: install.packages('Rcmdr',dependencies=TRUE) Installing package(s) into /usr/local/lib/R/site-library (as lib is unspecified) --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done Warning message: In getDependencies(pkgs, dependencies, available, lib) : package Rcmdr is not available Installing other packages works fine. Does anyone have any idea which stupid mistake I make? I have also installed the server version of Rstudio, I do not think this does have anything to doe with this? Thanks Frans Marcelissen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] keys in score.items in package psych
Hi Ruru's, score.items in package psych is very handy for scoring test items. It has the structure score.items(keys,items). For instance: score.items(c(1,1,1),data.frame(a1=rep(1,5),a2=rep(1,5),a3=rep(1,5)))$scores correctly gives 1 on each case. But if key -1,0,1 the following happens score.items(c(0.1,0.1,0.1),data.frame(a1=rep(1,5),a2=rep(1,5),a3=rep(1,5)))$scores gives 10 on each case. It appears that the inverse of key is the relative weight of that item. My questions: is this correct? Is this an undocumented feature? Can i trust on it? Frans [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.