Re: [R] Help with read.csv.sql()
On 07/30/2020 06:09 PM, Gabor Grothendieck wrote: > Probably simplest to assign the names afterwards as others have > suggested but it could be done like this: > > library(sqldf) > write.csv(BOD, "BOD.csv", quote = FALSE, row.names = FALSE) # test data > > read.csv.sql("BOD.csv", "select Time as Time2, demand as demand2 from file") > > giving the column names Time2 and demand2 rather than the original column > names. > > Time2 demand2 > 1 1 8.3 > 2 210.3 > 3 319.0 > 4 416.0 > 5 515.6 > 6 719.8 > > On Fri, Jul 17, 2020 at 9:28 PM H wrote: >> I have created a dataframe with columns that are characters, integers and >> numeric and with column names assigned by me. I am using read.csv.sql() to >> read portions of a number of large csv files into this dataframe, each csv >> file having a header row with columb names. >> >> The problem I am having is that the csv files have header rows with column >> names that are slightly different from the column names I have assigned in >> the dataframe and it seems that when I read the csv data into the dataframe, >> the column names from the csv file replace the column names I chose when >> creating the dataframe. >> >> I have been unable to figure out if it is possible to assign column names of >> my choosing in the read.csv.sql() function? I have tried various variations >> but none seem to work. I tried colClasses = c() but that did not work, I >> tried field.types = c(...) but could not get that to work either. >> >> It seems that the above should be feasible but I am missing something? Does >> anyone know? >> >> A secondary issue is that the csv files have a column with a date in >> mm/dd/ format that I would like to make into a Date type column in my >> dataframe. Again, I have been unable to find a way - if at all possible - to >> force a conversion into a Date format when importing into the dataframe. The >> best I have so far is to import is a character column and then use as.Date() >> to later force the conversion of the dataframe column. >> >> Is it possible to do this when importing using read.csv.sql()? >> >> __ >> 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. > > Apologies, I had tuned out from this discussion since I solved the problem by renaming the columns after reading the file. Your suggestion to do it in the SQL statement itself, however, seems to be neatest one though! Thank you. __ 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] Help with read.csv.sql()
Probably simplest to assign the names afterwards as others have suggested but it could be done like this: library(sqldf) write.csv(BOD, "BOD.csv", quote = FALSE, row.names = FALSE) # test data read.csv.sql("BOD.csv", "select Time as Time2, demand as demand2 from file") giving the column names Time2 and demand2 rather than the original column names. Time2 demand2 1 1 8.3 2 210.3 3 319.0 4 416.0 5 515.6 6 719.8 On Fri, Jul 17, 2020 at 9:28 PM H wrote: > > I have created a dataframe with columns that are characters, integers and > numeric and with column names assigned by me. I am using read.csv.sql() to > read portions of a number of large csv files into this dataframe, each csv > file having a header row with columb names. > > The problem I am having is that the csv files have header rows with column > names that are slightly different from the column names I have assigned in > the dataframe and it seems that when I read the csv data into the dataframe, > the column names from the csv file replace the column names I chose when > creating the dataframe. > > I have been unable to figure out if it is possible to assign column names of > my choosing in the read.csv.sql() function? I have tried various variations > but none seem to work. I tried colClasses = c() but that did not work, I > tried field.types = c(...) but could not get that to work either. > > It seems that the above should be feasible but I am missing something? Does > anyone know? > > A secondary issue is that the csv files have a column with a date in > mm/dd/ format that I would like to make into a Date type column in my > dataframe. Again, I have been unable to find a way - if at all possible - to > force a conversion into a Date format when importing into the dataframe. The > best I have so far is to import is a character column and then use as.Date() > to later force the conversion of the dataframe column. > > Is it possible to do this when importing using read.csv.sql()? > > __ > 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. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ 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] How to generate this type of scatter plots in R
This looks like a beeswarm plot - using package beeswarm or (for ggplot users) ggbeeswarm. Paul On Thu, 23 Jul 2020 at 05:31, Jim Lemon wrote: > > Hi John, > Perhaps "dendroPlot" in the plotrix package? > > JIm > > On Thu, Jul 23, 2020 at 11:00 AM array chip via R-help > wrote: > > > > > > Hello everyone, > > > > I saw this scatterplots from a paper and thought it looked very nice: > > > > https://drive.google.com/file/d/1V7F1gq-J_GIFDOrJs00hwGyXUqCZ_xwa/view?usp=sharing > > > > It was similar to stripchart() with 'jitter' method, but it has a special > > pattern of aligning points which made it look nicer than standard > > stripchart(). > > > > Does anyone know if there is a package in R that can do this kind of plots? > > > > Thanks, > > > > John > > > > __ > > 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. __ 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] adding new level with new values and transpose the dataframe
On 2020-07-30 18:07 +0300, Engin Yılmaz wrote: | El jueves, 30 de julio de 2020, Rasmus Liland escribió: | | On 2020-07-30 21:13 +1000, Jim Lemon wrote: | | | On Thu, Jul 30, 2020 at 8:33 PM Engin Yılmaz wrote: | | | | | | | | I have 3 different factors for every | | | | month in my dataframe.The column of | | | | classification description has 3 | | | | factors. | | | | | | | | Question 1: | | | | I need to add a new factor to the | | | | column of classification description | | | | but this *will be a summation* of | | | | other 3 factors in every month. How | | | | can I realize this? | | | | | | Hi Engin, | | | If you know what all the levels are, | | | you can specify these in the format | | | command: | | | | | | Classification_Description<-factor(Classification_Description, | | | levels=c("Total Surplus (+) or Deficit (-)","Borrowing from the Public", | | | "By other means")) | | | | | | This ensures that all the levels are | | | encoded even if one or more levels is | | | missing in the incoming data. | | | | ... and you can add a new/change | | the order of the levels later on | | using levels() like this: | | | | levels(engin[,"Classification Description"]) <- | | c(levels(engin[,"Classification Description"]), | | "New level") | | | | | | Question 2: | | | | How can I transpose my dataframe as | | | | the following ? | | | | This is the same as the first example in | | ?reshape on Indometh long to wide. | | | | reshape(data=engin, | | v.names="Current Month Budget Amount", | | idvar="Record Date", | | timevar="Classification Description", | | direction="wide") | | Dear liland | | 1-new level *will be a summation* of | other 3 factors in every month? Oh, you mean setting a group of levels to the same level, right? Well, you could select them using match, like in the other mail thread: idx <- levels(engin[,"Classification Description"]) %in% c("Borrowing from the Public", "Some other outrageous source of income") levels(engin[,"Classification Description"])[idx] <- "By Other Means" Got some errors, thus did some “reading”[1], perhaps it is useful in this case to use reshape2 instead of the regular reshape to do the summation: my_func <- function(x) { paste0(deparse(x), collapse="") } engin[,"Current Month Budget Amount"] <- as.numeric(gsub(",", "", engin[,"Current Month Budget Amount"])) engin.melt <- reshape2::melt(engin, id.vars= c("Record Date", "Classification Description")) colnames(engin.melt)[1:2] <- c("date", "class") reshape2::dcast( data=engin.melt, formula=date~class+., value.var="value", fun.aggregate=my_func) reshape2::dcast( data=engin.melt, formula=date~class+., value.var="value", fun.aggregate=sum) | 2-For your transpose approach, I have | a 200 rows 200 “Record Date” rows or? Please explain. Best, Rasmus [1] https://stackoverflow.com/questions/20795290/why-is-it-returning-a-warning-when-reshaping-in-r P.S. adding this into the list again ... signature.asc Description: PGP signature __ 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] How to create a readable plot in R with 10000+ values in a dataframe
Hi All, Thanks for all the suggestions and help.I have gone for simpler plots with lesser values for demonstration now which served the purpose. Regards, Ritwik On Thu, 30 Jul, 2020, 22:00 Dr Eberhard Lisse, wrote: > I always find two things helpful > > 1) RTFM > > 2) Asking myself what information do I want to convey >before thinking about how to do that. > > From the below I can not understand what you want to tell > your audience. > > I don't think it's helpful trying to read 17298 names on a > plot so maybe show the counts by region, perhaps with another > grouping. > > From the data sample in another post, one could maybe group/count > count the host(names) and them plot it on a worldmap with a colour > scale showing the numbers. > > > el > > On 2020-07-23 20:11 , Ritwik Mohapatra wrote: > > How to create a readable and legible plot in R with 10k+ values.I have a > > dataframe with 17298 records.There are two columns:Machine > Name(Character) > > and Region(Character).So i want to create a readable plot with region in > x > > axis and machine name in y axis.How do i do that using ggplot or any > other > > way.Please help. > > > > [[alternative HTML version deleted]] > > > > > -- > If you want to email me, replace nospam with el > > __ > 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] How to create a readable plot in R with 10000+ values in a dataframe
I always find two things helpful 1) RTFM 2) Asking myself what information do I want to convey before thinking about how to do that. >From the below I can not understand what you want to tell your audience. I don't think it's helpful trying to read 17298 names on a plot so maybe show the counts by region, perhaps with another grouping. >From the data sample in another post, one could maybe group/count count the host(names) and them plot it on a worldmap with a colour scale showing the numbers. el On 2020-07-23 20:11 , Ritwik Mohapatra wrote: > How to create a readable and legible plot in R with 10k+ values.I have a > dataframe with 17298 records.There are two columns:Machine Name(Character) > and Region(Character).So i want to create a readable plot with region in x > axis and machine name in y axis.How do i do that using ggplot or any other > way.Please help. > > [[alternative HTML version deleted]] > -- If you want to email me, replace nospam with el __ 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] Accessing the C++ source associated with the rgl function shade3d
Duncan writes: >> " ... If you're using RStudio, a really convenient way to view the source >> ..." This is fantastic! Thank you for this Duncan. On Thu, Jul 30, 2020 at 3:45 PM Duncan Murdoch wrote: > > On 29/07/2020 6:34 p.m., Jeff Newmiller wrote: > > To begin with, don't assume it is in C++... R supports multiple compiled > > languages, and rgl appears to have both C++ and C in it. > > Also a few thousand lines of Javascript, but in this case, the > interesting code is all in R. > > > > > I googled "r rgl github" and found an online copy of the src (source) files > > right away. The official way is to find the CRAN package page and download > > the tar.gz file and extract the files. Either way, you get the whole > > package source code this way. > > If you're using RStudio, a really convenient way to view the source for > a package whose source is on Github (maybe the majority of packages > these days?) is to create a new project from it. Then you can use the > built-in search functions to jump to the source of any function. > > For rgl, you can get a copy of the Github mirror of the source by > specifying the "Repository URL" as "https://github.com/rforge/rgl";, and > the "Project directory name" as "pkg/rgl". (The source is hosted in > Subversion on R-forge.r-project.org, but Subversion is less familiar to > most people these days and R-forge is pretty old-fashioned, so I'd go > with Github instead. There are some irritating things about Github.) > > Once you've got it in RStudio, you can type "shade3d" in the "Go to > file/function" box, and it will offer the generic as well as the two > methods shade3d.mesh3d and shade3d.shapelist3d. > > This kind of search is probably also possible in other front ends (ESS > etc.), and some purists probably know how to set it all up in command > line BSD Unix, but I don't. > > Duncan Murdoch > > > I am afraid I don't have time to dig into the source to identify which file > > you need. Keeping in mind that the rgl package is an interface to lower > > level code, beware that you may need to leave the R code to find what you > > are looking for... in which case you would be dealing with a different code > > base and community of coders. > > > > On July 29, 2020 2:35:33 PM PDT, Byron Dom via R-help > > wrote: > >> How can I access the C++ source associated with the rgl function > >> shade3d. More specifically, I'm interested in the part of the code used > >> by arrow3d to draw arrow heads. > >> > >> I'm not familiar with how GitHub is organized and I've put in a lot of > >> effort doing searches there and on the web in general. The result has > >> been a few fragments of rgl C++ code but not what I'm looking for. > >> > >> > >> [[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. __ 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] adding new level with new values and transpose the dataframe
Hi Engin, On 2020-07-30 21:13 +1000, Jim Lemon wrote: | On Thu, Jul 30, 2020 at 8:33 PM Engin Yılmaz wrote: | | | | I have 3 different factors for every | | month in my dataframe.The column of | | classification description has 3 | | factors. | | | | Question 1: | | I need to add a new factor to the | | column of classification description | | but this *will be a summation* of | | other 3 factors in every month. How | | can I realize this? | | Hi Engin, | If you know what all the levels are, | you can specify these in the format | command: | | Classification_Description<-factor(Classification_Description, | levels=c("Total Surplus (+) or Deficit (-)","Borrowing from the Public", | "By other means")) | | This ensures that all the levels are | encoded even if one or more levels is | missing in the incoming data. ... and you can add a new/change the order of the levels later on using levels() like this: levels(engin[,"Classification Description"]) <- c(levels(engin[,"Classification Description"]), "New level") | | Question 2: | | How can I transpose my dataframe as | | the following ? This is the same as the first example in ?reshape on Indometh long to wide. reshape(data=engin, v.names="Current Month Budget Amount", idvar="Record Date", timevar="Classification Description", direction="wide") P.S. dput() is such a great function for pasting data in emails like this: engin <- structure(list( `Record Date` = c("2020-06-30", "2020-06-30", "2020-06-30", "2020-05-31", "2020-05-31", "2020-05-31"), `Classification Description` = structure(c(3L, 1L, 2L, 1L, 2L, 3L), .Label = c("Borrowing from the Public", "By Other Means", "Total Surplus (+) or Deficit (-)"), class = "factor"), `Current Month Budget Amount` = c("-864,074,068,492", "716,272,172,707", "420,704,500,379", "759,987,728,236", "-92,071,767,771", "-398,821,413,660")), row.names = c(NA, -6L), class = "data.frame") Rasmus signature.asc Description: PGP signature __ 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] Accessing the C++ source associated with the rgl function shade3d
On 29/07/2020 6:34 p.m., Jeff Newmiller wrote: To begin with, don't assume it is in C++... R supports multiple compiled languages, and rgl appears to have both C++ and C in it. Also a few thousand lines of Javascript, but in this case, the interesting code is all in R. I googled "r rgl github" and found an online copy of the src (source) files right away. The official way is to find the CRAN package page and download the tar.gz file and extract the files. Either way, you get the whole package source code this way. If you're using RStudio, a really convenient way to view the source for a package whose source is on Github (maybe the majority of packages these days?) is to create a new project from it. Then you can use the built-in search functions to jump to the source of any function. For rgl, you can get a copy of the Github mirror of the source by specifying the "Repository URL" as "https://github.com/rforge/rgl";, and the "Project directory name" as "pkg/rgl". (The source is hosted in Subversion on R-forge.r-project.org, but Subversion is less familiar to most people these days and R-forge is pretty old-fashioned, so I'd go with Github instead. There are some irritating things about Github.) Once you've got it in RStudio, you can type "shade3d" in the "Go to file/function" box, and it will offer the generic as well as the two methods shade3d.mesh3d and shade3d.shapelist3d. This kind of search is probably also possible in other front ends (ESS etc.), and some purists probably know how to set it all up in command line BSD Unix, but I don't. Duncan Murdoch I am afraid I don't have time to dig into the source to identify which file you need. Keeping in mind that the rgl package is an interface to lower level code, beware that you may need to leave the R code to find what you are looking for... in which case you would be dealing with a different code base and community of coders. On July 29, 2020 2:35:33 PM PDT, Byron Dom via R-help wrote: How can I access the C++ source associated with the rgl function shade3d. More specifically, I'm interested in the part of the code used by arrow3d to draw arrow heads. I'm not familiar with how GitHub is organized and I've put in a lot of effort doing searches there and on the web in general. The result has been a few fragments of rgl C++ code but not what I'm looking for. [[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.
Re: [R] Accessing the C++ source associated with the rgl function shade3d
On 2020-07-30 05:23 -0400, Duncan Murdoch wrote: > On 29/07/2020 7:27 p.m., Rasmus Liland wrote: > > On 2020-07-29 18:04 -0400, Duncan Murdoch wrote: > > > The arrow3d function is also a pure R > > > function, but not a generic. You can > > > see the source by typing "arrow3d". > > > > ... but if I type rgl::shade3d, I get > > > > > rgl::shade3d > > function (x, ...) > > UseMethod("shade3d") > > > > > > That includes the full source code to > shade3d. Like most generic functions, > it's a one-liner. > > In the part of my post that you > deleted, I told the OP where to look > next. This part: > > > type "rgl:::shade3d.mesh3d" and you > > > can see the full source. Three colons. I didn't see it at first; Hmm ... I might have dyslexia or something ... So, Byron, this is the code that R reinterprets from the source, Rscript -e 'rgl:::arrow3d' | less Rscript -e 'rgl:::shade3d.mesh3d' | less so you cannot necessarily grab a line from there and expect it to look exactly the same in the source files. rasmus@beefylinuxbox ~ % grep -R 'paste(allowedMeshColor,' src/rgl src/rgl/R/mesh3d.R:stop("'meshColor' must be one of: ", paste(allowedMeshColor, collapse = ", ")) rasmus@beefylinuxbox ~ % grep -R 'pi - pi/nbarbs,' src/rgl 1 rasmus@beefylinuxbox ~ % grep -R 'pi/nbarbs,' src/rgl src/rgl/R/arrow3d.R: phi <- seq(pi/nbarbs, 2*pi-pi/nbarbs, len = nbarbs) rasmus@beefylinuxbox ~ % > > https://github.com/cran/rgl/blob/master/R/ashape3d.R > > No, that's not it. That file works > with mesh3d objects, but it has > nothing to do with arrows. ... I'm sorry, now I believe rgl::shade3d.mesh3d and rgl::arrow3d lives in https://github.com/cran/rgl/blob/master/R/mesh3d.R and https://github.com/cran/rgl/blob/master/R/arrow3d.R respectively. Byron, there's a bunch of .cpp and .h files in https://github.com/cran/rgl/blob/master/src you can look at to find the triangle or quadrilateral code you're interested in, I'm not quite sure what to look for there. Best, Rasmus __ 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] adding new level with new values and transpose the dataframe
Hi Engin, If you know what all the levels are, you can specify these in the format command: Classification_Description<-factor(Classification_Description, levels=c("Total Surplus (+) or Deficit (-)","Borrowing from the Public", "By other means")) This ensures that all the levels are encoded even if one or more levels is missing in the incoming data. Jim On Thu, Jul 30, 2020 at 8:33 PM Engin Yılmaz wrote: > > * Record Date* > > *Classification Description* > > *Current Month Budget Amount* > > > > 2020-06-30 > > Total Surplus (+) or Deficit (-) > > -864,074,068,492 > > > > 2020-06-30 > > Borrowing from the Public > > 716,272,172,707 > > > > 2020-06-30 > > By Other Means > > 420,704,500,379 > > > > 2020-05-31 > > Borrowing from the Public > > 759,987,728,236 > > > > 2020-05-31 > > By Other Means > > -92,071,767,771 > > > > 2020-05-31 > > Total Surplus (+) or Deficit (-) > > -398,821,413,660 > > Dear > > I have a 2 questions > > I have 3 different factors for every month in my dataframe.The column > of classification description has 3 factors. > > Question 1: > I need to add a new factor to the column of classification description but > this *will be a summation* of other 3 factors in every month. How can I > realize this? > > Question 2: > How can I transpose my dataframe as the following ? > > > > Total Surplus (+) or Deficit (-) > > Borrowing from the Public > > By Other Means > > 2020-06-30 > > -864,074,068,492 > > > > > > 716,272,172,707 > > > > 420,704,500,379 > > 2020-05-31 > > 759,987,728,236 > > > > > > -92,071,767,771 > > > > -398,821,413,660 > > Sincerely > Engin YILMAZ > > [[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.
Re: [R] How to create a readable plot in R with 10000+ values in a dataframe
Hi Ritwik, Carlos made an excellent suggestion and there are at least two ways to plot "machine" and "region" as the cells in a 2D matrix and then add two more variables (say count and price) as the attributes of each cell. Is the data you are using publicly available? If so a demonstration of this would not be difficult to program. Jim On Fri, Jul 24, 2020 at 9:55 PM Ritwik Mohapatra wrote: > > How to create a readable and legible plot in R with 10k+ values.I have a > dataframe with 17298 records.There are two columns:Machine Name(Character) > and Region(Character).So i want to create a readable plot with region in x > axis and machine name in y axis.How do i do that using ggplot or any other > way.Please help. > > [[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.
[R] adding new level with new values and transpose the dataframe
* Record Date* *Classification Description* *Current Month Budget Amount* 2020-06-30 Total Surplus (+) or Deficit (-) -864,074,068,492 2020-06-30 Borrowing from the Public 716,272,172,707 2020-06-30 By Other Means 420,704,500,379 2020-05-31 Borrowing from the Public 759,987,728,236 2020-05-31 By Other Means -92,071,767,771 2020-05-31 Total Surplus (+) or Deficit (-) -398,821,413,660 Dear I have a 2 questions I have 3 different factors for every month in my dataframe.The column of classification description has 3 factors. Question 1: I need to add a new factor to the column of classification description but this *will be a summation* of other 3 factors in every month. How can I realize this? Question 2: How can I transpose my dataframe as the following ? Total Surplus (+) or Deficit (-) Borrowing from the Public By Other Means 2020-06-30 -864,074,068,492 716,272,172,707 420,704,500,379 2020-05-31 759,987,728,236 -92,071,767,771 -398,821,413,660 Sincerely Engin YILMAZ [[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] Accessing the C++ source associated with the rgl function shade3d
On 29/07/2020 7:27 p.m., Rasmus Liland wrote: Dear Byron, On 2020-07-29 18:04 -0400, Duncan Murdoch wrote: The arrow3d function is also a pure R function, but not a generic. You can see the source by typing "arrow3d". ... but if I type rgl::shade3d, I get > rgl::shade3d function (x, ...) UseMethod("shade3d") That includes the full source code to shade3d. Like most generic functions, it's a one-liner. In the part of my post that you deleted, I told the OP where to look next. > dput(rgl::shade3d) function (x, ...) UseMethod("shade3d") I've observed this is possible in the past, but now I can't remember how ... On 2020-07-29 15:34 -0700, Jeff Newmiller wrote: On July 29, 2020 2:35:33 PM PDT, Byron Dom wrote: I'm not familiar with how GitHub is organized The official way is to find the CRAN package page and download the tar.gz file and extract the files. Either way, you get the whole package source code this way. I have a hunch this is the file you're looking for https://github.com/cran/rgl/blob/master/R/ashape3d.R No, that's not it. That file works with mesh3d objects, but it has nothing to do with arrows. Duncan Murdoch Remember, dealing with code on github is just a small uptick from how Linux was developed before, by shipping around diffs and tarballs on a mailing list much similar to this one, Thorvalds merging them into the kernel in the authoritarian way. You can do it! *cheers* Best, Rasmus [1] http://gameoftrees.org/ __ 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 Subset by Factor levels
I solve this as follows m2 <- subset(m1,`Classification Description`=="Borrowing from the Public" | `Classification Description`=="By Other Means" | `Classification Description`=="Total Surplus (+) or Deficit (-)") sincerely Engin YILMAZ Engin Yılmaz , 29 Tem 2020 Çar, 16:57 tarihinde şunu yazdı: > Dear > > I try to create a new subset from my dataframe. > My dataframe's name is m1. > "Classification Description" column has 15 different factors. > The following code is used creating a subset for 1 factor. > m2<-m1[m1$`Classification Description` == levels(m1$`Classification > Description`)[1],] > > My aim is to create a subset with 4 different factors. For example, > levels(m1$`Classification Description`)[1] > levels(m1$`Classification Description`)[15] > levels(m1$`Classification Description`)[2] > levels(m1$`Classification Description`)[4] > > I try to following code but it didnt work > > m2<-m1[m1$`Classification Description` == levels(m1$`Classification > Description`)[c(1,15,2,4],] > > How can I solve This Problem ? > > Example from my dataframe > > `Record Date` `Classification Description` `Current Month > Budget Amount` > > > 1 2019-06-30Total On-Budget and Off-Budget Results: > NA > 2 2019-06-30Off-Budget Surplus (+) or Deficit (-) > 41998597035. > 3 2019-06-30Total Outlays > 342428650968. > 4 2019-06-30By Other Means > 51648504883. > 5 2019-06-30On-Budget Outlays > 292169836521. > 6 2019-06-30Off-Budget Outlays > 50258814447. > 7 2019-06-30Total Receipts > 333952332514. > 8 2019-06-30On-Budget Surplus (+) or Deficit (-) > -50474915489. > 9 2019-06-30Off-Budget Receipts > 92257411482 > 10 2019-06-30Total On-Budget and Off-Budget Financing > 8476318454 > > > > -- > *Saygılarımla* > Engin YILMAZ > -- *Saygılarımla* Engin YILMAZ [[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.