R monthly plot with GGPlot2 in RMarkdown - r

I have a CSV file with the following data:
RegistrationDate;User_Id;Items
RegistrationDate has format like '22.05.2014 14:25'
Is there any easy way to connect CSV data to R markdown script? All of examples I've seen use random generated data, that looks too bad for reproducible research.
I need to create 2 plots with ggplot2:
a plot of users count per month.
a plot of items collected per month
I've checked a lot of graphs looks close to this one, but didn't find any right version. Looks like I don't understand something about R plotting :(.

What do you mean when you say "connect" CSV data to R markdown sript?
You mean reading them?
data <- read.csv("directory/name.csv", sep=";")
Or you mean adding somewhere a specific relation, telling that this data is related to this analysis? If the second, you can check the archivist package, stored on GitHub, that possess a set of tools for datasets and figures archivisation. There is a information how to install that package.
In question 2, you will need an extra column that specifies the month.

Related

How to load a xls or csv data file to work with the rugarch and rmgarch packages in R

I am new to R and have just started to use it. I am currently experimenting with the quantmod, rugarch and rmgarch packages.
In particular, I'm implementing the last package to make a multivariate portfolio analysis for the case of the european markets. In this sense, I need to download the 3-month german treasury bills, in order to use them as risk free rate. However, as far as I known, I canĀ“t download the the mentioned data serie from Yahoo, Google or FDRA databases, so I have already downloaded them from investing.com and I want to load them in R.
The fact here is, my data is different from the ones downloaded by the getsymbols () function of yahoo, because in this case I only have 2 columns, the date column and the closing price column. To sump up, the question arises here is, is there any way to load this type of data in R for rmgarch purposes??
thanks in advance
Not sure if this is the issue, but this is how you might go about getting the data from a csv file.
data <- read.csv(file="file/path/data.csv")
head(data) # Take a look at your data
# Do this if you want the data only replacing ColumnName with the proper name
data_only <- data$ColumnName
It looks like the input data for rugarch needs to be an xts vector. So, you might want to take a look at this. You might also want to take a look at ?read.csv.

Extracting and importing untidy Excel tables into R to wrangle for Tableau export

I want to read in to R an EXCEL tab that has the following content configuration into a more Tidy data format. The next picture shows how I want the content to look like once all of the code has run. The table below just represents file that will come in daily. Each day, the numbers and the date will change, but the format will be exactly the same. So I need to learn how to automate the extraction of the pieces of this format into R from EXCEL. The end goal is to stack the daily data into a format that can be exported to Tableau.
The image above (figure 2) represents the final format I want to arrive at. I know there are several packages to read in EXCEL data into R, however I cannot figure out how I can possibly automate this tasks with readr or readxl etc... I am at least hoping some one has faced this type of problem before and can give me general directions.

reaching max.print on R

I just found a bunch of weather data that I would like to play around with in glmnet in R. First I've been reading and organizing the data in R, and right now I am just trying to look at the raw data of each variable. Unfortunately, each variable has a lot of data and R isn't able to print it all. Is there a way I can view all the raw data in R or just in the file itself? I've tried opening the file in excel to no success. Thanks!
Try to use Frequency tables, you can group by segments.
str() , summary(), table(), pairs(), plots() etc. There are several libraries (such as decr) which facilitate analyzing numerical and factor levels. Let me know if you need help with any.

How to import data and create a scatter plot in R?

I have 334 records, with two columns:
Column (1): Resolution
Column (2): Number of images with a specific resolution
How can I make a scatter plot in R with this data? Is there a way to import the records, since it will be time consuming to enter 334 records?
If you do not know how to get data into R nor create a scatterplot, it sounds like you are very new to R.
You might want to use a program that lends a hand.
rstudio has a Workspace - import dataset menu; I'd recommend Rstudio, particularly if you are very new to R.
Rcmdr also has GUI options for getting data into R
As always Quick-R provides a helpful starting point:
importing data
scatterplots
More generally, it sounds like you need to spend some time with some introductory instructional material on R. Here are my suggested startings points.

How to output a chart from Nielsen?

I saw an interesting chart on engadget today made by Nielsen:
http://www.engadget.com/2011/07/28/nielsen-android-leads-us-smartphone-market-with-39-percent-shar/
original source: http://blog.nielsen.com/nielsenwire/online_mobile/in-u-s-smartphone-market-android-is-top-operating-system-apple-is-top-manufacturer/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+NielsenWire+%28Nielsen+Wire%29
I'd love for someone to replicate it if possible and show the R code. Basic packages or ggplot2 would be great.
I like that the boxes are proportional, that's a key feature :)
Thanks!
You can find several implementations in R under the name of 'mosaic chart'. E.g.:
require("vcd")
data(HairEyeColor)
mosaic(HairEyeColor, shade = TRUE)
Se some examples on e.g. quickR, but searching the R graph gallery is also a good option.
In ggplot2, you can find a sample on learnr's blog.
I have also done some tweaks in ggplot2, please find the attached plot below. It is in Hungarian, but if you are interested, I could clean up the code and post is somewhere.
UPDATE: I have searched for my old script based on comment and uploaded it to pastebin. Sorry, no code clean up and it is quite messy, as I had to make it up for mass reporting from SPSS data files, but I hope you could use it. The usage is simple: load all functions (e.g.: run all lines in R with the source(...) function), and you could generate a mosaic chart of any data frame by specifying two variable names in the parameters of ggMosaicChart(). The plot will be saved to a png file in the working directory (no easy resize in R of the plot as lots of manual tweaks are done to arrange text nicely).
I have translated the strings to English, a basic example (included in the above code) of the mtcars data set:
Count, row- and column percent and also Pearson residuals are shown for each cell.
It's called treemap. R project has packages named "treemap" or "portfolio" for it. Here is how to do: http://flowingdata.com/2010/02/11/an-easy-way-to-make-a-treemap/

Resources